diff --git a/src/main/java/com/dsic/gj_erp/bean/jhgk/DmYdjhLj.java b/src/main/java/com/dsic/gj_erp/bean/jhgk/DmYdjhLj.java index 971273f..0188383 100644 --- a/src/main/java/com/dsic/gj_erp/bean/jhgk/DmYdjhLj.java +++ b/src/main/java/com/dsic/gj_erp/bean/jhgk/DmYdjhLj.java @@ -345,16 +345,32 @@ public class DmYdjhLj implements Serializable { private String ypph; @TableField(exist = false) private String yzkw; + @TableField(exist = false) + private String sllph; public boolean checkZt(){ return !"03".equals(this.pkZt)||!"03".equals(this.qjgZt)||!"03".equals(this.dmZt); } + //报工检测 + public boolean checkZtBg(){ + return "03".equals(this.pkZt)||"03".equals(this.qjgZt)||"03".equals(this.dmZt); + } + public void updateZtWithDb(DmYdjhLj dbLj){ + this.setId(dbLj.getId()); + this.setDmZt(dbLj.getDmZt()); + this.setPkZt(dbLj.getPkZt()); + this.setQjgZt(dbLj.getQjgZt()); + this.setPpzt(dbLj.getPpzt()); + } - - - - + public boolean tmpEq(DmYdjhLj lj){ + return lj.getCzbh().equals(this.czbh) + &&lj.getPl().equals(this.pl) + &&lj.getTlth().equals(this.tlth) + &&lj.getLjbh()!=null + &&lj.getLjbh().equals(this.ljbh); + } } diff --git a/src/main/java/com/dsic/gj_erp/controller/jhgk/DmYdjhController.java b/src/main/java/com/dsic/gj_erp/controller/jhgk/DmYdjhController.java index 121d215..7e1fcb1 100644 --- a/src/main/java/com/dsic/gj_erp/controller/jhgk/DmYdjhController.java +++ b/src/main/java/com/dsic/gj_erp/controller/jhgk/DmYdjhController.java @@ -110,7 +110,7 @@ public class DmYdjhController { List list= service.list(new QueryWrapper() .eq(StrUtil.isNotEmpty(map.get("dcCh")),"dc_ch",map.get("dcCh")) .ge(StrUtil.isNotEmpty(map.get("zt")),"zt",map.get("zt")) - .lt("zt","61") + .lt("zt",11)//仅可下发未上料打印的计划 .ge(StrUtil.isNotEmpty(map.get("yf")), "jssj", DateUtil.beginOfMonth(DateUtil.parseDate(map.get("yf"))).toString("yyyy/MM/dd")) .le(StrUtil.isNotEmpty(map.get("yf")), "jssj", DateUtil.endOfMonth(DateUtil.parseDate(map.get("yf"))).toString("yyyy/MM/dd")) .orderByAsc("jssj,dc_ch,dc_pl,zl,lqlb") 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 e7930e2..267b053 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 @@ -291,6 +291,43 @@ public class ZyjhController { return new ResultBean<>(); } + @PostMapping("sdtbczzj") + public ResultBean sdTbCzzj(@RequestBody List list){ + ArrayList mpDhsjSaveList = new ArrayList<>(); + list.forEach(item-> zlgzCreate(item,mpDhsjSaveList)); + mpDhsjServcie.saveBatch(mpDhsjSaveList); + return new ResultBean<>(); + } + + private void zlgzCreate(DmYdjh item,ArrayList mpDhsjSaveList){ + List ljList = zyjhService.createLj(item.getDcCh(), item.getDcPl(), item.getTzbh()); + Map mpsycljljbp = zyjhService.getMPSYCLJLJBP(item.getDcCh(), item.getTzbh()); + //兼容手动处理没有上料炉批号的问题 + if (StrUtil.isEmpty(item.getSllph())&&!ljList.isEmpty()){ + item.setSllph(ljList.get(0).getSllph()); + } + mpDhsjServcie.remove(Wrappers.lambdaQuery() + .eq(MpDhsj::getDcCh,item.getDcCh()) + .eq(MpDhsj::getDcPl,item.getDcPl()) + .eq(MpDhsj::getDcTh,item.getTzbh()) + ); + //质量跟踪数据 + String date = DateUtil.date().toString("yyyy/MM/dd"); + String mpDhsjDhh = zyjhService.getMpDhsjDhh(); + for (int j = 0; j < ljList.size(); j++) { + DmYdjhLj item2 = ljList.get(j); + if (StrUtil.isNotEmpty(item.getSllph())){//兼容没有炉批号的老数据用 + MpDhsj mpDhsj = MpDhsj.of(item2, date, item.getSllph()); + String xh = StrUtil.padPre(j + 1 + "", 3, "0"); + mpDhsj.setDhh(mpDhsjDhh+"-"+xh); + if (ObjUtil.isNotEmpty(mpsycljljbp)) { + mpDhsj.setGysbh("BZGY-"+mpsycljljbp.get("gzzx3")); + } + mpDhsjSaveList.add(mpDhsj); + } + } + } + /** * 作业计划执行,派工&反馈 */ @@ -365,8 +402,6 @@ public class ZyjhController { updateYlList.add(dmYlInfo); } } - //生成零件信息 - List ljList = zyjhService.createLj(item.getDcCh(), item.getDcPl(), item.getTzbh()); //临时使用异常捕获,防止生产未更新余料库存表导致无法正常切割报工 try { @@ -396,24 +431,8 @@ public class ZyjhController { continue; } - Map mpsycljljbp = zyjhService.getMPSYCLJLJBP(item.getDcCh(), item.getTzbh()); //质量跟踪数据 - List collect = new ArrayList<>(); - String date = DateUtil.date().toString("yyyy/MM/dd"); - String mpDhsjDhh = zyjhService.getMpDhsjDhh(); - for (int j = 0; j < ljList.size(); j++) { - DmYdjhLj item2 = ljList.get(j); - if (StrUtil.isNotEmpty(item.getSllph())){//兼容没有炉批号的老数据用 - MpDhsj mpDhsj = MpDhsj.of(item2, date, item.getSllph()); - String xh = StrUtil.padPre(j + 1 + "", 3, "0"); - mpDhsj.setDhh(mpDhsjDhh+"-"+xh); - if (ObjUtil.isNotEmpty(mpsycljljbp)) { - mpDhsj.setGysbh("BZGY-"+mpsycljljbp.get("gzzx3")); - } - collect.add(mpDhsj); - MpDhsjSaveList.add(mpDhsj); - } - } + zlgzCreate(item,MpDhsjSaveList); } mpDhsjServcie.saveBatch(MpDhsjSaveList); diff --git a/src/main/java/com/dsic/gj_erp/service/jhgk/impl/DmYdjhServiceImpl.java b/src/main/java/com/dsic/gj_erp/service/jhgk/impl/DmYdjhServiceImpl.java index 3f3f4ef..934254e 100644 --- a/src/main/java/com/dsic/gj_erp/service/jhgk/impl/DmYdjhServiceImpl.java +++ b/src/main/java/com/dsic/gj_erp/service/jhgk/impl/DmYdjhServiceImpl.java @@ -324,9 +324,9 @@ public class DmYdjhServiceImpl extends ServiceImpl impleme DmYdjh dmYdjh = new DmYdjh(); dmYdjh.setId(item.getId()); dmYdjh.setZt("2"); - String perfix=item.getSljhrq().replace("/",""); - perfix=perfix.substring(2); - dmYdjh.setDjh(StrUtil.format("{}{}",perfix, String.format("%03d",djh))); + //String perfix=item.getSljhrq().replace("/",""); + //perfix=perfix.substring(2); + //dmYdjh.setDjh(StrUtil.format("{}{}",perfix, String.format("%03d",djh))); dmYdjh.setGxsj(gxsj); dmYdjh.setPlxh(item.getPlxh()); return dmYdjh; diff --git a/src/main/java/com/dsic/gj_erp/service/zyjh/ZyjhService.java b/src/main/java/com/dsic/gj_erp/service/zyjh/ZyjhService.java index 5dda61d..5c36377 100644 --- a/src/main/java/com/dsic/gj_erp/service/zyjh/ZyjhService.java +++ b/src/main/java/com/dsic/gj_erp/service/zyjh/ZyjhService.java @@ -33,7 +33,6 @@ import org.springframework.transaction.annotation.Transactional; import java.io.File; import java.util.List; import java.util.Map; -import java.util.regex.Pattern; import java.util.stream.Collectors; @Service @@ -175,12 +174,35 @@ public class ZyjhService extends ServiceImpl { } }); - ljService.remove(Wrappers.lambdaQuery() - .eq(DmYdjhLj::getCzbh,dcCh) - .eq(DmYdjhLj::getPl,dcPl) - .eq(DmYdjhLj::getTlth,tzbh) + //如果零件已报工,不可以删除,取消整图删除零件,改为修正 + List list = ljService.list(Wrappers.lambdaQuery() + .eq(DmYdjhLj::getCzbh, dcCh) + .eq(DmYdjhLj::getPl, dcPl) + .eq(DmYdjhLj::getTlth, tzbh) ); - ljService.saveBatch(ljInfo); + if (!list.isEmpty()){ + list.forEach(item->{ + //清理错误数据 + if (StrUtil.isEmpty(item.getLjbh())){ + ljService.removeById(item); + return; + } + ljInfo.forEach(lj->{ + if (lj.tmpEq(item)){ + //修正零件状态信息 + lj.updateZtWithDb(item); + } + }); + }); + ljService.saveOrUpdateBatch(ljInfo); + }else{ + ljService.remove(Wrappers.lambdaQuery() + .eq(DmYdjhLj::getCzbh,dcCh) + .eq(DmYdjhLj::getPl,dcPl) + .eq(DmYdjhLj::getTlth,tzbh) + ); + ljService.saveBatch(ljInfo); + } return ljInfo; } diff --git a/src/main/resources/mappers/jhgk/DmYdjhMapper.xml b/src/main/resources/mappers/jhgk/DmYdjhMapper.xml index 69076e7..f5af4e6 100644 --- a/src/main/resources/mappers/jhgk/DmYdjhMapper.xml +++ b/src/main/resources/mappers/jhgk/DmYdjhMapper.xml @@ -902,6 +902,7 @@ REPLACE(CAST(CAST(NEWID()AS BINARY(10)) + CAST(GETDATE() AS BINARY(6)) AS UNIQUEIDENTIFIER),'-','') as id, dm_ydjh.dc_ch as czbh, dm_ydjh.dc_pl as pl, + dm_ydjh.sllph as sllph, dm_bom.fd as fd, dm_ydjh.kw as kw, dm_bom.zl as zl,