1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- package com.rongwei.bsserver.controller;
- import com.rongwei.bscommon.sys.service.ZhcxOutsideInspectionItpService;
- import com.rongwei.bscommon.sys.utils.LockUtils;
- import com.rongwei.bsentity.vo.OperOutsideInspectionVo;
- import com.rongwei.bsentity.vo.ZhcxOutsideExportVo;
- 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.PostMapping;
- import org.springframework.web.bind.annotation.RequestBody;
- import org.springframework.web.bind.annotation.RequestMapping;
- import org.springframework.web.bind.annotation.RestController;
- import javax.servlet.http.HttpServletResponse;
- import java.io.FileNotFoundException;
- import java.util.List;
- import java.util.Map;
- @RestController
- @RequestMapping("/zhcxOperOutsideInspection")
- @Slf4j
- @Api("外部报验参数")
- public class ZhcxOperOutsideInspectionController {
- @Autowired
- private ZhcxOutsideInspectionItpService inspectionService;
- @Autowired
- private LockUtils lockUtils;
- @ApiOperation("外部报验操作")
- @PostMapping("/OperInspectionStatus")
- public R OperInspectionStatus(@RequestBody List<OperOutsideInspectionVo> vo) {
- try {
- for(OperOutsideInspectionVo inspectionVo : vo){
- String itpId = inspectionVo.getItpId();
- lockUtils.lock("itpid",itpId);
- }
- R r = inspectionService.operInspectionStatus(vo);
- return r;
- } catch (Exception e) {
- log.error("操作失败, {}", e);
- return R.errorWithMsg("操作失败");
- }finally {
- for(OperOutsideInspectionVo inspectionVo : vo){
- String itpId = inspectionVo.getItpId();
- lockUtils.unlock("itpid",itpId);
- }
- }
- }
- @ApiOperation("文件下载")
- @PostMapping("/downloadFile")
- public void downloadFile(@RequestBody ZhcxOutsideExportVo zhcxOutsideExportVo, HttpServletResponse response) throws FileNotFoundException {
- int i = inspectionService.downloadFile(zhcxOutsideExportVo, response);
- if(i == 0){
- throw new CustomException("暂无相关附件");
- }else if(i == 1){
- throw new CustomException("下载附件失败");
- }
- }
- }
|