lxp
2025-03-15 5c92f5ec07c74272c7bfd658ef9c9f5ceb02cfb1
统计图表、任务展示代码搬迁
已修改10个文件
已添加5个文件
556 ■■■■ 文件已修改
inspect-server/src/main/java/com/ruoyi/inspect/controller/InsOrderController.java 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
inspect-server/src/main/java/com/ruoyi/inspect/controller/InsOrderPlanController.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
inspect-server/src/main/java/com/ruoyi/inspect/controller/InsUnPassController.java 23 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
inspect-server/src/main/java/com/ruoyi/inspect/controller/ReportController.java 60 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
inspect-server/src/main/java/com/ruoyi/inspect/controller/WarehouseController.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
inspect-server/src/main/java/com/ruoyi/inspect/mapper/InsOrderMapper.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
inspect-server/src/main/java/com/ruoyi/inspect/mapper/InsUnPassMapper.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
inspect-server/src/main/java/com/ruoyi/inspect/mapper/ScheduleMapper.java 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
inspect-server/src/main/java/com/ruoyi/inspect/service/InsOrderService.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
inspect-server/src/main/java/com/ruoyi/inspect/service/ReportService.java 23 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
inspect-server/src/main/java/com/ruoyi/inspect/service/impl/InsOrderPlanServiceImpl.java 5 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
inspect-server/src/main/java/com/ruoyi/inspect/service/impl/InsOrderServiceImpl.java 11 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
inspect-server/src/main/java/com/ruoyi/inspect/service/impl/InsUnPassServiceImpl.java 5 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
inspect-server/src/main/java/com/ruoyi/inspect/service/impl/ReportServiceImpl.java 288 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
inspect-server/src/main/resources/mapper/InsOrderMapper.xml 108 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
inspect-server/src/main/java/com/ruoyi/inspect/controller/InsOrderController.java
@@ -151,8 +151,7 @@
    @ApiOperation(value = "费用统计获取总价")
    @GetMapping("/costStatistics2")
    public Result<?> costStatistics2(@RequestBody Map<String, Object> data) throws Exception {
        CostStatisticsDto costStatisticsDto = JackSonUtil.unmarshal(JackSonUtil.marshal(data.get("entity")), CostStatisticsDto.class);
    public Result<?> costStatistics2( CostStatisticsDto costStatisticsDto) throws Exception {
        return Result.success(insOrderService.costStatistics2(costStatisticsDto));
    }
inspect-server/src/main/java/com/ruoyi/inspect/controller/InsOrderPlanController.java
@@ -48,7 +48,7 @@
    @ApiOperation(value = "导出委托费用")
    @GetMapping("/exportCommissionFees")
    public void exportCommissionFees(Map<String, Object> data,HttpServletResponse response) {
    public void exportCommissionFees(@RequestParam Map<String, Object> data,HttpServletResponse response) {
         insOrderPlanService.exportCommissionFees(data,response);
    }
@@ -228,4 +228,4 @@
        return Result.success(insOrderPlanService.getCurrentMonthPlanTotalBySonLaboratory(insOrderPlanCountDTO.getSonLaboratory(),insOrderPlanCountDTO.getStartTime(),insOrderPlanCountDTO.getEndTime()));
    }
}
}
inspect-server/src/main/java/com/ruoyi/inspect/controller/InsUnPassController.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,23 @@
package com.ruoyi.inspect.controller;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruoyi.common.core.domain.Result;
import com.ruoyi.inspect.dto.UnPassPageDto;
import com.ruoyi.inspect.service.InsUnPassService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
@RestController
@RequestMapping("/unPass")
public class InsUnPassController {
    @Resource
    private InsUnPassService insUnPassService;
    @GetMapping("/pageInsUnPass")
    public Result selectUnPass(Page page, UnPassPageDto unPassPageDto) {
        return Result.success(insUnPassService.pageInsUnPass(page,unPassPageDto));
    }
}
inspect-server/src/main/java/com/ruoyi/inspect/controller/ReportController.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,60 @@
package com.ruoyi.inspect.controller;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruoyi.common.core.domain.Result;
import com.ruoyi.inspect.service.InsOrderService;
import com.ruoyi.inspect.service.ReportService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@AllArgsConstructor
@RequestMapping("/report")
@Api(tags = "报表模块")
public class ReportController {
    private ReportService reportService;
    private InsOrderService insOrderService;
    @ApiOperation(value = "查看样品缺陷指数")
    @PostMapping("/selectSampleDefects")
    public Result selectSampleDefects(Integer size, Integer current, String inspectionItems, String orderNumber) {
        return Result.success(insOrderService.selectSampleDefects(new Page<>(current, size),inspectionItems, orderNumber));
    }
    @ApiOperation(value = "查看每日业务统计")
    @GetMapping("/businessStatisticsByDay")
    public Result businessStatisticsByDay(){
        return Result.success(reportService.businessStatisticsByDay());
    }
    @ApiOperation(value = "查看检测项目统计")
    @GetMapping("/testProductByDay")
    public Result testProductByDay(){
        return Result.success(reportService.testProductByDay());
    }
    @ApiOperation(value = "查询日历任务图")
    @GetMapping("/calendarWorkByWeek")
    public Result calendarWorkByWeek(){
        return Result.success(reportService.calendarWorkByWeek());
    }
    @ApiOperation(value = "添加日程")
    @PostMapping("/addSchedule")
    public Result addSchedule(String time, String text){
        return Result.success(reportService.addSchedule(time,text));
    }
    @ApiOperation(value = "查询我的日程")
    @PostMapping("/ScheduleByMe")
    public Result ScheduleByMe(String date){
        return Result.success(reportService.ScheduleByMe(date));
    }
}
inspect-server/src/main/java/com/ruoyi/inspect/controller/WarehouseController.java
@@ -20,7 +20,7 @@
    private WarehouseService warehouseService;
    @PostMapping("/addWarehouse")
    @GetMapping("/addWarehouse")
    @ApiOperation("添加仓库")
    public Result addWarehouse(String name) {
        return Result.success(warehouseService.addWarehouse(name));
@@ -99,4 +99,4 @@
        return Result.success(warehouseService.searchSampleId(sampleCode));
    }
}
}
inspect-server/src/main/java/com/ruoyi/inspect/mapper/InsOrderMapper.java
@@ -56,7 +56,7 @@
    List<SampleProductDto2> selectSampleAndProductByOrderId(@Param("ew") QueryWrapper<SampleProductDto2> ew, @Param("id") Integer id);
    IPage<CostStatisticsDto> selectCostStatistics(IPage<CostStatisticsDto> page, QueryWrapper<CostStatisticsDto> ew, @Param("startTime") String startTime, @Param("endTime") String endTime, @Param("laboratory") String laboratory);
    IPage<CostStatisticsDto> selectCostStatistics(IPage<CostStatisticsDto> page,@Param("ew") QueryWrapper<CostStatisticsDto> ew, @Param("startTime") String startTime, @Param("endTime") String endTime, @Param("laboratory") String laboratory);
    List<CostStatisticsDto> selectCostStatistics2(@Param("ew") QueryWrapper<CostStatisticsDto> ew,@Param("startTime") String startTime, @Param("endTime") String endTime,@Param("laboratory") String laboratory);
@@ -104,4 +104,4 @@
                                                @Param("endTime") String endTime,
                                                @Param("checkName") String checkName
    );
}
}
inspect-server/src/main/java/com/ruoyi/inspect/mapper/InsUnPassMapper.java
@@ -6,6 +6,7 @@
import com.ruoyi.inspect.dto.UnPassPageDto;
import com.ruoyi.inspect.pojo.InsUnPass;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
/**
 * @author æœ±ä½³å‰
@@ -13,5 +14,5 @@
 */
@Mapper
public interface InsUnPassMapper extends BaseMapper<InsUnPass> {
    IPage<UnPassPageDto> pageInsUnPass(IPage<UnPassPageDto> page, QueryWrapper<UnPassPageDto> ew);
}
    IPage<UnPassPageDto> pageInsUnPass(IPage<UnPassPageDto> page,@Param("ew") QueryWrapper<UnPassPageDto> ew);
}
inspect-server/src/main/java/com/ruoyi/inspect/mapper/ScheduleMapper.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,11 @@
package com.ruoyi.inspect.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ruoyi.inspect.pojo.Schedule;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.stereotype.Repository;
@Mapper
@Repository
public interface ScheduleMapper extends BaseMapper<Schedule> {
}
inspect-server/src/main/java/com/ruoyi/inspect/service/InsOrderService.java
@@ -39,7 +39,7 @@
    void exportChecked(Map<String,Object> data, HttpServletResponse response);
    Map<String, Object> costStatistics(IPage<CostStatisticsDto> page, CostStatisticsDto costStatisticsDto);
    IPage<CostStatisticsDto> costStatistics(IPage<CostStatisticsDto> page, CostStatisticsDto costStatisticsDto);
    Map<String, Object> costStatistics2(CostStatisticsDto costStatisticsDto);
inspect-server/src/main/java/com/ruoyi/inspect/service/ReportService.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,23 @@
package com.ruoyi.inspect.service;
import com.ruoyi.inspect.pojo.Schedule;
import java.util.List;
import java.util.Map;
public interface ReportService {
    //每日业务统计
    Map<String,Object> businessStatisticsByDay();
    //检测项目统计
    Map<String,Object> testProductByDay();
    //首页-->日历任务图
    Map<String,Object> calendarWorkByWeek();
    //首页-->添加日程
    int addSchedule(String time, String text);
    //首页-->我的日程
    List<Schedule> ScheduleByMe(String date);
}
inspect-server/src/main/java/com/ruoyi/inspect/service/impl/InsOrderPlanServiceImpl.java
@@ -462,7 +462,10 @@
                        dateTimeFormatter),LocalTime.of(23, 59, 59)
        ).toString();
        // èŽ·å–æ•°æ®
        String company = data.get("company").toString();
        String company = "";
        if(data.containsKey("company")) {
            company =  data.get("company").toString();
        }
        List<CommissionFeesDto> list = insOrderMapper.selectCommissionFees(laboratory,company, start, end);
        list = list.stream().map(dto -> {
            Set<String> uniqueTags = new HashSet<>();
inspect-server/src/main/java/com/ruoyi/inspect/service/impl/InsOrderServiceImpl.java
@@ -1858,16 +1858,12 @@
    @Override
    public Map<String, Object> costStatistics(IPage<CostStatisticsDto> page, CostStatisticsDto costStatisticsDto) {
    public IPage<CostStatisticsDto> costStatistics(IPage<CostStatisticsDto> page, CostStatisticsDto costStatisticsDto) {
        String dates = costStatisticsDto.getDates();
        String[] split = dates.replaceAll("\\[", "").replaceAll("]", "").replaceAll("\"", "").split(",");
        costStatisticsDto.setDates(null);
        Map<String, Object> map = new HashMap<>();
//        map.put("head", PrintChina.printChina(CostStatisticsDto.class));
        Map<String, Integer> map1 = new HashMap<>();
        if (map1.get("look") == 1) costStatisticsDto.setCreateUser(map1.get("userId"));
        // èŽ·å–å½“å‰äººæ‰€åœ¨å®žéªŒå®¤
        Integer userId = 1;
        Integer userId = Integer.parseInt(SecurityUtils.getLoginUser().getUser().getUserId().toString());
        String departLimsId = userMapper.selectById(userId).getDepartLimsId();
        String laboratory = "";
        if (StringUtils.isNotBlank(departLimsId)) {
@@ -1894,8 +1890,7 @@
            return dto;
        }).collect(Collectors.toList());
        dtoIPage.setRecords(collect);
        map.put("body", dtoIPage);
        return map;
        return dtoIPage;
    }
    @Override
inspect-server/src/main/java/com/ruoyi/inspect/service/impl/InsUnPassServiceImpl.java
@@ -26,9 +26,6 @@
    @Override
    public IPage<UnPassPageDto> pageInsUnPass(Page page, UnPassPageDto unPassPageDto) {
        Map<String, Object> map = new HashMap<>();
//        Map<String, Integer> map1 = getLook.selectPowerByMethodAndUserId("pageInsUnPass");
//        if (map1.get("look") == 1) unPassPageDto.setCreateUser(map1.get("userId"));
        return insUnPassMapper.pageInsUnPass(page, QueryWrappers.queryWrappers(unPassPageDto));
    }
}
}
inspect-server/src/main/java/com/ruoyi/inspect/service/impl/ReportServiceImpl.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,288 @@
package com.ruoyi.inspect.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruoyi.common.core.domain.entity.User;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.inspect.dto.CostStatisticsDto;
import com.ruoyi.inspect.mapper.InsOrderMapper;
import com.ruoyi.inspect.mapper.InsProductMapper;
import com.ruoyi.inspect.mapper.InsProductUserMapper;
import com.ruoyi.inspect.mapper.ScheduleMapper;
import com.ruoyi.inspect.pojo.InsOrder;
import com.ruoyi.inspect.pojo.InsProduct;
import com.ruoyi.inspect.pojo.InsProductUser;
import com.ruoyi.inspect.pojo.Schedule;
import com.ruoyi.inspect.service.ReportService;
import com.ruoyi.system.mapper.UserMapper;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.stream.Collectors;
@Service
@AllArgsConstructor
public class ReportServiceImpl implements ReportService {
    private InsOrderMapper insOrderMapper;
    private InsProductUserMapper insProductUserMapper;
    private InsProductMapper insProductMapper;
    private ScheduleMapper scheduleMapper;
    private UserMapper userMapper;
    //每日业务统计
    @Override
    public Map<String, Object> businessStatisticsByDay() {
        Map<String, Object> map = new HashMap<>();
        /*任务接收*/
        //今日任务接收
        Long receive = insOrderMapper.selectCount(Wrappers.<InsOrder>lambdaQuery().eq(InsOrder::getState, 1).apply("DATE(create_time) = CURDATE()"));
        map.put("RECEIVE", receive);
        //昨日任务接收
        Long received = insOrderMapper.selectCount(Wrappers.<InsOrder>lambdaQuery().eq(InsOrder::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 = insOrderMapper.selectCount(Wrappers.<InsOrder>lambdaQuery().eq(InsOrder::getState, 4).apply("DATE(create_time) = CURDATE()"));
        map.put("FINISHE", finishe);
        //昨日任务完成
        Long finished = insOrderMapper.selectCount(Wrappers.<InsOrder>lambdaQuery().eq(InsOrder::getState, 4).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);
        LocalDate today = LocalDate.now();
        LocalTime end = LocalTime.of(23, 59, 59);
        // èŽ·å–å½“å‰äººæ‰€åœ¨å®žéªŒå®¤
        Integer userId = Integer.parseInt(SecurityUtils.getUserId().toString());
        String departLimsId = userMapper.selectById(userId).getDepartLimsId();
        String laboratory = "";
        if(StringUtils.isNotBlank(departLimsId)) {
            String[] split = departLimsId.split(",");
            for (String s : split) {
                if (StringUtils.isNotBlank(s) && (!Arrays.asList("1","22").contains(s))) {
                    laboratory = insOrderMapper.getDepartment(Integer.parseInt(s));
                }
            }
        }
        /*检测费用*/
        //今日检测费用
        QueryWrapper<CostStatisticsDto> costStatisticsDtoQueryWrappers = new QueryWrapper<>();
        costStatisticsDtoQueryWrappers.eq("create_time", LocalDateTime.now());
        IPage<CostStatisticsDto> page = new Page<>();
        page.setSize(-1);
        page.setCurrent(-1);
        IPage<CostStatisticsDto> iPage = insOrderMapper.selectCostStatistics(page, costStatisticsDtoQueryWrappers,LocalDate.now().atStartOfDay().toString(),today.atTime(end).toString(),laboratory);
        BigDecimal price = BigDecimal.ZERO;
        for (CostStatisticsDto record : iPage.getRecords()) {
            price.add(record.getPrice());
        }
        map.put("PRICE", price);
        //昨日检测费用
        QueryWrapper<CostStatisticsDto> costWrappers = new QueryWrapper<>();
        costWrappers.eq("create_time", LocalDateTime.now().minusDays(1));
        IPage<CostStatisticsDto> dtoIPage = insOrderMapper.selectCostStatistics(page, costWrappers,LocalDate.now().atStartOfDay().toString(),today.atTime(end).toString(),laboratory);
        BigDecimal priced = BigDecimal.ZERO;
        for (CostStatisticsDto record : dtoIPage.getRecords()) {
            priced.add(record.getPrice());
        }
        //比例=(今日-昨日)/昨日
        BigDecimal priceRatio = (price.subtract(priced)).divide(priced.compareTo(BigDecimal.ZERO) == 0 ? BigDecimal.ONE : priced, 2, BigDecimal.ROUND_HALF_UP);
        map.put("PRICE_RATIO", priceRatio);
        /*检测工时*/
        //今日检测工时
        Double cost = 0.0;
        for (CostStatisticsDto record : iPage.getRecords()) {
            cost += record.getCost();
        }
        map.put("COST", cost);
        //昨日检测工时
        Double costed = 0.0;
        for (CostStatisticsDto record : dtoIPage.getRecords()) {
            costed += record.getCost();
        }
        //比例=(今日-昨日)/昨日
        BigDecimal costRatio = new BigDecimal(cost - costed).divide(new BigDecimal(costed == 0 ? 1 : costed), 2, BigDecimal.ROUND_HALF_UP);
        map.put("COST_RATIO", costRatio);
        /*检测人员*/
        //今日检测人员
        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);
        //昨日检测人员
        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 == 0 ? 1 : persons), 2, BigDecimal.ROUND_HALF_UP);
        map.put("PERSON_RATIO", personRatio);
        /*近十日任务接收量与完成量*/
        //获取近十日的横坐标
        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(insOrderMapper.selectCount(Wrappers.<InsOrder>lambdaQuery().eq(InsOrder::getState, 1).apply("DATE(create_time) = CURDATE() - INTERVAL " + i + " DAY")));
            finTenDays.add(insOrderMapper.selectCount(Wrappers.<InsOrder>lambdaQuery().eq(InsOrder::getState, 4).apply("DATE(create_time) = CURDATE() - INTERVAL " + i + " DAY")));
        }
        map.put("DAYS", lastTenDays);
        map.put("RECETENDAYS", receTenDays);
        map.put("FINISHTENDAYS", finTenDays);
        return map;
    }
    //检测项目统计
    @Override
    public Map<String, Object> testProductByDay() {
        Map<String, Object> map = new HashMap<>();
        /*项目接收*/
        //今日项目接收量
        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()"));
        map.put("ACCEPT", accept);
        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;
    }
    //首页-->日历任务图
    @Override
    public Map<String, Object> calendarWorkByWeek() {
        Map<String, Object> map = new HashMap<>();
        List<Integer> insState = new ArrayList<>();
        insState.add(0);
        insState.add(1);
        /*获取后一周日期*/
        LocalDate currentDate = LocalDate.now();
        List<LocalDate> weekDays = new ArrayList<>();
        for (int i = 6, j = 0; i >= 0; i--, j++) {
            weekDays.add(currentDate.minusDays(i));
            //查询当天需要检测的委托订单
            List<InsOrder> insOrders = insOrderMapper.selectList(Wrappers.<InsOrder>lambdaQuery()
                    .eq(InsOrder::getState, 1)
                    .in(InsOrder::getInsState, insState)
                    .apply("DATE(create_time) = CURDATE() - INTERVAL " + j + " 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());
                User user = userMapper.selectById(insOrder.getCreateUser());
                hashMap.put("name", user.getName());
                return hashMap;
            }).collect(Collectors.toList());
            map.put("work" + i, works);
        }
        map.put("weekDays", weekDays);
        return map;
    }
    //首页-->添加日程
    @Override
    public int addSchedule(String time, String text) {
        //获取当前用户id
        Integer userId = Integer.parseInt(SecurityUtils.getUserId().toString());
        Schedule schedule = new Schedule();
        schedule.setUserId(userId);
        schedule.setScheduleTime(LocalDateTime.parse(time, DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
        schedule.setText(text);
        return scheduleMapper.insert(schedule);
    }
    //首页-->我的日程
    @Override
    public List<Schedule> ScheduleByMe(String date) {
        //获取当前用户id
        Integer userId = Integer.parseInt(SecurityUtils.getUserId().toString());
        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));
    }
}
inspect-server/src/main/resources/mapper/InsOrderMapper.xml
@@ -594,9 +594,6 @@
        A.company,
        A.`name`
        )B
        <if test="ew.customSqlSegment != null and ew.customSqlSegment != ''">
            ${ew.customSqlSegment}
        </if>
    </select>
    <select id="selectDeviceList" resultType="com.ruoyi.inspect.vo.DeviceVO">
        select
@@ -855,105 +852,6 @@
    <select id="selectCommissionFees" resultType="com.ruoyi.inspect.dto.CommissionFeesDto">
<!--        SELECT-->
<!--        date_format(create_time, '%Y-%m-%d') AS create_time,-->
<!--        entrust_code,-->
<!--        sample_name,-->
<!--        sample_model,-->
<!--        sample_num,-->
<!--        ins_item,-->
<!--        production,-->
<!--        company,-->
<!--        custom,-->
<!--        engineering,-->
<!--        total_price-->
<!--        FROM-->
<!--        (-->
<!--        SELECT-->
<!--        io.*,-->
<!--        sample_counts.sample_num,-->
<!--        GROUP_CONCAT( DISTINCT isa.sample SEPARATOR '、' ) AS sample_name,-->
<!--        GROUP_CONCAT( DISTINCT isa.model SEPARATOR '、' ) AS sample_model,-->
<!--        total_product_counts.ins_item,-->
<!--        total_price-->
<!--        FROM-->
<!--        ins_order io-->
<!--        LEFT JOIN ins_sample isa ON io.id = isa.ins_order_id-->
<!--        LEFT JOIN ins_sample_user isau ON isau.ins_sample_id = io.id-->
<!--        LEFT JOIN ins_order_state iot ON iot.ins_order_id = io.id-->
<!--        LEFT JOIN ins_report ir ON io.id = ir.ins_order_id-->
<!--        AND ir.is_ratify = 1-->
<!--        LEFT JOIN USER u ON io.create_user = u.id-->
<!--        LEFT JOIN (-->
<!--        SELECT-->
<!--        ins_order_id,-->
<!--        COUNT(*) AS sample_num-->
<!--        FROM-->
<!--        ins_sample-->
<!--        WHERE-->
<!--        id IN (-->
<!--        SELECT-->
<!--        id1-->
<!--        FROM-->
<!--        (-->
<!--        SELECT-->
<!--        is2.id id1,-->
<!--        ip.id-->
<!--        FROM-->
<!--        ins_sample is2-->
<!--        LEFT JOIN ins_product ip ON is2.id = ip.ins_sample_id-->
<!--        WHERE-->
<!--        ip.id IS NOT NULL-->
<!--        ) s-->
<!--        )-->
<!--        GROUP BY-->
<!--        ins_order_id-->
<!--        ) sample_counts ON io.id = sample_counts.ins_order_id-->
<!--        LEFT JOIN (-->
<!--        SELECT-->
<!--        SUM( price ) AS total_price,-->
<!--        sample_id,-->
<!--        ins_order_id,-->
<!--        man_hour_group,-->
<!--        ins_item-->
<!--        FROM-->
<!--        (-->
<!--        SELECT-->
<!--        ins_sample.id AS sample_id,-->
<!--        ins_sample.ins_order_id,-->
<!--        ins_product.man_hour_group,-->
<!--        GROUP_CONCAT( DISTINCT inspection_item SEPARATOR ',' ) AS ins_item,-->
<!--        price-->
<!--        FROM-->
<!--        ins_product-->
<!--        JOIN ins_sample ON ins_product.ins_sample_id = ins_sample.id-->
<!--        WHERE-->
<!--        ins_product.state = 1-->
<!--        GROUP BY-->
<!--        ins_sample.ins_order_id,-->
<!--        ins_sample.id,-->
<!--        ins_product.man_hour_group-->
<!--        ) b-->
<!--        GROUP BY-->
<!--        ins_order_id-->
<!--        ) total_product_counts ON io.id = total_product_counts.ins_order_id-->
<!--        WHERE-->
<!--        <if test="laboratory!=null and laboratory!=''">-->
<!--            io.laboratory=#{laboratory} AND-->
<!--        </if>-->
<!--        io.create_time between #{startTime} and #{endTime}-->
<!--        AND-->
<!--        io.state NOT IN ( 0, 2, 3 )-->
<!--        GROUP BY-->
<!--        io.id,-->
<!--        type-->
<!--        ORDER BY-->
<!--        type DESC,-->
<!--        io.id DESC-->
<!--        ) a-->
        SELECT
        A.entrust_code,
        A.engineering,
@@ -1086,8 +984,8 @@
        group by io.entrust_code
        order by send_time desc
    </select>
    <select id="getTasksShow" resultType="com.ruoyi.inspect.dto.TasksShowDto">
        SELECT
            io.entrust_code,
@@ -1141,7 +1039,7 @@
                LEFT JOIN `user` u ON ips.update_user = u.id
        WHERE
            io.entrust_code IS NOT NULL
          AND u.state = 1
          AND u.status = 0
          AND io.state in  (1,4)
          AND IFNULL(ir.is_ratify,-1) != 1
          AND ios.laboratory = #{sonLaboratory}