ReceiptHeaderMapper.xml
3.77 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
<?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.receipt.receiptHeader.mapper.ReceiptHeaderMapper">
<select id="createCode" resultType="java.lang.String">
SELECT code FROM receipt_header WHERE type = #{receiptType,jdbcType=VARCHAR} ORDER BY id DESC LIMIT 1
</select>
<insert id="headerToHistory">
INSERT INTO receipt_header_history (
code, warehouseCode, companyId, type, sourceCode, sourcePlatform, companyCode, totalQty,
totalLines, remark, uploadStatus, uploadremark, uploadTime, appointmentTime, firstStatus, lastStatus,
created, createdBy, lastUpdated, lastUpdatedBy, ENABLE, userDef1, userDef2, userDef3, deleted)
SELECT
code, warehouseCode, companyId, type, sourceCode, sourcePlatform, companyCode, totalQty,
totalLines, remark, uploadStatus, uploadremark, uploadTime, appointmentTime, firstStatus,
lastStatus, created, createdBy, lastUpdated, lastUpdatedBy, ENABLE, userDef1, userDef2, userDef3, 1
FROM receipt_header WHERE code = #{code,jdbcType=VARCHAR}
</insert>
<insert id="detailToHistory">
INSERT INTO receipt_detail_history (
id,sourceLine,receiptCode,materialCode,batch,lot,project,manufactureDate,expirationDate,inventoryStatus,qty,
price,uploadTime,created,createdBy,lastUpdated,lastUpdatedBy,enable,deleted,userDef1,userDef2,userDef3)
SELECT
id,sourceLine,receiptCode,materialCode,batch,lot,project,manufactureDate,expirationDate,inventoryStatus,qty,
price,uploadTime,created,createdBy,lastUpdated,lastUpdatedBy,enable,1,userDef1,userDef2,userDef3
FROM receipt_detail WHERE receiptCode = #{code,jdbcType=VARCHAR}
</insert>
<select id="getLastStatus" resultType="java.lang.Short">
SELECT MIN(`status`) AS lastStatus FROM receipt_detail WHERE receiptId = #{receiptId}
</select>
<update id="updateDetailStatus">
UPDATE receipt_detail SET status=#{status} WHERE id=#{receiptDetailId} AND qty <= qtyCompleted AND status >= 200
</update>
<update id="updateHeaderStatus">
UPDATE receipt_header SET
firstStatus = (CASE WHEN firstStatus<=#{firstStatus} THEN #{firstStatus} ELSE firstStatus END),
lastStatus = #{lastStatus}
WHERE id = #{receiptId}
</update>
<select id="selectLastOne" resultType="com.huaheng.pc.receipt.receiptHeader.domain.ReceiptHeader">
SELECT * FROM receipt_header order by id DESC LIMIT 1;
</select>
<select id="getReceipt" resultType="com.huaheng.pc.receipt.receiptHeader.domain.ReceiptHeader">
SELECT id, code, warehouseId, warehouseCode,uWarehouseCode, companyId, companyCode, type, sourceCode, sourcePlatform, supplierId, supplierCode, totalQty, totalLines, remark, uploadStatus, uploadremark, uploadTime, appointmentTime, firstStatus, lastStatus, created, createdBy, lastUpdated, lastUpdatedBy, enable, deleted, scanid, userDef1, userDef2, userDef3
FROM receipt_header
WHERE lastStatus = #{lastStatus} and (sourceCode <> '' or type='SI')
limit 1
</select>
<select id="selectNosScanSSP" resultType="com.huaheng.pc.receipt.receiptHeader.domain.ReceiptHeader">
select * from receipt_header where code = #{code} AND scanid not LIKE '1%' and lastStatus < 100 LIMIT 1
</select>
<select id="selectListByCreated" resultType="com.huaheng.pc.receipt.receiptHeader.domain.ReceiptHeader">
SELECT r.* from receipt_header r
inner join task_detail t on t.billCode=r.code and
t.status=40 and DATEDIFF(NOW(), t.endTime)=0 GROUP BY r.code
</select>
</mapper>