AdminReleaseApiController.java 16 KB

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