diff --git a/src/main/java/com/heai/modules/production/controller/BoxLabelController.java b/src/main/java/com/heai/modules/production/controller/BoxLabelController.java new file mode 100644 index 0000000..9ed42f6 --- /dev/null +++ b/src/main/java/com/heai/modules/production/controller/BoxLabelController.java @@ -0,0 +1,35 @@ +package com.heai.modules.production.controller; + +import com.heai.common.utils.R; +import com.heai.modules.production.entity.PrintBoxLabel; +import com.heai.modules.production.service.PrintLabelRecordService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import java.util.List; +import java.util.Map; + +@RestController +@RequestMapping("/delivery/box/label") +public class BoxLabelController { + + @Autowired + private PrintLabelRecordService printLabelRecordService; + @PostMapping + public R getPrintBoxLabel(@RequestBody PrintBoxLabel boxLabel){ + Map maps = printLabelRecordService.getPrintBoxLabel(boxLabel); + return R.ok().put("row", maps); + } + + @PostMapping("/handle") + public R handlerPrintBoxLabel(@RequestBody PrintBoxLabel boxLabel){ + List> maps = printLabelRecordService.handlerPrintBoxLabel(boxLabel); + return R.ok().put("rows", maps); + } + + @PostMapping("/finally") + public R finallyPrintBoxLabel(@RequestBody PrintBoxLabel boxLabel){ + printLabelRecordService.finallyPrintBoxLabel(boxLabel); + return R.ok(); + } +} diff --git a/src/main/java/com/heai/modules/production/dao/PrintLabelRecordMapper.java b/src/main/java/com/heai/modules/production/dao/PrintLabelRecordMapper.java index 952bc0d..e7dca71 100644 --- a/src/main/java/com/heai/modules/production/dao/PrintLabelRecordMapper.java +++ b/src/main/java/com/heai/modules/production/dao/PrintLabelRecordMapper.java @@ -1,9 +1,29 @@ package com.heai.modules.production.dao; import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.heai.modules.pad.entity.PartData; +import com.heai.modules.production.entity.CoHeader; +import com.heai.modules.production.entity.PrintBoxLabel; import com.heai.modules.production.entity.PrintLabelRecord; import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.List; +import java.util.Map; @Mapper public interface PrintLabelRecordMapper extends BaseMapper { + List> handlerPrintBoxLabel(PrintBoxLabel boxLabel); + + String getPrintFileType(PrintBoxLabel boxLabel); + + int finallyPrintBoxLabel(@Param("site") String site,@Param("delNotifyNo") String delNotifyNo,@Param("total") int total,@Param("seqNo") int seqNo); + + PartData getPartData(PrintBoxLabel boxLabel); + + CoHeader getCoHeaderData(PrintBoxLabel boxLabel); + + String getPartRevNo(PartData part); + + String getPartAttr(@Param("partNo") String partNo,@Param("site") String site,@Param("type") String type); } diff --git a/src/main/java/com/heai/modules/production/entity/CoHeader.java b/src/main/java/com/heai/modules/production/entity/CoHeader.java new file mode 100644 index 0000000..0fbcf1d --- /dev/null +++ b/src/main/java/com/heai/modules/production/entity/CoHeader.java @@ -0,0 +1,95 @@ +package com.heai.modules.production.entity; + + +import lombok.Data; + +import java.math.BigDecimal; +import java.util.Date; + +@Data +public class CoHeader { + + private String orderNo; + + private String site; + + private String customerId; + + private Date orderDate; + + private Date enterDate; + + private String customerPoNo; + + private Date wantDeliveryDate; + + private String username; + + private String intSales; + + private String extSales; + + private String status; + + private String sourceFlag; + + private String printed; + + private String orderType; + + private String remark; + + private String paymentTerm; + + private String currency; + + private BigDecimal currencyRate; + + private String deliveryTerm; + + private String authorizeFlag; + + private String approvedFlag; + + private String approveResult; + + private String authorizator; + + private Date authorizeDate; + + private String taxCode; + + private String delAddId; + + private String invAddId; + + private BigDecimal leadTime; + + private String codeNo; + + private String packMethod; + + private String batchType; + + private String shipVia; + + private String sortFlag; + + private String subOrderType; + + private String soRemark; + + private String authRuleId; + + private String soCreateFlag; + + private String payerCustomerId; + + private String contractNo; + + private String firstStepApprovedFlag; + + private String headerPrePayFlag; + + private BigDecimal headerPrePayAmount; +} diff --git a/src/main/java/com/heai/modules/production/entity/PrintBoxLabel.java b/src/main/java/com/heai/modules/production/entity/PrintBoxLabel.java new file mode 100644 index 0000000..007cde7 --- /dev/null +++ b/src/main/java/com/heai/modules/production/entity/PrintBoxLabel.java @@ -0,0 +1,41 @@ +package com.heai.modules.production.entity; + +import lombok.Data; + +import java.math.BigDecimal; + +@Data +public class PrintBoxLabel { + private String site; + + private String delNotifyNo; + + private String delNotifyItemNo; + + private String partNo; + + private String partSpec; + + private int printTotalBoxCount; + + private int printBoxSeqNo; + + private BigDecimal qtyPerBox; + + private BigDecimal qtyPerBag; + + private BigDecimal shipQty; + + private BigDecimal boxNum; + + private BigDecimal endBoxQty; + + private BigDecimal scatteredBoxNo; + + private BigDecimal boxLabelTotalQty; + + private String userId; + + private String printFileType; + +} diff --git a/src/main/java/com/heai/modules/production/service/PrintLabelRecordService.java b/src/main/java/com/heai/modules/production/service/PrintLabelRecordService.java index e9be6a3..ff7f240 100644 --- a/src/main/java/com/heai/modules/production/service/PrintLabelRecordService.java +++ b/src/main/java/com/heai/modules/production/service/PrintLabelRecordService.java @@ -1,7 +1,18 @@ package com.heai.modules.production.service; import com.baomidou.mybatisplus.extension.service.IService; +import com.heai.modules.production.entity.PrintBoxLabel; import com.heai.modules.production.entity.PrintLabelRecord; +import java.util.List; +import java.util.Map; + public interface PrintLabelRecordService extends IService { + Map getPrintBoxLabel(PrintBoxLabel boxLabel); + + List> handlerPrintBoxLabel(PrintBoxLabel boxLabel); + + String getPrintFileType(PrintBoxLabel boxLabel); + + void finallyPrintBoxLabel(PrintBoxLabel boxLabel); } diff --git a/src/main/java/com/heai/modules/production/service/impl/PrintLabelRecordServiceImpl.java b/src/main/java/com/heai/modules/production/service/impl/PrintLabelRecordServiceImpl.java index b1caa95..c8410fb 100644 --- a/src/main/java/com/heai/modules/production/service/impl/PrintLabelRecordServiceImpl.java +++ b/src/main/java/com/heai/modules/production/service/impl/PrintLabelRecordServiceImpl.java @@ -1,11 +1,121 @@ package com.heai.modules.production.service.impl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.heai.modules.pad.entity.PartData; import com.heai.modules.production.dao.PrintLabelRecordMapper; +import com.heai.modules.production.dao.ProcedureMapper; +import com.heai.modules.production.entity.CoHeader; +import com.heai.modules.production.entity.PrintBoxLabel; import com.heai.modules.production.entity.PrintLabelRecord; import com.heai.modules.production.service.PrintLabelRecordService; +import com.heai.modules.sys.entity.SysUserEntity; +import org.apache.shiro.SecurityUtils; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import org.springframework.util.StringUtils; + +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.stream.Collectors; @Service public class PrintLabelRecordServiceImpl extends ServiceImpl implements PrintLabelRecordService { + @Autowired + private ProcedureMapper procedureMapper; + + @Override + public Map getPrintBoxLabel(PrintBoxLabel boxLabel) { + List list = new ArrayList<>(); + list.add(boxLabel.getSite()); + list.add(boxLabel.getDelNotifyNo()); + list.add(boxLabel.getDelNotifyItemNo()); + list.add(boxLabel.getPartNo()); + List> maps = procedureMapper.getProcedureData("Get_PrintBoxLabel_Initial_Info", list); + return maps.stream().findFirst().orElse(null); + } + + @Override + public List> handlerPrintBoxLabel(PrintBoxLabel boxLabel) { + SysUserEntity user = (SysUserEntity) SecurityUtils.getSubject().getPrincipal(); + boxLabel.setUserId(user.getUsername()); + + boxLabel.setPrintFileType(getPrintFileType(boxLabel)); + // 获取物料信息 + PartData part = baseMapper.getPartData(boxLabel); + if (Objects.isNull(part)){ + throw new RuntimeException("Site"+boxLabel.getSite()+"未维护物料"+boxLabel.getPartNo()); + } + // 获得PartRevNo + String partRevNo = baseMapper.getPartRevNo(part); + // 获取采购订单信息 + CoHeader coHeader = baseMapper.getCoHeaderData(boxLabel); + if (Objects.isNull(coHeader)){ + coHeader = new CoHeader(); + coHeader.setContractNo(""); + coHeader.setCustomerPoNo(""); + } + // 获取Part属性信息 + String hardness = baseMapper.getPartAttr(part.getPartNo(),part.getSite(),"HARDNESS"); + String color = baseMapper.getPartAttr(part.getPartNo(),part.getSite(),"COLOR"); + String iconInfo = baseMapper.getPartAttr(part.getPartNo(),part.getSite(),"CARTON ICON"); + String materialType = baseMapper.getPartAttr(part.getPartNo(),part.getSite(),"MATERIAL TYPE"); + List> list = baseMapper.handlerPrintBoxLabel(boxLabel); + CoHeader finalCoHeader = coHeader; + return list.stream().map(item->{ + item.put("receiveDate",item.get("createDate")); + item.put("partSpec",part.getSpec()); + item.put("partDesc",part.getPartDescription()); + item.put("code",genPrintTypeCode(String.valueOf(item.get("labelType")))); + item.put("code",genPrintTypeCode(String.valueOf(item.get("labelType")))); + item.put("code",genPrintTypeCode(String.valueOf(item.get("labelType")))); + item.put("contractNo", finalCoHeader.getContractNo()); + item.put("customerPONo",finalCoHeader.getCustomerPoNo()); + item.put("partRevNo",partRevNo); + item.put("cOLOR",color); + item.put("hARDNESS",hardness); + item.put("iconInfo",iconInfo); + item.put("mATERIALTYPE",materialType); + return item; + }).collect(Collectors.toList()); + } + + private String genPrintTypeCode(String type){ + if (StringUtils.isEmpty(type)){ + return "CODEXX"; + } + if ("A".equals(type)){ + return "CODE128"; + }else if ("B".equals(type)){ + return "CODE128"; + }else if (type.equals("C")){ + return "CODE128"; + }else { + return "CODEXX"; + } + } + + @Override + public String getPrintFileType(PrintBoxLabel boxLabel) { + return baseMapper.getPrintFileType(boxLabel); + } + + @Override + public void finallyPrintBoxLabel(PrintBoxLabel boxLabel) { + int total = 0; + int seqNo = 0; + if (boxLabel.getScatteredBoxNo().compareTo(BigDecimal.ZERO) == 0){ + total = boxLabel.getPrintTotalBoxCount(); + seqNo = new BigDecimal(boxLabel.getPrintBoxSeqNo()).add(boxLabel.getBoxNum()).intValue(); + }else if (new BigDecimal(boxLabel.getPrintBoxSeqNo()).add(boxLabel.getBoxNum()).compareTo(boxLabel.getScatteredBoxNo()) >= 0){ + total = boxLabel.getBoxNum().intValue(); + seqNo = new BigDecimal(boxLabel.getPrintBoxSeqNo()).add(boxLabel.getBoxNum()).intValue(); + }else { + total = boxLabel.getBoxNum().intValue(); + seqNo = boxLabel.getPrintBoxSeqNo(); + } + baseMapper.finallyPrintBoxLabel(boxLabel.getSite(),boxLabel.getDelNotifyNo(),total,seqNo); + } } diff --git a/src/main/resources/mapper/production/PrintLabelRecordMapper.xml b/src/main/resources/mapper/production/PrintLabelRecordMapper.xml new file mode 100644 index 0000000..41d3df2 --- /dev/null +++ b/src/main/resources/mapper/production/PrintLabelRecordMapper.xml @@ -0,0 +1,201 @@ + + + + + + + + + update CODelNotifyHeader + set PrintTotalBoxCount = #{total}, + PrintBoxSeqNo = #{seqNo} + where Site = #{site} + and DelNotifyNo = #{delNotifyNo} + + + + + + + + + + \ No newline at end of file