|
@@ -1,18 +1,30 @@
|
|
package com.ruoyi.project.base.controller;
|
|
package com.ruoyi.project.base.controller;
|
|
|
|
|
|
|
|
+import java.io.IOException;
|
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
|
+import java.util.ArrayList;
|
|
import java.util.Date;
|
|
import java.util.Date;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
import javax.servlet.http.HttpServletResponse;
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
+
|
|
|
|
+import com.alibaba.fastjson2.JSON;
|
|
|
|
+import com.ruoyi.common.core.domain.entity.SysDictData;
|
|
|
|
+import com.ruoyi.common.utils.StringUtils;
|
|
|
|
+import com.ruoyi.common.utils.file.ExcelUtils;
|
|
|
|
+import com.ruoyi.project.base.domain.TBaseDevice;
|
|
|
|
+import com.ruoyi.project.base.domain.TBasePlant;
|
|
|
|
+import com.ruoyi.project.base.domain.TBaseRegion;
|
|
|
|
+import com.ruoyi.project.base.service.ITBaseDeviceService;
|
|
|
|
+import com.ruoyi.project.base.service.ITBasePlantService;
|
|
|
|
+import com.ruoyi.project.base.service.ITBaseRegionService;
|
|
|
|
+import com.ruoyi.system.service.ISysDictTypeService;
|
|
|
|
+import org.apache.poi.ss.usermodel.Cell;
|
|
|
|
+import org.apache.poi.ss.usermodel.Row;
|
|
|
|
+import org.apache.poi.ss.usermodel.Sheet;
|
|
|
|
+import org.apache.poi.ss.usermodel.Workbook;
|
|
import org.springframework.security.access.prepost.PreAuthorize;
|
|
import org.springframework.security.access.prepost.PreAuthorize;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
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.PutMapping;
|
|
|
|
-import org.springframework.web.bind.annotation.DeleteMapping;
|
|
|
|
-import org.springframework.web.bind.annotation.PathVariable;
|
|
|
|
-import org.springframework.web.bind.annotation.RequestBody;
|
|
|
|
-import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
|
-import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
import com.ruoyi.common.annotation.Log;
|
|
import com.ruoyi.common.annotation.Log;
|
|
import com.ruoyi.common.core.controller.BaseController;
|
|
import com.ruoyi.common.core.controller.BaseController;
|
|
import com.ruoyi.common.core.domain.AjaxResult;
|
|
import com.ruoyi.common.core.domain.AjaxResult;
|
|
@@ -21,6 +33,7 @@ import com.ruoyi.project.base.domain.TBasePoint;
|
|
import com.ruoyi.project.base.service.ITBasePointService;
|
|
import com.ruoyi.project.base.service.ITBasePointService;
|
|
import com.ruoyi.common.utils.poi.ExcelUtil;
|
|
import com.ruoyi.common.utils.poi.ExcelUtil;
|
|
import com.ruoyi.common.core.page.TableDataInfo;
|
|
import com.ruoyi.common.core.page.TableDataInfo;
|
|
|
|
+import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
/**
|
|
/**
|
|
* 密封点Controller
|
|
* 密封点Controller
|
|
@@ -30,18 +43,29 @@ import com.ruoyi.common.core.page.TableDataInfo;
|
|
*/
|
|
*/
|
|
@RestController
|
|
@RestController
|
|
@RequestMapping("/base/point")
|
|
@RequestMapping("/base/point")
|
|
-public class TBasePointController extends BaseController
|
|
|
|
-{
|
|
|
|
|
|
+public class TBasePointController extends BaseController {
|
|
@Autowired
|
|
@Autowired
|
|
private ITBasePointService tBasePointService;
|
|
private ITBasePointService tBasePointService;
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
+ private ITBaseDeviceService tBaseDeviceService;
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ private ITBasePlantService tBasePlantService;
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ private ITBaseRegionService tBaseRegionService;
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ private ISysDictTypeService isysDictTypeService;
|
|
|
|
+
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 查询密封点列表
|
|
* 查询密封点列表
|
|
*/
|
|
*/
|
|
@PreAuthorize("@ss.hasPermi('base:point:list')")
|
|
@PreAuthorize("@ss.hasPermi('base:point:list')")
|
|
@GetMapping("/list")
|
|
@GetMapping("/list")
|
|
- public TableDataInfo list(TBasePoint tBasePoint)
|
|
|
|
- {
|
|
|
|
|
|
+ public TableDataInfo list(TBasePoint tBasePoint) {
|
|
startPage();
|
|
startPage();
|
|
List<TBasePoint> list = tBasePointService.selectTBasePointList(tBasePoint);
|
|
List<TBasePoint> list = tBasePointService.selectTBasePointList(tBasePoint);
|
|
return getDataTable(list);
|
|
return getDataTable(list);
|
|
@@ -53,8 +77,7 @@ public class TBasePointController extends BaseController
|
|
@PreAuthorize("@ss.hasPermi('base:point:export')")
|
|
@PreAuthorize("@ss.hasPermi('base:point:export')")
|
|
@Log(title = "密封点", businessType = BusinessType.EXPORT)
|
|
@Log(title = "密封点", businessType = BusinessType.EXPORT)
|
|
@PostMapping("/export")
|
|
@PostMapping("/export")
|
|
- public void export(HttpServletResponse response, TBasePoint tBasePoint)
|
|
|
|
- {
|
|
|
|
|
|
+ public void export(HttpServletResponse response, TBasePoint tBasePoint) {
|
|
List<TBasePoint> list = tBasePointService.selectTBasePointList(tBasePoint);
|
|
List<TBasePoint> list = tBasePointService.selectTBasePointList(tBasePoint);
|
|
ExcelUtil<TBasePoint> util = new ExcelUtil<TBasePoint>(TBasePoint.class);
|
|
ExcelUtil<TBasePoint> util = new ExcelUtil<TBasePoint>(TBasePoint.class);
|
|
util.exportExcel(response, list, "密封点数据");
|
|
util.exportExcel(response, list, "密封点数据");
|
|
@@ -65,8 +88,7 @@ public class TBasePointController extends BaseController
|
|
*/
|
|
*/
|
|
@PreAuthorize("@ss.hasPermi('base:point:query')")
|
|
@PreAuthorize("@ss.hasPermi('base:point:query')")
|
|
@GetMapping(value = "/{id}")
|
|
@GetMapping(value = "/{id}")
|
|
- public AjaxResult getInfo(@PathVariable("id") Long id)
|
|
|
|
- {
|
|
|
|
|
|
+ public AjaxResult getInfo(@PathVariable("id") Long id) {
|
|
return AjaxResult.success(tBasePointService.selectTBasePointById(id));
|
|
return AjaxResult.success(tBasePointService.selectTBasePointById(id));
|
|
}
|
|
}
|
|
|
|
|
|
@@ -76,11 +98,17 @@ public class TBasePointController extends BaseController
|
|
@PreAuthorize("@ss.hasPermi('base:point:add')")
|
|
@PreAuthorize("@ss.hasPermi('base:point:add')")
|
|
@Log(title = "密封点", businessType = BusinessType.INSERT)
|
|
@Log(title = "密封点", businessType = BusinessType.INSERT)
|
|
@PostMapping
|
|
@PostMapping
|
|
- public AjaxResult add(@RequestBody TBasePoint tBasePoint)
|
|
|
|
- {
|
|
|
|
- tBasePoint.setUpdatedate(new Date());
|
|
|
|
- tBasePoint.setUpdaterCode(getUserId());
|
|
|
|
|
|
+ public AjaxResult add(@RequestBody TBasePoint tBasePoint) {
|
|
|
|
+ TBasePoint point = tBasePointService.selectTBasePointByGroupCodeAndExtendCode(tBasePoint);
|
|
|
|
+ if (point == null) {
|
|
|
|
+ tBasePoint.setUpdatedate(new Date());
|
|
|
|
+ tBasePoint.setUpdaterCode(getUserId());
|
|
|
|
+ tBasePoint.setCreaterCode(getUserId());
|
|
return toAjax(tBasePointService.insertTBasePoint(tBasePoint));
|
|
return toAjax(tBasePointService.insertTBasePoint(tBasePoint));
|
|
|
|
+ }else{
|
|
|
|
+ return AjaxResult.error("当前数据已存在!");
|
|
|
|
+ }
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -89,11 +117,15 @@ public class TBasePointController extends BaseController
|
|
@PreAuthorize("@ss.hasPermi('base:point:edit')")
|
|
@PreAuthorize("@ss.hasPermi('base:point:edit')")
|
|
@Log(title = "密封点", businessType = BusinessType.UPDATE)
|
|
@Log(title = "密封点", businessType = BusinessType.UPDATE)
|
|
@PutMapping
|
|
@PutMapping
|
|
- public AjaxResult edit(@RequestBody TBasePoint tBasePoint)
|
|
|
|
- {
|
|
|
|
- tBasePoint.setUpdatedate(new Date());
|
|
|
|
- tBasePoint.setUpdaterCode(getUserId());
|
|
|
|
- return toAjax(tBasePointService.updateTBasePoint(tBasePoint));
|
|
|
|
|
|
+ public AjaxResult edit(@RequestBody TBasePoint tBasePoint) {
|
|
|
|
+ TBasePoint point = tBasePointService.selectTBasePointByGroupCodeAndExtendCode(tBasePoint);
|
|
|
|
+ if (point == null) {
|
|
|
|
+ tBasePoint.setUpdatedate(new Date());
|
|
|
|
+ tBasePoint.setUpdaterCode(getUserId());
|
|
|
|
+ return toAjax(tBasePointService.updateTBasePoint(tBasePoint));
|
|
|
|
+ }else{
|
|
|
|
+ return AjaxResult.error("当前数据已存在!");
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -101,9 +133,195 @@ public class TBasePointController extends BaseController
|
|
*/
|
|
*/
|
|
@PreAuthorize("@ss.hasPermi('base:point:remove')")
|
|
@PreAuthorize("@ss.hasPermi('base:point:remove')")
|
|
@Log(title = "密封点", businessType = BusinessType.DELETE)
|
|
@Log(title = "密封点", businessType = BusinessType.DELETE)
|
|
- @DeleteMapping("/{ids}")
|
|
|
|
- public AjaxResult remove(@PathVariable Long[] ids)
|
|
|
|
- {
|
|
|
|
|
|
+ @DeleteMapping("/{ids}")
|
|
|
|
+ public AjaxResult remove(@PathVariable Long[] ids) {
|
|
return toAjax(tBasePointService.deleteTBasePointByIds(ids));
|
|
return toAjax(tBasePointService.deleteTBasePointByIds(ids));
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ @Log(title = "受控设备台账导入", businessType = BusinessType.INSERT)
|
|
|
|
+ @PostMapping("/importData")
|
|
|
|
+ public AjaxResult importData(@RequestParam("file") MultipartFile file) throws IOException {
|
|
|
|
+ //获取操作人员ID
|
|
|
|
+ Long userId = getUserId();
|
|
|
|
+ //报错行数统计
|
|
|
|
+ List<Integer> failRow = new ArrayList<>();
|
|
|
|
+ Workbook workbook = ExcelUtils.getWorkBook(file);
|
|
|
|
+ Sheet sheet = workbook.getSheetAt(0);
|
|
|
|
+ List<TBasePoint> list = new ArrayList<>();
|
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
|
+ int rowNum = sheet.getPhysicalNumberOfRows();
|
|
|
|
+ int failNumber = 0;
|
|
|
|
+ for (int i = 1; i < rowNum; i++) {
|
|
|
|
+ try {
|
|
|
|
+ logger.info("读取行数:" + i);
|
|
|
|
+ Row row = sheet.getRow(i);
|
|
|
|
+ int cellNum = row.getLastCellNum();
|
|
|
|
+ TBasePoint entity = new TBasePoint();
|
|
|
|
+ Long plantId = 0L;
|
|
|
|
+ Long regionId = 0L;
|
|
|
|
+ String devCode = "";
|
|
|
|
+ String devName = "";
|
|
|
|
+ for (int j = 0; j < cellNum; j++) {
|
|
|
|
+ Cell cell = row.getCell(j);
|
|
|
|
+ if (cell == null) {
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ String cellValue = ExcelUtils.getCellValue(cell);
|
|
|
|
+ logger.info("cellValue:" + cellValue);
|
|
|
|
+ if (j == 0) {
|
|
|
|
+ //装置名称
|
|
|
|
+ TBasePlant tBasePlant = tBasePlantService.selectTBasePlantByName(cellValue);
|
|
|
|
+ if (tBasePlant == null) {
|
|
|
|
+ return AjaxResult.success("未找到对应装置!请检查装置无误后重新提交!", 0);
|
|
|
|
+ }
|
|
|
|
+ plantId = tBasePlant.getId();
|
|
|
|
+ entity.setPlantId(plantId);
|
|
|
|
+ } else if (j == 1 || j == 2) {
|
|
|
|
+ if (StringUtils.isEmpty(cellValue))
|
|
|
|
+ return AjaxResult.success("未找到对应装置!请检查装置名称无误后重新提交!", 0);
|
|
|
|
+ } else if (j == 3) {
|
|
|
|
+ // 区域名称
|
|
|
|
+ TBaseRegion tBaseRegion = tBaseRegionService.selectTBaseRegionByName(cellValue, plantId);
|
|
|
|
+ if (tBaseRegion == null) {
|
|
|
|
+ return AjaxResult.success("未找到对应区域!请检查装置与区域无误后重新提交!", 0);
|
|
|
|
+ }
|
|
|
|
+ regionId = tBaseRegion.getId();
|
|
|
|
+ entity.setRegionId(regionId);
|
|
|
|
+ } else if (j == 4) {
|
|
|
|
+ if (StringUtils.isEmpty(cellValue))
|
|
|
|
+ return AjaxResult.success("未找到对应区域!请检查装置与区域无误后重新提交!", 0);
|
|
|
|
+ } else if (j == 5) {
|
|
|
|
+ // 平台
|
|
|
|
+ entity.setLayer(cellValue);
|
|
|
|
+ } else if (j == 6) {
|
|
|
|
+ //PID
|
|
|
|
+ entity.setPidNo(cellValue);
|
|
|
|
+ } else if (j == 7) {
|
|
|
|
+ // 设备名称
|
|
|
|
+ devName = cellValue;
|
|
|
|
+ } else if (j == 8) {
|
|
|
|
+ // 设备编号
|
|
|
|
+ devCode = cellValue;
|
|
|
|
+ TBaseDevice tBaseDevice = new TBaseDevice();
|
|
|
|
+ tBaseDevice.setPlantId(plantId);
|
|
|
|
+ tBaseDevice.setRegionId(regionId);
|
|
|
|
+ tBaseDevice.setCode(devCode);
|
|
|
|
+ tBaseDevice.setDescribe(devName);
|
|
|
|
+ TBaseDevice device = tBaseDeviceService.selectDeviceByPlantRegionAndDevice(tBaseDevice);
|
|
|
|
+ if (device == null) {
|
|
|
|
+ return AjaxResult.success("未找到对应设备!请检查装置、区域、设备无误后重新提交!", 0);
|
|
|
|
+ }
|
|
|
|
+ entity.setDevId(device.getId());// 设备id
|
|
|
|
+ } else if (j == 9) {
|
|
|
|
+ // 群组位置
|
|
|
|
+ entity.setGroupPosition(cellValue);
|
|
|
|
+ } else if (j == 10) {
|
|
|
|
+ // 密封点位置
|
|
|
|
+ entity.setPointPosition(cellValue);
|
|
|
|
+ } else if (j == 11) {
|
|
|
|
+ // 群组编码
|
|
|
|
+ entity.setGroupCode(cellValue);
|
|
|
|
+ } else if (j == 12) {
|
|
|
|
+ // 密封点扩展号编码
|
|
|
|
+ entity.setExtendCode(cellValue);
|
|
|
|
+ } else if (j == 13) {
|
|
|
|
+ for (SysDictData dictData : isysDictTypeService.selectDictDataByType("point_type")) {
|
|
|
|
+ if (dictData.getDictLabel().equals(cellValue)) {
|
|
|
|
+ // 密封点类型
|
|
|
|
+ entity.setPointType(dictData.getDictValue());
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ } else if (j == 14) {
|
|
|
|
+ // 密封点子类型
|
|
|
|
+ entity.setSubPointType(cellValue);
|
|
|
|
+ } else if (j == 15) {
|
|
|
|
+ // 公称直径
|
|
|
|
+ entity.setDia(cellValue);
|
|
|
|
+ } else if (j == 16) {
|
|
|
|
+ // 是否不可达点
|
|
|
|
+ entity.setUnarrive(cellValue.equals("是")?"1":"0");
|
|
|
|
+ } else if (j == 17) {
|
|
|
|
+ // 不可达原因
|
|
|
|
+ entity.setUnarriveReason(cellValue);
|
|
|
|
+ } else if (j == 18) {
|
|
|
|
+ // 是否保温
|
|
|
|
+ entity.setKeepWarm(cellValue.equals("是")?"1":"0");
|
|
|
|
+ } else if (j == 19) {
|
|
|
|
+ // 介质
|
|
|
|
+ entity.setMedium(cellValue);
|
|
|
|
+ } else if (j == 20) {
|
|
|
|
+ for (SysDictData dictData : isysDictTypeService.selectDictDataByType("medium_type")) {
|
|
|
|
+ if (dictData.getDictLabel().equals(cellValue)) {
|
|
|
|
+ // 介质状态
|
|
|
|
+ entity.setMediumType(dictData.getDictValue());
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ } else if (j == 21) {
|
|
|
|
+ // toc分数
|
|
|
|
+ entity.setTocMark(cellValue);
|
|
|
|
+ } else if (j == 22) {
|
|
|
|
+ // 甲烷质量分数
|
|
|
|
+ entity.setMethaneMark(cellValue);
|
|
|
|
+ } else if (j == 23) {
|
|
|
|
+ // vocs分数
|
|
|
|
+ entity.setVocsMark(cellValue);
|
|
|
|
+ } else if (j == 24) {
|
|
|
|
+ // 工艺温度
|
|
|
|
+ entity.setTemperature(cellValue);
|
|
|
|
+ } else if (j == 25) {
|
|
|
|
+ // 工艺压力
|
|
|
|
+ entity.setPressure(cellValue);
|
|
|
|
+ } else if (j == 26) {
|
|
|
|
+ // pic图号
|
|
|
|
+ entity.setPicNo(cellValue);
|
|
|
|
+ } else if (j == 27) {
|
|
|
|
+ // 运行时间
|
|
|
|
+ entity.setRunTime(sdf.parse(cellValue));
|
|
|
|
+ } else if (j == 28) {
|
|
|
|
+ // 备注
|
|
|
|
+ entity.setRemarks(cellValue);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ entity.setCreaterCode(userId);
|
|
|
|
+ entity.setApproveStatus(0L);
|
|
|
|
+ logger.info("entity:" + entity);
|
|
|
|
+ list.add(entity);
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ failNumber++;
|
|
|
|
+ logger.info("e:" + JSON.toJSONString(e));
|
|
|
|
+ failRow.add(i + 1);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ int successNumber = 0;
|
|
|
|
+ int failNum = 0;
|
|
|
|
+ for (TBasePoint t : list
|
|
|
|
+ ) {
|
|
|
|
+ failNum++;
|
|
|
|
+ try {
|
|
|
|
+ //进行数据更新
|
|
|
|
+ TBasePoint tBasePoint = tBasePointService.selectTBasePointByGroupCodeAndExtendCode(t);
|
|
|
|
+ if (tBasePoint == null) {
|
|
|
|
+ t.setUpdatedate(new Date());
|
|
|
|
+ t.setUpdaterCode(getUserId());
|
|
|
|
+ tBasePointService.insertTBasePoint(t);
|
|
|
|
+ successNumber++;
|
|
|
|
+ }else {
|
|
|
|
+ failNumber++;
|
|
|
|
+ failRow.add(failNum + 1);
|
|
|
|
+ }
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ failNumber++;
|
|
|
|
+ logger.info("e:" + e);
|
|
|
|
+ failRow.add(failNum + 1);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ logger.info("list:" + JSON.toJSONString(list));
|
|
|
|
+ logger.info("successNumber:" + successNumber);
|
|
|
|
+ logger.info("failNumber:" + failNumber);
|
|
|
|
+ logger.info("failRow:" + failRow);
|
|
|
|
+ return AjaxResult.success(String.valueOf(successNumber), failRow);
|
|
|
|
+ }
|
|
}
|
|
}
|