AdminReleaseApiController.java 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268
  1. package com.goafanti.weChat.controller;
  2. import java.util.List;
  3. import javax.annotation.Resource;
  4. import javax.servlet.http.HttpServletRequest;
  5. import javax.servlet.http.HttpServletResponse;
  6. import org.springframework.beans.factory.annotation.Value;
  7. import org.springframework.web.bind.annotation.RequestMapping;
  8. import org.springframework.web.bind.annotation.RequestMethod;
  9. import org.springframework.web.bind.annotation.RestController;
  10. import com.goafanti.common.bo.Result;
  11. import com.goafanti.common.constant.ErrorConstants;
  12. import com.goafanti.common.controller.CertifyApiController;
  13. import com.goafanti.common.utils.StringUtils;
  14. import com.goafanti.common.utils.excel.NewExcelUtil;
  15. import com.goafanti.weChat.bo.InputPublicDtails;
  16. import com.goafanti.weChat.bo.InputPublicRelease;
  17. import com.goafanti.weChat.bo.InputPublicReleaseList;
  18. import com.goafanti.weChat.bo.InputPublicStatistics;
  19. import com.goafanti.weChat.bo.OutPublicDtails;
  20. import com.goafanti.weChat.bo.OutPublicStatistics;
  21. import com.goafanti.weChat.service.PublicReleaseService;
  22. @RestController
  23. @RequestMapping(value = "/api/admin/release")
  24. public class AdminReleaseApiController extends CertifyApiController{
  25. @Resource
  26. private PublicReleaseService publicReleaseService;
  27. @Value(value = "${upload.path}")
  28. private String uploadPath = null;
  29. /**
  30. * 发起外出申请
  31. */
  32. @RequestMapping(value = "/addPublicRelease", method = RequestMethod.POST)
  33. public Result addPublicRelease(InputPublicRelease in){
  34. Result res = new Result();
  35. if (StringUtils.isBlank(in.getUid())) {
  36. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,"用户编号"));
  37. return res;
  38. }
  39. if (StringUtils.isBlank(in.getReleaseStarts())) {
  40. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,"公出时间"));
  41. return res;
  42. }
  43. if (StringUtils.isBlank(in.getUserName())) {
  44. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,"公出地点"));
  45. return res;
  46. }
  47. if (publicReleaseService.checkTime(in)) {
  48. res.getError().add(buildError("公出时段已经被使用!","公出时段已经被使用!"));
  49. return res;
  50. }
  51. res.setData(publicReleaseService.addPublicRelease(in));
  52. return res;
  53. }
  54. /**
  55. * 修改外出申请
  56. * @return
  57. */
  58. @RequestMapping(value = "/updatePublicRelease", method = RequestMethod.POST)
  59. public Result updatePublicRelease(InputPublicRelease in){
  60. Result res = new Result();
  61. if (publicReleaseService.checkTime(in)) {
  62. res.getError().add(buildError("公出时段已经被使用!","公出时段已经被使用!"));
  63. return res;
  64. }
  65. res.setData(publicReleaseService.updatePublicRelease(in));
  66. return res;
  67. }
  68. /**
  69. * 外出打卡、公出打卡
  70. * @return
  71. */
  72. @RequestMapping(value = "/publicReleaseClockIn", method = RequestMethod.POST)
  73. public Result publicReleaseClockIn(Integer id,String photoUrl){
  74. Result res =new Result();
  75. res.setData(publicReleaseService.pushPublicReleaseClockIn(id,photoUrl));
  76. return res;
  77. }
  78. /**
  79. * 外出申请详情
  80. * @return
  81. */
  82. @RequestMapping(value = "/dtails", method = RequestMethod.GET)
  83. public Result dtails(Integer id){
  84. Result res =new Result();
  85. res.setData(publicReleaseService.dtails(id));
  86. return res;
  87. }
  88. /**
  89. * 外出申请详情
  90. * @return
  91. */
  92. @RequestMapping(value = "/followDtails", method = RequestMethod.GET)
  93. public Result followDtails(String id){
  94. Result res =new Result();
  95. res.setData(publicReleaseService.followDtails(id));
  96. return res;
  97. }
  98. /**
  99. * 外出申请列表
  100. * @return
  101. */
  102. @RequestMapping(value = "/listPublicRelease", method = RequestMethod.GET)
  103. public Result listPublicRelease(InputPublicReleaseList in){
  104. Result res =new Result();
  105. res.setData(publicReleaseService.listPublicRelease(in));
  106. return res;
  107. }
  108. /**
  109. * 外出审核
  110. * @return
  111. */
  112. @RequestMapping(value = "/examinePublicRelease", method = RequestMethod.POST)
  113. public Result examinePublicRelease(Integer id ,Integer status,String remarks,Double duration){
  114. Result res =new Result();
  115. if (id==null) {
  116. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,"公出编号"));
  117. return res;
  118. }
  119. if (status!=0&&status!=2) {
  120. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,"审核状态"));
  121. return res;
  122. }
  123. if (remarks.length()>20) {
  124. res.getError().add(buildError("备注长度不能超过20个字符。"));
  125. return res;
  126. }
  127. res.setData(publicReleaseService.pushExaminePublicRelease( id , status, remarks,duration));
  128. return res;
  129. }
  130. /**
  131. * 外出审核日志列表
  132. * @return
  133. */
  134. @RequestMapping(value = "/listPublicReleaseLog", method = RequestMethod.GET)
  135. public Result listPublicReleaseLog(Integer id,String ufid){
  136. Result res =new Result();
  137. res.data(publicReleaseService.listPublicReleaseLog(id,ufid));
  138. return res;
  139. }
  140. /**
  141. * 公出统计
  142. * @return
  143. */
  144. @RequestMapping(value = "/publicReleaseStatistics", method = RequestMethod.GET)
  145. public Result publicReleaseStatistics(InputPublicStatistics in){
  146. Result res =new Result();
  147. res.data(publicReleaseService.publicReleaseStatistics(in));
  148. return res;
  149. }
  150. /**
  151. * 公出统计导出
  152. * @return
  153. */
  154. @RequestMapping(value = "/publicReleaseStatistics/export", method = RequestMethod.GET)
  155. public Result publicReleaseStatisticsExport(InputPublicStatistics in,HttpServletResponse response){
  156. List<OutPublicStatistics> list =publicReleaseService.publicReleaseStatisticsList(in);
  157. NewExcelUtil<OutPublicStatistics>excel=new NewExcelUtil<>(OutPublicStatistics.class);
  158. return excel.exportExcel(list,"公出统计列表",response);
  159. }
  160. /**
  161. * 公出详情列表
  162. * @return
  163. */
  164. @RequestMapping(value = "/publicReleaseDtails", method = RequestMethod.GET)
  165. public Result publicReleaseListDtails(InputPublicDtails in){
  166. Result res =new Result();
  167. res.data(publicReleaseService.publicReleaseListDtails(in));
  168. return res;
  169. }
  170. /**
  171. * 公出详情列表
  172. * @return
  173. */
  174. @RequestMapping(value = "/publicReleaseDtails/export", method = RequestMethod.GET)
  175. public Result publicReleaseListDtailsExport(InputPublicDtails in ){
  176. List<OutPublicDtails> list=publicReleaseService.publicReleaseListDtailsList(in);
  177. NewExcelUtil<OutPublicDtails>excel=new NewExcelUtil<>(OutPublicDtails.class);
  178. return excel.exportExcel(list,"公出详细列表",uploadPath);
  179. }
  180. /** 上传图片 **/
  181. @RequestMapping(value = "/upload", method = RequestMethod.POST)
  182. public Result uploadOrderInvoiceFile(HttpServletRequest req){
  183. Result res = new Result();
  184. res.setData(handleFile(res, "/publicRelease/", false, req, "publicRelease"));
  185. return res;
  186. }
  187. /**
  188. * 搜索
  189. * @return
  190. */
  191. @RequestMapping(value = "/addSupplement", method = RequestMethod.POST)
  192. public Result addSupplement(Integer id,String supplement,String nextPlan){
  193. Result res =new Result();
  194. if (id==null) {
  195. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,"公出编号"));
  196. return res;
  197. }
  198. if (supplement==null) {
  199. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,"本次公出目标总结"));
  200. return res;
  201. }
  202. if (nextPlan==null) {
  203. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,"下次公出计划"));
  204. return res;
  205. }
  206. res.setData(publicReleaseService.addSupplement( id ,supplement,nextPlan));
  207. return res;
  208. }
  209. /**
  210. * 根据客户返回订单
  211. */
  212. @RequestMapping(value = "/selectOrderByUid",method =RequestMethod.GET)
  213. public Result selectOrderByUid(String uid){
  214. Result res = new Result();
  215. if (uid==null){
  216. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,ErrorConstants.PARAM_EMPTY_ERROR,"客户编号"));
  217. return res;
  218. }
  219. res.data(publicReleaseService.selectOrderByUid(uid));
  220. return res;
  221. }
  222. /**
  223. * 查看上门记录
  224. */
  225. @RequestMapping(value = "/publicByOrder",method =RequestMethod.GET)
  226. public Result publicByOrder(String orderNo){
  227. Result res = new Result();
  228. if (orderNo==null){
  229. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,ErrorConstants.PARAM_EMPTY_ERROR,"订单编号"));
  230. return res;
  231. }
  232. res.data(publicReleaseService.publicByOrder(orderNo));
  233. return res;
  234. }
  235. }