420 lines
16 KiB
Plaintext
420 lines
16 KiB
Plaintext
|
|
package com.sercurityControl.proteam.newScreen.controller;
|
||
|
|
|
||
|
|
import com.alibaba.fastjson2.JSONObject;
|
||
|
|
import com.github.pagehelper.PageHelper;
|
||
|
|
import com.github.pagehelper.PageInfo;
|
||
|
|
import com.google.common.collect.Maps;
|
||
|
|
import com.securityControl.common.core.utils.aes.StringHelper;
|
||
|
|
import com.securityControl.common.core.web.domain.AjaxResult;
|
||
|
|
import com.securityControl.common.log.annotation.Log;
|
||
|
|
import com.securityControl.common.log.enums.BusinessType;
|
||
|
|
import com.securityControl.common.log.enums.OperationType;
|
||
|
|
import com.sercurityControl.proteam.controller.DeviceController;
|
||
|
|
import com.sercurityControl.proteam.domain.ProData;
|
||
|
|
import com.sercurityControl.proteam.domain.vo.DeviceVo;
|
||
|
|
import com.sercurityControl.proteam.domain.vo.ReturnCodeEntity;
|
||
|
|
import com.sercurityControl.proteam.newScreen.domain.MapStatisVo;
|
||
|
|
import com.sercurityControl.proteam.newScreen.domain.ProPlanVo;
|
||
|
|
import com.sercurityControl.proteam.newScreen.domain.SjNumberVo;
|
||
|
|
import com.sercurityControl.proteam.newScreen.domain.TySjEntity;
|
||
|
|
import com.sercurityControl.proteam.newScreen.service.TySjService;
|
||
|
|
import com.sercurityControl.proteam.util.DateTimeHelper;
|
||
|
|
import com.sercurityControl.proteam.util.ImportExcelUtils;
|
||
|
|
import io.swagger.annotations.ApiOperation;
|
||
|
|
import lombok.extern.slf4j.Slf4j;
|
||
|
|
import org.apache.poi.util.IOUtils;
|
||
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
||
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
||
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
||
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||
|
|
import org.springframework.web.bind.annotation.RestController;
|
||
|
|
import org.springframework.web.multipart.MultipartFile;
|
||
|
|
import org.springframework.web.multipart.MultipartHttpServletRequest;
|
||
|
|
import org.springframework.web.multipart.commons.CommonsMultipartResolver;
|
||
|
|
|
||
|
|
import javax.servlet.ServletOutputStream;
|
||
|
|
import javax.servlet.http.HttpServletRequest;
|
||
|
|
import javax.servlet.http.HttpServletResponse;
|
||
|
|
import java.io.IOException;
|
||
|
|
import java.io.InputStream;
|
||
|
|
import java.net.URLEncoder;
|
||
|
|
import java.nio.charset.StandardCharsets;
|
||
|
|
import java.util.*;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 通用设计应用率
|
||
|
|
*/
|
||
|
|
|
||
|
|
@RestController
|
||
|
|
@RequestMapping("/pot/tysj")
|
||
|
|
@Slf4j
|
||
|
|
public class TyDeviceController {
|
||
|
|
|
||
|
|
@Autowired
|
||
|
|
private TySjService service;
|
||
|
|
/**
|
||
|
|
* 工程技术统计
|
||
|
|
* @param tySjEntity
|
||
|
|
* @return
|
||
|
|
*/
|
||
|
|
@PostMapping("getGcjsNum")
|
||
|
|
public AjaxResult getGcjsNum(TySjEntity tySjEntity) {
|
||
|
|
Map<String,Object> map= Maps.newHashMap();
|
||
|
|
try {
|
||
|
|
map = service.getGcjsNum(tySjEntity);
|
||
|
|
} catch (Exception e) {
|
||
|
|
log.error(e.toString(), e);
|
||
|
|
}
|
||
|
|
return AjaxResult.success(map);
|
||
|
|
}
|
||
|
|
/**
|
||
|
|
* @param tySjEntity
|
||
|
|
* @return
|
||
|
|
*/
|
||
|
|
@PostMapping("insertData")
|
||
|
|
public AjaxResult insertData(TySjEntity tySjEntity) {
|
||
|
|
Map<String,Object> map= Maps.newHashMap();
|
||
|
|
try {
|
||
|
|
service.insertData(tySjEntity);
|
||
|
|
} catch (Exception e) {
|
||
|
|
log.error(e.toString(), e);
|
||
|
|
}
|
||
|
|
return AjaxResult.success(map);
|
||
|
|
}
|
||
|
|
/**
|
||
|
|
* 工程数量
|
||
|
|
* proType 01 变电 03 线路 04 全部
|
||
|
|
* @param orgId
|
||
|
|
* @return
|
||
|
|
*/
|
||
|
|
@PostMapping(value = "getProStatisNum")
|
||
|
|
public AjaxResult getProStatisNum(String proType, String orgId) {
|
||
|
|
try {
|
||
|
|
Map<String, Object> map = service.getProStatisNum(proType);
|
||
|
|
return AjaxResult.success("获取成功", map);
|
||
|
|
} catch (Exception e) {
|
||
|
|
log.error(e.toString(), e);
|
||
|
|
return AjaxResult.error("服务异常,请稍后重试");
|
||
|
|
}
|
||
|
|
}
|
||
|
|
/**
|
||
|
|
* 工程地图数量标注
|
||
|
|
* @param vo
|
||
|
|
* @param
|
||
|
|
* @return
|
||
|
|
*/
|
||
|
|
@PostMapping(value = "getMapProNum")
|
||
|
|
public AjaxResult getMapProNum(MapStatisVo vo) {
|
||
|
|
try {
|
||
|
|
List<MapStatisVo> list= service.getMapProNum(vo);
|
||
|
|
return AjaxResult.success("获取工程地图数量成功",list);
|
||
|
|
} catch (Exception e) {
|
||
|
|
log.error(e.toString(), e);
|
||
|
|
return AjaxResult.error("服务异常,请稍后重试");
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 获取工程列表数据
|
||
|
|
* @param proData
|
||
|
|
* @return
|
||
|
|
*/
|
||
|
|
@PostMapping(value = "getProListByType")
|
||
|
|
public Map<String, Object> getProListByType(ProData proData) {
|
||
|
|
Map<String, Object> map = new HashMap<String, Object>(16);
|
||
|
|
try {
|
||
|
|
PageHelper.startPage(Integer.parseInt(proData.getPage()), Integer.parseInt(proData.getLimit()));
|
||
|
|
PageInfo<ProData> pageInfo = service.getProListByType(proData);
|
||
|
|
map.put("code", 200);
|
||
|
|
map.put("msg", "获取数据成功");
|
||
|
|
map.put("count", pageInfo.getTotal());
|
||
|
|
map.put("curr", Integer.parseInt(proData.getPage()));
|
||
|
|
map.put("limit", Integer.parseInt(proData.getLimit()));
|
||
|
|
map.put("data", pageInfo.getList());
|
||
|
|
} catch (Exception e) {
|
||
|
|
log.error(e.toString(),e);
|
||
|
|
map.put("code", 500);
|
||
|
|
map.put("msg", "服务异常请稍后重试");
|
||
|
|
map.put("count", 0);
|
||
|
|
map.put("curr", Integer.parseInt(proData.getPage()));
|
||
|
|
map.put("limit", Integer.parseInt(proData.getLimit()));
|
||
|
|
map.put("data", null);
|
||
|
|
}
|
||
|
|
return map;
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 工程计划统计
|
||
|
|
*/
|
||
|
|
@PostMapping(value = "getProPlanStatis")
|
||
|
|
public AjaxResult getProPlanStatis(MapStatisVo vo) {
|
||
|
|
try {
|
||
|
|
Map<String,Object> map= service.getProPlanStatis(vo);
|
||
|
|
return AjaxResult.success("获取工程计划统计",map);
|
||
|
|
} catch (Exception e) {
|
||
|
|
log.error(e.toString(), e);
|
||
|
|
return AjaxResult.error("服务异常,请稍后重试");
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 工程造价统计
|
||
|
|
*/
|
||
|
|
@PostMapping(value = "getProZj")
|
||
|
|
public AjaxResult getProZj(MapStatisVo vo) {
|
||
|
|
try {
|
||
|
|
Map<String,Object> map= service.getProZj(vo);
|
||
|
|
return AjaxResult.success("获取工程造价",map);
|
||
|
|
} catch (Exception e) {
|
||
|
|
log.error(e.toString(), e);
|
||
|
|
return AjaxResult.error("服务异常,请稍后重试");
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 获取工程列表数据
|
||
|
|
* @param proPlanVo
|
||
|
|
* @return
|
||
|
|
*/
|
||
|
|
@PostMapping(value = "getProPlanList")
|
||
|
|
public Map<String, Object> getProPlanList(ProPlanVo proPlanVo) {
|
||
|
|
Map<String, Object> map = new HashMap<String, Object>(16);
|
||
|
|
Map<String, Object> map2 = new HashMap<String, Object>(16);
|
||
|
|
try {
|
||
|
|
PageHelper.startPage(Integer.parseInt(proPlanVo.getPage()), Integer.parseInt(proPlanVo.getLimit()));
|
||
|
|
PageInfo<ProPlanVo> pageInfo = service.getProPlanList(proPlanVo);
|
||
|
|
Map<String, Object> map1=service.getProPlanListTj(proPlanVo);
|
||
|
|
map.put("code", 200);
|
||
|
|
map.put("msg", "获取数据成功");
|
||
|
|
map.put("count", pageInfo.getTotal());
|
||
|
|
map.put("curr", Integer.parseInt(proPlanVo.getPage()));
|
||
|
|
map.put("limit", Integer.parseInt(proPlanVo.getLimit()));
|
||
|
|
map.put("data", pageInfo.getList());
|
||
|
|
map.put("tj",map1.get("map"));
|
||
|
|
map2.put("prjName","项目总数:"+map1.get("prjName"));
|
||
|
|
map2.put("subCap","变电总容量:"+map1.get("subCap"));
|
||
|
|
map2.put("lineLength","线路总长度:"+map1.get("lineLength"));
|
||
|
|
map.put("totalRow",map2);
|
||
|
|
} catch (Exception e) {
|
||
|
|
log.error(e.toString(),e);
|
||
|
|
map.put("code", 500);
|
||
|
|
map.put("msg", "服务异常请稍后重试");
|
||
|
|
map.put("count", 0);
|
||
|
|
map.put("curr", Integer.parseInt(proPlanVo.getPage()));
|
||
|
|
map.put("limit", Integer.parseInt(proPlanVo.getLimit()));
|
||
|
|
map.put("data", null);
|
||
|
|
}
|
||
|
|
return map;
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 获取工程造价数据
|
||
|
|
* @param proPlanVo
|
||
|
|
* @return
|
||
|
|
*/
|
||
|
|
@PostMapping(value = "getProZjList")
|
||
|
|
public Map<String, Object> getProZjList(ProPlanVo proPlanVo) {
|
||
|
|
Map<String, Object> map = new HashMap<String, Object>(16);
|
||
|
|
try {
|
||
|
|
PageHelper.startPage(Integer.parseInt(proPlanVo.getPage()), Integer.parseInt(proPlanVo.getLimit()));
|
||
|
|
PageInfo<ProPlanVo> pageInfo = service.getProZjList(proPlanVo);
|
||
|
|
map.put("code", 200);
|
||
|
|
map.put("msg", "获取数据成功");
|
||
|
|
map.put("count", pageInfo.getTotal());
|
||
|
|
map.put("curr", Integer.parseInt(proPlanVo.getPage()));
|
||
|
|
map.put("limit", Integer.parseInt(proPlanVo.getLimit()));
|
||
|
|
map.put("data", pageInfo.getList());
|
||
|
|
} catch (Exception e) {
|
||
|
|
log.error(e.toString(),e);
|
||
|
|
map.put("code", 500);
|
||
|
|
map.put("msg", "服务异常请稍后重试");
|
||
|
|
map.put("count", 0);
|
||
|
|
map.put("curr", Integer.parseInt(proPlanVo.getPage()));
|
||
|
|
map.put("limit", Integer.parseInt(proPlanVo.getLimit()));
|
||
|
|
map.put("data", null);
|
||
|
|
}
|
||
|
|
return map;
|
||
|
|
}
|
||
|
|
|
||
|
|
@ApiOperation("模板下载")
|
||
|
|
@GetMapping("/downloadExcel")
|
||
|
|
public void downloadExcel(HttpServletRequest request, HttpServletResponse response) {
|
||
|
|
InputStream inputStream = null;
|
||
|
|
ServletOutputStream servletOutputStream = null;
|
||
|
|
try {
|
||
|
|
String path = "download/" + "aqzlsj.xlsx";
|
||
|
|
inputStream = this.getClass().getClassLoader().getResourceAsStream(path);
|
||
|
|
response.setContentType("application/vnd.ms-excel");
|
||
|
|
response.addHeader("Cache-Control", "no-cache, no-store, must-revalidate");
|
||
|
|
response.addHeader("charset", "utf-8");
|
||
|
|
response.addHeader("Pragma", "no-cache");
|
||
|
|
String encodeName = URLEncoder.encode("安徽公司-输变电工程设计质量问题及管理情况表.xlsx", StandardCharsets.UTF_8.toString());
|
||
|
|
response.setHeader("Content-Disposition", "attachment; filename=\"" + encodeName + "\"; filename*=utf-8''" + encodeName);
|
||
|
|
servletOutputStream = response.getOutputStream();
|
||
|
|
IOUtils.copy(inputStream, servletOutputStream);
|
||
|
|
response.flushBuffer();
|
||
|
|
//log.info("文件下载成功!!");
|
||
|
|
} catch (Exception e) {
|
||
|
|
e.printStackTrace();
|
||
|
|
} finally {
|
||
|
|
try {
|
||
|
|
if (servletOutputStream != null) {
|
||
|
|
servletOutputStream.close();
|
||
|
|
}
|
||
|
|
if (inputStream != null) {
|
||
|
|
inputStream.close();
|
||
|
|
}
|
||
|
|
} catch (Exception e) {
|
||
|
|
e.printStackTrace();
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
@PostMapping("/importExcel")
|
||
|
|
public AjaxResult importExcel(MultipartFile file, HttpServletRequest request, HttpServletResponse response) throws IOException {
|
||
|
|
try {
|
||
|
|
CommonsMultipartResolver multipartResolver = new CommonsMultipartResolver();
|
||
|
|
MultipartHttpServletRequest multiReq = multipartResolver.resolveMultipart(request);
|
||
|
|
// 违章类型id
|
||
|
|
List<JSONObject> lstObj = ImportExcelUtils.readExcel(file, TyDeviceController.class, null);
|
||
|
|
List<SjNumberVo> list = new ArrayList<>();
|
||
|
|
if (lstObj != null && lstObj.size() > 0) {
|
||
|
|
for (JSONObject obj : lstObj) {
|
||
|
|
SjNumberVo vo=new SjNumberVo();
|
||
|
|
vo.setOrg(obj.getString("org"));
|
||
|
|
vo.setProName(obj.getString("proName"));
|
||
|
|
vo.setSignName(obj.getString("signName"));
|
||
|
|
vo.setVoltage(obj.getString("voltage"));
|
||
|
|
vo.setProType(obj.getString("proType"));
|
||
|
|
vo.setSjUnit(obj.getString("sjUnit"));
|
||
|
|
vo.setPsUnit(obj.getString("psUnit"));
|
||
|
|
vo.setPsYjTime(obj.getString("psYjTime"));
|
||
|
|
vo.setIsSjzlQ(obj.getString("isSjzlQ"));
|
||
|
|
vo.setIsQ(obj.getString("isQ"));
|
||
|
|
vo.setSjzlQName(obj.getString("sjzlQName"));
|
||
|
|
vo.setWtkNum(obj.getString("wtkNum"));
|
||
|
|
vo.setWtType(obj.getString("wtType"));
|
||
|
|
vo.setWtXz(obj.getString("wtXz"));
|
||
|
|
vo.setSjjd(obj.getString("sjjd"));
|
||
|
|
vo.setSszy(obj.getString("sszy"));
|
||
|
|
vo.setSfzg(obj.getString("sfzg"));
|
||
|
|
vo.setWtjs(obj.getString("wtjs"));
|
||
|
|
vo.setWtfx(obj.getString("wtfx"));
|
||
|
|
vo.setJycqcs(obj.getString("jycqcs"));
|
||
|
|
vo.setDelFag("0");
|
||
|
|
vo.setCreateTime(DateTimeHelper.getNowTime());
|
||
|
|
vo.setUpdateTime(DateTimeHelper.getNowTime());
|
||
|
|
list.add(vo);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
service.addImportJsNumData(list);
|
||
|
|
} catch (Exception e) {
|
||
|
|
AjaxResult.error("error");
|
||
|
|
log.error(e.toString(), e);
|
||
|
|
}
|
||
|
|
return AjaxResult.success("success");
|
||
|
|
}
|
||
|
|
|
||
|
|
@PostMapping("insertSjNum")
|
||
|
|
public ReturnCodeEntity insertSjNum(SjNumberVo vo) {
|
||
|
|
ReturnCodeEntity entity = new ReturnCodeEntity();
|
||
|
|
try {
|
||
|
|
vo.setDelFag("0");
|
||
|
|
vo.setUpdateTime(DateTimeHelper.getNowTime());
|
||
|
|
if(StringHelper.isEmpty(vo.getId())) {
|
||
|
|
vo.setCreateTime(DateTimeHelper.getNowTime());
|
||
|
|
List<SjNumberVo> list = new ArrayList<>();
|
||
|
|
list.add(vo);
|
||
|
|
service.addImportJsNumData(list);
|
||
|
|
entity.setMsg("添加成功");
|
||
|
|
entity.setCode("200");
|
||
|
|
}else{
|
||
|
|
int num= service.updateSjNum(vo);
|
||
|
|
entity.setCode("200");
|
||
|
|
if(num==1 ){
|
||
|
|
entity.setMsg("修改成功");
|
||
|
|
}else{
|
||
|
|
entity.setCode("500");
|
||
|
|
entity.setMsg("修改失败");
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
} catch (Exception e) {
|
||
|
|
log.error(e.toString(),e);
|
||
|
|
entity.setCode("500");
|
||
|
|
entity.setMsg("操作异常,请联系管理员");
|
||
|
|
}
|
||
|
|
return entity;
|
||
|
|
}
|
||
|
|
@PostMapping("deleteSjNum")
|
||
|
|
public ReturnCodeEntity deleteSjNum(String id) {
|
||
|
|
ReturnCodeEntity entity = new ReturnCodeEntity();
|
||
|
|
try {
|
||
|
|
if(StringHelper.isNotEmpty(id)){
|
||
|
|
List<String> list= Arrays.asList(id.split("@"));
|
||
|
|
service.deleteSjNum(list);
|
||
|
|
entity.setMsg("删除成功");
|
||
|
|
}
|
||
|
|
entity.setCode("200");
|
||
|
|
|
||
|
|
} catch (Exception e) {
|
||
|
|
log.error(e.toString(),e);
|
||
|
|
entity.setCode("500");
|
||
|
|
entity.setMsg("删除失败,请联系管理员");
|
||
|
|
}
|
||
|
|
return entity;
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 获取工程列表数据
|
||
|
|
* @param vo
|
||
|
|
* @return
|
||
|
|
*/
|
||
|
|
@PostMapping(value = "getSjNumList")
|
||
|
|
public Map<String, Object> getSjNumList(SjNumberVo vo) {
|
||
|
|
Map<String, Object> map = new HashMap<String, Object>(16);
|
||
|
|
try {
|
||
|
|
PageHelper.startPage(Integer.parseInt(vo.getPage()), Integer.parseInt(vo.getLimit()));
|
||
|
|
PageInfo<SjNumberVo> pageInfo = service.getSjNumList(vo);
|
||
|
|
map.put("code", 200);
|
||
|
|
map.put("msg", "获取数据成功");
|
||
|
|
map.put("count", pageInfo.getTotal());
|
||
|
|
map.put("curr", Integer.parseInt(vo.getPage()));
|
||
|
|
map.put("limit", Integer.parseInt(vo.getLimit()));
|
||
|
|
map.put("data", pageInfo.getList());
|
||
|
|
} catch (Exception e) {
|
||
|
|
log.error(e.toString(),e);
|
||
|
|
map.put("code", 500);
|
||
|
|
map.put("msg", "服务异常请稍后重试");
|
||
|
|
map.put("count", 0);
|
||
|
|
map.put("curr", Integer.parseInt(vo.getPage()));
|
||
|
|
map.put("limit", Integer.parseInt(vo.getLimit()));
|
||
|
|
map.put("data", null);
|
||
|
|
}
|
||
|
|
return map;
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 查看详情
|
||
|
|
*
|
||
|
|
* @param
|
||
|
|
* @return
|
||
|
|
*/
|
||
|
|
@PostMapping("getSjNumDetail")
|
||
|
|
public AjaxResult getSjNumDetail(String keyId) {
|
||
|
|
SjNumberVo vo = null;
|
||
|
|
try {
|
||
|
|
vo = service.getSjNumDetail(keyId);
|
||
|
|
System.err.println(vo);
|
||
|
|
return AjaxResult.success("success",vo);
|
||
|
|
} catch (Exception e) {
|
||
|
|
log.error(e.toString(),e);
|
||
|
|
return AjaxResult.error("服务异常,请稍后重试");
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|