ly преди 2 години
родител
ревизия
824ed6a48c

+ 20 - 14
master/src/main/java/com/ruoyi/project/base/controller/TBasePointController.java

@@ -8,12 +8,14 @@ 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.StringUtils;
 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.ITBasePointService;
 import com.ruoyi.system.service.ISysDictTypeService;
 import org.apache.poi.ss.usermodel.Cell;
@@ -22,6 +24,7 @@ import org.apache.poi.ss.usermodel.Sheet;
 import org.apache.poi.ss.usermodel.Workbook;
 import org.mybatis.spring.MyBatisSystemException;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.dao.DuplicateKeyException;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.multipart.MultipartFile;
@@ -50,6 +53,8 @@ import java.util.concurrent.atomic.AtomicInteger;
 public class TBasePointController extends BaseController {
     @Autowired
     private ITBasePointService tBasePointService;
+    @Resource
+    private TBasePointMapper tBasePointMapper;
 
     @Autowired
     private ISysDictTypeService isysDictTypeService;
@@ -156,8 +161,8 @@ public class TBasePointController extends BaseController {
             return AjaxResult.success();
         }
         List<Long> ids = new ArrayList<>();
-        for (TBasePoint t: list
-             ) {
+        for (TBasePoint t : list
+        ) {
             ids.add(t.getPointId());
         }
         TBasePoint point = new TBasePoint();
@@ -171,7 +176,7 @@ public class TBasePointController extends BaseController {
     @PutMapping("/handleUpload")
     public AjaxResult handleUpload(@RequestBody TBasePoint tBasePoint) {
         tBasePoint.setUpdaterCode(getUserId());
-        if ((tBasePointService.updateTBasePointByUploadFile(tBasePoint)>0))
+        if ((tBasePointService.updateTBasePointByUploadFile(tBasePoint) > 0))
             return AjaxResult.success();
         else
             return AjaxResult.error("未找到对应名称的PID图号/组件照片号");
@@ -311,6 +316,11 @@ public class TBasePointController extends BaseController {
                             entity.setRemarks(cellValue);
                         }
                     }
+                    if (StringUtils.isEmpty(entity.getPointType())) {
+                        logger.info("缺少必填项");
+                        failRow.add(finalI + 1);
+                        throw new InterruptedException(); //中止线程
+                    }
                     entity.setCreaterCode(userId);
                     entity.setApproveStatus(0L);
                     TBaseDevice device = tBaseDeviceMapper.selectTBaseDeviceByCode(entity);
@@ -324,20 +334,16 @@ public class TBasePointController extends BaseController {
                         entity.setRegionId(device.getRegionId());
                         logger.info("entity:" + entity);
                         //进行数据更新
-                        TBasePoint tBasePoint = tBasePointService.selectTBasePointByGroupCodeAndExtendCode(entity);
-                        if (tBasePoint == null) {
-                            entity.setUpdatedate(new Date());
-                            entity.setUpdaterCode(userId);
-                            tBasePointService.insertTBasePoint(entity);
-                            successNumber.getAndIncrement();
-                        } else {
-                            logger.info("重复数据");
-                            failRow.add(finalI + 1);
-                            throw new InterruptedException();//中止线程
-                        }
+                        entity.setUpdatedate(new Date());
+                        entity.setUpdaterCode(userId);
+                        tBasePointMapper.insertTBasePoint(entity);
+                        successNumber.getAndIncrement();
                     }
                 } catch (InterruptedException e) {
                     logger.info("中止线程" + Thread.currentThread().getName());
+                } catch (DuplicateKeyException e) {
+                    logger.info("重复数据");
+                    failRow.add(finalI + 1);
                 } catch (Exception e) {
                     failRow.add(finalI + 1);
                     e.printStackTrace();

+ 11 - 4
master/src/main/java/com/ruoyi/project/check/controller/TCheckCheckpointsController.java

@@ -168,6 +168,7 @@ public class TCheckCheckpointsController extends BaseController {
         //线程池
         ExecutorService executorService = Executors.newFixedThreadPool(50);
         final CountDownLatch latch = new CountDownLatch(rowNum - 1); //相同线程数量的计数
+        List<TCheckEnvironment> tCheckEnvironments = tCheckEnvironmentMapper.selectTCheckEnvironmentListByYear();
 
         List<TCheckLawitems> tCheckLawitems = tCheckLawitemsService.selectTCheckLawitemsByLawStatus();
         AtomicInteger successNumber = new AtomicInteger();
@@ -219,16 +220,22 @@ public class TCheckCheckpointsController extends BaseController {
                     environment.setPlantName(entity.getPlantName());
                     environment.setInstrumentCode(entity.getInstrumentCode());
                     environment.setTestTime(entity.getCheckDate());
-                    List<TCheckEnvironment> tCheckEnvironments = tCheckEnvironmentMapper.selectTCheckEnvironmentList(environment);
-                    if (CollectionUtils.isEmpty(tCheckEnvironments)) {
+//                    List<TCheckEnvironment> tCheckEnvironments = tCheckEnvironmentMapper.selectTCheckEnvironmentList(environment);
+                    TCheckEnvironment tCheckEnvironment = new TCheckEnvironment();
+                    for (TCheckEnvironment t : tCheckEnvironments
+                    ) {
+                        if (t.getTestTime().compareTo(entity.getCheckDate())==0 && t.getInstrumentCode().equals(entity.getInstrumentCode()) && t.getPlantName().equals(entity.getPlantName())) {
+                            tCheckEnvironment = t;
+                            break;
+                        }
+                    }
+                    if (tCheckEnvironment.getId() == null) {
                         logger.info("环境本底值数据不存在");
                         failRow.add(finalI + 1);
                         throw new InterruptedException();//中止线程
                     } else {
-                        TCheckEnvironment tCheckEnvironment = null;
                         String netTest;
                         try {
-                            tCheckEnvironment = tCheckEnvironments.get(0);
                             BigDecimal back = new BigDecimal(tCheckEnvironment.getBackgroundValue());// 当天的环境本底值
                             BigDecimal test = new BigDecimal(entity.getTestValue());// 当天检测值
                             // 计算净检测值

+ 10 - 8
master/src/main/java/com/ruoyi/project/check/mapper/TCheckEnvironmentMapper.java

@@ -5,15 +5,15 @@ import com.ruoyi.project.check.domain.TCheckEnvironment;
 
 /**
  * 环境本底值记录Mapper接口
- * 
+ *
  * @author ruoyi
  * @date 2022-11-24
  */
-public interface TCheckEnvironmentMapper 
+public interface TCheckEnvironmentMapper
 {
     /**
      * 查询环境本底值记录
-     * 
+     *
      * @param id 环境本底值记录主键
      * @return 环境本底值记录
      */
@@ -21,7 +21,7 @@ public interface TCheckEnvironmentMapper
 
     /**
      * 查询环境本底值记录列表
-     * 
+     *
      * @param tCheckEnvironment 环境本底值记录
      * @return 环境本底值记录集合
      */
@@ -29,7 +29,7 @@ public interface TCheckEnvironmentMapper
 
     /**
      * 新增环境本底值记录
-     * 
+     *
      * @param tCheckEnvironment 环境本底值记录
      * @return 结果
      */
@@ -37,7 +37,7 @@ public interface TCheckEnvironmentMapper
 
     /**
      * 修改环境本底值记录
-     * 
+     *
      * @param tCheckEnvironment 环境本底值记录
      * @return 结果
      */
@@ -45,7 +45,7 @@ public interface TCheckEnvironmentMapper
 
     /**
      * 删除环境本底值记录
-     * 
+     *
      * @param id 环境本底值记录主键
      * @return 结果
      */
@@ -53,9 +53,11 @@ public interface TCheckEnvironmentMapper
 
     /**
      * 批量删除环境本底值记录
-     * 
+     *
      * @param ids 需要删除的数据主键集合
      * @return 结果
      */
     public int deleteTCheckEnvironmentByIds(Long[] ids);
+
+    List<TCheckEnvironment> selectTCheckEnvironmentListByYear();
 }

+ 2 - 2
master/src/main/resources/mybatis/check/TCheckCheckpointsMapper.xml

@@ -126,10 +126,10 @@
     <select id="selectTCheckCheckpointByEntity" parameterType="TCheckCheckpoints" resultMap="TCheckCheckpointsResult">
         select d.plant_type,d.point_type,d.medium_type from t_check_checkpoints d
         <where>
-            <if test="plantId != null  and plantId != ''">and d.plant_id = #{plantId}</if>
+            <if test="plantName != null  and plantName != ''">and d.plant_name = #{plantName}</if>
             <if test="groupCode != null  and groupCode != ''">and d.group_code = #{groupCode}</if>
             <if test="extendCode != null  and extendCode != ''">and d.extend_code = #{extendCode}</if>
-            and d.del_flag = 0
+            <if test="inspectionId != null  and inspectionId != ''">and d.inspection_id = #{inspectionId}</if>
         </where>
     </select>
 

+ 10 - 0
master/src/main/resources/mybatis/check/TCheckEnvironmentMapper.xml

@@ -64,6 +64,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         </where>
     </select>
 
+    <select id="selectTCheckEnvironmentListByYear" parameterType="TCheckEnvironment" resultMap="TCheckEnvironmentResult">
+        select d.*,su.user_name updater,bp.plant_code plantCode,bp.plant_name plantName,ci.model instrumentModel,ci.code instrumentCode from t_check_environment d
+        left join sys_user su on su.user_id=d.updater_code
+        left join t_base_plant bp on bp.plant_id =d.plant_id
+        left join t_check_instrument ci on ci.id=d.instrument_id
+        where d.updatedate > subdate(now(),interval 365 day) and d.del_flag = 0
+        order by d.id desc
+    </select>
+
+
     <select id="selectTCheckEnvironmentById" parameterType="Long" resultMap="TCheckEnvironmentResult">
         <include refid="selectTCheckEnvironmentVo"/>
         where id = #{id}