Browse Source

出清确认单

ZeroLiYi 1 year ago
parent
commit
66b817e18d

+ 3 - 0
src/main/java/com/chinaitop/depot/storage/mapper/ClearanceConfirmationMapper.java

@@ -2,6 +2,7 @@ package com.chinaitop.depot.storage.mapper;
2 2
 
3 3
 import com.chinaitop.depot.storage.model.ClearanceConfirmation;
4 4
 import com.chinaitop.depot.storage.model.StorageStorehouseBusiness;
5
+import com.chinaitop.depot.storage.model.WarehouseSealingRecord;
5 6
 import org.springframework.stereotype.Repository;
6 7
 
7 8
 import java.math.BigDecimal;
@@ -35,4 +36,6 @@ public interface ClearanceConfirmationMapper {
35 36
     List<StorageStorehouseBusiness> findStorehouseList(Integer orgId);
36 37
 
37 38
     List<StorageStorehouseBusiness> findByWarehouseList(Integer storehouseId);
39
+
40
+    ClearanceConfirmation selectByCqqrd(String warehouseId);
38 41
 }

+ 7 - 0
src/main/java/com/chinaitop/depot/storage/mapper/ClearanceConfirmationMapper.xml

@@ -249,4 +249,11 @@ cc.updatename updatename,cc.updatedate updatedate,cc.warehouse_id
249 249
     where bw.storehouse_id=#{storehouseId} and dkkd.hwh is null
250 250
 
251 251
   </select>
252
+
253
+  <select id="selectByCqqrd" resultType="com.chinaitop.depot.storage.model.ClearanceConfirmation">
254
+    select cqqrdh from warehouse_sealing_record
255
+    where warehouse_id=#{warehouseId}
256
+    order by id desc
257
+      limit 1
258
+  </select>
252 259
 </mapper>

+ 70 - 2
src/main/java/com/chinaitop/depot/storage/service/impl/ClearanceConfirmationServiceImpl.java

@@ -3,8 +3,11 @@ package com.chinaitop.depot.storage.service.impl;
3 3
 import com.alibaba.fastjson.JSONObject;
4 4
 
5 5
 import com.chinaitop.depot.storage.mapper.ClearanceConfirmationMapper;
6
+import com.chinaitop.depot.storage.mapper.WarehouseSealingRecordMapper;
6 7
 import com.chinaitop.depot.storage.model.ClearanceConfirmation;
7 8
 import com.chinaitop.depot.storage.model.StorageStorehouseBusiness;
9
+import com.chinaitop.depot.storage.model.WarehouseSealingRecord;
10
+import com.chinaitop.depot.storage.model.vo.WareHouseVO;
8 11
 import com.chinaitop.depot.storage.service.ClearanceConfirmationService;
9 12
 import com.fasterxml.jackson.databind.ObjectMapper;
10 13
 import com.sun.javafx.collections.MappingChange;
@@ -13,6 +16,8 @@ import org.springframework.stereotype.Service;
13 16
 
14 17
 import javax.annotation.Resource;
15 18
 import javax.servlet.http.HttpServletRequest;
19
+import java.time.LocalDate;
20
+import java.time.format.DateTimeFormatter;
16 21
 import java.util.Date;
17 22
 import java.util.HashMap;
18 23
 import java.util.List;
@@ -26,8 +31,8 @@ public class ClearanceConfirmationServiceImpl implements ClearanceConfirmationSe
26 31
     @Resource
27 32
     private ClearanceConfirmationMapper ClearanceConfirmationMapper;
28 33
 
29
-//    @Resource
30
-//    private BasicStorehouseService basicStorehouseService;
34
+    @Resource
35
+    private WarehouseSealingRecordMapper WarehouseSealingRecordMapper;
31 36
 
32 37
 
33 38
 
@@ -67,17 +72,80 @@ public class ClearanceConfirmationServiceImpl implements ClearanceConfirmationSe
67 72
             dwbm = org.get("creditCode") == null?"":org.get("creditCode").toString();
68 73
         }
69 74
 
75
+        LocalDate currentDate = LocalDate.now();
76
+        DateTimeFormatter formatter1 = DateTimeFormatter.ofPattern("yyyyMMdd");
77
+        String formattedDate = currentDate.format(formatter1);
70 78
         Date date = new Date();
71 79
         // JSON字符串转对象
72 80
         ObjectMapper mapper = new ObjectMapper();
73 81
         ClearanceConfirmation ClearanceConfirmation = (ClearanceConfirmation) mapper.readValue(clearanceConfirmationJson, ClearanceConfirmation.class);
74 82
         if (ClearanceConfirmation.getId() == null) {
83
+            //根据货位查询同一货位编码
84
+            WareHouseVO wareHouseVO= WarehouseSealingRecordMapper.selectTyhwbm(Integer.parseInt(ClearanceConfirmation.getWarehouseId()));
85
+
75 86
             modelMap1.put("cqqrdh",ClearanceConfirmation.getCqqrdh());
76 87
             List<ClearanceConfirmation> clearanceConfirmation = ClearanceConfirmationMapper.findByCleConList(modelMap1);
77 88
             if(clearanceConfirmation.size()>0){
78 89
                 modelMap.put("message", "出清确认单号已经存在");
79 90
                 return modelMap;
80 91
             }
92
+            ClearanceConfirmation clearanceConfirmation1=  ClearanceConfirmationMapper.selectByCqqrd(ClearanceConfirmation.getWarehouseId());
93
+            if(clearanceConfirmation1!=null){
94
+
95
+                String fcqrd =clearanceConfirmation1.getCqqrdh();
96
+
97
+                int startIndex =fcqrd.length() - 11; // 假设20240909开始的位置是从字符串末尾数第15个字符开始
98
+                // 要截取的结束位置
99
+                int endIndex = fcqrd.length() - 3; // 假设20240909结束的位置是从字符串末尾数第9个字符结束
100
+
101
+                // 使用substring方法进行截取
102
+                String extractedDate = fcqrd.substring(startIndex, endIndex);
103
+                // 当前时间
104
+
105
+                // 将字符串转换为日期对象
106
+                String specificDateStr = extractedDate;
107
+                DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMdd");
108
+                LocalDate specificDateObj = LocalDate.parse(specificDateStr, formatter);
109
+                LocalDate today = LocalDate.now();
110
+
111
+                if (formattedDate.equals(extractedDate)){
112
+                    // 使用正则表达式提取后三位数字
113
+                    Pattern pattern = Pattern.compile("(\\d{3})$");
114
+                    Matcher matcher = pattern.matcher(fcqrd);
115
+                    if (matcher.find()) {
116
+                        String lastThreeDigits = matcher.group(1);
117
+
118
+                        // 将后三位数字转换为整数并加1
119
+                        int incrementedValue = Integer.parseInt(lastThreeDigits) + 1;
120
+
121
+                        // 将加1后的整数转换回三位数字字符串,保持前导零
122
+                        String incrementedDigits = String.format("%03d", incrementedValue);
123
+
124
+                        // 将原字符串的后三位替换为加1后的三位数字
125
+                        fcqrd = fcqrd.replaceFirst(pattern.pattern(), incrementedDigits);
126
+                        ClearanceConfirmation.setCqqrdh(fcqrd);
127
+                    }
128
+                }else{
129
+                    StringBuffer sbf = new StringBuffer();
130
+                    sbf.append(wareHouseVO.getTyhwbm());
131
+                    sbf.append(specificDateObj);
132
+                    sbf.append("001");
133
+                    ClearanceConfirmation.setCqqrdh(sbf.toString().trim());
134
+                }
135
+
136
+            }else{
137
+                StringBuffer sbf = new StringBuffer();
138
+                sbf.append(wareHouseVO.getTyhwbm());
139
+                sbf.append(formattedDate);
140
+                sbf.append("001");
141
+                ClearanceConfirmation.setCqqrdh(sbf.toString().trim());
142
+            }
143
+
144
+
145
+
146
+
147
+
148
+
81 149
             ClearanceConfirmation.setCreatename(userName);
82 150
             ClearanceConfirmation.setCreatedate(date);
83 151
             ClearanceConfirmation.setUpdatename(userName);