AdminCustomerApiController.java 56 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616
  1. package com.goafanti.customer.controller;
  2. import com.alibaba.fastjson.JSON;
  3. import com.alibaba.fastjson.JSONArray;
  4. import com.goafanti.admin.service.AdminService;
  5. import com.goafanti.admin.service.AttachmentService;
  6. import com.goafanti.common.bo.Error;
  7. import com.goafanti.common.bo.Result;
  8. import com.goafanti.common.constant.AFTConstants;
  9. import com.goafanti.common.constant.ErrorConstants;
  10. import com.goafanti.common.controller.BaseApiController;
  11. import com.goafanti.common.enums.AttachmentType;
  12. import com.goafanti.common.error.BusinessException;
  13. import com.goafanti.common.model.Attachment;
  14. import com.goafanti.common.model.OrganizationContactBook;
  15. import com.goafanti.common.model.User;
  16. import com.goafanti.common.utils.*;
  17. import com.goafanti.core.mybatis.page.Pagination;
  18. import com.goafanti.core.shiro.token.TokenManager;
  19. import com.goafanti.customer.bo.*;
  20. import com.goafanti.customer.service.CustomerService;
  21. import org.apache.poi.xssf.usermodel.XSSFWorkbook;
  22. import org.springframework.beans.factory.annotation.Value;
  23. import org.springframework.validation.BindingResult;
  24. import org.springframework.validation.annotation.Validated;
  25. import org.springframework.web.bind.annotation.RequestMapping;
  26. import org.springframework.web.bind.annotation.RequestMethod;
  27. import org.springframework.web.bind.annotation.RequestParam;
  28. import org.springframework.web.bind.annotation.RestController;
  29. import org.springframework.web.multipart.MultipartFile;
  30. import javax.annotation.Resource;
  31. import javax.servlet.http.HttpServletRequest;
  32. import javax.servlet.http.HttpServletResponse;
  33. import java.io.IOException;
  34. import java.io.OutputStream;
  35. import java.lang.reflect.InvocationTargetException;
  36. import java.text.DateFormat;
  37. import java.text.ParseException;
  38. import java.text.SimpleDateFormat;
  39. import java.util.*;
  40. @RestController
  41. @RequestMapping("/api/admin/customer")
  42. public class AdminCustomerApiController extends BaseApiController{
  43. @Resource
  44. private CustomerService customerService;
  45. @Resource
  46. private AttachmentService aftFileService;
  47. @Value(value = "${upload.private.path}")
  48. private String uploadPrivatePath = null;
  49. @Value(value = "${user.receive.max}")
  50. private Integer USER_RECEIVE_MAX = null;
  51. @Resource
  52. private AdminService adminService;
  53. @Value(value = "${aesSecretKey}")
  54. private String secretKey = null;
  55. /** 私有个人客户列表 **/
  56. @RequestMapping(value = "/listPrivatePersonalCustomer" , method = RequestMethod.POST)
  57. public Result listPrivatePersonalCustomer(CustomerListIn cli,Integer pageNo, Integer pageSize){
  58. Result res = new Result();
  59. res.setData(customerService.listPrivatePersonalCustomer(cli, pageNo, pageSize));
  60. return res;
  61. }
  62. /** 公共个人客户列表 **/
  63. @RequestMapping(value = "/listPublicPersonalCustomer" , method = RequestMethod.POST)
  64. public Result listPublicPersonalCustomer(CustomerListIn cli,Integer pageNo, Integer pageSize){
  65. Result res = new Result();
  66. res.setData(customerService.listPublicPersonalCustomer(cli, pageNo, pageSize));
  67. return res;
  68. }
  69. /** 个人客户查询 **/
  70. @RequestMapping(value = "/listAllPersonalCustomer" , method = RequestMethod.POST)
  71. public Result listAllPersonalCustomer(CustomerListIn cli,Integer pageNo, Integer pageSize){
  72. Result res = new Result();
  73. res.setData(customerService.listAllPersonalCustomer(cli, pageNo, pageSize));
  74. return res;
  75. }
  76. /** 签单的个人客户 **/
  77. @RequestMapping(value = "/listSignPersonalCustomer", method = RequestMethod.POST)
  78. public Result listSignPersonalCustomer(CustomerListIn cli,Integer pageNo, Integer pageSize){
  79. Result res = new Result();
  80. res.setData(customerService.listSignPersonalCustomer(cli, pageNo, pageSize));
  81. return res;
  82. }
  83. /** 管理个人客户查询 **/
  84. @RequestMapping(value = "/listAllManagePersonalCustomer" , method = RequestMethod.POST)
  85. public Result listAllManagePersonalCustomer(CustomerListIn cli,Integer pageNo, Integer pageSize){
  86. Result res = new Result();
  87. if (!TokenManager.hasRole(AFTConstants.SUPERADMIN) && !TokenManager.hasRole(AFTConstants.APPROVAL_DECISION)){
  88. cli.setAid(TokenManager.getAdminId());
  89. }
  90. res.setData(customerService.listAllManagePersonalCustomer(cli, pageNo, pageSize));
  91. return res;
  92. }
  93. /** 专家查询 **/
  94. @RequestMapping(value = "/listExpertCustomer" , method = RequestMethod.POST)
  95. public Result listExpertCustomer(CustomerListIn cli,Integer pageNo, Integer pageSize){
  96. Result res = new Result();
  97. res.setData(customerService.listAllManagePersonalCustomer(cli, pageNo, pageSize));
  98. return res;
  99. }
  100. /** 个人客户详情信息 **/
  101. @RequestMapping(value = "/findPersonalCustomerDetail" ,method = RequestMethod.GET)
  102. public Result findPersonalCustomerDetail(String uid){
  103. Result res = new Result();
  104. res.setData(customerService.findPersonalCustomerDetail(uid));
  105. return res;
  106. }
  107. /**
  108. * 私有单位客户列表
  109. * 私有客户列表
  110. **/
  111. @RequestMapping(value = "/listPrivateOrganizationCustomer" , method = RequestMethod.POST)
  112. public Result listPrivateOrganizationCustomer(CustomerListIn cli ,Integer sort,Integer sortType,Integer pageNo, Integer pageSize){
  113. Result res = new Result();
  114. //
  115. res.setData(customerService.listPrivateOrganizationCustomer(cli, sort, sortType, 0, pageNo, pageSize));
  116. return res;
  117. }
  118. /**
  119. * 私有渠道客户列表
  120. *
  121. **/
  122. @RequestMapping(value = "/channelUserList" , method = RequestMethod.GET)
  123. public Result channelUserList(InputChannelListBo in ){
  124. Result res = new Result();
  125. in.setNewChannel(1);
  126. in.setShareType(0);
  127. res.setData(customerService.channelUserList(in));
  128. return res;
  129. }
  130. /**
  131. * 公共渠道客户列表
  132. *
  133. **/
  134. @RequestMapping(value = "/publicChannelUserList" , method = RequestMethod.GET)
  135. public Result publicChannelUserList(InputChannelListBo in ){
  136. Result res = new Result();
  137. in.setNewChannel(1);
  138. //获取公共
  139. in.setShareType(1);
  140. res.setData(customerService.channelUserList(in));
  141. return res;
  142. }
  143. /**
  144. * 渠道客户查询
  145. *
  146. **/
  147. @RequestMapping(value = "/selectChannelUserList" , method = RequestMethod.GET)
  148. public Result selectChannelUserList(InputChannelListBo in ){
  149. Result res = new Result();
  150. in.setNewChannel(1);
  151. if (in.getName()==null||in.getName().length()<2){
  152. res.getError().add(buildError("搜索名字必须大于2个字符"));
  153. return res;
  154. }
  155. res.setData(customerService.selectChannelUserList(in));
  156. return res;
  157. }
  158. /** 跟进管理列表
  159. * 跟进列表
  160. **/
  161. @RequestMapping(value = "/listFollowManagement" , method = RequestMethod.GET)
  162. public Result listFollowManagement(CustomerListIn cli ,Integer sort,Integer sortType,Integer pageNo, Integer pageSize){
  163. Result res = new Result();
  164. res.setData(customerService.listPrivateOrganizationCustomer(cli, sort, sortType, 1, pageNo, pageSize));
  165. return res;
  166. }
  167. /**
  168. * 私有单位客户导出xls
  169. * @throws IOException
  170. */
  171. @RequestMapping(value = "/privateUnitCustomerOutXls" , method = RequestMethod.GET)
  172. public Result privateUnitCustomerOutXls(CustomerListIn cli ,Integer sort,Integer sortType,Integer pageNo, Integer pageSize,HttpServletResponse response) throws IOException{
  173. Result res = new Result();
  174. XSSFWorkbook wb = customerService.privateUnitCustomerOutXls(cli, sort, sortType, pageNo, pageSize);
  175. String fileName = "我的客户列表 " + new SimpleDateFormat("yyyy-MM-dd").format(new Date()) + ".xls";
  176. OutputStream out = null;
  177. try {
  178. out = response.getOutputStream();
  179. } catch (IOException e) {
  180. e.printStackTrace();
  181. }
  182. response.addHeader("Content-Disposition", "attachment;filename=" + new String(fileName.getBytes(),"iso-8859-1"));
  183. response.setContentType("application/octet-stream;charset=utf-8");
  184. try {
  185. // 返回数据流
  186. wb.write(out);
  187. out.flush();
  188. out.close();
  189. } finally {
  190. out.flush();
  191. out.close();
  192. }
  193. return res;
  194. }
  195. /** 公共单位客户列表 **/
  196. @RequestMapping(value = "/listPublicOrganizationCustomer" , method = RequestMethod.POST)
  197. public Result listPublicOrganizationCustomer(CustomerListIn cli,Integer pageNo, Integer pageSize){
  198. Result res = new Result();
  199. res.setData(customerService.listPublicOrganizationCustomer(cli, pageNo, pageSize));
  200. return res;
  201. }
  202. /** 单位客户查询 **/
  203. @RequestMapping(value = "/listAllOrganizationCustomer" , method = RequestMethod.POST)
  204. public Result listAllOrganizationCustomer(CustomerListIn cli,Integer pageNo, Integer pageSize){
  205. Result res = new Result();
  206. if (StringUtils.isBlank(cli.getName())){
  207. res.setData( new Pagination<>());
  208. return res;
  209. }
  210. res.setData(customerService.listAllOrganizationCustomer(cli, pageNo, pageSize));
  211. return res;
  212. }
  213. /** 管理单位客户查询 **/
  214. @RequestMapping(value = "/listAllManageOrganizationCustomer" , method = RequestMethod.POST)
  215. public Result listAllManageOrganizationCustomer(CustomerListIn cli,Integer pageNo, Integer pageSize){
  216. Result res = new Result();
  217. res.setData(customerService.listAllManageOrganizationCustomer(cli, pageNo, pageSize));
  218. return res;
  219. }
  220. /** 签单的单位客户 **/
  221. @RequestMapping(value = "/listSignOrganizationCustomer", method = RequestMethod.POST)
  222. public Result listSignOrganizationCustomer(CustomerListIn cli,Integer pageNo, Integer pageSize){
  223. Result res = new Result();
  224. res.setData(customerService.listSignOrganizationCustomer(cli, pageNo, pageSize));
  225. return res;
  226. }
  227. /** 签单客户转交 **/
  228. @RequestMapping(value = "/customerHandOver", method = RequestMethod.POST)
  229. public Result listSignPersonalCustomer(String userIds ,String receiveId){
  230. Result res = new Result();
  231. res.setData(customerService.customerHandOver( userIds , receiveId));
  232. return res;
  233. }
  234. /** 客户即时检索 **/
  235. @RequestMapping(value = "/findCustomerByName",method = RequestMethod.GET)
  236. public Result findCustomerByName(String name){
  237. Result res = new Result();
  238. res.setData(customerService.findCustomerByName(name));
  239. return res;
  240. }
  241. /** 客户即时检索(可签单客户) **/
  242. @RequestMapping(value = "/getCustomerByName",method = RequestMethod.GET)
  243. public Result getCustomerByName(String name,Integer type){
  244. Result res = new Result();
  245. if(type == null){
  246. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, ""));
  247. return res;
  248. }
  249. if(name.length()<2) return res;
  250. if(type == 0) res.setData(customerService.getPrivateCustomerByName(name));
  251. if(type == 1) res.setData(customerService.getSignedCustomerByName(name));
  252. if(type == 2) res.setData(customerService.getChannelCustomerByName(name));
  253. return res;
  254. }
  255. /** 客户查询 **/
  256. @RequestMapping(value = "/getUserByName",method = RequestMethod.GET)
  257. public Result getUserByName(String name){
  258. Result res = new Result();
  259. if(StringUtils.isEmpty(name)){
  260. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "名称","名称"));
  261. return res;
  262. }
  263. if(name.length()<2) return res;
  264. res.data(customerService.getUserByName(name));
  265. return res;
  266. }
  267. /**
  268. * 客户查询
  269. * @param name 查询名称
  270. * @param type 分类 0默认 1小程序App
  271. * @param pageNo
  272. * @param pageSize
  273. * @return
  274. */
  275. @RequestMapping(value = "/getUserByNames",method = RequestMethod.GET)
  276. public Result getUserByName(String name,Integer type,Integer pageNo,Integer pageSize){
  277. Result res = new Result();
  278. if(StringUtils.isEmpty(name)){
  279. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "名称","名称"));
  280. return res;
  281. }
  282. if(name.length()<2) return res;
  283. res.data(customerService.getUserByNames(name,type,pageNo,pageSize));
  284. return res;
  285. }
  286. /** 添加客户基本信息
  287. * @throws Exception
  288. * @throws NumberFormatException **/
  289. @RequestMapping(value = "/addCustomer", method = RequestMethod.POST)
  290. public Result addCustomer(InputAddCustomer in) {
  291. Result res = new Result();
  292. if(StringUtils.isBlank(in.getName()) || StringUtils.isBlank(in.getContacts())
  293. || StringUtils.isBlank(in.getContactMobile()) ||null==in.getProvince()||null==in.getCity()||null==in.getArea()
  294. || StringUtils.isBlank(in.getBusinessScope())||null==in.getOrgCode()
  295. || StringUtils.isBlank(in.getIntendedProject())){
  296. res.getError().add(buildError("","创建客户参数不全"));
  297. return res;
  298. }
  299. if (!customerService.checkAid(TokenManager.getAdminId(),Integer.valueOf(AFTConstants.CUSTOMER_SERVICE_SALESMAN))){
  300. if (customerService.checkMax(null,TokenManager.getAdminId())) {
  301. res.getError().add(buildError("","私有客户已达最大限制"));
  302. return res;
  303. }
  304. }
  305. if (customerService.checkOrgCode(in.getOrgCode())){
  306. res.getError().add(buildError("","统一信用代码已存在"));
  307. return res;
  308. }
  309. //新增为私有客户
  310. in.setShareType(0);
  311. //将新增客户的空格去除
  312. res.data(customerService.addCustomer(in));
  313. return res;
  314. }
  315. @RequestMapping(value = "/addChannel", method = RequestMethod.POST)
  316. public Result addChannel(@Validated InputAddCustomer in, BindingResult bindingResult) {
  317. Result res = new Result();
  318. if (bindingResult.hasErrors()) {
  319. res.getError().add(buildErrorByMsg(bindingResult.getFieldError().getDefaultMessage(),
  320. ParamUtils.getParamName(in,bindingResult.getFieldError().getField())));
  321. return res;
  322. }
  323. if (customerService.checkUserName(null,in.getName())){
  324. res.getError().add(buildError("客户名称已存在"));
  325. return res;
  326. }
  327. in.setType(1);
  328. //新增为私有客户
  329. in.setShareType(0);
  330. in.setNewChannel(1);
  331. //将新增客户的空格去除
  332. res.data(customerService.addCustomer(in));
  333. return res;
  334. }
  335. /** 单位客户详情信息 **/
  336. @RequestMapping(value = "/findOrganizationCustomerDetail", method = RequestMethod.GET)
  337. public Result findOrganizationCustomerDetail(String uid){
  338. Result res = new Result();
  339. res.setData(customerService.findOrganizationCustomerDetail(uid));
  340. return res;
  341. }
  342. /** 修改单位客户信息 **/
  343. @RequestMapping(value = "/updateOrganizationCustomer", method = RequestMethod.POST)
  344. public Result updateOrganizationCustomer(CustomerOrganizationDetailBo bo){
  345. Result res = new Result();
  346. if(StringUtils.isBlank(bo.getId()) || StringUtils.isBlank(bo.getUid())){
  347. res.getError().add(buildError(ErrorConstants.PARAM_ERROR,""));
  348. return res;
  349. }
  350. customerService.updateOrganizationCustomer(bo);
  351. return res;
  352. }
  353. /** 修改个人客户信息 **/
  354. @RequestMapping(value = "/updatePersonalCustomer", method = RequestMethod.POST)
  355. public Result updatePersonalCustomer(CustomerPersonalDetailBo bo){
  356. Result res = new Result();
  357. if(StringUtils.isBlank(bo.getUid()) || StringUtils.isBlank(bo.getId())){
  358. res.getError().add(buildError(ErrorConstants.PARAM_ERROR,""));
  359. return res;
  360. }
  361. customerService.updatePersonalCustomer(bo);
  362. return res;
  363. }
  364. /** 查看跟进记录 **/
  365. @RequestMapping(value = "/listFollowHistory", method = RequestMethod.GET)
  366. public Result listFollowHistory(Integer pageNo, Integer pageSize,String uid,String businessProjectId,Integer type){
  367. Result res = new Result();
  368. res.setData(customerService.listFollowHistory(pageNo,pageSize,uid,businessProjectId,type));
  369. return res;
  370. }
  371. /** 指导已读 **/
  372. @RequestMapping(value = "/pushGuidance", method = RequestMethod.POST)
  373. public Result pushGuidance(String uid){
  374. Result res = new Result();
  375. if (StringUtils.isBlank(uid)) {
  376. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,"用户编号"));
  377. return res;
  378. }
  379. res.setData(customerService.pushGuidance(uid));
  380. return res;
  381. }
  382. /** 新增指导意见 **/
  383. @RequestMapping(value = "/addGuidance", method = RequestMethod.POST)
  384. public Result addGuidance(String followId,String guidance){
  385. Result res = new Result();
  386. if (StringUtils.isBlank(followId)||StringUtils.isBlank(guidance)) {
  387. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,"编号、指导意见","编号、指导意见"));
  388. return res;
  389. }
  390. res.setData(customerService.addGuidance( followId, guidance));
  391. return res;
  392. }
  393. /** 查看客户账户信息 **/
  394. @RequestMapping(value = "/findUserAccountDetail", method = RequestMethod.GET)
  395. public Result findUserAcountDetail(String uid){
  396. Result res = new Result();
  397. UserDetailBo bo = new UserDetailBo();
  398. User user = customerService.findUserAccountDetail(uid);
  399. try {
  400. BeanUtilsExt.copyProperties(bo, user);
  401. } catch (InvocationTargetException | IllegalAccessException e) {
  402. e.printStackTrace();
  403. }
  404. SimpleDateFormat format = new SimpleDateFormat(AFTConstants.YYYYMMDDHHMMSS);
  405. bo.setCreateTimes(format.format(user.getCreateTime()));
  406. res.setData(bo);
  407. return res;
  408. }
  409. /** 修改客户账户信息 **/
  410. @RequestMapping(value = "/updateUserAccount", method = RequestMethod.POST)
  411. public Result updateUserAccount(User user){
  412. Result res = new Result();
  413. customerService.updateUserAccount(user);
  414. return res;
  415. }
  416. /** 查看客户联系人列表 **/
  417. @RequestMapping(value = "/findCustomerContacts", method = RequestMethod.GET)
  418. public Result findCustomerContacts(String uid){
  419. Result res = new Result();
  420. res.setData(customerService.findCustomerContacts(uid));
  421. return res;
  422. }
  423. /** 针对已作拜访的业务作跟进 **/
  424. @RequestMapping(value = "/toAddFollowOnHistory", method = RequestMethod.GET)
  425. public Result toAddFollowOnHistory(String uid){
  426. Result res = new Result();
  427. if(StringUtils.isBlank(uid)){
  428. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,""));
  429. return res;
  430. }
  431. User user = customerService.findUserAccountDetail(uid);
  432. FollowBusinessBo fbb = new FollowBusinessBo();
  433. SimpleDateFormat format = new SimpleDateFormat(AFTConstants.YYYYMMDDHHMMSS);
  434. fbb.setFollowTime(format.format(new Date()));
  435. fbb.setIdentifyName(user.getIdentifyName());
  436. fbb.setUid(uid);
  437. fbb.setUserBusinessList(customerService.findBusinessByUAid(uid, TokenManager.getAdminId()));
  438. res.setData(fbb);
  439. return res;
  440. }
  441. /** 针对已锁定的业务作跟进 **/
  442. @RequestMapping(value = "/toAddFollowOnLock", method = RequestMethod.GET)
  443. public Result toAddFollowOnLock(String uid){
  444. Result res = new Result();
  445. if(StringUtils.isBlank(uid)){
  446. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,""));
  447. return res;
  448. }
  449. User user = customerService.findUserAccountDetail(uid);
  450. FollowBusinessBo fbb = new FollowBusinessBo();
  451. SimpleDateFormat format = new SimpleDateFormat(AFTConstants.YYYYMMDDHHMMSS);
  452. fbb.setFollowTime(format.format(new Date()));
  453. fbb.setIdentifyName(user.getIdentifyName());
  454. fbb.setUid(uid);
  455. fbb.setUserBusinessList(customerService.findLockedBusinessByUAid(uid, TokenManager.getAdminId()));
  456. res.setData(fbb);
  457. return res;
  458. }
  459. /** 添加拜访记录、客户跟进
  460. * @throws ParseException
  461. * @throws Exception **/
  462. @RequestMapping(value = "/addFollow", method = RequestMethod.POST)
  463. public Result addFollow(String userBusinessList,String uid,String ocbId,String contactType,String result,String followTime) throws BusinessException{
  464. Result res = new Result();
  465. if(StringUtils.isBlank(uid) || StringUtils.isBlank(ocbId)){
  466. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, ""));
  467. return res;
  468. }
  469. JSONArray ja = (JSONArray) JSON.parse(userBusinessList);
  470. List<BusinessListBo> list = new ArrayList<BusinessListBo>();
  471. if (ja != null && !ja.isEmpty()) {
  472. BusinessListBo userBusiness = null;
  473. for (int idx = 0; idx < ja.size(); idx++) {
  474. userBusiness = ja.getJSONObject(idx).toJavaObject(BusinessListBo.class);
  475. for(BusinessListBo ub:list){
  476. if(ub.getBusinessProjectId() == userBusiness.getBusinessProjectId()){
  477. res.getError().add(new com.goafanti.common.bo.Error("业务类型重复,请检查后重新提交!"));
  478. return res;
  479. }
  480. }
  481. list.add(userBusiness);
  482. }
  483. }
  484. FollowBusinessBo fbb = new FollowBusinessBo();
  485. fbb.setOcbId(ocbId);
  486. fbb.setUid(uid);
  487. fbb.setContactType(contactType);
  488. fbb.setResult(result);
  489. fbb.setFollowTime(followTime);
  490. fbb.setUserBusinessList(list);
  491. customerService.addFollow(fbb,null,1);
  492. return res;
  493. }
  494. /** 进入修改拜访记录 **/
  495. @RequestMapping(value = "/toUpdateFollow", method = RequestMethod.GET)
  496. public Result toUpdateFollow(String followId){
  497. Result res = new Result();
  498. FollowBusinessBo fbb = customerService.findFollowById(followId);
  499. fbb.setUserBusinessList(customerService.findBusinessByFollowId(followId));
  500. res.setData(fbb);
  501. return res;
  502. }
  503. /** 修改拜访记录
  504. * @throws ParseException
  505. * @throws BusinessException
  506. */
  507. @RequestMapping(value = "/updateFollow", method = RequestMethod.POST)
  508. public Result updateFollow(String userBusinessList,String followId,String followTime,String uid,String contactType,String result) throws BusinessException{
  509. Result res = new Result();
  510. if(StringUtils.isBlank(uid) || StringUtils.isBlank(followId)){
  511. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, ""));
  512. return res;
  513. }
  514. JSONArray ja = (JSONArray) JSON.parse(userBusinessList);
  515. List<BusinessListBo> list = new ArrayList<BusinessListBo>();
  516. if (ja != null && !ja.isEmpty()) {
  517. BusinessListBo userBusiness = null;
  518. for (int idx = 0; idx < ja.size(); idx++) {
  519. userBusiness = ja.getJSONObject(idx).toJavaObject(BusinessListBo.class);
  520. for(BusinessListBo ub:list){
  521. if(ub.getBusinessProjectId() == userBusiness.getBusinessProjectId()){
  522. res.getError().add(new com.goafanti.common.bo.Error("业务类型重复,请检查后重新提交!"));
  523. return res;
  524. }
  525. }
  526. list.add(userBusiness);
  527. }
  528. }
  529. FollowBusinessBo fbb = new FollowBusinessBo();
  530. fbb.setFollowTime(followTime);
  531. fbb.setUid(uid);
  532. fbb.setContactType(contactType);
  533. fbb.setResult(result);
  534. fbb.setUserBusinessList(list);
  535. fbb.setFollowId(followId);
  536. customerService.updateFollow(fbb);
  537. return res;
  538. }
  539. /** 删除跟进记录 **/
  540. @RequestMapping(value = "/deleteFollow", method = RequestMethod.GET)
  541. public Result deleteFollow(String followId){
  542. Result res = new Result();
  543. if(StringUtils.isBlank(followId)){
  544. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, ""));
  545. return res;
  546. }
  547. customerService.deleteFollow(followId);
  548. return res;
  549. }
  550. /** 查询客户的所有联系人 **/
  551. @RequestMapping(value = "/findAllContacts", method = RequestMethod.GET)
  552. public Result findAllContacts(String uid){
  553. Result res = new Result();
  554. res.setData(customerService.findAllContacts(uid));
  555. return res;
  556. }
  557. /** 修改企业联系人 **/
  558. @RequestMapping(value = "/updateCustomerContacts", method = RequestMethod.POST)
  559. public Result updateCustomerContacts(String contactList,String uid){
  560. Result res = new Result();
  561. if(StringUtils.isBlank(uid)){
  562. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, ""));
  563. return res;
  564. }
  565. JSONArray ja = (JSONArray) JSON.parse(contactList);
  566. List<OrganizationContactBook> ocbList = new ArrayList<OrganizationContactBook>();
  567. OrganizationContactBook ocb = null;
  568. if(ja != null & !ja.isEmpty()){
  569. for (int idx = 0; idx < ja.size(); idx++) {
  570. ocb = ja.getJSONObject(idx).toJavaObject(OrganizationContactBook.class);
  571. if(StringUtils.isBlank(ocb.getMobile()) || StringUtils.isBlank(ocb.getName())){
  572. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "用户名和手机号码为必填"));
  573. return res;
  574. }
  575. if(StringUtils.isBlank(ocb.getUid())) ocb.setUid(uid);
  576. ocbList.add(ocb);
  577. }
  578. }
  579. customerService.updateCustomerContacts(ocbList,uid);
  580. return res;
  581. }
  582. /**
  583. * 领取客户
  584. * @param uid 客户编号
  585. * @param oldAid 原来的客户归属人
  586. * @return
  587. */
  588. @RequestMapping(value = "/receiveCustomer", method = RequestMethod.GET)
  589. public Result receiveCustomer(String uid, String oldAid) {
  590. Result res = new Result();
  591. if (StringUtils.isBlank(uid) || StringUtils.isBlank("oldAid")) {
  592. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, ""));
  593. return res;
  594. }
  595. Integer check =customerService.receiveEveryDay(uid);
  596. if (check!=0){
  597. if (check==-1){
  598. res.getError().add(buildError(ErrorConstants.CUSTOMER_ALREADY_RECEIVE));
  599. return res;
  600. }else if (check==-2){
  601. res.getError().add(buildError(ErrorConstants.CUSTOM_EREXCESS, USER_RECEIVE_MAX.toString(),USER_RECEIVE_MAX.toString()));
  602. return res;
  603. }else if (check==-3){
  604. //客服营销员不限制上线
  605. if (!TokenManager.hasRole(AFTConstants.CUSTOMER_SERVICE_SALESMAN)){
  606. res.getError().add(buildError("", "私有客户已达最大限制"));
  607. return res;
  608. }
  609. }else if (check==-4){
  610. res.getError().add(buildError("", "外联客户丢失后不可再领取"));
  611. return res;
  612. }else {
  613. res.getError().add(buildError("领取参数异常,请联系管理员"));
  614. return res;
  615. }
  616. }
  617. customerService.updateByOperatorType(uid, null, oldAid, AFTConstants.USER_RECEIVE, null);
  618. return res;
  619. }
  620. /**
  621. * 领取为渠道
  622. * @param uid
  623. * @return
  624. */
  625. @RequestMapping(value = "/receiveAsChannel",method=RequestMethod.POST)
  626. public Result receiveAsChannel(String uid){
  627. Result res = new Result();
  628. if (uid ==null ){
  629. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,"客户"));
  630. return res;
  631. }
  632. res.data(customerService.pushReceiveAsChannel(uid));
  633. return res;
  634. }
  635. /**
  636. * 上传excel文档
  637. * @param req
  638. * @return
  639. */
  640. @RequestMapping(value = "/uploadExcel",method = RequestMethod.POST)
  641. public Result uploadExcel(HttpServletRequest req){
  642. Result res = new Result();
  643. String excelPath = handleFile(res, "/customer_sys_file/", true, req, "");
  644. ExcelUtils utils = new ExcelUtils();
  645. Set<CustomerExcelBo> boSet;
  646. try {
  647. boSet = utils.parseExcel(uploadPrivatePath + excelPath);
  648. String errorMessage = "";
  649. if(boSet.size()>100) errorMessage += "导入数据不能超过一百条;";
  650. errorMessage += utils.getVacantRows();
  651. if(StringUtils.isNotBlank(errorMessage)) {
  652. res.getError().add(new Error(errorMessage));
  653. return res;
  654. }
  655. Set<Integer> existRows = new TreeSet<Integer>(); //数据库已存在
  656. Set<Integer> filterRows = new TreeSet<Integer>(); //过滤提示
  657. customerService.checkCustomer(boSet,existRows,filterRows);
  658. if(existRows.size()>0){
  659. errorMessage = StringUtils.join(existRows.toArray(),",")+ " 行客户业务已存在;";
  660. res.getError().add(new Error(errorMessage));
  661. return res;
  662. }
  663. if(filterRows.size()>0){
  664. errorMessage = StringUtils.join(filterRows.toArray(),",")+ " 行已经被系统过滤;";
  665. res.getError().add(new Error(errorMessage));
  666. return res;
  667. }
  668. customerService.saveUploadData(boSet);
  669. } catch (IOException e) {
  670. e.printStackTrace();
  671. }
  672. return res;
  673. }
  674. /**
  675. * 下载科技成果批量导入Excel模板
  676. */
  677. @RequestMapping(value = "/downloadTemplate", method = RequestMethod.GET)
  678. public Result downloadTemplateFile(HttpServletResponse response,String type) {
  679. Result res = new Result();
  680. if(AFTConstants.USER_TYPE_ORGANIZATION.equals(type)){
  681. Attachment af = aftFileService.selectAftFileBySign("organization_customer_template");
  682. if (null == af) {
  683. res.getError().add(buildError(ErrorConstants.FILE_NON_EXISTENT, "", "找不到文件!"));
  684. } else {
  685. String path = af.getFilePath();
  686. String suffix = path.substring(path.lastIndexOf("."));
  687. String fileName = af.getFileName() + suffix;
  688. downloadFile(response, fileName, path);
  689. }
  690. }else if(AFTConstants.USER_TYPE_PERSONAL.equals(type)){
  691. Attachment af = aftFileService.selectAftFileBySign("personal_customer_template");
  692. if (null == af) {
  693. res.getError().add(buildError(ErrorConstants.FILE_NON_EXISTENT, "", "找不到文件!"));
  694. } else {
  695. String path = af.getFilePath();
  696. String suffix = path.substring(path.lastIndexOf("."));
  697. String fileName = af.getFileName() + suffix;
  698. downloadFile(response, fileName, path);
  699. }
  700. }
  701. return res;
  702. }
  703. /**
  704. * 转为公共客户 释放客户
  705. * @param uid
  706. * @param aid
  707. * @return
  708. */
  709. @RequestMapping(value = "/transferToPublic", method = RequestMethod.GET)
  710. public Result transferToPublic(String uid,String aid){
  711. Result res = new Result();
  712. if(StringUtils.isBlank(uid) || StringUtils.isBlank("aid")){
  713. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, ""));
  714. }
  715. customerService.updateByOperatorType(uid, aid,null, AFTConstants.USER_TRANSFER_TO_PUBLIC,null);
  716. return res;
  717. }
  718. /** 图片上传 **/
  719. @RequestMapping(value = "/uploadCustomerImg", method = RequestMethod.POST)
  720. public Result uploadCustomerImg(HttpServletRequest req,String sign){
  721. Result res = new Result();
  722. res.setData(handleFile(res, "/customer_sys_file/", false, req, sign));
  723. return res;
  724. }
  725. /**
  726. *
  727. * @param startDate 开始日期
  728. * @param endDate 结束日期
  729. * @param timeSpan 时间差
  730. * @param depNo 部门编号
  731. * @param pageNo 页码
  732. * @param pageSize 页数
  733. * @return
  734. * @throws ParseException
  735. */
  736. @RequestMapping(value = "/customerStatistics",method = RequestMethod.GET)
  737. public Result customerStatistics(String startDate,String endDate,String timeSpan,String depNo,String businessGlossoryId,Integer pageNo, Integer pageSize) throws ParseException{
  738. Result res = new Result();
  739. Date sDate = null;
  740. Date eDate = null;
  741. DateFormat format = new SimpleDateFormat(AFTConstants.YYYYMMDD);
  742. if(StringUtils.isNotBlank(startDate)) sDate = format.parse(startDate);
  743. if(StringUtils.isNotBlank(endDate)) eDate = format.parse(endDate);
  744. if(StringUtils.isBlank(startDate)&&StringUtils.isBlank(endDate)){
  745. Date date = new Date();
  746. if(timeSpan.equals(DateUtils.DAY_SPAN)){
  747. sDate = DateUtils.getYesterday();
  748. }else if(timeSpan.equals(DateUtils.WEEK_SPAN)){
  749. sDate = DateUtils.getLastDayOfLastWeek(date);
  750. }else if(timeSpan.equals(DateUtils.MONTH_SPAN)){
  751. sDate = DateUtils.getLastDayOfLastMonth(date);
  752. }else if(timeSpan.equals(DateUtils.QUARTER_SPAN)){
  753. sDate = DateUtils.getLastDayOfLastQuarter(date);
  754. }else if(timeSpan.equals(DateUtils.YEAR_SPAN)){
  755. sDate = DateUtils.getLastDayOfLastYear(date);
  756. }
  757. }
  758. res.setData(customerService.customerStatistics(sDate,eDate,depNo,businessGlossoryId,pageNo,pageSize));
  759. return res;
  760. }
  761. /**
  762. *
  763. * @param startDate 开始日期
  764. * @param endDate 结束日期
  765. * @param timeSpan 时间差
  766. * @param depNo 部门编号
  767. * @param businessGlossoryId 业务编号
  768. * @param pageNo 页码
  769. * @param pageSize 页数
  770. * @return
  771. * @throws ParseException
  772. */
  773. @RequestMapping(value = "/businessStatistic", method = RequestMethod.GET)
  774. public Result businessStatistic(String startDate,String endDate,String timeSpan,String depNo,String businessGlossoryId,Integer pageNo, Integer pageSize) throws ParseException{
  775. Result res = new Result();
  776. Date sDate = null;
  777. Date eDate = null;
  778. DateFormat format = new SimpleDateFormat(AFTConstants.YYYYMMDD);
  779. if(StringUtils.isNotBlank(startDate)) sDate = format.parse(startDate);
  780. if(StringUtils.isNotBlank(endDate)) eDate = format.parse(endDate);
  781. if(StringUtils.isBlank(startDate)&&StringUtils.isBlank(endDate)){
  782. Date date = new Date();
  783. if(timeSpan.equals(DateUtils.DAY_SPAN)){
  784. sDate = DateUtils.getYesterday();
  785. }else if(timeSpan.equals(DateUtils.WEEK_SPAN)){
  786. sDate = DateUtils.getLastDayOfLastWeek(date);
  787. }else if(timeSpan.equals(DateUtils.MONTH_SPAN)){
  788. sDate = DateUtils.getLastDayOfLastMonth(date);
  789. }else if(timeSpan.equals(DateUtils.QUARTER_SPAN)){
  790. sDate = DateUtils.getLastDayOfLastQuarter(date);
  791. }else if(timeSpan.equals(DateUtils.YEAR_SPAN)){
  792. sDate = DateUtils.getLastDayOfLastYear(date);
  793. }
  794. }
  795. res.setData(customerService.businessStatistic(sDate,eDate,depNo,businessGlossoryId,pageNo,pageSize));
  796. return res;
  797. }
  798. /**
  799. *
  800. * @param startDate 开始日期
  801. * @param endDate 结束日期
  802. * @param timeSpan 时间差
  803. * @param depNo 部门编号
  804. * @param pageNo 页码
  805. * @param pageSize 页数
  806. * @return
  807. * @throws ParseException
  808. */
  809. @RequestMapping(value = "/followStatistic",method = RequestMethod.GET)
  810. public Result followStatistic(String startDate,String endDate,String timeSpan,String depNo,Integer pageNo, Integer pageSize) throws ParseException{
  811. Result res = new Result();
  812. Date sDate = null;
  813. Date eDate = null;
  814. DateFormat format = new SimpleDateFormat(AFTConstants.YYYYMMDD);
  815. if(StringUtils.isNotBlank(startDate)) sDate = format.parse(startDate);
  816. if(StringUtils.isNotBlank(endDate)) eDate = format.parse(endDate);
  817. if(StringUtils.isBlank(startDate)&&StringUtils.isBlank(endDate)){
  818. Date date = new Date();
  819. if(timeSpan.equals(DateUtils.DAY_SPAN)){
  820. sDate = DateUtils.getYesterday();
  821. }else if(timeSpan.equals(DateUtils.WEEK_SPAN)){
  822. sDate = DateUtils.getLastDayOfLastWeek(date);
  823. }else if(timeSpan.equals(DateUtils.MONTH_SPAN)){
  824. sDate = DateUtils.getLastDayOfLastMonth(date);
  825. }else if(timeSpan.equals(DateUtils.QUARTER_SPAN)){
  826. sDate = DateUtils.getLastDayOfLastQuarter(date);
  827. }else if(timeSpan.equals(DateUtils.YEAR_SPAN)){
  828. sDate = DateUtils.getLastDayOfLastYear(date);
  829. }
  830. }
  831. res.setData(customerService.followStatistic(sDate, eDate, depNo, pageNo, pageSize));
  832. return res;
  833. }
  834. /**
  835. * 管理员列表
  836. * @param adminName 名称
  837. * @param status 0 正常 1锁定 2全部
  838. * @return
  839. */
  840. @RequestMapping(value = "/listAdminByName",method = RequestMethod.GET)
  841. public Result listAdminByName(String adminName,Integer status){
  842. Result res = new Result();
  843. adminName=adminName.trim();
  844. if(StringUtils.isNotBlank(adminName))res.setData(adminService.listAdminByName(adminName,status));
  845. return res;
  846. }
  847. /**
  848. * 客户转交 私有客户转交,签单客户转交
  849. * @param uid 用户编号
  850. * @param aid
  851. * @param operatorType 3私有 4签单
  852. * @param oldAid
  853. * @param data 资料同步转移 0无 1资料转交 2订单转交 3全部转交
  854. * @return
  855. */
  856. @RequestMapping(value = "/transferToOther", method = RequestMethod.GET)
  857. public Result transferToOther(String uid,String aid,Integer operatorType,Integer data,String oldAid){
  858. Result res = new Result();
  859. if(StringUtils.isBlank(uid) || StringUtils.isBlank(aid)){
  860. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "客户编号或管理员编号"));
  861. return res;
  862. }
  863. //默认为私有转交,4为签单转交
  864. if (operatorType==null) operatorType=AFTConstants.USER_TRANSFER_TO_OTHER;
  865. //转交,对方不是客服营销员才需要判断最大限制
  866. if (operatorType ==AFTConstants.USER_TRANSFER_TO_OTHER&&(!customerService.checkAid(aid,Integer.valueOf(AFTConstants.CUSTOMER_SERVICE_SALESMAN)))){
  867. if (customerService.checkMax(uid,aid)){
  868. res.getError().add(buildError("","对方私有客户已达最大限制"));
  869. return res;
  870. }
  871. }
  872. if(data==null)data=0;
  873. res.setData(customerService.updateByOperatorType(uid, aid, oldAid, operatorType, data));
  874. return res;
  875. }
  876. /**
  877. * 客户转交记录
  878. * @param uid 客户编号
  879. * @return
  880. */
  881. @RequestMapping(value = "/transferList", method = RequestMethod.GET)
  882. public Result transferList(String uid){
  883. Result res = new Result();
  884. if(StringUtils.isBlank(uid) ){
  885. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,"客户编号", "客户编号"));
  886. return res;
  887. }
  888. res.data(customerService.transferList( uid));
  889. return res;
  890. }
  891. /** 查询我的业务列表 **/
  892. @RequestMapping(value = "/listBusiness", method = RequestMethod.POST)
  893. public Result listBusiness(BusinessListBo blo,Integer pageNo, Integer pageSize){
  894. Result res = new Result();
  895. res.setData(customerService.listBusiness(blo, pageNo, pageSize));
  896. return res;
  897. }
  898. /** 查询所有的业务列表 **/
  899. @RequestMapping(value = "/listAllBusiness", method = RequestMethod.POST)
  900. public Result listAllBusiness(BusinessListBo blo,Integer pageNo, Integer pageSize){
  901. Result res = new Result();
  902. res.setData(customerService.listAllBusiness(blo, pageNo, pageSize));
  903. return res;
  904. }
  905. /** 业务管理列表 **/
  906. @RequestMapping(value = "/listManageBusiness", method = RequestMethod.POST)
  907. public Result listManageBusiness(BusinessListBo blo,Integer pageNo, Integer pageSize){
  908. Result res = new Result();
  909. res.setData(customerService.listManageBusiness(blo, pageNo, pageSize));
  910. return res;
  911. }
  912. /** 查询业务字典 **/
  913. @RequestMapping(value = "/findBusinessGlossory",method = RequestMethod.GET)
  914. public Result findBusinessGlossory(){
  915. Result res = new Result();
  916. res.setData(customerService.findBusinessGlossory());
  917. return res;
  918. }
  919. /** 新增客户意向 **/
  920. @RequestMapping(value = "/addBusinessAndFollow", method = RequestMethod.POST)
  921. public Result addBusinessAndFollow(BussinessFollowBo bfb){
  922. Result res = new Result();
  923. if(StringUtils.isBlank(bfb.getBusinessProjectId()) || StringUtils.isBlank(bfb.getUid())){
  924. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,""));
  925. return res;
  926. }
  927. if(customerService.judgeBusiness(bfb.getUid(), bfb.getBusinessProjectId())>0){
  928. res.getError().add(new Error("该项业务已经被跟进"));
  929. return res;
  930. }
  931. try {
  932. customerService.addBusinessAndFollow(bfb);
  933. } catch (ParseException e) {
  934. e.printStackTrace();
  935. }
  936. return res;
  937. }
  938. /** 进入新增意向服务 **/
  939. @RequestMapping(value = "/toAddBusinessAndFollow", method = RequestMethod.GET)
  940. public Result toAddBusinessAndFollow(){
  941. Result res = new Result();
  942. BussinessFollowBo bo = new BussinessFollowBo();
  943. bo.setAdminName(TokenManager.getAdminToken().getName());
  944. SimpleDateFormat format = new SimpleDateFormat(AFTConstants.YYYYMMDDHHMMSS);
  945. bo.setCreateTime(format.format(new Date()));
  946. bo.setFollowTime(bo.getCreateTime());
  947. res.setData(bo);
  948. return res;
  949. }
  950. /** 进入修改业务意向 **/
  951. @RequestMapping(value = "/toUpdateBusiness", method = RequestMethod.GET)
  952. public Result toUpdateBusiness(String businessId){
  953. Result res = new Result();
  954. res.setData(customerService.findBusinessDetail(businessId));
  955. return res;
  956. }
  957. /** 修改业务意向 **/
  958. @RequestMapping(value = "/updateBusiness", method = RequestMethod.POST)
  959. public Result updateBusiness(BussinessFollowBo bfb){
  960. Result res = new Result();
  961. customerService.updateBusiness(bfb);
  962. return res;
  963. }
  964. /** 进入跟进单个客户意向 **/
  965. @RequestMapping(value = "/toAddFollowOneBusiness", method = RequestMethod.GET)
  966. public Result toAddFollowOneBusiness(String businessId){
  967. Result res = new Result();
  968. BussinessFollowBo bo = customerService.findBusinessDetail(businessId);
  969. SimpleDateFormat format = new SimpleDateFormat(AFTConstants.YYYYMMDDHHMMSS);
  970. bo.setFollowTime(format.format(new Date()));
  971. res.setData(bo);
  972. return res;
  973. }
  974. /** 跟进单个客户意向 **/
  975. @RequestMapping(value = "/addFollowOneBusiness", method = RequestMethod.POST)
  976. public Result addFollowOneBusiness(BussinessFollowBo bfb){
  977. Result res = new Result();
  978. if(StringUtils.isBlank(bfb.getBusinessId()) ||
  979. StringUtils.isBlank(bfb.getUid()) || StringUtils.isBlank(bfb.getOcbId())){
  980. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, ""));
  981. return res;
  982. }
  983. try {
  984. customerService.addFollowOneBusiness(bfb);
  985. } catch (ParseException e) {
  986. e.printStackTrace();
  987. }
  988. return res;
  989. }
  990. /** 进入修改某个客户一个业务的当次拜访 **/
  991. @RequestMapping(value = "/toUpdateFollowOneBusiness", method = RequestMethod.GET)
  992. public Result toUpdateFollowOneBusiness(String ufbId){
  993. Result res = new Result();
  994. if(StringUtils.isBlank(ufbId)) {
  995. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,""));
  996. return res;
  997. }
  998. res.setData(customerService.findFollowOneBusiness(ufbId));
  999. return res;
  1000. }
  1001. /** 修改某个客户一个业务的当次拜访 **/
  1002. @RequestMapping(value = "/updateFollowOneBusiness", method = RequestMethod.POST)
  1003. public Result updateFollowOneBusiness(BussinessFollowBo bfb){
  1004. Result res = new Result();
  1005. if(StringUtils.isBlank(bfb.getFollowId()) || StringUtils.isBlank(bfb.getUfbId())){
  1006. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,""));
  1007. return res;
  1008. }
  1009. customerService.updateFollowOneBusiness(bfb);
  1010. return res;
  1011. }
  1012. /** 删除某个客户一个业务的当次拜访 **/
  1013. @RequestMapping(value = "/deleteFollowOneBusiness", method = RequestMethod.GET)
  1014. public Result deleteFollowOneBusiness(String ufbId){
  1015. Result res = new Result();
  1016. if(StringUtils.isBlank(ufbId)){
  1017. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,""));
  1018. return res;
  1019. }
  1020. customerService.deleteFollowOneBusiness(ufbId);
  1021. return res;
  1022. }
  1023. /** 添加单个联系人 **/
  1024. @RequestMapping(value = "/addOneContact", method = RequestMethod.POST)
  1025. public Result addOneContact(OrganizationContactBook ocb){
  1026. Result res = new Result();
  1027. if(StringUtils.isBlank(ocb.getUid())){
  1028. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,""));
  1029. return res;
  1030. }
  1031. if(StringUtils.isBlank(ocb.getName()) || StringUtils.isBlank(ocb.getMobile())){
  1032. res.getError().add(buildError("联系人号码和联系人姓名不能为空"));
  1033. return res;
  1034. }
  1035. customerService.addOneContact(ocb);
  1036. return res;
  1037. }
  1038. /** 删除单个联系人 **/
  1039. @RequestMapping(value = "/deleteOneContact", method = RequestMethod.GET)
  1040. public Result deleteOneContact(String ocbId){
  1041. Result res = new Result();
  1042. if(StringUtils.isBlank(ocbId)){
  1043. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,""));
  1044. return res;
  1045. }
  1046. customerService.deleteOneContact(ocbId);
  1047. return res;
  1048. }
  1049. /** 修改主要联系人 **/
  1050. @RequestMapping(value = "/updateMainContact", method = RequestMethod.GET)
  1051. public Result updateMainContact(String ocbId,String uid){
  1052. Result res = new Result();
  1053. if(StringUtils.isBlank(uid) || StringUtils.isBlank(ocbId)){
  1054. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,""));
  1055. return res;
  1056. }
  1057. customerService.updateMainContact(ocbId,uid);
  1058. return res;
  1059. }
  1060. /** 删除 业务 **/
  1061. @RequestMapping(value = "/deleteBusiness", method =RequestMethod.GET)
  1062. public Result deleteBusiness(String businessId){
  1063. Result res = new Result();
  1064. if(StringUtils.isBlank(businessId)){
  1065. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,""));
  1066. return res;
  1067. }
  1068. customerService.deleteBusiness(businessId);
  1069. return res;
  1070. }
  1071. /** 停止业务 **/
  1072. @RequestMapping(value = "/stopBusiness", method = RequestMethod.GET)
  1073. public Result stopBusiness(String businessId){
  1074. Result res = new Result();
  1075. if(StringUtils.isBlank(businessId)){
  1076. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,""));
  1077. return res;
  1078. }
  1079. customerService.updateBusinessToStop(businessId);
  1080. return res;
  1081. }
  1082. /** 客户分配查询(本部门) **/
  1083. @RequestMapping(value = "/findAdminName" , method = RequestMethod.POST)
  1084. public Result findAdminName(){
  1085. Result res = new Result();
  1086. res.setData(customerService.findAdminName());
  1087. return res;
  1088. }
  1089. /** 分配个人客户 **/
  1090. @RequestMapping(value = "/updatePersonalCustomerz", method = RequestMethod.POST)
  1091. public Result updatePersonalCustomerz(CustomerPersonalDetailBo bo){
  1092. Result res = new Result();
  1093. if(StringUtils.isBlank(bo.getUid()) || StringUtils.isBlank(bo.getId())){
  1094. res.getError().add(buildError(ErrorConstants.PARAM_ERROR,""));
  1095. return res;
  1096. }
  1097. customerService.updatePersonalCustomerz(bo);
  1098. return res;
  1099. }
  1100. /** 客户录入审核 **/
  1101. @RequestMapping(value = "/findEnteringAudit" , method = RequestMethod.POST)
  1102. public Result findEnteringAudit(CustomerListOut clo,Integer pageNo, Integer pageSize){
  1103. Result res = new Result();
  1104. res.setData(customerService.findEnteringAudit(clo, pageNo, pageSize));
  1105. return res;
  1106. }
  1107. /** 修改客户录入审核状态 **/
  1108. @RequestMapping(value = "/updateEnteringAudit", method = RequestMethod.POST)
  1109. public Result updateEnteringAudit(User bo){
  1110. Result res = new Result();
  1111. if(StringUtils.isBlank(bo.getId())){
  1112. res.getError().add(buildError(ErrorConstants.PARAM_ERROR,""));
  1113. return res;
  1114. }
  1115. res.data(customerService.updateEnteringAudit(bo));
  1116. return res;
  1117. }
  1118. /** 审核拒绝客户查询 **/
  1119. @RequestMapping(value = "/findEnteringAuditIsNo" , method = RequestMethod.POST)
  1120. public Result findEnteringAuditIsNo(CustomerListOut clo,Integer pageNo, Integer pageSize){
  1121. Result res = new Result();
  1122. res.setData(customerService.findEnteringAuditIsNo(clo, pageNo, pageSize));
  1123. return res;
  1124. }
  1125. /** 修改拒绝客户信息 **/
  1126. @RequestMapping(value = "/updateRefusedCustomer", method = RequestMethod.POST)
  1127. public Result updateRefusedCustomer(String id,String nickname,String mobile,String societyTag){
  1128. Result res = new Result();
  1129. if(StringUtils.isBlank(nickname)){
  1130. res.getError().add(buildError(ErrorConstants.PARAM_ERROR,"名称"));
  1131. return res;
  1132. }
  1133. if(StringUtils.isBlank(mobile)){
  1134. res.getError().add(buildError(ErrorConstants.PARAM_ERROR,"电话"));
  1135. return res;
  1136. }
  1137. if(StringUtils.isBlank(societyTag)){
  1138. res.getError().add(buildError(ErrorConstants.PARAM_ERROR,"社会性质"));
  1139. return res;
  1140. }
  1141. customerService.updateRefusedCustomer(id, nickname, mobile, societyTag);
  1142. return res;
  1143. }
  1144. /** 查询客户的锁定业务 **/
  1145. @RequestMapping(value = "/getLockedProject", method = RequestMethod.GET)
  1146. public Result getLockedProject(String uid){
  1147. Result res = new Result();
  1148. if(StringUtils.isBlank(uid)){
  1149. res.getError().add(buildError(ErrorConstants.PARAM_ERROR,"用户ID"));
  1150. return res;
  1151. }
  1152. res.setData(customerService.selectLockedProject(uid));
  1153. return res;
  1154. }
  1155. /** 客户二次签项目业务 **/
  1156. @RequestMapping(value = "/againProjectTask", method = RequestMethod.GET)
  1157. public Result againProjectTask(String uid,String projectId,String aid){
  1158. Result res = new Result();
  1159. if(StringUtils.isBlank(uid)||StringUtils.isBlank(projectId)){
  1160. res.getError().add(buildError(ErrorConstants.PARAM_ERROR,"参数"));
  1161. return res;
  1162. }
  1163. res.setData(customerService.updateAgainProjectTask(uid,projectId,aid));
  1164. return res;
  1165. }
  1166. /** 客户资料转交 **/
  1167. @RequestMapping(value = "/updateInformationMaintainerr", method = RequestMethod.POST)
  1168. public Result updateInformationMaintainerr(String id,String aid){
  1169. Result res = new Result();
  1170. if(StringUtils.isBlank(id) || StringUtils.isBlank(aid)){
  1171. res.getError().add(buildError(ErrorConstants.PARAM_ERROR,""));
  1172. return res;
  1173. }
  1174. res.data(customerService.updateInformationMaintainerr(id,aid));
  1175. return res;
  1176. }
  1177. /** 个人单位客户信息列表 **/
  1178. @RequestMapping(value = "/listCustomerInformation", method = RequestMethod.POST)
  1179. public Result listCustomerInformation(CustomerListIn cli,Integer pageNo, Integer pageSize){
  1180. Result res = new Result();
  1181. res.data(customerService.listCustomerInformation(cli,pageNo,pageSize));
  1182. return res;
  1183. }
  1184. /** 部门单位客户信息列表 **/
  1185. @RequestMapping(value = "/listDepCustomerInformation", method = RequestMethod.POST)
  1186. public Result listDepCustomerInformation(CustomerListIn cli,Integer pageNo, Integer pageSize){
  1187. Result res = new Result();
  1188. res.data(customerService.listDepCustomerInformation(cli,pageNo,pageSize));
  1189. return res;
  1190. }
  1191. /** 修改客户等级 **/
  1192. @RequestMapping(value = "/updateUserLevel", method = RequestMethod.GET)
  1193. public Result updateUserLevel(User u){
  1194. Result res = new Result();
  1195. if(StringUtils.isBlank(u.getId())){
  1196. res.getError().add(buildError(ErrorConstants.PARAM_ERROR,"用户ID错误","用户ID"));
  1197. return res;
  1198. }
  1199. if(null==u.getLevel()){
  1200. res.getError().add(buildError(ErrorConstants.PARAM_ERROR,"用户等级错误","用户等级"));
  1201. return res;
  1202. }
  1203. res.data(customerService.updateUserLevel(u));
  1204. return res;
  1205. }
  1206. /** 释放客户 **/
  1207. @RequestMapping(value = "/pushReleaseUser", method = RequestMethod.GET)
  1208. public Result pushReleaseUser(String id){
  1209. Result res = new Result();
  1210. if(StringUtils.isBlank(id)){
  1211. res.getError().add(buildError(ErrorConstants.PARAM_ERROR,"用户ID错误","用户ID"));
  1212. return res;
  1213. }
  1214. res.data(customerService.pushReleaseUser(id));
  1215. return res;
  1216. }
  1217. /**
  1218. * 企业项目申报材料上传
  1219. *
  1220. * @param req
  1221. * @param uid
  1222. * @return
  1223. */
  1224. @RequestMapping(value = "/upload", method = RequestMethod.POST)
  1225. public Result cognizanceFile(HttpServletRequest req, String uid, String id, String sign) {
  1226. Result res = new Result();
  1227. AttachmentType attachmentType = AttachmentType.getField(sign);
  1228. if (attachmentType == AttachmentType.ORGANIZATION_APPLICATION) {
  1229. res.setData(handleFiles(res, "/orgApplication/", true, req, sign, uid));
  1230. } else {
  1231. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "附件标示"));
  1232. }
  1233. return res;
  1234. }
  1235. /**
  1236. * 企业项目申报材料预览授权
  1237. *
  1238. * @param id
  1239. * @param sign
  1240. * @return
  1241. */
  1242. @RequestMapping(value = "/techProject", method = RequestMethod.GET)
  1243. public Result previewTechProject(String id, String sign) {
  1244. Result res = new Result();
  1245. if (StringUtils.isEmpty(id)) {
  1246. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "企业项目申报材料ID"));
  1247. return res;
  1248. }
  1249. AttachmentType attachmentType = AttachmentType.getField(sign);
  1250. if (attachmentType == AttachmentType.ORGANIZATION_APPLICATION) {
  1251. String time = String.valueOf(Calendar.getInstance().getTime().getTime());
  1252. String auth = SHA256Util.toHash(sign + "|" + id + "|" + secretKey, time);
  1253. res.setData("sign=" + sign + "&token2=" + id + "&auth=" + auth + "&temp=" + time);
  1254. } else {
  1255. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "附件标示"));
  1256. }
  1257. return res;
  1258. }
  1259. /**
  1260. * 查看营销员客户统计
  1261. * @param depId
  1262. * @param startTime
  1263. * @param endTime
  1264. * @param pageSize
  1265. * @param pageNo
  1266. * @return
  1267. */
  1268. @RequestMapping(value = "/selectAdminCustomerStatistics", method = RequestMethod.GET)
  1269. public Result selectAdminCustomerstatistics(String depId, String startTime,String endTime, Integer pageSize, Integer pageNo) {
  1270. Result res = new Result();
  1271. res.data(adminService.selectAdminCustomerStatistics( depId, startTime, endTime, pageSize, pageNo));
  1272. return res;
  1273. }
  1274. /**
  1275. * 查看客户统计
  1276. * @param depId 部门编号
  1277. * @param startTime 开始时间
  1278. * @param endTime 结束时间
  1279. * @return
  1280. */
  1281. @RequestMapping(value = "/selectAllUser", method = RequestMethod.GET)
  1282. public Result selectAllUser(String depId, String startTime,String endTime,String aName ) {
  1283. Result res = new Result();
  1284. res.data(adminService.selectAllUser( depId, startTime, endTime, aName));
  1285. return res;
  1286. }
  1287. /**
  1288. * 查看客户日期内新增客户
  1289. * @param type 0私有 1渠道 2签单 3私有新增 4渠道新增 5私有面谈 6渠道面谈 7私有领取 8 私有转交
  1290. */
  1291. @RequestMapping(value = "/selectAdminCustomerList", method = RequestMethod.GET)
  1292. public Result selectAdminCustomerList(String aid, String startTime,String endTime,Integer type, Integer pageSize, Integer pageNo) {
  1293. Result res = new Result();
  1294. res.data(adminService.selectAdminCustomerList( aid, startTime, endTime, type, pageSize, pageNo));
  1295. return res;
  1296. }
  1297. /**
  1298. *
  1299. * @param inputId 业务转移客户id(接收者)
  1300. * @param uid 被转移的客户
  1301. * @param pid 呗转移的业务
  1302. * @return
  1303. */
  1304. @RequestMapping(value = "/privateBusinessTransfer", method = RequestMethod.POST)
  1305. public Result privateBusinessTransfer(String inputId,String uid,String pid ) {
  1306. Result res = new Result();
  1307. if (StringUtils.isBlank(inputId)) {
  1308. res.getError().add(buildError("请确认正确的接收者。","请确认正确的接收者。"));
  1309. return res;
  1310. }
  1311. int i= customerService.updatePrivateBusinessTransfer( inputId, uid, pid );
  1312. if (i<1) {
  1313. res.getError().add(buildError("请确认客户与业务归属是否正确。","请确认客户与业务归属是否正确。"));
  1314. return res;
  1315. }
  1316. res.data(i);
  1317. return res;
  1318. }
  1319. /**
  1320. * 渠道客户列表
  1321. **/
  1322. @RequestMapping(value = "/listChannelCustomer" , method = RequestMethod.POST)
  1323. public Result listChannelCustomer(InputListChannel in){
  1324. Result res = new Result();
  1325. res.setData(customerService.listChannelCustomer(in));
  1326. return res;
  1327. }
  1328. /**
  1329. * 渠道客户统计列表
  1330. **/
  1331. @RequestMapping(value = "/listChannelCounts" , method = RequestMethod.GET)
  1332. public Result listChannelCounts(InputChannelCounts in){
  1333. Result res = new Result();
  1334. res.setData(customerService.listChannelCounts(in));
  1335. return res;
  1336. }
  1337. /**
  1338. * 渠道客户转交
  1339. * @param userIds 用户编号集
  1340. * @param receiveId 接受者
  1341. * @param remarks 备注
  1342. * @param type 0 分配 1转交 2回退
  1343. * @return
  1344. */
  1345. @RequestMapping(value = "/channelCustomerDeliver", method = RequestMethod.POST)
  1346. public Result channelCustomerDeliver(String userIds ,String receiveId,String remarks,Integer type){
  1347. Result res = new Result();
  1348. if (StringUtils.isBlank(userIds)) {
  1349. res.getError().add(buildError("","用户编号不存在"));
  1350. return res;
  1351. }
  1352. String [] str=userIds.split(",");
  1353. List<String> uids=Arrays.asList(str);
  1354. if (type==1&&customerService.checkChannel(uids)) {
  1355. res.getError().add(buildError("","已跟进,禁止分配!"));
  1356. return res;
  1357. }
  1358. if (type==2&&customerService.checkRecovery(uids)) {
  1359. res.getError().add(buildError("","不允许二次回退"));
  1360. return res;
  1361. }
  1362. res.setData(customerService.pushChannelDeliver( uids , receiveId,remarks,type));
  1363. return res;
  1364. }
  1365. /** 修改客户名称 **/
  1366. @RequestMapping(value = "/updateUserName", method = RequestMethod.POST)
  1367. public Result updateUserName(String uid,String userName){
  1368. Result res = new Result();
  1369. if(StringUtils.isBlank(uid) || StringUtils.isBlank(userName)){
  1370. res.getError().add(buildError(ErrorConstants.PARAM_ERROR,null,"uid或者名称"));
  1371. return res;
  1372. }
  1373. if (userName!=null){
  1374. userName=userName.trim();
  1375. }
  1376. if(customerService.checkUserName(uid,userName)){
  1377. res.getError().add(buildError(ErrorConstants.CUSTOMER_ALREADY_EXIST,null,"["+userName+"]"));
  1378. return res;
  1379. }
  1380. res.data(customerService.updateUserName(uid,userName));
  1381. return res;
  1382. }
  1383. @RequestMapping(value = "/checkUserName",method = RequestMethod.GET)
  1384. public Result checkUserName(String userName){
  1385. Result res =new Result();
  1386. res.data(customerService.checkUserName(null,userName));
  1387. return res;
  1388. }
  1389. /** 修改客户关键资料 **/
  1390. @RequestMapping(value = "/updateUserDate", method = RequestMethod.POST)
  1391. public Result updateUserDate(String uid,Integer province,Integer city,Integer area,String businessScope,String intendedProject,String introduction
  1392. ,Integer channelType,String orgCode){
  1393. Result res = new Result();
  1394. if (orgCode!=null){
  1395. orgCode=orgCode.trim();
  1396. if (customerService.checkOrgCode(orgCode)){
  1397. res.getError().add(buildError("","统一信用代码已存在"));
  1398. return res;
  1399. }
  1400. }
  1401. res.data(customerService.updateUserDate(uid, province, city, area, businessScope, intendedProject,introduction,channelType,orgCode));
  1402. return res;
  1403. }
  1404. /** 客户名称列表 **/
  1405. @RequestMapping(value = "/listUserName", method = RequestMethod.GET)
  1406. public Result listUserName(String uid){
  1407. Result res = new Result();
  1408. if(StringUtils.isBlank(uid) || StringUtils.isBlank(uid)){
  1409. res.getError().add(buildError(ErrorConstants.PARAM_ERROR,"uid","uid"));
  1410. return res;
  1411. }
  1412. res.data(customerService.listUserName(uid));
  1413. return res;
  1414. }
  1415. /**
  1416. * 客户主营产品列表
  1417. * @return
  1418. */
  1419. @RequestMapping(value = "/mainProductsList", method = RequestMethod.GET)
  1420. public Result mainProductsList(InputMainProductsList in){
  1421. Result res = new Result();
  1422. res.data(customerService.mainProductsList(in));
  1423. return res;
  1424. }
  1425. /**
  1426. * 用户信息日志
  1427. * @param uid
  1428. * @return
  1429. */
  1430. @RequestMapping(value = "/userDateLogList",method = RequestMethod.GET)
  1431. public Result userDateLogList(String uid){
  1432. Result res =new Result();
  1433. res.data(customerService.userDateLogList(uid));
  1434. return res;
  1435. }
  1436. /**
  1437. * 修改用户主营产品
  1438. * @param id
  1439. * @param businessScope
  1440. * @return
  1441. */
  1442. @RequestMapping(value = "/updateUserBusinessScope",method = RequestMethod.POST)
  1443. public Result updateUserBusinessScope(String id,String businessScope){
  1444. Result res=new Result();
  1445. if (id==null||businessScope==null){
  1446. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,"参数","参数"));
  1447. return res;
  1448. }
  1449. res.data(customerService.updateuserBusinessScope(id,businessScope));
  1450. return res;
  1451. }
  1452. @RequestMapping(value = "/queryUserMax",method = RequestMethod.GET)
  1453. public Result queryUserMax(){
  1454. Result res =new Result();
  1455. res.setData(customerService.queryUserMax());
  1456. return res;
  1457. }
  1458. /**
  1459. * 客户最后跟进列表
  1460. * @param in
  1461. * @return
  1462. */
  1463. @RequestMapping(value = "/selectUserLastSign",method = RequestMethod.GET)
  1464. public Result selectUserLastSign (InputSelectUserLastSignBo in){
  1465. Result res =new Result();
  1466. res.setData(customerService.selectUserLastSign(in));
  1467. return res;
  1468. }
  1469. /**
  1470. * 客户最后跟进列表导出
  1471. * @param in
  1472. * @return
  1473. */
  1474. @RequestMapping(value = "/selectUserLastSign/export",method = RequestMethod.GET)
  1475. public Result selectUserLastSignExport (InputSelectUserLastSignBo in){
  1476. return customerService.selectUserLastSignExport(in);
  1477. }
  1478. /**
  1479. * Excel批量导入
  1480. *
  1481. * @return
  1482. */
  1483. @RequestMapping(value = "/importExcel" , method = RequestMethod.POST)
  1484. public Result importExcel(@RequestParam(value = "file", required = false) MultipartFile file) {
  1485. Result res=new Result();
  1486. //判断文件是否存在
  1487. if(null == file){
  1488. res.getError().add(buildError("文件不存在!","文件不存在!"));
  1489. return res;
  1490. }
  1491. String fileName = file.getOriginalFilename();
  1492. if (!fileName.matches("^.+\\.(?i)(xls)$") && !fileName.matches("^.+\\.(?i)(xlsx)$")) {
  1493. res.getError().add(buildError("格式不正确","格式不正确"));
  1494. return res;
  1495. }
  1496. // res.data(rdService.batchList(file));
  1497. res.data(customerService.importExcel(file));
  1498. return res;
  1499. }
  1500. }