From 00952e11d9c2f7be5277a4d752cd5dd0796301cd Mon Sep 17 00:00:00 2001
From: zss <zss@example.com>
Date: 星期四, 18 四月 2024 17:57:39 +0800
Subject: [PATCH] 资质明细修改+检测项目统计
---
cnas-server/src/main/java/com/yuanchu/mom/service/CertificationService.java | 3 -
cnas-server/src/main/java/com/yuanchu/mom/controller/CertificationController.java | 10 +--
cnas-server/src/main/resources/mapper/CertificationMapper.xml | 5 +
cnas-server/src/main/java/com/yuanchu/mom/service/impl/CertificationServiceImpl.java | 8 --
cnas-server/src/main/java/com/yuanchu/mom/pojo/Certification.java | 5 +
inspect-server/src/main/java/com/yuanchu/mom/service/impl/ReportServiceImpl.java | 94 +++++++++++++++++++++++-------
6 files changed, 82 insertions(+), 43 deletions(-)
diff --git a/cnas-server/src/main/java/com/yuanchu/mom/controller/CertificationController.java b/cnas-server/src/main/java/com/yuanchu/mom/controller/CertificationController.java
index e994f2c..0cb47fe 100644
--- a/cnas-server/src/main/java/com/yuanchu/mom/controller/CertificationController.java
+++ b/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));
}
}
diff --git a/cnas-server/src/main/java/com/yuanchu/mom/pojo/Certification.java b/cnas-server/src/main/java/com/yuanchu/mom/pojo/Certification.java
index cf9bedd..cad004f 100644
--- a/cnas-server/src/main/java/com/yuanchu/mom/pojo/Certification.java
+++ b/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 = "鍒涘缓浜�")
diff --git a/cnas-server/src/main/java/com/yuanchu/mom/service/CertificationService.java b/cnas-server/src/main/java/com/yuanchu/mom/service/CertificationService.java
index c908326..826758e 100644
--- a/cnas-server/src/main/java/com/yuanchu/mom/service/CertificationService.java
+++ b/cnas-server/src/main/java/com/yuanchu/mom/service/CertificationService.java
@@ -16,7 +16,4 @@
//鍒犻櫎璧勮川鏄庣粏鍒楄〃
int delCertificationDetail(List<Integer> ids);
-
- //闄勪欢涓嬭浇
- String downFile(Integer id);
}
diff --git a/cnas-server/src/main/java/com/yuanchu/mom/service/impl/CertificationServiceImpl.java b/cnas-server/src/main/java/com/yuanchu/mom/service/impl/CertificationServiceImpl.java
index 7c74ac1..8336cb3 100644
--- a/cnas-server/src/main/java/com/yuanchu/mom/service/impl/CertificationServiceImpl.java
+++ b/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();
- }
}
diff --git a/cnas-server/src/main/resources/mapper/CertificationMapper.xml b/cnas-server/src/main/resources/mapper/CertificationMapper.xml
index 55ae44b..2a355de 100644
--- a/cnas-server/src/main/resources/mapper/CertificationMapper.xml
+++ b/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
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..e90142f 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
@@ -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));
}
}
--
Gitblit v1.9.3