|
@@ -3,7 +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;
|
|
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;
|
7
|
11
|
import com.chinaitop.depot.storage.service.ClearanceConfirmationService;
|
8
|
12
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
9
|
13
|
import com.sun.javafx.collections.MappingChange;
|
|
@@ -12,6 +16,8 @@ import org.springframework.stereotype.Service;
|
12
|
16
|
|
13
|
17
|
import javax.annotation.Resource;
|
14
|
18
|
import javax.servlet.http.HttpServletRequest;
|
|
19
|
+import java.time.LocalDate;
|
|
20
|
+import java.time.format.DateTimeFormatter;
|
15
|
21
|
import java.util.Date;
|
16
|
22
|
import java.util.HashMap;
|
17
|
23
|
import java.util.List;
|
|
@@ -25,8 +31,8 @@ public class ClearanceConfirmationServiceImpl implements ClearanceConfirmationSe
|
25
|
31
|
@Resource
|
26
|
32
|
private ClearanceConfirmationMapper ClearanceConfirmationMapper;
|
27
|
33
|
|
28
|
|
-// @Resource
|
29
|
|
-// private BasicStorehouseService basicStorehouseService;
|
|
34
|
+ @Resource
|
|
35
|
+ private WarehouseSealingRecordMapper WarehouseSealingRecordMapper;
|
30
|
36
|
|
31
|
37
|
|
32
|
38
|
|
|
@@ -66,17 +72,80 @@ public class ClearanceConfirmationServiceImpl implements ClearanceConfirmationSe
|
66
|
72
|
dwbm = org.get("creditCode") == null?"":org.get("creditCode").toString();
|
67
|
73
|
}
|
68
|
74
|
|
|
75
|
+ LocalDate currentDate = LocalDate.now();
|
|
76
|
+ DateTimeFormatter formatter1 = DateTimeFormatter.ofPattern("yyyyMMdd");
|
|
77
|
+ String formattedDate = currentDate.format(formatter1);
|
69
|
78
|
Date date = new Date();
|
70
|
79
|
// JSON字符串转对象
|
71
|
80
|
ObjectMapper mapper = new ObjectMapper();
|
72
|
81
|
ClearanceConfirmation ClearanceConfirmation = (ClearanceConfirmation) mapper.readValue(clearanceConfirmationJson, ClearanceConfirmation.class);
|
73
|
82
|
if (ClearanceConfirmation.getId() == null) {
|
|
83
|
+ //根据货位查询同一货位编码
|
|
84
|
+ WareHouseVO wareHouseVO= WarehouseSealingRecordMapper.selectTyhwbm(Integer.parseInt(ClearanceConfirmation.getWarehouseId()));
|
|
85
|
+
|
74
|
86
|
modelMap1.put("cqqrdh",ClearanceConfirmation.getCqqrdh());
|
75
|
87
|
List<ClearanceConfirmation> clearanceConfirmation = ClearanceConfirmationMapper.findByCleConList(modelMap1);
|
76
|
88
|
if(clearanceConfirmation.size()>0){
|
77
|
89
|
modelMap.put("message", "出清确认单号已经存在");
|
78
|
90
|
return modelMap;
|
79
|
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
|
+
|
80
|
149
|
ClearanceConfirmation.setCreatename(userName);
|
81
|
150
|
ClearanceConfirmation.setCreatedate(date);
|
82
|
151
|
ClearanceConfirmation.setUpdatename(userName);
|
|
@@ -100,4 +169,15 @@ public class ClearanceConfirmationServiceImpl implements ClearanceConfirmationSe
|
100
|
169
|
public void updateBasicStorehouse(ClearanceConfirmation ClearanceConfirmation){
|
101
|
170
|
ClearanceConfirmationMapper.updateByPrimaryKey(ClearanceConfirmation);
|
102
|
171
|
}
|
|
172
|
+
|
|
173
|
+ @Override
|
|
174
|
+ public List<StorageStorehouseBusiness> findStorehouse(Integer orgId) {
|
|
175
|
+ System.out.print(ClearanceConfirmationMapper.findStorehouseList(orgId));
|
|
176
|
+ return ClearanceConfirmationMapper.findStorehouseList(orgId);
|
|
177
|
+ }
|
|
178
|
+
|
|
179
|
+ @Override
|
|
180
|
+ public List<StorageStorehouseBusiness> findByWarehouse(Integer storehouseId) {
|
|
181
|
+ return ClearanceConfirmationMapper.findByWarehouseList(storehouseId);
|
|
182
|
+ }
|
103
|
183
|
}
|