Browse Source

修改发起公出

anderx 3 years ago
parent
commit
52fc7672dc

+ 7 - 1
src/main/java/com/goafanti/common/dao/PublicReleaseDetailsMapper.java

@@ -2,6 +2,8 @@ package com.goafanti.common.dao;
 
 import com.goafanti.common.model.PublicReleaseDetails;
 
+import java.util.List;
+
 public interface PublicReleaseDetailsMapper {
     int deleteByPrimaryKey(Integer id);
 
@@ -14,4 +16,8 @@ public interface PublicReleaseDetailsMapper {
     int updateByPrimaryKeySelective(PublicReleaseDetails record);
 
     int updateByPrimaryKey(PublicReleaseDetails record);
-}
+
+    List<PublicReleaseDetails> selectByPCid(Integer id);
+
+    void insertBatch(List<PublicReleaseDetails> list);
+}

+ 26 - 5
src/main/java/com/goafanti/common/mapper/PublicReleaseDetailsMapper.xml

@@ -13,19 +13,20 @@
     id, prid, `uid`, ufid, new_user, sign_sum
   </sql>
   <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
-    select 
+    select
     <include refid="Base_Column_List" />
     from public_release_details
     where id = #{id,jdbcType=INTEGER}
   </select>
-  <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
+
+    <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
     delete from public_release_details
     where id = #{id,jdbcType=INTEGER}
   </delete>
   <insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.goafanti.common.model.PublicReleaseDetails" useGeneratedKeys="true">
-    insert into public_release_details (prid, `uid`, ufid, 
+    insert into public_release_details (prid, `uid`, ufid,
       new_user, sign_sum)
-    values (#{prid,jdbcType=INTEGER}, #{uid,jdbcType=VARCHAR}, #{ufid,jdbcType=VARCHAR}, 
+    values (#{prid,jdbcType=INTEGER}, #{uid,jdbcType=VARCHAR}, #{ufid,jdbcType=VARCHAR},
       #{newUser,jdbcType=INTEGER}, #{signSum,jdbcType=INTEGER})
   </insert>
   <insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.goafanti.common.model.PublicReleaseDetails" useGeneratedKeys="true">
@@ -65,6 +66,7 @@
       </if>
     </trim>
   </insert>
+
   <update id="updateByPrimaryKeySelective" parameterType="com.goafanti.common.model.PublicReleaseDetails">
     update public_release_details
     <set>
@@ -95,4 +97,23 @@
       sign_sum = #{signSum,jdbcType=INTEGER}
     where id = #{id,jdbcType=INTEGER}
   </update>
-</mapper>
+
+  <select id="selectByPCid" parameterType="java.lang.Integer" resultMap="BaseResultMap">
+    select
+    <include refid="Base_Column_List" />
+    from public_release_details
+    where prid = #{id,jdbcType=INTEGER}
+  </select>
+
+
+  <insert id="insertBatch">
+    insert into public_release_details (prid, `uid`, ufid,
+                                        new_user, sign_sum)
+    values
+    <foreach close=")" collection="prd" item="list" open="(" separator=",">
+      (#{prd.prid,jdbcType=INTEGER}, #{prd.uid,jdbcType=VARCHAR}, #{prd.ufid,jdbcType=VARCHAR},
+      #{prd.newUser,jdbcType=INTEGER}, #{prd.signSum,jdbcType=INTEGER})
+    </foreach>
+
+  </insert>
+</mapper>

+ 13 - 5
src/main/java/com/goafanti/weChat/bo/InputPublicRelease.java

@@ -5,19 +5,27 @@ import com.goafanti.common.model.PublicRelease;
 public class InputPublicRelease extends PublicRelease {
 
 	/**
-	 * 
+	 *
 	 */
 	private static final long serialVersionUID = 1L;
-	
+
 	private String releaseStarts;
-	
+
 	private String releaseEnds;
-	
+
 	private String ocbId;
-	
+
 	private String reason;
 
+	private String uids;
 
+	public String getUids() {
+		return uids;
+	}
+
+	public void setUids(String uids) {
+		this.uids = uids;
+	}
 
 	public String getReleaseStarts() {
 		return releaseStarts;

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

@@ -5,6 +5,7 @@ import java.util.*;
 
 import com.goafanti.admin.service.DepartmentService;
 import com.goafanti.common.dao.*;
+import com.goafanti.common.model.*;
 import com.goafanti.order.service.OrderService;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -17,12 +18,6 @@ import com.goafanti.common.bo.EmailBo;
 import com.goafanti.common.constant.AFTConstants;
 import com.goafanti.common.enums.NoticeStatus;
 import com.goafanti.common.error.BusinessException;
-import com.goafanti.common.model.Admin;
-import com.goafanti.common.model.Notice;
-import com.goafanti.common.model.OrganizationContactBook;
-import com.goafanti.common.model.PublicRelease;
-import com.goafanti.common.model.PublicReleaseLog;
-import com.goafanti.common.model.User;
 import com.goafanti.common.utils.AsyncUtils;
 import com.goafanti.common.utils.DateUtils;
 import com.goafanti.common.utils.SendEmailUtil;
@@ -55,7 +50,7 @@ public class PublicReleaseServiceImpl extends BaseMybatisDao<PublicReleaseMapper
 	@Autowired
 	private CustomerService customerService;
 	@Autowired
-	private OrderService orderService;
+	private PublicReleaseDetailsMapper publicReleaseDetailsMapper;
 	@Autowired
 	private WeChatUtils weChatUtils;
 	@Autowired
@@ -80,22 +75,34 @@ public class PublicReleaseServiceImpl extends BaseMybatisDao<PublicReleaseMapper
 		in.setCreateTime(date);
 		in.setStatus(1);
 		in.setAid(TokenManager.getAdminId());
-		in.setNewUser(0);
-		User u=userMapper.selectByPrimaryKey(in.getUid());
-		if (u!=null&&u.getShareType()==2){
-			in.setNewUser(1);
-		}
-		if (u==null||StringUtils.isEmpty(u.getAid())||u.getAid().equals(TokenManager.getAdminId())){
-			in.setMainStatus(1);
-		}
 		AdminListBo my = adminMapper.getDeptNameByAid(TokenManager.getAdminId());
 		if (in.getAssist()==1){
 			in.setAssistAidName(getAssistAidName(in.getAssistAid()));
 			in.setMainName(my.getName());
 		}
 		publicReleaseMapper.insertSelective(in);
+		List<PublicReleaseDetails> prdList=new ArrayList<>();
+		StringBuffer str =new StringBuffer();
+		if (in.getUids()!=null){
+			List<String> split = Arrays.asList(in.getUids().split(","));
+			for (String s : split) {
+				PublicReleaseDetails prd=new PublicReleaseDetails();
+				User u=userMapper.selectByPrimaryKey(in.getUid());
+				str.append(u.getNickname()).append(",");
+				if (u!=null&&u.getShareType()==2){
+					prd.setNewUser(1);
+				}else {
+					prd.setNewUser(0);
+				}
+				prd.setPrid(in.getId());
+				prd.setUid(s);
+				prd.setSignSum(0);
+				prdList.add(prd);
+			}
+			publicReleaseDetailsMapper.insertBatch(prdList);
+		}
 		addpublicLog(in.getId(), PublicReleaseLog.states.fq.getCode(), "发起外出申请");
-		Map<String, Object> map=addPublicReleaseLog(my, in,u.getNickname(),date);
+		Map<String, Object> map=addPublicReleaseLog(my, in,str.substring(0,str.length()-1),date);
 		return map;
 	}
 
@@ -501,18 +508,22 @@ public class PublicReleaseServiceImpl extends BaseMybatisDao<PublicReleaseMapper
 		p.setClockInTime(new Date());
 		String str="";
 		if (use.getClockIn()==0) {
-			FollowBusinessBo fbb=new FollowBusinessBo();
-			fbb.setUid(use.getUid());
-			fbb.setContactType("5");
-			fbb.setResult(use.getRemarks());
-			OrganizationContactBook ub=organizationContactBookMapper.getMajor(use.getUid(),aid);
-			if (ub !=null) {
-				fbb.setOcbId(ub.getId());
+			//获取列表
+			List<PublicReleaseDetails> prdList = publicReleaseDetailsMapper.selectByPCid(id);
+			for (PublicReleaseDetails prd : prdList) {
+				FollowBusinessBo fbb=new FollowBusinessBo();
+				fbb.setUid(prd.getUid());
+				fbb.setContactType("5");
+				fbb.setResult(use.getRemarks());
+				OrganizationContactBook ub=organizationContactBookMapper.getMajor(prd.getUid(),aid);
+				if (ub !=null) {
+					fbb.setOcbId(ub.getId());
+				}
+				fbb.setFollowTime(DateUtils.formatDate(p.getClockInTime(), AFTConstants.YYYYMMDDHHMMSS));
+				String ufid=UUID.randomUUID().toString();
+				p.setUfid(ufid);
+				customerService.addFollow(fbb,ufid,use.getMainStatus());
 			}
-			fbb.setFollowTime(DateUtils.formatDate(p.getClockInTime(), AFTConstants.YYYYMMDDHHMMSS));
-			String ufid=UUID.randomUUID().toString();
-			p.setUfid(ufid);
-			customerService.addFollow(fbb,ufid,use.getMainStatus());
 			if (clockIn==1)str="公出人员打卡";
 			else if(clockIn==2)str="公出人员异常打卡";
 		}else {