ZhcxOperOutsideInspectionController.java 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. package com.rongwei.bsserver.controller;
  2. import com.rongwei.bscommon.sys.service.ZhcxOutsideInspectionItpService;
  3. import com.rongwei.bscommon.sys.utils.LockUtils;
  4. import com.rongwei.bsentity.vo.OperOutsideInspectionVo;
  5. import com.rongwei.bsentity.vo.ZhcxOutsideExportVo;
  6. import com.rongwei.rwcommon.base.R;
  7. import com.rongwei.rwcommon.base.exception.CustomException;
  8. import io.swagger.annotations.Api;
  9. import io.swagger.annotations.ApiOperation;
  10. import lombok.extern.slf4j.Slf4j;
  11. import org.springframework.beans.factory.annotation.Autowired;
  12. import org.springframework.web.bind.annotation.PostMapping;
  13. import org.springframework.web.bind.annotation.RequestBody;
  14. import org.springframework.web.bind.annotation.RequestMapping;
  15. import org.springframework.web.bind.annotation.RestController;
  16. import javax.servlet.http.HttpServletResponse;
  17. import java.io.FileNotFoundException;
  18. import java.util.List;
  19. import java.util.Map;
  20. @RestController
  21. @RequestMapping("/zhcxOperOutsideInspection")
  22. @Slf4j
  23. @Api("外部报验参数")
  24. public class ZhcxOperOutsideInspectionController {
  25. @Autowired
  26. private ZhcxOutsideInspectionItpService inspectionService;
  27. @Autowired
  28. private LockUtils lockUtils;
  29. @ApiOperation("外部报验操作")
  30. @PostMapping("/OperInspectionStatus")
  31. public R OperInspectionStatus(@RequestBody List<OperOutsideInspectionVo> vo) {
  32. try {
  33. for(OperOutsideInspectionVo inspectionVo : vo){
  34. String itpId = inspectionVo.getItpId();
  35. lockUtils.lock("itpid",itpId);
  36. }
  37. R r = inspectionService.operInspectionStatus(vo);
  38. return r;
  39. } catch (Exception e) {
  40. log.error("操作失败, {}", e);
  41. return R.errorWithMsg("操作失败");
  42. }finally {
  43. for(OperOutsideInspectionVo inspectionVo : vo){
  44. String itpId = inspectionVo.getItpId();
  45. lockUtils.unlock("itpid",itpId);
  46. }
  47. }
  48. }
  49. @ApiOperation("文件下载")
  50. @PostMapping("/downloadFile")
  51. public void downloadFile(@RequestBody ZhcxOutsideExportVo zhcxOutsideExportVo, HttpServletResponse response) throws FileNotFoundException {
  52. int i = inspectionService.downloadFile(zhcxOutsideExportVo, response);
  53. if(i == 0){
  54. throw new CustomException("暂无相关附件");
  55. }else if(i == 1){
  56. throw new CustomException("下载附件失败");
  57. }
  58. }
  59. }