zss
2024-04-18 00952e11d9c2f7be5277a4d752cd5dd0796301cd
资质明细修改+检测项目统计
已修改6个文件
125 ■■■■■ 文件已修改
cnas-server/src/main/java/com/yuanchu/mom/controller/CertificationController.java 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
cnas-server/src/main/java/com/yuanchu/mom/pojo/Certification.java 5 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
cnas-server/src/main/java/com/yuanchu/mom/service/CertificationService.java 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
cnas-server/src/main/java/com/yuanchu/mom/service/impl/CertificationServiceImpl.java 8 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
cnas-server/src/main/resources/mapper/CertificationMapper.xml 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
inspect-server/src/main/java/com/yuanchu/mom/service/impl/ReportServiceImpl.java 94 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
cnas-server/src/main/java/com/yuanchu/mom/controller/CertificationController.java
@@ -1,6 +1,7 @@
package com.yuanchu.mom.controller;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yuanchu.mom.annotation.ValueAuth;
import com.yuanchu.mom.pojo.Certification;
import com.yuanchu.mom.pojo.Device;
import com.yuanchu.mom.service.CertificationService;
@@ -27,6 +28,7 @@
    @ApiOperation(value = "查询资质明细列表")
    @PostMapping("/getCertificationDetail")
    @ValueAuth
    public Result getCertificationDetail(@RequestBody Map<String, Object> data) throws Exception {
        Page page = JackSonUtil.unmarshal(JackSonUtil.marshal(data.get("page")), Page.class);
        Certification certification = JackSonUtil.unmarshal(JackSonUtil.marshal(data.get("entity")), Certification.class);
@@ -41,13 +43,7 @@
    @ApiOperation(value = "删除资质明细列表")
    @PostMapping("/delCertificationDetail")
    public Result<?> delCertificationDetail(List<Integer> ids) {
    public Result<?> delCertificationDetail(@RequestBody List<Integer> ids) {
        return Result.success(certificationService.delCertificationDetail(ids));
    }
    @ApiOperation(value = "附件下载")
    @PostMapping("/downFile")
    public Result<?> downFile(Integer id) {
        return Result.success(certificationService.downFile(id));
    }
}
cnas-server/src/main/java/com/yuanchu/mom/pojo/Certification.java
@@ -32,18 +32,21 @@
    @ValueTableShow(5)
    @ApiModelProperty(value = "资质说明")
    private String explain;
    private String explanation;
    @ValueTableShow(6)
    @ApiModelProperty(value = "首次颁发时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime firstTime;
    @ValueTableShow(7)
    @ApiModelProperty(value = "最近颁发时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime recentlyTime;
    @ValueTableShow(8)
    @ApiModelProperty(value = "到期颁发时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime expireTime;
    @ApiModelProperty(value = "创建人")
cnas-server/src/main/java/com/yuanchu/mom/service/CertificationService.java
@@ -16,7 +16,4 @@
    //删除资质明细列表
    int delCertificationDetail(List<Integer> ids);
    //附件下载
    String downFile(Integer id);
}
cnas-server/src/main/java/com/yuanchu/mom/service/impl/CertificationServiceImpl.java
@@ -13,6 +13,7 @@
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.time.LocalDateTime;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -30,8 +31,6 @@
    public Map<String, Object> getCertificationDetail(Page page, Certification certification) {
        Map<String, Object> map = new HashMap<>();
        map.put("head", PrintChina.printChina(Certification.class));
        Map<String, Integer> map1 = getLook.selectPowerByMethodAndUserId("getCertificationDetail");
        if (map1.get("look") == 1) certification.setCreateUser(map1.get("userId"));
        map.put("body", certificationMapper.getCertificationDetail(page, QueryWrappers.queryWrappers(certification)));
        return map;
    }
@@ -48,9 +47,4 @@
        return certificationMapper.deleteBatchIds(ids);
    }
    //附件下载
    @Override
    public String downFile(Integer id) {
        return certificationMapper.selectById(id).getFileUrl();
    }
}
cnas-server/src/main/resources/mapper/CertificationMapper.xml
@@ -7,13 +7,14 @@
        c.name,
        c.code,
        organization,
        `explain`,
        explanation,
        first_time,
        recently_time,
        expire_time,
        u1.name create_user_name,
        c.create_time,
        now()>expire_time?0:1 as state,
        case when now()>expire_time then 0
        else 1 end as state,
        image_url,
        file_url
        from certification c
inspect-server/src/main/java/com/yuanchu/mom/service/impl/ReportServiceImpl.java
@@ -45,9 +45,8 @@
        map.put("RECEIVE", receive);
        //昨日任务接收
        Long received = insOrderMapper.selectCount(Wrappers.<InsOrder>lambdaQuery().eq(InsOrder::getState, 1).apply("DATE(create_time) = CURDATE() - INTERVAL 1 DAY"));
        received = received == 0 ? 1 : received;
        //比例=(今天-昨天)/昨天
        BigDecimal ratio = new BigDecimal(receive - received).divide(new BigDecimal(received), 2, BigDecimal.ROUND_HALF_UP);
        BigDecimal ratio = new BigDecimal(receive - received).divide(new BigDecimal(received == 0 ? 1 : received), 2, BigDecimal.ROUND_HALF_UP);
        map.put("RECEIVE_RATIO", ratio);
        /*任务已完成*/
@@ -56,9 +55,8 @@
        map.put("FINISHE", finishe);
        //昨日任务完成
        Long finished = insOrderMapper.selectCount(Wrappers.<InsOrder>lambdaQuery().eq(InsOrder::getState, 4).apply("DATE(create_time) = CURDATE() - INTERVAL 1 DAY"));
        finished = finished == 0 ? 1 : finished;
        //任务完成比例=(今天-昨天)/昨天
        BigDecimal finishedRatio = new BigDecimal(finishe - finished).divide(new BigDecimal(finished), 2, BigDecimal.ROUND_HALF_UP);
        BigDecimal finishedRatio = new BigDecimal(finishe - finished).divide(new BigDecimal(finished == 0 ? 1 : finished), 2, BigDecimal.ROUND_HALF_UP);
        map.put("FINISHE_RATIO", finishedRatio);
        /*任务剩余*/
@@ -67,9 +65,8 @@
        map.put("SURPLUS", surplus);
        //昨日任务剩余
        long surplused = received - finished;
        surplused = surplused == 0 ? 1 : surplused;
        //剩余比例=(今天-昨天)/昨天
        BigDecimal surplusRatio = new BigDecimal(surplus - surplused).divide(new BigDecimal(surplused), 2, BigDecimal.ROUND_HALF_UP);
        BigDecimal surplusRatio = new BigDecimal(surplus - surplused).divide(new BigDecimal(surplused == 0 ? 1 : surplused), 2, BigDecimal.ROUND_HALF_UP);
        map.put("SURPLUS_RATIO", surplusRatio);
        /*检测费用*/
@@ -93,9 +90,8 @@
        for (CostStatisticsDto record : dtoIPage.getRecords()) {
            priced.add(record.getPrice());
        }
        priced = priced.compareTo(BigDecimal.ZERO) == 0 ? BigDecimal.ONE : priced;
        //比例=(今日-昨日)/昨日
        BigDecimal priceRatio = (price.subtract(priced)).divide(priced, 2, BigDecimal.ROUND_HALF_UP);
        BigDecimal priceRatio = (price.subtract(priced)).divide(priced.compareTo(BigDecimal.ZERO) == 0 ? BigDecimal.ONE : priced, 2, BigDecimal.ROUND_HALF_UP);
        map.put("PRICE_RATIO", priceRatio);
        /*检测工时*/
@@ -110,21 +106,21 @@
        for (CostStatisticsDto record : dtoIPage.getRecords()) {
            costed += record.getCost();
        }
        costed = costed == 0 ? 1 : costed;
        //比例=(今日-昨日)/昨日
        BigDecimal costRatio = new BigDecimal(cost - costed).divide(new BigDecimal(costed), 2, BigDecimal.ROUND_HALF_UP);
        BigDecimal costRatio = new BigDecimal(cost - costed).divide(new BigDecimal(costed == 0 ? 1 : costed), 2, BigDecimal.ROUND_HALF_UP);
        map.put("COST_RATIO", costRatio);
        /*检测人员*/
        //今日检测人员
        Long person = insProductUserMapper.selectCount(Wrappers.<InsProductUser>lambdaQuery().apply("DATE(create_time) = CURDATE()"));
        List<InsProductUser> insProductUsers = insProductUserMapper.selectList(Wrappers.<InsProductUser>lambdaQuery().apply("DATE(create_time) = CURDATE()"));
        long person = insProductUsers.stream().map(InsProductUser::getCreateUser).distinct().count();
        map.put("PERSON", person);
        //昨日检测人员
        Long persons = insProductUserMapper.selectCount(Wrappers.<InsProductUser>lambdaQuery().apply("DATE(create_time) = CURDATE() - INTERVAL 1 DAY"));
        persons = persons == 0 ? 1 : persons;
        List<InsProductUser> insProductUserss = insProductUserMapper.selectList(Wrappers.<InsProductUser>lambdaQuery().apply("DATE(create_time) = CURDATE() - INTERVAL 1 DAY"));
        long persons = insProductUserss.stream().map(InsProductUser::getCreateUser).distinct().count();
        //比例=(今天-昨天)/昨天
        BigDecimal personRatio = new BigDecimal(person - persons).divide(new BigDecimal(persons), 2, BigDecimal.ROUND_HALF_UP);
        BigDecimal personRatio = new BigDecimal(person - persons).divide(new BigDecimal(persons == 0 ? 1 : persons), 2, BigDecimal.ROUND_HALF_UP);
        map.put("PERSON_RATIO", personRatio);
        /*近十日任务接收量与完成量*/
@@ -151,12 +147,64 @@
        /*项目接收*/
        //今日项目接收量
        Long receive = insProductMapper.selectCount(Wrappers.<InsProduct>lambdaQuery().eq(InsProduct::getState, 1).apply("DATE(create_time) = CURDATE()"));
        map.put("RECEVICE", receive);
        //昨日项目接收量
        Long received = insProductMapper.selectCount(Wrappers.<InsProduct>lambdaQuery().eq(InsProduct::getState, 1).apply("DATE(create_time) = CURDATE() - INTERVAL 1 DAY"));
        //比例=(今天-昨天)/昨天
        BigDecimal ratio = new BigDecimal(receive - received).divide(new BigDecimal(received == 0 ? 1 : received), 2, BigDecimal.ROUND_HALF_UP);
        map.put("RECEIVE_RATIO", ratio);
        /*项目完成*/
        //今日项目完成量
        Long finishe = insProductMapper.selectCount(Wrappers.<InsProduct>lambdaQuery().eq(InsProduct::getState, 1).isNotNull(InsProduct::getInsResult).apply("DATE(create_time) = CURDATE()"));
        map.put("FINISHE", finishe);
        //昨日项目完成量
        Long finished = insProductMapper.selectCount(Wrappers.<InsProduct>lambdaQuery().eq(InsProduct::getState, 1).isNotNull(InsProduct::getInsResult).apply("DATE(create_time) = CURDATE() - INTERVAL 1 DAY"));
        //任务完成比例=(今天-昨天)/昨天
        BigDecimal finishedRatio = new BigDecimal(finishe - finished).divide(new BigDecimal(finished == 0 ? 1 : finished), 2, BigDecimal.ROUND_HALF_UP);
        map.put("FINISHE_RATIO", finishedRatio);
        /*项目剩余*/
        //今日项目剩余量
        long surplus = receive - finishe;
        map.put("SURPLUS", surplus);
        //昨日项目剩余
        long surplused = received - finished;
        //剩余比例=(今天-昨天)/昨天
        BigDecimal surplusRatio = new BigDecimal(surplus - surplused).divide(new BigDecimal(surplused == 0 ? 1 : surplused), 2, BigDecimal.ROUND_HALF_UP);
        map.put("SURPLUS_RATIO", surplusRatio);
        /*今日项目合格率*/
        //今日完成量中的合格量/今日完成量
        Long accept = insProductMapper.selectCount(Wrappers.<InsProduct>lambdaQuery().eq(InsProduct::getState, 1).eq(InsProduct::getInsResult,1).apply("DATE(create_time) = CURDATE()"));
        BigDecimal acceptRate = new BigDecimal(accept).divide(new BigDecimal(finishe == 0 ? 1 : finishe), 2, BigDecimal.ROUND_HALF_UP);
        map.put("ACCEPT_RATE_TODAY", acceptRate);
        /*今日项目完成率*/
        //今日完成量/今日接收量
        BigDecimal finishRate = new BigDecimal(finishe).divide(new BigDecimal(receive == 0 ? 1 : receive), 2, BigDecimal.ROUND_HALF_UP);
        map.put("FINISH_RATE_TODAY", finishRate);
        /*今日项目延期率*/
        //今日项目剩余/今日项目接收量
        BigDecimal delayRate = new BigDecimal(surplus).divide(new BigDecimal(received == 0 ? 1 : received), 2, BigDecimal.ROUND_HALF_UP);
        map.put("DELAY_RATE_TODAY", delayRate);
        /*近十日的项目接收量与完成量*/
        //获取近十日的横坐标
        LocalDate currentDate = LocalDate.now();
        List<LocalDate> lastTenDays = new ArrayList<>();
        List<Long> receTenDays = new ArrayList<>();
        List<Long> finTenDays = new ArrayList<>();
        for (int i = 9; i > -1; i--) {
            lastTenDays.add(currentDate.minusDays(i));
            receTenDays.add(insProductMapper.selectCount(Wrappers.<InsProduct>lambdaQuery().eq(InsProduct::getState, 1).apply("DATE(create_time) = CURDATE() - INTERVAL " + i + " DAY")));
            finTenDays.add(insProductMapper.selectCount(Wrappers.<InsProduct>lambdaQuery().eq(InsProduct::getState, 1).isNotNull(InsProduct::getInsResult).apply("DATE(create_time) = CURDATE() - INTERVAL " + i + " DAY")));
        }
        map.put("DAYS", lastTenDays);
        map.put("RECETENDAYS", receTenDays);
        map.put("FINISHTENDAYS", finTenDays);
        return map;
    }
@@ -164,25 +212,25 @@
    @Override
    public Map<String, Object> calendarWorkByWeek() {
        Map<String, Object> map = new HashMap<>();
        List<Integer> insState=new ArrayList<>();
        List<Integer> insState = new ArrayList<>();
        insState.add(0);
        insState.add(1);
        /*获取后一周日期*/
        LocalDate currentDate = LocalDate.now();
        List<LocalDate> weekDays = new ArrayList<>();
        for (int i = 0; i <7; i++) {
        for (int i = 0; i < 7; i++) {
            weekDays.add(currentDate.plusDays(i));
            //查询当天需要检测的委托订单
            List<InsOrder> insOrders = insOrderMapper.selectList(Wrappers.<InsOrder>lambdaQuery().eq(InsOrder::getState, 1).in(InsOrder::getInsState, insState).apply("DATE(create_time) = CURDATE() - INTERVAL " + i + " DAY"));
            List<Map<String,Object>> works = insOrders.stream().map(insOrder -> {
            List<InsOrder> insOrders = insOrderMapper.selectList(Wrappers.<InsOrder>lambdaQuery().eq(InsOrder::getState, 1).in(InsOrder::getInsState, insState).apply("DATE(create_time) = CURDATE() + INTERVAL " + i + " DAY"));
            List<Map<String, Object>> works = insOrders.stream().map(insOrder -> {
                HashMap<String, Object> hashMap = new HashMap<>();
                hashMap.put("text","委托订单" + insOrder.getEntrustCode() + "检测");
                hashMap.put("type",insOrder.getType());
                hashMap.put("text", "委托订单" + insOrder.getEntrustCode() + "检测");
                hashMap.put("type", insOrder.getType());
                User user = userMapper.selectById(insOrder.getCreateUser());
                hashMap.put("name", user.getName());
                return  hashMap;
                return hashMap;
            }).collect(Collectors.toList());
            map.put("work"+i, works);
            map.put("work" + i, works);
        }
        map.put("weekDays", weekDays);
        return map;
@@ -208,6 +256,6 @@
        LocalDate localDate = LocalDate.parse(date, DateTimeFormatter.ofPattern("yyyy-MM-dd"));
        LocalDateTime startTime = localDate.atStartOfDay();
        LocalDateTime endTime = localDate.plusDays(1).atStartOfDay().minusSeconds(1);
        return scheduleMapper.selectList(Wrappers.<Schedule>lambdaQuery().eq(Schedule::getUserId,userId).between(Schedule::getScheduleTime,startTime,endTime));
        return scheduleMapper.selectList(Wrappers.<Schedule>lambdaQuery().eq(Schedule::getUserId, userId).between(Schedule::getScheduleTime, startTime, endTime));
    }
}