소스 검색

组织机构

dongke 2 년 전
부모
커밋
69c61d394a

+ 13 - 0
src/main/java/com/dk/mdm/controller/mst/OrgController.java

@@ -14,6 +14,8 @@ import org.springframework.beans.factory.annotation.Autowired;
 import io.swagger.annotations.Api;
 import com.dk.mdm.service.mst.OrgService;
 
+import java.util.List;
+
 @Api(tags = "组织机构API接口")
 @RestController
 @RequestMapping("/mst/org")
@@ -89,4 +91,15 @@ public class OrgController{
         return orgService.update(orgVO);
     }
 
+    /**
+     * @desc   :  微信小程序 查询选择部门数据
+     * @author : 王英杰
+     * @date   : 2024/3/1 16:01
+     */
+    @PostMapping({"select_choose_org"})
+    public ResponseResultVO<List<OrgResponse>> selectChooseOrg(@RequestBody OrgQuery orgQuery) {
+        return orgService.selectChooseOrg(orgQuery);
+    }
+
+
 }

+ 52 - 5
src/main/java/com/dk/mdm/mapper/mst/OrgMacMapper.xml

@@ -8,10 +8,14 @@
         org_id, mac_id, display_no, flg_default, cp_id, op_create_time, op_create_user_id, op_update_time, op_update_user_id, op_app_code, op_timestamp, op_db_user
     </sql>
 
+    <sql id="Base_Column_List_prefix">
+        tmom.org_id, tmom.mac_id, tmom.display_no, tmom.flg_default, tmom.cp_id, tmom.op_create_time, tmom.op_create_user_id, tmom.op_update_time, tmom.op_update_user_id, tmom.op_app_code, tmom.op_timestamp, tmom.op_db_user
+    </sql>
     <!-- 通用查询映射结果 -->
     <resultMap id="BaseResultMap" type="com.dk.mdm.model.pojo.mst.OrgMac">
         <id column="org_id" property="orgId"/>
                 <result column="mac_id" property="macId" typeHandler="UuidTypeHandler"/>
+        <result column="mac_name" property="macName"/>
                 <result column="display_no" property="displayNo"/>
                 <result column="flg_default" property="flgDefault"/>
                 <result column="cp_id" property="cpId"/>
@@ -66,6 +70,46 @@
         </where>
     </sql>
 
+    <sql id="Condition_prefix">
+        <where>
+            <if test="macId != null and macId != ''">
+                AND tmom.mac_id = #{macId}
+            </if>
+            <if test="displayNo != null">
+                AND tmom.display_no = #{displayNo}
+            </if>
+            <if test="flgDefault != null">
+                AND tmom.flg_default = #{flgDefault}
+            </if>
+            <if test="cpId != null">
+                AND tmom.cp_id = #{cpId}
+            </if>
+            <if test="opCreateTime != null">
+                AND tmom.op_create_time = #{opCreateTime}
+            </if>
+            <if test="opCreateUserId != null and opCreateUserId != ''">
+                AND tmom.op_create_user_id = #{opCreateUserId}
+            </if>
+            <if test="opUpdateTime != null">
+                AND tmom.op_update_time = #{opUpdateTime}
+            </if>
+            <if test="opUpdateUserId != null and opUpdateUserId != ''">
+                AND tmom.op_update_user_id = #{opUpdateUserId}
+            </if>
+            <if test="opAppCode != null and opAppCode != ''">
+                AND tmom.op_app_code = #{opAppCode}
+            </if>
+            <if test="opTimestamp != null">
+                AND tmom.op_timestamp = #{opTimestamp}
+            </if>
+            <if test="opDbUser != null and opDbUser != ''">
+                AND tmom.op_db_user = #{opDbUser}
+            </if>
+            <if test="orgId != null">
+                AND tmom.org_id = #{orgId}::uuid
+            </if>
+        </where>
+    </sql>
     <sql id="idsForeach">
         <!-- 根据主键orgId批量操作 -->
         WHERE org_id in
@@ -77,9 +121,11 @@
     <!-- 查询表t_mst_org_mac,(条件查询+分页)列表 -->
     <select id="selectByCond" resultMap="BaseResultMap">
         SELECT
-        <include refid="Base_Column_List"/>
-        FROM t_mst_org_mac
-        <include refid="Condition"/>
+        <include refid="Base_Column_List_prefix"/>
+        ,tmma.mac_name
+        FROM dkic_b.t_mst_org_mac tmom
+        left join dkic_b.t_mst_money_account tmma on tmma.mac_id=tmom.mac_id
+        <include refid="Condition_prefix"/>
         <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
             limit #{end} offset #{start}
         </if>
@@ -89,8 +135,9 @@
     <select id="countByCond" resultType="Long">
         SELECT
         count(1)
-        FROM t_mst_org_mac
-        <include refid="Condition"/>
+        FROM dkic_b.t_mst_org_mac tmom
+        left join dkic_b.t_mst_money_account tmma on tmma.mac_id=tmom.mac_id
+        <include refid="Condition_prefix"/>
     </select>
 
     <!-- 根据主键查询表t_mst_org_mac的一行数据 -->

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

@@ -22,6 +22,13 @@ public interface OrgMapper extends BaseMapper<Org>{
     List<OrgResponse> selectByCond(OrgQuery orgQuery);
 
     /**
+     * @desc   : 根据条件进行查询
+     * @author : 姜宁
+     * @date   : 2023/1/10 17:20
+     */
+    List<OrgResponse> selectChooseOrg(OrgQuery orgQuery);
+
+    /**
      * @desc   : 根据条件进行查询(数量)
      * @author : 姜宁
      * @date   : 2023/1/10 17:20

+ 33 - 11
src/main/java/com/dk/mdm/mapper/mst/OrgMapper.xml

@@ -5,14 +5,27 @@
     <!-- 通用设置 -->
     <!-- 通用查询列 -->
     <sql id="Base_Column_List">
-        org_id, org_name, parent_id, display_no, top_id, level_upper, level_lower, level_leaf, level_no, level_code
+        org_id
+        , org_name, parent_id, display_no, top_id, level_upper, level_lower, level_leaf, level_no, level_code
         , level_name, remarks, flg_valid, cp_id, op_create_time, op_create_user_id, op_update_time, op_update_user_id
         , op_app_code, op_timestamp, op_db_user, org_code
     </sql>
     <sql id="Base_Column_List_view">
-        parent.org_id,parent.flg_valid,parent.level_leaf,parent.org_code,parent.level_name
-        , parent.org_name, parent.parent_id, parent.display_no, parent.top_id
-         ,
+                 parent.org_id
+                ,parent.org_name
+                ,parent.parent_id
+                ,parent.display_no
+                ,parent.top_id
+                ,parent.level_upper
+                ,parent.level_lower
+                ,parent.level_leaf
+                ,parent.level_no
+                ,parent.level_code
+                ,parent.level_name
+                ,parent.remarks
+                ,parent.flg_valid
+                ,parent.cp_id
+                         ,
                 (
                 SELECT
                 string_agg ( ma.mac_name, ',' )
@@ -60,7 +73,8 @@
         <result column="op_timestamp" property="opTimestamp" typeHandler="TimestampTypeHandler"/>
         <result column="op_db_user" property="opDbUser"/>
         <result column="org_code" property="orgCode"/>
-        <collection property="itemData" javaType="java.util.ArrayList" ofType="com.dk.mdm.model.pojo.mst.Org"  column="org_item_id">
+        <collection property="itemData" javaType="java.util.ArrayList" ofType="com.dk.mdm.model.pojo.mst.Org"
+                    column="org_item_id">
             <id column="org_item_id" property="orgId"/>
             <result column="org_item_name" property="orgName"/>
         </collection>
@@ -92,7 +106,8 @@
         <result column="org_code" property="orgCode"/>
         <result column="whName" property="whName"/>
         <result column="orgMac" property="orgMac"/>
-        <collection property="itemData" javaType="java.util.ArrayList" ofType="com.dk.mdm.model.pojo.mst.Org"  column="org_item_id">
+        <collection property="itemData" javaType="java.util.ArrayList" ofType="com.dk.mdm.model.pojo.mst.Org"
+                    column="org_item_id">
             <id column="org_item_id" property="orgId"/>
             <result column="org_item_name" property="orgName"/>
         </collection>
@@ -105,7 +120,7 @@
                 AND parent.org_name = #{orgName}
             </if>
             <if test="flgValidList != null and flgValidList.size>0">
-                AND parent.flg_valid  =any(#{flgValidList, typeHandler=BooleanListTypeHandler})
+                AND parent.flg_valid =any(#{flgValidList, typeHandler=BooleanListTypeHandler})
             </if>
             <if test="cpId != null">
                 AND parent.cp_id = #{cpId}
@@ -113,12 +128,12 @@
             <if test="parentId != null and parentId != ''">
                 AND parent.parent_id = #{parentId}::uuid
             </if>
+            <if test="searchText !=null">
+                AND parent.org_name LIKE concat('%', #{searchText}, '%')
+            </if>
             <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>
         </where>
     </sql>
 
@@ -139,7 +154,7 @@
     <select id="countByCond" resultType="Long">
         SELECT
         count(1)
-        FROM  dkic_b.t_mst_org parent
+        FROM dkic_b.t_mst_org parent
         <include refid="Condition"/>
     </select>
 
@@ -161,5 +176,12 @@
         WHERE org_id = #{orgId}
         for update
     </select>
+    <select id="selectChooseOrg" resultType="com.dk.common.model.response.mst.OrgResponse">
+        SELECT
+        <include refid="Base_Column_List_view"/>
+        FROM dkic_b.t_mst_org parent
+        <include refid="Condition"/>
+        ORDER BY level_code
+    </select>
 
 </mapper>

+ 55 - 6
src/main/java/com/dk/mdm/mapper/mst/OrgWhMapper.xml

@@ -7,12 +7,17 @@
     <sql id="Base_Column_List">
         org_id, wh_id, display_no, flg_default, cp_id, op_create_time, op_create_user_id, op_update_time, op_update_user_id, op_app_code, op_timestamp, op_db_user
     </sql>
+    <!-- 通用查询列 -->
+    <sql id="Base_Column_List_prefix">
+        tmow.org_id, tmow.wh_id, tmow.display_no, tmow.flg_default, tmow.cp_id, tmow.op_create_time, tmow.op_create_user_id, tmow.op_update_time, tmow.op_update_user_id, tmow.op_app_code, tmow.op_timestamp, tmow.op_db_user
+    </sql>
 
     <!-- 通用查询映射结果 -->
     <resultMap id="BaseResultMap" type="com.dk.mdm.model.pojo.mst.OrgWh">
         <id column="org_id" property="orgId"/>
                 <result column="wh_id" property="whId" typeHandler="UuidTypeHandler"/>
-                <result column="display_no" property="displayNo"/>
+        <result column="wh_name" property="whName"/>
+        <result column="display_no" property="displayNo"/>
                 <result column="flg_default" property="flgDefault"/>
                 <result column="cp_id" property="cpId"/>
             <result column="op_create_time" property="opCreateTime" typeHandler="TimestampTypeHandler"/>
@@ -66,6 +71,47 @@
         </where>
     </sql>
 
+    <!-- 通用条件列 -->
+    <sql id="Condition_prefix">
+        <where>
+            <if test="whId != null and whId != ''">
+                AND tmow.wh_id = #{whId}
+            </if>
+            <if test="displayNo != null">
+                AND tmow.display_no = #{displayNo}
+            </if>
+            <if test="flgDefault != null">
+                AND tmow.flg_default = #{flgDefault}
+            </if>
+            <if test="cpId != null">
+                AND tmow.cp_id = #{cpId}
+            </if>
+            <if test="orgId != null">
+                AND tmow.org_id = #{orgId}::uuid
+            </if>
+            <if test="opCreateTime != null">
+                AND tmow.op_create_time = #{opCreateTime}
+            </if>
+            <if test="opCreateUserId != null and opCreateUserId != ''">
+                AND tmow.op_create_user_id = #{opCreateUserId}
+            </if>
+            <if test="opUpdateTime != null">
+                AND tmow.op_update_time = #{opUpdateTime}
+            </if>
+            <if test="opUpdateUserId != null and opUpdateUserId != ''">
+                AND tmow.op_update_user_id = #{opUpdateUserId}
+            </if>
+            <if test="opAppCode != null and opAppCode != ''">
+                AND tmow.op_app_code = #{opAppCode}
+            </if>
+            <if test="opTimestamp != null">
+                AND tmow.op_timestamp = #{opTimestamp}
+            </if>
+            <if test="opDbUser != null and opDbUser != ''">
+                AND tmow.op_db_user = #{opDbUser}
+            </if>
+        </where>
+    </sql>
     <sql id="idsForeach">
         <!-- 根据主键orgId批量操作 -->
         WHERE org_id in
@@ -77,9 +123,11 @@
     <!-- 查询表t_mst_org_wh,(条件查询+分页)列表 -->
     <select id="selectByCond" resultMap="BaseResultMap">
         SELECT
-        <include refid="Base_Column_List"/>
-        FROM t_mst_org_wh
-        <include refid="Condition"/>
+        <include refid="Base_Column_List_prefix"/>
+        ,tmw.wh_name
+        FROM dkic_b.t_mst_org_wh tmow
+        left join dkic_b.t_mst_warehouse tmw on tmw.wh_id=tmow.wh_id
+        <include refid="Condition_prefix"/>
         <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
             limit #{end} offset #{start}
         </if>
@@ -89,8 +137,9 @@
     <select id="countByCond" resultType="Long">
         SELECT
         count(1)
-        FROM t_mst_org_wh
-        <include refid="Condition"/>
+        FROM dkic_b.t_mst_org_wh tmow
+        left join dkic_b.t_mst_warehouse tmw on tmw.wh_id=tmow.wh_id
+        <include refid="Condition_prefix"/>
     </select>
 
     <!-- 根据主键查询表t_mst_org_wh的一行数据 -->

+ 6 - 0
src/main/java/com/dk/mdm/model/pojo/mst/OrgMac.java

@@ -54,6 +54,12 @@ public class OrgMac extends PageInfo<OrgMac> implements Serializable {
     @TableField(typeHandler = UuidTypeHandler.class)
     private String macId;
 
+    /**
+     * 资金账户名称
+     */
+    @Excel(name = "资金账户名称")
+    @ApiModelProperty(value = "资金账户名称")
+    private String macName;
 
     /**
      * 显示顺序 (【1 ~ 46655】)

+ 6 - 0
src/main/java/com/dk/mdm/model/pojo/mst/OrgWh.java

@@ -47,6 +47,12 @@ public class OrgWh extends PageInfo<OrgWh> implements Serializable {
 
 
     /**
+     * 仓库名称
+     */
+    @Excel(name = "仓库名称")
+    @ApiModelProperty(value = "仓库名称")
+    private String whName;
+    /**
      * 仓库ID
      */
     @Excel(name = "仓库ID")

+ 20 - 3
src/main/java/com/dk/mdm/service/mst/OrgService.java

@@ -90,6 +90,15 @@ public class OrgService extends BaseService<Org> {
         return ResponseResultUtil.success(orgResponse);
     }
     /**
+     * @desc   : 微信小程序 查询选择部门数据
+     * @author : 宋扬
+     * @date   : 2023/2/29 10:40
+     */
+    @Pagination
+    public ResponseResultVO<List<OrgResponse>>  selectChooseOrg( OrgQuery orgQuery) {
+        return ResponseResultUtil.success(orgMapper.selectChooseOrg(orgQuery));
+    }
+    /**
      * @desc : 新建组织机构
      * @author : 王英杰
      * @date : 2024/2/27 9:17
@@ -113,15 +122,16 @@ public class OrgService extends BaseService<Org> {
         param.put("otherCond", "parent_id = #{parentID} ::uuid");
         organization.setDisplayNo(commonService.getMaxDisplayNo(Constant.DisplayNoTable.ORG ,param));
         if (organization.getParentId() != null) {
+            Org org = orgMapper.selectById(organization.getParentId());
             //插入TOPid
-            organization.setTopId(organization.getParentId());
+            organization.setTopId(org.getTopId());
         }
 
 
         // 插入组织部门数据
         super.insert(organization);
         //执行函数
-        orgMapper.resetLevelOrg(new Org().setTopId(organization.getParentId()).setCpId(organization.getCpId()));
+        orgMapper.resetLevelOrg(new Org().setTopId(organization.getTopId()).setCpId(organization.getCpId()));
 
         // 添加组织仓库
         if (orgVO.getWarehouseList() != null && orgVO.getWarehouseList().size() > 0) {
@@ -155,6 +165,7 @@ public class OrgService extends BaseService<Org> {
 //                ResponseResultUtil.error(ResponseCodeEnum.INSERT_FAIL);
     }
 
+
     /**
      * @desc : 新建组织机构
      * @author : 王英杰
@@ -197,8 +208,14 @@ public class OrgService extends BaseService<Org> {
         // 修改组织机构
         super.update(org, new UpdateWrapper<Org>().lambda().eq(Org::getOrgId,
                 UUID.fromString(org.getOrgId())));
+        if (orgVO.getParentId() != null) {
+            Org org_ = orgMapper.selectById(orgVO.getParentId());
+            //插入TOPid
+            org.setTopId(org_.getTopId());
+        }
+
         //执行函数
-        orgMapper.resetLevelOrg(new Org().setTopId(org.getParentId()).setCpId(org.getCpId()));
+        orgMapper.resetLevelOrg(new Org().setTopId(org.getTopId()).setCpId(org.getCpId()));
 
         //删除组织仓库和组织资金账户
         orgWhMapper.deleteByOrgId(org.getOrgId());