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 |   97 +++++++++++++++++++++++++++++++++---------------
 1 files changed, 67 insertions(+), 30 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 b81ac6f..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;
@@ -626,21 +627,21 @@
             //瀹℃壒閫氳繃锛屼絾鏄� 宸插埌鍙戣溅鏃堕棿锛屼笉鍙互鎾ら攢
             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;
     }
 
@@ -656,16 +657,19 @@
         if(StringUtils.isEmpty(op)){
             return;
         }
-
-        JSONObject dataJSON = dataInfoJSON.getJSONObject("data");
-        String no = dataJSON.getString("no");
-        if(StringUtils.isEmpty(no)){
+        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,no));
+                    .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");
@@ -686,7 +690,8 @@
             carUseBook = new CarUseBook();
             carUseBook.setCreateDate(new Date());
             carUseBook.setEditDate(new Date());
-            carUseBook.setJdyId(no);
+            carUseBook.setJdyNo(no);
+            carUseBook.setJdyId(id);
         }else{
             carUseBook.setEditDate(new Date());
         }
@@ -698,14 +703,15 @@
                     .eq(Cars::getCode,carCode).last("limit 1"));
             carUseBook.setCarId(Objects.nonNull(cars)?cars.getId():null);
         }
-        carUseBook.setStartTime(StringUtils.isBlank(startDate)?null:DateUtil.getISO8601DateByStr(startDate));
-        carUseBook.setEndTime(StringUtils.isBlank(endDate)?null:DateUtil.getISO8601DateByStr(endDate));
+
+        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(typeInfo)?null:reason);
-        carUseBook.setAddr(StringUtils.isBlank(typeInfo)?null:addr);
+        carUseBook.setContent(StringUtils.isBlank(reason)?null:reason);
+        carUseBook.setAddr(StringUtils.isBlank(addr)?null:addr);
         carUseBook.setStatus(Constants.TWO);
         JSONObject driverJSON = dataJSON.getJSONObject("driver");
-        if(!driverJSON.isEmpty()){
+        if(Objects.nonNull(driverJSON)){
             String driverName = driverJSON.getString("name");
             String driverUserName = driverJSON.getString("username");
             if(StringUtils.isNotBlank(driverUserName)){
@@ -716,7 +722,7 @@
             }
         }
         JSONObject createJSON = dataJSON.getJSONObject("creator");
-        if(!driverJSON.isEmpty()){
+        if(Objects.nonNull(createJSON)){
             String createName = createJSON.getString("name");
             String createUserName = createJSON.getString("username");
             if(StringUtils.isNotBlank(createUserName)){
@@ -728,13 +734,13 @@
         }
 
         JSONArray usersArray =   dataJSON.getJSONArray("users");
-        if(!usersArray.isEmpty()){
+        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 = createJSON.getString("name");
-                String userName = createJSON.getString("username");
+                String name = userJSON.getString("name");
+                String userName = userJSON.getString("username");
                 userDDIdList.add(userName);
                 names = names +
                         (StringUtils.isNotBlank(names)?",":"")
@@ -751,6 +757,37 @@
         }
         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