AdminCustomerApiController.java 46 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266
  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. if (customerService.checkMax(aid)) {
  721. res.getError().add(buildError("","对方私有客户已达最大限制"));
  722. return res;
  723. }
  724. customerService.updateByOperatorType(uid,oldAid,operatorType, aid);
  725. return res;
  726. }
  727. /**
  728. * 客户转交记录
  729. * @param uid 客户编号
  730. * @param aid 管理员编号
  731. * @param oldAid 接收者编号
  732. * @return
  733. */
  734. @RequestMapping(value = "/transferList", method = RequestMethod.GET)
  735. public Result transferList(String uid){
  736. Result res = new Result();
  737. if(StringUtils.isBlank(uid) ){
  738. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,"客户编号", "客户编号"));
  739. return res;
  740. }
  741. res.data(customerService.transferList( uid));
  742. return res;
  743. }
  744. /** 查询我的业务列表 **/
  745. @RequestMapping(value = "/listBusiness", method = RequestMethod.POST)
  746. public Result listBusiness(BusinessListBo blo,Integer pageNo, Integer pageSize){
  747. Result res = new Result();
  748. res.setData(customerService.listBusiness(blo, pageNo, pageSize));
  749. return res;
  750. }
  751. /** 查询所有的业务列表 **/
  752. @RequestMapping(value = "/listAllBusiness", method = RequestMethod.POST)
  753. public Result listAllBusiness(BusinessListBo blo,Integer pageNo, Integer pageSize){
  754. Result res = new Result();
  755. res.setData(customerService.listAllBusiness(blo, pageNo, pageSize));
  756. return res;
  757. }
  758. /** 业务管理列表 **/
  759. @RequestMapping(value = "/listManageBusiness", method = RequestMethod.POST)
  760. public Result listManageBusiness(BusinessListBo blo,Integer pageNo, Integer pageSize){
  761. Result res = new Result();
  762. res.setData(customerService.listManageBusiness(blo, pageNo, pageSize));
  763. return res;
  764. }
  765. /** 查询业务字典 **/
  766. @RequestMapping(value = "/findBusinessGlossory",method = RequestMethod.GET)
  767. public Result findBusinessGlossory(){
  768. Result res = new Result();
  769. res.setData(customerService.findBusinessGlossory());
  770. return res;
  771. }
  772. /** 新增客户意向 **/
  773. @RequestMapping(value = "/addBusinessAndFollow", method = RequestMethod.POST)
  774. public Result addBusinessAndFollow(BussinessFollowBo bfb){
  775. Result res = new Result();
  776. if(StringUtils.isBlank(bfb.getBusinessProjectId()) || StringUtils.isBlank(bfb.getUid())){
  777. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,""));
  778. return res;
  779. }
  780. if(customerService.judgeBusiness(bfb.getUid(), bfb.getBusinessProjectId())>0){
  781. res.getError().add(new Error("该项业务已经被跟进"));
  782. return res;
  783. }
  784. try {
  785. customerService.addBusinessAndFollow(bfb);
  786. } catch (ParseException e) {
  787. e.printStackTrace();
  788. }
  789. return res;
  790. }
  791. /** 进入新增意向服务 **/
  792. @RequestMapping(value = "/toAddBusinessAndFollow", method = RequestMethod.GET)
  793. public Result toAddBusinessAndFollow(){
  794. Result res = new Result();
  795. BussinessFollowBo bo = new BussinessFollowBo();
  796. bo.setAdminName(TokenManager.getAdminToken().getName());
  797. SimpleDateFormat format = new SimpleDateFormat(AFTConstants.YYYYMMDDHHMMSS);
  798. bo.setCreateTime(format.format(new Date()));
  799. bo.setFollowTime(bo.getCreateTime());
  800. res.setData(bo);
  801. return res;
  802. }
  803. /** 进入修改业务意向 **/
  804. @RequestMapping(value = "/toUpdateBusiness", method = RequestMethod.GET)
  805. public Result toUpdateBusiness(String businessId){
  806. Result res = new Result();
  807. res.setData(customerService.findBusinessDetail(businessId));
  808. return res;
  809. }
  810. /** 修改业务意向 **/
  811. @RequestMapping(value = "/updateBusiness", method = RequestMethod.POST)
  812. public Result updateBusiness(BussinessFollowBo bfb){
  813. Result res = new Result();
  814. customerService.updateBusiness(bfb);
  815. return res;
  816. }
  817. /** 进入跟进单个客户意向 **/
  818. @RequestMapping(value = "/toAddFollowOneBusiness", method = RequestMethod.GET)
  819. public Result toAddFollowOneBusiness(String businessId){
  820. Result res = new Result();
  821. BussinessFollowBo bo = customerService.findBusinessDetail(businessId);
  822. SimpleDateFormat format = new SimpleDateFormat(AFTConstants.YYYYMMDDHHMMSS);
  823. bo.setFollowTime(format.format(new Date()));
  824. res.setData(bo);
  825. return res;
  826. }
  827. /** 跟进单个客户意向 **/
  828. @RequestMapping(value = "/addFollowOneBusiness", method = RequestMethod.POST)
  829. public Result addFollowOneBusiness(BussinessFollowBo bfb){
  830. Result res = new Result();
  831. if(StringUtils.isBlank(bfb.getBusinessId()) ||
  832. StringUtils.isBlank(bfb.getUid()) || StringUtils.isBlank(bfb.getOcbId())){
  833. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, ""));
  834. return res;
  835. }
  836. try {
  837. customerService.addFollowOneBusiness(bfb);
  838. } catch (ParseException e) {
  839. e.printStackTrace();
  840. }
  841. return res;
  842. }
  843. /** 进入修改某个客户一个业务的当次拜访 **/
  844. @RequestMapping(value = "/toUpdateFollowOneBusiness", method = RequestMethod.GET)
  845. public Result toUpdateFollowOneBusiness(String ufbId){
  846. Result res = new Result();
  847. if(StringUtils.isBlank(ufbId)) {
  848. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,""));
  849. return res;
  850. }
  851. res.setData(customerService.findFollowOneBusiness(ufbId));
  852. return res;
  853. }
  854. /** 修改某个客户一个业务的当次拜访 **/
  855. @RequestMapping(value = "/updateFollowOneBusiness", method = RequestMethod.POST)
  856. public Result updateFollowOneBusiness(BussinessFollowBo bfb){
  857. Result res = new Result();
  858. if(StringUtils.isBlank(bfb.getFollowId()) || StringUtils.isBlank(bfb.getUfbId())){
  859. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,""));
  860. return res;
  861. }
  862. customerService.updateFollowOneBusiness(bfb);
  863. return res;
  864. }
  865. /** 删除某个客户一个业务的当次拜访 **/
  866. @RequestMapping(value = "/deleteFollowOneBusiness", method = RequestMethod.GET)
  867. public Result deleteFollowOneBusiness(String ufbId){
  868. Result res = new Result();
  869. if(StringUtils.isBlank(ufbId)){
  870. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,""));
  871. return res;
  872. }
  873. customerService.deleteFollowOneBusiness(ufbId);
  874. return res;
  875. }
  876. /** 添加单个联系人 **/
  877. @RequestMapping(value = "/addOneContact", method = RequestMethod.POST)
  878. public Result addOneContact(OrganizationContactBook ocb){
  879. Result res = new Result();
  880. if(StringUtils.isBlank(ocb.getUid())){
  881. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,""));
  882. return res;
  883. }
  884. if(StringUtils.isBlank(ocb.getName()) || StringUtils.isBlank(ocb.getMobile())){
  885. res.getError().add(buildError("联系人号码和联系人姓名不能为空"));
  886. return res;
  887. }
  888. customerService.addOneContact(ocb);
  889. return res;
  890. }
  891. /** 删除单个联系人 **/
  892. @RequestMapping(value = "/deleteOneContact", method = RequestMethod.GET)
  893. public Result deleteOneContact(String ocbId){
  894. Result res = new Result();
  895. if(StringUtils.isBlank(ocbId)){
  896. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,""));
  897. return res;
  898. }
  899. customerService.deleteOneContact(ocbId);
  900. return res;
  901. }
  902. /** 修改主要联系人 **/
  903. @RequestMapping(value = "/updateMainContact", method = RequestMethod.GET)
  904. public Result updateMainContact(String ocbId,String uid){
  905. Result res = new Result();
  906. if(StringUtils.isBlank(uid) || StringUtils.isBlank(ocbId)){
  907. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,""));
  908. return res;
  909. }
  910. customerService.updateMainContact(ocbId,uid);
  911. return res;
  912. }
  913. /** 删除 业务 **/
  914. @RequestMapping(value = "/deleteBusiness", method =RequestMethod.GET)
  915. public Result deleteBusiness(String businessId){
  916. Result res = new Result();
  917. if(StringUtils.isBlank(businessId)){
  918. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,""));
  919. return res;
  920. }
  921. customerService.deleteBusiness(businessId);
  922. return res;
  923. }
  924. /** 停止业务 **/
  925. @RequestMapping(value = "/stopBusiness", method = RequestMethod.GET)
  926. public Result stopBusiness(String businessId){
  927. Result res = new Result();
  928. if(StringUtils.isBlank(businessId)){
  929. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,""));
  930. return res;
  931. }
  932. customerService.updateBusinessToStop(businessId);
  933. return res;
  934. }
  935. /** 客户分配查询(本部门) **/
  936. @RequestMapping(value = "/findAdminName" , method = RequestMethod.POST)
  937. public Result findAdminName(){
  938. Result res = new Result();
  939. res.setData(customerService.findAdminName());
  940. return res;
  941. }
  942. /** 分配个人客户 **/
  943. @RequestMapping(value = "/updatePersonalCustomerz", method = RequestMethod.POST)
  944. public Result updatePersonalCustomerz(CustomerPersonalDetailBo bo){
  945. Result res = new Result();
  946. if(StringUtils.isBlank(bo.getUid()) || StringUtils.isBlank(bo.getId())){
  947. res.getError().add(buildError(ErrorConstants.PARAM_ERROR,""));
  948. return res;
  949. }
  950. customerService.updatePersonalCustomerz(bo);
  951. return res;
  952. }
  953. /** 客户录入审核 **/
  954. @RequestMapping(value = "/findEnteringAudit" , method = RequestMethod.POST)
  955. public Result findEnteringAudit(CustomerListOut clo,Integer pageNo, Integer pageSize){
  956. Result res = new Result();
  957. res.setData(customerService.findEnteringAudit(clo, pageNo, pageSize));
  958. return res;
  959. }
  960. /** 修改客户录入审核状态 **/
  961. @RequestMapping(value = "/updateEnteringAudit", method = RequestMethod.POST)
  962. public Result updateEnteringAudit(User bo){
  963. Result res = new Result();
  964. if(StringUtils.isBlank(bo.getId())){
  965. res.getError().add(buildError(ErrorConstants.PARAM_ERROR,""));
  966. return res;
  967. }
  968. res.data(customerService.updateEnteringAudit(bo));
  969. return res;
  970. }
  971. /** 审核拒绝客户查询 **/
  972. @RequestMapping(value = "/findEnteringAuditIsNo" , method = RequestMethod.POST)
  973. public Result findEnteringAuditIsNo(CustomerListOut clo,Integer pageNo, Integer pageSize){
  974. Result res = new Result();
  975. res.setData(customerService.findEnteringAuditIsNo(clo, pageNo, pageSize));
  976. return res;
  977. }
  978. /** 修改拒绝客户信息 **/
  979. @RequestMapping(value = "/updateRefusedCustomer", method = RequestMethod.POST)
  980. public Result updateRefusedCustomer(String id,String nickname,String mobile,String societyTag){
  981. Result res = new Result();
  982. if(StringUtils.isBlank(nickname)){
  983. res.getError().add(buildError(ErrorConstants.PARAM_ERROR,"名称"));
  984. return res;
  985. }
  986. if(StringUtils.isBlank(mobile)){
  987. res.getError().add(buildError(ErrorConstants.PARAM_ERROR,"电话"));
  988. return res;
  989. }
  990. if(StringUtils.isBlank(societyTag)){
  991. res.getError().add(buildError(ErrorConstants.PARAM_ERROR,"社会性质"));
  992. return res;
  993. }
  994. customerService.updateRefusedCustomer(id, nickname, mobile, societyTag);
  995. return res;
  996. }
  997. /** 查询客户的锁定业务 **/
  998. @RequestMapping(value = "/getLockedProject", method = RequestMethod.GET)
  999. public Result getLockedProject(String uid){
  1000. Result res = new Result();
  1001. if(StringUtils.isBlank(uid)){
  1002. res.getError().add(buildError(ErrorConstants.PARAM_ERROR,"用户ID"));
  1003. return res;
  1004. }
  1005. res.setData(customerService.selectLockedProject(uid));
  1006. return res;
  1007. }
  1008. /** 客户二次签项目业务 **/
  1009. @RequestMapping(value = "/againProjectTask", method = RequestMethod.GET)
  1010. public Result againProjectTask(String uid,String projectId,String aid){
  1011. Result res = new Result();
  1012. if(StringUtils.isBlank(uid)||StringUtils.isBlank(projectId)){
  1013. res.getError().add(buildError(ErrorConstants.PARAM_ERROR,"参数"));
  1014. return res;
  1015. }
  1016. res.setData(customerService.updateAgainProjectTask(uid,projectId,aid));
  1017. return res;
  1018. }
  1019. /** 客户资料转交 **/
  1020. @RequestMapping(value = "/updateInformationMaintainerr", method = RequestMethod.POST)
  1021. public Result updateInformationMaintainerr(String id,String aid){
  1022. Result res = new Result();
  1023. if(StringUtils.isBlank(id) || StringUtils.isBlank(aid)){
  1024. res.getError().add(buildError(ErrorConstants.PARAM_ERROR,""));
  1025. return res;
  1026. }
  1027. res.data(customerService.updateInformationMaintainerr(id,aid));
  1028. return res;
  1029. }
  1030. /** 个人单位客户信息列表 **/
  1031. @RequestMapping(value = "/listCustomerInformation", method = RequestMethod.POST)
  1032. public Result listCustomerInformation(CustomerListIn cli,Integer pageNo, Integer pageSize){
  1033. Result res = new Result();
  1034. res.data(customerService.listCustomerInformation(cli,pageNo,pageSize));
  1035. return res;
  1036. }
  1037. /** 部门单位客户信息列表 **/
  1038. @RequestMapping(value = "/listDepCustomerInformation", method = RequestMethod.POST)
  1039. public Result listDepCustomerInformation(CustomerListIn cli,Integer pageNo, Integer pageSize){
  1040. Result res = new Result();
  1041. res.data(customerService.listDepCustomerInformation(cli,pageNo,pageSize));
  1042. return res;
  1043. }
  1044. /** 修改客户等级 **/
  1045. @RequestMapping(value = "/updateUserLevel", method = RequestMethod.GET)
  1046. public Result updateUserLevel(User u){
  1047. Result res = new Result();
  1048. if(StringUtils.isBlank(u.getId())){
  1049. res.getError().add(buildError(ErrorConstants.PARAM_ERROR,"用户ID错误","用户ID"));
  1050. return res;
  1051. }
  1052. if(null==u.getLevel()){
  1053. res.getError().add(buildError(ErrorConstants.PARAM_ERROR,"用户等级错误","用户等级"));
  1054. return res;
  1055. }
  1056. res.data(customerService.updateUserLevel(u));
  1057. return res;
  1058. }
  1059. /** 释放客户 **/
  1060. @RequestMapping(value = "/pushReleaseUser", method = RequestMethod.GET)
  1061. public Result pushReleaseUser(String id){
  1062. Result res = new Result();
  1063. if(StringUtils.isBlank(id)){
  1064. res.getError().add(buildError(ErrorConstants.PARAM_ERROR,"用户ID错误","用户ID"));
  1065. return res;
  1066. }
  1067. res.data(customerService.pushReleaseUser(id));
  1068. return res;
  1069. }
  1070. /**
  1071. * 企业项目申报材料上传
  1072. *
  1073. * @param req
  1074. * @param uid
  1075. * @return
  1076. */
  1077. @RequestMapping(value = "/upload", method = RequestMethod.POST)
  1078. public Result cognizanceFile(HttpServletRequest req, String uid, String id, String sign) {
  1079. Result res = new Result();
  1080. AttachmentType attachmentType = AttachmentType.getField(sign);
  1081. if (attachmentType == AttachmentType.ORGANIZATION_APPLICATION) {
  1082. res.setData(handleFiles(res, "/orgApplication/", true, req, sign, uid));
  1083. } else {
  1084. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "附件标示"));
  1085. }
  1086. return res;
  1087. }
  1088. /**
  1089. * 企业项目申报材料预览授权
  1090. *
  1091. * @param id
  1092. * @param sign
  1093. * @return
  1094. */
  1095. @RequestMapping(value = "/techProject", method = RequestMethod.GET)
  1096. public Result previewTechProject(String id, String sign) {
  1097. Result res = new Result();
  1098. if (StringUtils.isEmpty(id)) {
  1099. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "企业项目申报材料ID"));
  1100. return res;
  1101. }
  1102. AttachmentType attachmentType = AttachmentType.getField(sign);
  1103. if (attachmentType == AttachmentType.ORGANIZATION_APPLICATION) {
  1104. String time = String.valueOf(Calendar.getInstance().getTime().getTime());
  1105. String auth = SHA256Util.toHash(sign + "|" + id + "|" + secretKey, time);
  1106. res.setData("sign=" + sign + "&token2=" + id + "&auth=" + auth + "&temp=" + time);
  1107. } else {
  1108. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "附件标示"));
  1109. }
  1110. return res;
  1111. }
  1112. /**
  1113. * 查看营销员客户统计
  1114. * @param depId
  1115. * @param startTime
  1116. * @param endTime
  1117. * @param pageSize
  1118. * @param pageNo
  1119. * @return
  1120. */
  1121. @RequestMapping(value = "/selectAdminCustomerStatistics", method = RequestMethod.GET)
  1122. public Result selectAdminCustomerstatistics(String depId, String startTime,String endTime, Integer pageSize, Integer pageNo) {
  1123. Result res = new Result();
  1124. res.data(adminService.selectAdminCustomerStatistics( depId, startTime, endTime, pageSize, pageNo));
  1125. return res;
  1126. }
  1127. /**
  1128. * 查看客户统计
  1129. * @param depId
  1130. * @param startTime
  1131. * @param endTime
  1132. * @param pageSize
  1133. * @param pageNo
  1134. * @return
  1135. */
  1136. @RequestMapping(value = "/selectAllUser", method = RequestMethod.GET)
  1137. public Result selectAllUser(String depId, String startTime,String endTime,String aName ) {
  1138. Result res = new Result();
  1139. res.data(adminService.selectAllUser( depId, startTime, endTime, aName));
  1140. return res;
  1141. }
  1142. /**
  1143. * 查看客户日期内新增客户
  1144. * @param depId
  1145. * @param startTime
  1146. * @param endTime
  1147. * @param pageSize
  1148. * @param pageNo
  1149. * @return
  1150. */
  1151. @RequestMapping(value = "/selectAdminCustomerList", method = RequestMethod.GET)
  1152. public Result selectAdminCustomerList(String aid, String startTime,String endTime,Integer type, Integer pageSize, Integer pageNo) {
  1153. Result res = new Result();
  1154. res.data(adminService.selectAdminCustomerList( aid, startTime, endTime, type, pageSize, pageNo));
  1155. return res;
  1156. }
  1157. /**
  1158. *
  1159. * @param inputId 业务转移客户id(接收者)
  1160. * @param uid 被转移的客户
  1161. * @param pid 呗转移的业务
  1162. * @return
  1163. */
  1164. @RequestMapping(value = "/privateBusinessTransfer", method = RequestMethod.POST)
  1165. public Result privateBusinessTransfer(String inputId,String uid,String pid ) {
  1166. Result res = new Result();
  1167. if (StringUtils.isBlank(inputId)) {
  1168. res.getError().add(buildError("请确认正确的接收者。","请确认正确的接收者。"));
  1169. return res;
  1170. }
  1171. int i= customerService.updatePrivateBusinessTransfer( inputId, uid, pid );
  1172. if (i<1) {
  1173. res.getError().add(buildError("请确认客户与业务归属是否正确。","请确认客户与业务归属是否正确。"));
  1174. return res;
  1175. }
  1176. res.data(i);
  1177. return res;
  1178. }
  1179. }