| | |
| | | import com.ruoyi.common.utils.QueryWrappers; |
| | | import com.ruoyi.common.utils.SecurityUtils; |
| | | import com.ruoyi.framework.exception.ErrorException; |
| | | import com.ruoyi.inspect.comparater.CustomComparator; |
| | | import com.ruoyi.inspect.dto.*; |
| | | import com.ruoyi.inspect.excel.FiberRibboGeometricalParameterExcelData; |
| | | import com.ruoyi.inspect.mapper.*; |
| | |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.security.core.Authentication; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Isolation; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | |
| | | |
| | | private NumberGenerator<InsOrder> numberGenerator; |
| | | |
| | | private NumberGenerator<InsSample> sampleCodeGenerator; |
| | | |
| | | private NumberGenerator<InsFibers> fibersCodeGenerator; |
| | | |
| | | private InsSampleUserMapper insSampleUserMapper; |
| | | |
| | | private InsOrderStateMapper insOrderStateMapper; |
| | |
| | | |
| | | //获取检验下单数据 |
| | | @Override |
| | | public Map<String, Object> selectInsOrderParameter(Page<InsOrder> page, SampleOrderDto sampleOrderDto) { |
| | | public IPage<SampleOrderDto> selectInsOrderParameter(Page<InsOrder> page, SampleOrderDto sampleOrderDto) { |
| | | page.setOptimizeCountSql(false); |
| | | List<String> startAndEndTime = sampleOrderDto.getStartAndEndTime(); |
| | | String startTime = ""; |
| | |
| | | startTime = startAndEndTime.get(0) + " 00:00:00"; |
| | | endTime = startAndEndTime.get(1) + " 23:59:59"; |
| | | } |
| | | |
| | | Map<String, Object> map = new HashMap<>(); |
| | | //// map.put("head", PrintChina.printChina(SampleOrderDto.class)); |
| | | // //判断全部,个人,组织的权限 |
| | | // Map<String, Integer> map1 = getLook.selectPowerByMethodAndUserId("selectInsOrderParameter"); |
| | | // User user = userMapper.selectById(map1.get("userId"));//当前登录的人 |
| | | // Integer roleId = user.getRoleId(); |
| | | User user = userMapper.selectById(SecurityUtils.getUserId());;//当前登录的人 |
| | | // //获取当前人所属实验室id |
| | | // String departLimsId = user.getDepartLimsId(); |
| | | String laboratory = null; |
| | | // if (ObjectUtils.isNotEmpty(departLimsId) && !departLimsId.isEmpty()) { |
| | | // String[] split = departLimsId.split(","); |
| | | // //查询对应架构名称(通信实验室,电力实验室,检测办) |
| | | // String departLims = baseMapper.seldepLimsId(Integer.parseInt(split[split.length - 1])); |
| | | // if (departLims.contains("实验室")) { |
| | | // laboratory = departLims; |
| | | // } |
| | | // } |
| | | String departLimsId = user.getDepartLimsId(); |
| | | String laboratory = ""; |
| | | if (ObjectUtils.isNotEmpty(departLimsId) && !departLimsId.isEmpty()) { |
| | | String[] split = departLimsId.split(","); |
| | | //查询对应架构名称(通信实验室,电力实验室,检测办) |
| | | String departLims = baseMapper.seldepLimsId(Integer.parseInt(split[split.length - 1])); |
| | | if (departLims.contains("实验室")) { |
| | | laboratory = departLims; |
| | | } |
| | | } |
| | | // //判断是否是全部权限 |
| | | // SecurityUtils.hasPermi(""); |
| | | // Power power = powerMapper.selectOne(Wrappers.<Power>lambdaQuery().eq(Power::getRoleId, roleId).eq(Power::getMenuMethod, "selectAllInsOrderParameter")); |
| | | // if (ObjectUtils.isEmpty(power)) { |
| | | // if (map1.get("look") == 1) { |
| | |
| | | i.setSampleCode(split[0]); |
| | | } |
| | | }); |
| | | map.put("body", sampleOrderDtoIPage); |
| | | return map; |
| | | return sampleOrderDtoIPage; |
| | | } |
| | | |
| | | @Override |
| | |
| | | String outEntrustCodePrefix = getOutEntrustCodePrefix(customCode, laboratoryCode); |
| | | String outEntrustCode = numberGenerator.generateNumberWithPrefix(5, outEntrustCodePrefix, InsOrder::getOutEntrustCode); |
| | | insOrder.setOutEntrustCode(outEntrustCode); |
| | | // String giveCode = this.giveCode.giveCode("JCZX-" + customCode + "-", "ins_sample", "", "yyMMdd"); |
| | | String giveCode = ""; |
| | | // insOrder.setOutEntrustCode(giveCode.giveCode3("ZT/" + code2 + "-" + code + "-", insOrder.getCompanyId(), insOrder.getLaboratory(), "ins_order", "", "yyMM")); |
| | | // String giveCode = this.giveCode.giveCode("JCZX-" + code + "-", "ins_sample", "", "yyMMdd"); |
| | | insOrderMapper.insert(insOrder); |
| | | //生成样品编号 |
| | | String currentDay = LocalDate.now().format(DateTimeFormatter.ofPattern("yyMMdd")); |
| | | String generatedSampleCode = sampleCodeGenerator.generateNumberWithPrefix(3, currentDay, InsSample::getSampleCode); |
| | | AtomicInteger count = new AtomicInteger(); |
| | | List<FiberDto> fiberList = new ArrayList<>(); |
| | | list.forEach(a -> { |
| | |
| | | a.setId(null); |
| | | a.setInsOrderId(insOrder.getId()); |
| | | if (StrUtil.isEmpty(a.getSampleCode())) { |
| | | a.setSampleCode(giveCode.split("-")[2] + "-" + count.get()); |
| | | a.setSampleCode(generatedSampleCode + "-" + count.get()); |
| | | } else { |
| | | //去除手输的样品编号中首尾可能包含的空格 |
| | | a.setSampleCode(a.getSampleCode().trim()); |
| | |
| | | for (FibersDto fibersDto : bushingDto.getFibers()) { |
| | | fibersDto.setInsBushingId(bushingDto.getId()); |
| | | if (StringUtils.isBlank(fibersDto.getCode())) { |
| | | // fibersDto.setCode(this.giveCode.giveCode("", "ins_fibers", "", "yyMMdd")); |
| | | fibersDto.setCode(""); |
| | | fibersDto.setCode(fibersCodeGenerator.generateNumberWithPrefix(3, currentDay, InsFibers::getCode)); |
| | | } |
| | | insFibersMapper.insert(fibersDto); |
| | | for (FiberDto fiberDto : fibersDto.getFiber()) { |
| | |
| | | insProductMapper.insert(product); |
| | | } |
| | | } |
| | | // else { |
| | | // throw new ErrorException("样品的光纤配置信息里面没有配置光纤带信息也没有光纤信息,请重新配置保存再提交下单!!!"); |
| | | // } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | if (ObjectUtil.isNotEmpty(a.getInsulating())) { |
| | | List<InsProduct> ip2 = new ArrayList<>(); |
| | | for (Integer i = 0; i < a.getInsulating().getNum(); i++) { |
| | | for (int i = 0; i < a.getInsulating().getNum(); i++) { |
| | | ip2.addAll(a.getInsulating().getInsProduct()); |
| | | } |
| | | for (InsProduct product : ip2) { |
| | |
| | | b.setInsOrderId(insOrder.getId()); |
| | | b.setParentId(a.getId()); |
| | | if (StrUtil.isEmpty(b.getSampleCode())) { |
| | | // b.setSampleCode(this.giveCode.giveCode("", "ins_sample", "", "yyMMdd")); |
| | | b.setSampleCode(""); |
| | | b.setSampleCode(sampleCodeGenerator.generateNumberWithPrefix(3, currentDay, InsSample::getSampleCode)); |
| | | } |
| | | insSampleMapper.insert(b); |
| | | if (ObjectUtil.isNotEmpty(b.getInsProduct())) { |
| | |
| | | } else { |
| | | for (FibersDto fibersDto : bushingDto.getFibers()) { |
| | | fibersDto.setInsBushingId(bushingDto.getId()); |
| | | fibersDto.setCode(""); |
| | | fibersDto.setCode(fibersCodeGenerator.generateNumberWithPrefix(3, currentDay, InsFibers::getCode)); |
| | | insFibersMapper.insert(fibersDto); |
| | | for (FiberDto fiberDto : fibersDto.getFiber()) { |
| | | fiberDto.setInsFibersId(fibersDto.getId()); |
| | |
| | | } |
| | | } |
| | | } |
| | | |
| | | // 没有进行光纤配置的熔接配对,直接添加样品 |
| | | // try { |
| | | // for (InsProduct insProduct : insProducts) { |
| | | // insProduct.setId(null); |
| | | // insProduct.setInsSampleId(insSample.getId()); |
| | | // insProductMapper.insert(insProduct); |
| | | // } |
| | | // } catch (Exception e) { |
| | | // } |
| | | } |
| | | } |
| | | return insOrder.getId(); |
| | |
| | | } |
| | | |
| | | @Override |
| | | public Map<String, Object> selectSampleAndProductByOrderId(SampleProductDto2 sampleProductDto) { |
| | | Map<String, Object> map = new HashMap<>(); |
| | | List<Map<String, Object>> headList = new ArrayList<>(); |
| | | public List<SampleProductDto2> selectSampleAndProductByOrderId(SampleProductDto2 sampleProductDto) { |
| | | List<SampleProductDto2> SampleProductDto2S = null; |
| | | if (!Objects.isNull(sampleProductDto.getId())) { |
| | | String laboratory = insOrderMapper.selectById(sampleProductDto.getId()).getLaboratory(); |
| | | if (laboratory.equals("电力产品实验室")) { |
| | | //电力试验室的数据查看,删除光纤配置相关字段 |
| | | // headList = PrintChina.printChina(SampleProductDTODL.class); |
| | | SampleProductDto2S = insOrderMapper.selectSampleAndProductByOrderId( |
| | | QueryWrappers.queryWrappers(sampleProductDto).orderByAsc("ins_product_id"), |
| | | sampleProductDto.getId()); |
| | | } else { |
| | | // headList = PrintChina.printChina(SampleProductDto2.class); |
| | | SampleProductDto2S = insOrderMapper.selectSampleAndProductByOrderId( |
| | | QueryWrappers.queryWrappers(sampleProductDto) |
| | | .orderByAsc("son_laboratory"), |
| | |
| | | } |
| | | collect2.addAll(list); |
| | | SampleProductDto2S = collect2; |
| | | // SampleProductDto2S.sort(new CustomComparator(enumService)); |
| | | SampleProductDto2S.sort(new CustomComparator(dictTypeService)); |
| | | } |
| | | } |
| | | for (SampleProductDto2 record : SampleProductDto2S) { |
| | |
| | | record.setLastValue(String.join(",", values)); |
| | | } |
| | | } |
| | | map.put("head", headList); |
| | | map.put("body", SampleProductDto2S); |
| | | return map; |
| | | return SampleProductDto2S; |
| | | } |
| | | |
| | | @Override |
| | |
| | | @Override |
| | | public void exportChecked(Map<String, Object> data, HttpServletResponse response) { |
| | | // Integer userId = getLook.selectPowerByMethodAndUserId(null).get("userId"); |
| | | Integer userId = Integer.valueOf(String.valueOf(SecurityUtils.getLoginUser().getUserId())); |
| | | User user = userMapper.selectById(userId); |
| | | User user = userMapper.selectById(SecurityUtils.getLoginUser().getUserId()); |
| | | List<String> names = null; |
| | | String startTime = ""; |
| | | String endTime = ""; |
| | |
| | | } |
| | | temperatureCyclingList = temperatureCyclingList.stream().distinct().collect(Collectors.toList()); |
| | | //查询全色谱,过滤色标并排序 |
| | | List<String> colorList = dictTypeService.selectDictDataByType("color_type").stream() |
| | | List<String> colorList = dictTypeService.selectDictDataByType("fiber_color_type").stream() |
| | | .sorted(Comparator.comparing(SysDictData::getDictSort)) |
| | | .map(SysDictData::getDictLabel) |
| | | .collect(Collectors.toList()); |
| | |
| | | LocalDate today = LocalDate.parse(split[1]); |
| | | LocalTime end = LocalTime.of(23, 59, 59); |
| | | List<CostStatisticsDto> costStatisticsDtos = insOrderMapper.selectCostStatistics2(QueryWrappers.queryWrappers(costStatisticsDto), split[0], today.atTime(end).toString(), laboratory); |
| | | // double totalPrice = costStatisticsDtos.stream() |
| | | // .filter(dto -> dto.getPrice() != null) // 过滤掉价格为 null 的对象 |
| | | // .mapToDouble(value -> value.getPrice().doubleValue() * value.getNum()) |
| | | // .sum(); |
| | | BigDecimal total = BigDecimal.ZERO; |
| | | for (CostStatisticsDto dto : costStatisticsDtos) { |
| | | if (Objects.isNull(dto.getPrice()) || dto.getPrice().compareTo(BigDecimal.ZERO) == 0) { |