AdminCustomerApiController.java 41 KB

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