Explorar o código

Merge branch 'master' of http://git.dongkesoft.com:9001/iBOSS-2.0-Mini/iboss-server-mdm

changhaoning %!s(int64=2) %!d(string=hai) anos
pai
achega
60842bb4a0

+ 39 - 9
src/main/java/com/dk/mdm/controller/mst/SupplierController.java

@@ -9,12 +9,10 @@ import com.dk.common.service.BaseService;
 import com.dk.mdm.model.query.mst.OrgQuery;
 import com.dk.mdm.model.query.mst.SupplierQuery;
 import com.dk.mdm.model.vo.mst.StaffVO;
+import com.dk.mdm.model.vo.mst.SupplierVo;
 import io.swagger.annotations.ApiOperation;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.*;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.RestController;
 import io.swagger.annotations.Api;
 import com.dk.mdm.service.mst.SupplierService;
 
@@ -45,11 +43,43 @@ public class SupplierController{
      * @author : 王英杰
      * @date : 2023/1/9 10:48
      */
-//    @ApiOperation(value = "新建供应商", notes = "新建供应商")
-//    @PostMapping({"insert"})
-//    public ResponseResultVO<?> insert(@RequestBody SupplierQuery staffVO) {
-//        return supplierService.insert(staffVO);
-//    }
+    @ApiOperation(value = "新建供应商", notes = "新建供应商")
+    @PostMapping({"insert"})
+    public ResponseResultVO<?> insert(@RequestBody SupplierVo supplierVo) {
+        return supplierService.insert(supplierVo);
+    }
+
+    /**
+     * @desc : 编辑供应商
+     * @author : 王英杰
+     * @date : 2023/1/9 10:48
+     */
+    @ApiOperation(value = "编辑员工", notes = "编辑员工")
+    @PostMapping({"update"})
+    public ResponseResultVO<?> update(@RequestBody SupplierVo supplierVo) {
+        return supplierService.update(supplierVo);
+    }
+
+
+    /**
+     * @desc : 停用供应商
+     * @author : 王英杰
+     * @date : 2023/1/9 10:48
+     */
+    @ApiOperation(value = "停用供应商", notes = "停用供应商")
+    @PostMapping({"deactivate_data"})
+    public ResponseResultVO<?> deactivateData(@RequestBody SupplierVo supplierVo) {
+        return supplierService.deactivateData(supplierVo);
+    }
 
+    /**
+     * @desc : 通过ID查询
+     * @author : 王英杰
+     * @date : 2023/1/9 10:41
+     */
+    @PostMapping({"/{id}"})
+    public ResponseResultVO selectById(@PathVariable String id) {
+        return supplierService.selectById(id);
+    }
 
 }

+ 24 - 0
src/main/java/com/dk/mdm/infrastructure/convert/mst/SupplierConvert.java

@@ -0,0 +1,24 @@
+package com.dk.mdm.infrastructure.convert.mst;
+
+import com.dk.mdm.model.pojo.mst.Org;
+import com.dk.mdm.model.pojo.mst.Supplier;
+import com.dk.mdm.model.vo.mst.OrgVO;
+import com.dk.mdm.model.vo.mst.SupplierVo;
+import org.mapstruct.Mapper;
+
+/**
+    * @desc   : org转换类
+    * @author : 王英杰
+    * @date   : 2024/2/27 9:34
+    */
+@Mapper(componentModel = "spring")
+public interface SupplierConvert {
+
+   /**
+    * @desc   : 转换vo为pojo
+    * @author : 姜宁
+    * @date   : 2023/1/10 16:59
+    */
+   Supplier convertToPo(SupplierVo supplierVO);
+
+}

+ 14 - 0
src/main/java/com/dk/mdm/mapper/common/CommonMapper.java

@@ -22,6 +22,20 @@ public interface CommonMapper extends BaseMapper<Map<String, Object>> {
     Integer getMaxDisplayNo(Map param);
 
     /**
+     * @desc : 获取编码
+     * @author : 周兴
+     * @date : 2024-3-1 15:47
+     */
+    Map<String, Object> getUniqueCode(Map param);
+
+    /**
+     * @desc : 获取单号
+     * @author : 周兴
+     * @date : 2024-3-1 15:47
+     */
+    Map<String, Object> getUniqueNote(Map param);
+
+    /**
      * @desc : 获取数据字典项目
      * @author : 王英杰
      * @date : 2023/1/6 14:15

+ 10 - 0
src/main/java/com/dk/mdm/mapper/common/CommonMapper.xml

@@ -19,6 +19,16 @@
         </if>
     </select>
 
+    <!--获取编码-->
+    <select id="getUniqueCode"  resultType="java.util.Map">
+        select out_id AS "outId",out_code AS "outNote" from dkic_b.f_create_code_id(#{cpId},#{docName});
+    </select>
+
+    <!--获取单号-->
+    <select id="getUniqueNote"  resultType="java.util.Map">
+        select out_id AS "outId",out_note AS "outNote" from dkic_b.f_create_note_id(#{cpId},#{docName});
+    </select>
+
     <resultMap id="BaseResultMap" type="java.util.Map">
         <result column="kindTags" property="kindTags" typeHandler="JsonTypeHandler"/>
     </resultMap>

+ 3 - 0
src/main/java/com/dk/mdm/mapper/mst/OrgMapper.xml

@@ -139,6 +139,9 @@
         <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
             limit #{end} offset #{start}
         </if>
+        <if test="searchText !=null">
+            AND ( parent.org_name LIKE concat('%', #{searchText}, '%')
+        </if>
     </select>
 
     <!-- 查询表t_mst_org,(条件查询)个数 -->

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

@@ -13,7 +13,7 @@
 
     <!-- 通用查询映射结果 -->
     <resultMap id="BaseResultMap" type="com.dk.mdm.model.response.mst.StaffResponse">
-        <id column="staff_id" property="staffId"/>
+        <id column="staff_id" property="staffId" typeHandler="UuidTypeHandler"/>
         <result column="staff_code" property="staffCode"/>
         <result column="staff_name" property="staffName"/>
         <result column="staff_phone" property="staffPhone"/>

+ 29 - 0
src/main/java/com/dk/mdm/mapper/mst/SupplierMapper.java

@@ -1,9 +1,11 @@
 package com.dk.mdm.mapper.mst;
 
+import com.dk.mdm.model.pojo.mst.Org;
 import com.dk.mdm.model.pojo.mst.Supplier;
 import com.dk.common.mapper.BaseMapper;
 import com.dk.mdm.model.query.mst.SupplierQuery;
 import com.dk.mdm.model.response.mst.StaffResponse;
+import com.dk.mdm.model.vo.mst.SupplierVo;
 import org.springframework.stereotype.Repository;
 
 import java.util.List;
@@ -26,5 +28,32 @@ public interface SupplierMapper extends BaseMapper<Supplier>{
      * @date   : 2023/1/9 10:42
      */
     Long countByCond(SupplierQuery supplierQuery);
+
+
+    /**
+        * @desc   : 保存供应商品牌
+        * @author : 王英杰
+        * @date   : 2024/2/29 17:49
+        */
+    int insertSupplierBrand(SupplierVo supplierVo);
+    /**
+     * @desc   : 批量删除 供应商iD对应的品牌
+     * @author : 王英杰
+     * @date   : 2024/2/29 17:49
+     */
+    int   batchDelete (SupplierVo supplierVo);
+    /**
+     * @desc   : 自动生id
+     * @author : 王英杰
+     * @date   : 2024/2/29 17:49
+     */
+    String selectUuid ();
+
+    /**
+     * @desc   :根据 公司id和uuid 生成 code
+     * @author : 王英杰
+     * @date   : 2024/2/29 17:49
+     */
+    String selectSupCode (SupplierVo supplierVo);
 }
 

+ 56 - 6
src/main/java/com/dk/mdm/mapper/mst/SupplierMapper.xml

@@ -14,8 +14,9 @@
         msl.service_categories, msl.remarks, msl.flg_valid, msl.cp_id,
         msl.op_create_time, msl.op_create_user_id, msl.op_update_time,
         msl.op_update_user_id, msl.op_app_code, msl.op_timestamp,
-        msl.op_db_user ,tmgb.brand_name
+        msl.op_db_user ,tmgb.brand_name,tmgb.brand_id
     </sql>
+
     <!-- 通用查询映射结果 -->
     <resultMap id="BaseResultMap" type="com.dk.mdm.model.pojo.mst.Supplier">
         <id column="sup_id" property="supId"/>
@@ -26,12 +27,22 @@
                 <result column="contact_phone" property="contactPhone"/>
                 <result column="org_id" property="orgId" typeHandler="UuidTypeHandler"/>
                 <result column="staff_id" property="staffId" typeHandler="UuidTypeHandler"/>
-                <result column="service_categories" property="serviceCategories"/>
+                <result column="service_categories" property="serviceCategories" typeHandler="StringListTypeHandler"/>
                 <result column="remarks" property="remarks"/>
                 <result column="flg_valid" property="flgValid"/>
                 <result column="cp_id" property="cpId"/>
                 <result column="brand_name" property="brandName"/>
+        <result column="brand_id" property="brandId"/>
+        <result column="staff_name" property="staffName"/>
+        <result column="org_name" property="orgName"/>
                 <result column="sum_residue" property="sumResidue"/>
+        <result column="op_create_time" property="opCreateTime" typeHandler="TimestampTypeHandler"/>
+        <result column="op_create_user_id" property="opCreateUserId" typeHandler="UuidTypeHandler"/>
+        <result column="op_update_time" property="opUpdateTime" typeHandler="TimestampTypeHandler"/>
+        <result column="op_update_user_id" property="opUpdateUserId" typeHandler="UuidTypeHandler"/>
+        <result column="op_app_code" property="opAppCode"/>
+        <result column="op_timestamp" property="opTimestamp" typeHandler="TimestampTypeHandler"/>
+        <result column="op_db_user" property="opDbUser"/>
     </resultMap>
 
     <!-- 通用条件列 -->
@@ -149,6 +160,11 @@
             <if test="opDbUser != null and opDbUser != ''">
                 AND msl.op_db_user = #{opDbUser}
             </if>
+            <if test="searchText !=null">
+                AND ( msl.sup_name LIKE concat('%', #{searchText}, '%')
+                or msl.contact_name LIKE concat('%', #{searchText}, '%')
+                or msl.contact_phone LIKE concat('%', #{searchText}, '%'))
+            </if>
         </where>
     </sql>
 
@@ -164,11 +180,15 @@
     <select id="selectByCond" resultMap="BaseResultMap">
         SELECT
         <include refid="msl_Base_Column_List"/>
+        ,tms.staff_name
+        ,tmo.org_name
         FROM dkic_b.t_mst_supplier msl
         LEFT JOIN dkic_b.t_mst_supplier_brand mslb ON msl.sup_id = mslb.sup_id
         LEFT JOIN dkic_b.t_mst_goods_brand tmgb ON tmgb.brand_id = mslb.brand_id
-
+        LEFT JOIN dkic_b.t_mst_staff  tms   ON tms.staff_id = msl.staff_id
+        LEFT JOIN dkic_b.t_mst_org  tmo   ON tmo.org_id = msl.org_id
         <include refid="msl_Condition"/>
+        ORDER BY  msl.op_create_time desc
         <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
             limit #{end} offset #{start}
         </if>
@@ -185,9 +205,15 @@
     <!-- 根据主键查询表t_mst_supplier的一行数据 -->
     <select id="selectById" resultMap="BaseResultMap">
         SELECT
-        <include refid="Base_Column_List"/>
-        FROM t_mst_supplier
-        WHERE sup_id = #{supId}::uuid
+        <include refid="msl_Base_Column_List"/>
+        ,tms.staff_name
+        ,tmo.org_name
+        FROM dkic_b.t_mst_supplier msl
+        LEFT JOIN dkic_b.t_mst_supplier_brand mslb ON msl.sup_id = mslb.sup_id
+        LEFT JOIN dkic_b.t_mst_goods_brand tmgb ON tmgb.brand_id = mslb.brand_id
+        LEFT JOIN dkic_b.t_mst_staff  tms   ON tms.staff_id = msl.staff_id
+        LEFT JOIN dkic_b.t_mst_org  tmo   ON tmo.org_id = msl.org_id
+        WHERE msl.sup_id = #{supId}::uuid
     </select>
 
     <!-- 根据主键锁定表t_mst_supplier的一行数据 -->
@@ -207,6 +233,13 @@
         <include refid="idsForeach"/>
         for update
     </select>
+    <select id="selectUuid" resultType="java.lang.String">
+        select  sys.f_uuid_seq()
+
+    </select>
+    <select id="selectSupCode" resultType="java.lang.String">
+        select  dkic_b.f_create_code( #{cpId},#{supId}::uuid,'供应商')
+    </select>
 
     <insert id="insertBatch">
         insert into t_mst_supplier
@@ -244,4 +277,21 @@
             )
         </foreach>
     </insert>
+
+    <insert id="insertSupplierBrand">
+        insert into dkic_b.t_mst_supplier_brand
+        (
+            sup_id,
+            brand_id
+        )
+        values
+            (
+                #{supId}::uuid,
+                #{brandId}::uuid
+            )
+    </insert>
+    <delete id="batchDelete">
+        DELETE FROM dkic_b.t_mst_supplier_brand
+        WHERE sup_id =  #{supId}::uuid;
+    </delete>
 </mapper>

+ 3 - 3
src/main/java/com/dk/mdm/model/pojo/mst/Staff.java

@@ -16,9 +16,11 @@ import lombok.experimental.Accessors;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 import com.alibaba.fastjson.JSONObject;
+import org.apache.ibatis.type.JdbcType;
 
 import java.util.List;
 import java.time.LocalDateTime;
+import java.util.UUID;
 
 /**
  *  员工
@@ -40,12 +42,11 @@ public class Staff extends PageInfo<Staff> implements Serializable {
     /**
      * 员工ID
      */
-    @TableId(value = "staff_id", type = IdType.AUTO)
+    //@TableId(value = "staff_id", type = IdType.INPUT)
     @ApiModelProperty(value = "员工ID")
     @TableField(typeHandler = UuidTypeHandler.class)
     private String staffId;
 
-
     /**
      * 员工编号
      */
@@ -53,7 +54,6 @@ public class Staff extends PageInfo<Staff> implements Serializable {
     @ApiModelProperty(value = "员工编号")
     private String staffCode;
 
-
     /**
      * 员工名称
      */

+ 24 - 2
src/main/java/com/dk/mdm/model/pojo/mst/Supplier.java

@@ -17,8 +17,11 @@ import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 import com.alibaba.fastjson.JSONObject;
 
+import java.util.Arrays;
+import java.util.HashSet;
 import java.util.List;
 import java.time.LocalDateTime;
+import java.util.Set;
 
 /**
  *  供应商
@@ -102,14 +105,29 @@ public class Supplier extends PageInfo<Supplier> implements Serializable {
     @ApiModelProperty(value = "业务员")
     @TableField(typeHandler = UuidTypeHandler.class)
     private String staffId;
-
+    /**
+     * 业务员
+     */
+    @Excel(name = "业务员")
+    @ApiModelProperty(value = "业务员")
+    @TableField(typeHandler = UuidTypeHandler.class)
+    private String staffName;
+    /**
+     * 业务员
+     */
+    @Excel(name = "组织机构")
+    @ApiModelProperty(value = "组织机构")
+    @TableField(typeHandler = UuidTypeHandler.class)
+    private String orgName;
 
     /**
      * 服务类别 (【系统字典】)
      */
     @Excel(name = "服务类别 (【系统字典】)")
     @ApiModelProperty(value = "服务类别 (【系统字典】)")
-    private String serviceCategories;
+    @TableField(typeHandler = StringListTypeHandler.class)
+    private List<String> serviceCategories;
+
 
 
     /**
@@ -204,6 +222,10 @@ public class Supplier extends PageInfo<Supplier> implements Serializable {
     private String brandName;
 
     @TableField(exist = false)
+    @ApiModelProperty(value = "商品品牌")
+    private String brandId;
+
+    @TableField(exist = false)
     @ApiModelProperty(value = "剩余应收付")
     private String sumResidue;
     /*

+ 1 - 1
src/main/java/com/dk/mdm/model/query/mst/OrgQuery.java

@@ -46,7 +46,7 @@ public class OrgQuery extends PageInfo<com.dk.mdm.model.query.mst.OrgQuery> impl
     @ApiModelProperty(value = "组织ID")
     private Integer orgId;
 
-
+    private String searchText;
     /**
      * 组织代码
      */

+ 3 - 2
src/main/java/com/dk/mdm/model/query/mst/SupplierQuery.java

@@ -111,7 +111,8 @@ import java.time.LocalDateTime;
          */
         @Excel(name = "服务类别 (【系统字典】)")
         @ApiModelProperty(value = "服务类别 (【系统字典】)")
-        private String serviceCategories;
+        @TableField(typeHandler = StringListTypeHandler.class)
+        private List<String> serviceCategories;
 
 
         /**
@@ -129,7 +130,7 @@ import java.time.LocalDateTime;
         @ApiModelProperty(value = "有效标识 (1:正常 0:停用)")
         private Boolean flgValid;
 
-
+        private String searchText;
         /**
          * 企业ID
          */

+ 5 - 65
src/main/java/com/dk/mdm/model/vo/mst/SupplierVo.java

@@ -111,7 +111,8 @@ public class SupplierVo extends PageInfo<SupplierVo> implements Serializable {
      */
     @Excel(name = "服务类别 (【系统字典】)")
     @ApiModelProperty(value = "服务类别 (【系统字典】)")
-    private String serviceCategories;
+    @TableField(typeHandler = StringListTypeHandler.class)
+    private List<String> serviceCategories;
 
 
     /**
@@ -137,73 +138,12 @@ public class SupplierVo extends PageInfo<SupplierVo> implements Serializable {
     @ApiModelProperty(value = "企业ID")
     private Integer cpId;
 
-
-    /**
-     * 创建时间 (触发器自动处理)
-     */
-    @Excel(name = "创建时间 (触发器自动处理)", format = "yyyy-MM-dd HH:mm:ss", width = 20)
-    @ApiModelProperty(value = "创建时间 (触发器自动处理)")
-    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
-    @TableField(typeHandler = TimestampTypeHandler.class)
-    private LocalDateTime opCreateTime;
-
-
-    /**
-     * 创建用户 (触发器自动处理)
-     */
-    @Excel(name = "创建用户 (触发器自动处理)")
-    @ApiModelProperty(value = "创建用户 (触发器自动处理)")
-    @TableField(typeHandler = UuidTypeHandler.class)
-    private String opCreateUserId;
-
-
-    /**
-     * 修改时间 (触发器自动处理)
-     */
-    @Excel(name = "修改时间 (触发器自动处理)", format = "yyyy-MM-dd HH:mm:ss", width = 20)
-    @ApiModelProperty(value = "修改时间 (触发器自动处理)")
-    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
-    @TableField(typeHandler = TimestampTypeHandler.class)
-    private LocalDateTime opUpdateTime;
-
-
-    /**
-     * 修改用户 (触发器自动处理)
-     */
-    @Excel(name = "修改用户 (触发器自动处理)")
-    @ApiModelProperty(value = "修改用户 (触发器自动处理)")
-    @TableField(typeHandler = UuidTypeHandler.class)
-    private String opUpdateUserId;
-
-
-    /**
-     * 数据操作应用 (触发器自动处理)
-     */
-    @Excel(name = "数据操作应用 (触发器自动处理)")
-    @ApiModelProperty(value = "数据操作应用 (触发器自动处理)")
-    private String opAppCode;
-
-
-    /**
-     * 数据时间戳 (触发器自动处理)
-     */
-    @Excel(name = "数据时间戳 (触发器自动处理)")
-    @ApiModelProperty(value = "数据时间戳 (触发器自动处理)")
-    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
-    @TableField(typeHandler = TimestampTypeHandler.class)
-    private LocalDateTime opTimestamp;
-
-
-    /**
-     * 数据操作数据库用户 (触发器自动处理)
-     */
-    @Excel(name = "数据操作数据库用户 (触发器自动处理)")
-    @ApiModelProperty(value = "数据操作数据库用户 (触发器自动处理)")
-    private String opDbUser;
-
     @TableField(exist = false)
     @ApiModelProperty(value = "商品品牌")
     private String brandName;
+    @TableField(exist = false)
+    @ApiModelProperty(value = "商品品牌")
+    private String brandId;
 
     @TableField(exist = false)
     @ApiModelProperty(value = "剩余应收付")

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

@@ -41,6 +41,26 @@ public class CommonService extends BaseService<Map<String, Object>> {
     private AuthUtils authUtils;
 
     /**
+     * @desc : 获取编码/单号
+     * @author : 周兴
+     * @date : 2024/3/1 11:41
+     */
+    public Map<String, Object> getUniqueNoteCode(String docName,Boolean codeFlag) {
+        Map<String, Object> param = new HashMap<>();
+        param.put("docName",docName);
+        // TODO 公司Id
+        param.put("cpId",1);
+        Map<String, Object> map = null;
+        // 获取系统基础数据
+        if(codeFlag){
+            map = commonMapper.getUniqueCode(param);
+        }else{
+            map = commonMapper.getUniqueNote(param);
+        }
+        return map;
+    }
+
+    /**
      * @desc : 获取数据字典项目
      * @author : 王英杰
      * @date : 2023/1/6 11:41

+ 12 - 2
src/main/java/com/dk/mdm/service/mst/OrgService.java

@@ -24,7 +24,15 @@ import org.springframework.transaction.annotation.Transactional;
 @Service
 @Transactional
 public class OrgService extends BaseService<Org> {
-
+    /**
+     * @desc : 重写主键
+     * @author : 王英杰
+     * @date : 2023/1/9 10:39
+     */
+    @Override
+    public String getPrimaryKey() {
+        return "org_id";
+    }
     @Override
     public BaseMapper<Org> getRepository() {
         return orgMapper;
@@ -60,7 +68,9 @@ public class OrgService extends BaseService<Org> {
         Org organization = orgConvert.convertToPo(orgVO);
 
         //查询 本次要加的 部门的 父级下 最大的DisplayNo  然后加1  就是现在要加的DisplayNo
-       int  maxDisplayNo =  orgMapper.maxDisplayNo(organization.getParentId()) +1;
+        String parentId = organization.getParentId();
+        int maxDisplayNo = orgMapper.maxDisplayNo(parentId) != null ? orgMapper.maxDisplayNo(parentId) + 1 : 0;
+
 
         organization.setDisplayNo(maxDisplayNo);
         // 插入组织部门数据

+ 11 - 0
src/main/java/com/dk/mdm/service/mst/StaffService.java

@@ -2,6 +2,7 @@ package com.dk.mdm.service.mst;
 
 import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
 import com.dk.common.infrastructure.annotaiton.Pagination;
+import com.dk.common.infrastructure.constant.Constant;
 import com.dk.common.model.pojo.PageList;
 import com.dk.common.response.ResponseCodeEnum;
 import com.dk.common.response.ResponseResultUtil;
@@ -14,12 +15,15 @@ import com.dk.common.mapper.BaseMapper;
 import com.dk.mdm.model.query.mst.StaffQuery;
 import com.dk.mdm.model.response.mst.StaffResponse;
 import com.dk.mdm.model.vo.mst.StaffVO;
+import com.dk.mdm.service.common.CommonService;
 import org.springframework.stereotype.Service;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.util.CollectionUtils;
 
 import java.util.List;
+import java.util.Map;
+import java.util.Random;
 import java.util.UUID;
 
 /**
@@ -57,6 +61,9 @@ public class StaffService extends BaseService<Staff> {
     @Autowired
     private StaffPurviewService staffPurviewService;
 
+    @Autowired
+    private CommonService commonService;
+
     /**
      * @desc : 条件查询
      * @author : 姜永辉
@@ -79,6 +86,10 @@ public class StaffService extends BaseService<Staff> {
     public ResponseResultVO<?> insert(StaffVO staffVO) {
         // 转化实体
         Staff staff = staffConvert.convertToPo(staffVO);
+        // 获取编码和主键UuId
+        Map<String, Object> codeMap = commonService.getUniqueNoteCode(Constant.docNameConstant.STAFF.getName(), true);
+        staff.setStaffId(codeMap.get("outId").toString());
+        staff.setStaffCode(codeMap.get("outNote").toString());
         return super.insert(staff);
     }
 

+ 108 - 17
src/main/java/com/dk/mdm/service/mst/SupplierService.java

@@ -1,39 +1,130 @@
 package com.dk.mdm.service.mst;
 
+import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
 import com.dk.common.infrastructure.annotaiton.Pagination;
 import com.dk.common.model.pojo.PageList;
+import com.dk.common.response.ResponseResultUtil;
 import com.dk.common.response.ResponseResultVO;
+import com.dk.mdm.infrastructure.convert.mst.OrgConvert;
+import com.dk.mdm.infrastructure.convert.mst.SupplierConvert;
 import com.dk.mdm.model.pojo.mst.Org;
+import com.dk.mdm.model.pojo.mst.Staff;
 import com.dk.mdm.model.pojo.mst.Supplier;
 import com.dk.mdm.mapper.mst.SupplierMapper;
 import com.dk.common.service.BaseService;
 import com.dk.common.mapper.BaseMapper;
 import com.dk.mdm.model.query.mst.OrgQuery;
 import com.dk.mdm.model.query.mst.SupplierQuery;
+import com.dk.mdm.model.vo.mst.OrgVO;
+import com.dk.mdm.model.vo.mst.StaffVO;
+import com.dk.mdm.model.vo.mst.SupplierVo;
 import org.springframework.stereotype.Service;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.transaction.annotation.Transactional;
+import org.springframework.transaction.interceptor.TransactionAspectSupport;
+
+import java.sql.CallableStatement;
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.SQLException;
+import java.util.UUID;
 
 @Service
 @Transactional
 public class SupplierService extends BaseService<Supplier> {
+    /**
+     * @desc : 重写主键
+     * @author : 王英杰
+     * @date : 2023/1/9 10:39
+     */
+    @Override
+    public String getPrimaryKey() {
+        return "sup_id";
+    }
+    @Override
+    public BaseMapper<Supplier> getRepository() {
+        return supplierMapper;
+    }
+
+    @Autowired
+    private SupplierMapper supplierMapper;
+
+    @Autowired
+    private SupplierConvert supplierConvert;
+
+    /**
+     * @desc : 条件查询
+     * @author : 王英杰
+     * @date : 2023/1/10 17:19
+     */
+    @Pagination
+    public ResponseResultVO<PageList<Supplier>> selectByCond(SupplierQuery supplierQuery) {
+        return super.mergeListWithCount(supplierQuery, supplierMapper.selectByCond(supplierQuery),
+                supplierMapper.countByCond(supplierQuery));
+    }
+    /**
+     * @desc : 停用 供应商
+     * @author : 王英杰
+     * @date : 2023/1/10 17:19
+     */
+    public ResponseResultVO<?> deactivateData(SupplierVo supplierVo) {
+        return  super.disable(supplierVo.getSupId());
+    }
+    /**
+     * @desc : 新建供应商
+     * @author : 王英杰
+     * @date : 2024/2/27 9:17
+     */
+    @Transactional(rollbackFor = {Exception.class})
+    public ResponseResultVO<?> insert(SupplierVo supplierVo) {
+        // 转化实体
+        Supplier supplier = supplierConvert.convertToPo(supplierVo);
+
+        try {
+
+            // 获取第一个插入操作生成的id
+            String supID = supplierMapper.selectUuid(); // 先生成id
+            supplierVo.setSupId(supID);
+            String supCode = supplierMapper.selectSupCode(supplierVo); //拿着生成的id 传过来的cpid 去生成code
+            supplierVo.setSupCode(supCode); //插入供应商品牌的实体
+            supplier.setSupCode(supCode);  //插入供应商表的实体
+            super.insert(supplier);// 先插入自己的供应商表
+            if (supplierVo.getBrandId() != null) {  //如果有 商品品牌
+                // 设置supplierVo的supplierId
+
+                supplierMapper.insertSupplierBrand(supplierVo); // 向供应商品牌表插入数据
+            }
+            return ResponseResultUtil.success();
+        } catch (Exception e) {
+            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); // 手动回滚事务
+
+            return ResponseResultUtil.error("保存失败");
+        }
 
-	@Override
-	public BaseMapper<Supplier> getRepository() {
-		return supplierMapper;
-	}
-
-	@Autowired
-	private SupplierMapper supplierMapper;
-	/**
-	 * @desc : 条件查询
-	 * @author : 王英杰
-	 * @date : 2023/1/10 17:19
-	 */
-	@Pagination
-	public ResponseResultVO<PageList<Supplier>> selectByCond(SupplierQuery supplierQuery) {
-		return super.mergeListWithCount(supplierQuery, supplierMapper.selectByCond(supplierQuery),
-				supplierMapper.countByCond(supplierQuery));
-	}
+    }
+    /**
+     * @desc : 编辑方法
+     * @author : 王英杰
+     * @date : 2023/1/9 10:49
+     */
+    @Transactional(
+            rollbackFor = {Exception.class}
+    )
+    public ResponseResultVO<?> update(SupplierVo supplierVo) {
+        // 转化实体
+        Supplier supplier = supplierConvert.convertToPo(supplierVo);
+        try {
+          super.updateByUuid(supplier);// 先更新的供应商表
+            supplierMapper.batchDelete(supplierVo);//批量删除供应商对应的供应商品牌
+            if (supplierVo.getBrandId() != null) {  //如果有 商品品牌
+                // 设置supplierVo的supplierId
+                supplierMapper.insertSupplierBrand(supplierVo); // 向供应商品牌表插入数据
+            }
+          return ResponseResultUtil.success();
+        } catch (Exception e) {
+            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); // 手动回滚事务
 
+            return ResponseResultUtil.error("更新失败");
+        }
+    }
 }