diff --git a/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/service/countadjustPlan/CountadjustPlanServiceImpl.java b/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/service/countadjustPlan/CountadjustPlanServiceImpl.java index 8db1f3e..61c922d 100644 --- a/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/service/countadjustPlan/CountadjustPlanServiceImpl.java +++ b/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/service/countadjustPlan/CountadjustPlanServiceImpl.java @@ -8,12 +8,20 @@ import com.win.module.eam.controller.countadjustPlan.vo.CountadjustPlanExportReq import com.win.module.eam.controller.countadjustPlan.vo.CountadjustPlanPageReqVO; import com.win.module.eam.controller.countadjustPlan.vo.CountadjustPlanUpdateReqVO; import com.win.module.eam.convert.countadjustPlan.CountadjustPlanConvert; +import com.win.module.eam.dal.dataobject.adjustRecord.AdjustRecordDetailDO; +import com.win.module.eam.dal.dataobject.adjustRecord.AdjustRecordMainDO; import com.win.module.eam.dal.dataobject.countJobDetail.CountJobDetailDO; import com.win.module.eam.dal.dataobject.countJobMain.CountJobMainDO; +import com.win.module.eam.dal.dataobject.countRecord.CountRecordDetailDO; +import com.win.module.eam.dal.dataobject.countRecord.CountRecordMainDO; import com.win.module.eam.dal.dataobject.countadjustPlan.CountadjustPlanDO; import com.win.module.eam.dal.dataobject.itemaccounts.ItemAccountsDO; +import com.win.module.eam.dal.mysql.adjustRecord.AdjustRecordDetailMapper; +import com.win.module.eam.dal.mysql.adjustRecord.AdjustRecordMainMapper; import com.win.module.eam.dal.mysql.countJobMain.CountJobDetailMapper; import com.win.module.eam.dal.mysql.countJobMain.CountJobMainMapper; +import com.win.module.eam.dal.mysql.countRecord.CountRecordDetailMapper; +import com.win.module.eam.dal.mysql.countRecord.CountRecordMainMapper; import com.win.module.eam.dal.mysql.countadjustPlan.CountadjustPlanMapper; import com.win.module.eam.dal.mysql.itemaccounts.ItemAccountsMapper; import com.win.module.eam.enums.basic.BooleanTypeEnum; @@ -49,6 +57,17 @@ public class CountadjustPlanServiceImpl implements CountadjustPlanService { @Resource private SerialNumberApi serialNumberApi; + @Resource + private CountRecordMainMapper countRecordMainMapper; + @Resource + private CountRecordDetailMapper countRecordDetailMapper; + + @Resource + private AdjustRecordMainMapper adjustRecordMainMapper; + @Resource + private AdjustRecordDetailMapper adjustRecordDetailMapper; + + @Override @Transactional(rollbackFor = Exception.class) public Long createCountadjustPlan(CountadjustPlanCreateReqVO createReqVO) { @@ -94,9 +113,50 @@ public class CountadjustPlanServiceImpl implements CountadjustPlanService { } @Override + @Transactional public Integer deleteCountadjustPlan(Long id) { // 校验存在 - validateCountadjustPlanExists(id); + CountadjustPlanDO countadjustPlanDO = countadjustPlanMapper.selectById(id); + if (countadjustPlanDO == null) { + throw exception(COUNTADJUST_PLAN_NOT_EXISTS); + } + QueryWrapper jobMainDO = new QueryWrapper<>(); + jobMainDO.eq("number",countadjustPlanDO.getNumber()); + CountJobMainDO countJobMainDO = countJobMainMapper.selectOne(jobMainDO);//盘点工单主 + if(countJobMainDO!=null){//有关联删除 + countJobMainMapper.deleteById(countJobMainDO.getId());//删除关联工单 + QueryWrapper jobDetailsDO = new QueryWrapper<>(); + jobDetailsDO.eq("master_id",countJobMainDO.getId()); + List countJobDetailDOS = countJobDetailMapper.selectList(jobDetailsDO);//盘点工单子 + for(CountJobDetailDO en:countJobDetailDOS){//删除工单子表 + countJobDetailMapper.deleteById(en.getId()); + } + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("job_number",countJobMainDO.getNumber()); + CountRecordMainDO countRecordMainDO = countRecordMainMapper.selectOne(queryWrapper);//盘点记录主 + if(countRecordMainDO!=null){//盘点记录 + countRecordMainMapper.deleteById(countRecordMainDO.getId()); + QueryWrapper queryWrapper1 = new QueryWrapper<>(); + queryWrapper1.eq("master_id",countJobMainDO.getId()); + List countRecordDetailDOS = countRecordDetailMapper.selectList(queryWrapper1);//盘点记录子 + for(CountRecordDetailDO en:countRecordDetailDOS){ + countRecordDetailMapper.deleteById(en.getId()); + } + } + QueryWrapper queryAdjustMain = new QueryWrapper<>(); + queryAdjustMain.eq("plan_number",countadjustPlanDO.getNumber()); + AdjustRecordMainDO adjustRecordMainDO = adjustRecordMainMapper.selectOne(queryAdjustMain);//盘点调整记录主 + if(adjustRecordMainDO!=null){ + adjustRecordMainMapper.deleteById(adjustRecordMainDO.getId()); + QueryWrapper queryAdjustDetails = new QueryWrapper<>(); + queryAdjustDetails.eq("master_id",adjustRecordMainDO.getId()); + List adjustRecordDetailDOS = adjustRecordDetailMapper.selectList(queryAdjustDetails);//盘点调整记录子 + for(AdjustRecordDetailDO en:adjustRecordDetailDOS){ + adjustRecordDetailMapper.deleteById(en.getId()); + } + } + + } // 删除 return countadjustPlanMapper.deleteById(id); }