AdminReleaseApiController.java 16 KB

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