diff --git a/bonus-common-biz/src/main/java/com/bonus/common/biz/domain/TypeTreeNode.java b/bonus-common-biz/src/main/java/com/bonus/common/biz/domain/TypeTreeNode.java index 5f5e443d..f351e603 100644 --- a/bonus-common-biz/src/main/java/com/bonus/common/biz/domain/TypeTreeNode.java +++ b/bonus-common-biz/src/main/java/com/bonus/common/biz/domain/TypeTreeNode.java @@ -32,6 +32,8 @@ public class TypeTreeNode { @JsonInclude(JsonInclude.Include.NON_EMPTY) private String typeName; + private String materialName; + @JsonInclude(JsonInclude.Include.NON_EMPTY) private List children = new ArrayList<>(); } diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/back/controller/BackApplyInfoController.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/back/controller/BackApplyInfoController.java index 58e53773..880646a8 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/back/controller/BackApplyInfoController.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/back/controller/BackApplyInfoController.java @@ -5,6 +5,8 @@ import javax.servlet.http.HttpServletResponse; import javax.validation.Valid; import com.bonus.common.log.enums.OperaType; +import com.bonus.material.back.domain.MaCode; +import com.bonus.material.back.domain.vo.BackAppRequestVo; import com.bonus.material.back.domain.vo.BackApplyRequestVo; import com.bonus.material.common.annotation.PreventRepeatSubmit; import io.swagger.annotations.Api; @@ -52,13 +54,29 @@ public class BackApplyInfoController extends BaseController { return getDataTable(list); } - + /** + * 根据单位和工程id查询领料机具 + * @param dto + * @return + */ @ApiOperation(value = "根据单位和工程id查询领料机具") @GetMapping("/getMachineById") public AjaxResult getMachineById(BackApplyInfo dto){ return backApplyInfoService.getMachineById(dto); } + /** + * app根据设备编码去检索领料详情 + * @param dto + * @return + */ + @ApiOperation(value = "app编码检索") + @RequiresPermissions("back:info:list") + @GetMapping("/getMachine") + public AjaxResult getMachine(BackApplyInfo dto){ + return backApplyInfoService.getMachine(dto); + } + /** * 导出退料任务列表 */ @@ -110,7 +128,7 @@ public class BackApplyInfoController extends BaseController { @RequiresPermissions("back:info:add") @SysLog(title = "退料任务", businessType = OperaType.INSERT, logType = 1,module = "仓储管理->新增退料任务app") @PostMapping("/insertApp") - public AjaxResult insertApp(@RequestBody BackApplyRequestVo dto) { + public AjaxResult insertApp(@RequestBody BackAppRequestVo dto) { try { return backApplyInfoService.insertApp(dto); } catch (Exception e) { @@ -170,9 +188,9 @@ public class BackApplyInfoController extends BaseController { @PreventRepeatSubmit @RequiresPermissions("back:info:remove") @SysLog(title = "退料任务", businessType = OperaType.DELETE, logType = 1,module = "仓储管理->删除退料任务") - @DeleteMapping("/{id}") - public AjaxResult remove(@PathVariable Long id) { - return backApplyInfoService.deleteBackApplyInfoById(id); + @PostMapping("/deleteById") + public AjaxResult remove(@RequestBody BackApplyInfo backApplyInfo) { + return backApplyInfoService.deleteBackApplyInfoById(backApplyInfo.getId()); } /** @@ -186,4 +204,26 @@ public class BackApplyInfoController extends BaseController { public AjaxResult delete(@RequestBody BackApplyInfo backApplyInfo) { return backApplyInfoService.delete(backApplyInfo); } + + @ApiOperation(value = "app查询单个类型设备编码") + @RequiresPermissions("back:info:list") + @SysLog(title = "退料任务", businessType = OperaType.QUERY, logType = 1,module = "仓储管理->app查询单个类型设备编码") + @GetMapping("/getMaCodeList") + public AjaxResult getMaCodeList(BackApplyInfo backApplyInfo) { + return backApplyInfoService.getMaCodeList(backApplyInfo); + } + + /** + * app编码查看保存 + * @param maCode + * @return + */ + @ApiOperation(value = "app编码查看保存") + @PreventRepeatSubmit + @RequiresPermissions("back:info:update") + @SysLog(title = "退料任务", businessType = OperaType.UPDATE, logType = 1,module = "仓储管理->删除退料任务") + @PostMapping("/updateMaCode") + public AjaxResult updateMaCode(@RequestBody MaCode maCode) { + return backApplyInfoService.updateMaCode(maCode); + } } diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/back/domain/BackApplyDetails.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/back/domain/BackApplyDetails.java index faee7159..f4f63114 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/back/domain/BackApplyDetails.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/back/domain/BackApplyDetails.java @@ -58,6 +58,16 @@ public class BackApplyDetails extends BaseEntity { @ApiModelProperty(value = "管理方式(0编号 1计数)") private String manageType; + /** + * 机具编码 + */ + @ApiModelProperty(value = "机具编码") + private String maCode; + + private String materialName; + + private String maStatus; + /** * 机具编码集合(可能存在多个,数据库存储用逗号分割) */ diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/back/domain/BackApplyInfo.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/back/domain/BackApplyInfo.java index 44fe921b..29391ce5 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/back/domain/BackApplyInfo.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/back/domain/BackApplyInfo.java @@ -153,4 +153,7 @@ public class BackApplyInfo { @ApiModelProperty(value="关键字") private String keyWord; + + @ApiModelProperty(value="设备编码") + private String maCode; } diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/back/domain/MaCode.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/back/domain/MaCode.java new file mode 100644 index 00000000..61483301 --- /dev/null +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/back/domain/MaCode.java @@ -0,0 +1,18 @@ +package com.bonus.material.back.domain; + +import lombok.Data; + +import java.util.List; + +/** + * @Author ma_sh + * @create 2024/11/21 17:14 + */ +@Data +public class MaCode { + + /** + * 编码设备列表传参 + */ + private List maCodeDtoList; +} diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/back/domain/MaCodeDto.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/back/domain/MaCodeDto.java index c337d2c3..a30e7864 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/back/domain/MaCodeDto.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/back/domain/MaCodeDto.java @@ -1,5 +1,6 @@ package com.bonus.material.back.domain; +import com.bonus.common.core.web.domain.BaseEntity; import com.bonus.material.basic.domain.BmFileInfo; import io.swagger.annotations.ApiModelProperty; import lombok.Data; @@ -12,11 +13,16 @@ import java.util.List; * @create 2024/11/11 15:57 */ @Data -public class MaCodeDto { +public class MaCodeDto extends BaseEntity { + + @ApiModelProperty(value = "主键id") + private Long id; @ApiModelProperty(value = "机具id") private Long maId; + private Long parentId; + /** * 机具编码 */ diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/back/domain/vo/BackAppRequestVo.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/back/domain/vo/BackAppRequestVo.java new file mode 100644 index 00000000..f847abc9 --- /dev/null +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/back/domain/vo/BackAppRequestVo.java @@ -0,0 +1,32 @@ +package com.bonus.material.back.domain.vo; + +import com.bonus.material.back.domain.BackApplyDetails; +import com.bonus.material.back.domain.BackApplyInfo; +import lombok.Data; + +import javax.validation.Valid; +import java.util.List; + +/** + * 退料申请请求参数 + * @Author ma_sh + * @create 2024/11/11 15:32 + */ +@Data +public class BackAppRequestVo { + + /** + * 退料申请信息 + */ + private BackApplyInfo backApplyInfo; + + /** + * 编码退料申请明细 + */ + private BackApplyDetails backApplyDetails; + + /** + * 数量退料申请明细 + */ + private List backApplyDetailsList; +} diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/back/domain/vo/MaCodeVo.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/back/domain/vo/MaCodeVo.java index a17cd8bf..4c06d529 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/back/domain/vo/MaCodeVo.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/back/domain/vo/MaCodeVo.java @@ -16,6 +16,8 @@ public class MaCodeVo { private String maStatus; + private String maStatusName; + private String typeId; @ApiModelProperty(value = "物资类型") diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/back/mapper/BackApplyInfoMapper.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/back/mapper/BackApplyInfoMapper.java index 3996f451..932220a4 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/back/mapper/BackApplyInfoMapper.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/back/mapper/BackApplyInfoMapper.java @@ -5,6 +5,7 @@ import java.util.List; import com.bonus.material.back.domain.BackApplyDetails; import com.bonus.material.back.domain.BackApplyInfo; +import com.bonus.material.back.domain.MaCodeDto; import com.bonus.material.back.domain.vo.MaCodeVo; import com.bonus.material.settlement.domain.SltAgreementInfo; import org.apache.ibatis.annotations.Param; @@ -225,4 +226,60 @@ public interface BackApplyInfoMapper { * @return */ int deleteDetails(BackApplyInfo backApplyInfo); + + /** + * 查询机具 + * @param dto + * @return + */ + List getMachine(BackApplyInfo dto); + + /** + * 查询机具数量 + * @param dto + * @return + */ + Integer getNum(BackApplyInfo dto); + + /** + * 查询详情 + * @param details + * @return + */ + BackApplyDetails selectBackApplyDetailsById(BackApplyDetails details); + + /** + * 更新详情 + * @param details + * @return + */ + int updateDetails(BackApplyDetails details); + + /** + * 查询机具详情 + * @param details + * @return + */ + BackApplyDetails selectCheckDetails(BackApplyDetails details); + + /** + * 更新机具详情 + * @param checkDetails + * @return + */ + int updateCheck(BackApplyDetails checkDetails); + + /** + * 根据类型查询机具 + * @param backApplyInfo + * @return + */ + List selectByTypeId(BackApplyInfo backApplyInfo); + + /** + * 更新机具外观状态 + * @param maCodeDto + * @return + */ + int updateMaCode(MaCodeDto maCodeDto); } diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/back/service/IBackApplyInfoService.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/back/service/IBackApplyInfoService.java index 4d95fd5c..352940d0 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/back/service/IBackApplyInfoService.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/back/service/IBackApplyInfoService.java @@ -4,6 +4,8 @@ import java.util.List; import com.bonus.common.core.web.domain.AjaxResult; import com.bonus.material.back.domain.BackApplyInfo; +import com.bonus.material.back.domain.MaCode; +import com.bonus.material.back.domain.vo.BackAppRequestVo; import com.bonus.material.back.domain.vo.BackApplyRequestVo; /** @@ -79,7 +81,7 @@ public interface IBackApplyInfoService { * @param dto * @return */ - AjaxResult insertApp(BackApplyRequestVo dto); + AjaxResult insertApp(BackAppRequestVo dto); /** * app内层删除退料任务 @@ -87,4 +89,25 @@ public interface IBackApplyInfoService { * @return */ AjaxResult delete(BackApplyInfo backApplyInfo); + + /** + * app编码检索 + * @param dto + * @return + */ + AjaxResult getMachine(BackApplyInfo dto); + + /** + * app查询单个类型设备编码 + * @param backApplyInfo + * @return + */ + AjaxResult getMaCodeList(BackApplyInfo backApplyInfo); + + /** + * app编码查看保存 + * @param maCode + * @return + */ + AjaxResult updateMaCode(MaCode maCode); } diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/back/service/impl/BackApplyInfoServiceImpl.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/back/service/impl/BackApplyInfoServiceImpl.java index efef9664..ed6bb4c5 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/back/service/impl/BackApplyInfoServiceImpl.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/back/service/impl/BackApplyInfoServiceImpl.java @@ -8,6 +8,7 @@ import cn.hutool.core.util.PhoneUtil; import com.alibaba.nacos.common.utils.CollectionUtils; import com.bonus.common.biz.enums.BackTaskStatusEnum; import com.bonus.common.biz.enums.HttpCodeEnum; +import com.bonus.common.biz.enums.MaMachineStatusEnum; import com.bonus.common.biz.enums.TmTaskTypeEnum; import com.bonus.common.core.exception.ServiceException; import com.bonus.common.core.utils.DateUtils; @@ -15,11 +16,15 @@ import com.bonus.common.core.utils.StringUtils; import com.bonus.common.core.web.domain.AjaxResult; import com.bonus.common.security.utils.SecurityUtils; import com.bonus.material.back.domain.BackApplyDetails; +import com.bonus.material.back.domain.MaCode; import com.bonus.material.back.domain.MaCodeDto; +import com.bonus.material.back.domain.vo.BackAppRequestVo; import com.bonus.material.back.domain.vo.BackApplyRequestVo; import com.bonus.material.back.domain.vo.MaCodeVo; import com.bonus.material.basic.domain.BmFileInfo; import com.bonus.material.basic.mapper.BmFileInfoMapper; +import com.bonus.material.ma.mapper.MachineMapper; +import com.bonus.material.purchase.config.RemoteConfig; import com.bonus.material.settlement.domain.SltAgreementInfo; import com.bonus.material.task.domain.TmTask; import com.bonus.material.task.domain.TmTaskAgreement; @@ -56,6 +61,12 @@ public class BackApplyInfoServiceImpl implements IBackApplyInfoService { @Resource private TmTaskAgreementMapper taskAgreementMapper; + @Resource + private MachineMapper machineMapper; + + @Resource + private RemoteConfig remoteConfig; + /** * 查询退料任务 * @@ -138,8 +149,9 @@ public class BackApplyInfoServiceImpl implements IBackApplyInfoService { * @param maCodeList */ private void setMaCodeDetails(BackApplyDetails details, List maCodeList) { + List codeVos = maCodeList.stream().filter(maCodeVo -> StringUtils.isNotBlank(maCodeVo.getMaCode())).collect(Collectors.toList()); List maCodeDtos = new ArrayList<>(); - for (MaCodeVo maCodeVo : maCodeList) { + for (MaCodeVo maCodeVo : codeVos) { MaCodeDto maCodeDto = new MaCodeDto(); maCodeDto.setMaCode(maCodeVo.getMaCode()); maCodeDto.setMaId(maCodeVo.getMaId()); @@ -228,7 +240,7 @@ public class BackApplyInfoServiceImpl implements IBackApplyInfoService { for (BackApplyDetails backApplyDetails : dto.getBackApplyDetailsList()) { if (backApplyDetails.getNum() != null && backApplyDetails.getPreNum() != null) { if (backApplyDetails.getNum() < backApplyDetails.getPreNum()) { - return AjaxResult.error("退料数量不能大于预退数量,请重新填写!"); + return AjaxResult.error(backApplyDetails.getTypeName() + "退料数量不能大于预退数量,请重新填写!"); } } } @@ -331,6 +343,8 @@ public class BackApplyInfoServiceImpl implements IBackApplyInfoService { details.setApDetection(maCodeDto.getApDetection()); // 插入 CheckDetails result += backApplyInfoMapper.insertCheckDetails(details); + //更新ma_machine表状态为3(退料检修) + result += machineMapper.updateStatus(maCodeDto.getMaId(), MaMachineStatusEnum.BACK_REPAIR.getStatus()); if (CollectionUtils.isNotEmpty(maCodeDto.getBmFileInfos())) { for (BmFileInfo bmFileInfo : maCodeDto.getBmFileInfos()) { bmFileInfo.setCreateBy(SecurityUtils.getUsername()); @@ -403,7 +417,7 @@ public class BackApplyInfoServiceImpl implements IBackApplyInfoService { for (BackApplyDetails backApplyDetails : dto.getBackApplyDetailsList()) { if (backApplyDetails.getNum() != null && backApplyDetails.getPreNum() != null) { if (backApplyDetails.getNum() < backApplyDetails.getPreNum()) { - return AjaxResult.error("退料数量不能大于预退数量,请重新填写!"); + return AjaxResult.error(backApplyDetails.getTypeName() + "退料数量不能大于预退数量,请重新填写!"); } } } @@ -415,10 +429,16 @@ public class BackApplyInfoServiceImpl implements IBackApplyInfoService { } // 查询信息 Long id = dto.getBackApplyInfo().getId(); + BackApplyInfo backApplyInfo = backApplyInfoMapper.selectBackApplyInfoById(id); List backApplyDetailsList = backApplyInfoMapper.selectBackApplyDetailsListByTaskId(id); List maCodeList = backApplyInfoMapper.selectByCode(id); - // 删除相关任务信息 int result = 0; + if (CollectionUtils.isNotEmpty(maCodeList)) { + for (MaCodeVo maCodeVo : maCodeList) { + result += machineMapper.updateStatus(maCodeVo.getMaId(), MaMachineStatusEnum.IN_USE.getStatus()); + } + } + // 删除相关任务信息 result += backApplyInfoMapper.deleteBackApplyDetails(id); result += backApplyInfoMapper.deleteCheckDetails(id); // 删除退料详情附件 @@ -428,9 +448,9 @@ public class BackApplyInfoServiceImpl implements IBackApplyInfoService { if (result > 0) { //执行新增操作 BackApplyInfo info = dto.getBackApplyInfo(); - info.setId(id); info.setUpdateTime(DateUtils.getNowDate()); info.setUpdateBy(SecurityUtils.getUsername()); + info.setCode(backApplyInfo.getCode()); result += backApplyInfoMapper.updateBackApplyInfo(info); // 保存退料详情 result = saveBackApplyDetails(dto, info, result); @@ -624,55 +644,235 @@ public class BackApplyInfoServiceImpl implements IBackApplyInfoService { * @return */ @Override - public AjaxResult insertApp(BackApplyRequestVo dto) { + @Transactional(rollbackFor = Exception.class) + public AjaxResult insertApp(BackAppRequestVo dto) { int result = 0; - if (dto != null && dto.getBackApplyInfo() != null && CollectionUtils.isEmpty(dto.getBackApplyDetailsList())) { - //只新增主任务单 - //对传入的手机号进行校验 + if (dto != null && dto.getBackApplyInfo() != null && dto.getBackApplyInfo().getId() == null) { + //只新增主任务单 + //对传入的手机号进行校验 if (StringUtils.isNotBlank(dto.getBackApplyInfo().getPhone()) && !PhoneUtil.isMobile(dto.getBackApplyInfo().getPhone())) { return AjaxResult.error("手机号格式不正确,请重新填写!"); } //生成退料单号 String code = getString(); if (StringUtils.isBlank(code)) { - return AjaxResult.error("后台退料编号生成异常,请重试!"); + return AjaxResult.error("后台退料编号生成异常,请重试!"); } - - int thisMonthMaxOrder = taskMapper.getMonthMaxOrderByDate(DateUtils.getCurrentYear(), DateUtils.getCurrentMonth(), TmTaskTypeEnum.TM_TASK_BACK.getTaskTypeId()); - TmTask tmTask = new TmTask(null, TmTaskTypeEnum.TM_TASK_BACK.getTaskTypeId(), + int thisMonthMaxOrder = taskMapper.getMonthMaxOrderByDate(DateUtils.getCurrentYear(), DateUtils.getCurrentMonth(), TmTaskTypeEnum.TM_TASK_BACK.getTaskTypeId()); + TmTask tmTask = new TmTask(null, TmTaskTypeEnum.TM_TASK_BACK.getTaskTypeId(), BackTaskStatusEnum.BACK_TASK_NO_FINISHED.getStatus(), - null,thisMonthMaxOrder + 1, code); - tmTask.setCreateTime(DateUtils.getNowDate()); - tmTask.setCreateBy(SecurityUtils.getUsername()); - BackApplyInfo backApplyInfo = dto.getBackApplyInfo(); - backApplyInfo.setCode(code); - backApplyInfo.setCreateBy(SecurityUtils.getUsername()); - backApplyInfo.setCreateTime(DateUtils.getNowDate()); - // 保存退料信息到 tm_task 表中 - result += taskMapper.insertTmTask(tmTask); - if (result > 0) { - TmTaskAgreement tmTaskAgreement = new TmTaskAgreement(tmTask.getTaskId(), dto.getBackApplyInfo().getAgreementId()); - tmTaskAgreement.setCreateTime(DateUtils.getNowDate()); - tmTaskAgreement.setCreateBy(SecurityUtils.getUsername()); - taskAgreementMapper.insertTmTaskAgreement(tmTaskAgreement); - backApplyInfo.setTaskId(tmTask.getTaskId()); - result += backApplyInfoMapper.insertBackApplyInfo(backApplyInfo); - } - if (result > 0) { - return AjaxResult.success(); - } - } else if (dto != null && dto.getBackApplyInfo() != null && dto.getBackApplyInfo().getId() != null) { - // 保存退料详情 - result = saveBackApplyDetails(dto, dto.getBackApplyInfo(), result); - if (result > 0) { - return AjaxResult.success(); - } - } else { - return insertBackApplyInfo(dto); + null, thisMonthMaxOrder + 1, code); + tmTask.setCreateTime(DateUtils.getNowDate()); + tmTask.setCreateBy(SecurityUtils.getUsername()); + BackApplyInfo backApplyInfo = dto.getBackApplyInfo(); + backApplyInfo.setCode(code); + backApplyInfo.setCreateBy(SecurityUtils.getUsername()); + backApplyInfo.setCreateTime(DateUtils.getNowDate()); + result = getResultTask(dto, result, tmTask, backApplyInfo); + if (result > 0) { + return AjaxResult.success(); + } + } else if (dto != null && dto.getBackApplyInfo() != null && dto.getBackApplyInfo().getId() != null + && ((dto.getBackApplyDetails() != null) || CollectionUtils.isNotEmpty(dto.getBackApplyDetailsList()))) { + if (dto.getBackApplyDetails() != null) { + dto.getBackApplyInfo().setTypeId(String.valueOf(dto.getBackApplyDetails().getTypeId())); + result = getResultMaCode(dto, result); + } + if (CollectionUtils.isNotEmpty(dto.getBackApplyDetailsList())) { + //数量退料入库 + for (BackApplyDetails details : dto.getBackApplyDetailsList()) { + result = getResultNum(dto, result, details); + } + } + if (result > 0) { + return AjaxResult.success(); + } + } else if (dto != null && dto.getBackApplyInfo() != null && dto.getBackApplyDetails() != null) { + //对传入的手机号进行校验 + if (StringUtils.isNotBlank(dto.getBackApplyInfo().getPhone()) && !PhoneUtil.isMobile(dto.getBackApplyInfo().getPhone())) { + return AjaxResult.error("手机号格式不正确,请重新填写!"); + } + //生成退料单号 + String code = getString(); + if (StringUtils.isBlank(code)) { + return AjaxResult.error("后台退料编号生成异常,请重试!"); + } + int thisMonthMaxOrder = taskMapper.getMonthMaxOrderByDate(DateUtils.getCurrentYear(), DateUtils.getCurrentMonth(), TmTaskTypeEnum.TM_TASK_BACK.getTaskTypeId()); + TmTask tmTask = new TmTask(null, TmTaskTypeEnum.TM_TASK_BACK.getTaskTypeId(), + BackTaskStatusEnum.BACK_TASK_NO_FINISHED.getStatus(), + null, thisMonthMaxOrder + 1, code); + tmTask.setCreateTime(DateUtils.getNowDate()); + tmTask.setCreateBy(SecurityUtils.getUsername()); + BackApplyInfo backApplyInfo = dto.getBackApplyInfo(); + backApplyInfo.setCode(code); + backApplyInfo.setCreateBy(SecurityUtils.getUsername()); + backApplyInfo.setCreateTime(DateUtils.getNowDate()); + // 保存退料信息到 tm_task 表中 + result = getResultTask(dto, result, tmTask, backApplyInfo); + extractedMaCode(dto, result, code, backApplyInfo); + if (result > 0) { + return AjaxResult.success(); + } } return AjaxResult.error(HttpCodeEnum.FAIL.getCode(), HttpCodeEnum.FAIL.getMsg()); } + /** + * app直接编码保存方法抽取 + * @param dto + * @param result + * @param code + * @param backApplyInfo + */ + private void extractedMaCode(BackAppRequestVo dto, int result, String code, BackApplyInfo backApplyInfo) { + //根据协议以及类型id查询领料数量 + Integer num = backApplyInfoMapper.getNum(backApplyInfo); + //编码退料入库 + Long id = backApplyInfo.getId(); + BackApplyDetails details = dto.getBackApplyDetails(); + details.setCode(code); + details.setParentId(id); + details.setNum(num); + details.setAuditNum(details.getPreNum()); + details.setStatus(String.valueOf(BackTaskStatusEnum.BACK_TASK_NO_FINISHED.getStatus())); + details.setCreateBy(SecurityUtils.getUsername()); + details.setCreateTime(DateUtils.getNowDate()); + // 保存退料详情 + result += backApplyInfoMapper.insertBackApplyDetails(details); + // 设置公共字段 + setCommonFields(details, id); + details.setPreNum(1); + // 插入 CheckDetails + result += backApplyInfoMapper.insertCheckDetails(details); + //更新ma_machine表状态为3(退料检修) + result += machineMapper.updateStatus(details.getMaId(), MaMachineStatusEnum.BACK_REPAIR.getStatus()); + if (CollectionUtils.isNotEmpty(details.getBmFileInfos())) { + for (BmFileInfo bmFileInfo : details.getBmFileInfos()) { + bmFileInfo.setCreateBy(SecurityUtils.getUsername()); + bmFileInfo.setCreateTime(DateUtils.getNowDate()); + bmFileInfo.setTaskId(details.getId()); + bmFileInfo.setTaskType(3); + bmFileInfo.setModelId(details.getMaId()); + result += bmFileInfoMapper.insertBmFileInfo(bmFileInfo); + } + } + } + + /** + * 保存退料信息到任务及任务协议表 + * @param dto + * @param result + * @param tmTask + * @param backApplyInfo + * @return + */ + private int getResultTask(BackAppRequestVo dto, int result, TmTask tmTask, BackApplyInfo backApplyInfo) { + // 保存退料信息到 tm_task 表中 + result += taskMapper.insertTmTask(tmTask); + if (result > 0) { + TmTaskAgreement tmTaskAgreement = new TmTaskAgreement(tmTask.getTaskId(), dto.getBackApplyInfo().getAgreementId()); + tmTaskAgreement.setCreateTime(DateUtils.getNowDate()); + tmTaskAgreement.setCreateBy(SecurityUtils.getUsername()); + taskAgreementMapper.insertTmTaskAgreement(tmTaskAgreement); + backApplyInfo.setTaskId(tmTask.getTaskId()); + result += backApplyInfoMapper.insertBackApplyInfo(backApplyInfo); + } + return result; + } + + /** + * 数量退料入库 + * @param dto + * @param result + * @param details + * @return + */ + private int getResultNum(BackAppRequestVo dto, int result, BackApplyDetails details) { + details.setCode(dto.getBackApplyInfo().getCode()); + details.setParentId(dto.getBackApplyInfo().getId()); + details.setAuditNum(details.getPreNum()); + details.setStatus(String.valueOf(BackTaskStatusEnum.BACK_TASK_NO_FINISHED.getStatus())); + details.setCreateBy(SecurityUtils.getUsername()); + details.setCreateTime(DateUtils.getNowDate()); + // 保存退料详情 + //现根据id查询back_apply_details表,看数据是否存在,存在则对数量进行更新,不存在则插入 + BackApplyDetails backApplyDetails = backApplyInfoMapper.selectBackApplyDetailsById(details); + if (backApplyDetails != null) { + details.setId(backApplyDetails.getId()); + result += backApplyInfoMapper.updateDetails(details); + } else { + result += backApplyInfoMapper.insertBackApplyDetails(details); + } + // 设置公共字段 + setCommonFields(details, dto.getBackApplyInfo().getId()); + // 插入 CheckDetails + //根据id查询back_check_details表,看数据是否存在,存在则对数量进行更新,不存在则插入 + BackApplyDetails checkDetails = backApplyInfoMapper.selectCheckDetails(details); + if (checkDetails != null) { + details.setId(checkDetails.getId()); + result += backApplyInfoMapper.updateCheck(details); + } else { + result += backApplyInfoMapper.insertCheckDetails(details); + } + // 处理附件 + result = saveBmFileInfo(details, dto.getBackApplyInfo().getId(), result); + return result; + } + + /** + * 编码退料入库 + * @param dto + * @param result + * @return + */ + private int getResultMaCode(BackAppRequestVo dto, int result) { + //根据协议以及类型id查询领料数量 + Integer num = backApplyInfoMapper.getNum(dto.getBackApplyInfo()); + //编码退料入库 + BackApplyDetails details = dto.getBackApplyDetails(); + details.setCode(dto.getBackApplyInfo().getCode()); + details.setParentId(dto.getBackApplyInfo().getId()); + details.setPreNum(1); + details.setAuditNum(details.getPreNum()); + details.setNum(num); + details.setStatus(String.valueOf(BackTaskStatusEnum.BACK_TASK_NO_FINISHED.getStatus())); + details.setCreateBy(SecurityUtils.getUsername()); + details.setCreateTime(DateUtils.getNowDate()); + // 保存退料详情 + //现根据id查询back_apply_details表,看数据是否存在,存在则对数量进行更新,不存在则插入 + BackApplyDetails backApplyDetails = backApplyInfoMapper.selectBackApplyDetailsById(details); + if (backApplyDetails != null) { + details.setId(backApplyDetails.getId()); + result += backApplyInfoMapper.updateDetails(details); + } else { + result += backApplyInfoMapper.insertBackApplyDetails(details); + } + // 设置公共字段 + setCommonFields(details, dto.getBackApplyInfo().getId()); + // 插入 CheckDetails + //根据id查询back_check_details表,看数据是否存在,存在则对数量进行更新,不存在则插入 + BackApplyDetails checkDetails = backApplyInfoMapper.selectCheckDetails(details); + if (checkDetails != null) { + checkDetails.setId(checkDetails.getId()); + result += backApplyInfoMapper.updateCheck(checkDetails); + } else { + result += backApplyInfoMapper.insertCheckDetails(details); + } + //更新ma_machine表状态为3(退料检修) + result += machineMapper.updateStatus(details.getMaId(), MaMachineStatusEnum.BACK_REPAIR.getStatus()); + if (CollectionUtils.isNotEmpty(details.getBmFileInfos())) { + for (BmFileInfo bmFileInfo : details.getBmFileInfos()) { + bmFileInfo.setCreateBy(SecurityUtils.getUsername()); + bmFileInfo.setCreateTime(DateUtils.getNowDate()); + bmFileInfo.setTaskId(details.getId()); + bmFileInfo.setTaskType(3); + bmFileInfo.setModelId(details.getMaId()); + result += bmFileInfoMapper.insertBmFileInfo(bmFileInfo); + } + } + return result; + } + /** * app内层删除退料任务 * @param backApplyInfo @@ -680,25 +880,33 @@ public class BackApplyInfoServiceImpl implements IBackApplyInfoService { */ @Override public AjaxResult delete(BackApplyInfo backApplyInfo) { - //先查询相关编码信息 - List maCodeVoList = backApplyInfoMapper.selectByCode(backApplyInfo.getParentId()); - //需要清除明细表以及可能存储的文件信息 - //清除back_apply_details表信息 - int result = backApplyInfoMapper.deleteApplyDetails(backApplyInfo); - //删除back_check_details表信息 - result += backApplyInfoMapper.deleteDetails(backApplyInfo); - //清除file文件表信息 - BmFileInfo fileInfo = new BmFileInfo(); - fileInfo.setTaskId(backApplyInfo.getParentId()); - fileInfo.setModelId(backApplyInfo.getId()); - result += bmFileInfoMapper.deleteBmFileInfoByBizInfo(fileInfo); - if (CollectionUtils.isNotEmpty(maCodeVoList)) { - for (MaCodeVo maCodeVo : maCodeVoList) { - BmFileInfo bmFileInfo = new BmFileInfo(); - bmFileInfo.setTaskId(backApplyInfo.getId()); - bmFileInfo.setModelId(maCodeVo.getMaId()); - result += bmFileInfoMapper.deleteBmFileInfoByBizInfo(bmFileInfo); + // 单个编码删除 + if (backApplyInfo.getMaId() != null) { + // 先查询相关编码信息 + List maCodeVoList = backApplyInfoMapper.selectByCode(backApplyInfo.getParentId()); + // 删除 back_check_details 表信息 + int result = deleteBackCheckDetails(backApplyInfo); + //修改机具状态 + result += machineMapper.updateStatus(backApplyInfo.getMaId(), MaMachineStatusEnum.IN_USE.getStatus()); + // 删除相关文件信息 + if (CollectionUtils.isNotEmpty(maCodeVoList)) { + result += deleteBmFileInfoForCodes(maCodeVoList, backApplyInfo.getId()); } + if (result > 0) { + return AjaxResult.success(); + } + } + // 查询相关编码信息 + List maCodeVoList = backApplyInfoMapper.selectByCode(backApplyInfo.getParentId()); + // 清除明细表以及相关的文件信息 + int result = deleteApplyDetails(backApplyInfo); + result += deleteBackCheckDetails(backApplyInfo); + // 删除文件信息 + result += deleteBmFileInfoByParentId(backApplyInfo.getParentId(), backApplyInfo.getId()); + + // 删除与 MaCodeVo 相关的文件信息 + if (CollectionUtils.isNotEmpty(maCodeVoList)) { + result += deleteBmFileInfoForCodes(maCodeVoList, backApplyInfo.getId()); } if (result > 0) { return AjaxResult.success(); @@ -706,6 +914,156 @@ public class BackApplyInfoServiceImpl implements IBackApplyInfoService { return AjaxResult.error(HttpCodeEnum.FAIL.getCode(), HttpCodeEnum.FAIL.getMsg()); } + /** + * 删除 back_check_details 表信息 + * @param backApplyInfo + * @return + */ + private int deleteBackCheckDetails(BackApplyInfo backApplyInfo) { + return backApplyInfoMapper.deleteDetails(backApplyInfo); + } + + /** + * 删除 back_apply_details 表信息 + * @param backApplyInfo + * @return + */ + private int deleteApplyDetails(BackApplyInfo backApplyInfo) { + return backApplyInfoMapper.deleteApplyDetails(backApplyInfo); + } + + /** + * 删除与指定 parentId 和 modelId 相关的文件信息 + * @param parentId + * @param modelId + * @return + */ + private int deleteBmFileInfoByParentId(Long parentId, Long modelId) { + BmFileInfo fileInfo = new BmFileInfo(); + fileInfo.setTaskId(parentId); + fileInfo.setModelId(modelId); + return bmFileInfoMapper.deleteBmFileInfoByBizInfo(fileInfo); + } + + /** + * 删除与 maCodeVo 中的 maId 相关的文件信息 + * @param maCodeVoList + * @param taskId + * @return + */ + private int deleteBmFileInfoForCodes(List maCodeVoList, Long taskId) { + int result = 0; + for (MaCodeVo maCodeVo : maCodeVoList) { + BmFileInfo bmFileInfo = new BmFileInfo(); + bmFileInfo.setTaskId(taskId); + bmFileInfo.setModelId(maCodeVo.getMaId()); + result += bmFileInfoMapper.deleteBmFileInfoByBizInfo(bmFileInfo); + } + return result; + } + + /** + * app编码检索 + * @param dto + * @return + */ + @Override + public AjaxResult getMachine(BackApplyInfo dto) { + //判断输入或者编码识别或者二维码识别是否为领料工程和单位对应 + List list = backApplyInfoMapper.getMachine(dto); + if (CollectionUtils.isNotEmpty(list)) { + for (MaCodeVo maCodeVo : list) { + Map maMachineMap = remoteConfig.getDictValue("ma_machine_status"); + String name = maMachineMap.get(maCodeVo.getMaStatus()); + maCodeVo.setMaStatusName(StringUtils.isBlank(name) ? "" : name); + } + } + return AjaxResult.success(list); + } + + /** + * app查询单个类型设备编码 + * @param backApplyInfo + * @return + */ + @Override + public AjaxResult getMaCodeList(BackApplyInfo backApplyInfo) { + // 查询相关编码信息 + List maCodeVoList = backApplyInfoMapper.selectByTypeId(backApplyInfo); + List maCodeDtos = new ArrayList<>(); + if (CollectionUtils.isNotEmpty(maCodeVoList)) { + for (MaCodeVo maCodeVo : maCodeVoList) { + MaCodeDto maCodeDto = new MaCodeDto(); + maCodeDto.setMaCode(maCodeVo.getMaCode()); + maCodeDto.setMaId(maCodeVo.getMaId()); + maCodeDto.setApDetection(maCodeVo.getApDetection()); + maCodeDto.setTypeName(maCodeVo.getTypeName()); + maCodeDto.setMaterialName(maCodeVo.getMaterialName()); + maCodeDto.setTypeId(maCodeVo.getTypeId()); + maCodeDto.setMaStatus(maCodeVo.getMaStatus()); + maCodeDto.setMaterialType(maCodeVo.getMaterialType()); + // 查询并设置编码附件 + List bmFileInfoList = fetchBmFileInfos(backApplyInfo.getId(), maCodeVo.getMaId()); + if (CollectionUtils.isNotEmpty(bmFileInfoList)) { + maCodeDto.setBmFileInfos(bmFileInfoList); + } + maCodeDtos.add(maCodeDto); + } + } + return AjaxResult.success(maCodeDtos); + } + + /** + * app编码查看保存 + * @param maCode + * @return + */ + @Override + public AjaxResult updateMaCode(MaCode maCode) { + int result = 0; + if (CollectionUtils.isNotEmpty(maCode.getMaCodeDtoList())) { + // 遍历 maCodeDtoList + for (MaCodeDto maCodeDto : maCode.getMaCodeDtoList()) { + // 参数校验 + if (maCodeDto.getId() == null ||maCodeDto.getParentId() == null || maCodeDto.getMaId() == null) { + return AjaxResult.error("参数错误"); + } + // 更新 back_check_details 表 + maCodeDto.setUpdateBy(SecurityUtils.getUsername()); + maCodeDto.setUpdateTime(DateUtils.getNowDate()); + result += backApplyInfoMapper.updateMaCode(maCodeDto); + // 获取 bmFileInfos + List bmFileInfos = maCodeDto.getBmFileInfos(); + if (CollectionUtils.isNotEmpty(bmFileInfos)) { + // 准备删除的文件 ID 列表 + BmFileInfo fileInfo = new BmFileInfo(); + fileInfo.setTaskId(maCodeDto.getId()); + fileInfo.setModelId(maCodeDto.getMaId()); + // 获取现有的附件信息 + List bmFileInfoList = bmFileInfoMapper.selectBmFileInfoList(fileInfo); + // 如果已有附件记录,则删除 + if (CollectionUtils.isNotEmpty(bmFileInfoList)) { + Long[] ids = bmFileInfoList.stream() + .map(BmFileInfo::getId) + .toArray(Long[]::new); + result += bmFileInfoMapper.deleteBmFileInfoByIds(ids); + } + // 批量插入新的附件 + for (BmFileInfo bmFileInfo : bmFileInfos) { + bmFileInfo.setTaskId(maCodeDto.getId()); + bmFileInfo.setModelId(maCodeDto.getMaId()); + result += bmFileInfoMapper.insertBmFileInfo(bmFileInfo); + } + } + } + // 如果成功执行了至少一项操作,返回成功 + if (result > 0) { + return AjaxResult.success("保存成功", result); + } + } + return AjaxResult.error(HttpCodeEnum.FAIL.getCode(), HttpCodeEnum.FAIL.getMsg()); + } + /** * 更新任务表及退料申请表状态 * @param backApplyInfo @@ -802,7 +1160,7 @@ public class BackApplyInfoServiceImpl implements IBackApplyInfoService { Long newTask = null; // 生成维修单号 String code = genCodeRule(); - int thisMonthMaxOrder = taskMapper.getMonthMaxOrderByDate(DateUtils.getCurrentYear(), DateUtils.getCurrentMonth(), TmTaskTypeEnum.TM_TASK_BACK.getTaskTypeId()); + int thisMonthMaxOrder = taskMapper.getMonthMaxOrderByDate(DateUtils.getCurrentYear(), DateUtils.getCurrentMonth(), TmTaskTypeEnum.TM_TASK_REPAIR.getTaskTypeId()); TmTask tmTask = new TmTask(null, TmTaskTypeEnum.TM_TASK_BACK.getTaskTypeId(), BackTaskStatusEnum.BACK_TASK_NO_FINISHED.getStatus(), null,thisMonthMaxOrder + 1, code); tmTask.setCreateTime(DateUtils.getNowDate()); diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/common/controller/SelectController.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/common/controller/SelectController.java index 735a1a84..1440608a 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/common/controller/SelectController.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/common/controller/SelectController.java @@ -131,4 +131,10 @@ public class SelectController { public AjaxResult getUseTypeTree(@RequestBody BackApplyInfo bean) { return service.getUseTypeTree(bean); } + + @ApiOperation(value = "在用设备类型") + @PostMapping("/getUseType") + public AjaxResult getUseType(@RequestBody BackApplyInfo bean) { + return service.getUseType(bean); + } } diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/common/mapper/SelectMapper.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/common/mapper/SelectMapper.java index 7759ce30..5ca1f011 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/common/mapper/SelectMapper.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/common/mapper/SelectMapper.java @@ -151,4 +151,11 @@ public interface SelectMapper { * @return */ List getProjectListApp(BmProject bmProject); + + /** + * 获取在用设备类型app + * @param bean + * @return + */ + List getUseTypeTreeApp(BackApplyInfo bean); } diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/common/service/SelectService.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/common/service/SelectService.java index d8aec26e..3bf23775 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/common/service/SelectService.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/common/service/SelectService.java @@ -185,4 +185,11 @@ public interface SelectService { * @return */ AjaxResult getUseTypeTree(BackApplyInfo bean); + + /** + * 获取设备类型 + * @param bean + * @return + */ + AjaxResult getUseType(BackApplyInfo bean); } diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/common/service/impl/SelectServiceImpl.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/common/service/impl/SelectServiceImpl.java index 642c9fba..dca53ee2 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/common/service/impl/SelectServiceImpl.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/common/service/impl/SelectServiceImpl.java @@ -283,6 +283,35 @@ public class SelectServiceImpl implements SelectService { return AjaxResult.success(groupList); } + /** + * 获取设备类型 app用 + * @param bean + * @return + */ + @Override + public AjaxResult getUseType(BackApplyInfo bean) { + //四级类型只查询数量管理类型数据 + List listL4 = mapper.getUseTypeTreeApp(bean); + if (CollectionUtils.isEmpty(listL4)) { + return AjaxResult.success(); + } + // 根据四级查询三级类型信息 + List list4ParentIds = listL4.stream() + .map(TypeTreeNode::getParentId) + .collect(Collectors.toList()); + // 根据第四层 parentId 查第三层类型 + List listL3 = mapper.getUseTypeTreeL3(list4ParentIds); + // 如果 bean.getTypeId() 不为 null,筛选符合条件的 listL4 数据 + if (bean.getTypeId() != null) { + List filteredListL4 = listL4.stream() + .filter(node -> String.valueOf(node.getParentId()).equals(bean.getTypeId())) + .collect(Collectors.toList()); + return AjaxResult.success(filteredListL4); + } + // 如果 bean.getTypeId() 为 null,则返回 listL3 + return AjaxResult.success(listL3); + } + @Override public AjaxResult getGoodsShelvesCbx(SelectDto dto) { List groupList = new ArrayList<>(); diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/controller/LeaseApplyInfoController.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/controller/LeaseApplyInfoController.java index c7ed7b09..903f356f 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/controller/LeaseApplyInfoController.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/controller/LeaseApplyInfoController.java @@ -65,8 +65,9 @@ public class LeaseApplyInfoController extends BaseController { @ApiOperation(value = "获取领料任务详细信息") //@RequiresPermissions("lease:info:query") @GetMapping(value = "/{id}") - public AjaxResult getInfo(@NotNull(message = "领料任务ID不能为空") @PathVariable("id") Long id) { - return success(leaseApplyInfoService.selectLeaseApplyInfoById(id)); + public AjaxResult getInfo(@NotNull(message = "领料任务ID不能为空") @PathVariable("id") Long id, + @RequestParam(value = "keyword", required = false) String keyword) { + return success(leaseApplyInfoService.selectLeaseApplyInfoById(id, keyword)); } /** diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/domain/LeaseApplyDetails.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/domain/LeaseApplyDetails.java index 16f2e15c..f1f8a01c 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/domain/LeaseApplyDetails.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/domain/LeaseApplyDetails.java @@ -83,6 +83,8 @@ public class LeaseApplyDetails extends BaseEntity { @ApiModelProperty(value = "数据所属组织") private Long companyId; + private String keyword; + public LeaseApplyDetails(Long id, Long parentId, Long typeId, Long preNum, Long auditNum, Long alNum, String status, Long companyId) { this.id = id; this.parentId = parentId; @@ -96,7 +98,8 @@ public class LeaseApplyDetails extends BaseEntity { public LeaseApplyDetails() {} - public LeaseApplyDetails(Long parentId) { + public LeaseApplyDetails(Long parentId, String keyword) { this.parentId = parentId; + this.keyword = keyword; } } diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/service/ILeaseApplyInfoService.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/service/ILeaseApplyInfoService.java index 8eed7439..bdcbf37c 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/service/ILeaseApplyInfoService.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/service/ILeaseApplyInfoService.java @@ -2,7 +2,6 @@ package com.bonus.material.lease.service; import java.util.List; import com.bonus.common.core.web.domain.AjaxResult; -import com.bonus.material.lease.domain.LeaseApplyDetails; import com.bonus.material.lease.domain.LeaseApplyInfo; import com.bonus.material.lease.domain.vo.LeaseApplyRequestVo; import com.bonus.material.lease.domain.vo.LeaseOutRequestVo; @@ -18,9 +17,10 @@ public interface ILeaseApplyInfoService { * 查询领料任务 * * @param id 领料任务主键 + * @param keyword keyword 关键字 * @return 领料任务 */ - LeaseApplyRequestVo selectLeaseApplyInfoById(Long id); + LeaseApplyRequestVo selectLeaseApplyInfoById(Long id, String keyword); /** * 查询领料任务列表 diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/service/impl/LeaseApplyInfoServiceImpl.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/service/impl/LeaseApplyInfoServiceImpl.java index b0679885..55d8ba17 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/service/impl/LeaseApplyInfoServiceImpl.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/service/impl/LeaseApplyInfoServiceImpl.java @@ -61,7 +61,7 @@ public class LeaseApplyInfoServiceImpl implements ILeaseApplyInfoService { * @return 领料任务 */ @Override - public LeaseApplyRequestVo selectLeaseApplyInfoById(Long id) { + public LeaseApplyRequestVo selectLeaseApplyInfoById(Long id, String keyword) { try { Optional optionalInfo = Optional.ofNullable(leaseApplyInfoMapper.selectLeaseApplyInfoById(id)); LeaseApplyRequestVo leaseApplyRequestVo = new LeaseApplyRequestVo(); @@ -69,7 +69,7 @@ public class LeaseApplyInfoServiceImpl implements ILeaseApplyInfoService { optionalInfo.ifPresent(info -> { leaseApplyRequestVo.setLeaseApplyInfo(info); // 获取领料单详情 - List details = leaseApplyDetailsMapper.selectLeaseApplyDetailsList(new LeaseApplyDetails(info.getId())); + List details = leaseApplyDetailsMapper.selectLeaseApplyDetailsList(new LeaseApplyDetails(info.getId(), keyword)); if (!CollectionUtils.isEmpty(details)) { leaseApplyRequestVo.setLeaseApplyDetailsList(details); } diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/mapper/MachineMapper.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/mapper/MachineMapper.java index 9e389845..114f5da4 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/mapper/MachineMapper.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/mapper/MachineMapper.java @@ -77,4 +77,12 @@ public interface MachineMapper * 修改机具设备(ma_machine表)的状态为:在用 */ int updateMaMachineStatus(@Param("record") LeaseOutDetails leaseOutDetails, @Param("status") Integer status); + + /** + * 修改机具设备(ma_machine表)的状态 + * @param maId + * @param status + * @return + */ + int updateStatus(@Param("maId") Long maId, @Param("status") Integer status); } diff --git a/bonus-modules/bonus-material/src/main/resources/mapper/material/back/BackApplyInfoMapper.xml b/bonus-modules/bonus-material/src/main/resources/mapper/material/back/BackApplyInfoMapper.xml index 3e8189a4..4dbdea91 100644 --- a/bonus-modules/bonus-material/src/main/resources/mapper/material/back/BackApplyInfoMapper.xml +++ b/bonus-modules/bonus-material/src/main/resources/mapper/material/back/BackApplyInfoMapper.xml @@ -278,6 +278,87 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" order by start_time asc + + + + + + + + + + insert into back_apply_info @@ -506,6 +587,32 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" update back_apply_details set use_num = use_num - COALESCE(#{preNum} ,0) where parent_id = #{parentId} and type_id = #{typeId} + + update back_apply_details set pre_num = pre_num + COALESCE(#{preNum} ,0) where id = #{id} + + + + update back_check_details set back_num = back_num + COALESCE(#{preNum} ,0) where parent_id = #{parentId} and type_id = #{typeId} + + and ma_id = #{maId} + + + + + update back_check_details + set + + update_by = #{updateBy}, + + + update_time = #{updateTime}, + + + ap_detection = #{apDetection} + + where parent_id = #{parentId} and ma_id = #{maId} + + insert into slt_agreement_info (agreement_id,type_id,ma_id,num,start_time,status,lease_id,lease_price,buy_price,is_slt,company_id,lease_type,create_time) values (#{info.agreementId},#{info.typeId},#{info.maId},#{many},#{info.startTime},#{info.status},#{info.leaseId},#{info.leasePrice},#{info.buyPrice},'0',#{info.companyId},#{info.leaseType},now()); @@ -528,6 +635,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - delete from back_apply_details where parent_id = #{parentId} and type_id = #{typeId} + delete from back_check_details where parent_id = #{parentId} and type_id = #{typeId} + + and ma_id = #{maId} + \ No newline at end of file diff --git a/bonus-modules/bonus-material/src/main/resources/mapper/material/common/SelectMapper.xml b/bonus-modules/bonus-material/src/main/resources/mapper/material/common/SelectMapper.xml index 22853232..bf3b3b2f 100644 --- a/bonus-modules/bonus-material/src/main/resources/mapper/material/common/SelectMapper.xml +++ b/bonus-modules/bonus-material/src/main/resources/mapper/material/common/SelectMapper.xml @@ -182,6 +182,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" SELECT mt3.type_id as typeId, + NULL as materialName, mt3.type_name as typeName, mt3.parent_id as parentId, mt3.unit_name as unitName, @@ -217,6 +220,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + + \ No newline at end of file diff --git a/bonus-modules/bonus-material/src/main/resources/mapper/material/lease/LeaseApplyDetailsMapper.xml b/bonus-modules/bonus-material/src/main/resources/mapper/material/lease/LeaseApplyDetailsMapper.xml index 557c903a..456f6198 100644 --- a/bonus-modules/bonus-material/src/main/resources/mapper/material/lease/LeaseApplyDetailsMapper.xml +++ b/bonus-modules/bonus-material/src/main/resources/mapper/material/lease/LeaseApplyDetailsMapper.xml @@ -50,6 +50,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" and lad.parent_id = #{parentId} + + AND (mt.type_name LIKE CONCAT('%', #{keyword}, '%') + OR mt2.type_name LIKE CONCAT('%', #{keyword}, '%')) + and lad.type_id = #{typeId} and lad.pre_num = #{preNum} and lad.audit_num = #{auditNum} diff --git a/bonus-modules/bonus-material/src/main/resources/mapper/material/ma/MachineMapper.xml b/bonus-modules/bonus-material/src/main/resources/mapper/material/ma/MachineMapper.xml index 4cd13226..60f6f555 100644 --- a/bonus-modules/bonus-material/src/main/resources/mapper/material/ma/MachineMapper.xml +++ b/bonus-modules/bonus-material/src/main/resources/mapper/material/ma/MachineMapper.xml @@ -98,6 +98,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" and ma.ma_status = #{maStatus} + + and ma.ma_code like concat('%', #{maCode}, '%') + and mt3.type_name like concat('%', #{materialType}, '%') @@ -312,4 +315,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + + UPDATE + ma_machine + SET + ma_status = #{status} + where + ma_id = #{maId} + \ No newline at end of file