Преглед изворни кода

Merge branch 'test' of jishutao/kede-server into prod

anderx пре 3 година
родитељ
комит
1dd953d8f9
29 измењених фајлова са 1001 додато и 138 уклоњено
  1. 24 0
      src/main/java/com/goafanti/admin/bo/AdminListBo.java
  2. 3 3
      src/main/java/com/goafanti/admin/controller/AdminSuperviseApiController.java
  3. 6 1
      src/main/java/com/goafanti/admin/controller/AdminSuperviserApiController.java
  4. 2 2
      src/main/java/com/goafanti/admin/service/AdminService.java
  5. 11 4
      src/main/java/com/goafanti/admin/service/impl/AdminServiceImpl.java
  6. 2 0
      src/main/java/com/goafanti/admin/service/impl/NewAdminServiceImpl.java
  7. 1 0
      src/main/java/com/goafanti/common/constant/AFTConstants.java
  8. 1 1
      src/main/java/com/goafanti/common/dao/AdminMapper.java
  9. 27 0
      src/main/java/com/goafanti/common/dao/PublicExamineMapper.java
  10. 1 0
      src/main/java/com/goafanti/common/enums/NoticeStatus.java
  11. 67 20
      src/main/java/com/goafanti/common/mapper/AdminMapper.xml
  12. 123 0
      src/main/java/com/goafanti/common/mapper/PublicExamineMapper.xml
  13. 100 32
      src/main/java/com/goafanti/common/mapper/PublicReleaseMapper.xml
  14. 6 2
      src/main/java/com/goafanti/common/mapper/UserMapperExt.xml
  15. 26 0
      src/main/java/com/goafanti/common/model/Admin.java
  16. 87 0
      src/main/java/com/goafanti/common/model/PublicExamine.java
  17. 39 0
      src/main/java/com/goafanti/common/model/PublicRelease.java
  18. 55 0
      src/main/java/com/goafanti/customer/bo/CustomerSimpleBo.java
  19. 12 3
      src/main/java/com/goafanti/customer/controller/AdminCustomerApiController.java
  20. 1 1
      src/main/java/com/goafanti/customer/service/CustomerService.java
  21. 24 2
      src/main/java/com/goafanti/customer/service/impl/CustomerServiceImpl.java
  22. 1 1
      src/main/java/com/goafanti/weChat/bo/InputPublicReleaseList.java
  23. 20 0
      src/main/java/com/goafanti/weChat/bo/OutPublicRelease.java
  24. 11 0
      src/main/java/com/goafanti/weChat/bo/OutPublicReleaseList.java
  25. 33 6
      src/main/java/com/goafanti/weChat/controller/AdminReleaseApiController.java
  26. 9 1
      src/main/java/com/goafanti/weChat/service/PublicReleaseService.java
  27. 307 57
      src/main/java/com/goafanti/weChat/service/impl/PublicReleaseServiceImpl.java
  28. 1 1
      src/main/resources/props/config_local.properties
  29. 1 1
      src/main/resources/props/config_test.properties

+ 24 - 0
src/main/java/com/goafanti/admin/bo/AdminListBo.java

@@ -110,14 +110,38 @@ public class AdminListBo {
 	 */
 	private String depManager;
 
+	/**
+	 *  0新员工 1老员工
+	 */
+	private Integer seniorStaff;
+	/**
+	 *  公出权限 0正常 1全部
+	 */
+	private Integer publicPurview;
 
 	private String ambId;
 	private String ancestors;
 	private Integer ambManage;
+
 	private String ambName;
 	private String ancestorsNames;
 	private String ambRole;
 
+	public Integer getPublicPurview() {
+		return publicPurview;
+	}
+
+	public void setPublicPurview(Integer publicPurview) {
+		this.publicPurview = publicPurview;
+	}
+
+	public Integer getSeniorStaff() {
+		return seniorStaff;
+	}
+
+	public void setSeniorStaff(Integer seniorStaff) {
+		this.seniorStaff = seniorStaff;
+	}
 
 	public String getAmbId() {
 		return ambId;

+ 3 - 3
src/main/java/com/goafanti/admin/controller/AdminSuperviseApiController.java

@@ -111,8 +111,8 @@ public class AdminSuperviseApiController extends CertifyApiController {
 	 * 管理员列表
 	 */
 	@RequestMapping(value = "/adminList", method = RequestMethod.GET)
-	public Result adminList(Integer province, Integer number, String mobile, String name,String roleName, String pageNo,
-			String pageSize) {
+	public Result adminList(Integer province, Integer number, String mobile, String name,String roleName,Integer seniorStaff,
+							String pageNo, String pageSize) {
 		Result res = new Result();
 		Integer pNo = 1;
 		Integer pSize = 10;
@@ -122,7 +122,7 @@ public class AdminSuperviseApiController extends CertifyApiController {
 		if (StringUtils.isNumeric(pageNo)) {
 			pNo = Integer.parseInt(pageNo);
 		}
-		res.setData(adminService.listAdmin(province, number, mobile, name, roleName, pNo, pSize));
+		res.setData(adminService.listAdmin(province, number, mobile, name, roleName,seniorStaff, pNo, pSize));
 		return res;
 	}
 

+ 6 - 1
src/main/java/com/goafanti/admin/controller/AdminSuperviserApiController.java

@@ -303,7 +303,12 @@ public class AdminSuperviserApiController extends CertifyApiController {
 		res.setData(UUID.randomUUID().toString());
 		return res;
 	}
-	/**编辑页面信息获取**/
+
+	/**
+	 * 编辑页面信息获取 管理员详情
+	 * @param id
+	 * @return
+	 */
 	@RequestMapping(value = "/selectAllByid", method = RequestMethod.POST)
 	public Result selectAllByid(String id){
 		Result res = new Result();

+ 2 - 2
src/main/java/com/goafanti/admin/service/AdminService.java

@@ -16,8 +16,8 @@ public interface AdminService {
 
 	Admin selectByPrimaryKey(String key);
 
-	Pagination<AdminListBo> listAdmin(Integer province, Integer number, String mobile, String name, String roleName, Integer pNo,
-			Integer pSize);
+	Pagination<AdminListBo> listAdmin(Integer province, Integer number, String mobile, String name, String roleName,Integer seniorStaff,
+									  Integer pNo, Integer pSize);
 
 	int insert(Admin ad);
 

+ 11 - 4
src/main/java/com/goafanti/admin/service/impl/AdminServiceImpl.java

@@ -75,13 +75,14 @@ public class AdminServiceImpl extends BaseMybatisDao<AdminMapper> implements Adm
 
 	@SuppressWarnings("unchecked")
 	@Override
-	public Pagination<AdminListBo> listAdmin(Integer province, Integer number, String mobile, String name,String roleName,
+	public Pagination<AdminListBo> listAdmin(Integer province, Integer number, String mobile, String name,String roleName,Integer seniorStaff,
 			Integer pageNo, Integer pageSize) {
 		Map<String, Object> params = new HashMap<>();
 		if (StringUtils.isNotBlank(roleName))params.put("roleName", roleName);
 		if (StringUtils.isNotBlank(mobile))params.put("mobile", mobile);
 		if (StringUtils.isNotBlank(name))params.put("name", name);
 		if (null != number)params.put("number", number);
+		if (null != seniorStaff)params.put("seniorStaff", seniorStaff);
 		if (pageNo == null || pageNo < 0)pageNo = 1;
 		if (pageSize == null || pageSize < 0 || pageSize > 10)pageSize = 10;
 		if (province != null) params.put("province", province);
@@ -375,6 +376,12 @@ public class AdminServiceImpl extends BaseMybatisDao<AdminMapper> implements Adm
 		if (endTime!=null)endTime=endTime+" 23:59:59";
 		List<DepCountBo >deps=new ArrayList<>();
 		List<Department> depIds=new ArrayList<>();
+		//总裁助力不查看老员工
+		Integer seniorstaff = null;
+		if (TokenManager.hasRole(AFTConstants.CED_ASSISTANT)){
+			seniorstaff=0;
+		}
+
 		if (depId==null) {
 			acb.setName("科德集团");
 			deps=departmentMapper.selectBysuperName("科德集团");
@@ -396,7 +403,7 @@ public class AdminServiceImpl extends BaseMybatisDao<AdminMapper> implements Adm
 		//原sql计算
 //		list=departmentMapper.AlldepCount(depIds,startTime,  endTime);
 		//新java计算
-		list=AllDepCount(depIds,startTime,endTime);
+		list=AllDepCount(depIds,startTime,endTime,seniorstaff);
 		for (AdminCustomerBo ad : list) {
 			if (acb.getId().equals(ad.getDepId())){
 				acb.getaList().add(ad);
@@ -416,8 +423,8 @@ public class AdminServiceImpl extends BaseMybatisDao<AdminMapper> implements Adm
 		return acb;
 	}
 
-	private List<AdminCustomerBo> AllDepCount(List<Department> depIds, String startTime, String endTime) {
-		List<AdminCustomerBo> admins = adminMapper.selectByDeps(depIds);
+	private List<AdminCustomerBo> AllDepCount(List<Department> depIds, String startTime, String endTime,Integer seniorStaff) {
+		List<AdminCustomerBo> admins = adminMapper.selectByDeps(depIds,seniorStaff);
 		if(!admins.isEmpty()){
 			List<AdminCustomerBo> users = 	userMapper.selectNoChannelByaids(admins,startTime,endTime);
 			List<AdminCustomerBo> users2 = 	userMapper.selectChannelByaids(admins,startTime,endTime);

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

@@ -51,6 +51,8 @@ public class NewAdminServiceImpl extends BaseMybatisDao<AdminMapper> implements
 		if(StringUtils.isNotBlank(alb.getAmbId())) params.put("ambId", alb.getAmbId());
 		if(StringUtils.isNotBlank(alb.getAncestors())) params.put("ancestors", alb.getAncestors());
 		if(alb.getAmbManage()!=null) params.put("ambManage", alb.getAmbManage());
+		if(alb.getSeniorStaff()!=null) params.put("seniorStaff", alb.getSeniorStaff());
+		if(alb.getPublicPurview()!=null) params.put("publicPurview", alb.getPublicPurview());
 		Pagination<AdminListBo> p=(Pagination<AdminListBo>)findPage("selectAdminListByPage","selectAdminCount",params,pageNo,pageSize);
 		List<AdminListBo> list= (List<AdminListBo>) p.getList();
 		for(AdminListBo i:list){

+ 1 - 0
src/main/java/com/goafanti/common/constant/AFTConstants.java

@@ -51,6 +51,7 @@ public class AFTConstants {
 	public static final String  SALESMAN_MANAGER                    = "996";
 	/**	营销员 */
 	public static final String  SALESMAN                      		= "96";
+	/** 客服营销员 */
 	public static final String  CUSTOMER_SERVICE_SALESMAN     		= "960";
 	/**	外包审核员 */
 	public static final String  OUTSOURCE_AUDITOR                   = "9991";

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

@@ -164,5 +164,5 @@ public interface AdminMapper {
 
     List<Admin> selectAdminByRoleType(@Param("roleType") String roleType);
 
-    List<AdminCustomerBo > selectByDeps(@Param("depIds") List<Department> depIds);
+    List<AdminCustomerBo > selectByDeps(@Param("depIds") List<Department> depIds,@Param("seniorStaff") Integer seniorStaff);
 }

+ 27 - 0
src/main/java/com/goafanti/common/dao/PublicExamineMapper.java

@@ -0,0 +1,27 @@
+package com.goafanti.common.dao;
+
+import com.goafanti.common.model.PublicExamine;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+public interface PublicExamineMapper {
+    int deleteByPrimaryKey(Integer id);
+
+    int insert(PublicExamine record);
+
+    int insertSelective(PublicExamine record);
+
+    PublicExamine selectByPrimaryKey(Integer id);
+
+    int updateByPrimaryKeySelective(PublicExamine record);
+
+    int updateByPrimaryKey(PublicExamine record);
+
+    List<PublicExamine> selectByPrid(Integer id);
+
+    void updatePrid(PublicExamine pe);
+
+
+    List<PublicExamine> selectByIds(@Param("ids") List<Integer> ids);
+}

+ 1 - 0
src/main/java/com/goafanti/common/enums/NoticeStatus.java

@@ -78,6 +78,7 @@ public enum NoticeStatus {
 	AMB_INVEST_START(69,"阿米巴投资发起"),
 	AMB_INVEST_YES(70,"阿米巴投资通过"),
 	AMB_INVEST_NO(71,"阿米巴投资拒绝"),
+	PUBLIC_OTHERS_USER(72,"公出他人企业"),
 	OTHER(0, "其他");
 
 	private NoticeStatus(Integer code, String desc) {

+ 67 - 20
src/main/java/com/goafanti/common/mapper/AdminMapper.xml

@@ -28,12 +28,14 @@
     <result column="amb_role" jdbcType="VARCHAR" property="ambRole" />
     <result column="amb_manage" jdbcType="INTEGER" property="ambManage" />
     <result column="manager_id" jdbcType="VARCHAR" property="managerId" />
+    <result column="senior_staff" jdbcType="INTEGER" property="seniorStaff" />
+    <result column="public_purview" jdbcType="INTEGER" property="publicPurview" />
   </resultMap>
   <sql id="Base_Column_List">
     id, mobile, `name`, `password`, email, create_time, `number`, province, `position`,
     superior_id, city, department_id, `status`, user_no, duty, district, head_portrait_url,
     contact_mobile, last_login_time, open_id, `type`, reviewer, amb_id, amb_role, amb_manage,
-    manager_id
+    manager_id, senior_staff, public_purview
   </sql>
   <select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap">
     select
@@ -54,7 +56,8 @@
       district, head_portrait_url, contact_mobile,
       last_login_time, open_id, `type`,
       reviewer, amb_id, amb_role,
-      amb_manage, manager_id)
+      amb_manage, manager_id, senior_staff,
+      public_purview)
     values (#{id,jdbcType=VARCHAR}, #{mobile,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR},
       #{password,jdbcType=VARCHAR}, #{email,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP},
       #{number,jdbcType=INTEGER}, #{province,jdbcType=VARCHAR}, #{position,jdbcType=VARCHAR},
@@ -63,7 +66,8 @@
       #{district,jdbcType=VARCHAR}, #{headPortraitUrl,jdbcType=VARCHAR}, #{contactMobile,jdbcType=VARCHAR},
       #{lastLoginTime,jdbcType=TIMESTAMP}, #{openId,jdbcType=VARCHAR}, #{type,jdbcType=INTEGER},
       #{reviewer,jdbcType=VARCHAR}, #{ambId,jdbcType=VARCHAR}, #{ambRole,jdbcType=VARCHAR},
-      #{ambManage,jdbcType=INTEGER}, #{managerId,jdbcType=VARCHAR})
+      #{ambManage,jdbcType=INTEGER}, #{managerId,jdbcType=VARCHAR}, #{seniorStaff,jdbcType=INTEGER},
+      #{publicPurview,jdbcType=INTEGER})
   </insert>
   <insert id="insertSelective" parameterType="com.goafanti.common.model.Admin">
     insert into admin
@@ -146,6 +150,12 @@
       <if test="managerId != null">
         manager_id,
       </if>
+      <if test="seniorStaff != null">
+        senior_staff,
+      </if>
+      <if test="publicPurview != null">
+        public_purview,
+      </if>
     </trim>
     <trim prefix="values (" suffix=")" suffixOverrides=",">
       <if test="id != null">
@@ -226,6 +236,12 @@
       <if test="managerId != null">
         #{managerId,jdbcType=VARCHAR},
       </if>
+      <if test="seniorStaff != null">
+        #{seniorStaff,jdbcType=INTEGER},
+      </if>
+      <if test="publicPurview != null">
+        #{publicPurview,jdbcType=INTEGER},
+      </if>
     </trim>
   </insert>
   <update id="updateByPrimaryKeySelective" parameterType="com.goafanti.common.model.Admin">
@@ -306,6 +322,12 @@
       <if test="managerId != null">
         manager_id = #{managerId,jdbcType=VARCHAR},
       </if>
+      <if test="seniorStaff != null">
+        senior_staff = #{seniorStaff,jdbcType=INTEGER},
+      </if>
+      <if test="publicPurview != null">
+        public_purview = #{publicPurview,jdbcType=INTEGER},
+      </if>
     </set>
     where id = #{id,jdbcType=VARCHAR}
   </update>
@@ -335,12 +357,15 @@
       amb_id = #{ambId,jdbcType=VARCHAR},
       amb_role = #{ambRole,jdbcType=VARCHAR},
       amb_manage = #{ambManage,jdbcType=INTEGER},
-      manager_id = #{managerId,jdbcType=VARCHAR}
+      manager_id = #{managerId,jdbcType=VARCHAR},
+      senior_staff = #{seniorStaff,jdbcType=INTEGER},
+      public_purview = #{publicPurview,jdbcType=INTEGER}
     where id = #{id,jdbcType=VARCHAR}
   </update>
 
 
 
+
   <select id="selectAllAdmin" resultMap="BaseResultMap">
     select
     <include refid="Base_Column_List" />
@@ -522,6 +547,9 @@
     <if test="number != null">
       and a.number = #{number,jdbcType=INTEGER}
     </if>
+    <if test="seniorStaff != null">
+      and a.senior_staff = #{seniorStaff}
+    </if>
     <if test="province != null">
       and a.province = #{province,jdbcType=VARCHAR}
     </if>
@@ -548,6 +576,9 @@
     <if test="number != null">
       and number = #{number,jdbcType=INTEGER}
     </if>
+    <if test="seniorStaff != null">
+      and a.senior_staff = #{seniorStaff}
+    </if>
     <if test="province != null">
       and a.province = #{province,jdbcType=VARCHAR}
     </if>
@@ -568,7 +599,7 @@
   <select id="selectAdminListByPage" parameterType="java.lang.String" resultType="com.goafanti.admin.bo.AdminListBo">
     select a.id, a.mobile, a.name, a.position, a.email, a.province, a.city, a.create_time as createTime, aa.name as superior,dep.name departmentName,
     a.superior_id as superiorId, a.department_id as departmentId, a.last_login_time as lastLoginTime, a.contact_mobile as contactMobile,
-    a.duty,a.status, a.type, ambs.id ambId,ambs.name ambName,ambs.ancestors_names ancestorsNames ,a.amb_role ambRole
+    a.duty,a.status, a.type, ambs.id ambId,ambs.name ambName,ambs.ancestors_names ancestorsNames ,a.amb_role ambRole,a.senior_staff seniorStaff,a.public_purview publicPurview
     from admin a
     left join admin_location al on a.id = al.admin_id
     left join admin aa on aa.id = a.superior_id
@@ -607,6 +638,13 @@
     <if test="ambId != null">
       and a.amb_id = #{ambId}
     </if>
+    <if test="seniorStaff != null">
+      and a.senior_staff = #{seniorStaff}
+    </if>
+      <if test="publicPurview != null">
+      and a.public_purview = #{publicPurview}
+    </if>
+
     <if test="ancestors != null">
       and (ambs.id=#{ancestors} or find_in_set( #{ancestors} ,ambs.ancestors))
     </if>
@@ -657,6 +695,12 @@
     <if test="ambId != null">
       and a.amb_id = #{ambId}
     </if>
+    <if test="seniorStaff != null">
+      and a.senior_staff = #{seniorStaff}
+    </if>
+    <if test="publicPurview != null">
+      and a.public_purview = #{publicPurview}
+    </if>
     <if test="ancestors != null">
       and (ambs.id=#{ancestors} or find_in_set( #{ancestors} ,ambs.ancestors))
     </if>
@@ -698,12 +742,12 @@
   </select>
   <select id="selectAllByid" parameterType="java.lang.String" resultType="com.goafanti.common.model.Admin">
     select a.id, a.mobile, a.name, a.`password`, a.email, a.create_time as createTime,
-           a.province, a.`position`,a.reviewer , a.superior_id as superiorId,
+           a.province, a.`position`,a.reviewer , a.superior_id as superiorId,a.public_purview publicPurview,
            a.department_id as departmentId, a.status,a.user_no as userNo,a.duty,a.district,
-           a.head_portrait_url as headPortraitUrl, a.contact_mobile as contactMobile,
+           a.head_portrait_url as headPortraitUrl, a.contact_mobile as contactMobile,a.senior_staff seniorStaff,
            b.name superior,c.name reviewerName,a.type,a.amb_id ambId,a.manager_id managerId ,d.name managerName
     from admin a left join admin b on a.superior_id =b.id left join admin c on a.reviewer =c.id
-    left join admin d on a.manager_id=d.id
+                 left join admin d on a.manager_id=d.id
     where a.id= #{id,jdbcType=VARCHAR}
   </select>
   <select id="selectNameByid" parameterType="java.lang.String" resultType="java.lang.String">
@@ -855,7 +899,7 @@
 
   <select id="getDeptNameByAid" parameterType="java.lang.String" resultType="com.goafanti.admin.bo.AdminListBo">
     select a.id,a.name, d.name as departmentName,a.department_id departmentId,a.email,a.superior_id superiorId,a.open_id openId,
-           a.reviewer,d.manager_id depManager
+           a.reviewer,d.manager_id depManager,a.public_purview publicPurview
     from admin a left join department d on a.department_id = d.id
     where a.id = #{_parameter,jdbcType=VARCHAR}
   </select>
@@ -1156,15 +1200,18 @@
       and c.role_type  in (#{roleType})
     </if>
   </select>
-    <select id="selectByDeps" resultType="com.goafanti.admin.bo.AdminCustomerBo">
-      SELECT a.id aid,a.name aName,a.department_id depId,d.name depName
-      from admin a left join department d on a.department_id = d.id
-      where a.status =0 and a.`type` =1
-      <if test="depIds!= null">
-        and a.department_id in
-        <foreach close=")" collection="depIds" item="deps" open="(" separator=",">
-          #{deps.id}
-        </foreach>
-      </if>
-    </select>
+  <select id="selectByDeps" resultType="com.goafanti.admin.bo.AdminCustomerBo">
+    SELECT a.id aid,a.name aName,a.department_id depId,d.name depName
+    from admin a left join department d on a.department_id = d.id
+    where a.status =0 and a.`type` =1
+    <if test="seniorStaff != null">
+      and a.senior_staff=#{seniorStaff}
+    </if>
+    <if test="depIds!= null">
+      and a.department_id in
+      <foreach close=")" collection="depIds" item="deps" open="(" separator=",">
+        #{deps.id}
+      </foreach>
+    </if>
+  </select>
 </mapper>

+ 123 - 0
src/main/java/com/goafanti/common/mapper/PublicExamineMapper.xml

@@ -0,0 +1,123 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.goafanti.common.dao.PublicExamineMapper">
+  <resultMap id="BaseResultMap" type="com.goafanti.common.model.PublicExamine">
+    <id column="id" jdbcType="INTEGER" property="id" />
+    <result column="prid" jdbcType="INTEGER" property="prid" />
+    <result column="aid" jdbcType="VARCHAR" property="aid" />
+    <result column="status" jdbcType="INTEGER" property="status" />
+    <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
+    <result column="aname" jdbcType="VARCHAR" property="aname" />
+  </resultMap>
+  <sql id="Base_Column_List">
+    id, prid, aid, `status`, create_time, aname
+  </sql>
+  <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
+    select
+    <include refid="Base_Column_List" />
+    from public_examine
+    where id = #{id,jdbcType=INTEGER}
+  </select>
+  <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
+    delete from public_examine
+    where id = #{id,jdbcType=INTEGER}
+  </delete>
+  <insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.goafanti.common.model.PublicExamine" useGeneratedKeys="true">
+    insert into public_examine (prid, aid, `status`,
+      create_time, aname)
+    values (#{prid,jdbcType=INTEGER}, #{aid,jdbcType=VARCHAR}, #{status,jdbcType=INTEGER},
+      #{createTime,jdbcType=TIMESTAMP}, #{aname,jdbcType=VARCHAR})
+  </insert>
+  <insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.goafanti.common.model.PublicExamine" useGeneratedKeys="true">
+    insert into public_examine
+    <trim prefix="(" suffix=")" suffixOverrides=",">
+      <if test="prid != null">
+        prid,
+      </if>
+      <if test="aid != null">
+        aid,
+      </if>
+      <if test="status != null">
+        `status`,
+      </if>
+      <if test="createTime != null">
+        create_time,
+      </if>
+      <if test="aname != null">
+        aname,
+      </if>
+    </trim>
+    <trim prefix="values (" suffix=")" suffixOverrides=",">
+      <if test="prid != null">
+        #{prid,jdbcType=INTEGER},
+      </if>
+      <if test="aid != null">
+        #{aid,jdbcType=VARCHAR},
+      </if>
+      <if test="status != null">
+        #{status,jdbcType=INTEGER},
+      </if>
+      <if test="createTime != null">
+        #{createTime,jdbcType=TIMESTAMP},
+      </if>
+      <if test="aname != null">
+        #{aname,jdbcType=VARCHAR},
+      </if>
+    </trim>
+  </insert>
+  <update id="updateByPrimaryKeySelective" parameterType="com.goafanti.common.model.PublicExamine">
+    update public_examine
+    <set>
+      <if test="prid != null">
+        prid = #{prid,jdbcType=INTEGER},
+      </if>
+      <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 id = #{id,jdbcType=INTEGER}
+  </update>
+  <update id="updateByPrimaryKey" parameterType="com.goafanti.common.model.PublicExamine">
+    update public_examine
+    set prid = #{prid,jdbcType=INTEGER},
+      aid = #{aid,jdbcType=VARCHAR},
+      `status` = #{status,jdbcType=INTEGER},
+      create_time = #{createTime,jdbcType=TIMESTAMP},
+      aname = #{aname,jdbcType=VARCHAR}
+    where id = #{id,jdbcType=INTEGER}
+  </update>
+  <update id="updatePrid">
+    update public_examine
+    set  `status` = #{status,jdbcType=INTEGER}
+    where prid = #{prid,jdbcType=INTEGER}
+      <if test="aid != null">
+      and aid = #{aid,jdbcType=VARCHAR}
+      </if>
+  </update>
+
+
+  <select id="selectByPrid" parameterType="java.lang.Integer" resultMap="BaseResultMap">
+    select
+    <include refid="Base_Column_List" />
+    from public_examine
+    where prid = #{id,jdbcType=INTEGER}
+  </select>
+  <select id="selectByIds" parameterType="java.lang.Integer" resultMap="BaseResultMap">
+  select
+  <include refid="Base_Column_List" />
+  from public_examine
+  where prid in
+    <foreach close=")" collection="ids" item="id" open="(" separator=",">
+      #{id}
+    </foreach>
+  </select>
+</mapper>

+ 100 - 32
src/main/java/com/goafanti/common/mapper/PublicReleaseMapper.xml

@@ -37,13 +37,16 @@
     <result column="sign_sum" jdbcType="VARCHAR" property="signSum" />
     <result column="user_names" jdbcType="VARCHAR" property="userNames" />
     <result column="object_type" jdbcType="INTEGER" property="objectType" />
+    <result column="public_type" jdbcType="INTEGER" property="publicType" />
+    <result column="district_name" jdbcType="VARCHAR" property="districtName" />
+    <result column="clock_in" jdbcType="INTEGER" property="clockIn" />
   </resultMap>
   <sql id="Base_Column_List">
     id, aid, release_start, release_end, remarks, annex_url, `status`, create_time, pid,
     pname, duration, valid_date, supplement, audit_info, `plan`, expected_effect, next_plan,
     `type`, order_no, update_time, update_status, assist, assist_aid, assist_aid_name,
     main_id, main_name, reject_name, assistant_aid, assistant_name, public_again, audit_time,
-    new_user, sign_sum, user_names, object_type
+    new_user, sign_sum, user_names, object_type, public_type, district_name, clock_in
   </sql>
   <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
     select
@@ -67,7 +70,8 @@
       main_name, reject_name, assistant_aid,
       assistant_name, public_again, audit_time,
       new_user, sign_sum, user_names,
-      object_type)
+      object_type, public_type, district_name,
+      clock_in)
     values (#{aid,jdbcType=VARCHAR}, #{releaseStart,jdbcType=TIMESTAMP}, #{releaseEnd,jdbcType=TIMESTAMP},
       #{remarks,jdbcType=VARCHAR}, #{annexUrl,jdbcType=VARCHAR}, #{status,jdbcType=INTEGER},
       #{createTime,jdbcType=TIMESTAMP}, #{pid,jdbcType=VARCHAR}, #{pname,jdbcType=VARCHAR},
@@ -79,7 +83,8 @@
       #{mainName,jdbcType=VARCHAR}, #{rejectName,jdbcType=VARCHAR}, #{assistantAid,jdbcType=VARCHAR},
       #{assistantName,jdbcType=VARCHAR}, #{publicAgain,jdbcType=INTEGER}, #{auditTime,jdbcType=TIMESTAMP},
       #{newUser,jdbcType=VARCHAR}, #{signSum,jdbcType=VARCHAR}, #{userNames,jdbcType=VARCHAR},
-      #{objectType,jdbcType=INTEGER})
+      #{objectType,jdbcType=INTEGER}, #{publicType,jdbcType=INTEGER}, #{districtName,jdbcType=VARCHAR},
+      #{clockIn,jdbcType=INTEGER})
   </insert>
   <insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.goafanti.common.model.PublicRelease" useGeneratedKeys="true">
     insert into public_release
@@ -186,6 +191,15 @@
       <if test="objectType != null">
         object_type,
       </if>
+      <if test="publicType != null">
+        public_type,
+      </if>
+      <if test="districtName != null">
+        district_name,
+      </if>
+      <if test="clockIn != null">
+        clock_in,
+      </if>
     </trim>
     <trim prefix="values (" suffix=")" suffixOverrides=",">
       <if test="aid != null">
@@ -290,6 +304,15 @@
       <if test="objectType != null">
         #{objectType,jdbcType=INTEGER},
       </if>
+      <if test="publicType != null">
+        #{publicType,jdbcType=INTEGER},
+      </if>
+      <if test="districtName != null">
+        #{districtName,jdbcType=VARCHAR},
+      </if>
+      <if test="clockIn != null">
+        #{clockIn,jdbcType=INTEGER},
+      </if>
     </trim>
   </insert>
   <update id="updateByPrimaryKeySelective" parameterType="com.goafanti.common.model.PublicRelease">
@@ -397,6 +420,15 @@
       <if test="objectType != null">
         object_type = #{objectType,jdbcType=INTEGER},
       </if>
+      <if test="publicType != null">
+        public_type = #{publicType,jdbcType=INTEGER},
+      </if>
+      <if test="districtName != null">
+        district_name = #{districtName,jdbcType=VARCHAR},
+      </if>
+      <if test="clockIn != null">
+        clock_in = #{clockIn,jdbcType=INTEGER},
+      </if>
     </set>
     where id = #{id,jdbcType=INTEGER}
   </update>
@@ -435,7 +467,10 @@
       new_user = #{newUser,jdbcType=VARCHAR},
       sign_sum = #{signSum,jdbcType=VARCHAR},
       user_names = #{userNames,jdbcType=VARCHAR},
-      object_type = #{objectType,jdbcType=INTEGER}
+      object_type = #{objectType,jdbcType=INTEGER},
+      public_type = #{publicType,jdbcType=INTEGER},
+      district_name = #{districtName,jdbcType=VARCHAR},
+      clock_in = #{clockIn,jdbcType=INTEGER}
     where id = #{id,jdbcType=INTEGER}
   </update>
 
@@ -450,16 +485,21 @@
   <select id="listPublicRelease" resultType="com.goafanti.weChat.bo.OutPublicReleaseList">
     select  a.id ,c.name  aname,date_format(a.release_start,'%Y-%m-%d %H:%i:%S') releaseStarts,a.aid,
     date_format(a.release_end ,'%Y-%m-%d %H:%i:%S') releaseEnds,date_format(a.create_time ,'%Y-%m-%d %H:%i:%S') createTimes,a.status,
-    date_format(a.update_time ,'%Y-%m-%d %H:%i:%S') updateTimes,a.update_status updateStatus,x.district_name districtName,
+    date_format(a.update_time ,'%Y-%m-%d %H:%i:%S') updateTimes,a.update_status updateStatus,a.district_name districtName,
     a.assist,a.assist_aid assistAid,a.assist_aid_name assistAidName,a.type,a.main_name mainName,a.reject_name rejectName,
-    a.assistant_aid assistantAid ,a.assistant_name assistantName,a.public_again publicAgain,a.user_names userNames
+    a.assistant_aid assistantAid ,a.assistant_name assistantName,a.public_again publicAgain,a.user_names userNames,a.clock_in clockIn
     from public_release a  left join admin c on a.aid =c.id
-    left join (select min(prid)id,min(district_name)district_name from public_release_details group by prid )x on a.id=x.id
-  <if test="type==2">
-    left join department d on c.department_id =d.id
-  </if>
+    <if test="type==2">
+      left join department d on c.department_id =d.id
+    </if>
+    <if test="type==4">
+        /*审核列表由4来判断*/
+      left join public_release_details b on a.id=b.prid
+      left join user e on b.uid=e.id
+    </if>
       where 1=1
     <if test="type==0">
+      and a.public_type in (0,1,2,3)
       <if test="assist ==0">
         and a.assist in(0,1)
       </if>
@@ -472,44 +512,59 @@
       <if test="assist ==4">
         and a.assist in (2,3)
       </if>
-        <if test="aid !=null">
+      <if test="assistType ==1">
+        and a.assist in(0,1,2)
+      </if>
+      <if test="aid !=null">
         and a.aid= #{aid}
-        </if>
+      </if>
       <if test="statusType ==1">
         and a.status in (0,1,2,4)
       </if>
-	</if>
-	<if test="type==1">
+    </if>
+    <if test="type==1">
+      and a.public_type in (0,2)
       and a.assist in(0,1)
-	and c.reviewer = #{aid}
-	</if>
+      and c.reviewer = #{aid}
+    </if>
     <if test="type==2">
+      and a.public_type in (0,2)
       and a.assist in(0,1)
       and d.manager_id = #{aid}
     </if>
     <if test="type==3">
-        and a.assist in (2,3)
-        <if test="aid !=null">
+      and a.public_type in (0,2)
+      and a.assist=2
+      <if test="aid !=null">
         and a.aid= #{aid}
-        </if>
+      </if>
       and a.type = #{type}
     </if>
-	<if test="clockTime !=null">
-	and a.release_start &lt; #{clockTime} and a.release_end &gt; #{clockTime}
-	</if>
-	<if test="releaseStarts != null and publicEnd != null">
-	and a.release_start  BETWEEN #{releaseStarts} and #{publicEnd}
-	</if>
-	<if test="status !=null">
-	and a.status = #{status}
-	</if>
-    <if test="type==2">
+    <if test="type==4">
+      and a.assist in(0,1)
+      and e.aid = #{aid}
+      and a.public_type in (1,2)
+    </if>
+    <if test="clockIn !=null">
+      and a.clock_in =#{clockIn}
+    </if>
+    <if test="clockTime !=null">
+      and a.release_start &lt; #{clockTime} and a.release_end &gt; #{clockTime}
+    </if>
+    <if test="releaseStarts != null and publicEnd != null">
+      and a.release_start  BETWEEN #{releaseStarts} and #{publicEnd}
+    </if>
+
+    <if test="status !=null">
+      and a.status = #{status}
+    </if>
+    <if test="type==2 or type==4">
       ORDER BY a.create_time desc
     </if>
-    <if test="type!=2">
+    <if test="type==0 or type==1 or type==3">
       ORDER BY (case when a.status=1 then 1 when a.status=2 then 2 when a.status=3 then 5
       when a.status=0 then 3 when a.status=4 then 4
-      else 0 end),a.status ,a.create_time desc
+      else 0 end),a.create_time desc
     </if>
   	<if test="page_sql!=null">
 			${page_sql}
@@ -521,8 +576,13 @@
     <if test="type==2">
       left join department d on c.department_id =d.id
     </if>
+    <if test="type==4">
+      left join public_release_details b on a.id=b.prid
+      left join user e on b.uid=e.id
+    </if>
     where 1=1
     <if test="type==0">
+      and a.public_type in (0,1,2,3)
       <if test="assist ==0">
         and a.assist in(0,1)
       </if>
@@ -546,20 +606,28 @@
       </if>
     </if>
     <if test="type==1">
+      and a.public_type in (0,2)
       and a.assist in(0,1)
       and c.reviewer = #{aid}
     </if>
     <if test="type==2">
+      and a.public_type in (0,2)
       and a.assist in(0,1)
       and d.manager_id = #{aid}
     </if>
     <if test="type==3">
+      and a.public_type in (0,2)
       and a.assist=2
       <if test="aid !=null">
         and a.aid= #{aid}
       </if>
       and a.type = #{type}
     </if>
+    <if test="type==4">
+      and a.assist in(0,1)
+      and e.aid = #{aid}
+      and a.public_type in (1,2)
+    </if>
 	<if test="clockTime !=null">
 	and a.release_start &lt; #{clockTime} and a.release_end &gt; #{clockTime}
 	</if>
@@ -578,7 +646,7 @@
     a.annex_url annexUrl ,a.remarks,a.duration ,a.valid_date validDate ,a.aid ,c.superior_id suprId,
     a.plan ,a.expected_effect expectedEffect,a.next_plan nextPlan,c.reviewer,a.type,a.order_no orderNo,d.contract_no contractNo,
     date_format(a.update_time ,'%Y-%m-%d %H:%i:%S') updateTimes,a.update_Status updateStatus,a.assist,a.assist_aid assistAid,a.assist_aid_name assistAidName,
-    a.main_name mainName,a.assistant_aid assistantAid,a.assistant_name assistantName,a.public_again publicAhain,x.uids
+    a.main_name mainName,a.assistant_aid assistantAid,a.assistant_name assistantName,a.public_again publicAhain,x.uids,a.public_type publicType
     from public_release a  left join admin c on a.aid =c.id
     left join (select prid ,GROUP_CONCAT(uid)uids from public_release_details where prid= #{id} group by prid)x on a.id=x.prid
     left join t_order_new d on a.order_no=d.order_no

+ 6 - 2
src/main/java/com/goafanti/common/mapper/UserMapperExt.xml

@@ -2207,8 +2207,12 @@ inner join(
   </select>
 
   <select id="getUserByNameList" parameterType="java.lang.String" resultType="com.goafanti.customer.bo.CustomerSimpleBo">
-  	select id,nickname name from `user` where type = 1 and status =0 and source in (1,2,3)
-	and nickname like concat('%',#{name},'%')
+	  select a.id,a.nickname name,a.aid,a.channel,a.share_type shareType ,
+	  a.new_channel newChannel,b.name aname
+	  from `user` a left join admin b on a.aid =b.id
+	  where a.type = 1 and a.status =0 and a.source in (1,2,3)
+	and a.nickname like concat('%',#{name},'%')
+
   	<if test="page_sql != null">
    		${page_sql}
 	</if>

+ 26 - 0
src/main/java/com/goafanti/common/model/Admin.java

@@ -135,6 +135,16 @@ public class Admin extends BaseModel implements AftUser {
      */
     private String managerId;
 
+    /**
+     * 0新员工 1老员工
+     */
+    private Integer seniorStaff;
+
+    /**
+     * 0正常 1全部
+     */
+    private Integer publicPurview;
+
     private static final long serialVersionUID = 1L;
 
 
@@ -391,4 +401,20 @@ public class Admin extends BaseModel implements AftUser {
     public void setManagerId(String managerId) {
         this.managerId = managerId;
     }
+
+    public Integer getSeniorStaff() {
+        return seniorStaff;
+    }
+
+    public void setSeniorStaff(Integer seniorStaff) {
+        this.seniorStaff = seniorStaff;
+    }
+
+    public Integer getPublicPurview() {
+        return publicPurview;
+    }
+
+    public void setPublicPurview(Integer publicPurview) {
+        this.publicPurview = publicPurview;
+    }
 }

+ 87 - 0
src/main/java/com/goafanti/common/model/PublicExamine.java

@@ -0,0 +1,87 @@
+package com.goafanti.common.model;
+
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * public_examine
+ * @author 
+ */
+public class PublicExamine implements Serializable {
+    private Integer id;
+
+    /**
+     * 公出编号
+     */
+    private Integer prid;
+
+    /**
+     * 审核人编号
+     */
+    private String aid;
+
+    /**
+     * 0未审核 ,1已审核
+     */
+    private Integer status;
+
+    /**
+     * 创建时间
+     */
+    private Date createTime;
+
+    /**
+     * 审核人名称
+     */
+    private String aname;
+
+    private static final long serialVersionUID = 1L;
+
+    public Integer getId() {
+        return id;
+    }
+
+    public void setId(Integer id) {
+        this.id = id;
+    }
+
+    public Integer getPrid() {
+        return prid;
+    }
+
+    public void setPrid(Integer prid) {
+        this.prid = prid;
+    }
+
+    public String getAid() {
+        return aid;
+    }
+
+    public void setAid(String aid) {
+        this.aid = aid;
+    }
+
+    public Integer getStatus() {
+        return status;
+    }
+
+    public void setStatus(Integer status) {
+        this.status = status;
+    }
+
+    public Date getCreateTime() {
+        return createTime;
+    }
+
+    public void setCreateTime(Date createTime) {
+        this.createTime = createTime;
+    }
+
+    public String getAname() {
+        return aname;
+    }
+
+    public void setAname(String aname) {
+        this.aname = aname;
+    }
+}

+ 39 - 0
src/main/java/com/goafanti/common/model/PublicRelease.java

@@ -180,6 +180,21 @@ public class PublicRelease implements Serializable {
      */
     private Integer objectType;
 
+    /**
+     * 公出分类 0不含他人客户 1待审核 2已审核
+     */
+    private Integer publicType;
+
+    /**
+     * 公出企业地址
+     */
+    private String districtName;
+
+    /**
+     * 打卡状态 0未打卡 1已打卡 2异常打卡(冗余)
+     */
+    private Integer clockIn;
+
     private static final long serialVersionUID = 1L;
 
     public Integer getId() {
@@ -461,4 +476,28 @@ public class PublicRelease implements Serializable {
     public void setObjectType(Integer objectType) {
         this.objectType = objectType;
     }
+
+    public Integer getPublicType() {
+        return publicType;
+    }
+
+    public void setPublicType(Integer publicType) {
+        this.publicType = publicType;
+    }
+
+    public String getDistrictName() {
+        return districtName;
+    }
+
+    public void setDistrictName(String districtName) {
+        this.districtName = districtName;
+    }
+
+    public Integer getClockIn() {
+        return clockIn;
+    }
+
+    public void setClockIn(Integer clockIn) {
+        this.clockIn = clockIn;
+    }
 }

+ 55 - 0
src/main/java/com/goafanti/customer/bo/CustomerSimpleBo.java

@@ -3,6 +3,61 @@ package com.goafanti.customer.bo;
 public class CustomerSimpleBo {
 	private String id;
 	private String name;
+	private String aid;
+	private Integer shareType;
+	private Integer channel;
+	private Integer newChannel;
+	private String aname;
+	private Integer status;
+
+	public Integer getShareType() {
+		return shareType;
+	}
+
+	public void setShareType(Integer shareType) {
+		this.shareType = shareType;
+	}
+
+	public Integer getChannel() {
+		return channel;
+	}
+
+	public void setChannel(Integer channel) {
+		this.channel = channel;
+	}
+
+	public Integer getNewChannel() {
+		return newChannel;
+	}
+
+	public void setNewChannel(Integer newChannel) {
+		this.newChannel = newChannel;
+	}
+
+	public String getAname() {
+		return aname;
+	}
+
+	public void setAname(String aname) {
+		this.aname = aname;
+	}
+
+	public Integer getStatus() {
+		return status;
+	}
+
+	public void setStatus(Integer status) {
+		this.status = status;
+	}
+
+	public String getAid() {
+		return aid;
+	}
+
+	public void setAid(String aid) {
+		this.aid = aid;
+	}
+
 	public String getId() {
 		return id;
 	}

+ 12 - 3
src/main/java/com/goafanti/customer/controller/AdminCustomerApiController.java

@@ -300,19 +300,28 @@ public class AdminCustomerApiController extends BaseApiController{
 		return res;
 	}
 
-	/** 客户查询 **/
+	/**
+	 * 客户查询
+	 * @param name  查询名称
+	 * @param type  分类 0默认 1小程序App
+	 * @param pageNo
+	 * @param pageSize
+	 * @return
+	 */
 	@RequestMapping(value = "/getUserByNames",method = RequestMethod.GET)
-	public Result getUserByName(String name,Integer pageNo,Integer pageSize){
+	public Result getUserByName(String name,Integer type,Integer pageNo,Integer pageSize){
 		Result res = new Result();
 		if(StringUtils.isEmpty(name)){
 			res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "名称","名称"));
 			return res;
 		}
 		if(name.length()<2) return res;
-		res.data(customerService.getUserByNames(name,pageNo,pageSize));
+		res.data(customerService.getUserByNames(name,type,pageNo,pageSize));
 		return res;
 	}
 
+
+
 	/** 添加客户基本信息
 	 * @throws Exception
 	 * @throws NumberFormatException **/

+ 1 - 1
src/main/java/com/goafanti/customer/service/CustomerService.java

@@ -527,7 +527,7 @@ public interface CustomerService {
 	int updateUserName(String uid, String userName);
 	List<UserNamesListBo> listUserName(String uid);
 	boolean checkUserName(String userName);
-	Object getUserByNames(String name, Integer pageNo, Integer pageSize);
+	Object getUserByNames(String name,Integer type, Integer pageNo, Integer pageSize);
 
 	Pagination<OutUserMianProducts> mainProductsList(InputMainProductsList in) ;
 

+ 24 - 2
src/main/java/com/goafanti/customer/service/impl/CustomerServiceImpl.java

@@ -24,6 +24,7 @@ import com.goafanti.order.bo.TOrderNewBo;
 import org.apache.commons.beanutils.BeanUtils;
 import org.apache.commons.beanutils.PropertyUtils;
 import org.apache.ibatis.builder.BuilderException;
+import org.apache.poi.ss.formula.functions.T;
 import org.apache.poi.xssf.usermodel.XSSFWorkbook;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
@@ -2462,12 +2463,33 @@ public class CustomerServiceImpl extends BaseMybatisDao<UserMapper> implements C
 	}
 
 	@Override
-	public Object getUserByNames(String name, Integer pageNo, Integer pageSize) {
+	public Object getUserByNames(String name, Integer type,Integer pageNo, Integer pageSize) {
 		Map<String, Object> params = new HashMap<>();
 		params.put("name", name);
-		return  findPage("getUserByNameList", "getUserByNameCount", params, pageNo,pageSize);
+		Pagination<?> page =findPage("getUserByNameList", "getUserByNameCount", params, pageNo, pageSize);
+		return  pushRetrun(page);
 	}
 
+	private Object pushRetrun(Pagination<?> page) {
+		Admin admin = adminMapper.selectByPrimaryKey(TokenManager.getAdminId());
+		List<CustomerSimpleBo> list = (List<CustomerSimpleBo>) page.getList();
+		list.forEach(e ->{
+			if (admin.getPublicPurview()==1){
+				//如果是白名单不管是不是自己都可以公出
+				e.setStatus(0);
+			}else {
+				//不是白名单不是自己的需要审核
+				if (e.getShareType()==1){
+					e.setStatus(2);
+				}else if (admin.getId().equals(e.getAid())){
+					e.setStatus(0);
+				}else {
+					e.setStatus(1);
+				}
+			}
+		});
+		return page;
+	}
 
 
 	@Override

+ 1 - 1
src/main/java/com/goafanti/weChat/bo/InputPublicReleaseList.java

@@ -4,7 +4,7 @@ public class InputPublicReleaseList {
 
 	private Integer pageSize;
 	private Integer pageNo;
-//	查看类型 0我的公出 1公出审核 2管理员 3协单(技术财税总监看全部)
+//	查看类型 0我的公出 1公出审核 2管理员 3协单(技术财税总监看全部) 4 公出企业负责人审核
 	private Integer type;
 	private String clockTime;
 	/**

+ 20 - 0
src/main/java/com/goafanti/weChat/bo/OutPublicRelease.java

@@ -1,5 +1,6 @@
 package com.goafanti.weChat.bo;
 
+import com.goafanti.common.model.PublicExamine;
 import com.goafanti.common.model.PublicRelease;
 
 import java.util.Date;
@@ -20,6 +21,8 @@ public class OutPublicRelease extends PublicRelease {
 	private String suprId;
 	/** 审核权限*/
 	private Integer permission;
+	/** 自己是否审核 */
+	private Integer myExamine;
 
 	private String reviewer;
 
@@ -36,6 +39,23 @@ public class OutPublicRelease extends PublicRelease {
 	private String assistAidName;
 	private String uids;
 	private List<OutPublicReleaseDetails> prdList;
+	private List<PublicExamine> peList;
+
+	public List<PublicExamine> getPeList() {
+		return peList;
+	}
+
+	public void setPeList(List<PublicExamine> peList) {
+		this.peList = peList;
+	}
+
+	public Integer getMyExamine() {
+		return myExamine;
+	}
+
+	public void setMyExamine(Integer myExamine) {
+		this.myExamine = myExamine;
+	}
 
 	public List<OutPublicReleaseDetails> getPrdList() {
 		return prdList;

+ 11 - 0
src/main/java/com/goafanti/weChat/bo/OutPublicReleaseList.java

@@ -29,9 +29,20 @@ public class OutPublicReleaseList {
 	private String assistantAid;
 	private String assistantName;
 	private String userNames;
+	private String adminExamine;
 	private Integer publicAgain;
+
+
 	private List<OutPublicReleaseDetails> prdList;
 
+	public String getAdminExamine() {
+		return adminExamine;
+	}
+
+	public void setAdminExamine(String adminExamine) {
+		this.adminExamine = adminExamine;
+	}
+
 	public List<OutPublicReleaseDetails> getPrdList() {
 		return prdList;
 	}

+ 33 - 6
src/main/java/com/goafanti/weChat/controller/AdminReleaseApiController.java

@@ -37,7 +37,7 @@ public class AdminReleaseApiController extends CertifyApiController{
 
 
 	/**
-	 * 发起外出申请
+	 * 发起外出申请、发起公出
 	 */
 	@RequestMapping(value = "/addPublicRelease", method = RequestMethod.POST)
 	public Result addPublicRelease(InputPublicRelease in){
@@ -68,7 +68,7 @@ public class AdminReleaseApiController extends CertifyApiController{
 	}
 
 	/**
-	 * 修改外出申请
+	 * 修改外出申请、修改公出
 	 * @return
 	 */
 	@RequestMapping(value = "/updatePublicRelease", method = RequestMethod.POST)
@@ -113,8 +113,12 @@ public class AdminReleaseApiController extends CertifyApiController{
 	@RequestMapping(value = "/publicReleaseClockIn", method = RequestMethod.POST)
 	public Result publicReleaseClockIn(Integer id,String photoUrl,Integer clockIn ,String clockInRemarks,String uid ){
 		Result res =new Result();
-
-		res.setData(publicReleaseService.pushPublicReleaseClockIn(id,photoUrl,clockIn,clockInRemarks,uid));
+		Integer x=publicReleaseService.pushPublicReleaseClockIn(id,photoUrl,clockIn,clockInRemarks,uid);
+		if (x==-1){
+			res.getError().add(buildError("公出他人企业!需通过审核,才可以打卡!"));
+			return res;
+		}
+		res.setData(x);
 		return res;
 	}
 	/**
@@ -152,7 +156,7 @@ public class AdminReleaseApiController extends CertifyApiController{
 	}
 
 	/**
-	 * 公出审核、外出审核
+	 * 公出审核、外出审核 上级
 	 * @return
 	 */
 	@RequestMapping(value = "/examinePublicRelease", method = RequestMethod.POST)
@@ -170,7 +174,30 @@ public class AdminReleaseApiController extends CertifyApiController{
 			res.getError().add(buildError("备注长度不能超过20个字符。"));
 			return res;
 		}
-		res.setData(publicReleaseService.pushExaminePublicRelease(id,status,remarks));
+		res.setData(publicReleaseService.pushExaminePublicRelease(id,status,remarks,0));
+		return res;
+	}
+
+	/**
+	 * 公出审核、外出审核 营销
+	 * @return
+	 */
+	@RequestMapping(value = "/MarketersExamine", method = RequestMethod.POST)
+	public Result MarketersExamine(Integer id ,Integer status,String remarks){
+		Result res =new Result();
+		if (id==null) {
+			res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,"公出编号"));
+			return res;
+		}
+		if (status!=0&&status!=2) {
+			res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,"审核状态"));
+			return res;
+		}
+		if (remarks.length()>20) {
+			res.getError().add(buildError("备注长度不能超过20个字符。"));
+			return res;
+		}
+		res.setData(publicReleaseService.pushExaminePublicRelease(id,status,remarks,1));
 		return res;
 	}
 

+ 9 - 1
src/main/java/com/goafanti/weChat/service/PublicReleaseService.java

@@ -12,7 +12,15 @@ public interface PublicReleaseService {
 	Object listPublicRelease(InputPublicReleaseList in);
 
 
-	int pushExaminePublicRelease(Integer id, Integer status, String remarks);
+	/**
+	 *
+	 * @param id
+	 * @param status 状态 0驳回 1发起 2同意 3 撤销 4技术驳回
+	 * @param remarks
+	 * @param type 0上级审核 1营销员审核
+	 * @return
+	 */
+	int pushExaminePublicRelease(Integer id, Integer status, String remarks,Integer type);
 
 
 	List<outPublicReleaseLog> listPublicReleaseLog(Integer id,String ufid);

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

@@ -2,6 +2,7 @@ package com.goafanti.weChat.service.impl;
 
 import java.text.ParseException;
 import java.util.*;
+import java.util.concurrent.atomic.AtomicReference;
 
 import com.goafanti.admin.service.DepartmentService;
 import com.goafanti.common.dao.*;
@@ -10,6 +11,7 @@ import com.goafanti.weChat.bo.*;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
 import org.springframework.web.socket.TextMessage;
 
 import com.goafanti.admin.bo.AdminListBo;
@@ -57,12 +59,16 @@ public class PublicReleaseServiceImpl extends BaseMybatisDao<PublicReleaseMapper
 	private TOrderNewMapper tOrderNewMapper;
 	@Autowired
 	private DepartmentService	departmentService;
+	@Autowired
+	private PublicExamineMapper publicExamineMapper;
 
 	@Override
+	@Transactional
 	public Map<String, Object> addPublicRelease(InputPublicRelease in) {
 		Date date =new Date();
 		if (in.getPublicAgain()==null)in.setPublicAgain(0);
 		in.setCreateTime(date);
+		in.setPublicType(0);
 		in.setStatus(1);
 		in.setAid(TokenManager.getAdminId());
 		AdminListBo my = adminMapper.getDeptNameByAid(TokenManager.getAdminId());
@@ -72,6 +78,7 @@ public class PublicReleaseServiceImpl extends BaseMybatisDao<PublicReleaseMapper
 		}
 		publicReleaseMapper.insertSelective(in);
 		List<PublicReleaseDetails> prdList=new ArrayList<>();
+		List<User> users=new ArrayList<>();
 		StringBuffer str =new StringBuffer();
 		if (in.getUids()!=null){
 			List<String> split = Arrays.asList(in.getUids().split(","));
@@ -80,9 +87,11 @@ public class PublicReleaseServiceImpl extends BaseMybatisDao<PublicReleaseMapper
 			//计算平均
 			double d = durationSum(duration, userCount);
 			Integer index=1;
+			//获取非已企业公出需要的审核人员
 			for (String s : split) {
 				PublicReleaseDetails prd=new PublicReleaseDetails();
 				User u=userMapper.selectByPrimaryKey(s);
+					users.add(u);
 				str.append(u.getNickname()).append(",");
 				if (u!=null&&u.getShareType()==2){
 					prd.setNewUser(1);
@@ -93,6 +102,7 @@ public class PublicReleaseServiceImpl extends BaseMybatisDao<PublicReleaseMapper
 					prd.setMainStatus(1);
 				}else {
 					prd.setMainStatus(0);
+					if(in.getPublicType()==null||in.getPublicType()==0)in.setPublicType(1);
 				}
 				prd.setPrid(in.getId());
 				prd.setUid(s);
@@ -120,12 +130,37 @@ public class PublicReleaseServiceImpl extends BaseMybatisDao<PublicReleaseMapper
 		PublicRelease upName=new PublicRelease();
 		upName.setId(in.getId());
 		upName.setUserNames(userNames);
-		publicReleaseMapper.updateByPrimaryKeySelective(upName);
+		if (in.getPublicType()==1){
+			upName.setPublicType(1);
+		}
 		addpublicLog(in.getId(), PublicReleaseLog.states.fq.getCode(), "发起外出申请");
-		Map<String, Object> map=addPublicReleaseLog(my, in,userNames,date);
+		Map<String, Object> map=addPublicReleaseLog(my, in,userNames,date,users);
+		publicReleaseMapper.updateByPrimaryKeySelective(upName);
 		return map;
 	}
 
+	private void addPublicExamine(Integer id, String aid) {
+		Admin admin = adminMapper.selectByPrimaryKey(aid);
+		addPublicExamine(id,admin);
+	}
+
+	private void addPublicExamine(Integer id, Admin a) {
+		List<PublicExamine> publicExamines = publicExamineMapper.selectByPrid(id);
+		boolean flag=false;
+		for (PublicExamine pe : publicExamines) {
+			if (pe.getAid().equals(a.getId())){
+				flag=true;
+			}
+		}
+		if (!flag){
+			PublicExamine pe=new PublicExamine();
+			pe.setPrid(id);
+			pe.setAid(a.getId());
+			pe.setAname(a.getName());
+			pe.setStatus(0);
+			publicExamineMapper.insertSelective(pe);
+		}
+	}
 
 
 	private  double durationSum(Double duration, Integer sum) {
@@ -145,26 +180,67 @@ public class PublicReleaseServiceImpl extends BaseMybatisDao<PublicReleaseMapper
 	 * @param nickname	客户名称
 	 * @param date	时间
 	 */
-	private Map<String, Object> addPublicReleaseLog(AdminListBo my,PublicRelease in,String nickname,Date date ) {
+	private Map<String, Object> addPublicReleaseLog(AdminListBo my,PublicRelease in,String nickname,Date date,List<User> users) {
+		//获取公出审核人
 		Admin a=adminMapper.selectByPrimaryKey(my.getReviewer());
-		String openid=a.getOpenId();
 		String str="["+my.getName()+"]发起["+nickname+"]的外出申请,请及时审核。";
-		sendNoticeAndSoucket(a.getId(),1,str);
+		//默认上级审核
+		AtomicReference<Integer> status= new AtomicReference<>(1);
 		Map<String, Object>map=new HashMap<String, Object>();
-		map.put("data", publicReleaseMapper.selectDtails(in.getId()));
-		if (openid!=null) {
-			Integer res= weChatUtils.addNotice(openid, in.getStatus(),in.getId(),date,my.getName(),"["+my.getName()+"]发起外出申请");
+		if (my.getPublicPurview()==0){
+			users.forEach(u->{
+				if (!u.getAid().equals(my.getId())){
+					StringBuffer str2=new StringBuffer();
+					str2=str2.append(my.getName()).append("(需审核),准备公出您的企业");
+					str2=str2.append("[").append(u.getNickname()).append("]!!!。");
+					sendEmailAndNoticeAndSoucket(u.getAid(),3,str2.toString());
+					Admin admin = adminMapper.selectByPrimaryKey(u.getAid());
+					//不是自己的企业则需要审核并设置非自己客户待审核
+					addPublicExamine(in.getId(), admin);
+					if(in.getPublicType()==null|| in.getPublicType()==0) in.setPublicType(1);
+					pushNoticeAndSoucketAndEmail(my, in, date, admin, str, map);
+					status.set(0);
+				}
+			});
+		}else {
+			users.forEach(u->{
+				if (!u.getAid().equals(my.getId())){
+					StringBuffer str2=new StringBuffer();
+					str2=str2.append("业务员").append(my.getName()).append("(无需审核),准备公出您的企业");
+					str2=str2.append("[").append(u.getNickname()).append("]!!!");
+					sendNoticeAndSoucket(u.getAid(),3,str2.toString());
+				}
+			});
+
+		}
+		if (status.get()==1){
+			pushNoticeAndSoucketAndEmail(my, in, date, a, str, map);
+		}
+			map.put("data", publicReleaseMapper.selectDtails(in.getId()));
+		return map;
+	}
+
+	/**
+	 *
+	 * @param my 发送人信息
+	 * @param in 公出信息
+	 * @param date 时间
+	 * @param a  接受者信息
+	 * @param str  站内信内容
+	 * @param map 返回实体
+	 */
+	private void pushNoticeAndSoucketAndEmail(AdminListBo my, PublicRelease in, Date date, Admin a,  String str, Map<String, Object> map) {
+		sendNoticeAndSoucket(a.getId(),1, str);
+		if (a.getOpenId() !=null) {
+			Integer res= weChatUtils.addNotice(a.getOpenId(), in.getStatus(), in.getId(), date, my.getName(),"["+ my.getName()+"]发起外出申请");
 			if (res!=0) {
 				sendEmail(my, a,1);
 			}
 			map.put("code", res);
-
-
 		}else {
 			sendEmail(my, a,1);
 			map.put("code", 2);
 		}
-		return map;
 	}
 
 	private String getAssistAidName(String assistAid) {
@@ -178,11 +254,28 @@ public class PublicReleaseServiceImpl extends BaseMybatisDao<PublicReleaseMapper
 		return  sb.deleteCharAt(sb.length() - 1).toString();
 	}
 
+	private void sendEmailAndNoticeAndSoucket(String id,Integer type,String content){
+		sendNoticeAndSoucket(id,type,content);
+		Admin admin = adminMapper.selectByPrimaryKey(id);
+		String title="暂无标题";
+		if (type==3)title=NoticeStatus.PUBLIC_OTHERS_USER.getDesc();
+		EmailBo emailBo=new EmailBo(title,admin.getEmail(),content);
+		asyncUtils.send(emailBo);
+
+	}
 
+	/**
+	 *
+	 * @param id 接受者编号
+	 * @param type 状态 0驳回 1发起 2同意 3 公出他人企业
+	 * @param content 内容
+	 */
 	private void sendNoticeAndSoucket(String id,Integer type,String content) {
 		Integer noticeType=NoticeStatus.PUBLIC_RELEASE_START.getCode();
 		if(type==0)noticeType=NoticeStatus.PUBLIC_RELEASE_NO.getCode();
 			else if (type==2)noticeType=NoticeStatus.PUBLIC_RELEASE_YES.getCode();
+			else if (type==3)noticeType=NoticeStatus.PUBLIC_OTHERS_USER.getCode();
+			//触发通知有未读消息
 		systemWebSocketHandler.sendMessageToUser(id, new TextMessage("unread"));
 		Notice n =new Notice();
 		n.setId(UUID.randomUUID().toString());
@@ -210,6 +303,8 @@ public class PublicReleaseServiceImpl extends BaseMybatisDao<PublicReleaseMapper
 		}
 	}
 
+
+
 	@Override
 	public int updatePublicRelease(InputPublicRelease in) {
 		Date date = new Date();
@@ -220,13 +315,13 @@ public class PublicReleaseServiceImpl extends BaseMybatisDao<PublicReleaseMapper
 			e.printStackTrace();
 			throw new BusinessException("转换异常");
 		}
+		List<User> uses=null;
 		PublicRelease use = publicReleaseMapper.selectByPrimaryKey(in.getId());
 		if (in.getUids()!=null){
 			List<String> split = Arrays.asList(in.getUids().split(","));
 			List<OutPublicReleaseDetails> prList = publicReleaseDetailsMapper.selectByPCid(in.getId());
-			pushPublicReleaseDetails(split,prList,use,in);
+			uses=pushPublicReleaseDetails(split,prList,use,in);
 		}
-
 		String userNames=publicReleaseDetailsMapper.getNamesByPrid(in.getId());
 		PublicReleaseLog log=new PublicReleaseLog(in.getId(),TokenManager.getAdminId(),null,in.getReason(),date);
 		in.setUserNames(userNames);
@@ -234,10 +329,17 @@ public class PublicReleaseServiceImpl extends BaseMybatisDao<PublicReleaseMapper
 			in.setStatus(1);
 			log.setStatus(PublicReleaseLog.states.xg.getCode());
 			in.setUpdateStatus(1);
+			if(use.getPublicType()==2||use.getPublicType()==3){
+				in.setPublicType(1);
+				PublicExamine pe=new PublicExamine();
+				pe.setPrid(in.getId());
+				pe.setStatus(0);
+				publicExamineMapper.updatePrid(pe);
+			}
 			AdminListBo my = adminMapper.getDeptNameByAid(TokenManager.getAdminId());
 			//新增修改日志
 			//重新发起
-			addPublicReleaseLog(my,in,in.getUserNames(),date);
+			addPublicReleaseLog(my,in,in.getUserNames(),date,uses);
 		}else {
 			List<PublicRelease> list = publicReleaseMapper.selectByMainId(in.getId(),3,null);
 			List<PublicRelease> list2 = publicReleaseMapper.selectByMainId(in.getId(),4,null);
@@ -256,16 +358,22 @@ public class PublicReleaseServiceImpl extends BaseMybatisDao<PublicReleaseMapper
 		}
 		publicReleaseLogMapper.insertSelective(log);
 		publicReleaseMapper.updateByPrimaryKeySelective(in);
+
 		return 1;
 	}
 
-	private void pushPublicReleaseDetails(List<String> split, List<OutPublicReleaseDetails> prList, PublicRelease use, InputPublicRelease in) {
+	private List<User> pushPublicReleaseDetails(List<String> split, List<OutPublicReleaseDetails> prList, PublicRelease use, InputPublicRelease in) {
 		//先删除,再修改个,再新增,有利于减少计算
 		deletePRD(split,prList);
 		publicReleaseDetailsMapper.updateDistrictByPrid(in);
-		addPRD(split,prList,use);
+		List<User> users = addPRD(split, prList, use);
+
+
+		return users;
 	}
 
+
+
 	private void deletePRD(List<String> split, List<OutPublicReleaseDetails> prdList) {
 		for (OutPublicReleaseDetails prd : prdList) {
 			boolean flag=true;
@@ -285,9 +393,13 @@ public class PublicReleaseServiceImpl extends BaseMybatisDao<PublicReleaseMapper
 	 * @param prdList 修改前客户集
 	 * @param use 原订单信息
 	 */
-	private void  addPRD(List<String> split, List<OutPublicReleaseDetails> prdList, PublicRelease use) {
+	private List<User>  addPRD(List<String> split, List<OutPublicReleaseDetails> prdList, PublicRelease use) {
 		List<PublicReleaseDetails> addPrdList=new ArrayList<>();
+		List<User> users=new ArrayList<>();
+		Integer publicType = use.getPublicType();
 		for (String s : split) {
+			User u=userMapper.selectByPrimaryKey(s);
+			users.add(u);
 			boolean flag=true;
 			Integer id=null;
 			String districtName=null,latitude=null,longitude=null;
@@ -302,7 +414,6 @@ public class PublicReleaseServiceImpl extends BaseMybatisDao<PublicReleaseMapper
 			}
 			if (flag){
 				PublicReleaseDetails prd=new PublicReleaseDetails();
-				User u=userMapper.selectByPrimaryKey(s);
 				if (u!=null&&u.getShareType()==2){
 					prd.setNewUser(1);
 				}else {
@@ -321,9 +432,25 @@ public class PublicReleaseServiceImpl extends BaseMybatisDao<PublicReleaseMapper
 				prd.setLongitude(longitude);
 				prd.setClockIn(0);
 				addPrdList.add(prd);
+				if (!use.getAid().equals(u.getAid())){
+					addPublicExamine(use.getId(), u.getAid());
+					if (publicType==1)publicType=1;
+				}
 			}
 		}
+		StringBuffer str=new StringBuffer();
+		for (User u : users) {
+			str=str.append(use.getUserNames()).append(",");
+		}
+		if (publicType!=use.getPublicType()){
+			PublicRelease newP=new PublicRelease();
+			newP.setId(use.getId());
+			if (str.length()>1)newP.setUserNames(str.substring(0,str.length()-1));
+			newP.setPublicType(publicType);
+			publicReleaseMapper.updateByPrimaryKeySelective(newP);
+		}
 		if (!addPrdList.isEmpty())publicReleaseDetailsMapper.insertBatch(addPrdList);
+		return users;
 	}
 
 	@SuppressWarnings("unchecked")
@@ -345,63 +472,152 @@ public class PublicReleaseServiceImpl extends BaseMybatisDao<PublicReleaseMapper
 		if(in.getClockIn()!=null)	map.put("clockIn", in.getClockIn());
 		map.put("assist",in.getAssist()==null?0:in.getAssist());
 		Pagination<OutPublicReleaseList> p=(Pagination<OutPublicReleaseList>) findPage("listPublicRelease", "countPublicRelease", map, in.getPageNo(), in.getPageSize());
+		if(in.getType()==0||in.getType()==4){
+			pushExamines(p);
+
+
+		}
 		return p;
 	}
 
+	private void pushExamines(Pagination<OutPublicReleaseList> p) {
+		List<OutPublicReleaseList> list = (List<OutPublicReleaseList>) p.getList();
+		if (!list.isEmpty()){
+			List<Integer> ids=new ArrayList<>();
+			list.forEach(e ->{ ids.add(e.getId()); });
+			List<PublicExamine> publicExamines = publicExamineMapper.selectByIds(ids);
+			for (OutPublicReleaseList e : list) {
+				if (!publicExamines.isEmpty()){
+					StringBuffer str =new StringBuffer();
+					for (PublicExamine pe : publicExamines) {
+						if (e.getId().equals(pe.getPrid())){
+							str=str.append(pe.getAname());
+							if (pe.getStatus()==0)str=str.append(" 未审核,");
+							if (pe.getStatus()==1)str=str.append(" 已审核,");
+						}
+						if (str.length()>1) e.setAdminExamine(str.substring(0,str.length()-1));
+					}
+
+				}
+			}
+		}
+
+
+	}
+
 	@Override
-	public int pushExaminePublicRelease(Integer id, Integer status, String remarks) {
+	@Transactional
+	public int pushExaminePublicRelease(Integer id, Integer status, String remarks,Integer examineType) {
 		PublicRelease p=new PublicRelease();
 		Date date =new Date();
+		boolean flag=false;
 		String aid=TokenManager.getAdminId();
 		p.setId(id);
-		p.setStatus(status);
 		PublicRelease use=publicReleaseMapper.selectByPrimaryKey(id);
 		if (use.getStatus()!=1) {
 			throw new BusinessException("只能修改发起的状态公出");
 		}
-		StringBuffer str=new StringBuffer();
+		//当前审核人员
 		Admin ad=adminMapper.selectByPrimaryKey(aid);
+		//公出负责人
+		Admin a;
+		Admin publicAdmin =adminMapper.selectByPrimaryKey(use.getAid());
+		a=publicAdmin;
+		StringBuffer str=new StringBuffer();
 		str=str.append("(").append(ad.getName()).append(")");
-		Integer type=0;
-		String content="";
-		Admin a=adminMapper.selectByPrimaryKey(use.getAid());
-		if (status==0){
-			str=str.append("驳回,");
-			if (use.getAssist()==2){
-				content="["+use.getUserNames()+"]公司的外出申请,技术协单被["+ad.getName()+"]拒绝!";
-			}else {
-				content="["+use.getUserNames()+"]公司的外出申请,未通过公出审核!";
+		StringBuffer content=new StringBuffer().append("[").append(use.getUserNames()).append("]公司的外出申请,");
+		//上级审核
+		if(examineType==0){
+			p.setStatus(status);
+			if (status==0){
+				str=str.append("驳回,");
+				if (use.getAssist()==2){
+					content=content.append("技术协单被[").append(ad.getName()).append("]拒绝!");
+				}else {
+					content=content.append("未通过公出审核!");
+				}
+				if(use.getPublicType()>1){
+					p.setPublicType(1);
+					PublicExamine inpe=new PublicExamine();
+					inpe.setStatus(0);
+					inpe.setPrid(use.getId());
+					publicExamineMapper.updatePrid(inpe);
+				}
+			}else if(status==2){
+				str=str.append("同意,");
+				//如果是协单公出主公出,在审核通过
+				if (use.getAssist()==1){
+					pushPublicReleaseAssist(use,status,date,a);
+				}else if (use.getAssist()==0){
+					publicReleaseMapper.updateStatusByMainId(3,use.getId(),null,null);
+				}
+				content=content.append("已通过审核!");
 			}
-		}else if(status==2){
-			str=str.append("同意,");
-			//如果是协单公出主公出,在审核通过
-			if (use.getAssist()==1){
-				pushPublicReleaseAssist(use,status,date,a);
-			}else if (use.getAssist()==0){
-				publicReleaseMapper.updateStatusByMainId(3,use.getId(),null,null);
+			str=str.append(remarks);
+			p.setAuditInfo(str.toString());
+			p.setAuditTime(date);
+			p.setRejectName(ad.getName());
+			addpublicLog(id, status, remarks);
+			flag=true;
+			//营销员审核
+		}else if (examineType==1){
+			//通知公出人切换成公出人审核人
+			a=adminMapper.selectByPrimaryKey(a.getReviewer());
+			if (status==2){//审核通过
+				str=str.append("同意公出我的企业,").append(remarks);
+				content=content.append("已通过审核,请尽快审核。");
+				List<PublicExamine> publicExamines = publicExamineMapper.selectByPrid(use.getId());
+				int x=0;
+				for (PublicExamine pe : publicExamines) {
+					if (pe.getAid().equals(aid)){
+						pe.setStatus(1);
+						PublicExamine newp=new PublicExamine();
+						newp.setId(pe.getId());
+						newp.setStatus(1);
+						publicExamineMapper.updateByPrimaryKeySelective(newp);
+						x++;
+					}else {
+						if (pe.getStatus()==1){
+							x++;
+						}
+					}
+				}
+				if (x==publicExamines.size()){
+					p.setPublicType(2);
+					flag=true;
+				}
+				addpublicLog(id, status, str.toString());
+
+			}else if (status==0){//审核驳回
+				//切换通知人公出负责人
+				a=publicAdmin;
+				str=str.append("不同意公出我的企业,").append(remarks);;
+				content=content.append("未通过审核,请修改后重新发起。");
+				p.setPublicType(3);
+				p.setStatus(0);
+				p.setAuditInfo(str.toString());
+				p.setRejectName(ad.getName());
+				addpublicLog(id, 0, str.toString());
 			}
-
-			content="["+use.getUserNames()+"]公司的外出申请,已通过审核!";
 		}
-		str=str.append(remarks);
-		p.setAuditInfo(str.toString());
-		p.setAuditTime(date);
-		p.setRejectName(ad.getName());
-		publicReleaseMapper.updateByPrimaryKeySelective(p);
-		addpublicLog(id, status, remarks);
 		AdminListBo my = adminMapper.getDeptNameByAid(TokenManager.getAdminId());
-
-		sendNoticeAndSoucket(a.getId(),status,content);
-		if (my.getOpenId()!=null) {
+		if (flag){
+			sendNoticeAndSoucket(a.getId(),status,content.toString());
+		}
+		if (p.getStatus()!=null||p.getPublicType()!=null){
+			publicReleaseMapper.updateByPrimaryKeySelective(p);
+		}
+		if (a.getOpenId()!=null) {
 			if (remarks.length()>19) {
 				remarks=remarks.substring(0, 15)+"...";
 			}
-			Integer res=weChatUtils.addNotice(a.getOpenId(),p.getStatus(),p.getId(),date,my.getName(),remarks);
+			Integer res=weChatUtils.addNotice(a.getOpenId(),status,p.getId(),date,my.getName(),remarks);
 			if (res!=0) {
 				sendEmail( my,  a, status);
 
 			}
 			return res;
+		}else {
 		}
 			return 1;
 	}
@@ -605,7 +821,6 @@ public class PublicReleaseServiceImpl extends BaseMybatisDao<PublicReleaseMapper
 	 * @param use
 	 */
 	private void updatepushAssistant(PublicRelease use,Admin a) {
-		List<String> list=new ArrayList();
 		List<PublicRelease> uselist = publicReleaseMapper.selectByMainId(use.getId(),4,null);
 		for (PublicRelease p : uselist) {
 					if(!use.getReleaseStart().equals(p.getReleaseStart()))p.setReleaseStart(use.getReleaseStart());
@@ -619,7 +834,6 @@ public class PublicReleaseServiceImpl extends BaseMybatisDao<PublicReleaseMapper
 					PublicReleaseLog log = new PublicReleaseLog(p.getId(), TokenManager.getAdminId(), PublicReleaseLog.states.ty.getCode(), str.toString(), new Date());
 					sendNoticeAndSoucket(p.getAid(),p.getStatus(),str.toString());
 					publicReleaseLogMapper.insertSelective(log);
-
 		}
 	}
 
@@ -634,9 +848,13 @@ public class PublicReleaseServiceImpl extends BaseMybatisDao<PublicReleaseMapper
 	public int pushPublicReleaseClockIn(Integer id,String photoUrl,Integer clockIn ,String clockInRemarks ,String uid) {
 		if (clockIn == null) clockIn = 1;
 		PublicRelease use = publicReleaseMapper.selectByPrimaryKey(id);
+		if (use.getPublicType()==1||use.getPublicType()==3){
+			return -1;
+		}
 		List<OutPublicReleaseDetails> prdList = publicReleaseDetailsMapper.selectByPCid(id);
 		String str = "";
 		boolean flag=false;
+		Integer clockCount=0;
 		for (OutPublicReleaseDetails prd : prdList) {
 			if (prd.getUid().equals(uid)){
 				String aid = TokenManager.getAdminId();
@@ -669,8 +887,17 @@ public class PublicReleaseServiceImpl extends BaseMybatisDao<PublicReleaseMapper
 				publicReleaseLogMapper.insertSelective(log);
 				publicReleaseDetailsMapper.updateByPrimaryKeySelective(prd);
 				flag=true;
+				clockCount++;
+			}else if (prd.getClockIn()==1){
+				clockCount++;
 			}
 		}
+		if (prdList.size()==clockCount){
+			PublicRelease newp=new PublicRelease();
+			newp.setId(id);
+			newp.setClockIn(1);
+			publicReleaseMapper.updateByPrimaryKeySelective(newp);
+		}
 		if (!flag){
 			return 0;
 		}
@@ -679,25 +906,48 @@ public class PublicReleaseServiceImpl extends BaseMybatisDao<PublicReleaseMapper
 
 	@Override
 	public OutPublicRelease dtails(Integer id) {
+		String aid=TokenManager.getAdminId();
 		//如果不是本人和审核人员则不返回信息
 		OutPublicRelease out=publicReleaseMapper.selectDtails(id);
+		List<PublicExamine> ps = publicExamineMapper.selectByPrid(out.getId());
+		out.setPeList(ps);
 		if(out!=null){
 			boolean flag=false;
 			//自己、审核人员与部门负责人可以查看
 			AdminListBo ab=adminMapper.getDeptNameByAid(out.getAid());
-			if (!TokenManager.getAdminId().equals( out.getAid())&&
-					!TokenManager.getAdminId().equals(out.getReviewer())&&
-					!TokenManager.getAdminId().equals(ab.getDepManager())&&
+			if (!aid.equals( out.getAid())&&
+					!aid.equals(out.getReviewer())&&
+					!aid.equals(ab.getDepManager())&&
 					!TokenManager.hasRole(AFTConstants.TECH_FINANCE_DIRECTOR)){
 				flag=true;
 			}
+			//是否可以查看
+			if (!ps.isEmpty()){
+				for (PublicExamine p : ps) {
+					if (p.getAid().equals(aid)){
+						if (p.getStatus()==1)out.setMyExamine(1);
+						else out.setMyExamine(0);
+						flag=false;
+						break;
+					}
+				}
+			}
 			if(flag){
 				out=null;
+				return out;
 			}else {
-				if(TokenManager.getAdminId().equals(out.getAid())) {
-					out.setPermission(0);
+				if (out.getPublicType()==1){
+					if (aid.equals(out.getAid())){
+						out.setPermission(0);
+					}else {
+						out.setPermission(1);
+					}
 				}else {
-					out.setPermission(1);
+					if(aid.equals(out.getAid())) {
+						out.setPermission(0);
+					}else {
+						out.setPermission(1);
+					}
 				}
 			}
 		}

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

@@ -52,7 +52,7 @@ yxjl_max=100
 amb.maxLvl=6
 
 avatar.host=//static.jishutao.com
-static.host=//static.jishutao.com/1.2.64
+static.host=//static.jishutao.com/1.2.65
 rd.static.host=//static.jishutao.com/RD/1.0.00
 #avatar.host=//172.16.0.255:3000
 #static.host=//172.16.0.255:3000/1.2.62

+ 1 - 1
src/main/resources/props/config_test.properties

@@ -49,7 +49,7 @@ yxjl_max=100
 
 amb.maxLvl=6
 
-static.host=//static.jishutao.com/1.2.64
+static.host=//static.jishutao.com/1.2.65
 portal.host=//static.jishutao.com/portal/2.0.6
 avatar.host=//static.jishutao.com
 rd.static.host=//static.jishutao.com/RD/1.0.00