From 3aac0bf15ae2942f9b810715946be8a7588004ec Mon Sep 17 00:00:00 2001 From: zhuo <2089219845@qq.com> Date: 星期五, 28 二月 2025 11:39:53 +0800 Subject: [PATCH] 工时创建流程调整 --- inspect-server/src/main/java/com/ruoyi/inspect/service/impl/InsOrderPlanServiceImpl.java | 245 +++++++++++++++++++++++++----------------------- 1 files changed, 128 insertions(+), 117 deletions(-) diff --git a/inspect-server/src/main/java/com/ruoyi/inspect/service/impl/InsOrderPlanServiceImpl.java b/inspect-server/src/main/java/com/ruoyi/inspect/service/impl/InsOrderPlanServiceImpl.java index c33bb08..d366471 100644 --- a/inspect-server/src/main/java/com/ruoyi/inspect/service/impl/InsOrderPlanServiceImpl.java +++ b/inspect-server/src/main/java/com/ruoyi/inspect/service/impl/InsOrderPlanServiceImpl.java @@ -34,7 +34,6 @@ import com.ruoyi.common.constant.InsOrderTypeConstants; import com.ruoyi.common.core.domain.entity.Custom; import com.ruoyi.common.core.domain.entity.InformationNotification; -import com.ruoyi.common.core.domain.entity.SysDictData; import com.ruoyi.common.core.domain.entity.User; import com.ruoyi.common.utils.*; import com.ruoyi.framework.exception.ErrorException; @@ -49,13 +48,16 @@ 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; import com.ruoyi.system.service.InformationNotificationService; import org.apache.commons.lang3.StringUtils; import org.apache.poi.xwpf.usermodel.*; +import org.jetbrains.annotations.NotNull; import org.springframework.beans.factory.annotation.Value; import org.springframework.mock.web.MockMultipartFile; import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; @@ -119,9 +121,9 @@ @Resource private InsUnPassService insUnPassService; @Resource - private AuxiliaryOutputWorkingHoursMapper auxiliaryOutputWorkingHoursMapper; - @Resource private AuxiliaryOutputWorkingHoursService auxiliaryOutputWorkingHoursService; + @Resource + private AuxiliaryOutputWorkingHoursTemporaryService auxiliaryOutputWorkingHoursTemporaryService; @Resource private InformationNotificationService informationNotificationService; @Resource @@ -500,13 +502,6 @@ } } - //鏌ヨ妫�楠屽崟淇℃伅 - // 娣诲姞宸ユ椂 - 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); @@ -591,8 +586,27 @@ 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()); // 鏌ヨ璁㈠崟鐘舵�佸垽鏂槸鍚︽槸鏌ュ巻鍙叉ā鏉� if (order.getIsFirstSubmit() != null && order.getIsFirstSubmit().equals(1)) { InsOrderState insOrderState = insOrderStateMapper.selectOne(Wrappers.<InsOrderState>lambdaQuery() @@ -612,8 +626,9 @@ .eq(InsOrderStandardTemplate::getInsOrderId, order.getId())); thing = one.getThing(); if (StrUtil.isNotEmpty(thing)) { - JSONObject sheet = JSON.parseObject(JSON.toJSONString(JSON.parseArray(JSON.toJSONString(JSON.parseObject(thing).get("data"))).get(0))); - JSONObject config = JSON.parseObject(JSON.toJSONString(sheet.get("config"))); + thing = GZipUtil.uncompress(thing); + 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")); @@ -636,8 +651,8 @@ 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))); - 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")); @@ -647,6 +662,90 @@ product.setTemplateName(standardTemplateService.getStandTempNameById(product.getTemplateId())); } } + } + + /** + * todo: 娓呴櫎娌℃湁浣跨敤鐨勬楠岄」 + * @param sheet + * @param itemNameList + */ + private static void eliminateItem(JSONObject sheet, List<String> itemNameList) { + // 鑾峰彇鍒� 妫�楠岄」鍒嗙被+妫�楠岄」+妫�楠屽瓙椤圭殑鎷兼帴,濡傛灉妯℃澘閲岀殑淇℃伅璺熸帴鍙h繑鍥炵殑妫�楠岄」淇℃伅鑳藉鍖归厤鍒欏睍绀哄嚭鏉� + + // 寰幆琛屾暟鍒ゆ柇鏄惁 + JSONArray dataListJSONArray = sheet.getJSONArray("data"); + + // 娣诲姞鍧愭爣map + Map<String, String> coordinatesMap = new HashMap<>(); + + // 闇�瑕佺Щ闄ょ殑绱㈠紩 + List<Integer> deleteIndex = new ArrayList<>(); + // 寰幆鍒� + for (int r = 0; r < dataListJSONArray.size(); r++) { + JSONArray dataList = dataListJSONArray.getJSONArray(r); + // 寰幆琛� + String itemName = ""; + // 鍒ゆ柇鏄惁鏄剧ず + boolean isShow = false; + + for (int c = 0; c < dataList.size(); c++) { + // 鏌ヨ鎵规敞 + JSONObject jsonObject = dataList.getJSONObject(c); + try { + if (jsonObject.getJSONObject("ps").getString("value").equals("妫�楠岄」鍒嗙被")) { + String value = jsonObject.getString("v").trim(); + itemName += value; + // 娣诲姞鍧愭爣 + String coordinates = coordinatesJoint(r, c); + coordinatesMap.put(coordinates, value); + isShow = true; + } else if (jsonObject.getJSONObject("ps").getString("value").equals("妫�楠岄」")) { + String value = jsonObject.getString("v").trim(); + itemName += value; + // 娣诲姞鍧愭爣 + String coordinates = coordinatesJoint(r, c); + coordinatesMap.put(coordinates, value); + isShow = true; + } else if (jsonObject.getJSONObject("ps").getString("value").equals("妫�楠屽瓙椤�")) { + String value = jsonObject.getString("v").trim(); + itemName += value; + // 娣诲姞鍧愭爣 + String coordinates = coordinatesJoint(r, c); + coordinatesMap.put(coordinates, value); + isShow = true; + } + } catch (Exception e) { + // 鍒ゆ柇鏄惁鏈塵c鍚堝苟鍗曞厓鏍� + if (jsonObject != null && jsonObject.getJSONObject("mc") != null) { + // 鏌ヨ鍧愭爣杩涜娣诲姞 + String value = coordinatesMap.get(coordinatesJoint(jsonObject.getJSONObject("mc").getInteger("r"), jsonObject.getJSONObject("mc").getInteger("c"))); + if (StringUtils.isNotBlank(value) && !itemName.contains(value)) { + itemName += value; + } + } + } + } + // 鍒ゆ柇璇ヨ鍗曟槸鍚︽湁鏀规楠岄」, 娌℃湁鍓旈櫎 + if (isShow) { + if (!itemNameList.contains(itemName)) { + dataListJSONArray.remove(r); + r--; + } + } + } + } + + + /** + * 鍧愭爣鎷兼帴 + * @param r 妯潗鏍� + * @param c 绾靛潗鏍� + * @return + */ + private static String coordinatesJoint(int r, int c) { + String coordinates = ""; + coordinates = "r:" + r + ",c:" + c; + return coordinates; } @Override @@ -788,6 +887,21 @@ } } + // 娣诲姞宸ユ椂 + // 鍒犻櫎鍘熸湰璁㈠崟宸ユ椂 + 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) { @@ -865,59 +979,6 @@ } 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 "鏈煡"; - } } @@ -4226,56 +4287,6 @@ } } 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); - - } } } -- Gitblit v1.9.3