Explorar el Código

客户转交,订单转交修改公出转交审核人

anderx hace 2 años
padre
commit
506cf73bd3

+ 6 - 1
src/main/java/com/goafanti/common/dao/PublicExamineMapper.java

@@ -1,6 +1,7 @@
 package com.goafanti.common.dao;
 
 import com.goafanti.common.model.PublicExamine;
+import com.goafanti.customer.bo.PublicReleaseTransferUserBo;
 import org.apache.ibatis.annotations.Param;
 
 import java.util.List;
@@ -20,7 +21,7 @@ public interface PublicExamineMapper {
 
     List<PublicExamine> selectByPrid(Integer id);
 
-    void updatePrid(PublicExamine pe);
+    void updateStatusByPrid(PublicExamine pe);
 
 
     List<PublicExamine> selectByIds(@Param("ids") List<Integer> ids);
@@ -33,4 +34,8 @@ public interface PublicExamineMapper {
      * @param aid
      */
     void updateAidByAid(@Param("oldAid")String oldAid, @Param("aid")String aid);
+
+    List<PublicReleaseTransferUserBo> selectByuList(@Param("list") List<String> list);
+
+    void updateByPridSelective(PublicExamine pe);
 }

+ 34 - 1
src/main/java/com/goafanti/common/mapper/PublicExamineMapper.xml

@@ -96,6 +96,9 @@
       aname = #{aname,jdbcType=VARCHAR}
     where id = #{id,jdbcType=INTEGER}
   </update>
+
+
+
   <update id="updatePrid">
     update public_examine
     set  `status` = #{status,jdbcType=INTEGER}
@@ -109,6 +112,24 @@
     set a.aid=b.id ,a.aname =b.name
     where a.aid = #{oldAid} and a.status=0
   </update>
+  <update id="updateByPridSelective">
+    update public_examine
+    <set>
+      <if test="aid != null">
+        aid = #{aid,jdbcType=VARCHAR},
+      </if>
+      <if test="status != null">
+        `status` = #{status,jdbcType=INTEGER},
+      </if>
+      <if test="createTime != null">
+        create_time = #{createTime,jdbcType=TIMESTAMP},
+      </if>
+      <if test="aname != null">
+        aname = #{aname,jdbcType=VARCHAR},
+      </if>
+    </set>
+    where prid = #{prid}
+  </update>
 
 
   <select id="selectByPrid" parameterType="java.lang.Integer" resultMap="BaseResultMap">
@@ -126,8 +147,20 @@
       #{id}
     </foreach>
   </select>
-  <delete id="deletePrid">
+
+    <delete id="deletePrid">
     delete from public_examine
     where prid = #{id,jdbcType=INTEGER}
   </delete>
+
+  <select id="selectByuList" resultType="com.goafanti.customer.bo.PublicReleaseTransferUserBo">
+    SELECT a.id ,a.user_names userNames,b.uid ,a.aid ,c.aid examineId
+    from public_release a left join public_release_details b on a.id=b.prid
+                          left join public_examine c on a.id=c.prid
+    where a.public_type in (1,3)
+      and b.uid in
+    <foreach close=")" collection="list" item="uid" open="(" separator=",">
+      #{uid,jdbcType=VARCHAR}
+    </foreach>
+  </select>
 </mapper>

+ 41 - 0
src/main/java/com/goafanti/customer/bo/PublicReleaseTransferUserBo.java

@@ -0,0 +1,41 @@
+package com.goafanti.customer.bo;
+
+public class PublicReleaseTransferUserBo {
+
+    private Integer id;
+    private String uid;
+    private String aid;
+    private String userNames;
+
+    public Integer getId() {
+        return id;
+    }
+
+    public void setId(Integer id) {
+        this.id = id;
+    }
+
+    public String getUid() {
+        return uid;
+    }
+
+    public void setUid(String uid) {
+        this.uid = uid;
+    }
+
+    public String getAid() {
+        return aid;
+    }
+
+    public void setAid(String aid) {
+        this.aid = aid;
+    }
+
+    public String getUserNames() {
+        return userNames;
+    }
+
+    public void setUserNames(String userNames) {
+        this.userNames = userNames;
+    }
+}

+ 50 - 1
src/main/java/com/goafanti/customer/service/impl/CustomerServiceImpl.java

@@ -15,6 +15,7 @@ import com.goafanti.common.utils.excel.NewExcelUtil;
 import com.goafanti.core.mybatis.BaseMybatisDao;
 import com.goafanti.core.mybatis.page.Pagination;
 import com.goafanti.core.shiro.token.TokenManager;
+import com.goafanti.core.websocket.SystemWebSocketHandler;
 import com.goafanti.customer.bo.*;
 import com.goafanti.customer.service.CustomerService;
 import com.goafanti.order.bo.TOrderNewBo;
@@ -27,6 +28,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
+import org.springframework.web.socket.TextMessage;
 
 import javax.annotation.Resource;
 import java.lang.reflect.InvocationTargetException;
@@ -98,7 +100,15 @@ public class CustomerServiceImpl extends BaseMybatisDao<UserMapper> implements C
 	private TOrderLogMapper	tOrderLogMapper;
 	@Resource
 	private PublicExamineMapper publicExamineMapper;
+	@Resource
+	private PublicReleaseLogMapper publicReleaseLogMapper;
+	@Resource
+	private PublicReleaseMapper publicReleaseMapper;
+	@Autowired
+	private SystemWebSocketHandler systemWebSocketHandler;
 
+	@Autowired
+	private	AsyncUtils asyncUtils;
 
 
 
@@ -1288,7 +1298,7 @@ public class CustomerServiceImpl extends BaseMybatisDao<UserMapper> implements C
 
 			addUserTransferLog(uid, aid,oldAid, type, null, now, uList);
 			//转交客户后公出审核人也切换
-			publicExamineMapper.updateAidByAid(oldAid,aid);
+			transferUser(uList,aid,uid);
 		}
 		if (isUs) {
 			if (AFTConstants.USER_RECEIVE == operatorType) {
@@ -1302,6 +1312,45 @@ public class CustomerServiceImpl extends BaseMybatisDao<UserMapper> implements C
 		return errors;
 	}
 
+	private void transferUser(List<String> uList, String aid, String uid) {
+		if(uList.isEmpty())uList.add(uid);
+		//先查出所有在其他审核的公出
+		List<PublicReleaseTransferUserBo> list=publicExamineMapper.selectByuList(uList);
+		Admin admin = adminMapper.selectByPrimaryKey(aid);
+		for (PublicReleaseTransferUserBo e : list) {
+			PublicExamine pe=new PublicExamine();
+			pe.setPrid(e.getId());
+			if (e.getAid().equals(aid)){
+				//再查比对和发起者一致的全部走入下一个审核流程
+				PublicReleaseLog log = new PublicReleaseLog(e.getId(), TokenManager.getAdminId(), 2, "转交客户到发起公出审核人,自动审核通过。", new Date());
+				publicReleaseLogMapper.insertSelective(log);
+				PublicRelease pr=new PublicRelease();
+				pr.setId(e.getId());
+				pr.setPublicType(0);
+				publicReleaseMapper.updateByPrimaryKeySelective(pr);
+				Admin sendAdmin=adminMapper.selectByPrimaryKey(admin.getReviewer());
+				systemWebSocketHandler.sendMessageToUser(sendAdmin.getId(), new TextMessage("unread"));
+				StringBuffer content=new StringBuffer().append("[").append(e.getUserNames()).append("]公司的外出申请已发起,请尽快审核。");
+				Notice n =new Notice();
+				n.setId(UUID.randomUUID().toString());
+				n.setAid(sendAdmin.getId());
+				n.setNoticeType(NoticeStatus.PUBLIC_RELEASE_START.getCode());
+				n.setContent(content.toString());
+				n.setReaded(0);//未读
+				asyncUtils.addNotice(n);
+				pe.setAid(sendAdmin.getId());
+				pe.setAname(sendAdmin.getName());
+				pe.setCreateTime(new Date());
+			}else {
+				//与发起者不一致的就需要修改审核人员
+
+				pe.setAid(aid);
+				pe.setAname(admin.getName());
+			}
+				publicExamineMapper.updateByPridSelective(pe);
+		}
+	}
+
 	private void updateOrderHandOver(String uid, String aid, String oldAid) {
 		List<TOrderNewBo> list = tOrderNewMapper.selectByuidandAid(uid, oldAid);
 		for (TOrderNewBo bo : list) {

+ 2 - 2
src/main/java/com/goafanti/weChat/service/impl/PublicReleaseServiceImpl.java

@@ -339,7 +339,7 @@ public class PublicReleaseServiceImpl extends BaseMybatisDao<PublicReleaseMapper
 				PublicExamine pe=new PublicExamine();
 				pe.setPrid(in.getId());
 				pe.setStatus(0);
-				publicExamineMapper.updatePrid(pe);
+				publicExamineMapper.updateStatusByPrid(pe);
 			}
 			AdminListBo my = adminMapper.getDeptNameByAid(TokenManager.getAdminId());
 
@@ -585,7 +585,7 @@ public class PublicReleaseServiceImpl extends BaseMybatisDao<PublicReleaseMapper
 					PublicExamine inpe=new PublicExamine();
 					inpe.setStatus(0);
 					inpe.setPrid(use.getId());
-					publicExamineMapper.updatePrid(inpe);
+					publicExamineMapper.updateStatusByPrid(inpe);
 				}
 			}else if(status==2){
 				str=str.append("同意,");