AdminCustomerApiController.java 46 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264
  1. package com.goafanti.customer.controller;
  2. import java.io.IOException;
  3. import java.io.OutputStream;
  4. import java.lang.reflect.InvocationTargetException;
  5. import java.text.DateFormat;
  6. import java.text.ParseException;
  7. import java.text.SimpleDateFormat;
  8. import java.util.ArrayList;
  9. import java.util.Calendar;
  10. import java.util.Date;
  11. import java.util.List;
  12. import java.util.Set;
  13. import java.util.TreeSet;
  14. import javax.annotation.Resource;
  15. import javax.servlet.http.HttpServletRequest;
  16. import javax.servlet.http.HttpServletResponse;
  17. import org.apache.poi.xssf.usermodel.XSSFWorkbook;
  18. import org.springframework.beans.factory.annotation.Value;
  19. import org.springframework.web.bind.annotation.RequestMapping;
  20. import org.springframework.web.bind.annotation.RequestMethod;
  21. import org.springframework.web.bind.annotation.RestController;
  22. import com.alibaba.fastjson.JSON;
  23. import com.alibaba.fastjson.JSONArray;
  24. import com.goafanti.admin.service.AdminService;
  25. import com.goafanti.admin.service.AttachmentService;
  26. import com.goafanti.common.bo.Error;
  27. import com.goafanti.common.bo.Result;
  28. import com.goafanti.common.constant.AFTConstants;
  29. import com.goafanti.common.constant.ErrorConstants;
  30. import com.goafanti.common.controller.BaseApiController;
  31. import com.goafanti.common.enums.AttachmentType;
  32. import com.goafanti.common.error.BusinessException;
  33. import com.goafanti.common.model.Attachment;
  34. import com.goafanti.common.model.OrganizationContactBook;
  35. import com.goafanti.common.model.User;
  36. import com.goafanti.common.utils.BeanUtilsExt;
  37. import com.goafanti.common.utils.DateUtils;
  38. import com.goafanti.common.utils.ExcelUtils;
  39. import com.goafanti.common.utils.SHA256Util;
  40. import com.goafanti.common.utils.StringUtils;
  41. import com.goafanti.core.shiro.token.TokenManager;
  42. import com.goafanti.customer.bo.BusinessListBo;
  43. import com.goafanti.customer.bo.BussinessFollowBo;
  44. import com.goafanti.customer.bo.CustomerExcelBo;
  45. import com.goafanti.customer.bo.CustomerListIn;
  46. import com.goafanti.customer.bo.CustomerListOut;
  47. import com.goafanti.customer.bo.CustomerOrganizationDetailBo;
  48. import com.goafanti.customer.bo.CustomerPersonalDetailBo;
  49. import com.goafanti.customer.bo.FollowBusinessBo;
  50. import com.goafanti.customer.bo.UserDetailBo;
  51. import com.goafanti.customer.service.CustomerService;
  52. import com.goafanti.customer.service.impl.AdminOrgAnnualReportServiceImpl;
  53. @RestController
  54. @RequestMapping("/api/admin/customer")
  55. public class AdminCustomerApiController extends BaseApiController{
  56. @Resource
  57. private CustomerService customerService;
  58. @Resource
  59. private AdminOrgAnnualReportServiceImpl adminOrgAnnualReportService;
  60. @Resource
  61. private AttachmentService aftFileService;
  62. @Value(value = "${upload.private.path}")
  63. private String uploadPrivatePath = null;
  64. @Resource
  65. private AdminService adminService;
  66. @Value(value = "${aesSecretKey}")
  67. private String secretKey = null;
  68. /** 私有个人客户列表 **/
  69. @RequestMapping(value = "/listPrivatePersonalCustomer" , method = RequestMethod.POST)
  70. public Result listPrivatePersonalCustomer(CustomerListIn cli,Integer pageNo, Integer pageSize){
  71. Result res = new Result();
  72. res.setData(customerService.listPrivatePersonalCustomer(cli, pageNo, pageSize));
  73. return res;
  74. }
  75. /** 公共个人客户列表 **/
  76. @RequestMapping(value = "/listPublicPersonalCustomer" , method = RequestMethod.POST)
  77. public Result listPublicPersonalCustomer(CustomerListIn cli,Integer pageNo, Integer pageSize){
  78. Result res = new Result();
  79. res.setData(customerService.listPublicPersonalCustomer(cli, pageNo, pageSize));
  80. return res;
  81. }
  82. /** 个人客户查询 **/
  83. @RequestMapping(value = "/listAllPersonalCustomer" , method = RequestMethod.POST)
  84. public Result listAllPersonalCustomer(CustomerListIn cli,Integer pageNo, Integer pageSize){
  85. Result res = new Result();
  86. res.setData(customerService.listAllPersonalCustomer(cli, pageNo, pageSize));
  87. return res;
  88. }
  89. /** 管理个人客户查询 **/
  90. @RequestMapping(value = "/listAllManagePersonalCustomer" , method = RequestMethod.POST)
  91. public Result listAllManagePersonalCustomer(CustomerListIn cli,Integer pageNo, Integer pageSize){
  92. Result res = new Result();
  93. if (!TokenManager.hasRole(AFTConstants.SUPERADMIN) && !TokenManager.hasRole(AFTConstants.APPROVAL_DECISION)){
  94. cli.setAid(TokenManager.getAdminId());
  95. }
  96. res.setData(customerService.listAllManagePersonalCustomer(cli, pageNo, pageSize));
  97. return res;
  98. }
  99. /** 专家查询 **/
  100. @RequestMapping(value = "/listExpertCustomer" , method = RequestMethod.POST)
  101. public Result listExpertCustomer(CustomerListIn cli,Integer pageNo, Integer pageSize){
  102. Result res = new Result();
  103. res.setData(customerService.listAllManagePersonalCustomer(cli, pageNo, pageSize));
  104. return res;
  105. }
  106. /**
  107. * 私有单位客户列表
  108. * 私有客户列表
  109. **/
  110. @RequestMapping(value = "/listPrivateOrganizationCustomer" , method = RequestMethod.POST)
  111. public Result listPrivateOrganizationCustomer(CustomerListIn cli ,Integer sort,Integer sortType,Integer pageNo, Integer pageSize){
  112. Result res = new Result();
  113. //
  114. res.setData(customerService.listPrivateOrganizationCustomer(cli, sort, sortType, 0, pageNo, pageSize));
  115. return res;
  116. }
  117. /** 跟进管理列表
  118. * 跟进列表
  119. **/
  120. @RequestMapping(value = "/listFollowManagement" , method = RequestMethod.GET)
  121. public Result listFollowManagement(CustomerListIn cli ,Integer sort,Integer sortType,Integer pageNo, Integer pageSize){
  122. Result res = new Result();
  123. res.setData(customerService.listPrivateOrganizationCustomer(cli, sort, sortType, 1, pageNo, pageSize));
  124. return res;
  125. }
  126. /**
  127. * 私有单位客户导出xls
  128. * @throws IOException
  129. */
  130. @RequestMapping(value = "/privateUnitCustomerOutXls" , method = RequestMethod.GET)
  131. public Result privateUnitCustomerOutXls(CustomerListIn cli ,Integer sort,Integer sortType,Integer pageNo, Integer pageSize,HttpServletResponse response) throws IOException{
  132. Result res = new Result();
  133. XSSFWorkbook wb = customerService.privateUnitCustomerOutXls(cli, sort, sortType, pageNo, pageSize);
  134. String fileName = "我的客户列表 " + new SimpleDateFormat("yyyy-MM-dd").format(new Date()) + ".xls";
  135. OutputStream out = null;
  136. try {
  137. out = response.getOutputStream();
  138. } catch (IOException e) {
  139. e.printStackTrace();
  140. }
  141. response.addHeader("Content-Disposition", "attachment;filename=" + new String(fileName.getBytes(),"iso-8859-1"));
  142. response.setContentType("application/octet-stream;charset=utf-8");
  143. try {
  144. // 返回数据流
  145. wb.write(out);
  146. out.flush();
  147. out.close();
  148. } finally {
  149. out.flush();
  150. out.close();
  151. }
  152. return res;
  153. }
  154. /** 公共单位客户列表 **/
  155. @RequestMapping(value = "/listPublicOrganizationCustomer" , method = RequestMethod.POST)
  156. public Result listPublicOrganizationCustomer(CustomerListIn cli,Integer pageNo, Integer pageSize){
  157. Result res = new Result();
  158. res.setData(customerService.listPublicOrganizationCustomer(cli, pageNo, pageSize));
  159. return res;
  160. }
  161. /** 单位客户查询 **/
  162. @RequestMapping(value = "/listAllOrganizationCustomer" , method = RequestMethod.POST)
  163. public Result listAllOrganizationCustomer(CustomerListIn cli,Integer pageNo, Integer pageSize){
  164. Result res = new Result();
  165. res.setData(customerService.listAllOrganizationCustomer(cli, pageNo, pageSize));
  166. return res;
  167. }
  168. /** 管理单位客户查询 **/
  169. @RequestMapping(value = "/listAllManageOrganizationCustomer" , method = RequestMethod.POST)
  170. public Result listAllManageOrganizationCustomer(CustomerListIn cli,Integer pageNo, Integer pageSize){
  171. Result res = new Result();
  172. res.setData(customerService.listAllManageOrganizationCustomer(cli, pageNo, pageSize));
  173. return res;
  174. }
  175. /** 签单的单位客户 **/
  176. @RequestMapping(value = "/listSignOrganizationCustomer", method = RequestMethod.POST)
  177. public Result listSignOrganizationCustomer(CustomerListIn cli,Integer pageNo, Integer pageSize){
  178. Result res = new Result();
  179. res.setData(customerService.listSignOrganizationCustomer(cli, pageNo, pageSize));
  180. return res;
  181. }
  182. /** 签单的个人客户 **/
  183. @RequestMapping(value = "/listSignPersonalCustomer", method = RequestMethod.POST)
  184. public Result listSignPersonalCustomer(CustomerListIn cli,Integer pageNo, Integer pageSize){
  185. Result res = new Result();
  186. res.setData(customerService.listSignPersonalCustomer(cli, pageNo, pageSize));
  187. return res;
  188. }
  189. /** 签单客户转交 **/
  190. @RequestMapping(value = "/customerHandOver", method = RequestMethod.POST)
  191. public Result listSignPersonalCustomer(String userIds ,String receiveId){
  192. Result res = new Result();
  193. res.setData(customerService.customerHandOver( userIds , receiveId));
  194. return res;
  195. }
  196. /** 客户即时检索 **/
  197. @RequestMapping(value = "/findCustomerByName",method = RequestMethod.GET)
  198. public Result findCustomerByName(String name){
  199. Result res = new Result();
  200. res.setData(customerService.findCustomerByName(name));
  201. return res;
  202. }
  203. /** 客户即时检索(可签单客户) **/
  204. @RequestMapping(value = "/getCustomerByName",method = RequestMethod.GET)
  205. public Result getCustomerByName(String name,Integer type){
  206. Result res = new Result();
  207. if(type == null){
  208. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, ""));
  209. return res;
  210. }
  211. if(name.length()<2) return res;
  212. if(type == 0) res.setData(customerService.getPrivateCustomerByName(name));
  213. if(type == 1) res.setData(customerService.getSignedCustomerByName(name));
  214. return res;
  215. }
  216. /** 添加客户基本信息
  217. * @throws Exception
  218. * @throws NumberFormatException **/
  219. @RequestMapping(value = "/addCustomer", method = RequestMethod.POST)
  220. public Result addCustomer(String name,String contacts,String contactMobile,Integer type,
  221. Integer province ,Integer city, Integer area,Integer source,String societyTag) throws Exception{
  222. Result res = new Result();
  223. if(StringUtils.isBlank(name) || StringUtils.isBlank(contacts)
  224. || StringUtils.isBlank(contactMobile) || StringUtils.isBlank(societyTag)||null==province||null==city||null==area){
  225. res.getError().add(buildError("","客户名称、联系人、联系电话、社会性质、地址不能为空"));
  226. return res;
  227. }
  228. if (customerService.checkMax(TokenManager.getAdminId())) {
  229. res.getError().add(buildError("","私有客户已达最大限制"));
  230. return res;
  231. }
  232. //将新增客户的空格去除
  233. customerService.addCustomer(name.replace(" ", ""), contacts, contactMobile,type,source,societyTag,province,city,area);
  234. return res;
  235. }
  236. /** 个人客户详情信息 **/
  237. @RequestMapping(value = "/findPersonalCustomerDetail" ,method = RequestMethod.GET)
  238. public Result findPersonalCustomerDetail(String uid){
  239. Result res = new Result();
  240. res.setData(customerService.findPersonalCustomerDetail(uid));
  241. return res;
  242. }
  243. /** 单位客户详情信息 **/
  244. @RequestMapping(value = "/findOrganizationCustomerDetail", method = RequestMethod.GET)
  245. public Result findOrganizationCustomerDetail(String uid){
  246. Result res = new Result();
  247. res.setData(customerService.findOrganizationCustomerDetail(uid));
  248. return res;
  249. }
  250. /** 修改单位客户信息 **/
  251. @RequestMapping(value = "/updateOrganizationCustomer", method = RequestMethod.POST)
  252. public Result updateOrganizationCustomer(CustomerOrganizationDetailBo bo){
  253. Result res = new Result();
  254. if(StringUtils.isBlank(bo.getId()) || StringUtils.isBlank(bo.getUid())){
  255. res.getError().add(buildError(ErrorConstants.PARAM_ERROR,""));
  256. return res;
  257. }
  258. customerService.updateOrganizationCustomer(bo);
  259. return res;
  260. }
  261. /** 修改个人客户信息 **/
  262. @RequestMapping(value = "/updatePersonalCustomer", method = RequestMethod.POST)
  263. public Result updatePersonalCustomer(CustomerPersonalDetailBo bo){
  264. Result res = new Result();
  265. if(StringUtils.isBlank(bo.getUid()) || StringUtils.isBlank(bo.getId())){
  266. res.getError().add(buildError(ErrorConstants.PARAM_ERROR,""));
  267. return res;
  268. }
  269. customerService.updatePersonalCustomer(bo);
  270. return res;
  271. }
  272. /** 查看跟进记录 **/
  273. @RequestMapping(value = "/listFollowHistory", method = RequestMethod.GET)
  274. public Result listFollowHistory(Integer pageNo, Integer pageSize,String uid,String businessProjectId,Integer type){
  275. Result res = new Result();
  276. res.setData(customerService.listFollowHistory(pageNo,pageSize,uid,businessProjectId,type));
  277. return res;
  278. }
  279. /** 指导已读 **/
  280. @RequestMapping(value = "/pushGuidance", method = RequestMethod.POST)
  281. public Result pushGuidance(String uid){
  282. Result res = new Result();
  283. if (StringUtils.isBlank(uid)) {
  284. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,"用户编号"));
  285. return res;
  286. }
  287. res.setData(customerService.pushGuidance(uid));
  288. return res;
  289. }
  290. /** 新增指导意见 **/
  291. @RequestMapping(value = "/addGuidance", method = RequestMethod.POST)
  292. public Result addGuidance(String followId,String guidance){
  293. Result res = new Result();
  294. if (StringUtils.isBlank(followId)||StringUtils.isBlank(guidance)) {
  295. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,"编号、指导意见","编号、指导意见"));
  296. return res;
  297. }
  298. res.setData(customerService.addGuidance( followId, guidance));
  299. return res;
  300. }
  301. /** 查看客户账户信息 **/
  302. @RequestMapping(value = "/findUserAccountDetail", method = RequestMethod.GET)
  303. public Result findUserAcountDetail(String uid){
  304. Result res = new Result();
  305. UserDetailBo bo = new UserDetailBo();
  306. User user = customerService.findUserAccountDetail(uid);
  307. try {
  308. BeanUtilsExt.copyProperties(bo, user);
  309. } catch (InvocationTargetException | IllegalAccessException e) {
  310. e.printStackTrace();
  311. }
  312. SimpleDateFormat format = new SimpleDateFormat(AFTConstants.YYYYMMDDHHMMSS);
  313. bo.setCreateTimes(format.format(user.getCreateTime()));
  314. res.setData(bo);
  315. return res;
  316. }
  317. /** 修改客户账户信息 **/
  318. @RequestMapping(value = "/updateUserAccount", method = RequestMethod.POST)
  319. public Result updateUserAccount(User user){
  320. Result res = new Result();
  321. customerService.updateUserAccount(user);
  322. return res;
  323. }
  324. /** 查看客户联系人列表 **/
  325. @RequestMapping(value = "/findCustomerContacts", method = RequestMethod.GET)
  326. public Result findCustomerContacts(String uid){
  327. Result res = new Result();
  328. res.setData(customerService.findCustomerContacts(uid));
  329. return res;
  330. }
  331. /** 针对已作拜访的业务作跟进 **/
  332. @RequestMapping(value = "/toAddFollowOnHistory", method = RequestMethod.GET)
  333. public Result toAddFollowOnHistory(String uid){
  334. Result res = new Result();
  335. if(StringUtils.isBlank(uid)){
  336. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,""));
  337. return res;
  338. }
  339. User user = customerService.findUserAccountDetail(uid);
  340. FollowBusinessBo fbb = new FollowBusinessBo();
  341. SimpleDateFormat format = new SimpleDateFormat(AFTConstants.YYYYMMDDHHMMSS);
  342. fbb.setFollowTime(format.format(new Date()));
  343. fbb.setIdentifyName(user.getIdentifyName());
  344. fbb.setUid(uid);
  345. fbb.setUserBusinessList(customerService.findBusinessByUAid(uid, TokenManager.getAdminId()));
  346. res.setData(fbb);
  347. return res;
  348. }
  349. /** 针对已锁定的业务作跟进 **/
  350. @RequestMapping(value = "/toAddFollowOnLock", method = RequestMethod.GET)
  351. public Result toAddFollowOnLock(String uid){
  352. Result res = new Result();
  353. if(StringUtils.isBlank(uid)){
  354. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,""));
  355. return res;
  356. }
  357. User user = customerService.findUserAccountDetail(uid);
  358. FollowBusinessBo fbb = new FollowBusinessBo();
  359. SimpleDateFormat format = new SimpleDateFormat(AFTConstants.YYYYMMDDHHMMSS);
  360. fbb.setFollowTime(format.format(new Date()));
  361. fbb.setIdentifyName(user.getIdentifyName());
  362. fbb.setUid(uid);
  363. fbb.setUserBusinessList(customerService.findLockedBusinessByUAid(uid, TokenManager.getAdminId()));
  364. res.setData(fbb);
  365. return res;
  366. }
  367. /** 添加拜访记录
  368. * @throws ParseException
  369. * @throws Exception **/
  370. @RequestMapping(value = "/addFollow", method = RequestMethod.POST)
  371. public Result addFollow(String userBusinessList,String uid,String ocbId,String contactType,String result,String followTime) throws BusinessException{
  372. Result res = new Result();
  373. if(StringUtils.isBlank(uid) || StringUtils.isBlank(ocbId)){
  374. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, ""));
  375. return res;
  376. }
  377. JSONArray ja = (JSONArray) JSON.parse(userBusinessList);
  378. List<BusinessListBo> list = new ArrayList<BusinessListBo>();
  379. if (ja != null && !ja.isEmpty()) {
  380. BusinessListBo userBusiness = null;
  381. for (int idx = 0; idx < ja.size(); idx++) {
  382. userBusiness = ja.getJSONObject(idx).toJavaObject(BusinessListBo.class);
  383. for(BusinessListBo ub:list){
  384. if(ub.getBusinessProjectId() == userBusiness.getBusinessProjectId()){
  385. res.getError().add(new com.goafanti.common.bo.Error("业务类型重复,请检查后重新提交!"));
  386. return res;
  387. }
  388. }
  389. list.add(userBusiness);
  390. }
  391. }
  392. FollowBusinessBo fbb = new FollowBusinessBo();
  393. fbb.setOcbId(ocbId);
  394. fbb.setUid(uid);
  395. fbb.setContactType(contactType);
  396. fbb.setResult(result);
  397. fbb.setFollowTime(followTime);
  398. fbb.setUserBusinessList(list);
  399. customerService.addFollow(fbb);
  400. return res;
  401. }
  402. /** 进入修改拜访记录 **/
  403. @RequestMapping(value = "/toUpdateFollow", method = RequestMethod.GET)
  404. public Result toUpdateFollow(String followId){
  405. Result res = new Result();
  406. FollowBusinessBo fbb = customerService.findFollowById(followId);
  407. fbb.setUserBusinessList(customerService.findBusinessByFollowId(followId));
  408. res.setData(fbb);
  409. return res;
  410. }
  411. /** 修改拜访记录
  412. * @throws ParseException
  413. * @throws BusinessException
  414. */
  415. @RequestMapping(value = "/updateFollow", method = RequestMethod.POST)
  416. public Result updateFollow(String userBusinessList,String followId,String followTime,String uid,String contactType,String result) throws BusinessException{
  417. Result res = new Result();
  418. if(StringUtils.isBlank(uid) || StringUtils.isBlank(followId)){
  419. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, ""));
  420. return res;
  421. }
  422. JSONArray ja = (JSONArray) JSON.parse(userBusinessList);
  423. List<BusinessListBo> list = new ArrayList<BusinessListBo>();
  424. if (ja != null && !ja.isEmpty()) {
  425. BusinessListBo userBusiness = null;
  426. for (int idx = 0; idx < ja.size(); idx++) {
  427. userBusiness = ja.getJSONObject(idx).toJavaObject(BusinessListBo.class);
  428. for(BusinessListBo ub:list){
  429. if(ub.getBusinessProjectId() == userBusiness.getBusinessProjectId()){
  430. res.getError().add(new com.goafanti.common.bo.Error("业务类型重复,请检查后重新提交!"));
  431. return res;
  432. }
  433. }
  434. list.add(userBusiness);
  435. }
  436. }
  437. FollowBusinessBo fbb = new FollowBusinessBo();
  438. fbb.setFollowTime(followTime);
  439. fbb.setUid(uid);
  440. fbb.setContactType(contactType);
  441. fbb.setResult(result);
  442. fbb.setUserBusinessList(list);
  443. fbb.setFollowId(followId);
  444. customerService.updateFollow(fbb);
  445. return res;
  446. }
  447. /** 删除跟进记录 **/
  448. @RequestMapping(value = "/deleteFollow", method = RequestMethod.GET)
  449. public Result deleteFollow(String followId){
  450. Result res = new Result();
  451. if(StringUtils.isBlank(followId)){
  452. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, ""));
  453. return res;
  454. }
  455. customerService.deleteFollow(followId);
  456. return res;
  457. }
  458. /** 查询客户的所有联系人 **/
  459. @RequestMapping(value = "/findAllContacts", method = RequestMethod.GET)
  460. public Result findAllContacts(String uid){
  461. Result res = new Result();
  462. res.setData(customerService.findAllContacts(uid));
  463. return res;
  464. }
  465. /** 修改企业联系人 **/
  466. @RequestMapping(value = "/updateCustomerContacts", method = RequestMethod.POST)
  467. public Result updateCustomerContacts(String contactList,String uid){
  468. Result res = new Result();
  469. if(StringUtils.isBlank(uid)){
  470. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, ""));
  471. return res;
  472. }
  473. JSONArray ja = (JSONArray) JSON.parse(contactList);
  474. List<OrganizationContactBook> ocbList = new ArrayList<OrganizationContactBook>();
  475. OrganizationContactBook ocb = null;
  476. if(ja != null & !ja.isEmpty()){
  477. for (int idx = 0; idx < ja.size(); idx++) {
  478. ocb = ja.getJSONObject(idx).toJavaObject(OrganizationContactBook.class);
  479. if(StringUtils.isBlank(ocb.getMobile()) || StringUtils.isBlank(ocb.getName())){
  480. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "用户名和手机号码为必填"));
  481. return res;
  482. }
  483. if(StringUtils.isBlank(ocb.getUid())) ocb.setUid(uid);
  484. ocbList.add(ocb);
  485. }
  486. }
  487. customerService.updateCustomerContacts(ocbList,uid);
  488. return res;
  489. }
  490. /** 领取客户 **/
  491. @RequestMapping(value = "/receiveCustomer", method = RequestMethod.GET)
  492. public Result receiveCustomer(String uid,String oldAid){
  493. Result res = new Result();
  494. if(StringUtils.isBlank(uid) || StringUtils.isBlank("oldAid")){
  495. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, ""));
  496. return res;
  497. }
  498. if (customerService.checkMax(TokenManager.getAdminId())) {
  499. res.getError().add(buildError("","私有客户已达最大限制"));
  500. return res;
  501. }
  502. customerService.updateByOperatorType(uid, oldAid,AFTConstants.USER_RECEIVE);
  503. return res;
  504. }
  505. /**
  506. * 上传excel文档
  507. * @param req
  508. * @return
  509. */
  510. @RequestMapping(value = "/uploadExcel",method = RequestMethod.POST)
  511. public Result uploadExcel(HttpServletRequest req){
  512. Result res = new Result();
  513. String excelPath = handleFile(res, "/customer_sys_file/", true, req, "");
  514. ExcelUtils utils = new ExcelUtils();
  515. Set<CustomerExcelBo> boSet;
  516. try {
  517. boSet = utils.parseExcel(uploadPrivatePath + excelPath);
  518. String errorMessage = "";
  519. if(boSet.size()>100) errorMessage += "导入数据不能超过一百条;";
  520. errorMessage += utils.getVacantRows();
  521. if(StringUtils.isNotBlank(errorMessage)) {
  522. res.getError().add(new Error(errorMessage));
  523. return res;
  524. }
  525. Set<Integer> existRows = new TreeSet<Integer>(); //数据库已存在
  526. Set<Integer> filterRows = new TreeSet<Integer>(); //过滤提示
  527. customerService.checkCustomer(boSet,existRows,filterRows);
  528. if(existRows.size()>0){
  529. errorMessage = StringUtils.join(existRows.toArray(),",")+ " 行客户业务已存在;";
  530. res.getError().add(new Error(errorMessage));
  531. return res;
  532. }
  533. if(filterRows.size()>0){
  534. errorMessage = StringUtils.join(filterRows.toArray(),",")+ " 行已经被系统过滤;";
  535. res.getError().add(new Error(errorMessage));
  536. return res;
  537. }
  538. customerService.saveUploadData(boSet);
  539. } catch (IOException e) {
  540. e.printStackTrace();
  541. }
  542. return res;
  543. }
  544. /**
  545. * 下载科技成果批量导入Excel模板
  546. */
  547. @RequestMapping(value = "/downloadTemplate", method = RequestMethod.GET)
  548. public Result downloadTemplateFile(HttpServletResponse response,String type) {
  549. Result res = new Result();
  550. if(AFTConstants.USER_TYPE_ORGANIZATION.equals(type)){
  551. Attachment af = aftFileService.selectAftFileBySign("organization_customer_template");
  552. if (null == af) {
  553. res.getError().add(buildError(ErrorConstants.FILE_NON_EXISTENT, "", "找不到文件!"));
  554. } else {
  555. String path = af.getFilePath();
  556. String suffix = path.substring(path.lastIndexOf("."));
  557. String fileName = af.getFileName() + suffix;
  558. downloadFile(response, fileName, path);
  559. }
  560. }else if(AFTConstants.USER_TYPE_PERSONAL.equals(type)){
  561. Attachment af = aftFileService.selectAftFileBySign("personal_customer_template");
  562. if (null == af) {
  563. res.getError().add(buildError(ErrorConstants.FILE_NON_EXISTENT, "", "找不到文件!"));
  564. } else {
  565. String path = af.getFilePath();
  566. String suffix = path.substring(path.lastIndexOf("."));
  567. String fileName = af.getFileName() + suffix;
  568. downloadFile(response, fileName, path);
  569. }
  570. }
  571. return res;
  572. }
  573. /** 转为公共客户 **/
  574. @RequestMapping(value = "/transferToPublic", method = RequestMethod.GET)
  575. public Result transferToPublic(String uid,String aid){
  576. Result res = new Result();
  577. if(StringUtils.isBlank(uid) || StringUtils.isBlank("aid")){
  578. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, ""));
  579. }
  580. customerService.updateByOperatorType(uid, aid, AFTConstants.USER_TRANSFER_TO_PUBLIC);
  581. return res;
  582. }
  583. /** 图片上传 **/
  584. @RequestMapping(value = "/uploadCustomerImg", method = RequestMethod.POST)
  585. public Result uploadCustomerImg(HttpServletRequest req,String sign){
  586. Result res = new Result();
  587. res.setData(handleFile(res, "/customer_sys_file/", false, req, sign));
  588. return res;
  589. }
  590. /**
  591. *
  592. * @param startDate 开始日期
  593. * @param endDate 结束日期
  594. * @param timeSpan 时间差
  595. * @param depId 部门编号
  596. * @param pageNo 页码
  597. * @param pageSize 页数
  598. * @return
  599. * @throws ParseException
  600. */
  601. @RequestMapping(value = "/customerStatistics",method = RequestMethod.GET)
  602. public Result customerStatistics(String startDate,String endDate,String timeSpan,String depNo,String businessGlossoryId,Integer pageNo, Integer pageSize) throws ParseException{
  603. Result res = new Result();
  604. Date sDate = null;
  605. Date eDate = null;
  606. DateFormat format = new SimpleDateFormat(AFTConstants.YYYYMMDD);
  607. if(StringUtils.isNotBlank(startDate)) sDate = format.parse(startDate);
  608. if(StringUtils.isNotBlank(endDate)) eDate = format.parse(endDate);
  609. if(StringUtils.isBlank(startDate)&&StringUtils.isBlank(endDate)){
  610. Date date = new Date();
  611. if(timeSpan.equals(DateUtils.DAY_SPAN)){
  612. sDate = DateUtils.getYesterday();
  613. }else if(timeSpan.equals(DateUtils.WEEK_SPAN)){
  614. sDate = DateUtils.getLastDayOfLastWeek(date);
  615. }else if(timeSpan.equals(DateUtils.MONTH_SPAN)){
  616. sDate = DateUtils.getLastDayOfLastMonth(date);
  617. }else if(timeSpan.equals(DateUtils.QUARTER_SPAN)){
  618. sDate = DateUtils.getLastDayOfLastQuarter(date);
  619. }else if(timeSpan.equals(DateUtils.YEAR_SPAN)){
  620. sDate = DateUtils.getLastDayOfLastYear(date);
  621. }
  622. }
  623. res.setData(customerService.customerStatistics(sDate,eDate,depNo,businessGlossoryId,pageNo,pageSize));
  624. return res;
  625. }
  626. /**
  627. *
  628. * @param startDate 开始日期
  629. * @param endDate 结束日期
  630. * @param timeSpan 时间差
  631. * @param depId 部门编号
  632. * @param businessGlossoryId 业务编号
  633. * @param pageNo 页码
  634. * @param pageSiz 页数
  635. * @return
  636. * @throws ParseException
  637. */
  638. @RequestMapping(value = "/businessStatistic", method = RequestMethod.GET)
  639. public Result businessStatistic(String startDate,String endDate,String timeSpan,String depNo,String businessGlossoryId,Integer pageNo, Integer pageSize) throws ParseException{
  640. Result res = new Result();
  641. Date sDate = null;
  642. Date eDate = null;
  643. DateFormat format = new SimpleDateFormat(AFTConstants.YYYYMMDD);
  644. if(StringUtils.isNotBlank(startDate)) sDate = format.parse(startDate);
  645. if(StringUtils.isNotBlank(endDate)) eDate = format.parse(endDate);
  646. if(StringUtils.isBlank(startDate)&&StringUtils.isBlank(endDate)){
  647. Date date = new Date();
  648. if(timeSpan.equals(DateUtils.DAY_SPAN)){
  649. sDate = DateUtils.getYesterday();
  650. }else if(timeSpan.equals(DateUtils.WEEK_SPAN)){
  651. sDate = DateUtils.getLastDayOfLastWeek(date);
  652. }else if(timeSpan.equals(DateUtils.MONTH_SPAN)){
  653. sDate = DateUtils.getLastDayOfLastMonth(date);
  654. }else if(timeSpan.equals(DateUtils.QUARTER_SPAN)){
  655. sDate = DateUtils.getLastDayOfLastQuarter(date);
  656. }else if(timeSpan.equals(DateUtils.YEAR_SPAN)){
  657. sDate = DateUtils.getLastDayOfLastYear(date);
  658. }
  659. }
  660. res.setData(customerService.businessStatistic(sDate,eDate,depNo,businessGlossoryId,pageNo,pageSize));
  661. return res;
  662. }
  663. /**
  664. *
  665. * @param startDate 开始日期
  666. * @param endDate 结束日期
  667. * @param timeSpan 时间差
  668. * @param depId 部门编号
  669. * @param businessGlossoryId 业务编号
  670. * @param pageNo 页码
  671. * @param pageSiz 页数
  672. * @return
  673. * @throws ParseException
  674. */
  675. @RequestMapping(value = "/followStatistic",method = RequestMethod.GET)
  676. public Result followStatistic(String startDate,String endDate,String timeSpan,String depNo,Integer pageNo, Integer pageSize) throws ParseException{
  677. Result res = new Result();
  678. Date sDate = null;
  679. Date eDate = null;
  680. DateFormat format = new SimpleDateFormat(AFTConstants.YYYYMMDD);
  681. if(StringUtils.isNotBlank(startDate)) sDate = format.parse(startDate);
  682. if(StringUtils.isNotBlank(endDate)) eDate = format.parse(endDate);
  683. if(StringUtils.isBlank(startDate)&&StringUtils.isBlank(endDate)){
  684. Date date = new Date();
  685. if(timeSpan.equals(DateUtils.DAY_SPAN)){
  686. sDate = DateUtils.getYesterday();
  687. }else if(timeSpan.equals(DateUtils.WEEK_SPAN)){
  688. sDate = DateUtils.getLastDayOfLastWeek(date);
  689. }else if(timeSpan.equals(DateUtils.MONTH_SPAN)){
  690. sDate = DateUtils.getLastDayOfLastMonth(date);
  691. }else if(timeSpan.equals(DateUtils.QUARTER_SPAN)){
  692. sDate = DateUtils.getLastDayOfLastQuarter(date);
  693. }else if(timeSpan.equals(DateUtils.YEAR_SPAN)){
  694. sDate = DateUtils.getLastDayOfLastYear(date);
  695. }
  696. }
  697. res.setData(customerService.followStatistic(sDate, eDate, depNo, pageNo, pageSize));
  698. return res;
  699. }
  700. /** 管理员列表 **/
  701. @RequestMapping(value = "/listAdminByName",method = RequestMethod.GET)
  702. public Result listAdminByName(String adminName){
  703. Result res = new Result();
  704. if(StringUtils.isNotBlank(adminName))res.setData(adminService.listAdminByName(adminName));
  705. return res;
  706. }
  707. /** 转交客户到制定人 **/
  708. @RequestMapping(value = "/transferToOther", method = RequestMethod.GET)
  709. public Result transferToOther(String uid,String aid,Integer operatorType,String oldAid){
  710. Result res = new Result();
  711. if(StringUtils.isBlank(uid) || StringUtils.isBlank(aid)){
  712. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "客户编号或管理员编号"));
  713. return res;
  714. }
  715. //默认为私有转交,4为签单转交
  716. if (operatorType==null) {
  717. operatorType=AFTConstants.USER_TRANSFER_TO_OTHER;
  718. }
  719. if (operatorType !=AFTConstants.SIGN_USER_TRANSFER_TO_OTHER&& customerService.checkMax(aid)) {
  720. res.getError().add(buildError("","对方私有客户已达最大限制"));
  721. return res;
  722. }
  723. customerService.updateByOperatorType(uid,oldAid,operatorType, aid);
  724. return res;
  725. }
  726. /**
  727. * 客户转交记录
  728. * @param uid 客户编号
  729. * @param aid 管理员编号
  730. * @param oldAid 接收者编号
  731. * @return
  732. */
  733. @RequestMapping(value = "/transferList", method = RequestMethod.GET)
  734. public Result transferList(String uid){
  735. Result res = new Result();
  736. if(StringUtils.isBlank(uid) ){
  737. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,"客户编号", "客户编号"));
  738. return res;
  739. }
  740. res.data(customerService.transferList( uid));
  741. return res;
  742. }
  743. /** 查询我的业务列表 **/
  744. @RequestMapping(value = "/listBusiness", method = RequestMethod.POST)
  745. public Result listBusiness(BusinessListBo blo,Integer pageNo, Integer pageSize){
  746. Result res = new Result();
  747. res.setData(customerService.listBusiness(blo, pageNo, pageSize));
  748. return res;
  749. }
  750. /** 查询所有的业务列表 **/
  751. @RequestMapping(value = "/listAllBusiness", method = RequestMethod.POST)
  752. public Result listAllBusiness(BusinessListBo blo,Integer pageNo, Integer pageSize){
  753. Result res = new Result();
  754. res.setData(customerService.listAllBusiness(blo, pageNo, pageSize));
  755. return res;
  756. }
  757. /** 业务管理列表 **/
  758. @RequestMapping(value = "/listManageBusiness", method = RequestMethod.POST)
  759. public Result listManageBusiness(BusinessListBo blo,Integer pageNo, Integer pageSize){
  760. Result res = new Result();
  761. res.setData(customerService.listManageBusiness(blo, pageNo, pageSize));
  762. return res;
  763. }
  764. /** 查询业务字典 **/
  765. @RequestMapping(value = "/findBusinessGlossory",method = RequestMethod.GET)
  766. public Result findBusinessGlossory(){
  767. Result res = new Result();
  768. res.setData(customerService.findBusinessGlossory());
  769. return res;
  770. }
  771. /** 新增客户意向 **/
  772. @RequestMapping(value = "/addBusinessAndFollow", method = RequestMethod.POST)
  773. public Result addBusinessAndFollow(BussinessFollowBo bfb){
  774. Result res = new Result();
  775. if(StringUtils.isBlank(bfb.getBusinessProjectId()) || StringUtils.isBlank(bfb.getUid())){
  776. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,""));
  777. return res;
  778. }
  779. if(customerService.judgeBusiness(bfb.getUid(), bfb.getBusinessProjectId())>0){
  780. res.getError().add(new Error("该项业务已经被跟进"));
  781. return res;
  782. }
  783. try {
  784. customerService.addBusinessAndFollow(bfb);
  785. } catch (ParseException e) {
  786. e.printStackTrace();
  787. }
  788. return res;
  789. }
  790. /** 进入新增意向服务 **/
  791. @RequestMapping(value = "/toAddBusinessAndFollow", method = RequestMethod.GET)
  792. public Result toAddBusinessAndFollow(){
  793. Result res = new Result();
  794. BussinessFollowBo bo = new BussinessFollowBo();
  795. bo.setAdminName(TokenManager.getAdminToken().getName());
  796. SimpleDateFormat format = new SimpleDateFormat(AFTConstants.YYYYMMDDHHMMSS);
  797. bo.setCreateTime(format.format(new Date()));
  798. bo.setFollowTime(bo.getCreateTime());
  799. res.setData(bo);
  800. return res;
  801. }
  802. /** 进入修改业务意向 **/
  803. @RequestMapping(value = "/toUpdateBusiness", method = RequestMethod.GET)
  804. public Result toUpdateBusiness(String businessId){
  805. Result res = new Result();
  806. res.setData(customerService.findBusinessDetail(businessId));
  807. return res;
  808. }
  809. /** 修改业务意向 **/
  810. @RequestMapping(value = "/updateBusiness", method = RequestMethod.POST)
  811. public Result updateBusiness(BussinessFollowBo bfb){
  812. Result res = new Result();
  813. customerService.updateBusiness(bfb);
  814. return res;
  815. }
  816. /** 进入跟进单个客户意向 **/
  817. @RequestMapping(value = "/toAddFollowOneBusiness", method = RequestMethod.GET)
  818. public Result toAddFollowOneBusiness(String businessId){
  819. Result res = new Result();
  820. BussinessFollowBo bo = customerService.findBusinessDetail(businessId);
  821. SimpleDateFormat format = new SimpleDateFormat(AFTConstants.YYYYMMDDHHMMSS);
  822. bo.setFollowTime(format.format(new Date()));
  823. res.setData(bo);
  824. return res;
  825. }
  826. /** 跟进单个客户意向 **/
  827. @RequestMapping(value = "/addFollowOneBusiness", method = RequestMethod.POST)
  828. public Result addFollowOneBusiness(BussinessFollowBo bfb){
  829. Result res = new Result();
  830. if(StringUtils.isBlank(bfb.getBusinessId()) ||
  831. StringUtils.isBlank(bfb.getUid()) || StringUtils.isBlank(bfb.getOcbId())){
  832. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, ""));
  833. return res;
  834. }
  835. try {
  836. customerService.addFollowOneBusiness(bfb);
  837. } catch (ParseException e) {
  838. e.printStackTrace();
  839. }
  840. return res;
  841. }
  842. /** 进入修改某个客户一个业务的当次拜访 **/
  843. @RequestMapping(value = "/toUpdateFollowOneBusiness", method = RequestMethod.GET)
  844. public Result toUpdateFollowOneBusiness(String ufbId){
  845. Result res = new Result();
  846. if(StringUtils.isBlank(ufbId)) {
  847. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,""));
  848. return res;
  849. }
  850. res.setData(customerService.findFollowOneBusiness(ufbId));
  851. return res;
  852. }
  853. /** 修改某个客户一个业务的当次拜访 **/
  854. @RequestMapping(value = "/updateFollowOneBusiness", method = RequestMethod.POST)
  855. public Result updateFollowOneBusiness(BussinessFollowBo bfb){
  856. Result res = new Result();
  857. if(StringUtils.isBlank(bfb.getFollowId()) || StringUtils.isBlank(bfb.getUfbId())){
  858. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,""));
  859. return res;
  860. }
  861. customerService.updateFollowOneBusiness(bfb);
  862. return res;
  863. }
  864. /** 删除某个客户一个业务的当次拜访 **/
  865. @RequestMapping(value = "/deleteFollowOneBusiness", method = RequestMethod.GET)
  866. public Result deleteFollowOneBusiness(String ufbId){
  867. Result res = new Result();
  868. if(StringUtils.isBlank(ufbId)){
  869. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,""));
  870. return res;
  871. }
  872. customerService.deleteFollowOneBusiness(ufbId);
  873. return res;
  874. }
  875. /** 添加单个联系人 **/
  876. @RequestMapping(value = "/addOneContact", method = RequestMethod.POST)
  877. public Result addOneContact(OrganizationContactBook ocb){
  878. Result res = new Result();
  879. if(StringUtils.isBlank(ocb.getUid())){
  880. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,""));
  881. return res;
  882. }
  883. if(StringUtils.isBlank(ocb.getName()) || StringUtils.isBlank(ocb.getMobile())){
  884. res.getError().add(buildError("联系人号码和联系人姓名不能为空"));
  885. return res;
  886. }
  887. customerService.addOneContact(ocb);
  888. return res;
  889. }
  890. /** 删除单个联系人 **/
  891. @RequestMapping(value = "/deleteOneContact", method = RequestMethod.GET)
  892. public Result deleteOneContact(String ocbId){
  893. Result res = new Result();
  894. if(StringUtils.isBlank(ocbId)){
  895. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,""));
  896. return res;
  897. }
  898. customerService.deleteOneContact(ocbId);
  899. return res;
  900. }
  901. /** 修改主要联系人 **/
  902. @RequestMapping(value = "/updateMainContact", method = RequestMethod.GET)
  903. public Result updateMainContact(String ocbId,String uid){
  904. Result res = new Result();
  905. if(StringUtils.isBlank(uid) || StringUtils.isBlank(ocbId)){
  906. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,""));
  907. return res;
  908. }
  909. customerService.updateMainContact(ocbId,uid);
  910. return res;
  911. }
  912. /** 删除 业务 **/
  913. @RequestMapping(value = "/deleteBusiness", method =RequestMethod.GET)
  914. public Result deleteBusiness(String businessId){
  915. Result res = new Result();
  916. if(StringUtils.isBlank(businessId)){
  917. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,""));
  918. return res;
  919. }
  920. customerService.deleteBusiness(businessId);
  921. return res;
  922. }
  923. /** 停止业务 **/
  924. @RequestMapping(value = "/stopBusiness", method = RequestMethod.GET)
  925. public Result stopBusiness(String businessId){
  926. Result res = new Result();
  927. if(StringUtils.isBlank(businessId)){
  928. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,""));
  929. return res;
  930. }
  931. customerService.updateBusinessToStop(businessId);
  932. return res;
  933. }
  934. /** 客户分配查询(本部门) **/
  935. @RequestMapping(value = "/findAdminName" , method = RequestMethod.POST)
  936. public Result findAdminName(){
  937. Result res = new Result();
  938. res.setData(customerService.findAdminName());
  939. return res;
  940. }
  941. /** 分配个人客户 **/
  942. @RequestMapping(value = "/updatePersonalCustomerz", method = RequestMethod.POST)
  943. public Result updatePersonalCustomerz(CustomerPersonalDetailBo bo){
  944. Result res = new Result();
  945. if(StringUtils.isBlank(bo.getUid()) || StringUtils.isBlank(bo.getId())){
  946. res.getError().add(buildError(ErrorConstants.PARAM_ERROR,""));
  947. return res;
  948. }
  949. customerService.updatePersonalCustomerz(bo);
  950. return res;
  951. }
  952. /** 客户录入审核 **/
  953. @RequestMapping(value = "/findEnteringAudit" , method = RequestMethod.POST)
  954. public Result findEnteringAudit(CustomerListOut clo,Integer pageNo, Integer pageSize){
  955. Result res = new Result();
  956. res.setData(customerService.findEnteringAudit(clo, pageNo, pageSize));
  957. return res;
  958. }
  959. /** 修改客户录入审核状态 **/
  960. @RequestMapping(value = "/updateEnteringAudit", method = RequestMethod.POST)
  961. public Result updateEnteringAudit(User bo){
  962. Result res = new Result();
  963. if(StringUtils.isBlank(bo.getId())){
  964. res.getError().add(buildError(ErrorConstants.PARAM_ERROR,""));
  965. return res;
  966. }
  967. res.data(customerService.updateEnteringAudit(bo));
  968. return res;
  969. }
  970. /** 审核拒绝客户查询 **/
  971. @RequestMapping(value = "/findEnteringAuditIsNo" , method = RequestMethod.POST)
  972. public Result findEnteringAuditIsNo(CustomerListOut clo,Integer pageNo, Integer pageSize){
  973. Result res = new Result();
  974. res.setData(customerService.findEnteringAuditIsNo(clo, pageNo, pageSize));
  975. return res;
  976. }
  977. /** 修改拒绝客户信息 **/
  978. @RequestMapping(value = "/updateRefusedCustomer", method = RequestMethod.POST)
  979. public Result updateRefusedCustomer(String id,String nickname,String mobile,String societyTag){
  980. Result res = new Result();
  981. if(StringUtils.isBlank(nickname)){
  982. res.getError().add(buildError(ErrorConstants.PARAM_ERROR,"名称"));
  983. return res;
  984. }
  985. if(StringUtils.isBlank(mobile)){
  986. res.getError().add(buildError(ErrorConstants.PARAM_ERROR,"电话"));
  987. return res;
  988. }
  989. if(StringUtils.isBlank(societyTag)){
  990. res.getError().add(buildError(ErrorConstants.PARAM_ERROR,"社会性质"));
  991. return res;
  992. }
  993. customerService.updateRefusedCustomer(id, nickname, mobile, societyTag);
  994. return res;
  995. }
  996. /** 查询客户的锁定业务 **/
  997. @RequestMapping(value = "/getLockedProject", method = RequestMethod.GET)
  998. public Result getLockedProject(String uid){
  999. Result res = new Result();
  1000. if(StringUtils.isBlank(uid)){
  1001. res.getError().add(buildError(ErrorConstants.PARAM_ERROR,"用户ID"));
  1002. return res;
  1003. }
  1004. res.setData(customerService.selectLockedProject(uid));
  1005. return res;
  1006. }
  1007. /** 客户二次签项目业务 **/
  1008. @RequestMapping(value = "/againProjectTask", method = RequestMethod.GET)
  1009. public Result againProjectTask(String uid,String projectId,String aid){
  1010. Result res = new Result();
  1011. if(StringUtils.isBlank(uid)||StringUtils.isBlank(projectId)){
  1012. res.getError().add(buildError(ErrorConstants.PARAM_ERROR,"参数"));
  1013. return res;
  1014. }
  1015. res.setData(customerService.updateAgainProjectTask(uid,projectId,aid));
  1016. return res;
  1017. }
  1018. /** 客户资料转交 **/
  1019. @RequestMapping(value = "/updateInformationMaintainerr", method = RequestMethod.POST)
  1020. public Result updateInformationMaintainerr(String id,String aid){
  1021. Result res = new Result();
  1022. if(StringUtils.isBlank(id) || StringUtils.isBlank(aid)){
  1023. res.getError().add(buildError(ErrorConstants.PARAM_ERROR,""));
  1024. return res;
  1025. }
  1026. res.data(customerService.updateInformationMaintainerr(id,aid));
  1027. return res;
  1028. }
  1029. /** 个人单位客户信息列表 **/
  1030. @RequestMapping(value = "/listCustomerInformation", method = RequestMethod.POST)
  1031. public Result listCustomerInformation(CustomerListIn cli,Integer pageNo, Integer pageSize){
  1032. Result res = new Result();
  1033. res.data(customerService.listCustomerInformation(cli,pageNo,pageSize));
  1034. return res;
  1035. }
  1036. /** 部门单位客户信息列表 **/
  1037. @RequestMapping(value = "/listDepCustomerInformation", method = RequestMethod.POST)
  1038. public Result listDepCustomerInformation(CustomerListIn cli,Integer pageNo, Integer pageSize){
  1039. Result res = new Result();
  1040. res.data(customerService.listDepCustomerInformation(cli,pageNo,pageSize));
  1041. return res;
  1042. }
  1043. /** 修改客户等级 **/
  1044. @RequestMapping(value = "/updateUserLevel", method = RequestMethod.GET)
  1045. public Result updateUserLevel(User u){
  1046. Result res = new Result();
  1047. if(StringUtils.isBlank(u.getId())){
  1048. res.getError().add(buildError(ErrorConstants.PARAM_ERROR,"用户ID错误","用户ID"));
  1049. return res;
  1050. }
  1051. if(null==u.getLevel()){
  1052. res.getError().add(buildError(ErrorConstants.PARAM_ERROR,"用户等级错误","用户等级"));
  1053. return res;
  1054. }
  1055. res.data(customerService.updateUserLevel(u));
  1056. return res;
  1057. }
  1058. /** 释放客户 **/
  1059. @RequestMapping(value = "/pushReleaseUser", method = RequestMethod.GET)
  1060. public Result pushReleaseUser(String id){
  1061. Result res = new Result();
  1062. if(StringUtils.isBlank(id)){
  1063. res.getError().add(buildError(ErrorConstants.PARAM_ERROR,"用户ID错误","用户ID"));
  1064. return res;
  1065. }
  1066. res.data(customerService.pushReleaseUser(id));
  1067. return res;
  1068. }
  1069. /**
  1070. * 企业项目申报材料上传
  1071. *
  1072. * @param req
  1073. * @param uid
  1074. * @return
  1075. */
  1076. @RequestMapping(value = "/upload", method = RequestMethod.POST)
  1077. public Result cognizanceFile(HttpServletRequest req, String uid, String id, String sign) {
  1078. Result res = new Result();
  1079. AttachmentType attachmentType = AttachmentType.getField(sign);
  1080. if (attachmentType == AttachmentType.ORGANIZATION_APPLICATION) {
  1081. res.setData(handleFiles(res, "/orgApplication/", true, req, sign, uid));
  1082. } else {
  1083. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "附件标示"));
  1084. }
  1085. return res;
  1086. }
  1087. /**
  1088. * 企业项目申报材料预览授权
  1089. *
  1090. * @param id
  1091. * @param sign
  1092. * @return
  1093. */
  1094. @RequestMapping(value = "/techProject", method = RequestMethod.GET)
  1095. public Result previewTechProject(String id, String sign) {
  1096. Result res = new Result();
  1097. if (StringUtils.isEmpty(id)) {
  1098. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "企业项目申报材料ID"));
  1099. return res;
  1100. }
  1101. AttachmentType attachmentType = AttachmentType.getField(sign);
  1102. if (attachmentType == AttachmentType.ORGANIZATION_APPLICATION) {
  1103. String time = String.valueOf(Calendar.getInstance().getTime().getTime());
  1104. String auth = SHA256Util.toHash(sign + "|" + id + "|" + secretKey, time);
  1105. res.setData("sign=" + sign + "&token2=" + id + "&auth=" + auth + "&temp=" + time);
  1106. } else {
  1107. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "附件标示"));
  1108. }
  1109. return res;
  1110. }
  1111. /**
  1112. * 查看营销员客户统计
  1113. * @param depId
  1114. * @param startTime
  1115. * @param endTime
  1116. * @param pageSize
  1117. * @param pageNo
  1118. * @return
  1119. */
  1120. @RequestMapping(value = "/selectAdminCustomerStatistics", method = RequestMethod.GET)
  1121. public Result selectAdminCustomerstatistics(String depId, String startTime,String endTime, Integer pageSize, Integer pageNo) {
  1122. Result res = new Result();
  1123. res.data(adminService.selectAdminCustomerStatistics( depId, startTime, endTime, pageSize, pageNo));
  1124. return res;
  1125. }
  1126. /**
  1127. * 查看客户统计
  1128. * @param depId
  1129. * @param startTime
  1130. * @param endTime
  1131. * @param pageSize
  1132. * @param pageNo
  1133. * @return
  1134. */
  1135. @RequestMapping(value = "/selectAllUser", method = RequestMethod.GET)
  1136. public Result selectAllUser(String depId, String startTime,String endTime,String aName ) {
  1137. Result res = new Result();
  1138. res.data(adminService.selectAllUser( depId, startTime, endTime, aName));
  1139. return res;
  1140. }
  1141. /**
  1142. * 查看客户日期内新增客户
  1143. * @param depId
  1144. * @param startTime
  1145. * @param endTime
  1146. * @param pageSize
  1147. * @param pageNo
  1148. * @return
  1149. */
  1150. @RequestMapping(value = "/selectAdminCustomerList", method = RequestMethod.GET)
  1151. public Result selectAdminCustomerList(String aid, String startTime,String endTime,Integer type, Integer pageSize, Integer pageNo) {
  1152. Result res = new Result();
  1153. res.data(adminService.selectAdminCustomerList( aid, startTime, endTime, type, pageSize, pageNo));
  1154. return res;
  1155. }
  1156. /**
  1157. *
  1158. * @param inputId 业务转移客户id(接收者)
  1159. * @param uid 被转移的客户
  1160. * @param pid 呗转移的业务
  1161. * @return
  1162. */
  1163. @RequestMapping(value = "/privateBusinessTransfer", method = RequestMethod.POST)
  1164. public Result privateBusinessTransfer(String inputId,String uid,String pid ) {
  1165. Result res = new Result();
  1166. if (StringUtils.isBlank(inputId)) {
  1167. res.getError().add(buildError("请确认正确的接收者。","请确认正确的接收者。"));
  1168. return res;
  1169. }
  1170. int i= customerService.updatePrivateBusinessTransfer( inputId, uid, pid );
  1171. if (i<1) {
  1172. res.getError().add(buildError("请确认客户与业务归属是否正确。","请确认客户与业务归属是否正确。"));
  1173. return res;
  1174. }
  1175. res.data(i);
  1176. return res;
  1177. }
  1178. }