Commit a0aea8830cf695cb879ddafc58290a466286445e
1 parent
0b01801a
工单管理耗材登录修改
Showing
7 changed files
with
131 additions
and
45 deletions
urbanops-module-workorder/src/main/java/com/zteits/urbanops/module/workorder/controller/admin/materialdetail/MaterialDetailController.java
| @@ -101,4 +101,17 @@ public class MaterialDetailController { | @@ -101,4 +101,17 @@ public class MaterialDetailController { | ||
| 101 | BeanUtils.toBean(list, MaterialDetailRespVO.class)); | 101 | BeanUtils.toBean(list, MaterialDetailRespVO.class)); |
| 102 | } | 102 | } |
| 103 | 103 | ||
| 104 | -} | ||
| 105 | \ No newline at end of file | 104 | \ No newline at end of file |
| 105 | + /** | ||
| 106 | + * 批量创建物料明细 | ||
| 107 | + * @param materialDetailSaveReqVOs 物料明细保存请求列表 | ||
| 108 | + * @return 统一响应结果 | ||
| 109 | + */ | ||
| 110 | + @PostMapping("/batch-create") | ||
| 111 | + @Operation(summary = "批量创建工单耗材明细") | ||
| 112 | + @PreAuthorize("@ss.hasPermission('workorder:material-detail:create')") | ||
| 113 | + public CommonResult<Boolean> batchCreateMaterialDetail( | ||
| 114 | + @RequestBody @Valid List<MaterialDetailSaveReqVO> materialDetailSaveReqVOs) { | ||
| 115 | + return success(materialDetailService.batchCreateMaterialDetail(materialDetailSaveReqVOs)); | ||
| 116 | + } | ||
| 117 | + | ||
| 118 | +} |
urbanops-module-workorder/src/main/java/com/zteits/urbanops/module/workorder/controller/admin/materialdetail/vo/MaterialDetailSaveReqVO.java
| @@ -16,14 +16,6 @@ public class MaterialDetailSaveReqVO { | @@ -16,14 +16,6 @@ public class MaterialDetailSaveReqVO { | ||
| 16 | @NotEmpty(message = "工单号不能为空") | 16 | @NotEmpty(message = "工单号不能为空") |
| 17 | private String orderNo; | 17 | private String orderNo; |
| 18 | 18 | ||
| 19 | - @Schema(description = "提交用户ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "10300") | ||
| 20 | - @NotNull(message = "提交用户ID不能为空") | ||
| 21 | - private Long userId; | ||
| 22 | - | ||
| 23 | - @Schema(description = "提交用户名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "赵六") | ||
| 24 | - @NotEmpty(message = "提交用户名称不能为空") | ||
| 25 | - private String userName; | ||
| 26 | - | ||
| 27 | @Schema(description = "种类ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "27821") | 19 | @Schema(description = "种类ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "27821") |
| 28 | @NotNull(message = "种类ID不能为空") | 20 | @NotNull(message = "种类ID不能为空") |
| 29 | private Long classifyId; | 21 | private Long classifyId; |
| @@ -60,7 +52,17 @@ public class MaterialDetailSaveReqVO { | @@ -60,7 +52,17 @@ public class MaterialDetailSaveReqVO { | ||
| 60 | private String status; | 52 | private String status; |
| 61 | 53 | ||
| 62 | @Schema(description = "描述", requiredMode = Schema.RequiredMode.REQUIRED, example = "你说的对") | 54 | @Schema(description = "描述", requiredMode = Schema.RequiredMode.REQUIRED, example = "你说的对") |
| 63 | - @NotEmpty(message = "描述不能为空") | ||
| 64 | private String remark; | 55 | private String remark; |
| 65 | 56 | ||
| 66 | -} | ||
| 67 | \ No newline at end of file | 57 | \ No newline at end of file |
| 58 | + /*耗材ID*/ | ||
| 59 | + @Schema(description = "耗材ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "111") | ||
| 60 | + @NotNull(message = "物料ID不能为空") | ||
| 61 | + private Long materialId; | ||
| 62 | + | ||
| 63 | + /** | ||
| 64 | + * 耗材名称 | ||
| 65 | + */ | ||
| 66 | + @Schema(description = "耗材名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "耗材名称") | ||
| 67 | + @NotEmpty(message = "耗材名称不能为空") | ||
| 68 | + private String materialName; | ||
| 69 | +} |
urbanops-module-workorder/src/main/java/com/zteits/urbanops/module/workorder/dal/dataobject/materialdetail/MaterialDetailDO.java
| @@ -66,7 +66,7 @@ public class MaterialDetailDO extends BaseDO { | @@ -66,7 +66,7 @@ public class MaterialDetailDO extends BaseDO { | ||
| 66 | /** | 66 | /** |
| 67 | * 使用数量 | 67 | * 使用数量 |
| 68 | */ | 68 | */ |
| 69 | - private Double userCount; | 69 | + private Long userCount; |
| 70 | /** | 70 | /** |
| 71 | * 单位 | 71 | * 单位 |
| 72 | */ | 72 | */ |
| @@ -80,5 +80,11 @@ public class MaterialDetailDO extends BaseDO { | @@ -80,5 +80,11 @@ public class MaterialDetailDO extends BaseDO { | ||
| 80 | */ | 80 | */ |
| 81 | private String remark; | 81 | private String remark; |
| 82 | 82 | ||
| 83 | + /*耗材ID*/ | ||
| 84 | + private Long materialId; | ||
| 83 | 85 | ||
| 84 | -} | ||
| 85 | \ No newline at end of file | 86 | \ No newline at end of file |
| 87 | + /** | ||
| 88 | + * 耗材名称 | ||
| 89 | + */ | ||
| 90 | + private String materialName; | ||
| 91 | +} |
urbanops-module-workorder/src/main/java/com/zteits/urbanops/module/workorder/service/maininfo/MainInfoService.java
| @@ -59,4 +59,12 @@ public interface MainInfoService { | @@ -59,4 +59,12 @@ public interface MainInfoService { | ||
| 59 | */ | 59 | */ |
| 60 | PageResult<MainInfoDO> getMainInfoPage(MainInfoPageReqVO pageReqVO); | 60 | PageResult<MainInfoDO> getMainInfoPage(MainInfoPageReqVO pageReqVO); |
| 61 | 61 | ||
| 62 | -} | ||
| 63 | \ No newline at end of file | 62 | \ No newline at end of file |
| 63 | + /** | ||
| 64 | + * 获得工单信息 | ||
| 65 | + * | ||
| 66 | + * @param orderNo 编号 | ||
| 67 | + * @return 工单信息 | ||
| 68 | + */ | ||
| 69 | + MainInfoDO getMainInfoByOrderNo(String orderNo); | ||
| 70 | + | ||
| 71 | +} |
urbanops-module-workorder/src/main/java/com/zteits/urbanops/module/workorder/service/maininfo/MainInfoServiceImpl.java
| 1 | package com.zteits.urbanops.module.workorder.service.maininfo; | 1 | package com.zteits.urbanops.module.workorder.service.maininfo; |
| 2 | 2 | ||
| 3 | -import cn.hutool.core.collection.CollUtil; | ||
| 4 | -import org.springframework.stereotype.Service; | ||
| 5 | -import jakarta.annotation.Resource; | ||
| 6 | -import org.springframework.validation.annotation.Validated; | ||
| 7 | -import org.springframework.transaction.annotation.Transactional; | ||
| 8 | - | ||
| 9 | -import java.util.*; | ||
| 10 | -import com.zteits.urbanops.module.workorder.controller.admin.maininfo.vo.*; | ||
| 11 | -import com.zteits.urbanops.module.workorder.dal.dataobject.maininfo.MainInfoDO; | ||
| 12 | import com.zteits.urbanops.framework.common.pojo.PageResult; | 3 | import com.zteits.urbanops.framework.common.pojo.PageResult; |
| 13 | -import com.zteits.urbanops.framework.common.pojo.PageParam; | ||
| 14 | import com.zteits.urbanops.framework.common.util.object.BeanUtils; | 4 | import com.zteits.urbanops.framework.common.util.object.BeanUtils; |
| 15 | - | 5 | +import com.zteits.urbanops.module.workorder.controller.admin.maininfo.vo.MainInfoPageReqVO; |
| 6 | +import com.zteits.urbanops.module.workorder.controller.admin.maininfo.vo.MainInfoSaveReqVO; | ||
| 7 | +import com.zteits.urbanops.module.workorder.dal.dataobject.maininfo.MainInfoDO; | ||
| 16 | import com.zteits.urbanops.module.workorder.dal.mysql.maininfo.MainInfoMapper; | 8 | import com.zteits.urbanops.module.workorder.dal.mysql.maininfo.MainInfoMapper; |
| 9 | +import jakarta.annotation.Resource; | ||
| 10 | +import org.springframework.stereotype.Service; | ||
| 11 | +import org.springframework.validation.annotation.Validated; | ||
| 12 | + | ||
| 13 | +import java.util.List; | ||
| 17 | 14 | ||
| 18 | import static com.zteits.urbanops.framework.common.exception.util.ServiceExceptionUtil.exception; | 15 | import static com.zteits.urbanops.framework.common.exception.util.ServiceExceptionUtil.exception; |
| 19 | -import static com.zteits.urbanops.framework.common.util.collection.CollectionUtils.convertList; | ||
| 20 | -import static com.zteits.urbanops.framework.common.util.collection.CollectionUtils.diffList; | ||
| 21 | -import static com.zteits.urbanops.module.workorder.enums.ErrorCodeConstants.*; | 16 | +import static com.zteits.urbanops.module.workorder.enums.ErrorCodeConstants.MAIN_INFO_NOT_EXISTS; |
| 22 | 17 | ||
| 23 | /** | 18 | /** |
| 24 | * 工单信息 Service 实现类 | 19 | * 工单信息 Service 实现类 |
| @@ -82,4 +77,9 @@ public class MainInfoServiceImpl implements MainInfoService { | @@ -82,4 +77,9 @@ public class MainInfoServiceImpl implements MainInfoService { | ||
| 82 | return mainInfoMapper.selectPage(pageReqVO); | 77 | return mainInfoMapper.selectPage(pageReqVO); |
| 83 | } | 78 | } |
| 84 | 79 | ||
| 85 | -} | ||
| 86 | \ No newline at end of file | 80 | \ No newline at end of file |
| 81 | + @Override | ||
| 82 | + public MainInfoDO getMainInfoByOrderNo(String orderNo) { | ||
| 83 | + return mainInfoMapper.selectOne(MainInfoDO::getOrderNo, orderNo); | ||
| 84 | + } | ||
| 85 | + | ||
| 86 | +} |
urbanops-module-workorder/src/main/java/com/zteits/urbanops/module/workorder/service/materialdetail/MaterialDetailService.java
| @@ -59,4 +59,12 @@ public interface MaterialDetailService { | @@ -59,4 +59,12 @@ public interface MaterialDetailService { | ||
| 59 | */ | 59 | */ |
| 60 | PageResult<MaterialDetailDO> getMaterialDetailPage(MaterialDetailPageReqVO pageReqVO); | 60 | PageResult<MaterialDetailDO> getMaterialDetailPage(MaterialDetailPageReqVO pageReqVO); |
| 61 | 61 | ||
| 62 | -} | ||
| 63 | \ No newline at end of file | 62 | \ No newline at end of file |
| 63 | + /** | ||
| 64 | + * 创建工单耗材明细 | ||
| 65 | + * | ||
| 66 | + * @param createReqVO 创建信息 | ||
| 67 | + * @return 编号 | ||
| 68 | + */ | ||
| 69 | + Boolean batchCreateMaterialDetail(@Valid List<MaterialDetailSaveReqVO> createReqVO); | ||
| 70 | + | ||
| 71 | +} |
urbanops-module-workorder/src/main/java/com/zteits/urbanops/module/workorder/service/materialdetail/MaterialDetailServiceImpl.java
| 1 | package com.zteits.urbanops.module.workorder.service.materialdetail; | 1 | package com.zteits.urbanops.module.workorder.service.materialdetail; |
| 2 | 2 | ||
| 3 | -import cn.hutool.core.collection.CollUtil; | ||
| 4 | -import org.springframework.stereotype.Service; | ||
| 5 | -import jakarta.annotation.Resource; | ||
| 6 | -import org.springframework.validation.annotation.Validated; | ||
| 7 | -import org.springframework.transaction.annotation.Transactional; | ||
| 8 | - | ||
| 9 | -import java.util.*; | ||
| 10 | -import com.zteits.urbanops.module.workorder.controller.admin.materialdetail.vo.*; | ||
| 11 | -import com.zteits.urbanops.module.workorder.dal.dataobject.materialdetail.MaterialDetailDO; | ||
| 12 | import com.zteits.urbanops.framework.common.pojo.PageResult; | 3 | import com.zteits.urbanops.framework.common.pojo.PageResult; |
| 13 | -import com.zteits.urbanops.framework.common.pojo.PageParam; | ||
| 14 | import com.zteits.urbanops.framework.common.util.object.BeanUtils; | 4 | import com.zteits.urbanops.framework.common.util.object.BeanUtils; |
| 15 | - | 5 | +import com.zteits.urbanops.module.garden.controller.admin.materialinventoryout.vo.MaterialInventoryOutSaveReqVO; |
| 6 | +import com.zteits.urbanops.module.garden.service.materialinventoryout.MaterialInventoryOutService; | ||
| 7 | +import com.zteits.urbanops.module.workorder.controller.admin.materialdetail.vo.MaterialDetailPageReqVO; | ||
| 8 | +import com.zteits.urbanops.module.workorder.controller.admin.materialdetail.vo.MaterialDetailSaveReqVO; | ||
| 9 | +import com.zteits.urbanops.module.workorder.dal.dataobject.maininfo.MainInfoDO; | ||
| 10 | +import com.zteits.urbanops.module.workorder.dal.dataobject.materialdetail.MaterialDetailDO; | ||
| 16 | import com.zteits.urbanops.module.workorder.dal.mysql.materialdetail.MaterialDetailMapper; | 11 | import com.zteits.urbanops.module.workorder.dal.mysql.materialdetail.MaterialDetailMapper; |
| 12 | +import com.zteits.urbanops.module.workorder.service.maininfo.MainInfoService; | ||
| 13 | +import jakarta.annotation.Resource; | ||
| 14 | +import org.springframework.stereotype.Service; | ||
| 15 | +import org.springframework.transaction.annotation.Transactional; | ||
| 16 | +import org.springframework.validation.annotation.Validated; | ||
| 17 | + | ||
| 18 | +import java.time.LocalDateTime; | ||
| 19 | +import java.util.List; | ||
| 20 | +import java.util.stream.Collectors; | ||
| 17 | 21 | ||
| 22 | +import static com.zteits.urbanops.framework.common.exception.enums.GlobalErrorCodeConstants.BAD_REQUEST; | ||
| 18 | import static com.zteits.urbanops.framework.common.exception.util.ServiceExceptionUtil.exception; | 23 | import static com.zteits.urbanops.framework.common.exception.util.ServiceExceptionUtil.exception; |
| 19 | -import static com.zteits.urbanops.framework.common.util.collection.CollectionUtils.convertList; | ||
| 20 | -import static com.zteits.urbanops.framework.common.util.collection.CollectionUtils.diffList; | ||
| 21 | -import static com.zteits.urbanops.module.workorder.enums.ErrorCodeConstants.*; | 24 | +import static com.zteits.urbanops.framework.common.exception.util.ServiceExceptionUtil.exception0; |
| 25 | +import static com.zteits.urbanops.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; | ||
| 26 | +import static com.zteits.urbanops.framework.security.core.util.SecurityFrameworkUtils.getLoginUserNickname; | ||
| 27 | +import static com.zteits.urbanops.module.workorder.enums.ErrorCodeConstants.MATERIAL_DETAIL_NOT_EXISTS; | ||
| 22 | 28 | ||
| 23 | /** | 29 | /** |
| 24 | * 工单耗材明细 Service 实现类 | 30 | * 工单耗材明细 Service 实现类 |
| @@ -32,10 +38,18 @@ public class MaterialDetailServiceImpl implements MaterialDetailService { | @@ -32,10 +38,18 @@ public class MaterialDetailServiceImpl implements MaterialDetailService { | ||
| 32 | @Resource | 38 | @Resource |
| 33 | private MaterialDetailMapper materialDetailMapper; | 39 | private MaterialDetailMapper materialDetailMapper; |
| 34 | 40 | ||
| 41 | + @Resource | ||
| 42 | + private MaterialInventoryOutService materialInventoryOutService; | ||
| 43 | + | ||
| 44 | + @Resource | ||
| 45 | + private MainInfoService mainInfoService; | ||
| 46 | + | ||
| 35 | @Override | 47 | @Override |
| 36 | public Long createMaterialDetail(MaterialDetailSaveReqVO createReqVO) { | 48 | public Long createMaterialDetail(MaterialDetailSaveReqVO createReqVO) { |
| 37 | // 插入 | 49 | // 插入 |
| 38 | MaterialDetailDO materialDetail = BeanUtils.toBean(createReqVO, MaterialDetailDO.class); | 50 | MaterialDetailDO materialDetail = BeanUtils.toBean(createReqVO, MaterialDetailDO.class); |
| 51 | + materialDetail.setUserId(getLoginUserId()); | ||
| 52 | + materialDetail.setUserName(getLoginUserNickname()); | ||
| 39 | materialDetailMapper.insert(materialDetail); | 53 | materialDetailMapper.insert(materialDetail); |
| 40 | 54 | ||
| 41 | // 返回 | 55 | // 返回 |
| @@ -82,4 +96,39 @@ public class MaterialDetailServiceImpl implements MaterialDetailService { | @@ -82,4 +96,39 @@ public class MaterialDetailServiceImpl implements MaterialDetailService { | ||
| 82 | return materialDetailMapper.selectPage(pageReqVO); | 96 | return materialDetailMapper.selectPage(pageReqVO); |
| 83 | } | 97 | } |
| 84 | 98 | ||
| 85 | -} | ||
| 86 | \ No newline at end of file | 99 | \ No newline at end of file |
| 100 | + @Override | ||
| 101 | + @Transactional | ||
| 102 | + public Boolean batchCreateMaterialDetail(List<MaterialDetailSaveReqVO> createReqVO) { | ||
| 103 | + | ||
| 104 | + List<MaterialDetailDO> materialDetailList = createReqVO.stream() | ||
| 105 | + .map(vo -> { | ||
| 106 | + MaterialDetailDO detailDO = new MaterialDetailDO(); | ||
| 107 | + BeanUtils.copyProperties(vo, detailDO); // 单个对象属性拷贝 | ||
| 108 | + detailDO.setUserId(getLoginUserId()); | ||
| 109 | + detailDO.setUserName(getLoginUserNickname()); | ||
| 110 | + return detailDO; | ||
| 111 | + }) | ||
| 112 | + .collect(Collectors.toList()); | ||
| 113 | + | ||
| 114 | + //订单号校验 | ||
| 115 | + for (MaterialDetailDO materialDetailDO : materialDetailList) { | ||
| 116 | + MainInfoDO mainInfoDO = mainInfoService.getMainInfoByOrderNo(materialDetailDO.getOrderNo()); | ||
| 117 | + if (mainInfoDO == null) { | ||
| 118 | + throw exception0(BAD_REQUEST.getCode(),"订单号"+materialDetailDO.getOrderNo()+"不存在"); | ||
| 119 | + } | ||
| 120 | + } | ||
| 121 | + //耗材出库 | ||
| 122 | + for (MaterialDetailDO materialDetailDO : materialDetailList) { | ||
| 123 | + MaterialInventoryOutSaveReqVO materialInventoryOutSaveReqVO = new MaterialInventoryOutSaveReqVO(); | ||
| 124 | + materialInventoryOutSaveReqVO.setMaterialId(materialDetailDO.getMaterialId()); | ||
| 125 | + materialInventoryOutSaveReqVO.setMaterialName(materialDetailDO.getMaterialName()); | ||
| 126 | + materialInventoryOutSaveReqVO.setOutInventoryNum(materialDetailDO.getUserCount()); | ||
| 127 | + materialInventoryOutSaveReqVO.setOutDate(LocalDateTime.now()); | ||
| 128 | + materialInventoryOutService.createMaterialInventoryOut(materialInventoryOutSaveReqVO); | ||
| 129 | + } | ||
| 130 | + //保存耗材 | ||
| 131 | + materialDetailMapper.insertBatch(materialDetailList); | ||
| 132 | + return Boolean.TRUE; | ||
| 133 | + } | ||
| 134 | + | ||
| 135 | +} |