|
@@ -1,47 +1,44 @@
|
|
|
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.List;
|
|
|
-import java.util.concurrent.CopyOnWriteArrayList;
|
|
|
-import java.util.concurrent.CountDownLatch;
|
|
|
-import java.util.concurrent.ExecutorService;
|
|
|
-import java.util.concurrent.Executors;
|
|
|
-import java.util.concurrent.atomic.AtomicInteger;
|
|
|
-import javax.annotation.Resource;
|
|
|
-import javax.servlet.http.HttpServletResponse;
|
|
|
-
|
|
|
import com.alibaba.fastjson2.JSON;
|
|
|
+import com.ruoyi.common.annotation.Log;
|
|
|
+import com.ruoyi.common.config.RuoYiConfig;
|
|
|
+import com.ruoyi.common.core.controller.BaseController;
|
|
|
+import com.ruoyi.common.core.domain.AjaxResult;
|
|
|
import com.ruoyi.common.core.domain.entity.SysDictData;
|
|
|
+import com.ruoyi.common.core.page.TableDataInfo;
|
|
|
+import com.ruoyi.common.enums.BusinessType;
|
|
|
import com.ruoyi.common.utils.file.ExcelUtils;
|
|
|
+import com.ruoyi.common.utils.file.FileUploadUtils;
|
|
|
+import com.ruoyi.common.utils.poi.ExcelUtil;
|
|
|
import com.ruoyi.project.base.domain.TBaseDevice;
|
|
|
+import com.ruoyi.project.base.domain.TBasePoint;
|
|
|
import com.ruoyi.project.base.mapper.TBaseDeviceMapper;
|
|
|
-import com.ruoyi.project.base.mapper.TBasePointMapper;
|
|
|
-import com.ruoyi.project.base.service.ITBaseDeviceService;
|
|
|
-import com.ruoyi.project.base.service.ITBasePlantService;
|
|
|
-import com.ruoyi.project.base.service.ITBaseRegionService;
|
|
|
+import com.ruoyi.project.base.service.ITBasePointService;
|
|
|
import com.ruoyi.system.service.ISysDictTypeService;
|
|
|
-import org.apache.ibatis.exceptions.TooManyResultsException;
|
|
|
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.mybatis.spring.MyBatisSystemException;
|
|
|
-import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
-import com.ruoyi.common.annotation.Log;
|
|
|
-import com.ruoyi.common.core.controller.BaseController;
|
|
|
-import com.ruoyi.common.core.domain.AjaxResult;
|
|
|
-import com.ruoyi.common.enums.BusinessType;
|
|
|
-import com.ruoyi.project.base.domain.TBasePoint;
|
|
|
-import com.ruoyi.project.base.service.ITBasePointService;
|
|
|
-import com.ruoyi.common.utils.poi.ExcelUtil;
|
|
|
-import com.ruoyi.common.core.page.TableDataInfo;
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
+import javax.annotation.Resource;
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
|
+import java.io.IOException;
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.Date;
|
|
|
+import java.util.List;
|
|
|
+import java.util.concurrent.CopyOnWriteArrayList;
|
|
|
+import java.util.concurrent.CountDownLatch;
|
|
|
+import java.util.concurrent.ExecutorService;
|
|
|
+import java.util.concurrent.Executors;
|
|
|
+import java.util.concurrent.atomic.AtomicInteger;
|
|
|
+
|
|
|
/**
|
|
|
* 密封点Controller
|
|
|
*
|
|
@@ -54,20 +51,9 @@ public class TBasePointController extends BaseController {
|
|
|
@Autowired
|
|
|
private ITBasePointService tBasePointService;
|
|
|
|
|
|
- @Autowired
|
|
|
- private ITBaseDeviceService tBaseDeviceService;
|
|
|
-
|
|
|
- @Autowired
|
|
|
- private ITBasePlantService tBasePlantService;
|
|
|
-
|
|
|
- @Autowired
|
|
|
- private ITBaseRegionService tBaseRegionService;
|
|
|
-
|
|
|
@Autowired
|
|
|
private ISysDictTypeService isysDictTypeService;
|
|
|
|
|
|
- @Resource
|
|
|
- private TBasePointMapper tBasePointMapper;
|
|
|
@Resource
|
|
|
private TBaseDeviceMapper tBaseDeviceMapper;
|
|
|
|
|
@@ -123,14 +109,14 @@ public class TBasePointController extends BaseController {
|
|
|
tBasePoint.setUpdatedate(new Date());
|
|
|
tBasePoint.setUpdaterCode(getUserId());
|
|
|
tBasePoint.setCreaterCode(getUserId());
|
|
|
- return toAjax(tBasePointService.insertTBasePoint(tBasePoint));
|
|
|
- }else{
|
|
|
- return AjaxResult.success("当前装置下的密封点已存在该群组编号和扩展编码!",0);
|
|
|
+ return toAjax(tBasePointService.insertTBasePoint(tBasePoint));
|
|
|
+ } else {
|
|
|
+ return AjaxResult.success("当前装置下的密封点已存在该群组编号和扩展编码!", 0);
|
|
|
}
|
|
|
} catch (MyBatisSystemException e) {
|
|
|
e.printStackTrace();
|
|
|
- return AjaxResult.success("当前装置下的密封点已存在该群组编号和扩展编码!",0);
|
|
|
- }catch (Exception e) {
|
|
|
+ return AjaxResult.success("当前装置下的密封点已存在该群组编号和扩展编码!", 0);
|
|
|
+ } catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
return AjaxResult.error();
|
|
|
}
|
|
@@ -149,15 +135,24 @@ public class TBasePointController extends BaseController {
|
|
|
tBasePoint.setUpdatedate(new Date());
|
|
|
tBasePoint.setUpdaterCode(getUserId());
|
|
|
return toAjax(tBasePointService.updateTBasePoint(tBasePoint));
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
return AjaxResult.error("当前数据已存在!");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@PutMapping("/handleApprove")
|
|
|
public AjaxResult handleApprove(@RequestBody TBasePoint tBasePoint) {
|
|
|
- tBasePoint.setApproveTime(new Date());
|
|
|
- return toAjax(tBasePointService.updateTBasePointByPointIds(tBasePoint));
|
|
|
+ tBasePoint.setApproveTime(new Date());
|
|
|
+ return toAjax(tBasePointService.updateTBasePointByPointIds(tBasePoint));
|
|
|
+ }
|
|
|
+
|
|
|
+ @PutMapping("/handleUpload")
|
|
|
+ public AjaxResult handleUpload(@RequestBody TBasePoint tBasePoint) {
|
|
|
+ tBasePoint.setUpdaterCode(getUserId());
|
|
|
+ if ((tBasePointService.updateTBasePointByUploadFile(tBasePoint)>0))
|
|
|
+ return AjaxResult.success();
|
|
|
+ else
|
|
|
+ return AjaxResult.error("未找到对应名称的PID图号/组件照片号");
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -187,7 +182,7 @@ public class TBasePointController extends BaseController {
|
|
|
int rowNum = sheet.getPhysicalNumberOfRows();
|
|
|
//线程池
|
|
|
ExecutorService executorService = Executors.newFixedThreadPool(30);
|
|
|
- final CountDownLatch latch = new CountDownLatch(rowNum -1); //相同线程数量的计数
|
|
|
+ final CountDownLatch latch = new CountDownLatch(rowNum - 1); //相同线程数量的计数
|
|
|
AtomicInteger failNumber = new AtomicInteger();
|
|
|
AtomicInteger successNumber = new AtomicInteger();
|
|
|
for (int i = 1; i < rowNum; i++) {
|
|
@@ -208,7 +203,7 @@ public class TBasePointController extends BaseController {
|
|
|
if (j == 0) {
|
|
|
//装置名称
|
|
|
entity.setPlantName(cellValue);
|
|
|
- } else if (j == 1 ) {
|
|
|
+ } else if (j == 1) {
|
|
|
entity.setPlantCode(cellValue);
|
|
|
} else if (j == 3) {
|
|
|
// 区域名称
|
|
@@ -303,7 +298,7 @@ public class TBasePointController extends BaseController {
|
|
|
logger.info("没有设备数据");
|
|
|
failRow.add(finalI + 1);
|
|
|
throw new InterruptedException(); //中止线程
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
entity.setDevId(device.getDevId());
|
|
|
entity.setPlantId(device.getPlantId());
|
|
|
entity.setRegionId(device.getRegionId());
|
|
@@ -315,15 +310,15 @@ public class TBasePointController extends BaseController {
|
|
|
entity.setUpdaterCode(userId);
|
|
|
tBasePointService.insertTBasePoint(entity);
|
|
|
successNumber.getAndIncrement();
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
logger.info("重复数据");
|
|
|
failRow.add(finalI + 1);
|
|
|
throw new InterruptedException();//中止线程
|
|
|
}
|
|
|
}
|
|
|
- }catch (InterruptedException e) {
|
|
|
- logger.info("中止线程"+ Thread.currentThread().getName());
|
|
|
- }catch (Exception e) {
|
|
|
+ } catch (InterruptedException e) {
|
|
|
+ logger.info("中止线程" + Thread.currentThread().getName());
|
|
|
+ } catch (Exception e) {
|
|
|
failRow.add(finalI + 1);
|
|
|
e.printStackTrace();
|
|
|
} finally {
|
|
@@ -344,4 +339,16 @@ public class TBasePointController extends BaseController {
|
|
|
logger.info("failRow:" + failRow);
|
|
|
return AjaxResult.success(String.valueOf(successNumber.get()), failRow);
|
|
|
}
|
|
|
+
|
|
|
+ @Log(title = "文件上传", businessType = BusinessType.UPDATE)
|
|
|
+ @PostMapping("/uploadFile")
|
|
|
+ public AjaxResult uploadFile(@RequestParam("file") MultipartFile file) throws IOException {
|
|
|
+ if (!file.isEmpty()) {
|
|
|
+ String avatar = FileUploadUtils.upload(RuoYiConfig.getFilePath("/point"), file);
|
|
|
+ return AjaxResult.success(avatar);
|
|
|
+ }
|
|
|
+ return AjaxResult.error("上传异常,请联系管理员");
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
}
|