This commit is contained in:
parent
893f67f82a
commit
266bd0f4ce
|
|
@ -2,11 +2,15 @@ package com.bonus.material.largeScreen.controller;
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollectionUtil;
|
import cn.hutool.core.collection.CollectionUtil;
|
||||||
import com.bonus.common.biz.utils.MathUtil;
|
import com.bonus.common.biz.utils.MathUtil;
|
||||||
|
import com.bonus.common.core.utils.StringUtils;
|
||||||
|
import com.bonus.common.core.web.controller.BaseController;
|
||||||
import com.bonus.common.core.web.domain.AjaxResult;
|
import com.bonus.common.core.web.domain.AjaxResult;
|
||||||
import com.bonus.material.device.domain.DevInfo;
|
import com.bonus.material.device.domain.DevInfo;
|
||||||
import com.bonus.material.device.domain.vo.DevInfoVo;
|
import com.bonus.material.device.domain.vo.DevInfoVo;
|
||||||
import com.bonus.material.device.mapper.DevInfoMapper;
|
import com.bonus.material.device.mapper.DevInfoMapper;
|
||||||
import com.bonus.material.device.service.DevInfoService;
|
import com.bonus.material.device.service.DevInfoService;
|
||||||
|
import com.bonus.material.largeScreen.entity.MaLeaseAnswerInfo;
|
||||||
|
import com.bonus.material.largeScreen.entity.MaLeaseOnlyInfo;
|
||||||
import com.bonus.material.largeScreen.entity.OrderData;
|
import com.bonus.material.largeScreen.entity.OrderData;
|
||||||
import com.bonus.material.largeScreen.service.LargeScreenService;
|
import com.bonus.material.largeScreen.service.LargeScreenService;
|
||||||
import com.bonus.material.lease.domain.MaLeaseInfo;
|
import com.bonus.material.lease.domain.MaLeaseInfo;
|
||||||
|
|
@ -17,11 +21,16 @@ import com.bonus.material.order.mapper.OrderMapper;
|
||||||
import com.bonus.material.order.service.OrderService;
|
import com.bonus.material.order.service.OrderService;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import org.springframework.util.CollectionUtils;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
import java.time.Instant;
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import java.time.ZoneId;
|
||||||
|
import java.time.temporal.ChronoUnit;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
|
@ -33,7 +42,7 @@ import java.util.stream.Collectors;
|
||||||
@Api(value = "大屏", tags = {"大屏"})
|
@Api(value = "大屏", tags = {"大屏"})
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/largeScreen")
|
@RequestMapping("/largeScreen")
|
||||||
public class LargeScreenController {
|
public class LargeScreenController extends BaseController {
|
||||||
@Resource
|
@Resource
|
||||||
private OrderService orderService;
|
private OrderService orderService;
|
||||||
|
|
||||||
|
|
@ -241,4 +250,128 @@ public class LargeScreenController {
|
||||||
// return AjaxResult.success(orderData);
|
// return AjaxResult.success(orderData);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 应答率二级页面
|
||||||
|
* @param dto
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@ApiOperation("应答率二级页面")
|
||||||
|
@GetMapping("/getLeaseAnswerRate")
|
||||||
|
public AjaxResult getLeaseAnswerRate(MaLeaseAnswerInfo dto) {
|
||||||
|
startPage();
|
||||||
|
List<MaLeaseAnswerInfo> list = leaseInfoMapper.getLeaseAnswerRate(dto);
|
||||||
|
if (!CollectionUtils.isEmpty(list)) {
|
||||||
|
for (MaLeaseAnswerInfo maLeaseAnswerInfo : list) {
|
||||||
|
// 根据 typeId 查询设备名称
|
||||||
|
if (maLeaseAnswerInfo.getTypeId() != null) {
|
||||||
|
// 获取list集合
|
||||||
|
List<String> typeIds = Arrays.asList(maLeaseAnswerInfo.getTypeId().split(","));
|
||||||
|
// 查询类型名称
|
||||||
|
String typeName = leaseInfoMapper.selectMaTypeList(typeIds);
|
||||||
|
maLeaseAnswerInfo.setTypeName(typeName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!StringUtils.isBlank(dto.getKeyWord())) {
|
||||||
|
list = list.stream()
|
||||||
|
.filter(item -> containsKeyword(item, dto.getKeyWord()))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return AjaxResult.success(getDataTable(list));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 判断关键字
|
||||||
|
* @param item
|
||||||
|
* @param keyWord
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
private boolean containsKeyword(MaLeaseAnswerInfo item, String keyWord) {
|
||||||
|
return (item.getDeviceName() != null && item.getDeviceName().contains(keyWord)) ||
|
||||||
|
(item.getTypeName() != null && item.getTypeName().contains(keyWord));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 最需装备二级页面
|
||||||
|
* @param dto
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@ApiOperation("最需装备二级页面")
|
||||||
|
@GetMapping("/getLeaseOnlyInfo")
|
||||||
|
public AjaxResult getLeaseOnlyInfo(MaLeaseOnlyInfo dto) {
|
||||||
|
startPage();
|
||||||
|
List<MaLeaseOnlyInfo> list = leaseInfoMapper.getLeaseOnlyInfo(dto);
|
||||||
|
return AjaxResult.success(getDataTable(list));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 需求装备种类
|
||||||
|
* @param dto
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@ApiOperation("需求装备种类")
|
||||||
|
@GetMapping("/getLeaseTypeList")
|
||||||
|
public AjaxResult getLeaseTypeList(MaLeaseOnlyInfo dto) {
|
||||||
|
startPage();
|
||||||
|
List<MaLeaseOnlyInfo> list = leaseInfoMapper.getLeaseTypeList(dto);
|
||||||
|
if (!CollectionUtils.isEmpty(list)) {
|
||||||
|
for (MaLeaseOnlyInfo maLeaseOnlyInfo : list) {
|
||||||
|
// 获取list集合
|
||||||
|
List<String> typeIds = Arrays.asList(maLeaseOnlyInfo.getTypeId().split(","));
|
||||||
|
// 查询类型名称
|
||||||
|
String typeName = leaseInfoMapper.selectMaTypeList(typeIds);
|
||||||
|
maLeaseOnlyInfo.setTypeName(typeName);
|
||||||
|
long daysDifference = calculateDaysDifference(maLeaseOnlyInfo.getStartTime(), maLeaseOnlyInfo.getEndTime());
|
||||||
|
maLeaseOnlyInfo.setEstimateDays((int) daysDifference);
|
||||||
|
}
|
||||||
|
if (!StringUtils.isBlank(dto.getKeyWord())) {
|
||||||
|
list = list.stream()
|
||||||
|
.filter(item -> containsTypeKeyword(item, dto.getKeyWord()))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return AjaxResult.success(getDataTable(list));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 判断关键字
|
||||||
|
* @param item
|
||||||
|
* @param keyWord
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
private boolean containsTypeKeyword(MaLeaseOnlyInfo item, String keyWord) {
|
||||||
|
return (item.getDeviceName() != null && item.getDeviceName().contains(keyWord)) ||
|
||||||
|
(item.getTypeName() != null && item.getTypeName().contains(keyWord));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 计算租赁天数差
|
||||||
|
* @param startTime
|
||||||
|
* @param rentEndTime
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
private long calculateDaysDifference(Date startTime, Date rentEndTime) {
|
||||||
|
// 将 java.util.Date 转换为 java.time.LocalDate
|
||||||
|
LocalDate preOutboundLocalDate = convertToLocalDate(startTime);
|
||||||
|
LocalDate rentEndLocalDate = convertToLocalDate(rentEndTime);
|
||||||
|
// 计算天数差
|
||||||
|
long days = ChronoUnit.DAYS.between(preOutboundLocalDate, rentEndLocalDate);
|
||||||
|
if (days == 0) {
|
||||||
|
days = 1;
|
||||||
|
} else {
|
||||||
|
days = days + 1;
|
||||||
|
}
|
||||||
|
return days;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 将 java.util.Date 转换为 java.time.LocalDate
|
||||||
|
* @param date
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static LocalDate convertToLocalDate(Date date) {
|
||||||
|
return Instant.ofEpochMilli(date.getTime())
|
||||||
|
.atZone(ZoneId.systemDefault())
|
||||||
|
.toLocalDate();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,60 @@
|
||||||
|
package com.bonus.material.largeScreen.entity;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author ma_sh
|
||||||
|
* @create 2025/3/18 9:21
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class MaLeaseAnswerInfo {
|
||||||
|
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 装备类型
|
||||||
|
*/
|
||||||
|
private String typeName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 装备名称
|
||||||
|
*/
|
||||||
|
private String deviceName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 发布需求数
|
||||||
|
*/
|
||||||
|
private Integer publishCount;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 接单数
|
||||||
|
*/
|
||||||
|
private Integer orderCount;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 应答率
|
||||||
|
*/
|
||||||
|
private String answerRate;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 关键字
|
||||||
|
*/
|
||||||
|
private String keyWord;
|
||||||
|
|
||||||
|
private String typeId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 租赁开始时间
|
||||||
|
*/
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||||
|
private Date startTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 租赁结束时间
|
||||||
|
*/
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||||
|
private Date endTime;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,67 @@
|
||||||
|
package com.bonus.material.largeScreen.entity;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author ma_sh
|
||||||
|
* @create 2025/3/18 10:11
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class MaLeaseOnlyInfo {
|
||||||
|
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 装备名称
|
||||||
|
*/
|
||||||
|
private String deviceName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 租赁公司
|
||||||
|
*/
|
||||||
|
private String publishCompany;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 联系人
|
||||||
|
*/
|
||||||
|
private String person;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 电话
|
||||||
|
*/
|
||||||
|
private String phoneNumber;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 预估数量
|
||||||
|
*/
|
||||||
|
private Integer estimateCount;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 需求发布时间
|
||||||
|
*/
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
private Date startTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 需求截止日期(年月日)
|
||||||
|
*/
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
private Date endTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 关键字
|
||||||
|
*/
|
||||||
|
private String keyWord;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 预估时长
|
||||||
|
*/
|
||||||
|
private Integer estimateDays;
|
||||||
|
|
||||||
|
private String typeId;
|
||||||
|
|
||||||
|
private String typeName;
|
||||||
|
}
|
||||||
|
|
@ -1,5 +1,7 @@
|
||||||
package com.bonus.material.lease.mapper;
|
package com.bonus.material.lease.mapper;
|
||||||
|
|
||||||
|
import com.bonus.material.largeScreen.entity.MaLeaseAnswerInfo;
|
||||||
|
import com.bonus.material.largeScreen.entity.MaLeaseOnlyInfo;
|
||||||
import com.bonus.material.lease.domain.MaLease;
|
import com.bonus.material.lease.domain.MaLease;
|
||||||
import com.bonus.material.lease.domain.MaLeaseDetails;
|
import com.bonus.material.lease.domain.MaLeaseDetails;
|
||||||
import com.bonus.material.lease.domain.MaLeaseDto;
|
import com.bonus.material.lease.domain.MaLeaseDto;
|
||||||
|
|
@ -138,4 +140,32 @@ public interface MaLeaseInfoMapper {
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
int updateRejectDevInfo(MaLeaseInfo maLeaseInfo);
|
int updateRejectDevInfo(MaLeaseInfo maLeaseInfo);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 应答率二级页面
|
||||||
|
* @param dto
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List<MaLeaseAnswerInfo> getLeaseAnswerRate(MaLeaseAnswerInfo dto);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询类型名称
|
||||||
|
* @param typeIds
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
String selectMaTypeList(@Param("list") List<String> typeIds);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 最需装备二级页面
|
||||||
|
* @param dto
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List<MaLeaseOnlyInfo> getLeaseOnlyInfo(MaLeaseOnlyInfo dto);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 需求装备种类
|
||||||
|
* @param dto
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List<MaLeaseOnlyInfo> getLeaseTypeList(MaLeaseOnlyInfo dto);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -538,4 +538,72 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
ORDER BY
|
ORDER BY
|
||||||
lease_count DESC
|
lease_count DESC
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<select id="getLeaseAnswerRate" resultType="com.bonus.material.largeScreen.entity.MaLeaseAnswerInfo">
|
||||||
|
SELECT
|
||||||
|
ml.lease_name AS deviceName,
|
||||||
|
COUNT( 1 ) AS publishCount,
|
||||||
|
SUM( CASE WHEN ml.lease_status = '1' THEN 1 ELSE 0 END ) AS orderCount,
|
||||||
|
GROUP_CONCAT( DISTINCT md.type_id ) as typeId,
|
||||||
|
-- 计算百分比,避免除零错误
|
||||||
|
CASE
|
||||||
|
WHEN COUNT(1) = 0 THEN NULL
|
||||||
|
ELSE ROUND((SUM(CASE WHEN ml.lease_status = '1' THEN 1 ELSE 0 END) / COUNT(1)) * 100, 2)
|
||||||
|
END AS answerRate
|
||||||
|
FROM
|
||||||
|
ma_lease_info ml
|
||||||
|
LEFT JOIN ma_lease_details md ON ml.id = md.lease_id
|
||||||
|
GROUP BY
|
||||||
|
ml.lease_name
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="selectMaTypeList" resultType="java.lang.String">
|
||||||
|
SELECT
|
||||||
|
GROUP_CONCAT(mt.type_name)
|
||||||
|
FROM
|
||||||
|
ma_type mt
|
||||||
|
WHERE
|
||||||
|
mt.type_id IN
|
||||||
|
<foreach collection="list" item="typeId" open="(" separator="," close=")">
|
||||||
|
#{typeId}
|
||||||
|
</foreach>
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="getLeaseOnlyInfo" resultType="com.bonus.material.largeScreen.entity.MaLeaseOnlyInfo">
|
||||||
|
SELECT
|
||||||
|
ml.lease_name AS deviceName,
|
||||||
|
sd.dept_name AS publishCompany,
|
||||||
|
ml.person AS person,
|
||||||
|
ml.person_phone AS phoneNumber,
|
||||||
|
COUNT( md.lease_num ) AS estimateCount,
|
||||||
|
ml.start_time AS startTime,
|
||||||
|
ml.end_time AS endTime
|
||||||
|
FROM
|
||||||
|
ma_lease_info ml
|
||||||
|
LEFT JOIN sys_dept sd ON ml.publish_company = sd.dept_id
|
||||||
|
LEFT JOIN ma_lease_details md ON ml.id = md.lease_id
|
||||||
|
WHERE 1 =1
|
||||||
|
<if test="keyWord != null and keyWord != ''">
|
||||||
|
and ml.lease_name like concat('%', #{keyWord}, '%') or
|
||||||
|
sd.dept_name like concat('%', #{keyWord}, '%') or
|
||||||
|
ml.person like concat('%', #{keyWord}, '%') or
|
||||||
|
ml.person_phone like concat('%', #{keyWord}, '%')
|
||||||
|
</if>
|
||||||
|
GROUP BY
|
||||||
|
ml.id
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="getLeaseTypeList" resultType="com.bonus.material.largeScreen.entity.MaLeaseOnlyInfo">
|
||||||
|
SELECT
|
||||||
|
ml.lease_name AS deviceName,
|
||||||
|
COUNT( md.lease_num ) AS estimateCount,
|
||||||
|
GROUP_CONCAT( md.type_id ) AS typeId,
|
||||||
|
ml.lease_start_time as startTime,
|
||||||
|
ml.lease_end_time as endTime
|
||||||
|
FROM
|
||||||
|
ma_lease_info ml
|
||||||
|
LEFT JOIN ma_lease_details md ON ml.id = md.lease_id
|
||||||
|
GROUP BY
|
||||||
|
ml.id
|
||||||
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue