|
@@ -6,16 +6,15 @@ import com.alibaba.fastjson.TypeReference;
|
6
|
6
|
import com.auth0.jwt.internal.org.bouncycastle.jce.exception.ExtCertificateEncodingException;
|
7
|
7
|
import com.th.demo.mapping.maint.*;
|
8
|
8
|
import com.th.demo.mapping.system.SysUserMapper;
|
9
|
|
-import com.th.demo.mapping.ware.InRecordMapper;
|
10
|
|
-import com.th.demo.mapping.ware.StoreMapper;
|
|
9
|
+import com.th.demo.mapping.ware.*;
|
|
10
|
+import com.th.demo.model.finance.AccountDetail;
|
11
|
11
|
import com.th.demo.model.maint.*;
|
12
|
12
|
import com.th.demo.model.system.ResponseCodeMsg;
|
13
|
13
|
import com.th.demo.model.system.SysUser;
|
14
|
14
|
import com.th.demo.model.system.Type;
|
15
|
|
-import com.th.demo.model.ware.InRecord;
|
16
|
|
-import com.th.demo.model.ware.OutRecord;
|
17
|
|
-import com.th.demo.model.ware.Store;
|
|
15
|
+import com.th.demo.model.ware.*;
|
18
|
16
|
import com.th.demo.service.ware.InService;
|
|
17
|
+import com.th.demo.service.ware.OutService;
|
19
|
18
|
import com.th.demo.service.ware.StoreService;
|
20
|
19
|
import com.th.demo.tools.JSONTools;
|
21
|
20
|
import com.th.demo.tools.Tools;
|
|
@@ -25,6 +24,9 @@ import org.springframework.beans.factory.annotation.Autowired;
|
25
|
24
|
import org.springframework.stereotype.Service;
|
26
|
25
|
import org.springframework.transaction.annotation.Transactional;
|
27
|
26
|
|
|
27
|
+import java.text.DateFormat;
|
|
28
|
+import java.text.ParseException;
|
|
29
|
+import java.text.SimpleDateFormat;
|
28
|
30
|
import java.util.ArrayList;
|
29
|
31
|
import java.util.Collections;
|
30
|
32
|
import java.util.Date;
|
|
@@ -53,6 +55,12 @@ public class InServiceImpl implements InService {
|
53
|
55
|
public PriceMapper priceMapper;
|
54
|
56
|
@Autowired
|
55
|
57
|
public OrdTractMapper ordTractMapper;
|
|
58
|
+ @Autowired
|
|
59
|
+ public OutRecordMapper outRecordMapper;
|
|
60
|
+ @Autowired
|
|
61
|
+ public DistributionMapper distributionMapper;
|
|
62
|
+ @Autowired
|
|
63
|
+ public DistributionDetailMapper distributionDetailMapper;
|
56
|
64
|
String result = Type.FAIL;
|
57
|
65
|
int num = 0;
|
58
|
66
|
|
|
@@ -111,8 +119,7 @@ public class InServiceImpl implements InService {
|
111
|
119
|
public String inImport(String json, String userId, String belongId) throws Exception {
|
112
|
120
|
long startTime = System.currentTimeMillis();
|
113
|
121
|
|
114
|
|
- List<JSONObject> listJO = JSON.parseObject(json, new TypeReference<List<JSONObject>>() {
|
115
|
|
- });
|
|
122
|
+ List<JSONObject> listJO = JSON.parseObject(json, new TypeReference<List<JSONObject>>() { });
|
116
|
123
|
|
117
|
124
|
List<Store> listStore = objToStore(listJO, userId, belongId);
|
118
|
125
|
List storeArray = new ArrayList();
|
|
@@ -178,6 +185,153 @@ public class InServiceImpl implements InService {
|
178
|
185
|
return result;
|
179
|
186
|
}
|
180
|
187
|
|
|
188
|
+ @Override
|
|
189
|
+ public String inImportAll(String json, String userId, String belongId) throws ParseException {
|
|
190
|
+ List<JSONObject> listJO = JSON.parseObject(json, new TypeReference<List<JSONObject>>() { });
|
|
191
|
+ Store store = new Store();
|
|
192
|
+ Distribution distribution = new Distribution();
|
|
193
|
+ String err = Type.SUCCESS;
|
|
194
|
+ DateFormat df2 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
195
|
+ for (int i = 0; i < listJO.size(); i++){
|
|
196
|
+ String wareName = listJO.get(i).get("仓库名称").toString();
|
|
197
|
+ String stackName = listJO.get(i).get("垛位号").toString();
|
|
198
|
+ String materialName = listJO.get(i).get("品名").toString();
|
|
199
|
+ String standard = listJO.get(i).get("钢种").toString();
|
|
200
|
+ String customerName = listJO.get(i).get("客户名称").toString();
|
|
201
|
+ String fk_compony_name = listJO.get(i).get("货权单位").toString();
|
|
202
|
+ //验证信息增加多条信息验证
|
|
203
|
+ Ware ware = wareMapper.selectByWareName(wareName, userId, belongId);
|
|
204
|
+ if (ware == null) {
|
|
205
|
+ err += "未找到名为\"" + wareName + "\"的库房;";
|
|
206
|
+ }
|
|
207
|
+ Stack stack = stackMapper.selectByWareNameStackName(wareName, stackName, userId, belongId);
|
|
208
|
+ if (stack == null) {
|
|
209
|
+ err += "未找到名为\"" + stackName + "\"的垛位号;";
|
|
210
|
+ }
|
|
211
|
+ // 将传入的材料品名和钢种进行校验
|
|
212
|
+ Material material = new Material();
|
|
213
|
+ List<Material> materialList = materialMapper.selectListByNameStandard(materialName, standard, belongId);
|
|
214
|
+ if (materialList.size() == 0 ){
|
|
215
|
+ err += "未找到名为\"" + materialName + "," + standard + "\"的物料类型;";
|
|
216
|
+ } else if (materialList.size() > 1) {
|
|
217
|
+ err += "名为\"" + materialName + "," + standard + "\"的物料类型维护多条;";
|
|
218
|
+ }else {
|
|
219
|
+ material= materialList.get(0);
|
|
220
|
+ }
|
|
221
|
+
|
|
222
|
+ // 将传入的客户名称进行校验
|
|
223
|
+ Customer customer = new Customer();
|
|
224
|
+ List<Customer> customerList = customerMapper.selectByNameCode(customerName,customerName,belongId);
|
|
225
|
+ if (customerList.size() == 0){
|
|
226
|
+ err += "未找到全名或简称为\"" + customerName + "\"的客户名称;";
|
|
227
|
+ } else if (customerList.size() > 1) {
|
|
228
|
+ err += "全名或简称为\"" + customerName + "\"的客户名称维护多条;";
|
|
229
|
+ }else{
|
|
230
|
+ customer = customerList.get(0);
|
|
231
|
+ }
|
|
232
|
+
|
|
233
|
+ // 将传入的客户名称进行校验
|
|
234
|
+ Customer fk_compony = new Customer();
|
|
235
|
+ List<Customer> customerList2 = customerMapper.selectByNameCode(fk_compony_name,fk_compony_name,belongId);
|
|
236
|
+ if (customerList2.size() == 0){
|
|
237
|
+ err += "未找到全名或简称为\"" + fk_compony_name + "\"的客户名称;";
|
|
238
|
+ } else if (customerList2.size() > 1) {
|
|
239
|
+ err += "全名或简称为\"" + fk_compony_name + "\"的客户名称维护多条;";
|
|
240
|
+ }else{
|
|
241
|
+ fk_compony = customerList2.get(0);
|
|
242
|
+ }
|
|
243
|
+ store.setWare(ware);
|
|
244
|
+ store.setStack(stack);
|
|
245
|
+ store.setMaterial(material);
|
|
246
|
+ store.setCustomer(customer);
|
|
247
|
+ store.setFkComponyId(fk_compony.getId());
|
|
248
|
+ store.setLayer(Integer.parseInt(listJO.get(i).get("层号").toString()));
|
|
249
|
+ store.setPlateNo(listJO.get(i).get("产品编号").toString());
|
|
250
|
+ store.setModel(listJO.get(i).get("规格型号").toString());
|
|
251
|
+ store.setCount(Double.parseDouble(listJO.get(i).get("数量").toString()));
|
|
252
|
+ store.setWeight(Double.parseDouble(listJO.get(i).get("重量").toString()));
|
|
253
|
+ if (listJO.get(i).get("收货地址") != null && !listJO.get(i).get("收货地址").toString().equals("")) {
|
|
254
|
+ store.setReceiveAddress(listJO.get(i).get("收货地址").toString());
|
|
255
|
+ }
|
|
256
|
+
|
|
257
|
+ if(listJO.get(i).get("备注") != null && !listJO.get(i).get("备注").toString().equals("")){
|
|
258
|
+ store.setRemark(listJO.get(i).get("备注").toString());
|
|
259
|
+ }
|
|
260
|
+
|
|
261
|
+ store.setAddId(userId);
|
|
262
|
+ store.setAddTime(df2.parse(listJO.get(i).get("入库时间").toString()));
|
|
263
|
+ store.setCancelFlag("0");
|
|
264
|
+ store.setBelongId(belongId);
|
|
265
|
+ if(listJO.get(i).get("计量方式") != null && !listJO.get(i).get("计量方式").toString().equals("")){
|
|
266
|
+ store.setWgtDcnMtcCd(listJO.get(i).get("计量方式").toString());
|
|
267
|
+ }
|
|
268
|
+ if(listJO.get(i).get("产地") != null && !listJO.get(i).get("产地").toString().equals("")){
|
|
269
|
+ store.setProductionPlace(listJO.get(i).get("产地").toString());
|
|
270
|
+ }
|
|
271
|
+ if(listJO.get(i).get("合约号") != null && !listJO.get(i).get("合约号").toString().equals("")){
|
|
272
|
+ store.setContractNo(listJO.get(i).get("合约号").toString());
|
|
273
|
+ }
|
|
274
|
+ if(listJO.get(i).get("订单号") != null && !listJO.get(i).get("订单号").toString().equals("")){
|
|
275
|
+ store.setOrdNo(listJO.get(i).get("订单号").toString());
|
|
276
|
+ }
|
|
277
|
+ if(listJO.get(i).get("入库车号") != null && !listJO.get(i).get("入库车号").toString().equals("")){
|
|
278
|
+ store.setCarNo(listJO.get(i).get("入库车号").toString());
|
|
279
|
+ }
|
|
280
|
+ if(listJO.get(i).get("吊装工") != null && !listJO.get(i).get("吊装工").toString().equals("")){
|
|
281
|
+ store.setTallyPeople(listJO.get(i).get("吊装工").toString());
|
|
282
|
+ }
|
|
283
|
+ if(listJO.get(i).get("捆包号") != null && !listJO.get(i).get("捆包号").toString().equals("")){
|
|
284
|
+ store.setPackNo(listJO.get(i).get("捆包号").toString());
|
|
285
|
+ }
|
|
286
|
+ InRecord inRecord = getInRecord(store, "1", userId);
|
|
287
|
+ inRecord.setAddTime(df2.parse(listJO.get(i).get("入库时间").toString()));
|
|
288
|
+ num += inRecordMapper.insert(inRecord);
|
|
289
|
+
|
|
290
|
+ store.setOutFlag("0");
|
|
291
|
+ store.setLockFlag("0");
|
|
292
|
+ store.setOutId("");
|
|
293
|
+ store.setInId(inRecord.getId());
|
|
294
|
+ num += storeMapper.insert(store);
|
|
295
|
+
|
|
296
|
+ if(listJO.get(i).get("出库时间")!= null && !listJO.get(i).get("出库时间").equals("")){
|
|
297
|
+ Distribution isExist = distributionMapper.selectByDisNo(listJO.get(i).get("出库单号").toString(),belongId);
|
|
298
|
+ if (isExist == null) {
|
|
299
|
+ distribution.setTruckNo(listJO.get(i).get("出库车号").toString());
|
|
300
|
+ distribution.setAddId(userId);
|
|
301
|
+ distribution.setAddTime(new Date());
|
|
302
|
+ distribution.setOutFlag("1");
|
|
303
|
+ distribution.setBelongId(belongId);
|
|
304
|
+ distribution.setSumCount(store.getCount());
|
|
305
|
+ distribution.setSumWeight(store.getWeight());
|
|
306
|
+ num += distributionMapper.insert(distribution);
|
|
307
|
+ DistributionDetail detail = getDistributionDetail(distribution, store, userId, belongId);
|
|
308
|
+ num += distributionDetailMapper.insert(detail);
|
|
309
|
+ } else {
|
|
310
|
+ distribution.setModifyId(userId);
|
|
311
|
+ distribution.setModifyTime(new Date());
|
|
312
|
+ distribution.setSumCount(distribution.getSumCount()+store.getCount());
|
|
313
|
+ distribution.setSumWeight(distribution.getSumWeight()+store.getWeight());
|
|
314
|
+ num += distributionMapper.updateByPrimaryKey(distribution);
|
|
315
|
+ DistributionDetail detail = getDistributionDetail(distribution, store, userId, belongId);
|
|
316
|
+ num += distributionDetailMapper.insert(detail);
|
|
317
|
+ }
|
|
318
|
+
|
|
319
|
+ OutRecord outRecord = getOutRecord(store, distribution.getId(), "1", userId);
|
|
320
|
+ outRecord.setAddTime(df2.parse(listJO.get(i).get("出库时间").toString()));
|
|
321
|
+ num += outRecordMapper.insert(outRecord);
|
|
322
|
+
|
|
323
|
+ store.setOutId(outRecord.getId());
|
|
324
|
+ store.setOutFlag("1");
|
|
325
|
+ store.setLockFlag("1");
|
|
326
|
+ num += storeMapper.updateByPrimaryKey(store);
|
|
327
|
+ }
|
|
328
|
+
|
|
329
|
+
|
|
330
|
+ }
|
|
331
|
+ result = Tools.moreThanZeroResultJSON(num);
|
|
332
|
+ return result;
|
|
333
|
+ }
|
|
334
|
+
|
181
|
335
|
private List<Store> resortAndInsert(List<Store> listStore, String userId, String belongId) throws Exception {
|
182
|
336
|
for (int i = 0; i < listStore.size(); i++) {
|
183
|
337
|
Store temp = listStore.get(i);
|
|
@@ -275,7 +429,6 @@ public class InServiceImpl implements InService {
|
275
|
429
|
String standard = listJO.get(0).get("钢种").toString();
|
276
|
430
|
String customerName = listJO.get(0).get("客户名称").toString();
|
277
|
431
|
String fk_compony_name = listJO.get(0).get("货权单位").toString();
|
278
|
|
- String addUserName = listJO.get(0).get("入库操作人员").toString();
|
279
|
432
|
//验证信息增加多条信息验证
|
280
|
433
|
Ware ware = wareMapper.selectByWareName(wareName, userId, belongId);
|
281
|
434
|
if (ware == null) {
|
|
@@ -500,5 +653,56 @@ public class InServiceImpl implements InService {
|
500
|
653
|
return inRecord;
|
501
|
654
|
}
|
502
|
655
|
|
|
656
|
+ private OutRecord getOutRecord(Store store, String distributionId, String recordType, String userId) {
|
|
657
|
+ OutRecord outRecord = new OutRecord();
|
|
658
|
+ outRecord.setWareName(store.getWare().getName());
|
|
659
|
+ outRecord.setStackName(store.getStack().getName());
|
|
660
|
+ outRecord.setLayer(store.getLayer());
|
|
661
|
+ outRecord.setMaterialName(store.getMaterial().getName());
|
|
662
|
+ outRecord.setStandard(store.getMaterial().getStandard());
|
|
663
|
+ outRecord.setModel(store.getModel());
|
|
664
|
+ outRecord.setCustomerName(store.getCustomer().getName());
|
|
665
|
+ if (recordType.equals("0")) {
|
|
666
|
+ outRecord.setCount(-1 * store.getCount());
|
|
667
|
+ outRecord.setWeight(-1 * store.getWeight());
|
|
668
|
+ } else {
|
|
669
|
+ outRecord.setCount(store.getCount());
|
|
670
|
+ outRecord.setWeight(store.getWeight());
|
|
671
|
+ }
|
|
672
|
+ if (recordType.equals("0")) {
|
|
673
|
+ outRecord.setCancelFlag("9");
|
|
674
|
+ } else {
|
|
675
|
+ outRecord.setCancelFlag("0");
|
|
676
|
+ }
|
|
677
|
+
|
|
678
|
+ outRecord.setPackNo(store.getPackNo());
|
|
679
|
+ outRecord.setContractNo(store.getContractNo());
|
|
680
|
+
|
|
681
|
+ outRecord.setRemark(store.getRemark());
|
|
682
|
+ outRecord.setBelongId(store.getBelongId());
|
|
683
|
+ outRecord.setPlateNo(store.getPlateNo());
|
|
684
|
+ outRecord.setAddUser(new SysUser(userId));
|
|
685
|
+ outRecord.setAddTime(new Date());
|
|
686
|
+ outRecord.setInId(store.getInId());
|
|
687
|
+ outRecord.setRecordType(recordType);
|
|
688
|
+ outRecord.setReceiveAddress(store.getReceiveAddress());
|
|
689
|
+ outRecord.setDistributionId(distributionId);
|
|
690
|
+
|
|
691
|
+ outRecord.setWgtDcnMtcCd(store.getWgtDcnMtcCd());
|
|
692
|
+ outRecord.setEdgeTy(store.getEdgeTy());
|
|
693
|
+ outRecord.setProductionPlace(store.getProductionPlace());
|
|
694
|
+ outRecord.setInvoicePrice(store.getInvoicePrice());
|
|
695
|
+ return outRecord;
|
|
696
|
+ }
|
503
|
697
|
|
|
698
|
+ public DistributionDetail getDistributionDetail(Distribution distribution, Store store, String userId, String belongId) {
|
|
699
|
+ DistributionDetail detail = new DistributionDetail();
|
|
700
|
+ detail.setDistributionId(distribution.getId());
|
|
701
|
+ detail.setStore(store);
|
|
702
|
+ detail.setAddId(userId);
|
|
703
|
+ detail.setAddTime(new Date());
|
|
704
|
+ detail.setCancelFlag("0");
|
|
705
|
+ detail.setBelongId(belongId);
|
|
706
|
+ return detail;
|
|
707
|
+ }
|
504
|
708
|
}
|