123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198 |
- package com.rongwei.bsserver.controller;
- import cn.hutool.core.util.ObjectUtil;
- import com.alibaba.fastjson.JSON;
- import com.rongwei.bscommon.sys.service.ZhcxInsideInspectionService;
- import com.rongwei.bsentity.dto.InsideInspectionOperRequest;
- import com.rongwei.bsentity.dto.inside.*;
- import com.rongwei.bsentity.vo.ZhcxInsideInspectionVo;
- import com.rongwei.rwcommon.base.R;
- import com.rongwei.rwcommon.base.exception.CustomException;
- import io.swagger.annotations.Api;
- import io.swagger.annotations.ApiOperation;
- import lombok.extern.slf4j.Slf4j;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.web.bind.annotation.*;
- import javax.servlet.http.HttpServletResponse;
- import java.util.List;
- import java.util.Map;
- /**
- * <p>
- * 内部报验-报验管理 前端控制器
- * </p>
- *
- * @author wm
- * @since 2024-05-21
- */
- @RestController
- @RequestMapping("/inside/inspection")
- @Api(tags = "内部报验")
- @Slf4j
- public class ZhcxInsideInspectionController {
- @Autowired
- private ZhcxInsideInspectionService service;
- /**
- * 发起
- *
- * @param req
- * @return
- */
- @ApiOperation("发起报验")
- @PostMapping("/launch")
- public R launch(@RequestBody InsideInspectionOperRequest req){
- service.launch(req);
- return R.ok();
- }
- /**
- * 派单
- *
- * @param req
- * @return
- */
- @PostMapping("/dispacth")
- @ApiOperation("派单")
- public R dispacth(@RequestBody InsideInspectionDispatchRequest req){
- req.setDispatchFlag(1);
- service.dispatch(req);
- return R.ok("派单成功");
- }
- /**
- * 派单
- *
- * @param req
- * @return
- */
- @ApiOperation("改派")
- @PostMapping("/reDispatch")
- public R reDispatch(@RequestBody InsideInspectionDispatchRequest req){
- req.setDispatchFlag(2);
- service.reDispatch(req);
- return R.ok("改派成功");
- }
- /**
- * 执行
- *
- * @param req
- * @return
- */
- @ApiOperation("执行")
- @PostMapping("/execute")
- public R execute(@RequestBody InsideInspectionDispatchRequest req){
- try {
- service.execute(req);
- return R.ok("执行成功");
- } catch (Exception e) {
- log.error("执行异常, {}", e);
- return R.error("执行异常");
- }
- }
- /**
- * 取消
- *
- * @param req
- * @return
- */
- @ApiOperation("取消")
- @PostMapping("/cancel")
- public R cancel(@RequestBody InsideInspectionRequest req){
- service.cancel(req);
- return R.ok();
- }
- /**
- * 重新报验
- *
- * @param req
- * @return
- */
- @ApiOperation("重新报验")
- @PostMapping("/reInspection")
- public R reInspection(@RequestBody InsideInspectionReInspectionRequest req){
- service.reInspection(req);
- return R.ok();
- }
- /**
- * 添加修改记录
- *
- * @param req
- * @return
- */
- @ApiOperation("添加修改记录")
- @PostMapping("/addModifyHistory")
- public R addModifyHistory(@RequestBody InsideInspectionModifyRecordRequest req){
- service.addModifyHistory(req);
- return R.ok();
- }
- /**
- * 下载
- *
- * @param exportReq
- * @param response
- */
- @ApiOperation("文件下载")
- @PostMapping("/downloadFile")
- public void downloadFile(@RequestBody ZhcxInsideExportRequest exportReq, HttpServletResponse response) {
- int i = service.downloadFile(exportReq, response);
- if(i == 0){
- throw new CustomException("暂无相关附件");
- }else if(i == 1){
- throw new CustomException("下载附件失败");
- }
- }
- /**
- * 保存
- *
- * @param req
- * @return
- */
- @ApiOperation("保存内部报验")
- @PostMapping("/insertInspection")
- public R insertInspection(@RequestBody InsideInspectionInsertRequest req){
- service.insertInspection(req);
- return R.ok();
- }
- /**
- * 修改/重新报验
- *
- * @param req
- * @return
- */
- @ApiOperation("修改内部报验")
- @PostMapping("/updateInspection")
- public R updateInspection(@RequestBody InsideInspectionUpdateRequest req){
- service.updateInspection(req);
- return R.ok();
- }
- /**
- * 内部执行导入
- * @param file
- * @param request
- */
- @PostMapping("/executeImport")
- @ResponseBody
- public R excelImport(@RequestBody Map<String,Object> map) {
- Object dataObj = map.get("data");
- if(ObjectUtil.isEmpty(dataObj)){
- return R.error();
- }
- String data = (String) dataObj;
- List<ZhcxInsideInspectionVo> list = JSON.parseArray(data, ZhcxInsideInspectionVo.class);
- service.updateSupervision(list);
- return R.ok();
- }
- }
|