From 165050015b3bc1a8a41eed7851d29e2e8d3db187 Mon Sep 17 00:00:00 2001 From: chenrui <1187576398@qq.com> Date: 星期一, 07 四月 2025 17:33:48 +0800 Subject: [PATCH] 成品下单人员权限修改 --- inspect-server/src/main/java/com/ruoyi/inspect/service/impl/InsOrderServiceImpl.java | 149 +++++++++++++------------------------------------ 1 files changed, 39 insertions(+), 110 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 ae86eed..868ba44 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 @@ -10,14 +10,12 @@ 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.conditions.update.UpdateWrapper; 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; @@ -28,6 +26,7 @@ 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.*; @@ -37,17 +36,15 @@ 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.performance.pojo.AuxiliaryOutputWorkingHours; import com.ruoyi.performance.pojo.AuxiliaryOutputWorkingHoursTemporary; import com.ruoyi.performance.service.AuxiliaryOutputWorkingHoursTemporaryService; -import com.ruoyi.system.mapper.CustomMapper; import com.ruoyi.system.mapper.UserMapper; import lombok.AllArgsConstructor; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.BeanUtils; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import org.springframework.util.CollectionUtils; import javax.servlet.http.HttpServletResponse; import java.io.IOException; @@ -94,7 +91,8 @@ //鑾峰彇妫�楠屼笅鍗曟暟鎹� @Override public IPage<SampleOrderDto> selectInsOrderParameter(IPage<InsOrder> page, SampleOrderDto sampleOrderDto) { - //todo: 鍙湅鎴戝垽鏂叏閮�,涓汉,缁勭粐鐨勬潈闄� + // TODO 閽堝浜哄憳鍋氭潈闄愬鐞� 鐩墠鍏堝妫�楠屼汉鍛樺仛鏁版嵁澶勭悊 濡傛灉鏄楠屼汉鍛樺彧鑳芥煡璇㈠埌妫�楠岄」鐩槸鑷繁鎴栬�呰鍗曞垎娲句汉鏄嚜宸辩殑璁㈠崟锛屼笉鏄楠屼汉鍛樼殑鏆傛椂鍏ㄦ煡 + boolean checkUserFlag = isCheckUser(SecurityUtils.getUserId().intValue()); String laboratory = null; // 鍒ゆ柇鏄惁鏄叏閮� String isOrderAll = null; @@ -102,7 +100,12 @@ isOrderAll = "1"; sampleOrderDto.setState(null); } - return insOrderMapper.selectInsOrderPage(page, QueryWrappers.queryWrappers(sampleOrderDto), laboratory, isOrderAll); + SampleOrderDto otherParam = new SampleOrderDto(); + otherParam.setLaboratory(laboratory); + otherParam.setIsOrderAll(isOrderAll); + otherParam.setCheckUserFlag(checkUserFlag); + otherParam.setCheckUserId(SecurityUtils.getUserId()); + return insOrderMapper.selectInsOrderPage(page, QueryWrappers.queryWrappers(sampleOrderDto), otherParam); } @@ -125,7 +128,6 @@ .in(InsProduct::getInsSampleId, ids) .eq(InsProduct::getState, 1) .select(InsProduct::getSonLaboratory).groupBy(InsProduct::getSonLaboratory)); - // 鎵归噺娣诲姞妫�楠屼换鍔$姸鎬佽〃 List<InsOrderState> insOrderStateList = insProducts.stream().map(insProduct -> { InsOrderState insOrderState = new InsOrderState(); @@ -193,6 +195,14 @@ return auxiliaryOutputWorkingHours; }).collect(Collectors.toList()); + + // 鍒濇鍒嗛厤妫�楠屼汉锛屽悇涓楠岄」榛樿璁㈠崟鐨勬楠屼汉 + List<Integer> insProductIds = insProductList.stream().map(insproduct -> { + return insproduct.getId(); + }).collect(Collectors.toList()); + if(!CollectionUtils.isEmpty(insProductIds)){ + insProductMapper.batchUpdateInsProductCheckUserId(insProductIds, userId); + } auxiliaryOutputWorkingHoursTemporaryService.saveBatch(outputWorkingHours); return 1; @@ -442,6 +452,9 @@ if (StringUtils.isBlank(product.getAsk()) || StringUtils.isBlank(product.getTell())) { throw new ErrorException("鏈夋楠岄」鐨勮姹傚�兼垨瑕佹眰鎻忚堪涓虹┖, 璇峰厛鍘绘爣鍑嗗簱閰嶇疆瑕佹眰鍊兼垨瑕佹眰鎻忚堪"); } + if (StringUtils.isBlank(product.getSonLaboratory())) { + throw new ErrorException("鏈夋楠岄」鐨勭殑瀛愬疄楠屽涓虹粦瀹�, 璇峰厛缁戝畾瀛愬疄楠屽"); + } insProductMapper.insert(product); } } @@ -493,7 +506,7 @@ } // 鐢熸垚缂栧彿 String no = numberGenerator.generateNumberWithPrefix(3, - "JCZX/ZB-" + code + LimsDateUtil.resetDate(LocalDateTime.now()), + "JCZX/SP-" + code + LimsDateUtil.resetDate(LocalDateTime.now()), InsOrder::getEntrustCode); // 鍒ゆ柇鏄惁鏄搴︽楠�, 鏄搴︽楠屽彇娑堝師鏉愭枡瀛e害妫�楠屼笅鍗� if (InsOrderTypeConstants.QUARTERLY_TEST.equals(order.getOrderType())) { @@ -557,112 +570,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搴撳瓨淇℃伅 @@ -1125,6 +1038,22 @@ } } + + /** + * 鍒ゆ柇鏄惁涓烘楠屼汉鍛� + * @param userId + * @return + */ + public boolean isCheckUser(Integer userId) { + List<User> userList = userMapper.selectQualityUserList(); + for (User user : userList) { + if(userId.equals(user.getId())){ + return true; + } + } + return false; + } + } -- Gitblit v1.9.3