Browse Source

用户新增修改权限判断修改

anderx 3 years ago
parent
commit
9071a633eb

+ 35 - 7
src/main/java/com/goafanti/admin/service/impl/NewAdminServiceImpl.java

@@ -125,11 +125,26 @@ public class NewAdminServiceImpl extends BaseMybatisDao<AdminMapper> implements
 
 
 	private void pushAdminRole(String id,List<String>roleIds, Set<String> useRole) {
-		boolean flag=false;
+		Integer flag=0;
+		String roleType="";
+		//加入以前有也要重新计算
 		if (useRole!=null){
 			for (String s : useRole) {
-				if (AFTConstants.COMPANY_MANAGER.equals(s)){
-					flag=true;
+				if (AFTConstants.SALESMAN_ADMIN.equals(s)){
+					flag=1;
+					roleType=AFTConstants.SALESMAN_ADMIN;
+					break;
+				}else if (AFTConstants.COMPANY_MANAGER.equals(s)){
+					flag=2;
+					roleType=AFTConstants.COMPANY_MANAGER;
+					break;
+				}else if (AFTConstants.FINANCE_ADMIN.equals(s)){
+					flag=3;
+					roleType=AFTConstants.FINANCE_ADMIN;
+					break;
+				}else if (AFTConstants.TECH_ADMIN.equals(s)){
+					flag=4;
+					roleType=AFTConstants.TECH_ADMIN;
 					break;
 				}
 			}
@@ -137,15 +152,28 @@ public class NewAdminServiceImpl extends BaseMybatisDao<AdminMapper> implements
 		List<Role> roleList = roleMapper.selectByIdList(roleIds);
 		if (roleList!=null){
 			for (Role role : roleList) {
-				if (AFTConstants.COMPANY_MANAGER.equals(role.getRoleType().toString())){
-					flag=true;
+				if (AFTConstants.SALESMAN_ADMIN.equals(role.getRoleType().toString())){
+					flag=1;
+					roleType=AFTConstants.SALESMAN_ADMIN;
+					break;
+				}else if (AFTConstants.COMPANY_MANAGER.equals(role.getRoleType().toString())){
+					flag=2;
+					roleType=AFTConstants.COMPANY_MANAGER;
+					break;
+				}else if (AFTConstants.FINANCE_ADMIN.equals(role.getRoleType().toString())){
+					flag=3;
+					roleType=AFTConstants.FINANCE_ADMIN;
+					break;
+				}else if (AFTConstants.TECH_ADMIN.equals(role.getRoleType().toString())){
+					flag=4;
+					roleType=AFTConstants.TECH_ADMIN;
 					break;
 				}
 			}
 		}
-		if (flag){
+		if (flag!=1){
 			Admin admin = adminMapper.selectByPrimaryKey(id);
-			asyncUtils.updateexamineName(2,admin.getDepartmentId(),admin.getId());
+			asyncUtils.updateListExamineName(flag,admin.getDepartmentId(),roleType);
 		}
 
 	}

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

@@ -49,4 +49,6 @@ public interface NewOrderChangeMapper {
      * @return
      */
     int updateExamineName(@Param("type")Integer type, @Param("depId")String depId, @Param("aid")String aid);
+
+    int updateTaskExamineName(@Param("aid") String aid, @Param("taskReceiverId") String taskReceiverId,@Param("type") Integer type);
 }

+ 1 - 0
src/main/java/com/goafanti/common/dao/OrderExamineMapper.java

@@ -116,4 +116,5 @@ public interface OrderExamineMapper {
     void deleteByAidAndStatus(@Param("aid")String aid,  @Param("type")Integer type);
 
 
+    void updateBack(@Param("aid")String aid, @Param("taskReceiverId")String taskReceiverId);
 }

+ 2 - 3
src/main/java/com/goafanti/common/dao/TOrderInvoiceMapper.java

@@ -45,10 +45,9 @@ public interface TOrderInvoiceMapper {
     int updateExamineName(@Param("type")Integer type, @Param("depId")String depId, @Param("aid")String aid);
 
     /**
-     *  type 为预留,目前没有改sql
-     * @param type 2 公司管理
+     * @param roleType
      * @param depId
      * @return
      */
-    int updateListExamineName(@Param("type")Integer type, @Param("depId")String depId);
+    int updateListExamineName(@Param("type")Integer type, @Param("depId")String depId,@Param("roleType")String roleType);
 }

+ 11 - 0
src/main/java/com/goafanti/common/mapper/NewOrderChangeMapper.xml

@@ -734,4 +734,15 @@ select
       and b.order_dep = #{depId}
       and c.id= #{aid}
   </update>
+    <update id="updateTaskExamineName">
+      update new_order_change n left join (select a.order_no
+           from t_order_new a left join t_order_task b on a.order_no =b.order_no
+                              left join new_order_change c on a.order_no =c.order_no
+           where b.task_receiver in (#{aid},#{taskReceiverId})
+             and c.process_state in (#{type}) group by a.order_no )x on n.order_no =x.order_no
+      left join (select a.order_no ,group_concat(b.name)name from order_examine a left join admin b on a.aid=b.id
+                   where  a.type=0 group by a.order_no ) a on n.order_no =a.order_no
+      set n.examine_name =a.name
+      where n.process_state =#{type}
+    </update>
 </mapper>

+ 6 - 0
src/main/java/com/goafanti/common/mapper/OrderExamineMapper.xml

@@ -337,8 +337,14 @@
       and type= #{type}
     </if>
   </update>
+
   <delete id="deleteByAidAndStatus">
     delete  from order_examine
     where status=0 and  aid=#{aid} and type=#{type}
   </delete>
+  <update id="updateBack">
+    update order_examine
+    set aid= #{taskReceiverId} ,`type` =1
+    where aid= #{aid} and and status =0
+  </update>
 </mapper>

+ 13 - 7
src/main/java/com/goafanti/common/mapper/TOrderInvoiceMapper.xml

@@ -611,12 +611,18 @@ where a.status=2 and a.order_no=  #{orderNo,jdbcType=VARCHAR}
       and c.id= #{aid}
   </update>
   <update id="updateListExamineName">
-    update t_order_invoice t0,(select a.id , ifnull(GROUP_CONCAT(x.name) ,'暂无人员')name
-        from t_order_invoice a left join t_order_new b on a.order_no =b.order_no left join (select name ,department_id
-            from admin a left join user_role b on a.id =b.uid left join `role` c on b.rid =c.id where a.status ='0'
-            and c.role_type in ('9993'))x on b.order_dep =x.department_id where a.`type` =1 and a.status =1
-        and a.approval =1 and b.order_dep= #{depId}  group by a.id)t1
-    set t0.examine_name =t1.name
-    where t0.id=t1.id
+    <if test="type==1">
+
+    </if>
+    <if test="type==2">
+      update t_order_invoice t0,(select a.id , ifnull(GROUP_CONCAT(x.name) ,'暂无人员')name
+      from t_order_invoice a left join t_order_new b on a.order_no =b.order_no left join (select name ,department_id
+      from admin a left join user_role b on a.id =b.uid left join `role` c on b.rid =c.id where a.status ='0'
+      and c.role_type in (#{roleType}))x on b.order_dep =x.department_id where a.`type` =1 and a.status =1
+      and a.approval =1 and b.order_dep= #{depId}  group by a.id)t1
+      set t0.examine_name =t1.name
+      where t0.id=t1.id
+    </if>
+
   </update>
 </mapper>

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

@@ -9,6 +9,7 @@ import java.util.UUID;
 import javax.mail.MessagingException;
 
 import com.goafanti.admin.bo.AdminListBo;
+import com.goafanti.common.constant.AFTConstants;
 import com.goafanti.common.dao.*;
 import com.goafanti.common.enums.NoticeStatus;
 import com.goafanti.common.model.Admin;
@@ -112,22 +113,35 @@ public class AsyncUtils {
 
 	/**
 	 * 切换审核人员
-	 * @param type 1营销管理 2公司管理  3财务
+	 * @param type 1营销管理   3财务
 	 * @param depId 部门编号
 	 * @param aid 切换后审核人
 	 * @return
 	 */
-    public void updateexamineName(Integer type, String depId, String aid) {
+    public void updateExamineName(Integer type, String depId, String aid) {
 		if (type==1){
 			tOrderNewMapper.updateExamineName(1,depId,aid);
 			newOrderChangeMapper.updateExamineName(1,depId,aid);
 			tOrderInvoiceMapper.updateExamineName(1,depId,aid);
-		}else if (type==2){
-			tOrderInvoiceMapper.updateListExamineName(2,depId);
 		}else if (type==3){
 			tOrderNewMapper.updateExamineName(3,depId,aid);
 			newOrderChangeMapper.updateExamineName(5,depId,aid);
 			tOrderInvoiceMapper.updateExamineName(0,depId,aid);
 		}
 	}
+
+	/**
+	 *
+	 * @param type 1营销管理 2公司管理 3财务管理 4咨询管理
+	 * @param depId
+	 * @param roleType
+	 */
+	public void updateListExamineName(Integer type, String depId, String roleType) {
+
+		if (type==1){
+			tOrderInvoiceMapper.updateListExamineName(type,depId,roleType);
+		}else if (type==2){
+			tOrderInvoiceMapper.updateListExamineName(type,depId,roleType);
+		}
+	}
 }

+ 31 - 0
src/main/java/com/goafanti/order/service/impl/OrderProjectServiceImpl.java

@@ -119,6 +119,11 @@ public class OrderProjectServiceImpl extends BaseMybatisDao<TOrderTaskMapper> im
 	private TTaskMemberMapper tTaskMemberMapper;
 	@Autowired
 	private TOrderMidMapper	tOrderMidMapper;
+	@Autowired
+	private OrderExamineMapper orderExamineMapper;
+	@Autowired
+	private NewOrderChangeMapper newOrderChangeMapper;
+
 	@Value(value = "${upload.path}")
 	private String 					uploadPath 			= null;
 
@@ -160,6 +165,7 @@ public class OrderProjectServiceImpl extends BaseMybatisDao<TOrderTaskMapper> im
 			t.setConsultantId(null);
 			t.setManagerId(taskReceiverId);
 		}
+
 		t.setReceiverName(a.getName());
 		tOrderTaskMapper.updateByPrimaryKey(t);
 		List<String> aids = new ArrayList<>();
@@ -167,9 +173,34 @@ public class OrderProjectServiceImpl extends BaseMybatisDao<TOrderTaskMapper> im
 		TOrderNewBo order = tOrderNewMapper.getSaleIdByOno(t.getOrderNo());
 		orderNewService.pushGeneralSendNoticeAndEmail(aids, NoticeStatus.ORDER_TASK_TO.getCode(),order, TokenManager.getAdminId(),0,taskId);
 		checkProjiectAllocation(t.getOrderNo());
+		pushTaskChange(TokenManager.getAdminId(),taskReceiverId,type,t.getOrderNo());
 		return 1;
 	}
 
+	/**
+	 *
+	 * @param aid 操作者
+	 * @param taskReceiverId 接收方
+	 * @param type type – 0管理员派单 1经理转交 2经理派单 3咨询师转交 4回退
+	 */
+	private void pushTaskChange(String aid, String taskReceiverId,Integer type,String orderNo) {
+		if (type==1||type==3){
+			orderExamineMapper.updateDimissionTransfer(aid,taskReceiverId,null);
+		}else if (type==2){
+			OrderExamine o=new OrderExamine();
+			o.setAid(taskReceiverId);
+			o.setOrderNo(orderNo);
+			o.setCreateTime(new Date());
+			o.setType(0);//咨询师经理
+			o.setStatus(0);//正常
+			orderExamineMapper.insertSelective(o);
+		}else if (type==4){
+			orderExamineMapper.updateBack(aid,taskReceiverId);
+		}
+		newOrderChangeMapper.updateTaskExamineName(aid,taskReceiverId,2);
+		newOrderChangeMapper.updateTaskExamineName(aid,taskReceiverId,3);
+	}
+
 	private void projectDistributionPushUserMid(TOrderNew tn) {
 		if (tn.getProcessStatus()==4){
 			UserMid um=new UserMid();

+ 2 - 2
src/main/java/com/goafanti/organization/service/impl/OrganizationServiceImpl.java

@@ -199,10 +199,10 @@ public class OrganizationServiceImpl extends BaseMybatisDao<DepartmentMapper> im
 		Department use = departmentMapper.selectByPrimaryKey(id);
 		if (!use.getFinanceId().equals(financeId)){
 			//切换后更换审核人
-			asyncUtils.updateexamineName(3,id,financeId);
+			asyncUtils.updateExamineName(3,id,financeId);
 		}
 		if (!use.getManagerId().equals(managerId)){
-			asyncUtils.updateexamineName(1,id,managerId);
+			asyncUtils.updateExamineName(1,id,managerId);
 		}
 		tOrderMidMapper.updateFinanceId(id,financeId);
 		int x=departmentMapper.updateByPrimaryKeySelective(dep);

+ 4 - 0
src/main/java/com/goafanti/permission/service/impl/NewRoleServiceImpl.java

@@ -217,6 +217,7 @@ public class NewRoleServiceImpl extends BaseMybatisDao<RoleMapper> implements Ne
 				userTransferLogMapper.insertUserLockLog(aid,transferId,date);
 				patentNewMapper.updateAdmin(aid,transferId);
 				roleResourcesMapper.updateLockRelease("1",aid,transferId);//将业务锁转给指定人
+
 			}
 			if (s == roleResources.YQDD.getCode()) {
 
@@ -271,6 +272,7 @@ public class NewRoleServiceImpl extends BaseMybatisDao<RoleMapper> implements Ne
 				int x=1;
 				if (changeBo.getProcessState()==2){
 					x=orderExamineMapper.checkCountStatus(changeBo.getOrderNo(), 0,0);
+
 				}else if (changeBo.getProcessState()==3){
 					  x=orderExamineMapper.checkCountStatus(changeBo.getOrderNo(), 1,0);
 				}
@@ -287,6 +289,8 @@ public class NewRoleServiceImpl extends BaseMybatisDao<RoleMapper> implements Ne
 					newOrderChangeMapper.updateByPrimaryKeySelective(changeBo);
 				}
 			}
+			newOrderChangeMapper.updateTaskExamineName(aid,transferId,2);
+			newOrderChangeMapper.updateTaskExamineName(aid,transferId,3);
 			taskAttributionLogMapper.insertList(aid, transferId, date);
 			tTaskLogMapper.updateDimissionTransfer(aid, transferId);
 		}

+ 4 - 4
src/main/java/com/goafanti/user/controller/UserLoginController.java

@@ -100,18 +100,18 @@ public class UserLoginController extends BaseController {
 	@CrossOrigin
 	public Result managesignin(Admin admin, Boolean remember) {
 		Result res = new Result();
-		String mobile=adminMapper.selectStatusByMobile(admin.getMobile());
-		if("锁定".equals(mobile)){
+		Admin a =adminMapper.selectByMobile(admin.getMobile());
+		if("1".equals(a.getStatus())){
 			res.getError().add(buildError("","用户已被锁定不能登录"));
 			return res;
 		}
-		if("注销".equals(mobile)){
+		if("2".equals(a.getStatus())){
 			res.getError().add(buildError("","用户已被注销"));
 			return res;
 		}
 
 		res.setData(TokenManager.manageLogin(admin, remember));
-		Admin a =adminMapper.selectByMobile(admin.getMobile());
+
 		if (a!=null) {
 			shiroAddRedis();
 			a.setLastLoginTime(new Date());