소스 검색

名称判重和页面调整

liuyao 1 년 전
부모
커밋
5d43ff6353

+ 23 - 0
src/main/java/com/dk/mdm/controller/common/CommonController.java

@@ -787,6 +787,29 @@ public class CommonController extends BaseController<Map<String, Object>> {
     public ResponseResultVO<Map<String, Object>> getHomeOrderRecCost(@RequestBody Map<String, Object> param) {
         return commonService.getHomeOrderRecCost(param);
     }
+
+    /**
+     * @desc :  获取商品系列不分页
+     * @author : 刘尧
+     * @date : 2024/5/29 11:26
+     */
+    @ApiOperation(value = "分页、关联、条件查询", notes = "分页、关联、条件查询")
+    @PostMapping({"get_goods_series_no_page"})
+    public ResponseResultVO<List<Map<String, Object>>> getGoodsSeriesListNoPage(@RequestBody Map<String, Object> param) {
+        return commonService.getGoodsSeriesListNoPage(param);
+    }
+
+    /**
+     * @desc :  获取计量单位不分页
+     * @author : 刘尧
+     * @date : 2024/5/29 11:26
+     */
+    @ApiOperation(value = "分页、关联、条件查询", notes = "分页、关联、条件查询")
+    @PostMapping({"get_unit_no_page"})
+    public ResponseResultVO<List<Map<String, Object>>> getUnitNoPage(@RequestBody Map<String, Object> param) {
+        return commonService.getUnitNoPage(param);
+    }
+
 }
 
 

+ 0 - 1
src/main/java/com/dk/mdm/mapper/mst/GoodsBrandMapper.java

@@ -32,6 +32,5 @@ public interface GoodsBrandMapper extends BaseMapper<GoodsBrand>{
 
     Integer saveSupplierBrand(String supId,String brandId);
 
-    Long checkNameDuplicated(GoodsBrand goodsBrand);
 }
 

+ 16 - 0
src/main/java/com/dk/mdm/mapper/mst/GoodsCategoryMapper.xml

@@ -240,4 +240,20 @@
     <update id="disableBachByParentId">
         update dkic_b.t_mst_goods_category set  flg_valid = false  where parent_id = #{id}::uuid
     </update>
+
+    <!-- 校验名称不重复 -->
+    <select id="checkNameDuplicated" resultType="java.lang.Long">
+        SELECT COUNT(cat_id)
+        FROM dkic_b.t_mst_goods_category
+        WHERE
+        cp_id = #{cpId}
+        AND flg_valid = TRUE
+        <!-- 通过判断id是否存在判断为新增操作还是修改操作 -->
+        <if test="catId != null and catId != ''">
+            AND cat_id != #{catId}::uuid
+        </if>
+        <if test="catName != null and catName != ''">
+            AND cat_name = #{catName}
+        </if>
+    </select>
 </mapper>

+ 15 - 1
src/main/java/com/dk/mdm/mapper/mst/GoodsSeriesMapper.xml

@@ -172,7 +172,21 @@
         </foreach>
     </insert>
 
-
+    <!-- 校验名称不重复 -->
+    <select id="checkNameDuplicated" resultType="java.lang.Long">
+        SELECT COUNT(series_id)
+        FROM dkic_b.t_mst_goods_series
+        WHERE
+        cp_id = #{cpId}
+        AND flg_valid = TRUE
+        <!-- 通过判断id是否存在判断为新增操作还是修改操作 -->
+        <if test="seriesId != null and seriesId != ''">
+            AND series_id != #{seriesId}::uuid
+        </if>
+        <if test="seriesName != null and seriesName != ''">
+            AND series_name = #{seriesName}
+        </if>
+    </select>
 
 
 

+ 15 - 0
src/main/java/com/dk/mdm/mapper/mst/UnitMapper.xml

@@ -168,6 +168,21 @@
         </foreach>
     </insert>
 
+    <!-- 校验名称不重复 -->
+    <select id="checkNameDuplicated" resultType="java.lang.Long">
+        SELECT COUNT(unit_id)
+        FROM dkic_b.t_mst_unit
+        WHERE
+        cp_id = #{cpId}
+        AND flg_valid = TRUE
+        <!-- 通过判断id是否存在判断为新增操作还是修改操作 -->
+        <if test="unitId != null and unitId != ''">
+            AND unit_id != #{unitId}::uuid
+        </if>
+        <if test="unitName != null and unitName != ''">
+            AND unit_name = #{unitName}
+        </if>
+    </select>
 
 
 

+ 18 - 0
src/main/java/com/dk/mdm/service/common/CommonService.java

@@ -1042,4 +1042,22 @@ public class CommonService extends BaseService<Map<String, Object>> {
         JSONObject jObject = JSONObject.parseObject(m.get("f_get_home_order_rec_cost").toString());
         return ResponseResultUtil.success(jObject);
     }
+    /**
+     * @desc :  获取商品系列不分页
+     * @author : 刘尧
+     * @date : 2024/5/29 11:26
+     */
+    public ResponseResultVO<List<Map<String, Object>>> getGoodsSeriesListNoPage(Map<String, Object> param) {
+        List<Map<String, Object>> list = commonMapper.getGoodsSeries(param);
+        return ResponseResultUtil.success(list);
+    }
+    /**
+     * @desc :  获取计量单位不分页
+     * @author : 刘尧
+     * @date : 2024/5/29 16:04
+     */
+    public ResponseResultVO<List<Map<String, Object>>> getUnitNoPage(Map<String, Object> param) {
+        List<Map<String, Object>> list = commonMapper.getUnit(param);
+        return ResponseResultUtil.success(list);
+    }
 }

+ 4 - 1
src/main/java/com/dk/mdm/service/mst/GoodsBrandService.java

@@ -93,7 +93,10 @@ public class GoodsBrandService extends BaseService<GoodsBrand> {
         //设置编码
         Map<String, Object> uniqueNoteCode = commonService.getUniqueNoteCode(Constant.docNameConstant.BRAND.getName(), true);
 
-        // 判断是否存在相同名称 如果存在直接返回重复信息 不进行下一部操作
+        /*
+        * 判断是否存在相同名称 如果存在直接返回重复信息 不进行下一部操作
+        * 刘尧 2024/5/28
+        * */
         if(goodsBrandMapper.checkNameDuplicated(goodsBrand) > 0){
             throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.ISEXISTS_BRAVDNAME.getMessage());
         }

+ 21 - 0
src/main/java/com/dk/mdm/service/mst/GoodsCategoryService.java

@@ -1,8 +1,11 @@
 package com.dk.mdm.service.mst;
 
+import com.dk.common.exception.BaseBusinessException;
 import com.dk.common.infrastructure.annotaiton.Pagination;
 import com.dk.common.infrastructure.constant.Constant;
+import com.dk.common.infrastructure.enums.ErrorCodeEnum;
 import com.dk.common.model.pojo.PageList;
+import com.dk.common.response.ResponseCodeEnum;
 import com.dk.common.response.ResponseResultUtil;
 import com.dk.common.response.ResponseResultVO;
 import com.dk.mdm.infrastructure.convert.mst.GoodsCategoryConvert;
@@ -80,6 +83,15 @@ public class GoodsCategoryService extends BaseService<GoodsCategory> {
     public ResponseResultVO<?> insert(GoodsCategoryVO goodsCategoryVO) {
         //实体转换
         GoodsCategory goodsCategory = goodsCategoryConvert.convertToPo(goodsCategoryVO);
+
+        /*
+         * 判断是否存在相同名称 如果存在直接返回重复信息 不进行下一部操作
+         * 刘尧 2024/5/29
+         * */
+        if(goodsCategoryMapper.checkNameDuplicated(goodsCategory) > 0){
+            throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.ISEXISTS_GOODSCATEGORY.getMessage());
+        }
+
         //设置序号
         goodsCategory.setDisplayNo(commonService.getMaxDisplayNo(Constant.DisplayNoTable.GOODSSERIES));
         if (goodsCategory.getParentId() != null) {
@@ -109,6 +121,15 @@ public class GoodsCategoryService extends BaseService<GoodsCategory> {
     )
     public ResponseResultVO<?> update(GoodsCategoryVO goodsCategoryVO) {
         GoodsCategory goodsCategory = goodsCategoryConvert.convertToPo(goodsCategoryVO);
+
+        /*
+         * 判断是否存在相同名称 如果存在直接返回重复信息 不进行下一部操作
+         * 刘尧 2024/5/29
+         * */
+        if(goodsCategoryMapper.checkNameDuplicated(goodsCategory) > 0){
+            throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.ISEXISTS_GOODSCATEGORY.getMessage());
+        }
+
         super.updateByUuid(goodsCategory);
         return ResponseResultUtil.success();
     }

+ 21 - 0
src/main/java/com/dk/mdm/service/mst/GoodsSeriesService.java

@@ -1,8 +1,11 @@
 package com.dk.mdm.service.mst;
 
+import com.dk.common.exception.BaseBusinessException;
 import com.dk.common.infrastructure.annotaiton.Pagination;
 import com.dk.common.infrastructure.constant.Constant;
+import com.dk.common.infrastructure.enums.ErrorCodeEnum;
 import com.dk.common.model.pojo.PageList;
+import com.dk.common.response.ResponseCodeEnum;
 import com.dk.common.response.ResponseResultUtil;
 import com.dk.common.response.ResponseResultVO;
 import com.dk.mdm.infrastructure.convert.mst.GoodsBrandConvert;
@@ -97,6 +100,15 @@ public class GoodsSeriesService extends BaseService<GoodsSeries> {
 		Map<String, Object> uniqueNoteCode = commonService.getUniqueNoteCode(Constant.docNameConstant.SERIES.getName(), true);
 		goodsSeries.setSeriesId(uniqueNoteCode.get("outId").toString());
 		goodsSeries.setSeriesCode(uniqueNoteCode.get("outNote").toString());
+
+		/*
+		 * 判断是否存在相同名称 如果存在直接抛出异常 不进行下一部操作
+		 * 刘尧 2024/5/29
+		 * */
+		if(goodsSeriesMapper.checkNameDuplicated(goodsSeries) > 0){
+			throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.ISEXISTS_CATNAME.getMessage());
+		}
+
 		//新建
 		goodsSeriesMapper.insert(goodsSeries);
 		return ResponseResultUtil.success(goodsSeries);
@@ -114,6 +126,15 @@ public class GoodsSeriesService extends BaseService<GoodsSeries> {
 	)
 	public ResponseResultVO<?> update(GoodsSeriesVO goodsSeriesVO) {
 		GoodsSeries goodsSeries = goodsSeriesConvert.convertToPo(goodsSeriesVO);
+
+		/*
+		 * 判断是否存在相同名称 如果存在直接抛出异常 不进行下一部操作
+		 * 刘尧 2024/5/29
+		 * */
+		if(goodsSeriesMapper.checkNameDuplicated(goodsSeries) > 0){
+			throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.ISEXISTS_CATNAME.getMessage());
+		}
+
 		super.updateByUuid(goodsSeries);
 		return ResponseResultUtil.success();
 	}

+ 21 - 0
src/main/java/com/dk/mdm/service/mst/UnitService.java

@@ -1,8 +1,11 @@
 package com.dk.mdm.service.mst;
 
+import com.dk.common.exception.BaseBusinessException;
 import com.dk.common.infrastructure.annotaiton.Pagination;
 import com.dk.common.infrastructure.constant.Constant;
+import com.dk.common.infrastructure.enums.ErrorCodeEnum;
 import com.dk.common.model.pojo.PageList;
+import com.dk.common.response.ResponseCodeEnum;
 import com.dk.common.response.ResponseResultUtil;
 import com.dk.common.response.ResponseResultVO;
 import com.dk.mdm.infrastructure.convert.mst.UnitConvert;
@@ -70,6 +73,15 @@ public class UnitService extends BaseService<Unit> {
 		Unit unit = unitConvert.convertToPo(unitVO);
 		//设置序号
 		unit.setDisplayNo(commonService.getMaxDisplayNo(Constant.DisplayNoTable.UNIT));
+
+		/*
+		 * 判断是否存在相同名称 如果存在直接抛出异常 不进行下一部操作
+		 * 刘尧 2024/5/29
+		 * */
+		if(unitMapper.checkNameDuplicated(unit) > 0){
+			throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.ISEXISTS_UNITNAME.getMessage());
+		}
+
 		//设置编码
 		Map<String, Object> uniqueNoteCode = commonService.getUniqueNoteCode(Constant.docNameConstant.UNIT.getName(), true);
 		unit.setUnitId(uniqueNoteCode.get("outId").toString());
@@ -91,6 +103,15 @@ public class UnitService extends BaseService<Unit> {
 	)
 	public ResponseResultVO<?> update(UnitVO unitVO) {
 		Unit unit = unitConvert.convertToPo(unitVO);
+
+		/*
+		 * 判断是否存在相同名称 如果存在直接抛出异常 不进行下一部操作
+		 * 刘尧 2024/5/29
+		 * */
+		if(unitMapper.checkNameDuplicated(unit) > 0){
+			throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.ISEXISTS_UNITNAME.getMessage());
+		}
+
 		super.updateByUuid(unit);
 		return ResponseResultUtil.success();
 	}