From f682213b9ff8a7d41ea16edfb1b68d996c46e080 Mon Sep 17 00:00:00 2001
From: zhuo <2089219845@qq.com>
Date: 星期六, 29 三月 2025 14:03:36 +0800
Subject: [PATCH] 1.清除无用方法 2.检测项目预警修改 3.数采绑定调整

---
 inspect-server/src/main/java/com/ruoyi/inspect/service/impl/InsOrderServiceImpl.java |  147 ++++++++++++------------------------------------
 1 files changed, 37 insertions(+), 110 deletions(-)

diff --git a/inspect-server/src/main/java/com/ruoyi/inspect/service/impl/InsOrderServiceImpl.java b/inspect-server/src/main/java/com/ruoyi/inspect/service/impl/InsOrderServiceImpl.java
index ae86eed..e830686 100644
--- a/inspect-server/src/main/java/com/ruoyi/inspect/service/impl/InsOrderServiceImpl.java
+++ b/inspect-server/src/main/java/com/ruoyi/inspect/service/impl/InsOrderServiceImpl.java
@@ -10,14 +10,11 @@
 import com.alibaba.excel.ExcelWriter;
 import com.alibaba.excel.write.metadata.WriteSheet;
 import com.alibaba.excel.write.style.column.LongestMatchColumnWidthStyleStrategy;
-import com.alibaba.excel.write.style.column.SimpleColumnWidthStyleStrategy;
 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.CollectionUtils;
 import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
-import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.ruoyi.basic.mapper.IfsInventoryQuantityMapper;
 import com.ruoyi.basic.mapper.StandardProductListMapper;
@@ -28,6 +25,7 @@
 import com.ruoyi.common.core.domain.entity.User;
 import com.ruoyi.common.numgen.NumberGenerator;
 import com.ruoyi.common.utils.*;
+import com.ruoyi.common.utils.api.IfsApiUtils;
 import com.ruoyi.framework.exception.ErrorException;
 import com.ruoyi.inspect.dto.*;
 import com.ruoyi.inspect.mapper.*;
@@ -37,11 +35,8 @@
 import com.ruoyi.inspect.service.InsProductService;
 import com.ruoyi.inspect.service.InsSampleService;
 import com.ruoyi.inspect.vo.InsOrderPrintingVo;
-import com.ruoyi.inspect.vo.SampleDefectsFatherVo;
-import com.ruoyi.performance.pojo.AuxiliaryOutputWorkingHours;
 import com.ruoyi.performance.pojo.AuxiliaryOutputWorkingHoursTemporary;
 import com.ruoyi.performance.service.AuxiliaryOutputWorkingHoursTemporaryService;
-import com.ruoyi.system.mapper.CustomMapper;
 import com.ruoyi.system.mapper.UserMapper;
 import lombok.AllArgsConstructor;
 import org.apache.commons.lang3.StringUtils;
@@ -160,9 +155,21 @@
             spotCheckQuarterItemMapper.updateById(spotCheckQuarterItem);
         }
 
-
         // 鍒涘缓宸ユ椂鏆傚瓨
         // 缂撳瓨鏍峰搧id, 缂栧彿map
+//        addWorkingHoursTemporary(userId, insSamples, ids, order);
+
+        return 1;
+    }
+
+    /**
+     * 鍒涘缓宸ユ椂鏆傚瓨
+     * @param userId
+     * @param insSamples
+     * @param ids
+     * @param order
+     */
+    private void addWorkingHoursTemporary(Integer userId, List<InsSample> insSamples, List<Integer> ids, InsOrder order) {
         Map<Integer, String> sampleMap = insSamples.stream().collect(Collectors.toMap(InsSample::getId, InsSample::getSampleCode));
         List<InsProduct> insProductList = insProductMapper.selectList(Wrappers.<InsProduct>lambdaQuery()
                 .in(InsProduct::getInsSampleId, ids)
@@ -194,8 +201,6 @@
             return auxiliaryOutputWorkingHours;
         }).collect(Collectors.toList());
         auxiliaryOutputWorkingHoursTemporaryService.saveBatch(outputWorkingHours);
-
-        return 1;
     }
 
     public static String getWeek(String dayStr) {
@@ -442,6 +447,9 @@
                 if (StringUtils.isBlank(product.getAsk()) || StringUtils.isBlank(product.getTell())) {
                     throw new ErrorException("鏈夋楠岄」鐨勮姹傚�兼垨瑕佹眰鎻忚堪涓虹┖, 璇峰厛鍘绘爣鍑嗗簱閰嶇疆瑕佹眰鍊兼垨瑕佹眰鎻忚堪");
                 }
+                if (StringUtils.isBlank(product.getSonLaboratory())) {
+                    throw new ErrorException("鏈夋楠岄」鐨勭殑瀛愬疄楠屽涓虹粦瀹�, 璇峰厛缁戝畾瀛愬疄楠屽");
+                }
                 insProductMapper.insert(product);
             }
         }
@@ -557,112 +565,12 @@
         return productDto2IPage;
     }
 
-    @Override
-    public IPage<CostStatisticsDto> costStatistics(IPage<CostStatisticsDto> page, CostStatisticsDto costStatisticsDto) {
-        String dates = costStatisticsDto.getDates();
-        String[] split = dates.replaceAll("\\[", "").replaceAll("]", "").replaceAll("\"", "").split(",");
-        costStatisticsDto.setDates(null);
-
-        //todo:浠呯湅鑷繁
-
-        IPage<CostStatisticsDto> dtoIPage = insOrderMapper.selectCostStatistics(page, QueryWrappers.queryWrappers(costStatisticsDto).ge("create_time", split[0]).le("create_time", split[1] + " 23:59:59"));
-        List<CostStatisticsDto> collect = dtoIPage.getRecords().stream().map(dto -> {
-            Set<String> uniqueTags = new HashSet<>();
-            if (dto.getInspectionItem().contains(",")) {
-                for (String s : dto.getInspectionItem().split(",")) {
-                    uniqueTags.add(s.split("@")[0]);
-                }
-            } else {
-                uniqueTags.add(dto.getInspectionItem().split("@")[0]);
-            }
-            dto.setInspectionItem(uniqueTags.toString());
-            return dto;
-        }).collect(Collectors.toList());
-        dtoIPage.setRecords(collect);
-        return dtoIPage;
-    }
-
-    @Override
-    public Map<String, Object> costStatistics2(CostStatisticsDto costStatisticsDto) {
-        Map<String, Object> map = new HashMap<>();
-        String dates = costStatisticsDto.getDates();
-        String[] split = dates.replaceAll("\\[", "").replaceAll("]", "").replaceAll("\"", "").split(",");
-        costStatisticsDto.setDates(null);
-        List<CostStatisticsDto> costStatisticsDtos = insOrderMapper.selectCostStatistics2(QueryWrappers.queryWrappers(costStatisticsDto).ge("create_time", split[0]).le("create_time", split[1] + " 23:59:59"));
-        double totalPrice = costStatisticsDtos.stream()
-                .filter(dto -> dto.getPrice() != null) // 杩囨护鎺変环鏍间负 null 鐨勫璞�
-                .mapToDouble(value -> value.getPrice().doubleValue() * value.getNum())
-                .sum();
-        map.put("total", totalPrice);
-        return map;
-    }
-
-    @Override
-    public Map<String, Object> selectSampleDefects(Page page, String inspectionItems, String orderNumber) {
-        List<SampleDefectsFatherVo> sampleDefectsFatherVos = insOrderMapper.selectSampleDefects(page, inspectionItems, orderNumber);
-        Map<String, Object> map = new HashMap<>();
-        map.put("records", sampleDefectsFatherVos);
-        Long aLong = insOrderMapper.getCount(inspectionItems, orderNumber);
-        map.put("total", aLong);
-        return map;
-    }
 
     @Override
     public int updateStatus(Integer id) {
         return insOrderMapper.updateStatus(id);
     }
 
-
-    @Override
-    public void export(CostStatisticsDto costStatisticsDto, HttpServletResponse response) throws IOException {
-        //鏌ヨ瀵煎嚭鐨勮垂鐢ㄧ粺璁℃暟鎹�
-        String dates = costStatisticsDto.getDates();
-        String[] split = dates.replaceAll("\\[", "").replaceAll("]", "").replaceAll("\"", "").split(",");
-        costStatisticsDto.setDates(null);
-        List<CostStatisticsDto> costStatisticsDtos = insOrderMapper.selectCostStatistics2(QueryWrappers.queryWrappers(costStatisticsDto).ge("create_time", split[0]).le("create_time", split[1] + " 23:59:59"));
-        costStatisticsDtos = costStatisticsDtos.stream().map(dto -> {
-            Set<String> uniqueTags = new HashSet<>();
-            if (dto.getInspectionItem().contains(",")) {
-                for (String s : dto.getInspectionItem().split(",")) {
-                    uniqueTags.add(s.split("@")[0]);
-                }
-            } else {
-                uniqueTags.add(dto.getInspectionItem().split("@")[0]);
-            }
-            dto.setInspectionItem(uniqueTags.toString());
-            return dto;
-        }).collect(Collectors.toList());
-
-        response.setContentType("application/vnd.ms-excel");
-        response.setCharacterEncoding("UTF-8");
-        // 杩欓噷URLEncoder.encode鍙互闃叉涓枃涔辩爜 褰撶劧鍜宔asyexcel娌℃湁鍏崇郴
-        String fileName = URLEncoder.encode("鏍峰搧璐圭敤缁熻瀵煎嚭", "UTF-8");
-        response.setHeader("Content-disposition", "attachment;filename=" + fileName + ".xlsx");
-        Map<String, List<CostStatisticsDto>> groupByCompany =
-                costStatisticsDtos.stream().filter(e -> StrUtil.isNotEmpty(e.getCompany()))
-                        .collect(Collectors.groupingBy(CostStatisticsDto::getCompany));
-        try {
-            // 鏂板缓ExcelWriter
-            // 鏂板缓ExcelWriter
-            ExcelWriter excelWriter =
-                    EasyExcel.write(response.getOutputStream())
-                            .registerWriteHandler(new SimpleColumnWidthStyleStrategy(25))
-                            .build();
-            for (Map.Entry<String, List<CostStatisticsDto>> companyDataEntry : groupByCompany.entrySet()) {
-                String sheetName = companyDataEntry.getKey();
-                List<CostStatisticsDto> dataList = companyDataEntry.getValue();
-                WriteSheet mainSheet = EasyExcel.writerSheet(sheetName)
-                        .head(CostStatisticsDto.class)
-                        .registerWriteHandler(new SimpleColumnWidthStyleStrategy(25))
-                        .build();
-                excelWriter.write(dataList, mainSheet);
-            }
-            // 鍏抽棴娴�
-            excelWriter.finish();
-        } catch (IOException e) {
-            throw new RuntimeException("瀵煎嚭澶辫触");
-        }
-    }
 
     /**
      * 鑾峰彇ifs搴撳瓨淇℃伅
@@ -1034,7 +942,8 @@
         // 鏌ヨ鏍囧噯鏍�
         List<StandardProductList> standardProductLists = standardProductListMapper.selectList(Wrappers.<StandardProductList>lambdaQuery()
                 .eq(StandardProductList::getStandardMethodListId, insProduct.getStandardMethodListId())
-                .eq(StandardProductList::getTree, tree));
+                .eq(StandardProductList::getTree, tree)
+                .orderByAsc(StandardProductList::getSort));
         for (StandardProductList standardProductList : standardProductLists) {
             standardProductList.setId(null);
         }
@@ -1125,6 +1034,24 @@
         }
     }
 
+    /**
+     * 淇敼鏍峰搧鍨嬪彿
+     * @param insSample
+     */
+    @Override
+    public void updateSampleModel(InsSample insSample) {
+        // 鍒ゆ柇褰撳墠璁㈠崟鏄惁鐢熸垚浜嗘姤鍛�, 鐢熸垚浜嗘姤鍛婁笉鑳戒慨鏀瑰崟鍙�
+        Long count = insReportMapper.selectCount(Wrappers.<InsReport>lambdaQuery()
+                .eq(InsReport::getInsOrderId, insSample.getInsOrderId()));
+        if (count > 0 ) {
+            throw new ErrorException("褰撳墠璁㈠崟宸茬粡鐢熸垚浜嗘姤鍛婁笉鑳戒慨鏀圭紪鍙�");
+        }
+
+        insSampleService.update(Wrappers.<InsSample>lambdaUpdate()
+                .eq(InsSample::getId, insSample.getId())
+                .set(InsSample::getModel, insSample.getModel()));
+    }
+
 }
 
 

--
Gitblit v1.9.3