From da497e4c08c46cbde5dfcd7ea0cf2e455ee6f592 Mon Sep 17 00:00:00 2001
From: 廖井涛 <2265517004@qq.com>
Date: 星期一, 20 五月 2024 10:36:44 +0800
Subject: [PATCH] 添加发货报表

---
 north-glass-erp/src/main/resources/mapper/pp/DeviceMaintenance.xml |   91 +++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 91 insertions(+), 0 deletions(-)

diff --git a/north-glass-erp/src/main/resources/mapper/pp/DeviceMaintenance.xml b/north-glass-erp/src/main/resources/mapper/pp/DeviceMaintenance.xml
new file mode 100644
index 0000000..741cc4c
--- /dev/null
+++ b/north-glass-erp/src/main/resources/mapper/pp/DeviceMaintenance.xml
@@ -0,0 +1,91 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper
+        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.example.erp.mapper.pp.DeviceMaintenanceMapper">
+    <resultMap id="DeviceMaintenanceMapper" type="com.example.erp.entity.pp.DeviceMaintenance">
+        <id column="id" property="id"/>
+        <result column="device_id" property="deviceId"/>
+        <result column="type" property="type"/>
+        <result column="fault_time" property="faultTime"/>
+        <result column="fault_reason" property="faultReason"/>
+        <result column="maintenance_time" property="maintenanceTime"/>
+        <result column="maintenance_illustrate" property="maintenanceIllustrate"/>
+        <result column="start_time" property="startTime"/>
+        <result column="stop_time" property="stopTime"/>
+        <result column="personnel" property="personnel"/>
+        <result column="cost" property="cost"/>
+
+
+    </resultMap>
+    <select id="getBasicData">
+        select id
+        from sd.basic_data
+        where basic_category = 'process'
+          and basic_name = #{process}
+    </select>
+
+<insert id="addMachineMp">
+    insert into pp.basic_data_produce(basic_type,basic_name,basic_category,create_time)
+    values('device',#{basicName},#{basicId},now())
+</insert>
+
+    <select id="selectProcessMp">
+        select * from sd.basic_data where basic_type='product' and basic_category='process'
+    </select>
+
+    <select id="selectDeviceMp">
+        SELECT
+            bdp.id,
+            bdp.basic_type,
+            bdp.basic_name,
+            bd.basic_name AS basic_category
+        FROM
+            sd.basic_data AS bd
+                LEFT JOIN `basic_data_produce` AS bdp ON bd.id = bdp.basic_category
+        WHERE
+            bd.basic_category = 'process'
+          AND bdp.basic_type = 'device'
+    </select>
+
+    <select id="getDeviceData">
+        select id
+        from basic_data_produce
+        where basic_type = 'device'
+          and basic_name = #{deviceName}
+    </select>
+
+    <insert id="saveMaintenanceAndRepairMp">
+        insert into device_maintenance(device_id,device_name,type,fault_time,fault_reason,maintenance_time,
+                                       maintenance_illustrate,start_time,stop_time,process,personnel,cost,create_time)
+        values (#{deviceId},#{deviceName},#{type},#{faultTime},#{faultReason},#{maintenanceTime},
+                #{maintenanceIllustrate},#{stopTime},#{startTime},#{process},#{personnel},#{cost},now())
+    </insert>
+
+    <select id="selectMaintenanceMp" resultMap="DeviceMaintenanceMapper">
+        select * from device_maintenance where DATE_FORMAT((create_time),'%Y-%m-%d') BETWEEN #{ selectTime1 } AND #{ selectTime2 }
+    </select>
+
+    <delete id="deleteMaintenanceMp">
+        delete from device_maintenance where id = #{id}
+    </delete>
+
+    <select id="selectMachineMp">
+        select dm.device_id,dm.device_name,
+        if(dm.type=1,'缁翠慨','淇濆吇') as type,
+        (select count(*) from device_maintenance where id = dm.id and type = 1) as faultCount,
+        (select count(*) from device_maintenance where id = dm.id and type = 2) as maintenanceCount,
+        (select date(fault_time) from device_maintenance where id = dm.id and type = 1 order by fault_time desc limit 1) as faultLastTime,
+        (select date(maintenance_time) from device_maintenance where id = dm.id and type = 2 order by maintenance_time desc limit 1) as maintenanceLastTime,
+        (select sum(cost) from device_maintenance where id = dm.id and dm.type=1) as faultCost,
+        (select sum(cost) from device_maintenance where id = dm.id and dm.type=2) as maintenanceCost,
+        dm.process
+        from device_maintenance as dm
+        group by dm.device_id
+
+    </select>
+
+    <select id="openSelectIdMp">
+    select * from device_maintenance where id = #{id}
+    </select>
+</mapper>
\ No newline at end of file

--
Gitblit v1.8.0