From 103cf80ceb40c5ed7f7731eee6e4b95293710f61 Mon Sep 17 00:00:00 2001 From: cwchen <1048842385@qq.com> Date: Sat, 16 Dec 2023 21:27:14 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E8=AF=95=E5=85=A5=E5=BA=93=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/RepairTestInputController.java | 50 ++++++ .../base/domain/RepairTestInputDetailVo.java | 47 ++++++ .../sgzb/base/domain/RepairTestInputDto.java | 18 +++ .../sgzb/base/domain/RepairTestInputVo.java | 28 ++++ .../base/domain/RepairTestWarehousingDto.java | 45 ++++++ .../base/mapper/RepairTestInputMapper.java | 108 +++++++++++++ .../base/service/RepairTestInputService.java | 41 +++++ .../impl/RepairTestInputServiceImpl.java | 125 +++++++++++++++ .../mapper/base/RepairTestInputMapper.xml | 144 ++++++++++++++++++ 9 files changed, 606 insertions(+) create mode 100644 sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/base/controller/RepairTestInputController.java create mode 100644 sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/base/domain/RepairTestInputDetailVo.java create mode 100644 sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/base/domain/RepairTestInputDto.java create mode 100644 sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/base/domain/RepairTestInputVo.java create mode 100644 sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/base/domain/RepairTestWarehousingDto.java create mode 100644 sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/base/mapper/RepairTestInputMapper.java create mode 100644 sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/base/service/RepairTestInputService.java create mode 100644 sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/base/service/impl/RepairTestInputServiceImpl.java create mode 100644 sgzb-modules/sgzb-base/src/main/resources/mapper/base/RepairTestInputMapper.xml diff --git a/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/base/controller/RepairTestInputController.java b/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/base/controller/RepairTestInputController.java new file mode 100644 index 00000000..d93fef5d --- /dev/null +++ b/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/base/controller/RepairTestInputController.java @@ -0,0 +1,50 @@ +package com.bonus.sgzb.base.controller; + +import com.bonus.sgzb.base.domain.RepairTestInputDetailVo; +import com.bonus.sgzb.base.domain.RepairTestInputDto; +import com.bonus.sgzb.base.domain.RepairTestInputVo; +import com.bonus.sgzb.base.service.RepairTestInputService; +import com.bonus.sgzb.common.core.web.controller.BaseController; +import com.bonus.sgzb.common.core.web.domain.AjaxResult; +import com.bonus.sgzb.common.core.web.page.TableDataInfo; +import io.swagger.annotations.ApiOperation; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import javax.annotation.Resource; +import java.util.List; + +/** + * @author 10488 + * 修试入库 + */ +@RestController +@RequestMapping("/RepairTestInput/") +public class RepairTestInputController extends BaseController { + + @Resource(name = "RepairTestInputService") + private RepairTestInputService service; + + @ApiOperation(value = "获取修试后入库列表") + @PostMapping("getRepairedList") + public TableDataInfo getRepairedList(RepairTestInputDto dto){ + startPage(); + List list = service.getRepairedList(dto); + return getDataTable(list); + } + + @ApiOperation(value = "获取修试后入库列表-详情") + @PostMapping("getRepairedDetailList") + public TableDataInfo getRepairedDetailList(RepairTestInputDto dto){ + startPage(); + List list = service.getRepairedDetailList(dto); + return getDataTable(list); + } + + @ApiOperation(value = "修试后入库-入库操作") + @PostMapping("inputByType") + public AjaxResult inputByType(String params){ + return service.inputByType(params); + } +} diff --git a/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/base/domain/RepairTestInputDetailVo.java b/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/base/domain/RepairTestInputDetailVo.java new file mode 100644 index 00000000..28f523be --- /dev/null +++ b/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/base/domain/RepairTestInputDetailVo.java @@ -0,0 +1,47 @@ +package com.bonus.sgzb.base.domain; + +import lombok.Data; + +/** + * @author 10488 + * 修试入库详细 + */ + +@Data +public class RepairTestInputDetailVo { + + private int id; + + /** 机具id*/ + private Integer maId; + + /** 规格ID*/ + private Integer typeId; + + /** 设备类型*/ + private String typeName; + + /** 规格型号*/ + private String typeName2; + + /** 管理方式(0编号 1计数)*/ + private String manageType; + + /** 数量*/ + private double repairNum; + + /** 编号*/ + private String maCode; + + /** 提交入库人员*/ + private String updateBy; + + /** 提交入库时间*/ + private String updateTime; + + /** 不通过原因*/ + private String remark; + + /** 状态*/ + private String status; +} diff --git a/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/base/domain/RepairTestInputDto.java b/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/base/domain/RepairTestInputDto.java new file mode 100644 index 00000000..d868169d --- /dev/null +++ b/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/base/domain/RepairTestInputDto.java @@ -0,0 +1,18 @@ +package com.bonus.sgzb.base.domain; + +import lombok.Data; + +/** + * @author 10488 + * 修试入库-前端传参 + */ +@Data +public class RepairTestInputDto { + + /** 任务id*/ + private int taskId; + + /** 关键字*/ + private String keyWord; + +} diff --git a/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/base/domain/RepairTestInputVo.java b/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/base/domain/RepairTestInputVo.java new file mode 100644 index 00000000..d7359a9a --- /dev/null +++ b/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/base/domain/RepairTestInputVo.java @@ -0,0 +1,28 @@ +package com.bonus.sgzb.base.domain; + +import lombok.Data; + +/** + * @author 10488 + * 修试入库-Vo + */ +@Data +public class RepairTestInputVo { + + private int id; + + /** 维修单号*/ + private String repairCode; + + /** 工器具类型*/ + private String maTypeName; + + /** 维修人员*/ + private String wxName; + + /** 维修时间*/ + private String wxTime; + + /** 状态*/ + private String taskStatus; +} diff --git a/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/base/domain/RepairTestWarehousingDto.java b/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/base/domain/RepairTestWarehousingDto.java new file mode 100644 index 00000000..369f662e --- /dev/null +++ b/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/base/domain/RepairTestWarehousingDto.java @@ -0,0 +1,45 @@ +package com.bonus.sgzb.base.domain; + +import lombok.Data; + +/** + * @author 10488 + * 修试入库-审核入库-前端传参 + */ +@Data +public class RepairTestWarehousingDto { + + /** 任务id*/ + private String taskId; + + /** id*/ + private String id; + + /** 审核类型 1 审核通过 2 驳回*/ + private String checkType; + + /** 类型 0.编号 1.计数*/ + private String type; + + /** 机具id*/ + private String maId; + + /** 类型规格id*/ + private String typeId; + + /** 不通过原因*/ + private String remark; + + /** 数量*/ + private String repairNum; + + /**更新时间*/ + private String updateTime; + + /** 更新者*/ + private String updateBy; + + /** 数据所属组织*/ + private long companyId; + +} diff --git a/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/base/mapper/RepairTestInputMapper.java b/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/base/mapper/RepairTestInputMapper.java new file mode 100644 index 00000000..f7b675df --- /dev/null +++ b/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/base/mapper/RepairTestInputMapper.java @@ -0,0 +1,108 @@ +package com.bonus.sgzb.base.mapper; + +import com.bonus.sgzb.base.domain.RepairTestInputDetailVo; +import com.bonus.sgzb.base.domain.RepairTestInputDto; +import com.bonus.sgzb.base.domain.RepairTestInputVo; +import com.bonus.sgzb.base.domain.RepairTestWarehousingDto; +import org.apache.ibatis.annotations.Param; +import org.springframework.stereotype.Repository; + +import java.util.List; +import java.util.Map; + +/** + * @author 10488 + * 修试入库 + */ +@Repository("RepairTestInputMapper") +public interface RepairTestInputMapper { + + /** + * @param dto + * @return List + * @description 获取修试后入库列表 + * @author cwchen + * @date 2023/12/16 16:05 + */ + List getRepairedList(RepairTestInputDto dto); + + /** + * @param dto + * @return List + * @description 获取修试后入库-详情列表 + * @author cwchen + * @date 2023/12/16 17:34 + */ + List getRepairedDetailList(RepairTestInputDto dto); + + /** + * @param dto + * @description 更新修试后入库-数据 + * @author cwchen + * @date 2023/12/16 19:17 + */ + void updateRepairInputDetails(RepairTestWarehousingDto dto); + + /** + * @param dto + * @description 新增入库任务详细表-数据 + * @author cwchen + * @date 2023/12/16 19:33 + */ + void addInputApplyDetails(RepairTestWarehousingDto dto); + + /** + * @param typeId + * @return Map + * @description 查询机具类型-库存数量 + * @author cwchen + * @date 2023/12/16 20:24 + */ + Map getMaTypeByNum(String typeId); + + /** + * @param typeId + * @param num + * @description 更新机具类型-库存数量 + * @author cwchen + * @date 2023/12/16 20:45 + */ + void updateMaTypeNum(@Param("typeId") String typeId, @Param("num") double num); + + /** + * @param ma_status + * @param status + * @return int + * @description 查询机具状态-在库的id + * @author cwchen + * @date 2023/12/16 20:52 + */ + int getDicByMaStatusId(@Param("maStatus") String ma_status, @Param("status") String status); + + /** + * @param dicId + * @param maId + * @description 管理方式为编号的需更新机具设备的机具状态 + * @author cwchen + * @date 2023/12/16 20:59 + */ + void updateMaMachineStatus(@Param("dicId") int dicId, @Param("maId") String maId); + + /** + * @param dto + * @return List + * @description 查询修试后入库的状态是否全部更新 + * @author cwchen + * @date 2023/12/16 21:03 + */ + Map getIsAllUpdate(RepairTestWarehousingDto dto); + + /** + * @param dto + * @param dicId + * @description 更新任务表状态 + * @author cwchen + * @date 2023/12/16 21:19 + */ + void updateTmTaskStatus(@Param("params") RepairTestWarehousingDto dto,@Param("dictId") int dicId); +} diff --git a/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/base/service/RepairTestInputService.java b/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/base/service/RepairTestInputService.java new file mode 100644 index 00000000..95f29b66 --- /dev/null +++ b/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/base/service/RepairTestInputService.java @@ -0,0 +1,41 @@ +package com.bonus.sgzb.base.service; + +import com.bonus.sgzb.base.domain.RepairTestInputDetailVo; +import com.bonus.sgzb.base.domain.RepairTestInputDto; +import com.bonus.sgzb.base.domain.RepairTestInputVo; +import com.bonus.sgzb.common.core.web.domain.AjaxResult; + +import java.util.List; + +/** + * @author 10488 + * 修试入库 + */ +public interface RepairTestInputService { + /** + * @param dto + * @return List + * @description 获取修试后入库列表 + * @author cwchen + * @date 2023/12/16 16:03 + */ + List getRepairedList(RepairTestInputDto dto); + + /** + * @param dto + * @return List + * @description 获取修试后入库列表-详情 + * @author cwchen + * @date 2023/12/16 17:33 + */ + List getRepairedDetailList(RepairTestInputDto dto); + + /** + * @param params + * @return AjaxResult + * @description 修试后入库-入库操作 + * @author cwchen + * @date 2023/12/16 18:35 + */ + AjaxResult inputByType(String params); +} diff --git a/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/base/service/impl/RepairTestInputServiceImpl.java b/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/base/service/impl/RepairTestInputServiceImpl.java new file mode 100644 index 00000000..e8527b2b --- /dev/null +++ b/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/base/service/impl/RepairTestInputServiceImpl.java @@ -0,0 +1,125 @@ +package com.bonus.sgzb.base.service.impl; + +import com.alibaba.fastjson.JSONObject; +import com.bonus.sgzb.base.domain.RepairTestInputDetailVo; +import com.bonus.sgzb.base.domain.RepairTestInputDto; +import com.bonus.sgzb.base.domain.RepairTestInputVo; +import com.bonus.sgzb.base.domain.RepairTestWarehousingDto; +import com.bonus.sgzb.base.mapper.RepairTestInputMapper; +import com.bonus.sgzb.base.service.RepairTestInputService; +import com.bonus.sgzb.common.core.constant.HttpStatus; +import com.bonus.sgzb.common.core.utils.DateTimeHelper; +import com.bonus.sgzb.common.core.utils.StringUtils; +import com.bonus.sgzb.common.core.web.domain.AjaxResult; +import com.bonus.sgzb.common.security.utils.SecurityUtils; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.transaction.interceptor.TransactionAspectSupport; + +import javax.annotation.Resource; +import java.math.BigDecimal; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +/** + * @author 10488 + * 修试入库 + */ +@Service("RepairTestInputService") +@Slf4j +public class RepairTestInputServiceImpl implements RepairTestInputService { + + @Resource(name = "RepairTestInputMapper") + private RepairTestInputMapper mapper; + + @Override + public List getRepairedList(RepairTestInputDto dto) { + return mapper.getRepairedList(dto); + } + + @Override + public List getRepairedDetailList(RepairTestInputDto dto) { + return mapper.getRepairedDetailList(dto); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public AjaxResult inputByType(String params) { + try { + if (StringUtils.isEmpty(params)) { + return AjaxResult.error(HttpStatus.ERROR, "参数类型不正确"); + } + List list = JSONObject.parseArray(params, RepairTestWarehousingDto.class); + Long companyId = SecurityUtils.getLoginUser().getSysUser().getCompanyId(); + String updateTime = DateTimeHelper.getNowTime(); + String updateBy = SecurityUtils.getLoginUser().getUsername(); + for (RepairTestWarehousingDto dto : list) { + dto.setCompanyId(companyId); + dto.setUpdateTime(updateTime); + dto.setUpdateBy(updateBy); + if (Objects.equals("2", dto.getCheckType())) { + // 审核不通过-入库数量修改为0 + dto.setRepairNum("0"); + } + // 更新修试后入库数据 + mapper.updateRepairInputDetails(dto); + if (Objects.equals("1", dto.getCheckType())) { + // 审核通过-更新入库任务详细表 + mapper.addInputApplyDetails(dto); + // 查询机具类型-现有库存 + Map map = mapper.getMaTypeByNum(dto.getTypeId()); + // 更新机具类型-库存 + String repairNum = StringUtils.isNotEmpty(dto.getRepairNum()) ? dto.getRepairNum() : "0"; + double num = countNum(map.get("num"), repairNum); + mapper.updateMaTypeNum(dto.getTypeId(),num); + if(Objects.equals("0", dto.getType())){ + // 查询机具状态-在库的id、管理方式为编号的需更新机具设备的机具状态 + int dicId = mapper.getDicByMaStatusId("ma_status","在库"); + mapper.updateMaMachineStatus(dicId,dto.getMaId()); + } + } + // 查询修试后入库的状态是否全部更新、更新任务表状态 + Map numMap = mapper.getIsAllUpdate(dto); + // 总量、未审核数量、入库数量、驳回数量 + int totalNum = Integer.parseInt(String.valueOf(numMap.get("num"))); + int noCheckNum = Integer.parseInt(String.valueOf(numMap.get("noCheckNum"))); + int passNum = Integer.parseInt(String.valueOf(numMap.get("passNum"))); + int noPassNum = Integer.parseInt(String.valueOf(numMap.get("noPassNum"))); + if(passNum == totalNum){ + int dicId = mapper.getDicByMaStatusId("rk_task","入库完成"); + mapper.updateTmTaskStatus(dto,dicId); + }else if(noPassNum > 0){ + int dicId = mapper.getDicByMaStatusId("rk_task","入库驳回"); + mapper.updateTmTaskStatus(dto,dicId); + } + } + } catch (Exception e) { + //手动回滚异常 + TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); + log.error("修试后入库-入库操作", e); + return AjaxResult.error(); + } + return AjaxResult.success(); + } + + /** + * @param num + * @param repairNum + * @return double + * @description 添加库存 + * @author cwchen + * @date 2023/12/16 20:43 + */ + public double countNum(Object num, String repairNum) { + BigDecimal value = new BigDecimal(new Double(0).toString()); + BigDecimal repairNumValue = new BigDecimal(new Double(repairNum).toString()); + value = value.add(repairNumValue); + if (Objects.nonNull(num)) { + BigDecimal numValue = new BigDecimal(new Double(String.valueOf(num)).toString()); + value.add(numValue); + } + return value.doubleValue(); + } +} diff --git a/sgzb-modules/sgzb-base/src/main/resources/mapper/base/RepairTestInputMapper.xml b/sgzb-modules/sgzb-base/src/main/resources/mapper/base/RepairTestInputMapper.xml new file mode 100644 index 00000000..b9df3f4a --- /dev/null +++ b/sgzb-modules/sgzb-base/src/main/resources/mapper/base/RepairTestInputMapper.xml @@ -0,0 +1,144 @@ + + + + + + INSERT INTO input_apply_details + + task_id, + ma_id, + type_id, + input_num, + input_type, + create_by, + create_time, + update_by, + update_time, + company_id, + + + #{taskId}, + #{maId}, + #{typeId}, + #{repairNum}, + '3', + #{updateBy}, + #{updateTime}, + #{updateBy}, + #{updateTime}, + #{companyId}, + + + + + UPDATE repair_input_details + + input_num = #{repairNum}, + update_by = #{updateBy}, + update_time = #{status}, + `status` = #{checkType}, + `remark` = #{remark} + + WHERE id = #{id} + + + + UPDATE ma_type SET num = #{num} WHERE type_id = #{typeId} + + + + UPDATE ma_machine SET ma_status = #{dicId} WHERE ma_id = #{maId} + + + + UPDATE tm_task SET task_status = #{dictId} WHERE task_id = #{params.taskId} + + + + + + + + + + + + + + + \ No newline at end of file