Browse Source

Merge remote-tracking branch 'origin/dev' into test

anderx 6 years ago
parent
commit
dd6a9a816d

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

@@ -1,6 +1,7 @@
 package com.goafanti.common.dao;
 
 import java.util.List;
+import java.util.Map;
 
 import org.apache.ibatis.annotations.Param;
 
@@ -15,6 +16,7 @@ import com.goafanti.user.bo.UserPageHomeBo;
 import com.goafanti.user.bo.UserPartnerDetailBo;
 import com.goafanti.common.model.UserExample;
 import com.goafanti.customer.bo.BusinessListBo;
+import com.goafanti.customer.bo.CustomerListOut;
 import com.goafanti.customer.bo.CustomerOrganizationDetailBo;
 import com.goafanti.customer.bo.CustomerPersonalDetailBo;
 import com.goafanti.customer.bo.CustomerSimpleBo;
@@ -248,5 +250,7 @@ public interface UserMapper {
 	int UserReceiveCount( @Param("aid")String aid);
 
 	int getAidAndUser(@Param("uid")String uid,@Param("aid") String aid);
+
+	 List<CustomerListOut> privateUnitCustomerList(@Param("params")Map<String, Object> params);
 	
 }

+ 50 - 3
src/main/java/com/goafanti/common/mapper/PatentNewMapper.xml

@@ -475,17 +475,39 @@
   </update>
   
   <select id="selectPatentNewList" resultType="com.goafanti.patent.bo.PatentNewBo">
-	  select a.id,a.patent_no as patentNo,a.name,a.type,a.status,
+	  	  select a.id,a.patent_no as patentNo,a.name,a.type,a.status,
 	  date_format(a.apply_date,'%Y-%m-%d') as applyDates,
 	  date_format(a.authorization_date ,'%Y-%m-%d ')as authorizationDates,a.patent_amount as patentAmount,a.province,
 	a.applicant,a.contact_mobile as contactMobile,a.email,a.certificate_url as certificateUrl,
-	date_format(a.create_time,'%Y-%m-%d %H:%I:%S') as createTimeS,a.apply_date as applyDate,
+	date_format(a.create_time,'%Y-%m-%d %H:%I:%S') as createTimeS,a.apply_date as applyDate,c.name depName,
 	date_format(a.update_time,'%Y-%m-%d %H:%I:%S') as updateTimeS,b.name as aname
 	from patent_new a left join admin b on a.aid=b.id
+	left join department c on b.department_id=c.id
 	where 1=1
  	<if test="aid != null">
      and  a.aid = #{aid,jdbcType=VARCHAR}
     </if>
+    <if test="status != null">
+     and a.status=#{status}
+     </if>
+       <if test="type != null">
+     and a.type=#{type}
+     </if>
+     <if test="startDate != null and endDate != null">
+     and a.apply_date between  #{startDate} and  #{endDate}
+     </if>
+     <if test="name != null">
+     and a.applicant  like concat('%',#{name},'%')
+     </if>
+     <if test="patentNo != null">
+     and a.patent_no like concat('%',#{patentNo},'%')
+     </if>
+     <if test="aname != null">
+     and b.name like concat('%',#{aname},'%')
+     </if>
+     <if test="departmentId != null">
+     and b.department_id= #{departmentId}
+     </if>
 	order by status ,applyDate
 	<if test="page_sql!=null">
 			${page_sql}
@@ -493,7 +515,32 @@
   </select>
     <select id="selectPatentNewCount" resultType="java.lang.Integer">
 	  select count(*)
-	from patent_new a
+	from patent_new a left join admin b on a.aid=b.id
+	where 1=1
+	<if test="aid != null">
+     and  a.aid = #{aid,jdbcType=VARCHAR}
+    </if>
+    <if test="status != null">
+     and a.status=#{status}
+     </if>
+     <if test="type != null">
+     and a.type=#{type}
+     </if>
+    <if test="startDate != null and endDate != null">
+     and a.apply_date between  #{startDate} and  #{endDate}
+     </if>
+     <if test="name != null">
+     and a.applicant  like concat('%',#{name},'%')
+     </if>
+     <if test="patentNo != null">
+     and a.patent_no like concat('%',#{patentNo},'%')
+     </if>
+     <if test="aname != null">
+     and b.name like concat('%',#{aname},'%')
+     </if>
+     <if test="departmentId != null">
+     and b.department_id= #{departmentId}
+     </if>
 	where 1=1
 	<if test="aid != null">
 	     and  a.aid = #{aid,jdbcType=VARCHAR}

+ 69 - 0
src/main/java/com/goafanti/common/mapper/UserMapperExt.xml

@@ -1981,4 +1981,73 @@ inner join(
 		and share_type=0
 		and to_days(transfer_time)=to_days(now())
 	</select>
+	
+	
+	<select id="privateUnitCustomerList" parameterType="Map" resultType="com.goafanti.customer.bo.CustomerListOut">
+		select 	t0.id as uid,
+			   	t0.aid,
+			  	date_format(t0.transfer_time,'%Y-%m-%d %H:%i:%S') as transferTime,
+			  	date_format(t0.create_time,'%Y-%m-%d %H:%i:%S') as createTime,
+			   	t0.identify_name as name,
+			   	t0.society_tag as societyTag,
+			   	t0.level,
+			   	date_format(t1.last_follow_time,'%Y-%m-%d %H:%i:%S') as lastFollowTime,
+			   	date_format(t2.last_sign_time,'%Y-%m-%d %H:%i:%S') as lastSignTime,
+				b.contacts,
+				b.contact_mobile as contactMobile,
+				dg1.name as province,
+				dg2.name as city, 
+				dg3.name as area,
+				c.name as industry,
+				if(t0.transfer_time &lt; t1.last_follow_time,t1.last_follow_time,t0.transfer_time) as orderTime,
+				d.name as adminName
+		from 
+			(select id,aid,type,share_type,transfer_time,create_time,identify_name,society_tag,level from user where aid = #{params.aid} and type = 1 and share_type = 0 and status != 1)t0
+		left join 
+			(select uid,aid,max(create_time) as last_follow_time from user_follow where aid = #{params.aid} group by uid)t1
+		on t0.id = t1.uid left join 
+			(select aid,uid,max(lock_time) as last_sign_time from user_lock_release  where aid = #{params.aid} group by uid)t2
+		on t0.id = t2.uid
+		left join organization_identity b on t0.id = b.uid 
+		left join district_glossory dg1 on b.location_province = dg1.id
+		left join district_glossory dg2 on b.location_city = dg2.id
+		left join district_glossory dg3 on b.location_area = dg3.id
+		left join industry_category c on b.industry = c.id
+		left join admin d on t0.aid = d.id where 1=1
+		<if test="params != null">
+			<if test="params.aid != null and params.aid !=''">
+				and t0.aid = #{params.aid,jdbcType=VARCHAR}
+			</if>
+			<if test="params.name != null and params.name != ''">
+				and t0.identify_name like concat('%',#{params.name},'%')
+			</if>
+			<if test="params.startDate != null and params.startDate != ''">
+				and t0.transfer_time &gt; #{params.startDate}
+			</if>
+			<if test="params.endDate != null and params.endDate != ''">
+				and t0.transfer_time &lt; #{params.endDate}
+			</if>
+			<if test="params.province != null">
+				and b.location_province = #{params.province,jdbcType=INTEGER}
+			</if>
+			<if test="params.city != null">
+				and b.location_city = #{params.city,jdbcType=INTEGER}
+			</if>
+			<if test="params.area != null">
+				and b.location_area = #{params.area,jdbcType=INTEGER}
+			</if>
+			<if test="params.level != null">
+				and t0.level = #{params.level,jdbcType=INTEGER}
+			</if>
+			
+		 </if>
+			   order by orderTime 
+			
+			<if test="params!=null and params.sort == 1"> 
+			 order by t0.create_time 
+			 </if>
+			 <if test="params != null and params.sortType == 1">
+			 		desc
+			 </if>
+	</select>
 </mapper>

+ 67 - 1
src/main/java/com/goafanti/common/utils/ExportExcelUtil.java

@@ -22,6 +22,7 @@ import org.apache.poi.xssf.usermodel.XSSFSheet;
 import org.apache.poi.xssf.usermodel.XSSFWorkbook;
 
 import com.goafanti.common.model.TOrderBillNew;
+import com.goafanti.customer.bo.CustomerListOut;
 import com.goafanti.order.bo.OrderReportBo;
 import com.goafanti.order.bo.TOrderBonusBo;
 import com.goafanti.order.bo.TOrderNewBo;
@@ -650,5 +651,70 @@ public class ExportExcelUtil {
 		}
 		return wb;
 	}
-	
+
+	public static XSSFWorkbook exportSelectPrivateOrganizationCustomer(List<CustomerListOut> list, String[] comment,
+			String filePath) {
+		//map 数据 comment表头 (列名称)
+ 		//1,创建一个workbook,对应的是一个excel文件
+		XSSFWorkbook wb = new XSSFWorkbook();
+		//2.创建一个sheet
+			XSSFSheet sheet = wb.createSheet();
+			//创建表头
+			XSSFCellStyle style1 = setCellStyle1(wb);
+			XSSFRow row = sheet.createRow(0);
+			for(int i = 0; i < comment.length; i++){
+				sheet.autoSizeColumn(i);  
+				sheet.autoSizeColumn(i, true);
+				sheet.setColumnWidth(i, 3000);//设置列宽
+				XSSFCell c = row.createCell(i);
+				c.setCellValue(comment[i]);
+				c.setCellStyle(style1);
+			}
+			for (CustomerListOut ob : list) {
+				//新增一行
+				XSSFRow r = sheet.createRow(sheet.getLastRowNum()+1);
+				for (int i = 0; i < comment.length; i++) {
+					//当前列的只
+					String o="" ;
+					switch (comment[i]) {
+					//"客户名称","地区","联系人","联系电话","社会性质","客户初始时间","剩余私有天数","最新跟进时间","客户等级"
+					case "客户名称": o = ob.getName();  break;
+					case "地区": o = ob.getProvince()+"-"+ob.getCity()+"-"+ob.getArea(); break;//
+					case "联系人": o = ob.getContacts(); break;
+					case "联系电话": o = ob.getContactMobile();break;
+					case "社会性质": o = getSocietyTagName(ob.getSocietyTag());break;
+					case "客户初始时间": o = ob.getCreateTime();break;
+					case "剩余私有天数": o = ob.getSurplusFollowTime();break;
+					case "最新跟进时间": o = ob.getLastSignTime();break;
+					case "客户等级": o = getLevelName(ob.getLevel());break;//
+					default: o = ""; break;
+					}
+					XSSFCell c = r.createCell(i);
+					c.setCellValue(o);
+				}
+			}
+		return wb;
+	}
+	private static String getLevelName(Integer s){
+		if(s==null)return "";
+		if(s.equals(0))return "一般客户";
+		if(s.equals(1))return "意向客户";
+		if(s.equals(2))return "重点客户";
+		return "";
+	}
+	private static String getSocietyTagName(String  s){
+		if(s==null)return "";
+		if(s.equals("0"))return "社会企业";
+		if(s.equals("1"))return "科研单位";
+		if(s.equals("2"))return "高等院校";
+		if(s.equals("3"))return "科研专家";
+		if(s.equals("4"))return "科技达人";
+		if(s.equals("5"))return "服务机构";
+		if(s.equals("6"))return "政府部门";
+		if(s.equals("7"))return "商会";
+		if(s.equals("8"))return "协会";
+		if(s.equals("9"))return "其他组织";
+		if(s.equals("10"))return "其他个人";
+		return "";
+	}
 }

+ 9 - 8
src/main/java/com/goafanti/customer/bo/CustomerListIn.java

@@ -57,7 +57,7 @@ public class CustomerListIn {
 	
 	private String departmentId;
 
-	private String level;
+	private Integer level;
 	
 	private String follow;
 	
@@ -218,13 +218,6 @@ public class CustomerListIn {
 		this.departmentId = departmentId;
 	}
 
-	public String getLevel() {
-		return level;
-	}
-
-	public void setLevel(String level) {
-		this.level = level;
-	}
 
 	public String getFollow() {
 		return follow;
@@ -241,4 +234,12 @@ public class CustomerListIn {
 	public void setIname(String iname) {
 		this.iname = iname;
 	}
+
+	public Integer getLevel() {
+		return level;
+	}
+
+	public void setLevel(Integer level) {
+		this.level = level;
+	}
 }

+ 6 - 3
src/main/java/com/goafanti/customer/bo/CustomerListOut.java

@@ -50,7 +50,7 @@ public class CustomerListOut extends CustomerListIn{
 	
 	private String mid;
 	
-	private String level;
+	private Integer level;
 	
 	public String getAuditOpinion() {
 		return auditOpinion;
@@ -187,11 +187,14 @@ public class CustomerListOut extends CustomerListIn{
 		this.mid = mid;
 	}
 
-	public String getLevel() {
+	public Integer getLevel() {
 		return level;
 	}
 
-	public void setLevel(String level) {
+	public void setLevel(Integer level) {
 		this.level = level;
 	}
+
+	
+
 }

+ 34 - 0
src/main/java/com/goafanti/customer/controller/AdminCustomerApiController.java

@@ -1,6 +1,7 @@
 package com.goafanti.customer.controller;
 
 import java.io.IOException;
+import java.io.OutputStream;
 import java.lang.reflect.InvocationTargetException;
 import java.text.DateFormat;
 import java.text.ParseException;
@@ -14,6 +15,8 @@ import java.util.TreeSet;
 import javax.annotation.Resource;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
+
+import org.apache.poi.xssf.usermodel.XSSFWorkbook;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestMethod;
@@ -116,6 +119,37 @@ public class AdminCustomerApiController extends BaseApiController{
 		res.setData(customerService.listPrivateOrganizationCustomer(cli, sort, sortType, pageNo, pageSize));
 		return res;
 	}
+	/** 
+	 * 私有单位客户导出xls
+	 * @throws IOException 
+	 */
+	@RequestMapping(value = "/privateUnitCustomerOutXls" , method = RequestMethod.GET)
+	public Result privateUnitCustomerOutXls(CustomerListIn cli ,Integer sort,Integer sortType,Integer pageNo, Integer pageSize,HttpServletResponse response) throws IOException{
+		Result res = new Result();
+ 		
+ 		XSSFWorkbook wb = customerService.privateUnitCustomerOutXls(cli, sort, sortType, pageNo, pageSize);
+ 		 String fileName = "我的客户列表  " + new SimpleDateFormat("yyyy-MM-dd").format(new Date()) + ".xls";
+		 OutputStream out = null;
+		try {
+			out = response.getOutputStream();
+		} catch (IOException e) {
+			e.printStackTrace();
+		}
+		 response.addHeader("Content-Disposition", "attachment;filename="  + new String(fileName.getBytes(),"iso-8859-1"));  
+         response.setContentType("application/octet-stream;charset=utf-8");  
+		try {
+			// 返回数据流
+			wb.write(out);
+			out.flush();
+			out.close();
+		} finally {
+			out.flush();
+			out.close();
+		}
+		
+		return res;
+		
+	}
 	
 	/** 公共单位客户列表 **/
 	@RequestMapping(value = "/listPublicOrganizationCustomer" , method = RequestMethod.POST)

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

@@ -5,6 +5,10 @@ import java.util.Date;
 import java.util.List;
 import java.util.Set;
 
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.poi.xssf.usermodel.XSSFWorkbook;
+
 import com.goafanti.common.error.BusinessException;
 import com.goafanti.common.model.Admin;
 import com.goafanti.common.model.OrganizationContactBook;
@@ -502,6 +506,7 @@ public interface CustomerService {
 	List<LockingReleaseBo> selectPendinglockUserList();
 	int updateUserLevel(User u);
 	public  Float countIntegrity(CustomerOrganizationDetailBo bo);
+	XSSFWorkbook privateUnitCustomerOutXls(CustomerListIn cli ,Integer sort,Integer sortType,Integer pageNo, Integer pageSize);
 	
 	
 }

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

@@ -15,7 +15,9 @@ import javax.annotation.Resource;
 
 import org.apache.commons.beanutils.BeanUtils;
 import org.apache.commons.beanutils.PropertyUtils;
+import org.apache.poi.xssf.usermodel.XSSFWorkbook;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
@@ -55,6 +57,7 @@ import com.goafanti.common.model.UserIdentity;
 import com.goafanti.common.model.UserLockRelease;
 import com.goafanti.common.utils.BeanUtilsExt;
 import com.goafanti.common.utils.DateUtils;
+import com.goafanti.common.utils.ExportExcelUtil;
 import com.goafanti.common.utils.PasswordUtil;
 import com.goafanti.common.utils.StringUtils;
 import com.goafanti.core.mybatis.BaseMybatisDao;
@@ -73,9 +76,10 @@ import com.goafanti.customer.bo.FollowListBo;
 import com.goafanti.customer.bo.LockingReleaseBo;
 import com.goafanti.customer.bo.StatisticBo;
 import com.goafanti.customer.service.CustomerService;
+import com.goafanti.order.bo.TOrderTaskListBo;
 
 @Service
-public class CustomerServiceImpl  extends BaseMybatisDao<UserMapper> implements CustomerService {
+public class CustomerServiceImpl extends BaseMybatisDao<UserMapper> implements CustomerService {
 	@Autowired
 	private UserMapper userMapper;
 	@Autowired
@@ -106,6 +110,8 @@ public class CustomerServiceImpl  extends BaseMybatisDao<UserMapper> implements
 	private OrganizationAnnualReportMapper	organizationAnnualReportMapper;
 	@Resource
 	private OrganizationYearProjectMapper	organizationYearProjectMapper;
+	@Value(value = "${upload.path}")
+	private String 					uploadPath 			= null;
 	
 	
 	@SuppressWarnings("unchecked")
@@ -1453,4 +1459,24 @@ public class CustomerServiceImpl  extends BaseMybatisDao<UserMapper> implements
 	public int updateUserLevel(User u) {
 		return userMapper.updateByPrimaryKeySelective(u);
 	}
+
+	@Override
+	public XSSFWorkbook privateUnitCustomerOutXls(CustomerListIn cli, Integer sort, Integer sortType, Integer pageNo,
+			Integer pageSize) {
+		cli.setType(AFTConstants.USER_TYPE_ORGANIZATION);
+		cli.setAid(TokenManager.getAdminId());
+//		cli.setAid("1");
+		cli.setShareType(String.valueOf(AFTConstants.USER_SHARE_PRIVATE));
+		Map<String,Object> params = disposeParams(cli);
+		params.put("sort", sort);
+		params.put("sortType",sortType);
+		List<CustomerListOut> list= userMapper.privateUnitCustomerList(params);
+		if (list==null || list.size()==0) return null;
+		String[] comment = {"客户名称","地区","联系人","联系电话","社会性质","客户初始时间","剩余私有天数","最新跟进时间","客户等级"};
+		String filePath = uploadPath + "/privateUnitCustomer";
+		XSSFWorkbook wb = ExportExcelUtil.exportSelectPrivateOrganizationCustomer(list, comment, filePath);
+		return wb;
+	}
+
+
 }

+ 28 - 1
src/main/java/com/goafanti/patent/bo/PatentNewBo.java

@@ -1,6 +1,5 @@
 package com.goafanti.patent.bo;
 
-import java.util.Date;
 
 import com.goafanti.common.model.PatentNew;
 
@@ -8,8 +7,12 @@ public class PatentNewBo extends PatentNew{
 	private String applyDates;
 	private String authorizationDates;
 	private String aname;
+	private String depName;
 	private String createTimes;
 	private String updateTimes;
+	private String startDate;
+	private String endDate;
+	private String departmentId;
 	public String getApplyDates() {
 		return applyDates;
 	}
@@ -40,4 +43,28 @@ public class PatentNewBo extends PatentNew{
 	public void setUpdateTimes(String updateTimes) {
 		this.updateTimes = updateTimes;
 	}
+	public String getStartDate() {
+		return startDate;
+	}
+	public void setStartDate(String startDate) {
+		this.startDate = startDate;
+	}
+	public String getEndDate() {
+		return endDate;
+	}
+	public void setEndDate(String endDate) {
+		this.endDate = endDate;
+	}
+	public String getDepName() {
+		return depName;
+	}
+	public void setDepName(String depName) {
+		this.depName = depName;
+	}
+	public String getDepartmentId() {
+		return departmentId;
+	}
+	public void setDepartmentId(String departmentId) {
+		this.departmentId = departmentId;
+	}
 }

+ 2 - 2
src/main/java/com/goafanti/patent/controller/AdminPatentNewApiController.java

@@ -78,9 +78,9 @@ public class AdminPatentNewApiController extends CertifyApiController {
 	 * 专利列表
 	 */
 	@RequestMapping(value = "/selectPatentNew", method = RequestMethod.GET)
-	public Result selectPatentNew(Integer pageSize,Integer pageNo){
+	public Result selectPatentNew(PatentNewBo p,Integer pageSize,Integer pageNo){
 		Result res = new Result();
-		return res.data(patentNewService.selectPatentNew(pageSize,pageNo));
+		return res.data(patentNewService.selectPatentNew(p,pageSize,pageNo));
 	}
 	/** 证件上传 **/
 	@RequestMapping(value = "/uploadFile", method = RequestMethod.POST)

+ 1 - 1
src/main/java/com/goafanti/patent/service/PatentNewService.java

@@ -13,7 +13,7 @@ public interface PatentNewService {
 
 	int updatePatenNew(PatentNew p);
 
-	Pagination<PatentNewBo> selectPatentNew(Integer pageSize, Integer pageNo);
+	Pagination<PatentNewBo> selectPatentNew(PatentNewBo p,Integer pageSize, Integer pageNo);
 	
 	List<PatentNew> AllselectStartPatentNew();
 	

+ 11 - 2
src/main/java/com/goafanti/patent/service/impl/PatentNewServiceImpl.java

@@ -39,14 +39,23 @@ public class PatentNewServiceImpl  extends BaseMybatisDao<PatentNewMapper> imple
 
 	@SuppressWarnings("unchecked")
 	@Override
-	public Pagination<PatentNewBo> selectPatentNew(Integer pageSize, Integer pageNo) {
+	public Pagination<PatentNewBo> selectPatentNew(PatentNewBo p,Integer pageSize, Integer pageNo) {
 		Map<String, Object> params = new HashMap<>();
 		if (pageNo == null || pageNo < 0) pageNo = 1;
 		if (pageSize == null || pageSize < 0)	pageSize = 10;
+		if(p.getStatus()!=null)params.put("status", p.getStatus());
+		if(p.getName()!=null)params.put("name", p.getName());
+		if(p.getAname()!=null)params.put("aname", p.getAname());
+		if(p.getPatentNo()!=null)params.put("patentNo", p.getPatentNo());
+		if(p.getDepartmentId()!=null)params.put("departmentId", p.getDepartmentId());
+		if(p.getStartDate()!=null)params.put("startDate", p.getStartDate());
+		if(p.getEndDate()!=null)params.put("endDate", p.getEndDate());
+		if(p.getType()!=null)params.put("type", p.getType());
 		if (!TokenManager.hasRole(AFTConstants.SUPERADMIN) && !TokenManager.hasRole(AFTConstants.AUDITORADMIN)) {
 			params.put("aid", TokenManager.getAdminId());
+		}else {
+			params.put("aid", p.getAid());
 		}
-		
 		return (Pagination<PatentNewBo>) findPage("selectPatentNewList", "selectPatentNewCount", params, pageNo,
 				pageSize);
 	}