|
@@ -1,8 +1,7 @@
|
|
|
package org.springblade.business.controller;
|
|
|
|
|
|
-import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
-import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import io.swagger.annotations.Api;
|
|
@@ -22,11 +21,11 @@ import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
-import javax.servlet.http.HttpServletRequest;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
import javax.servlet.http.HttpSession;
|
|
|
import java.io.IOException;
|
|
|
import java.io.OutputStream;
|
|
|
+import java.io.PrintWriter;
|
|
|
import java.net.URLEncoder;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.util.*;
|
|
@@ -45,13 +44,19 @@ public class DatumPointController {
|
|
|
private final DatumPointService service;
|
|
|
|
|
|
|
|
|
- @PostMapping("/list")
|
|
|
+ @GetMapping("/list")
|
|
|
public R<IPage<DatumPoint>> list( String contractId, Query page, String type, String name){
|
|
|
Map<String, Object> param = new HashMap<>(10);
|
|
|
- param.put("contractId",contractId);
|
|
|
- param.put("type",type);
|
|
|
- param.put("name",name);
|
|
|
- param.put("remark",name);
|
|
|
+ if(StringUtil.isNotBlank(contractId)){
|
|
|
+ param.put("contractId",contractId);
|
|
|
+ }
|
|
|
+ if(StringUtil.isNotBlank(type)){
|
|
|
+ param.put("type",type);
|
|
|
+ }
|
|
|
+ if(StringUtil.isNotBlank(contractId)){
|
|
|
+ param.put("name",name);
|
|
|
+ param.put("remark",name);
|
|
|
+ }
|
|
|
return R.data(service.page(Condition.getPage(page),Condition.getQueryWrapper(param,DatumPoint.class)));
|
|
|
}
|
|
|
|
|
@@ -70,8 +75,11 @@ public class DatumPointController {
|
|
|
|
|
|
|
|
|
@PostMapping("/del")
|
|
|
- public R del(String id){
|
|
|
- return R.status(this.service.removeById(id));
|
|
|
+ public R del(String ids){
|
|
|
+ if(StringUtil.isNotBlank(ids)){
|
|
|
+ return R.status(this.service.removeByIds(Func.toLongList(ids)));
|
|
|
+ }
|
|
|
+ return R.status(false);
|
|
|
}
|
|
|
|
|
|
|
|
@@ -83,26 +91,27 @@ public class DatumPointController {
|
|
|
}
|
|
|
|
|
|
@ResponseBody
|
|
|
- @RequestMapping(value = "/queryData",method=RequestMethod.POST)
|
|
|
- public R<DatumPointVo> queryData(HttpServletRequest request,String queryName,String contractId ,Integer type){
|
|
|
+ @GetMapping("/queryData")
|
|
|
+ public R<DatumPointVo> queryData(String queryName,String contractId ,Integer type){
|
|
|
if(StringUtil.isEmpty(queryName)||StringUtil.isEmpty(contractId)||StringUtil.isEmpty(type)){
|
|
|
return R.fail("缺少参数");
|
|
|
}
|
|
|
-
|
|
|
LambdaQueryWrapper<DatumPoint> wrapper = Wrappers.<DatumPoint>lambdaQuery().eq(DatumPoint::getName,queryName).eq(DatumPoint::getContractId,contractId).eq(DatumPoint::getType,type);
|
|
|
DatumPoint dap = this.service.getOne(wrapper);
|
|
|
DatumPointVo vo = new DatumPointVo();
|
|
|
- BeanUtils.copyProperties(dap,vo);
|
|
|
+ if(dap!=null) {
|
|
|
+ BeanUtils.copyProperties(dap, vo);
|
|
|
+ }
|
|
|
return R.data(vo);
|
|
|
}
|
|
|
|
|
|
|
|
|
@PostMapping("/import")
|
|
|
- public R<String> importXy(@RequestParam("file") MultipartFile file, Integer type , Long contractId) throws Exception {
|
|
|
- if(file != null&& type!=null && contractId!=null) {
|
|
|
+ public R importXy(@RequestParam("file") MultipartFile file, Integer type , Long contractId, Long projectId) throws Exception {
|
|
|
+ if(file != null&& type!=null && contractId!=null&&projectId!=null) {
|
|
|
String fileName = Objects.requireNonNull(file.getOriginalFilename());
|
|
|
- if(Pattern.matches(".(\\.xls)x?$",fileName.toLowerCase(Locale.ROOT))) {
|
|
|
- return R.success(this.service.importData(file,contractId,type));
|
|
|
+ if(Pattern.matches(".+(\\.xls)x?$",fileName.toLowerCase(Locale.ROOT))) {
|
|
|
+ return this.service.importData(file,contractId,projectId,type);
|
|
|
} else {
|
|
|
R.fail("文件格式不正确,请上传Excel文件");
|
|
|
}
|
|
@@ -174,6 +183,12 @@ public class DatumPointController {
|
|
|
response.setHeader("Content-Disposition", "attachment; filename=" + URLEncoder.encode(fileName, "UTF-8"));
|
|
|
wb.write(output);
|
|
|
output.close();
|
|
|
+ }else {
|
|
|
+ response.setContentType("application/json;charset=UTF-8");
|
|
|
+ PrintWriter out = response.getWriter();
|
|
|
+ out.println(JSON.toJSONString(R.fail("没有查到到相关数据")));
|
|
|
+ out.flush();
|
|
|
+ out.close();
|
|
|
}
|
|
|
|
|
|
}
|