AdminReleaseApiController.java 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550
  1. package com.goafanti.weChat.controller;
  2. import com.goafanti.common.bo.Error;
  3. import com.goafanti.common.bo.Result;
  4. import com.goafanti.common.constant.ErrorConstants;
  5. import com.goafanti.common.controller.CertifyApiController;
  6. import com.goafanti.common.error.BusinessException;
  7. import com.goafanti.common.utils.StringUtils;
  8. import com.goafanti.common.utils.excel.NewExcelUtil;
  9. import com.goafanti.weChat.bo.*;
  10. import com.goafanti.weChat.service.PublicReleaseService;
  11. import org.apache.commons.beanutils.BeanUtils;
  12. import org.springframework.beans.factory.annotation.Value;
  13. import org.springframework.web.bind.annotation.RequestMapping;
  14. import org.springframework.web.bind.annotation.RequestMethod;
  15. import org.springframework.web.bind.annotation.RestController;
  16. import javax.annotation.Resource;
  17. import javax.servlet.http.HttpServletRequest;
  18. import javax.servlet.http.HttpServletResponse;
  19. import java.util.ArrayList;
  20. import java.util.List;
  21. @RestController
  22. @RequestMapping(value = "/api/admin/release")
  23. public class AdminReleaseApiController extends CertifyApiController{
  24. @Resource
  25. private PublicReleaseService publicReleaseService;
  26. @Value(value = "${upload.path}")
  27. private String uploadPath = null;
  28. /**
  29. * 发起外出申请、发起公出
  30. */
  31. @RequestMapping(value = "/addPublicRelease", method = RequestMethod.POST)
  32. public Result addPublicRelease(InputPublicRelease in){
  33. Result res = new Result();
  34. if (StringUtils.isBlank(in.getUids())) {
  35. res.getError().add(buildErrorMessageParams(ErrorConstants.PARAM_EMPTY_ERROR,"用户编号"));
  36. return res;
  37. }
  38. if (StringUtils.isBlank(in.getReleaseStarts())) {
  39. res.getError().add(buildErrorMessageParams(ErrorConstants.PARAM_EMPTY_ERROR,"公出时间"));
  40. return res;
  41. }
  42. if (StringUtils.isBlank(in.getDistrictName())) {
  43. res.getError().add(buildErrorMessageParams(ErrorConstants.PARAM_EMPTY_ERROR,"公出地点"));
  44. return res;
  45. }
  46. int i = publicReleaseService.checkTime(in);
  47. if (i==1) {
  48. res.getError().add(buildError("发起人公出时段已经被使用!","发起人公出时段已经被使用!"));
  49. return res;
  50. }
  51. if (i==2) {
  52. res.getError().add(buildError("协单人公出时段已经被使用!","协单人公出时段已经被使用!"));
  53. return res;
  54. }
  55. if(in.getAssist()==null)in.setAssist(0);
  56. if (in.getAssist()==1&&in.getAssistAid()==null) {
  57. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,"协单人员"));
  58. return res;
  59. }
  60. if (publicReleaseService.checkPublicReviewer(in)){
  61. res.getError().add(buildError("请让管理员先设置公出审核人。"));
  62. return res;
  63. }
  64. res.setData(publicReleaseService.addPublicRelease(in));
  65. return res;
  66. }
  67. /**
  68. * 判定客户是否完成了客户档案
  69. */
  70. @RequestMapping(value = "/checkUserArchives", method = RequestMethod.GET)
  71. public Result checkUserArchives(String uid){
  72. Result res = new Result();
  73. if (StringUtils.isBlank(uid)) {
  74. res.getError().add(buildErrorMessageParams(ErrorConstants.PARAM_EMPTY_ERROR,"用户编号"));
  75. return res;
  76. }
  77. res.setData(publicReleaseService.checkUserArchives(uid));
  78. return res;
  79. }
  80. /**
  81. * 修改外出申请、修改公出
  82. */
  83. @RequestMapping(value = "/updatePublicRelease", method = RequestMethod.POST)
  84. public Result updatePublicRelease(InputPublicRelease in){
  85. Result res = new Result();
  86. if (in.getId()==null){
  87. res.getError().add(buildErrorMessageParams(ErrorConstants.PARAM_EMPTY_ERROR,"编号"));
  88. return res;
  89. }
  90. if (in.getStatus()!=3) {
  91. int i = publicReleaseService.checkTime(in);
  92. if (i==1) {
  93. res.getError().add(buildError("发起人公出时段已经被使用!","发起人公出时段已经被使用!"));
  94. return res;
  95. }
  96. if (i==2) {
  97. res.getError().add(buildError("协单人公出时段已经被使用!","协单人公出时段已经被使用!"));
  98. return res;
  99. }
  100. }
  101. res.setData(publicReleaseService.updatePublicRelease(in));
  102. return res;
  103. }
  104. /**
  105. * 修改打卡地址
  106. */
  107. @RequestMapping(value = "/updateLocation", method = RequestMethod.POST)
  108. public Result updateLocation(InputPublicRelease in){
  109. Result res = new Result();
  110. if (in.getId()==null||in.getUid()==null){
  111. res.getError().add(buildErrorMessageParams(ErrorConstants.PARAM_EMPTY_ERROR,"编号"));
  112. return res;
  113. }
  114. if (in.getLatitude()==null||in.getLongitude()==null||in.getDistrictName()==null){
  115. res.getError().add(buildErrorMessageParams(ErrorConstants.PARAM_EMPTY_ERROR,"位置"));
  116. return res;
  117. }
  118. res.setData(publicReleaseService.updateLocation(in));
  119. return res;
  120. }
  121. /**
  122. * 外出打卡、公出打卡
  123. */
  124. @RequestMapping(value = "/publicReleaseClockIn", method = RequestMethod.POST)
  125. public Result publicReleaseClockIn(Integer id,String photoUrl,Integer clockIn ,String clockInRemarks,String uid ){
  126. Result res =new Result();
  127. int x=publicReleaseService.pushPublicReleaseClockIn(id,photoUrl,clockIn,clockInRemarks,uid);
  128. if (x==-1){
  129. res.getError().add(buildError("公出他人企业!需通过审核,才可以打卡!"));
  130. return res;
  131. }
  132. // 取消打卡限制
  133. if (x==-2){
  134. res.getError().add(buildError("公出审核中,不可打卡!"));
  135. return res;
  136. }
  137. if (x==-3){
  138. res.getError().add(buildError("技术协单,必须先写协单意见,才可打卡!"));
  139. return res;
  140. }
  141. res.setData(x);
  142. return res;
  143. }
  144. /**
  145. * 外出申请详情、公出详情
  146. */
  147. @RequestMapping(value = "/dtails", method = RequestMethod.GET)
  148. public Result details(Integer id){
  149. Result res =new Result();
  150. res.setData(publicReleaseService.dtails(id));
  151. return res;
  152. }
  153. /**
  154. * 外出申请详情
  155. */
  156. @RequestMapping(value = "/followDtails", method = RequestMethod.GET)
  157. public Result followDetails(String id){
  158. Result res =new Result();
  159. res.setData(publicReleaseService.followDtails(id));
  160. return res;
  161. }
  162. /**
  163. * 外出申请列表.公出列表,我的协单列表,协单审核,
  164. */
  165. @RequestMapping(value = "/listPublicRelease", method = RequestMethod.GET)
  166. public Result listPublicRelease(InputPublicReleaseList in){
  167. Result res =new Result();
  168. res.setData(publicReleaseService.listPublicRelease(in));
  169. return res;
  170. }
  171. /**
  172. * 公出审核、外出审核 上级
  173. */
  174. @RequestMapping(value = "/examinePublicRelease", method = RequestMethod.POST)
  175. public Result examinePublicRelease(Integer id ,Integer status,String remarks,Integer evaluateType){
  176. Result res =new Result();
  177. if (id==null) {
  178. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,"公出编号"));
  179. return res;
  180. }
  181. if (status!=0&&status!=2) {
  182. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,"审核状态"));
  183. return res;
  184. }
  185. if (remarks.length()>20) {
  186. res.getError().add(buildError("备注长度不能超过20个字符。"));
  187. return res;
  188. }
  189. res.setData(publicReleaseService.pushExaminePublicRelease(id,status,remarks,0,evaluateType));
  190. return res;
  191. }
  192. /**
  193. * 公出审核、外出审核 客户归属人
  194. */
  195. @RequestMapping(value = "/marketersExamine", method = RequestMethod.POST)
  196. public Result marketersExamine(Integer id ,Integer status,String remarks){
  197. Result res =new Result();
  198. if (id==null) {
  199. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,"公出编号"));
  200. return res;
  201. }
  202. if (status!=0&&status!=2) {
  203. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,"审核状态"));
  204. return res;
  205. }
  206. if (remarks.length()>20) {
  207. res.getError().add(buildError("备注长度不能超过20个字符。"));
  208. return res;
  209. }
  210. res.setData(publicReleaseService.pushExaminePublicRelease(id,status,remarks,1,0));
  211. return res;
  212. }
  213. /**
  214. * 公出审核、外出审核 协单审核
  215. */
  216. @RequestMapping(value = "/assistExamine", method = RequestMethod.POST)
  217. public Result assistExamine(Integer id ,Integer status,String remarks){
  218. Result res =new Result();
  219. if (id==null) {
  220. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,"公出编号"));
  221. return res;
  222. }
  223. if (status!=0&&status!=2) {
  224. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,"审核状态"));
  225. return res;
  226. }
  227. if (remarks.length()>20) {
  228. res.getError().add(buildError("备注长度不能超过20个字符。"));
  229. return res;
  230. }
  231. res.setData(publicReleaseService.updateAssistExamine(id,status,remarks));
  232. return res;
  233. }
  234. /**
  235. * 技术公出审核 公出他人企业
  236. */
  237. @RequestMapping(value = "/techExamine", method = RequestMethod.POST)
  238. public Result techExamine(Integer id ,Integer status,String remarks){
  239. Result res =new Result();
  240. if (id==null) {
  241. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,"公出编号"));
  242. return res;
  243. }
  244. if (status!=0&&status!=2) {
  245. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,"审核状态"));
  246. return res;
  247. }
  248. if (remarks.length()>20) {
  249. res.getError().add(buildError("备注长度不能超过20个字符。"));
  250. return res;
  251. }
  252. res.setData(publicReleaseService.pushExaminePublicRelease(id,status,remarks,2,0));
  253. return res;
  254. }
  255. /**
  256. * 咨询驳回
  257. */
  258. @RequestMapping(value = "/techReject", method = RequestMethod.POST)
  259. public Result techReject(Integer id ,String remarks){
  260. Result res =new Result();
  261. if (id==null) {
  262. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,"公出编号"));
  263. return res;
  264. }
  265. if (remarks.length()>20) {
  266. res.getError().add(buildError("备注长度不能超过20个字符。"));
  267. return res;
  268. }
  269. res.setData(publicReleaseService.pushTechReject( id , remarks));
  270. return res;
  271. }
  272. /**
  273. * 外出审核日志列表
  274. */
  275. @RequestMapping(value = "/listPublicReleaseLog", method = RequestMethod.GET)
  276. public Result listPublicReleaseLog(Integer id,String ufid){
  277. Result res =new Result();
  278. res.data(publicReleaseService.listPublicReleaseLog(id,ufid));
  279. return res;
  280. }
  281. /**
  282. * 公出统计
  283. */
  284. @RequestMapping(value = "/publicReleaseStatistics", method = RequestMethod.GET)
  285. public Result publicReleaseStatistics(InputPublicStatistics in){
  286. Result res =new Result();
  287. res.data(publicReleaseService.publicReleaseStatistics(in));
  288. return res;
  289. }
  290. /**
  291. * 公出统计导出
  292. */
  293. @RequestMapping(value = "/publicReleaseStatistics/export", method = RequestMethod.GET)
  294. public Result publicReleaseStatisticsExport(InputPublicStatistics in,HttpServletResponse response){
  295. List<OutPublicStatistics> list =publicReleaseService.publicReleaseStatisticsList(in);
  296. NewExcelUtil<OutPublicStatistics>excel=new NewExcelUtil<>(OutPublicStatistics.class);
  297. return excel.exportExcel(list,"公出统计列表",response);
  298. }
  299. /**
  300. * 公出详情列表
  301. */
  302. @RequestMapping(value = "/publicReleaseDtails", method = RequestMethod.GET)
  303. public Result publicReleaseListDtails(InputPublicDtails in){
  304. Result res =new Result();
  305. res.data(publicReleaseService.publicReleaseListDtails(in));
  306. return res;
  307. }
  308. @RequestMapping(value = "/publicReleaseAndCount", method = RequestMethod.GET)
  309. public Result publicReleaseAndCount(InputPublicDtails in){
  310. Result res =new Result();
  311. res.data(publicReleaseService.publicReleaseAndCount(in));
  312. return res;
  313. }
  314. /**
  315. * 公出详情列表
  316. */
  317. @RequestMapping(value = "/publicReleaseDtails/export", method = RequestMethod.GET)
  318. public Result publicReleaseListDtailsExport(InputPublicDtails in ,Integer exportType){
  319. if (exportType==null)exportType=0;
  320. List<OutPublicDtails> outList=publicReleaseService.publicReleaseListDtailsList(in);
  321. publicReleaseService.pushOutPublicDtails(outList);
  322. if (exportType==0){
  323. NewExcelUtil<OutPublicDtails>excel=new NewExcelUtil<>(OutPublicDtails.class);
  324. return excel.exportExcel(outList,"公出详细列表",uploadPath);
  325. }else if (exportType==1){
  326. List<OutPublicDtailsFinance> list = new ArrayList<>();
  327. for (OutPublicDtails outPublicDtails : outList) {
  328. OutPublicDtailsFinance of= new OutPublicDtailsFinance();
  329. try {
  330. BeanUtils.copyProperties( of,outPublicDtails);
  331. } catch (Exception e) {
  332. throw new BusinessException("数据转换异常");
  333. }
  334. list.add(of);
  335. }
  336. NewExcelUtil<OutPublicDtailsFinance>excel=new NewExcelUtil<>(OutPublicDtailsFinance.class);
  337. return excel.exportExcel(list,"公出详细列表",uploadPath);
  338. }
  339. return null;
  340. }
  341. /** 上传图片 **/
  342. @RequestMapping(value = "/upload", method = RequestMethod.POST)
  343. public Result uploadOrderInvoiceFile(HttpServletRequest req){
  344. Result res = new Result();
  345. res.setData(handleFile(res, "/publicRelease/", false, req, "publicRelease"));
  346. return res;
  347. }
  348. /**
  349. * 搜索
  350. */
  351. @RequestMapping(value = "/addSupplement", method = RequestMethod.POST)
  352. public Result addSupplement(Integer id,String supplement,String nextPlan){
  353. Result res =new Result();
  354. if (id==null) {
  355. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,"公出编号"));
  356. return res;
  357. }
  358. res.setData(publicReleaseService.addSupplement( id ,supplement,nextPlan));
  359. return res;
  360. }
  361. /**
  362. * 根据客户返回订单
  363. */
  364. @RequestMapping(value = "/selectOrderByUid",method =RequestMethod.GET)
  365. public Result selectOrderByUid(String uid){
  366. Result res = new Result();
  367. if (uid==null){
  368. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,ErrorConstants.PARAM_EMPTY_ERROR,"客户编号"));
  369. return res;
  370. }
  371. res.data(publicReleaseService.selectOrderByUid(uid));
  372. return res;
  373. }
  374. /**
  375. * 查看上门记录
  376. */
  377. @RequestMapping(value = "/publicByOrder",method =RequestMethod.GET)
  378. public Result publicByOrder(String orderNo){
  379. Result res = new Result();
  380. if (orderNo==null){
  381. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,ErrorConstants.PARAM_EMPTY_ERROR,"订单编号"));
  382. return res;
  383. }
  384. res.data(publicReleaseService.publicByOrder(orderNo));
  385. return res;
  386. }
  387. /**
  388. * 打卡页面获取自己最新的打卡
  389. */
  390. @RequestMapping(value = "/getMyNewPublic",method = RequestMethod.GET)
  391. public Result getMyNewPublic (){
  392. Result res =new Result();
  393. res.data(publicReleaseService.getMyNewPublic());
  394. return res;
  395. }
  396. /**
  397. * 新增协单助手
  398. * @param id 公出编号
  399. * @param aid 协单助手编号
  400. */
  401. @RequestMapping(value = "/addAssistant",method = RequestMethod.POST)
  402. public Result addAssistant (Integer id,String aid){
  403. Result res =new Result();
  404. if (id==null||aid==null){
  405. res.getError().add(new Error(ErrorConstants.PARAM_EMPTY_ERROR,"公出编号与人员编号"));
  406. return res;
  407. }
  408. if (publicReleaseService.checkaddAssistant(id,aid)){
  409. res.getError().add(new Error("协单助手已经存在"));
  410. return res;
  411. }
  412. res.data(publicReleaseService.addAssistant(id,aid));
  413. return res;
  414. }
  415. /**
  416. * 删除协单助手
  417. * @param id 公出编号
  418. * @param aid 协单助手编号
  419. */
  420. @RequestMapping(value = "/deleteAssistant",method = RequestMethod.POST)
  421. public Result deleteAssistant (Integer id,String aid){
  422. Result res =new Result();
  423. if (id==null||aid==null){
  424. res.getError().add(new Error(ErrorConstants.PARAM_EMPTY_ERROR,"公出编号与人员编号"));
  425. return res;
  426. }
  427. if (publicReleaseService.checkdeleteAssistant(id,aid)){
  428. res.getError().add(new Error("协单助手已经打卡,无法删除"));
  429. return res;
  430. }
  431. res.data(publicReleaseService.deleteAssistant(id,aid));
  432. return res;
  433. }
  434. /**
  435. * 技术发起公出查询发起情况
  436. */
  437. @RequestMapping(value = "/checkOrderNoDuration",method = RequestMethod.GET)
  438. public Result checkOrderNoDuration (InputPublicRelease in){
  439. Result res =new Result();
  440. return res.data(publicReleaseService.checkOrderNoDuration(in));
  441. }
  442. /**
  443. * 技术发起公出查询发起情况
  444. */
  445. @RequestMapping(value = "/pushDateClock",method = RequestMethod.POST)
  446. public Result pushDateClock (){
  447. Result res =new Result();
  448. return res.data(publicReleaseService.pushDateClock());
  449. }
  450. /**
  451. * 公出&报销表
  452. */
  453. @RequestMapping(value = "/releaseAndExpenseCount",method = RequestMethod.GET)
  454. public Result releaseAndExpenseCount (InputreleaseAndExpenseCount in){
  455. Result res =new Result();
  456. return res.data(publicReleaseService.releaseAndExpenseCount(in));
  457. }/**
  458. * 公出&报销缓存清除
  459. */
  460. @RequestMapping(value = "/releaseAndExpenseCountClear",method = RequestMethod.GET)
  461. public Result releaseAndExpenseCountClear (){
  462. Result res =new Result();
  463. return res.data(publicReleaseService.releaseAndExpenseCountClear());
  464. }
  465. /**
  466. * 公出&报销表导出
  467. */
  468. @RequestMapping(value = "/releaseAndExpenseCount/Export",method = RequestMethod.GET)
  469. public Result releaseAndExpenseCountExport (InputreleaseAndExpenseCount in){
  470. List<releaseAndExpenseCountOut> list = publicReleaseService.releaseAndExpenseCount(in);
  471. NewExcelUtil<releaseAndExpenseCountOut> excelUtil=new NewExcelUtil<>(releaseAndExpenseCountOut.class);
  472. return excelUtil.exportExcel(list,"公出与报销表",uploadPath);
  473. }
  474. /**
  475. * 协单审核是否有未审核查询
  476. */
  477. @RequestMapping(value = "/unaudited",method = RequestMethod.GET)
  478. public Result assistUnaudited (){
  479. Result res =new Result();
  480. return res.data(publicReleaseService.assistUnaudited());
  481. }
  482. /**
  483. * 分享限时查询
  484. */
  485. @RequestMapping(value = "/limitUser",method = RequestMethod.POST)
  486. public Result limitUser (String uid,Integer hours){
  487. Result res =new Result();
  488. int i = publicReleaseService.pushLimitUser(uid,hours);
  489. if (i==0){
  490. return res().error(buildError(ErrorConstants.PARAM_ERROR,"只有客户归属人可以分享"));
  491. }
  492. return res.data(i);
  493. }
  494. }