Browse Source

Merge branch 'test' of jishutao/aft into prod

gitadmin 7 years ago
parent
commit
91ba19e7db

+ 1 - 1
src/main/java/com/goafanti/admin/bo/InputAdmin.java

@@ -8,7 +8,7 @@ public class InputAdmin {
 	@Size(min = 0, max = 36, message = "{" + ErrorConstants.PARAM_SIZE_ERROR + "}")
 	private String	id;
 
-	@Size(min = 0, max = 11, message = "{" + ErrorConstants.MOBILE_SIZE_ERROR + "}")
+	@Size(min = 0, max = 15, message = "{" + ErrorConstants.MOBILE_SIZE_ERROR + "}")
 	private String	mobile;
 
 	@Size(min = 0, max = 6, message = "{" + ErrorConstants.PARAM_SIZE_ERROR + "}")

+ 3 - 1
src/main/java/com/goafanti/business/service/impl/BusinessProjectServiceImpl.java

@@ -195,7 +195,9 @@ public class BusinessProjectServiceImpl extends BaseMybatisDao<BusinessProjectMa
 		String cid=businessVarietiesMapper.getThisCid(s);
 		String cname=businessVarietiesMapper.getThisCname(cid);
 		BusinessVarieties bv=businessVarietiesMapper.selectByPrimaryKey(s);
-		String sid=bv.getSuperId();
+		String sid="";
+		if(null!=bv.getSuperId())sid=bv.getSuperId();
+
 		if (cid.length()>4) {
 			if(bv.getSuperId().equals(bv.getId())){
 				return "";

+ 125 - 120
src/main/java/com/goafanti/common/constant/AFTConstants.java

@@ -1,121 +1,126 @@
-package com.goafanti.common.constant;
-
-public class AFTConstants {
-	public static final String	YYYYMMDDHHMMSS						= "yyyy-MM-dd HH:mm:ss";
-
-	public static final String	YYYYMMDD							= "yyyy-MM-dd";
-
-	public static final String	YYYY								= "yyyy";
-
-	public static final String	MMDDYYYY							= "MM/dd/yyyy";
-
-	public static final String	MMDD								= "MM-dd";
-
-	public static final String	INITIALPASSWORD						= "123456";				// 初始密码
-
-	public static final String	SUPERADMIN							= "999999";				// 超级管理员
-
-	public static final String	APPROVAL_DECISION					= "99999";				// 特批决策者
-	
-	public static final String  TECH_ADMIN                          = "99998";				// 技术管理员
-
-	public static final String	AREAADMIN							= "";					// 地区管理员
-
-	public static final String	AUDITORADMIN						= "";					// 审核员
-
-	public static final String	MANAGERADMIN						= "";					// 客户经理
-
-	public static final String	SALESMANAGERADMIN					= "";					// 营销经理
-
-	public static final String	SALESMANADMIN						= "";					// 营销员
-
-	public static final String	TECHBROKER							= "";					// 技术经纪人
-
-	public static final String	PATENTINFO							= "专利申请管理";
-
-	public static final String	COGNIZANCE							= "高企认定管理";
-
-	public static final String	COPYRIGHT							= "软著申请管理";
-
-	public static final String	TECHPROJECT							= "科技项目申报管理";
-	
-	public static final String	DEFAULT_INITIATOR					= "超级管理员";
-	
-	public static final String	CONSULTANT_MANAGER					= "咨询师管理员";
-
-	public static final int		KEYWORDLENTH						= 16;
-
-	public static final int		IMPORTMAXLENTH						= 1000;					// 科技需求&科技成果批量导入最大数据量
-
-	public static final int		PROVINCEMAXNUM						= 99;
-
-	public static final int		CITYMAXNUM							= 999;
-
-	public static final Integer	ACHIEVEMENT_DEMAND_INIT_COUNT		= 0;
-
-	public static final Integer	ACHIEVEMENT_DEMAND_FIRST_COUNT		= 1;
-
-	public static final Integer	BIG_SHOT_STAR_CACHE_KEY				= 666;
-
-	public static final Integer	BIG_SHOT_LECTURE_CACHE_KEY			= 667;
-
-	public static final Integer	LECTURE_DYNAMIC_LIST_CACHE_KEY		= 668;
-
-	public static final Integer	LECTURE_LIST_CACHE_KEY				= 669;
-
-	public static final Integer	INTERNATIONAL_ACHIEVEMENT_CACHE_KEY	= 670;
-
-	public static final Integer	INTERNATIONAL_USER_CACHE_KEY		= 671;
-
-	public static final Integer	INTERNATIONAL_ORG_CACHE_KEY			= 672;
-
-	public static final Integer	YES									= 1;
-
-	public static final Integer	NO									= 0;
-
-	public static final String	USER_TYPE_PERSONAL					= "0";
-
-	public static final String	USER_TYPE_ORGANIZATION				= "1";
-
-	public static final Integer	USER_SOURCE_REGISTER				= 0;
-
-	public static final Integer	USER_SOURCE_CREATE					= 1;
-
-	public static final Integer	USER_SHARE_PRIVATE					= 0;
-
-	public static final Integer	USER_SHARE_PUBLIC					= 1;
-
-	public static final Integer	USER_STATUS_NORMAL					= 0;
-
-	public static final Integer	USER_STATUS_CANCEL					= 1;
-
-	public static final Integer	USER_STATUS_LOCKING					= 2;
-
-	public static final String	USER_TRANSFER_TO_PUBLIC				= "转为公共客户";
-
-	public static final String	USER_DELETE							= "删除客户";
-
-	public static final String	USER_RECEIVE						= "领取";
-
-	public static final String	USER_TRANSFER_TO_OTHER				= "转交客户给制定人";
-
-	/**组织类型-公司*/
-	public static final String	ORGANIZATION_TYPE_COMPANY			= "0";
-	/**组织类型-部门*/
-	public static final String	ORGANIZATION_TYPE_DEPARTMENT		= "1";
-	/**组织类型-团队*/
-	public static final String	ORGANIZATION_TYPE_TEAM				= "2";
-
-	public static final String	DAILY								= "daily";
-	public static final String	WEEKLY								= "weekly";
-	public static final String	MONTHLY								= "monthly";
-	public static final String	QUARTERLY							= "quarterly";
-	public static final String	ANNUALLY							= "annually";
-
-	/** 转公共客户拜访时限 **/
-	public static final long USER_FOLLOW_LIMIT_MS					= 24*3600*1000*30L;
-	/** 转公公共客户签单时限 **/
-	public static final long USER_SIGN_LIMIT_MS						= 24*3600*1000*270L;
-	
-	public static final Integer USER_STATUS = 1;
+package com.goafanti.common.constant;
+
+public class AFTConstants {
+	public static final String	YYYYMMDDHHMMSS						= "yyyy-MM-dd HH:mm:ss";
+
+	public static final String	YYYYMMDD							= "yyyy-MM-dd";
+
+	public static final String	YYYY								= "yyyy";
+
+	public static final String	MMDDYYYY							= "MM/dd/yyyy";
+
+	public static final String	MMDD								= "MM-dd";
+
+	public static final String	INITIALPASSWORD						= "123456";				// 初始密码
+
+	public static final String	SUPERADMIN							= "999999";				// 超级管理员
+
+	public static final String	APPROVAL_DECISION					= "99999";				// 特批决策者
+	
+	public static final String  TECH_ADMIN                          = "99998";				// 技术管理员
+
+	public static final String	AREAADMIN							= "";					// 地区管理员
+
+	public static final String	AUDITORADMIN						= "";					// 审核员
+
+	public static final String	MANAGERADMIN						= "";					// 客户经理
+
+	public static final String	SALESMANAGERADMIN					= "";					// 营销经理
+
+	public static final String	SALESMANADMIN						= "";					// 营销员
+
+	public static final String	TECHBROKER							= "";					// 技术经纪人
+
+	public static final String	PATENTINFO							= "专利申请管理";
+
+	public static final String	COGNIZANCE							= "高企认定管理";
+
+	public static final String	COPYRIGHT							= "软著申请管理";
+
+	public static final String	TECHPROJECT							= "科技项目申报管理";
+	
+	public static final String	DEFAULT_INITIATOR					= "超级管理员";
+	
+	public static final String	CONSULTANT_MANAGER					= "咨询师管理员";
+
+	public static final int		KEYWORDLENTH						= 16;
+
+	public static final int		IMPORTMAXLENTH						= 1000;					// 科技需求&科技成果批量导入最大数据量
+
+	public static final int		PROVINCEMAXNUM						= 99;
+
+	public static final int		CITYMAXNUM							= 999;
+
+	public static final Integer	ACHIEVEMENT_DEMAND_INIT_COUNT		= 0;
+
+	public static final Integer	ACHIEVEMENT_DEMAND_FIRST_COUNT		= 1;
+
+	public static final Integer	BIG_SHOT_STAR_CACHE_KEY				= 666;
+
+	public static final Integer	BIG_SHOT_LECTURE_CACHE_KEY			= 667;
+
+	public static final Integer	LECTURE_DYNAMIC_LIST_CACHE_KEY		= 668;
+
+	public static final Integer	LECTURE_LIST_CACHE_KEY				= 669;
+
+	public static final Integer	INTERNATIONAL_ACHIEVEMENT_CACHE_KEY	= 670;
+
+	public static final Integer	INTERNATIONAL_USER_CACHE_KEY		= 671;
+
+	public static final Integer	INTERNATIONAL_ORG_CACHE_KEY			= 672;
+
+	public static final Integer	YES									= 1;
+
+	public static final Integer	NO									= 0;
+
+	public static final String	USER_TYPE_PERSONAL					= "0";
+
+	public static final String	USER_TYPE_ORGANIZATION				= "1";
+
+	public static final Integer	USER_SOURCE_REGISTER				= 0;
+
+	public static final Integer	USER_SOURCE_CREATE					= 1;
+
+	public static final Integer	USER_SHARE_PRIVATE					= 0;
+
+	public static final Integer	USER_SHARE_PUBLIC					= 1;
+
+	public static final Integer	USER_STATUS_NORMAL					= 0;
+
+	public static final Integer	USER_STATUS_CANCEL					= 1;
+
+	public static final Integer	USER_STATUS_LOCKING					= 2;
+
+	public static final String	USER_TRANSFER_TO_PUBLIC				= "转为公共客户";
+
+	public static final String	USER_DELETE							= "删除客户";
+
+	public static final String	USER_RECEIVE						= "领取";
+
+	public static final String	USER_TRANSFER_TO_OTHER				= "转交客户给制定人";
+
+	/**组织类型-公司*/
+	public static final String	ORGANIZATION_TYPE_COMPANY			= "0";
+	/**组织类型-部门*/
+	public static final String	ORGANIZATION_TYPE_DEPARTMENT		= "1";
+	/**组织类型-团队*/
+	public static final String	ORGANIZATION_TYPE_TEAM				= "2";
+
+	public static final String	DAILY								= "daily";
+	public static final String	WEEKLY								= "weekly";
+	public static final String	MONTHLY								= "monthly";
+	public static final String	QUARTERLY							= "quarterly";
+	public static final String	ANNUALLY							= "annually";
+
+	/** 转公共客户拜访时限 **/
+	public static final long USER_FOLLOW_LIMIT_MS					= 24*3600*1000*30L;
+	/** 转公公共客户签单时限 **/
+	public static final long USER_SIGN_LIMIT_MS						= 24*3600*1000*270L;
+	
+	public static final Integer USER_STATUS = 1;
+	
+	
+	public static final String DEFAULT_CONTACT_TYPE="0";
+	
+	public static final String DEFAULT_RESULT="签单-自动触发";
 }

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

@@ -92,9 +92,11 @@ public interface UserLockReleaseMapper {
 
 	List<LockingReleaseBo> selectWaitReleaseBusiness(String aid);
 
-	void updateReleaseLock(@Param("releaseTime")Date releaseTime);
+	void updateReleaseLock(@Param("time")String time);
 
 	void updatePendingReleaseLock(@Param("lockIds")String lockIds);
 
 	List<LockingReleaseBo> selectPendinglockUserList();
+
+	void updateProject(@Param("uid")String uid, @Param("aid")String aid, @Param("businessProjectId")String businessProjectId);
 }

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

@@ -229,7 +229,7 @@ public interface UserMapper {
 	
 	List<User> selectUserByRoleName(@Param("roleName1")String roleName1,@Param("roleName2")String roleName2);
 	
-	void updateReleaseLock();
+	void updateReleaseLock(String time);
 
 	marketingESBo marketingStatistics(@Param("id")String id, @Param("dailyStart")String dailyStart, @Param("dailyEnd")String dailyEnd);
 

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

@@ -56,7 +56,7 @@
     <result column="registration_time" jdbcType="TIMESTAMP" property="registrationTime" />
     <result column="ratepay_code" jdbcType="VARCHAR" property="ratepayCode" />
     <result column="industry" jdbcType="INTEGER" property="industry" />
-    <result column="enterprise_scale" jdbcType="INTEGER" property="enterpriseScale" />
+    <result column="enterprise_scale" jdbcType="VARCHAR" property="enterpriseScale" />
     <result column="register_type" jdbcType="VARCHAR" property="registerType" />
     <result column="foreign_investment" jdbcType="VARCHAR" property="foreignInvestment" />
     <result column="field" jdbcType="VARCHAR" property="field" />
@@ -259,7 +259,7 @@
       #{issuingDate,jdbcType=TIMESTAMP}, #{cogContacts,jdbcType=INTEGER}, #{techPrincipal,jdbcType=VARCHAR}, 
       #{contactsFixedTel,jdbcType=VARCHAR}, #{contactsFax,jdbcType=VARCHAR}, #{legalPersonTel,jdbcType=VARCHAR}, 
       #{legalPersonFax,jdbcType=VARCHAR}, #{legalPersonEmail,jdbcType=VARCHAR}, #{registrationTime,jdbcType=TIMESTAMP}, 
-      #{ratepayCode,jdbcType=VARCHAR}, #{industry,jdbcType=INTEGER}, #{enterpriseScale,jdbcType=INTEGER}, 
+      #{ratepayCode,jdbcType=VARCHAR}, #{industry,jdbcType=INTEGER}, #{enterpriseScale,jdbcType=VARCHAR}, 
       #{registerType,jdbcType=VARCHAR}, #{foreignInvestment,jdbcType=VARCHAR}, #{field,jdbcType=VARCHAR}, 
       #{taxAuthority,jdbcType=INTEGER}, #{ratepayMethod,jdbcType=INTEGER}, #{highTechZone,jdbcType=INTEGER}, 
       #{riskInvestment,jdbcType=INTEGER}, #{businessScope,jdbcType=VARCHAR}, #{highTechName,jdbcType=VARCHAR}, 
@@ -630,7 +630,7 @@
         #{industry,jdbcType=INTEGER},
       </if>
       <if test="enterpriseScale != null">
-        #{enterpriseScale,jdbcType=INTEGER},
+        #{enterpriseScale,jdbcType=VARCHAR},
       </if>
       <if test="registerType != null">
         #{registerType,jdbcType=VARCHAR},
@@ -855,7 +855,7 @@
         industry = #{record.industry,jdbcType=INTEGER},
       </if>
       <if test="record.enterpriseScale != null">
-        enterprise_scale = #{record.enterpriseScale,jdbcType=INTEGER},
+        enterprise_scale = #{record.enterpriseScale,jdbcType=VARCHAR},
       </if>
       <if test="record.registerType != null">
         register_type = #{record.registerType,jdbcType=VARCHAR},
@@ -972,7 +972,7 @@
       registration_time = #{record.registrationTime,jdbcType=TIMESTAMP},
       ratepay_code = #{record.ratepayCode,jdbcType=VARCHAR},
       industry = #{record.industry,jdbcType=INTEGER},
-      enterprise_scale = #{record.enterpriseScale,jdbcType=INTEGER},
+      enterprise_scale = #{record.enterpriseScale,jdbcType=VARCHAR},
       register_type = #{record.registerType,jdbcType=VARCHAR},
       foreign_investment = #{record.foreignInvestment,jdbcType=VARCHAR},
       field = #{record.field,jdbcType=VARCHAR},
@@ -1148,7 +1148,7 @@
         industry = #{industry,jdbcType=INTEGER},
       </if>
       <if test="enterpriseScale != null">
-        enterprise_scale = #{enterpriseScale,jdbcType=INTEGER},
+        enterprise_scale = #{enterpriseScale,jdbcType=VARCHAR},
       </if>
       <if test="registerType != null">
         register_type = #{registerType,jdbcType=VARCHAR},
@@ -1262,7 +1262,7 @@
       registration_time = #{registrationTime,jdbcType=TIMESTAMP},
       ratepay_code = #{ratepayCode,jdbcType=VARCHAR},
       industry = #{industry,jdbcType=INTEGER},
-      enterprise_scale = #{enterpriseScale,jdbcType=INTEGER},
+      enterprise_scale = #{enterpriseScale,jdbcType=VARCHAR},
       register_type = #{registerType,jdbcType=VARCHAR},
       foreign_investment = #{foreignInvestment,jdbcType=VARCHAR},
       field = #{field,jdbcType=VARCHAR},

+ 1 - 0
src/main/java/com/goafanti/common/mapper/TOrderMapper.xml

@@ -1231,6 +1231,7 @@
 			a.buyer_id as buyerId,
 			a.seller_id as sellerId,
 			a.buyer_id as buyerId,
+			a.salesman_id as salesmanId,
 			b.type as buyerType,
 			b.nickname as buyerName,
 			c.name as salesmanName,

+ 8 - 1
src/main/java/com/goafanti/common/mapper/UserLockReleaseMapper.xml

@@ -385,7 +385,7 @@
   </select>
   
   <update id="updateReleaseLock" parameterType="java.lang.String">
-  		update user_lock_release set status = 2,release_time =  #{releaseTime} where status=1
+  		update user_lock_release set status = 2,release_time =  #{time} where status=1
   </update>
   
   <update id="updatePendingReleaseLock" parameterType="java.lang.String">
@@ -395,4 +395,11 @@
   <select id="selectPendinglockUserList" resultType="com.goafanti.customer.bo.LockingReleaseBo">
   	select id,uid,type  from user_lock_release where status=1
   </select>
+  
+  <update id="updateProject" parameterType="java.lang.String">
+  	update user_lock_release set status = 2,release_time=now()
+  	where uid= #{uid,jdbcType=VARCHAR}
+	and aid= #{aid,jdbcType=VARCHAR}
+	and business_project_id= #{businessProjectId,jdbcType=VARCHAR}
+  </update>
 </mapper>

+ 21 - 3
src/main/java/com/goafanti/common/mapper/UserMapperExt.xml

@@ -1634,8 +1634,8 @@
 			where b.status != 1 and b.identify_name like concat('%',#{name},'%')
     </select>
     
-    <update id="updateReleaseLock" parameterType="com.goafanti.customer.bo.LockingReleaseBo">
-    	update user a,user_lock_release b set a.share_type = 1 where b.status=1 and a.id=b.uid 
+    <update id="updateReleaseLock" parameterType="java.lang.String">
+    	update user a,user_lock_release b set a.share_type = 1,a.transfer_time =  #{time} where b.status=1 and a.id=b.uid 
     </update>
     
     <select id="marketingStatistics" parameterType="java.lang.String" resultType="com.goafanti.report.bo.marketingESBo">
@@ -1702,11 +1702,20 @@
 			on b.location_province=c.id left join district_glossory c1 
 			on b.location_city=c1.id left join district_glossory c2 
 			on b.location_area=c2.id left join industry_category d on b.industry = d.id
+			<if test="follow !=null and follow!=''">
+			left join (select aid,uid,contact_type from user_follow where aid= #{aid,jdbcType=VARCHAR} and contact_type=0 GROUP by uid) e on a.id=e.uid and a.aid=e.aid
+			</if>
 			where  a.status=0 
 			and a.information_maintainer = #{aid,jdbcType=VARCHAR}
 			<if test="type !=null and type!=''">
 			and a.`type`=#{type,jdbcType=VARCHAR}
 			</if>
+			<if test="follow ==0">
+			and (e.contact_type !=0 or e.contact_type is null)
+			</if>
+			<if test="follow ==1">
+			and e.contact_type=0
+			</if>
 			<if test="name!=null and name!=''">
 			and a.nickname like concat('%',#{name,jdbcType=VARCHAR},'%')
 			</if>
@@ -1750,10 +1759,19 @@
 		select count(0)
 			from user a left join organization_identity b 
 			on a.id=b.uid 
+			<if test="follow  !=null and follow!=''">
+			left join (select aid,uid,contact_type from user_follow where aid= #{aid,jdbcType=VARCHAR} and contact_type=0 GROUP by uid) e on a.id=e.uid and a.aid=e.aid
+			</if>
 			where  a.status=0 and a.information_maintainer = #{aid,jdbcType=VARCHAR}
 			<if test="type !=null and type!=''">
 			and a.`type`=#{type,jdbcType=VARCHAR}
 			</if>
+			<if test="follow ==0">
+			and (e.contact_type !=0 or e.contact_type is null)
+			</if>
+			<if test="follow ==1">
+			and e.contact_type=0
+			</if>
 			<if test="name!=null and name!=''">
 			and a.nickname like concat('%',#{name,jdbcType=VARCHAR},'%')
 			</if>
@@ -1879,7 +1897,7 @@ inner join(
 	<select id="selectDepCustomerInformationCount" resultType="java.lang.Integer">
 		select count(0)
 			from user a left join organization_identity b 
-			on a.id=b.uid  inner join (select id
+			on a.id=b.uid inner join (select id
 			from admin
 			where id=   #{aid,jdbcType=VARCHAR}
 			or superior_id=  #{aid,jdbcType=VARCHAR}

+ 3 - 3
src/main/java/com/goafanti/common/model/OrganizationIdentity.java

@@ -254,7 +254,7 @@ public class OrganizationIdentity {
 	 * This field was generated by MyBatis Generator. This field corresponds to the database column organization_identity.enterprise_scale
 	 * @mbg.generated  Wed Jun 06 10:26:09 CST 2018
 	 */
-	private Integer enterpriseScale;
+	private String enterpriseScale;
 	/**
 	 * This field was generated by MyBatis Generator. This field corresponds to the database column organization_identity.register_type
 	 * @mbg.generated  Wed Jun 06 10:26:09 CST 2018
@@ -1233,7 +1233,7 @@ public class OrganizationIdentity {
 	 * @return  the value of organization_identity.enterprise_scale
 	 * @mbg.generated  Wed Jun 06 10:26:09 CST 2018
 	 */
-	public Integer getEnterpriseScale() {
+	public String getEnterpriseScale() {
 		return enterpriseScale;
 	}
 
@@ -1242,7 +1242,7 @@ public class OrganizationIdentity {
 	 * @param enterpriseScale  the value for organization_identity.enterprise_scale
 	 * @mbg.generated  Wed Jun 06 10:26:09 CST 2018
 	 */
-	public void setEnterpriseScale(Integer enterpriseScale) {
+	public void setEnterpriseScale(String enterpriseScale) {
 		this.enterpriseScale = enterpriseScale;
 	}
 

+ 10 - 0
src/main/java/com/goafanti/customer/bo/CustomerListIn.java

@@ -59,6 +59,8 @@ public class CustomerListIn {
 
 	private String level;
 	
+	private String follow;
+	
 	
 	public String getType() {
 		return type;
@@ -219,4 +221,12 @@ public class CustomerListIn {
 	public void setLevel(String level) {
 		this.level = level;
 	}
+
+	public String getFollow() {
+		return follow;
+	}
+
+	public void setFollow(String follow) {
+		this.follow = follow;
+	}
 }

+ 7 - 3
src/main/java/com/goafanti/customer/service/impl/CustomerServiceImpl.java

@@ -15,6 +15,7 @@ import java.util.UUID;
 import javax.annotation.Resource;
 
 import org.apache.commons.beanutils.BeanUtils;
+import org.apache.commons.lang3.time.DateFormatUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
@@ -205,6 +206,7 @@ public class CustomerServiceImpl  extends BaseMybatisDao<UserMapper> implements
 		if(StringUtils.isNotBlank(cli.getDepartmentId())) params.put("departmentId", cli.getDepartmentId());
 		if(StringUtils.isNotBlank(cli.getStatus())) params.put("status", Integer.parseInt(cli.getStatus()));
 		if(StringUtils.isNotBlank(cli.getSocietyTag())) params.put("societyTag", cli.getSocietyTag());
+		if(StringUtils.isNotBlank(cli.getFollow())) params.put("follow", cli.getFollow());
 		if(StringUtils.isNotBlank(cli.getStartDate())) params.put("startDate", cli.getStartDate()+" 00:00:00");
 		if(StringUtils.isNotBlank(cli.getEndDate())) params.put("endDate", cli.getEndDate()+" 23:59:59");
 		if(null!=cli.getDataGrade()) params.put("dataGrade", cli.getDataGrade());
@@ -1291,11 +1293,13 @@ public class CustomerServiceImpl  extends BaseMybatisDao<UserMapper> implements
 	 */
 	@Override
 	public void updateReleaseLock(Date releaseTime){
-		userMapper.updateReleaseLock();
-		userLockReleaseMapper.updateReleaseLock(releaseTime);
+		 SimpleDateFormat formatter=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); 
+		 String time=formatter.format(releaseTime); 
+		userMapper.updateReleaseLock(time);
+		userLockReleaseMapper.updateReleaseLock(time);
 		
 	}
-
+	
 	@Override
 	public int updateAgainProjectTask(String uid, String projectId,String aid) {
 		List<LockingReleaseBo>  businessLockedList = userMapper.selectLockedProject(uid, TokenManager.getAdminId(), projectId, 1, UserLockReleaseStatus.LOCKED.getCode());

+ 31 - 1
src/main/java/com/goafanti/order/controller/AdminOrderApiController.java

@@ -1,5 +1,9 @@
 package com.goafanti.order.controller;
 
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
 import javax.annotation.Resource;
 import javax.servlet.http.HttpServletRequest;
 
@@ -8,11 +12,16 @@ import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestMethod;
 import org.springframework.web.bind.annotation.RestController;
 
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONArray;
 import com.goafanti.business.service.BusinessProjectService;
 import com.goafanti.common.bo.Result;
+import com.goafanti.common.constant.AFTConstants;
 import com.goafanti.common.constant.ErrorConstants;
 import com.goafanti.common.controller.CertifyApiController;
 import com.goafanti.core.shiro.token.TokenManager;
+import com.goafanti.customer.bo.BusinessListBo;
+import com.goafanti.customer.bo.FollowBusinessBo;
 import com.goafanti.order.bo.OrderListBo;
 import com.goafanti.order.enums.AuditState;
 import com.goafanti.order.enums.CommodityType;
@@ -96,7 +105,7 @@ public class AdminOrderApiController extends CertifyApiController {
 	 */
 	@RequestMapping(value = "/signServiceOrder", method = RequestMethod.POST)
 	public Result signServiceOrder(String orderNo,String contractNo,String signFirstPayment,String signTotalAmount,
-			String approval,String orderRemarks,String signTime,String contractPictureUrl){
+			String approval,String orderRemarks,String signTime,String contractPictureUrl,String userBusinessList,String uid){
 		Result res = new Result();
 		if(StringUtils.isBlank(orderNo)){
 			res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "订单编号", "订单编号"));
@@ -114,7 +123,28 @@ public class AdminOrderApiController extends CertifyApiController {
 		res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "合同图片", "合同图片"));
 		return res;
 		}
+		if(StringUtils.isBlank(uid)/* || StringUtils.isBlank(ocbId)*/){
+			res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, ""));
+			return res;
+		}
 		orderServiceImpl.updateSignServiceOrder(orderNo,contractNo,signFirstPayment,signTotalAmount,approval,orderRemarks,signTime);
+		//自动把签单任务标记成已签单
+		JSONArray ja = (JSONArray) JSON.parse(userBusinessList);
+		List<BusinessListBo> list = new ArrayList<BusinessListBo>();
+		if (ja != null && !ja.isEmpty()) {
+			BusinessListBo userBusiness = null;
+			for (int idx = 0; idx < ja.size(); idx++) {
+				userBusiness = ja.getJSONObject(idx).toJavaObject(BusinessListBo.class);
+				list.add(userBusiness);
+			}
+		}
+		FollowBusinessBo fbb = new FollowBusinessBo();
+		//fbb.setOcbId(ocbId);
+		fbb.setUid(uid);
+		fbb.setContactType(AFTConstants.DEFAULT_CONTACT_TYPE);
+		fbb.setResult(AFTConstants.DEFAULT_RESULT);
+		fbb.setUserBusinessList(list);	
+		orderServiceImpl.addBusinessProjectId(fbb);
 		return res;
 	}
 	

+ 5 - 0
src/main/java/com/goafanti/order/service/OrderService.java

@@ -7,6 +7,7 @@ import java.util.List;
 import com.goafanti.common.model.OrganizationManagement;
 import com.goafanti.common.model.TOrderDetail;
 import com.goafanti.core.mybatis.page.Pagination;
+import com.goafanti.customer.bo.FollowBusinessBo;
 import com.goafanti.order.bo.BillDetailBo;
 import com.goafanti.order.bo.BillListBo;
 import com.goafanti.order.bo.OrderListBo;
@@ -488,5 +489,9 @@ public interface OrderService {
 
 	boolean checkCustomerInformation(String uid);
 
+	int addBusinessProjectId(FollowBusinessBo fbb);
+
+	
+
 	
 }

+ 104 - 14
src/main/java/com/goafanti/order/service/impl/OrderServiceImpl.java

@@ -23,6 +23,8 @@ import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONArray;
 import com.goafanti.common.bo.Error;
 import com.goafanti.common.bo.Result;
 import com.goafanti.common.constant.AFTConstants;
@@ -39,6 +41,9 @@ import com.goafanti.common.dao.TOrderChangeMapper;
 import com.goafanti.common.dao.TOrderDetailMapper;
 import com.goafanti.common.dao.TOrderMapper;
 import com.goafanti.common.dao.TmpTableMapper;
+import com.goafanti.common.dao.UserBusinessMapper;
+import com.goafanti.common.dao.UserFollowBusinessMapper;
+import com.goafanti.common.dao.UserFollowMapper;
 import com.goafanti.common.dao.UserLockReleaseMapper;
 import com.goafanti.common.dao.UserMapper;
 import com.goafanti.common.dao.UserRoleMapper;
@@ -60,6 +65,9 @@ import com.goafanti.common.model.TOrderChange;
 import com.goafanti.common.model.TOrderDetail;
 import com.goafanti.common.model.TmpTable;
 import com.goafanti.common.model.User;
+import com.goafanti.common.model.UserBusiness;
+import com.goafanti.common.model.UserFollow;
+import com.goafanti.common.model.UserFollowBusiness;
 import com.goafanti.common.model.UserLockRelease;
 import com.goafanti.common.model.UserRole;
 import com.goafanti.common.utils.BeanUtilsExt;
@@ -70,7 +78,10 @@ import com.goafanti.core.mybatis.BaseMybatisDao;
 import com.goafanti.core.mybatis.JDBCIdGenerator;
 import com.goafanti.core.mybatis.page.Pagination;
 import com.goafanti.core.shiro.token.TokenManager;
+import com.goafanti.customer.bo.BusinessListBo;
+import com.goafanti.customer.bo.FollowBusinessBo;
 import com.goafanti.customer.bo.LockingReleaseBo;
+import com.goafanti.customer.service.CustomerService;
 import com.goafanti.order.bo.BillDetailBo;
 import com.goafanti.order.bo.BillListBo;
 import com.goafanti.order.bo.CommodityDetailBo;
@@ -133,6 +144,12 @@ public class OrderServiceImpl extends BaseMybatisDao<TOrderMapper> implements Or
 	private UserLockReleaseMapper userLockReleaseMapper;
 	@Autowired
 	UserRoleMapper	userRoleMapper;
+	@Autowired
+	private UserBusinessMapper	userBusinessMapper;
+	@Autowired
+	private UserFollowMapper	userFollowMapper;
+	@Autowired
+	private UserFollowBusinessMapper	userFollowBusinessMapper;
 	
 	@Value(value = "${mobileRemindCodeTemplate}")
 	private String					mobileRemindCodeTemplate	= null;
@@ -1045,6 +1062,7 @@ public class OrderServiceImpl extends BaseMybatisDao<TOrderMapper> implements Or
 		boolean isBusinessOwner = false;
 		String businessName = "";
 		for(TOrderDetail td : list){
+			//业务锁定
 			lockedList = userMapper.selectLockedProject(tOrder.getBuyerId(), null,td.getCommodityId(), 1, UserLockReleaseStatus.LOCKED.getCode());
 			businessName = businessProjectMapper.selectByPrimaryKey(td.getCommodityId()).getBname();
 			if(lockedList.size() > 0){
@@ -1062,24 +1080,26 @@ public class OrderServiceImpl extends BaseMybatisDao<TOrderMapper> implements Or
 		return releaseList;
 	}
 	
-	@SuppressWarnings("unused")
-	private void lockProject(TOrder tOrder){
-		List<TOrderDetail> list = tOrderMapper.selectOrderCommodity(tOrder.getOrderNo());
-		UserLockRelease ulr = null;
-		for(TOrderDetail td : list){
-			//新增锁定数据
-			ulr = new UserLockRelease();
+	private void lockProject(BusinessListBo ub) {
+		UserLockRelease ulr= new UserLockRelease();
 			ulr.setId(UUID.randomUUID().toString());
 			ulr.setType(1);
 			ulr.setAid(TokenManager.getAdminId());
-			ulr.setBusinessProjectId(td.getCommodityId());
-			ulr.setLockTime(tOrder.getSignTime());
+			ulr.setBusinessProjectId(ub.getBusinessProjectId());
+			SimpleDateFormat sdf =   new SimpleDateFormat( " yyyy-MM-dd HH:mm:ss " ); 
+			try {
+				if (null==ub.getCreateTime()) {
+					ulr.setLockTime(new Date());
+				}else {
+					ulr.setLockTime(sdf.parse(ub.getCreateTime()));
+				}
+			} catch (ParseException e) {
+				e.printStackTrace();
+			}
 			ulr.setStatus(UserLockReleaseStatus.LOCKED.getCode());
-			ulr.setUid(tOrder.getBuyerId());
-			ulr.setOrderNo(tOrder.getOrderNo());
+			ulr.setUid(ub.getUid());
 			userLockReleaseMapper.insert(ulr);
 		}
-	}
 	
 	@SuppressWarnings("unused")
 	private void releaseProject(List<LockingReleaseBo> releaseList){
@@ -1998,8 +2018,10 @@ public class OrderServiceImpl extends BaseMybatisDao<TOrderMapper> implements Or
 						}
 					}
 				}
-				mobile=mobile.substring(0, mobile.length()-1);
-			sendMessage(tOrder,mobile,OrderFlowState.DDBG.getDesc());
+				if(mobile.length()>1){
+					mobile=mobile.substring(0, mobile.length()-1);
+					sendMessage(tOrder,mobile,OrderFlowState.DDBG.getDesc());
+				}
 
 		}
 	}
@@ -2046,4 +2068,72 @@ public class OrderServiceImpl extends BaseMybatisDao<TOrderMapper> implements Or
 		}
 		return false;
 	}
+
+	@Override
+	public int addBusinessProjectId(FollowBusinessBo fbb) {
+		//if(fbb.getUserBusinessList().size()<1) throw new BusinessException(new Error(ErrorConstants.AT_LEAST_A_BUSINESS,"",""));
+		//更新跟进记录表
+		SimpleDateFormat format = new SimpleDateFormat(AFTConstants.YYYYMMDDHHMMSS);
+		fbb.setFollowTime(format.format(new Date()));
+		UserFollow userFollow = new UserFollow();
+		String followId = UUID.randomUUID().toString();
+		userFollow.setId(followId);
+		userFollow.setAid(TokenManager.getAdminId());
+		userFollow.setContactType(Integer.parseInt(fbb.getContactType()));
+		userFollow.setEffective(DeleteStatus.UNDELETE.getCode());
+		userFollow.setCreateTime(new Date());
+		userFollow.setOcbId(fbb.getOcbId());
+		userFollow.setResult(fbb.getResult());
+		userFollow.setUid(fbb.getUid());
+		int followCount = userBusinessMapper.selectFollowCountByUAid(fbb.getUid(), TokenManager.getAdminId()) + 1;
+		userFollow.setFollowCount(followCount);
+		userFollowMapper.insert(userFollow);
+		//检查客户锁定情况
+		if(fbb.getUserBusinessList().size()>0){
+			String ufbId = "";
+			UserBusiness userBusiness = null;
+			UserFollowBusiness userFollowBusiness = null;
+			for(BusinessListBo ub: fbb.getUserBusinessList()){
+				userBusiness = new UserBusiness();
+				userFollowBusiness = new UserFollowBusiness();
+				ufbId = UUID.randomUUID().toString();
+				if (ub.getFollowSituation()==5) {//如果改成已签合同,则锁定业务
+						if (StringUtils.isNotBlank(fbb.getUid())) ub.setUid(fbb.getUid());
+						userLockReleaseMapper.updateProject(fbb.getUid(), TokenManager.getAdminId(), ub.getBusinessProjectId());
+						lockProject(ub);//锁定客户业务
+					}
+					String ubId = UUID.randomUUID().toString();
+					//更新业务表
+					userBusiness.setId(ubId);
+					userBusiness.setBusinessProjectId(ub.getBusinessProjectId());
+					try {
+						userBusiness.setCreateTime(format.parse(fbb.getFollowTime()));
+						userBusiness.setUpdateTime(format.parse(fbb.getFollowTime()));
+					} catch (ParseException e) {
+						e.printStackTrace();
+					}
+					userBusiness.setCustomerStatus(ub.getCustomerStatus());
+					userBusiness.setFollowSituation(ub.getFollowSituation());
+					userBusiness.setUid(fbb.getUid());
+					userBusiness.setAid(TokenManager.getAdminId());
+					userBusiness.setRemarks(ub.getRemarks());
+					userBusinessMapper.insert(userBusiness);	
+					//更新业务中间表
+					userFollowBusiness.setBusinessId(ubId);
+					userFollowBusiness.setCustomerStatus(ub.getCustomerStatus());
+					userFollowBusiness.setFollowSituation(ub.getFollowSituation());
+					userFollowBusiness.setId(ufbId);
+					userFollowBusiness.setFollowId(followId);
+					userFollowBusiness.setRemarks(ub.getRemarks());
+					userFollowBusiness.setBusinessProjectId(ub.getBusinessProjectId());
+					userFollowBusinessMapper.insert(userFollowBusiness);
+				}
+				
+			}	
+			
+		
+		return 1;
+	}
+
+	
 }

+ 223 - 223
src/main/java/com/goafanti/report/controller/ReportApiController.java

@@ -1,223 +1,223 @@
-package com.goafanti.report.controller;
-
-import java.util.Calendar;
-import java.util.Date;
-
-import org.apache.commons.lang3.StringUtils;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
-import org.springframework.web.bind.annotation.RequestParam;
-import org.springframework.web.bind.annotation.RestController;
-
-import com.goafanti.common.bo.Result;
-import com.goafanti.common.constant.AFTConstants;
-import com.goafanti.common.constant.ErrorConstants;
-import com.goafanti.common.controller.BaseApiController;
-import com.goafanti.common.utils.DateUtils;
-import com.goafanti.report.enums.OrderBy;
-import com.goafanti.report.enums.SalesReportOrderField;
-import com.goafanti.report.enums.TimeType;
-import com.goafanti.report.service.SalesReportServiceImpl;
-
-@RestController
-@RequestMapping(value = "/api/admin/report")
-public class ReportApiController extends BaseApiController {
-	@Autowired
-	SalesReportServiceImpl reportService;
-
-	@RequestMapping(value = "/sales/personal", method = RequestMethod.GET)
-	public Result personal(@RequestParam(required = false) String orderField,
-			@RequestParam(required = false) String order, @RequestParam(required = false) String pSize,
-			@RequestParam(required = false) String pNo, @RequestParam(required = false) String date,
-			@RequestParam(required = false) String depName, @RequestParam(required = false) String name,
-			@RequestParam(required = false) String position) {
-		Date startTime = null;
-		try {
-			startTime = StringUtils.isNotBlank(date) ? DateUtils.parseDate(date, AFTConstants.YYYYMMDDHHMMSS)
-					: new Date();
-		} catch (Exception e) {
-			startTime = new Date();
-		}
-		if (StringUtils.isBlank(depName)) {
-			depName = null;
-		}
-		if (StringUtils.isBlank(name)) {
-			name = null;
-		}
-		if (StringUtils.isBlank(position)) {
-			position = null;
-		}
-		Integer pageSize = StringUtils.isBlank(pSize) ? null : handlePageSize(pSize);
-		Integer pageNo = StringUtils.isBlank(pNo) ? null : handlePageNo(pNo);
-		if (pageSize != null && pageNo != null) {
-			pageNo = (pageNo - 1) * pageSize;
-		}
-		return res().data(reportService.getPersonSalesReports(SalesReportOrderField.getField(orderField),
-				OrderBy.getField(order), pageSize, pageNo, startTime, depName, name, position));
-	}
-
-	@RequestMapping(value = "/sales/total", method = RequestMethod.GET)
-	public Result total(String date, @RequestParam(required = false) String depName,
-			@RequestParam(required = false) String name, @RequestParam(required = false) String position) {
-		Date startTime = null;
-		try {
-			startTime = DateUtils.parseDate(date, AFTConstants.YYYYMMDDHHMMSS);
-		} catch (Exception e) {
-			startTime = new Date();
-		}
-		if (StringUtils.isBlank(depName)) {
-			depName = null;
-		}
-		if (StringUtils.isBlank(name)) {
-			name = null;
-		}
-		if (StringUtils.isBlank(position)) {
-			position = null;
-		}
-		return res().data(reportService.getReportTotal(startTime, depName, name, position));
-	}
-
-	@RequestMapping(value = "/sales/department", method = RequestMethod.GET)
-	public Result department(String date) {
-		Date startTime = null;
-		try {
-			startTime = DateUtils.parseDate(date, AFTConstants.YYYYMMDDHHMMSS);
-		} catch (Exception e) {
-			startTime = new Date();
-		}
-		return res().data(reportService.getDepartmentSalesReports(startTime));
-	}
-
-	@RequestMapping(value = "/sales/doStatistics", method = RequestMethod.GET)
-	public Result doStatistics(String date) {
-		Date dateTime = null;
-		try {
-			dateTime = DateUtils.parseDate(date, AFTConstants.YYYYMMDDHHMMSS);
-		} catch (Exception e) {
-			dateTime = new Date();
-		}
-		Calendar now = Calendar.getInstance();
-		now.setTime(dateTime);
-		now.set(Calendar.MILLISECOND, 0);
-		now.set(Calendar.SECOND, 0);
-		now.set(Calendar.MINUTE, 0);
-		now.set(Calendar.HOUR_OF_DAY, 17);
-		Date start = new Calendar.Builder()
-				.setDate(now.get(Calendar.YEAR), now.get(Calendar.MONTH), now.get(Calendar.DAY_OF_MONTH) - 1)
-				.setTimeOfDay(17, 0, 0, 0).build().getTime();
-		// 统计从指定日期前一天的17点到指定日期17点的数据,算作改日期数据
-		return res().data(reportService.insertDailyReports(start, now.getTime()));
-	}
-	/**
-	 * 客户营销统计表
-	 * @param depId
-	 * @param type
-	 * @return
-	 */
-	@RequestMapping(value = "/sales/marketingStatistics", method = RequestMethod.GET)
-	public Result marketingStatistics(String depId,Integer type) {
-		Result res=new Result();
-		
-		if (null==type||type>1) {
-			 res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "参数错误", "参数"));
-	            return res;
-		}
-		if (Integer.valueOf(type)==0) {
-			return res.data(reportService.marketingStatistics(depId));
-		}else {
-			return res.data(reportService.marketingDepStatistics(depId));
-		}
-	}
-	/**
-	 * 客户营销统计表(总计)
-	 * @param depId
-	 * @param type
-	 * @return
-	 */
-	@RequestMapping(value = "/sales/countMarketingStatistics", method = RequestMethod.GET)
-	public Result countMarketingStatistics(String depId,Integer type) {
-		Result res=new Result();
-		
-		if (null==type||type>1) {
-			 res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "参数错误", "参数"));
-	            return res;
-		}
-		if (Integer.valueOf(type)==0) {
-			return res.data(reportService.countMarketingStatistics(depId));
-		}else {
-			return res.data(reportService.countMarketingDepStatistics(depId));
-		}
-	}
-	
-	/**
-	 * 客户营销时段统计表
-	 * @param depId
-	 * @param type
-	 * @return
-	 */
-	@RequestMapping(value = "/sales/sometimeMarketingStatistics", method = RequestMethod.GET)
-	public Result sometimeMarketingStatistics(String depId,Integer timeType,Integer type,String startTime,String endTime) {
-		Result res=new Result();
-		if (null==type||type>1) {
-			 res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "参数错误", "参数"));
-	            return res;
-		}
-		if (null==timeType||timeType>4) {
-			 res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "日期类型参数参数错误", "日期类型参数"));
-	            return res;
-	    }
-	   if (timeType==4&&null==startTime&&null==endTime) {
-			 res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "日期类型参数参数错误", "日期类型参数"));
-	            return res;
-		}
-		if (Integer.valueOf(type)==0) {
-			return res.data(reportService.sometimeMarketingStatistics(depId,timeType,startTime,endTime));
-		}else {
-			return res.data(reportService.sometimeMarketingDepStatistics(depId,timeType,startTime,endTime));
-		}
-	}
-	/**
-	 * 客户营销时段统计表(总计)
-	 * @param depId
-	 * @param type
-	 * @return
-	 */
-	@RequestMapping(value = "/sales/countsometimeMarketingStatistics", method = RequestMethod.GET)
-	public Result countsometimeMarketingStatistics(String depId,Integer timeType,Integer type,String startTime,String endTime) {
-		Result res=new Result();
-		if (null==type||type>TimeType.WEEKLY.getCode()) {
-			 res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "参数错误", "参数"));
-	            return res;
-		}
-		if (null==timeType||timeType>TimeType.ZS.getCode()) {
-			 res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "日期类型参数参数错误", "日期类型参数"));
-	            return res;
-	    }
-	   if (timeType==TimeType.ZS.getCode()&&null==startTime&&null==endTime) {
-			 res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "日期类型参数参数错误", "日期类型参数"));
-	            return res;
-		}
-	  return res.data(reportService.countSometimeMarketingStatistics(depId,timeType,startTime,endTime));
-		
-	}
-	/**
-	 * 技术部派单报表统计
-	 */
-	@RequestMapping(value="/technicalDepStatistics" , method=RequestMethod.GET)
-	public Result technicalDepStatistics(String depId,Integer timeType,String startTime,String endTime,String publishStatus,String taskStatus){
-		Result res=new Result();
-		if (null==timeType||timeType>TimeType.ZS.getCode()) {
-			 res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "日期类型参数参数错误", "日期类型参数"));
-	            return res;
-	    }
-	   if (timeType==TimeType.ZS.getCode()&&null==startTime&&null==endTime) {
-			 res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "日期类型参数参数错误", "日期类型参数"));
-	            return res;
-		}
-	   return res.data(reportService.technicalDepStatistics(depId,timeType,startTime,endTime,publishStatus,taskStatus));
-		
-	}
-	
-
-}
+package com.goafanti.report.controller;
+
+import java.util.Calendar;
+import java.util.Date;
+
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
+
+import com.goafanti.common.bo.Result;
+import com.goafanti.common.constant.AFTConstants;
+import com.goafanti.common.constant.ErrorConstants;
+import com.goafanti.common.controller.BaseApiController;
+import com.goafanti.common.utils.DateUtils;
+import com.goafanti.report.enums.OrderBy;
+import com.goafanti.report.enums.SalesReportOrderField;
+import com.goafanti.report.enums.TimeType;
+import com.goafanti.report.service.SalesReportServiceImpl;
+
+@RestController
+@RequestMapping(value = "/api/admin/report")
+public class ReportApiController extends BaseApiController {
+	@Autowired
+	SalesReportServiceImpl reportService;
+
+	@RequestMapping(value = "/sales/personal", method = RequestMethod.GET)
+	public Result personal(@RequestParam(required = false) String orderField,
+			@RequestParam(required = false) String order, @RequestParam(required = false) String pSize,
+			@RequestParam(required = false) String pNo, @RequestParam(required = false) String date,
+			@RequestParam(required = false) String depName, @RequestParam(required = false) String name,
+			@RequestParam(required = false) String position) {
+		Date startTime = null;
+		try {
+			startTime = StringUtils.isNotBlank(date) ? DateUtils.parseDate(date, AFTConstants.YYYYMMDDHHMMSS)
+					: new Date();
+		} catch (Exception e) {
+			startTime = new Date();
+		}
+		if (StringUtils.isBlank(depName)) {
+			depName = null;
+		}
+		if (StringUtils.isBlank(name)) {
+			name = null;
+		}
+		if (StringUtils.isBlank(position)) {
+			position = null;
+		}
+		Integer pageSize = StringUtils.isBlank(pSize) ? null : handlePageSize(pSize);
+		Integer pageNo = StringUtils.isBlank(pNo) ? null : handlePageNo(pNo);
+		if (pageSize != null && pageNo != null) {
+			pageNo = (pageNo - 1) * pageSize;
+		}
+		return res().data(reportService.getPersonSalesReports(SalesReportOrderField.getField(orderField),
+				OrderBy.getField(order), pageSize, pageNo, startTime, depName, name, position));
+	}
+
+	@RequestMapping(value = "/sales/total", method = RequestMethod.GET)
+	public Result total(String date, @RequestParam(required = false) String depName,
+			@RequestParam(required = false) String name, @RequestParam(required = false) String position) {
+		Date startTime = null;
+		try {
+			startTime = DateUtils.parseDate(date, AFTConstants.YYYYMMDDHHMMSS);
+		} catch (Exception e) {
+			startTime = new Date();
+		}
+		if (StringUtils.isBlank(depName)) {
+			depName = null;
+		}
+		if (StringUtils.isBlank(name)) {
+			name = null;
+		}
+		if (StringUtils.isBlank(position)) {
+			position = null;
+		}
+		return res().data(reportService.getReportTotal(startTime, depName, name, position));
+	}
+
+	@RequestMapping(value = "/sales/department", method = RequestMethod.GET)
+	public Result department(String date) {
+		Date startTime = null;
+		try {
+			startTime = DateUtils.parseDate(date, AFTConstants.YYYYMMDDHHMMSS);
+		} catch (Exception e) {
+			startTime = new Date();
+		}
+		return res().data(reportService.getDepartmentSalesReports(startTime));
+	}
+
+	@RequestMapping(value = "/sales/doStatistics", method = RequestMethod.GET)
+	public Result doStatistics(String date) {
+		Date dateTime = null;
+		try {
+			dateTime = DateUtils.parseDate(date, AFTConstants.YYYYMMDDHHMMSS);
+		} catch (Exception e) {
+			dateTime = new Date();
+		}
+		Calendar now = Calendar.getInstance();
+		now.setTime(dateTime);
+		now.set(Calendar.MILLISECOND, 0);
+		now.set(Calendar.SECOND, 0);
+		now.set(Calendar.MINUTE, 0);
+		now.set(Calendar.HOUR_OF_DAY, 17);
+		Date start = new Calendar.Builder()
+				.setDate(now.get(Calendar.YEAR), now.get(Calendar.MONTH), now.get(Calendar.DAY_OF_MONTH) - 1)
+				.setTimeOfDay(17, 0, 0, 0).build().getTime();
+		// 统计从指定日期前一天的17点到指定日期17点的数据,算作改日期数据
+		return res().data(reportService.insertDailyReports(start, now.getTime()));
+	}
+	/**
+	 * 客户营销统计表
+	 * @param depId
+	 * @param type
+	 * @return
+	 */
+	@RequestMapping(value = "/sales/marketingStatistics", method = RequestMethod.GET)
+	public Result marketingStatistics(String depId,Integer type) {
+		Result res=new Result();
+		
+		if (null==type||type>1) {
+			 res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "参数错误", "参数"));
+	            return res;
+		}
+		if (Integer.valueOf(type)==0) {
+			return res.data(reportService.marketingStatistics(depId));
+		}else {
+			return res.data(reportService.marketingDepStatistics(depId));
+		}
+	}
+	/**
+	 * 客户营销统计表(总计)
+	 * @param depId
+	 * @param type
+	 * @return
+	 */
+	@RequestMapping(value = "/sales/countMarketingStatistics", method = RequestMethod.GET)
+	public Result countMarketingStatistics(String depId,Integer type) {
+		Result res=new Result();
+		
+		if (null==type||type>1) {
+			 res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "参数错误", "参数"));
+	            return res;
+		}
+		if (Integer.valueOf(type)==0) {
+			return res.data(reportService.countMarketingStatistics(depId));
+		}else {
+			return res.data(reportService.countMarketingDepStatistics(depId));
+		}
+	}
+	
+	/**
+	 * 客户营销时段统计表
+	 * @param depId
+	 * @param type
+	 * @return
+	 */
+	@RequestMapping(value = "/sales/sometimeMarketingStatistics", method = RequestMethod.GET)
+	public Result sometimeMarketingStatistics(String depId,Integer timeType,Integer type,String startTime,String endTime) {
+		Result res=new Result();
+		if (null==type||type>1) {
+			 res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "参数错误", "参数"));
+	            return res;
+		}
+		if (null==timeType||timeType>4) {
+			 res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "日期类型参数参数错误", "日期类型参数"));
+	            return res;
+	    }
+	   if (timeType==4&&null==startTime&&null==endTime) {
+			 res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "日期类型参数参数错误", "日期类型参数"));
+	            return res;
+		}
+		if (Integer.valueOf(type)==0) {
+			return res.data(reportService.sometimeMarketingStatistics(depId,timeType,startTime,endTime));
+		}else {
+			return res.data(reportService.sometimeMarketingDepStatistics(depId,timeType,startTime,endTime));
+		}
+	}
+	/**
+	 * 客户营销时段统计表(总计)
+	 * @param depId
+	 * @param type
+	 * @return
+	 */
+	@RequestMapping(value = "/sales/countsometimeMarketingStatistics", method = RequestMethod.GET)
+	public Result countsometimeMarketingStatistics(String depId,Integer timeType,Integer type,String startTime,String endTime) {
+		Result res=new Result();
+		if (null==type||type>TimeType.ZS.getCode()) {
+			 res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "参数错误", "参数"));
+	            return res;
+		}
+		if (null==timeType||timeType>TimeType.ZS.getCode()) {
+			 res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "日期类型参数参数错误", "日期类型参数"));
+	            return res;
+	    }
+	   if (timeType==TimeType.ZS.getCode()&&null==startTime&&null==endTime) {
+			 res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "日期类型参数参数错误", "日期类型参数"));
+	            return res;
+		}
+	  return res.data(reportService.countSometimeMarketingStatistics(depId,timeType,startTime,endTime));
+		
+	}
+	/**
+	 * 技术部派单报表统计
+	 */
+	@RequestMapping(value="/technicalDepStatistics" , method=RequestMethod.GET)
+	public Result technicalDepStatistics(String depId,Integer timeType,String startTime,String endTime,String publishStatus,String taskStatus){
+		Result res=new Result();
+		if (null==timeType||timeType>TimeType.ZS.getCode()) {
+			 res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "日期类型参数参数错误", "日期类型参数"));
+	            return res;
+	    }
+	   if (timeType==TimeType.ZS.getCode()&&null==startTime&&null==endTime) {
+			 res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "日期类型参数参数错误", "日期类型参数"));
+	            return res;
+		}
+	   return res.data(reportService.technicalDepStatistics(depId,timeType,startTime,endTime,publishStatus,taskStatus));
+		
+	}
+	
+
+}

+ 38 - 13
src/main/java/com/goafanti/techproject/service/impl/TechProjectServiceImpl.java

@@ -50,6 +50,8 @@ import com.goafanti.common.utils.StringUtils;
 import com.goafanti.core.mybatis.BaseMybatisDao;
 import com.goafanti.core.mybatis.page.Pagination;
 import com.goafanti.core.shiro.token.TokenManager;
+import com.goafanti.order.bo.BillListBo;
+import com.goafanti.order.bo.ServiceOrderDetailBo;
 import com.goafanti.order.enums.CommodityType;
 import com.goafanti.order.enums.ProjectStage;
 import com.goafanti.order.enums.PublicStatus;
@@ -439,23 +441,36 @@ public class TechProjectServiceImpl extends BaseMybatisDao<TechProjectMapper> im
 		contractTaskLogMapper.insert(c);*/
 		//contractTaskMapper.updateByPrimaryKeySelective(task);
 		Admin a=adminMapper.selectByPrimaryKey(task.getTaskReceiver());
-		TaskDetailBo tb= contractTaskMapper.selectProjectTaskDetail(task.getId());
+		Admin ad=null;
 		String regex = "^(1[1-9][0-9])\\d{8}$";
-		 Pattern p = Pattern.compile(regex);
-		  SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+		Pattern p = Pattern.compile(regex);
+		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+		TaskDetailBo tb= contractTaskMapper.selectProjectTaskDetail(task.getId());
+		String mobile = "";
+		if (null!=tb&&tb.getOrderNo()!=null) {
+			ServiceOrderDetailBo t=tOrderMapper.selectServiceOrderDetail(tb.getOrderNo());
+			System.out.println(t.getSalesmanId());
+			if (null!=t&&t.getSalesmanId()!=null) {
+				ad=adminMapper.selectByPrimaryKey(t.getSalesmanId());
+				Matcher s1 = p.matcher(ad.getContactMobile());
+				if (s1.matches()) {
+					mobile=ad.getContactMobile();
+				}
+			}
+		}
 		if (null!=a&&null!=a.getContactMobile()) {
 			Matcher m = p.matcher(a.getContactMobile());
 			if ( m.matches()) {
-			String mobile=a.getContactMobile();
-			String paramString = "{\"number\":\"" + tb.getOrderNo() 
-			+ "\",\"operator\":\"" + TokenManager.getAdminToken().getName()
-			+ "\",\"time\":\"" +   sdf.format(new Date())
-			+ "\",\"name\":\"" +  tb.getBuyerName()
-			+ "\",\"type\":\"" +  OrderFlowState.RWPD.getDesc() +
-			"\"}";
-			MobileMessageUtils.sendMessage(mobileRemindCodeTemplate, paramString, mobile, accessKey, accessSecret);
+			mobile=mobile+","+a.getContactMobile();
 				}
 			}
+		String paramString = "{\"number\":\"" + tb.getOrderNo() 
+		+ "\",\"operator\":\"" + TokenManager.getAdminToken().getName()
+		+ "\",\"time\":\"" +   sdf.format(new Date())
+		+ "\",\"name\":\"" +  tb.getBuyerName()
+		+ "\",\"type\":\"" +  OrderFlowState.RWPD.getDesc() +
+		"\"}";
+		MobileMessageUtils.sendMessage(mobileRemindCodeTemplate, paramString, mobile, accessKey, accessSecret);
 		return contractTaskMapper.updateByPrimaryKeySelective(task);
 	}
 
@@ -585,13 +600,23 @@ public class TechProjectServiceImpl extends BaseMybatisDao<TechProjectMapper> im
 			String regex = "^(1[1-9][0-9])\\d{8}$";
 			 Pattern p = Pattern.compile(regex);
 			 String mobile="";
+			 if (null!=t&&t.getOrderNo()!=null) {
+					TOrder tb=tOrderMapper.selectByPrimaryKey(t.getOrderNo());
+					if (null!=tb&&tb.getSalesmanId()!=null) {
+						Admin ad=adminMapper.selectByPrimaryKey(tb.getSalesmanId());
+						Matcher s1 = p.matcher(ad.getContactMobile() );
+						if(s1.matches()){
+							mobile=ad.getContactMobile();
+						}
+					}
+				}
 			if (null!=a.getContactMobile()) {
 				Matcher m = p.matcher(a.getContactMobile());
 			if ( m.matches()) {
-				mobile=a.getContactMobile();
-				sendMessage(t.getOrderNo(),mobile,OrderFlowState.RWPD.getDesc());
+				mobile=mobile+","+a.getContactMobile();
 				}
 			}
+			sendMessage(t.getOrderNo(),mobile,OrderFlowState.RWPD.getDesc());
 			return setTaskDistribution(task.getContractId());
 			
 		}

+ 3 - 3
src/main/java/com/goafanti/user/bo/InputOrgBasicInfo.java

@@ -136,7 +136,7 @@ public class InputOrgBasicInfo {
 	 */
 	@Max(value = 9, message = "{" + ErrorConstants.PARAM_ERROR + "}")
 	@Min(value = 0, message = "{" + ErrorConstants.PARAM_ERROR + "}")
-	private Integer		enterpriseScale;
+	private String		enterpriseScale;
 
 	/**
 	 * 注册类型
@@ -403,11 +403,11 @@ public class InputOrgBasicInfo {
 		this.industry = industry;
 	}
 
-	public Integer getEnterpriseScale() {
+	public String getEnterpriseScale() {
 		return enterpriseScale;
 	}
 
-	public void setEnterpriseScale(Integer enterpriseScale) {
+	public void setEnterpriseScale(String enterpriseScale) {
 		this.enterpriseScale = enterpriseScale;
 	}
 

+ 4 - 4
src/main/java/com/goafanti/user/bo/OrgBasicInfoBo.java

@@ -109,7 +109,7 @@ public class OrgBasicInfoBo {
 	/**
 	 * 企业规模(注册资金)
 	 */
-	private Integer		enterpriseScale;
+	private String		enterpriseScale;
 
 	/**
 	 * 注册类型
@@ -355,12 +355,12 @@ public class OrgBasicInfoBo {
 		this.industry = industry;
 	}
 
-	@JsonFormat(shape = Shape.STRING)
-	public Integer getEnterpriseScale() {
+	
+	public String getEnterpriseScale() {
 		return enterpriseScale;
 	}
 
-	public void setEnterpriseScale(Integer enterpriseScale) {
+	public void setEnterpriseScale(String enterpriseScale) {
 		this.enterpriseScale = enterpriseScale;
 	}