Browse Source

MagicHand 导入

wfg 5 months ago
parent
commit
9f1149d037

+ 52 - 15
blade-service/blade-los/src/main/java/org/springblade/los/business/sea/service/impl/MscZipImportImpl.java

@@ -550,6 +550,8 @@ public class MscZipImportImpl extends ServiceImpl<BillsMapper, Bills> implements
 		List<BCntrTypes> cntrTypes = new ArrayList<>();
 		List<BPackages> packages = new ArrayList<>();
 
+		String defTeamId = AuthUtil.getPostId().split(",")[0];
+
 		String deptId;
 		String deptName;
 		Long branchId = deptUtils.getDeptPid();
@@ -609,8 +611,9 @@ public class MscZipImportImpl extends ServiceImpl<BillsMapper, Bills> implements
 					boolean isNewBill = true;
 					Bills bill = bBillsService.getOne(new LambdaQueryWrapper<Bills>()
 						.eq(Bills::getTenantId, AuthUtil.getTenantId())
+						.eq(Bills::getBranchId, branchId + "")
 						.eq(Bills::getIsDeleted, 0)
-						.eq(Bills::getTeamId, AuthUtil.getPostId())
+						.eq(Bills::getTeamId, defTeamId)
 						.eq(Bills::getBookingNo, getJsonValueAsString(joa, "BookingNumber"))
 						.last("limit 1"));
 
@@ -720,6 +723,9 @@ public class MscZipImportImpl extends ServiceImpl<BillsMapper, Bills> implements
 
 						// 客户 市场部 QDJMSMARKET
 						bill.setCorpId(marketCorp.getId());
+						bill.setCorpCode(marketCorp.getCode());
+						bill.setShortName(marketCorp.getShortName());
+						bill.setCorpShortName(marketCorp.getShortName());
 						bill.setCorpCnName(marketCorp.getCnName());
 						bill.setCorpEnName(marketCorp.getEnName());
 
@@ -937,6 +943,15 @@ public class MscZipImportImpl extends ServiceImpl<BillsMapper, Bills> implements
 						}
 					}
 
+					Integer V20 = 0;
+					Integer V40 = 0;
+					Integer V40HC = 0;
+					Integer V45 = 0;
+					Integer V48 = 0;
+					Integer other = 0;
+					BigDecimal teu = new BigDecimal("0.00");
+					StringBuilder boxTypeSum = new StringBuilder();
+
 					// 预配箱 及 已装箱
 					Long lineNo = 0L;
 					if(ObjectUtils.isNotNull(jaContainers) && jaContainers.size()>0) {
@@ -948,13 +963,15 @@ public class MscZipImportImpl extends ServiceImpl<BillsMapper, Bills> implements
 								BCntrTypes cntrType = getCntrTypeByEdiCode(cntrTypes, getJsonValueAsString(jof, "ContainerTypeCode"));
 								if(ObjectUtils.isNotNull(cntrType)){
 									// 预配箱
+									PreContainers preContainer;
 									Optional<PreContainers> preCntrsOptional = preContainers.stream()
-										.filter(v -> v.getCntrTypeCodeId().equals(cntrType.getId()))
+										.filter(v -> v.getCntrTypeCodeId().equals(cntrType.getId().toString()))
 										.findFirst();
 									if(preCntrsOptional.isPresent()){
-										preCntrsOptional.get().setQuantity(preCntrsOptional.get().getQuantity() + 1);
+										preContainer = preCntrsOptional.get();
+										preContainer.setQuantity(preContainer.getQuantity() + 1);
 									}else{
-										PreContainers preContainer = new PreContainers();
+										preContainer = new PreContainers();
 										// preContainer.setId(0L);
 										preContainer.setPid(0L);
 										preContainer.setTenantId(AuthUtil.getTenantId());
@@ -973,6 +990,20 @@ public class MscZipImportImpl extends ServiceImpl<BillsMapper, Bills> implements
 										preContainers.add(preContainer);
 									}
 
+									if (preContainer.getCntrTypeCode().contains("20")) {
+										V20 += 1;
+									} else if (preContainer.getCntrTypeCode().contains("45")) {
+										V45 += 1;
+									} else if (preContainer.getCntrTypeCode().contains("48")) {
+										V48 += 1;
+									} else if (preContainer.getCntrTypeCode().contains("40")) {
+										V40 += 1;
+									} else if (preContainer.getCntrTypeCode().contains("40") && preContainer.getCntrTypeCode().contains("HC")) {
+										V40HC += 1;
+									} else {
+										other += 1;
+									}
+
 									// 已装箱
 									Containers cntr = new Containers();
 									// cntr.setId(0L);
@@ -1109,20 +1140,25 @@ public class MscZipImportImpl extends ServiceImpl<BillsMapper, Bills> implements
 					String quantityCntrTypesDescr = "";
 					for (PreContainers preContainer : preContainers) {
 						quantityCntrTypesDescr += (quantityCntrTypesDescr.isEmpty() ? "" : " AND ") + BigDecimalUtils.convertToEnglish(new BigDecimal(preContainer.getQuantity() + ""));
+						boxTypeSum.append(preContainer.getCntrTypeCode()).append("*").append(preContainer.getQuantity()).append(",");
+						teu = teu.add(new BigDecimal(preContainer.getQuantity()).multiply(preContainer.getTeu()));
+					}
+					if (boxTypeSum.length() > 0) {
+						boxTypeSum = new StringBuilder(boxTypeSum.substring(0, boxTypeSum.length() - 1));
+						bill.setQuantityCntrDescr(boxTypeSum.toString());
 					}
 					if(!quantityCntrTypesDescr.isEmpty()){
-						quantityCntrTypesDescr = "SAY " + quantityCntrTypesDescr + "ONLY";
+						quantityCntrTypesDescr = "SAY " + quantityCntrTypesDescr + " ONLY";
 					}
 					bill.setQuantityCntrTypesDescr(quantityCntrTypesDescr);
-					/*
-		bills.setQuantityV20(V20);
-		bills.setQuantityV40(V40);
-		bills.setQuantityV40hc(V40HC);
-		bills.setQuantityV45(V45);
-		bills.setQuantityV48(V48);
-		bills.setQuantityOther(other);
-		bills.setTeu(teu.intValue());
-					 */
+
+					bill.setQuantityV20(V20);
+					bill.setQuantityV40(V40);
+					bill.setQuantityV40hc(V40HC);
+					bill.setQuantityV45(V45);
+					bill.setQuantityV48(V48);
+					bill.setQuantityOther(other);
+					bill.setTeu(teu.intValue());
 				});
 			}
 		});
@@ -1159,7 +1195,6 @@ public class MscZipImportImpl extends ServiceImpl<BillsMapper, Bills> implements
 				Object object = StringTools.handle(mhBill, "Bills");
 				Bills bills = JSONObject.parseObject(JSONObject.toJSONString(object), Bills.class);
 
-
 				if (ObjectUtils.isNull(bills.getBillNo())) {
 					BusinessBillNo businessBillNo = new BusinessBillNo();
 					businessBillNo.setBusinessTypeId(businessType.getId());
@@ -1194,6 +1229,8 @@ public class MscZipImportImpl extends ServiceImpl<BillsMapper, Bills> implements
 					bills.setUpdateTime(new Date());
 					bills.setUpdateUserName(AuthUtil.getUserName());
 
+					// 查一下是否有生成账单的费用,有的话不允许更改
+
 					this.updateById(bills);
 
 					bPreContainersService.remove(new LambdaQueryWrapper<PreContainers>()