| | |
| | | import com.deepoove.poi.util.TableTools; |
| | | import com.yuanchu.mom.common.GetLook; |
| | | import com.yuanchu.mom.common.PrintChina; |
| | | import com.yuanchu.mom.dto.ExcelDto; |
| | | import com.yuanchu.mom.dto.InsOrderPlanDTO; |
| | | import com.yuanchu.mom.dto.InsProductResultDto; |
| | | import com.yuanchu.mom.dto.SampleProductDto; |
| | | import com.yuanchu.mom.exception.ErrorException; |
| | | import com.yuanchu.mom.mapper.*; |
| | |
| | | import com.yuanchu.mom.utils.*; |
| | | import com.yuanchu.mom.vo.*; |
| | | import org.apache.commons.io.IOUtils; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.apache.poi.xwpf.usermodel.*; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.stereotype.Service; |
| | |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import java.io.*; |
| | | import java.math.BigDecimal; |
| | | import java.nio.file.Files; |
| | | import java.nio.file.Paths; |
| | | import java.text.SimpleDateFormat; |
| | |
| | | import java.util.concurrent.CompletableFuture; |
| | | import java.util.concurrent.atomic.AtomicInteger; |
| | | import java.util.concurrent.atomic.AtomicReference; |
| | | import java.util.regex.Matcher; |
| | | import java.util.regex.Pattern; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | |
| | | |
| | | @Resource |
| | | private InsProductResultMapper insProductResultMapper; |
| | | |
| | | @Resource |
| | | private InsProductResult2Mapper insProductResult2Mapper; |
| | | |
| | | @Resource |
| | | private InsProductUserMapper insProductUserMapper; |
| | |
| | | Map<String, Integer> map1 = getLook.selectPowerByMethodAndUserId(null); |
| | | Integer userId = map1.get("userId"); |
| | | User user = userMapper.selectById(map1.get("userId"));//当前登录的人 |
| | | |
| | | String laboratory = null; |
| | | //获取当前人所属实验室id |
| | | /* String departLimsId = user.getDepartLimsId(); |
| | | 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()); |
| | | } |
| | |
| | | for (Integer samId : sampleIds) { |
| | | //过滤没有检验项目的样品id |
| | | if (ObjectUtils.isEmpty(insProductMapper.selectList(Wrappers.<InsProduct>lambdaQuery() |
| | | .eq(InsProduct::getInsSampleId,samId) |
| | | .eq(InsProduct::getState,1)))){ |
| | | .eq(InsProduct::getInsSampleId, samId) |
| | | .eq(InsProduct::getState, 1)))) { |
| | | continue; |
| | | } |
| | | //入库次数 |
| | |
| | | break; |
| | | case 1: |
| | | //光纤带 |
| | | insProducts = insSampleMapper.getInsProduct2(id); |
| | | break; |
| | | case 2: |
| | | //光纤 |
| | | insProducts = insSampleMapper.getInsProduct3(id); |
| | | break; |
| | | case 3: |
| | | //套管 |
| | | insProducts = insSampleMapper.getInsProduct4(id); |
| | | 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)).get(0).getId())); |
| | | insProducts = insSampleMapper.getInsProduct3(insFibers.get(0).getId()); |
| | | } |
| | | Set<Integer> set = new HashSet<>(); |
| | | Map<Integer, String> map2 = new HashMap<>(); |
| | |
| | | return sonLaboratory; |
| | | } |
| | | |
| | | @Override |
| | | public int deleteInsContext(InsProductResultVo insProductResultVo) { |
| | | return insProductResult2Mapper.delete(Wrappers.<InsProductResult2>lambdaQuery() |
| | | .eq(InsProductResult2::getFrequency, insProductResultVo.getFrequency()) |
| | | .in(InsProductResult2::getInsProductId, insProductResultVo.getProductIds())); |
| | | } |
| | | |
| | | @Override |
| | | public int deleteInsContext2(String frequency, Integer productId, String often) { |
| | | return insProductResult2Mapper.delete(Wrappers.<InsProductResult2>lambdaQuery() |
| | | .eq(InsProductResult2::getFrequency, frequency) |
| | | .eq(InsProductResult2::getInsProductId, productId) |
| | | .eq(InsProductResult2::getOften, often)); |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public void saveInsContext(Map<String, Object> insContext) { |
| | |
| | | insProduct.setId(Integer.parseInt(k)); |
| | | List<InsProductResult> results = insProductResultMapper.selectList(Wrappers.<InsProductResult>lambdaQuery() |
| | | .eq(InsProductResult::getInsProductId, insProduct.getId())); |
| | | InsProduct product = insProductMapper.selectById(insProduct.getId()); |
| | | InsProductResult result; |
| | | if (CollectionUtils.isEmpty(results)) { |
| | | result = new InsProductResult(); |
| | |
| | | result = results.get(0); |
| | | } |
| | | result.setInsProductId(Integer.parseInt(k)); |
| | | /*校验一下result表*/ |
| | | List<InsProductResult> insProductResultss = insProductResultMapper.selectList(Wrappers.<InsProductResult>lambdaQuery() |
| | | .eq(InsProductResult::getInsProductId, insProduct.getId())); |
| | | if (insProductResultss.size() > 1) { |
| | | for (int i = 1; i < insProductResultss.size(); i++) { |
| | | insProductResultMapper.deleteById(insProductResultss.get(i)); |
| | | } |
| | | } |
| | | //检验值 |
| | | if (jo.get("insValue") != null) { |
| | | JSONArray jsonArray = JSON.parseArray(JSON.toJSONString(jo.get("insValue"))); |
| | |
| | | // 跨天的情况 |
| | | isWithinRange = !now.isBefore(startTime) || !now.isAfter(endTime); |
| | | } |
| | | //加班 |
| | | List<AuxiliaryOutputWorkingHours> count1s = auxiliaryOutputWorkingHoursMapper.selectList(Wrappers.<AuxiliaryOutputWorkingHours>lambdaQuery() |
| | | .eq(AuxiliaryOutputWorkingHours::getCheck, userId) |
| | | .eq(AuxiliaryOutputWorkingHours::getInspectionItem, insProduct.getInspectionItem()) |
| | | .eq(AuxiliaryOutputWorkingHours::getInspectionItemSubclass, insProduct.getInspectionItemSubclass()) |
| | | .eq(AuxiliaryOutputWorkingHours::getOvertimeOrderNo, insOrder.getEntrustCode()) |
| | | .eq(AuxiliaryOutputWorkingHours::getSample, insSampleMapper.selectById(insProduct.getInsSampleId()).getSampleCode())); |
| | | if (count1s.size() > 1) { |
| | | for (int i = 1; i < count1s.size(); i++) { |
| | | auxiliaryOutputWorkingHoursMapper.deleteById(count1s.get(i)); |
| | | } |
| | | } |
| | | //非加班 |
| | | List<AuxiliaryOutputWorkingHours> count2s = auxiliaryOutputWorkingHoursMapper.selectList(Wrappers.<AuxiliaryOutputWorkingHours>lambdaQuery() |
| | | .eq(AuxiliaryOutputWorkingHours::getCheck, userId) |
| | | .eq(AuxiliaryOutputWorkingHours::getInspectionItem, insProduct.getInspectionItem()) |
| | | .eq(AuxiliaryOutputWorkingHours::getInspectionItemSubclass, insProduct.getInspectionItemSubclass()) |
| | | .eq(AuxiliaryOutputWorkingHours::getOrderNo, insOrder.getEntrustCode()) |
| | | .eq(AuxiliaryOutputWorkingHours::getSample, insSampleMapper.selectById(insProduct.getInsSampleId()).getSampleCode())); |
| | | if (count2s.size() > 1) { |
| | | for (int i = 1; i < count2s.size(); i++) { |
| | | auxiliaryOutputWorkingHoursMapper.deleteById(count2s.get(i)); |
| | | } |
| | | } |
| | | if (ObjectUtils.isNotEmpty(insProduct.getManHour()) && CollectionUtils.isEmpty(count2s) && CollectionUtils.isEmpty(count1s)) { |
| | | if (ObjectUtils.isNotEmpty(insProduct.getManHour())) { |
| | | //先删后加(工时记录最后一次保存的时间) |
| | | auxiliaryOutputWorkingHoursMapper.delete(Wrappers.<AuxiliaryOutputWorkingHours>lambdaQuery() |
| | | .eq(AuxiliaryOutputWorkingHours::getInsProductId, insProduct.getId())); |
| | | AuxiliaryOutputWorkingHours auxiliaryOutputWorkingHours = new AuxiliaryOutputWorkingHours(); |
| | | if (isWithinRange) { |
| | | //在时间内就是正常上班 |
| | | auxiliaryOutputWorkingHours.setInspectionItem(insProduct.getInspectionItem());//检测父项 |
| | | auxiliaryOutputWorkingHours.setInspectionItemSubclass(insProduct.getInspectionItemSubclass());//检测子项 |
| | | auxiliaryOutputWorkingHours.setSample(insSampleMapper.selectById(insProduct.getInsSampleId()).getSampleCode());//样品编号 |
| | | auxiliaryOutputWorkingHours.setOrderNo(insOrder.getEntrustCode());//非加班委托单号 |
| | | auxiliaryOutputWorkingHours.setWorkTime(insProduct.getManHour());//非加班工时 |
| | | auxiliaryOutputWorkingHours.setAmount(1);//非加班数量 |
| | | auxiliaryOutputWorkingHours.setOutputWorkTime((ObjectUtils.isNotEmpty(auxiliaryOutputWorkingHours.getOvertimeWorkTime()) ? auxiliaryOutputWorkingHours.getOvertimeWorkTime() : 0) + (ObjectUtils.isNotEmpty(auxiliaryOutputWorkingHours.getWorkTime()) ? auxiliaryOutputWorkingHours.getWorkTime() : 0));//产量工时 |
| | | auxiliaryOutputWorkingHours.setManHourGroup(insProduct.getManHourGroup());//工时分组 |
| | | DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); |
| | | DateTimeFormatter formatters = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); |
| | | auxiliaryOutputWorkingHours.setDateTime(LocalDateTime.now().toLocalDate().atStartOfDay().format(formatters));//日期 |
| | | LocalDateTime localDateTime = LocalDateTime.now(); |
| | | DateTime parse = DateUtil.parse(localDateTime.format(formatter)); |
| | | auxiliaryOutputWorkingHours.setWeekDay(getWeek(localDateTime.format(formatters)));//星期 |
| | | auxiliaryOutputWorkingHours.setWeek(String.valueOf(DateUtil.weekOfYear(DateUtil.offsetDay(parse, 1))));//周次 |
| | | auxiliaryOutputWorkingHours.setCheck(userId);//检测人 |
| | | } |
| | | else { |
| | | |
| | | } else { |
| | | //加班 |
| | | auxiliaryOutputWorkingHours.setInspectionItem(insProduct.getInspectionItem());//检测父项 |
| | | auxiliaryOutputWorkingHours.setInspectionItemSubclass(insProduct.getInspectionItemSubclass());//检测子项 |
| | | auxiliaryOutputWorkingHours.setSample(insSampleMapper.selectById(insProduct.getInsSampleId()).getSampleCode());//样品编号 |
| | | auxiliaryOutputWorkingHours.setOvertimeOrderNo(insOrder.getEntrustCode());//加班委托单号 |
| | | auxiliaryOutputWorkingHours.setOvertimeWorkTime(insProduct.getManHour());//加班工时 |
| | | auxiliaryOutputWorkingHours.setOvertimeAmount(1);//加班数量 |
| | | auxiliaryOutputWorkingHours.setOutputWorkTime((ObjectUtils.isNotEmpty(auxiliaryOutputWorkingHours.getOvertimeWorkTime()) ? auxiliaryOutputWorkingHours.getOvertimeWorkTime() : 0) + (ObjectUtils.isNotEmpty(auxiliaryOutputWorkingHours.getWorkTime()) ? auxiliaryOutputWorkingHours.getWorkTime() : 0));//产量工时 |
| | | auxiliaryOutputWorkingHours.setManHourGroup(insProduct.getManHourGroup());//工时分组 |
| | | DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); |
| | | DateTimeFormatter formatters = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); |
| | | auxiliaryOutputWorkingHours.setDateTime(LocalDateTime.now().toLocalDate().atStartOfDay().format(formatters));//日期 |
| | | LocalDateTime localDateTime = LocalDateTime.now(); |
| | | DateTime parse = DateUtil.parse(localDateTime.format(formatter)); |
| | | auxiliaryOutputWorkingHours.setWeekDay(getWeek(localDateTime.format(formatters)));//星期 |
| | | auxiliaryOutputWorkingHours.setWeek(String.valueOf(DateUtil.weekOfYear(DateUtil.offsetDay(parse, 1))));//周次 |
| | | auxiliaryOutputWorkingHours.setCheck(userId);//检测人 |
| | | } |
| | | try { |
| | | //这个检验项目还没有填写过检验值且这次这个检验项目填写的检验值不为空 |
| | | if (CollectionUtils.isEmpty(insProductResultss) && jo.get("insValue") != null |
| | | //这个检验项目还没有填写过检验值且这次这个检验项目填写的计算值不为空但是检验值为空 |
| | | || CollectionUtils.isEmpty(insProductResultss) && jo.get("insValue") == null && jo.get("comValue") != null |
| | | //这个检验项目有填写过检验值且这次填写的检验值和原来的检验值不相等,且这次的检验值不等于空 |
| | | || (CollectionUtils.isNotEmpty(insProductResultss) && !insProductResultss.get(0).getInsValue().equals(result.getInsValue()) && jo.get("insValue") != null) |
| | | //这个检验项目有填写过检验值且这次填写的计算值和原来的计算值不相等,且这次的计算值不等于空,且这次的检验值等于空 |
| | | || (CollectionUtils.isNotEmpty(insProductResultss) && !insProductResultss.get(0).getComValue().equals(result.getComValue()) && jo.get("insValue") == null && jo.get("comValue") != null)) { |
| | | auxiliaryOutputWorkingHoursMapper.insert(auxiliaryOutputWorkingHours); |
| | | } |
| | | } catch (Exception e) { |
| | | System.out.println("工时新增不成功!!!"); |
| | | } |
| | | auxiliaryOutputWorkingHours.setInspectionItem(insProduct.getInspectionItem());//检测父项 |
| | | auxiliaryOutputWorkingHours.setInspectionItemSubclass(insProduct.getInspectionItemSubclass());//检测子项 |
| | | auxiliaryOutputWorkingHours.setSample(insSampleMapper.selectById(insProduct.getInsSampleId()).getSampleCode());//样品编号 |
| | | auxiliaryOutputWorkingHours.setManHourGroup(insProduct.getManHourGroup());//工时分组 |
| | | DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); |
| | | DateTimeFormatter formatters = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); |
| | | auxiliaryOutputWorkingHours.setDateTime(LocalDateTime.now().toLocalDate().atStartOfDay().format(formatters));//日期 |
| | | LocalDateTime localDateTime = LocalDateTime.now(); |
| | | DateTime parse = DateUtil.parse(localDateTime.format(formatter)); |
| | | auxiliaryOutputWorkingHours.setWeekDay(getWeek(localDateTime.format(formatters)));//星期 |
| | | auxiliaryOutputWorkingHours.setWeek(String.valueOf(DateUtil.weekOfYear(DateUtil.offsetDay(parse, 1))));//周次 |
| | | auxiliaryOutputWorkingHours.setCheck(userId);//检测人 |
| | | auxiliaryOutputWorkingHours.setInsProductId(insProduct.getId());//检验项目id |
| | | auxiliaryOutputWorkingHoursMapper.insert(auxiliaryOutputWorkingHours); |
| | | } |
| | | } |
| | | } |
| | | |
| | | InsSample insSample = insSampleMapper.selectById(insProductMapper.selectById(insProduct.getId()).getInsSampleId()); |
| | | insSample.setInsState(1); |
| | | Long l = insProductMapper.selectCount(Wrappers.<InsProduct>lambdaQuery() |
| | |
| | | if (res != null) { |
| | | int pId = Integer.parseInt(res.replaceAll("\\D+", "")); |
| | | InsProduct insProduct = insProductMapper.selectById(pId); |
| | | // 通过pId 获取当前样本id |
| | | int sampleId = insProductMapper.selectById(pId).getInsSampleId(); |
| | | // 通过样本id获取订单id |
| | | int orderId = insSampleMapper.selectById(sampleId).getInsOrderId(); |
| | | // 通过订单id查找所有样本id |
| | | List<Integer> sampleIds = insSampleMapper.selectList(Wrappers.<InsSample>lambdaQuery().eq(InsSample::getInsOrderId, orderId)).stream().map(InsSample::getId).collect(Collectors.toList()); |
| | | // 通过检查每一个样本id查到属于检验项结论 is null 或者 =2 的数量 |
| | | Long count = insProductMapper.selectCount(Wrappers.<InsProduct>lambdaQuery() |
| | | .in(InsProduct::getInsSampleId, sampleIds) |
| | | .and(wrapper -> wrapper |
| | | .isNull(InsProduct::getInsResult) |
| | | .or() |
| | | .eq(InsProduct::getInsResult, 2) |
| | | ) |
| | | .eq(InsProduct::getSonLaboratory, insProduct.getSonLaboratory()) |
| | | .eq(InsProduct::getState, 1)); |
| | | int orderId = insSampleMapper.selectById(insProduct.getInsSampleId()).getInsOrderId(); |
| | | int count = insProductMapper.selectInsProductCountByOrderId(orderId); |
| | | if (count == 0) { |
| | | insOrderStateMapper.update(new InsOrderState(), Wrappers.<InsOrderState>lambdaUpdate() |
| | | .eq(InsOrderState::getInsOrderId, orderId) |
| | |
| | | e.printStackTrace(); |
| | | return null; |
| | | }); |
| | | } |
| | | |
| | | //电路试验的保存检验内容 |
| | | @Override |
| | | public List<Integer> saveInsContext2(InsProductResultDto insProductResultDtos) { |
| | | if (ObjectUtils.isEmpty(insProductResultDtos.getFrequency())){ |
| | | throw new ErrorException("频率不能为空"); |
| | | } |
| | | Integer userId = getLook.selectPowerByMethodAndUserId(null).get("userId"); |
| | | //查询检验单信息 |
| | | InsOrder insOrder = insOrderMapper.selectById(insProductResultDtos.getOrderId()); |
| | | //查询样品信息 |
| | | InsSample insSample = insSampleMapper.selectById(insProductResultDtos.getSampleId()); |
| | | List<Integer> list = new ArrayList<>(); |
| | | /*新增检验项目检验值记录表(采取先删后增)*/ |
| | | insProductResult2Mapper.delete(Wrappers.<InsProductResult2>lambdaQuery() |
| | | .in(InsProductResult2::getInsProductId, insProductResultDtos.getInsProductResult2s().stream().map(InsProductResult2::getInsProductId).distinct().collect(Collectors.toList())) |
| | | .eq(InsProductResult2::getFrequency, insProductResultDtos.getFrequency())); |
| | | for (InsProductResult2 insProductResult2 : insProductResultDtos.getInsProductResult2s()) { |
| | | InsProduct insProduct = new InsProduct(); |
| | | insProduct.setId(insProductResult2.getInsProductId());//项目id |
| | | InsProductResult2 result2 = new InsProductResult2(); |
| | | result2.setInsProductId(insProductResult2.getInsProductId()); |
| | | //频率 |
| | | result2.setFrequency(insProductResultDtos.getFrequency()); |
| | | //频点 |
| | | if (insProductResult2.getOften() != null) { |
| | | result2.setOften(insProductResult2.getOften()); |
| | | } |
| | | //端口 |
| | | if (insProductResult2.getPort() != null) { |
| | | result2.setPort(insProductResult2.getPort()); |
| | | } |
| | | //角度 |
| | | if (insProductResult2.getAngle() != null) { |
| | | result2.setAngle(insProductResult2.getAngle()); |
| | | } |
| | | //设备编号 |
| | | if (insProductResult2.getEquipValue() != null) { |
| | | result2.setEquipValue(insProductResult2.getEquipValue()); |
| | | } |
| | | //设备名称 |
| | | if (insProductResult2.getEquipName() != null) { |
| | | result2.setEquipName(insProductResult2.getEquipName()); |
| | | } |
| | | insProduct = insProductMapper.selectById(insProduct.getId()); |
| | | //值 |
| | | if (insProductResult2.getValue() != null) { |
| | | result2.setValue(insProductResult2.getValue()); |
| | | //结论 |
| | | int ressult = 1; |
| | | String valueStr = insProductResult2.getValue(); |
| | | if (!insProduct.getAsk().contains(",")) { |
| | | if (!isValueValid(valueStr, new String[]{insProduct.getAsk()})) { |
| | | ressult = 0; //不合格 |
| | | } |
| | | } else { |
| | | // 如果要求值是(2°≥20,7°≥25,12°≥25)这种情况 |
| | | String[] askParts = insProduct.getAsk().split(","); |
| | | String[] angles = insProductResult2.getAngle().split(","); |
| | | for (String s : askParts) { |
| | | String[] askSplit = s.split("°"); |
| | | String angleKey = askSplit[0]; |
| | | String angleValue = askSplit[1]; |
| | | |
| | | for (int i = 0; i < angles.length; i++) { |
| | | if (angles[i].split("°")[0].equals(angleKey)) { |
| | | try { |
| | | String s1 = valueStr.substring(1, valueStr.length() - 1).split("\\],\\[")[i]; |
| | | if (!s1.startsWith("[")) { |
| | | s1 = "[" + s1; |
| | | } |
| | | if (!s1.endsWith("]")) { |
| | | s1 = s1 + "]"; |
| | | } |
| | | if (!isValueValid("[" + s1 + "]", new String[]{angleValue})) { |
| | | ressult = 0; // 不合格 |
| | | break; |
| | | } |
| | | }catch (Exception e) { |
| | | }finally { |
| | | continue; |
| | | } |
| | | |
| | | } |
| | | } |
| | | } |
| | | } |
| | | result2.setResult(ressult); |
| | | list.add(ressult); |
| | | } |
| | | result2.setCreateUser(userId); |
| | | result2.setUpdateUser(userId); |
| | | insProductResult2Mapper.insert(result2); |
| | | insProduct.setUpdateUser(userId); |
| | | insProductMapper.updateById(insProduct); |
| | | insProductUserMapper.insert(new InsProductUser(null, userId, LocalDateTime.now(), insProduct.getId())); |
| | | /*生成产量工时*/ |
| | | //校验如果这个人这个检测项目已经添加过了则不需要再新增 |
| | | //首先判断当前人的当前时间是否是排班时间内,如果不是就是加班 |
| | | 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())); |
| | | if (ObjectUtils.isNotEmpty(shiftTime)) { |
| | | DateTimeFormatter forma = DateTimeFormatter.ofPattern("HH:mm"); |
| | | LocalTime now = LocalTime.now(); |
| | | LocalTime startTime = LocalTime.parse(shiftTime.getStartTime(), forma); |
| | | LocalTime endTime = LocalTime.parse(shiftTime.getEndTime(), forma); |
| | | // 检查当前时间是否在范围内(包括边界) |
| | | boolean isWithinRange; |
| | | if (endTime.isAfter(startTime)) { |
| | | // 不跨天的情况 |
| | | isWithinRange = !now.isBefore(startTime) && !now.isAfter(endTime); |
| | | } else { |
| | | // 跨天的情况 |
| | | isWithinRange = !now.isBefore(startTime) || !now.isAfter(endTime); |
| | | } |
| | | if (ObjectUtils.isNotEmpty(insProduct.getManHour())) { |
| | | //先删后加(工时记录最后一次保存的时间) |
| | | auxiliaryOutputWorkingHoursMapper.delete(Wrappers.<AuxiliaryOutputWorkingHours>lambdaQuery() |
| | | .eq(AuxiliaryOutputWorkingHours::getInsProductId, insProduct.getId())); |
| | | AuxiliaryOutputWorkingHours auxiliaryOutputWorkingHours = new AuxiliaryOutputWorkingHours(); |
| | | if (isWithinRange) { |
| | | //在时间内就是正常上班 |
| | | auxiliaryOutputWorkingHours.setOrderNo(insOrder.getEntrustCode());//非加班委托单号 |
| | | auxiliaryOutputWorkingHours.setWorkTime(insProduct.getManHour());//非加班工时 |
| | | auxiliaryOutputWorkingHours.setAmount(1);//非加班数量 |
| | | auxiliaryOutputWorkingHours.setOutputWorkTime((ObjectUtils.isNotEmpty(auxiliaryOutputWorkingHours.getOvertimeWorkTime()) ? auxiliaryOutputWorkingHours.getOvertimeWorkTime() : 0) + (ObjectUtils.isNotEmpty(auxiliaryOutputWorkingHours.getWorkTime()) ? auxiliaryOutputWorkingHours.getWorkTime() : 0));//产量工时 |
| | | |
| | | } else { |
| | | //加班 |
| | | auxiliaryOutputWorkingHours.setOvertimeOrderNo(insOrder.getEntrustCode());//加班委托单号 |
| | | auxiliaryOutputWorkingHours.setOvertimeWorkTime(insProduct.getManHour());//加班工时 |
| | | auxiliaryOutputWorkingHours.setOvertimeAmount(1);//加班数量 |
| | | auxiliaryOutputWorkingHours.setOutputWorkTime((ObjectUtils.isNotEmpty(auxiliaryOutputWorkingHours.getOvertimeWorkTime()) ? auxiliaryOutputWorkingHours.getOvertimeWorkTime() : 0) + (ObjectUtils.isNotEmpty(auxiliaryOutputWorkingHours.getWorkTime()) ? auxiliaryOutputWorkingHours.getWorkTime() : 0));//产量工时 |
| | | } |
| | | auxiliaryOutputWorkingHours.setInspectionItem(insProduct.getInspectionItem());//检测父项 |
| | | auxiliaryOutputWorkingHours.setInspectionItemSubclass(insProduct.getInspectionItemSubclass());//检测子项 |
| | | auxiliaryOutputWorkingHours.setSample(insSampleMapper.selectById(insProduct.getInsSampleId()).getSampleCode());//样品编号 |
| | | auxiliaryOutputWorkingHours.setManHourGroup(insProduct.getManHourGroup());//工时分组 |
| | | DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); |
| | | DateTimeFormatter formatters = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); |
| | | auxiliaryOutputWorkingHours.setDateTime(LocalDateTime.now().toLocalDate().atStartOfDay().format(formatters));//日期 |
| | | LocalDateTime localDateTime = LocalDateTime.now(); |
| | | DateTime parse = DateUtil.parse(localDateTime.format(formatter)); |
| | | auxiliaryOutputWorkingHours.setWeekDay(getWeek(localDateTime.format(formatters)));//星期 |
| | | auxiliaryOutputWorkingHours.setWeek(String.valueOf(DateUtil.weekOfYear(DateUtil.offsetDay(parse, 1))));//周次 |
| | | auxiliaryOutputWorkingHours.setCheck(userId);//检测人 |
| | | auxiliaryOutputWorkingHours.setInsProductId(insProduct.getId());//检验项目id |
| | | auxiliaryOutputWorkingHoursMapper.insert(auxiliaryOutputWorkingHours); |
| | | } |
| | | } |
| | | } |
| | | /*更新样品的检验状态*/ |
| | | insSample.setInsState(1); |
| | | Long l = insProductMapper.selectCount(Wrappers.<InsProduct>lambdaQuery() |
| | | .eq(InsProduct::getInsSampleId, insSample.getId())); |
| | | Long l1 = insProductMapper.selectCount(Wrappers.<InsProduct>lambdaQuery() |
| | | .eq(InsProduct::getInsSampleId, insSample.getId()) |
| | | .and(wrapper -> wrapper |
| | | .isNotNull(InsProduct::getInsResult) |
| | | .or() |
| | | .ne(InsProduct::getInsResult, 2) |
| | | )); |
| | | if (l == l1) { |
| | | //如果所有项目都有结论,那么该样品状态已检 |
| | | insSample.setInsState(2); |
| | | } |
| | | insSampleMapper.updateById(insSample); |
| | | } |
| | | /*判断该站点的检验项目是否全部已检*/ |
| | | int count = insProductMapper.selectInsProductCountByOrderId(insProductResultDtos.getOrderId()); |
| | | if (count == 0) { |
| | | insOrderStateMapper.update(new InsOrderState(), Wrappers.<InsOrderState>lambdaUpdate() |
| | | .eq(InsOrderState::getInsOrderId, insProductResultDtos.getOrderId()) |
| | | .eq(InsOrderState::getLaboratory, insProductResultDtos.getSonLaboratory()) |
| | | .set(InsOrderState::getInsState, 2)); |
| | | } |
| | | return list; |
| | | } |
| | | |
| | | //解析要求值的格式 |
| | | private boolean getResult(double s, String ask) { |
| | | // 处理±范围的条件 |
| | | if (ask.contains("±")) { |
| | | Pattern pattern = Pattern.compile("(\\d+)±(\\d+)"); |
| | | Matcher matcher = pattern.matcher(ask); |
| | | if (matcher.matches()) { |
| | | double center = Double.parseDouble(matcher.group(1)); |
| | | double tolerance = Double.parseDouble(matcher.group(2)); |
| | | return Math.abs(s - center) <= tolerance; |
| | | } |
| | | } |
| | | // 处理其他比较条件 |
| | | if (ask.startsWith(">")) { |
| | | double threshold = Double.parseDouble(ask.substring(1)); |
| | | return s > threshold; |
| | | } else if (ask.startsWith("≥")) { |
| | | double threshold = Double.parseDouble(ask.substring(1)); |
| | | return s >= threshold; |
| | | } else if (ask.startsWith("<")) { |
| | | double threshold = Double.parseDouble(ask.substring(1)); |
| | | return s < threshold; |
| | | } else if (ask.startsWith("≤")) { |
| | | double threshold = Double.parseDouble(ask.substring(1)); |
| | | return s <= threshold; |
| | | } else if (ask.equals("=")) { |
| | | double exactValue = Double.parseDouble(ask.substring(1)); |
| | | return s == exactValue; |
| | | } |
| | | // 处理不支持的条件 |
| | | throw new IllegalArgumentException("未知格式要求值请检查" + ask); |
| | | } |
| | | |
| | | //将前端传过来的值转换成数组的形式 |
| | | private String[] parseValues(String valueStr) { |
| | | String trimmedStr = valueStr.substring(1, valueStr.length() - 1); |
| | | return Arrays.stream(trimmedStr.split("\\],\\[")) |
| | | .map(s -> s.substring(1, s.length() - 1).split(",")) |
| | | .flatMap(Arrays::stream) |
| | | .map(s -> s.replace("\"", "")) |
| | | .toArray(String[]::new); |
| | | } |
| | | |
| | | //判读合格与不合格 |
| | | private boolean isValueValid(String valueStr, String[] valuesToCheck) { |
| | | for (String s : parseValues(valueStr)) { |
| | | if (ObjectUtils.isEmpty(s)) { |
| | | continue; |
| | | } |
| | | double numericValue = Double.parseDouble(s); |
| | | boolean valid = Arrays.stream(valuesToCheck) |
| | | .allMatch(v -> getResult(numericValue, v)); |
| | | if (!valid) { |
| | | return false; |
| | | } |
| | | } |
| | | return true; |
| | | } |
| | | |
| | | //交接 |
| | |
| | | insOrderState.setLaboratory(minElement); |
| | | insOrderState.setInsState(0); |
| | | insOrderStateMapper.insert(insOrderState); |
| | | } |
| | | else { |
| | | } else { |
| | | //如果继续试验没有其他站点的检验任务那就结束试验 |
| | | verifyPlan(orderId, laboratory, 2, tell); |
| | | } |
| | |
| | | String str = ""; |
| | | int count = 0; |
| | | for (InsProduct product : insProducts) { |
| | | //辐射试验检测的检验项目,不需要去手动填写检验值,只需要上传表格文件就可以了,后台提交的时候校验跳过这个检验项目 |
| | | if (product.getInspectionItem().equals("辐射试验检测")) { |
| | | product.setInsResult(3);//不判定 |
| | | insProductMapper.updateById(product); |
| | | continue; |
| | | } |
| | | //电路试验的检验项目,需要在提交的时候再去赋值合格与不合格 |
| | | if (product.getInspectionItem().equals("电路试验")) { |
| | | List<Integer> collect = insProductResult2Mapper.selectList(Wrappers.<InsProductResult2>lambdaQuery() |
| | | .eq(InsProductResult2::getInsProductId, product.getId())).stream().map(InsProductResult2::getResult).distinct().collect(Collectors.toList()); |
| | | if (collect.contains(0)) { |
| | | product.setInsResult(0);//不合格 |
| | | } else { |
| | | product.setInsResult(1);//合格 |
| | | } |
| | | insProductMapper.updateById(product); |
| | | continue; |
| | | } |
| | | count++; |
| | | str += "<br/>" + count + ":" + product.getInspectionItem() + " " + product.getInspectionItemSubclass() + "<br/>"; |
| | | } |
| | |
| | | InsOrder insOrder = insOrderMapper.selectById(orderId); |
| | | if (insOrder.getOrderType().equals("C") && insOrder.getDepartmentLims().equals("质量部")) { |
| | | verifyPlan(orderId, laboratory, 2, null); |
| | | }else { |
| | | } else { |
| | | Integer userId = getLook.selectPowerByMethodAndUserId(null).get("userId"); |
| | | //LIMS系统消息推送 |
| | | InformationNotification info = new InformationNotification(); |