From 801ac0807d44c6c3d37de97cdea0161be6add59a Mon Sep 17 00:00:00 2001 From: "liang.chao" <1360241448@qq.com> Date: Tue, 16 Jul 2024 19:44:16 +0800 Subject: [PATCH] =?UTF-8?q?=E9=80=80=E6=96=99=E5=8F=AF=E9=80=89=E9=9C=80?= =?UTF-8?q?=E6=B1=82=E5=8F=98=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/controller/BackReceiveController.java | 19 ++- .../sgzb/app/mapper/BackReceiveMapper.java | 2 + .../service/impl/BackReceiveServiceImpl.java | 160 +++++++++--------- .../mapper/app/BackReceiveMapper.xml | 50 +++++- .../controller/BackApplyController.java | 6 - 5 files changed, 139 insertions(+), 98 deletions(-) diff --git a/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/app/controller/BackReceiveController.java b/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/app/controller/BackReceiveController.java index 0e5c20f7..6c23bc5d 100644 --- a/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/app/controller/BackReceiveController.java +++ b/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/app/controller/BackReceiveController.java @@ -118,13 +118,22 @@ public class BackReceiveController extends BaseController { @Log(title = "退料接收明细-web", businessType = BusinessType.QUERY) @PostMapping("/getReceiveViewWebNum") public AjaxResult getReceiveViewWebNum(@RequestBody BackApplyInfo record) { - List list = backReceiveService.receiveView(record); - for (BackApplyInfo backApplyInfo : list) { - if (Double.valueOf(backApplyInfo.getNum()).intValue() > 0) { - return AjaxResult.success(0); + int res = 0; + String[] split = record.getTypeId().split(","); + for (String s : split) { + record.setModelId(s); + List list = backReceiveService.receiveView(record); + for (BackApplyInfo backApplyInfo : list) { + if (Double.valueOf(backApplyInfo.getNum()).intValue() != 0) { + res++; + } } } - return AjaxResult.success(1); + if (res > 0) { + return AjaxResult.success(0); + } else { + return AjaxResult.success(1); + } } /** diff --git a/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/app/mapper/BackReceiveMapper.java b/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/app/mapper/BackReceiveMapper.java index f14fb269..89d6340d 100644 --- a/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/app/mapper/BackReceiveMapper.java +++ b/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/app/mapper/BackReceiveMapper.java @@ -31,6 +31,7 @@ public interface BackReceiveMapper { * @return List */ List receiveView(BackApplyInfo record); + List receiveView2(BackApplyInfo record); /** * 添加接收数据back_check_details @@ -207,4 +208,5 @@ public interface BackReceiveMapper { List getScrapBackMachine(TmTask task); + int updateStatus(BackApplyInfo record); } \ No newline at end of file diff --git a/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/app/service/impl/BackReceiveServiceImpl.java b/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/app/service/impl/BackReceiveServiceImpl.java index 02d4f39a..5dd77e58 100644 --- a/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/app/service/impl/BackReceiveServiceImpl.java +++ b/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/app/service/impl/BackReceiveServiceImpl.java @@ -13,8 +13,10 @@ import com.bonus.sgzb.common.core.enums.TaskTypeEnum; import com.bonus.sgzb.common.core.utils.DateUtils; import com.bonus.sgzb.common.core.utils.GlobalConstants; import com.bonus.sgzb.common.core.utils.StringHelper; +import com.bonus.sgzb.common.core.web.domain.AjaxResult; import com.bonus.sgzb.common.security.utils.SecurityUtils; import org.apache.commons.lang3.ObjectUtils; +import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -44,7 +46,7 @@ public class BackReceiveServiceImpl implements BackReceiveService { @Override public List getbackReceiveList(BackApplyInfo record) { List backApplyInfoList = backReceiveMapper.getbackReceiveList(record); - if (SecurityUtils.getLoginUser().getRoles().contains("admin")){ + if (SecurityUtils.getLoginUser().getRoles().contains("admin")) { return backApplyInfoList; } List backApplyInfos = new ArrayList<>(); @@ -65,32 +67,11 @@ public class BackReceiveServiceImpl implements BackReceiveService { @Override public List receiveView(BackApplyInfo record) { List backApplyInfoList = backReceiveMapper.receiveView(record); - //重庆成套设备处理(宁夏不用) - /* int count1 = 0; - int count2 = 0; - for (BackApplyInfo backApplyInfo : backApplyInfoList) { - if ("2".equals(backApplyInfo.getManageType())) { - List machineParts = new ArrayList<>(); - List typeIds = tmTaskMapper.getMaTypeDetailsByTypeId(backApplyInfo); - typeIds.removeIf(item -> item == null); - for (TmTask typeId : typeIds) { - MachinePart machinePart = tmTaskMapper.getMachineParts(typeId); - machinePart.setParentId(record.getId()); - int countMachineByPidAndTid = tmTaskMapper.getCountMachineByPidAndTid(machinePart); - Double machinePartNum = typeId.getPartNum() * Double.parseDouble(backApplyInfo.getPreNum()); - count1 += machinePartNum; - count2 += countMachineByPidAndTid; - machinePart.setPartNum(machinePartNum - countMachineByPidAndTid); - machineParts.add(machinePart); - } - backApplyInfo.setMaTypeDetails(machineParts); - if (count1 == count2) { - backApplyInfo.setPartNum(0); - } else { - backApplyInfo.setPartNum((int) Double.parseDouble(backApplyInfo.getPreNum())); - } - } - }*/ + return backApplyInfoList; + } + + public List receiveView2(BackApplyInfo record) { + List backApplyInfoList = backReceiveMapper.receiveView2(record); return backApplyInfoList; } @@ -114,6 +95,10 @@ public class BackReceiveServiceImpl implements BackReceiveService { return res; } + private int updateStatus(BackApplyInfo record) { + return backReceiveMapper.updateStatus(record); + } + private int updateTaskStatus(int taskId, int i) { int res; res = backReceiveMapper.updateTaskStatus(taskId, i); @@ -165,8 +150,7 @@ public class BackReceiveServiceImpl implements BackReceiveService { @Override @Transactional(rollbackFor = Exception.class) public int endBack(BackApplyInfo record) { - int res; -// try { + int res = 0; int taskId = record.getTaskId(); //先判断是否已经完成退料了 int taskStatus = selectTaskStatus(taskId); @@ -174,69 +158,81 @@ public class BackReceiveServiceImpl implements BackReceiveService { throw new RuntimeException("该退料单已完成退料"); } //修改任务状态 - res = updateTaskStatus(taskId, 40); + /* res = updateTaskStatus(taskId, 40); if (res == 0) { throw new RuntimeException("tm_task修改状态"); + }*/ + record.setId(record.getParentId()); + List list = receiveView2(record); + boolean allZeros = list.stream().allMatch(n -> Double.valueOf(n.getNum()).intValue() == 0); + if (allZeros) { + res = updateTaskStatus(taskId, 40); } //更加退料接收的数据创建下一步流程 //合格的插入入库记录input_apply_details,修改库存ma_type,修改机具状态 - List hgList = backReceiveMapper.getHgList(record); - if (hgList != null && hgList.size() > 0) { - res = insertIad(hgList); - if (res == 0) { - throw new RuntimeException("input_apply_details"); - } - // 如果是成套的机具,成套机具的库存也要添加 - List ctList = backReceiveMapper.getCtList(record); + if (StringUtils.isNotBlank(record.getTypeId())) { + for (String s : record.getTypeId().split(",")) { + record.setTypeId(s); + //修改back_apply_details为已退料(1) + res = updateStatus(record); + List hgList = backReceiveMapper.getHgList(record); + if (hgList != null && hgList.size() > 0) { + res = insertIad(hgList); + if (res == 0) { + throw new RuntimeException("input_apply_details"); + } + // 如果是成套的机具,成套机具的库存也要添加 + /* List ctList = backReceiveMapper.getCtList(record); if (ctList.size() > 0) { for (BackApplyInfo backApplyInfo : ctList) { if ("2".equals(backApplyInfo.getManageType())) { backReceiveMapper.updateMt(backApplyInfo); } } - } - res = updateMt(hgList); - if (res == 0) { - throw new RuntimeException("ma_type"); - } - res = updateMaStatus(hgList); - if (res == 0) { - throw new RuntimeException("ma_machines"); - } + }*/ + res = updateMt(hgList); + if (res == 0) { + throw new RuntimeException("ma_type"); + } + res = updateMaStatus(hgList); + if (res == 0) { + throw new RuntimeException("ma_machines"); + } - } - //维修的创建维修任务,插入任务协议表 - List wxList = backReceiveMapper.getWxList(record); - if (wxList != null && wxList.size() > 0) { - //插入任务表tm_task - int newTaskId = insertTt(wxList, TaskTypeEnum.MAINTENANCE_TASK.getCode(), record.getCreateBy()); - //插入协议任务表tm_task_agreement - res = insertTta(newTaskId, wxList); - //插入维修记录表repair_apply_details - res = insertRad(newTaskId, wxList); - } - //待报废的创建报废任务,插入任务协议表 + } + //维修的创建维修任务,插入任务协议表 + List wxList = backReceiveMapper.getWxList(record); + if (wxList != null && wxList.size() > 0) { + //插入任务表tm_task + int newTaskId = insertTt(wxList, TaskTypeEnum.MAINTENANCE_TASK.getCode(), record.getCreateBy()); + //插入协议任务表tm_task_agreement + res = insertTta(newTaskId, wxList); + //插入维修记录表repair_apply_details + res = insertRad(newTaskId, wxList); + } + //待报废的创建报废任务,插入任务协议表 - List bfList = backReceiveMapper.getBfList(record); - if (bfList != null && bfList.size() > 0) { - //插入任务表tm_task - int newTaskId = insertTt(bfList, TaskTypeEnum.RETURNED_MATERIALS_TO_BE_SCRAPPED.getCode(), record.getCreateBy()); - //插入协议任务表tm_task_agreement - res = insertTta(newTaskId, bfList); - //插入维修记录表scrap_apply_details - res = insertSad(newTaskId, bfList); - } - - List allList = backReceiveMapper.getAllList(record); - if (allList != null && allList.size() > 0) { - res = updateSlt(record, allList); - if (res == 0) { - throw new RuntimeException("该机具未被领料使用"); + List bfList = backReceiveMapper.getBfList(record); + if (bfList != null && bfList.size() > 0) { + //插入任务表tm_task + int newTaskId = insertTt(bfList, TaskTypeEnum.RETURNED_MATERIALS_TO_BE_SCRAPPED.getCode(), record.getCreateBy()); + //插入协议任务表tm_task_agreement + res = insertTta(newTaskId, bfList); + //插入维修记录表scrap_apply_details + res = insertSad(newTaskId, bfList); + } + // 结算功能 + List allList = backReceiveMapper.getAllList(record); + if (allList != null && allList.size() > 0) { + res = updateSlt(record, allList); + if (res == 0) { + throw new RuntimeException("该机具未被领料使用"); + } + } } + } else { + throw new RuntimeException("typeId为空"); } -// } catch (Exception e) { -// throw new RuntimeException(e.getMessage()); -// } return res; } @@ -249,6 +245,11 @@ public class BackReceiveServiceImpl implements BackReceiveService { } } + @Override + public List codeQuery(BackApplyInfo record) { + return backReceiveMapper.codeQuery(record); + } + private int updateSlt(BackApplyInfo record, List hgList) { for (BackApplyInfo bean : hgList) { List infoList = backReceiveMapper.getStlInfo(bean); @@ -276,11 +277,6 @@ public class BackReceiveServiceImpl implements BackReceiveService { return 1; } - @Override - public List codeQuery(BackApplyInfo record) { - return backReceiveMapper.codeQuery(record); - } - @Override public List qrcodeQuery(BackApplyInfo record) { return backReceiveMapper.qrcodeQuery(record); diff --git a/sgzb-modules/sgzb-base/src/main/resources/mapper/app/BackReceiveMapper.xml b/sgzb-modules/sgzb-base/src/main/resources/mapper/app/BackReceiveMapper.xml index 84bbf14f..2bd13d6d 100644 --- a/sgzb-modules/sgzb-base/src/main/resources/mapper/app/BackReceiveMapper.xml +++ b/sgzb-modules/sgzb-base/src/main/resources/mapper/app/BackReceiveMapper.xml @@ -614,6 +614,9 @@ status = '1' where id = #{info.id} + + update back_apply_details set back_status = 1 where parent_id = #{parentId} and type_id = #{typeId} + delete from back_check_details where parent_id = #{parentId} and type_id = #{typeId} @@ -658,7 +661,7 @@ LEFT JOIN sys_dic sd ON sd.id = tt.task_status LEFT JOIN tm_task tt1 on tt1.task_id = bai.parent_id WHERE - tt.task_status IN ( 37, 38, 39, 40 ) + tt.task_status IN ( 38, 39, 40 ) and bai.code like concat('%', #{keyWord}, '%') @@ -708,6 +711,7 @@ mt2.type_name AS typeName, bad.audit_num as preNum, bad.status as status, + bad.back_status as backStatus, IFNULL(bad.audit_num,0)-IFNULL(aa.back_num,0) as num, mt.manage_type as manageType, CONCAT('NSJJ',mt.`code`,mt.model_code) as `code` @@ -757,7 +761,7 @@ LEFT JOIN back_apply_info bai on bai.id=bcd.parent_id LEFT JOIN tm_task_agreement tta on tta.task_id=bai.task_id WHERE - bcd.parent_id=#{parentId} + bcd.parent_id=#{parentId} and bcd.type_id=#{typeId} and bcd.back_status='1' @@ -777,7 +781,7 @@ LEFT JOIN back_apply_info bai on bai.id=bcd.parent_id LEFT JOIN tm_task_agreement tta on tta.task_id=bai.task_id WHERE - bcd.parent_id=#{parentId} + bcd.parent_id=#{parentId} and bcd.type_id=#{typeId} and bcd.back_status='2' @@ -800,7 +804,7 @@ LEFT JOIN back_apply_info bai on bai.id=bcd.parent_id LEFT JOIN tm_task_agreement tta on tta.task_id=bai.task_id WHERE - bcd.parent_id=#{parentId} + bcd.parent_id=#{parentId} and bcd.type_id=#{typeId} and bcd.back_status='3' @@ -932,7 +936,7 @@ LEFT JOIN back_apply_info bai ON bai.id = bcd.parent_id LEFT JOIN tm_task_agreement tta ON tta.task_id = bai.task_id WHERE - bcd.parent_id = #{parentId} + bcd.parent_id = #{parentId} and bcd.type_id=#{typeId} GROUP By bcd.type_id,bcd.ma_id + \ No newline at end of file diff --git a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/controller/BackApplyController.java b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/controller/BackApplyController.java index 60bf20d1..9c5fa296 100644 --- a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/controller/BackApplyController.java +++ b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/controller/BackApplyController.java @@ -60,12 +60,6 @@ public class BackApplyController extends BaseController { return AjaxResult.success(ListPagingUtil.paging(pageIndex, pageSize, list)); } - /* @ApiOperation(value = "退料申请获取当前类型在用量") - @GetMapping("/getUseNumByTypeId") - public AjaxResult getUseNumByTypeId(String typeId) { - return AjaxResult.success(backApplyService.getUseNumByTypeId(typeId)); - }*/ - @ApiOperation(value = "在用设备类型树") @PostMapping("/getUseTypeTree") public AjaxResult getUseTypeTree(@RequestBody BackApplyInfo bean) {