lxp
2025-03-15 5a697e6fafbe3855336ca5fd7e1785de12840d16
inspect-server/src/main/java/com/ruoyi/inspect/service/impl/InsOrderPlanServiceImpl.java
ÎļþÃû´Ó cnas-require/src/main/java/com/ruoyi/require/service/impl/InsOrderPlanServiceImpl.java ÐÞ¸Ä
@@ -1,4 +1,4 @@
package com.ruoyi.require.service.impl;
package com.ruoyi.inspect.service.impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.lang.UUID;
@@ -37,37 +37,32 @@
import com.ruoyi.basic.mapper.StandardProductListMapper;
import com.ruoyi.basic.service.StandardTemplateService;
import com.ruoyi.basic.vo.StandardProductVO;
import com.ruoyi.common.constant.ExchangeConstants;
import com.ruoyi.common.constant.RouterKeyConstants;
import com.ruoyi.common.core.domain.entity.Custom;
import com.ruoyi.common.core.domain.entity.SysDictData;
import com.ruoyi.common.core.domain.entity.User;
import com.ruoyi.common.utils.DictUtils;
import com.ruoyi.common.utils.JackSonUtil;
import com.ruoyi.common.utils.QueryWrappers;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.framework.exception.ErrorException;
import com.ruoyi.framework.util.MatrixToImageWriter;
import com.ruoyi.framework.util.RedisUtil;
import com.ruoyi.framework.util.SheetWriteHandlerUtil;
import com.ruoyi.inspect.amqp.constants.ExchangeConstants;
import com.ruoyi.inspect.amqp.constants.RouterKeyConstants;
import com.ruoyi.inspect.dto.*;
import com.ruoyi.inspect.handler.*;
import com.ruoyi.inspect.mapper.*;
import com.ruoyi.inspect.pojo.*;
import com.ruoyi.inspect.service.InsBushingService;
import com.ruoyi.inspect.service.InsOrderPlanService;
import com.ruoyi.inspect.service.InsOrderService;
import com.ruoyi.inspect.service.InsUnPassService;
import com.ruoyi.inspect.service.impl.InsOrderServiceImpl;
import com.ruoyi.framework.util.SheetWriteHandlerUtil;
import com.ruoyi.inspect.service.impl.InsReportServiceImpl;
import com.ruoyi.inspect.vo.*;
import com.ruoyi.performance.mapper.AuxiliaryOutputWorkingHoursMapper;
import com.ruoyi.performance.mapper.PerformanceShiftMapper;
import com.ruoyi.performance.mapper.ShiftTimeMapper;
import com.ruoyi.require.handler.*;
import com.ruoyi.require.pojo.InformationNotification;
import com.ruoyi.require.service.InformationNotificationService;
import com.ruoyi.require.service.InsOrderPlanService;
import com.ruoyi.notice.pojo.InformationNotification;
import com.ruoyi.notice.service.InformationNotificationService;
import com.ruoyi.system.mapper.CustomMapper;
import com.ruoyi.system.mapper.UserMapper;
import com.ruoyi.system.service.ISysDictTypeService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringUtils;
@@ -126,6 +121,7 @@
    private InsSampleMapper insSampleMapper;
    @Resource
    private InsSampleUserMapper insSampleUserMapper;
    @Resource
    private InsOrderMapper insOrderMapper;
    @Resource
@@ -140,10 +136,6 @@
    private InsOrderStateMapper insOrderStateMapper;
    @Resource
    private InsProductMapper insProductMapper;
    @Resource
    private ShiftTimeMapper shiftTimeMapper;
    @Resource
    private PerformanceShiftMapper performanceShiftMapper;
    @Resource
    private StandardProductListMapper standardProductListMapper;
@@ -167,7 +159,7 @@
    private InsUnPassService insUnPassService;
    @Resource
    AuxiliaryOutputWorkingHoursMapper auxiliaryOutputWorkingHoursMapper;
    private ISysDictTypeService dictTypeService;
    @Resource
    private InformationNotificationService informationNotificationService;
@@ -202,24 +194,18 @@
    @Autowired
    private RabbitTemplate rabbitTemplate;
    private ReentrantLock lock = new ReentrantLock();
    @Resource
    private ThreadPoolTaskExecutor threadPoolTaskExecutor;
    @Override
    public void exportInsOrderPlanResult(Map<String, Object> data, HttpServletResponse response) {
    public void exportInsOrderPlanResult(QueryResultDTO data, HttpServletResponse response) {
        List<Map<String,Object>> dataList = new ArrayList<>();
        ObjectMapper objectMapper = new ObjectMapper();
        try {
            Object o = getTabHeader(data.get("sonLaboratory").toString(), data.get("samples").toString()).get("tableHeader");// èŽ·å–åŠ¨æ€è¡¨å¤´
            Object o = getTabHeader(data.getSonLaboratory(), data.getSampleType()).get("tableHeader");// èŽ·å–åŠ¨æ€è¡¨å¤´
            List<Map<String, Object>>  tableHeader = objectMapper.readValue(JSONUtil.toJsonStr(o), new TypeReference<List<Map<String, Object>>>() {
            });// è¡¨å¤´æ•°æ®
            Map<String, Object> table = objectMapper.readValue(JSONUtil.toJsonStr(data.get("trendsTable")), new TypeReference<Map<String, Object>>() {
            });
            List<Map<String, Object>> trendsTable = getInsOrderPlanList(table); // è¡¨æ ¼æ•°æ®
            // è¡¨å¤´æ•°æ®
            List<Map<String, Object>> trendsTable = getInsOrderPlanList(data); // è¡¨æ ¼æ•°æ®
            for (Map<String, Object> trend : trendsTable) {
                Map<String, Object> addMap = new HashMap<>();
                addMap.put("委托单号", trend.get("entrustCode"));
@@ -250,7 +236,7 @@
            ExcelWriter excelWriter = EasyExcel.write(response.getOutputStream())
                    .registerWriteHandler(new LongestMatchColumnWidthStyleStrategy())
                    .registerWriteHandler(new SheetWriteHandlerUtil(data.get("samples").toString(),head.size()))
                    .registerWriteHandler(new SheetWriteHandlerUtil(data.getSampleType(),head.size()))
                    .useDefaultStyle(true).relativeHeadRowIndex(1)
                    .registerWriteHandler(horizontalCellStyleStrategy)
                    .build();
@@ -346,29 +332,28 @@
        return headWriteCellStyle;
    }
    @Override
    public List<Map<String, Object>> getInsOrderPlanList(Map<String,Object> data) {
        String sampleType = data.get("sampleType").toString();
        String sonLaboratory = data.get("sonLaboratory").toString();
        String entrustCode = data.get("entrustCode").toString();
    public List<Map<String, Object>> getInsOrderPlanList(QueryResultDTO data) {
        String sampleType = data.getSampleType();
        String sonLaboratory = data.getSonLaboratory();
        String entrustCode = data.getEntrustCode();
        Integer createUser = null;
        String name = "";
        if(StringUtils.isNotBlank(data.get("createUser").toString())) {
             createUser = Integer.parseInt(data.get("createUser").toString());
        if(StringUtils.isNotBlank(data.getCreateUser())) {
             createUser = Integer.parseInt(data.getCreateUser());
             name = userMapper.selectById(createUser).getName();
        }
        String sampleCode = data.get("sampleCode").toString();
        String sampleCode = data.getSampleCode();
        String startTime = "";
        String endTime = "";
        List<Map<String, Object>> maps = new ArrayList<>();
        ObjectMapper objectMapper = new ObjectMapper();
        try {
            if(StringUtils.isNotBlank(data.get("insTime").toString()) && !Objects.isNull(data.get("insTime"))) {
                List insTime = objectMapper.readValue(JSONUtil.toJsonStr(data.get("insTime")), List.class);
                startTime = insTime.get(0).toString();
                endTime = insTime.get(1).toString();
            if(CollectionUtils.isNotEmpty(data.getInsTime())) {
                startTime = data.getInsTime().get(0);
                endTime = data.getInsTime().get(1);
            }
            // è¡¨å¤´ä¿¡æ¯
            List<Map<String, Object>> headerS = objectMapper.readValue(JSONUtil.toJsonStr(data.get("headerS")), new TypeReference<List<Map<String, Object>>>() {
            List<Map<String, Object>> headerS = objectMapper.readValue(JSONUtil.toJsonStr(data.getHeaderS()), new TypeReference<List<Map<String, Object>>>() {
            });
            // åˆ¤æ–­æ˜¯å¦æ˜¯æ¸©åº¦å¾ªçޝ
            if(sampleType.equals("温度循环")) {
@@ -446,8 +431,7 @@
     */
    private String getCurrentUserLaboratory(){
        // èŽ·å–å½“å‰äººæ‰€åœ¨å®žéªŒå®¤
        Integer userId = SecurityUtils.getUserId().intValue();
        String departLimsId = userMapper.selectById(userId).getDepartLimsId();
        String departLimsId = userMapper.selectById(SecurityUtils.getUserId()).getDepartLimsId();
        String laboratory = "";
        if(StringUtils.isNotBlank(departLimsId)) {
            String[] split = departLimsId.split(",");
@@ -619,7 +603,7 @@
            }
        }
        if (samples.contains("温度循环")){
        if (Objects.nonNull(samples)&&samples.contains("温度循环")){
            addElementToMaps(maps, "循环次数", "inspectionItems");
            addElementToMaps(maps, "温度点", "inspectionItemSubclass");
            addElementToMaps(maps, "衰减系数1310", "attenuationCoefficient1310");
@@ -663,6 +647,7 @@
    @Override
    public IPage<InsOrderPlanVO> selectInsOrderPlanList(Page page, InsOrderPlanDTO insOrderPlanDTO) {
        User user = userMapper.selectById(SecurityUtils.getUserId());//当前登录的人
        //获取当前人所属实验室id
        String departLimsId = user.getDepartLimsId();
        String laboratory = null;
@@ -685,8 +670,7 @@
            }
            insOrderPlanDTO.setUserId(null);
        }
        InsOrderPlanDTO planDTO = new InsOrderPlanDTO();
        QueryWrapper<InsOrderPlanDTO> wrappers = QueryWrappers.queryWrappers(planDTO);
        QueryWrapper<InsOrderPlanDTO> wrappers = QueryWrappers.queryWrappers(new InsOrderPlanDTO());
        IPage<InsOrderPlanVO> insOrderPage = insSampleMapper.findInsSampleAndOrder(
                page,
                userName,
@@ -705,8 +689,7 @@
    @Override
    public IPage<InsOrderPlanTaskSwitchVo> inspectionOrderDetailsTaskSwitching(Page page, InsOrderPlanDTO insOrderPlanDTO) {
        Integer userId = SecurityUtils.getUserId().intValue();
        User user = userMapper.selectById(userId);//当前登录的人
        User user = userMapper.selectById(SecurityUtils.getUserId());//当前登录的人
        //获取当前人所属实验室id
        String departLimsId = user.getDepartLimsId();
@@ -720,11 +703,10 @@
            }
        }
        if (ObjectUtil.isNotEmpty(insOrderPlanDTO.getUserId())) {
            insOrderPlanDTO.setUserId(userId.longValue());
            insOrderPlanDTO.setUserId(Long.valueOf(user.getId()));
        }
        String sonLaboratory = insOrderPlanDTO.getSonLaboratory();//试验室
        IPage<InsOrderPlanTaskSwitchVo> insOrderPage = insSampleMapper.inspectionOrderDetailsTaskSwitching(page, QueryWrappers.queryWrappers(insOrderPlanDTO), userId, sonLaboratory, laboratory);
        return insOrderPage;
        return insSampleMapper.inspectionOrderDetailsTaskSwitching(page, QueryWrappers.queryWrappers(insOrderPlanDTO), user.getId(), sonLaboratory, laboratory);
    }
    //认领任务
@@ -740,8 +722,6 @@
    @Override
    public Map<String, Object> doInsOrder(Integer id, String laboratory) {
//        InsOrder insOrder = new InsOrder();
//        insOrder.setId(id);
        InsOrder order = insOrderMapper.selectById(id);
        InsOrderState insOrderState = insOrderStateMapper.selectOne(new LambdaQueryWrapper<InsOrderState>()
@@ -859,8 +839,7 @@
    public IPage<InsOrderFile> getFileList(Page page, InsOrderFile insOrderFile) {
        Integer insOrderId = insOrderFile.getInsOrderId();
        insOrderFile.setInsOrderId(null);
        IPage<InsOrderFile> insOrderFileIPage = insOrderFileMapper.getFileList(page, QueryWrappers.queryWrappers(insOrderFile),insOrderId);
        return insOrderFileIPage;
        return insOrderFileMapper.getFileList(page, QueryWrappers.queryWrappers(insOrderFile),insOrderId);
    }
    @Override
@@ -2088,9 +2067,10 @@
                    .and(i->i.isNull(InsProduct::getInspectionItemClass).or().eq(InsProduct::getInspectionItemClass,""))
                    );//用检验分项字段区别光纤配置与温度循环
            //查询全色谱,过滤色标并排序
            List<String> colorList = DictUtils.getDictCache("色标").stream()
            List<String> colorList = dictTypeService.selectDictDataByType("fiber_color_type").stream()
                    .sorted(Comparator.comparing(SysDictData::getDictSort))
                    .map(SysDictData::getDictValue)
                    .map(SysDictData::getDictLabel)
                    .collect(Collectors.toList());
            //松套管附件处理
            long piperCount = insProducts.stream().filter(f->!Objects.isNull(f.getInsBushId())).count();