| | |
| | | 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; |
| | |
| | | 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.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; |
| | |
| | | spotCheckQuarterItemMapper.updateById(spotCheckQuarterItem); |
| | | } |
| | | |
| | | |
| | | // 创建工时暂存 |
| | | // 缓存样品id, 编号map |
| | | // addWorkingHoursTemporary(userId, insSamples, ids, order); |
| | | |
| | | return 1; |
| | | } |
| | | |
| | | /** |
| | | * 创建工时暂存 |
| | | * @param userId |
| | | * @param insSamples |
| | | * @param ids |
| | | * @param order |
| | | */ |
| | | private void addWorkingHoursTemporary(Integer userId, List<InsSample> insSamples, List<Integer> ids, InsOrder order) { |
| | | 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) |
| | |
| | | return auxiliaryOutputWorkingHours; |
| | | }).collect(Collectors.toList()); |
| | | auxiliaryOutputWorkingHoursTemporaryService.saveBatch(outputWorkingHours); |
| | | |
| | | return 1; |
| | | } |
| | | |
| | | public static String getWeek(String dayStr) { |
| | |
| | | if (StringUtils.isBlank(product.getAsk()) || StringUtils.isBlank(product.getTell())) { |
| | | throw new ErrorException("有检验项的要求值或要求描述为空, 请先去标准库配置要求值或要求描述"); |
| | | } |
| | | if (StringUtils.isBlank(product.getSonLaboratory())) { |
| | | throw new ErrorException("有检验项的的子实验室为绑定, 请先绑定子实验室"); |
| | | } |
| | | insProductMapper.insert(product); |
| | | } |
| | | } |
| | |
| | | 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可以防止中文乱码 当然和easyexcel没有关系 |
| | | 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库存信息 |
| | |
| | | ifsInventoryQuantity.setIsSource(1); |
| | | ifsInventoryQuantity.setState(0); |
| | | |
| | | IfsInventoryQuantity one = ifsInventoryQuantityMapper.selectOne(new LambdaQueryWrapper<IfsInventoryQuantity>() |
| | | Long count = ifsInventoryQuantityMapper.selectCount(new LambdaQueryWrapper<IfsInventoryQuantity>() |
| | | .eq(IfsInventoryQuantity::getOrderNo, ifsInventoryQuantity.getOrderNo()) |
| | | .eq(IfsInventoryQuantity::getLineNo, ifsInventoryQuantity.getLineNo()) |
| | | .eq(IfsInventoryQuantity::getReleaseNo, ifsInventoryQuantity.getReleaseNo()) |
| | |
| | | .eq(IfsInventoryQuantity::getWaivDevRejNo, ifsInventoryQuantity.getWaivDevRejNo()) |
| | | .eq(IfsInventoryQuantity::getActivitySeq, ifsInventoryQuantity.getActivitySeq()) |
| | | ); |
| | | if(Objects.isNull(one)) { |
| | | |
| | | if(count == 0) { |
| | | ifsInventoryQuantity.setIsFirst(0); |
| | | // 查询产业链检测数据 |
| | | String industryChainAttrFields = IndustryChainUtils.getIndustryChainAttrFields(ifsInventoryQuantity.getOrderNo(), |
| | |
| | | |
| | | // 修改检验项 |
| | | for (SampleProductDto sampleProductDto : insOrderUpdateDto.getSampleProduct()) { |
| | | insSampleService.update(Wrappers.<InsSample>lambdaUpdate() |
| | | .eq(InsSample::getId, sampleProductDto.getId()) |
| | | .set(InsSample::getSpecialStandardMethod, sampleProductDto.getSpecialStandardMethod())); |
| | | |
| | | insProductService.updateBatchById(sampleProductDto.getInsProduct()); |
| | | } |
| | | |
| | |
| | | // 查询标准树 |
| | | List<StandardProductList> standardProductLists = standardProductListMapper.selectList(Wrappers.<StandardProductList>lambdaQuery() |
| | | .eq(StandardProductList::getStandardMethodListId, insProduct.getStandardMethodListId()) |
| | | .eq(StandardProductList::getTree, tree)); |
| | | .eq(StandardProductList::getTree, tree) |
| | | .orderByAsc(StandardProductList::getSort)); |
| | | for (StandardProductList standardProductList : standardProductLists) { |
| | | standardProductList.setId(null); |
| | | } |
| | |
| | | product.setCreateUser(null); |
| | | product.setUpdateTime(null); |
| | | product.setUpdateUser(null); |
| | | product.setSection(null); |
| | | product.setInsSampleId(omitOrderProductDto.getInsSampleId()); |
| | | if (StringUtils.isBlank(product.getCableTag())) { |
| | | product.setCableTag(null); |
| | |
| | | */ |
| | | @Override |
| | | public void rawAllInsOrderExport(SampleOrderDto sampleOrderDto, HttpServletResponse response) { |
| | | //判断全部,个人,组织的权限 |
| | | //todo:仅看我获取当前人所属实验室id |
| | | String laboratory = null; |
| | | // 判断是否是全部 |
| | | String isOrderAll = null; |
| | | if (sampleOrderDto.getState() != null && sampleOrderDto.getState() == -2) { |
| | | isOrderAll = "1"; |
| | | sampleOrderDto.setState(null); |
| | | List<SampleOrderDto> sampleOrderDtoList = new ArrayList<>(); |
| | | if (StringUtils.isNotBlank(sampleOrderDto.getIds())) { |
| | | List<String> orderIds = StrUtil.split(sampleOrderDto.getIds(), ","); |
| | | sampleOrderDtoList = insOrderMapper.getInsOrderExportByIds(orderIds); |
| | | } else { |
| | | String laboratory = null; |
| | | // 判断是否是全部 |
| | | String isOrderAll = null; |
| | | if (sampleOrderDto.getState() != null && sampleOrderDto.getState() == -2) { |
| | | isOrderAll = "1"; |
| | | sampleOrderDto.setState(null); |
| | | } |
| | | sampleOrderDto.setIds(null); |
| | | sampleOrderDtoList = insOrderMapper.rawAllInsOrderExport(QueryWrappers.queryWrappers(sampleOrderDto), laboratory, isOrderAll); |
| | | } |
| | | List<SampleOrderDto> sampleOrderDtoList = insOrderMapper.rawAllInsOrderExport(QueryWrappers.queryWrappers(sampleOrderDto), laboratory, isOrderAll); |
| | | |
| | | // 判断是否是不合格, 不合格查询不合格项 |
| | | for (SampleOrderDto orderDto : sampleOrderDtoList) { |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 修改样品型号 |
| | | * @param insSample |
| | | */ |
| | | @Override |
| | | public void updateSampleModel(InsSample insSample) { |
| | | // 判断当前订单是否生成了报告, 生成了报告不能修改单号 |
| | | Long count = insReportMapper.selectCount(Wrappers.<InsReport>lambdaQuery() |
| | | .eq(InsReport::getInsOrderId, insSample.getInsOrderId())); |
| | | if (count > 0 ) { |
| | | throw new ErrorException("当前订单已经生成了报告不能修改编号"); |
| | | } |
| | | |
| | | insSampleService.update(Wrappers.<InsSample>lambdaUpdate() |
| | | .eq(InsSample::getId, insSample.getId()) |
| | | .set(InsSample::getModel, insSample.getModel())); |
| | | } |
| | | |
| | | } |
| | | |
| | | |