From d5165d2cdaeab2be112b805addf438466b59bedd Mon Sep 17 00:00:00 2001
From: zhuo <2089219845@qq.com>
Date: 星期二, 18 三月 2025 10:36:01 +0800
Subject: [PATCH] 单点登录完成
---
inspect-server/src/main/java/com/ruoyi/inspect/service/impl/InsOrderServiceImpl.java | 220 ++++++++++++++++++++++++++----------------------------
1 files changed, 106 insertions(+), 114 deletions(-)
diff --git a/inspect-server/src/main/java/com/ruoyi/inspect/service/impl/InsOrderServiceImpl.java b/inspect-server/src/main/java/com/ruoyi/inspect/service/impl/InsOrderServiceImpl.java
index 30bbed5..aed6e35 100644
--- a/inspect-server/src/main/java/com/ruoyi/inspect/service/impl/InsOrderServiceImpl.java
+++ b/inspect-server/src/main/java/com/ruoyi/inspect/service/impl/InsOrderServiceImpl.java
@@ -1,6 +1,8 @@
package com.ruoyi.inspect.service.impl;
import cn.hutool.core.collection.CollUtil;
+import cn.hutool.core.date.DateTime;
+import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONUtil;
@@ -8,14 +10,11 @@
import com.alibaba.excel.ExcelWriter;
import com.alibaba.excel.write.metadata.WriteSheet;
import com.alibaba.excel.write.style.column.LongestMatchColumnWidthStyleStrategy;
-import com.alibaba.excel.write.style.column.SimpleColumnWidthStyleStrategy;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
-import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
-import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.basic.mapper.IfsInventoryQuantityMapper;
import com.ruoyi.basic.mapper.StandardProductListMapper;
@@ -26,16 +25,18 @@
import com.ruoyi.common.core.domain.entity.User;
import com.ruoyi.common.numgen.NumberGenerator;
import com.ruoyi.common.utils.*;
+import com.ruoyi.common.utils.api.IfsApiUtils;
import com.ruoyi.framework.exception.ErrorException;
import com.ruoyi.inspect.dto.*;
import com.ruoyi.inspect.mapper.*;
import com.ruoyi.inspect.pojo.*;
import com.ruoyi.inspect.service.InsOrderService;
+import com.ruoyi.inspect.service.InsOrderStateService;
import com.ruoyi.inspect.service.InsProductService;
import com.ruoyi.inspect.service.InsSampleService;
import com.ruoyi.inspect.vo.InsOrderPrintingVo;
-import com.ruoyi.inspect.vo.SampleDefectsFatherVo;
-import com.ruoyi.system.mapper.CustomMapper;
+import com.ruoyi.performance.pojo.AuxiliaryOutputWorkingHoursTemporary;
+import com.ruoyi.performance.service.AuxiliaryOutputWorkingHoursTemporaryService;
import com.ruoyi.system.mapper.UserMapper;
import lombok.AllArgsConstructor;
import org.apache.commons.lang3.StringUtils;
@@ -47,6 +48,7 @@
import java.io.IOException;
import java.math.BigDecimal;
import java.net.URLEncoder;
+import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.Month;
@@ -70,18 +72,17 @@
private InsSampleMapper insSampleMapper;
private InsProductService insProductService;
private InsProductMapper insProductMapper;
- private InsProductUserMapper insProductUserMapper;
private InsSampleUserMapper insSampleUserMapper;
- private InsOrderStateMapper insOrderStateMapper;
+ private InsOrderStateService insOrderStateService;
private UserMapper userMapper;
private IfsInventoryQuantityMapper ifsInventoryQuantityMapper;
- private CustomMapper customMapper;
private final NumberGenerator<InsOrder> numberGenerator;
private InsReportMapper insReportMapper;
private InsUnqualifiedRetestProductMapper insUnqualifiedRetestProductMapper;
private IfsApiUtils ifsApiUtils;
private SpotCheckQuarterItemMapper spotCheckQuarterItemMapper;
private StandardProductListMapper standardProductListMapper;
+ private AuxiliaryOutputWorkingHoursTemporaryService auxiliaryOutputWorkingHoursTemporaryService;
@@ -100,6 +101,11 @@
}
+ /**
+ * 鍒嗛厤妫�楠屼汉
+ *
+ * @return
+ */
@Override
@Transactional(rollbackFor = Exception.class)
public int upInsOrder(Integer orderId, Integer sampleId, String appointed, Integer userId, String sonLaboratory) {
@@ -108,13 +114,15 @@
insOrder.setAppointed(StringUtils.isNotEmpty(appointed) ? LocalDate.parse(appointed) : null);
insOrder.setSendTime(LocalDateTime.now());
insOrderMapper.updateById(insOrder);
- List<InsSample> insSamples = insSampleMapper.selectList(Wrappers.<InsSample>lambdaQuery().eq(InsSample::getInsOrderId, orderId).select(InsSample::getId));
- List<Integer> ids = insSamples.stream().map(a -> a.getId()).collect(Collectors.toList());
+ List<InsSample> insSamples = insSampleMapper.selectList(Wrappers.<InsSample>lambdaQuery().eq(InsSample::getInsOrderId, orderId));
+ List<Integer> ids = insSamples.stream().map(InsSample::getId).collect(Collectors.toList());
List<InsProduct> insProducts = insProductMapper.selectList(Wrappers.<InsProduct>lambdaQuery()
.in(InsProduct::getInsSampleId, ids)
.eq(InsProduct::getState, 1)
.select(InsProduct::getSonLaboratory).groupBy(InsProduct::getSonLaboratory));
- for (InsProduct insProduct : insProducts) {
+
+ // 鎵归噺娣诲姞妫�楠屼换鍔$姸鎬佽〃
+ List<InsOrderState> insOrderStateList = insProducts.stream().map(insProduct -> {
InsOrderState insOrderState = new InsOrderState();
insOrderState.setInsOrderId(orderId);
try {
@@ -123,8 +131,10 @@
throw new ErrorException("璇ユ楠屽崟鏈夋湭缁存姢瀹為獙瀹ょ殑妫�楠岄」鐩�");
}
insOrderState.setInsState(0);
- insOrderStateMapper.insert(insOrderState);
- }
+ return insOrderState;
+ }).collect(Collectors.toList());
+ insOrderStateService.saveBatch(insOrderStateList);
+
if (userId != null) {
InsSampleUser insSampleUser = new InsSampleUser();
insSampleUser.setState(0);
@@ -144,7 +154,79 @@
spotCheckQuarterItem.setSamplingUser(user.getName());
spotCheckQuarterItemMapper.updateById(spotCheckQuarterItem);
}
+
+
+ // 鍒涘缓宸ユ椂鏆傚瓨
+ // 缂撳瓨鏍峰搧id, 缂栧彿map
+ Map<Integer, String> sampleMap = insSamples.stream().collect(Collectors.toMap(InsSample::getId, InsSample::getSampleCode));
+ List<InsProduct> insProductList = insProductMapper.selectList(Wrappers.<InsProduct>lambdaQuery()
+ .in(InsProduct::getInsSampleId, ids)
+ .eq(InsProduct::getState, 1));
+ List<AuxiliaryOutputWorkingHoursTemporary> outputWorkingHours = insProductList.stream().map(insProduct -> {
+ AuxiliaryOutputWorkingHoursTemporary auxiliaryOutputWorkingHours = new AuxiliaryOutputWorkingHoursTemporary();
+ auxiliaryOutputWorkingHours.setInspectionItemClass(insProduct.getInspectionItemClass());//妫�娴嬮」鍒嗙被
+ auxiliaryOutputWorkingHours.setInspectionItem(insProduct.getInspectionItem());//妫�娴嬬埗椤�
+ auxiliaryOutputWorkingHours.setInspectionItemSubclass(insProduct.getInspectionItemSubclass());//妫�娴嬪瓙椤�
+ auxiliaryOutputWorkingHours.setSample(sampleMap.get(insProduct.getInsSampleId()));//鏍峰搧缂栧彿
+ auxiliaryOutputWorkingHours.setOrderId(order.getId());//璁㈠崟id
+ auxiliaryOutputWorkingHours.setOrderNo(order.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
+
+ return auxiliaryOutputWorkingHours;
+ }).collect(Collectors.toList());
+ auxiliaryOutputWorkingHoursTemporaryService.saveBatch(outputWorkingHours);
+
return 1;
+ }
+
+ 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 "鏈煡";
+ }
}
@Override
@@ -284,9 +366,11 @@
.set(IfsInventoryQuantity::getInspectStatus, 0));
}
+ // 瀹℃牳妫�楠屽崟
upInsOrderOfState(insOrder);
- upInsOrder(insOrder.getId(), null, appointed != null ? appointed.toString() : null, SecurityUtils.getUserId().intValue(), "鍘熸潗鏂�");
+ // 鍒嗛厤妫�楠屼汉
+ upInsOrder(insOrder.getId(), null, appointed != null ? appointed.toString() : null, SecurityUtils.getUserId().intValue(), "鍘熸潗鏂�");
// 鏍规嵁闆朵欢鍙峰垽鏂槸鍚︽槸杈呮潗
boolean isRaw = false;
@@ -353,6 +437,9 @@
if (StringUtils.isBlank(product.getAsk()) || StringUtils.isBlank(product.getTell())) {
throw new ErrorException("鏈夋楠岄」鐨勮姹傚�兼垨瑕佹眰鎻忚堪涓虹┖, 璇峰厛鍘绘爣鍑嗗簱閰嶇疆瑕佹眰鍊兼垨瑕佹眰鎻忚堪");
}
+ if (StringUtils.isBlank(product.getSonLaboratory())) {
+ throw new ErrorException("鏈夋楠岄」鐨勭殑瀛愬疄楠屽涓虹粦瀹�, 璇峰厛缁戝畾瀛愬疄楠屽");
+ }
insProductMapper.insert(product);
}
}
@@ -377,6 +464,11 @@
return map;
}
+ /**
+ * 瀹℃牳妫�楠屽崟
+ * @param insOrder
+ * @return
+ */
@Override
public int upInsOrderOfState(InsOrder insOrder) {
insOrder.setExamineTime(LocalDateTime.now());
@@ -463,112 +555,12 @@
return productDto2IPage;
}
- @Override
- public IPage<CostStatisticsDto> costStatistics(IPage<CostStatisticsDto> page, CostStatisticsDto costStatisticsDto) {
- String dates = costStatisticsDto.getDates();
- String[] split = dates.replaceAll("\\[", "").replaceAll("]", "").replaceAll("\"", "").split(",");
- costStatisticsDto.setDates(null);
-
- //todo:浠呯湅鑷繁
-
- IPage<CostStatisticsDto> dtoIPage = insOrderMapper.selectCostStatistics(page, QueryWrappers.queryWrappers(costStatisticsDto).ge("create_time", split[0]).le("create_time", split[1] + " 23:59:59"));
- List<CostStatisticsDto> collect = dtoIPage.getRecords().stream().map(dto -> {
- Set<String> uniqueTags = new HashSet<>();
- if (dto.getInspectionItem().contains(",")) {
- for (String s : dto.getInspectionItem().split(",")) {
- uniqueTags.add(s.split("@")[0]);
- }
- } else {
- uniqueTags.add(dto.getInspectionItem().split("@")[0]);
- }
- dto.setInspectionItem(uniqueTags.toString());
- return dto;
- }).collect(Collectors.toList());
- dtoIPage.setRecords(collect);
- return dtoIPage;
- }
-
- @Override
- public Map<String, Object> costStatistics2(CostStatisticsDto costStatisticsDto) {
- Map<String, Object> map = new HashMap<>();
- String dates = costStatisticsDto.getDates();
- String[] split = dates.replaceAll("\\[", "").replaceAll("]", "").replaceAll("\"", "").split(",");
- costStatisticsDto.setDates(null);
- List<CostStatisticsDto> costStatisticsDtos = insOrderMapper.selectCostStatistics2(QueryWrappers.queryWrappers(costStatisticsDto).ge("create_time", split[0]).le("create_time", split[1] + " 23:59:59"));
- double totalPrice = costStatisticsDtos.stream()
- .filter(dto -> dto.getPrice() != null) // 杩囨护鎺変环鏍间负 null 鐨勫璞�
- .mapToDouble(value -> value.getPrice().doubleValue() * value.getNum())
- .sum();
- map.put("total", totalPrice);
- return map;
- }
-
- @Override
- public Map<String, Object> selectSampleDefects(Page page, String inspectionItems, String orderNumber) {
- List<SampleDefectsFatherVo> sampleDefectsFatherVos = insOrderMapper.selectSampleDefects(page, inspectionItems, orderNumber);
- Map<String, Object> map = new HashMap<>();
- map.put("records", sampleDefectsFatherVos);
- Long aLong = insOrderMapper.getCount(inspectionItems, orderNumber);
- map.put("total", aLong);
- return map;
- }
@Override
public int updateStatus(Integer id) {
return insOrderMapper.updateStatus(id);
}
-
- @Override
- public void export(CostStatisticsDto costStatisticsDto, HttpServletResponse response) throws IOException {
- //鏌ヨ瀵煎嚭鐨勮垂鐢ㄧ粺璁℃暟鎹�
- String dates = costStatisticsDto.getDates();
- String[] split = dates.replaceAll("\\[", "").replaceAll("]", "").replaceAll("\"", "").split(",");
- costStatisticsDto.setDates(null);
- List<CostStatisticsDto> costStatisticsDtos = insOrderMapper.selectCostStatistics2(QueryWrappers.queryWrappers(costStatisticsDto).ge("create_time", split[0]).le("create_time", split[1] + " 23:59:59"));
- costStatisticsDtos = costStatisticsDtos.stream().map(dto -> {
- Set<String> uniqueTags = new HashSet<>();
- if (dto.getInspectionItem().contains(",")) {
- for (String s : dto.getInspectionItem().split(",")) {
- uniqueTags.add(s.split("@")[0]);
- }
- } else {
- uniqueTags.add(dto.getInspectionItem().split("@")[0]);
- }
- dto.setInspectionItem(uniqueTags.toString());
- return dto;
- }).collect(Collectors.toList());
-
- response.setContentType("application/vnd.ms-excel");
- response.setCharacterEncoding("UTF-8");
- // 杩欓噷URLEncoder.encode鍙互闃叉涓枃涔辩爜 褰撶劧鍜宔asyexcel娌℃湁鍏崇郴
- String fileName = URLEncoder.encode("鏍峰搧璐圭敤缁熻瀵煎嚭", "UTF-8");
- response.setHeader("Content-disposition", "attachment;filename=" + fileName + ".xlsx");
- Map<String, List<CostStatisticsDto>> groupByCompany =
- costStatisticsDtos.stream().filter(e -> StrUtil.isNotEmpty(e.getCompany()))
- .collect(Collectors.groupingBy(CostStatisticsDto::getCompany));
- try {
- // 鏂板缓ExcelWriter
- // 鏂板缓ExcelWriter
- ExcelWriter excelWriter =
- EasyExcel.write(response.getOutputStream())
- .registerWriteHandler(new SimpleColumnWidthStyleStrategy(25))
- .build();
- for (Map.Entry<String, List<CostStatisticsDto>> companyDataEntry : groupByCompany.entrySet()) {
- String sheetName = companyDataEntry.getKey();
- List<CostStatisticsDto> dataList = companyDataEntry.getValue();
- WriteSheet mainSheet = EasyExcel.writerSheet(sheetName)
- .head(CostStatisticsDto.class)
- .registerWriteHandler(new SimpleColumnWidthStyleStrategy(25))
- .build();
- excelWriter.write(dataList, mainSheet);
- }
- // 鍏抽棴娴�
- excelWriter.finish();
- } catch (IOException e) {
- throw new RuntimeException("瀵煎嚭澶辫触");
- }
- }
/**
* 鑾峰彇ifs搴撳瓨淇℃伅
--
Gitblit v1.9.3