CustomerApiController.java 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589
  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.Date;
  9. import java.util.List;
  10. import java.util.Set;
  11. import java.util.TreeSet;
  12. import javax.annotation.Resource;
  13. import javax.servlet.http.HttpServletRequest;
  14. import javax.servlet.http.HttpServletResponse;
  15. import org.springframework.beans.factory.annotation.Value;
  16. import org.springframework.web.bind.annotation.RequestMapping;
  17. import org.springframework.web.bind.annotation.RequestMethod;
  18. import org.springframework.web.bind.annotation.RestController;
  19. import com.alibaba.fastjson.JSON;
  20. import com.alibaba.fastjson.JSONArray;
  21. import com.goafanti.admin.service.AftFileService;
  22. import com.goafanti.common.bo.Error;
  23. import com.goafanti.common.bo.Result;
  24. import com.goafanti.common.constant.AFTConstants;
  25. import com.goafanti.common.constant.ErrorConstants;
  26. import com.goafanti.common.controller.BaseApiController;
  27. import com.goafanti.common.error.BusinessException;
  28. import com.goafanti.common.model.AftFile;
  29. import com.goafanti.common.model.OrganizationContactBook;
  30. import com.goafanti.common.model.User;
  31. import com.goafanti.common.model.UserBusiness;
  32. import com.goafanti.common.utils.BeanUtilsExt;
  33. import com.goafanti.common.utils.DateUtils;
  34. import com.goafanti.common.utils.ExcelUtils;
  35. import com.goafanti.common.utils.StringUtils;
  36. import com.goafanti.core.shiro.token.TokenManager;
  37. import com.goafanti.customer.bo.CustomerExcelBo;
  38. import com.goafanti.customer.bo.CustomerListIn;
  39. import com.goafanti.customer.bo.CustomerOrganizationDetailBo;
  40. import com.goafanti.customer.bo.CustomerPersonalDetailBo;
  41. import com.goafanti.customer.bo.FollowBusinessBo;
  42. import com.goafanti.customer.bo.UserDetailBo;
  43. import com.goafanti.customer.service.BusinessService;
  44. import com.goafanti.customer.service.CustomerService;
  45. @RestController
  46. @RequestMapping("api/admin/customer")
  47. public class CustomerApiController extends BaseApiController{
  48. @Resource
  49. private CustomerService customerService;
  50. @Resource
  51. private BusinessService businessService;
  52. @Resource
  53. private AftFileService aftFileService;
  54. @Value(value = "${upload.private.path}")
  55. private String uploadPrivatePath = null;
  56. /** 私有个人客户列表 **/
  57. @RequestMapping(value = "/listPrivatePersonalCustomer" , method = RequestMethod.POST)
  58. public Result listPrivatePersonalCustomer(CustomerListIn cli,Integer pageNo, Integer pageSize){
  59. Result res = new Result();
  60. res.setData(customerService.listPrivatePersonalCustomer(cli, pageNo, pageSize));
  61. return res;
  62. }
  63. /** 公共个人客户列表 **/
  64. @RequestMapping(value = "/listPublicPersonalCustomer" , method = RequestMethod.POST)
  65. public Result listPublicPersonalCustomer(CustomerListIn cli,Integer pageNo, Integer pageSize){
  66. Result res = new Result();
  67. res.setData(customerService.listPublicPersonalCustomer(cli, pageNo, pageSize));
  68. return res;
  69. }
  70. /** 个人客户查询 **/
  71. @RequestMapping(value = "/listAllPersonalCustomer" , method = RequestMethod.POST)
  72. public Result listAllPersonalCustomer(CustomerListIn cli,Integer pageNo, Integer pageSize){
  73. Result res = new Result();
  74. res.setData(customerService.listAllPersonalCustomer(cli, pageNo, pageSize));
  75. return res;
  76. }
  77. /** 私有单位客户列表 **/
  78. @RequestMapping(value = "/listPrivateOrganizationCustomer" , method = RequestMethod.POST)
  79. public Result listPrivateOrganizationCustomer(CustomerListIn cli,Integer pageNo, Integer pageSize){
  80. Result res = new Result();
  81. res.setData(customerService.listPrivateOrganizationCustomer(cli, pageNo, pageSize));
  82. return res;
  83. }
  84. /** 公共单位客户列表 **/
  85. @RequestMapping(value = "/listPublicOrganizationCustomer" , method = RequestMethod.POST)
  86. public Result listPublicOrganizationCustomer(CustomerListIn cli,Integer pageNo, Integer pageSize){
  87. Result res = new Result();
  88. res.setData(customerService.listPublicOrganizationCustomer(cli, pageNo, pageSize));
  89. return res;
  90. }
  91. /** 单位客户查询 **/
  92. @RequestMapping(value = "/listAllOrganizationCustomer" , method = RequestMethod.POST)
  93. public Result listAllOrganizationCustomer(CustomerListIn cli,Integer pageNo, Integer pageSize){
  94. Result res = new Result();
  95. res.setData(customerService.listAllOrganizationCustomer(cli, pageNo, pageSize));
  96. return res;
  97. }
  98. /** 客户即时检索 **/
  99. @RequestMapping(value = "/findCustomerByName",method = RequestMethod.GET)
  100. public Result findCustomerByName(String name){
  101. Result res = new Result();
  102. res.setData(customerService.findCustomerByName(name));
  103. return res;
  104. }
  105. /** 添加客户基本信息
  106. * @throws Exception
  107. * @throws NumberFormatException **/
  108. @RequestMapping(value = "/addCustomer", method = RequestMethod.POST)
  109. public Result addCustomer(String name,String contacts,String contactMobile,String type,String societyTag) throws Exception{
  110. Result res = new Result();
  111. if(StringUtils.isBlank(name) || StringUtils.isBlank(contacts)
  112. || StringUtils.isBlank(contactMobile) || StringUtils.isBlank(societyTag)){
  113. res.getError().add(buildError("客户名称、联系人、联系电话、社会性质不能为空"));
  114. return res;
  115. }
  116. customerService.addCustomer(name, contacts, contactMobile, Integer.parseInt(type),societyTag);
  117. return res;
  118. }
  119. /** 个人客户详情信息 **/
  120. @RequestMapping(value = "/findPersonalCustomerDetail" ,method = RequestMethod.GET)
  121. public Result findPersonalCustomerDetail(String uid){
  122. Result res = new Result();
  123. res.setData(customerService.findPersonalCustomerDetail(uid));
  124. return res;
  125. }
  126. /** 单位客户详情信息 **/
  127. @RequestMapping(value = "/findOrganizationCustomerDetail", method = RequestMethod.GET)
  128. public Result findOrganizationCustomerDetail(String uid){
  129. Result res = new Result();
  130. res.setData(customerService.findOrganizationCustomerDetail(uid));
  131. return res;
  132. }
  133. /** 修改单位客户信息 **/
  134. @RequestMapping(value = "/updateOrganizationCustomer", method = RequestMethod.POST)
  135. public Result updateOrganizationCustomer(CustomerOrganizationDetailBo bo){
  136. Result res = new Result();
  137. if(StringUtils.isBlank(bo.getId()) || StringUtils.isBlank(bo.getUid())){
  138. res.getError().add(buildError(ErrorConstants.PARAM_ERROR,""));
  139. return res;
  140. }
  141. customerService.updateOrganizationCustomer(bo);
  142. return res;
  143. }
  144. /** 修改个人客户信息 **/
  145. @RequestMapping(value = "/updatePersonalCustomer", method = RequestMethod.POST)
  146. public Result updatePersonalCustomer(CustomerPersonalDetailBo bo){
  147. Result res = new Result();
  148. if(StringUtils.isBlank(bo.getUid()) || StringUtils.isBlank(bo.getId())){
  149. res.getError().add(buildError(ErrorConstants.PARAM_ERROR,""));
  150. return res;
  151. }
  152. customerService.updatePersonalCustomer(bo);
  153. return res;
  154. }
  155. /** 查看跟进记录 **/
  156. @RequestMapping(value = "/listFollowHistory", method = RequestMethod.GET)
  157. public Result listFollowHistory(Integer pageNo, Integer pageSize,String uid,String businessGlossoryId){
  158. Result res = new Result();
  159. res.setData(customerService.listFollowHistory(pageNo,pageSize,uid,businessGlossoryId));
  160. return res;
  161. }
  162. /** 查看客户账户信息 **/
  163. @RequestMapping(value = "/findUserAccountDetail", method = RequestMethod.GET)
  164. public Result findUserAcountDetail(String uid){
  165. Result res = new Result();
  166. UserDetailBo bo = new UserDetailBo();
  167. User user = customerService.findUserAccountDetail(uid);
  168. try {
  169. BeanUtilsExt.copyProperties(bo, user);
  170. } catch (InvocationTargetException | IllegalAccessException e) {
  171. e.printStackTrace();
  172. }
  173. SimpleDateFormat format = new SimpleDateFormat(AFTConstants.YYYYMMDDHHMMSS);
  174. bo.setCreateTimes(format.format(user.getCreateTime()));
  175. res.setData(bo);
  176. return res;
  177. }
  178. /** 修改客户账户信息 **/
  179. @RequestMapping(value = "/updateUserAccount", method = RequestMethod.POST)
  180. public Result updateUserAccount(User user){
  181. Result res = new Result();
  182. customerService.updateUserAccount(user);
  183. return res;
  184. }
  185. /** 查看客户联系人列表 **/
  186. @RequestMapping(value = "/findCustomerContacts", method = RequestMethod.GET)
  187. public Result findCustomerContacts(String uid){
  188. Result res = new Result();
  189. res.setData(customerService.findCustomerContacts(uid));
  190. return res;
  191. }
  192. /** 进入添加拜访记录 **/
  193. @RequestMapping(value = "/toAddFollow", method = RequestMethod.GET)
  194. public Result toAddFollow(String uid){
  195. Result res = new Result();
  196. if(StringUtils.isBlank(uid)){
  197. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,""));
  198. return res;
  199. }
  200. User user = customerService.findUserAccountDetail(uid);
  201. FollowBusinessBo fbb = new FollowBusinessBo();
  202. SimpleDateFormat format = new SimpleDateFormat(AFTConstants.YYYYMMDDHHMMSS);
  203. fbb.setFollowTime(format.format(new Date()));
  204. fbb.setIdentifyName(user.getIdentifyName());
  205. fbb.setUid(uid);
  206. fbb.setUserBusinessList(businessService.findBusinessByUAid(uid, TokenManager.getAdminId()));
  207. res.setData(fbb);
  208. return res;
  209. }
  210. /** 添加拜访记录
  211. * @throws ParseException
  212. * @throws Exception **/
  213. @RequestMapping(value = "/addFollow", method = RequestMethod.POST)
  214. public Result addFollow(String userBusinessList,String uid,String ocbId,String contactType,String result,String followTime) throws BusinessException{
  215. Result res = new Result();
  216. if(StringUtils.isBlank(uid) || StringUtils.isBlank(ocbId)){
  217. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, ""));
  218. return res;
  219. }
  220. JSONArray ja = (JSONArray) JSON.parse(userBusinessList);
  221. List<UserBusiness> list = new ArrayList<UserBusiness>();
  222. if (ja != null && !ja.isEmpty()) {
  223. UserBusiness userBusiness = null;
  224. for (int idx = 0; idx < ja.size(); idx++) {
  225. userBusiness = ja.getJSONObject(idx).toJavaObject(UserBusiness.class);
  226. for(UserBusiness ub:list){
  227. if(ub.getBusinessGlossoryId() == userBusiness.getBusinessGlossoryId()){
  228. res.getError().add(new com.goafanti.common.bo.Error("业务类型重复,请检查后重新提交!"));
  229. return res;
  230. }
  231. }
  232. list.add(userBusiness);
  233. }
  234. }
  235. FollowBusinessBo fbb = new FollowBusinessBo();
  236. fbb.setOcbId(ocbId);
  237. fbb.setUid(uid);
  238. fbb.setContactType(contactType);
  239. fbb.setResult(result);
  240. fbb.setFollowTime(followTime);
  241. fbb.setUserBusinessList(list);
  242. customerService.addFollow(fbb);
  243. return res;
  244. }
  245. /** 进入修改拜访记录 **/
  246. @RequestMapping(value = "/toUpdateFollow", method = RequestMethod.GET)
  247. public Result toUpdateFollow(String followId){
  248. Result res = new Result();
  249. FollowBusinessBo fbb = customerService.findFollowById(followId);
  250. fbb.setUserBusinessList(customerService.findBusinessByFollowId(followId));
  251. res.setData(fbb);
  252. return res;
  253. }
  254. /** 修改拜访记录
  255. * @throws ParseException
  256. * @throws BusinessException
  257. */
  258. @RequestMapping(value = "/updateFollow", method = RequestMethod.POST)
  259. public Result updateFollow(String userBusinessList,String followId,String followTime,String uid,String contactType,String result) throws BusinessException{
  260. Result res = new Result();
  261. if(StringUtils.isBlank(uid) || StringUtils.isBlank(followId)){
  262. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, ""));
  263. return res;
  264. }
  265. JSONArray ja = (JSONArray) JSON.parse(userBusinessList);
  266. List<UserBusiness> list = new ArrayList<UserBusiness>();
  267. if (ja != null && !ja.isEmpty()) {
  268. UserBusiness userBusiness = null;
  269. for (int idx = 0; idx < ja.size(); idx++) {
  270. userBusiness = ja.getJSONObject(idx).toJavaObject(UserBusiness.class);
  271. for(UserBusiness ub:list){
  272. if(ub.getBusinessGlossoryId() == userBusiness.getBusinessGlossoryId()){
  273. res.getError().add(new com.goafanti.common.bo.Error("业务类型重复,请检查后重新提交!"));
  274. return res;
  275. }
  276. }
  277. list.add(userBusiness);
  278. }
  279. }
  280. FollowBusinessBo fbb = new FollowBusinessBo();
  281. fbb.setFollowTime(followTime);
  282. fbb.setUid(uid);
  283. fbb.setContactType(contactType);
  284. fbb.setResult(result);
  285. fbb.setUserBusinessList(list);
  286. fbb.setFollowId(followId);
  287. customerService.updateFollow(fbb);
  288. return res;
  289. }
  290. /** 删除跟进记录 **/
  291. @RequestMapping(value = "/deleteFollow", method = RequestMethod.GET)
  292. public Result deleteFollow(String followId){
  293. Result res = new Result();
  294. if(StringUtils.isBlank(followId)){
  295. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, ""));
  296. return res;
  297. }
  298. customerService.deleteFollow(followId);
  299. return res;
  300. }
  301. /** 查询客户的所有联系人 **/
  302. @RequestMapping(value = "/findAllContacts", method = RequestMethod.GET)
  303. public Result findAllContacts(String uid){
  304. Result res = new Result();
  305. res.setData(customerService.findAllContacts(uid));
  306. return res;
  307. }
  308. /** 修改企业联系人 **/
  309. @RequestMapping(value = "/updateCustomerContacts", method = RequestMethod.POST)
  310. public Result updateCustomerContacts(String contactList,String uid){
  311. Result res = new Result();
  312. if(StringUtils.isBlank(uid)){
  313. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, ""));
  314. return res;
  315. }
  316. JSONArray ja = (JSONArray) JSON.parse(contactList);
  317. List<OrganizationContactBook> ocbList = new ArrayList<OrganizationContactBook>();
  318. OrganizationContactBook ocb = null;
  319. if(ja != null & !ja.isEmpty()){
  320. for (int idx = 0; idx < ja.size(); idx++) {
  321. ocb = ja.getJSONObject(idx).toJavaObject(OrganizationContactBook.class);
  322. if(StringUtils.isBlank(ocb.getMobile()) || StringUtils.isBlank(ocb.getName())){
  323. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "用户名和手机号码为必填"));
  324. return res;
  325. }
  326. if(StringUtils.isBlank(ocb.getUid())) ocb.setUid(uid);
  327. ocbList.add(ocb);
  328. }
  329. }
  330. customerService.updateCustomerContacts(ocbList,uid);
  331. return res;
  332. }
  333. /** 领取客户 **/
  334. @RequestMapping(value = "/receiveCustomer", method = RequestMethod.GET)
  335. public Result receiveCustomer(String uid){
  336. Result res = new Result();
  337. if(StringUtils.isBlank(uid)){
  338. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, ""));
  339. return res;
  340. }
  341. customerService.updateByOperatorType(uid, AFTConstants.USER_RECEIVE);
  342. return res;
  343. }
  344. /** 删除客户 **/
  345. @RequestMapping(value = "/deleteCustomer", method = RequestMethod.GET)
  346. public Result deleteCustomer(String uid){
  347. Result res = new Result();
  348. if(StringUtils.isBlank(uid)){
  349. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, ""));
  350. return res;
  351. }
  352. customerService.updateByOperatorType(uid, AFTConstants.USER_DELETE);
  353. return res;
  354. }
  355. /**
  356. * 上传excel文档
  357. * @param req
  358. * @return
  359. */
  360. @RequestMapping(value = "/uploadExcel",method = RequestMethod.POST)
  361. public Result uploadExcel(HttpServletRequest req){
  362. Result res = new Result();
  363. String excelPath = handleFile(res, "/customer_sys_file/", true, req, "");
  364. ExcelUtils utils = new ExcelUtils();
  365. Set<CustomerExcelBo> boSet;
  366. try {
  367. boSet = utils.parseExcel(uploadPrivatePath + excelPath);
  368. String errorMessage = "";
  369. if(boSet.size()>100) errorMessage += "导入数据不能超过一百条;";
  370. errorMessage += utils.getVacantRows();
  371. if(StringUtils.isNotBlank(errorMessage)) {
  372. res.getError().add(new Error(errorMessage));
  373. return res;
  374. }
  375. Set<Integer> existRows = new TreeSet<Integer>(); //数据库已存在
  376. Set<Integer> filterRows = new TreeSet<Integer>(); //过滤提示
  377. customerService.checkCustomer(boSet,existRows,filterRows);
  378. if(existRows.size()>0){
  379. errorMessage = StringUtils.join(existRows.toArray(),",")+ " 行客户业务已存在;";
  380. res.getError().add(new Error(errorMessage));
  381. return res;
  382. }
  383. if(filterRows.size()>0){
  384. errorMessage = StringUtils.join(filterRows.toArray(),",")+ " 行已经被系统过滤;";
  385. res.getError().add(new Error(errorMessage));
  386. return res;
  387. }
  388. customerService.saveUploadData(boSet);
  389. } catch (IOException e) {
  390. e.printStackTrace();
  391. }
  392. return res;
  393. }
  394. /**
  395. * 下载科技成果批量导入Excel模板
  396. */
  397. @RequestMapping(value = "/downloadTemplate", method = RequestMethod.GET)
  398. public Result downloadTemplateFile(HttpServletResponse response,String type) {
  399. Result res = new Result();
  400. if(AFTConstants.USER_TYPE_ORGANIZATION.equals(type)){
  401. AftFile af = aftFileService.selectAftFileBySign("organization_customer_template");
  402. if (null == af) {
  403. res.getError().add(buildError(ErrorConstants.FILE_NON_EXISTENT, "", "找不到文件!"));
  404. } else {
  405. String path = af.getFilePath();
  406. String suffix = path.substring(path.lastIndexOf("."));
  407. String fileName = af.getFileName() + suffix;
  408. downloadFile(response, fileName, path);
  409. }
  410. }else if(AFTConstants.USER_TYPE_PERSONAL.equals(type)){
  411. AftFile af = aftFileService.selectAftFileBySign("personal_customer_template");
  412. if (null == af) {
  413. res.getError().add(buildError(ErrorConstants.FILE_NON_EXISTENT, "", "找不到文件!"));
  414. } else {
  415. String path = af.getFilePath();
  416. String suffix = path.substring(path.lastIndexOf("."));
  417. String fileName = af.getFileName() + suffix;
  418. downloadFile(response, fileName, path);
  419. }
  420. }
  421. return res;
  422. }
  423. /** 转为公共客户 **/
  424. @RequestMapping(value = "/transferToPublic", method = RequestMethod.GET)
  425. public Result transferToPublic(String uid){
  426. Result res = new Result();
  427. if(StringUtils.isBlank(uid)){
  428. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, ""));
  429. }
  430. customerService.updateByOperatorType(uid, AFTConstants.USER_TRANSFER_TO_PUBLIC);
  431. return res;
  432. }
  433. /** 图片上传 **/
  434. @RequestMapping(value = "/uploadCustomerImg", method = RequestMethod.POST)
  435. public Result uploadCustomerImg(HttpServletRequest req,String sign){
  436. Result res = new Result();
  437. res.setData(handleFile(res, "/customer_sys_file/", false, req, sign));
  438. return res;
  439. }
  440. /**
  441. *
  442. * @param startDate 开始日期
  443. * @param endDate 结束日期
  444. * @param timeSpan 时间差
  445. * @param depId 部门编号
  446. * @param pageNo 页码
  447. * @param pageSize 页数
  448. * @return
  449. * @throws ParseException
  450. */
  451. @RequestMapping(value = "/customerStatistics",method = RequestMethod.GET)
  452. public Result customerStatistics(String startDate,String endDate,String timeSpan,String depId,Integer pageNo, Integer pageSize) throws ParseException{
  453. Result res = new Result();
  454. Date sDate = null;
  455. Date eDate = null;
  456. DateFormat format = new SimpleDateFormat(AFTConstants.YYYYMMDD);
  457. if(StringUtils.isNotBlank(startDate)) sDate = format.parse(startDate);
  458. if(StringUtils.isNotBlank(endDate)) eDate = format.parse(endDate);
  459. if(StringUtils.isBlank(startDate)&&StringUtils.isBlank(endDate)){
  460. Date date = new Date();
  461. if(timeSpan.equals(DateUtils.DAY_SPAN)){
  462. sDate = DateUtils.getYesterday();
  463. }else if(timeSpan.equals(DateUtils.WEEK_SPAN)){
  464. sDate = DateUtils.getLastDayOfLastWeek(date);
  465. }else if(timeSpan.equals(DateUtils.MONTH_SPAN)){
  466. sDate = DateUtils.getLastDayOfLastMonth(date);
  467. }else if(timeSpan.equals(DateUtils.QUARTER_SPAN)){
  468. sDate = DateUtils.getLastDayOfLastQuarter(date);
  469. }else if(timeSpan.equals(DateUtils.YEAR_SPAN)){
  470. sDate = DateUtils.getLastDayOfLastYear(date);
  471. }
  472. }
  473. res.setData(customerService.customerStatistics(sDate,eDate,depId,pageNo,pageSize));
  474. return res;
  475. }
  476. /**
  477. *
  478. * @param startDate 开始日期
  479. * @param endDate 结束日期
  480. * @param timeSpan 时间差
  481. * @param depId 部门编号
  482. * @param businessGlossoryId 业务编号
  483. * @param pageNo 页码
  484. * @param pageSiz 页数
  485. * @return
  486. * @throws ParseException
  487. */
  488. @RequestMapping(value = "/businessStatistic", method = RequestMethod.GET)
  489. public Result businessStatistic(String startDate,String endDate,String timeSpan,String depId,String businessGlossoryId,Integer pageNo, Integer pageSize) throws ParseException{
  490. Result res = new Result();
  491. Date sDate = null;
  492. Date eDate = null;
  493. DateFormat format = new SimpleDateFormat(AFTConstants.YYYYMMDD);
  494. if(StringUtils.isNotBlank(startDate)) sDate = format.parse(startDate);
  495. if(StringUtils.isNotBlank(endDate)) eDate = format.parse(endDate);
  496. if(StringUtils.isBlank(startDate)&&StringUtils.isBlank(endDate)){
  497. Date date = new Date();
  498. if(timeSpan.equals(DateUtils.DAY_SPAN)){
  499. sDate = DateUtils.getYesterday();
  500. }else if(timeSpan.equals(DateUtils.WEEK_SPAN)){
  501. sDate = DateUtils.getLastDayOfLastWeek(date);
  502. }else if(timeSpan.equals(DateUtils.MONTH_SPAN)){
  503. sDate = DateUtils.getLastDayOfLastMonth(date);
  504. }else if(timeSpan.equals(DateUtils.QUARTER_SPAN)){
  505. sDate = DateUtils.getLastDayOfLastQuarter(date);
  506. }else if(timeSpan.equals(DateUtils.YEAR_SPAN)){
  507. sDate = DateUtils.getLastDayOfLastYear(date);
  508. }
  509. }
  510. res.setData(customerService.businessStatistic(sDate,eDate,depId,businessGlossoryId,pageNo,pageSize));
  511. return res;
  512. }
  513. /**
  514. *
  515. * @param startDate 开始日期
  516. * @param endDate 结束日期
  517. * @param timeSpan 时间差
  518. * @param depId 部门编号
  519. * @param businessGlossoryId 业务编号
  520. * @param pageNo 页码
  521. * @param pageSiz 页数
  522. * @return
  523. * @throws ParseException
  524. */
  525. @RequestMapping(value = "/followStatistic",method = RequestMethod.GET)
  526. public Result followStatistic(String startDate,String endDate,String timeSpan,String depId,String businessGlossoryId,Integer pageNo, Integer pageSize) throws ParseException{
  527. Result res = new Result();
  528. Date sDate = null;
  529. Date eDate = null;
  530. DateFormat format = new SimpleDateFormat(AFTConstants.YYYYMMDD);
  531. if(StringUtils.isNotBlank(startDate)) sDate = format.parse(startDate);
  532. if(StringUtils.isNotBlank(endDate)) eDate = format.parse(endDate);
  533. if(StringUtils.isBlank(startDate)&&StringUtils.isBlank(endDate)){
  534. Date date = new Date();
  535. if(timeSpan.equals(DateUtils.DAY_SPAN)){
  536. sDate = DateUtils.getYesterday();
  537. }else if(timeSpan.equals(DateUtils.WEEK_SPAN)){
  538. sDate = DateUtils.getLastDayOfLastWeek(date);
  539. }else if(timeSpan.equals(DateUtils.MONTH_SPAN)){
  540. sDate = DateUtils.getLastDayOfLastMonth(date);
  541. }else if(timeSpan.equals(DateUtils.QUARTER_SPAN)){
  542. sDate = DateUtils.getLastDayOfLastQuarter(date);
  543. }else if(timeSpan.equals(DateUtils.YEAR_SPAN)){
  544. sDate = DateUtils.getLastDayOfLastYear(date);
  545. }
  546. }
  547. res.setData(customerService.followStatistic(sDate, eDate, businessGlossoryId, depId, pageNo, pageSize));
  548. return res;
  549. }
  550. }