ShipmentHeaderMapper.xml
5.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
<?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.huaheng.pc.shipment.shipmentHeader.mapper.ShipmentHeaderMapper">
<insert id="HeaderToHistory" parameterType="string">
INSERT INTO shipment_header_history (
code,warehouseCode,companyId,sourceCode,sourcePlatform,shipmentTypeId,shipTo,priority,station,totalQty,
totalLines,remark,uploadremark,uploadTime,appointmentTime,firstStatus,lastStatus,uploadStatus,created,
createdBy,lastUpdated,lastUpdatedBy,enable,deleted,userDef1,userDef2,userDef3)
SELECT
code,warehouseCode,companyId,sourceCode,sourcePlatform,shipmentTypeId,shipTo,priority,station,totalQty,
totalLines,remark,uploadremark,uploadTime,appointmentTime,firstStatus,lastStatus,uploadStatus,created,
createdBy,lastUpdated,lastUpdatedBy,enable,1,userDef1,userDef2,userDef3
FROM shipment_header WHERE code = #{code,jdbcType=VARCHAR}
</insert>
<insert id="DetailToHistory" parameterType="string">
INSERT INTO shipment_detail_history (
sourceLine,shipmentCode,materialCode,batch,lot,project,manufactureDate,agingDate,inventoryStatus,qty,
price,created,createdBy,lastUpdated,lastUpdatedBy,enable,deleted,userDef1,userDef2,userDef3)
SELECT
sourceLine,shipmentCode,materialCode,batch,lot,project,manufactureDate,agingDate,inventoryStatus,qty,
price,created,createdBy,lastUpdated,lastUpdatedBy,enable,1,userDef1,userDef2,userDef3
FROM shipment_detail WHERE shipmentCode = #{code,jdbcType=VARCHAR}
</insert>
<select id="list" resultType="com.huaheng.pc.shipment.shipmentHeader.domain.ShipmentHeader">
select * from shipment_header
<where>
<if test="shipmentCode != null">
and code = #{shipmentCode}
</if>
<if test="shipmentType != 0">
and shipmentTypeId = #{shipmentType}
</if>
<if test="company != 0">
and companyId = #{company}
</if>
<if test="firstStatus != null">
and firstStatus = #{firstStatus}
</if>
<if test="lastStatus != null">
and lastStatus = #{lastStatus}
</if>
<if test="beginTime != null">
and created >= #{beginTime}
</if>
<if test="endTime != null">
and created <= #{endTime}
</if>
</where>
</select>
<select id="getShipDetail" resultType="java.util.Map">
SELECT detail.id, detail.shipmentId, detail.shipmentCode, detail.materialCode, detail.materialName,detail.qty, detail.qtyCompleted, m.name, i.locationCode,inventoryStatus, '个' unit
FROM shipment_detail detail
INNER JOIN material m ON detail.materialId = m.id and m.deleted = FALSE AND detail.shipmentCode = #{code}
INNER JOIN sys_dict_data s ON s.dictType = 'inventoryStatus' AND detail.inventoryStatus = s.dictValue AND s.enable = TRUE AND s.deleted = FALSE
INNER JOIN inventory i ON i.materialCode = detail.materialCode
</select>
<select id="getContainerMaterial" resultType="java.util.Map">
SELECT rch.locationCode, rcd.id, rd.receiptId, m.barcode, m.name, rd.qty
FROM receipt_container_header rch
INNER JOIN receipt_container_detail rcd ON rcd.headerId = rch.id AND rch.receiptContainerCode = #{containerCode,jdbcType=VARCHAR}
INNER JOIN receipt_detail rd ON rd.id = rcd.receiptDetailId
INNER JOIN material m ON rd.materialId = m.id AND m.deleted = FALSE
</select>
<select id="createCode" resultType="java.lang.String">
SELECT code FROM shipment_header WHERE type = #{shipmentType,jdbcType=VARCHAR} ORDER BY id DESC LIMIT 1
</select>
<select id="selectLastOne" resultType="com.huaheng.pc.shipment.shipmentHeader.domain.ShipmentHeader">
SELECT * FROM shipment_header order by id DESC LIMIT 1;
</select>
<select id="getShipment" resultType="com.huaheng.pc.shipment.shipmentHeader.domain.ShipmentHeader">
SELECT id, code, warehouseId, warehouseCode,uWarehouseCode, companyId, companyCode, sourceCode, sourcePlatform, type, shipTo, priority, station, totalQty, totalLines, remark, uploadremark, uploadTime, appointmentTime, firstStatus, lastStatus, uploadStatus, created, createdBy, lastUpdated, lastUpdatedBy, enable, deleted, scanId, userDef1, userDef2, userDef3
FROM shipment_header
where sourceCode <> '' and type <> "TO" AND lastStatus = #{lastStatus}
LIMIT 1
</select>
<select id="selectNosScanSSP" resultType="com.huaheng.pc.shipment.shipmentHeader.domain.ShipmentHeader">
select * from shipment_header where code = #{code} AND scanid LIKE '0%' and lastStatus < 100 LIMIT 1
</select>
<select id="selectListByCreated" resultType="com.huaheng.pc.shipment.shipmentHeader.domain.ShipmentHeader">
SELECT s.* from shipment_header s
inner join task_detail t on t.billCode=s.code and
t.status=40 and DATEDIFF(NOW(), t.endTime)=0 GROUP BY s.code
</select>
<select id="newQueryDayShipmentHeader" resultType="com.huaheng.pc.shipment.shipmentHeader.domain.ShipmentHeader">
SELECT id, code, warehouseId, warehouseCode, uWarehouseCode, companyId, companyCode, sourceCode,
sourcePlatform, type, shipTo, priority, station, totalQty, totalLines, remark, uploadremark, uploadTime,
appointmentTime, firstStatus, lastStatus, uploadStatus, created, createdBy, lastUpdated, lastUpdatedBy,
enable, deleted, scanid, userDef1, userDef2, userDef3
FROM shipment_header
WHERE to_days(created) = to_days(now()) AND firstStatus = 0
GROUP BY id DESC
LIMIT 1
</select>
</mapper>