Browse Source

离职一键转交变更审核角色处理

anderx 3 years ago
parent
commit
14ea823433

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

@@ -114,4 +114,6 @@ public interface OrderExamineMapper {
      * @param type 0咨询师 1经理
      */
     void deleteByAidAndStatus(@Param("aid")String aid,  @Param("type")Integer type);
+
+
 }

+ 8 - 7
src/main/java/com/goafanti/common/dao/TChangeTaskMapper.java

@@ -78,25 +78,26 @@ public interface TChangeTaskMapper {
 	void insertSelectiveList(@Param("list")List<TChangeTask> list);
 
 	List<TChangeTaskOut> selectByCid(@Param("id")Integer id, @Param("splitStatus")Integer splitStatus);
-	
+
 	/**
-	 * 
+	 *
 	 * @param tid �更项目id
 	 * @param sid �更拆分父项目id
 	 * @param type 处�类型
-	 * @param i 
 	 * @return
 	 */
 	int updateByTid(@Param("tid")Integer tid,@Param("sid")Integer sid,@Param("cid")Integer cid,@Param("type")Integer type);
-	
+
 	int deleteByTid(Integer tid);
 
 	/**
-	 *   获��更�项�??
+	 *   获��更�项�???
 	 * @param splitSuper
-	 * @param cid 
+	 * @param cid
 	 * @return
 	 */
 	List<TChangeTask> selectBySuper(@Param("splitSuper")Integer splitSuper, @Param("cid")Integer cid);
 
-}
+
+	TChangeTask selectBytid(Integer id);
+}

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

@@ -66,4 +66,5 @@ public interface TOrderTaskMapper {
                                                    @Param("sort") Integer sort, @Param("startDate") String startDate, @Param("endDate") String endDate);
 
 
+    List<TOrderTaskBo> selectByAid(String aid);
 }

+ 35 - 27
src/main/java/com/goafanti/common/mapper/TChangeTaskMapper.xml

@@ -99,8 +99,8 @@
       This element is automatically generated by MyBatis Generator, do not modify.
       This element was generated on Fri Oct 16 15:54:00 CST 2020.
     -->
-    id, tid, cid, order_no, main, commodity_id, commodity_name, commodity_quantity, commodity_price, 
-    task_comment, type, create_time, split_status, split_super, receiver_name, official_cost, 
+    id, tid, cid, order_no, main, commodity_id, commodity_name, commodity_quantity, commodity_price,
+    task_comment, type, create_time, split_status, split_super, receiver_name, official_cost,
     cost_reduction
   </sql>
   <select id="selectByExample" parameterType="com.goafanti.common.model.TChangeTaskExample" resultMap="BaseResultMap">
@@ -128,7 +128,7 @@
       This element is automatically generated by MyBatis Generator, do not modify.
       This element was generated on Fri Oct 16 15:54:00 CST 2020.
     -->
-    select 
+    select
     <include refid="Base_Column_List" />
     from t_change_task
     where id = #{id,jdbcType=INTEGER}
@@ -159,17 +159,17 @@
       This element is automatically generated by MyBatis Generator, do not modify.
       This element was generated on Fri Oct 16 15:54:00 CST 2020.
     -->
-    insert into t_change_task (id, tid, cid, 
-      order_no, main, commodity_id, 
-      commodity_name, commodity_quantity, commodity_price, 
-      task_comment, type, create_time, 
-      split_status, split_super, receiver_name, 
+    insert into t_change_task (id, tid, cid,
+      order_no, main, commodity_id,
+      commodity_name, commodity_quantity, commodity_price,
+      task_comment, type, create_time,
+      split_status, split_super, receiver_name,
       official_cost, cost_reduction)
-    values (#{id,jdbcType=INTEGER}, #{tid,jdbcType=INTEGER}, #{cid,jdbcType=INTEGER}, 
-      #{orderNo,jdbcType=VARCHAR}, #{main,jdbcType=INTEGER}, #{commodityId,jdbcType=VARCHAR}, 
-      #{commodityName,jdbcType=VARCHAR}, #{commodityQuantity,jdbcType=INTEGER}, #{commodityPrice,jdbcType=DECIMAL}, 
-      #{taskComment,jdbcType=VARCHAR}, #{type,jdbcType=INTEGER}, #{createTime,jdbcType=TIMESTAMP}, 
-      #{splitStatus,jdbcType=INTEGER}, #{splitSuper,jdbcType=INTEGER}, #{receiverName,jdbcType=VARCHAR}, 
+    values (#{id,jdbcType=INTEGER}, #{tid,jdbcType=INTEGER}, #{cid,jdbcType=INTEGER},
+      #{orderNo,jdbcType=VARCHAR}, #{main,jdbcType=INTEGER}, #{commodityId,jdbcType=VARCHAR},
+      #{commodityName,jdbcType=VARCHAR}, #{commodityQuantity,jdbcType=INTEGER}, #{commodityPrice,jdbcType=DECIMAL},
+      #{taskComment,jdbcType=VARCHAR}, #{type,jdbcType=INTEGER}, #{createTime,jdbcType=TIMESTAMP},
+      #{splitStatus,jdbcType=INTEGER}, #{splitSuper,jdbcType=INTEGER}, #{receiverName,jdbcType=VARCHAR},
       #{officialCost,jdbcType=INTEGER}, #{costReduction,jdbcType=INTEGER})
   </insert>
   <insert id="insertSelective" parameterType="com.goafanti.common.model.TChangeTask">
@@ -473,17 +473,17 @@
       cost_reduction = #{costReduction,jdbcType=INTEGER}
     where id = #{id,jdbcType=INTEGER}
   </update>
-  
+
   <insert id="insertSelectiveList" parameterType="java.util.List">
     insert into t_change_task ( tid, cid, split_status,
-      order_no, commodity_id, commodity_name, 
-      commodity_quantity, commodity_price, task_comment, 
+      order_no, commodity_id, commodity_name,
+      commodity_quantity, commodity_price, task_comment,
         split_super , receiver_name, create_time)
-    values 
+    values
     <foreach collection="list" index="index" item="item" separator=",">
       ( #{item.tid,jdbcType=INTEGER}, #{item.cid,jdbcType=INTEGER}, #{item.splitStatus,jdbcType=INTEGER},
-      #{item.orderNo,jdbcType=VARCHAR}, #{item.commodityId,jdbcType=VARCHAR}, #{item.commodityName,jdbcType=VARCHAR}, 
-      #{item.commodityQuantity,jdbcType=INTEGER}, #{item.commodityPrice,jdbcType=DECIMAL}, #{item.taskComment,jdbcType=VARCHAR}, 
+      #{item.orderNo,jdbcType=VARCHAR}, #{item.commodityId,jdbcType=VARCHAR}, #{item.commodityName,jdbcType=VARCHAR},
+      #{item.commodityQuantity,jdbcType=INTEGER}, #{item.commodityPrice,jdbcType=DECIMAL}, #{item.taskComment,jdbcType=VARCHAR},
        #{item.splitSuper,jdbcType=INTEGER}, #{item.receiverName,jdbcType=VARCHAR}, now())
     </foreach>
   </insert>
@@ -493,7 +493,7 @@
 	a.receiver_name receiverName, a.task_comment as taskComment ,a.commodity_price as commodityPrice,a.split_status splitStatus,
 	a.split_super splitSuper
     from t_change_task a left join business_project i on a.commodity_id=i.id
-  	left join business_category c on i.cid=c.id 
+  	left join business_category c on i.cid=c.id
   	where 1=1
   	<if test="splitStatus !=null and splitStatus !=3">
   	and a.split_status= #{splitStatus}
@@ -504,8 +504,8 @@
   	 and a.cid= #{id} order by a.id
   </select>
     <update id="updateByTid">
-  		update t_change_task set type= #{type} 
-  		where 1=1 
+  		update t_change_task set type= #{type}
+  		where 1=1
   		<if test="tid !=null">
   		and tid= #{tid}
   		</if>
@@ -516,19 +516,27 @@
   		and split_super= #{sid}
   		</if>
   </update>
-  
+
    <update id="deleteByTid">
   		delete from t_change_task where tid= #{tid};
   </update>
-  
-  
+
+
 
     <select id="selectBySuper" resultType="com.goafanti.order.bo.TChangeTaskOut">
 	select a.id,a.order_no as orderNo,a.main, c.cname,c.sort cSort,a.commodity_name as commodityName,
   	a.commodity_quantity as commodityQuantity,i.price,a.commodity_id as commodityId,a.type,a.tid,a.receiver_name receiverName,
 	a.task_comment as taskComment ,a.commodity_price as commodityPrice,a.split_status splitStatus,a.split_super splitSuper
     from t_change_task a left join business_project i on a.commodity_id=i.id
-  	left join business_category c on i.cid=c.id 
+  	left join business_category c on i.cid=c.id
   	where a.split_status=2 and a.split_super= #{splitSuper} and a.cid= #{cid} order by a.id
   </select>
-</mapper>
+
+
+
+<select id="selectBytid" resultType="com.goafanti.common.model.TChangeTask">
+    select tct.id,tct.tid,tct.cid,tct.order_no orderNo
+    from t_change_task tct left join new_order_change noc on tct.cid =noc.id
+    where noc.process_state &lt; 4 and tct.tid= #{tid}
+  </select>
+</mapper>

+ 3 - 0
src/main/java/com/goafanti/common/mapper/TOrderTaskMapper.xml

@@ -1876,6 +1876,9 @@
         and a.process_status = #{status}
       </if>
   </select>
+  <select id="selectByAid" resultType="com.goafanti.order.bo.TOrderTaskBo">
+    select id,order_no orderNo ,task_receiver taskReceiver from t_order_task where task_receiver = #{aid}
+  </select>
 
 
 </mapper>

+ 58 - 41
src/main/java/com/goafanti/permission/service/impl/NewRoleServiceImpl.java

@@ -10,35 +10,18 @@ import java.util.Map;
 import java.util.Set;
 import java.util.UUID;
 
+import com.goafanti.common.bo.OrderExamineBo;
+import com.goafanti.common.dao.*;
+import com.goafanti.common.model.*;
+import com.goafanti.order.bo.NewOrderChangeBo;
+import com.goafanti.order.bo.TOrderTaskBo;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 import com.goafanti.common.bo.Error;
 import com.goafanti.common.constant.AFTConstants;
-import com.goafanti.common.dao.AdminMapper;
-import com.goafanti.common.dao.OrderExamineMapper;
-import com.goafanti.common.dao.OrganizationContactBookMapper;
-import com.goafanti.common.dao.PatentNewMapper;
-import com.goafanti.common.dao.RoleMapper;
-import com.goafanti.common.dao.RolePermissionMapper;
-import com.goafanti.common.dao.RoleResourcesMapper;
-import com.goafanti.common.dao.TOrderLogMapper;
-import com.goafanti.common.dao.TOrderMidMapper;
-import com.goafanti.common.dao.TOrderNewMapper;
-import com.goafanti.common.dao.TOrderTaskMapper;
-import com.goafanti.common.dao.TTaskLogMapper;
-import com.goafanti.common.dao.TaskAttributionLogMapper;
-import com.goafanti.common.dao.UserBusinessMapper;
-import com.goafanti.common.dao.UserMapper;
-import com.goafanti.common.dao.UserRoleMapper;
-import com.goafanti.common.dao.UserTransferLogMapper;
 import com.goafanti.common.enums.roleResources;
 import com.goafanti.common.error.BusinessException;
-import com.goafanti.common.model.Admin;
-import com.goafanti.common.model.Role;
-import com.goafanti.common.model.RolePermission;
-import com.goafanti.common.model.RoleResources;
-import com.goafanti.common.model.UserRole;
 import com.goafanti.common.utils.StringUtils;
 import com.goafanti.core.mybatis.BaseMybatisDao;
 import com.goafanti.core.mybatis.page.Pagination;
@@ -82,6 +65,10 @@ public class NewRoleServiceImpl extends BaseMybatisDao<RoleMapper> implements Ne
 	private TaskAttributionLogMapper	taskAttributionLogMapper;
 	@Autowired
 	private TOrderLogMapper	tOrderLogMapper;
+	@Autowired
+	private TChangeTaskMapper tChangeTaskMapper;
+	@Autowired
+	private NewOrderChangeMapper newOrderChangeMapper;
 
 
 	@Override
@@ -212,6 +199,8 @@ public class NewRoleServiceImpl extends BaseMybatisDao<RoleMapper> implements Ne
 			throw new BusinessException(new Error("","用户角色资源不存在"));
 		}
 		Date date=new Date();
+		Admin admin=adminMapper.selectAllByid(aid);
+		Admin tadmin=adminMapper.selectAllByid(transferId);
 		for (Integer s : list) {
 			if (s==roleResources.YXKH.getCode()) {
 				userTransferLogMapper.insertUserLog(aid,transferId,date);
@@ -227,19 +216,17 @@ public class NewRoleServiceImpl extends BaseMybatisDao<RoleMapper> implements Ne
 				roleResourcesMapper.updateLockRelease("1",aid,transferId);//将业务锁转给指定人
 			}
 			if (s == roleResources.YQDD.getCode()) {
-				Admin ad=adminMapper.selectAllByid(aid);
-				Admin ad2=adminMapper.selectAllByid(transferId);
+
 				StringBuffer str=new StringBuffer();
-				str.append(ad.getName()).append("离职转交到").append(ad2.getName());
+				str.append(admin.getName()).append("离职转交到").append(tadmin.getName());
 				tOrderLogMapper.insertOrderLog(aid,TokenManager.getAdminId(),date,str.toString());
 				tOrderNewMapper.updateSalesmanId(aid, transferId);
 				tOrderMidMapper.updateSalesmanId(aid, transferId);
 			}
 			if (s == roleResources.XMRW.getCode()) {
 				// 获取被转角色判断修改对应任务角色
-				pushTechTransfer(aid,transferId);
-				taskAttributionLogMapper.insertList(aid, transferId, date);
-				tTaskLogMapper.updateDimissionTransfer(aid, transferId);
+				pushTechTransfer(aid,transferId,date,admin,tadmin);
+
 			}
 			if (s!=roleResources.QDYW.getCode()) {
 				roleResourcesMapper.updateDimissionTransfer(s,aid,transferId);
@@ -248,21 +235,49 @@ public class NewRoleServiceImpl extends BaseMybatisDao<RoleMapper> implements Ne
 		return 1;
 	}
 
-	private void pushTechTransfer(String aid, String transferId) {
+	private void pushTechTransfer(String aid, String transferId,Date date,Admin admin,Admin tadmin) {
+		//获取旧人员与新人员的角色
 		int useType=getTech(aid);
 		int newType=getTech(transferId);
-		if ((useType==0&&newType==0)||(useType==1&&newType==1)){
-			tOrderTaskMapper.updateDimissionTransfer(aid, transferId, useType);
-			orderExamineMapper.updateDimissionTransfer(aid, transferId,useType);
-		}else if (useType==0&&newType==1){//下转上 下清空
-			tOrderTaskMapper.updateDimissionTransfer(aid, transferId, 3);
-			orderExamineMapper.updateDimissionTransfer(aid, transferId,newType);
-			orderExamineMapper.deleteByAidAndStatus(aid,useType);
-		}else if (useType==1&&newType==0){//上转下  上清空
-			tOrderTaskMapper.updateDimissionTransfer(aid, transferId, 4);
-			orderExamineMapper.updateDimissionTransfer(aid, transferId,newType);
-			orderExamineMapper.deleteByAidAndStatus(aid,useType);
+		//如果不是咨询或者经理不走项目转交
+		if(useType!=-1&&newType!=-1){
+			//获取所有需要修改角色的变更项目
+			List<TOrderTaskBo> list = tOrderTaskMapper.selectByAid(aid);
+			if ((useType==0&&newType==0)||(useType==1&&newType==1)){
+				tOrderTaskMapper.updateDimissionTransfer(aid, transferId, useType);
+				orderExamineMapper.updateDimissionTransfer(aid, transferId,useType);
+			}else if (useType==0&&newType==1){//下转上 下清空
+				tOrderTaskMapper.updateDimissionTransfer(aid, transferId, 3);
+				orderExamineMapper.updateDimissionTransfer(aid, transferId,newType);
+				orderExamineMapper.deleteByAidAndStatus(aid,useType);
+			}else if (useType==1&&newType==0){//上转下  上清空
+				tOrderTaskMapper.updateDimissionTransfer(aid, transferId, 4);
+				orderExamineMapper.updateDimissionTransfer(aid, transferId,newType);
+				orderExamineMapper.deleteByAidAndStatus(aid,useType);
+			}
+			List<Integer> tlist=new ArrayList<>();
+			for (TOrderTaskBo tOrderTaskBo : list) {
+				TChangeTask tct = tChangeTaskMapper.selectBytid(tOrderTaskBo.getId());
+				tct.setReceiverName(tadmin.getName());
+				tChangeTaskMapper.updateByPrimaryKeySelective(tct);
+				//如果不包含就加入集合
+				if (tlist.contains(tct.getId()))tlist.add(tct.getId());
+			}
+			for (Integer i : tlist) {
+				NewOrderChangeBo changeBo = newOrderChangeMapper.selectById(i);
+				if (changeBo.getProcessState()==2){
+					int  x=orderExamineMapper.checkCountStatus(changeBo.getOrderNo(), 0,0);
+					if (x==0)changeBo.setProcessState(changeBo.getProcessState()+1);
+				}else if (changeBo.getProcessState()==3){
+					int  x=orderExamineMapper.checkCountStatus(changeBo.getOrderNo(), 1,0);
+					if (x==0)changeBo.setProcessState(changeBo.getProcessState()+1);
+				}
+				newOrderChangeMapper.updateByPrimaryKeySelective(changeBo);
+			}
+			taskAttributionLogMapper.insertList(aid, transferId, date);
+			tTaskLogMapper.updateDimissionTransfer(aid, transferId);
 		}
+
 	}
 
 	/**
@@ -273,7 +288,9 @@ public class NewRoleServiceImpl extends BaseMybatisDao<RoleMapper> implements Ne
 	private int getTech(String transferId) {
 		List<String>  l=adminMapper.getAdminRoleListByAid(transferId);
 		for (String str : l) {
-			if (str.equals(AFTConstants.TECH_MANAGER)) {
+			if (str==null){
+				break;
+			}else if (str.equals(AFTConstants.TECH_MANAGER)) {
 				return 1;
 			}else if (str.equals(AFTConstants.TECH)){
 				return 0;

+ 5 - 5
src/main/resources/props/config_local.properties

@@ -1,12 +1,12 @@
 dev.name=local
 jdbc.driverClassName=com.mysql.jdbc.Driver
-jdbc.url=jdbc\:mysql://localhost:3306/aft?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&useSSL=false
+#jdbc.url=jdbc\:mysql://localhost:3306/aft?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&useSSL=false
 #jdbc.url=jdbc\:mysql://localhost:3306/aft20220318?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&useSSL=false
-jdbc.username=root
-jdbc.password=123456
-#jdbc.url=jdbc:mysql://101.37.32.31:3306/aft?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&useSSL=false
 #jdbc.username=root
-#jdbc.password=aftdev
+#jdbc.password=123456
+jdbc.url=jdbc:mysql://101.37.32.31:3306/aft?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&useSSL=false
+jdbc.username=root
+jdbc.password=aftdev
 jdbc.validationQuery=SELECT 'x'
 jdbc.initialSize=3
 jdbc.maxActive=20