From 9894da46a0f6f6f15c531aa3506eba9fc6fe5eb9 Mon Sep 17 00:00:00 2001
From: rk <94314517@qq.com>
Date: 星期五, 19 十二月 2025 07:36:51 +0800
Subject: [PATCH] 功能优化
---
server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/InoutRecordServiceImpl.java | 85 ++++++++++++++++++++++++++++++------------
1 files changed, 61 insertions(+), 24 deletions(-)
diff --git a/server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/InoutRecordServiceImpl.java b/server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/InoutRecordServiceImpl.java
index 1f668c0..dd19231 100644
--- a/server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/InoutRecordServiceImpl.java
+++ b/server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/InoutRecordServiceImpl.java
@@ -24,7 +24,7 @@
import com.github.yulichang.wrapper.MPJLambdaWrapper;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.models.auth.In;
-import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang3.StringUtils;
import org.checkerframework.checker.units.qual.C;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@@ -122,8 +122,8 @@
queryWrapper.selectAll(InoutRecord.class)
.eq(InoutRecord::getIsdeleted,Constants.ZERO)
// .eq(Objects.nonNull(model.getType()),InoutRecord::getType, model.getType())
- .isNotNull(Objects.nonNull(model.getType())&&Constants.equalsInteger(model.getType(),Constants.ZERO),model.getCarCode())
- .isNotNull(Objects.nonNull(model.getType())&&Constants.equalsInteger(model.getType(),Constants.ONE),model.getMemberPhone())
+ .isNotNull(Objects.nonNull(model.getType())&&Constants.equalsInteger(model.getType(),Constants.ZERO),InoutRecord::getCarCode)
+ .isNotNull(Objects.nonNull(model.getType())&&Constants.equalsInteger(model.getType(),Constants.ONE),InoutRecord::getMemberPhone)
.eq(Objects.nonNull(model.getInOrOut()),InoutRecord::getInOrOut, model.getInOrOut())
.eq(Objects.nonNull(model.getObjType()),InoutRecord::getObjType, model.getObjType())
.eq(Objects.nonNull(model.getCarBizType()),InoutRecord::getCarBizType, model.getCarBizType())
@@ -155,7 +155,7 @@
//浜哄憳鍒嗙被 鍗曠嫭澶勭悊浜哄憳鏁版嵁 0鍔冲姟璁垮 1鏅�氳瀹� 2鍐呴儴鍛樺伐 3杞﹁締淇℃伅 4鐩稿叧鏂逛汉鍛� 5璐ц繍鍙告満
- private static String[] userTypeList = new String[]{"","鏅�氳瀹�","鍐呴儴浜哄憳","","鐩稿叧鏂逛汉鍛�","璐ц繍鍙告満"};
+ private static String[] userTypeList = new String[]{"","鏅�氳瀹�","鍐呴儴浜哄憳","","鐩稿叧鏂逛汉鍛�"};
/**
@@ -172,8 +172,11 @@
){
throw new BusinessException(ResponseStatus.BAD_REQUEST);
}
- //鏌ヨ鏈懆鐨勫紑濮嬫棩鏈熷拰缁撴潫鏃ユ湡
- Long weekStart = LocalDate.now().with(TemporalAdjusters.previousOrSame(DayOfWeek.MONDAY)).atStartOfDay(ZoneOffset.UTC).toInstant().toEpochMilli();
+ //鏌ヨ鏈懆鐨勫紑濮嬫棩鏈�
+ LocalDate today = LocalDate.now();
+ // 璁$畻鍛ㄤ竴鍜屽懆浜旂殑鏃ユ湡
+ LocalDate monday = today.with(DayOfWeek.MONDAY);
+ Long weekStart = DateUtil.fromStringToDate("yyyy-MM-dd HH:mm:ss",monday.toString() + " 00:00:00").getTime();//LocalDate.now().with(TemporalAdjusters.previousOrSame(DayOfWeek.MONDAY)).atStartOfDay(ZoneOffset.UTC).toInstant().toEpochMilli();
InParkUserDataVO inParkUserDataVO = new InParkUserDataVO();
List<InoutRecord> yearList = inoutRecordMapper.selectJoinList(InoutRecord.class,new MPJLambdaWrapper<InoutRecord>()
.selectAll(InoutRecord.class)
@@ -310,7 +313,7 @@
for (String categoryName:setList) {
GeneralDataVO generalDataVO = new GeneralDataVO();
generalDataVO.setName(categoryName);
- generalDataVO.setTotal(yearList.stream().filter(j->StringUtils.isNotBlank(j.getCategoryParentName())&&j.getCategoryName().equals(categoryName)).collect(Collectors.toList()).size());
+ generalDataVO.setTotal(yearList.stream().filter(j->StringUtils.isNotBlank(j.getCategoryParentName())&&j.getCategoryParentName().equals(categoryName)).collect(Collectors.toList()).size());
generalDataVO.setRata(new BigDecimal(generalDataVO.getTotal().toString()).divide(new BigDecimal(yearList.size()+""),2,BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal("100")));
rataList.add(generalDataVO);
}
@@ -331,21 +334,59 @@
){
throw new BusinessException(ResponseStatus.BAD_REQUEST);
}
- List<InoutRecord> allList = inoutRecordMapper.selectJoinList(InoutRecord.class,new MPJLambdaWrapper<InoutRecord>()
- .selectAll(InoutRecord.class)
- .eq(InoutRecord::getIsdeleted,Constants.ZERO)
+ List<InoutRecord> allList = new ArrayList<>();
+ MPJLambdaWrapper mpjLambdaWrapper = new MPJLambdaWrapper<InoutRecord>().eq(InoutRecord::getIsdeleted,Constants.ZERO)
.eq(InoutRecord::getInOrOut,Constants.ZERO)
.isNotNull(Constants.equalsInteger(inParkDataDTO.getType(),Constants.ZERO),InoutRecord::getCarCode)
.isNotNull(Constants.equalsInteger(inParkDataDTO.getType(),Constants.ONE),InoutRecord::getMemberPhone)
.apply(Constants.equalsInteger(inParkDataDTO.getDateStr().length(),4)," ( DATE_FORMAT(CREATE_DATE, '%Y') = '"+inParkDataDTO.getDateStr()+"' ) ")
- .apply(Constants.equalsInteger(inParkDataDTO.getDateStr().length(),7)," ( DATE_FORMAT(CREATE_DATE, '%Y-%m') = '"+inParkDataDTO.getDateStr()+"' ) ")
- );
+ .apply(Constants.equalsInteger(inParkDataDTO.getDateStr().length(),7)," ( DATE_FORMAT(CREATE_DATE, '%Y-%m') = '"+inParkDataDTO.getDateStr()+"' ) ");
+ if(Constants.equalsInteger(inParkDataDTO.getIsGroupBy(),Constants.ONE)){
+ mpjLambdaWrapper.groupBy(Constants.equalsInteger(inParkDataDTO.getDateStr().length(),4)&&Constants.equalsInteger(inParkDataDTO.getType(),Constants.ZERO),
+ "car_code,category_name,DATE_FORMAT(CREATE_DATE, '%Y-%m')")
+ .groupBy(Constants.equalsInteger(inParkDataDTO.getDateStr().length(),7)&&Constants.equalsInteger(inParkDataDTO.getType(),Constants.ZERO),
+ "car_code,category_name,DATE_FORMAT(CREATE_DATE, '%Y-%m-%d')")
+ .groupBy(Constants.equalsInteger(inParkDataDTO.getDateStr().length(),4)&&Constants.equalsInteger(inParkDataDTO.getType(),Constants.ONE),
+ "member_phone,MEMBER_TYPE,DATE_FORMAT(CREATE_DATE, '%Y-%m')")
+ .groupBy(Constants.equalsInteger(inParkDataDTO.getDateStr().length(),7)&&Constants.equalsInteger(inParkDataDTO.getType(),Constants.ONE),
+ "member_phone,MEMBER_TYPE,DATE_FORMAT(CREATE_DATE, '%Y-%m-%d')");
+ if(Constants.equalsInteger(inParkDataDTO.getDateStr().length(),4)&&Constants.equalsInteger(inParkDataDTO.getType(),Constants.ZERO)){
+ mpjLambdaWrapper.select("car_code,category_name,DATE_FORMAT(CREATE_DATE, '%Y-%m') as createDateStr ");
+ }else if(Constants.equalsInteger(inParkDataDTO.getDateStr().length(),7)&&Constants.equalsInteger(inParkDataDTO.getType(),Constants.ZERO)){
+ mpjLambdaWrapper.select("car_code,category_name,DATE_FORMAT(CREATE_DATE, '%Y-%m-%d') as createDateStr ");
+ }else if(Constants.equalsInteger(inParkDataDTO.getDateStr().length(),4)&&Constants.equalsInteger(inParkDataDTO.getType(),Constants.ONE)){
+ mpjLambdaWrapper.select("member_phone,MEMBER_TYPE,DATE_FORMAT(CREATE_DATE, '%Y-%m') as createDateStr");
+ }else{
+ mpjLambdaWrapper.select("member_phone,MEMBER_TYPE,DATE_FORMAT(CREATE_DATE, '%Y-%m-%d') as createDateStr ");
+ }
+
+ }else{
+ mpjLambdaWrapper.selectAll(InoutRecord.class);
+ if(Constants.equalsInteger(inParkDataDTO.getDateStr().length(),4)&&Constants.equalsInteger(inParkDataDTO.getType(),Constants.ZERO)){
+ mpjLambdaWrapper.select("DATE_FORMAT(CREATE_DATE, '%Y-%m') as createDateStr ");
+ }else if(Constants.equalsInteger(inParkDataDTO.getDateStr().length(),7)&&Constants.equalsInteger(inParkDataDTO.getType(),Constants.ZERO)){
+ mpjLambdaWrapper.select("DATE_FORMAT(CREATE_DATE, '%Y-%m-%d') as createDateStr ");
+ }else if(Constants.equalsInteger(inParkDataDTO.getDateStr().length(),4)&&Constants.equalsInteger(inParkDataDTO.getType(),Constants.ONE)){
+
+ mpjLambdaWrapper.select("DATE_FORMAT(CREATE_DATE, '%Y-%m') as createDateStr");
+ }else{
+ mpjLambdaWrapper.select("DATE_FORMAT(CREATE_DATE, '%Y-%m-%d') as createDateStr ");
+ }
+// allList = inoutRecordMapper.selectJoinList(InoutRecord.class,new MPJLambdaWrapper<InoutRecord>()
+// .selectAll(InoutRecord.class)
+// .eq(InoutRecord::getIsdeleted,Constants.ZERO)
+// .eq(InoutRecord::getInOrOut,Constants.ZERO)
+// .isNotNull(Constants.equalsInteger(inParkDataDTO.getType(),Constants.ZERO),InoutRecord::getCarCode)
+// .isNotNull(Constants.equalsInteger(inParkDataDTO.getType(),Constants.ONE),InoutRecord::getMemberPhone)
+// .apply(Constants.equalsInteger(inParkDataDTO.getDateStr().length(),4)," ( DATE_FORMAT(CREATE_DATE, '%Y') = '"+inParkDataDTO.getDateStr()+"' ) ")
+// .apply(Constants.equalsInteger(inParkDataDTO.getDateStr().length(),7)," ( DATE_FORMAT(CREATE_DATE, '%Y-%m') = '"+inParkDataDTO.getDateStr()+"' ) ")
+// );
+ }
+ allList = inoutRecordMapper.selectJoinList(InoutRecord.class,mpjLambdaWrapper);
+
List<List<String>> resultList = new ArrayList<>();
if(CollectionUtils.isEmpty(allList)){
return resultList;
- }
- if(Constants.equalsInteger(inParkDataDTO.getIsGroupBy(),Constants.ONE)){
- allList = this.getListByType(allList,inParkDataDTO.getType());
}
List<String> dateList = new ArrayList<>();
@@ -384,7 +425,7 @@
public List<List<String>> dealResultData(List<InoutRecord> allList,List<String> dataList ,Integer type,String dateStr){
List<List<String>> resultList = new ArrayList<>();
List<String> totalString = new ArrayList<>();
- totalString.add("鏃ユ湡");
+ totalString.add("鏁版嵁鏃ユ湡");
if(Constants.equalsInteger(type,Constants.ZERO)){
List<String> categoryNameList = allList.stream().filter(j-> StringUtils.isNotBlank(j.getCategoryName())).map(j->j.getCategoryName()).collect(Collectors.toList());
if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isEmpty(categoryNameList)){
@@ -403,14 +444,14 @@
for (String categoryName:setList) {
if(Constants.equalsInteger(dateStr.length(),4)){
Integer childNum = allList.stream().filter(i->categoryName.equals(i.getCategoryName())
- && DateUtil.formatDate(i.getCreateDate(),"yyyy-MM").equals(str)).collect(Collectors.toList()).size();
+ && i.getCreateDateStr().equals(str)).collect(Collectors.toList()).size();
dataChildList.add(
Integer.toString(childNum)
);
total = total + childNum;
}else if(Constants.equalsInteger(dateStr.length(),7)){
Integer childNum = allList.stream().filter(i->categoryName.equals(i.getCategoryName())
- &&DateUtil.formatDate(i.getCreateDate(),"yyyy-MM-dd").equals(str)).collect(Collectors.toList()).size();
+ &&i.getCreateDateStr().equals(str)).collect(Collectors.toList()).size();
dataChildList.add(
Integer.toString(childNum)
);
@@ -441,14 +482,14 @@
int finalI = i;
if(Constants.equalsInteger(dateStr.length(),4)){
Integer childNum = allList.stream().filter(j->Constants.equalsInteger(j.getMemberType(), finalI)
- && DateUtil.formatDate(j.getCreateDate(),"yyyy-MM").equals(str)).collect(Collectors.toList()).size();
+ && j.getCreateDateStr().equals(str)).collect(Collectors.toList()).size();
dataChildList.add(
Integer.toString(childNum)
);
total = total + childNum;
}else if(Constants.equalsInteger(dateStr.length(),7)){
Integer childNum = allList.stream().filter(j->Constants.equalsInteger(j.getMemberType(), finalI)
- &&DateUtil.formatDate(j.getCreateDate(),"yyyy-MM-dd").equals(str)).collect(Collectors.toList()).size();
+ &&j.getCreateDateStr().equals(str)).collect(Collectors.toList()).size();
dataChildList.add(
Integer.toString(childNum)
);
@@ -461,10 +502,6 @@
}
return resultList;
}
-
-
-
-
public List<InoutRecord> getListByType(List<InoutRecord> list,Integer type){
--
Gitblit v1.9.3