| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028 |
- package com.goafanti.customer.controller;
- import java.io.IOException;
- import java.lang.reflect.InvocationTargetException;
- import java.text.DateFormat;
- import java.text.ParseException;
- import java.text.SimpleDateFormat;
- import java.util.ArrayList;
- import java.util.Date;
- import java.util.List;
- import java.util.Set;
- import java.util.TreeSet;
- import javax.annotation.Resource;
- import javax.servlet.http.HttpServletRequest;
- import javax.servlet.http.HttpServletResponse;
- import org.springframework.beans.factory.annotation.Value;
- 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.admin.service.AdminService;
- import com.goafanti.admin.service.AftFileService;
- import com.goafanti.common.bo.Error;
- 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.error.BusinessException;
- import com.goafanti.common.model.AftFile;
- import com.goafanti.common.model.OrganizationContactBook;
- import com.goafanti.common.model.User;
- import com.goafanti.common.utils.BeanUtilsExt;
- import com.goafanti.common.utils.DateUtils;
- import com.goafanti.common.utils.ExcelUtils;
- import com.goafanti.common.utils.StringUtils;
- import com.goafanti.core.shiro.token.TokenManager;
- import com.goafanti.customer.bo.BusinessListBo;
- import com.goafanti.customer.bo.BussinessFollowBo;
- import com.goafanti.customer.bo.CustomerExcelBo;
- import com.goafanti.customer.bo.CustomerListIn;
- import com.goafanti.customer.bo.CustomerListOut;
- import com.goafanti.customer.bo.CustomerOrganizationDetailBo;
- import com.goafanti.customer.bo.CustomerPersonalDetailBo;
- import com.goafanti.customer.bo.FollowBusinessBo;
- import com.goafanti.customer.bo.UserDetailBo;
- import com.goafanti.customer.service.CustomerService;
- @RestController
- @RequestMapping("/open/api/admin/customer")
- public class AdminCustomerApiController extends BaseApiController{
- @Resource
- private CustomerService customerService;
- @Resource
- private AftFileService aftFileService;
- @Value(value = "${upload.private.path}")
- private String uploadPrivatePath = null;
- @Resource
- private AdminService adminService;
- /** 私有个人客户列表 **/
- @RequestMapping(value = "/listPrivatePersonalCustomer" , method = RequestMethod.POST)
- public Result listPrivatePersonalCustomer(CustomerListIn cli,Integer pageNo, Integer pageSize){
- Result res = new Result();
- res.setData(customerService.listPrivatePersonalCustomer(cli, pageNo, pageSize));
- return res;
- }
-
- /** 公共个人客户列表 **/
- @RequestMapping(value = "/listPublicPersonalCustomer" , method = RequestMethod.POST)
- public Result listPublicPersonalCustomer(CustomerListIn cli,Integer pageNo, Integer pageSize){
- Result res = new Result();
- res.setData(customerService.listPublicPersonalCustomer(cli, pageNo, pageSize));
- return res;
- }
- /** 个人客户查询 **/
- @RequestMapping(value = "/listAllPersonalCustomer" , method = RequestMethod.POST)
- public Result listAllPersonalCustomer(CustomerListIn cli,Integer pageNo, Integer pageSize){
- Result res = new Result();
- res.setData(customerService.listAllPersonalCustomer(cli, pageNo, pageSize));
- return res;
- }
-
- /** 管理个人客户查询 **/
- @RequestMapping(value = "/listAllManagePersonalCustomer" , method = RequestMethod.POST)
- public Result listAllManagePersonalCustomer(CustomerListIn cli,Integer pageNo, Integer pageSize){
- Result res = new Result();
- if (!TokenManager.hasRole(AFTConstants.SUPERADMIN) && !TokenManager.hasRole(AFTConstants.APPROVAL_DECISION)){
- cli.setAid(TokenManager.getAdminId());
- }
- res.setData(customerService.listAllManagePersonalCustomer(cli, pageNo, pageSize));
- return res;
- }
-
- /** 专家查询 **/
- @RequestMapping(value = "/listExpertCustomer" , method = RequestMethod.POST)
- public Result listExpertCustomer(CustomerListIn cli,Integer pageNo, Integer pageSize){
- Result res = new Result();
- res.setData(customerService.listAllManagePersonalCustomer(cli, pageNo, pageSize));
- return res;
- }
-
- /** 私有单位客户列表 **/
- @RequestMapping(value = "/listPrivateOrganizationCustomer" , method = RequestMethod.POST)
- public Result listPrivateOrganizationCustomer(CustomerListIn cli,Integer pageNo, Integer pageSize){
- Result res = new Result();
- res.setData(customerService.listPrivateOrganizationCustomer(cli, pageNo, pageSize));
- return res;
- }
-
- /** 公共单位客户列表 **/
- @RequestMapping(value = "/listPublicOrganizationCustomer" , method = RequestMethod.POST)
- public Result listPublicOrganizationCustomer(CustomerListIn cli,Integer pageNo, Integer pageSize){
- Result res = new Result();
- res.setData(customerService.listPublicOrganizationCustomer(cli, pageNo, pageSize));
- return res;
- }
- /** 单位客户查询 **/
- @RequestMapping(value = "/listAllOrganizationCustomer" , method = RequestMethod.POST)
- public Result listAllOrganizationCustomer(CustomerListIn cli,Integer pageNo, Integer pageSize){
- Result res = new Result();
- res.setData(customerService.listAllOrganizationCustomer(cli, pageNo, pageSize));
- return res;
- }
-
- /** 管理单位客户查询 **/
- @RequestMapping(value = "/listAllManageOrganizationCustomer" , method = RequestMethod.POST)
- public Result listAllManageOrganizationCustomer(CustomerListIn cli,Integer pageNo, Integer pageSize){
- Result res = new Result();
- res.setData(customerService.listAllManageOrganizationCustomer(cli, pageNo, pageSize));
- return res;
- }
-
- /** 签单的单位客户 **/
- @RequestMapping(value = "/listSignOrganizationCustomer", method = RequestMethod.POST)
- public Result listSignOrganizationCustomer(CustomerListIn cli,Integer pageNo, Integer pageSize){
- Result res = new Result();
- res.setData(customerService.listSignOrganizationCustomer(cli, pageNo, pageSize));
- return res;
- }
-
- /** 签单的个人客户 **/
- @RequestMapping(value = "/listSignPersonalCustomer", method = RequestMethod.POST)
- public Result listSignPersonalCustomer(CustomerListIn cli,Integer pageNo, Integer pageSize){
- Result res = new Result();
- res.setData(customerService.listSignPersonalCustomer(cli, pageNo, pageSize));
- return res;
- }
-
- /** 客户即时检索 **/
- @RequestMapping(value = "/findCustomerByName",method = RequestMethod.GET)
- public Result findCustomerByName(String name){
- Result res = new Result();
- res.setData(customerService.findCustomerByName(name));
- return res;
- }
-
- /** 客户即时检索(可签单客户) **/
- @RequestMapping(value = "/getCustomerByName",method = RequestMethod.GET)
- public Result getCustomerByName(String name,Integer type){
- Result res = new Result();
- if(type == null){
- res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, ""));
- return res;
- }
- if(name.length()<2) return res;
- if(type == 0) res.setData(customerService.getPrivateCustomerByName(name));
- if(type == 1) res.setData(customerService.getSignedCustomerByName(name));
- return res;
- }
-
- /** 添加客户基本信息
- * @throws Exception
- * @throws NumberFormatException **/
- @RequestMapping(value = "/addCustomer", method = RequestMethod.POST)
- public Result addCustomer(String name,String contacts,String contactMobile,Integer type,
- Integer province ,Integer city, Integer area,Integer source,String societyTag) throws Exception{
- Result res = new Result();
- if(StringUtils.isBlank(name) || StringUtils.isBlank(contacts)
- || StringUtils.isBlank(contactMobile) || StringUtils.isBlank(societyTag)||null==province||null==city||null==area){
- res.getError().add(buildError("","客户名称、联系人、联系电话、社会性质、地址不能为空"));
- return res;
- }
- customerService.addCustomer(name, contacts, contactMobile,type,source,societyTag,province,city,area);
- return res;
- }
-
- /** 个人客户详情信息 **/
- @RequestMapping(value = "/findPersonalCustomerDetail" ,method = RequestMethod.GET)
- public Result findPersonalCustomerDetail(String uid){
- Result res = new Result();
- res.setData(customerService.findPersonalCustomerDetail(uid));
- return res;
- }
-
- /** 单位客户详情信息 **/
- @RequestMapping(value = "/findOrganizationCustomerDetail", method = RequestMethod.GET)
- public Result findOrganizationCustomerDetail(String uid){
- Result res = new Result();
- res.setData(customerService.findOrganizationCustomerDetail(uid));
- return res;
- }
-
- /** 修改单位客户信息 **/
- @RequestMapping(value = "/updateOrganizationCustomer", method = RequestMethod.POST)
- public Result updateOrganizationCustomer(CustomerOrganizationDetailBo bo){
- Result res = new Result();
- if(StringUtils.isBlank(bo.getId()) || StringUtils.isBlank(bo.getUid())){
- res.getError().add(buildError(ErrorConstants.PARAM_ERROR,""));
- return res;
- }
- customerService.updateOrganizationCustomer(bo);
- return res;
- }
-
- /** 修改个人客户信息 **/
- @RequestMapping(value = "/updatePersonalCustomer", method = RequestMethod.POST)
- public Result updatePersonalCustomer(CustomerPersonalDetailBo bo){
- Result res = new Result();
- if(StringUtils.isBlank(bo.getUid()) || StringUtils.isBlank(bo.getId())){
- res.getError().add(buildError(ErrorConstants.PARAM_ERROR,""));
- return res;
- }
- customerService.updatePersonalCustomer(bo);
- return res;
- }
-
- /** 查看跟进记录 **/
- @RequestMapping(value = "/listFollowHistory", method = RequestMethod.GET)
- public Result listFollowHistory(Integer pageNo, Integer pageSize,String uid,String businessProjectId){
- Result res = new Result();
- res.setData(customerService.listFollowHistory(pageNo,pageSize,uid,businessProjectId));
- return res;
- }
-
- /** 查看客户账户信息 **/
- @RequestMapping(value = "/findUserAccountDetail", method = RequestMethod.GET)
- public Result findUserAcountDetail(String uid){
- Result res = new Result();
- UserDetailBo bo = new UserDetailBo();
- User user = customerService.findUserAccountDetail(uid);
- try {
- BeanUtilsExt.copyProperties(bo, user);
- } catch (InvocationTargetException | IllegalAccessException e) {
- e.printStackTrace();
- }
- SimpleDateFormat format = new SimpleDateFormat(AFTConstants.YYYYMMDDHHMMSS);
- bo.setCreateTimes(format.format(user.getCreateTime()));
- res.setData(bo);
- return res;
- }
-
- /** 修改客户账户信息 **/
- @RequestMapping(value = "/updateUserAccount", method = RequestMethod.POST)
- public Result updateUserAccount(User user){
- Result res = new Result();
- customerService.updateUserAccount(user);
- return res;
- }
- /** 查看客户联系人列表 **/
- @RequestMapping(value = "/findCustomerContacts", method = RequestMethod.GET)
- public Result findCustomerContacts(String uid){
- Result res = new Result();
- res.setData(customerService.findCustomerContacts(uid));
- return res;
- }
-
- /** 针对已作拜访的业务作跟进 **/
- @RequestMapping(value = "/toAddFollowOnHistory", method = RequestMethod.GET)
- public Result toAddFollowOnHistory(String uid){
- Result res = new Result();
- if(StringUtils.isBlank(uid)){
- res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,""));
- return res;
- }
- User user = customerService.findUserAccountDetail(uid);
- FollowBusinessBo fbb = new FollowBusinessBo();
- SimpleDateFormat format = new SimpleDateFormat(AFTConstants.YYYYMMDDHHMMSS);
- fbb.setFollowTime(format.format(new Date()));
- fbb.setIdentifyName(user.getIdentifyName());
- fbb.setUid(uid);
- fbb.setUserBusinessList(customerService.findBusinessByUAid(uid, TokenManager.getAdminId()));
- res.setData(fbb);
- return res;
- }
-
- /** 针对已锁定的业务作跟进 **/
- @RequestMapping(value = "/toAddFollowOnLock", method = RequestMethod.GET)
- public Result toAddFollowOnLock(String uid){
- Result res = new Result();
- if(StringUtils.isBlank(uid)){
- res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,""));
- return res;
- }
- User user = customerService.findUserAccountDetail(uid);
- FollowBusinessBo fbb = new FollowBusinessBo();
- SimpleDateFormat format = new SimpleDateFormat(AFTConstants.YYYYMMDDHHMMSS);
- fbb.setFollowTime(format.format(new Date()));
- fbb.setIdentifyName(user.getIdentifyName());
- fbb.setUid(uid);
- fbb.setUserBusinessList(customerService.findLockedBusinessByUAid(uid, TokenManager.getAdminId()));
- res.setData(fbb);
- return res;
- }
-
- /** 添加拜访记录
- * @throws ParseException
- * @throws Exception **/
- @RequestMapping(value = "/addFollow", method = RequestMethod.POST)
- public Result addFollow(String userBusinessList,String uid,String ocbId,String contactType,String result,String followTime) throws BusinessException{
- Result res = new Result();
- if(StringUtils.isBlank(uid) || StringUtils.isBlank(ocbId)){
- res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, ""));
- return res;
- }
- 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);
- for(BusinessListBo ub:list){
- if(ub.getBusinessProjectId() == userBusiness.getBusinessProjectId()){
- res.getError().add(new com.goafanti.common.bo.Error("业务类型重复,请检查后重新提交!"));
- return res;
- }
- }
- list.add(userBusiness);
- }
- }
- FollowBusinessBo fbb = new FollowBusinessBo();
- fbb.setOcbId(ocbId);
- fbb.setUid(uid);
- fbb.setContactType(contactType);
- fbb.setResult(result);
- fbb.setFollowTime(followTime);
- fbb.setUserBusinessList(list);
- customerService.addFollow(fbb);
- return res;
- }
-
- /** 进入修改拜访记录 **/
- @RequestMapping(value = "/toUpdateFollow", method = RequestMethod.GET)
- public Result toUpdateFollow(String followId){
- Result res = new Result();
- FollowBusinessBo fbb = customerService.findFollowById(followId);
- fbb.setUserBusinessList(customerService.findBusinessByFollowId(followId));
- res.setData(fbb);
- return res;
- }
-
- /** 修改拜访记录
- * @throws ParseException
- * @throws BusinessException
- */
- @RequestMapping(value = "/updateFollow", method = RequestMethod.POST)
- public Result updateFollow(String userBusinessList,String followId,String followTime,String uid,String contactType,String result) throws BusinessException{
- Result res = new Result();
- if(StringUtils.isBlank(uid) || StringUtils.isBlank(followId)){
- res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, ""));
- return res;
- }
- 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);
- for(BusinessListBo ub:list){
- if(ub.getBusinessProjectId() == userBusiness.getBusinessProjectId()){
- res.getError().add(new com.goafanti.common.bo.Error("业务类型重复,请检查后重新提交!"));
- return res;
- }
- }
- list.add(userBusiness);
- }
- }
- FollowBusinessBo fbb = new FollowBusinessBo();
- fbb.setFollowTime(followTime);
- fbb.setUid(uid);
- fbb.setContactType(contactType);
- fbb.setResult(result);
- fbb.setUserBusinessList(list);
- fbb.setFollowId(followId);
- customerService.updateFollow(fbb);
- return res;
- }
-
- /** 删除跟进记录 **/
- @RequestMapping(value = "/deleteFollow", method = RequestMethod.GET)
- public Result deleteFollow(String followId){
- Result res = new Result();
- if(StringUtils.isBlank(followId)){
- res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, ""));
- return res;
- }
- customerService.deleteFollow(followId);
- return res;
- }
-
- /** 查询客户的所有联系人 **/
- @RequestMapping(value = "/findAllContacts", method = RequestMethod.GET)
- public Result findAllContacts(String uid){
- Result res = new Result();
- res.setData(customerService.findAllContacts(uid));
- return res;
- }
-
- /** 修改企业联系人 **/
- @RequestMapping(value = "/updateCustomerContacts", method = RequestMethod.POST)
- public Result updateCustomerContacts(String contactList,String uid){
- Result res = new Result();
- if(StringUtils.isBlank(uid)){
- res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, ""));
- return res;
- }
- JSONArray ja = (JSONArray) JSON.parse(contactList);
- List<OrganizationContactBook> ocbList = new ArrayList<OrganizationContactBook>();
- OrganizationContactBook ocb = null;
- if(ja != null & !ja.isEmpty()){
- for (int idx = 0; idx < ja.size(); idx++) {
- ocb = ja.getJSONObject(idx).toJavaObject(OrganizationContactBook.class);
- if(StringUtils.isBlank(ocb.getMobile()) || StringUtils.isBlank(ocb.getName())){
- res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "用户名和手机号码为必填"));
- return res;
- }
- if(StringUtils.isBlank(ocb.getUid())) ocb.setUid(uid);
- ocbList.add(ocb);
- }
- }
- customerService.updateCustomerContacts(ocbList,uid);
- return res;
- }
-
- /** 领取客户 **/
- @RequestMapping(value = "/receiveCustomer", method = RequestMethod.GET)
- public Result receiveCustomer(String uid,String oldAid){
- Result res = new Result();
- if(StringUtils.isBlank(uid) || StringUtils.isBlank("oldAid")){
- res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, ""));
- return res;
- }
- customerService.updateByOperatorType(uid, oldAid,AFTConstants.USER_RECEIVE);
- return res;
- }
- /** 删除客户 **/
- @RequestMapping(value = "/deleteCustomer", method = RequestMethod.GET)
- public Result deleteCustomer(String uid,String oldAid){
- Result res = new Result();
- if(StringUtils.isBlank(uid) || StringUtils.isBlank("aid")){
- res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, ""));
- return res;
- }
- customerService.updateByOperatorType(uid, oldAid,AFTConstants.USER_DELETE);
- return res;
- }
-
- /**
- * 上传excel文档
- * @param req
- * @return
- */
- @RequestMapping(value = "/uploadExcel",method = RequestMethod.POST)
- public Result uploadExcel(HttpServletRequest req){
- Result res = new Result();
- String excelPath = handleFile(res, "/customer_sys_file/", true, req, "");
- ExcelUtils utils = new ExcelUtils();
- Set<CustomerExcelBo> boSet;
- try {
- boSet = utils.parseExcel(uploadPrivatePath + excelPath);
- String errorMessage = "";
- if(boSet.size()>100) errorMessage += "导入数据不能超过一百条;";
- errorMessage += utils.getVacantRows();
- if(StringUtils.isNotBlank(errorMessage)) {
- res.getError().add(new Error(errorMessage));
- return res;
- }
- Set<Integer> existRows = new TreeSet<Integer>(); //数据库已存在
- Set<Integer> filterRows = new TreeSet<Integer>(); //过滤提示
- customerService.checkCustomer(boSet,existRows,filterRows);
- if(existRows.size()>0){
- errorMessage = StringUtils.join(existRows.toArray(),",")+ " 行客户业务已存在;";
- res.getError().add(new Error(errorMessage));
- return res;
- }
- if(filterRows.size()>0){
- errorMessage = StringUtils.join(filterRows.toArray(),",")+ " 行已经被系统过滤;";
- res.getError().add(new Error(errorMessage));
- return res;
- }
- customerService.saveUploadData(boSet);
- } catch (IOException e) {
- e.printStackTrace();
- }
- return res;
- }
- /**
- * 下载科技成果批量导入Excel模板
- */
- @RequestMapping(value = "/downloadTemplate", method = RequestMethod.GET)
- public Result downloadTemplateFile(HttpServletResponse response,String type) {
- Result res = new Result();
- if(AFTConstants.USER_TYPE_ORGANIZATION.equals(type)){
- AftFile af = aftFileService.selectAftFileBySign("organization_customer_template");
- if (null == af) {
- res.getError().add(buildError(ErrorConstants.FILE_NON_EXISTENT, "", "找不到文件!"));
- } else {
- String path = af.getFilePath();
- String suffix = path.substring(path.lastIndexOf("."));
- String fileName = af.getFileName() + suffix;
- downloadFile(response, fileName, path);
- }
- }else if(AFTConstants.USER_TYPE_PERSONAL.equals(type)){
- AftFile af = aftFileService.selectAftFileBySign("personal_customer_template");
- if (null == af) {
- res.getError().add(buildError(ErrorConstants.FILE_NON_EXISTENT, "", "找不到文件!"));
- } else {
- String path = af.getFilePath();
- String suffix = path.substring(path.lastIndexOf("."));
- String fileName = af.getFileName() + suffix;
- downloadFile(response, fileName, path);
- }
- }
- return res;
- }
-
- /** 转为公共客户 **/
- @RequestMapping(value = "/transferToPublic", method = RequestMethod.GET)
- public Result transferToPublic(String uid,String aid){
- Result res = new Result();
- if(StringUtils.isBlank(uid) || StringUtils.isBlank("aid")){
- res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, ""));
- }
- customerService.updateByOperatorType(uid, aid, AFTConstants.USER_TRANSFER_TO_PUBLIC);
- return res;
- }
-
- /** 图片上传 **/
- @RequestMapping(value = "/uploadCustomerImg", method = RequestMethod.POST)
- public Result uploadCustomerImg(HttpServletRequest req,String sign){
- Result res = new Result();
- res.setData(handleFile(res, "/customer_sys_file/", false, req, sign));
- return res;
- }
-
- /**
- *
- * @param startDate 开始日期
- * @param endDate 结束日期
- * @param timeSpan 时间差
- * @param depId 部门编号
- * @param pageNo 页码
- * @param pageSize 页数
- * @return
- * @throws ParseException
- */
- @RequestMapping(value = "/customerStatistics",method = RequestMethod.GET)
- public Result customerStatistics(String startDate,String endDate,String timeSpan,String depNo,String businessGlossoryId,Integer pageNo, Integer pageSize) throws ParseException{
- Result res = new Result();
- Date sDate = null;
- Date eDate = null;
- DateFormat format = new SimpleDateFormat(AFTConstants.YYYYMMDD);
- if(StringUtils.isNotBlank(startDate)) sDate = format.parse(startDate);
- if(StringUtils.isNotBlank(endDate)) eDate = format.parse(endDate);
- if(StringUtils.isBlank(startDate)&&StringUtils.isBlank(endDate)){
- Date date = new Date();
- if(timeSpan.equals(DateUtils.DAY_SPAN)){
- sDate = DateUtils.getYesterday();
- }else if(timeSpan.equals(DateUtils.WEEK_SPAN)){
- sDate = DateUtils.getLastDayOfLastWeek(date);
- }else if(timeSpan.equals(DateUtils.MONTH_SPAN)){
- sDate = DateUtils.getLastDayOfLastMonth(date);
- }else if(timeSpan.equals(DateUtils.QUARTER_SPAN)){
- sDate = DateUtils.getLastDayOfLastQuarter(date);
- }else if(timeSpan.equals(DateUtils.YEAR_SPAN)){
- sDate = DateUtils.getLastDayOfLastYear(date);
- }
- }
- res.setData(customerService.customerStatistics(sDate,eDate,depNo,businessGlossoryId,pageNo,pageSize));
- return res;
- }
-
- /**
- *
- * @param startDate 开始日期
- * @param endDate 结束日期
- * @param timeSpan 时间差
- * @param depId 部门编号
- * @param businessGlossoryId 业务编号
- * @param pageNo 页码
- * @param pageSiz 页数
- * @return
- * @throws ParseException
- */
- @RequestMapping(value = "/businessStatistic", method = RequestMethod.GET)
- public Result businessStatistic(String startDate,String endDate,String timeSpan,String depNo,String businessGlossoryId,Integer pageNo, Integer pageSize) throws ParseException{
- Result res = new Result();
- Date sDate = null;
- Date eDate = null;
- DateFormat format = new SimpleDateFormat(AFTConstants.YYYYMMDD);
- if(StringUtils.isNotBlank(startDate)) sDate = format.parse(startDate);
- if(StringUtils.isNotBlank(endDate)) eDate = format.parse(endDate);
- if(StringUtils.isBlank(startDate)&&StringUtils.isBlank(endDate)){
- Date date = new Date();
- if(timeSpan.equals(DateUtils.DAY_SPAN)){
- sDate = DateUtils.getYesterday();
- }else if(timeSpan.equals(DateUtils.WEEK_SPAN)){
- sDate = DateUtils.getLastDayOfLastWeek(date);
- }else if(timeSpan.equals(DateUtils.MONTH_SPAN)){
- sDate = DateUtils.getLastDayOfLastMonth(date);
- }else if(timeSpan.equals(DateUtils.QUARTER_SPAN)){
- sDate = DateUtils.getLastDayOfLastQuarter(date);
- }else if(timeSpan.equals(DateUtils.YEAR_SPAN)){
- sDate = DateUtils.getLastDayOfLastYear(date);
- }
- }
- res.setData(customerService.businessStatistic(sDate,eDate,depNo,businessGlossoryId,pageNo,pageSize));
- return res;
- }
-
- /**
- *
- * @param startDate 开始日期
- * @param endDate 结束日期
- * @param timeSpan 时间差
- * @param depId 部门编号
- * @param businessGlossoryId 业务编号
- * @param pageNo 页码
- * @param pageSiz 页数
- * @return
- * @throws ParseException
- */
- @RequestMapping(value = "/followStatistic",method = RequestMethod.GET)
- public Result followStatistic(String startDate,String endDate,String timeSpan,String depNo,Integer pageNo, Integer pageSize) throws ParseException{
- Result res = new Result();
- Date sDate = null;
- Date eDate = null;
- DateFormat format = new SimpleDateFormat(AFTConstants.YYYYMMDD);
- if(StringUtils.isNotBlank(startDate)) sDate = format.parse(startDate);
- if(StringUtils.isNotBlank(endDate)) eDate = format.parse(endDate);
- if(StringUtils.isBlank(startDate)&&StringUtils.isBlank(endDate)){
- Date date = new Date();
- if(timeSpan.equals(DateUtils.DAY_SPAN)){
- sDate = DateUtils.getYesterday();
- }else if(timeSpan.equals(DateUtils.WEEK_SPAN)){
- sDate = DateUtils.getLastDayOfLastWeek(date);
- }else if(timeSpan.equals(DateUtils.MONTH_SPAN)){
- sDate = DateUtils.getLastDayOfLastMonth(date);
- }else if(timeSpan.equals(DateUtils.QUARTER_SPAN)){
- sDate = DateUtils.getLastDayOfLastQuarter(date);
- }else if(timeSpan.equals(DateUtils.YEAR_SPAN)){
- sDate = DateUtils.getLastDayOfLastYear(date);
- }
- }
- res.setData(customerService.followStatistic(sDate, eDate, depNo, pageNo, pageSize));
- return res;
- }
-
- /** 管理员列表 **/
- @RequestMapping(value = "/listAdminByName",method = RequestMethod.GET)
- public Result listAdminByName(String adminName){
- Result res = new Result();
- if(StringUtils.isNotBlank(adminName))res.setData(adminService.listAdminByName(adminName));
- return res;
- }
-
- /** 转交客户到制定人 **/
- @RequestMapping(value = "/transferToOther", method = RequestMethod.GET)
- public Result transferToOther(String uid,String aid,String oldAid){
- Result res = new Result();
- if(StringUtils.isBlank(uid) || StringUtils.isBlank(aid)){
- res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "客户编号或管理员编号"));
- return res;
- }
- customerService.updateByOperatorType(uid,oldAid,AFTConstants.USER_TRANSFER_TO_OTHER, aid);
- return res;
- }
-
- /** 查询我的业务列表 **/
- @RequestMapping(value = "/listBusiness", method = RequestMethod.POST)
- public Result listBusiness(BusinessListBo blo,Integer pageNo, Integer pageSize){
- Result res = new Result();
- res.setData(customerService.listBusiness(blo, pageNo, pageSize));
- return res;
- }
-
- /** 查询所有的业务列表 **/
- @RequestMapping(value = "/listAllBusiness", method = RequestMethod.POST)
- public Result listAllBusiness(BusinessListBo blo,Integer pageNo, Integer pageSize){
- Result res = new Result();
- res.setData(customerService.listAllBusiness(blo, pageNo, pageSize));
- return res;
- }
-
- /** 业务管理列表 **/
- @RequestMapping(value = "/listManageBusiness", method = RequestMethod.POST)
- public Result listManageBusiness(BusinessListBo blo,Integer pageNo, Integer pageSize){
- Result res = new Result();
- res.setData(customerService.listManageBusiness(blo, pageNo, pageSize));
- return res;
- }
-
- /** 查询业务字典 **/
- @RequestMapping(value = "/findBusinessGlossory",method = RequestMethod.GET)
- public Result findBusinessGlossory(){
- Result res = new Result();
- res.setData(customerService.findBusinessGlossory());
- return res;
- }
- /** 新增客户意向 **/
- @RequestMapping(value = "/addBusinessAndFollow", method = RequestMethod.POST)
- public Result addBusinessAndFollow(BussinessFollowBo bfb){
- Result res = new Result();
- if(StringUtils.isBlank(bfb.getBusinessProjectId()) || StringUtils.isBlank(bfb.getUid())){
- res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,""));
- return res;
- }
- if(customerService.judgeBusiness(bfb.getUid(), bfb.getBusinessProjectId())>0){
- res.getError().add(new Error("该项业务已经被跟进"));
- return res;
- }
- try {
- customerService.addBusinessAndFollow(bfb);
- } catch (ParseException e) {
- e.printStackTrace();
- }
- return res;
- }
-
- /** 进入新增意向服务 **/
- @RequestMapping(value = "/toAddBusinessAndFollow", method = RequestMethod.GET)
- public Result toAddBusinessAndFollow(){
- Result res = new Result();
- BussinessFollowBo bo = new BussinessFollowBo();
- bo.setAdminName(TokenManager.getAdminToken().getName());
- SimpleDateFormat format = new SimpleDateFormat(AFTConstants.YYYYMMDDHHMMSS);
- bo.setCreateTime(format.format(new Date()));
- bo.setFollowTime(bo.getCreateTime());
- res.setData(bo);
- return res;
- }
-
- /** 进入修改业务意向 **/
- @RequestMapping(value = "/toUpdateBusiness", method = RequestMethod.GET)
- public Result toUpdateBusiness(String businessId){
- Result res = new Result();
- res.setData(customerService.findBusinessDetail(businessId));
- return res;
- }
-
- /** 修改业务意向 **/
- @RequestMapping(value = "/updateBusiness", method = RequestMethod.POST)
- public Result updateBusiness(BussinessFollowBo bfb){
- Result res = new Result();
- customerService.updateBusiness(bfb);
- return res;
- }
-
- /** 进入跟进单个客户意向 **/
- @RequestMapping(value = "/toAddFollowOneBusiness", method = RequestMethod.GET)
- public Result toAddFollowOneBusiness(String businessId){
- Result res = new Result();
- BussinessFollowBo bo = customerService.findBusinessDetail(businessId);
- SimpleDateFormat format = new SimpleDateFormat(AFTConstants.YYYYMMDDHHMMSS);
- bo.setFollowTime(format.format(new Date()));
- res.setData(bo);
- return res;
- }
-
- /** 跟进单个客户意向 **/
- @RequestMapping(value = "/addFollowOneBusiness", method = RequestMethod.POST)
- public Result addFollowOneBusiness(BussinessFollowBo bfb){
- Result res = new Result();
- if(StringUtils.isBlank(bfb.getBusinessId()) ||
- StringUtils.isBlank(bfb.getUid()) || StringUtils.isBlank(bfb.getOcbId())){
- res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, ""));
- return res;
- }
- try {
- customerService.addFollowOneBusiness(bfb);
- } catch (ParseException e) {
- e.printStackTrace();
- }
- return res;
- }
-
- /** 进入修改某个客户一个业务的当次拜访 **/
- @RequestMapping(value = "/toUpdateFollowOneBusiness", method = RequestMethod.GET)
- public Result toUpdateFollowOneBusiness(String ufbId){
- Result res = new Result();
- if(StringUtils.isBlank(ufbId)) {
- res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,""));
- return res;
- }
- res.setData(customerService.findFollowOneBusiness(ufbId));
- return res;
- }
-
- /** 修改某个客户一个业务的当次拜访 **/
- @RequestMapping(value = "/updateFollowOneBusiness", method = RequestMethod.POST)
- public Result updateFollowOneBusiness(BussinessFollowBo bfb){
- Result res = new Result();
- if(StringUtils.isBlank(bfb.getFollowId()) || StringUtils.isBlank(bfb.getUfbId())){
- res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,""));
- return res;
- }
- customerService.updateFollowOneBusiness(bfb);
- return res;
- }
-
- /** 删除某个客户一个业务的当次拜访 **/
- @RequestMapping(value = "/deleteFollowOneBusiness", method = RequestMethod.GET)
- public Result deleteFollowOneBusiness(String ufbId){
- Result res = new Result();
- if(StringUtils.isBlank(ufbId)){
- res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,""));
- return res;
- }
- customerService.deleteFollowOneBusiness(ufbId);
- return res;
- }
-
- /** 添加单个联系人 **/
- @RequestMapping(value = "/addOneContact", method = RequestMethod.POST)
- public Result addOneContact(OrganizationContactBook ocb){
- Result res = new Result();
- if(StringUtils.isBlank(ocb.getUid())){
- res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,""));
- return res;
- }
- if(StringUtils.isBlank(ocb.getName()) || StringUtils.isBlank(ocb.getMobile())){
- res.getError().add(buildError("联系人号码和联系人姓名不能为空"));
- return res;
- }
- customerService.addOneContact(ocb);
- return res;
- }
-
- /** 删除单个联系人 **/
- @RequestMapping(value = "/deleteOneContact", method = RequestMethod.GET)
- public Result deleteOneContact(String ocbId){
- Result res = new Result();
- if(StringUtils.isBlank(ocbId)){
- res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,""));
- return res;
- }
- customerService.deleteOneContact(ocbId);
- return res;
- }
-
- /** 修改主要联系人 **/
- @RequestMapping(value = "/updateMainContact", method = RequestMethod.GET)
- public Result updateMainContact(String ocbId,String uid){
- Result res = new Result();
- if(StringUtils.isBlank(uid) || StringUtils.isBlank(ocbId)){
- res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,""));
- return res;
- }
- customerService.updateMainContact(ocbId,uid);
- return res;
- }
-
- /** 删除 业务 **/
- @RequestMapping(value = "/deleteBusiness", method =RequestMethod.GET)
- public Result deleteBusiness(String businessId){
- Result res = new Result();
- if(StringUtils.isBlank(businessId)){
- res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,""));
- return res;
- }
- customerService.deleteBusiness(businessId);
- return res;
- }
-
- /** 停止业务 **/
- @RequestMapping(value = "/stopBusiness", method = RequestMethod.GET)
- public Result stopBusiness(String businessId){
- Result res = new Result();
- if(StringUtils.isBlank(businessId)){
- res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,""));
- return res;
- }
- customerService.updateBusinessToStop(businessId);
- return res;
- }
-
- /** 客户分配查询(本部门) **/
- @RequestMapping(value = "/findAdminName" , method = RequestMethod.POST)
- public Result findAdminName(){
- Result res = new Result();
- res.setData(customerService.findAdminName());
- return res;
- }
-
- /** 分配个人客户 **/
- @RequestMapping(value = "/updatePersonalCustomerz", method = RequestMethod.POST)
- public Result updatePersonalCustomerz(CustomerPersonalDetailBo bo){
- Result res = new Result();
- if(StringUtils.isBlank(bo.getUid()) || StringUtils.isBlank(bo.getId())){
- res.getError().add(buildError(ErrorConstants.PARAM_ERROR,""));
- return res;
- }
- customerService.updatePersonalCustomerz(bo);
- return res;
- }
-
- /** 客户录入审核 **/
- @RequestMapping(value = "/findEnteringAudit" , method = RequestMethod.POST)
- public Result findEnteringAudit(CustomerListOut clo,Integer pageNo, Integer pageSize){
- Result res = new Result();
- res.setData(customerService.findEnteringAudit(clo, pageNo, pageSize));
- return res;
- }
-
- /** 修改客户录入审核状态 **/
- @RequestMapping(value = "/updateEnteringAudit", method = RequestMethod.POST)
- public Result updateEnteringAudit(User bo){
- Result res = new Result();
- if(StringUtils.isBlank(bo.getId())){
- res.getError().add(buildError(ErrorConstants.PARAM_ERROR,""));
- return res;
- }
- res.data(customerService.updateEnteringAudit(bo));
- return res;
- }
-
- /** 审核拒绝客户查询 **/
- @RequestMapping(value = "/findEnteringAuditIsNo" , method = RequestMethod.POST)
- public Result findEnteringAuditIsNo(CustomerListOut clo,Integer pageNo, Integer pageSize){
- Result res = new Result();
- res.setData(customerService.findEnteringAuditIsNo(clo, pageNo, pageSize));
- return res;
- }
-
- /** 修改拒绝客户信息 **/
- @RequestMapping(value = "/updateRefusedCustomer", method = RequestMethod.POST)
- public Result updateRefusedCustomer(String id,String nickname,String mobile,String societyTag){
- Result res = new Result();
- if(StringUtils.isBlank(nickname)){
- res.getError().add(buildError(ErrorConstants.PARAM_ERROR,"名称"));
- return res;
- }
- if(StringUtils.isBlank(mobile)){
- res.getError().add(buildError(ErrorConstants.PARAM_ERROR,"电话"));
- return res;
- }
- if(StringUtils.isBlank(societyTag)){
- res.getError().add(buildError(ErrorConstants.PARAM_ERROR,"社会性质"));
- return res;
- }
- customerService.updateRefusedCustomer(id, nickname, mobile, societyTag);
- return res;
- }
- /** 查询客户的锁定业务 **/
- @RequestMapping(value = "/getLockedProject", method = RequestMethod.GET)
- public Result getLockedProject(String uid){
- Result res = new Result();
- if(StringUtils.isBlank(uid)){
- res.getError().add(buildError(ErrorConstants.PARAM_ERROR,"用户ID"));
- return res;
- }
- res.setData(customerService.selectLockedProject(uid));
- return res;
- }
-
-
- /** 客户二次签项目业务 **/
- @RequestMapping(value = "/againProjectTask", method = RequestMethod.GET)
- public Result againProjectTask(String uid,String projectId,String aid){
- Result res = new Result();
- if(StringUtils.isBlank(uid)||StringUtils.isBlank(projectId)){
- res.getError().add(buildError(ErrorConstants.PARAM_ERROR,"参数"));
- return res;
- }
- res.setData(customerService.updateAgainProjectTask(uid,projectId,aid));
- return res;
- }
- /** 客户资料转交 **/
- @RequestMapping(value = "/updateInformationMaintainerr", method = RequestMethod.POST)
- public Result updateInformationMaintainerr(String id,String aid){
- Result res = new Result();
- if(StringUtils.isBlank(id) || StringUtils.isBlank(aid)){
- res.getError().add(buildError(ErrorConstants.PARAM_ERROR,""));
- return res;
- }
- res.data(customerService.updateInformationMaintainerr(id,aid));
- return res;
- }
- /** 个人单位客户信息列表 **/
- @RequestMapping(value = "/listCustomerInformation", method = RequestMethod.POST)
- public Result listCustomerInformation(CustomerListIn cli,Integer pageNo, Integer pageSize){
- Result res = new Result();
- res.data(customerService.listCustomerInformation(cli,pageNo,pageSize));
- return res;
- }
- /** 部门单位客户信息列表 **/
- @RequestMapping(value = "/listDepCustomerInformation", method = RequestMethod.POST)
- public Result listDepCustomerInformation(CustomerListIn cli,Integer pageNo, Integer pageSize){
- Result res = new Result();
- res.data(customerService.listDepCustomerInformation(cli,pageNo,pageSize));
- return res;
- }
- /** 修改客户等级 **/
- @RequestMapping(value = "/updateUserLevel", method = RequestMethod.GET)
- public Result updateUserLevel(User u){
- Result res = new Result();
- if(StringUtils.isBlank(u.getId())){
- res.getError().add(buildError(ErrorConstants.PARAM_ERROR,"用户ID错误","用户ID"));
- return res;
- }
- if(null==u.getLevel()){
- res.getError().add(buildError(ErrorConstants.PARAM_ERROR,"用户等级错误","用户等级"));
- return res;
- }
- res.data(customerService.updateUserLevel(u));
- return res;
- }
- }
|