zss
2024-12-17 31f3dcc7c566174cbdec4f41a9a96e58a1be9a4e
统计2.0+首页2.0+检验下单型号过滤修改
已修改6个文件
185 ■■■■ 文件已修改
inspect-server/src/main/java/com/yuanchu/mom/controller/ReportController.java 8 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
inspect-server/src/main/java/com/yuanchu/mom/service/ReportService.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
inspect-server/src/main/java/com/yuanchu/mom/service/impl/InsOrderPlanServiceImpl.java 34 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
inspect-server/src/main/java/com/yuanchu/mom/service/impl/ReportServiceImpl.java 107 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
inspect-server/src/main/java/com/yuanchu/mom/service/impl/StandardProductListServiceImpl.java 31 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
inspect-server/src/main/resources/mapper/InsOrderMapper.xml 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
inspect-server/src/main/java/com/yuanchu/mom/controller/ReportController.java
@@ -56,14 +56,14 @@
    @ValueAuth
    @ApiOperation(value = "各站点工时")
    @PostMapping("/manHourByStation")
    public Result manHourByStation(String startTime,String endTime){
        return Result.success(reportService.manHourByStation(startTime,endTime));
    public Result manHourByStation(String startTime,String endTime,String sonLaboratory){
        return Result.success(reportService.manHourByStation(startTime,endTime,sonLaboratory));
    }
    @ValueAuth
    @ApiOperation(value = "各站点工时每个人所占百分比")
    @PostMapping("/manHourByPerson")
    public Result manHourByPerson(String startTime,String endTime){
        return Result.success(reportService.manHourByPerson(startTime,endTime));
    public Result manHourByPerson(String startTime,String endTime,String sonLaboratory){
        return Result.success(reportService.manHourByPerson(startTime,endTime,sonLaboratory));
    }
}
inspect-server/src/main/java/com/yuanchu/mom/service/ReportService.java
@@ -24,8 +24,8 @@
    List<Schedule> ScheduleByMe(String date);
    //首页-->各站点工时
    Map<String,Double> manHourByStation(String startTime,String endTime);
    String manHourByStation(String startTime,String endTime,String sonLaboratory);
    //首页-->各站点工时每个人所占百分比
    Map<String, Map<String, Double>> manHourByPerson(String startTime, String endTime);
    Map<Object, Double> manHourByPerson(String startTime, String endTime,String sonLaboratory);
}
inspect-server/src/main/java/com/yuanchu/mom/service/impl/InsOrderPlanServiceImpl.java
@@ -1179,22 +1179,6 @@
        info.setViewStatus(false);
        info.setJumpPath("b1-inspect-order-plan");
        informationNotificationService.addInformationNotification(info);
        //  todo 企业微信消息推送@zss
        HashMap<String, Object> map = new HashMap<>();
        String account = userMapper.selectById(submitPlanDto.getVerifyUser()).getAccount();
        map.put("touser", account);//接收消息成员的账号'ZT-031292'这种类型(如果有多个用'|'分隔)
        map.put("toparty", "");//接收部门id
        map.put("totag", "");//消息标签id
        map.put("msgtype", "text");//消息类型 text:文本
        map.put("agentid", 1000517);//应用id
        HashMap<String, Object> hashMap = new HashMap<>();
        hashMap.put("content", "您有一条检验任务待复核消息,订单号是:" + insOrder.getEntrustCode() + ",样品名称为:" + insSample.getSample() +
                ",请前往LIMS系统查看。请点击<a href=\"https://ztwxlims.ztt.cn:7443/enter\">中天通信LIMS系统 </a>");
        map.put("text", hashMap);//消息内容
        map.put("safe", 0);//是否保密消息.0否
        map.put("enable_id_trans", 0);//是否开启id转译.0否
        map.put("enable_duplicate_check", 0);//是否开启重复消息检查.0否
        qywxApi.send(map);
        //复核人--检验单相关负责人
        InsSampleUser insSampleUser = new InsSampleUser();
        insSampleUser.setUserId(submitPlanDto.getVerifyUser());
@@ -1212,7 +1196,6 @@
                throw new ErrorException("电路试验的站点报告生成有误,请联系开发人员调整!");
            }
        }
        /*生成产量工时*/
        //校验如果这个人这个检测项目已经添加过了则不需要再新增
        //首先判断当前人的当前时间是否是排班时间内,如果不是就是加班
@@ -1261,6 +1244,23 @@
                }
            }
        }
        //  todo 企业微信消息推送@zss
        HashMap<String, Object> map = new HashMap<>();
        String account = userMapper.selectById(submitPlanDto.getVerifyUser()).getAccount();
        map.put("touser", account);//接收消息成员的账号'ZT-031292'这种类型(如果有多个用'|'分隔)
        map.put("toparty", "");//接收部门id
        map.put("totag", "");//消息标签id
        map.put("msgtype", "text");//消息类型 text:文本
        map.put("agentid", 1000517);//应用id
        HashMap<String, Object> hashMap = new HashMap<>();
        hashMap.put("content", "您有一条检验任务待复核消息,订单号是:" + insOrder.getEntrustCode() + ",样品名称为:" + insSample.getSample() +
                ",请前往LIMS系统查看。请点击<a href=\"https://ztwxlims.ztt.cn:7443/enter\">中天通信LIMS系统 </a>");
        map.put("text", hashMap);//消息内容
        map.put("safe", 0);//是否保密消息.0否
        map.put("enable_id_trans", 0);//是否开启id转译.0否
        map.put("enable_duplicate_check", 0);//是否开启重复消息检查.0否
        qywxApi.send(map);
        return 1;
    }
inspect-server/src/main/java/com/yuanchu/mom/service/impl/ReportServiceImpl.java
@@ -39,13 +39,13 @@
    //每日业务统计
    @Override
    public Map<String, Object> businessStatisticsByDay(String startTime,String endTime,String type) {
    public Map<String, Object> businessStatisticsByDay(String startTime, String endTime, String type) {
        DateTimeFormatter format = DateTimeFormatter.ofPattern("yyyy-MM-dd");
        LocalDateTime start = LocalDate.parse(startTime, format).atStartOfDay();
        LocalDateTime end = LocalDate.parse(endTime, format).atTime(23, 59, 59);
        LocalDateTime oldStart=start  ;
        LocalDateTime oldEnd=end ;
        switch (type){
        LocalDateTime oldStart = start;
        LocalDateTime oldEnd = end;
        switch (type) {
            case "周":
                oldStart = start.minusDays(7);
                oldEnd = end.minusDays(7);
@@ -101,23 +101,23 @@
        /*检测费用*/
        //今日检测费用
        QueryWrapper<CostStatisticsDto> costStatisticsDtoQueryWrappers = new QueryWrapper<>();
        costStatisticsDtoQueryWrappers.between("create_time", start,end);
        costStatisticsDtoQueryWrappers.between("create_time", start, end);
        IPage<CostStatisticsDto> page = new Page<>();
        page.setSize(-1);
        page.setCurrent(-1);
        IPage<CostStatisticsDto> iPage = insOrderMapper.selectCostStatistics(page, costStatisticsDtoQueryWrappers);
        BigDecimal price = BigDecimal.ZERO;
        for (CostStatisticsDto record : iPage.getRecords()) {
            price.add(record.getPrice());
            price = price.add(ObjectUtils.isNotEmpty(record.getPrice()) ? record.getPrice() : BigDecimal.ZERO);
        }
        map.put("PRICE", price);
        //昨日检测费用
        QueryWrapper<CostStatisticsDto> costWrappers = new QueryWrapper<>();
        costWrappers.between("create_time", oldStart,oldEnd);
        costWrappers.between("create_time", oldStart, oldEnd);
        IPage<CostStatisticsDto> dtoIPage = insOrderMapper.selectCostStatistics(page, costWrappers);
        BigDecimal priced = BigDecimal.ZERO;
        for (CostStatisticsDto record : dtoIPage.getRecords()) {
            priced.add(record.getPrice());
            priced = priced.add(ObjectUtils.isNotEmpty(record.getPrice()) ? record.getPrice() : BigDecimal.ZERO);
        }
        //比例=(今日-昨日)/昨日
        BigDecimal priceRatio = (price.subtract(priced)).divide(priced.compareTo(BigDecimal.ZERO) == 0 ? BigDecimal.ONE : priced, 2, BigDecimal.ROUND_HALF_UP);
@@ -127,13 +127,13 @@
        //今日检测工时
        Double cost = 0.0;
        for (CostStatisticsDto record : iPage.getRecords()) {
            cost += record.getCost();
            cost += ObjectUtils.isNotEmpty(record.getCost()) ? record.getCost() : 0.0;
        }
        map.put("COST", cost);
        //昨日检测工时
        Double costed = 0.0;
        for (CostStatisticsDto record : dtoIPage.getRecords()) {
            costed += record.getCost();
            costed += ObjectUtils.isNotEmpty(record.getCost()) ? record.getCost() : 0.0;
        }
        //比例=(今日-昨日)/昨日
        BigDecimal costRatio = new BigDecimal(cost - costed).divide(new BigDecimal(costed == 0 ? 1 : costed), 2, BigDecimal.ROUND_HALF_UP);
@@ -158,18 +158,26 @@
        //获取近十日的横坐标
        LocalDate startDate = LocalDate.parse(startTime, format);
        LocalDate endDate = LocalDate.parse(endTime, format);
        List<LocalDate> lastTenDays = new ArrayList<>();
        List<String> lastTenDays = new ArrayList<>();
        List<Long> receTenDays = new ArrayList<>();
        List<Long> finTenDays = new ArrayList<>();
        while (!startDate.isAfter(endDate)) {
            lastTenDays.add(startDate);
            if (type.equals("年")){
                lastTenDays.add(startDate.format(format).substring(0,7));
            }else {
                lastTenDays.add(startDate.format(format));
            }
            receTenDays.add(insOrderMapper.selectCount(Wrappers.<InsOrder>lambdaQuery()
                    .eq(InsOrder::getState, 1)
                    .between(InsOrder::getCreateTime,startDate.atStartOfDay(),startDate.atTime(23,59,59))));
                    .between(InsOrder::getCreateTime, startDate.atStartOfDay(), startDate.atTime(23, 59, 59))));
            finTenDays.add(insOrderMapper.selectCount(Wrappers.<InsOrder>lambdaQuery()
                    .eq(InsOrder::getState, 4)
                    .between(InsOrder::getCreateTime,startDate.atStartOfDay(),startDate.atTime(23,59,59))));
            startDate = startDate.plusDays(1);
                    .between(InsOrder::getCreateTime, startDate.atStartOfDay(), startDate.atTime(23, 59, 59))));
            if (type.equals("年")) {
                startDate = startDate.plusMonths(1);
            }else {
                startDate=startDate.plusDays(1);
            }
        }
        map.put("DAYS", lastTenDays);
        map.put("RECETENDAYS", receTenDays);
@@ -179,12 +187,12 @@
    //检测项目统计
    @Override
    public Map<String, Object> testProductByDay(String startTime,String endTime,String type) {
    public Map<String, Object> testProductByDay(String startTime, String endTime, String type) {
        DateTimeFormatter format = DateTimeFormatter.ofPattern("yyyy-MM-dd");
        LocalDateTime start = LocalDate.parse(startTime, format).atStartOfDay();
        LocalDateTime end = LocalDate.parse(endTime, format).atTime(23, 59, 59);
        LocalDateTime oldStart=start  ;
        LocalDateTime oldEnd=end ;
        LocalDateTime oldStart = start;
        LocalDateTime oldEnd = end;
        Map<String, Object> map = new HashMap<>();
        /*项目接收*/
        //今日项目接收量
@@ -230,7 +238,8 @@
        //今日完成量中的合格量/今日完成量
        Long accept = insProductMapper.selectCount(Wrappers.<InsProduct>lambdaQuery()
                .eq(InsProduct::getState, 1)
                .eq(InsProduct::getInsResult, 1)
                .isNotNull(InsProduct::getInsResult)
                .ne(InsProduct::getInsResult, 0)
                .between(InsProduct::getCreateTime, start, end));
        map.put("ACCEPT", accept);
        BigDecimal acceptRate = new BigDecimal(accept).divide(new BigDecimal(finishe == 0 ? 1 : finishe), 2, BigDecimal.ROUND_HALF_UP);
@@ -250,19 +259,27 @@
        //获取近十日的横坐标
        LocalDate startDate = LocalDate.parse(startTime, format);
        LocalDate endDate = LocalDate.parse(endTime, format);
        List<LocalDate> lastTenDays = new ArrayList<>();
        List<String> lastTenDays = new ArrayList<>();
        List<Long> receTenDays = new ArrayList<>();
        List<Long> finTenDays = new ArrayList<>();
        while (!startDate.isAfter(endDate))  {
            lastTenDays.add(startDate);
        while (!startDate.isAfter(endDate)) {
            if (type.equals("年")){
                lastTenDays.add(startDate.format(format).substring(0,7));
            }else {
                lastTenDays.add(startDate.format(format));
            }
            receTenDays.add(insProductMapper.selectCount(Wrappers.<InsProduct>lambdaQuery()
                    .eq(InsProduct::getState, 1)
                    .between(InsProduct::getCreateTime,startDate.atStartOfDay(),startDate.atTime(23,59,59))));
                    .between(InsProduct::getCreateTime, startDate.atStartOfDay(), startDate.atTime(23, 59, 59))));
            finTenDays.add(insProductMapper.selectCount(Wrappers.<InsProduct>lambdaQuery()
                    .eq(InsProduct::getState, 1)
                    .isNotNull(InsProduct::getInsResult)
                    .between(InsProduct::getCreateTime,startDate.atStartOfDay(),startDate.atTime(23,59,59))));
            startDate = startDate.plusDays(1);
                    .between(InsProduct::getCreateTime, startDate.atStartOfDay(), startDate.atTime(23, 59, 59))));
            if (type.equals("年")) {
                startDate = startDate.plusMonths(1);
            }else {
                startDate=startDate.plusDays(1);
            }
        }
        map.put("DAYS", lastTenDays);
        map.put("RECETENDAYS", receTenDays);
@@ -350,31 +367,24 @@
    //首页-->各站点的工时
    @Override
    public Map<String, Double> manHourByStation(String startTime, String endTime) {
    public String manHourByStation(String startTime, String endTime, String sonLaboratory) {
        DateTimeFormatter format = DateTimeFormatter.ofPattern("yyyy-MM-dd");
        LocalDateTime start = LocalDate.parse(startTime, format).atStartOfDay();
        LocalDateTime end = LocalDate.parse(endTime, format).atTime(23, 59, 59);
        //查询这个时间内所有的工时
        List<AuxiliaryOutputWorkingHours> auxiliaryOutputWorkingHours = auxiliaryOutputWorkingHoursMapper.selectList(Wrappers.<AuxiliaryOutputWorkingHours>lambdaQuery()
                .between(AuxiliaryOutputWorkingHours::getCreateTime, start, end));
        //根据检验项查出来的站点进行分类
        List<AuxiliaryOutputWorkingHoursDto> outputWorkingHoursDtos = auxiliaryOutputWorkingHours.stream().map(auxiliaryOutputWorkingHours1 -> {
            AuxiliaryOutputWorkingHoursDto auxiliaryOutputWorkingHoursDto = new AuxiliaryOutputWorkingHoursDto();
            BeanUtils.copyProperties(auxiliaryOutputWorkingHours1, auxiliaryOutputWorkingHoursDto);
            InsProduct insProduct = insProductMapper.selectById(auxiliaryOutputWorkingHours1.getInsProductId());
            auxiliaryOutputWorkingHoursDto.setSonLaboratory(insProduct.getSonLaboratory());
            return auxiliaryOutputWorkingHoursDto;
        }).collect(Collectors.toList());
        Map<String, Double> map = outputWorkingHoursDtos.stream()
                .collect(Collectors.groupingBy(
                        AuxiliaryOutputWorkingHoursDto::getSonLaboratory,
                        Collectors.summingDouble(AuxiliaryOutputWorkingHours::getOutputWorkTime)));
        return map;
        double sum = auxiliaryOutputWorkingHours.stream()
                .filter(auxiliaryOutputWorkingHours1 ->
                        insProductMapper.selectById(auxiliaryOutputWorkingHours1.getInsProductId()).getSonLaboratory().equals(sonLaboratory)
                ).mapToDouble(AuxiliaryOutputWorkingHours::getOutputWorkTime).sum();
        String num = String.format("%.2f", sum);
        return num;
    }
    //首页-->各站点工时每个人所占百分比
    @Override
    public Map<String, Map<String, Double>> manHourByPerson(String startTime, String endTime) {
    public Map<Object, Double> manHourByPerson(String startTime, String endTime, String sonLaboratory) {
        DateTimeFormatter format = DateTimeFormatter.ofPattern("yyyy-MM-dd");
        LocalDateTime start = LocalDate.parse(startTime, format).atStartOfDay();
        LocalDateTime end = LocalDate.parse(endTime, format).atTime(23, 59, 59);
@@ -382,19 +392,14 @@
        List<AuxiliaryOutputWorkingHours> auxiliaryOutputWorkingHours = auxiliaryOutputWorkingHoursMapper.selectList(Wrappers.<AuxiliaryOutputWorkingHours>lambdaQuery()
                .between(AuxiliaryOutputWorkingHours::getCreateTime, start, end));
        //根据检验项查出来的站点进行分类
        List<AuxiliaryOutputWorkingHoursDto> outputWorkingHoursDtos = auxiliaryOutputWorkingHours.stream().map(auxiliaryOutputWorkingHours1 -> {
            AuxiliaryOutputWorkingHoursDto auxiliaryOutputWorkingHoursDto = new AuxiliaryOutputWorkingHoursDto();
            BeanUtils.copyProperties(auxiliaryOutputWorkingHours1, auxiliaryOutputWorkingHoursDto);
            InsProduct insProduct = insProductMapper.selectById(auxiliaryOutputWorkingHours1.getInsProductId());
            auxiliaryOutputWorkingHoursDto.setSonLaboratory(insProduct.getSonLaboratory());
            return auxiliaryOutputWorkingHoursDto;
        }).collect(Collectors.toList());
        Map<String, Map<String, Double>> mapMap = outputWorkingHoursDtos.stream()
        List<AuxiliaryOutputWorkingHours> outputWorkingHours = auxiliaryOutputWorkingHours.stream()
                .filter(auxiliaryOutputWorkingHours1 ->
                        insProductMapper.selectById(auxiliaryOutputWorkingHours1.getInsProductId()).getSonLaboratory().equals(sonLaboratory)
                ).collect(Collectors.toList());
        Map<Object, Double> mapMap = outputWorkingHours.stream()
                .collect(Collectors.groupingBy(
                        AuxiliaryOutputWorkingHoursDto::getSonLaboratory,
                        Collectors.groupingBy(
                                t -> userMapper.selectById(t.getCheck()).getName(),
                                Collectors.summingDouble(AuxiliaryOutputWorkingHours::getOutputWorkTime))));
                                Collectors.summingDouble(AuxiliaryOutputWorkingHours::getOutputWorkTime)));
        return mapMap;
    }
inspect-server/src/main/java/com/yuanchu/mom/service/impl/StandardProductListServiceImpl.java
@@ -83,9 +83,9 @@
        //判断长度
        if (split1.length > 4) {
            if (ObjectUtils.isNotEmpty(split1[3])) {
                list = list.stream().filter(list1 -> Objects.nonNull(list1.getSample())&&Objects.equals(list1.getSample(),split1[3])).collect(Collectors.toList());
            }else if (split1[3].equals("")) {
                list = list.stream().filter(list1 ->  Objects.nonNull(list1.getSampleType())&&Objects.equals(list1.getSampleType(),split1[2])).collect(Collectors.toList());
                list = list.stream().filter(list1 -> Objects.nonNull(list1.getSample()) && Objects.equals(list1.getSample(), split1[3])).collect(Collectors.toList());
            } else if (split1[3].equals("")) {
                list = list.stream().filter(list1 -> Objects.nonNull(list1.getSampleType()) && Objects.equals(list1.getSampleType(), split1[2])).collect(Collectors.toList());
            }
        }
        list = list.stream().filter(a -> {
@@ -103,16 +103,9 @@
                        } else {
                            if (sections.get(i).contains("&")) {
                                String[] split = sections.get(i).split("&");
                                isIf = getIsIf(split[0], models1[1]) && getIsIf(split[1], models[1].split(";")[0]);
                                isIf = getIsIf(split[0], models1[1]);
                            } else {
                                if (ObjectUtils.isNotEmpty(models[1].split(";")[0])){
                                    isIf = getIsIf(sections.get(i), models[1].split(";")[0]);
                                    if (!isIf) {
                                        isIf = getIsIf(sections.get(i), models1[1]);
                                    }
                                }else {
                                    isIf = getIsIf(sections.get(i), models1[1]);
                                }
                                isIf = getIsIf(sections.get(i), models1[1]);
                            }
                            if (isIf) {
                                a.setSection(sections.get(i));
@@ -138,7 +131,7 @@
        //按照电路试验--辐射试验--温湿度试验--环境试验进行排序
        // 定义自定义排序器
        Comparator<StandardProductList> testTypeComparator = (o1, o2) -> {
            String[] order = {"电路试验", "辐射试验", "温湿度试验", "环境试验","功率试验"};
            String[] order = {"电路试验", "辐射试验", "温湿度试验", "环境试验", "功率试验"};
            int index1 = -1;
            int index2 = -1;
            // 找出两个对象 在自定义顺序数组中的位置
@@ -186,8 +179,8 @@
        String model2 = "";
        if (matcher.find()) {
            model2 += matcher.group();
        }else {
            model2=model;
        } else {
            model2 = model;
        }
        if (str.contains("≥") || str.contains(">=")) {
            String param = str.replace("≥", "").replace(">=", "");
@@ -205,7 +198,7 @@
            String param = str.replace("=", "");
            if (matcher.find()) {
                return new BigDecimal(model2).compareTo(new BigDecimal(param)) == 0;
            }else {
            } else {
                return model2.equals(param);
            }
        }
@@ -252,8 +245,7 @@
                list.addAll(standardTreeMapper.selectStandardProductListByTree("\"" + trees[2] + "\"", standardTree2.getSample(), standardTree2.getModel(), tree2, trees[1]));
                list.addAll(standardTreeMapper.selectStandardProductListByTree2("\"" + trees[2] + "\",\"" + standardTree2.getSample() + "\"", standardTree2.getSample(), standardTree2.getModel(), tree2, trees[1]));
            }
        }
        else if (trees.length == 4) {
        } else if (trees.length == 4) {
            List<StandardTree> treeList = standardTreeMapper.selectList(Wrappers.<StandardTree>lambdaQuery().eq(StandardTree::getLaboratory, trees[1]).eq(StandardTree::getSampleType, trees[2]).eq(StandardTree::getSample, trees[3]));
            if (treeList.size() == 0) {
                StandardTree standardTree = new StandardTree();
@@ -268,8 +260,7 @@
                list.addAll(standardTreeMapper.selectStandardProductListByTree("\"" + trees[2] + "\"", standardTree.getSample(), standardTree.getModel(), str, trees[1]));
                list.addAll(standardTreeMapper.selectStandardProductListByTree2("\"" + trees[2] + "\",\"" + trees[3] + "\"", standardTree.getSample(), standardTree.getModel(), str, trees[1]));
            }
        }
        else {
        } else {
            list.addAll(standardTreeMapper.selectStandardProductListByTree("\"" + trees[2] + "\"", trees[3].equals("null") ? null : trees[3], trees[4], tree, trees[1]));
            list.addAll(standardTreeMapper.selectStandardProductListByTree2("\"" + trees[2] + "\",\"" + trees[3] + "\"", trees[3].equals("null") ? null : trees[3], trees[4], tree, trees[1]));
        }
inspect-server/src/main/resources/mapper/InsOrderMapper.xml
@@ -201,6 +201,7 @@
        isa.sample,
        isa.model,
        ins_sample_id,
        times cost,
        sum(c.price * times)                                   price,
        GROUP_CONCAT(distinct c.inspection_item SEPARATOR ',') inspection_item,
        i.company,