AdminReleaseApiController.java 16 KB

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