Commit 4e6761f3 authored by qinhu's avatar qinhu

报告上传

parent e8f51016
package cn.wise.sc.cement.business.controller; package cn.wise.sc.cement.business.controller;
import cn.hutool.core.bean.BeanUtil;
import cn.wise.sc.cement.business.entity.EntityEnclosure;
import cn.wise.sc.cement.business.model.BaseResponse; import cn.wise.sc.cement.business.model.BaseResponse;
import cn.wise.sc.cement.business.model.FileExt; import cn.wise.sc.cement.business.model.FileExt;
import cn.wise.sc.cement.business.model.IndustrialElementKey; import cn.wise.sc.cement.business.model.IndustrialElementKey;
...@@ -8,24 +10,33 @@ import cn.wise.sc.cement.business.model.PageQuery; ...@@ -8,24 +10,33 @@ import cn.wise.sc.cement.business.model.PageQuery;
import cn.wise.sc.cement.business.model.ReportDetailVo; import cn.wise.sc.cement.business.model.ReportDetailVo;
import cn.wise.sc.cement.business.model.SixElementKey; import cn.wise.sc.cement.business.model.SixElementKey;
import cn.wise.sc.cement.business.model.SixElementReport; import cn.wise.sc.cement.business.model.SixElementReport;
import cn.wise.sc.cement.business.model.query.SampleHandleEnclosureQuery;
import cn.wise.sc.cement.business.model.vo.EntrustVo; import cn.wise.sc.cement.business.model.vo.EntrustVo;
import cn.wise.sc.cement.business.service.IEntityEnclosureService;
import cn.wise.sc.cement.business.service.IEntrustService; import cn.wise.sc.cement.business.service.IEntrustService;
import cn.wise.sc.cement.business.util.WordUtil; import cn.wise.sc.cement.business.util.WordUtil;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.Assert;
import org.springframework.web.bind.annotation.CrossOrigin; import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping; 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.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.time.LocalDateTime;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
...@@ -46,6 +57,8 @@ public class ReportController { ...@@ -46,6 +57,8 @@ public class ReportController {
final final
IEntrustService iEntrustService; IEntrustService iEntrustService;
@Autowired
IEntityEnclosureService iEntityEnclosureService;
public ReportController(IEntrustService iEntrustService) { public ReportController(IEntrustService iEntrustService) {
this.iEntrustService = iEntrustService; this.iEntrustService = iEntrustService;
...@@ -128,6 +141,45 @@ public class ReportController { ...@@ -128,6 +141,45 @@ public class ReportController {
} }
@PostMapping("/upload")
@ApiOperation("上传报告")
public BaseResponse<Boolean> uploadReport(@RequestBody SampleHandleEnclosureQuery query){
Assert.notNull(query.getId(),"委托id不能为空!");
QueryWrapper<EntityEnclosure> qw = new QueryWrapper();
qw.eq("entity_type",5);
qw.eq("entity_id",query.getId());
if (FileExt.EXCL.getName().equals(query.getExtName()) ||
FileExt.EXCLX.getName().equals(query.getExtName())){
EntityEnclosure one = iEntityEnclosureService.getOne(qw);
if (BeanUtil.isEmpty(one)){
EntityEnclosure entityEnclosure = new EntityEnclosure();
entityEnclosure.setEntityId(query.getId());
entityEnclosure.setExtName(query.getExtName());
entityEnclosure.setCreateTime(LocalDateTime.now());
entityEnclosure.setUpdateTime(LocalDateTime.now());
entityEnclosure.setEnclosureUrl(query.getEnclosureUrl());
entityEnclosure.setAlias(query.getAlias());
entityEnclosure.setEntityType(5);
iEntityEnclosureService.save(entityEnclosure);
return BaseResponse.okData(true);
}else {
one.setAlias(query.getAlias());
one.setEnclosureUrl(query.getEnclosureUrl());
one.setExtName(query.getExtName());
one.setUpdateTime(LocalDateTime.now());
iEntityEnclosureService.updateById(one);
return BaseResponse.okData(true);
}
}else {
return BaseResponse.errorMsg("文件类型只能是excel!");
}
}
/** /**
* 将样品六元素检测Map转换成单独属性 * 将样品六元素检测Map转换成单独属性
* *
...@@ -201,4 +253,6 @@ public class ReportController { ...@@ -201,4 +253,6 @@ public class ReportController {
return strBuilder.replace(0, 5, "").toString(); return strBuilder.replace(0, 5, "").toString();
} }
} }
...@@ -10,7 +10,8 @@ public enum FileExt { ...@@ -10,7 +10,8 @@ public enum FileExt {
//office后缀名 //office后缀名
DOC(".doc"), DOC(".doc"),
EXCL(".xls"); EXCL(".xls"),
EXCLX(".xlsx");
private String name; private String name;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment