From 97bb7a8832281eafe0ef947ea095258d355e52f5 Mon Sep 17 00:00:00 2001 From: zss <zss@example.com> Date: 星期一, 30 十二月 2024 15:57:51 +0800 Subject: [PATCH] 无源器件的数采+电路模版查询 --- inspect-server/src/main/java/com/yuanchu/mom/service/impl/ReportServiceImpl.java | 329 ++++++++++++++++++++++++++++++++++++++++++++++-------- 1 files changed, 280 insertions(+), 49 deletions(-) diff --git a/inspect-server/src/main/java/com/yuanchu/mom/service/impl/ReportServiceImpl.java b/inspect-server/src/main/java/com/yuanchu/mom/service/impl/ReportServiceImpl.java index c044f08..00943f6 100644 --- a/inspect-server/src/main/java/com/yuanchu/mom/service/impl/ReportServiceImpl.java +++ b/inspect-server/src/main/java/com/yuanchu/mom/service/impl/ReportServiceImpl.java @@ -2,26 +2,24 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.yuanchu.mom.common.GetLook; import com.yuanchu.mom.dto.CostStatisticsDto; +import com.yuanchu.mom.dto.InsOrderUserDto; import com.yuanchu.mom.mapper.*; import com.yuanchu.mom.pojo.*; import com.yuanchu.mom.service.ReportService; -import com.yuanchu.mom.utils.QueryWrappers; import lombok.AllArgsConstructor; import org.springframework.stereotype.Service; import java.math.BigDecimal; +import java.time.Duration; import java.time.LocalDate; import java.time.LocalDateTime; -import java.time.LocalTime; import java.time.format.DateTimeFormatter; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.*; import java.util.stream.Collectors; @Service @@ -29,36 +27,67 @@ public class ReportServiceImpl implements ReportService { private InsOrderMapper insOrderMapper; + private InsSampleMapper insSampleMapper; private InsProductUserMapper insProductUserMapper; private InsProductMapper insProductMapper; private GetLook getLook; private ScheduleMapper scheduleMapper; private UserMapper userMapper; + private RoleMapper roleMapper; + private InsSampleUserMapper insSampleUserMapper; + private AuxiliaryOutputWorkingHoursMapper auxiliaryOutputWorkingHoursMapper; + private InsOrderStateMapper insOrderStateMapper; + private InsOrderUserMapper insOrderUserMapper; //姣忔棩涓氬姟缁熻 @Override - public Map<String, Object> businessStatisticsByDay() { + 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) { + case "鍛�": + oldStart = start.minusDays(7); + oldEnd = end.minusDays(7); + break; + case "鏈�": + oldStart = start.minusMonths(1); + oldEnd = end.minusMonths(1); + break; + case "骞�": + oldStart = start.minusYears(1); + oldEnd = end.minusYears(1); + break; + } Map<String, Object> map = new HashMap<>(); /*浠诲姟鎺ユ敹*/ //浠婃棩浠诲姟鎺ユ敹 - Long receive = insOrderMapper.selectCount(Wrappers.<InsOrder>lambdaQuery().eq(InsOrder::getState, 1).apply("DATE(create_time) = CURDATE()")); + Long receive = insOrderMapper.selectCount(Wrappers.<InsOrder>lambdaQuery() + .eq(InsOrder::getState, 1) + .between(InsOrder::getCreateTime, start, end)); 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; + Long received = insOrderMapper.selectCount(Wrappers.<InsOrder>lambdaQuery() + .eq(InsOrder::getState, 1) + .between(InsOrder::getCreateTime, oldStart, oldEnd)); //姣斾緥=(浠婂ぉ-鏄ㄥぉ)/鏄ㄥぉ - 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); /*浠诲姟宸插畬鎴�*/ //浠婃棩浠诲姟瀹屾垚 - Long finishe = insOrderMapper.selectCount(Wrappers.<InsOrder>lambdaQuery().eq(InsOrder::getState, 4).apply("DATE(create_time) = CURDATE()")); + Long finishe = insOrderMapper.selectCount(Wrappers.<InsOrder>lambdaQuery() + .eq(InsOrder::getState, 4) + .between(InsOrder::getCreateTime, start, end)); 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; + Long finished = insOrderMapper.selectCount(Wrappers.<InsOrder>lambdaQuery() + .eq(InsOrder::getState, 4) + .between(InsOrder::getCreateTime, oldStart, oldEnd)); //浠诲姟瀹屾垚姣斾緥=(浠婂ぉ-鏄ㄥぉ)/鏄ㄥぉ - 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,76 +96,90 @@ 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); /*妫�娴嬭垂鐢�*/ //浠婃棩妫�娴嬭垂鐢� QueryWrapper<CostStatisticsDto> costStatisticsDtoQueryWrappers = new QueryWrapper<>(); - costStatisticsDtoQueryWrappers.eq("create_time", LocalDateTime.now()); + 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.eq("create_time", LocalDateTime.now().minusDays(1)); + 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); } - 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); /*妫�娴嬪伐鏃�*/ //浠婃棩妫�娴嬪伐鏃� 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; } - 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() + .between(InsProductUser::getCreateTime, start, end)); + 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() + .between(InsProductUser::getCreateTime, oldStart, oldEnd)); + 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); /*杩戝崄鏃ヤ换鍔℃帴鏀堕噺涓庡畬鎴愰噺*/ //鑾峰彇杩戝崄鏃ョ殑妯潗鏍� - LocalDate currentDate = LocalDate.now(); - List<LocalDate> lastTenDays = new ArrayList<>(); + LocalDate startDate = LocalDate.parse(startTime, format); + LocalDate endDate = LocalDate.parse(endTime, format); + List<String> 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"))); + while (!startDate.isAfter(endDate)) { + 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.plusMonths(1).minusDays(1).atTime(23, 59, 59)))); + finTenDays.add(insOrderMapper.selectCount(Wrappers.<InsOrder>lambdaQuery() + .eq(InsOrder::getState, 4) + .between(InsOrder::getCreateTime, startDate.atStartOfDay(), startDate.plusMonths(1).minusDays(1).atTime(23, 59, 59)))); + if (type.equals("骞�")) { + startDate = startDate.plusMonths(1); + } else { + startDate = startDate.plusDays(1); + } } map.put("DAYS", lastTenDays); map.put("RECETENDAYS", receTenDays); @@ -146,43 +189,170 @@ //妫�娴嬮」鐩粺璁� @Override - public Map<String, Object> testProductByDay() { + 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; Map<String, Object> map = new HashMap<>(); + switch (type) { + case "鍛�": + oldStart = start.minusDays(7); + oldEnd = end.minusDays(7); + break; + case "鏈�": + oldStart = start.minusMonths(1); + oldEnd = end.minusMonths(1); + break; + case "骞�": + oldStart = start.minusYears(1); + oldEnd = end.minusYears(1); + break; + } /*椤圭洰鎺ユ敹*/ //浠婃棩椤圭洰鎺ユ敹閲� - Long receive = insProductMapper.selectCount(Wrappers.<InsProduct>lambdaQuery().eq(InsProduct::getState, 1).apply("DATE(create_time) = CURDATE()")); + Long receive = insProductMapper.selectCount(Wrappers.<InsProduct>lambdaQuery() + .eq(InsProduct::getState, 1) + .between(InsProduct::getCreateTime, start, end)); + map.put("RECEVICE", receive); + //鏄ㄦ棩椤圭洰鎺ユ敹閲� + Long received = insProductMapper.selectCount(Wrappers.<InsProduct>lambdaQuery() + .eq(InsProduct::getState, 1) + .between(InsProduct::getCreateTime, oldStart, oldEnd)); + //姣斾緥=(浠婂ぉ-鏄ㄥぉ)/鏄ㄥぉ + 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) + .between(InsProduct::getCreateTime, start, end)); + map.put("FINISHE", finishe); + //鏄ㄦ棩椤圭洰瀹屾垚閲� + Long finished = insProductMapper.selectCount(Wrappers.<InsProduct>lambdaQuery() + .eq(InsProduct::getState, 1) + .isNotNull(InsProduct::getInsResult) + .between(InsProduct::getCreateTime, oldStart, oldEnd)); + //浠诲姟瀹屾垚姣斾緥=(浠婂ぉ-鏄ㄥぉ)/鏄ㄥぉ + 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) + .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); + 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 startDate = LocalDate.parse(startTime, format); + LocalDate endDate = LocalDate.parse(endTime, format); + List<String> lastTenDays = new ArrayList<>(); + List<Long> receTenDays = new ArrayList<>(); + List<Long> finTenDays = new ArrayList<>(); + 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.plusMonths(1).minusDays(1).atTime(23, 59, 59)))); + finTenDays.add(insProductMapper.selectCount(Wrappers.<InsProduct>lambdaQuery() + .eq(InsProduct::getState, 1) + .isNotNull(InsProduct::getInsResult) + .between(InsProduct::getCreateTime, startDate.atStartOfDay(), startDate.plusMonths(1).minusDays(1).atTime(23, 59, 59)))); + if (type.equals("骞�")) { + startDate = startDate.plusMonths(1); + } else { + startDate = startDate.plusDays(1); + } + } + map.put("DAYS", lastTenDays); + map.put("RECETENDAYS", receTenDays); + map.put("FINISHTENDAYS", finTenDays); + return map; } //棣栭〉-->鏃ュ巻浠诲姟鍥� @Override public Map<String, Object> calendarWorkByWeek() { + Integer userId = getLook.selectPowerByMethodAndUserId(null).get("userId"); + String name = roleMapper.selectById(userMapper.selectById(userId).getRoleId()).getName(); 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++) { - weekDays.add(currentDate.plusDays(i)); + 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 " + 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 " + j + " DAY")); + //濡傛灉褰撳墠鐧诲綍浜烘槸娴嬭瘯宸ョ▼甯堟垨鑰呮槸妫�娴嬬粍闀�,闇�瑕佽繃婊ゅ嚭妫�楠屼汉鏄粬浠殑璁㈠崟鎴栬�呮槸杩樻病妫�楠岀殑璁㈠崟 + if (name.equals("娴嬭瘯宸ョ▼甯�") || name.equals("妫�娴嬬粍闀�")) { + insOrders = insOrders.stream().filter(insOrder -> { + List<InsSample> insSamples = insSampleMapper.selectList(Wrappers.<InsSample>lambdaQuery().eq(InsSample::getInsOrderId, insOrder.getId())); + List<Integer> sampleId = insSamples.stream().map(InsSample::getId).collect(Collectors.toList()); + List<InsSampleUser> insSampleUsers = insSampleUserMapper.selectList(Wrappers.<InsSampleUser>lambdaQuery() + .in(InsSampleUser::getInsSampleId, sampleId) + .eq(InsSampleUser::getState, 0) //妫�楠屼汉 + ); + return insSampleUsers.size() == 0 || insSampleUsers.stream().map(InsSampleUser::getUserId).collect(Collectors.toList()).contains(userId); + }).collect(Collectors.toList()); + } + //濡傛灉褰撳墠鐧诲綍浜烘槸閫佹牱鍛�,闇�杩囨护鍑哄崟瀛愮殑閫佹牱鍛樻槸褰撳墠浜虹殑璁㈠崟 + else if (name.equals("閫佹牱鍛�")) { + insOrders = insOrders.stream().filter(insOrder -> + ObjectUtils.isNotEmpty(insOrder.getIssueUser()) && insOrder.getIssueUser().equals(userId) + ).collect(Collectors.toList()); + } + List<Map<String, Object>> works = insOrders.stream().map(insOrder -> { + List<InsSample> insSamples = insSampleMapper.selectList(Wrappers.<InsSample>lambdaQuery().eq(InsSample::getInsOrderId, insOrder.getId())); HashMap<String, Object> hashMap = new HashMap<>(); - hashMap.put("text","濮旀墭璁㈠崟" + insOrder.getEntrustCode() + "妫�娴�"); - hashMap.put("type",insOrder.getType()); + hashMap.put("text", insOrder.getEntrustCode()); + hashMap.put("sample", insSamples.stream().map(InsSample::getSample).collect(Collectors.joining(","))); + hashMap.put("type", insOrder.getType()); + hashMap.put("state", insOrder.getState()); 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 +378,67 @@ 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)); + } + + //棣栭〉-->鍚勭珯鐐圭殑宸ユ椂 + @Override + 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)); + 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<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); + //鏌ヨ杩欎釜鏃堕棿鍐呮墍鏈夌殑宸ユ椂 + List<AuxiliaryOutputWorkingHours> auxiliaryOutputWorkingHours = auxiliaryOutputWorkingHoursMapper.selectList(Wrappers.<AuxiliaryOutputWorkingHours>lambdaQuery() + .between(AuxiliaryOutputWorkingHours::getCreateTime, start, end)); + //鏍规嵁妫�楠岄」鏌ュ嚭鏉ョ殑绔欑偣杩涜鍒嗙被 + 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( + t -> userMapper.selectById(t.getCheck()).getName(), + Collectors.summingDouble(AuxiliaryOutputWorkingHours::getOutputWorkTime))); + return mapMap; + } + + @Override + public Map<String, IPage<InsOrderUserDto>> timeByStation(String startTime, String endTime, Page page, 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); + Map<String, IPage<InsOrderUserDto>> map = new HashMap<>(); + //鏌ヨ杩欎釜鏃堕棿鍐呮墍鏈夋楠屼换鍔� + if (ObjectUtils.isNotEmpty(sonLaboratory)) { + IPage<InsOrderUserDto> insOrderUserDtoIPage = insOrderUserMapper.selectInsOrderUserDto(start, end, sonLaboratory, page); + map.put(sonLaboratory, insOrderUserDtoIPage); + }else { + List<InsOrderState> insOrderStates = insOrderStateMapper.selectList(Wrappers.<InsOrderState>lambdaQuery() + .between(InsOrderState::getCreateTime, start, end)); + Map<String, List<InsOrderState>> listMap = insOrderStates.stream().collect(Collectors.groupingBy(InsOrderState::getLaboratory)); + for (Map.Entry<String, List<InsOrderState>> entry : listMap.entrySet()) { + List<Integer> ids = entry.getValue().stream().map(InsOrderState::getId).collect(Collectors.toList()); + IPage<InsOrderUserDto> insOrderUserDtoIPage = insOrderUserMapper.selectInsOrderUserDto2(ids, new Page(1,9)); + map.put(entry.getKey(), insOrderUserDtoIPage); + } + } + return map; } } -- Gitblit v1.9.3