diff --git a/mes-module-chemmes/mes-module-chemmes-api/src/main/java/com/ningxia/yunxi/chemmes/module/biz/enums/ErrorCodeConstants.java b/mes-module-chemmes/mes-module-chemmes-api/src/main/java/com/ningxia/yunxi/chemmes/module/biz/enums/ErrorCodeConstants.java index d167711..88829a4 100644 --- a/mes-module-chemmes/mes-module-chemmes-api/src/main/java/com/ningxia/yunxi/chemmes/module/biz/enums/ErrorCodeConstants.java +++ b/mes-module-chemmes/mes-module-chemmes-api/src/main/java/com/ningxia/yunxi/chemmes/module/biz/enums/ErrorCodeConstants.java @@ -70,4 +70,8 @@ public interface ErrorCodeConstants { ErrorCode CUSTOMER_CODE_DUPLICATE = new ErrorCode(1_001_024, "客户编码不能重复"); ErrorCode CUSTOMER_NAME_DUPLICATE = new ErrorCode(1_001_025, "客户名称不能重复"); + + /********************质检方案信息*************************/ + ErrorCode INS_PLAN_SCHEME_NAME_DUPLICATE = new ErrorCode(1_001_026, "质检方案名称不能重复"); + ErrorCode INS_PLAN_SCHEME_NO_DUPLICATE = new ErrorCode(1_001_027, "质检方案编号不能重复"); } diff --git a/mes-module-chemmes/mes-module-chemmes-biz/src/main/java/com/ningxia/yunxi/chemmes/module/biz/controller/admin/checkitem/vo/CheckItemPageReqVO.java b/mes-module-chemmes/mes-module-chemmes-biz/src/main/java/com/ningxia/yunxi/chemmes/module/biz/controller/admin/checkitem/vo/CheckItemPageReqVO.java index fd73d30..0d0d65f 100644 --- a/mes-module-chemmes/mes-module-chemmes-biz/src/main/java/com/ningxia/yunxi/chemmes/module/biz/controller/admin/checkitem/vo/CheckItemPageReqVO.java +++ b/mes-module-chemmes/mes-module-chemmes-biz/src/main/java/com/ningxia/yunxi/chemmes/module/biz/controller/admin/checkitem/vo/CheckItemPageReqVO.java @@ -49,4 +49,5 @@ public class CheckItemPageReqVO extends PageParam { private String printAvgValues; @Schema(description = "编号") private String itemNo; + private String keyWord; } diff --git a/mes-module-chemmes/mes-module-chemmes-biz/src/main/java/com/ningxia/yunxi/chemmes/module/biz/controller/admin/inspplan/InspPlanController.java b/mes-module-chemmes/mes-module-chemmes-biz/src/main/java/com/ningxia/yunxi/chemmes/module/biz/controller/admin/inspplan/InspPlanController.java index 13f8fde..8e51b84 100644 --- a/mes-module-chemmes/mes-module-chemmes-biz/src/main/java/com/ningxia/yunxi/chemmes/module/biz/controller/admin/inspplan/InspPlanController.java +++ b/mes-module-chemmes/mes-module-chemmes-biz/src/main/java/com/ningxia/yunxi/chemmes/module/biz/controller/admin/inspplan/InspPlanController.java @@ -39,7 +39,7 @@ public class InspPlanController { @PostMapping("/create") @Operation(summary = "创建质检方案表主") @PreAuthorize("@ss.hasPermission('biz:insp-plan:create')") - public CommonResult createInspPlan(@Valid @RequestBody InspPlanSaveReqVO createReqVO) { + public CommonResult createInspPlan(@Valid @RequestBody InspPlanSaveReqVO createReqVO) { return success(inspPlanService.createInspPlan(createReqVO)); } @@ -55,7 +55,7 @@ public class InspPlanController { @Operation(summary = "删除质检方案表主") @Parameter(name = "id", description = "编号", required = true) @PreAuthorize("@ss.hasPermission('biz:insp-plan:delete')") - public CommonResult deleteInspPlan(@RequestParam("id") String id) { + public CommonResult deleteInspPlan(@RequestParam("id") Integer id) { inspPlanService.deleteInspPlan(id); return success(true); } @@ -64,7 +64,7 @@ public class InspPlanController { @Operation(summary = "获得质检方案表主") @Parameter(name = "id", description = "编号", required = true, example = "1024") @PreAuthorize("@ss.hasPermission('biz:insp-plan:query')") - public CommonResult getInspPlan(@RequestParam("id") String id) { + public CommonResult getInspPlan(@RequestParam("id") Integer id) { InspPlanDO inspPlan = inspPlanService.getInspPlan(id); return success(BeanUtils.toBean(inspPlan, InspPlanRespVO.class)); } diff --git a/mes-module-chemmes/mes-module-chemmes-biz/src/main/java/com/ningxia/yunxi/chemmes/module/biz/controller/admin/inspplan/vo/InspPlanRespVO.java b/mes-module-chemmes/mes-module-chemmes-biz/src/main/java/com/ningxia/yunxi/chemmes/module/biz/controller/admin/inspplan/vo/InspPlanRespVO.java index fe0cfd8..14a6aac 100644 --- a/mes-module-chemmes/mes-module-chemmes-biz/src/main/java/com/ningxia/yunxi/chemmes/module/biz/controller/admin/inspplan/vo/InspPlanRespVO.java +++ b/mes-module-chemmes/mes-module-chemmes-biz/src/main/java/com/ningxia/yunxi/chemmes/module/biz/controller/admin/inspplan/vo/InspPlanRespVO.java @@ -17,7 +17,7 @@ public class InspPlanRespVO { @Schema(description = "id", requiredMode = Schema.RequiredMode.REQUIRED, example = "17012") @ExcelProperty("id") - private String id; + private Integer id; @Schema(description = "质检方案编号") @ExcelProperty("质检方案编号") diff --git a/mes-module-chemmes/mes-module-chemmes-biz/src/main/java/com/ningxia/yunxi/chemmes/module/biz/controller/admin/inspplan/vo/InspPlanSaveReqVO.java b/mes-module-chemmes/mes-module-chemmes-biz/src/main/java/com/ningxia/yunxi/chemmes/module/biz/controller/admin/inspplan/vo/InspPlanSaveReqVO.java index 7e101b4..23bf19a 100644 --- a/mes-module-chemmes/mes-module-chemmes-biz/src/main/java/com/ningxia/yunxi/chemmes/module/biz/controller/admin/inspplan/vo/InspPlanSaveReqVO.java +++ b/mes-module-chemmes/mes-module-chemmes-biz/src/main/java/com/ningxia/yunxi/chemmes/module/biz/controller/admin/inspplan/vo/InspPlanSaveReqVO.java @@ -1,47 +1,51 @@ -package com.ningxia.yunxi.chemmes.module.biz.controller.admin.inspplan.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.*; -import java.util.*; -import javax.validation.constraints.*; -import java.util.*; - -@Schema(description = "管理后台 - 质检方案表主新增/修改 Request VO") -@Data -public class InspPlanSaveReqVO { - - @Schema(description = "id", requiredMode = Schema.RequiredMode.REQUIRED, example = "17012") - private String id; - - @Schema(description = "质检方案编号") - private String schemeNo; - - @Schema(description = "质检方案名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "赵六") - @NotEmpty(message = "质检方案名称不能为空") - private String schemeName; - - @Schema(description = "描述", example = "你猜") - private String remark; - - @Schema(description = "适用类型,1表示原材料 2表示半成品 3表示成品", example = "2") - private Integer schemeType; - - @Schema(description = "分类编码") - private String tiemClass; - - @Schema(description = "表单编号") - private String formCode; - - @Schema(description = "执行标准") - private String execStandard; - - @Schema(description = "检验值数量") - private Integer testNum; - - @Schema(description = "打印模板编码") - private String printCode; - - @Schema(description = "打印模板名称", example = "张三") - private String printName; - -} \ No newline at end of file +package com.ningxia.yunxi.chemmes.module.biz.controller.admin.inspplan.vo; + +import com.ningxia.yunxi.chemmes.module.biz.controller.admin.inspplanitem.vo.InspPlanItemSaveReqVO; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.*; +import java.util.*; +import javax.validation.constraints.*; +import java.util.*; + +@Schema(description = "管理后台 - 质检方案表主新增/修改 Request VO") +@Data +public class InspPlanSaveReqVO { + + @Schema(description = "id", requiredMode = Schema.RequiredMode.REQUIRED, example = "17012") + private Integer id; + + @Schema(description = "质检方案编号") + private String schemeNo; + + @Schema(description = "质检方案名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "赵六") + @NotEmpty(message = "质检方案名称不能为空") + private String schemeName; + + @Schema(description = "描述", example = "你猜") + private String remark; + + @Schema(description = "适用类型,1表示原材料 2表示半成品 3表示成品", example = "2") + private Integer schemeType; + + @Schema(description = "分类编码") + private String tiemClass; + + @Schema(description = "表单编号") + private String formCode; + + @Schema(description = "执行标准") + private String execStandard; + + @Schema(description = "检验值数量") + private Integer testNum; + + @Schema(description = "打印模板编码") + private String printCode; + + @Schema(description = "打印模板名称", example = "张三") + private String printName; + + @Schema(description = "子表列表") + private List inspPlanItemList; + +} diff --git a/mes-module-chemmes/mes-module-chemmes-biz/src/main/java/com/ningxia/yunxi/chemmes/module/biz/controller/admin/inspplanitem/InspPlanItemController.java b/mes-module-chemmes/mes-module-chemmes-biz/src/main/java/com/ningxia/yunxi/chemmes/module/biz/controller/admin/inspplanitem/InspPlanItemController.java index 99648bc..1d08527 100644 --- a/mes-module-chemmes/mes-module-chemmes-biz/src/main/java/com/ningxia/yunxi/chemmes/module/biz/controller/admin/inspplanitem/InspPlanItemController.java +++ b/mes-module-chemmes/mes-module-chemmes-biz/src/main/java/com/ningxia/yunxi/chemmes/module/biz/controller/admin/inspplanitem/InspPlanItemController.java @@ -41,7 +41,7 @@ public class InspPlanItemController { @PostMapping("/create") @Operation(summary = "创建质检方案子") @PreAuthorize("@ss.hasPermission('tba:insp-plan-item:create')") - public CommonResult createInspPlanItem(@Valid @RequestBody InspPlanItemSaveReqVO createReqVO) { + public CommonResult createInspPlanItem(@Valid @RequestBody InspPlanItemSaveReqVO createReqVO) { return success(inspPlanItemService.createInspPlanItem(createReqVO)); } @@ -57,7 +57,7 @@ public class InspPlanItemController { @Operation(summary = "删除质检方案子") @Parameter(name = "id", description = "编号", required = true) @PreAuthorize("@ss.hasPermission('tba:insp-plan-item:delete')") - public CommonResult deleteInspPlanItem(@RequestParam("id") String id) { + public CommonResult deleteInspPlanItem(@RequestParam("id") Integer id) { inspPlanItemService.deleteInspPlanItem(id); return success(true); } @@ -66,7 +66,7 @@ public class InspPlanItemController { @Operation(summary = "获得质检方案子") @Parameter(name = "id", description = "编号", required = true, example = "1024") @PreAuthorize("@ss.hasPermission('tba:insp-plan-item:query')") - public CommonResult getInspPlanItem(@RequestParam("id") String id) { + public CommonResult getInspPlanItem(@RequestParam("id") Integer id) { InspPlanItemDO inspPlanItem = inspPlanItemService.getInspPlanItem(id); return success(BeanUtils.toBean(inspPlanItem, InspPlanItemRespVO.class)); } @@ -91,5 +91,11 @@ public class InspPlanItemController { ExcelUtils.write(response, "质检方案子.xls", "数据", InspPlanItemRespVO.class, BeanUtils.toBean(list, InspPlanItemRespVO.class)); } - + @GetMapping("/getInspPlanItemByPlanId") + @Operation(summary = "获得质检方案子") + @Parameter(name = "id", description = "编号", required = true, example = "1024") + @PreAuthorize("@ss.hasPermission('tba:insp-plan-item:query')") + public CommonResult> getInspPlanItemByPlanId(@RequestParam("planId") Integer planId) { + return success(inspPlanItemService.getInspPlanItemByPlanId(planId)); + } } diff --git a/mes-module-chemmes/mes-module-chemmes-biz/src/main/java/com/ningxia/yunxi/chemmes/module/biz/controller/admin/inspplanitem/vo/InspPlanItemSaveReqVO.java b/mes-module-chemmes/mes-module-chemmes-biz/src/main/java/com/ningxia/yunxi/chemmes/module/biz/controller/admin/inspplanitem/vo/InspPlanItemSaveReqVO.java index 2371a81..209fd7d 100644 --- a/mes-module-chemmes/mes-module-chemmes-biz/src/main/java/com/ningxia/yunxi/chemmes/module/biz/controller/admin/inspplanitem/vo/InspPlanItemSaveReqVO.java +++ b/mes-module-chemmes/mes-module-chemmes-biz/src/main/java/com/ningxia/yunxi/chemmes/module/biz/controller/admin/inspplanitem/vo/InspPlanItemSaveReqVO.java @@ -1,5 +1,6 @@ package com.ningxia.yunxi.chemmes.module.biz.controller.admin.inspplanitem.vo; +import com.ningxia.yunxi.chemmes.module.biz.dal.dataobject.inspplanitem.InspPlanItemDO; import io.swagger.v3.oas.annotations.media.Schema; import lombok.*; import java.util.*; @@ -11,13 +12,13 @@ import java.util.*; public class InspPlanItemSaveReqVO { @Schema(description = "id", requiredMode = Schema.RequiredMode.REQUIRED, example = "16314") - private String id; + private Integer id; @Schema(description = "质检方案id,对应qa_scheme_base中的id列", example = "4222") - private String schemeId; + private Integer schemeId; @Schema(description = "检验项目id,对应qa_check_item_base中的id列", example = "32292") - private String itemId; + private Integer itemId; @Schema(description = "单位") private String unit; @@ -48,5 +49,7 @@ public class InspPlanItemSaveReqVO { @Schema(description = "模板检测值数量") private Integer printNum; + @Schema(description = "明细列表") + private List inspPlanItemList; } diff --git a/mes-module-chemmes/mes-module-chemmes-biz/src/main/java/com/ningxia/yunxi/chemmes/module/biz/dal/dataobject/inspplan/InspPlanDO.java b/mes-module-chemmes/mes-module-chemmes-biz/src/main/java/com/ningxia/yunxi/chemmes/module/biz/dal/dataobject/inspplan/InspPlanDO.java index 7157273..967b8be 100644 --- a/mes-module-chemmes/mes-module-chemmes-biz/src/main/java/com/ningxia/yunxi/chemmes/module/biz/dal/dataobject/inspplan/InspPlanDO.java +++ b/mes-module-chemmes/mes-module-chemmes-biz/src/main/java/com/ningxia/yunxi/chemmes/module/biz/dal/dataobject/inspplan/InspPlanDO.java @@ -25,8 +25,7 @@ public class InspPlanDO extends BaseDO { /** * id */ - @TableId(type = IdType.INPUT) - private String id; + private Integer id; /** * 质检方案编号 */ diff --git a/mes-module-chemmes/mes-module-chemmes-biz/src/main/java/com/ningxia/yunxi/chemmes/module/biz/dal/dataobject/inspplanitem/InspPlanItemDO.java b/mes-module-chemmes/mes-module-chemmes-biz/src/main/java/com/ningxia/yunxi/chemmes/module/biz/dal/dataobject/inspplanitem/InspPlanItemDO.java index 7ab73f6..b2df6d4 100644 --- a/mes-module-chemmes/mes-module-chemmes-biz/src/main/java/com/ningxia/yunxi/chemmes/module/biz/dal/dataobject/inspplanitem/InspPlanItemDO.java +++ b/mes-module-chemmes/mes-module-chemmes-biz/src/main/java/com/ningxia/yunxi/chemmes/module/biz/dal/dataobject/inspplanitem/InspPlanItemDO.java @@ -25,12 +25,11 @@ public class InspPlanItemDO extends BaseDO { /** * id */ - @TableId(type = IdType.INPUT) - private String id; + private Integer id; /** * 质检方案id,对应qa_scheme_base中的id列 */ - private String schemeId; + private Integer schemeId; /** * 检验项目id,对应qa_check_item_base中的id列 */ diff --git a/mes-module-chemmes/mes-module-chemmes-biz/src/main/java/com/ningxia/yunxi/chemmes/module/biz/dal/mysql/checkitem/CheckItemMapper.java b/mes-module-chemmes/mes-module-chemmes-biz/src/main/java/com/ningxia/yunxi/chemmes/module/biz/dal/mysql/checkitem/CheckItemMapper.java index 3bad75f..6b6aa8c 100644 --- a/mes-module-chemmes/mes-module-chemmes-biz/src/main/java/com/ningxia/yunxi/chemmes/module/biz/dal/mysql/checkitem/CheckItemMapper.java +++ b/mes-module-chemmes/mes-module-chemmes-biz/src/main/java/com/ningxia/yunxi/chemmes/module/biz/dal/mysql/checkitem/CheckItemMapper.java @@ -2,10 +2,13 @@ package com.ningxia.yunxi.chemmes.module.biz.dal.mysql.checkitem; import java.util.*; +import cn.hutool.core.util.ObjectUtil; import com.ningxia.yunxi.chemmes.framework.common.pojo.PageResult; import com.ningxia.yunxi.chemmes.framework.mybatis.core.query.LambdaQueryWrapperX; import com.ningxia.yunxi.chemmes.framework.mybatis.core.mapper.BaseMapperX; import com.ningxia.yunxi.chemmes.module.biz.dal.dataobject.checkitem.CheckItemDO; +import com.ningxia.yunxi.chemmes.module.biz.dal.dataobject.inspplan.InspPlanDO; +import org.apache.commons.lang3.StringUtils; import org.apache.ibatis.annotations.Mapper; import com.ningxia.yunxi.chemmes.module.biz.controller.admin.checkitem.vo.*; @@ -47,7 +50,10 @@ public interface CheckItemMapper extends BaseMapperX { .eqIfPresent(CheckItemDO::getTestNum, reqVO.getTestNum()) .eqIfPresent(CheckItemDO::getFloatNum, reqVO.getFloatNum()) .eqIfPresent(CheckItemDO::getPrintAvgValues, reqVO.getPrintAvgValues()) - .orderByDesc(CheckItemDO::getCreateTime)); + .orderByDesc(CheckItemDO::getCreateTime) .and(ObjectUtil.isNotEmpty(reqVO.getKeyWord()), wrapper -> wrapper + .like(CheckItemDO::getItemName, reqVO.getKeyWord()) + .or() + .like(CheckItemDO::getItemNo, reqVO.getKeyWord()))); } } diff --git a/mes-module-chemmes/mes-module-chemmes-biz/src/main/java/com/ningxia/yunxi/chemmes/module/biz/dal/mysql/inspplan/InspPlanMapper.java b/mes-module-chemmes/mes-module-chemmes-biz/src/main/java/com/ningxia/yunxi/chemmes/module/biz/dal/mysql/inspplan/InspPlanMapper.java index 129b055..aa814f5 100644 --- a/mes-module-chemmes/mes-module-chemmes-biz/src/main/java/com/ningxia/yunxi/chemmes/module/biz/dal/mysql/inspplan/InspPlanMapper.java +++ b/mes-module-chemmes/mes-module-chemmes-biz/src/main/java/com/ningxia/yunxi/chemmes/module/biz/dal/mysql/inspplan/InspPlanMapper.java @@ -33,4 +33,26 @@ public interface InspPlanMapper extends BaseMapperX { .like(InspPlanDO::getSchemeNo, keyWord)) ); } + + default InspPlanDO selectBySchemeName(String schemeName) { + return selectOne(new LambdaQueryWrapperX() + .eq(InspPlanDO::getSchemeName, schemeName)); + } + + default InspPlanDO selectBySchemeNameExcludeId(String schemeName, Integer excludeId) { + return selectOne(new LambdaQueryWrapperX() + .eq(InspPlanDO::getSchemeName, schemeName) + .ne(InspPlanDO::getId, excludeId)); + } + + default InspPlanDO selectBySchemeNo(String schemeNo) { + return selectOne(new LambdaQueryWrapperX() + .eq(InspPlanDO::getSchemeNo, schemeNo)); + } + + default InspPlanDO selectBySchemeNoExcludeId(String schemeNo, Integer excludeId) { + return selectOne(new LambdaQueryWrapperX() + .eq(InspPlanDO::getSchemeNo, schemeNo) + .ne(InspPlanDO::getId, excludeId)); + } } diff --git a/mes-module-chemmes/mes-module-chemmes-biz/src/main/java/com/ningxia/yunxi/chemmes/module/biz/dal/mysql/inspplanitem/InspPlanItemMapper.java b/mes-module-chemmes/mes-module-chemmes-biz/src/main/java/com/ningxia/yunxi/chemmes/module/biz/dal/mysql/inspplanitem/InspPlanItemMapper.java index 7eee318..1b4d5bf 100644 --- a/mes-module-chemmes/mes-module-chemmes-biz/src/main/java/com/ningxia/yunxi/chemmes/module/biz/dal/mysql/inspplanitem/InspPlanItemMapper.java +++ b/mes-module-chemmes/mes-module-chemmes-biz/src/main/java/com/ningxia/yunxi/chemmes/module/biz/dal/mysql/inspplanitem/InspPlanItemMapper.java @@ -7,6 +7,8 @@ import com.ningxia.yunxi.chemmes.module.biz.controller.admin.inspplanitem.vo.Ins import com.ningxia.yunxi.chemmes.module.biz.dal.dataobject.inspplanitem.InspPlanItemDO; import org.apache.ibatis.annotations.Mapper; +import java.util.List; + /** * 质检方案子 Mapper * @@ -38,4 +40,20 @@ public interface InspPlanItemMapper extends BaseMapperX { .eq(InspPlanItemDO::getItemId, id)); } + default List getInspPlanItemByPlanId(Integer planId){ + return selectList(new LambdaQueryWrapperX() + .eq(InspPlanItemDO::getSchemeId, planId) + .orderByAsc(InspPlanItemDO::getSeqNo)); + } + + default InspPlanItemDO selectBySchemeIdAndItemId(Integer schemeId, Integer itemId) { + return selectOne(new LambdaQueryWrapperX() + .eq(InspPlanItemDO::getSchemeId, schemeId) + .eq(InspPlanItemDO::getItemId, itemId)); + } + + default int deleteBySchemeId(Integer schemeId) { + return delete(new LambdaQueryWrapperX() + .eq(InspPlanItemDO::getSchemeId, schemeId)); + } } diff --git a/mes-module-chemmes/mes-module-chemmes-biz/src/main/java/com/ningxia/yunxi/chemmes/module/biz/dal/mysql/techproc/TechProcMapper.java b/mes-module-chemmes/mes-module-chemmes-biz/src/main/java/com/ningxia/yunxi/chemmes/module/biz/dal/mysql/techproc/TechProcMapper.java index 2a44384..51513b7 100644 --- a/mes-module-chemmes/mes-module-chemmes-biz/src/main/java/com/ningxia/yunxi/chemmes/module/biz/dal/mysql/techproc/TechProcMapper.java +++ b/mes-module-chemmes/mes-module-chemmes-biz/src/main/java/com/ningxia/yunxi/chemmes/module/biz/dal/mysql/techproc/TechProcMapper.java @@ -33,7 +33,7 @@ public interface TechProcMapper extends BaseMapperX { default Long selectByTechProcCount(String techProc, Integer id){ return selectCount(new MPJLambdaWrapper() .eq(TechProcDO::getTechProc, techProc) - .eq(TechProcDO::getId, id) + .ne(ObjectUtil.isNotEmpty(id),TechProcDO::getId, id) ); } diff --git a/mes-module-chemmes/mes-module-chemmes-biz/src/main/java/com/ningxia/yunxi/chemmes/module/biz/service/inspplan/InspPlanService.java b/mes-module-chemmes/mes-module-chemmes-biz/src/main/java/com/ningxia/yunxi/chemmes/module/biz/service/inspplan/InspPlanService.java index 37b83a9..9f2bb94 100644 --- a/mes-module-chemmes/mes-module-chemmes-biz/src/main/java/com/ningxia/yunxi/chemmes/module/biz/service/inspplan/InspPlanService.java +++ b/mes-module-chemmes/mes-module-chemmes-biz/src/main/java/com/ningxia/yunxi/chemmes/module/biz/service/inspplan/InspPlanService.java @@ -21,7 +21,7 @@ public interface InspPlanService { * @param createReqVO 创建信息 * @return 编号 */ - String createInspPlan(@Valid InspPlanSaveReqVO createReqVO); + Integer createInspPlan(@Valid InspPlanSaveReqVO createReqVO); /** * 更新质检方案表主 @@ -35,7 +35,7 @@ public interface InspPlanService { * * @param id 编号 */ - void deleteInspPlan(String id); + void deleteInspPlan(Integer id); /** * 获得质检方案表主 @@ -43,7 +43,7 @@ public interface InspPlanService { * @param id 编号 * @return 质检方案表主 */ - InspPlanDO getInspPlan(String id); + InspPlanDO getInspPlan(Integer id); /** * 获得质检方案表主分页 diff --git a/mes-module-chemmes/mes-module-chemmes-biz/src/main/java/com/ningxia/yunxi/chemmes/module/biz/service/inspplan/InspPlanServiceImpl.java b/mes-module-chemmes/mes-module-chemmes-biz/src/main/java/com/ningxia/yunxi/chemmes/module/biz/service/inspplan/InspPlanServiceImpl.java index e38d342..86c62a9 100644 --- a/mes-module-chemmes/mes-module-chemmes-biz/src/main/java/com/ningxia/yunxi/chemmes/module/biz/service/inspplan/InspPlanServiceImpl.java +++ b/mes-module-chemmes/mes-module-chemmes-biz/src/main/java/com/ningxia/yunxi/chemmes/module/biz/service/inspplan/InspPlanServiceImpl.java @@ -1,16 +1,28 @@ package com.ningxia.yunxi.chemmes.module.biz.service.inspplan; +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.StrUtil; import com.ningxia.yunxi.chemmes.framework.common.pojo.PageResult; import com.ningxia.yunxi.chemmes.framework.common.util.object.BeanUtils; import com.ningxia.yunxi.chemmes.module.biz.controller.admin.inspplan.vo.InspPlanPageReqVO; import com.ningxia.yunxi.chemmes.module.biz.controller.admin.inspplan.vo.InspPlanSaveReqVO; +import com.ningxia.yunxi.chemmes.module.biz.controller.admin.inspplanitem.vo.InspPlanItemSaveReqVO; import com.ningxia.yunxi.chemmes.module.biz.dal.dataobject.inspplan.InspPlanDO; +import com.ningxia.yunxi.chemmes.module.biz.dal.dataobject.inspplanitem.InspPlanItemDO; import com.ningxia.yunxi.chemmes.module.biz.dal.mysql.inspplan.InspPlanMapper; +import com.ningxia.yunxi.chemmes.module.biz.dal.mysql.inspplanitem.InspPlanItemMapper; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; import org.springframework.validation.annotation.Validated; import javax.annotation.Resource; import java.util.List; +import java.util.UUID; +import java.util.stream.Collectors; + +import static com.ningxia.yunxi.chemmes.framework.common.exception.util.ServiceExceptionUtil.exception; +import static com.ningxia.yunxi.chemmes.module.biz.enums.ErrorCodeConstants.*; /** * 质检方案表主 Service 实现类 @@ -24,40 +36,106 @@ public class InspPlanServiceImpl implements InspPlanService { @Resource private InspPlanMapper inspPlanMapper; + @Resource + private InspPlanItemMapper inspPlanItemMapper; + @Override - public String createInspPlan(InspPlanSaveReqVO createReqVO) { - // 插入 + @Transactional(rollbackFor = Exception.class) + public Integer createInspPlan(InspPlanSaveReqVO createReqVO) { + // 校验方案名称不能重复 + if (inspPlanMapper.selectBySchemeName(createReqVO.getSchemeName()) != null) { + throw exception(INS_PLAN_SCHEME_NAME_DUPLICATE); + } + // 校验方案编号不能重复 + if (createReqVO.getSchemeNo() != null && inspPlanMapper.selectBySchemeNo(createReqVO.getSchemeNo()) != null) { + throw exception(INS_PLAN_SCHEME_NO_DUPLICATE); + } + // 插入主表 InspPlanDO inspPlan = BeanUtils.toBean(createReqVO, InspPlanDO.class); inspPlanMapper.insert(inspPlan); + + // 处理子表 + saveInspPlanItemList(inspPlan.getId(), createReqVO.getInspPlanItemList()); + // 返回 return inspPlan.getId(); } @Override + @Transactional(rollbackFor = Exception.class) public void updateInspPlan(InspPlanSaveReqVO updateReqVO) { // 校验存在 validateInspPlanExists(updateReqVO.getId()); - // 更新 + // 校验方案名称不能重复(排除自身) + if (inspPlanMapper.selectBySchemeNameExcludeId(updateReqVO.getSchemeName(), updateReqVO.getId()) != null) { + throw exception(INS_PLAN_SCHEME_NAME_DUPLICATE); + } + // 校验方案编号不能重复(排除自身) + if (updateReqVO.getSchemeNo() != null && inspPlanMapper.selectBySchemeNoExcludeId(updateReqVO.getSchemeNo(), updateReqVO.getId()) != null) { + throw exception(INS_PLAN_SCHEME_NO_DUPLICATE); + } + // 更新主表 InspPlanDO updateObj = BeanUtils.toBean(updateReqVO, InspPlanDO.class); inspPlanMapper.updateById(updateObj); + + // 处理子表 + saveInspPlanItemList(updateReqVO.getId(), updateReqVO.getInspPlanItemList()); } - @Override - public void deleteInspPlan(String id) { - // 校验存在 - validateInspPlanExists(id); - // 删除 - inspPlanMapper.deleteById(id); - } + /** + * 保存子表列表 + */ + private void saveInspPlanItemList(Integer schemeId, List itemList) { + if (CollUtil.isEmpty(itemList)) { + return; + } - private void validateInspPlanExists(String id) { - if (inspPlanMapper.selectById(id) == null) { -// throw exception(INSP_PLAN_NOT_EXISTS); + // 处理子表:如果子表数据没有 id 但有相同的 schemeId + itemId,则复用已有的 id + List collect = itemList.stream() + .filter(model -> ObjectUtil.isEmpty(model.getId())) + .collect(Collectors.toList()); + + boolean updated = false; + if (CollUtil.isNotEmpty(collect)) { + for (InspPlanItemSaveReqVO model : collect) { + // 查询是否已存在相同的 schemeId + itemId + InspPlanItemDO existItem = inspPlanItemMapper.selectBySchemeIdAndItemId(schemeId, model.getItemId()); + if (existItem != null) { + model.setId(existItem.getId()); + updated = true; + } + } + } + + // 删除该方案下所有旧的子表数据 + inspPlanItemMapper.deleteBySchemeId(schemeId); + + // 重新插入/更新子表数据 + for (InspPlanItemSaveReqVO item : itemList) { + InspPlanItemDO inspPlanItem = BeanUtils.toBean(item, InspPlanItemDO.class); + inspPlanItem.setSchemeId(schemeId); + inspPlanItemMapper.insertOrUpdate(inspPlanItem); } } @Override - public InspPlanDO getInspPlan(String id) { + public void deleteInspPlan(Integer id) { + // 校验存在 + validateInspPlanExists(id); + // 删除子表 + inspPlanItemMapper.deleteBySchemeId(id); + // 删除主表 + inspPlanMapper.deleteById(id); + } + + private void validateInspPlanExists(Integer id) { + if (inspPlanMapper.selectById(id) == null) { + throw exception("数据不存在"); + } + } + + @Override + public InspPlanDO getInspPlan(Integer id) { return inspPlanMapper.selectById(id); } diff --git a/mes-module-chemmes/mes-module-chemmes-biz/src/main/java/com/ningxia/yunxi/chemmes/module/biz/service/inspplanitem/InspPlanItemService.java b/mes-module-chemmes/mes-module-chemmes-biz/src/main/java/com/ningxia/yunxi/chemmes/module/biz/service/inspplanitem/InspPlanItemService.java index e9b68d1..7046134 100644 --- a/mes-module-chemmes/mes-module-chemmes-biz/src/main/java/com/ningxia/yunxi/chemmes/module/biz/service/inspplanitem/InspPlanItemService.java +++ b/mes-module-chemmes/mes-module-chemmes-biz/src/main/java/com/ningxia/yunxi/chemmes/module/biz/service/inspplanitem/InspPlanItemService.java @@ -6,6 +6,7 @@ import com.ningxia.yunxi.chemmes.module.biz.controller.admin.inspplanitem.vo.Ins import com.ningxia.yunxi.chemmes.module.biz.dal.dataobject.inspplanitem.InspPlanItemDO; import javax.validation.Valid; +import java.util.List; /** * 质检方案子 Service 接口 @@ -20,7 +21,7 @@ public interface InspPlanItemService { * @param createReqVO 创建信息 * @return 编号 */ - String createInspPlanItem(@Valid InspPlanItemSaveReqVO createReqVO); + Integer createInspPlanItem(@Valid InspPlanItemSaveReqVO createReqVO); /** * 更新质检方案子 @@ -34,7 +35,7 @@ public interface InspPlanItemService { * * @param id 编号 */ - void deleteInspPlanItem(String id); + void deleteInspPlanItem(Integer id); /** * 获得质检方案子 @@ -42,7 +43,7 @@ public interface InspPlanItemService { * @param id 编号 * @return 质检方案子 */ - InspPlanItemDO getInspPlanItem(String id); + InspPlanItemDO getInspPlanItem(Integer id); /** * 获得质检方案子分页 @@ -52,4 +53,5 @@ public interface InspPlanItemService { */ PageResult getInspPlanItemPage(InspPlanItemPageReqVO pageReqVO); + List getInspPlanItemByPlanId(Integer planId); } diff --git a/mes-module-chemmes/mes-module-chemmes-biz/src/main/java/com/ningxia/yunxi/chemmes/module/biz/service/inspplanitem/InspPlanItemServiceImpl.java b/mes-module-chemmes/mes-module-chemmes-biz/src/main/java/com/ningxia/yunxi/chemmes/module/biz/service/inspplanitem/InspPlanItemServiceImpl.java index 8f4f55c..6d65726 100644 --- a/mes-module-chemmes/mes-module-chemmes-biz/src/main/java/com/ningxia/yunxi/chemmes/module/biz/service/inspplanitem/InspPlanItemServiceImpl.java +++ b/mes-module-chemmes/mes-module-chemmes-biz/src/main/java/com/ningxia/yunxi/chemmes/module/biz/service/inspplanitem/InspPlanItemServiceImpl.java @@ -10,6 +10,9 @@ import org.springframework.stereotype.Service; import org.springframework.validation.annotation.Validated; import javax.annotation.Resource; +import java.util.List; + +import static com.ningxia.yunxi.chemmes.framework.common.exception.util.ServiceExceptionUtil.exception; /** * 质检方案子 Service 实现类 @@ -24,7 +27,7 @@ public class InspPlanItemServiceImpl implements InspPlanItemService { private InspPlanItemMapper inspPlanItemMapper; @Override - public String createInspPlanItem(InspPlanItemSaveReqVO createReqVO) { + public Integer createInspPlanItem(InspPlanItemSaveReqVO createReqVO) { // 插入 InspPlanItemDO inspPlanItem = BeanUtils.toBean(createReqVO, InspPlanItemDO.class); inspPlanItemMapper.insert(inspPlanItem); @@ -42,21 +45,21 @@ public class InspPlanItemServiceImpl implements InspPlanItemService { } @Override - public void deleteInspPlanItem(String id) { + public void deleteInspPlanItem(Integer id) { // 校验存在 validateInspPlanItemExists(id); // 删除 inspPlanItemMapper.deleteById(id); } - private void validateInspPlanItemExists(String id) { + private void validateInspPlanItemExists(Integer id) { if (inspPlanItemMapper.selectById(id) == null) { -// throw exception(INSP_PLAN_ITEM_NOT_EXISTS); + throw exception("数据不存在"); } } @Override - public InspPlanItemDO getInspPlanItem(String id) { + public InspPlanItemDO getInspPlanItem(Integer id) { return inspPlanItemMapper.selectById(id); } @@ -65,4 +68,9 @@ public class InspPlanItemServiceImpl implements InspPlanItemService { return inspPlanItemMapper.selectPage(pageReqVO); } + @Override + public List getInspPlanItemByPlanId(Integer planId) { + return inspPlanItemMapper.getInspPlanItemByPlanId(planId); + } + } diff --git a/mes-ui/mes-ui-admin-vue3/src/api/biz/inspplanitem/index.ts b/mes-ui/mes-ui-admin-vue3/src/api/biz/inspplanitem/index.ts index 92f4905..5ea9abc 100644 --- a/mes-ui/mes-ui-admin-vue3/src/api/biz/inspplanitem/index.ts +++ b/mes-ui/mes-ui-admin-vue3/src/api/biz/inspplanitem/index.ts @@ -1,47 +1,52 @@ -import request from '@/config/axios' - -export interface InspPlanItemVO { - id: string - schemeId: string - itemId: string - unit: string - standardValue: string - upperLimit: string - lowerLimit: string - remark: string - itemName: string - seqNo: number - printMergeYn: string - printItem: string - printNum: number -} - -// 查询质检方案子分页 -export const getInspPlanItemPage = async (params) => { - return await request.get({ url: `/tba/insp-plan-item/page`, params }) -} - -// 查询质检方案子详情 -export const getInspPlanItem = async (id: number) => { - return await request.get({ url: `/tba/insp-plan-item/get?id=` + id }) -} - -// 新增质检方案子 -export const createInspPlanItem = async (data: InspPlanItemVO) => { - return await request.post({ url: `/tba/insp-plan-item/create`, data }) -} - -// 修改质检方案子 -export const updateInspPlanItem = async (data: InspPlanItemVO) => { - return await request.put({ url: `/tba/insp-plan-item/update`, data }) -} - -// 删除质检方案子 -export const deleteInspPlanItem = async (id: number) => { - return await request.delete({ url: `/tba/insp-plan-item/delete?id=` + id }) -} - -// 导出质检方案子 Excel -export const exportInspPlanItem = async (params) => { - return await request.download({ url: `/tba/insp-plan-item/export-excel`, params }) -} \ No newline at end of file +import request from '@/config/axios' + + + +export interface InspPlanItemVO { + id: string + schemeId: string + itemId: string + unit: string + standardValue: string + upperLimit: string + lowerLimit: string + remark: string + itemName: string + seqNo: number + printMergeYn: string + printItem: string + printNum: number +} + +// 查询质检方案子分页 +export const getInspPlanItemPage = async (params) => { + return await request.get({ url: `/tba/insp-plan-item/page`, params }) +} + +// 查询质检方案子详情 +export const getInspPlanItem = async (id: number) => { + return await request.get({ url: `/tba/insp-plan-item/get?id=` + id }) +} + +// 新增质检方案子 +export const createInspPlanItem = async (data: InspPlanItemVO) => { + return await request.post({ url: `/tba/insp-plan-item/create`, data }) +} + +// 修改质检方案子 +export const updateInspPlanItem = async (data: InspPlanItemVO) => { + return await request.put({ url: `/tba/insp-plan-item/update`, data }) +} + +// 删除质检方案子 +export const deleteInspPlanItem = async (id: number) => { + return await request.delete({ url: `/tba/insp-plan-item/delete?id=` + id }) +} + +// 导出质检方案子 Excel +export const exportInspPlanItem = async (params) => { + return await request.download({ url: `/tba/insp-plan-item/export-excel`, params }) +} +export const getInspPlanItemByPlanId = async (id: number) => { + return await request.get({ url: `/tba/insp-plan-item/getInspPlanItemByPlanId?planId=` + id }) +} diff --git a/mes-ui/mes-ui-admin-vue3/src/utils/dict.ts b/mes-ui/mes-ui-admin-vue3/src/utils/dict.ts index d1ee522..fb59a60 100644 --- a/mes-ui/mes-ui-admin-vue3/src/utils/dict.ts +++ b/mes-ui/mes-ui-admin-vue3/src/utils/dict.ts @@ -239,6 +239,7 @@ export enum DICT_TYPE { TEST_VALUE_TYPE='test_value_type', // 检验值类型 RAW_MATERIALS_TYPE='raw_materials_type', // 原材料大类 FINISHED_PRODUCT_TYPE='finished_product_type', // 成品大类 + CLASSIFICATION_CODE='classification_code',// 质检方案分类编码 TEMPLATE_CODE='template_code', // 模板编码 ORDER_TYPE='order_type', // 销售订单类型 ORDER_STATUS='order_status', // 销售订单状态 diff --git a/mes-ui/mes-ui-admin-vue3/src/views/biz/checkitem/CheckItemForm.vue b/mes-ui/mes-ui-admin-vue3/src/views/biz/checkitem/CheckItemForm.vue index dfe75fb..632d6a8 100644 --- a/mes-ui/mes-ui-admin-vue3/src/views/biz/checkitem/CheckItemForm.vue +++ b/mes-ui/mes-ui-admin-vue3/src/views/biz/checkitem/CheckItemForm.vue @@ -13,19 +13,19 @@ - + - + - + - + - + - + - + - + @@ -96,14 +96,14 @@ - + - + - + - + - + - + @@ -147,7 +147,7 @@ diff --git a/mes-ui/mes-ui-admin-vue3/src/views/biz/inspplan/InspPlanForm.vue b/mes-ui/mes-ui-admin-vue3/src/views/biz/inspplan/InspPlanForm.vue index 05f6073..ae6721b 100644 --- a/mes-ui/mes-ui-admin-vue3/src/views/biz/inspplan/InspPlanForm.vue +++ b/mes-ui/mes-ui-admin-vue3/src/views/biz/inspplan/InspPlanForm.vue @@ -1,67 +1,247 @@ \ No newline at end of file + diff --git a/mes-ui/mes-ui-admin-vue3/src/views/biz/inspplan/index.vue b/mes-ui/mes-ui-admin-vue3/src/views/biz/inspplan/index.vue index d8af9bd..257f110 100644 --- a/mes-ui/mes-ui-admin-vue3/src/views/biz/inspplan/index.vue +++ b/mes-ui/mes-ui-admin-vue3/src/views/biz/inspplan/index.vue @@ -6,21 +6,21 @@ :model="queryParams" ref="queryFormRef" :inline="true" - label-width="68px" + label-width="80px" > - + - + @@ -39,55 +39,38 @@ type="primary" plain @click="openForm('create')" - v-hasPermi="['biz:insp-plan:create']" > 新增 - - 导出 - - - - - - - + + + + - - + + + - - - + +