¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.requier.service.impl; |
| | | |
| | | import cn.hutool.core.bean.BeanUtil; |
| | | import cn.hutool.core.lang.UUID; |
| | | import cn.hutool.core.util.NumberUtil; |
| | | import cn.hutool.core.util.ObjectUtil; |
| | | import cn.hutool.core.util.StrUtil; |
| | | import cn.hutool.json.JSONUtil; |
| | | import com.alibaba.excel.EasyExcel; |
| | | import com.alibaba.excel.ExcelWriter; |
| | | import com.alibaba.excel.write.metadata.WriteSheet; |
| | | import com.alibaba.excel.write.metadata.style.WriteCellStyle; |
| | | import com.alibaba.excel.write.metadata.style.WriteFont; |
| | | import com.alibaba.excel.write.style.HorizontalCellStyleStrategy; |
| | | import com.alibaba.excel.write.style.column.LongestMatchColumnWidthStyleStrategy; |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | 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.deepoove.poi.XWPFTemplate; |
| | | import com.deepoove.poi.config.Configure; |
| | | import com.deepoove.poi.config.ConfigureBuilder; |
| | | import com.deepoove.poi.data.*; |
| | | import com.deepoove.poi.data.style.Style; |
| | | import com.deepoove.poi.util.TableTools; |
| | | import com.fasterxml.jackson.core.JsonProcessingException; |
| | | import com.fasterxml.jackson.core.type.TypeReference; |
| | | import com.fasterxml.jackson.databind.ObjectMapper; |
| | | 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.inspect.dto.*; |
| | | import com.ruoyi.inspect.mapper.*; |
| | | import com.ruoyi.inspect.pojo.*; |
| | | import com.ruoyi.inspect.service.InsBushingService; |
| | | 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.vo.*; |
| | | import com.ruoyi.performance.mapper.AuxiliaryOutputWorkingHoursMapper; |
| | | import com.ruoyi.performance.mapper.PerformanceShiftMapper; |
| | | import com.ruoyi.performance.mapper.ShiftTimeMapper; |
| | | import com.ruoyi.requier.handler.*; |
| | | import com.ruoyi.requier.pojo.InformationNotification; |
| | | import com.ruoyi.requier.service.InformationNotificationService; |
| | | import com.ruoyi.requier.service.InsOrderPlanService; |
| | | import com.ruoyi.system.mapper.CustomMapper; |
| | | import com.ruoyi.system.mapper.UserMapper; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.io.IOUtils; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.apache.logging.log4j.util.Strings; |
| | | import org.apache.poi.openxml4j.util.ZipSecureFile; |
| | | import org.apache.poi.ss.usermodel.FillPatternType; |
| | | import org.apache.poi.ss.usermodel.IndexedColors; |
| | | import org.apache.poi.xwpf.usermodel.*; |
| | | import org.springframework.amqp.rabbit.core.RabbitTemplate; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Isolation; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.io.*; |
| | | import java.net.URLEncoder; |
| | | import java.nio.file.Files; |
| | | import java.nio.file.Paths; |
| | | import java.text.SimpleDateFormat; |
| | | import java.time.LocalDate; |
| | | import java.time.LocalDateTime; |
| | | import java.time.LocalTime; |
| | | import java.time.format.DateTimeFormatter; |
| | | import java.time.temporal.TemporalAdjusters; |
| | | import java.util.*; |
| | | import java.util.concurrent.CompletableFuture; |
| | | import java.util.concurrent.TimeUnit; |
| | | import java.util.concurrent.atomic.AtomicInteger; |
| | | import java.util.concurrent.atomic.AtomicReference; |
| | | import java.util.concurrent.locks.ReentrantLock; |
| | | import java.util.regex.Matcher; |
| | | import java.util.regex.Pattern; |
| | | import java.util.stream.Collectors; |
| | | |
| | | |
| | | /** |
| | | * æ£éªä»»å¡-ä¸å¡å®ç°å± |
| | | */ |
| | | @Service |
| | | @Slf4j |
| | | public class InsOrderPlanServiceImpl extends ServiceImpl<InsOrderMapper, InsOrder> implements InsOrderPlanService { |
| | | |
| | | // æ¥åæ«ç è·¯å¾ |
| | | @Value("${phoneQrCode}") |
| | | private String phoneQrCode; |
| | | |
| | | @Resource |
| | | private InsReportServiceImpl insReportService; |
| | | @Resource |
| | | private InsSampleMapper insSampleMapper; |
| | | @Resource |
| | | private InsSampleUserMapper insSampleUserMapper; |
| | | @Resource |
| | | private InsOrderMapper insOrderMapper; |
| | | @Resource |
| | | private InsOrderService insOrderService; |
| | | |
| | | @Resource |
| | | private InsOrderServiceImpl insOrderServiceImpl; |
| | | |
| | | @Resource |
| | | private StandardTemplateService standardTemplateService; |
| | | @Resource |
| | | private InsOrderStateMapper insOrderStateMapper; |
| | | @Resource |
| | | private InsProductMapper insProductMapper; |
| | | @Resource |
| | | private ShiftTimeMapper shiftTimeMapper; |
| | | @Resource |
| | | private PerformanceShiftMapper performanceShiftMapper; |
| | | |
| | | @Resource |
| | | private StandardProductListMapper standardProductListMapper; |
| | | |
| | | @Value("${wordUrl}") |
| | | private String wordUrl; |
| | | |
| | | @Value("${twoCode}") |
| | | private String twoCode; |
| | | |
| | | @Resource |
| | | private InsReportMapper insReportMapper; |
| | | |
| | | @Resource |
| | | private InsProductResultMapper insProductResultMapper; |
| | | |
| | | @Resource |
| | | private InsProductUserMapper insProductUserMapper; |
| | | |
| | | @Resource |
| | | private InsUnPassService insUnPassService; |
| | | |
| | | @Resource |
| | | AuxiliaryOutputWorkingHoursMapper auxiliaryOutputWorkingHoursMapper; |
| | | |
| | | @Resource |
| | | private InformationNotificationService informationNotificationService; |
| | | |
| | | @Resource |
| | | private UserMapper userMapper; |
| | | |
| | | @Resource |
| | | private CustomMapper customMapper; |
| | | |
| | | @Value("${file.path}") |
| | | private String imgUrl; |
| | | |
| | | @Resource |
| | | private InsBushingService insBushingService; |
| | | |
| | | @Resource |
| | | private InsBushingMapper insBushingMapper; |
| | | |
| | | @Resource |
| | | private InsFiberMapper insFiberMapper; |
| | | |
| | | @Resource |
| | | private InsFibersMapper insFibersMapper; |
| | | |
| | | @Resource |
| | | private InsOrderFileMapper insOrderFileMapper; |
| | | |
| | | @Resource |
| | | private InsReportApproveConfigMapper insReportApproveConfigMapper; |
| | | |
| | | @Autowired |
| | | private RabbitTemplate rabbitTemplate; |
| | | |
| | | |
| | | |
| | | private ReentrantLock lock = new ReentrantLock(); |
| | | |
| | | @Resource |
| | | private ThreadPoolTaskExecutor threadPoolTaskExecutor; |
| | | |
| | | @Override |
| | | public void exportInsOrderPlanResult(Map<String, Object> 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");// è·åå¨æè¡¨å¤´ |
| | | 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); // è¡¨æ ¼æ°æ® |
| | | for (Map<String, Object> trend : trendsTable) { |
| | | Map<String, Object> addMap = new HashMap<>(); |
| | | addMap.put("å§æåå·", trend.get("entrustCode")); |
| | | addMap.put("æ ·åç¼å·", trend.get("sampleCode")); |
| | | addMap.put("ç®¡è²æ ", trend.get("bushing")); |
| | | addMap.put("å
çº¤å¸¦è²æ ", trend.get("fibers")); |
| | | addMap.put("å
çº¤è²æ ", trend.get("fiber")); |
| | | addMap.put("æ£éªé¡¹ç®åç±»", trend.get("inspectionItem")); |
| | | addMap.put("å建人", trend.get("userName")); |
| | | addMap.put("æ£æµæ¶é´", trend.get("insTime")); |
| | | addMap.put("ä¸åæ¶é´", trend.get("sendTime")); |
| | | for (Map<String, Object> map : tableHeader) { |
| | | if(Objects.isNull(trend.get(map.get("prop").toString())) || Objects.equals(trend.get(map.get("prop").toString()),"null")) { |
| | | addMap.put(map.get("label").toString(), ""); |
| | | }else { |
| | | addMap.put(map.get("label").toString(), trend.get(map.get("prop").toString())); |
| | | } |
| | | } |
| | | dataList.add(addMap); |
| | | } |
| | | List<List<String>> head = head(tableHeader); |
| | | response.setContentType("application/vnd.ms-excel"); |
| | | response.setCharacterEncoding("UTF-8"); |
| | | String fileName = URLEncoder.encode("æ£éªç»æ", "UTF-8"); |
| | | response.setHeader("Content-disposition", "attachment;filename=" + fileName + ".xlsx"); |
| | | HorizontalCellStyleStrategy horizontalCellStyleStrategy = |
| | | new HorizontalCellStyleStrategy(getHeadStyle((short) 12),new WriteCellStyle()); |
| | | |
| | | ExcelWriter excelWriter = EasyExcel.write(response.getOutputStream()) |
| | | .registerWriteHandler(new LongestMatchColumnWidthStyleStrategy()) |
| | | .registerWriteHandler(new SheetWriteHandlerUtil(data.get("samples").toString(),head.size())) |
| | | .useDefaultStyle(true).relativeHeadRowIndex(1) |
| | | .registerWriteHandler(horizontalCellStyleStrategy) |
| | | .build(); |
| | | WriteSheet mainSheet = EasyExcel.writerSheet("Sheet0").head(head).build(); |
| | | excelWriter.write(dataList(head,dataList), mainSheet); |
| | | // å
³éæµ |
| | | excelWriter.finish(); |
| | | } catch (Exception e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * å¨æè¡¨å¤´ |
| | | * @param tableHeader |
| | | * @return |
| | | */ |
| | | private List<List<String>> head(List<Map<String, Object>> tableHeader) { |
| | | List<List<String>> list = new ArrayList<>(); |
| | | List<String> head0 = new ArrayList<>(); |
| | | head0.add("å§æåå·"); |
| | | List<String> head1 = new ArrayList<>(); |
| | | head1.add("æ ·åç¼å·"); |
| | | List<String> head2 = new ArrayList<>(); |
| | | head2.add("æ£éªé¡¹ç®åç±»"); |
| | | List<String> head3 = new ArrayList<>(); |
| | | head3.add("å建人"); |
| | | List<String> head4 = new ArrayList<>(); |
| | | head4.add("æ£æµæ¶é´"); |
| | | List<String> head5 = new ArrayList<>(); |
| | | head5.add("ä¸åæ¶é´"); |
| | | List<String> head6 = new ArrayList<>(); |
| | | head6.add("ç®¡è²æ "); |
| | | List<String> head7 = new ArrayList<>(); |
| | | head7.add("å
çº¤å¸¦è²æ "); |
| | | List<String> head8 = new ArrayList<>(); |
| | | head8.add("å
çº¤è²æ "); |
| | | |
| | | list.add(head0); |
| | | list.add(head1); |
| | | list.add(head6); |
| | | list.add(head7); |
| | | list.add(head8); |
| | | list.add(head2); |
| | | list.add(head3); |
| | | list.add(head4); |
| | | list.add(head5); |
| | | for (Map<String, Object> map : tableHeader) { |
| | | List<String> head = new ArrayList<>(); |
| | | head.add(map.get("label").toString()); |
| | | list.add(head); |
| | | } |
| | | return list.stream().distinct().collect(Collectors.toList()); |
| | | } |
| | | |
| | | /** |
| | | * excelå¯¼åºæ°æ® |
| | | * @param head |
| | | * @param dataList |
| | | * @return |
| | | */ |
| | | private List<List<Object>> dataList(List<List<String>> head,List<Map<String,Object>> dataList) { |
| | | List<List<Object>> list = new ArrayList<>(); |
| | | for(Map<String, Object> map : dataList) { |
| | | List<Object> addList = new ArrayList<>(); |
| | | for(List<String> k : head) { |
| | | if(map.containsKey(k.get(0))) { |
| | | addList.add(map.get(k.get(0))); |
| | | } |
| | | } |
| | | list.add(addList); |
| | | } |
| | | return list; |
| | | } |
| | | |
| | | /** |
| | | * 头ççç¥ |
| | | * @return |
| | | */ |
| | | public WriteCellStyle getHeadStyle(Short size){ |
| | | // 头ççç¥ |
| | | WriteCellStyle headWriteCellStyle = new WriteCellStyle(); |
| | | // èæ¯é¢è² |
| | | headWriteCellStyle.setFillForegroundColor(IndexedColors.WHITE.getIndex()); |
| | | headWriteCellStyle.setFillPatternType(FillPatternType.SOLID_FOREGROUND); |
| | | // åä½ |
| | | WriteFont headWriteFont = new WriteFont(); |
| | | headWriteFont.setFontName("é»ä½");//设置åä½åå |
| | | headWriteFont.setFontHeightInPoints(size);//设置åä½å¤§å° |
| | | headWriteFont.setBold(true);//åä½å ç² |
| | | headWriteCellStyle.setWriteFont(headWriteFont); //卿 ·å¼ç¨åºç¨è®¾ç½®çåä½; |
| | | |
| | | 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(); |
| | | Integer createUser = null; |
| | | String name = ""; |
| | | if(StringUtils.isNotBlank(data.get("createUser").toString())) { |
| | | createUser = Integer.parseInt(data.get("createUser").toString()); |
| | | name = userMapper.selectById(createUser).getName(); |
| | | } |
| | | String sampleCode = data.get("sampleCode").toString(); |
| | | 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(); |
| | | } |
| | | // è¡¨å¤´ä¿¡æ¯ |
| | | List<Map<String, Object>> headerS = objectMapper.readValue(JSONUtil.toJsonStr(data.get("headerS")), new TypeReference<List<Map<String, Object>>>() { |
| | | }); |
| | | // 夿æ¯å¦æ¯æ¸©åº¦å¾ªç¯ |
| | | if(sampleType.equals("温度循ç¯")) { |
| | | List<ExportInsProductVO> insOrderTemList = insOrderMapper.getInsOrderTemList(entrustCode, sampleCode, startTime, endTime,name); |
| | | List<TemperatureCycling> temList = insOrderServiceImpl.getTemList(insOrderTemList); |
| | | for (TemperatureCycling map : temList) { |
| | | Map<String, Object> resultMap = new HashMap<>(); |
| | | resultMap.put("entrustCode", map.getEntrustCode()); //å§æåå· |
| | | resultMap.put("sampleCode", map.getSampleCode()); //æ ·åç¼å· |
| | | resultMap.put("bushing", map.getBushColor()); //å¥ç®¡ |
| | | resultMap.put("fiber", map.getColor()); //å
纤 |
| | | resultMap.put("fibers", map.getCode()); //å
纤带 |
| | | resultMap.put("userName", map.getCheckName()); //æ£éªäºº |
| | | resultMap.put("insTime", map.getInsTime()); //æ£æµæ¶é´ |
| | | resultMap.put("sendTime", map.getSendTime()); //ä¸åæ¶é´ |
| | | resultMap.put("inspectionItem", map.getSample()); //æ£éªé¡¹ç® |
| | | //温度循ç¯å项 |
| | | resultMap.put("inspectionItems", map.getInspectionItem()); |
| | | resultMap.put("inspectionItemSubclass", map.getInspectionItemSubclass()); |
| | | resultMap.put("attenuationCoefficient1310", map.getAttenuationCoefficient1310()); |
| | | resultMap.put("attenuationDifference1", map.getAttenuationDifference1()); |
| | | resultMap.put("attenuationDifference2", map.getAttenuationDifference2()); |
| | | resultMap.put("attenuationCoefficient1625", map.getAttenuationCoefficient1625()); |
| | | resultMap.put("attenuationDifference3", map.getAttenuationDifference3()); |
| | | resultMap.put("attenuationCoefficient1383", map.getAttenuationCoefficient1383()); |
| | | resultMap.put("attenuationDifference4", map.getAttenuationDifference4()); |
| | | resultMap.put("attenuationCoefficient1490", map.getAttenuationCoefficient1490()); |
| | | resultMap.put("attenuationDifference5", map.getAttenuationDifference5()); |
| | | resultMap.put("attenuationDifferenceMax", map.getAttenuationDifferenceMax()); |
| | | resultMap.put("insResult", map.getInsResult()); |
| | | maps.add(resultMap); |
| | | } |
| | | } |
| | | else { |
| | | List<Map<String, Object>> insOrderPlanList = baseMapper.getInsOrderPlanList(sonLaboratory, entrustCode, sampleCode, createUser, startTime, endTime,sampleType); |
| | | for (Map<String, Object> map : insOrderPlanList) { |
| | | Map<String, Object> resultMap = new HashMap<>(); |
| | | resultMap.put("entrustCode", map.get("entrustCode")); //å§æåå· |
| | | resultMap.put("sampleCode", map.get("sampleCode")); //æ ·åç¼å· |
| | | resultMap.put("bushing", map.get("bushing")); //å¥ç®¡ |
| | | resultMap.put("fiber", map.get("fiber")); //å
纤 |
| | | resultMap.put("fibers", map.get("fibers")); //å
纤带 |
| | | resultMap.put("userName", map.get("userName")); //å建人 |
| | | resultMap.put("insTime", map.get("insTime")); //æ£æµæ¶é´ |
| | | resultMap.put("sendTime", map.get("sendTime")); //ä¸åæ¶é´ |
| | | resultMap.put("inspectionItem", map.get("inspectionItem")); //æ£éªé¡¹ç® |
| | | // æ¥ç表头æ¯å¦åå¨å项 |
| | | List<Map<String, Object>> collect = headerS.stream().filter(item -> |
| | | item.get("label").toString().equals(map.get("inspectionItemSubclass").toString())) |
| | | .collect(Collectors.toList()); |
| | | // æå°±åå项 没æå°±åç¶é¡¹ |
| | | if(!collect.isEmpty() && !Objects.isNull(collect)) { |
| | | resultMap.put(collect.get(0).get("prop").toString(), map.get("lastValue"));//æ£éªåé¡¹ç® æ£éªç»æ |
| | | }else { |
| | | List<Map<String, Object>> collect1 = headerS.stream().filter(item -> |
| | | item.get("label").toString().equals(map.get("inspectionItem").toString())) |
| | | .collect(Collectors.toList()); |
| | | if(!collect1.isEmpty() && !Objects.isNull(collect1)) { |
| | | resultMap.put(collect1.get(0).get("prop").toString(), map.get("lastValue"));//æ£éªé¡¹ç® æ£éªç»æ |
| | | } |
| | | } |
| | | maps.add(resultMap); |
| | | } |
| | | |
| | | } |
| | | } catch (JsonProcessingException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | return maps.stream().distinct().collect(Collectors.toList()); |
| | | } |
| | | |
| | | /** |
| | | * è·åå½åç¨æ·çå®éªå®¤ |
| | | * @return |
| | | */ |
| | | private String getCurrentUserLaboratory(){ |
| | | // è·åå½å人æå¨å®éªå®¤ |
| | | Integer userId = SecurityUtils.getUserId().intValue(); |
| | | String departLimsId = userMapper.selectById(userId).getDepartLimsId(); |
| | | String laboratory = ""; |
| | | if(StringUtils.isNotBlank(departLimsId)) { |
| | | String[] split = departLimsId.split(","); |
| | | for (String s : split) { |
| | | if (StringUtils.isNotBlank(s) && (!Arrays.asList("1","22").contains(s))) { |
| | | laboratory = insOrderMapper.getDepartment(Integer.parseInt(s)); |
| | | } |
| | | } |
| | | } |
| | | return laboratory; |
| | | } |
| | | |
| | | /** |
| | | * 导åºå§æè´¹ç¨ |
| | | * @param data æ°æ® |
| | | */ |
| | | @Override |
| | | public void exportCommissionFees(Map<String, Object> data,HttpServletResponse response) { |
| | | String laboratory = getCurrentUserLaboratory(); |
| | | // æ¥ææ ¼å¼å |
| | | DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); |
| | | String start = LocalDateTime.of( |
| | | LocalDate.parse(data.get("startTime").toString(), |
| | | dateTimeFormatter),LocalTime.of(00, 00, 00) |
| | | ).toString(); |
| | | String end = LocalDateTime.of( |
| | | LocalDate.parse(data.get("endTime").toString(), |
| | | dateTimeFormatter),LocalTime.of(23, 59, 59) |
| | | ).toString(); |
| | | // è·åæ°æ® |
| | | String company = data.get("company").toString(); |
| | | List<CommissionFeesDto> list = insOrderMapper.selectCommissionFees(laboratory,company, start, end); |
| | | list = list.stream().map(dto -> { |
| | | Set<String> uniqueTags = new HashSet<>(); |
| | | if (dto.getInsItem().contains(",")) { |
| | | for (String s : dto.getInsItem().split(",")) { |
| | | uniqueTags.add(s.split("@")[0]); |
| | | } |
| | | } else { |
| | | uniqueTags.add(dto.getInsItem().split("@")[0]); |
| | | } |
| | | dto.setInsItem(uniqueTags.toString()); |
| | | return dto; |
| | | }).collect(Collectors.toList()); |
| | | try { |
| | | String fileName = URLEncoder.encode(laboratory+"å§æè´¹ç¨ç»è®¡", "UTF-8"); |
| | | response.setContentType("application/vnd.ms-excel"); |
| | | response.setCharacterEncoding("UTF-8"); |
| | | response.setHeader("content-disposition", "attachment;filename=" + fileName + ".xlsx"); |
| | | // æ°å»ºExcelWriter |
| | | ExcelWriter excelWriter = EasyExcel.write(response.getOutputStream(),CommissionFeesDto.class).build(); |
| | | // æ ¹æ®å§æåä½è¿è¡sheetåç±» |
| | | Map<String, List<CommissionFeesDto>> collect = list.stream().collect(Collectors.groupingBy(CommissionFeesDto::getCompany)); |
| | | Iterator<Map.Entry<String, List<CommissionFeesDto>>> iterator = collect.entrySet().iterator(); |
| | | int i = 0; |
| | | while(iterator.hasNext()) { |
| | | Map.Entry<String, List<CommissionFeesDto>> entry = iterator.next(); |
| | | WriteSheet writeSheet = EasyExcel.writerSheet(i, entry.getKey()).build(); |
| | | excelWriter.write(entry.getValue(), writeSheet); |
| | | i++; |
| | | } |
| | | // WriteSheet writeSheet = EasyExcel.writerSheet().head(CommissionFeesDto.class).build(); |
| | | // excelWriter.write(list, writeSheet); |
| | | |
| | | // å°æ°æ®åå
¥ |
| | | excelWriter.finish(); |
| | | } catch (Exception e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void exportUnInsProducts(UnInsProductsDTO unInsProductsDTO, HttpServletResponse response) { |
| | | String laboratory = getCurrentUserLaboratory(); |
| | | //æ¥ææ ¼å¼å |
| | | DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); |
| | | LocalDateTime startDateTime = LocalDateTime.of(LocalDate.parse(unInsProductsDTO.getStartDate(),dateTimeFormatter),LocalTime.MIN); |
| | | LocalDateTime endDateTime = LocalDateTime.of(LocalDate.parse(unInsProductsDTO.getEndDate(),dateTimeFormatter),LocalTime.MAX); |
| | | |
| | | // è·åæ°æ® |
| | | List<UnInsProductsVO> list = baseMapper.selectUnInsProducts(laboratory, startDateTime, endDateTime,unInsProductsDTO); |
| | | try { |
| | | String fileName = URLEncoder.encode(laboratory+"å¾
æ£ä»»å¡ç»è®¡", "UTF-8"); |
| | | response.setContentType("application/vnd.ms-excel"); |
| | | response.setCharacterEncoding("UTF-8"); |
| | | response.setHeader("content-disposition", "attachment;filename=" + fileName + ".xlsx"); |
| | | // æ°å»ºExcelWriter |
| | | ExcelWriter excelWriter = EasyExcel.write(response.getOutputStream()).build(); |
| | | WriteSheet writeSheet = EasyExcel.writerSheet().head(UnInsProductsVO.class).build(); |
| | | excelWriter.write(list, writeSheet); |
| | | // å
³éæµ |
| | | excelWriter.finish(); |
| | | } catch (Exception e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public IPage<TasksShowDto> tasksShow(Page page, String sonLaboratory) { |
| | | IPage tasksShow = insOrderMapper.getTasksShow(page, sonLaboratory); |
| | | return tasksShow; |
| | | } |
| | | |
| | | @Override |
| | | public int getCurrentMonthPlanTotalBySonLaboratory(String sonLaboratory,LocalDateTime startTime, LocalDateTime endTime) { |
| | | if(StringUtils.isNotBlank(sonLaboratory)){ |
| | | if(Objects.isNull(startTime) || Objects.isNull(endTime)) { |
| | | //è·å彿çå¼å§åç»ææ¶é´ |
| | | // 彿çå¼å§æ¶é´ï¼ç¬¬ä¸å¤© 00:00:00ï¼ |
| | | startTime = LocalDate.now() |
| | | .withDayOfMonth(1) |
| | | .atStartOfDay(); |
| | | |
| | | // 彿çç»ææ¶é´ï¼æåä¸å¤© 23:59:59.999999999ï¼ |
| | | endTime = LocalDate.now() |
| | | .with(TemporalAdjusters.lastDayOfMonth()) |
| | | .atTime(LocalTime.MAX); |
| | | } |
| | | //æ¥è¯¢å½æè¯¥åè¯éªå®¤çæ»ä»»å¡æ¡æ° |
| | | return baseMapper.selectPlanCountBySonLaboratory(sonLaboratory,startTime,endTime); |
| | | } |
| | | return 0; |
| | | } |
| | | |
| | | @Override |
| | | public Map<String, Object> getTabHeader(String sonLaboratory,String samples) { |
| | | Map<String, Object> resultMap = new HashMap<>(); |
| | | List<String> list = new ArrayList<>(); |
| | | List<Map<String, Object>> maps = new ArrayList<>(); |
| | | if(StringUtils.isNotBlank(samples)) { |
| | | samples = "[" + "\"" + samples + "\""; |
| | | } |
| | | List<Map<String, Object>> tabHeader = baseMapper.getTabHeader(sonLaboratory,samples); |
| | | ObjectMapper objectMapper = new ObjectMapper(); |
| | | Long count = 1l; |
| | | for (Map<String, Object> map : tabHeader) { |
| | | try { |
| | | List<List<String>> sample = objectMapper.readValue(JSONUtil.toJsonStr(map.get("sample").toString()), new TypeReference<List<List<String>>>() { |
| | | }); |
| | | // è·åtab页表头 |
| | | for (List<String> strings : sample) { |
| | | list.add(strings.get(0)); |
| | | } |
| | | // è·åè¡¨æ ¼è¡¨å¤´ |
| | | if(StringUtils.isNotBlank(samples)) { |
| | | if(map.containsKey("inspectionItemSubclass")) { |
| | | if(StringUtils.isNotBlank(map.get("inspectionItemSubclass").toString())) { |
| | | HashMap<String, Object> map1 = new HashMap<>(); |
| | | map1.put("label", map.get("inspectionItemSubclass").toString()); // label |
| | | map1.put("prop","lastValue"+count); // prop |
| | | maps.add(map1); |
| | | }else { |
| | | HashMap<String, Object> map1 = new HashMap<>(); |
| | | map1.put("label", map.get("inspectionItem").toString()); // label |
| | | map1.put("prop","lastValue"+count); // prop |
| | | maps.add(map1); |
| | | } |
| | | }else { |
| | | HashMap<String, Object> map1 = new HashMap<>(); |
| | | map1.put("label", map.get("inspectionItem").toString()); // label |
| | | map1.put("prop","lastValue"+count); // prop |
| | | maps.add(map1); |
| | | } |
| | | count++; |
| | | } |
| | | } catch (JsonProcessingException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | } |
| | | |
| | | if (samples.contains("温度循ç¯")){ |
| | | addElementToMaps(maps, "å¾ªç¯æ¬¡æ°", "inspectionItems"); |
| | | addElementToMaps(maps, "温度ç¹", "inspectionItemSubclass"); |
| | | addElementToMaps(maps, "è¡°åç³»æ°1310", "attenuationCoefficient1310"); |
| | | addElementToMaps(maps, "è¡°åå·®1", "attenuationDifference1"); |
| | | addElementToMaps(maps, "è¡°åç³»æ°1550", "attenuationCoefficient1550"); |
| | | addElementToMaps(maps, "è¡°åå·®2", "attenuationDifference2"); |
| | | addElementToMaps(maps, "è¡°åç³»æ°1625", "attenuationCoefficient1625"); |
| | | addElementToMaps(maps, "è¡°åå·®3", "attenuationDifference3"); |
| | | addElementToMaps(maps, "è¡°å1383", "attenuationCoefficient1383"); |
| | | addElementToMaps(maps, "è¡°åå·®4", "attenuationDifference4"); |
| | | addElementToMaps(maps, "è¡°å1490", "attenuationCoefficient1490"); |
| | | addElementToMaps(maps, "è¡°åå·®5", "attenuationDifference5"); |
| | | addElementToMaps(maps, "è¡°åå·®Max", "attenuationDifferenceMax"); |
| | | addElementToMaps(maps, "æ¯å¦åæ ¼", "insResult"); |
| | | } |
| | | |
| | | Map<String, Map<String, Object>> uniqueByLabel = maps.stream() |
| | | .collect(Collectors.toMap( |
| | | map -> (String) map.get("label"), |
| | | map -> map, |
| | | (existing, replacement) -> existing, // ä¿ç第ä¸ä¸ªéå°çMap |
| | | LinkedHashMap::new |
| | | )); |
| | | // å°ç»æè½¬æ¢åList<Map<String, Object>> |
| | | List<Map<String, Object>> collect1 = new ArrayList<>(uniqueByLabel.values()); |
| | | // List<Map<String, Object>> collect1 = maps.stream().distinct().collect(Collectors.toList()); |
| | | List<String> collect = list.stream().distinct().collect(Collectors.toList()); |
| | | collect.add("温度循ç¯"); |
| | | resultMap.put("tabHeader", collect); |
| | | resultMap.put("tableHeader", collect1); |
| | | return resultMap; |
| | | } |
| | | |
| | | private static void addElementToMaps(List<Map<String, Object>> maps, String label, String prop) { |
| | | Map<String, Object> map = new HashMap<>(); |
| | | map.put("label", label); |
| | | map.put("prop", prop); |
| | | maps.add(map); |
| | | } |
| | | |
| | | @Override |
| | | public IPage<InsOrderPlanVO> selectInsOrderPlanList(Page page, InsOrderPlanDTO insOrderPlanDTO) { |
| | | User user = userMapper.selectById(SecurityUtils.getUserId());//å½åç»å½ç人 |
| | | //è·åå½å人æå±å®éªå®¤id |
| | | String departLimsId = user.getDepartLimsId(); |
| | | String laboratory = null; |
| | | if (ObjectUtils.isNotEmpty(departLimsId) && !departLimsId.isEmpty()) { |
| | | String[] split = departLimsId.split(","); |
| | | //æ¥è¯¢å¯¹åºæ¶æåç§°(éä¿¡å®éªå®¤,çµåå®éªå®¤,æ£æµå) |
| | | String departLims = baseMapper.seldepLimsId(Integer.parseInt(split[split.length - 1])); |
| | | if (departLims.contains("å®éªå®¤")) { |
| | | laboratory = departLims; |
| | | } |
| | | } |
| | | |
| | | String checkName = null; |
| | | String userName = null; |
| | | if (ObjectUtil.isNotEmpty(insOrderPlanDTO.getUserId())) { |
| | | userName = userMapper.selectById(SecurityUtils.getUserId()).getName(); |
| | | if(Objects.equals(insOrderPlanDTO.getInsState(),"3")) { |
| | | userName = ""; |
| | | checkName = userMapper.selectById(SecurityUtils.getUserId()).getName(); |
| | | } |
| | | insOrderPlanDTO.setUserId(null); |
| | | } |
| | | InsOrderPlanDTO planDTO = new InsOrderPlanDTO(); |
| | | QueryWrapper<InsOrderPlanDTO> wrappers = QueryWrappers.queryWrappers(planDTO); |
| | | IPage<InsOrderPlanVO> insOrderPage = insSampleMapper.findInsSampleAndOrder( |
| | | page, |
| | | userName, |
| | | checkName, |
| | | insOrderPlanDTO.getSonLaboratory(), |
| | | insOrderPlanDTO.getSample(), |
| | | insOrderPlanDTO.getSampleCode(), |
| | | laboratory, |
| | | insOrderPlanDTO.getEntrustCode(), |
| | | insOrderPlanDTO.getInsState(), |
| | | wrappers, |
| | | insOrderPlanDTO.getSendTimeRange() |
| | | ); |
| | | return insOrderPage; |
| | | } |
| | | |
| | | @Override |
| | | public IPage<InsOrderPlanTaskSwitchVo> inspectionOrderDetailsTaskSwitching(Page page, InsOrderPlanDTO insOrderPlanDTO) { |
| | | Integer userId = SecurityUtils.getUserId().intValue(); |
| | | User user = userMapper.selectById(userId);//å½åç»å½ç人 |
| | | |
| | | //è·åå½å人æå±å®éªå®¤id |
| | | String departLimsId = user.getDepartLimsId(); |
| | | String laboratory = null; |
| | | if (ObjectUtils.isNotEmpty(departLimsId) && !departLimsId.equals("")) { |
| | | String[] split = departLimsId.split(","); |
| | | //æ¥è¯¢å¯¹åºæ¶æåç§°(éä¿¡å®éªå®¤,çµåå®éªå®¤,æ£æµå) |
| | | String departLims = baseMapper.seldepLimsId(Integer.parseInt(split[split.length - 1])); |
| | | if (departLims.contains("å®éªå®¤")) { |
| | | laboratory = departLims; |
| | | } |
| | | } |
| | | if (ObjectUtil.isNotEmpty(insOrderPlanDTO.getUserId())) { |
| | | insOrderPlanDTO.setUserId(userId.longValue()); |
| | | } |
| | | String sonLaboratory = insOrderPlanDTO.getSonLaboratory();//è¯éªå®¤ |
| | | IPage<InsOrderPlanTaskSwitchVo> insOrderPage = insSampleMapper.inspectionOrderDetailsTaskSwitching(page, QueryWrappers.queryWrappers(insOrderPlanDTO), userId, sonLaboratory, laboratory); |
| | | return insOrderPage; |
| | | } |
| | | |
| | | //认é¢ä»»å¡ |
| | | @Override |
| | | public boolean claimInsOrderPlan(InsOrderPlanDTO entity) { |
| | | if (Objects.isNull(entity)) { |
| | | return false; |
| | | } |
| | | Integer userId = SecurityUtils.getUserId().intValue(); |
| | | InsSampleUser insSampleUser = new InsSampleUser(entity.getInsSampleId().intValue(), userId, 0, entity.getSonLaboratory()); |
| | | return insSampleUserMapper.insert(insSampleUser) > 0; |
| | | } |
| | | |
| | | @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>() |
| | | .eq(InsOrderState::getInsOrderId, id) |
| | | .eq(InsOrderState::getLaboratory, laboratory)); |
| | | |
| | | if (BeanUtil.isEmpty(insOrderState.getInsTime())) { |
| | | order.setInsTime(LocalDateTime.now()); |
| | | insOrderMapper.updateById(order); |
| | | insOrderStateMapper.update(null, Wrappers.<InsOrderState>lambdaUpdate().eq(InsOrderState::getInsOrderId, id).eq(InsOrderState::getLaboratory, laboratory).set(InsOrderState::getInsTime, LocalDateTime.now()).set(InsOrderState::getInsState, 1)); |
| | | } |
| | | Map<String, Object> map = insOrderService.getInsOrderAndSample(id, laboratory); |
| | | List<SampleProductDto> list = JSON.parseArray(JSON.toJSONString(map.get("sampleProduct")), SampleProductDto.class); |
| | | for (SampleProductDto samples : list) { |
| | | if (BeanUtil.isEmpty(samples.getInsProduct())) continue; |
| | | samples.setBushing(insBushingService.selectBushingBySampleId(samples.getId())); |
| | | } |
| | | map.put("sampleProduct", list.stream().sorted(Comparator.comparing(SampleProductDto::getId)).collect(Collectors.toList())); |
| | | return map; |
| | | } |
| | | |
| | | @Override |
| | | public List<InsProduct> getInsProduct(Integer id, Integer type, String laboratory, HttpServletRequest request) { |
| | | List<InsProduct> insProducts = new ArrayList<>(); |
| | | switch (type) { |
| | | case 0: |
| | | //æ ·å |
| | | insProducts = insSampleMapper.getInsProduct1(id, laboratory); |
| | | if(!insProducts.isEmpty()) { |
| | | boolean flag = false; |
| | | for(InsProduct insProduct : insProducts) { |
| | | if("温度循ç¯".equals(insProduct.getInspectionItem())) { |
| | | flag = true; |
| | | break; |
| | | } |
| | | } |
| | | if(flag) { |
| | | insProducts = insSampleMapper.getInsProduct5(id, laboratory); |
| | | } |
| | | } |
| | | break; |
| | | case 1: |
| | | //å
纤带 |
| | | insProducts = insSampleMapper.getInsProduct2(id, laboratory); |
| | | break; |
| | | case 2: |
| | | //å
纤 |
| | | insProducts = insSampleMapper.getInsProduct3(id, laboratory); |
| | | break; |
| | | case 3: |
| | | //å¥ç®¡ |
| | | insProducts = insSampleMapper.getInsProduct4(id, laboratory); |
| | | break; |
| | | } |
| | | |
| | | //妿æ¯å¤§æ ·åä¸ç项ç®ä¸ºç©º,é£ä¹æ¥è¯¢ç¬¬ä¸ä¸ªå
纤çé¡¹ç® |
| | | if (ObjectUtils.isEmpty(insProducts) && type == 0) { |
| | | //æ¥è¯¢ç¬¬ä¸ä¸ªå
纤çid |
| | | List<InsFiber> insFibers = insFiberMapper.selectList(Wrappers.<InsFiber>lambdaQuery() |
| | | .eq(InsFiber::getInsBushingId, insBushingMapper.selectList(Wrappers.<InsBushing>lambdaQuery() |
| | | .eq(InsBushing::getInsSampleId, id) |
| | | .isNotNull(InsBushing::getStandNum) |
| | | .isNotNull(InsBushing::getTestNum)).get(0).getId())); |
| | | if(CollectionUtils.isNotEmpty(insFibers)) { |
| | | insProducts = insSampleMapper.getInsProduct3(insFibers.get(0).getId(),laboratory); |
| | | } |
| | | // 妿å
纤ä¸ç项ç®ä¸ºç©º,é£ä¹æ¥è¯¢ç¬¬ä¸ä¸ªå
纤带çé¡¹ç® |
| | | else { |
| | | List<InsFibers> insFibersS = insFibersMapper.selectList(Wrappers.<InsFibers>lambdaQuery() |
| | | .eq(InsFibers::getInsBushingId, insBushingMapper.selectList(Wrappers.<InsBushing>lambdaQuery() |
| | | .eq(InsBushing::getInsSampleId, id) |
| | | .isNotNull(InsBushing::getTestNum) |
| | | ).get(0).getId())); |
| | | //妿å
纤带ä¸ä¸ºç©ºï¼æ¥è¯¢å
çº¤å¸¦ä¸æ¯å¦é
æå
纤 |
| | | if(!insFibersS.isEmpty()){ |
| | | List<InsFiber> insFiberList = insFiberMapper.selectList(Wrappers.<InsFiber>lambdaQuery().eq(InsFiber::getInsFibersId, insFibersS.get(0).getId())); |
| | | if(!insFiberList.isEmpty()){ |
| | | insProducts = insSampleMapper.getInsProduct3(insFiberList.get(0).getId(),laboratory); |
| | | }else{ |
| | | insProducts = insSampleMapper.getInsProduct6(insFibersS.get(0).getId(),laboratory); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | Set<Integer> set = new HashSet<>(); |
| | | Map<Integer, String> map2 = new HashMap<>(); |
| | | if (BeanUtil.isEmpty(insProducts)) return null; |
| | | getTemplateThing(set, map2, insProducts); |
| | | return insProducts; |
| | | } |
| | | |
| | | @Override |
| | | public List<String> checkSubmitPlan(Integer orderId, String laboratory,String temperature,String humidity) { |
| | | List<String> collect = new ArrayList<>(); |
| | | List<InsSample> insSamples = insSampleMapper.selectList(Wrappers.<InsSample>lambdaQuery().eq(InsSample::getInsOrderId, orderId).select(InsSample::getId)); |
| | | List<Integer> ids = insSamples.stream().map(InsSample::getId).collect(Collectors.toList()); |
| | | List<InsProduct> insProducts = insProductMapper.selectList(Wrappers.<InsProduct>lambdaQuery() |
| | | .in(InsProduct::getInsSampleId, ids) |
| | | .eq(InsProduct::getSonLaboratory, laboratory) |
| | | .eq(InsProduct::getState, 1) |
| | | .eq(InsProduct::getInsResult, 0)); |
| | | if (insProducts.size() > 0) { |
| | | collect = insProducts.stream().map(insProduct -> { |
| | | return insProduct.getInspectionItem() + "-" + insProduct.getInspectionItemSubclass(); |
| | | }).collect(Collectors.toList()); |
| | | insProductMapper.update(null,new LambdaUpdateWrapper<InsProduct>() |
| | | .set(InsProduct::getTemperature,temperature) |
| | | .set(InsProduct::getHumidity,humidity) |
| | | .in(InsProduct::getInsSampleId,ids)); |
| | | } |
| | | return collect; |
| | | } |
| | | |
| | | @Override |
| | | 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; |
| | | } |
| | | |
| | | @Override |
| | | public int uploadFile(Integer orderId, MultipartFile file) { |
| | | String urlString; |
| | | String pathName; |
| | | String path; |
| | | String filename = file.getOriginalFilename(); |
| | | String contentType = file.getContentType(); |
| | | InsOrderFile insOrderFile = new InsOrderFile(); |
| | | insOrderFile.setInsOrderId(orderId); |
| | | insOrderFile.setFileName(filename); |
| | | if (contentType != null && contentType.startsWith("image/")) { |
| | | // æ¯å¾ç |
| | | path = imgUrl; |
| | | insOrderFile.setType(1); |
| | | } else { |
| | | // æ¯æä»¶ |
| | | path = wordUrl; |
| | | insOrderFile.setType(2); |
| | | } |
| | | try { |
| | | File realpath = new File(path); |
| | | if (!realpath.exists()) { |
| | | realpath.mkdirs(); |
| | | } |
| | | pathName = UUID.randomUUID() + "_" + file.getOriginalFilename(); |
| | | urlString = realpath + "/" + pathName; |
| | | file.transferTo(new File(urlString)); |
| | | insOrderFile.setFileUrl(pathName); |
| | | return insOrderFileMapper.insert(insOrderFile); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | System.err.println("éä»¶ä¸ä¼ é误"); |
| | | return 0; |
| | | } |
| | | } |
| | | |
| | | //åæ¢è®°å½æ¨¡çæ¥è¯¢æ£éªå
容 |
| | | @Override |
| | | public Map<String, Object> getReportModel(Integer sampleId, String sonLaboratory) { |
| | | Map<String, Object> map = new HashMap<>(); |
| | | //å
æ¥åºå¥ç®¡ |
| | | List<InsBushing> insBushings = insBushingMapper.selectList(Wrappers.<InsBushing>lambdaQuery().eq(InsBushing::getInsSampleId, sampleId)); |
| | | List<InsFibersVO> fibers = new ArrayList<>(); |
| | | List<InsFiber> fiber = new ArrayList<>(); |
| | | List<InsBushing> bush = new ArrayList<>(); |
| | | for (InsBushing insBushing : insBushings) { |
| | | //ä¿åå¥ç®¡(æ¾å¥ç®¡) |
| | | List<InsProduct> insProductsByBush = insProductMapper.selectList(Wrappers.<InsProduct>lambdaQuery() |
| | | .eq(InsProduct::getInsBushId, insBushing.getId()) |
| | | .eq(InsProduct::getSonLaboratory,sonLaboratory) |
| | | .eq(InsProduct::getState,1) |
| | | .and(i->i.like(InsProduct::getInspectionItem,"æ¾å¥ç®¡") |
| | | .or() |
| | | .like(InsProduct::getInspectionItemSubclass,"æ¾å¥ç®¡")) |
| | | ); |
| | | List<Integer> collectByBush = insProductsByBush.stream() |
| | | .map(InsProduct::getInsResult) |
| | | .filter(sm -> ObjectUtils.isNotEmpty(sm) && sm != 2).collect(Collectors.toList()); |
| | | //1ï¼å·²æ£éªï¼0ï¼æªæ£éª,2:卿£ |
| | | int bushState = 0; |
| | | if(insProductsByBush.size() == collectByBush.size()){ |
| | | bushState = 1; |
| | | }else if(!collectByBush.isEmpty() && collectByBush.size()<insProductsByBush.size()){ |
| | | bushState = 2; |
| | | } |
| | | insBushing.setState(bushState); |
| | | if(!insProductsByBush.isEmpty()){ |
| | | bush.add(insBushing); |
| | | } |
| | | //åæ¥è¯¢åºææçå
纤带 |
| | | List<InsFibers> insFibers = insFibersMapper.selectList(Wrappers.<InsFibers>lambdaQuery().eq(InsFibers::getInsBushingId, insBushing.getId())); |
| | | |
| | | List<InsFiber> insFiberList = insFiberMapper.selectList(Wrappers.<InsFiber>lambdaQuery().eq(InsFiber::getInsBushingId, insBushing.getId())); |
| | | if (CollectionUtils.isNotEmpty(insFibers)) { |
| | | for (InsFibers insFiberS : insFibers) { |
| | | //æ¥è¯¢å
纤带ä¸çå
纤é
ç½® |
| | | List<InsFiber> fiberList = insFiberMapper.selectList(Wrappers.<InsFiber>lambdaQuery().eq(InsFiber::getInsFibersId, insFiberS.getId())); |
| | | if(fiberList.isEmpty()){ |
| | | List<InsProduct> insProducts = insProductMapper.selectList(Wrappers.<InsProduct>lambdaQuery() |
| | | .eq(InsProduct::getState,1) |
| | | .eq(InsProduct::getSonLaboratory,sonLaboratory) |
| | | .eq(InsProduct::getInsFibersId, insFiberS.getId())); |
| | | // è¿æ»¤å
纤æ¥å¤´æè |
| | | if(CollectionUtils.isNotEmpty(insProducts)) { |
| | | insProducts = insProducts.stream().filter(item -> !item.getInspectionItem().equals("å
纤æ¥å¤´æè")).collect(Collectors.toList()); |
| | | } |
| | | //设置å¥ç®¡çæ£éªç¶æ |
| | | insFiberS.setState(getInsState(insProducts)); |
| | | InsFibersVO insFibersVO = new InsFibersVO(); |
| | | BeanUtil.copyProperties(insFiberS,insFibersVO); |
| | | insFibersVO.setIsExistProduct(!insProducts.isEmpty());//æ¯å¦å卿£éªé¡¹ |
| | | insFibersVO.setBushingColor(insBushing.getColor()); |
| | | //妿å
纤带ä¸çé¡¹ç®æ²¡æå
纤æ¥å¤´æè项ç®ï¼ææ·»å å
çº¤å¸¦ä¿¡æ¯ |
| | | if(CollectionUtils.isNotEmpty(insProducts)) { |
| | | fibers.add(insFibersVO); |
| | | } |
| | | }else{ |
| | | InsFibersVO insFibersVO = new InsFibersVO(); |
| | | BeanUtil.copyProperties(insFiberS,insFibersVO); |
| | | insFibersVO.setBushingColor(insBushing.getColor()); |
| | | //æ¥è¯¢å
纤带ä¸çæ£éªé¡¹ |
| | | List<InsProduct> fibersProducts = insProductMapper.selectList(Wrappers.<InsProduct>lambdaQuery() |
| | | .eq(InsProduct::getState,1) |
| | | .eq(InsProduct::getSonLaboratory,sonLaboratory) |
| | | .eq(InsProduct::getInsFibersId, insFiberS.getId())); |
| | | insFibersVO.setIsExistProduct(!fibersProducts.isEmpty());//æ¯å¦å卿£éªé¡¹ |
| | | if(!fibersProducts.isEmpty()){ |
| | | //设置å
çº¤å¸¦è²æ çæ£éªç¶æ |
| | | insFibersVO.setState(getInsState(fibersProducts)); |
| | | } |
| | | //æ·»å å
çº¤å¸¦ä¿¡æ¯ |
| | | fibers.add(insFibersVO); |
| | | for (InsFiber insFiber : fiberList) { |
| | | List<InsProduct> insProducts = insProductMapper.selectList(Wrappers.<InsProduct>lambdaQuery() |
| | | .eq(InsProduct::getState,1) |
| | | .eq(InsProduct::getSonLaboratory,sonLaboratory) |
| | | .eq(InsProduct::getInsFiberId, insFiber.getId())); |
| | | // è¿æ»¤å
纤æ¥å¤´æè |
| | | if(CollectionUtils.isNotEmpty(insProducts)) { |
| | | insProducts = insProducts.stream().filter(item -> !item.getInspectionItem().equals("å
纤æ¥å¤´æè")).collect(Collectors.toList()); |
| | | } |
| | | //设置å
çº¤è²æ çæ£éªç¶æ |
| | | insFiber.setState(getInsState(insProducts)); |
| | | //妿å
纤ä¸çé¡¹ç®æ²¡æå
纤æ¥å¤´æè项ç®ï¼ææ·»å å
çº¤ä¿¡æ¯ |
| | | if(CollectionUtils.isNotEmpty(insProducts)) { |
| | | fiber.add(insFiber); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | //妿å¥ç®¡ä¸æ²¡æå
çº¤å¸¦å°±åªæå
çº¤äº |
| | | else if (CollectionUtils.isNotEmpty(insFiberList)) { |
| | | for (InsFiber insFiber : insFiberList) { |
| | | List<InsProduct> insProducts = insProductMapper.selectList(Wrappers.<InsProduct>lambdaQuery() |
| | | .eq(InsProduct::getState,1) |
| | | .eq(InsProduct::getSonLaboratory,sonLaboratory) |
| | | .eq(InsProduct::getInsFiberId, insFiber.getId())); |
| | | // è¿æ»¤å
纤æ¥å¤´æè |
| | | if(CollectionUtils.isNotEmpty(insProducts)) { |
| | | insProducts = insProducts.stream().filter(item -> !item.getInspectionItem().equals("å
纤æ¥å¤´æè")).collect(Collectors.toList()); |
| | | } |
| | | //设置å
çº¤è²æ çæ£éªç¶æ |
| | | insFiber.setState(getInsState(insProducts)); |
| | | if(CollectionUtils.isNotEmpty(insProducts)){ |
| | | fiber.add(insFiber); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | map.put("å
纤带", fibers); |
| | | map.put("å
纤", fiber); |
| | | map.put("å¥ç®¡", bush); |
| | | return map; |
| | | } |
| | | |
| | | /** |
| | | * 夿æ£éªé¡¹æ¯å¦æ£æµå®ï¼è¿åæ£æµç¶æ |
| | | * @param insProducts |
| | | * @return |
| | | */ |
| | | private Integer getInsState(List<InsProduct> insProducts){ |
| | | List<Integer> collect = insProducts.stream().map(InsProduct::getInsResult) |
| | | .filter(sm -> ObjectUtils.isNotEmpty(sm) && sm != 2).collect(Collectors.toList()); |
| | | if (insProducts.size() == collect.size()) { |
| | | return 1;//å·²æ£éª |
| | | } else if(!collect.isEmpty() && collect.size()<insProducts.size()){ |
| | | return 2;//卿£éª |
| | | } |
| | | return 0;//æªæ£éª |
| | | } |
| | | |
| | | //æ¸©åº¦å¾ªç¯æ¥çåè¡¨æ°æ®(å
æ¬éè¿æ ·åid,å¾ªç¯æ¬¡æ°,温度,å¾ªç¯æ¬¡æ°è¿è¡çé) |
| | | @Override |
| | | public Map<String, Object> temCycle(Integer sampleId, String inspectionItem, String inspectionItemSubclass) { |
| | | Map<String, Object> map = new HashMap<>(); |
| | | //æ ·åä¿¡æ¯ |
| | | SampleVo sampleVo = insSampleMapper.getDetailById(sampleId); |
| | | map.put("sampleVo", sampleVo); |
| | | List<ProductVo> productVos = new ArrayList<>(); |
| | | //å
æ¥åºè¿ä¸ªæ ·å䏿åªäºç®¡è²æ ,å
纤带,å
çº¤è²æ |
| | | //å
æ¥åºå¥ç®¡ |
| | | List<InsBushing> insBushings = insBushingMapper.selectList(Wrappers.<InsBushing>lambdaQuery().eq(InsBushing::getInsSampleId, sampleId)); |
| | | if (insBushings.size() > 0) { |
| | | //éä¿¡--æ¸©åº¦å¾ªç¯ |
| | | for (InsBushing insBushing : insBushings) { |
| | | //åæ¥è¯¢åºææçå
纤带 |
| | | List<InsFibers> insFibers = insFibersMapper.selectList(Wrappers.<InsFibers>lambdaQuery().eq(InsFibers::getInsBushingId, insBushing.getId())); |
| | | if (CollectionUtils.isNotEmpty(insFibers)) { |
| | | for (InsFibers insFiber : insFibers) { |
| | | //æ¥åºå
çº¤å¸¦ä¸ææçå
纤 |
| | | List<InsFiber> fiberList = insFiberMapper.selectList(Wrappers.<InsFiber>lambdaQuery().eq(InsFiber::getInsFibersId, insFiber.getId())); |
| | | for (InsFiber fiber : fiberList) { |
| | | //åæ ¹æ®å
³èçå
纤é
ç½®çidåå¾ªç¯æ¬¡æ°åæ¸©åº¦åæ ·åidè¿è¡æ¥è¯¢æ£éªé¡¹ç® |
| | | List<InsProduct> insProducts = insProductMapper.selectList(Wrappers.<InsProduct>lambdaQuery() |
| | | .eq(InsProduct::getInsSampleId, sampleId) |
| | | .eq(InsProduct::getInspectionItem, inspectionItem) |
| | | .eq(InsProduct::getInspectionItemSubclass, inspectionItemSubclass) |
| | | .eq(InsProduct::getInsFiberId, fiber.getId())); |
| | | for (InsProduct insProduct : insProducts) { |
| | | InsProductResult insProductResult = insProductResultMapper.selectOne(Wrappers.<InsProductResult>lambdaQuery() |
| | | .eq(InsProductResult::getInsProductId, insProduct.getId())); |
| | | ProductVo productVo = new ProductVo(); |
| | | productVo.setCode(insFiber.getCode()); |
| | | productVo.setColor(fiber.getColor()); |
| | | productVo.setBushColor(insBushing.getColor()); |
| | | if (ObjectUtils.isNotEmpty(insProductResult)) { |
| | | insProduct.setInsProductResult(insProductResult); |
| | | } |
| | | //æ±åçæ¡ä»¶ä¸1次循ç¯20度常温ç计ç®å¼ |
| | | InsProductResult insProductResult1 = insProductResultMapper.selectOne(Wrappers.<InsProductResult>lambdaQuery().eq(InsProductResult::getInsProductId, insProductMapper.selectOne(Wrappers.<InsProduct>lambdaQuery() |
| | | .eq(InsProduct::getInsSampleId, sampleId) |
| | | .eq(InsProduct::getInspectionItem, "1") |
| | | .eq(InsProduct::getInspectionItemSubclass, "20â(常温)") |
| | | .eq(InsProduct::getInspectionItemClass, insProduct.getInspectionItemClass()) |
| | | .eq(InsProduct::getInsFiberId, fiber.getId())).getId())); |
| | | if (ObjectUtils.isNotEmpty(insProductResult1) && !insProductResult1.getComValue().equals("[]")) { |
| | | String[] splitStr = insProductResult1.getComValue().split(":"); |
| | | insProduct.setComplue(splitStr[splitStr.length-1].split("\"")[1]); |
| | | } |
| | | productVo.setInsProduct(insProduct); |
| | | productVos.add(productVo); |
| | | } |
| | | } |
| | | } |
| | | } else { |
| | | //妿å¥ç®¡ä¸æ²¡æå
çº¤å¸¦å°±åªæå
çº¤äº |
| | | List<InsFiber> insFiberList = insFiberMapper.selectList(Wrappers.<InsFiber>lambdaQuery().eq(InsFiber::getInsBushingId, insBushing.getId())); |
| | | for (InsFiber fiber : insFiberList) { |
| | | //åæ ¹æ®å
³èçå
纤é
ç½®çidåå¾ªç¯æ¬¡æ°åæ¸©åº¦åæ ·åidè¿è¡æ¥è¯¢æ£éªé¡¹ç® |
| | | List<InsProduct> insProducts = insProductMapper.selectList(Wrappers.<InsProduct>lambdaQuery() |
| | | .eq(InsProduct::getInsSampleId, sampleId) |
| | | .eq(InsProduct::getInspectionItem, inspectionItem) |
| | | .eq(InsProduct::getInspectionItemSubclass, inspectionItemSubclass) |
| | | .eq(InsProduct::getInsFiberId, fiber.getId())); |
| | | for (InsProduct insProduct : insProducts) { |
| | | InsProductResult insProductResult = insProductResultMapper.selectOne(Wrappers.<InsProductResult>lambdaQuery().eq(InsProductResult::getInsProductId, insProduct.getId())); |
| | | ProductVo productVo = new ProductVo(); |
| | | productVo.setCode("-"); |
| | | productVo.setColor(fiber.getColor()); |
| | | productVo.setBushColor(fiber.getBushColor()); |
| | | insProduct.setInsProductResult(insProductResult); |
| | | //æ±åçæ¡ä»¶ä¸1次循ç¯20度常温ç计ç®å¼ |
| | | InsProductResult insProductResult1 = insProductResultMapper.selectOne(Wrappers.<InsProductResult>lambdaQuery().eq(InsProductResult::getInsProductId, insProductMapper.selectOne(Wrappers.<InsProduct>lambdaQuery() |
| | | .eq(InsProduct::getInsSampleId, sampleId) |
| | | .eq(InsProduct::getInspectionItem, "1") |
| | | .eq(InsProduct::getInspectionItemSubclass, "20â(常温)") |
| | | .eq(InsProduct::getInspectionItemClass, insProduct.getInspectionItemClass()) |
| | | .eq(InsProduct::getInsFiberId, fiber.getId())).getId())); |
| | | if (ObjectUtils.isNotEmpty(insProductResult1) && !insProductResult1.getComValue().equals("[]")) { |
| | | String[] splitStr = insProductResult1.getComValue().split(":"); |
| | | insProduct.setComplue(splitStr[splitStr.length-1].split("\"")[1]); |
| | | } |
| | | productVo.setInsProduct(insProduct); |
| | | productVos.add(productVo); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | productVos = productVos.stream().sorted(Comparator.comparing(productVo -> productVo.getInsProduct().getInspectionItemClass())).collect(Collectors.toList()); |
| | | } else { |
| | | //çµå--ç循ç¯å温åè¯éª |
| | | List<InsProduct> insProducts = insProductMapper.selectList(Wrappers.<InsProduct>lambdaQuery() |
| | | .eq(InsProduct::getInsSampleId, sampleId) |
| | | .eq(InsProduct::getInspectionItem, inspectionItem)); |
| | | for (InsProduct insProduct : insProducts) { |
| | | InsProductResult insProductResult = insProductResultMapper.selectOne(Wrappers.<InsProductResult>lambdaQuery().eq(InsProductResult::getInsProductId, insProduct.getId())); |
| | | ProductVo productVo = new ProductVo(); |
| | | if (ObjectUtils.isNotEmpty(insProductResult)) { |
| | | insProduct.setInsProductResult(insProductResult); |
| | | } |
| | | productVo.setInsProduct(insProduct); |
| | | productVos.add(productVo); |
| | | } |
| | | } |
| | | map.put("productVos", productVos); |
| | | return map; |
| | | } |
| | | |
| | | @Override |
| | | public List<String> upPlanUser2(Integer orderId) { |
| | | List<Integer> sampleId = insSampleMapper.selectList(Wrappers.<InsSample>lambdaQuery().eq(InsSample::getInsOrderId, orderId)).stream().map(InsSample::getId).collect(Collectors.toList()); |
| | | List<String> sonLaboratory = insProductMapper.selectList(Wrappers.<InsProduct>lambdaQuery().eq(InsProduct::getState, 1).in(InsProduct::getInsSampleId, sampleId)).stream().map(InsProduct::getSonLaboratory).distinct().collect(Collectors.toList()); |
| | | return sonLaboratory; |
| | | } |
| | | |
| | | @Override |
| | | public Map<String, Object> getSagTemperatureProducts(Integer sampleId) { |
| | | Map<String, Object> map = new HashMap<>(); |
| | | //æ ·åä¿¡æ¯ |
| | | SampleVo sampleVo = insSampleMapper.getDetailById(sampleId); |
| | | map.put("sampleVo", sampleVo); |
| | | //çµå:å¼§å-æ¸©åº¦ç¹æ®é¡¹ |
| | | List<ProductVo> productVos = new ArrayList<>(); |
| | | List<InsProduct> insProducts = insProductMapper.findSagTemperatureProducts(sampleId,"å¼§å-温度"); |
| | | for (InsProduct insProduct : insProducts) { |
| | | InsProductResult insProductResult = insProductResultMapper.selectOne(Wrappers.<InsProductResult>lambdaQuery().eq(InsProductResult::getInsProductId, insProduct.getId())); |
| | | ProductVo productVo = new ProductVo(); |
| | | if (ObjectUtils.isNotEmpty(insProductResult)) { |
| | | insProduct.setInsProductResult(insProductResult); |
| | | } |
| | | productVo.setInsProduct(insProduct); |
| | | productVos.add(productVo); |
| | | } |
| | | map.put("productVos", productVos); |
| | | return map; |
| | | } |
| | | |
| | | @Override |
| | | public Map<String, Object> getSampleInfoByOrderId(Integer orderId,String sonLaboratory) { |
| | | Map<String, Object> map = new HashMap<>(); |
| | | if(!Objects.isNull(orderId)){ |
| | | //æ£éªå
容对象 |
| | | List<InsProductVO> insProductVOS = insProductMapper.selectProductByOrderId(orderId,sonLaboratory); |
| | | //æ ¹æ®æ ·åidåç» |
| | | Map<Integer, List<InsProductVO>> groupMap = insProductVOS.stream().collect(Collectors.groupingBy(InsProductVO::getSampleId)); |
| | | List<InsProductVO> sampleList = new ArrayList<>(); |
| | | for (Integer key : groupMap.keySet()) { |
| | | AtomicInteger insSum = new AtomicInteger(0); |
| | | List<String> inspectNameList = new ArrayList<>(); |
| | | InsProductVO insProductVO = new InsProductVO(); |
| | | groupMap.get(key).forEach(k->{ |
| | | if(StringUtils.isNotBlank(k.getInspectName())){ |
| | | insSum.getAndIncrement(); |
| | | inspectNameList.add(k.getInspectName()); |
| | | } |
| | | insProductVO.setId(k.getSampleId()); |
| | | insProductVO.setSampleCode(k.getSampleCode()); |
| | | }); |
| | | if(CollectionUtils.isEmpty(inspectNameList)){ |
| | | insProductVO.setState(0); |
| | | }else if(inspectNameList.size() < groupMap.get(key).size()){ |
| | | insProductVO.setState(1); |
| | | }else if(inspectNameList.size() == groupMap.get(key).size()){ |
| | | insProductVO.setState(2); |
| | | } |
| | | insProductVO.setInspectName(inspectNameList.stream().distinct().collect(Collectors.joining(","))); |
| | | sampleList.add(insProductVO); |
| | | } |
| | | map.put("insSamples",sampleList); |
| | | map.put("insProductVOS",insProductVOS); |
| | | } |
| | | return map; |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class,isolation = Isolation.READ_COMMITTED) |
| | | public void saveInsContext(Map<String, Object> insContext, Integer currentTable, Integer currentSampleId, Integer orderId, String sonLaboratory, Boolean isDelete) { |
| | | try{ |
| | | if(lock.tryLock(10,TimeUnit.SECONDS)){ |
| | | Integer userId = SecurityUtils.getUserId().intValue(); |
| | | insContext.forEach((k, v) -> { |
| | | JSONObject jo = JSON.parseObject(JSON.toJSONString(v)); |
| | | InsProduct insProduct = new InsProduct(); |
| | | insProduct.setId(Integer.parseInt(k)); |
| | | InsProduct product = insProductMapper.selectById(insProduct.getId()); |
| | | if (currentTable.equals(product.getTemplateId()) && currentSampleId.equals(product.getInsSampleId())) { |
| | | List<InsProductResult> oldResults = insProductResultMapper.selectList(Wrappers.<InsProductResult>lambdaQuery() |
| | | .eq(InsProductResult::getInsProductId, insProduct.getId())); |
| | | |
| | | InsProductResult newResult = new InsProductResult(); |
| | | if (CollectionUtils.isNotEmpty(oldResults)) { |
| | | BeanUtil.copyProperties(oldResults.get(0), newResult); |
| | | } |
| | | newResult.setInsProductId(Integer.parseInt(k)); |
| | | /*æ ¡éªä¸ä¸result表*/ |
| | | if (oldResults.size() > 1) { |
| | | for (int i = 1; i < oldResults.size(); i++) { |
| | | insProductResultMapper.deleteById(oldResults.get(i)); |
| | | } |
| | | } |
| | | // ä¿åçæ°æ®å°æ°ä½æ°å¿
须大äºçäºtellæå¤§çå°æ°ä½æ° |
| | | String tells = product.getTell(); |
| | | Integer digit = null; |
| | | if(StringUtils.isEmpty(tells)) { |
| | | digit = -1; |
| | | }else { |
| | | // æ¾å°å°æ°ä½æ°æå¤çæ°å¼ |
| | | Map<String, Object> stringObjectMap = maxDecimalNumber(tells); |
| | | digit = Integer.parseInt(stringObjectMap.get("maxNumber").toString()); |
| | | } |
| | | if (!Arrays.asList("åºååºå","æ¯å¨ç²å³").contains(product.getInspectionItem())) { |
| | | //æ£éªå¼ |
| | | if (jo.get("insValue") != null) { |
| | | JSONArray jsonArray = JSON.parseArray(JSON.toJSONString(jo.get("insValue"))); |
| | | List<Map<String, Object>> iv = new ArrayList<>(); |
| | | for (Object o : jsonArray) { |
| | | JSONObject insValue = JSON.parseObject(JSON.toJSONString(o)); |
| | | Map<String, Object> map = new HashMap<>(); |
| | | String val = ""; |
| | | if(Objects.nonNull(JSON.parseObject(JSON.toJSONString(insValue.get("v"))).get("v"))){ |
| | | val = JSON.parseObject(JSON.toJSONString(insValue.get("v"))).get("v").toString(); |
| | | } |
| | | // 妿å¯ä»¥è½¬æ¢ä¸ºæ°åï¼å°±è¦è¿è¡ä½æ°çæ¯è¾ |
| | | map.put("v", completion(val, digit)); |
| | | map.put("r", JSON.toJSONString(insValue.get("r"))); |
| | | map.put("c", JSON.toJSONString(insValue.get("c"))); |
| | | map.put("w", insValue.get("w")); |
| | | try { |
| | | if ((insValue.get("u") == null || insValue.get("u").equals("")) && StrUtil.isNotEmpty(val)) { |
| | | map.put("u", userId + ""); |
| | | } else { |
| | | map.put("u", insValue.get("u")); |
| | | } |
| | | iv.add(map); |
| | | } catch (Exception e) { |
| | | } |
| | | } |
| | | newResult.setInsValue(JSON.toJSONString(iv)); |
| | | } |
| | | } |
| | | if (!Arrays.asList("åºååºå","æ¯å¨ç²å³").contains(product.getInspectionItem())) { |
| | | //计ç®å¼ |
| | | if (jo.get("comValue") != null && !Objects.equals(jo.get("comValue"), "")) { |
| | | JSONArray jsonArray2 = JSON.parseArray(JSON.toJSONString(jo.get("comValue"))); |
| | | List<Map<String, Object>> cv = new ArrayList<>(); |
| | | for (Object o : jsonArray2) { |
| | | JSONObject comValue = JSON.parseObject(JSON.toJSONString(o)); |
| | | Map<String, Object> map = new HashMap<>(); |
| | | map.put("r", JSON.toJSONString(comValue.get("r"))); |
| | | map.put("c", JSON.toJSONString(comValue.get("c"))); |
| | | // 妿å¯ä»¥è½¬æ¢ä¸ºæ°åï¼å°±è¦è¿è¡ä½æ°çæ¯è¾ |
| | | map.put("v", completion(JSON.parseObject(JSON.toJSONString(comValue.get("v"))).get("v").toString(), digit)); |
| | | cv.add(map); |
| | | } |
| | | newResult.setComValue(JSON.toJSONString(cv)); |
| | | } |
| | | } |
| | | //æç»å¼ |
| | | try { |
| | | JSONObject resValue = JSON.parseObject(JSON.toJSONString(jo.get("resValue"))); |
| | | if (resValue.get("v") != null) { |
| | | Object o = JSON.parseObject(JSON.toJSONString(resValue.get("v"))).get("v"); |
| | | // 妿å¯ä»¥è½¬æ¢ä¸ºæ°åï¼å°±è¦è¿è¡ä½æ°çæ¯è¾ |
| | | insProduct.setLastValue(completion(o.equals("") ? null : (o.toString()), digit)); |
| | | } |
| | | } catch (Exception e) { |
| | | insProduct.setLastValue("");//'' |
| | | } |
| | | //设å¤ç¼å· |
| | | if (jo.get("equipValue") != null) { |
| | | JSONArray jsonArray2 = JSON.parseArray(JSON.toJSONString(jo.get("equipValue"))); |
| | | List<Map<String, Object>> ev = new ArrayList<>(); |
| | | for (Object o : jsonArray2) { |
| | | JSONObject equipValue = JSON.parseObject(JSON.toJSONString(o)); |
| | | Map<String, Object> map = new HashMap<>(); |
| | | map.put("v", JSON.parseObject(JSON.toJSONString(equipValue.get("v"))).get("v")); |
| | | ev.add(map); |
| | | } |
| | | newResult.setEquipValue(JSON.toJSONString(ev)); |
| | | } |
| | | //设å¤åç§° |
| | | if (jo.get("equipName") != null) { |
| | | JSONArray jsonArray2 = JSON.parseArray(JSON.toJSONString(jo.get("equipName"))); |
| | | List<Map<String, Object>> ev = new ArrayList<>(); |
| | | for (Object o : jsonArray2) { |
| | | JSONObject equipValue = JSON.parseObject(JSON.toJSONString(o)); |
| | | Map<String, Object> map = new HashMap<>(); |
| | | map.put("v", JSON.parseObject(JSON.toJSONString(equipValue.get("v"))).get("v")); |
| | | ev.add(map); |
| | | } |
| | | newResult.setEquipName(JSON.toJSONString(ev)); |
| | | } |
| | | //ç»è®º |
| | | try { |
| | | JSONObject insResult = JSON.parseObject(JSON.toJSONString(jo.get("insResult"))); |
| | | String ir = JSON.parseObject(JSON.toJSONString(insResult.get("v"))).get("v") + ""; |
| | | insProduct.setInsResult(Integer.parseInt(ir)); |
| | | if (product.getInspectionItem().equals("ç循ç¯") || product.getInspectionItem().equals("温åè¯éª")) { |
| | | List<Integer> collect = insProductMapper.selectList(new LambdaQueryWrapper<InsProduct>() |
| | | .eq(InsProduct::getSpecialItemParentId, product.getId())).stream() |
| | | .map(InsProduct::getInsResult) |
| | | .collect(Collectors.toList()); |
| | | if (collect.contains(null)) { |
| | | insProduct.setInsResult(2); |
| | | } else if (collect.contains(0)) { |
| | | insProduct.setInsResult(0); |
| | | } else { |
| | | insProduct.setInsResult(1); |
| | | } |
| | | |
| | | } |
| | | } catch (Exception e) { |
| | | insProduct.setInsResult(2);//å¾
å® |
| | | if (product.getInspectionItem().equals("åºååºå") && product.getInspectionItemSubclass().equals("å¼¹æ§æ¨¡é") |
| | | && Arrays.asList("/", "-").contains(product.getAsk())) { |
| | | insProduct.setInsResult(3);// ä¸å¤å® |
| | | } |
| | | // 妿æ¯å¼§åçç»è®ºä¹æ¹ä¸ºä¸å¤å® |
| | | if(product.getInspectionItem().equals("å¼§å-温度")) { |
| | | insProduct.setInsResult(3);// ä¸å¤å® |
| | | } |
| | | } |
| | | if (Objects.isNull(newResult.getId())) { |
| | | newResult.setCreateUser(userId); |
| | | newResult.setUpdateUser(userId); |
| | | insProductResultMapper.insert(newResult); |
| | | } else { |
| | | newResult.setUpdateUser(userId); |
| | | newResult.setUpdateTime(LocalDateTime.now()); |
| | | insProductResultMapper.updateById(newResult); |
| | | } |
| | | /*妿æ¯ç¬¬ä¸æ¬¡éæ©è®¾å¤ä¿¡æ¯,ä¸è¿æå
¶ä½æ ·å乿åä¸ä¸ªæ£éªé¡¹ç®,é£ä¹æææ ·åç该项ç®é½ç¨è¿ä¸ªè®¾å¤ä¿¡æ¯*/ |
| | | //å
æ¥è¯¢æ¯å¦è¿æå
¶ä½æ ·å |
| | | Integer insSampleId = product.getInsSampleId(); |
| | | List<InsSample> insSamples = insSampleMapper.selectList(Wrappers.<InsSample>lambdaQuery().eq(InsSample::getInsOrderId, insSampleMapper.selectById(insSampleId).getInsOrderId())); |
| | | //妿æå¤ä¸ªæ ·åæè
æ¯ä¸æ¯ééç±»åå°±åä¸ä¸ªè®¾å¤ |
| | | if (insSamples.size() > 1 && !product.getInspectionItemType().equals("1")) { |
| | | //åå¨å
¶ä½æ ·å,æ¥è¯¢æ¯å¦æåä¸ç§æ£éªé¡¹ç® |
| | | for (InsSample sample : insSamples.stream().filter(insSample -> !insSample.getId().equals(insSampleId)).collect(Collectors.toList())) { |
| | | InsProduct product1 = insProductMapper.selectOne(Wrappers.<InsProduct>lambdaQuery() |
| | | .eq(InsProduct::getState, 1) |
| | | .eq(InsProduct::getInsSampleId, sample.getId()) |
| | | .eq(InsProduct::getInspectionItem, product.getInspectionItem()) |
| | | .eq(InsProduct::getInspectionItemEn, product.getInspectionItemEn()) |
| | | .eq(InsProduct::getInspectionItemSubclass, product.getInspectionItemSubclass()) |
| | | .eq(InsProduct::getInspectionItemSubclassEn, product.getInspectionItemSubclassEn()) |
| | | .eq(InsProduct::getTemplateId, product.getTemplateId()) |
| | | .eq(InsProduct::getStandardMethodListId, product.getStandardMethodListId()) |
| | | .eq(InsProduct::getInsBushId, product.getInsBushId()) |
| | | .eq(InsProduct::getInsFibersId, product.getInsFibersId()) |
| | | .eq(InsProduct::getInsFiberId, product.getInsFiberId()) |
| | | ); |
| | | if (ObjectUtils.isNotEmpty(product1)) { |
| | | //妿åå¨é¡¹ç®,æ¥è¯¢æ¯å¦æè¡¨ |
| | | InsProductResult productResult = insProductResultMapper.selectOne(Wrappers.<InsProductResult>lambdaQuery() |
| | | .eq(InsProductResult::getInsProductId, product1.getId())); |
| | | if (ObjectUtils.isEmpty(productResult)) { |
| | | //没æè¡¨æ°å»ºè¡¨ |
| | | productResult = new InsProductResult(); |
| | | productResult.setInsProductId(product1.getId()); |
| | | productResult.setEquipValue(newResult.getEquipValue()); |
| | | productResult.setEquipName(newResult.getEquipValue()); |
| | | productResult.setCreateUser(userId); |
| | | productResult.setUpdateUser(userId); |
| | | insProductResultMapper.insert(productResult); |
| | | } else if (ObjectUtils.isEmpty(productResult.getEquipValue())) { |
| | | //æè¡¨å¤ææ¯å¦æè®¾å¤ |
| | | productResult.setEquipValue(newResult.getEquipValue()); |
| | | productResult.setEquipName(newResult.getEquipValue()); |
| | | productResult.setUpdateUser(userId); |
| | | productResult.setUpdateTime(LocalDateTime.now()); |
| | | insProductResultMapper.updateById(productResult); |
| | | } |
| | | } |
| | | } |
| | | |
| | | } |
| | | insProduct.setUpdateUser(userId); |
| | | insProductMapper.updateById(insProduct); |
| | | // å½åæ ·åæ¯å¦æ¯å
纤é
ç½®çå
纤æ¥å¤´æè |
| | | if ((!Objects.isNull(product.getInsFiberId()) || !Objects.isNull(product.getInsFibersId())) && product.getInspectionItem().equals("å
纤æ¥å¤´æè")) { |
| | | // æ¥æ¾åæ ·åä¸çå
纤æå
纤带çå
纤æ¥å¤´æè |
| | | List<InsProduct> insProducts = insProductMapper.selectList(new LambdaQueryWrapper<InsProduct>() |
| | | .eq(InsProduct::getInsSampleId, product.getInsSampleId()) |
| | | .eq(InsProduct::getInspectionItem, product.getInspectionItem()) |
| | | .eq(InsProduct::getInspectionItemSubclass, product.getInspectionItemSubclass()) |
| | | .and(item -> item |
| | | .isNotNull(InsProduct::getInsFiberId) |
| | | .or() |
| | | .isNotNull(InsProduct::getInsFibersId))); |
| | | // è¦å¤å¶çresult |
| | | InsProductResult copyResult = insProductResultMapper.selectOne(new LambdaQueryWrapper<InsProductResult>() |
| | | .eq(InsProductResult::getInsProductId, product.getId())); |
| | | |
| | | for (InsProduct insProduct1 : insProducts) { |
| | | InsProduct copyInsProduct = insProductMapper.selectById(product.getId()); // å¤å¶çinsProduct |
| | | if (!insProduct1.getId().equals(copyInsProduct.getId())) { |
| | | copyInsProduct.setId(insProduct1.getId()); // å°å¤å¶çinsProductçid设置为被å¤å¶çid |
| | | copyInsProduct.setInsFibersId(insProduct1.getInsFibersId()); // å
纤带id |
| | | copyInsProduct.setInsFiberId(insProduct1.getInsFiberId()); // å
纤id |
| | | copyInsProduct.setInsBushId(insProduct1.getInsBushId()); // å¥ç®¡id |
| | | insProductMapper.updateById(copyInsProduct); |
| | | // èµå¼insProductResult |
| | | InsProductResult insProductResult = insProductResultMapper.selectOne(new LambdaQueryWrapper<InsProductResult>() |
| | | .eq(InsProductResult::getInsProductId, insProduct1.getId())); |
| | | if (Objects.isNull(insProductResult)) { |
| | | copyResult.setId(null); |
| | | copyResult.setInsProductId(insProduct1.getId()); |
| | | insProductResultMapper.insert(copyResult); |
| | | } else { |
| | | copyResult.setId(insProductResult.getId()); |
| | | copyResult.setInsProductId(insProduct1.getId()); |
| | | insProductResultMapper.updateById(copyResult); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | insProductUserMapper.insert(new InsProductUser(null, userId, LocalDateTime.now(), insProduct.getId())); |
| | | |
| | | insProduct = insProductMapper.selectById(insProduct); |
| | | //æ¥è¯¢æ£éªåä¿¡æ¯ |
| | | InsSample insSample = insSampleMapper.selectById(insProduct.getInsSampleId()); |
| | | InsOrder insOrder = insOrderMapper.selectById(insSample.getInsOrderId()); |
| | | //æ¥è¯¢ç¶æ£éªé¡¹ |
| | | InsProduct parentInsProduct; |
| | | if (ObjectUtil.isNotNull(insProduct.getSpecialItemParentId())) { |
| | | parentInsProduct = insProductMapper.selectById(insProduct.getSpecialItemParentId()); |
| | | } else { |
| | | parentInsProduct = null; |
| | | } |
| | | if (!Objects.isNull(parentInsProduct)) { |
| | | if ("温åè¯éª".equals(parentInsProduct.getInspectionItem()) || "ç循ç¯".equals(parentInsProduct.getInspectionItem())) { |
| | | // 温åè¯éªä»¥åç循ç¯çå é¤ |
| | | if (isDelete) { |
| | | String inspectionItem = insProduct.getInspectionItem(); |
| | | List<InsProduct> insProducts = insProductMapper.selectList(new LambdaQueryWrapper<InsProduct>() |
| | | .eq(InsProduct::getSpecialItemParentId, parentInsProduct.getId())) |
| | | .stream() |
| | | .filter(item -> item.getInspectionItem().equals(inspectionItem)).collect(Collectors.toList()); |
| | | for (InsProduct insProduct1 : insProducts) { |
| | | InsProductResult insProductResult = insProductResultMapper.selectOne(new LambdaQueryWrapper<InsProductResult>() |
| | | .eq(InsProductResult::getInsProductId, insProduct1.getId())); |
| | | if (!Objects.isNull(insProductResult)) { |
| | | if (insProductResult.getInsProductId().equals(Integer.parseInt(k))) { |
| | | continue; |
| | | } |
| | | String insValue = insProductResult.getInsValue(); |
| | | List<Map> maps = com.alibaba.fastjson2.JSON.parseArray(insValue, Map.class); |
| | | if (maps.size() > 1) { |
| | | maps.remove(maps.size() - 1); |
| | | insProductResult.setInsValue(com.alibaba.fastjson2.JSON.toJSONString(maps)); |
| | | insProductResultMapper.updateById(insProductResult); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | // 温åè¯éªä»¥åçå¾ªç¯æ¥è¯¢ |
| | | // çå¾ªç¯ææå项 |
| | | List<InsProduct> c = insProductMapper.selectList(new LambdaQueryWrapper<InsProduct>() |
| | | .eq(InsProduct::getSpecialItemParentId, parentInsProduct.getId())); |
| | | //éè¿inspectionItemåç» |
| | | Map<String, List<InsProduct>> collect1 = c.stream().collect(Collectors.groupingBy(InsProduct::getInspectionItem)); |
| | | HashMap<Integer, InsProductResult> map1 = new HashMap<>(); |
| | | Integer maxKey = Integer.MIN_VALUE; |
| | | for (Map.Entry<String, List<InsProduct>> m : collect1.entrySet()) { |
| | | List<InsProduct> thermalCycleCollect = m.getValue(); |
| | | if (!thermalCycleCollect.isEmpty()) { |
| | | for (InsProduct product1 : thermalCycleCollect) { |
| | | InsProductResult insProductResult = insProductResultMapper.selectOne(Wrappers.<InsProductResult>lambdaQuery() |
| | | .eq(InsProductResult::getInsProductId, product1.getId())); |
| | | if (!Objects.isNull(insProductResult)) { |
| | | List<Map> maps = com.alibaba.fastjson2.JSON.parseArray(insProductResult.getInsValue(), Map.class); |
| | | map1.put(maps.size(), insProductResult); |
| | | } |
| | | if (!map1.isEmpty()) { |
| | | for (Map.Entry<Integer, InsProductResult> entry : map1.entrySet()) { |
| | | if (entry.getKey() > maxKey) { |
| | | maxKey = entry.getKey(); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | if (maxKey != Integer.MIN_VALUE) { |
| | | InsProductResult insProductResult = map1.get(maxKey); |
| | | List<Map> maps = com.alibaba.fastjson2.JSON.parseArray(insProductResult.getInsValue(), Map.class); |
| | | maps.get(maps.size() - 1).put("v", "");//æåä¸ä¸ªå¼ä¸ºç©º |
| | | if (maps.get(maps.size() - 1).containsKey("w")) { |
| | | maps.get(maps.size() - 1).put("w", ""); |
| | | } |
| | | for (InsProduct product1 : thermalCycleCollect) { |
| | | InsProductResult insProductResult1 = insProductResultMapper.selectOne(Wrappers.<InsProductResult>lambdaQuery() |
| | | .eq(InsProductResult::getInsProductId, product1.getId())); |
| | | if (!Objects.isNull(insProductResult1)) { |
| | | if (!insProductResult1.getInsProductId().equals(insProductResult.getInsProductId())) { |
| | | List<Map> maps1 = com.alibaba.fastjson2.JSON.parseArray(insProductResult1.getInsValue(), Map.class); |
| | | if (maps1.size() < maxKey) { |
| | | int number = maxKey - maps1.size(); |
| | | for (int i = 0; i < number; i++) { |
| | | maps1.add(maps.get(maps.size() - 1)); |
| | | } |
| | | insProductResult1.setInsValue(com.alibaba.fastjson2.JSON.toJSONString(maps1)); |
| | | insProductResultMapper.updateById(insProductResult1); |
| | | } |
| | | } |
| | | } else { |
| | | if (maxKey != Integer.MIN_VALUE) { |
| | | InsProductResult insProductResult2 = map1.get(maxKey); |
| | | List<Map> maps1 = com.alibaba.fastjson2.JSON.parseArray(insProductResult2.getInsValue(), Map.class); |
| | | for (Map map : maps1) { |
| | | map.put("v", ""); |
| | | if (map.containsKey("w")) { |
| | | map.put("w", ""); |
| | | } |
| | | } |
| | | insProductResult2.setInsValue(com.alibaba.fastjson2.JSON.toJSONString(maps1)); |
| | | insProductResult2.setId(null); |
| | | insProductResult2.setInsProductId(product1.getId()); |
| | | insProductResultMapper.insert(insProductResult2); |
| | | } |
| | | } |
| | | } |
| | | maxKey = Integer.MIN_VALUE; |
| | | map1.clear(); |
| | | } |
| | | } |
| | | } |
| | | // 妿æ¯å¯¼çº¿æ¸©åº¦ç弿´æ°ï¼é£ä¹å°±è¦å¤æèå¼ åæ¥ç»æ¯å¦åæ ¼ |
| | | InsProduct insProduct1 = insProductMapper.selectById(Integer.parseInt(k)); |
| | | if (insProduct1.getInspectionItemSubclass().equals("导线温度")) { |
| | | // æ ¹æ®ç¶id以忣éªé¡¹æ¥æ¥æ¾åä¸å¾ªç¯ä¸çèå¼ åæ¥ç» |
| | | List<InsProduct> insProducts2 = insProductMapper.selectList(new LambdaQueryWrapper<InsProduct>() |
| | | .eq(InsProduct::getSpecialItemParentId, parentInsProduct.getId()) |
| | | .eq(InsProduct::getInspectionItem, insProduct1.getInspectionItem())); |
| | | List<Double> wire = new ArrayList<>(); // 导线温度çå¼ |
| | | List<Double> strain = new ArrayList<>(); // èå¼ çå¼ |
| | | List<Double> joint = new ArrayList<>(); // æ¥ç»çå¼ |
| | | |
| | | boolean strainFlag = true; // èå¼ æ¯å¦åæ ¼ |
| | | boolean jointFlag = true; // æ¥ç»æ¯å¦åæ ¼ |
| | | boolean strainPending = false; // æ¯å¦æå¾
å® |
| | | boolean jointPending = false; // æ¯å¦æå¾
å® |
| | | for (InsProduct insProduct2 : insProducts2) { |
| | | if (insProduct2.getInspectionItemSubclass().equals("导线温度")) { |
| | | String insValue = ""; |
| | | InsProductResult insProductResult = insProductResultMapper.selectOne(new LambdaQueryWrapper<InsProductResult>() |
| | | .eq(InsProductResult::getInsProductId, insProduct2.getId())); |
| | | if (!Objects.isNull(insProductResult)) { |
| | | insValue = insProductResult.getInsValue(); |
| | | List<Map> maps = com.alibaba.fastjson2.JSON.parseArray(insValue, Map.class); |
| | | if (maps.size() > 0) { |
| | | for (Map map : maps) { |
| | | if (Strings.isNotEmpty(map.get("v").toString())) { |
| | | wire.add(Double.parseDouble(map.get("v").toString())); |
| | | } else { |
| | | wire.add(-1.0); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | if (insProduct2.getInspectionItemSubclass().equals("èå¼ æ¸©åº¦")) { |
| | | String insValue = ""; |
| | | InsProductResult insProductResult = insProductResultMapper.selectOne(new LambdaQueryWrapper<InsProductResult>() |
| | | .eq(InsProductResult::getInsProductId, insProduct2.getId())); |
| | | if (!Objects.isNull(insProductResult)) { |
| | | insValue = insProductResult.getInsValue(); |
| | | List<Map> maps = com.alibaba.fastjson2.JSON.parseArray(insValue, Map.class); |
| | | if (maps.size() > 0) { |
| | | for (Map map : maps) { |
| | | if (Strings.isNotEmpty(map.get("v").toString())) { |
| | | strain.add(Double.parseDouble(map.get("v").toString())); |
| | | } else { |
| | | strain.add(-1.0); |
| | | } |
| | | } |
| | | } |
| | | } else { |
| | | strain.add(-1.0); |
| | | } |
| | | } |
| | | if (insProduct2.getInspectionItemSubclass().equals("æ¥ç»æ¸©åº¦")) { |
| | | String insValue = ""; |
| | | InsProductResult insProductResult = insProductResultMapper.selectOne(new LambdaQueryWrapper<InsProductResult>() |
| | | .eq(InsProductResult::getInsProductId, insProduct2.getId())); |
| | | if (!Objects.isNull(insProductResult)) { |
| | | insValue = insProductResult.getInsValue(); |
| | | List<Map> maps = com.alibaba.fastjson2.JSON.parseArray(insValue, Map.class); |
| | | if (maps.size() > 0) { |
| | | for (Map map : maps) { |
| | | if (Strings.isNotEmpty(map.get("v").toString())) { |
| | | joint.add(Double.parseDouble(map.get("v").toString())); |
| | | } else { |
| | | joint.add(-1.0); |
| | | } |
| | | } |
| | | } |
| | | } else { |
| | | joint.add(-1.0); |
| | | } |
| | | } |
| | | } |
| | | // å¦æå¯¼çº¿æ¸©åº¦çå¼å¤§äºèå¼ åæ¥ç»çå¼ï¼é£ä¹å°±æ¯åæ ¼ |
| | | if (!strain.isEmpty() && !wire.isEmpty() && (strain.size() == wire.size())) { |
| | | if (wire.contains(-1.0) || strain.contains(-1.0)) { |
| | | insProductMapper.update(null, new LambdaUpdateWrapper<InsProduct>() |
| | | .set(InsProduct::getInsResult, 2) |
| | | .eq(InsProduct::getSpecialItemParentId, parentInsProduct.getId()) |
| | | .eq(InsProduct::getInspectionItem, insProduct1.getInspectionItem()) |
| | | .eq(InsProduct::getInspectionItemSubclass, "èå¼ æ¸©åº¦")); |
| | | strainPending = true; |
| | | } else { |
| | | for (int i = 0; i < wire.size(); i++) { |
| | | if (wire.get(i) <= strain.get(i)) { |
| | | strainFlag = false; |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | if (joint.size() > 0 && wire.size() > 0 && (joint.size() == wire.size())) { |
| | | if (wire.contains(-1.0) || joint.contains(-1.0)) { |
| | | insProductMapper.update(null, new LambdaUpdateWrapper<InsProduct>() |
| | | .set(InsProduct::getInsResult, 2) |
| | | .eq(InsProduct::getSpecialItemParentId, parentInsProduct.getId()) |
| | | .eq(InsProduct::getInspectionItem, insProduct1.getInspectionItem()) |
| | | .eq(InsProduct::getInspectionItemSubclass, "æ¥ç»æ¸©åº¦")); |
| | | jointPending = true; |
| | | } else { |
| | | for (int i = 0; i < wire.size(); i++) { |
| | | if (wire.get(i) <= joint.get(i)) { |
| | | jointFlag = false; |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | if (!strainPending) { |
| | | if (strainFlag) { |
| | | insProductMapper.update(null, new LambdaUpdateWrapper<InsProduct>() |
| | | .set(InsProduct::getInsResult, 1) |
| | | .eq(InsProduct::getSpecialItemParentId, parentInsProduct.getId()) |
| | | .eq(InsProduct::getInspectionItem, insProduct1.getInspectionItem()) |
| | | .eq(InsProduct::getInspectionItemSubclass, "èå¼ æ¸©åº¦")); |
| | | } else { |
| | | insProductMapper.update(null, new LambdaUpdateWrapper<InsProduct>() |
| | | .set(InsProduct::getInsResult, 0) |
| | | .eq(InsProduct::getSpecialItemParentId, parentInsProduct.getId()) |
| | | .eq(InsProduct::getInspectionItem, insProduct1.getInspectionItem()) |
| | | .eq(InsProduct::getInspectionItemSubclass, "èå¼ æ¸©åº¦")); |
| | | } |
| | | } |
| | | if (!jointPending) { |
| | | if (jointFlag) { |
| | | insProductMapper.update(null, new LambdaUpdateWrapper<InsProduct>() |
| | | .set(InsProduct::getInsResult, 1) |
| | | .eq(InsProduct::getSpecialItemParentId, parentInsProduct.getId()) |
| | | .eq(InsProduct::getInspectionItem, insProduct1.getInspectionItem()) |
| | | .eq(InsProduct::getInspectionItemSubclass, "æ¥ç»æ¸©åº¦")); |
| | | } else { |
| | | insProductMapper.update(null, new LambdaUpdateWrapper<InsProduct>() |
| | | .set(InsProduct::getInsResult, 0) |
| | | .eq(InsProduct::getSpecialItemParentId, parentInsProduct.getId()) |
| | | .eq(InsProduct::getInspectionItem, insProduct1.getInspectionItem()) |
| | | .eq(InsProduct::getInspectionItemSubclass, "æ¥ç»æ¸©åº¦")); |
| | | } |
| | | } |
| | | } |
| | | // æ¥æ¾æ¯å¦ææªæ£æµçæ¬¡æ° |
| | | List<Integer> insResult = Arrays.asList(0, 1, 3); |
| | | List<InsProduct> insProducts = insProductMapper.selectList(new LambdaQueryWrapper<InsProduct>() |
| | | .eq(InsProduct::getSpecialItemParentId, parentInsProduct.getId()) |
| | | .and(w -> w.notIn(InsProduct::getInsResult, insResult) |
| | | .or() |
| | | .isNull(InsProduct::getInsResult))); |
| | | if (insProducts.isEmpty()) { |
| | | List<InsProduct> insProducts1 = insProductMapper.selectList(new LambdaQueryWrapper<InsProduct>() |
| | | .eq(InsProduct::getSpecialItemParentId, parentInsProduct.getId()) |
| | | .eq(InsProduct::getInsResult, 0)); |
| | | if (!insProducts1.isEmpty()) { |
| | | insProductMapper.update(null, new LambdaUpdateWrapper<InsProduct>() |
| | | .set(InsProduct::getInsResult, 0) |
| | | .eq(InsProduct::getId, parentInsProduct.getId())); |
| | | } else { |
| | | insProductMapper.update(null, new LambdaUpdateWrapper<InsProduct>() |
| | | .set(InsProduct::getInsResult, 1) |
| | | .eq(InsProduct::getId, parentInsProduct.getId())); |
| | | } |
| | | |
| | | } |
| | | } |
| | | } |
| | | //æ·»å å·¥æ¶è®°å½ |
| | | InsProduct finalInsProduct = insProduct; |
| | | WorkTimeDTO workTimeDTO = new WorkTimeDTO(userId, insOrder, insSample, finalInsProduct, parentInsProduct, currentSampleId, k, oldResults, newResult); |
| | | String jsonStr; |
| | | try { |
| | | jsonStr = JackSonUtil.marshal(workTimeDTO); |
| | | } catch (Exception e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | String routerKey; |
| | | switch (sonLaboratory){ |
| | | case "ææè¯éªå®¤": |
| | | routerKey = RouterKeyConstants.CL_KEY; |
| | | break; |
| | | case "æºæ¢°æ§è½è¯éªå®¤": |
| | | routerKey = RouterKeyConstants.JX_KEY; |
| | | break; |
| | | case "çµåè¯éªå®¤": |
| | | routerKey = RouterKeyConstants.DL_KEY; |
| | | break; |
| | | default: |
| | | routerKey = RouterKeyConstants.GX_KEY; |
| | | break; |
| | | } |
| | | sendQueueMessage(ExchangeConstants.WORK_TIME_EXCHANGE,routerKey,jsonStr); |
| | | |
| | | insSample.setInsState(1); |
| | | //æªæ£éªçæ£éªé¡¹æ°é |
| | | Long unInsCount = insProductMapper.selectCount(Wrappers.<InsProduct>lambdaQuery() |
| | | .eq(InsProduct::getInsSampleId, insSample.getId()) |
| | | .and(wrapper -> wrapper |
| | | .isNull(InsProduct::getInsResult) |
| | | .or() |
| | | .eq(InsProduct::getInsResult, 2) |
| | | )); |
| | | if (0 == unInsCount) { |
| | | insSample.setInsState(2); |
| | | } |
| | | insSampleMapper.updateById(insSample); |
| | | /*æ ¡éªä¸ä¸result表*/ |
| | | List<InsProductResult> insProductResults = insProductResultMapper.selectList(Wrappers.<InsProductResult>lambdaQuery() |
| | | .eq(InsProductResult::getInsProductId, insProduct.getId())); |
| | | if (insProductResults.size() > 1) { |
| | | for (int i = 1; i < insProductResults.size(); i++) { |
| | | insProductResultMapper.deleteById(insProductResults.get(i)); |
| | | } |
| | | } |
| | | } |
| | | }); |
| | | String sampleIdStr = insContext.keySet().stream().findFirst().orElse(null); |
| | | if (sampleIdStr != null) { |
| | | int count = insProductMapper.selectInsProductCountByOrderId(orderId); |
| | | if (count == 0) { |
| | | insOrderStateMapper.update(new InsOrderState(), Wrappers.<InsOrderState>lambdaUpdate() |
| | | .eq(InsOrderState::getInsOrderId, orderId) |
| | | .eq(InsOrderState::getLaboratory, sonLaboratory) |
| | | .set(InsOrderState::getInsState, 2)); |
| | | insOrderMapper.update(null, new LambdaUpdateWrapper<InsOrder>() |
| | | .set(InsOrder::getState, 4) |
| | | .eq(InsOrder::getId, orderId)); |
| | | } else { |
| | | insOrderStateMapper.update(new InsOrderState(), Wrappers.<InsOrderState>lambdaUpdate() |
| | | .eq(InsOrderState::getInsOrderId, orderId) |
| | | .eq(InsOrderState::getLaboratory, sonLaboratory) |
| | | .set(InsOrderState::getInsState, 1)); |
| | | insOrderMapper.update(null, new LambdaUpdateWrapper<InsOrder>() |
| | | .set(InsOrder::getInsState, 1) |
| | | .eq(InsOrder::getId, orderId)); |
| | | } |
| | | } |
| | | } |
| | | }catch (Exception e){ |
| | | log.error("å·¥æ¶è®¡ç®å¤±è´¥-->å½åæ ·åID:{},æ£éªè¯¦æ
:{}",currentSampleId,insContext); |
| | | throw new RuntimeException(e); |
| | | }finally { |
| | | if(lock.isLocked())lock.unlock(); |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * æ¥æ¾å°æ°ä½æ°æå¤çæ°å¼ |
| | | */ |
| | | public Map<String,Object> maxDecimalNumber(String tells) { |
| | | HashMap<String, Object> map = new HashMap<>(); |
| | | Pattern pattern = Pattern.compile("[-+]?\\d*\\.?\\d+"); |
| | | Matcher matcher = pattern.matcher(tells); |
| | | String tell = ""; |
| | | Integer maxNumber = 0; |
| | | while (matcher.find()) { |
| | | String group = matcher.group(); |
| | | Integer length = 0; |
| | | if(group.contains(".")) { |
| | | length = group.split("\\.")[1].length(); |
| | | }else { |
| | | length = 0; |
| | | } |
| | | if(length > maxNumber) { |
| | | maxNumber = length; |
| | | tell = group; |
| | | } |
| | | } |
| | | map.put("tell",tell); |
| | | map.put("maxNumber",maxNumber); |
| | | return map; |
| | | } |
| | | |
| | | /** |
| | | * å°æ°ä½æ°çè¡¥å
¨ |
| | | */ |
| | | public String completion(String value, Integer digit) { |
| | | if(NumberUtil.isDouble(value)) { |
| | | int length = 0; |
| | | String[] splits = value.split("\\."); |
| | | if(splits.length>1){ |
| | | length = splits[1].length(); |
| | | } |
| | | if(digit > length) { |
| | | int difference = digit - length; |
| | | for (int i = 0; i < difference; i++) { |
| | | value += "0"; |
| | | } |
| | | } |
| | | } |
| | | return value; |
| | | } |
| | | |
| | | //äº¤æ¥ |
| | | @Override |
| | | public int upPlanUser(Integer userId, Integer orderId, String sonLaboratory) { |
| | | InsSampleUser insSampleUser = new InsSampleUser(); |
| | | insSampleUser.setUserId(userId); |
| | | insSampleUser.setInsSampleId(orderId); |
| | | insSampleUser.setState(0); |
| | | insSampleUser.setSonLaboratory(sonLaboratory); |
| | | return insSampleUserMapper.insert(insSampleUser); |
| | | } |
| | | |
| | | //æ ¹æ®åå
æ ¼çææ¬å
容计ç®å®é
è¡é« |
| | | private int estimateCellHeight(CellRenderData cellRenderData) { |
| | | // å设é»è®¤è¡é«æ¯40 |
| | | int defaultHeight = 40; |
| | | // è·ååå
æ ¼ä¸çæææ®µè½ |
| | | List<ParagraphRenderData> paragraphs = cellRenderData.getParagraphs(); |
| | | int estimatedHeight = 0; |
| | | try { |
| | | // éåæ®µè½ï¼ä¼°ç®æ¯ä¸ªæ®µè½çé«åº¦ |
| | | for (ParagraphRenderData paragraph : paragraphs) { |
| | | List<RenderData> contents = paragraph.getContents(); |
| | | for (RenderData content : contents) { |
| | | if (content instanceof TextRenderData) { |
| | | TextRenderData text = (TextRenderData) content; |
| | | Style style = text.getStyle(); |
| | | // å设æ¯è¡ææ¬çé«åº¦ä¸ºåä½å¤§å°ç1.2å |
| | | Double fontSize = Objects.isNull(style.getFontSize()) ? 12.0 : style.getFontSize(); |
| | | int lines = (int) Math.ceil(text.getText().length() / 15.0); // å设æ¯è¡çº¦15个å符 |
| | | int textHeight = (int) (fontSize * 1.2 * lines); |
| | | // ç´¯å æ®µè½çé«åº¦ |
| | | estimatedHeight += textHeight; |
| | | } |
| | | } |
| | | } |
| | | }catch (Exception ignored){} |
| | | // è¿åæå¤§å¼ï¼ç¡®ä¿é«åº¦ä¸ä½äºé»è®¤é«åº¦ |
| | | return Math.max(estimatedHeight, defaultHeight); |
| | | } |
| | | |
| | | /** |
| | | * åééåæ¶æ¯ |
| | | * @param exchange äº¤æ¢æºåç§° |
| | | * @param routerKey è·¯ç±ä¸»é® |
| | | * @param jsonStr æ¶æ¯å
容 |
| | | */ |
| | | public void sendQueueMessage(String exchange,String routerKey,String jsonStr){ |
| | | rabbitTemplate.convertAndSend(exchange,routerKey,jsonStr); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public int verifyPlan(Integer orderId, String laboratory, Integer type, String tell) { |
| | | int num = (type == 1 ? 5 : 4); |
| | | LocalDateTime now = LocalDateTime.now(); |
| | | insOrderStateMapper.update(null, Wrappers.<InsOrderState>lambdaUpdate().eq(InsOrderState::getInsOrderId, orderId).eq(InsOrderState::getLaboratory, laboratory).set(InsOrderState::getInsTime, now).set(InsOrderState::getInsState, num).set(InsOrderState::getVerifyTell, tell).set(InsOrderState::getVerifyUser, SecurityUtils.getUserId())); |
| | | Long count = insOrderStateMapper.selectCount(Wrappers.<InsOrderState>lambdaQuery().eq(InsOrderState::getInsOrderId, orderId).ne(InsOrderState::getInsState, 5)); |
| | | if (count == 0 && num == 5) { |
| | | List<InsUnPass> insUnPasses = new ArrayList<>(); |
| | | /*æ ·åä¸ç项ç®åªè¦æä¸ä¸ªé¡¹ç®ä¸åæ ¼åæ£éªç»æä¸º0,å¦å为1*/ |
| | | //è¿éçinsSamplesæ¯è®¢åä¸çæææ ·åå
æ¬("/") |
| | | List<InsSample> insSamples = insSampleMapper.selectList(Wrappers.<InsSample>lambdaQuery().eq(InsSample::getInsOrderId, orderId)); |
| | | for (InsSample insSample : insSamples) { |
| | | List<InsProduct> insProducts = insProductMapper.selectList(Wrappers.<InsProduct>lambdaQuery().eq(InsProduct::getInsSampleId, insSample.getId()).eq(InsProduct::getState, 1)); |
| | | List<Integer> results = insProducts.stream().map(InsProduct::getInsResult).filter(Objects::nonNull).collect(Collectors.toList()); |
| | | if (results.contains(0)) { |
| | | insSample.setInsResult(0); |
| | | } else { |
| | | insSample.setInsResult(1); |
| | | } |
| | | insSampleMapper.updateById(insSample); |
| | | /*夿 ¸éè¿åï¼å°ä¸åæ ¼ç项ç®ä¿¡æ¯æ·»å å°ins_un_pass表ä¸*/ |
| | | for (InsProduct insProduct : insProducts) { |
| | | if (insProduct.getInsResult() == 0) { |
| | | InsUnPass insUnPass = new InsUnPass(); |
| | | insUnPass.setId(null); |
| | | insUnPass.setModel(insSample.getModel()); |
| | | insUnPass.setSample(insSample.getSample()); |
| | | insUnPass.setInspectionItem(insProduct.getInspectionItem()); |
| | | insUnPass.setInspectionItemSubclass(insProduct.getInspectionItemSubclass()); |
| | | insUnPass.setLastValue(insProduct.getLastValue()); |
| | | insUnPass.setEntrustCode(insOrderMapper.selectById(orderId).getEntrustCode()); |
| | | List<Integer> userIds = insProductUserMapper.selectList(Wrappers.<InsProductUser>lambdaQuery().eq(InsProductUser::getInsProductId, insProduct.getId())).stream().map(InsProductUser::getCreateUser).distinct().collect(Collectors.toList()); |
| | | if(!userIds.isEmpty()){ |
| | | String name = userMapper.selectBatchIds(userIds).stream().map(User::getName).collect(Collectors.joining(",")); |
| | | insUnPass.setName(name); |
| | | insUnPasses.add(insUnPass); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | insUnPassService.saveBatch(insUnPasses); |
| | | InsOrder insOrder = insOrderMapper.selectById(orderId); |
| | | String oldSampleStr = insOrder.getSample(); |
| | | //samplesæ¯è¿æ»¤ææ²¡ææ£éªé¡¹ç®çæ ·å |
| | | List<SampleProductDto> samples = insSampleMapper.selectSampleProductListByOrderId(orderId); |
| | | //æ¥è¯¢è®¢åä¸çå»éåçæ ·ååç§° |
| | | List<String> unqeSampleList = samples.stream().map(InsSample::getSample).distinct().collect(Collectors.toList()); |
| | | if(unqeSampleList.size()==1){ |
| | | insOrder.setSample(unqeSampleList.get(0)); |
| | | } |
| | | InsReport insReport = new InsReport(); |
| | | insReport.setCode(insOrder.getEntrustCode()); |
| | | insReport.setInsOrderId(orderId); |
| | | List<Map<String, Object>> tables = new ArrayList<>(); |
| | | Set<String> standardMethod = new HashSet<>(); |
| | | Set<String> deviceSet = new HashSet<>(); |
| | | Set<String> models = new HashSet<>(); |
| | | AtomicReference<Integer> productSize = new AtomicReference<>(0); |
| | | String[] monthNames = {"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"}; |
| | | Set<String> resultCh = new HashSet<>(); |
| | | Set<String> resultEn = new HashSet<>(); |
| | | //è·åæ£éªé¡¹ç®æ°é |
| | | Set<String> unEqualSet = new HashSet<>(); |
| | | //çµåè¯éªå®¤ï¼é¢æ/éææ ·ååå· |
| | | List<String> modelDl = new ArrayList<>(); |
| | | /*åºç¡æ¥å(æ ¹æ®ç»å¶çåå§è®°å½æ¨¡çå½¢æ)*/ |
| | | BasicReportHandler basicReportHandler = new BasicReportHandler(baseMapper, this,insSampleMapper); |
| | | basicReportHandler.doWrite(samples,insReport,tables,standardMethod,models,unEqualSet,modelDl,deviceSet); |
| | | productSize.getAndSet(unEqualSet.size()); |
| | | String sampleStr = insOrder.getSample(); |
| | | if(!modelDl.isEmpty()){ |
| | | String model = modelDl.stream().distinct().findFirst().orElse(""); |
| | | sampleStr += model; |
| | | } |
| | | /*å
纤æ¥å¤´æèçæ¥åæ ·å¼*/ |
| | | //æ¥è¯¢è®¢åä¸æææ ·åçæ£éªé¡¹ç®,妿æå
纤æ¥å¤´æèåéæ°æå»ºè¡¨æ ¼ |
| | | List<Map<String, Object>> tables4 = new ArrayList<>(); |
| | | //å½å订åä¸çæææ£éªé¡¹ |
| | | List<InsProduct> insProducts0 = insProductMapper.selectList(Wrappers.<InsProduct>lambdaQuery() |
| | | .eq(InsProduct::getState, 1) |
| | | .in(InsProduct::getInsSampleId, insSamples.stream().map(InsSample::getId).distinct().collect(Collectors.toList()))); |
| | | if (insProducts0.stream().map(InsProduct::getInspectionItem).collect(Collectors.toList()).contains("å
纤æ¥å¤´æè")){ |
| | | //å¤çå
纤æ¥å¤´æèæ¥å |
| | | FiberOpticConnectorLossReportHandler lossReportHandler = new FiberOpticConnectorLossReportHandler(insProductMapper); |
| | | lossReportHandler.doWrite(insProducts0,insSamples,insReport,tables4); |
| | | } |
| | | String url; |
| | | try { |
| | | InputStream inputStream = this.getClass().getResourceAsStream("/static/report-template.docx"); |
| | | File file = File.createTempFile("temp", ".tmp"); |
| | | OutputStream outputStream = new FileOutputStream(file); |
| | | IOUtils.copy(inputStream, outputStream); |
| | | url = file.getAbsolutePath(); |
| | | } catch (FileNotFoundException e) { |
| | | throw new ErrorException("æ¾ä¸å°æ¨¡æ¿æä»¶"); |
| | | } catch (IOException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | StringBuilder standardMethod2 = new StringBuilder(); |
| | | for (String s : standardMethod) { |
| | | standardMethod2.append("ã").append(s); |
| | | } |
| | | standardMethod2.replace(0, 1, ""); |
| | | tables.forEach(table -> { |
| | | table.put("tableSize", tables.size() + 1); |
| | | }); |
| | | List<DeviceVO> deviceList = new ArrayList<>(); |
| | | if (!deviceSet.isEmpty()) { |
| | | deviceSet.forEach(d->deviceList.add(insOrderMapper.selectDeviceList(d))); |
| | | } |
| | | Map<String, String> codeStr = new HashMap<>(); |
| | | codeStr.put("æ¥åç¼å·", insReport.getCode()); |
| | | codeStr.put("æ ·ååç§°", insOrder.getSample()); |
| | | codeStr.put("è§æ ¼åå·", samples.get(0).getModel()); |
| | | codeStr.put("åæ¾æ¥æ", now.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"))); |
| | | String codePath; |
| | | try { |
| | | String content = phoneQrCode+ insOrder.getEntrustCode() + "&type=word"; |
| | | codePath = new MatrixToImageWriter().code(content, twoCode); |
| | | } catch (Exception e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | String modelStr = ""; |
| | | for (String model : models) { |
| | | modelStr += "," + model; |
| | | } |
| | | String finalModelStr = modelStr; |
| | | String sampleEn = insSampleMapper.getSampleEn(insOrder.getSample()); |
| | | insOrder.setSample(sampleStr); |
| | | String orderType = insOrderMapper.getEnumLabelByValue(insOrder.getOrderType()); |
| | | String formType = insOrderMapper.getEnumLabelByValue(insOrder.getFormType()); |
| | | ConfigureBuilder builder = Configure.builder(); |
| | | builder.useSpringEL(true); |
| | | List<DeviceVO> finalDeviceList = deviceList; |
| | | Integer userId = insSampleUserMapper.selectOne(Wrappers.<InsSampleUser>lambdaQuery() |
| | | .eq(InsSampleUser::getInsSampleId, orderId) |
| | | .eq(InsSampleUser::getState,0) |
| | | .orderByDesc(InsSampleUser::getCreateTime) |
| | | .last("limit 1")).getUserId(); |
| | | String signatureUrl; |
| | | try { |
| | | signatureUrl = userMapper.selectById(userId).getSignatureUrl(); |
| | | } catch (Exception e) { |
| | | throw new ErrorException("æ¾ä¸å°æ£éªäººçç¾å"); |
| | | } |
| | | if (ObjectUtils.isEmpty(signatureUrl) || signatureUrl.isEmpty()) { |
| | | throw new ErrorException("æ¾ä¸å°æ£éªäººçç¾å"); |
| | | } |
| | | //妿æ¯ä¸å¤©ç§æè½¯å¾®ç¼å(02)ï¼æ¥åå±ç¤ºå§æåä½ä¸ºä¸å¤©ç§æå
ç¼æ»å(01) |
| | | Custom custom = customMapper.selectById(insOrder.getCompanyId()); |
| | | if(!Objects.isNull(custom) && Objects.equals("ä¸å¤©ç§æè½¯å¾®ç¼å",custom.getCompany())){ |
| | | //ä¸å¤©ç§æå
ç¼æ»å客æ·ä¿¡æ¯ |
| | | custom = customMapper.selectOne(Wrappers.<Custom>lambdaQuery() |
| | | .eq(Custom::getCompany,"ä¸å¤©ç§æå
ç¼æ»å") |
| | | .eq(Custom::getCode2,"01").last("limit 1")); |
| | | } |
| | | //åæ ¼æ°é |
| | | long qualifiedCount = insProducts0.stream().filter(f->f.getInsResult()==1).count(); |
| | | //æ ¼å¼åä¸åæ ¼é¡¹ç® |
| | | joinUnqualifiedItemChars(resultCh,resultEn,insProducts0); |
| | | String resultChStr = "便®å§æè¦æ±ï¼ææ£é¡¹ç®å符åè¦æ±ã"; |
| | | String resultEnStr = "According to commissioned requirements, all the tested items meet the requirements."; |
| | | if (!resultCh.isEmpty() && qualifiedCount>0) { |
| | | resultChStr = "便®å§æè¦æ±ï¼" + String.join("ã",resultCh) + "ææ£é¡¹ç®ä¸ç¬¦åè¦æ±ï¼å
¶ä½ææ£é¡¹ç®å符åè¦æ±ã"; |
| | | resultEnStr = "According to commissioned requirements," + String.join("ã",resultEn) + " these inspected items do not meet the requirements, all other inspected items meet the requirements."; |
| | | }else if(!resultCh.isEmpty() && qualifiedCount==0){ |
| | | resultChStr = "便®å§æè¦æ±ï¼ææ£é¡¹ç®åä¸ç¬¦åè¦æ±ã"; |
| | | resultEnStr = "According to commissioned requirements, all the tested items do not meet the requirements."; |
| | | } |
| | | |
| | | //å
纤éä»¶è¡¨æ ¼æ°æ® |
| | | List<Map<String, Object>> tables2 = new ArrayList<>(); |
| | | //æ¾å¥ç®¡éä»¶è¡¨æ ¼æ°æ® |
| | | List<Map<String, Object>> tables5 = new ArrayList<>(); |
| | | //å°ºå¯¸åæ°éä»¶è¡¨æ ¼æ°æ® |
| | | List<Map<String, Object>> tables6 = new ArrayList<>(); |
| | | /*å
纤é
ç½®çæ£éªæ¥å*/ |
| | | //å
夿æ¯å¦æå
纤é
ç½® |
| | | List<InsProduct> insProducts = insProductMapper.selectList(Wrappers.<InsProduct>lambdaQuery() |
| | | .eq(InsProduct::getState, 1) |
| | | .in(InsProduct::getInsSampleId, insSamples.stream().map(InsSample::getId).distinct().collect(Collectors.toList())) |
| | | .and(i->i.isNull(InsProduct::getInspectionItemClass).or().eq(InsProduct::getInspectionItemClass,"")) |
| | | );//ç¨æ£éªå项忮µåºå«å
纤é
ç½®ä¸æ¸©åº¦å¾ªç¯ |
| | | //æ¥è¯¢å
¨è²è°±ï¼è¿æ»¤è²æ å¹¶æåº |
| | | List<String> colorList = DictUtils.getDictCache("è²æ ").stream() |
| | | .sorted(Comparator.comparing(SysDictData::getDictSort)) |
| | | .map(SysDictData::getDictValue) |
| | | .collect(Collectors.toList()); |
| | | //æ¾å¥ç®¡éä»¶å¤ç |
| | | long piperCount = insProducts.stream().filter(f->!Objects.isNull(f.getInsBushId())).count(); |
| | | if(piperCount>0){ |
| | | PiperConfigReportHandler piperConfigReportHandler = new PiperConfigReportHandler(insProductMapper); |
| | | piperConfigReportHandler.doWrite(samples,insReport,tables5,colorList); |
| | | } |
| | | //è¿æ»¤æå
纤é
ç½®çé¡¹ç® |
| | | long fiberCount = insProducts.stream().filter(f->!Objects.isNull(f.getInsFiberId())).count(); |
| | | FiberConfigReportHandler lossReportHandler = new FiberConfigReportHandler(insProductMapper,insSampleMapper); |
| | | if (fiberCount>0) { |
| | | lossReportHandler.doWrite(samples,insReport,tables2,colorList); |
| | | } else{ |
| | | //æé¤å
纤æ¥å¤´æèåå°ºå¯¸åæ° |
| | | List<InsProduct> filterLists = insProducts.stream() |
| | | .filter(f->!Arrays.asList("å
纤æ¥å¤´æè","å°ºå¯¸åæ°","温度循ç¯").contains(f.getInspectionItem())&&f.getSonLaboratory().equals("å
纤è¯éªå®¤")).collect(Collectors.toList()); |
| | | lossReportHandler.writeFiberEnclosureTableRow(filterLists,tables2,insReport); |
| | | } |
| | | //è¿æ»¤æå
纤带é
ç½®çé¡¹ç® |
| | | long fibersCount = insProducts.stream().filter(f->!Objects.isNull(f.getInsFibersId())).count(); |
| | | FiberOpticRibbonReportHandler fiberOpticRibbonReportHandler = new FiberOpticRibbonReportHandler(insProductMapper,insSampleMapper); |
| | | if (fibersCount>0) { |
| | | fiberOpticRibbonReportHandler.doWrite(samples,insReport,tables6,colorList); |
| | | } else{ |
| | | //è¿æ»¤å°ºå¯¸åæ°é¡¹ç® |
| | | List<InsProductFiberVO> productList = new ArrayList<>(); |
| | | insSamples.stream() |
| | | .map(InsSample::getId).distinct() |
| | | .forEach(id->productList.addAll(insProductMapper.selectProductBySampleId(id))); |
| | | List<InsProductFiberVO> vos = productList.stream().filter(f->f.getInspectionItem().equals("å°ºå¯¸åæ°")).collect(Collectors.toList()); |
| | | if(!vos.isEmpty()){ |
| | | fiberOpticRibbonReportHandler.writeFiberOpticRibbonEnclosureTableRow(vos,tables6,insReport); |
| | | } |
| | | } |
| | | tables2.forEach(table2 -> table2.put("tableSize2", tables2.size())); |
| | | tables5.forEach(table5 -> table5.put("tableSize5", tables5.size())); |
| | | tables6.forEach(table6 -> table6.put("tableSize6", tables6.size())); |
| | | |
| | | /*温度循ç¯çæ£éªæ¥å*/ |
| | | //å
夿æ¯å¦ææ¸©åº¦å¾ªç¯ |
| | | List<InsProduct> insProducts3 = insProductMapper.selectList(Wrappers.<InsProduct>lambdaQuery() |
| | | .eq(InsProduct::getState, 1) |
| | | .in(InsProduct::getInsSampleId, insSamples.stream().map(InsSample::getId).distinct().collect(Collectors.toList())) |
| | | .isNotNull(InsProduct::getSpecialItemParentId) //åºå常è§é¡¹ç® |
| | | .isNotNull(InsProduct::getInspectionItemClass)//ç¨æ£éªå项忮µåºå«å
纤é
ç½®ä¸æ¸©åº¦å¾ªç¯ |
| | | .isNotNull(InsProduct::getInsFiberId)); //ç¨å
纤åºå«ç循ç¯åæ¸©åº¦å¾ªç¯ |
| | | List<Map<String, Object>> tables3 = new ArrayList<>(); |
| | | if (!insProducts3.isEmpty()) { |
| | | //å¤çæ¸©åº¦å¾ªç¯æ¥å |
| | | TemperatureCyclingReportHandler1 cyclingReportHandler = new TemperatureCyclingReportHandler1(insProductMapper, insFiberMapper, insProductResultMapper); |
| | | cyclingReportHandler.doWrite(samples,insReport,tables3); |
| | | } |
| | | |
| | | /*温åè¯éªçæ£éªæ¥å*/ |
| | | List<InsProduct> insProducts1 = insProductMapper.selectList(Wrappers.<InsProduct>lambdaQuery() |
| | | .eq(InsProduct::getState, 1) |
| | | .in(InsProduct::getInsSampleId, insSamples.stream().map(InsSample::getId).distinct().collect(Collectors.toList())) |
| | | .isNotNull(InsProduct::getSpecialItemParentId) //åºå常è§é¡¹ç® |
| | | .isNull(InsProduct::getInspectionItemClass)//ç¨æ£éªå项忮µåºå«æ¸©åè¯éªä¸çå¾ªç¯ |
| | | .isNull(InsProduct::getInsFiberId) //ç¨å
纤åºå«æ¸©åè¯éªåæ¸©åº¦å¾ªç¯ |
| | | .eq(InsProduct::getInspectionItem, "1")); //温åè¯éªç循ç¯åªæ1次 |
| | | if (!insProducts1.isEmpty()) { |
| | | //å¤ç温åè¯éªæ¥å |
| | | TemperatureTestReportHandler testReportHandler = new TemperatureTestReportHandler(insProductMapper, insProductResultMapper); |
| | | testReportHandler.doWrite(samples,insReport,tables3); |
| | | } |
| | | |
| | | /*ç循ç¯çæ£éªæ¥å*/ |
| | | List<InsProduct> insProducts2 = insProductMapper.selectList(Wrappers.<InsProduct>lambdaQuery() |
| | | .eq(InsProduct::getState, 1) |
| | | .in(InsProduct::getInsSampleId, insSamples.stream().map(InsSample::getId).distinct().collect(Collectors.toList())) |
| | | .isNotNull(InsProduct::getSpecialItemParentId) //åºå常è§é¡¹ç® |
| | | .isNotNull(InsProduct::getInspectionItemClass)//ç¨æ£éªå项忮µåºå«æ¸©åè¯éªä¸çå¾ªç¯ |
| | | .isNull(InsProduct::getInsFiberId)); //ç¨å
纤åºå«ç循ç¯åæ¸©åº¦å¾ªç¯ |
| | | if (!insProducts2.isEmpty()) { |
| | | //å¤ççå¾ªç¯æ¥å |
| | | ThermalCycleReportHandler cycleReportHandler = new ThermalCycleReportHandler(insProductMapper, insProductResultMapper); |
| | | cycleReportHandler.doWrite(samples,insReport,tables3); |
| | | } |
| | | //åæ ¹åç´çç§çæ£éªæ¥å |
| | | tables3.forEach(table3 -> { |
| | | table3.put("tableSize3", tables3.size()); |
| | | }); |
| | | /*è·åéä»¶å¾çç±»å*/ |
| | | List<Map<String, Object>> images = new ArrayList<>(); |
| | | List<InsOrderFile> insOrderFiles = insOrderFileMapper.selectList(Wrappers.<InsOrderFile>lambdaQuery().eq(InsOrderFile::getType, 1).eq(InsOrderFile::getInsOrderId, orderId)); |
| | | if (CollectionUtils.isNotEmpty(insOrderFiles)) { |
| | | insOrderFiles.forEach(insOrderFile -> { |
| | | Map<String, Object> image = new HashMap<>(); |
| | | PictureRenderData pictureRenderData = Pictures.ofLocal(imgUrl + "/" + insOrderFile.getFileUrl()).sizeInCm(17, 20).create(); |
| | | image.put("url", pictureRenderData); |
| | | image.put("report", insReport); |
| | | images.add(image); |
| | | }); |
| | | } |
| | | //å§æäººåçµè¯åæ®µå¤æ |
| | | if (ObjectUtils.isEmpty(insOrder.getPrepareUser())) { |
| | | insOrder.setPrepareUser("/"); |
| | | } |
| | | if (ObjectUtils.isEmpty(insOrder.getPhone())) { |
| | | insOrder.setPhone("/"); |
| | | } |
| | | //æ¥è¯¢å®¡æ¹ç¾åé
ç½® |
| | | Map<String,Object> urlMap = insReportApproveConfigMapper.selectApprovalConfigByLaboratory(insOrder.getLaboratory()); |
| | | String writeUrl = imgUrl + "/" + (Objects.isNull(urlMap.get("writeUrl"))?"":urlMap.get("writeUrl").toString());//ç¼å¶äººç¾åurl |
| | | String examineUrl = imgUrl + "/" + (Objects.isNull(urlMap.get("examineUrl"))?"":urlMap.get("examineUrl").toString());//å®¡æ ¸äººç¾åurl |
| | | String ratifyUrl = imgUrl + "/" + (Objects.isNull(urlMap.get("ratifyUrl"))?"":urlMap.get("ratifyUrl").toString());//æ¹å人ç¾åurl |
| | | //è·ååºæçæ¥åä¸ç¨ç« |
| | | String sealUrl; |
| | | try { |
| | | sealUrl = insReportMapper.getLaboratoryByName(insOrder.getLaboratory()); |
| | | } catch (Exception e) { |
| | | throw new ErrorException("æ¾ä¸å°æ¥åä¸ç¨ç« "); |
| | | } |
| | | |
| | | //æ£éªé¡¹ç®çç¯å¢ |
| | | InsProduct insProduct = insProductMapper.selectList(Wrappers.<InsProduct>lambdaQuery().eq(InsProduct::getState, 1).eq(InsProduct::getInsSampleId, samples.get(0).getId())).get(0); |
| | | String environment = ""; |
| | | environment = (ObjectUtils.isNotEmpty(insProduct.getTemperature()) ? insProduct.getTemperature() + "â " : "") + (ObjectUtils.isNotEmpty(insProduct.getHumidity()) ? insProduct.getHumidity() + "%" : ""); |
| | | String finalEnvironment = environment; |
| | | Custom finalCustom = custom; |
| | | String finalSealUrl = imgUrl + "/" +sealUrl; |
| | | String finalResultChStr = resultChStr; |
| | | String finalResultEnStr = resultEnStr; |
| | | ZipSecureFile.setMinInflateRatio(0.001); |
| | | XWPFTemplate template = XWPFTemplate.compile(url, builder.build()).render( |
| | | new HashMap<String, Object>() {{ |
| | | put("order", insOrder); |
| | | put("report", insReport); |
| | | put("environment", finalEnvironment); |
| | | put("custom", finalCustom); |
| | | put("sampleSize", samples.size()); |
| | | put("tables", tables); |
| | | put("tableSize", tables.size() + 1); |
| | | put("tables2", tables2.isEmpty()?null:tables2); |
| | | put("tableSize2", tables2.size()); |
| | | put("tables3", tables3.isEmpty()?null:tables3); |
| | | put("tableSize3", tables3.size()); |
| | | put("tables4", tables4.isEmpty()?null:tables4); |
| | | put("tableSize4", tables4.size()); |
| | | put("tables5", tables5.isEmpty()?null:tables5); |
| | | put("tableSize5", tables5.size()); |
| | | put("tables6", tables6.isEmpty()?null:tables6); |
| | | put("tableSize6", tables6.size()); |
| | | put("standardMethod", (standardMethod2.toString().equals("null") ? "" : standardMethod2)); |
| | | put("deviceList", finalDeviceList); |
| | | put("twoCode", Pictures.ofLocal(codePath).create()); |
| | | put("models", finalModelStr.replace(",", "")); |
| | | put("productSize", productSize); |
| | | put("createTime", now.format(DateTimeFormatter.ofPattern("yyyyå¹´MMæddæ¥"))); |
| | | put("createTimeEn", monthNames[now.getMonthValue() - 1] + " " + now.getDayOfMonth() + ", " + now.getYear()); |
| | | put("insTime", insOrder.getInsTime().format(DateTimeFormatter.ofPattern("yyyyå¹´MMæddæ¥"))); |
| | | put("insTimeEn", monthNames[insOrder.getInsTime().getMonthValue() - 1] + " " + insOrder.getInsTime().getDayOfMonth() + ", " + insOrder.getInsTime().getYear()); |
| | | put("writeUrl", new FilePictureRenderData(100,50, writeUrl)); |
| | | put("insUrl", new FilePictureRenderData(100,50,imgUrl + "/" + signatureUrl)); |
| | | put("images", images.isEmpty()?null:images); |
| | | put("examineUrl", new FilePictureRenderData(100,50,examineUrl)); |
| | | put("ratifyUrl", new FilePictureRenderData(100,50,ratifyUrl)); |
| | | put("sampleEn", sampleEn); |
| | | put("orderType", orderType); |
| | | put("getTime", insOrder.getExamineTime().format(DateTimeFormatter.ofPattern("yyyyå¹´MMæddæ¥"))); |
| | | put("getTimeEn", monthNames[insOrder.getExamineTime().getMonthValue() - 1] + " " + insOrder.getExamineTime().getDayOfMonth() + ", " + insOrder.getExamineTime().getYear()); |
| | | put("seal1", new FilePictureRenderData(600,600, finalSealUrl)); |
| | | put("seal2", new FilePictureRenderData(600,600, finalSealUrl)); |
| | | put("formTypeCh", formType); |
| | | put("formTypeEn", insOrder.getFormType()); |
| | | put("resultCh", finalResultChStr); |
| | | put("resultEn", finalResultEnStr); |
| | | }}); |
| | | // æ´æ°æ°æ®åºä¸çç¾åæ¥æ |
| | | insOrderService.update(Wrappers.<InsOrder>lambdaUpdate() |
| | | .eq(InsOrder::getId, insOrder.getId()) |
| | | .set(InsOrder::getIssuingDate, now)); |
| | | try { |
| | | String name = insReport.getCode().replace("/", "") + ".docx"; |
| | | template.writeAndClose(Files.newOutputStream(Paths.get(wordUrl + "/" + name))); |
| | | insReport.setUrl("/word/" + name); |
| | | insReport.setIsExamine(-9);//æªå®¡æ ¸ç¶æä¸º-9 |
| | | insReport.setIsRatify(-9);//æªæ¹åç¶æä¸º-9 |
| | | insReportMapper.insert(insReport); |
| | | insOrder.setInsState(5); |
| | | insOrder.setSample(oldSampleStr); |
| | | insOrderMapper.updateById(insOrder); |
| | | } catch (IOException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | // å¤çåå¹¶åå
æ ¼çé®é¢ |
| | | String path = wordUrl + "/" + insReport.getCode().replace("/", "") + ".docx"; |
| | | // word 转 pdf |
| | | String tempUrlPdf = insReportService.wordToPdfTemp((StrUtil.isBlank(insReport.getUrlS()) ? insReport.getUrl() : insReport.getUrlS()).replace("/word", wordUrl)); |
| | | insReportMapper.update(null,new LambdaUpdateWrapper<InsReport>() |
| | | .set(InsReport::getTempUrlPdf,tempUrlPdf) |
| | | .eq(InsReport::getId,insReport.getId())); |
| | | try { |
| | | ZipSecureFile.setMinInflateRatio(0.0001);//è§£å³éä»¶æä»¶è¿å¤§å¼åçZipBomå¼å¸¸ |
| | | FileInputStream stream = new FileInputStream(path); |
| | | XWPFDocument document = new XWPFDocument(stream); |
| | | List<XWPFTable> xwpfTables = document.getTables(); |
| | | for (int i = 0; i < xwpfTables.size(); i++) { |
| | | Set<String> set1 = new HashSet<>(); |
| | | Map<String, Map<String, Integer>> maps = new HashMap<>(); |
| | | for (int j = 0; j < xwpfTables.get(i).getRows().size(); j++) { |
| | | for (int k = 0; k < xwpfTables.get(i).getRows().get(j).getTableCells().size(); k++) { |
| | | if (xwpfTables.get(i).getRows().get(j).getTableCells().get(k).getText().indexOf("â") > -1) { |
| | | String[] split = xwpfTables.get(i).getRows().get(j).getTableCells().get(k).getText().split("â"); |
| | | if (set1.add(split[1])) { |
| | | Map<String, Integer> map = new HashMap<>(); |
| | | map.put("sr", j); |
| | | map.put("sc", k); |
| | | map.put("er", j + 0); |
| | | map.put("ec", k + 0); |
| | | maps.put(split[1], map); |
| | | } else { |
| | | Map<String, Integer> map1 = maps.get(split[1]); |
| | | if (j == map1.get("sr")) { |
| | | map1.put("ec", map1.get("ec") + 1); |
| | | } else if (k == map1.get("sc")) { |
| | | map1.put("er", map1.get("er") + 1); |
| | | } |
| | | } |
| | | String str = xwpfTables.get(i).getRows().get(j).getTableCells().get(k).getText().split("â")[0]; |
| | | xwpfTables.get(i).getRows().get(j).getTableCells().get(k).removeParagraph(0); |
| | | xwpfTables.get(i).getRows().get(j).getTableCells().get(k).setText(str); |
| | | xwpfTables.get(i).getRows().get(j).getTableCells().get(k).setVerticalAlignment(XWPFTableCell.XWPFVertAlign.CENTER); |
| | | xwpfTables.get(i).getRows().get(j).getTableCells().get(k).getParagraphArray(0).setAlignment(ParagraphAlignment.CENTER); |
| | | } |
| | | } |
| | | } |
| | | |
| | | // åå
æ ¼æåº, é¿å
æ ¼å¼éä¹± |
| | | List<Map.Entry<String, Map<String, Integer>>> entries = new ArrayList<>(maps.entrySet()); |
| | | entries.sort((o1, o2) -> o1.getValue().get("sc") - o2.getValue().get("sc")); |
| | | |
| | | // æç
§é¡ºåºæ·»å è¿éå |
| | | List<String> list = new ArrayList<>(); |
| | | for (Map.Entry<String, Map<String, Integer>> entry : entries) { |
| | | list.add(entry.getKey()); |
| | | } |
| | | /*List<String> list = new ArrayList<>(); |
| | | for (String s : maps.keySet()) { |
| | | list.add(s); |
| | | }*/ |
| | | for (int a = list.size() - 1; a >= 0; a--) { |
| | | Map<String, Integer> v = maps.get(list.get(a)); |
| | | for (int j = 0; j < v.get("er") - v.get("sr") + 1; j++) { |
| | | if (v.get("ec") > v.get("sc")) { |
| | | try { |
| | | TableTools.mergeCellsHorizonal(xwpfTables.get(i), v.get("sr") + j, v.get("sc"), v.get("ec")); |
| | | } catch (Exception e) { |
| | | } |
| | | } |
| | | } |
| | | if (v.get("er") > v.get("sr")) { |
| | | try { |
| | | TableTools.mergeCellsVertically(xwpfTables.get(i), v.get("sc"), v.get("sr"), v.get("er")); |
| | | } catch (Exception e) { |
| | | } |
| | | } |
| | | } |
| | | } |
| | | FileOutputStream fileOutputStream = new FileOutputStream(path); |
| | | document.write(fileOutputStream); |
| | | fileOutputStream.close(); |
| | | } catch (FileNotFoundException e) { |
| | | throw new RuntimeException(e); |
| | | } catch (IOException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | //å¤çä¸è±ææ¢è¡çé®é¢ |
| | | try { |
| | | FileInputStream stream1 = new FileInputStream(path); |
| | | XWPFDocument document1 = new XWPFDocument(stream1); |
| | | List<XWPFTable> xwpfTables1 = document1.getTables(); |
| | | for (int i = 1; i < xwpfTables1.size() - (deviceList == null ? 1 : 2); i++) { |
| | | for (int j = 0; j < xwpfTables1.get(i).getRows().size(); j++) { |
| | | for (int k = 0; k < xwpfTables1.get(i).getRows().get(j).getTableCells().size(); k++) { |
| | | if (xwpfTables1.get(i).getRows().get(j).getTableCells().get(k).getText().contains("@")) { |
| | | String text = xwpfTables1.get(i).getRows().get(j).getTableCells().get(k).getText(); |
| | | String[] split = text.split("@"); |
| | | xwpfTables1.get(i).getRows().get(j).getTableCells().get(k).removeParagraph(0); |
| | | XWPFParagraph xwpfParagraph = xwpfTables1.get(i).getRows().get(j).getTableCells().get(k).addParagraph(); |
| | | XWPFRun run = xwpfParagraph.createRun(); |
| | | run.setText(split.length>0?split[0]:""); |
| | | if (split.length>1 && ObjectUtils.isNotNull(split[1])) { |
| | | run.addBreak(); |
| | | run.setText(split[1]); |
| | | } |
| | | xwpfParagraph.setAlignment(ParagraphAlignment.CENTER); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | FileOutputStream fileOutputStream1 = new FileOutputStream(path); |
| | | document1.write(fileOutputStream1); |
| | | fileOutputStream1.close(); |
| | | } catch (FileNotFoundException e) { |
| | | throw new RuntimeException(e); |
| | | } catch (IOException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | } else if(num != 5) { |
| | | //夿 ¸ä¸éè¿å°æå¤æ ¸çè´è´£äººå»æ |
| | | Integer id = insSampleUserMapper.selectOne(Wrappers.<InsSampleUser>lambdaQuery().eq(InsSampleUser::getInsSampleId, orderId).orderByDesc(InsSampleUser::getId).last("limit 1")).getId(); |
| | | insSampleUserMapper.deleteById(id); |
| | | } |
| | | return 1; |
| | | } |
| | | |
| | | /** |
| | | * æ ¼å¼åä¸åæ ¼é¡¹ç®å符串 |
| | | * @param resultCh ä¸åæ ¼é¡¹ç®ä¸æå表 |
| | | * @param resultEn ä¸åæ ¼é¡¹ç®è±æå表 |
| | | * @param insProducts0 æ£éªé¡¹å表 |
| | | */ |
| | | private void joinUnqualifiedItemChars(Set<String> resultCh, Set<String> resultEn, List<InsProduct> insProducts0) { |
| | | if(!insProducts0.isEmpty()){ |
| | | insProducts0.stream().filter(f->f.getInsResult()==0).forEach(e->{ |
| | | String chinaStr = String.join("-",e.getInspectionItem(),e.getInspectionItemSubclass()); |
| | | String englishStr = String.join("-",e.getInspectionItemEn(),e.getInspectionItemSubclassEn()); |
| | | resultCh.add(chinaStr); |
| | | resultEn.add(englishStr); |
| | | }); |
| | | } |
| | | } |
| | | |
| | | public void getTemplateThing |
| | | (Set<Integer> set, Map<Integer, String> map2, List<InsProduct> insProducts) { |
| | | for (InsProduct product : insProducts) { |
| | | if (product.getSpecialItemParentId()!=null) { |
| | | product.setTemplate(new ArrayList<>()); |
| | | continue; |
| | | } |
| | | String thing = null; |
| | | if (product.getSpecialItemParentId() == null && set.add(product.getTemplateId())) { |
| | | map2.put(product.getTemplateId(), standardTemplateService.getStandTempThingById(product.getTemplateId()) + ""); |
| | | thing = map2.get(product.getTemplateId()); |
| | | } |
| | | if (StrUtil.isNotEmpty(thing)) { |
| | | JSONObject sheet = JSON.parseObject(JSON.toJSONString(JSON.parseArray(JSON.toJSONString(JSON.parseObject(thing).get("data"))).get(0))); |
| | | JSONObject config = JSON.parseObject(JSON.toJSONString(sheet.get("config"))); |
| | | List<JSONObject> cellData = JSON.parseArray(JSON.toJSONString(sheet.get("celldata")), JSONObject.class); |
| | | Map<String, Object> style = new HashMap<>(); |
| | | style.put("rowlen", config.get("rowlen")); |
| | | style.put("columnlen", config.get("columnlen")); |
| | | product.setTemplate(cellData); |
| | | product.setStyle(style); |
| | | product.setTemplateName(standardTemplateService.getStandTempNameById(product.getTemplateId())); |
| | | } |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public int submitPlan(Integer orderId, String laboratory, Integer verifyUser, String entrustCode) { |
| | | List<InsSample> insSamples = insSampleMapper.selectList(Wrappers.<InsSample>lambdaQuery().eq(InsSample::getInsOrderId, orderId).select(InsSample::getId)); |
| | | List<Integer> ids = insSamples.stream().map(a -> a.getId()).collect(Collectors.toList()); |
| | | List<InsProduct> insProducts = insProductMapper.selectList(Wrappers.<InsProduct>lambdaQuery() |
| | | .in(InsProduct::getInsSampleId, ids) |
| | | .eq(InsProduct::getSonLaboratory, laboratory) |
| | | .eq(InsProduct::getState, 1) |
| | | .and(wrapper -> wrapper |
| | | .isNull(InsProduct::getInsResult) |
| | | .or() |
| | | .eq(InsProduct::getInsResult, 2) |
| | | ) |
| | | .isNull(InsProduct::getInsFiberId) |
| | | .isNull(InsProduct::getInsFibersId)); |
| | | insProducts.addAll(insProductMapper.selectFiberInsProduct(ids, laboratory)); |
| | | if (insProducts.size() > 0) { |
| | | String str = ""; |
| | | HashSet<String> set = new HashSet<>(); |
| | | int count = 0; |
| | | for (InsProduct product : insProducts) { |
| | | //妿æ¯å
ç¼çæ¸©åº¦å¾ªç¯ |
| | | if (product.getInspectionItem().equals("温度循ç¯") && insOrderMapper.selectById(orderId).getSampleType().equals("å
ç¼")) { |
| | | //æ¥è¯¢é£äºå¾ªç¯æ¸©åº¦çæ£éªé¡¹ç®çç»è®ºæ¯å¦å
¨é¨æ£éª |
| | | List<InsProduct> insProductList = insProductMapper.selectList(Wrappers.<InsProduct>lambdaQuery().eq(InsProduct::getInsSampleId, product.getInsSampleId()) |
| | | .isNotNull(InsProduct::getInsFiberId).like(InsProduct::getInspectionItemSubclass, "â")); |
| | | List<Integer> collect = insProductList.stream().filter(insProduct -> insProduct.getInsResult() != null).map(InsProduct::getInsResult).collect(Collectors.toList()); |
| | | List<Integer> tt = new ArrayList<>(); |
| | | tt.add(1); |
| | | if (collect.contains(0)) { |
| | | product.setLastValue("ä¸åæ ¼"); |
| | | product.setInsResult(0); |
| | | } else if (collect.size() == insProductList.size() && collect.stream().distinct().collect(Collectors.toList()).containsAll(tt)) { |
| | | product.setLastValue("åæ ¼"); |
| | | product.setInsResult(1); |
| | | } |
| | | insProductMapper.updateById(product); |
| | | } |
| | | //妿æ¯çå¾ªç¯æè
æ¯æ¸©åè¯éª |
| | | else if (product.getInspectionItem().equals("ç循ç¯") || product.getInspectionItem().equals("温åè¯éª")) { |
| | | //æ¥è¯¢è¿äºé¡¹ç®ä¸çå
¶ä»æ£éªé¡¹ç®æ¯å¦å
¨é¨æ£éª |
| | | List<InsProduct> insProductList = insProductMapper.selectList(Wrappers.<InsProduct>lambdaQuery() |
| | | .eq(InsProduct::getInsSampleId, product.getInsSampleId()) |
| | | .like(InsProduct::getInspectionItemSubclass, "温度")); |
| | | List<Integer> collect = insProductList.stream().filter(insProduct -> insProduct.getInsResult() != null).map(InsProduct::getInsResult).collect(Collectors.toList()); |
| | | List<Integer> tt = new ArrayList<>(); |
| | | tt.add(1); |
| | | if (collect.contains(0)) { |
| | | product.setLastValue("ä¸åæ ¼"); |
| | | product.setInsResult(0); |
| | | } else if (collect.size() == insProductList.size() && collect.stream().distinct().collect(Collectors.toList()).containsAll(tt)) { |
| | | product.setLastValue("åæ ¼"); |
| | | product.setInsResult(1); |
| | | } |
| | | insProductMapper.updateById(product); |
| | | } |
| | | //妿æ¯çµåçåºååºåæ£éªé¡¹ç®æè
æ¯ç²å³è¯éª,ç»è®ºæ¹æä¸å¤å® |
| | | else if (product.getInspectionItem().equals("åºååºå") || product.getInspectionItem().contains("ç²å³è¯éª")){ |
| | | product.setInsResult(3); |
| | | insProductMapper.updateById(product); |
| | | } |
| | | //妿æ¯é²æ¯é¤åçç¹æ§è¯éª |
| | | else if (product.getInspectionItem().equals("鲿¯é¤åçç¹æ§è¯éª")){ |
| | | product.setInsResult(1);//é»è®¤åæ ¼ |
| | | //éè¦å»å¤æå¡«åçæ£éªæ°æ®æ¯å¦æä¸åæ ¼ |
| | | InsProductResult insProductResult = insProductResultMapper.selectOne(Wrappers.<InsProductResult>lambdaQuery().eq(InsProductResult::getInsProductId, product.getId())); |
| | | cn.hutool.json.JSONObject jsonObject = new cn.hutool.json.JSONObject(insProductResult.getComValue()); |
| | | // æ£æ¥ arr2 |
| | | cn.hutool.json.JSONArray arr2 = jsonObject.getJSONArray("arr2"); |
| | | for (int i = 0; i < arr2.size(); i++) { |
| | | cn.hutool.json.JSONObject obj = arr2.getJSONObject(i); |
| | | if (obj.getInt("state") == 2) { |
| | | product.setInsResult(0); |
| | | break; |
| | | } |
| | | } |
| | | // æ£æ¥ arr3 |
| | | cn.hutool.json.JSONArray arr3 = jsonObject.getJSONArray("arr3"); |
| | | for (int i = 0; i < arr3.size(); i++) { |
| | | cn.hutool.json.JSONObject obj = arr3.getJSONObject(i); |
| | | if (obj.getInt("state") == 2) { |
| | | product.setInsResult(0); |
| | | break; |
| | | } |
| | | } |
| | | insProductMapper.updateById(product); |
| | | } |
| | | else { |
| | | String notDetected = product.getInspectionItem() + " " + product.getInspectionItemSubclass(); |
| | | if(!set.contains(notDetected)) { |
| | | count++; |
| | | str += "<br/>" + count + "ï¼" + product.getInspectionItem() + " " + product.getInspectionItemSubclass() + "<br/>"; |
| | | set.add(notDetected); |
| | | } |
| | | |
| | | } |
| | | } |
| | | if (ObjectUtils.isNotEmpty(str)) { |
| | | throw new ErrorException("<strong>åå¨å¾
æ£éªç项ç®ï¼</strong><br/>" + str); |
| | | } |
| | | } |
| | | insOrderStateMapper.update(null, Wrappers.<InsOrderState>lambdaUpdate().eq(InsOrderState::getInsOrderId, orderId).eq(InsOrderState::getLaboratory, laboratory).set(InsOrderState::getInsTime, LocalDateTime.now()).set(InsOrderState::getInsState, 3).set(InsOrderState::getVerifyUser, verifyUser)); |
| | | Integer userId = SecurityUtils.getUserId().intValue(); |
| | | InformationNotification info = new InformationNotification(); |
| | | info.setCreateUser(insProductMapper.selectUserById(userId).get("name")); |
| | | info.setMessageType("2"); |
| | | info.setTheme("夿 ¸éç¥"); |
| | | info.setContent("æ¨æä¸æ¡æ£éªä»»å¡å¾
夿 ¸æ¶æ¯"); |
| | | info.setSenderId(userId); |
| | | info.setConsigneeId(verifyUser); |
| | | info.setViewStatus(false); |
| | | info.setJumpPath("b1-inspect-order-plan"); |
| | | informationNotificationService.addInformationNotification(info); |
| | | //夿 ¸äºº--æ£éªåç¸å
³è´è´£äºº |
| | | InsSampleUser insSampleUser = new InsSampleUser(); |
| | | insSampleUser.setUserId(verifyUser); |
| | | insSampleUser.setInsSampleId(orderId); |
| | | insSampleUser.setState(1); |
| | | insSampleUser.setSonLaboratory(laboratory); |
| | | insSampleUserMapper.insert(insSampleUser); |
| | | /*æ ¡éªä¸ä¸result表*/ |
| | | CompletableFuture.supplyAsync(() -> { |
| | | List<Integer> ips = insProducts.stream().map(InsProduct::getId).distinct().collect(Collectors.toList()); |
| | | for (Integer ip : ips) { |
| | | List<InsProductResult> insProductResults = insProductResultMapper.selectList(Wrappers.<InsProductResult>lambdaQuery() |
| | | .eq(InsProductResult::getInsProductId, ip)); |
| | | if (insProductResults.size() > 1) { |
| | | for (int i = 1; i < insProductResults.size(); i++) { |
| | | insProductResultMapper.deleteById(insProductResults.get(i)); |
| | | } |
| | | } |
| | | } |
| | | return null; |
| | | }); |
| | | // å 餿°éé鿬¡æ° |
| | | String key = "frequency" + ":" + entrustCode + ":*"; |
| | | RedisUtil.delsLike(key); |
| | | return 1; |
| | | } |
| | | |
| | | @Override |
| | | public List<String> getEquipName(Integer orderId,String sonLaboratory) { |
| | | List<Integer> ids = insSampleMapper.selectList(new LambdaQueryWrapper<InsSample>() |
| | | .eq(InsSample::getInsOrderId, orderId)) |
| | | .stream() |
| | | .map(InsSample::getId) |
| | | .collect(Collectors.toList()); |
| | | // æ¥çå忝å¦éæ©äºè®¾å¤ |
| | | List<String> strList = new ArrayList<>(); |
| | | HashSet<String> set = new HashSet<>(); |
| | | List<InsProduct> productList = insProductMapper.selectList(new LambdaQueryWrapper<InsProduct>() |
| | | .in(InsProduct::getInsSampleId, ids) |
| | | .eq(InsProduct::getSonLaboratory, sonLaboratory) |
| | | .eq(InsProduct::getState, 1)); |
| | | if (CollectionUtils.isNotEmpty(productList)) { |
| | | List<InsProduct> collect = productList.stream() |
| | | .filter(item -> Objects.isNull(item.getSpecialItemParentId()) || StringUtils.isEmpty(item.getSpecialItemParentId()+"")) |
| | | .collect(Collectors.toList()); |
| | | for (InsProduct product : collect) { |
| | | InsProductResult insProductResult = insProductResultMapper.selectOne(new LambdaQueryWrapper<InsProductResult>() |
| | | .eq(InsProductResult::getInsProductId, product.getId())); |
| | | if(Objects.nonNull(insProductResult)){ |
| | | if(Objects.isNull(insProductResult.getEquipName()) || StringUtils.isEmpty(insProductResult.getEquipName())) { |
| | | strList.add(product.getInspectionItem() + " " + product.getInspectionItemSubclass()); |
| | | }else { |
| | | List<Map> maps = JSONArray.parseArray(insProductResult.getEquipName(), Map.class); |
| | | if(CollectionUtils.isNotEmpty(maps)) { |
| | | List<Map> mapList = maps.stream().filter(item -> StringUtils.isEmpty(item.get("v") + "")).collect(Collectors.toList()); |
| | | if(mapList.size() == maps.size()) { |
| | | strList.add(product.getInspectionItem() + " " + product.getInspectionItemSubclass()); |
| | | } |
| | | // for (Map map : maps) { |
| | | // if(StringUtils.isEmpty(map.get("v")+"")){ |
| | | // strList.add(product.getInspectionItem() + " " + product.getInspectionItemSubclass()); |
| | | // } |
| | | // } |
| | | }else { |
| | | strList.add(product.getInspectionItem() + " " + product.getInspectionItemSubclass()); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | return strList.stream().distinct().collect(Collectors.toList()); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class,isolation = Isolation.READ_COMMITTED) |
| | | public int saveInsContext2(InsProductResultDTO insProductResult) { |
| | | Integer userId = SecurityUtils.getUserId().intValue(); |
| | | try { |
| | | //æ£éªç»æ |
| | | Map<String,Object> insValueMap = JackSonUtil.unmarshal(insProductResult.getInsValue(), Map.class); |
| | | //saveInsContext2æ¹æ³æå¤ä¸ªæ¨¡æ¿è°ç¨ï¼éæ ¹æ®æ¨¡æ¿åç§°åå¼å¤ç |
| | | switch (insProductResult.getTemplateName()){ |
| | | case "æ¶ç©ºå°çº¿åºååºå": |
| | | //ä¿åå¼¹æ§æ¨¡é忣éªç»è®º |
| | | if(Objects.nonNull(insValueMap.get("elasticityModulus"))){ |
| | | String elasticityModulus = insValueMap.get("elasticityModulus").toString(); |
| | | insProductMapper.update(null,Wrappers.<InsProduct>lambdaUpdate() |
| | | .set(InsProduct::getInsResult,3)//ç»è®ºè®¾ä¸ºä¸å¤å® |
| | | .set(InsProduct::getElasticityModulus,elasticityModulus) |
| | | .eq(InsProduct::getId,insProductResult.getInsProductId()) |
| | | ); |
| | | } |
| | | //å é¤å¼¹æ§æ¨¡ékey |
| | | insValueMap.remove("elasticityModulus"); |
| | | insProductResult.setInsValue(JackSonUtil.marshal(insValueMap)); |
| | | break; |
| | | case "ç²å³è¯éª": |
| | | //ä¿åæ£éªç»æ |
| | | if(Objects.nonNull(insValueMap.get("damage"))){ |
| | | String damage = insValueMap.get("damage").toString(); |
| | | Integer insResult = "符å".equals(damage)?1:0; |
| | | insProductMapper.update(null,Wrappers.<InsProduct>lambdaUpdate() |
| | | .set(InsProduct::getInsResult,insResult) |
| | | .set(InsProduct::getLastValue,damage) |
| | | .eq(InsProduct::getId,insProductResult.getInsProductId()) |
| | | ); |
| | | } |
| | | break; |
| | | } |
| | | List<InsProductResult> oldResults = new ArrayList<>(); |
| | | InsProductResult insProductResult1 = insProductResultMapper.selectOne(new LambdaQueryWrapper<InsProductResult>().eq(InsProductResult::getInsProductId, insProductResult.getInsProductId())); |
| | | //æ°å¢ææ´æ°æ£éªè®°å½ |
| | | if (ObjectUtils.isNull(insProductResult1)){ |
| | | insProductResultMapper.insert(insProductResult); |
| | | }else { |
| | | insProductResult.setId(insProductResult1.getId()); |
| | | oldResults.add(insProductResult1); |
| | | insProductResultMapper.updateById(insProductResult); |
| | | } |
| | | //æ·»å å·¥æ¶è®°å½ |
| | | InsOrder insOrder = insOrderMapper.selectById(insProductResult.getOrderId()); |
| | | InsSample insSample = insSampleMapper.selectById(insProductResult.getSampleId()); |
| | | InsProduct insProduct = insProductMapper.selectById(insProductResult.getInsProductId()); |
| | | InsProductResult newInsResult = new InsProductResult(); |
| | | BeanUtil.copyProperties(insProductResult,newInsResult); |
| | | WorkTimeDTO workTimeDTO = new WorkTimeDTO(userId,insOrder,insSample,insProduct,null,insProductResult.getSampleId(), String.valueOf(insProductResult.getInsProductId()),oldResults ,newInsResult); |
| | | String jsonStr = JackSonUtil.marshal(workTimeDTO); |
| | | //计ç®å·¥æ¶ |
| | | //TODO:è¯¥æ¹æ³ç®ååªæçµåç¨ï¼é»è®¤è·¯ç±ä½¿ç¨çµåç |
| | | sendQueueMessage(ExchangeConstants.WORK_TIME_EXCHANGE,RouterKeyConstants.DL_KEY,jsonStr); |
| | | }catch (Exception e){ |
| | | throw new RuntimeException(e); |
| | | } |
| | | return 0; |
| | | } |
| | | |
| | | // è·å两个localDateTimeçæ¯ä¸å¤© |
| | | public static List<LocalDateTime> getLocalDateTimesBetween(LocalDateTime start, LocalDateTime end) { |
| | | List<LocalDateTime> localDateTimes = new ArrayList<>(); |
| | | LocalDate currentDate = start.toLocalDate(); |
| | | LocalDateTime currentLocalDateTime = start; |
| | | while (!currentDate.isAfter(end.toLocalDate())) { |
| | | localDateTimes.add(currentLocalDateTime); |
| | | currentLocalDateTime = currentLocalDateTime.plusDays(1); |
| | | currentDate = currentDate.plusDays(1); |
| | | } |
| | | return localDateTimes; |
| | | } |
| | | |
| | | /** |
| | | * æ¥è¯¢æ£éªé¡¹å¯¹åºæ ååºé
ç½®çå·¥æ¶ä¿¡æ¯ |
| | | * @param insProduct |
| | | * @return |
| | | */ |
| | | public StandardProductVO getInspectWorkHourAndGroup(InsProduct insProduct){ |
| | | StandardProductVO standardProductVO = new StandardProductVO(); |
| | | if(!Objects.isNull(insProduct)){ |
| | | //æ¥è¯¢å¯¹åºæ ååº |
| | | List<StandardProductVO> productVO = standardProductListMapper.getStandardProductByInsProduct( |
| | | insProduct.getLaboratory(), |
| | | insProduct.getSampleType(), |
| | | insProduct.getSample(), |
| | | insProduct.getModel(), |
| | | insProduct.getInspectionItem(), |
| | | insProduct.getInspectionItemSubclass(), |
| | | insProduct.getSonLaboratory(), |
| | | insProduct.getStandardMethodListId()); |
| | | if(!productVO.isEmpty()){ |
| | | standardProductVO = productVO.get(0); |
| | | } |
| | | //æåºé´çæ£éªé¡¹ï¼åæ£éªé¡¹åçå·¥æ¶ä¿¡æ¯ |
| | | if(StringUtils.isNotBlank(insProduct.getSection()) && StringUtils.isNotBlank(standardProductVO.getSection())){ |
| | | try { |
| | | ObjectMapper objectMapper = new ObjectMapper(); |
| | | //åºé´è®¾ç½® |
| | | List<String> sectionList = (List<String>)objectMapper.readValue(standardProductVO.getSection(), List.class); |
| | | //éä¸åºé´ç䏿 |
| | | int i = sectionList.indexOf(insProduct.getSection()); |
| | | //è·å对åºä¸æ çå·¥æ¶åå·¥æ¶åç» |
| | | List<Double> hourList = (List<Double>)objectMapper.readValue(standardProductVO.getManHour(), List.class); |
| | | standardProductVO.setManHour(String.valueOf(hourList.get(i))); |
| | | } catch (JsonProcessingException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | } |
| | | } |
| | | return standardProductVO; |
| | | } |
| | | |
| | | public static String getWeek(String dayStr) { |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
| | | try { |
| | | Date date = sdf.parse(dayStr); |
| | | Calendar calendar = Calendar.getInstance(); |
| | | calendar.setTime(date); |
| | | int dayOfWeek = calendar.get(Calendar.DAY_OF_WEEK); |
| | | int day = calendar.get(Calendar.DAY_OF_MONTH); |
| | | return getWeekDay(dayOfWeek); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | |
| | | public static String getWeekDay(int dayOfWeek) { |
| | | switch (dayOfWeek) { |
| | | case Calendar.MONDAY: |
| | | return "å¨ä¸"; |
| | | case Calendar.TUESDAY: |
| | | return "å¨äº"; |
| | | case Calendar.WEDNESDAY: |
| | | return "å¨ä¸"; |
| | | case Calendar.THURSDAY: |
| | | return "å¨å"; |
| | | case Calendar.FRIDAY: |
| | | return "å¨äº"; |
| | | case Calendar.SATURDAY: |
| | | return "å¨å
"; |
| | | case Calendar.SUNDAY: |
| | | return "卿¥"; |
| | | default: |
| | | return "æªç¥"; |
| | | } |
| | | } |
| | | |
| | | } |