AdminReleaseApiController.java 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417
  1. package com.goafanti.weChat.controller;
  2. import java.util.ArrayList;
  3. import java.util.List;
  4. import javax.annotation.Resource;
  5. import javax.servlet.http.HttpServletRequest;
  6. import javax.servlet.http.HttpServletResponse;
  7. import com.goafanti.common.bo.Error;
  8. import com.goafanti.common.error.BusinessException;
  9. import com.goafanti.weChat.bo.*;
  10. import org.apache.commons.beanutils.BeanUtils;
  11. import org.springframework.beans.factory.annotation.Value;
  12. import org.springframework.web.bind.annotation.RequestMapping;
  13. import org.springframework.web.bind.annotation.RequestMethod;
  14. import org.springframework.web.bind.annotation.RestController;
  15. import com.goafanti.common.bo.Result;
  16. import com.goafanti.common.constant.ErrorConstants;
  17. import com.goafanti.common.controller.CertifyApiController;
  18. import com.goafanti.common.utils.StringUtils;
  19. import com.goafanti.common.utils.excel.NewExcelUtil;
  20. import com.goafanti.weChat.service.PublicReleaseService;
  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. res.setData(x);
  108. return res;
  109. }
  110. /**
  111. * 外出申请详情
  112. * @return
  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. * @return
  123. */
  124. @RequestMapping(value = "/followDtails", method = RequestMethod.GET)
  125. public Result followDtails(String id){
  126. Result res =new Result();
  127. res.setData(publicReleaseService.followDtails(id));
  128. return res;
  129. }
  130. /**
  131. * 外出申请列表
  132. * @return
  133. */
  134. @RequestMapping(value = "/listPublicRelease", method = RequestMethod.GET)
  135. public Result listPublicRelease(InputPublicReleaseList in){
  136. Result res =new Result();
  137. res.setData(publicReleaseService.listPublicRelease(in));
  138. return res;
  139. }
  140. /**
  141. * 公出审核、外出审核 上级
  142. * @return
  143. */
  144. @RequestMapping(value = "/examinePublicRelease", method = RequestMethod.POST)
  145. public Result examinePublicRelease(Integer id ,Integer status,String remarks){
  146. Result res =new Result();
  147. if (id==null) {
  148. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,"公出编号"));
  149. return res;
  150. }
  151. if (status!=0&&status!=2) {
  152. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,"审核状态"));
  153. return res;
  154. }
  155. if (remarks.length()>20) {
  156. res.getError().add(buildError("备注长度不能超过20个字符。"));
  157. return res;
  158. }
  159. res.setData(publicReleaseService.pushExaminePublicRelease(id,status,remarks,0));
  160. return res;
  161. }
  162. /**
  163. * 公出审核、外出审核 上级
  164. * @return
  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. * @return
  187. */
  188. @RequestMapping(value = "/techReject", method = RequestMethod.POST)
  189. public Result techReject(Integer id ,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 (remarks.length()>20) {
  196. res.getError().add(buildError("备注长度不能超过20个字符。"));
  197. return res;
  198. }
  199. res.setData(publicReleaseService.pushTechReject( id , remarks));
  200. return res;
  201. }
  202. /**
  203. * 外出审核日志列表
  204. * @return
  205. */
  206. @RequestMapping(value = "/listPublicReleaseLog", method = RequestMethod.GET)
  207. public Result listPublicReleaseLog(Integer id,String ufid){
  208. Result res =new Result();
  209. res.data(publicReleaseService.listPublicReleaseLog(id,ufid));
  210. return res;
  211. }
  212. /**
  213. * 公出统计
  214. * @return
  215. */
  216. @RequestMapping(value = "/publicReleaseStatistics", method = RequestMethod.GET)
  217. public Result publicReleaseStatistics(InputPublicStatistics in){
  218. Result res =new Result();
  219. res.data(publicReleaseService.publicReleaseStatistics(in));
  220. return res;
  221. }
  222. /**
  223. * 公出统计导出
  224. * @return
  225. */
  226. @RequestMapping(value = "/publicReleaseStatistics/export", method = RequestMethod.GET)
  227. public Result publicReleaseStatisticsExport(InputPublicStatistics in,HttpServletResponse response){
  228. List<OutPublicStatistics> list =publicReleaseService.publicReleaseStatisticsList(in);
  229. NewExcelUtil<OutPublicStatistics>excel=new NewExcelUtil<>(OutPublicStatistics.class);
  230. return excel.exportExcel(list,"公出统计列表",response);
  231. }
  232. /**
  233. * 公出详情列表
  234. * @return
  235. */
  236. @RequestMapping(value = "/publicReleaseDtails", method = RequestMethod.GET)
  237. public Result publicReleaseListDtails(InputPublicDtails in){
  238. Result res =new Result();
  239. res.data(publicReleaseService.publicReleaseListDtails(in));
  240. return res;
  241. }
  242. /**
  243. * 公出详情列表
  244. * @return
  245. */
  246. @RequestMapping(value = "/publicReleaseDtails/export", method = RequestMethod.GET)
  247. public Result publicReleaseListDtailsExport(InputPublicDtails in ,Integer exportType){
  248. if (exportType==null)exportType=0;
  249. List<OutPublicDtails> outList=publicReleaseService.publicReleaseListDtailsList(in);
  250. if (exportType==0){
  251. List<OutPublicDtails> list=outList;
  252. NewExcelUtil<OutPublicDtails>excel=new NewExcelUtil<>(OutPublicDtails.class);
  253. return excel.exportExcel(list,"公出详细列表",uploadPath);
  254. }else if (exportType==1){
  255. List<OutPublicDtailsFinance> list = new ArrayList<>();
  256. for (OutPublicDtails outPublicDtails : outList) {
  257. OutPublicDtailsFinance of= new OutPublicDtailsFinance();
  258. try {
  259. BeanUtils.copyProperties( of,outPublicDtails);
  260. } catch (Exception e) {
  261. throw new BusinessException("数据转换异常");
  262. }
  263. list.add(of);
  264. }
  265. NewExcelUtil<OutPublicDtailsFinance>excel=new NewExcelUtil<>(OutPublicDtailsFinance.class);
  266. return excel.exportExcel(list,"公出详细列表",uploadPath);
  267. }
  268. return null;
  269. }
  270. /** 上传图片 **/
  271. @RequestMapping(value = "/upload", method = RequestMethod.POST)
  272. public Result uploadOrderInvoiceFile(HttpServletRequest req){
  273. Result res = new Result();
  274. res.setData(handleFile(res, "/publicRelease/", false, req, "publicRelease"));
  275. return res;
  276. }
  277. /**
  278. * 搜索
  279. * @return
  280. */
  281. @RequestMapping(value = "/addSupplement", method = RequestMethod.POST)
  282. public Result addSupplement(Integer id,String supplement,String nextPlan){
  283. Result res =new Result();
  284. if (id==null) {
  285. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,"公出编号"));
  286. return res;
  287. }
  288. if (supplement==null) {
  289. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,"本次公出目标总结"));
  290. return res;
  291. }
  292. if (nextPlan==null) {
  293. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,"下次公出计划"));
  294. return res;
  295. }
  296. res.setData(publicReleaseService.addSupplement( id ,supplement,nextPlan));
  297. return res;
  298. }
  299. /**
  300. * 根据客户返回订单
  301. */
  302. @RequestMapping(value = "/selectOrderByUid",method =RequestMethod.GET)
  303. public Result selectOrderByUid(String uid){
  304. Result res = new Result();
  305. if (uid==null){
  306. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,ErrorConstants.PARAM_EMPTY_ERROR,"客户编号"));
  307. return res;
  308. }
  309. res.data(publicReleaseService.selectOrderByUid(uid));
  310. return res;
  311. }
  312. /**
  313. * 查看上门记录
  314. */
  315. @RequestMapping(value = "/publicByOrder",method =RequestMethod.GET)
  316. public Result publicByOrder(String orderNo){
  317. Result res = new Result();
  318. if (orderNo==null){
  319. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,ErrorConstants.PARAM_EMPTY_ERROR,"订单编号"));
  320. return res;
  321. }
  322. res.data(publicReleaseService.publicByOrder(orderNo));
  323. return res;
  324. }
  325. /**
  326. * 打卡页面获取自己最新的打卡
  327. * @return
  328. */
  329. @RequestMapping(value = "/getMyNewPublic",method = RequestMethod.GET)
  330. public Result getMyNewPublic (){
  331. Result res =new Result();
  332. res.data(publicReleaseService.getMyNewPublic());
  333. return res;
  334. }
  335. /**
  336. * 新增协单助手
  337. * @param id 公出编号
  338. * @param aid 协单助手编号
  339. * @return
  340. */
  341. @RequestMapping(value = "/addAssistant",method = RequestMethod.POST)
  342. public Result addAssistant (Integer id,String aid){
  343. Result res =new Result();
  344. if (id==null||aid==null){
  345. res.getError().add(new Error(ErrorConstants.PARAM_EMPTY_ERROR,"公出编号与人员编号"));
  346. return res;
  347. }
  348. if (publicReleaseService.checkaddAssistant(id,aid)){
  349. res.getError().add(new Error("协单助手已经存在"));
  350. return res;
  351. }
  352. res.data(publicReleaseService.addAssistant(id,aid));
  353. return res;
  354. }
  355. /**
  356. * 删除协单助手
  357. * @param id 公出编号
  358. * @param aid 协单助手编号
  359. * @return
  360. */
  361. @RequestMapping(value = "/deleteAssistant",method = RequestMethod.POST)
  362. public Result deleteAssistant (Integer id,String aid){
  363. Result res =new Result();
  364. if (id==null||aid==null){
  365. res.getError().add(new Error(ErrorConstants.PARAM_EMPTY_ERROR,"公出编号与人员编号"));
  366. return res;
  367. }
  368. if (publicReleaseService.checkdeleteAssistant(id,aid)){
  369. res.getError().add(new Error("协单助手已经打卡,无法删除"));
  370. return res;
  371. }
  372. res.data(publicReleaseService.deleteAssistant(id,aid));
  373. return res;
  374. }
  375. }