AdminReleaseApiController.java 14 KB

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