From f7167562105604f1e7656983d120f145db6edd12 Mon Sep 17 00:00:00 2001
From: rk <94314517@qq.com>
Date: 星期五, 28 十一月 2025 13:42:31 +0800
Subject: [PATCH] 钥匙柜大屏
---
server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/CarUseBookServiceImpl.java | 170 +++++++++++++++++++++++++++++++++++++++++++++-----------
1 files changed, 136 insertions(+), 34 deletions(-)
diff --git a/server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/CarUseBookServiceImpl.java b/server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/CarUseBookServiceImpl.java
index b020f1f..61bc24d 100644
--- a/server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/CarUseBookServiceImpl.java
+++ b/server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/CarUseBookServiceImpl.java
@@ -5,6 +5,7 @@
import com.doumee.biz.system.SystemDictDataBiz;
import com.doumee.core.constants.ResponseStatus;
import com.doumee.core.exception.BusinessException;
+import com.doumee.dao.admin.response.InterestedListVO;
import com.doumee.dao.business.dao.UserActionMapper;
import com.doumee.service.business.third.model.LoginUserInfo;
import com.doumee.service.business.third.model.PageData;
@@ -49,6 +50,7 @@
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.Date;
+import java.util.stream.Collectors;
/**
* 杞﹁締_鐢ㄨ溅鐢宠淇℃伅琛⊿ervice瀹炵幇
@@ -625,67 +627,167 @@
//瀹℃壒閫氳繃锛屼絾鏄� 宸插埌鍙戣溅鏃堕棿锛屼笉鍙互鎾ら攢
return Constants.ZERO;
}
- if((Constants.equalsInteger(carUseBook.getStatus(),Constants.ZERO))
- ||Constants.equalsInteger(carUseBook.getStatus(),Constants.ONE)
- ||Constants.equalsInteger(carUseBook.getStatus(),Constants.TWO)){
- //瀹℃壒浜哄彲浠ユ挙閿� 鑷繁瀹℃壒鐨勭敵璇疯褰�
- Approve approve = approveJoinMapper.selectOne(new QueryWrapper<Approve>().lambda()
- .eq(Approve::getIsdeleted,Constants.ZERO)
- .ge(Approve::getLevel,Constants.ZERO)
- .eq(Approve::getChekorId,loginUserInfo.getMemberId())
- .eq(Approve::getObjId,carUseBook.getId())
- .eq(Approve::getObjType,carUseBook.getType()==0?3:4)
- .last("limit 1"));
- if(approve!=null){
- return Constants.ONE;
- }
- }
+// if((Constants.equalsInteger(carUseBook.getStatus(),Constants.ZERO))
+// ||Constants.equalsInteger(carUseBook.getStatus(),Constants.ONE)
+// ||Constants.equalsInteger(carUseBook.getStatus(),Constants.TWO)){
+// //瀹℃壒浜哄彲浠ユ挙閿� 鑷繁瀹℃壒鐨勭敵璇疯褰�
+// Approve approve = approveJoinMapper.selectOne(new QueryWrapper<Approve>().lambda()
+// .eq(Approve::getIsdeleted,Constants.ZERO)
+// .ge(Approve::getLevel,Constants.ZERO)
+// .eq(Approve::getChekorId,loginUserInfo.getMemberId())
+// .eq(Approve::getObjId,carUseBook.getId())
+// .eq(Approve::getObjType,carUseBook.getType()==0?3:4)
+// .last("limit 1"));
+// if(approve!=null){
+// return Constants.ONE;
+// }
+// }
return Constants.ZERO;
}
+ @Override
public void jdyPushCarUseBook(String dataInfo){
JSONObject dataInfoJSON = JSONObject.parseObject(dataInfo);
if(dataInfoJSON.isEmpty()){
return;
}
- JSONObject dataJSON = dataInfoJSON.getJSONObject("data");
- String id = dataJSON.getString("_id");
- if(StringUtils.isEmpty(id)){
+ String op = dataInfoJSON.getString("op");
+ //鍒犻櫎锛歞ata_remove 鏂板锛歞ata_add 淇敼锛歞ata_update
+ if(StringUtils.isEmpty(op)){
return;
}
+ if(op.equals("data_test")){
+ return;
+ }
+ JSONObject dataJSON = dataInfoJSON.getJSONObject("data");
+ String id = dataJSON.getString("_id");
+ if(op.equals("data_remove")){
+ carUseBookJoinMapper.update(new UpdateWrapper<CarUseBook>().lambda()
+ .set(CarUseBook::getEditDate,DateUtil.getCurrDateTime())
+ .set(CarUseBook::getIsdeleted,Constants.ONE).eq(CarUseBook::getJdyId,id));
+ return;
+ }
+ String no = dataJSON.getString("no");
+ if(StringUtils.isEmpty(no)){
+ return;
+ }
+ Integer status = dataJSON.getInteger("flowState");
+ if(Objects.isNull(status)||!(Constants.equalsInteger(status,Constants.ONE)||Constants.equalsInteger(status,Constants.TWO))){
+ return;
+ }
+
String carCode = dataJSON.getString("car_no");
String startDate = dataJSON.getString("start_date");
String endDate = dataJSON.getString("end_date");
- Integer status = dataJSON.getInteger("flowState");
String typeInfo = dataJSON.getString("scope");
String reason = dataJSON.getString("reason");
String addr = dataJSON.getString("addr");
- JSONArray usersArray = dataJSON.getJSONArray("users");
- JSONObject driverJSON = dataJSON.getJSONObject("driver");
- if(!(Constants.equalsInteger(status,Constants.ONE)||Constants.equalsInteger(status,Constants.TWO))){
-
- }
CarUseBook carUseBook = carUseBookJoinMapper.selectOne(new QueryWrapper<CarUseBook>()
- .lambda().eq(CarUseBook::getJdyId,id).last("limit 1"));
+ .lambda().eq(CarUseBook::getJdyId,no).last("limit 1"));
if(Objects.isNull(carUseBook)){
carUseBook = new CarUseBook();
carUseBook.setCreateDate(new Date());
- carUseBook.setCarCode(carCode);
- carUseBook.setCarId(null);
- carUseBook.setStartTime(DateUtil.fromStringToDate("yyyy-MM-dd HH:mm:ss",DateUtil.getDateStrOfUTCStr(startDate)));
- carUseBook.setEndTime(DateUtil.fromStringToDate("yyyy-MM-dd HH:mm:ss",DateUtil.getDateStrOfUTCStr(endDate)));
-
-
+ carUseBook.setEditDate(new Date());
+ carUseBook.setJdyNo(no);
+ carUseBook.setJdyId(id);
}else{
-
+ carUseBook.setEditDate(new Date());
+ }
+ carUseBook.setIsdeleted(Constants.equalsInteger(status,Constants.ONE)?Constants.ZERO:Constants.ONE);
+ carUseBook.setCarCode(StringUtils.isBlank(carCode)?null:carCode);
+ if(StringUtils.isNotBlank(carCode)){
+ Cars cars = carsMapper.selectOne(new QueryWrapper<Cars>().lambda()
+ .eq(Cars::getIsdeleted,Constants.ZERO)
+ .eq(Cars::getCode,carCode).last("limit 1"));
+ carUseBook.setCarId(Objects.nonNull(cars)?cars.getId():null);
}
+ carUseBook.setStartTime(StringUtils.isBlank(startDate)?null:DateUtil.getXMinuteAfterDate(DateUtil.getISO8601DateByStr(startDate),480));
+ carUseBook.setEndTime(StringUtils.isBlank(endDate)?null:DateUtil.getXMinuteAfterDate(DateUtil.getISO8601DateByStr(endDate),480));
+ carUseBook.setTypeInfo(StringUtils.isBlank(typeInfo)?null:typeInfo);
+ carUseBook.setContent(StringUtils.isBlank(reason)?null:reason);
+ carUseBook.setAddr(StringUtils.isBlank(addr)?null:addr);
+ carUseBook.setStatus(Constants.TWO);
+ JSONObject driverJSON = dataJSON.getJSONObject("driver");
+ if(Objects.nonNull(driverJSON)){
+ String driverName = driverJSON.getString("name");
+ String driverUserName = driverJSON.getString("username");
+ if(StringUtils.isNotBlank(driverUserName)){
+ Member driverMember = memberMapper.selectOne(new QueryWrapper<Member>().lambda().eq(Member::getIsdeleted,Constants.ZERO).eq(Member::getDdId,driverUserName).last("limit 1 "));
+ if(Objects.nonNull(driverMember)){
+ carUseBook.setDriverId(driverMember.getId());
+ }
+ }
+ }
+ JSONObject createJSON = dataJSON.getJSONObject("creator");
+ if(Objects.nonNull(createJSON)){
+ String createName = createJSON.getString("name");
+ String createUserName = createJSON.getString("username");
+ if(StringUtils.isNotBlank(createUserName)){
+ Member createMember = memberMapper.selectOne(new QueryWrapper<Member>().lambda().eq(Member::getIsdeleted,Constants.ZERO).eq(Member::getDdId,createUserName).last("limit 1 "));
+ if(Objects.nonNull(createMember)){
+ carUseBook.setMemberId(createMember.getId());
+ }
+ }
+ }
-
-
+ JSONArray usersArray = dataJSON.getJSONArray("users");
+ if(Objects.nonNull(usersArray)){
+ String names = "";
+ List<String> userDDIdList = new ArrayList<>();
+ for (int i = 0; i < usersArray.size(); i++) {
+ JSONObject userJSON = usersArray.getJSONObject(i);
+ String name = userJSON.getString("name");
+ String userName = userJSON.getString("username");
+ userDDIdList.add(userName);
+ names = names +
+ (StringUtils.isNotBlank(names)?",":"")
+ + name;
+ }
+ if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(userDDIdList)){
+ List<Member> memberList = memberMapper.selectList(new QueryWrapper<Member>().lambda().eq(Member::getIsdeleted,Constants.ZERO).in(Member::getDdId,userDDIdList));
+ if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(memberList)){
+ names = String.join(",",memberList.stream().map(i->i.getName()).collect(Collectors.toList()));
+ carUseBook.setMemberIds(String.join(",",memberList.stream().map(i->i.getId().toString()).collect(Collectors.toList())));
+ }
+ }
+ carUseBook.setMemberNames(names);
+ }
+ carUseBookMapper.insertOrUpdate(carUseBook);
}
+
+
+
+
+ @Override
+ public List<InterestedListVO> getCarUseStatistics(Integer type){
+ List<String> weekDays = DateUtil.getBeforDaysByFormat(new Date(),Objects.isNull(type)||Constants.equalsInteger(type,Constants.ZERO)?7:15,"MM-dd");
+ MPJLambdaWrapper<CarUseBook> wrapper = new MPJLambdaWrapper<CarUseBook>()
+ .selectAll(CarUseBook.class)
+ .eq(CarUseBook::getIsdeleted, Constants.ZERO)
+ .eq(CarUseBook::getStatus,Constants.TWO)
+ .apply(" CREATE_DATE > CURDATE() - INTERVAL "+(Objects.isNull(type)||Constants.equalsInteger(type,Constants.ZERO)?7:15)+" DAY ")
+ .orderByDesc(CarUseBook::getCreateDate);
+ List<CarUseBook> carUseBookList = carUseBookMapper.selectJoinList(CarUseBook.class,wrapper);
+ List<InterestedListVO> list = new ArrayList<>();
+ for (String days:weekDays) {
+ InterestedListVO vo = new InterestedListVO();
+ vo.setName(days);
+ vo.setNum(Constants.ZERO);
+ vo.setNextNum(Constants.ZERO);
+ if (com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(carUseBookList)) {
+ vo.setNum(
+ carUseBookList.stream().filter(i->DateUtil.dateToString(i.getCreateDate(),"MM-dd").equals(days))
+ .collect(Collectors.toList()).size()
+ );
+ }
+ list.add(vo);
+ }
+ return list;
+ }
+
}
--
Gitblit v1.9.3