Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
bc7eeb87e6
|
@ -2,6 +2,7 @@ package com.ruoyi.bst.complaint.service.impl;
|
|||
|
||||
import java.util.List;
|
||||
import com.ruoyi.common.utils.DateUtils;
|
||||
import com.ruoyi.common.utils.ServiceUtil;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.ruoyi.bst.complaint.mapper.ComplaintMapper;
|
||||
|
@ -56,6 +57,8 @@ public class ComplaintServiceImpl implements ComplaintService
|
|||
public int insertComplaint(Complaint complaint)
|
||||
{
|
||||
complaint.setCreateTime(DateUtils.getNowDate());
|
||||
ServiceUtil.assertion(complaint.getType()==null,"类型不能为空");
|
||||
ServiceUtil.assertion(complaint.getContact()==null,"联系方式不能为空");
|
||||
return complaintMapper.insertComplaint(complaint);
|
||||
}
|
||||
|
||||
|
|
|
@ -22,11 +22,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
bf.vehicle_num,
|
||||
bf.store_id,
|
||||
su.agent_id
|
||||
from <include refid="searchTables"/>
|
||||
<include refid="searchTables"></include>
|
||||
</sql>
|
||||
|
||||
<sql id="searchTables">
|
||||
bst_fault bf
|
||||
from bst_fault bf
|
||||
left join sys_user su on bf.store_id = su.user_id
|
||||
</sql>
|
||||
|
||||
|
@ -48,7 +47,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="query.appealStatus != null and query.appealStatus != ''"> and bf.appeal_status = #{query.appealStatus}</if>
|
||||
${@com.ruoyi.framework.util.DataScopeUtil@dataScope(
|
||||
null,
|
||||
"bf.store_id,su.agent_id",
|
||||
"bf.store_id,su.agent_id,bf.user_id",
|
||||
null,
|
||||
null,
|
||||
query.scope
|
||||
|
@ -60,6 +59,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<include refid="selectFaultVo"/>
|
||||
<where>
|
||||
<include refid="searchCondition"/>
|
||||
order by bf.create_time desc
|
||||
</where>
|
||||
</select>
|
||||
|
||||
|
|
|
@ -5,6 +5,8 @@ import java.util.List;
|
|||
import com.github.pagehelper.PageHelper;
|
||||
import com.ruoyi.bst.area.domain.AreaQuery;
|
||||
import com.ruoyi.bst.area.domain.AreaVO;
|
||||
import com.ruoyi.bst.device.domain.DeviceVO;
|
||||
import com.ruoyi.bst.device.service.DeviceService;
|
||||
import com.ruoyi.bst.fault.domain.enums.FaultHandleStatus;
|
||||
import com.ruoyi.bst.fault.domain.enums.FaultStatus;
|
||||
import com.ruoyi.common.utils.DateUtils;
|
||||
|
@ -30,6 +32,8 @@ public class FaultServiceImpl implements FaultService
|
|||
{
|
||||
@Autowired
|
||||
private FaultMapper faultMapper;
|
||||
@Autowired
|
||||
private DeviceService deviceService;
|
||||
|
||||
@Override
|
||||
public FaultVO selectFaultById(Long id, boolean scope) {
|
||||
|
@ -77,7 +81,9 @@ public class FaultServiceImpl implements FaultService
|
|||
{
|
||||
fault.setCreateTime(DateUtils.getNowDate());
|
||||
fault.setUserId(SecurityUtils.getLoginUser().getUserId());
|
||||
return faultMapper.insertFault(fault);
|
||||
DeviceVO vo = deviceService.selectDeviceBySn(fault.getVehicleNum());
|
||||
ServiceUtil.assertion(vo==null,"当前设备不存在");
|
||||
return faultMapper.insertFault(fault);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,7 +1,15 @@
|
|||
package com.ruoyi.bst.hardwareVersion.domain;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class HardwareVersionQuery extends HardwareVersion{
|
||||
|
||||
@ApiModelProperty("硬件版本列表")
|
||||
private List<Long> hardwareVersionIds;
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -88,6 +88,9 @@ public interface HardwareVersionMapper
|
|||
*/
|
||||
int countUnBoundNum(Long id);
|
||||
|
||||
List<HardwareVersionVO> selectBoundCount(HardwareVersionQuery query);
|
||||
|
||||
List<HardwareVersionVO> selectUnBoundCount(HardwareVersionQuery query);
|
||||
/**
|
||||
* 查询硬件版本名称
|
||||
*/
|
||||
|
|
|
@ -81,6 +81,26 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
select count(1) from bst_device where hardware_version_id = #{hardwareVersionId} and mch_id is null
|
||||
</select>
|
||||
|
||||
<select id="selectBoundCount" resultType="com.ruoyi.bst.hardwareVersion.domain.HardwareVersionVO">
|
||||
select bhv.id,count(1) as Bound
|
||||
from bst_hardware_version bhv
|
||||
left join bst_device bd
|
||||
on bhv.id = bd.hardware_version_id
|
||||
where bd.mch_id is not null
|
||||
and bd.hardware_version_id is not null
|
||||
group by bhv.id
|
||||
</select>
|
||||
|
||||
<select id="selectUnBoundCount" resultType="com.ruoyi.bst.hardwareVersion.domain.HardwareVersionVO">
|
||||
select bhv.id,count(1) as unBound
|
||||
from bst_hardware_version bhv
|
||||
left join bst_device bd
|
||||
on bhv.id = bd.hardware_version_id
|
||||
where bd.mch_id is null
|
||||
and bd.hardware_version_id is not null
|
||||
group by bhv.id
|
||||
</select>
|
||||
|
||||
<insert id="insertHardwareVersion" parameterType="HardwareVersion" useGeneratedKeys="true" keyProperty="id">
|
||||
insert into bst_hardware_version
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
package com.ruoyi.bst.hardwareVersion.service;
|
||||
|
||||
import com.ruoyi.bst.hardwareVersion.domain.HardwareVersionVO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface HardwareVersionAssembler {
|
||||
|
||||
void assembleRevenue(List<HardwareVersionVO> list);
|
||||
}
|
|
@ -58,6 +58,10 @@ public interface HardwareVersionService
|
|||
|
||||
List<HardwareVersionVO> computeNumber(HardwareVersionQuery query);
|
||||
|
||||
List<HardwareVersionVO> selectBoundCount(HardwareVersionQuery query);
|
||||
|
||||
List<HardwareVersionVO> selectUnBoundCount(HardwareVersionQuery query);
|
||||
|
||||
/**
|
||||
* 查询所有硬件版本名称
|
||||
* @return
|
||||
|
|
|
@ -0,0 +1,117 @@
|
|||
package com.ruoyi.bst.hardwareVersion.service.impl;
|
||||
|
||||
import com.ruoyi.bst.hardwareVersion.domain.HardwareVersion;
|
||||
import com.ruoyi.bst.hardwareVersion.domain.HardwareVersionQuery;
|
||||
import com.ruoyi.bst.hardwareVersion.domain.HardwareVersionVO;
|
||||
import com.ruoyi.bst.hardwareVersion.service.HardwareVersionAssembler;
|
||||
import com.ruoyi.bst.hardwareVersion.service.HardwareVersionService;
|
||||
import com.ruoyi.common.utils.collection.CollectionUtils;
|
||||
import org.checkerframework.checker.units.qual.A;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
public class HardwareVersionAssemblerImpl implements HardwareVersionAssembler {
|
||||
|
||||
@Autowired
|
||||
private HardwareVersionService hardwareVersionService;
|
||||
|
||||
@Override
|
||||
public void assembleRevenue(List<HardwareVersionVO> list) {
|
||||
if (CollectionUtils.isEmptyElement(list)) {
|
||||
return;
|
||||
}
|
||||
// 子版本
|
||||
// 计算已绑定设备数量
|
||||
this.assembleBoundCount(list);
|
||||
// 计算未绑定设备数量
|
||||
this.assembleUnboundCount(list);
|
||||
// 计算已录入的设备数量
|
||||
this.assembleEnteredNum(list);
|
||||
// 父版本
|
||||
// 累加子版本的数据
|
||||
this.aggregateParentData(list);
|
||||
// 计算丢算的设备数量
|
||||
this.assembleLost(list);
|
||||
}
|
||||
|
||||
|
||||
// 拼接已绑定数量
|
||||
private void assembleBoundCount(List<HardwareVersionVO> list) {
|
||||
if (CollectionUtils.isEmpty(list)) {
|
||||
return;
|
||||
}
|
||||
HardwareVersionQuery query = new HardwareVersionQuery();
|
||||
query.setHardwareVersionIds(list.stream().map(HardwareVersionVO::getId).collect(Collectors.toList()));
|
||||
List<HardwareVersionVO> hardwareVersionList = hardwareVersionService.selectBoundCount(query);
|
||||
Map<Long, Integer> idToBoundMap = hardwareVersionList.stream().collect(Collectors.toMap(HardwareVersionVO::getId, HardwareVersion::getBound));
|
||||
list.forEach(vo->{
|
||||
vo.setBound(idToBoundMap.getOrDefault(vo.getId(), 0));
|
||||
});
|
||||
}
|
||||
|
||||
// 拼接未绑定数量
|
||||
private void assembleUnboundCount(List<HardwareVersionVO> list) {
|
||||
if (CollectionUtils.isEmpty(list)) {
|
||||
return;
|
||||
}
|
||||
HardwareVersionQuery query = new HardwareVersionQuery();
|
||||
query.setHardwareVersionIds(list.stream().map(HardwareVersionVO::getId).collect(Collectors.toList()));
|
||||
List<HardwareVersionVO> hardwareVersionList = hardwareVersionService.selectUnBoundCount(query);
|
||||
Map<Long, Integer> idToBoundMap = hardwareVersionList.stream().collect(Collectors.toMap(HardwareVersionVO::getId, HardwareVersion::getUnBound));
|
||||
list.forEach(vo->{
|
||||
vo.setUnBound(idToBoundMap.getOrDefault(vo.getId(), 0));
|
||||
});
|
||||
}
|
||||
|
||||
// 拼接已录入数量
|
||||
private void assembleEnteredNum(List<HardwareVersionVO> list) {
|
||||
list.forEach(vo->{
|
||||
int enteredNum = vo.getBound()+vo.getUnBound();
|
||||
vo.setEnteredNum(enteredNum);
|
||||
});
|
||||
}
|
||||
|
||||
// 计算父版本数量
|
||||
private void aggregateParentData(List<HardwareVersionVO> list) {
|
||||
// 创建映射表
|
||||
Map<Long, List<HardwareVersionVO>> parentChildMap = list.stream()
|
||||
.filter(vo -> vo.getParentId() != 0)
|
||||
.collect(Collectors.groupingBy(HardwareVersionVO::getParentId));
|
||||
|
||||
// 处理父版本数据
|
||||
list.stream()
|
||||
.filter(vo -> vo.getParentId() == 0)
|
||||
.forEach(parent -> {
|
||||
List<HardwareVersionVO> children = parentChildMap.getOrDefault(parent.getId(), Collections.emptyList());
|
||||
|
||||
// 初始化父版本统计值
|
||||
parent.setBound(0);
|
||||
parent.setUnBound(0);
|
||||
parent.setEnteredNum(0);
|
||||
|
||||
// 单次遍历累加子版本数据
|
||||
for (HardwareVersionVO child : children) {
|
||||
parent.setBound(parent.getBound() + child.getBound());
|
||||
parent.setUnBound(parent.getUnBound() + child.getUnBound());
|
||||
parent.setEnteredNum(parent.getEnteredNum() + child.getEnteredNum());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 拼接丢损的数量
|
||||
private void assembleLost(List<HardwareVersionVO> list) {
|
||||
list.stream()
|
||||
.filter(vo -> vo.getParentId() == 0) // 仅处理父版本
|
||||
.forEach(vo -> {
|
||||
int lost = vo.getQuantity() - vo.getEnteredNum() - vo.getNotEnteredNum();
|
||||
vo.setLost(lost);
|
||||
});
|
||||
}
|
||||
|
||||
}
|
|
@ -1,5 +1,6 @@
|
|||
package com.ruoyi.bst.hardwareVersion.service.impl;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
@ -163,4 +164,14 @@ public class HardwareVersionServiceImpl implements HardwareVersionService
|
|||
String key = CacheConstants.ALL_HARDWARE_VERSION_NAME;
|
||||
redisCache.deleteObject(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<HardwareVersionVO> selectBoundCount(HardwareVersionQuery query) {
|
||||
return hardwareVersionMapper.selectBoundCount(query);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<HardwareVersionVO> selectUnBoundCount(HardwareVersionQuery query) {
|
||||
return hardwareVersionMapper.selectUnBoundCount(query);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -49,6 +49,7 @@ public class FaultController extends BaseController
|
|||
startPage();
|
||||
startOrderBy();
|
||||
query.setScope(true);
|
||||
query.setStoreId(getUserId());
|
||||
List<FaultVO> list = faultService.selectFaultList(query);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@ import org.springframework.web.bind.annotation.RestController;
|
|||
import com.ruoyi.bst.hardwareVersion.domain.HardwareVersion;
|
||||
import com.ruoyi.bst.hardwareVersion.domain.HardwareVersionQuery;
|
||||
import com.ruoyi.bst.hardwareVersion.domain.HardwareVersionVO;
|
||||
import com.ruoyi.bst.hardwareVersion.service.HardwareVersionAssembler;
|
||||
import com.ruoyi.bst.hardwareVersion.service.HardwareVersionService;
|
||||
import com.ruoyi.common.annotation.Log;
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
|
@ -39,6 +40,8 @@ public class HardwareVersionController extends BaseController
|
|||
@Autowired
|
||||
private HardwareVersionService hardwareVersionService;
|
||||
|
||||
@Autowired
|
||||
private HardwareVersionAssembler hardwareVersionAssembler;
|
||||
/**
|
||||
* 查询硬件版本列表
|
||||
*/
|
||||
|
@ -48,7 +51,8 @@ public class HardwareVersionController extends BaseController
|
|||
{
|
||||
startPage();
|
||||
startOrderBy();
|
||||
List<HardwareVersionVO> list = hardwareVersionService.computeNumber(query);
|
||||
List<HardwareVersionVO> list = hardwareVersionService.selectHardwareVersionList(query);
|
||||
hardwareVersionAssembler.assembleRevenue(list);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user