|
|
|
@ -12,10 +12,7 @@ import com.xujie.sys.modules.ecss.entity.*; |
|
|
|
import com.xujie.sys.modules.ecss.mapper.CoDelMapper; |
|
|
|
import com.xujie.sys.modules.ecss.service.CoDelService; |
|
|
|
import com.xujie.sys.modules.orderIssure.entity.PartData; |
|
|
|
import com.xujie.sys.modules.part.entity.PartSubPropertiesValue; |
|
|
|
import com.xujie.sys.modules.part.entity.PartSubPropertiesValueData; |
|
|
|
import com.xujie.sys.modules.part.entity.PartSubPropertiesValueHeaderData; |
|
|
|
import com.xujie.sys.modules.part.entity.PlmPropertiesItemAvailableData; |
|
|
|
import com.xujie.sys.modules.part.entity.*; |
|
|
|
import com.xujie.sys.modules.part.mapper.PartInformationMapper; |
|
|
|
import com.xujie.sys.modules.pms.mapper.EamMapper; |
|
|
|
import com.xujie.sys.modules.sys.entity.SysUserEntity; |
|
|
|
@ -171,7 +168,7 @@ public class CoDelServiceImpl implements CoDelService { |
|
|
|
task.setStatus(getStringCellValue(row, 6)); |
|
|
|
task.setFamily(getStringCellValue(row, 7)); |
|
|
|
task.setPn(getStringCellValue(row, 8)); |
|
|
|
List<PartData> parts = coDelMapper.getPartNo(site, task.getPn(),currentUser.getUsername()); |
|
|
|
List<PartData> parts = coDelMapper.getPartNo(site, task.getPn(),currentUser.getUsername(),inData.getBuNo()); |
|
|
|
if (parts.isEmpty()) { |
|
|
|
throw new RuntimeException("导入失败:物料:" + task.getPn() + "不存在!"); |
|
|
|
} |
|
|
|
@ -316,6 +313,12 @@ public class CoDelServiceImpl implements CoDelService { |
|
|
|
|
|
|
|
@Override |
|
|
|
public void changeEcssDelStatus(EcssCoDelNotifyHeaderData data) { |
|
|
|
if (data.getNotifyStatus().equals("已下达")) { |
|
|
|
List<EcssCoDelNotifyDetailData> checkEcssCoDelNotifyDetail = coDelMapper.searchEcssCoDelNotifyDetail(data); |
|
|
|
if (checkEcssCoDelNotifyDetail.isEmpty()) { |
|
|
|
throw new RuntimeException("该发货通知单下没有明细无法下达!"); |
|
|
|
} |
|
|
|
} |
|
|
|
coDelMapper.changeEcssDelStatus(data); |
|
|
|
} |
|
|
|
|
|
|
|
@ -328,6 +331,11 @@ public class CoDelServiceImpl implements CoDelService { |
|
|
|
if (!"已计划".equals(checkHeader.get(0).getNotifyStatus())) { |
|
|
|
throw new RuntimeException("发货通知单状态不为已计划,无法修改。"); |
|
|
|
} |
|
|
|
SysUserEntity currentUser = (SysUserEntity) SecurityUtils.getSubject().getPrincipal(); |
|
|
|
List<PartData> parts = coDelMapper.getPartNo(data.getSite(), data.getPn(),currentUser.getUsername(),data.getBuNo()); |
|
|
|
if (parts.isEmpty()) { |
|
|
|
throw new RuntimeException("修改失败:物料:" + data.getPn() + "不存在!"); |
|
|
|
} |
|
|
|
coDelMapper.updateEcssDelDetail(data); |
|
|
|
} |
|
|
|
|
|
|
|
@ -534,6 +542,7 @@ public class CoDelServiceImpl implements CoDelService { |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
@Transactional |
|
|
|
public void saveCoDelPalletDataByExcel(MultipartFile file, EcssCoDelNotifyHeaderData inData) { |
|
|
|
SysUserEntity currentUser = (SysUserEntity) SecurityUtils.getSubject().getPrincipal(); |
|
|
|
List<EcssCoDelPalletData> excelList = new ArrayList<>(); |
|
|
|
@ -582,7 +591,7 @@ public class CoDelServiceImpl implements CoDelService { |
|
|
|
excelData.setPalletRemark(getStringCellValue(row, 2)); |
|
|
|
excelData.setPoNo(getStringCellValue(row, 3)); |
|
|
|
excelData.setPn(getStringCellValue(row, 4)); |
|
|
|
List<PartData> parts = coDelMapper.getPartNo(excelData.getSite(), excelData.getPn(),currentUser.getUsername()); |
|
|
|
List<PartData> parts = coDelMapper.getPartNo(excelData.getSite(), excelData.getPn(),currentUser.getUsername(),inData.getBuNo()); |
|
|
|
if (parts.isEmpty()) { |
|
|
|
throw new RuntimeException("导入失败:物料:" + excelData.getPn() + "不存在!"); |
|
|
|
} |
|
|
|
@ -680,12 +689,12 @@ public class CoDelServiceImpl implements CoDelService { |
|
|
|
// 每一个物料加属性对应一个属性,用来下面遍历发货通知单明细时获取具体属性值 |
|
|
|
Map<String, PartSubPropertiesValueData> partNoAndItemNoMap = propertiesValues.stream() |
|
|
|
.collect(Collectors.toMap(o -> o.getPartNo() + "$" + o.getPropertiesItemNo(), o -> o)); |
|
|
|
PartSubPropertiesValueData propertiesWeight = partNoAndItemNoMap.get(partNo + "$ROLLWEIGHT");//每卷重量 |
|
|
|
//PartSubPropertiesValueData propertiesWeight = partNoAndItemNoMap.get(partNo + "$ROLLWEIGHT");//每卷重量 |
|
|
|
PartSubPropertiesValueData propertiesRollQty = partNoAndItemNoMap.get(partNo + "$ROLLQTY");//每卷数量 |
|
|
|
PartSubPropertiesValueData propertiesBoxRolls = partNoAndItemNoMap.get(partNo + "$BOXROLLS");//每箱卷数 |
|
|
|
PartSubPropertiesValueData propertiesBoxWeight = partNoAndItemNoMap.get(partNo + "$BOXWEIGHT");//箱重量 |
|
|
|
if (propertiesWeight==null||propertiesRollQty==null||propertiesBoxRolls==null||propertiesBoxWeight==null) { |
|
|
|
throw new RuntimeException("请先维护物料["+partNo+"]基本信息!"); |
|
|
|
//PartSubPropertiesValueData propertiesBoxWeight = partNoAndItemNoMap.get(partNo + "$BOXWEIGHT");//箱重量 |
|
|
|
if (propertiesRollQty==null||propertiesBoxRolls==null) { |
|
|
|
throw new RuntimeException("请先维护物料["+detailData.getPn()+"]的每卷数量和每箱卷数!"); |
|
|
|
} |
|
|
|
detailData.setBoxQty(detailData.getQty().divide( |
|
|
|
BigDecimal.valueOf(((double) propertiesRollQty.getNumValue().intValue() * propertiesBoxRolls.getNumValue().intValue())),2, BigDecimal.ROUND_HALF_UP)); |
|
|
|
@ -740,8 +749,28 @@ public class CoDelServiceImpl implements CoDelService { |
|
|
|
for (int i = 0; i < headerList.size(); i++) { |
|
|
|
coDelMapper.saveCodelPalletHeader(headerList.get(i)); |
|
|
|
} |
|
|
|
Map<String, BigDecimal> palletDetailMap = new HashMap<>(); |
|
|
|
for (int i = 0; i < detailList.size(); i++) { |
|
|
|
coDelMapper.saveCodelPalletDetail(detailList.get(i)); |
|
|
|
if (!palletDetailMap.containsKey(detailList.get(i).getPn())) { |
|
|
|
palletDetailMap.put(detailList.get(i).getPn(), detailList.get(i).getQty()); |
|
|
|
} else { |
|
|
|
palletDetailMap.put(detailList.get(i).getPn(), palletDetailMap.get(detailList.get(i).getPn()).add(detailList.get(i).getQty())); |
|
|
|
} |
|
|
|
} |
|
|
|
List<EcssCoDelNotifyDetailData> ecssCoDelNotifyDetail = coDelMapper.searchEcssCoDelNotifyDetail(inData); |
|
|
|
Map<String, BigDecimal> notifyDetailMap = new HashMap<>(); |
|
|
|
for (EcssCoDelNotifyDetailData detailData : ecssCoDelNotifyDetail) { |
|
|
|
if (!notifyDetailMap.containsKey(detailData.getPn())) { |
|
|
|
notifyDetailMap.put(detailData.getPn(), detailData.getQty()); |
|
|
|
} else { |
|
|
|
notifyDetailMap.put(detailData.getPn(), notifyDetailMap.get(detailData.getPn()).add(detailData.getQty())); |
|
|
|
} |
|
|
|
} |
|
|
|
for (Map.Entry<String, BigDecimal> entry : palletDetailMap.entrySet()) { |
|
|
|
if (notifyDetailMap.get(entry.getKey()).compareTo(entry.getValue())!=0) { |
|
|
|
throw new RuntimeException("物料["+entry.getKey()+"]的数量和发货通知单数量不一致!"); |
|
|
|
} |
|
|
|
} |
|
|
|
} catch (Exception e) { |
|
|
|
throw new RuntimeException("导入失败:" + e.getMessage()); |
|
|
|
@ -886,7 +915,8 @@ public class CoDelServiceImpl implements CoDelService { |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
public void savePalletDetail(EcssCoDelPalletDetailData inData) { |
|
|
|
@Transactional |
|
|
|
public void savePalletDetail(EcssCoDelPalletData inData) { |
|
|
|
List<PartData> checkPart = coDelMapper.checkPart(inData.getSite(), inData.getPartNo()); |
|
|
|
if (checkPart.size() == 0) { |
|
|
|
throw new RuntimeException("导入失败:物料:" + inData.getPartNo() + "在当前工厂不存在!"); |
|
|
|
@ -900,6 +930,7 @@ public class CoDelServiceImpl implements CoDelService { |
|
|
|
} else { |
|
|
|
inData.setUpdateBy(currentUser.getUsername()); |
|
|
|
coDelMapper.updateCodelPalletDetail(inData); |
|
|
|
coDelMapper.updateCodelPalletHeader2(inData); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@ -1263,7 +1294,7 @@ public class CoDelServiceImpl implements CoDelService { |
|
|
|
template.addVar("dateStr", DateUtils.format(notifyHeader.getReadyDate(), "yyyy-MM-dd")); |
|
|
|
template.addVar("Currency", "CNY"); |
|
|
|
template.addVar("Incoterm", "EXW "); |
|
|
|
template.addVar("shippingMode", notifyHeader.getShippingMode()); |
|
|
|
template.addVar("shippingMode", stringInput(notifyHeader.getShippingMode())); |
|
|
|
Map<String, EcssCoDelNotifyDetailData> notifyDetailMap = notifyDetailList.stream().collect( |
|
|
|
Collectors.toMap(EcssCoDelNotifyDetailData::getPartNo,e->e)); |
|
|
|
// 装箱明细 |
|
|
|
@ -1323,12 +1354,12 @@ public class CoDelServiceImpl implements CoDelService { |
|
|
|
} |
|
|
|
// RFID需要的 |
|
|
|
if (notifyHeader.getBuNo().equals("01-Label") || notifyHeader.getBuNo().equals("03-RFID")) { |
|
|
|
template.addVar("madein", data.getOrigin()); |
|
|
|
template.addVar("madein", stringInput(data.getOrigin())); |
|
|
|
} |
|
|
|
// 孟加拉需要的 |
|
|
|
if (data.getMaterial()!=null && data.getMaterial()) { |
|
|
|
template.addVar("RFIDBase", "RFID Base Material"); |
|
|
|
template.addVar("HSCode", "& H.S.Code:"+data.getHsCode()); |
|
|
|
template.addVar("HSCode", "& H.S.Code:"+stringInput(data.getHsCode())); |
|
|
|
} |
|
|
|
// 欧洲地区需要 |
|
|
|
if (ecHeader.getPackaging()!=null && ecHeader.getPackaging()) { |
|
|
|
@ -1496,7 +1527,7 @@ public class CoDelServiceImpl implements CoDelService { |
|
|
|
// 孟加拉需要的 |
|
|
|
if (data.getMaterial()!=null && data.getMaterial()) { |
|
|
|
template.addVar("RFIDBase", "RFID Base Material"); |
|
|
|
template.addVar("HSCode", "& H.S.Code:"+data.getHsCode()); |
|
|
|
template.addVar("HSCode", "& H.S.Code:"+stringInput(data.getHsCode())); |
|
|
|
template.addVar("volume", palletHeaderData.map(ecssCoDelPalletHeaderData -> |
|
|
|
ecssCoDelPalletHeaderData.getLength().setScale(2, RoundingMode.HALF_UP) |
|
|
|
+ "*" + ecssCoDelPalletHeaderData.getWidth().setScale(2, RoundingMode.HALF_UP) + "*" |
|
|
|
@ -1515,7 +1546,7 @@ public class CoDelServiceImpl implements CoDelService { |
|
|
|
template.addVar("originLabel", "Origin of goods Made in China"); |
|
|
|
template.addVar("sellerLabel", "Name of seller Checkpoint Commercial (Shanghai) Co.. Ltd."); |
|
|
|
} |
|
|
|
template.addVar("Shipping_Mark", data.getShippingMark()); |
|
|
|
template.addVar("Shipping_Mark", stringInput(data.getShippingMark())); |
|
|
|
template.addVar("Measurement", palletHeaderData.get().getLength(). |
|
|
|
multiply(palletHeaderData.get().getWidth()).multiply(palletHeaderData.get().getHeight()). |
|
|
|
multiply(BigDecimal.valueOf(totalPlt)).setScale(2, RoundingMode.HALF_UP)); |
|
|
|
@ -1636,14 +1667,14 @@ public class CoDelServiceImpl implements CoDelService { |
|
|
|
template.addVar("shipping_port", stringInput(notifyHeader.getDestination())); |
|
|
|
template.addVar("cmc_invoice", stringInput(notifyHeader.getCmcInvoice())); |
|
|
|
// 导出时默认,可编辑的栏目 |
|
|
|
template.addVar("sales_method", data.getSalesMethod());//贸易方式 |
|
|
|
template.addVar("currency", data.getCurrency());//币制 |
|
|
|
template.addVar("made_area", data.getMadeArea());//货物产地 |
|
|
|
template.addVar("send_port", data.getSendPort());//发货港 |
|
|
|
template.addVar("shipper", data.getShipper());//发货人 |
|
|
|
template.addVar("voyage", data.getVoyage());//航次 |
|
|
|
template.addVar("delivery_goods_date", data.getDeliveryGoodsDate());//提货日期 |
|
|
|
template.addVar("shipping_date", data.getShippingDate());//船期 |
|
|
|
template.addVar("sales_method", stringInput(data.getSalesMethod()));//贸易方式 |
|
|
|
template.addVar("currency", stringInput(data.getCurrency()));//币制 |
|
|
|
template.addVar("made_area", stringInput(data.getMadeArea()));//货物产地 |
|
|
|
template.addVar("send_port", stringInput(data.getSendPort()));//发货港 |
|
|
|
template.addVar("shipper", stringInput(data.getShipper()));//发货人 |
|
|
|
template.addVar("voyage", stringInput(data.getVoyage()));//航次 |
|
|
|
template.addVar("delivery_goods_date", stringInput(data.getDeliveryGoodsDate()));//提货日期 |
|
|
|
template.addVar("shipping_date", stringInput(data.getShippingDate()));//船期 |
|
|
|
// 需要计算的 |
|
|
|
// 总托数 |
|
|
|
Integer totalPlt = palletHeaderDataList.get(0).getPalletQty(); |
|
|
|
@ -1686,49 +1717,22 @@ public class CoDelServiceImpl implements CoDelService { |
|
|
|
@Override |
|
|
|
public void downloadContract(HttpServletResponse response, EcssDeclarationHeaderData data) { |
|
|
|
try { |
|
|
|
ExcelTemplate template = ExcelTemplate.load(new ClassPathResource("templates/declaration-elements-template.xlsx").getInputStream()); |
|
|
|
template.addVar("brandType", data.getBrandType()); |
|
|
|
// 获取partNo列表 |
|
|
|
List<Map> partNos = coDelMapper.getDeclarationElements(data); |
|
|
|
List<String> partNoList = partNos.stream().map(map -> map.get("partNo").toString()).collect(Collectors.toList()); |
|
|
|
// 根据partNo获取hsCode |
|
|
|
List<Map> hsCodes = coDelMapper.getHsCodeByPartNo(data.getSite(), partNoList); |
|
|
|
Map<String, Map> hsCodeMap = new HashMap<>(); |
|
|
|
for (int i = 0; i < hsCodes.size(); i++) { |
|
|
|
Map eorder = hsCodes.get(i); |
|
|
|
String key = eorder.get("hsCode")+"&"+eorder.get("hsCodeDesc"); |
|
|
|
if (hsCodeMap.containsKey(key)) { |
|
|
|
hsCodeMap.get(key).put("sku", hsCodeMap.get(key).get("sku")+"\n "+eorder.get("sku")); |
|
|
|
} else { |
|
|
|
// hscode所有属性 |
|
|
|
PartSubPropertiesValueData inData = new PartSubPropertiesValueData(); |
|
|
|
inData.setSite(data.getSite()); |
|
|
|
inData.setBuNo(eorder.get("BuNo").toString()); |
|
|
|
inData.setCodeNo(eorder.get("codeNo").toString()); |
|
|
|
inData.setPartNo(eorder.get("hsCodeDesc").toString()); |
|
|
|
inData.setRecordType("ECSS"); |
|
|
|
List<PartSubPropertiesValueData> propertiesList = coDelMapper.getPropertiesListByPartAndCodeNo(inData); |
|
|
|
StringBuilder properties = new StringBuilder(); |
|
|
|
for (int j = 0; j < propertiesList.size(); j++) { |
|
|
|
if (j == propertiesList.size() - 1) { |
|
|
|
properties.append(propertiesList.get(j).getItemDesc()).append(": ").append(propertiesList.get(j).getTextValue()); |
|
|
|
} else { |
|
|
|
properties.append(propertiesList.get(j).getItemDesc()).append(": ").append(propertiesList.get(j).getTextValue()).append("\n"); |
|
|
|
} |
|
|
|
} |
|
|
|
eorder.put("properties",properties); |
|
|
|
hsCodeMap.put(key, eorder); |
|
|
|
} |
|
|
|
} |
|
|
|
List<Map> list = new ArrayList<>(hsCodeMap.values()); |
|
|
|
for (int i = 0; i < list.size(); i++) { |
|
|
|
Map fMap = list.get(i); |
|
|
|
fMap.put("content", "HS Code: "+fMap.get("hsCode")+ |
|
|
|
"\n品名: "+(data.getHsCodeDescType()!=null&&data.getHsCodeDescType().equals("N")?fMap.get("hsCodeDescEn"):fMap.get("hsCodeDesc"))+ |
|
|
|
"\n"+fMap.get("properties")+ |
|
|
|
"\n型号: "+fMap.get("sku")); |
|
|
|
ExcelTemplate template = ExcelTemplate.load(new ClassPathResource("templates/declaration-contract-template.xlsx").getInputStream()); |
|
|
|
EcssDeclarationHeaderData ecHeader = coDelMapper.getDeclarationHeader(data); |
|
|
|
// 发货通知单 |
|
|
|
EcssCoDelNotifyHeaderData notifyHeader = coDelMapper.getEcssCoDelNotifyHeader(data.getSite(), data.getDelNo()); |
|
|
|
template.addVar("cmcInvoice", notifyHeader.getCmcInvoice()); |
|
|
|
List<Map> notifyDetailGroup = coDelMapper.getNotifyDetailGroup(data); |
|
|
|
BigDecimal totalQty = BigDecimal.ZERO; |
|
|
|
BigDecimal totalAmount = BigDecimal.ZERO; |
|
|
|
for (int i = 0; i < notifyDetailGroup.size(); i++) { |
|
|
|
Map notifyDetail = notifyDetailGroup.get(i); |
|
|
|
totalQty = totalQty.add((BigDecimal) notifyDetail.get("total_qty")); |
|
|
|
totalAmount = totalAmount.add((BigDecimal) notifyDetail.get("ttl_amount")); |
|
|
|
} |
|
|
|
template.addListVarAll(list); |
|
|
|
template.addVar("totalQty", totalQty); |
|
|
|
template.addVar("totalAmount", totalAmount); |
|
|
|
template.addListVarAll(notifyDetailGroup); |
|
|
|
template.render(response.getOutputStream()); |
|
|
|
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); |
|
|
|
response.setHeader("Content-Disposition", "attachment; filename=\"合同.xlsx\""); |
|
|
|
@ -1786,10 +1790,10 @@ public class CoDelServiceImpl implements CoDelService { |
|
|
|
int seqNo = coDelMapper.getCoDelPalletHeaderSeqNo(inData); |
|
|
|
for (String partNo : palletItemMap.keySet()) { |
|
|
|
List<PartData> partList = coDelMapper.getPartInfo(inData.getSite(),partNo); |
|
|
|
List<EcssPackageData> packageDataList = coDelMapper.getPackage(inData.getSite(),inData.getBuNo(),partList.get(0).getPackageNo()); |
|
|
|
/* List<EcssPackageData> packageDataList = coDelMapper.getPackage(inData.getSite(),inData.getBuNo(),partList.get(0).getPackageNo()); |
|
|
|
if (packageDataList.isEmpty()) { |
|
|
|
throw new RuntimeException("物料["+partList.get(0).getSku()+"]未维护包装箱信息!"); |
|
|
|
} |
|
|
|
}*/ |
|
|
|
PartSubPropertiesValueData propertiesWeight = partNoAndItemNoMap.get(partNo + "$ROLLWEIGHT");//每卷重量 |
|
|
|
PartSubPropertiesValueData propertiesRollQty = partNoAndItemNoMap.get(partNo + "$ROLLQTY");//每卷数量 |
|
|
|
PartSubPropertiesValueData propertiesBoxRolls = partNoAndItemNoMap.get(partNo + "$BOXROLLS");//每箱卷数 |
|
|
|
@ -2022,4 +2026,10 @@ public class CoDelServiceImpl implements CoDelService { |
|
|
|
}); |
|
|
|
return list; |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public PageUtils queryPartListAll(PartInformationEntity data) { |
|
|
|
IPage<PartInformationEntity> list = this.coDelMapper.queryPartListAll(new Page<PartInformationEntity>(data.getPage(), data.getLimit()), data); |
|
|
|
return new PageUtils(list); |
|
|
|
} |
|
|
|
} |