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..b7d9dda 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 @@ -350,11 +350,24 @@ public class DmYdjhLj implements Serializable { 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().equals(this.ljbh); + } } 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..20f5056 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,36 @@ 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()); + //质量跟踪数据 + 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); + } + } + } + /** * 作业计划执行,派工&反馈 */ @@ -365,8 +395,6 @@ public class ZyjhController { updateYlList.add(dmYlInfo); } } - //生成零件信息 - List ljList = zyjhService.createLj(item.getDcCh(), item.getDcPl(), item.getTzbh()); //临时使用异常捕获,防止生产未更新余料库存表导致无法正常切割报工 try { @@ -396,24 +424,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/zyjh/ZyjhService.java b/src/main/java/com/dsic/gj_erp/service/zyjh/ZyjhService.java index 5dda61d..d8430fa 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,30 @@ 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->{ + 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; }