¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.inspect.amqp; |
| | | |
| | | import cn.hutool.core.date.DateTime; |
| | | import cn.hutool.core.date.DateUtil; |
| | | import cn.hutool.core.util.ObjectUtil; |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; |
| | | import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.fasterxml.jackson.core.JsonProcessingException; |
| | | import com.fasterxml.jackson.databind.ObjectMapper; |
| | | import com.rabbitmq.client.Channel; |
| | | |
| | | import com.ruoyi.basic.mapper.StandardProductListMapper; |
| | | import com.ruoyi.basic.vo.StandardProductVO; |
| | | import com.ruoyi.common.utils.JackSonUtil; |
| | | import com.ruoyi.inspect.amqp.constants.ExchangeConstants; |
| | | import com.ruoyi.inspect.amqp.constants.QueueConstants; |
| | | import com.ruoyi.inspect.amqp.constants.RouterKeyConstants; |
| | | import com.ruoyi.inspect.dto.WorkTimeDTO; |
| | | import com.ruoyi.inspect.mapper.InsProductMapper; |
| | | import com.ruoyi.inspect.mapper.InsProductResultMapper; |
| | | import com.ruoyi.inspect.mapper.InsSampleUserMapper; |
| | | import com.ruoyi.inspect.pojo.*; |
| | | import com.ruoyi.performance.mapper.AuxiliaryOutputWorkingHoursMapper; |
| | | import com.ruoyi.performance.mapper.PerformanceShiftMapper; |
| | | import com.ruoyi.performance.mapper.ShiftTimeMapper; |
| | | import com.ruoyi.performance.pojo.AuxiliaryOutputWorkingHours; |
| | | import com.ruoyi.performance.pojo.PerformanceShift; |
| | | import com.ruoyi.performance.pojo.ShiftTime; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.apache.logging.log4j.util.Strings; |
| | | import org.springframework.amqp.core.Message; |
| | | import org.springframework.amqp.rabbit.annotation.Exchange; |
| | | import org.springframework.amqp.rabbit.annotation.Queue; |
| | | import org.springframework.amqp.rabbit.annotation.QueueBinding; |
| | | import org.springframework.amqp.rabbit.annotation.RabbitListener; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.stereotype.Component; |
| | | import org.springframework.transaction.annotation.Isolation; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.io.IOException; |
| | | import java.math.BigDecimal; |
| | | import java.math.RoundingMode; |
| | | import java.text.SimpleDateFormat; |
| | | import java.time.LocalDate; |
| | | import java.time.LocalDateTime; |
| | | import java.time.LocalTime; |
| | | import java.time.format.DateTimeFormatter; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | @Slf4j |
| | | @Component |
| | | public class WorkTimeInsertConsumer { |
| | | |
| | | @Resource |
| | | private StandardProductListMapper standardProductListMapper; |
| | | |
| | | @Resource |
| | | private InsSampleUserMapper insSampleUserMapper; |
| | | |
| | | @Resource |
| | | private InsProductMapper insProductMapper; |
| | | |
| | | @Resource |
| | | private ShiftTimeMapper shiftTimeMapper; |
| | | |
| | | @Resource |
| | | private PerformanceShiftMapper performanceShiftMapper; |
| | | |
| | | @Resource |
| | | private InsProductResultMapper insProductResultMapper; |
| | | |
| | | @Resource |
| | | AuxiliaryOutputWorkingHoursMapper auxiliaryOutputWorkingHoursMapper; |
| | | |
| | | /** |
| | | * å·¥æ¶è®¡ç®æ¶è´¹è
-å
纤è¯éªå®¤ |
| | | * @param jsonStr |
| | | * @param channel |
| | | * @param message |
| | | */ |
| | | @Transactional(rollbackFor = Exception.class,isolation = Isolation.READ_COMMITTED) |
| | | @RabbitListener(bindings = @QueueBinding(key = {RouterKeyConstants.GX_KEY},value = @Queue(QueueConstants.GX_QUEUE),exchange = @Exchange(name = ExchangeConstants.WORK_TIME_EXCHANGE))) |
| | | public void addWorkTimeListenerByGX(String jsonStr, Channel channel, Message message){ |
| | | long deliveryTag = message.getMessageProperties().getDeliveryTag(); |
| | | WorkTimeDTO workTimeDTO = new WorkTimeDTO(); |
| | | try { |
| | | workTimeDTO = JackSonUtil.unmarshal(jsonStr,WorkTimeDTO.class); |
| | | addWorkTimeRecord( |
| | | workTimeDTO.getUserId(), |
| | | workTimeDTO.getInsOrder(), |
| | | workTimeDTO.getInsSample(), |
| | | workTimeDTO.getInsProduct(), |
| | | workTimeDTO.getParentInsProduct(), |
| | | workTimeDTO.getCurrentSampleId(), |
| | | workTimeDTO.getInsProductId(), |
| | | workTimeDTO.getOldResults(), |
| | | workTimeDTO.getNewResult() |
| | | ); |
| | | //æ§è¡æåï¼æå¨ç¡®è®¤ |
| | | channel.basicAck(deliveryTag,false); |
| | | log.info("å
纤è¯éªå®¤å·¥æ¶è®¡ç®éå:æ§è¡æåï¼ç¨æ·id:{},æ£éªé¡¹id:{}",workTimeDTO.getUserId(),workTimeDTO.getInsProductId()); |
| | | } catch (Exception e) { |
| | | log.error("å
纤è¯éªå®¤å·¥æ¶è®¡ç®éå:æ§è¡å¤±è´¥ï¼ç¨æ·id:{},æ£éªé¡¹id:{}",workTimeDTO.getUserId(),workTimeDTO.getInsProductId(),e); |
| | | try { |
| | | channel.basicNack(deliveryTag,false,false); |
| | | } catch (IOException ex) { |
| | | throw new RuntimeException(ex); |
| | | } |
| | | throw new RuntimeException(e); |
| | | } |
| | | } |
| | | /** |
| | | * å·¥æ¶è®¡ç®æ¶è´¹è
-ææè¯éªå®¤ |
| | | * @param jsonStr |
| | | * @param channel |
| | | * @param message |
| | | */ |
| | | @Transactional(rollbackFor = Exception.class,isolation = Isolation.READ_COMMITTED) |
| | | @RabbitListener(bindings = @QueueBinding(key = {RouterKeyConstants.CL_KEY},value = @Queue(QueueConstants.CL_QUEUE),exchange = @Exchange(name = ExchangeConstants.WORK_TIME_EXCHANGE))) |
| | | public void addWorkTimeListenerByCL(String jsonStr, Channel channel, Message message){ |
| | | long deliveryTag = message.getMessageProperties().getDeliveryTag(); |
| | | WorkTimeDTO workTimeDTO = new WorkTimeDTO(); |
| | | try { |
| | | workTimeDTO = JackSonUtil.unmarshal(jsonStr,WorkTimeDTO.class); |
| | | addWorkTimeRecord( |
| | | workTimeDTO.getUserId(), |
| | | workTimeDTO.getInsOrder(), |
| | | workTimeDTO.getInsSample(), |
| | | workTimeDTO.getInsProduct(), |
| | | workTimeDTO.getParentInsProduct(), |
| | | workTimeDTO.getCurrentSampleId(), |
| | | workTimeDTO.getInsProductId(), |
| | | workTimeDTO.getOldResults(), |
| | | workTimeDTO.getNewResult() |
| | | ); |
| | | //æ§è¡æåï¼æå¨ç¡®è®¤ |
| | | channel.basicAck(deliveryTag,false); |
| | | log.info("ææè¯éªå®¤å·¥æ¶è®¡ç®éå:æ§è¡æåï¼ç¨æ·id:{},æ£éªé¡¹id:{}",workTimeDTO.getUserId(),workTimeDTO.getInsProductId()); |
| | | } catch (Exception e) { |
| | | log.error("ææè¯éªå®¤å·¥æ¶è®¡ç®éå:æ§è¡å¤±è´¥ï¼ç¨æ·id:{},æ£éªé¡¹id:{}",workTimeDTO.getUserId(),workTimeDTO.getInsProductId(),e); |
| | | try { |
| | | channel.basicNack(deliveryTag,false,false); |
| | | } catch (IOException ex) { |
| | | throw new RuntimeException(ex); |
| | | } |
| | | throw new RuntimeException(e); |
| | | } |
| | | } |
| | | /** |
| | | * å·¥æ¶è®¡ç®æ¶è´¹è
-æºæ¢°æ§è½è¯éªå®¤ |
| | | * @param jsonStr |
| | | * @param channel |
| | | * @param message |
| | | */ |
| | | @Transactional(rollbackFor = Exception.class,isolation = Isolation.READ_COMMITTED) |
| | | @RabbitListener(bindings = @QueueBinding(key = {RouterKeyConstants.JX_KEY},value = @Queue(QueueConstants.JX_QUEUE),exchange = @Exchange(name = ExchangeConstants.WORK_TIME_EXCHANGE))) |
| | | public void addWorkTimeListenerByJX(String jsonStr, Channel channel, Message message){ |
| | | long deliveryTag = message.getMessageProperties().getDeliveryTag(); |
| | | WorkTimeDTO workTimeDTO = new WorkTimeDTO(); |
| | | try { |
| | | workTimeDTO = JackSonUtil.unmarshal(jsonStr,WorkTimeDTO.class); |
| | | addWorkTimeRecord( |
| | | workTimeDTO.getUserId(), |
| | | workTimeDTO.getInsOrder(), |
| | | workTimeDTO.getInsSample(), |
| | | workTimeDTO.getInsProduct(), |
| | | workTimeDTO.getParentInsProduct(), |
| | | workTimeDTO.getCurrentSampleId(), |
| | | workTimeDTO.getInsProductId(), |
| | | workTimeDTO.getOldResults(), |
| | | workTimeDTO.getNewResult() |
| | | ); |
| | | //æ§è¡æåï¼æå¨ç¡®è®¤ |
| | | channel.basicAck(deliveryTag,false); |
| | | log.info("æºæ¢°æ§è½è¯éªå®¤å·¥æ¶è®¡ç®éå:æ§è¡æåï¼ç¨æ·id:{},æ£éªé¡¹id:{}",workTimeDTO.getUserId(),workTimeDTO.getInsProductId()); |
| | | } catch (Exception e) { |
| | | log.error("æºæ¢°æ§è½è¯éªå®¤å·¥æ¶è®¡ç®éå:æ§è¡å¤±è´¥ï¼ç¨æ·id:{},æ£éªé¡¹id:{}",workTimeDTO.getUserId(),workTimeDTO.getInsProductId(),e); |
| | | try { |
| | | channel.basicNack(deliveryTag,false,false); |
| | | } catch (IOException ex) { |
| | | throw new RuntimeException(ex); |
| | | } |
| | | throw new RuntimeException(e); |
| | | } |
| | | } |
| | | /** |
| | | * å·¥æ¶è®¡ç®æ¶è´¹è
-çµåè¯éªå®¤ |
| | | * @param jsonStr |
| | | * @param channel |
| | | * @param message |
| | | */ |
| | | @Transactional(rollbackFor = Exception.class,isolation = Isolation.READ_COMMITTED) |
| | | @RabbitListener(bindings = @QueueBinding(key = {RouterKeyConstants.DL_KEY},value = @Queue(QueueConstants.DL_QUEUE),exchange = @Exchange(name = ExchangeConstants.WORK_TIME_EXCHANGE))) |
| | | public void addWorkTimeListenerByDL(String jsonStr, Channel channel, Message message){ |
| | | long deliveryTag = message.getMessageProperties().getDeliveryTag(); |
| | | WorkTimeDTO workTimeDTO = new WorkTimeDTO(); |
| | | try { |
| | | workTimeDTO = JackSonUtil.unmarshal(jsonStr,WorkTimeDTO.class); |
| | | addWorkTimeRecord( |
| | | workTimeDTO.getUserId(), |
| | | workTimeDTO.getInsOrder(), |
| | | workTimeDTO.getInsSample(), |
| | | workTimeDTO.getInsProduct(), |
| | | workTimeDTO.getParentInsProduct(), |
| | | workTimeDTO.getCurrentSampleId(), |
| | | workTimeDTO.getInsProductId(), |
| | | workTimeDTO.getOldResults(), |
| | | workTimeDTO.getNewResult() |
| | | ); |
| | | //æ§è¡æåï¼æå¨ç¡®è®¤ |
| | | channel.basicAck(deliveryTag,false); |
| | | log.info("çµåè¯éªå®¤å·¥æ¶è®¡ç®éå:æ§è¡æåï¼ç¨æ·id:{},æ£éªé¡¹id:{}",workTimeDTO.getUserId(),workTimeDTO.getInsProductId()); |
| | | } catch (Exception e) { |
| | | log.error("çµåè¯éªå®¤å·¥æ¶è®¡ç®éå:æ§è¡å¤±è´¥ï¼ç¨æ·id:{},æ£éªé¡¹id:{}",workTimeDTO.getUserId(),workTimeDTO.getInsProductId(),e); |
| | | try { |
| | | channel.basicNack(deliveryTag,false,false); |
| | | } catch (IOException ex) { |
| | | throw new RuntimeException(ex); |
| | | } |
| | | throw new RuntimeException(e); |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * æ·»å å·¥æ¶è®°å½ |
| | | * @param userId å½åç»å½äººid |
| | | * @param insOrder 订åä¸»ä½ |
| | | * @param insSample æ ·åä¿¡æ¯ |
| | | * @param insProduct æ£éªé¡¹ä¿¡æ¯ |
| | | * @param parentInsProduct ç¶æ£éªé¡¹ä¿¡æ¯ |
| | | * @param currentSampleId å½åæ ·åid |
| | | * @param k 循ç¯key,å½åæ£éªé¡¹id |
| | | * @param oldResults æ§çæ£éªç»æå表 |
| | | * @param newResult æ°çæ£éªç»æ |
| | | */ |
| | | public synchronized void addWorkTimeRecord(Integer userId, |
| | | InsOrder insOrder, |
| | | InsSample insSample, |
| | | InsProduct insProduct, |
| | | InsProduct parentInsProduct, |
| | | Integer currentSampleId, |
| | | String k, |
| | | List<InsProductResult> oldResults, |
| | | InsProductResult newResult){ |
| | | //æ ¡éªå¦æè¿ä¸ªäººè¿ä¸ªæ£æµé¡¹ç®å·²ç»æ·»å è¿äºåä¸éè¦åæ°å¢ |
| | | //é¦å
夿å½å人çå½åæ¶é´æ¯å¦æ¯æçæ¶é´å
,妿䏿¯å°±æ¯å ç |
| | | LocalDateTime today = LocalDateTime.of(LocalDate.now(), LocalTime.MIDNIGHT); |
| | | PerformanceShift performanceShift = performanceShiftMapper.selectOne(Wrappers.<PerformanceShift>lambdaQuery() |
| | | .eq(PerformanceShift::getUserId, userId) |
| | | .eq(PerformanceShift::getWorkTime, today)); |
| | | if (ObjectUtils.isNotEmpty(performanceShift)) { |
| | | ShiftTime shiftTime = shiftTimeMapper.selectOne(Wrappers.<ShiftTime>lambdaQuery().eq(ShiftTime::getShift, performanceShift.getShift())); |
| | | // å天çæ
åµ 7:30 23:30 |
| | | if(performanceShift.getShift().equals("5")) { |
| | | shiftTime = new ShiftTime(); |
| | | shiftTime.setStartTime("07:30"); |
| | | shiftTime.setEndTime("23:30"); |
| | | } |
| | | // æ£æ¥å½åæ¶é´æ¯å¦å¨èå´å
ï¼å
æ¬è¾¹çï¼ |
| | | boolean isWithinRange; |
| | | boolean isCross; // æ¯å¦å°å½åæ£éªååçå·¥æ¶è®¡ç®å°ç次å¼å§å¤© |
| | | DateTimeFormatter forma = DateTimeFormatter.ofPattern("HH:mm"); |
| | | LocalTime now = LocalTime.now(); |
| | | |
| | | //shiftTime为空ï¼è¡¨ç¤ºæªé
ç½®æ¶é´ |
| | | if(Objects.isNull(shiftTime)){ |
| | | isCross = true; |
| | | isWithinRange=false; |
| | | }else{ |
| | | LocalTime startTime = LocalTime.parse(shiftTime.getStartTime(), forma); |
| | | LocalTime endTime = LocalTime.parse(shiftTime.getEndTime(), forma); |
| | | |
| | | // 妿å½åæ¶é´ä¸å¨ä»å¤©ççæ¬¡å
17:00~5.00 15.00 é¦å
夿æ¯å¦è·¨å¤©äº |
| | | // 跨天çæ
åµ |
| | | if (startTime.isAfter(endTime)) { |
| | | // æ¥çå½åæ¶é´æ¯å¦å¨ç次æ¶é´å
|
| | | if (now.isAfter(startTime)) { |
| | | // 妿æ¯å¨ç»ææ¶é´ä¹åé£ä¹å°±æ¯æ£å¸¸ä¸ç |
| | | isWithinRange = true; |
| | | isCross = false; |
| | | } else { |
| | | // å½åæ¶é´ä¸å¨ç次å
ï¼æ¥çæ¨å¤©ççæ¬¡ |
| | | LocalDateTime yesterday = LocalDateTime.of(LocalDate.now().minusDays(1), LocalTime.MIDNIGHT); |
| | | PerformanceShift yesterdayShift = performanceShiftMapper.selectOne(Wrappers.<PerformanceShift>lambdaQuery() |
| | | .eq(PerformanceShift::getUserId, userId) |
| | | .eq(PerformanceShift::getWorkTime, yesterday)); |
| | | ShiftTime yesterdayShiftTime = shiftTimeMapper.selectOne(Wrappers.<ShiftTime>lambdaQuery().eq(ShiftTime::getShift, yesterdayShift.getShift())); |
| | | // 妿æ¨å¤©ççæ¬¡ä¸ä¸ºç©ºï¼é£ä¹å°±è¦çæ¨å¤©ççæ¬¡æ¶é´ |
| | | if (!Objects.isNull(yesterdayShiftTime)) { |
| | | LocalTime yesterdayStartTime = LocalTime.parse(yesterdayShiftTime.getStartTime(), forma); |
| | | LocalTime yesterdayEndTime = LocalTime.parse(yesterdayShiftTime.getEndTime(), forma); |
| | | // æ¨å¤©ççæ¬¡æ¯å¦è·¨å¤© |
| | | if (yesterdayStartTime.isAfter(yesterdayEndTime)) { |
| | | // 妿æ¨å¤©ççæ¬¡è·¨å¤©äºï¼é£ä¹å°±è¦çä»å¤©æ¯å¦å¨æ¨å¤©ççæ¬¡å
ï¼å¹¶ä¸åªè½æ¯å¨ç»ææ¶é´ä¹åï¼å·²ç»å®ç°äºè·¨å¤© |
| | | if (now.isBefore(yesterdayEndTime)) { |
| | | // 卿¨å¤©ç次æ¶é´å
æ£å¸¸ä¸çï¼å·¥æ¶è®¡ç®å°æ¨å¤© |
| | | isWithinRange = true; |
| | | isCross = true; |
| | | } else { |
| | | // ä¸å¨æ¨å¤©ç次æ¶é´å
å°±æ¯å çï¼å·¥æ¶è®¡ç®å°æ¨å¤© |
| | | isWithinRange = false; |
| | | isCross = true; |
| | | } |
| | | } else { |
| | | // æ¨å¤©ççæ¬¡æ²¡æè·¨å¤© 妿å½åæ¶é´å¨ä»å¤©ç次å¼å§æ¶é´ä¹åå°±æ¯æ¨å¤©çå çï¼å¦åå°±æ¯ä»å¤©çå ç |
| | | if (now.isBefore(startTime)) { |
| | | isWithinRange = false; |
| | | isCross = true; |
| | | } else { |
| | | isWithinRange = false; |
| | | isCross = false; |
| | | } |
| | | } |
| | | } else { |
| | | isWithinRange = false; |
| | | // 妿æ¯å¨å¼å§æ¶é´ä¹åé£ä¹å°±è¦ç®å°æ¨å¤© |
| | | if (now.isBefore(startTime)) { |
| | | isCross = true; |
| | | } else { |
| | | isCross = false; |
| | | } |
| | | } |
| | | } |
| | | } else { |
| | | // å½åçæ¬¡ä¸è·¨å¤©çæ
åµä¸ |
| | | // 妿å½åæ¶é´å¨å¼å§æ¶é´ä¹åï¼æ¥æ¨å¤©ççæ¬¡çå½åæ¶é´æ¯å¦å¨æ¨å¤©ççæ¬¡å
|
| | | if (now.isBefore(startTime)) { |
| | | // æ¥çæ¨å¤©æ¯å¦è·¨å¤© |
| | | LocalDateTime yesterday = LocalDateTime.of(LocalDate.now().minusDays(1), LocalTime.MIDNIGHT); |
| | | PerformanceShift yesterdayShift = performanceShiftMapper.selectOne(Wrappers.<PerformanceShift>lambdaQuery() |
| | | .eq(PerformanceShift::getUserId, userId) |
| | | .eq(PerformanceShift::getWorkTime, yesterday)); |
| | | ShiftTime yesterdayShiftTime = shiftTimeMapper.selectOne(Wrappers.<ShiftTime>lambdaQuery().eq(ShiftTime::getShift, yesterdayShift.getShift())); |
| | | LocalTime yesterdayStartTime = LocalTime.parse(yesterdayShiftTime.getStartTime(), forma); |
| | | LocalTime yesterdayEndTime = LocalTime.parse(yesterdayShiftTime.getEndTime(), forma); |
| | | if (yesterdayStartTime.isAfter(yesterdayEndTime)) { |
| | | // 妿æ¨å¤©è·¨å¤© |
| | | if (now.isBefore(yesterdayEndTime)) { |
| | | // 卿¨å¤©ççæ¬¡æ¶é´å
æ£å¸¸ä¸çï¼å·¥æ¶è®¡ç®å°æ¨å¤© |
| | | isWithinRange = true; |
| | | isCross = true; |
| | | } else { |
| | | // ä¸å¨æ¨å¤©ç次æ¶é´å
å°±æ¯å çï¼å·¥æ¶è®¡ç®å°æ¨å¤© |
| | | isWithinRange = false; |
| | | isCross = true; |
| | | } |
| | | } else { |
| | | // æ¨å¤©ä¸è·¨å¤© |
| | | isWithinRange = false; |
| | | isCross = true; |
| | | } |
| | | } else if (now.isAfter(endTime)) { |
| | | // 妿å½åæ¶é´å¨ç»ææ¶é´ä¹åï¼é£ä¹å°±æ¯ä»å¤©çå ç |
| | | isWithinRange = false; |
| | | isCross = false; |
| | | } else { |
| | | // æ£å¸¸ä¸ç |
| | | isWithinRange = true; |
| | | isCross = false; |
| | | } |
| | | } |
| | | } |
| | | //æ£éªç¶é¡¹åç§° |
| | | String inspectItem = ObjectUtil.isNotNull(parentInsProduct) ? parentInsProduct.getInspectionItem() : insProduct.getInspectionItem(); |
| | | //æ£éªå项åç§° |
| | | String inspectSubItem = ObjectUtil.isNotNull(parentInsProduct) ? parentInsProduct.getInspectionItemSubclass() : insProduct.getInspectionItemSubclass(); |
| | | //å ç |
| | | List<AuxiliaryOutputWorkingHours> count1s = auxiliaryOutputWorkingHoursMapper.selectList(Wrappers.<AuxiliaryOutputWorkingHours>lambdaQuery() |
| | | .eq(AuxiliaryOutputWorkingHours::getCheckId, userId) |
| | | .eq(AuxiliaryOutputWorkingHours::getInspectionItem, inspectItem) |
| | | .eq(AuxiliaryOutputWorkingHours::getInspectionItemSubclass, inspectSubItem) |
| | | .eq(AuxiliaryOutputWorkingHours::getOvertimeOrderNo, insOrder.getEntrustCode()) |
| | | .eq(AuxiliaryOutputWorkingHours::getSample, insSample.getSampleCode())); |
| | | if (count1s.size() > 1) { |
| | | for (int i = 1; i < count1s.size(); i++) { |
| | | // ç¹æ®é¡¹ç®ä¸è½å é¤ |
| | | List<String> arrList = Arrays.asList("温度循ç¯", "ç循ç¯", "温åè¯éª", "åæ ¹åç´çç§", "æ¶æ¯è¯ä¼°"); |
| | | if (arrList.contains(count1s.get(i).getInspectionItem()) || |
| | | count1s.get(i).getInspectionItem().contains("æ¾å¥ç®¡") || |
| | | count1s.get(i).getInspectionItemSubclass().contains("æ¾å¥ç®¡") || |
| | | !Objects.isNull(insProduct.getInsFiberId()) || |
| | | !Objects.isNull(insProduct.getInsFibersId())) { |
| | | continue; |
| | | } |
| | | // 妿æ¯å
纤é
ç½®ä¸çå
纤æ¥å¤´æèï¼é£ä¹å°±å é¤ |
| | | if((!Objects.isNull(insProduct.getInsFiberId()) || |
| | | !Objects.isNull(insProduct.getInsFibersId())) && insProduct.getInspectionItem().equals("å
纤æ¥å¤´æè") ) { |
| | | auxiliaryOutputWorkingHoursMapper.deleteById(count1s.get(i)); |
| | | } |
| | | auxiliaryOutputWorkingHoursMapper.deleteById(count1s.get(i)); |
| | | } |
| | | } |
| | | //éå ç |
| | | List<AuxiliaryOutputWorkingHours> count2s = auxiliaryOutputWorkingHoursMapper.selectList(Wrappers.<AuxiliaryOutputWorkingHours>lambdaQuery() |
| | | .eq(AuxiliaryOutputWorkingHours::getCheckId, userId) |
| | | .eq(AuxiliaryOutputWorkingHours::getInspectionItem, inspectItem) |
| | | .eq(AuxiliaryOutputWorkingHours::getInspectionItemSubclass, inspectSubItem) |
| | | .eq(AuxiliaryOutputWorkingHours::getOrderNo, insOrder.getEntrustCode()) |
| | | .eq(AuxiliaryOutputWorkingHours::getSample, insSample.getSampleCode())); |
| | | if (count2s.size() > 1) { |
| | | for (int i = 1; i < count2s.size(); i++) { |
| | | // ç¹æ®é¡¹ç®ä¸è½å é¤ |
| | | List<String> arrList = Arrays.asList("温度循ç¯", "ç循ç¯", "温åè¯éª", "åæ ¹åç´çç§", "æ¶æ¯è¯ä¼°"); |
| | | if (arrList.contains(count2s.get(i).getInspectionItem()) || |
| | | count2s.get(i).getInspectionItem().contains("æ¾å¥ç®¡") || |
| | | count2s.get(i).getInspectionItemSubclass().contains("æ¾å¥ç®¡") || |
| | | !Objects.isNull(insProduct.getInsFiberId()) || |
| | | !Objects.isNull(insProduct.getInsFibersId())) { |
| | | continue; |
| | | } |
| | | // 妿æ¯å
纤é
ç½®ä¸çå
纤æ¥å¤´æèï¼é£ä¹å°±å é¤ |
| | | if((!Objects.isNull(insProduct.getInsFiberId()) || |
| | | !Objects.isNull(insProduct.getInsFibersId())) && insProduct.getInspectionItem().equals("å
纤æ¥å¤´æè")) { |
| | | auxiliaryOutputWorkingHoursMapper.deleteById(count2s.get(i)); |
| | | } |
| | | auxiliaryOutputWorkingHoursMapper.deleteById(count2s.get(i)); |
| | | } |
| | | } |
| | | //产éå·¥æ¶è®¡ç® |
| | | AuxiliaryOutputWorkingHours auxiliaryOutputWorkingHours = new AuxiliaryOutputWorkingHours(); |
| | | //å·¥æ¶ |
| | | BigDecimal manHour = BigDecimal.ZERO; |
| | | // Double manHour = 0.0; |
| | | StandardProductVO workHourMap = getInspectWorkHourAndGroup(Objects.isNull(parentInsProduct) ? insProduct : parentInsProduct); |
| | | if (ObjectUtil.isNotNull(workHourMap)) { |
| | | manHour = new BigDecimal(workHourMap.getManHour()); |
| | | } |
| | | if (isWithinRange) { |
| | | //卿¶é´å
å°±æ¯æ£å¸¸ä¸ç |
| | | auxiliaryOutputWorkingHours.setOrderNo(insOrder.getEntrustCode());//éå çå§æåå· |
| | | auxiliaryOutputWorkingHours.setWorkTime(manHour.doubleValue());//éå çå·¥æ¶ |
| | | auxiliaryOutputWorkingHours.setAmount(1);//éå çæ°é |
| | | } else { |
| | | //å ç |
| | | auxiliaryOutputWorkingHours.setOvertimeOrderNo(insOrder.getEntrustCode());//å çå§æåå· |
| | | auxiliaryOutputWorkingHours.setOvertimeWorkTime(manHour.doubleValue());//å çå·¥æ¶ |
| | | auxiliaryOutputWorkingHours.setOvertimeAmount(1);//å çæ°é |
| | | } |
| | | |
| | | //æ°å¢å·¥æ¶ |
| | | if (CollectionUtils.isEmpty(count2s) && CollectionUtils.isEmpty(count1s)) { |
| | | //æ¥ææ ¼å¼ |
| | | DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); |
| | | DateTimeFormatter formatters = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); |
| | | //å½åæ¶é´ |
| | | LocalDateTime localDateTime = LocalDateTime.now(); |
| | | DateTime parse = DateUtil.parse(localDateTime.format(formatter)); |
| | | //æåºå
Œ
±å段 |
| | | auxiliaryOutputWorkingHours.setInspectionItem(inspectItem);//æ£æµç¶é¡¹ |
| | | auxiliaryOutputWorkingHours.setInspectionItemSubclass(inspectSubItem);//æ£æµå项 |
| | | auxiliaryOutputWorkingHours.setSample(insSample.getSampleCode());//æ ·åç¼å· |
| | | auxiliaryOutputWorkingHours.setOutputWorkTime((ObjectUtils.isNotEmpty(auxiliaryOutputWorkingHours.getOvertimeWorkTime()) ? auxiliaryOutputWorkingHours.getOvertimeWorkTime() : 0) + (ObjectUtils.isNotEmpty(auxiliaryOutputWorkingHours.getWorkTime()) ? auxiliaryOutputWorkingHours.getWorkTime() : 0));//产éå·¥æ¶ |
| | | auxiliaryOutputWorkingHours.setManHourGroup(workHourMap.getManHourGroup());//å·¥æ¶åç» |
| | | if (isCross) { |
| | | List<Integer> list = Arrays.asList(3, 4, 6); // 伿¯ 请å åºå·® |
| | | List<PerformanceShift> performanceShifts = performanceShiftMapper.selectList(new LambdaQueryWrapper<PerformanceShift>() |
| | | .eq(PerformanceShift::getUserId, userId) |
| | | .lt(PerformanceShift::getWorkTime, localDateTime.toLocalDate().atStartOfDay().format(formatters)) |
| | | .notIn(PerformanceShift::getShift, list) |
| | | .orderByDesc(PerformanceShift::getWorkTime)); |
| | | auxiliaryOutputWorkingHours.setDateTime(performanceShifts.get(0).getWorkTime().format(formatters));//æ¥æ åä¸å¤© |
| | | |
| | | } else { |
| | | auxiliaryOutputWorkingHours.setDateTime(LocalDateTime.now().toLocalDate().atStartOfDay().format(formatters));//æ¥æ å½å天 |
| | | } |
| | | auxiliaryOutputWorkingHours.setWeekDay(getWeek(localDateTime.format(formatters)));//ææ |
| | | auxiliaryOutputWorkingHours.setWeek(String.valueOf(DateUtil.weekOfYear(DateUtil.offsetDay(parse, 1))));//卿¬¡ |
| | | auxiliaryOutputWorkingHours.setCheckId(userId);//æ£æµäºº |
| | | try { |
| | | |
| | | if (CollectionUtils.isEmpty(oldResults) && !newResult.getInsValue().equals("[]") || |
| | | (CollectionUtils.isNotEmpty(oldResults) && !oldResults.get(0).getInsValue().equals(newResult.getInsValue())/* && !oldResults.get(0).getInsValue().equals("[]")*/) || |
| | | (newResult.getInsValue().equals("[]") && !newResult.getComValue().equals("[]"))) { |
| | | List<String> insItems = Arrays.asList("æ¡å", "ææå", "ç ´æ"); |
| | | if (StringUtils.equals("çµå产åå®éªå®¤", insProduct.getLaboratory()) && insItems.contains(insProduct.getInspectionItem())) { |
| | | //çµå产åå®éªå®¤çæ¡ååææå项ç®ï¼å䏿£éªç人åé½è¦å å·¥æ¶ |
| | | //æ¥è¯¢å䏿£éªç人å |
| | | List<InsSampleUser> insSampleUsers = insSampleUserMapper.selectList(Wrappers.<InsSampleUser>lambdaQuery().eq(InsSampleUser::getInsSampleId, insOrder.getId())); |
| | | insSampleUsers.forEach(user -> { |
| | | auxiliaryOutputWorkingHours.setCheckId(user.getUserId());//æ£æµäºº |
| | | auxiliaryOutputWorkingHoursMapper.insert(auxiliaryOutputWorkingHours); |
| | | auxiliaryOutputWorkingHours.setId(null); |
| | | }); |
| | | |
| | | } else { |
| | | if (insProduct.getInspectionItem().contains("å¼§å")) { |
| | | // æ ·åä¸çæ£éªé¡¹å
å«å¼§åçä¸ªæ° |
| | | AuxiliaryOutputWorkingHours sampleCount = auxiliaryOutputWorkingHoursMapper.selectOne(new LambdaQueryWrapper<AuxiliaryOutputWorkingHours>() |
| | | .eq(AuxiliaryOutputWorkingHours::getSample, insSample.getSampleCode()) // æ ·åç¼å· |
| | | .eq(AuxiliaryOutputWorkingHours::getInspectionItem, parentInsProduct.getInspectionItem()) // æ£éªé¡¹ç® |
| | | .and(item -> item.eq(AuxiliaryOutputWorkingHours::getOrderNo, insOrder.getEntrustCode()) // éå çå§æåå· |
| | | .or() |
| | | .eq(AuxiliaryOutputWorkingHours::getOvertimeOrderNo, insOrder.getEntrustCode())) // å çå§æåå· |
| | | ); |
| | | auxiliaryOutputWorkingHours.setInspectionItem(parentInsProduct.getInspectionItem()); |
| | | if (Objects.isNull(sampleCount)) { |
| | | auxiliaryOutputWorkingHoursMapper.insert(auxiliaryOutputWorkingHours); |
| | | } |
| | | } else { |
| | | auxiliaryOutputWorkingHoursMapper.insert(auxiliaryOutputWorkingHours); |
| | | } |
| | | } |
| | | } else if (inspectItem.equals("åºååºå") && inspectSubItem.equals("å¼¹æ§æ¨¡é")) { |
| | | auxiliaryOutputWorkingHoursMapper.insert(auxiliaryOutputWorkingHours); |
| | | } |
| | | } catch (Exception e) { |
| | | log.error("å·¥æ¶æ°å¢å¤±è´¥-->",e); |
| | | } |
| | | } else { |
| | | // æ¥è¯¢å½åæ£éªé¡¹çå·¥æ¶æ·»å è®°å½ |
| | | List<AuxiliaryOutputWorkingHours> oldRecords = auxiliaryOutputWorkingHoursMapper.selectList(Wrappers.<AuxiliaryOutputWorkingHours>lambdaQuery() |
| | | .eq(AuxiliaryOutputWorkingHours::getCheckId, userId) |
| | | .eq(AuxiliaryOutputWorkingHours::getInspectionItem, inspectItem) |
| | | .eq(AuxiliaryOutputWorkingHours::getInspectionItemSubclass, inspectSubItem) |
| | | .eq(AuxiliaryOutputWorkingHours::getSample, insSample.getSampleCode()) |
| | | .and(i -> i.eq(AuxiliaryOutputWorkingHours::getOrderNo, insOrder.getEntrustCode()) |
| | | .or() |
| | | .eq(AuxiliaryOutputWorkingHours::getOvertimeOrderNo, insOrder.getEntrustCode())) |
| | | .orderByAsc(AuxiliaryOutputWorkingHours::getDateTime) |
| | | ); |
| | | List<String> special = Arrays.asList("温度循ç¯", "ç循ç¯", "温åè¯éª", "åæ ¹åç´çç§", "æ¶æ¯è¯ä¼°"); |
| | | if (special.contains(inspectItem) || inspectItem.contains("æ¾å¥ç®¡") || inspectSubItem.contains("æ¾å¥ç®¡") || |
| | | !Objects.isNull(insProduct.getInsFiberId()) || |
| | | !Objects.isNull(insProduct.getInsFibersId())) { |
| | | // æ¯å¦éè¦è·¨å¤© |
| | | if (isCross) { |
| | | DateTimeFormatter formatters = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); |
| | | List<Integer> list = Arrays.asList(3, 4, 6); // 伿¯ 请å åºå·® |
| | | List<PerformanceShift> performanceShifts = performanceShiftMapper.selectList(new LambdaQueryWrapper<PerformanceShift>() |
| | | .eq(PerformanceShift::getUserId, userId) |
| | | .lt(PerformanceShift::getWorkTime, LocalDateTime.now().toLocalDate().atStartOfDay().format(formatters)) |
| | | .notIn(PerformanceShift::getShift, list) |
| | | .orderByDesc(PerformanceShift::getWorkTime)); |
| | | String date = performanceShifts.get(0).getWorkTime().format(formatters); // å颿£å¸¸ä¸ççæ¥æ |
| | | boolean addOrUpdate; |
| | | // è¿æ»¤åºæ¥æä¸è´çè®°å½ |
| | | List<AuxiliaryOutputWorkingHours> collect2 = oldRecords.stream().filter(item -> item.getDateTime().equals(date)).collect(Collectors.toList()); |
| | | AuxiliaryOutputWorkingHours currentRecord = null; |
| | | if (CollectionUtils.isNotEmpty(collect2)) { |
| | | // æå°±æ´æ° 没æå°±æ°å¢ |
| | | addOrUpdate = true; |
| | | currentRecord = collect2.get(collect2.size() - 1); |
| | | } else { |
| | | addOrUpdate = false; |
| | | // æ°å¢çæ¥ææ¯æåå¤ççï¼æä»¥è¿éåoldRecordsçæåä¸ä¸ª |
| | | currentRecord = oldRecords.get(oldRecords.size() - 1); |
| | | } |
| | | specialWorkCount(currentRecord, date, isWithinRange, manHour, currentSampleId, parentInsProduct, auxiliaryOutputWorkingHours, formatters, oldRecords, k, addOrUpdate, insProduct,userId); |
| | | } else { |
| | | // ä¸éè¦è·¨å¤© |
| | | //夿æ¥è¯¢å¾å°æ¥ææ¯å¦è¦ä¸æ·»å æ°æ®çæ¥æä¸è´,å¦ææ¥æä¸è´ï¼åè¿è¡æ´æ°ï¼å¦åæ°å¢ |
| | | DateTimeFormatter formatters = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); |
| | | String date = LocalDateTime.now().toLocalDate().atStartOfDay().format(formatters); |
| | | boolean addOrUpdate; |
| | | // è¿æ»¤åºæ¥æä¸è´çè®°å½ |
| | | List<AuxiliaryOutputWorkingHours> collect2 = oldRecords.stream().filter(item -> item.getDateTime().equals(date)).collect(Collectors.toList()); |
| | | AuxiliaryOutputWorkingHours oldRecord = null; |
| | | if (CollectionUtils.isNotEmpty(collect2)) { |
| | | // æå°±æ´æ° 没æå°±æ°å¢ |
| | | addOrUpdate = true; |
| | | oldRecord = collect2.get(collect2.size() - 1); |
| | | } else { |
| | | addOrUpdate = false; |
| | | // æ°å¢çæ¥ææ¯æåå¤ççï¼æä»¥è¿éåoldRecordsçæåä¸ä¸ª |
| | | oldRecord = oldRecords.get(oldRecords.size() - 1); |
| | | } |
| | | // ç¹æ®é¡¹å·¥æ¶è®¡ç® |
| | | specialWorkCount(oldRecord, date, isWithinRange, manHour, currentSampleId, parentInsProduct, auxiliaryOutputWorkingHours, formatters, oldRecords, k, addOrUpdate, insProduct,userId); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | log.info("å·¥æ¶è®¡ç®å®æï¼productId:{}",k); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * ç¹æ®é¡¹å·¥æ¶è®¡ç® |
| | | */ |
| | | public synchronized void specialWorkCount(AuxiliaryOutputWorkingHours oldRecord,String date,boolean isWithinRange, |
| | | BigDecimal manHour,Integer currentSampleId,InsProduct parentInsProduct, |
| | | AuxiliaryOutputWorkingHours auxiliaryOutputWorkingHours, |
| | | DateTimeFormatter formatters, |
| | | List<AuxiliaryOutputWorkingHours> oldRecords, |
| | | String k,boolean addOrUpdate, |
| | | InsProduct insProduct,Integer userId) { |
| | | //夿å¾å°æ¥ææ¯å¦å·²ç»å«ææ°æ® æå°±æ´æ° 没æå°±æ°å¢ |
| | | if(addOrUpdate){ |
| | | //æ´æ°å·¥æ¶ æ¯å¦å ç |
| | | List<InsProduct> insProducts = insProductMapper.selectList(new LambdaQueryWrapper<InsProduct>() |
| | | .eq(InsProduct::getInsSampleId, currentSampleId)); |
| | | String inspectionItem = oldRecord.getInspectionItem(); |
| | | String inspectionItemSubclass = oldRecord.getInspectionItemSubclass(); |
| | | switch (inspectionItem) { |
| | | case "åæ ¹åç´çç§": |
| | | //计ç®å·¥æ¶ æ¥çæ£éªçä¸ªæ°æ¯å¦ä¸å·¥æ¶ç个æ°ä¸è´(åºåæ£éªé¡¹åæ£éªå项ç®) |
| | | int count1 = 0; // å·¥æ¶çä¸ªæ° |
| | | InsProduct insProduct2 = insProductMapper.selectById(Integer.parseInt(k)); |
| | | InsProductResult result = insProductResultMapper.selectList(new LambdaQueryWrapper<InsProductResult>() |
| | | .eq(InsProductResult::getInsProductId, insProduct2.getId()) |
| | | .orderByAsc(InsProductResult::getId)).get(0); |
| | | List<Map> maps1 = JSONArray.parseArray(result.getInsValue(), Map.class); |
| | | for (Map map : maps1) { |
| | | if (Strings.isNotEmpty(map.get("v").toString())) { |
| | | count1++; |
| | | } |
| | | } |
| | | Integer oldAmount1 = 0; |
| | | for(AuxiliaryOutputWorkingHours a : oldRecords) { |
| | | if(a.getInspectionItem().equals(insProduct2.getInspectionItem()) && |
| | | a.getInspectionItemSubclass().equals(insProduct2.getInspectionItemSubclass())){ |
| | | oldAmount1 += (Objects.isNull(a.getAmount()) ? 0 : a.getAmount()) + (Objects.isNull(a.getOvertimeAmount()) ? 0 : a.getOvertimeAmount()); |
| | | } |
| | | }// ä¹åçå·¥æ¶ä¸ªæ° |
| | | if(count1 > oldAmount1) { |
| | | if(isWithinRange) { |
| | | // éå ç |
| | | oldRecord.setOrderNo(StringUtils.isNotEmpty(oldRecord.getOrderNo()) ? oldRecord.getOrderNo() : oldRecord.getOvertimeOrderNo()); // éå çå§æåå· |
| | | oldRecord.setWorkTime( addAccuracy((Objects.isNull(oldRecord.getWorkTime()) ? 0 : oldRecord.getWorkTime()),manHour.doubleValue())); // éå çå·¥æ¶ |
| | | oldRecord.setAmount((Objects.isNull(oldRecord.getAmount()) ? 0 : oldRecord.getAmount()) + 1); // éå çæ°é |
| | | oldRecord.setOutputWorkTime((Objects.isNull(oldRecord.getWorkTime()) ? 0 : oldRecord.getWorkTime()) + |
| | | (Objects.isNull(oldRecord.getOvertimeWorkTime()) ? 0 : oldRecord.getOvertimeWorkTime())); // 产éå·¥æ¶ |
| | | }else { |
| | | // å ç |
| | | oldRecord.setOvertimeOrderNo(StringUtils.isNotEmpty(oldRecord.getOrderNo()) ? oldRecord.getOrderNo() : oldRecord.getOvertimeOrderNo()); // å çå§æåå· |
| | | oldRecord.setOvertimeWorkTime(addAccuracy((Objects.isNull(oldRecord.getOvertimeWorkTime()) ? 0: oldRecord.getOvertimeWorkTime()),manHour.doubleValue() ));// å çå·¥æ¶ |
| | | oldRecord.setOvertimeAmount((Objects.isNull(oldRecord.getOvertimeAmount()) ? 0 : oldRecord.getOvertimeAmount()) + 1); // å çæ°é |
| | | oldRecord.setOutputWorkTime((Objects.isNull(oldRecord.getWorkTime()) ? 0 : oldRecord.getWorkTime()) + |
| | | (Objects.isNull(oldRecord.getOvertimeWorkTime()) ? 0 : oldRecord.getOvertimeWorkTime())); // 产éå·¥æ¶ |
| | | } |
| | | auxiliaryOutputWorkingHoursMapper.updateById(oldRecord); |
| | | } |
| | | break; |
| | | case "温度循ç¯": |
| | | // æ¥è¯¢ææçæ£éªè®°å½ æ ¹æ®productResultçinsValueçä¸ªæ° ä¸ oldRecordç个æ°è¿è¡æ¯è¾ |
| | | int all = 0; // ææç温度循ç¯çä¸ªæ° |
| | | int allValue = 0; // ææç温度循ç¯çæå¼çä¸ªæ° |
| | | int count = 0; // å½å次æ°ç温度æå¼çä¸ªæ° |
| | | int countAll = 0; // å½å次æ°ç温度ææçä¸ªæ° |
| | | if(CollectionUtils.isNotEmpty(insProducts)) { |
| | | InsProduct insProduct3 = insProductMapper.selectById(Integer.parseInt(k)); |
| | | // è¿æ»¤åºå½å次æ°ç温度 |
| | | List<InsProduct> collect = insProducts.stream() |
| | | .filter(item -> item.getInspectionItem().equals(insProduct3.getInspectionItem()) && |
| | | item.getInspectionItemSubclass().equals(insProduct3.getInspectionItemSubclass())) |
| | | .collect(Collectors.toList()); |
| | | countAll = collect.size(); |
| | | all = insProducts.size(); |
| | | if(CollectionUtils.isNotEmpty(collect)) { |
| | | for(InsProduct insProduct1 : collect) { |
| | | // æ¥è¯¢insProductResultæ¿å°insValueçæå¼çä¸ªæ° |
| | | InsProductResult insProductResult = insProductResultMapper.selectOne(new LambdaQueryWrapper<InsProductResult>() |
| | | .eq(InsProductResult::getInsProductId, insProduct1.getId())); |
| | | if(!Objects.isNull(insProductResult)) { |
| | | // insProductResultä¸ä¸ºç©º,è·åæå¼çä¸ªæ° |
| | | List<Map> maps = JSONArray.parseArray(insProductResult.getInsValue(), Map.class); |
| | | for (Map map : maps) { |
| | | if (Strings.isNotEmpty(map.get("v").toString())) { |
| | | count++; |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | // ææ æå¼çä¸ªæ° |
| | | for (InsProduct insProduct1 : insProducts) { |
| | | // æ¥è¯¢insProductResultæ¿å°insValueçæå¼çä¸ªæ° |
| | | InsProductResult insProductResult = insProductResultMapper.selectOne(new LambdaQueryWrapper<InsProductResult>() |
| | | .eq(InsProductResult::getInsProductId, insProduct1.getId())); |
| | | if(!Objects.isNull(insProductResult)) { |
| | | // insProductResultä¸ä¸ºç©º,è·åæå¼çä¸ªæ° |
| | | List<Map> maps = JSONArray.parseArray(insProductResult.getInsValue(), Map.class); |
| | | for (Map map : maps) { |
| | | if (Strings.isNotEmpty(map.get("v").toString())) { |
| | | allValue++; |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | Integer oldAmount = 0; // å·²ç»æ·»å çå·¥æ¶ä¸ªæ° |
| | | for(AuxiliaryOutputWorkingHours a : oldRecords) { |
| | | oldAmount += (Objects.isNull(a.getAmount()) ? 0 : a.getAmount()) + (Objects.isNull(a.getOvertimeAmount()) ? 0 : a.getOvertimeAmount()); |
| | | } |
| | | if(all > oldAmount && count < countAll && allValue > oldAmount) { |
| | | if(isWithinRange) { |
| | | // éå çå·¥æ¶ |
| | | oldRecord.setOrderNo(StringUtils.isNotEmpty(oldRecord.getOrderNo()) ? oldRecord.getOrderNo() : oldRecord.getOvertimeOrderNo()); // éå çå§æåå· |
| | | oldRecord.setAmount((Objects.isNull(oldRecord.getAmount()) ? 0 : oldRecord.getAmount()) + 1); |
| | | oldRecord.setWorkTime(addAccuracy((Objects.isNull(oldRecord.getWorkTime()) ? 0 : oldRecord.getWorkTime()),manHour.doubleValue())); |
| | | oldRecord.setOutputWorkTime((Objects.isNull(oldRecord.getWorkTime()) ? 0 : oldRecord.getWorkTime()) + |
| | | (Objects.isNull(oldRecord.getOvertimeWorkTime()) ? 0 : oldRecord.getOvertimeWorkTime())); |
| | | |
| | | }else { |
| | | // å çå·¥æ¶ |
| | | oldRecord.setOvertimeOrderNo(StringUtils.isNotEmpty(oldRecord.getOrderNo()) ? oldRecord.getOrderNo() : oldRecord.getOvertimeOrderNo()); // éå çå§æåå· |
| | | oldRecord.setOvertimeAmount((Objects.isNull(oldRecord.getOvertimeAmount()) ? 0 : oldRecord.getOvertimeAmount()) + 1); |
| | | oldRecord.setOvertimeWorkTime(addAccuracy((Objects.isNull(oldRecord.getOvertimeWorkTime()) ? 0 : oldRecord.getOvertimeWorkTime()),manHour.doubleValue() )); |
| | | oldRecord.setOutputWorkTime((Objects.isNull(oldRecord.getWorkTime()) ? 0 : oldRecord.getWorkTime()) + |
| | | (Objects.isNull(oldRecord.getOvertimeWorkTime()) ? 0 : oldRecord.getOvertimeWorkTime())); |
| | | } |
| | | auxiliaryOutputWorkingHoursMapper.updateById(oldRecord); |
| | | } |
| | | break; |
| | | case "温åè¯éª": |
| | | // æç
§æ£éªé¡¹åç» æå 个æ£éªå¼å°±ç®å æ¬¡å·¥æ¶ |
| | | Map<String, List<InsProduct>> collect = insProductMapper.selectList(new LambdaQueryWrapper<InsProduct>() |
| | | .eq(InsProduct::getSpecialItemParentId, parentInsProduct.getId())) |
| | | .stream() |
| | | .collect(Collectors.groupingBy(InsProduct::getInspectionItem)); |
| | | int group = 0; |
| | | for (Map.Entry<String,List<InsProduct>> entry : collect.entrySet()) { |
| | | int minValue = Integer.MIN_VALUE; |
| | | List<InsProduct> insProducts1 = entry.getValue(); |
| | | for (InsProduct product1 : insProducts1) { |
| | | 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); |
| | | // æé¿çinsValue å°±æå ç»å·¥æ¶ |
| | | if(maps.size() > minValue) { |
| | | minValue = maps.size(); |
| | | } |
| | | } |
| | | } |
| | | if(minValue != Integer.MIN_VALUE) { |
| | | group += minValue; |
| | | } |
| | | } |
| | | double oldWorkTime2 = 0; |
| | | double oldAmount2 = 0; |
| | | for(AuxiliaryOutputWorkingHours a : oldRecords) { |
| | | oldWorkTime2 += (Objects.isNull(a.getOvertimeWorkTime()) ? 0 : a.getOvertimeWorkTime()) + (Objects.isNull(a.getWorkTime()) ? 0 : a.getWorkTime()); |
| | | oldAmount2+= (Objects.isNull(a.getAmount()) ? 0 : a.getAmount()) + (Objects.isNull(a.getOvertimeAmount()) ? 0 : a.getOvertimeAmount()); |
| | | } |
| | | // æ£éªçç»æ°å¤§äºå·²ç»æ·»å çç»æ°å°±è¦æ´æ°å·¥æ¶ |
| | | int oldGroup1 = 0; |
| | | if(manHour.doubleValue() != 0) { |
| | | oldGroup1 =(int) (oldWorkTime2 / manHour.doubleValue()); |
| | | } |
| | | if((group > oldGroup1) && (group > oldAmount2)) { |
| | | if(isWithinRange) { |
| | | // éå ç |
| | | oldRecord.setOrderNo(StringUtils.isNotEmpty(oldRecord.getOrderNo()) ? oldRecord.getOrderNo() : oldRecord.getOvertimeOrderNo()); // éå çå§æåå· |
| | | oldRecord.setAmount((Objects.isNull(oldRecord.getAmount()) ? 0 : oldRecord.getAmount()) + 1); // éå çæ°é |
| | | oldRecord.setWorkTime(accuracy(manHour,oldRecord.getAmount())); // éå çå·¥æ¶ |
| | | oldRecord.setOutputWorkTime((Objects.isNull(oldRecord.getWorkTime()) ? 0 : oldRecord.getWorkTime()) + |
| | | (Objects.isNull(oldRecord.getOvertimeWorkTime()) ? 0 : oldRecord.getOvertimeWorkTime())); // 产éå·¥æ¶ |
| | | }else { |
| | | // å ç |
| | | oldRecord.setOvertimeOrderNo(StringUtils.isNotEmpty(oldRecord.getOrderNo()) ? oldRecord.getOrderNo() : oldRecord.getOvertimeOrderNo()); // å çå§æåå· |
| | | oldRecord.setOvertimeAmount((Objects.isNull(oldRecord.getOvertimeAmount()) ? 0 : oldRecord.getOvertimeAmount()) + 1); // å çæ°é |
| | | oldRecord.setOvertimeWorkTime(accuracy(manHour,oldRecord.getOvertimeAmount())); // å çå·¥æ¶ |
| | | oldRecord.setOutputWorkTime((Objects.isNull(oldRecord.getWorkTime()) ? 0 : oldRecord.getWorkTime()) + |
| | | (Objects.isNull(oldRecord.getOvertimeWorkTime()) ? 0 : oldRecord.getOvertimeWorkTime())); // 产éå·¥æ¶ |
| | | } |
| | | auxiliaryOutputWorkingHoursMapper.updateById(oldRecord); |
| | | } |
| | | break; |
| | | case "ç循ç¯": |
| | | // æç
§æ£éªé¡¹åç» æå 个æ£éªå¼å°±ç®å æ¬¡å·¥æ¶ |
| | | Map<String, List<InsProduct>> collect1 = new HashMap<>(); |
| | | if(Objects.nonNull(parentInsProduct)){ |
| | | collect1 = insProductMapper.selectList(new LambdaQueryWrapper<InsProduct>() |
| | | .eq(InsProduct::getSpecialItemParentId, parentInsProduct.getId())) |
| | | .stream() |
| | | .collect(Collectors.groupingBy(InsProduct::getInspectionItem)); |
| | | } |
| | | int group1 = 0; |
| | | for (Map.Entry<String,List<InsProduct>> entry : collect1.entrySet()) { |
| | | int minValue = Integer.MIN_VALUE; |
| | | List<InsProduct> insProducts1 = entry.getValue(); |
| | | for (InsProduct product1 : insProducts1) { |
| | | 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); |
| | | // æé¿çinsValue å°±æå ç»å·¥æ¶ |
| | | if(maps.size() > minValue) { |
| | | minValue = maps.size(); |
| | | } |
| | | } |
| | | } |
| | | if(minValue != Integer.MIN_VALUE) { |
| | | group1 += minValue; |
| | | } |
| | | } |
| | | double oldWorkTime3 = 0; |
| | | double oldAmount3 = 0; |
| | | for(AuxiliaryOutputWorkingHours a : oldRecords) { |
| | | oldWorkTime3 += (Objects.isNull(a.getOvertimeWorkTime()) ? 0 : a.getOvertimeWorkTime()) + (Objects.isNull(a.getWorkTime()) ? 0 : a.getWorkTime()); |
| | | oldAmount3+= (Objects.isNull(a.getAmount()) ? 0 : a.getAmount()) + (Objects.isNull(a.getOvertimeAmount()) ? 0 : a.getOvertimeAmount()); |
| | | } |
| | | // æ£éªçç»æ°å¤§äºå·²ç»æ·»å çç»æ°å°±è¦æ´æ°å·¥æ¶ |
| | | int oldGroup = 0; |
| | | if(manHour.doubleValue() != 0) { |
| | | oldGroup =(int) (oldWorkTime3 / manHour.doubleValue()); |
| | | } |
| | | |
| | | if((group1 > oldGroup) && (group1 > oldAmount3)) { |
| | | if(isWithinRange) { |
| | | // éå ç |
| | | oldRecord.setOrderNo(StringUtils.isNotEmpty(oldRecord.getOrderNo()) ? oldRecord.getOrderNo() : oldRecord.getOvertimeOrderNo()); // éå çå§æåå· |
| | | oldRecord.setAmount((Objects.isNull(oldRecord.getAmount()) ? 0 : oldRecord.getAmount()) + 1); // éå çæ°é |
| | | oldRecord.setWorkTime(accuracy(manHour, oldRecord.getAmount())); // éå çå·¥æ¶ |
| | | oldRecord.setOutputWorkTime((Objects.isNull(oldRecord.getWorkTime()) ? 0 : oldRecord.getWorkTime()) + |
| | | (Objects.isNull(oldRecord.getOvertimeWorkTime()) ? 0 : oldRecord.getOvertimeWorkTime())); // 产éå·¥æ¶ |
| | | }else { |
| | | // å ç |
| | | oldRecord.setOvertimeOrderNo(StringUtils.isNotEmpty(oldRecord.getOrderNo()) ? oldRecord.getOrderNo() : oldRecord.getOvertimeOrderNo()); // å çå§æåå· |
| | | oldRecord.setOvertimeAmount((Objects.isNull(oldRecord.getOvertimeAmount()) ? 0 : oldRecord.getOvertimeAmount()) + 1); // å çæ°é |
| | | oldRecord.setOvertimeWorkTime(accuracy(manHour,oldRecord.getOvertimeAmount())); // å çå·¥æ¶ |
| | | oldRecord.setOutputWorkTime((Objects.isNull(oldRecord.getWorkTime()) ? 0 : oldRecord.getWorkTime()) + |
| | | (Objects.isNull(oldRecord.getOvertimeWorkTime()) ? 0 : oldRecord.getOvertimeWorkTime())); // 产éå·¥æ¶ |
| | | } |
| | | auxiliaryOutputWorkingHoursMapper.updateById(oldRecord); |
| | | } |
| | | break; |
| | | case "æ¶æ¯è¯ä¼°": |
| | | // æ ¹æ®åæ æ¥è¿è¡å·¥æ¶çæ·»å |
| | | InsProductResult result1 = insProductResultMapper.selectOne(new LambdaQueryWrapper<InsProductResult>() |
| | | .eq(InsProductResult::getInsProductId, insProduct.getId())); |
| | | // å·¥æ¶çä¸ªæ° |
| | | int count4 = 0; |
| | | if(!Objects.isNull(result1)) { |
| | | List<Map> maps = JSONArray.parseArray(result1.getInsValue(), Map.class); |
| | | // æ ¹æ®åæ æ¥è¿è¡åç» |
| | | Map<Object, List<Map>> coordinate = maps.stream().collect(Collectors.groupingBy(item -> item.get("r"))); |
| | | Iterator<Map.Entry<Object, List<Map>>> iterator = coordinate.entrySet().iterator(); |
| | | while (iterator.hasNext()) { |
| | | Map.Entry<Object, List<Map>> entry = iterator.next(); |
| | | List<Map> value = entry.getValue(); |
| | | if(value.size() > count4) { |
| | | count4 = value.size(); |
| | | } |
| | | } |
| | | } |
| | | Integer oldAmount4 = 0; // å·²ç»æ·»å çå·¥æ¶ä¸ªæ° |
| | | for(AuxiliaryOutputWorkingHours a : oldRecords) { |
| | | oldAmount4 += (Objects.isNull(a.getAmount()) ? 0 : a.getAmount()) + (Objects.isNull(a.getOvertimeAmount()) ? 0 : a.getOvertimeAmount()); |
| | | } |
| | | if(count4 > oldAmount4) { |
| | | if(isWithinRange) { |
| | | // éå çå·¥æ¶ |
| | | oldRecord.setOrderNo(StringUtils.isNotEmpty(oldRecord.getOrderNo()) ? oldRecord.getOrderNo() : oldRecord.getOvertimeOrderNo()); // éå çå§æåå· |
| | | oldRecord.setAmount((Objects.isNull(oldRecord.getAmount()) ? 0 : oldRecord.getAmount()) + 1); // éå çä¸ªæ° |
| | | oldRecord.setWorkTime(addAccuracy((Objects.isNull(oldRecord.getWorkTime()) ? 0 : oldRecord.getWorkTime()),manHour.doubleValue())); // éå çå·¥æ¶ |
| | | oldRecord.setOutputWorkTime((Objects.isNull(oldRecord.getWorkTime()) ? 0 : oldRecord.getWorkTime()) + |
| | | (Objects.isNull(oldRecord.getOvertimeWorkTime()) ? 0 : oldRecord.getOvertimeWorkTime())); // 产åºå·¥æ¶ |
| | | |
| | | }else { |
| | | // å çå·¥æ¶ |
| | | oldRecord.setOvertimeOrderNo(StringUtils.isNotEmpty(oldRecord.getOrderNo()) ? oldRecord.getOrderNo() : oldRecord.getOvertimeOrderNo()); // éå çå§æåå· |
| | | oldRecord.setOvertimeAmount((Objects.isNull(oldRecord.getOvertimeAmount()) ? 0 : oldRecord.getOvertimeAmount()) + 1); // éå çä¸ªæ° |
| | | oldRecord.setOvertimeWorkTime(addAccuracy((Objects.isNull(oldRecord.getOvertimeWorkTime()) ? 0 : oldRecord.getOvertimeWorkTime()),manHour.doubleValue() )); |
| | | oldRecord.setOutputWorkTime((Objects.isNull(oldRecord.getWorkTime()) ? 0 : oldRecord.getWorkTime()) + |
| | | (Objects.isNull(oldRecord.getOvertimeWorkTime()) ? 0 : oldRecord.getOvertimeWorkTime())); // 产åºå·¥æ¶ |
| | | } |
| | | auxiliaryOutputWorkingHoursMapper.updateById(oldRecord); |
| | | } |
| | | break; |
| | | |
| | | } |
| | | |
| | | // æ¾å¥ç®¡ æ´æ° |
| | | if((inspectionItem.contains("æ¾å¥ç®¡") || inspectionItemSubclass.contains("æ¾å¥ç®¡") || |
| | | !Objects.isNull(insProduct.getInsFiberId()) || |
| | | !Objects.isNull(insProduct.getInsFibersId())) && Objects.isNull(insProduct.getSpecialItemParentId()) && !insProduct.getInspectionItem().equals("å
纤æ¥å¤´æè")) { |
| | | InsProduct product = insProductMapper.selectById(Integer.parseInt(k)); |
| | | // æ¥è¯¢æ ·åä¸é¢ææçæ¾å¥ç®¡ å¹¶ä¸è¿æ»¤åºæ£éªé¡¹åæ£éªå项ç¸åçæ°æ® |
| | | List<InsProduct> collect = insProductMapper.selectList(new LambdaQueryWrapper<InsProduct>() |
| | | .eq(InsProduct::getInsSampleId, currentSampleId) |
| | | .and(item -> item.like(InsProduct::getInspectionItem, "æ¾å¥ç®¡") |
| | | .or() |
| | | .like(InsProduct::getInspectionItemSubclass, "æ¾å¥ç®¡") |
| | | .or() |
| | | .isNotNull(InsProduct::getInsFibersId) |
| | | .or() |
| | | .isNotNull(InsProduct::getInsFiberId))).stream() |
| | | .filter(item -> item.getInspectionItem().equals(product.getInspectionItem()) && |
| | | item.getInspectionItemSubclass().equals(product.getInspectionItemSubclass())) |
| | | .collect(Collectors.toList()); |
| | | // æ£éªæ»å
±çä¸ªæ° |
| | | int count = 0; |
| | | for (InsProduct insProduct1 : collect) { |
| | | // æ¥è¯¢result表 |
| | | InsProductResult insProductResult = insProductResultMapper.selectOne(new LambdaQueryWrapper<InsProductResult>() |
| | | .eq(InsProductResult::getInsProductId, insProduct1.getId())); |
| | | // 妿æå¼åè¿è¡æ°éç¸å |
| | | if(Objects.isNull(insProductResult)) { |
| | | continue; |
| | | } |
| | | count++; |
| | | // List<Map> maps = JSONArray.parseArray(insProductResult.getInsValue(), Map.class); |
| | | // for(Map map : maps) { |
| | | // if(Strings.isNotEmpty(map.get("v").toString())) { |
| | | // count++; |
| | | // } |
| | | // } |
| | | } |
| | | // å·¥æ¶çä¸ªæ° |
| | | Integer oldAmount = 0; |
| | | for(AuxiliaryOutputWorkingHours a : oldRecords) { |
| | | oldAmount += (Objects.isNull(a.getAmount()) ? 0 : a.getAmount()) + (Objects.isNull(a.getOvertimeAmount()) ? 0 : a.getOvertimeAmount()); |
| | | } |
| | | if((count > oldAmount)) { |
| | | if(isWithinRange) { |
| | | // éå ç |
| | | oldRecord.setOrderNo(StringUtils.isNotEmpty(oldRecord.getOrderNo()) ? oldRecord.getOrderNo() : oldRecord.getOvertimeOrderNo()); // éå çå§æåå· |
| | | oldRecord.setAmount((Objects.isNull(oldRecord.getAmount()) ? 0 : oldRecord.getAmount()) + 1); // éå çæ°é |
| | | oldRecord.setWorkTime(accuracy(manHour,oldRecord.getAmount())); // éå çå·¥æ¶ |
| | | oldRecord.setOutputWorkTime((Objects.isNull(oldRecord.getWorkTime()) ? 0 : oldRecord.getWorkTime()) + |
| | | (Objects.isNull(oldRecord.getOvertimeWorkTime()) ? 0 : oldRecord.getOvertimeWorkTime())); // 产éå·¥æ¶ |
| | | }else { |
| | | // å ç |
| | | oldRecord.setOvertimeOrderNo(StringUtils.isNotEmpty(oldRecord.getOrderNo()) ? oldRecord.getOrderNo() : oldRecord.getOvertimeOrderNo()); // å çå§æåå· |
| | | oldRecord.setOvertimeAmount((Objects.isNull(oldRecord.getOvertimeAmount()) ? 0 : oldRecord.getOvertimeAmount()) + 1); // å çæ°é |
| | | oldRecord.setOvertimeWorkTime(accuracy(manHour,oldRecord.getOvertimeAmount())); // å çå·¥æ¶ |
| | | oldRecord.setOutputWorkTime((Objects.isNull(oldRecord.getWorkTime()) ? 0 : oldRecord.getWorkTime()) + |
| | | (Objects.isNull(oldRecord.getOvertimeWorkTime()) ? 0 : oldRecord.getOvertimeWorkTime())); // 产éå·¥æ¶ |
| | | } |
| | | auxiliaryOutputWorkingHoursMapper.updateById(oldRecord); |
| | | } |
| | | } |
| | | }else { |
| | | DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); |
| | | DateTime parse = DateUtil.parse(LocalDateTime.now().format(formatter)); |
| | | // æ°å¢å·¥æ¶ |
| | | AuxiliaryOutputWorkingHours addOutputWorkingHours = new AuxiliaryOutputWorkingHours(); |
| | | BeanUtils.copyProperties(oldRecord, addOutputWorkingHours); |
| | | addOutputWorkingHours.setDateTime(date); // æ¥æ |
| | | addOutputWorkingHours.setOvertimeOrderNo(auxiliaryOutputWorkingHours.getOvertimeOrderNo()); // å çå§æåå· |
| | | addOutputWorkingHours.setOrderNo(auxiliaryOutputWorkingHours.getOrderNo()); // éå çå§æåå· |
| | | addOutputWorkingHours.setId(null); |
| | | addOutputWorkingHours.setOutputWorkTime((ObjectUtils.isNotEmpty(auxiliaryOutputWorkingHours.getOvertimeWorkTime()) ? |
| | | auxiliaryOutputWorkingHours.getOvertimeWorkTime() : 0) + |
| | | (ObjectUtils.isNotEmpty(auxiliaryOutputWorkingHours.getWorkTime()) ? auxiliaryOutputWorkingHours.getWorkTime() : 0));//产éå·¥æ¶ |
| | | addOutputWorkingHours.setWeekDay(getWeek(LocalDateTime.now().format(formatters)));//ææ |
| | | addOutputWorkingHours.setCheckId(userId);//æ£æµäºº |
| | | addOutputWorkingHours.setWeek(String.valueOf(DateUtil.weekOfYear(DateUtil.offsetDay(parse, 1))));//卿¬¡ |
| | | if(isWithinRange) { |
| | | addOutputWorkingHours.setWorkTime(manHour.doubleValue()); // éå çå·¥æ¶ |
| | | addOutputWorkingHours.setOvertimeWorkTime(null); |
| | | addOutputWorkingHours.setAmount(1);//éå çæ°é |
| | | addOutputWorkingHours.setOvertimeAmount(null);//å çæ°é |
| | | }else { |
| | | addOutputWorkingHours.setOvertimeWorkTime(manHour.doubleValue()); // å çå·¥æ¶ |
| | | addOutputWorkingHours.setWorkTime(null); |
| | | addOutputWorkingHours.setOvertimeAmount(1);//å çæ°é |
| | | addOutputWorkingHours.setAmount(null);//éå çæ°é |
| | | } |
| | | |
| | | List<InsProduct> insProducts = insProductMapper.selectList(new LambdaQueryWrapper<InsProduct>() |
| | | .eq(InsProduct::getInsSampleId, currentSampleId)); |
| | | String inspectionItem = oldRecord.getInspectionItem(); |
| | | String inspectionItemSubclass = oldRecord.getInspectionItemSubclass(); |
| | | switch (inspectionItem) { |
| | | case "æ¶æ¯è¯ä¼°": |
| | | // æ ¹æ®åæ æ¥è¿è¡å·¥æ¶çæ·»å |
| | | InsProductResult result1 = insProductResultMapper.selectOne(new LambdaQueryWrapper<InsProductResult>() |
| | | .eq(InsProductResult::getInsProductId, insProduct.getId())); |
| | | // å·¥æ¶çä¸ªæ° |
| | | int count4 = 0; |
| | | if(!Objects.isNull(result1)) { |
| | | List<Map> maps = JSONArray.parseArray(result1.getInsValue(), Map.class); |
| | | // æ ¹æ®åæ æ¥è¿è¡åç» |
| | | Map<Object, List<Map>> coordinate = maps.stream().collect(Collectors.groupingBy(item -> item.get("r"))); |
| | | Iterator<Map.Entry<Object, List<Map>>> iterator = coordinate.entrySet().iterator(); |
| | | while (iterator.hasNext()) { |
| | | Map.Entry<Object, List<Map>> entry = iterator.next(); |
| | | List<Map> value = entry.getValue(); |
| | | if(value.size() > count4) { |
| | | count4 = value.size(); |
| | | } |
| | | } |
| | | } |
| | | Integer oldAmount4 = 0; // å·²ç»æ·»å çå·¥æ¶ä¸ªæ° |
| | | for(AuxiliaryOutputWorkingHours a : oldRecords) { |
| | | oldAmount4 += (Objects.isNull(a.getAmount()) ? 0 : a.getAmount()) + (Objects.isNull(a.getOvertimeAmount()) ? 0 : a.getOvertimeAmount()); |
| | | } |
| | | if(count4 > oldAmount4) { |
| | | auxiliaryOutputWorkingHoursMapper.insert(addOutputWorkingHours); |
| | | } |
| | | break; |
| | | case "温度循ç¯": |
| | | int count = 0; // å·¥æ¶çä¸ªæ° |
| | | if(CollectionUtils.isNotEmpty(insProducts)) { |
| | | for(InsProduct insProduct1 : insProducts) { |
| | | // æ¥è¯¢insProductResultæ¿å°insValueçæå¼çä¸ªæ° |
| | | InsProductResult insProductResult = insProductResultMapper.selectOne(new LambdaQueryWrapper<InsProductResult>() |
| | | .eq(InsProductResult::getInsProductId, insProduct1.getId())); |
| | | if(!Objects.isNull(insProductResult)) { |
| | | // insProductResultä¸ä¸ºç©º,è·åæå¼çä¸ªæ° |
| | | List<Map> maps = JSONArray.parseArray(insProductResult.getInsValue(), Map.class); |
| | | for (Map map : maps) { |
| | | if (Strings.isNotEmpty(map.get("v").toString())) { |
| | | count++; |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | Integer oldAmount = 0; |
| | | for(AuxiliaryOutputWorkingHours a : oldRecords) { |
| | | oldAmount += (Objects.isNull(a.getAmount()) ? 0 : a.getAmount()) + (Objects.isNull(a.getOvertimeAmount()) ? 0 : a.getOvertimeAmount()); |
| | | } |
| | | if(count > oldAmount) { |
| | | auxiliaryOutputWorkingHoursMapper.insert(addOutputWorkingHours); |
| | | } |
| | | break; |
| | | case "åæ ¹åç´çç§": |
| | | // æ¥çä¸ªæ° æ¯å¦ä¸å·¥æ¶ç个æ°ä¸è´ï¼å¦ææ£éªç个æ°å¤§äºå·¥æ¶ç个æ°ï¼é£ä¹å°±æ°å¢ |
| | | int count1 = 0; |
| | | if(CollectionUtils.isNotEmpty(insProducts)) { |
| | | for(InsProduct insProduct1 : insProducts) { |
| | | // æ¥è¯¢insProductResultæ¿å°insValueçæå¼çä¸ªæ° |
| | | InsProductResult insProductResult = insProductResultMapper.selectOne(new LambdaQueryWrapper<InsProductResult>() |
| | | .eq(InsProductResult::getInsProductId, insProduct1.getId())); |
| | | if(!Objects.isNull(insProductResult)) { |
| | | // insProductResultä¸ä¸ºç©º,è·åæå¼çä¸ªæ° |
| | | insProductResult.getInsValue(); |
| | | List<Map> maps = JSONArray.parseArray(insProductResult.getInsValue(), Map.class); |
| | | for (Map map : maps) { |
| | | if (Strings.isNotEmpty(map.get("v").toString())) { |
| | | count1++; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | Integer oldAmount1 = 0; |
| | | for(AuxiliaryOutputWorkingHours a : oldRecords) { |
| | | oldAmount1 += (Objects.isNull(a.getAmount()) ? 0 : a.getAmount()) + (Objects.isNull(a.getOvertimeAmount()) ? 0 : a.getOvertimeAmount()); |
| | | } |
| | | if(count1 > oldAmount1) { |
| | | auxiliaryOutputWorkingHoursMapper.insert(addOutputWorkingHours); |
| | | } |
| | | break; |
| | | case "温åè¯éª": |
| | | // æç
§æ£éªé¡¹åç» æå 个æ£éªå¼å°±ç®å æ¬¡å·¥æ¶ |
| | | Map<String, List<InsProduct>> collect = insProductMapper.selectList(new LambdaQueryWrapper<InsProduct>() |
| | | .eq(InsProduct::getSpecialItemParentId, parentInsProduct.getId())) |
| | | .stream() |
| | | .collect(Collectors.groupingBy(InsProduct::getInspectionItem)); |
| | | int group = 0; |
| | | double oldWorkTime2 = 0; // ä¹åçå·¥æ¶ |
| | | double oldAmount2 = 0; // ä¹åçæ°é |
| | | for(AuxiliaryOutputWorkingHours a : oldRecords) { |
| | | oldWorkTime2 += (Objects.isNull(a.getOvertimeWorkTime()) ? 0 : a.getOvertimeWorkTime()) + (Objects.isNull(a.getWorkTime()) ? 0 : a.getWorkTime()); |
| | | oldAmount2+= (Objects.isNull(a.getAmount()) ? 0 : a.getAmount()) + (Objects.isNull(a.getOvertimeAmount()) ? 0 : a.getOvertimeAmount()); |
| | | } |
| | | for (Map.Entry<String,List<InsProduct>> entry : collect.entrySet()) { |
| | | int minValue = Integer.MIN_VALUE; |
| | | List<InsProduct> insProducts1 = entry.getValue(); |
| | | for (InsProduct product1 : insProducts1) { |
| | | 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); |
| | | // æé¿çinsValue å°±æå ç»å·¥æ¶ |
| | | if(maps.size() > minValue) { |
| | | minValue = maps.size(); |
| | | } |
| | | } |
| | | } |
| | | if(minValue != Integer.MIN_VALUE) { |
| | | group += minValue; |
| | | } |
| | | } |
| | | // æ£éªçç»æ°å¤§äºå·²ç»æ·»å çç»æ°å°±è¦æ´æ°å·¥æ¶ |
| | | int oldGroup = 0; |
| | | if(manHour.doubleValue() != 0) { |
| | | oldGroup =(int) (oldWorkTime2 / manHour.doubleValue()); |
| | | } |
| | | // æ£éªçç»æ°å¤§äºå·²ç»æ·»å çç»æ°å°±è¦æ´æ°å·¥æ¶ |
| | | if(group > oldGroup && group > oldAmount2) { |
| | | auxiliaryOutputWorkingHoursMapper.insert(addOutputWorkingHours); |
| | | } |
| | | break; |
| | | case "ç循ç¯": |
| | | // æç
§æ£éªé¡¹åç» æå 个æ£éªå¼å°±ç®å æ¬¡å·¥æ¶ |
| | | Map<String, List<InsProduct>> collect1 = new HashMap<>(); |
| | | if(Objects.nonNull(parentInsProduct)){ |
| | | collect1 = insProductMapper.selectList(new LambdaQueryWrapper<InsProduct>() |
| | | .eq(InsProduct::getSpecialItemParentId, parentInsProduct.getId())) |
| | | .stream() |
| | | .collect(Collectors.groupingBy(InsProduct::getInspectionItem)); |
| | | } |
| | | int group1 = 0; |
| | | for (Map.Entry<String,List<InsProduct>> entry : collect1.entrySet()) { |
| | | int minValue = Integer.MIN_VALUE; |
| | | List<InsProduct> insProducts1 = entry.getValue(); |
| | | for (InsProduct product1 : insProducts1) { |
| | | 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); |
| | | // æé¿çinsValue å°±æå ç»å·¥æ¶ |
| | | if(maps.size() > minValue) { |
| | | minValue = maps.size(); |
| | | } |
| | | } |
| | | } |
| | | if(minValue != Integer.MIN_VALUE) { |
| | | group1 += minValue; |
| | | } |
| | | } |
| | | |
| | | double oldWorkTime3 = 0; // ä¹åçå·¥æ¶ |
| | | double oldAmount3 = 0; // ä¹åçæ°é |
| | | for(AuxiliaryOutputWorkingHours a : oldRecords) { |
| | | oldWorkTime3 += (Objects.isNull(a.getOvertimeWorkTime()) ? 0 : a.getOvertimeWorkTime()) + (Objects.isNull(a.getWorkTime()) ? 0 : a.getWorkTime()); |
| | | oldAmount3+= (Objects.isNull(a.getAmount()) ? 0 : a.getAmount()) + (Objects.isNull(a.getOvertimeAmount()) ? 0 : a.getOvertimeAmount()); |
| | | } |
| | | // æ£éªçç»æ°å¤§äºå·²ç»æ·»å çç»æ°å°±è¦æ´æ°å·¥æ¶ |
| | | int oldGroup1 = 0; |
| | | if(manHour.doubleValue() != 0) { |
| | | oldGroup1 =(int) (oldWorkTime3 / manHour.doubleValue()); |
| | | } |
| | | // æ£éªçç»æ°å¤§äºå·²ç»æ·»å çç»æ°å°±è¦æ´æ°å·¥æ¶ |
| | | if((group1 > oldGroup1) && (group1 > oldAmount3)) { |
| | | auxiliaryOutputWorkingHoursMapper.insert(addOutputWorkingHours); |
| | | } |
| | | break; |
| | | } |
| | | |
| | | if((inspectionItem.contains("æ¾å¥ç®¡") || inspectionItemSubclass.contains("æ¾å¥ç®¡") || |
| | | !Objects.isNull(insProduct.getInsFiberId()) || |
| | | !Objects.isNull(insProduct.getInsFibersId())) && Objects.isNull(insProduct.getSpecialItemParentId()) && !insProduct.getInspectionItem().equals("å
纤æ¥å¤´æè")) { |
| | | InsProduct product = insProductMapper.selectById(Integer.parseInt(k)); |
| | | // æ¥è¯¢æ ·åä¸é¢ææçæ¾å¥ç®¡ å¹¶ä¸è¿æ»¤åºæ£éªé¡¹åæ£éªå项ç¸åçæ°æ® |
| | | List<InsProduct> collect = insProductMapper.selectList(new LambdaQueryWrapper<InsProduct>() |
| | | .eq(InsProduct::getInsSampleId, currentSampleId) |
| | | .and(item -> item.like(InsProduct::getInspectionItem, "æ¾å¥ç®¡") |
| | | .or() |
| | | .like(InsProduct::getInspectionItemSubclass, "æ¾å¥ç®¡") |
| | | .or() |
| | | .isNotNull(InsProduct::getInsFiberId) |
| | | .or() |
| | | .isNotNull(InsProduct::getInsFibersId))).stream() |
| | | .filter(item -> item.getInspectionItem().equals(product.getInspectionItem()) && |
| | | item.getInspectionItemSubclass().equals(product.getInspectionItemSubclass())) |
| | | .collect(Collectors.toList()); |
| | | // æ£éªæ»å
±çä¸ªæ° |
| | | int count = 0; |
| | | for (InsProduct insProduct1 : collect) { |
| | | // æ¥è¯¢result表 |
| | | InsProductResult insProductResult = insProductResultMapper.selectOne(new LambdaQueryWrapper<InsProductResult>() |
| | | .eq(InsProductResult::getInsProductId, insProduct1.getId())); |
| | | // å»é¤å½åæ£éªé¡¹ 妿æå¼åè¿è¡æ°éç¸å |
| | | if(Objects.isNull(insProductResult)) { |
| | | continue; |
| | | } |
| | | count++; |
| | | // List<Map> maps = JSONArray.parseArray(insProductResult.getInsValue(), Map.class); |
| | | // for(Map map : maps) { |
| | | // if(Strings.isNotEmpty(map.get("v").toString())) { |
| | | // count++; |
| | | // } |
| | | // } |
| | | } |
| | | // å·¥æ¶çä¸ªæ° |
| | | Integer oldAmount = 0; |
| | | for(AuxiliaryOutputWorkingHours a : oldRecords) { |
| | | oldAmount += (Objects.isNull(a.getAmount()) ? 0 : a.getAmount()) + (Objects.isNull(a.getOvertimeAmount()) ? 0 : a.getOvertimeAmount()); |
| | | } |
| | | // è¾å
¥çä¸ªæ° å¤§äº ç°æå·¥æ¶çä¸ªæ°æè¿è¡æ·»å |
| | | if(count > oldAmount) { |
| | | auxiliaryOutputWorkingHoursMapper.insert(addOutputWorkingHours); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | } |
| | | } |
| | | /** |
| | | * 精度é®é¢ 乿³ |
| | | */ |
| | | public double accuracy(BigDecimal manHour, int count){ |
| | | return manHour.multiply(BigDecimal.valueOf(count)).setScale(4, RoundingMode.HALF_UP).doubleValue(); |
| | | } |
| | | /** |
| | | * 精度é®é¢ å æ³ |
| | | */ |
| | | public double addAccuracy(double manHour, double count){ |
| | | return BigDecimal.valueOf(manHour).add(BigDecimal.valueOf(count)).setScale(4, RoundingMode.HALF_UP).doubleValue(); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * æ¥è¯¢æ£éªé¡¹å¯¹åºæ ååºé
ç½®çå·¥æ¶ä¿¡æ¯ |
| | | * @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 "æªç¥"; |
| | | } |
| | | } |
| | | |
| | | } |