From d674b880e7b20d42727ed7b63aa3e2a3fd7dd9c0 Mon Sep 17 00:00:00 2001 From: mashuai Date: Thu, 28 Nov 2024 15:53:12 +0800 Subject: [PATCH] =?UTF-8?q?=E7=A7=9F=E8=B5=81=E9=9C=80=E6=B1=82=E5=A4=A7?= =?UTF-8?q?=E5=8E=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../book/service/impl/BookCarServiceImpl.java | 7 ++- .../device/controller/DevInfoController.java | 6 +-- .../material/device/domain/vo/LeaseVo.java | 12 +++-- .../material/device/mapper/DevInfoMapper.java | 10 ++++- .../device/service/DevInfoService.java | 2 +- .../service/impl/DevInfoServiceImpl.java | 22 ++++++++-- .../service/impl/MaLeaseInfoServiceImpl.java | 21 ++++++++- .../mapper/material/device/DevInfoMapper.xml | 44 ++++++++++++++++--- .../material/lease/MaLeaseInfoMapper.xml | 37 +++++----------- 9 files changed, 112 insertions(+), 49 deletions(-) diff --git a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/book/service/impl/BookCarServiceImpl.java b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/book/service/impl/BookCarServiceImpl.java index 615ba89..e70e84a 100644 --- a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/book/service/impl/BookCarServiceImpl.java +++ b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/book/service/impl/BookCarServiceImpl.java @@ -67,8 +67,11 @@ public class BookCarServiceImpl implements BookCarService { BmFileInfo bmFileInfo = new BmFileInfo(); bmFileInfo.setModelId(bookCarDetail.getMaId()); bmFileInfo.setTaskType(MaterialConstants.MATERIAL_FILE_TYPE_CODE); - List fileList = bmFileInfoMapper.selectBmFileInfoList(bmFileInfo); - bookCarDetail.setBmFileInfoList(fileList); + bmFileInfo.setFileType(0L); + List mainFileInfoList = bmFileInfoMapper.selectBmFileInfoList(bmFileInfo); + if (!CollectionUtils.isEmpty(mainFileInfoList)) { + bookCarDetail.setPicUrl(mainFileInfoList.get(0).getFileUrl()); + } } // 根据 companyName, person, personPhone 进行分组 Map> groupedByKey = bookCarDetails.stream() diff --git a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/device/controller/DevInfoController.java b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/device/controller/DevInfoController.java index 46bfe64..8e95df7 100644 --- a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/device/controller/DevInfoController.java +++ b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/device/controller/DevInfoController.java @@ -88,10 +88,8 @@ public class DevInfoController extends BaseController { // @RequiresPermissions("equip:info:list") @ApiOperation(value = "装备推荐列表") @GetMapping("/hotList") - public TableDataInfo hotList(DevInfoVo devInfo) { - startPage(); - List list = devInfoService.selectDevInfoHotList(devInfo); - return getDataTable(list); + public AjaxResult hotList(DevInfoVo devInfo) { + return devInfoService.selectDevInfoHotList(devInfo); } /** diff --git a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/device/domain/vo/LeaseVo.java b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/device/domain/vo/LeaseVo.java index ae025c0..df3416a 100644 --- a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/device/domain/vo/LeaseVo.java +++ b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/device/domain/vo/LeaseVo.java @@ -1,10 +1,14 @@ package com.bonus.material.device.domain.vo; +import com.fasterxml.jackson.annotation.JsonFormat; import io.swagger.annotations.ApiModelProperty; import lombok.AllArgsConstructor; import lombok.Data; import lombok.NoArgsConstructor; +import java.math.BigDecimal; +import java.util.Date; + /** * 出租方信息vo * @Author ma_sh @@ -28,11 +32,13 @@ public class LeaseVo { private String leaseName; @ApiModelProperty("租赁开始时间") - private String leaseStartTime; + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private Date leaseStartTime; @ApiModelProperty("租赁结束时间") - private String leaseEndTime; + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private Date leaseEndTime; @ApiModelProperty("租赁费用") - private String leasePrice; + private BigDecimal leasePrice; } diff --git a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/device/mapper/DevInfoMapper.java b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/device/mapper/DevInfoMapper.java index 19a202e..64d2961 100644 --- a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/device/mapper/DevInfoMapper.java +++ b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/device/mapper/DevInfoMapper.java @@ -6,6 +6,7 @@ import com.bonus.material.book.domain.BookCarInfoDto; import com.bonus.material.device.domain.DevInfo; import com.bonus.material.device.domain.dto.InfoMotionDto; import com.bonus.material.device.domain.vo.DevInfoVo; +import com.bonus.material.device.domain.vo.LeaseVo; import org.apache.ibatis.annotations.Param; import java.util.List; @@ -52,7 +53,7 @@ public interface DevInfoMapper { * @param companyId * @return */ - int getCompanyUpNum(String companyId); + DevInfoVo getCompanyUpNum(String companyId); /** * 查询设备信息列表 @@ -145,5 +146,12 @@ public interface DevInfoMapper { * @return */ int selectCompany(String companyId); + + /** + * 查询该设备的出租记录 + * @param maId + * @return + */ + List getLeaseList(Long maId); } diff --git a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/device/service/DevInfoService.java b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/device/service/DevInfoService.java index a5891cf..e5c71c3 100644 --- a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/device/service/DevInfoService.java +++ b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/device/service/DevInfoService.java @@ -34,7 +34,7 @@ public interface DevInfoService { List selectUserCollectList(DevInfoVo devInfo); - List selectDevInfoHotList(DevInfoVo devInfo); + AjaxResult selectDevInfoHotList(DevInfoVo devInfo); /** * 修改设备信息 diff --git a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/device/service/impl/DevInfoServiceImpl.java b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/device/service/impl/DevInfoServiceImpl.java index 3fd631f..28843b5 100644 --- a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/device/service/impl/DevInfoServiceImpl.java +++ b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/device/service/impl/DevInfoServiceImpl.java @@ -13,6 +13,7 @@ import com.bonus.material.book.domain.BookCarInfoDto; import com.bonus.material.device.domain.DevInfo; import com.bonus.material.device.domain.dto.InfoMotionDto; import com.bonus.material.device.domain.vo.DevInfoVo; +import com.bonus.material.device.domain.vo.LeaseVo; import com.bonus.material.device.mapper.BmFileInfoMapper; import com.bonus.material.device.mapper.DevInfoMapper; import com.bonus.material.device.service.DevInfoService; @@ -96,8 +97,9 @@ public class DevInfoServiceImpl implements DevInfoService { //根据设备id查询所属公司上架装备数以及公司访问量 if (StringUtils.isNotBlank(devInfoVo.getCompanyId())) { int devNum = devInfoMapper.selectCompany(devInfoVo.getCompanyId()); - int companyVisitNum = devInfoMapper.getCompanyUpNum(devInfoVo.getCompanyId()); - devInfoVo.setCompanyVisitNum(companyVisitNum); + DevInfoVo infoVo = devInfoMapper.getCompanyUpNum(devInfoVo.getCompanyId()); + devInfoVo.setCompanyVisitNum(infoVo.getCompanyVisitNum()); + devInfoVo.setCompanyCreateTime(infoVo.getCompanyCreateTime()); devInfoVo.setDevUapNum(devNum); } //根据设备id及用户id去预约表中查询是否已经加入预约车 @@ -107,6 +109,11 @@ public class DevInfoServiceImpl implements DevInfoService { } else { devInfoVo.setIsBookCar(1); } + //查询该设备的出租记录 + List leaseList = devInfoMapper.getLeaseList(maId); + if (!CollectionUtils.isEmpty(leaseList)) { + devInfoVo.setLeaseList(leaseList); + } } return devInfoVo; } @@ -170,10 +177,17 @@ public class DevInfoServiceImpl implements DevInfoService { @Override - public List selectDevInfoHotList(DevInfoVo devInfo) { + public AjaxResult selectDevInfoHotList(DevInfoVo devInfo) { List hotList = devInfoMapper.selectDevInfoHotList(devInfo); + if (CollectionUtil.isEmpty(hotList)) { + return AjaxResult.success(Collections.emptyMap()); + } extractedFile(hotList); - return hotList; + // 按照一级设备类型进行分组 + Map> groupedByFirstName = hotList.stream() + .filter(info -> info.getFirstName() != null) + .collect(Collectors.groupingBy(DevInfoVo::getFirstName)); + return AjaxResult.success(groupedByFirstName); } /** diff --git a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/lease/service/impl/MaLeaseInfoServiceImpl.java b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/lease/service/impl/MaLeaseInfoServiceImpl.java index 97e86cc..467f98d 100644 --- a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/lease/service/impl/MaLeaseInfoServiceImpl.java +++ b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/lease/service/impl/MaLeaseInfoServiceImpl.java @@ -216,7 +216,26 @@ public class MaLeaseInfoServiceImpl implements MaLeaseInfoService { */ @Override public List leaseList(MaLease maLease) { - return leaseInfoMapper.leaseList(maLease); + List list = new ArrayList<>(); + list = leaseInfoMapper.leaseList(maLease); + int result = 0; + //查询列表中数据,如果需求截止日期超过当前,则修改状态为已过期 + for (MaLeaseVo maLeaseVo : list) { + Date endTime = maLeaseVo.getEndTime(); + if (maLeaseVo.getLeaseStatus().equals(LeaseInfoEnum.LEASE_PENDING_ORDER.getStatus()) + && endTime != null && endTime.before(new Date())) { + //根据id修改状态为已过期 + MaLeaseInfo maLeaseInfo = new MaLeaseInfo(); + maLeaseInfo.setId(maLeaseVo.getId()); + maLeaseInfo.setLeaseStatus(LeaseInfoEnum.LEASE_PAST_DUE.getStatus()); + maLeaseInfo.setUpdateTime(DateUtils.getNowDate()); + result = leaseInfoMapper.updateDevInfo(maLeaseInfo); + } + } + if (result > 0) { + list = leaseInfoMapper.leaseList(maLease); + } + return list; } /** diff --git a/bonus-modules/bonus-material-mall/src/main/resources/mapper/material/device/DevInfoMapper.xml b/bonus-modules/bonus-material-mall/src/main/resources/mapper/material/device/DevInfoMapper.xml index 0fb9176..e9de6c8 100644 --- a/bonus-modules/bonus-material-mall/src/main/resources/mapper/material/device/DevInfoMapper.xml +++ b/bonus-modules/bonus-material-mall/src/main/resources/mapper/material/device/DevInfoMapper.xml @@ -173,6 +173,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" d.device_name as deviceName, d.device_weight as deviceWeight, d.type_id as typeId, + mt4.type_name as typeName, d.ma_status as maStatus, d.brand as brand, d.model_name as modelName, @@ -186,10 +187,20 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" c.company_name as companyName, c.company_id as companyId, c.operate_address as operateAddress, - d.create_time as createTime + d.create_time as createTime, + mt3.type_id as thirdId, + mt3.type_name as thirdName, + mt2.type_id as secondId, + mt2.type_name as secondName, + mt1.type_id as firstId, + mt1.type_name as firstName FROM ma_dev_info d LEFT JOIN bm_company_info c ON d.own_co = c.company_id + LEFT JOIN ma_type mt4 ON mt4.type_id = d.type_id and mt4.del_flag = '0' + LEFT JOIN ma_type mt3 ON mt3.type_id = mt4.parent_id and mt3.del_flag = '0' + LEFT JOIN ma_type mt2 ON mt2.type_id = mt3.parent_id and mt2.del_flag = '0' + LEFT JOIN ma_type mt1 ON mt1.type_id = mt2.parent_id and mt1.del_flag = '0' where d.is_active='1' and d.ma_status = '2' @@ -410,13 +421,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - INSERT INTO ma_hot_search (ma_id, search_num) - VALUES (#{maId}, 1) + INSERT INTO ma_hot_search (ma_id, search_num, create_time) + VALUES (#{maId}, 1, now()) update ma_hot_search - set search_num = search_num + 1 + set search_num = search_num + 1, + update_time = now() where ma_id = #{maId} @@ -630,9 +642,27 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" select COUNT(1) from ma_dev_info where ma_status = '2' and own_co = #{companyId} - SELECT - SUM( h.search_num ) AS num + m.order_id as orderId, + m.ma_id as maId, + m1.`code` as orderCode, + su.nick_name as leaseName, + m.rent_begin_time as leaseStartTime, + m.rent_end_time as leaseEndTime, + m.costs as leasePrice + FROM + ma_order_details m + LEFT JOIN ma_order_info m1 ON m.order_id = m1.order_id + LEFT JOIN sys_user su ON m1.order_user = su.user_id + WHERE + m.ma_id = #{maId} + + + diff --git a/bonus-modules/bonus-material-mall/src/main/resources/mapper/material/lease/MaLeaseInfoMapper.xml b/bonus-modules/bonus-material-mall/src/main/resources/mapper/material/lease/MaLeaseInfoMapper.xml index dc6fb61..510e9c5 100644 --- a/bonus-modules/bonus-material-mall/src/main/resources/mapper/material/lease/MaLeaseInfoMapper.xml +++ b/bonus-modules/bonus-material-mall/src/main/resources/mapper/material/lease/MaLeaseInfoMapper.xml @@ -98,13 +98,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" m.person as person, m.person_phone as personPhone, m.description as description, - h.lease_num as searchNum, + IFNULL(h.lease_num, 0) AS searchNum, mt3.type_id as thirdId, mt3.type_name as thirdName, mt2.type_id as secondId, mt2.type_name as secondName, mt1.type_id as firstId, - mt1.type_name as firstName + mt1.type_name as firstName, + GROUP_CONCAT(CONCAT(mt1.type_name, '/', mt2.type_name, '/', mt3.type_name)) AS groupName, + m.publish_user as publishUser FROM ma_lease_info m LEFT JOIN bm_company_info c ON m.company_id = c.company_id @@ -137,26 +139,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" m.id as id, m.lease_name as leaseName, m.lease_code as leaseCode, - m.type_id as typeId, - mt4.type_name as typeName, m.company_id as companyId, c.company_name as companyName, c.operate_address as operateAddress, m.lease_status as leaseStatus, - m.lease_day as leaseDay, - m.lease_num as leaseNum, m.start_time as startTime, m.end_time as endTime, - m.person as person, - m.person_phone as personPhone, - m.description as description, - mt3.type_id as thirdId, - mt3.type_name as thirdName, - mt2.type_id as secondId, - mt2.type_name as secondName, - mt1.type_id as firstId, - mt1.type_name as firstName, - GROUP_CONCAT(CONCAT(mt1.type_name, '/', mt2.type_name, '/', mt3.type_name)) AS groupName, CASE WHEN lease_status = 0 THEN '待接单' WHEN lease_status = 1 THEN '已接单' @@ -169,10 +157,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ma_lease_info m LEFT JOIN bm_company_info c ON m.company_id = c.company_id LEFT JOIN sys_user su ON m.publish_user = su.user_id - LEFT JOIN ma_type mt4 ON mt4.type_id = m.type_id and mt4.del_flag = '0' - LEFT JOIN ma_type mt3 ON mt3.type_id = mt4.parent_id and mt3.del_flag = '0' - LEFT JOIN ma_type mt2 ON mt2.type_id = mt3.parent_id and mt2.del_flag = '0' - LEFT JOIN ma_type mt1 ON mt1.type_id = mt2.parent_id and mt1.del_flag = '0' WHERE 1 = 1 and m.create_by = #{createBy} and m.lease_code like concat('%',#{leaseCode},'%') @@ -221,7 +205,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" mt2.type_name as secondName, mt1.type_id as firstId, mt1.type_name as firstName, - GROUP_CONCAT(CONCAT(mt1.type_name, '/', mt2.type_name, '/', mt3.type_name)) AS groupName + GROUP_CONCAT(CONCAT(mt1.type_name, '/', mt2.type_name, '/', mt3.type_name)) AS groupName, + m.publish_user as publishUser FROM ma_lease_info m LEFT JOIN bm_company_info c ON m.company_id = c.company_id @@ -234,7 +219,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - and d.type_id = #{typeId} + and m.type_id = #{typeId} and mt3.type_id = #{typeId} @@ -267,10 +252,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ,m.start_time DESC - + ,m.lease_day - + ,m.lease_day DESC @@ -279,10 +264,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ,m.end_time DESC - + ,m.lease_num - + ,m.lease_num DESC