Browse Source

财务报销类型修改

wangqiang 2 years ago
parent
commit
c7b46dc70a

+ 15 - 0
jeeplus-module/jeeplus-test/src/main/java/com/jeeplus/test/cw/reimbursementApproval/approvalType/domain/OfficeDomain.java

@@ -0,0 +1,15 @@
+package com.jeeplus.test.cw.reimbursementApproval.approvalType.domain;
+
+import lombok.Data;
+
+/**
+ * @author: 王强
+ * @create: 2023-02-15 13:31
+ **/
+@Data
+public class OfficeDomain {
+    private String id;     //部门id
+    private String name;    //部门名称
+    private String grade;   //部门等级
+    private String parentId; //父级部门id
+}

+ 22 - 0
jeeplus-module/jeeplus-test/src/main/java/com/jeeplus/test/cw/reimbursementApproval/approvalType/mapper/CwReimbursementTypeMapper.java

@@ -10,6 +10,7 @@ import com.jeeplus.core.domain.TreeMapper;
 import com.jeeplus.test.cw.projectRecords.domain.CwProjectRecords;
 import com.jeeplus.test.cw.projectRecords.service.dto.CwProjectRecordsDTO;
 import com.jeeplus.test.cw.reimbursementApproval.approvalType.domain.CwReimbursementTypeInfo;
+import com.jeeplus.test.cw.reimbursementApproval.approvalType.domain.OfficeDomain;
 import org.apache.ibatis.annotations.Param;
 
 import java.util.List;
@@ -32,6 +33,27 @@ public interface CwReimbursementTypeMapper extends BaseMapper<CwReimbursementTyp
                                           @Param("officeId") String officeId);
 
     /**
+     * 查找当前登陆人的部门的信息
+     * @param id
+     * @return
+     */
+    OfficeDomain officeInfo(@Param("id") String id);
+
+    /**
+     * 当前登陆人为三级部门时查二级部门方法
+     * @param id
+     * @return
+     */
+    OfficeDomain officeInfo2(@Param("id") String id);
+
+    /**
+     * 递归方式获取父级部门信息
+     * @param id
+     * @return
+     */
+    List<OfficeDomain> officeInfo3(@Param("id") String id);
+
+    /**
      * 根据id查询详情信息
      * @param id
      * @return

+ 32 - 0
jeeplus-module/jeeplus-test/src/main/java/com/jeeplus/test/cw/reimbursementApproval/approvalType/mapper/xml/CwReimbursementTypeMapper.xml

@@ -237,6 +237,38 @@
 				) t
 			${ew.customSqlSegment}
 	</select>
+	<select id="officeInfo"
+			resultType="com.jeeplus.test.cw.reimbursementApproval.approvalType.domain.OfficeDomain">
+		SELECT id,name,grade,parent_id FROM sys_office WHERE id = #{id} and del_flag = 0
+	</select>
+	<select id="officeInfo2"
+			resultType="com.jeeplus.test.cw.reimbursementApproval.approvalType.domain.OfficeDomain">
+		SELECT id,name,grade,parent_id FROM sys_office WHERE id =
+		(SELECT parent_id FROM sys_office WHERE id = #{id} and del_flag = 0)
+		 and del_flag = 0
+	</select>
+	<select id="officeInfo3"
+			resultType="com.jeeplus.test.cw.reimbursementApproval.approvalType.domain.OfficeDomain">
+		SELECT T2.ID, T2.parent_id,T2.name,T2.grade
+			FROM
+			(SELECT @r := #{id}, @l := 0) vars,
+			(SELECT
+				@r as _id,
+				(SELECT
+					@r := parent_id
+					FROM
+					sys_office
+					WHERE
+					id = _id
+				) as parent_id,
+				@l := @l + 1 as lv1
+				FROM sys_office h
+				WHERE
+				@r != 0
+			) T1
+		join sys_office T2 on T1._id = T2.id and T2.del_flag = 0
+		ORDER BY grade desc
+	</select>
 
 	<delete id="deleteReimbursementTypeOfficeInfo">
 		delete from cw_reimbursement_type_office_info where reimbursement_type_id = #{id}

+ 22 - 0
jeeplus-module/jeeplus-test/src/main/java/com/jeeplus/test/cw/reimbursementApproval/approvalType/service/CwReimbursementTypeService.java

@@ -11,6 +11,7 @@ import com.jeeplus.sys.utils.UserUtils;
 import com.jeeplus.test.cw.projectRecords.service.dto.CwProjectClientContactDTO;
 import com.jeeplus.test.cw.projectRecords.service.dto.CwProjectRecordsDTO;
 import com.jeeplus.test.cw.reimbursementApproval.approvalType.domain.CwReimbursementTypeInfo;
+import com.jeeplus.test.cw.reimbursementApproval.approvalType.domain.OfficeDomain;
 import com.jeeplus.test.cw.reimbursementApproval.approvalType.mapper.CwReimbursementTypeMapper;
 import com.jeeplus.test.cw.workClientInfo.domain.CwWorkClientContact;
 import org.apache.commons.compress.utils.Lists;
@@ -48,6 +49,27 @@ public class CwReimbursementTypeService {
 
         wrapper.eq(BaseEntity::getDelFlag, 0);
         wrapper.orderByAsc(CwReimbursementTypeInfo::getSort);
+        //查当前登陆人的父级部门的id为江苏兴光的
+//        OfficeDomain officeInfo = mapper.officeInfo(info.getOfficeId());
+//        if (null != officeInfo && officeInfo.getGrade().equals("2")){
+//            info.setOfficeId(officeInfo.getId());
+//        } else if (null != officeInfo && officeInfo.getGrade().equals("3")) {
+//            officeInfo = mapper.officeInfo2(officeInfo.getId());
+//            if (null != officeInfo){
+//                info.setOfficeId(officeInfo.getId());
+//            }
+//        }
+        //使用递归的方式来查当前登陆人部门父节点信息
+        List<OfficeDomain> officeDomains = mapper.officeInfo3(info.getOfficeId());
+        if (null != officeDomains && officeDomains.size()>0){
+            for (int i=0;i<officeDomains.size()-1;i++){
+                //当get(i)的父级id与 i+1的id相同,并且i+的部门层级为1的时候
+                if (officeDomains.get(i).getParentId().equals(officeDomains.get(i+1).getId()) &&
+                        officeDomains.get(i+1).getGrade().equals("1")){
+                    info.setOfficeId(officeDomains.get(i).getId());
+                }
+            }
+        }
         return mapper.bxList2(wrapper,info.getOfficeId());
     }
 

+ 1 - 0
jeeplus-platform/jeeplus-admin/src/main/java/com/jeeplus/sys/mapper/xml/OfficeMapper.xml

@@ -137,6 +137,7 @@
         from sys_office a
         <where>
             a.parent_id in (select id from sys_office where parent_id = 0)
+            and a.del_flag = 0
         </where>
     </select>
 </mapper>