ZhcxInsideInspectionController.java 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  1. package com.rongwei.bsserver.controller;
  2. import cn.hutool.core.util.ObjectUtil;
  3. import com.alibaba.fastjson.JSON;
  4. import com.rongwei.bscommon.sys.service.ZhcxInsideInspectionService;
  5. import com.rongwei.bsentity.dto.InsideInspectionOperRequest;
  6. import com.rongwei.bsentity.dto.inside.*;
  7. import com.rongwei.bsentity.vo.ZhcxInsideInspectionVo;
  8. import com.rongwei.rwcommon.base.R;
  9. import com.rongwei.rwcommon.base.exception.CustomException;
  10. import io.swagger.annotations.Api;
  11. import io.swagger.annotations.ApiOperation;
  12. import lombok.extern.slf4j.Slf4j;
  13. import org.springframework.beans.factory.annotation.Autowired;
  14. import org.springframework.web.bind.annotation.*;
  15. import javax.servlet.http.HttpServletResponse;
  16. import java.util.List;
  17. import java.util.Map;
  18. /**
  19. * <p>
  20. * 内部报验-报验管理 前端控制器
  21. * </p>
  22. *
  23. * @author wm
  24. * @since 2024-05-21
  25. */
  26. @RestController
  27. @RequestMapping("/inside/inspection")
  28. @Api(tags = "内部报验")
  29. @Slf4j
  30. public class ZhcxInsideInspectionController {
  31. @Autowired
  32. private ZhcxInsideInspectionService service;
  33. /**
  34. * 发起
  35. *
  36. * @param req
  37. * @return
  38. */
  39. @ApiOperation("发起报验")
  40. @PostMapping("/launch")
  41. public R launch(@RequestBody InsideInspectionOperRequest req){
  42. service.launch(req);
  43. return R.ok();
  44. }
  45. /**
  46. * 派单
  47. *
  48. * @param req
  49. * @return
  50. */
  51. @PostMapping("/dispacth")
  52. @ApiOperation("派单")
  53. public R dispacth(@RequestBody InsideInspectionDispatchRequest req){
  54. req.setDispatchFlag(1);
  55. service.dispatch(req);
  56. return R.ok("派单成功");
  57. }
  58. /**
  59. * 派单
  60. *
  61. * @param req
  62. * @return
  63. */
  64. @ApiOperation("改派")
  65. @PostMapping("/reDispatch")
  66. public R reDispatch(@RequestBody InsideInspectionDispatchRequest req){
  67. req.setDispatchFlag(2);
  68. service.reDispatch(req);
  69. return R.ok("改派成功");
  70. }
  71. /**
  72. * 执行
  73. *
  74. * @param req
  75. * @return
  76. */
  77. @ApiOperation("执行")
  78. @PostMapping("/execute")
  79. public R execute(@RequestBody InsideInspectionDispatchRequest req){
  80. try {
  81. service.execute(req);
  82. return R.ok("执行成功");
  83. } catch (Exception e) {
  84. log.error("执行异常, {}", e);
  85. return R.error("执行异常");
  86. }
  87. }
  88. /**
  89. * 取消
  90. *
  91. * @param req
  92. * @return
  93. */
  94. @ApiOperation("取消")
  95. @PostMapping("/cancel")
  96. public R cancel(@RequestBody InsideInspectionRequest req){
  97. service.cancel(req);
  98. return R.ok();
  99. }
  100. /**
  101. * 重新报验
  102. *
  103. * @param req
  104. * @return
  105. */
  106. @ApiOperation("重新报验")
  107. @PostMapping("/reInspection")
  108. public R reInspection(@RequestBody InsideInspectionReInspectionRequest req){
  109. service.reInspection(req);
  110. return R.ok();
  111. }
  112. /**
  113. * 添加修改记录
  114. *
  115. * @param req
  116. * @return
  117. */
  118. @ApiOperation("添加修改记录")
  119. @PostMapping("/addModifyHistory")
  120. public R addModifyHistory(@RequestBody InsideInspectionModifyRecordRequest req){
  121. service.addModifyHistory(req);
  122. return R.ok();
  123. }
  124. /**
  125. * 下载
  126. *
  127. * @param exportReq
  128. * @param response
  129. */
  130. @ApiOperation("文件下载")
  131. @PostMapping("/downloadFile")
  132. public void downloadFile(@RequestBody ZhcxInsideExportRequest exportReq, HttpServletResponse response) {
  133. int i = service.downloadFile(exportReq, response);
  134. if(i == 0){
  135. throw new CustomException("暂无相关附件");
  136. }else if(i == 1){
  137. throw new CustomException("下载附件失败");
  138. }
  139. }
  140. /**
  141. * 保存
  142. *
  143. * @param req
  144. * @return
  145. */
  146. @ApiOperation("保存内部报验")
  147. @PostMapping("/insertInspection")
  148. public R insertInspection(@RequestBody InsideInspectionInsertRequest req){
  149. service.insertInspection(req);
  150. return R.ok();
  151. }
  152. /**
  153. * 修改/重新报验
  154. *
  155. * @param req
  156. * @return
  157. */
  158. @ApiOperation("修改内部报验")
  159. @PostMapping("/updateInspection")
  160. public R updateInspection(@RequestBody InsideInspectionUpdateRequest req){
  161. service.updateInspection(req);
  162. return R.ok();
  163. }
  164. /**
  165. * 内部执行导入
  166. * @param file
  167. * @param request
  168. */
  169. @PostMapping("/executeImport")
  170. @ResponseBody
  171. public R excelImport(@RequestBody Map<String,Object> map) {
  172. Object dataObj = map.get("data");
  173. if(ObjectUtil.isEmpty(dataObj)){
  174. return R.error();
  175. }
  176. String data = (String) dataObj;
  177. List<ZhcxInsideInspectionVo> list = JSON.parseArray(data, ZhcxInsideInspectionVo.class);
  178. service.updateSupervision(list);
  179. return R.ok();
  180. }
  181. }