Просмотр исходного кода

修改管理员最后登录时间没有了BUG修复

anderx лет назад: 3
Родитель
Сommit
7b49264386

+ 2 - 5
src/main/java/com/goafanti/admin/service/impl/NewAdminServiceImpl.java

@@ -96,7 +96,7 @@ public class NewAdminServiceImpl extends BaseMybatisDao<AdminMapper> implements
 		Map<String, Object> params = new HashMap<>();
 		params.put("uid", ad.getId());
 		params.put("roles", roleIds);
-		Set<String> useRole = roleMapper.findRoleByUserId(ad.getId());
+		List<Role>  useRole = roleMapper.selectByAid(ad.getId());
 		if (ad.getId() != "1") {
 			userRoleMapper.deleteByUserId(ad.getId());
 			if (!roleIds.isEmpty()) {
@@ -108,6 +108,7 @@ public class NewAdminServiceImpl extends BaseMybatisDao<AdminMapper> implements
 		ad.setType(sumType(roleIds));
 		int count=adminMapper.updateByPrimaryKey(ad);
 		//
+		asyncUtils.pushRoleUpdateExamine(ad,useAdmin,roleIds,useRole);
 		pushAmbRole(ad);
 		if (count>0&&ad.getAmbId()!=null){
 			//进行巴人数计算
@@ -116,8 +117,6 @@ public class NewAdminServiceImpl extends BaseMybatisDao<AdminMapper> implements
 //				List<String> list = Arrays.asList(ambSystem.getAncestors().split(","));
 //
 //			}
-
-
 		}
 		return count;
 	}
@@ -125,8 +124,6 @@ public class NewAdminServiceImpl extends BaseMybatisDao<AdminMapper> implements
 
 
 
-
-
 	private int sumType(List<String > roleIds) {
 		int type=0;
 		for (String roleId : roleIds) {

+ 4 - 9
src/main/java/com/goafanti/common/dao/NewOrderChangeMapper.java

@@ -42,15 +42,8 @@ public interface NewOrderChangeMapper {
 
     NewOrderChangeBo selectByorderNoAndStatus(String orderNo);
 
-    /**
-     * 切换审核人员
-     * @param type 3财务
-     * @param depId 部门编号
-     * @param aid 切换后审核人
-     * @return
-     */
-    int updateExamineName(@Param("type")Integer type, @Param("depId")String depId, @Param("aid")String aid,
-                          @Param("names")String names);
+
+    int updateExamineName(String depId);
 
     int updateTaskExamineName(@Param("aid") String aid, @Param("taskReceiverId") String taskReceiverId,@Param("type") Integer type);
 
@@ -69,4 +62,6 @@ public interface NewOrderChangeMapper {
      * @return
      */
     List<Integer> selectProcess(@Param("type")Integer type, @Param("aid")String aid);
+
+    void updateExamineById(@Param("id") String id,@Param("type")Integer type);
 }

+ 2 - 0
src/main/java/com/goafanti/common/dao/RoleMapper.java

@@ -21,6 +21,8 @@ public interface RoleMapper {
 
 	Set<String> findRoleByUserId(String userId);
 
+	List<Role> selectByAid(String userId);
+
 	List<RolePermissionBo> findRolePermissions();
 
 	int insertBatch(List<Role> records);

+ 4 - 0
src/main/java/com/goafanti/common/dao/TOrderNewMapper.java

@@ -67,4 +67,8 @@ public interface TOrderNewMapper {
      */
     OrderProcessName getProcessName(String orderNo);
 
+    void updateExamine(String departmentId);
+
+    void updateExamineById(@Param("id") String id,@Param("type")Integer type);
+
 }

+ 41 - 18
src/main/java/com/goafanti/common/mapper/NewOrderChangeMapper.xml

@@ -735,24 +735,13 @@ select
 
 
   <update id="updateExamineName">
-    update  new_order_change a
-    <if test="names ==null">
-      ,t_order_new b,admin c
-      set a.examine_name=c.name
-      where a.process_state = #{type} and a.order_no =b.order_no
-      <if test="type==1">
-        and b.order_dep = #{depId}
-      </if>
-      and c.id= #{aid}
-    </if>
-      <if test="names !=null">
-        ,t_order_new b
-        set a.examine_name=#{names}
-        where a.process_state = #{type} and a.order_no =b.order_no
-        <if test="type==1">
-          and b.order_dep = #{depId}
-        </if>
-      </if>
+    update new_order_change a , t_order_new b ,(select a.department_id depId,group_concat(a.name) name
+                                                from admin a left join user_role b on a.id=b.uid
+                                                             left join `role` c on b.rid =c.id
+                                                where c.role_type ='9996' and a.status ='0' and a.department_id = #{depId}
+                                                group by a.department_id ) c
+    set a.examine_name =c.name
+    where a.order_no =b.order_no and b.order_dep = #{depId} and b.order_dep =c.depId
   </update>
     <update id="updateTaskExamineName">
       update new_order_change n left join (select c.id
@@ -772,6 +761,40 @@ select
       set n.examine_name =a.name
       where n.process_state =#{type}
     </update>
+  <update id="updateExamineById">
+    update new_order_change a left join t_order_new b on a.order_no =b.order_no
+    <if test="type==1">
+      left join admin c on b.salesman_id =c.id
+      set a.examine_name=c.name
+      where a.process_state =1 and c.manager_id = #{id}
+    </if>
+    <if test="type==3">
+      left join department c on b.order_dep =c.id
+      left join admin d on c.finance_id =d.id
+      set a.examine_name=d.name
+      where a.process_state =3 and d.id = #{id}
+    </if>
+    <if test="type==3">
+      left join department c on b.order_dep =c.id
+      left join admin d on c.finance_id =d.id
+      set a.examine_name=d.name
+      where a.process_state =3 and d.id = #{id}
+    </if>
+    <if test="type==5 or type==7">
+      left join (select group_concat(a.name) name
+      from admin a left join user_role b on a.id=b.uid
+      left join `role` c on b.rid =c.id
+        <if test="type==5">
+      where c.role_type in ('9998') and a.status ='0'
+        </if>
+      <if test="type==7">
+      where c.role_type in ('9997') and a.status ='0'
+        </if>
+        )c on 1=1
+      set a.examine_name =c.name
+      where a.process_state = #{type}
+    </if>
+  </update>
 
   <select id="getProcessName" resultType="com.goafanti.order.bo.OutProcessName">
     select a.id,a.order_no orderNo ,a.`type`,a.change_amount changeAmount ,a.status,a.process_state processState,

+ 8 - 0
src/main/java/com/goafanti/common/mapper/RoleMapper.xml

@@ -108,6 +108,13 @@
     left join user_role tur on tur.rid=tr.id
     where tur.uid = #{userId,jdbcType=VARCHAR}
   </select>
+
+    <select id="selectByAid" resultType="com.goafanti.common.model.Role">
+        select tr.id, tr.role_name roleName, tr.role_type roleType ,tr.creater,tr.create_time as createTime
+        from role tr
+        left join user_role tur on tur.rid=tr.id
+        where tur.uid = #{userId,jdbcType=VARCHAR}
+    </select>
   <delete id="deleteByPrimaryKeys" parameterType="java.lang.String">
     delete from role
     where id in
@@ -187,4 +194,5 @@
             #{item,jdbcType=VARCHAR}
         </foreach>
     </select>
+
 </mapper>

+ 31 - 0
src/main/java/com/goafanti/common/mapper/TOrderNewMapper.xml

@@ -1630,6 +1630,37 @@ left join department d on o.order_dep = d.id   left join t_order_mid a on o.orde
     update t_order_new set settlement_amount=settlement_amount-#{refundAmount,jdbcType=DECIMAL},
                            refund_amount=#{refundAmount,jdbcType=DECIMAL}	where order_no=#{orderNo}
   </update>
+    <update id="updateExamine">
+      update t_order_new a ,(select a.department_id depId,group_concat(a.name) name
+                             from admin a left join user_role b on a.id=b.uid
+                                          left join `role` c on b.rid =c.id
+                             where c.role_type ='9996' and a.status ='0' and a.department_id = #{departmentId}
+                             group by a.department_id ) b
+      set a.examine_name =b.name
+      where a.order_dep = #{departmentId} and a.order_dep =b.depId
+    </update>
+  <update id="updateExamineById">
+    update t_order_new a
+    <if test="type==1">
+    left join admin b on a.salesman_id =b.id
+    set a.examine_name=b.name
+    where a.process_status =1 and b.manager_id = #{id}
+    </if>
+    <if test="type==3">
+      left join department b on a.order_dep =b.id
+      left join admin c on b.finance_id =c.id
+      set a.examine_name =c.name
+      where a.process_status =3 and c.id =#{id}
+    </if>
+    <if test="type==5">
+      update t_order_new a left join (select group_concat(a.name) name
+      from admin a left join user_role b on a.id=b.uid
+      left join `role` c on b.rid =c.id
+      where c.role_type in ('9998') and a.status ='0' )b on 1=1
+      set a.examine_name =b.name
+      where a.process_status =5
+    </if>
+  </update>
 
 
 

+ 89 - 4
src/main/java/com/goafanti/common/utils/AsyncUtils.java

@@ -1,10 +1,7 @@
 package com.goafanti.common.utils;
 
 import java.io.UnsupportedEncodingException;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
-import java.util.UUID;
+import java.util.*;
 
 import javax.mail.MessagingException;
 
@@ -55,6 +52,8 @@ public class AsyncUtils {
 	private OrderChangeLogMapper orderChangeLogMapper;
 	@Autowired
 	private TChangeTaskMapper tChangeTaskMapper;
+	@Autowired
+	private RoleMapper roleMapper;
 
 
 
@@ -447,4 +446,90 @@ public class AsyncUtils {
 			}
 		}
 	}
+
+	/**
+	 * 处理修改角色对于订单、变更审核人员的修改
+	 * @param ad
+	 * @param usead
+	 * @param roleIds
+	 */
+	public  void pushRoleUpdateExamine(Admin ad, Admin usead, List<String> roleIds, List<Role>  useRole) {
+		List<Role> roles = roleMapper.selectByIdList(roleIds);
+		updateExamineByRole(ad, usead, useRole, roles,AFTConstants.SALESMAN_MANAGER);
+		updateExamineByRole(ad, usead, useRole, roles,AFTConstants.SALESMAN_ADMIN);
+		updateExamineByRole(ad, usead, useRole, roles,AFTConstants.TECH_ADMIN);
+		updateExamineByRole(ad, usead, useRole, roles,AFTConstants.FINANCE);
+		updateExamineByRole(ad, usead, useRole, roles,AFTConstants.FINANCE_ADMIN);
+		updateExamineByRole(ad, usead, useRole, roles,AFTConstants.SALESMAN_ADMIN);
+	}
+
+	private void updateExamineByRole(Admin ad, Admin usead, List<Role> useRole, List<Role> roles, String roleType) {
+		boolean updateParam=false;
+		int updatedep =0;
+		if (!ad.getName().equals(usead.getName())){
+			updateParam=true;
+		}
+		boolean newDEP=Rolescontains(roles,roleType);
+		boolean useDep=Rolescontains(useRole,roleType);
+		if (roleType.equals(AFTConstants.SALESMAN_ADMIN)){
+			if (ad.getDepartmentId().equals(usead.getDepartmentId())){
+				updatedep=1;
+			}else{
+				updatedep=2;
+			}
+			if (newDEP&&useDep){
+				//新旧为同一个,修改当前就可以了
+				if (updatedep ==1&& updateParam){
+					updateOrderAndChangeExamine(ad, roleType);
+					//新旧不是同一个,俩个都要修改
+				}else if (updatedep ==2){
+					updateOrderAndChangeExamine(ad, roleType);
+					updateOrderAndChangeExamine(usead, roleType);
+				}
+			}else if (newDEP&&!useDep){
+				updateOrderAndChangeExamine(ad, roleType);
+			}else if (!newDEP&&useDep){
+				updateOrderAndChangeExamine(usead, roleType);
+			}
+		}else {
+			if (updateParam){
+				updateOrderAndChangeExamine(ad, roleType);
+			}
+		}
+
+	}
+
+
+	private boolean Rolescontains(List<Role> roles, String roleType) {
+		for (Role role : roles) {
+			if (role.getRoleType().equals(roleType)){
+				return true;
+			}
+		}
+		return false;
+	}
+	/**
+	 *
+	 * @param ad
+	 * @param roleType
+	 */
+	public void updateOrderAndChangeExamine(Admin ad, String roleType) {
+		if (roleType.equals(AFTConstants.SALESMAN_ADMIN)){
+			tOrderNewMapper.updateExamine(ad.getDepartmentId());
+			newOrderChangeMapper.updateExamineName(ad.getDepartmentId());
+		}else if (roleType.equals(AFTConstants.SALESMAN_MANAGER)){
+//			订单 0=营销员,1=经理,2=营销管理员,3=财务专员,4=总裁,5=技术总监,6部分分配,7全部分配
+//			变更 流程状态 0=营销员,1=营销经理,2=营销管理员,3=技术员,4=技术经理,5=技术总监,6=财务专员,7=财务总监,8=总裁,9=董事长
+			tOrderNewMapper.updateExamineById(ad.getId(),1);
+			newOrderChangeMapper.updateExamineById(ad.getId(),1);
+		}else if (roleType.equals(AFTConstants.FINANCE)){
+			tOrderNewMapper.updateExamineById(ad.getId(),3);
+			newOrderChangeMapper.updateExamineById(ad.getId(),3);
+		}else if (roleType.equals(AFTConstants.TECH_ADMIN)) {
+			tOrderNewMapper.updateExamineById(null, 5);
+			newOrderChangeMapper.updateExamineById(null, 5);
+		}else if (roleType.equals(AFTConstants.FINANCE_ADMIN)) {
+			newOrderChangeMapper.updateExamineById(null, 7);
+		}
+	}
 }