| | |
| | | import com.ruoyi.performance.mapper.PerformanceShiftMapper; |
| | | import com.ruoyi.performance.mapper.ShiftTimeMapper; |
| | | import com.ruoyi.performance.pojo.AuxiliaryOutputWorkingHours; |
| | | import com.ruoyi.performance.pojo.AuxiliaryOutputWorkingHoursTemporary; |
| | | import com.ruoyi.performance.service.AuxiliaryOutputWorkingHoursService; |
| | | import com.ruoyi.performance.service.AuxiliaryOutputWorkingHoursTemporaryService; |
| | | import com.ruoyi.system.mapper.CustomMapper; |
| | | import com.ruoyi.system.mapper.UserMapper; |
| | | import com.ruoyi.system.service.ISysDictTypeService; |
| | |
| | | @Resource |
| | | private InsUnPassService insUnPassService; |
| | | @Resource |
| | | private AuxiliaryOutputWorkingHoursMapper auxiliaryOutputWorkingHoursMapper; |
| | | @Resource |
| | | private AuxiliaryOutputWorkingHoursService auxiliaryOutputWorkingHoursService; |
| | | @Resource |
| | | private AuxiliaryOutputWorkingHoursTemporaryService auxiliaryOutputWorkingHoursTemporaryService; |
| | | @Resource |
| | | private InformationNotificationService informationNotificationService; |
| | | @Resource |
| | |
| | | } |
| | | } |
| | | |
| | | //查询检验单信息 |
| | | // 添加工时 |
| | | InsProduct finalInsProduct = insProductMapper.selectById(product.getId()); |
| | | threadPoolTaskExecutor.execute(() -> { |
| | | InsOrder insOrder = insOrderMapper.selectById(insSample.getInsOrderId()); |
| | | this.addAuxiliary(userId, finalInsProduct, insOrder); |
| | | }); |
| | | } |
| | | }); |
| | | String sampleIdStr = insContext.keySet().stream().findFirst().orElse(null); |
| | |
| | | return insSampleUserMapper.insert(insSampleUser); |
| | | } |
| | | |
| | | /** |
| | | * 查询模板内容 |
| | | * @param order |
| | | * @param insProducts |
| | | */ |
| | | private void getTemplateThing(InsOrder order, List<InsProduct> insProducts) { |
| | | Set<Integer> set = new HashSet<>(); |
| | | // 检验项分类+检验项+检验子项的拼接 |
| | | List<String> itemNameList = insProducts.stream().map(insProduct -> { |
| | | String itemName = ""; |
| | | if (StringUtils.isNotBlank(insProduct.getInspectionItemClass())) { |
| | | itemName += insProduct.getInspectionItemClass().trim(); |
| | | } |
| | | if (StringUtils.isNotBlank(insProduct.getInspectionItem())) { |
| | | itemName += insProduct.getInspectionItem().trim(); |
| | | } |
| | | if (StringUtils.isNotBlank(insProduct.getInspectionItemSubclass())) { |
| | | itemName += insProduct.getInspectionItemSubclass().trim(); |
| | | } |
| | | return itemName; |
| | | }).collect(Collectors.toList()); |
| | | // List<String> itemNameList = insProducts.stream().map(insProduct -> { |
| | | // String itemName = ""; |
| | | // if (StringUtils.isNotBlank(insProduct.getInspectionItemClass())) { |
| | | // itemName += insProduct.getInspectionItemClass().trim(); |
| | | // } |
| | | // if (StringUtils.isNotBlank(insProduct.getInspectionItem())) { |
| | | // itemName += insProduct.getInspectionItem().trim(); |
| | | // } |
| | | // if (StringUtils.isNotBlank(insProduct.getInspectionItemSubclass())) { |
| | | // itemName += insProduct.getInspectionItemSubclass().trim(); |
| | | // } |
| | | // return itemName; |
| | | // }).collect(Collectors.toList()); |
| | | // 查询订单状态判断是否是查历史模板 |
| | | if (order.getIsFirstSubmit() != null && order.getIsFirstSubmit().equals(1)) { |
| | | InsOrderState insOrderState = insOrderStateMapper.selectOne(Wrappers.<InsOrderState>lambdaQuery() |
| | |
| | | thing = one.getThing(); |
| | | if (StrUtil.isNotEmpty(thing)) { |
| | | thing = GZipUtil.uncompress(thing); |
| | | JSONObject sheet = JSON.parseObject(JSON.toJSONString(JSON.parseArray(JSON.toJSONString(JSON.parseObject(thing).get("data"))).get(0))); |
| | | // 清除没有关联的检验项 |
| | | eliminateItem(sheet, itemNameList); |
| | | |
| | | JSONObject config = JSON.parseObject(JSON.toJSONString(sheet.get("config"))); |
| | | JSONObject sheet = JSON.parseObject(thing).getJSONArray("data").getJSONObject(0); |
| | | JSONObject config = sheet.getJSONObject("config"); |
| | | List<JSONObject> cellData = JSON.parseArray(JSON.toJSONString(sheet.get("celldata")), JSONObject.class); |
| | | Map<String, Object> style = new HashMap<>(); |
| | | style.put("rowlen", config.get("rowlen")); |
| | |
| | | thing = standardTemplateService.getStandTempThingById(product.getTemplateId()); |
| | | } |
| | | if (StrUtil.isNotEmpty(thing)) { |
| | | JSONObject sheet = JSON.parseObject(JSON.toJSONString(JSON.parseArray(JSON.toJSONString(JSON.parseObject(thing).get("data"))).get(0))); |
| | | // 清除没有关联的检验项 |
| | | eliminateItem(sheet, itemNameList); |
| | | JSONObject config = JSON.parseObject(JSON.toJSONString(sheet.get("config"))); |
| | | JSONObject sheet = JSON.parseObject(thing).getJSONArray("data").getJSONObject(0); |
| | | JSONObject config = sheet.getJSONObject("config"); |
| | | List<JSONObject> cellData = JSON.parseArray(JSON.toJSONString(sheet.get("celldata")), JSONObject.class); |
| | | Map<String, Object> style = new HashMap<>(); |
| | | style.put("rowlen", config.get("rowlen")); |
| | |
| | | } |
| | | |
| | | /** |
| | | * 清除没有使用的检验项 |
| | | * todo: 清除没有使用的检验项 |
| | | * @param sheet |
| | | * @param itemNameList |
| | | */ |
| | |
| | | } |
| | | } |
| | | |
| | | // 添加工时 |
| | | // 删除原本订单工时 |
| | | auxiliaryOutputWorkingHoursService.remove(Wrappers.<AuxiliaryOutputWorkingHours>lambdaQuery() |
| | | .eq(AuxiliaryOutputWorkingHours::getOrderId, orderId)); |
| | | // 查询工时暂存 |
| | | List<AuxiliaryOutputWorkingHoursTemporary> hoursTemporaries = auxiliaryOutputWorkingHoursTemporaryService.list(Wrappers.<AuxiliaryOutputWorkingHoursTemporary>lambdaQuery() |
| | | .eq(AuxiliaryOutputWorkingHoursTemporary::getOrderId, orderId)); |
| | | List<AuxiliaryOutputWorkingHours> outputWorkingHours = hoursTemporaries.stream().map(hoursTemporary -> { |
| | | AuxiliaryOutputWorkingHours workingHours = new AuxiliaryOutputWorkingHours(); |
| | | BeanUtil.copyProperties(hoursTemporary, workingHours); |
| | | workingHours.setId(null); |
| | | return workingHours; |
| | | }).collect(Collectors.toList()); |
| | | auxiliaryOutputWorkingHoursService.saveBatch(outputWorkingHours); |
| | | |
| | | // 成品抽样添加合格状态 |
| | | // 判断是否有抽样信息 |
| | | if (order.getQuarterItemId() != null) { |
| | |
| | | } |
| | | |
| | | return 1; |
| | | } |
| | | |
| | | public int pxToCm(int px) { |
| | | return px / 9; |
| | | } |
| | | |
| | | // 获取两个localDateTime的每一天 |
| | | public static List<LocalDateTime> getLocalDateTimesBetween(LocalDateTime start, LocalDateTime end) { |
| | | List<LocalDateTime> localDateTimes = new ArrayList<>(); |
| | | LocalDate currentDate = start.toLocalDate(); |
| | | LocalDateTime currentLocalDateTime = start; |
| | | while (!currentDate.isAfter(end.toLocalDate())) { |
| | | localDateTimes.add(currentLocalDateTime); |
| | | currentLocalDateTime = currentLocalDateTime.plusDays(1); |
| | | currentDate = currentDate.plusDays(1); |
| | | } |
| | | return localDateTimes; |
| | | } |
| | | |
| | | 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 "未知"; |
| | | } |
| | | } |
| | | |
| | | |
| | |
| | | } |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * 添加工时 |
| | | * @param userId |
| | | * @param insProduct |
| | | * @param insOrder |
| | | */ |
| | | private synchronized void addAuxiliary(Integer userId, InsProduct insProduct, InsOrder insOrder) { |
| | | if (insProduct.getIsBinding().equals(1)) { |
| | | return; |
| | | } |
| | | |
| | | //首先判断当前人的当前时间是否是排班时间内,如果不是就是加班 |
| | | LocalDateTime today = LocalDateTime.of(LocalDate.now(), LocalTime.MIDNIGHT); |
| | | |
| | | //校验如果这个人这个检测项目已经添加过了 |
| | | List<AuxiliaryOutputWorkingHours> count2s = auxiliaryOutputWorkingHoursMapper.selectList(Wrappers.<AuxiliaryOutputWorkingHours>lambdaQuery() |
| | | .eq(AuxiliaryOutputWorkingHours::getCheck, userId) |
| | | .eq(AuxiliaryOutputWorkingHours::getInsProductId, insProduct.getId())); |
| | | if (CollectionUtils.isNotEmpty(count2s)) { |
| | | auxiliaryOutputWorkingHoursMapper.deleteBatchIds(count2s.stream().map(auxiliaryOutputWorkingHours -> auxiliaryOutputWorkingHours.getId()).collect(Collectors.toList())); |
| | | } |
| | | if (ObjectUtils.isNotEmpty(insProduct.getManHour()) && StringUtils.isNotBlank(insProduct.getLastValue())) { |
| | | AuxiliaryOutputWorkingHours auxiliaryOutputWorkingHours = new AuxiliaryOutputWorkingHours(); |
| | | auxiliaryOutputWorkingHours.setInspectionItemClass(insProduct.getInspectionItemClass());//检测项分类 |
| | | auxiliaryOutputWorkingHours.setInspectionItem(insProduct.getInspectionItem());//检测父项 |
| | | auxiliaryOutputWorkingHours.setInspectionItemSubclass(insProduct.getInspectionItemSubclass());//检测子项 |
| | | auxiliaryOutputWorkingHours.setSample(insSampleMapper.selectById(insProduct.getInsSampleId()).getSampleCode());//样品编号 |
| | | auxiliaryOutputWorkingHours.setOrderId(insOrder.getId());//订单id |
| | | auxiliaryOutputWorkingHours.setOrderNo(insOrder.getEntrustCode());//非加班委托单号 |
| | | auxiliaryOutputWorkingHours.setWorkTime(insProduct.getManHour());//非加班工时 |
| | | auxiliaryOutputWorkingHours.setAmount(1);//非加班数量 |
| | | auxiliaryOutputWorkingHours.setOutputWorkTime((ObjectUtils.isNotEmpty(auxiliaryOutputWorkingHours.getOvertimeWorkTime()) ? auxiliaryOutputWorkingHours.getOvertimeWorkTime() : BigDecimal.ZERO).add(ObjectUtils.isNotEmpty(auxiliaryOutputWorkingHours.getWorkTime()) ? auxiliaryOutputWorkingHours.getWorkTime() : BigDecimal.ZERO));//产量工时 |
| | | 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.setPrice(insProduct.getPrice());//单价 |
| | | auxiliaryOutputWorkingHours.setSampleId(insProduct.getInsSampleId());//样品id |
| | | auxiliaryOutputWorkingHours.setInsProductId(insProduct.getId());//检验项id |
| | | |
| | | auxiliaryOutputWorkingHoursMapper.insert(auxiliaryOutputWorkingHours); |
| | | |
| | | } |
| | | } |
| | | |
| | | } |