AdminReleaseApiController.java 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449
  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. @RequestMapping(value = "/techExamine", method = RequestMethod.POST)
  181. public Result techExamine(Integer id ,Integer status,String remarks){
  182. Result res =new Result();
  183. if (id==null) {
  184. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,"公出编号"));
  185. return res;
  186. }
  187. if (status!=0&&status!=2) {
  188. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,"审核状态"));
  189. return res;
  190. }
  191. if (remarks.length()>20) {
  192. res.getError().add(buildError("备注长度不能超过20个字符。"));
  193. return res;
  194. }
  195. res.setData(publicReleaseService.pushExaminePublicRelease(id,status,remarks,2));
  196. return res;
  197. }
  198. /**
  199. * 咨询驳回
  200. */
  201. @RequestMapping(value = "/techReject", method = RequestMethod.POST)
  202. public Result techReject(Integer id ,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 (remarks.length()>20) {
  209. res.getError().add(buildError("备注长度不能超过20个字符。"));
  210. return res;
  211. }
  212. res.setData(publicReleaseService.pushTechReject( id , remarks));
  213. return res;
  214. }
  215. /**
  216. * 外出审核日志列表
  217. */
  218. @RequestMapping(value = "/listPublicReleaseLog", method = RequestMethod.GET)
  219. public Result listPublicReleaseLog(Integer id,String ufid){
  220. Result res =new Result();
  221. res.data(publicReleaseService.listPublicReleaseLog(id,ufid));
  222. return res;
  223. }
  224. /**
  225. * 公出统计
  226. */
  227. @RequestMapping(value = "/publicReleaseStatistics", method = RequestMethod.GET)
  228. public Result publicReleaseStatistics(InputPublicStatistics in){
  229. Result res =new Result();
  230. res.data(publicReleaseService.publicReleaseStatistics(in));
  231. return res;
  232. }
  233. /**
  234. * 公出统计导出
  235. */
  236. @RequestMapping(value = "/publicReleaseStatistics/export", method = RequestMethod.GET)
  237. public Result publicReleaseStatisticsExport(InputPublicStatistics in,HttpServletResponse response){
  238. List<OutPublicStatistics> list =publicReleaseService.publicReleaseStatisticsList(in);
  239. NewExcelUtil<OutPublicStatistics>excel=new NewExcelUtil<>(OutPublicStatistics.class);
  240. return excel.exportExcel(list,"公出统计列表",response);
  241. }
  242. /**
  243. * 公出详情列表
  244. */
  245. @RequestMapping(value = "/publicReleaseDtails", method = RequestMethod.GET)
  246. public Result publicReleaseListDtails(InputPublicDtails in){
  247. Result res =new Result();
  248. res.data(publicReleaseService.publicReleaseListDtails(in));
  249. return res;
  250. }
  251. @RequestMapping(value = "/publicReleaseAndCount", method = RequestMethod.GET)
  252. public Result publicReleaseAndCount(InputPublicDtails in){
  253. Result res =new Result();
  254. res.data(publicReleaseService.publicReleaseAndCount(in));
  255. return res;
  256. }
  257. /**
  258. * 公出详情列表
  259. */
  260. @RequestMapping(value = "/publicReleaseDtails/export", method = RequestMethod.GET)
  261. public Result publicReleaseListDtailsExport(InputPublicDtails in ,Integer exportType){
  262. if (exportType==null)exportType=0;
  263. List<OutPublicDtails> outList=publicReleaseService.publicReleaseListDtailsList(in);
  264. publicReleaseService.pushOutPublicDtails(outList);
  265. if (exportType==0){
  266. NewExcelUtil<OutPublicDtails>excel=new NewExcelUtil<>(OutPublicDtails.class);
  267. return excel.exportExcel(outList,"公出详细列表",uploadPath);
  268. }else if (exportType==1){
  269. List<OutPublicDtailsFinance> list = new ArrayList<>();
  270. for (OutPublicDtails outPublicDtails : outList) {
  271. OutPublicDtailsFinance of= new OutPublicDtailsFinance();
  272. try {
  273. BeanUtils.copyProperties( of,outPublicDtails);
  274. } catch (Exception e) {
  275. throw new BusinessException("数据转换异常");
  276. }
  277. list.add(of);
  278. }
  279. NewExcelUtil<OutPublicDtailsFinance>excel=new NewExcelUtil<>(OutPublicDtailsFinance.class);
  280. return excel.exportExcel(list,"公出详细列表",uploadPath);
  281. }
  282. return null;
  283. }
  284. /** 上传图片 **/
  285. @RequestMapping(value = "/upload", method = RequestMethod.POST)
  286. public Result uploadOrderInvoiceFile(HttpServletRequest req){
  287. Result res = new Result();
  288. res.setData(handleFile(res, "/publicRelease/", false, req, "publicRelease"));
  289. return res;
  290. }
  291. /**
  292. * 搜索
  293. */
  294. @RequestMapping(value = "/addSupplement", method = RequestMethod.POST)
  295. public Result addSupplement(Integer id,String supplement,String nextPlan){
  296. Result res =new Result();
  297. if (id==null) {
  298. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,"公出编号"));
  299. return res;
  300. }
  301. if (supplement==null) {
  302. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,"本次公出目标总结"));
  303. return res;
  304. }
  305. if (nextPlan==null) {
  306. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,"下次公出计划"));
  307. return res;
  308. }
  309. res.setData(publicReleaseService.addSupplement( id ,supplement,nextPlan));
  310. return res;
  311. }
  312. /**
  313. * 根据客户返回订单
  314. */
  315. @RequestMapping(value = "/selectOrderByUid",method =RequestMethod.GET)
  316. public Result selectOrderByUid(String uid){
  317. Result res = new Result();
  318. if (uid==null){
  319. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,ErrorConstants.PARAM_EMPTY_ERROR,"客户编号"));
  320. return res;
  321. }
  322. res.data(publicReleaseService.selectOrderByUid(uid));
  323. return res;
  324. }
  325. /**
  326. * 查看上门记录
  327. */
  328. @RequestMapping(value = "/publicByOrder",method =RequestMethod.GET)
  329. public Result publicByOrder(String orderNo){
  330. Result res = new Result();
  331. if (orderNo==null){
  332. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,ErrorConstants.PARAM_EMPTY_ERROR,"订单编号"));
  333. return res;
  334. }
  335. res.data(publicReleaseService.publicByOrder(orderNo));
  336. return res;
  337. }
  338. /**
  339. * 打卡页面获取自己最新的打卡
  340. */
  341. @RequestMapping(value = "/getMyNewPublic",method = RequestMethod.GET)
  342. public Result getMyNewPublic (){
  343. Result res =new Result();
  344. res.data(publicReleaseService.getMyNewPublic());
  345. return res;
  346. }
  347. /**
  348. * 新增协单助手
  349. * @param id 公出编号
  350. * @param aid 协单助手编号
  351. */
  352. @RequestMapping(value = "/addAssistant",method = RequestMethod.POST)
  353. public Result addAssistant (Integer id,String aid){
  354. Result res =new Result();
  355. if (id==null||aid==null){
  356. res.getError().add(new Error(ErrorConstants.PARAM_EMPTY_ERROR,"公出编号与人员编号"));
  357. return res;
  358. }
  359. if (publicReleaseService.checkaddAssistant(id,aid)){
  360. res.getError().add(new Error("协单助手已经存在"));
  361. return res;
  362. }
  363. res.data(publicReleaseService.addAssistant(id,aid));
  364. return res;
  365. }
  366. /**
  367. * 删除协单助手
  368. * @param id 公出编号
  369. * @param aid 协单助手编号
  370. */
  371. @RequestMapping(value = "/deleteAssistant",method = RequestMethod.POST)
  372. public Result deleteAssistant (Integer id,String aid){
  373. Result res =new Result();
  374. if (id==null||aid==null){
  375. res.getError().add(new Error(ErrorConstants.PARAM_EMPTY_ERROR,"公出编号与人员编号"));
  376. return res;
  377. }
  378. if (publicReleaseService.checkdeleteAssistant(id,aid)){
  379. res.getError().add(new Error("协单助手已经打卡,无法删除"));
  380. return res;
  381. }
  382. res.data(publicReleaseService.deleteAssistant(id,aid));
  383. return res;
  384. }
  385. /**
  386. * 技术发起公出查询发起情况
  387. */
  388. @RequestMapping(value = "/checkOrderNoDuration",method = RequestMethod.GET)
  389. public Result checkOrderNoDuration (InputPublicRelease in){
  390. Result res =new Result();
  391. return res.data(publicReleaseService.checkOrderNoDuration(in));
  392. }
  393. /**
  394. * 技术发起公出查询发起情况
  395. */
  396. @RequestMapping(value = "/pushDateClock",method = RequestMethod.POST)
  397. public Result pushDateClock (){
  398. Result res =new Result();
  399. return res.data(publicReleaseService.pushDateClock());
  400. }
  401. }