From 2f878afd46d429628d1b66ee32b267541bb3c4b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=91=A3=E5=93=B2=E5=A5=87?= <13840175730@139.com> Date: Wed, 14 May 2025 17:20:09 +0800 Subject: [PATCH] =?UTF-8?q?1.=E5=A2=9E=E5=8A=A0=E4=BD=99=E6=96=99=E5=BA=93?= =?UTF-8?q?=E5=AD=98=E7=AE=A1=E7=90=86=202.=E5=88=87=E5=89=B2=E5=AE=8C?= =?UTF-8?q?=E6=88=90=E5=90=8E,=E5=AD=98=E5=9C=A8=E4=BD=99=E6=96=99?= =?UTF-8?q?=E7=9A=84,=E8=87=AA=E5=8A=A8=E7=94=9F=E6=88=90=E5=B8=A6?= =?UTF-8?q?=E6=9D=A5=E6=BA=90=E5=9B=BE=E7=BA=B8=E7=9A=84=E4=BD=99=E6=96=99?= =?UTF-8?q?=E4=BF=A1=E6=81=AF=203.=E4=BD=99=E6=96=99=E4=B8=8A=E6=96=99,?= =?UTF-8?q?=E8=87=AA=E5=8A=A8=E5=90=8C=E6=AD=A5=E4=BD=99=E6=96=99=E5=BA=93?= =?UTF-8?q?=E5=AD=98,=E4=BD=99=E6=96=99=E8=A2=AB=E5=93=AA=E4=B8=AA?= =?UTF-8?q?=E5=A5=97=E6=96=99=E5=9B=BE=E4=BD=BF=E7=94=A8=204.=E4=BD=99?= =?UTF-8?q?=E6=96=99=E6=8A=A5=E5=B7=A5,=E5=88=87=E5=89=B2=E5=AE=8C?= =?UTF-8?q?=E6=88=90,=E5=AD=98=E5=9C=A8=E4=BD=99=E6=96=99=E7=9A=84,?= =?UTF-8?q?=E8=87=AA=E5=8A=A8=E7=94=9F=E6=88=90=E5=B8=A6=E6=9D=A5=E6=BA=90?= =?UTF-8?q?=E5=9B=BE=E7=BA=B8=E4=BD=99=E6=96=99=E4=BF=A1=E6=81=AF=205.?= =?UTF-8?q?=E8=B0=83=E6=95=B4=E6=8A=80=E6=9C=AF=E5=87=86=E5=A4=87,?= =?UTF-8?q?=E5=AF=BC=E5=87=BA=E6=95=B0=E6=8D=AE=E7=AD=9B=E9=80=89=E4=BB=8E?= =?UTF-8?q?=E5=A5=97=E6=96=99=E5=9B=BE=E5=8F=B7=E4=B8=AD=E8=8E=B7=E5=8F=96?= =?UTF-8?q?=206.=E6=8A=9B=E4=B8=B8=E5=AE=8C=E6=88=90=E5=90=8E=E8=87=AA?= =?UTF-8?q?=E5=8A=A8=E8=AE=BE=E7=BD=AE=E5=85=89=E7=94=B5=E4=B8=BA=E5=85=AD?= =?UTF-8?q?=E5=8C=BA,=E8=BF=9B=E8=A1=8C=E5=88=87=E5=89=B2=E6=8A=A5?= =?UTF-8?q?=E5=B7=A5=207.=E5=A2=9E=E5=8A=A0=E7=9C=8B=E6=9D=BF=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E8=A1=A8=E6=98=BE=E7=A4=BA=E7=9C=8B=E6=9D=BF=E5=9B=BE?= =?UTF-8?q?=E5=BD=A2=E5=AF=B9=E5=BA=94=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dsic/gj_erp/bean/SpringContextHolder.java | 4 + .../com/dsic/gj_erp/bean/jhgk/DmYdjh.java | 7 +- .../com/dsic/gj_erp/bean/zyjh/DmYlInfo.java | 126 ++++++++++++++++++ .../gj_erp/controller/zyjh/YlController.java | 121 +++++++++++++++++ .../controller/zyjh/ZyjhController.java | 48 ++++++- .../gj_erp/controller/zyjh/dto/YlSlDto.java | 27 ++++ .../gj_erp/mapper/zyjh/DmYlInfoMapper.java | 7 + .../gj_erp/service/zyjh/DmYlInfoService.java | 10 ++ .../resources/mappers/zyjh/DmYlInfoMapper.xml | 5 + 9 files changed, 349 insertions(+), 6 deletions(-) create mode 100644 src/main/java/com/dsic/gj_erp/bean/zyjh/DmYlInfo.java create mode 100644 src/main/java/com/dsic/gj_erp/controller/zyjh/YlController.java create mode 100644 src/main/java/com/dsic/gj_erp/controller/zyjh/dto/YlSlDto.java create mode 100644 src/main/java/com/dsic/gj_erp/mapper/zyjh/DmYlInfoMapper.java create mode 100644 src/main/java/com/dsic/gj_erp/service/zyjh/DmYlInfoService.java create mode 100644 src/main/resources/mappers/zyjh/DmYlInfoMapper.xml diff --git a/src/main/java/com/dsic/gj_erp/bean/SpringContextHolder.java b/src/main/java/com/dsic/gj_erp/bean/SpringContextHolder.java index faf42d7..5fbf545 100644 --- a/src/main/java/com/dsic/gj_erp/bean/SpringContextHolder.java +++ b/src/main/java/com/dsic/gj_erp/bean/SpringContextHolder.java @@ -56,4 +56,8 @@ public class SpringContextHolder implements ApplicationContextAware { public static void pushEvent(Object event) { springContext.publishEvent(event); } + + public static String getActiveProfile() { + return springContext.getEnvironment().getActiveProfiles()[0]; + } } \ No newline at end of file diff --git a/src/main/java/com/dsic/gj_erp/bean/jhgk/DmYdjh.java b/src/main/java/com/dsic/gj_erp/bean/jhgk/DmYdjh.java index 66aaf97..d411251 100644 --- a/src/main/java/com/dsic/gj_erp/bean/jhgk/DmYdjh.java +++ b/src/main/java/com/dsic/gj_erp/bean/jhgk/DmYdjh.java @@ -419,6 +419,9 @@ public class DmYdjh implements Serializable { public void setForPwpg(){ this.zt=ZyjhzxEnum.PWPG.code; } + public void setZtForPwfk(){ + this.zt=ZyjhzxEnum.PWFK.code; + } public void setZtForHXFK(){ this.zt=ZyjhzxEnum.HXFK.code; } @@ -438,7 +441,9 @@ public class DmYdjh implements Serializable { ZyjhzxEnum zyjhzxEnum = ZyjhzxEnum.valueOf(type); //光电跳过划线,抛丸后直接进行切割流程 if ("17".equals(kw)&&zyjhzxEnum==ZyjhzxEnum.PWFK){ - //this.zt=ZyjhzxEnum.HXFK.code; +// this.zt=ZyjhzxEnum.HXFK.code; +// this.zyq="FP6Q"; +// this.zyq1="六区"; }else{ ZyjhzxEnum zt = ZyjhzxEnum.getEnumByCode(this.zt); if (zyjhzxEnum==null){ diff --git a/src/main/java/com/dsic/gj_erp/bean/zyjh/DmYlInfo.java b/src/main/java/com/dsic/gj_erp/bean/zyjh/DmYlInfo.java new file mode 100644 index 0000000..71c3a2f --- /dev/null +++ b/src/main/java/com/dsic/gj_erp/bean/zyjh/DmYlInfo.java @@ -0,0 +1,126 @@ +package com.dsic.gj_erp.bean.zyjh; + +import cn.hutool.core.date.DateUtil; +import cn.hutool.core.util.StrUtil; +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import com.dsic.gj_erp.bean.jcsj.DmBchxylp; +import com.dsic.gj_erp.bean.jhgk.DmYdjh; +import lombok.Getter; +import lombok.Setter; + +import java.math.BigDecimal; + +@Getter +@Setter +@TableName("dm_yl_info") +public class DmYlInfo { + @TableId(value = "id", type = IdType.ASSIGN_UUID) + private String id; + + private String 余料编号;//余料编号,套料图中存在编号时产生 + + private String 规格;//规格 + + private BigDecimal 厚; + + private BigDecimal 宽; + + private BigDecimal 长; + + private String 炉批号; + + private String 重量; + + private String 数量="1"; + + private String 垛位; + + private String 层数; + + private String 来源船号;//来源船号 + + private String 来源批量;//来源批量 + + private String 来源图纸;//来源图纸 + + private String 物品型号; + + private String 物品规格; + + private String 切割日期; + + private String 使用船号;//使用船号 + + private String 使用批量;//使用批量 + + private String 使用分段;//使用分段 + + private String 使用图纸;//使用图纸 + + private String 使用日期;//同打印日期 + + private int 使用状态;//0:未使用;1:已使用;2:已打印;3:已切割 + + public boolean 指定余料编号的上料匹配(String 余料编号){ + return StrUtil.isNotEmpty(this.余料编号) &&this.余料编号.equals(余料编号); + } + + public boolean 不指定余料编号的上料匹配(DmYdjh ydjh){ + if (使用状态>0){ + return false; + } + if (ydjh.getWpxh()==null||ydjh.getWpgg()==null){ + return false; + } + + String[] split = ydjh.getWpgg().split("\\*"); + if (split.length<3){ + return false; + } + //必须保证材质相同,厚度相同,宽和长要小于余料的宽和长才能使用 + return ydjh.getWpxh().equals(物品型号) + &&new BigDecimal(split[0]).compareTo(厚)==0 + &&new BigDecimal(split[1]).compareTo(宽)<=0 + &&new BigDecimal(split[1]).compareTo(长)<=0; + } + + public void 修正上料信息(DmYdjh ydjh){ + 使用船号=ydjh.getDcCh(); + 使用批量=ydjh.getDcPl(); + 使用分段=ydjh.getDcFd(); + 使用图纸=ydjh.getTzbh(); + 使用状态=UseStatus.已使用.ordinal(); + } + + public static DmYlInfo of(DmBchxylp bchxylp, DmYdjh ydjh){ + DmYlInfo dmYlInfo = new DmYlInfo(); + dmYlInfo.余料编号=bchxylp.getYlbh(); + dmYlInfo.规格=bchxylp.getYlgg(); + + if (dmYlInfo.规格!=null){ + String[] split = dmYlInfo.规格.split("\\*"); + if (split.length>=3){ + dmYlInfo.厚=new BigDecimal(split[0]); + dmYlInfo.宽=new BigDecimal(split[1]); + dmYlInfo.长=new BigDecimal(split[2]); + } + } + + dmYlInfo.炉批号= ydjh.getSllph(); + dmYlInfo.重量=ydjh.getBcylzl().toString(); + dmYlInfo.来源船号=ydjh.getDcCh(); + dmYlInfo.来源批量=ydjh.getDcPl(); + dmYlInfo.来源图纸=ydjh.getTzbh(); + dmYlInfo.物品型号=bchxylp.getWpxh(); + dmYlInfo.物品规格=ydjh.getWpgg(); + dmYlInfo.切割日期= DateUtil.date().toString("yyyy/MM/dd"); + dmYlInfo.使用状态=UseStatus.未使用.ordinal(); + return dmYlInfo; + } + + public enum UseStatus{ + 未使用,已使用,已打印,已切割 + } +} diff --git a/src/main/java/com/dsic/gj_erp/controller/zyjh/YlController.java b/src/main/java/com/dsic/gj_erp/controller/zyjh/YlController.java new file mode 100644 index 0000000..3b30dfa --- /dev/null +++ b/src/main/java/com/dsic/gj_erp/controller/zyjh/YlController.java @@ -0,0 +1,121 @@ +package com.dsic.gj_erp.controller.zyjh; + +import cn.hutool.core.date.DateUtil; +import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.StrUtil; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.dsic.gj_erp.bean.ResultBean; +import com.dsic.gj_erp.bean.jhgk.DmYdjh; +import com.dsic.gj_erp.bean.zyjh.DmYlInfo; +import com.dsic.gj_erp.controller.zyjh.dto.YlSlDto; +import com.dsic.gj_erp.exception.ServiceException; +import com.dsic.gj_erp.service.jhgk.DmYdjhService; +import com.dsic.gj_erp.service.zyjh.DmYlInfoService; +import lombok.AllArgsConstructor; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.web.bind.annotation.*; + +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Collectors; + +/** + * 余料管理 + */ +@RestController +@RequestMapping("yl") +@AllArgsConstructor +public class YlController { + + private final DmYlInfoService ylInfoService; + private final DmYdjhService ydjhService; + + @PostMapping("list") + public ResultBean list(@RequestBody YlSlDto dto){ + return new ResultBean<>( + ylInfoService.list(Wrappers.lambdaQuery() + .eq(DmYlInfo::get来源船号,dto.getDcCh()) + .eq(DmYlInfo::get使用状态,dto.getStatus()) + ) + ); + } + + /** + * 保存功能 + */ + @PostMapping("edit") + public ResultBean edit(@RequestBody List list){ + ylInfoService.updateBatchById(list); + return new ResultBean<>(); + } + + /** + * 打印 + */ + @PostMapping("print") + @Transactional(rollbackFor = Exception.class) + public ResultBean print(@RequestBody List list){ + ArrayList updateList = new ArrayList<>(); + list.forEach(item->{ + String date = DateUtil.date().toString("yyyy/MM/dd"); + item.set使用日期(date); + item.set使用状态(2);//已打印 + List ydjhList = ydjhService.list(Wrappers.lambdaQuery() + .eq(DmYdjh::getDcCh, item.get使用船号()) + .eq(DmYdjh::getTzbh,item.get使用图纸()) + ); + List collect = ydjhList.stream().map(it -> { + it.setSllph(item.get炉批号()); + it.setSlfkrq(date); + //fixme 不确定是否还需要抛丸,先执行到上料 + it.setZtForPwfk(); + if ("17".equals(it.getKw())){//光电直接切割 + it.setZtForHXFK(); + } + return it; + }).collect(Collectors.toList()); + + updateList.addAll(collect); + }); + ydjhService.updateBatchById(updateList); + ylInfoService.updateBatchById(list); + return new ResultBean<>(); + } + + /** + * 根据语料库存数据选择结果匹配作业计划 + * 匹配成功后返回匹配结果并显示到 + */ + @PostMapping("sl") + public ResultBean sl(@RequestBody YlSlDto dto){ + if (!dto.isAllow()){ + throw new ServiceException(99999,"请填写需求船号和批次"); + } + if (ObjectUtil.isEmpty(dto.getYlList())){ + return new ResultBean<>(new ArrayList<>()); + } + + List list = ydjhService.list(Wrappers.lambdaQuery() + .eq(DmYdjh::getDcCh, dto.getDcCh()) + .eq(DmYdjh::getDcPl, dto.getDcPl()) + .eq(StrUtil.isNotEmpty(dto.getTzbh()),DmYdjh::getTzbh,dto.getTzbh()) + ); + + List 匹配成功的余料信息=new ArrayList<>(); + for (DmYdjh ydjh:list){ + for (DmYlInfo ylInfo:dto.getYlList()){ + if (ylInfo.指定余料编号的上料匹配("")){//暂时不支持,仅保留分支流程 + break; + } + + if (ylInfo.不指定余料编号的上料匹配(ydjh)){ + ylInfo.修正上料信息(ydjh); + 匹配成功的余料信息.add(ylInfo); + break; + } + } + } + + return new ResultBean<>(匹配成功的余料信息); + } +} diff --git a/src/main/java/com/dsic/gj_erp/controller/zyjh/ZyjhController.java b/src/main/java/com/dsic/gj_erp/controller/zyjh/ZyjhController.java index 06c2687..770482c 100644 --- a/src/main/java/com/dsic/gj_erp/controller/zyjh/ZyjhController.java +++ b/src/main/java/com/dsic/gj_erp/controller/zyjh/ZyjhController.java @@ -10,19 +10,19 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.dsic.gj_erp.annotation.AuthFunction; import com.dsic.gj_erp.bean.ResultBean; import com.dsic.gj_erp.bean.czzj.MpDhsj; +import com.dsic.gj_erp.bean.jcsj.DmBchxylp; import com.dsic.gj_erp.bean.jhgk.DmYdjh; import com.dsic.gj_erp.bean.jhgk.DmYdjhLj; import com.dsic.gj_erp.bean.kc.ImCkwpkwp; -import com.dsic.gj_erp.bean.zyjh.DmYppyz; -import com.dsic.gj_erp.bean.zyjh.PwExcel; -import com.dsic.gj_erp.bean.zyjh.Ycldw; -import com.dsic.gj_erp.bean.zyjh.YcldwInfo; +import com.dsic.gj_erp.bean.zyjh.*; import com.dsic.gj_erp.controller.zyjh.dto.*; import com.dsic.gj_erp.dao.zyjh.PPBGongDto; import com.dsic.gj_erp.exception.ServiceException; import com.dsic.gj_erp.listeners.ExcelPwListener; import com.dsic.gj_erp.service.czzj.MpDhsjServcie; +import com.dsic.gj_erp.service.jcsj.DmBchxylpService; import com.dsic.gj_erp.service.kc.ImCkwpkwpService; +import com.dsic.gj_erp.service.zyjh.DmYlInfoService; import com.dsic.gj_erp.service.zyjh.YcldwInfoService; import com.dsic.gj_erp.service.zyjh.YcldwService; import com.dsic.gj_erp.service.zyjh.ZyjhService; @@ -64,6 +64,10 @@ public class ZyjhController { private final TransactionTemplate transactionTemplate; + private final DmBchxylpService bchxylpService; + + private final DmYlInfoService ylInfoService; + @PostMapping("yppbg") public ResultBean yppbg(@RequestBody List list){ List updateList=new ArrayList<>(); @@ -345,10 +349,40 @@ public class ZyjhController { wsHandler.sendQGComplete((JSONObject) JSONObject.toJSON(dto.getYcldwInfo())); } + ArrayList updateYlList = new ArrayList<>(); + ArrayList MpDhsjSaveList = new ArrayList<>(); for (DmYdjh item : list) { + if ("Y".equalsIgnoreCase(item.getYlbs())){ + List ylList = ylInfoService.list(Wrappers.lambdaQuery() + .eq(DmYlInfo::get使用船号, item.getDcCh()) + .eq(DmYlInfo::get使用图纸, item.getTzbh()) + ); + for (DmYlInfo dmYlInfo : ylList) { + dmYlInfo.set使用状态(3); + dmYlInfo.set切割日期(item.getQgfkrq()); + updateYlList.add(dmYlInfo); + } + } //生成零件信息 List ljList = zyjhService.createLj(item.getDcCh(), item.getDcPl(), item.getTzbh()); + //临时使用异常捕获,防止生产未更新余料库存表导致无法正常切割报工 + try { + //生成余料信息 + List _list = bchxylpService.list(Wrappers.lambdaQuery() + .eq(DmBchxylp::getDcCh, item.getDcCh()) + .eq(DmBchxylp::getTzbh, item.getTzbh()) + ); + + List ylList = _list.stream() + .filter(it -> StrUtil.isNotEmpty(it.getYlbh())) + .map(it -> DmYlInfo.of(it,item)) + .collect(Collectors.toList()); + ylInfoService.saveBatch(ylList); + }catch (Exception e){ + e.printStackTrace(); + } + //兼容老系统回报的数据 int count = mpDhsjServcie.count(Wrappers.lambdaQuery() .eq(MpDhsj::getDcCh,item.getDcCh()) @@ -375,11 +409,15 @@ public class ZyjhController { mpDhsj.setGysbh("BZGY-"+mpsycljljbp.get("gzzx3")); } collect.add(mpDhsj); + MpDhsjSaveList.add(mpDhsj); } } - mpDhsjServcie.saveBatch(collect); +// mpDhsjServcie.saveBatch(collect); } + mpDhsjServcie.saveBatch(MpDhsjSaveList); + ylInfoService.updateBatchById(updateYlList); } + zyjhService.updateBatchById(list); if (dto.getAudioFlag()){ diff --git a/src/main/java/com/dsic/gj_erp/controller/zyjh/dto/YlSlDto.java b/src/main/java/com/dsic/gj_erp/controller/zyjh/dto/YlSlDto.java new file mode 100644 index 0000000..69557e0 --- /dev/null +++ b/src/main/java/com/dsic/gj_erp/controller/zyjh/dto/YlSlDto.java @@ -0,0 +1,27 @@ +package com.dsic.gj_erp.controller.zyjh.dto; + +import cn.hutool.core.util.StrUtil; +import com.dsic.gj_erp.bean.zyjh.DmYlInfo; +import lombok.Getter; +import lombok.Setter; + +import java.util.List; + +@Getter +@Setter +public class YlSlDto { + + private String dcCh; + private String dcPl; + private String tzbh; + private String dw; + private String gg; + private String lph; + private int status; + + private List ylList; + + public boolean isAllow(){ + return StrUtil.isAllNotEmpty(dcCh,dcPl); + } +} diff --git a/src/main/java/com/dsic/gj_erp/mapper/zyjh/DmYlInfoMapper.java b/src/main/java/com/dsic/gj_erp/mapper/zyjh/DmYlInfoMapper.java new file mode 100644 index 0000000..d5f1ad5 --- /dev/null +++ b/src/main/java/com/dsic/gj_erp/mapper/zyjh/DmYlInfoMapper.java @@ -0,0 +1,7 @@ +package com.dsic.gj_erp.mapper.zyjh; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.dsic.gj_erp.bean.zyjh.DmYlInfo; + +public interface DmYlInfoMapper extends BaseMapper { +} diff --git a/src/main/java/com/dsic/gj_erp/service/zyjh/DmYlInfoService.java b/src/main/java/com/dsic/gj_erp/service/zyjh/DmYlInfoService.java new file mode 100644 index 0000000..74815e9 --- /dev/null +++ b/src/main/java/com/dsic/gj_erp/service/zyjh/DmYlInfoService.java @@ -0,0 +1,10 @@ +package com.dsic.gj_erp.service.zyjh; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.dsic.gj_erp.bean.zyjh.DmYlInfo; +import com.dsic.gj_erp.mapper.zyjh.DmYlInfoMapper; +import org.springframework.stereotype.Service; + +@Service +public class DmYlInfoService extends ServiceImpl { +} diff --git a/src/main/resources/mappers/zyjh/DmYlInfoMapper.xml b/src/main/resources/mappers/zyjh/DmYlInfoMapper.xml new file mode 100644 index 0000000..c332b1d --- /dev/null +++ b/src/main/resources/mappers/zyjh/DmYlInfoMapper.xml @@ -0,0 +1,5 @@ + + + + +