暂降治理一期工作内容+1
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
package com.njcn.advance.service.govern.voltage;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.njcn.advance.pojo.param.govern.voltage.SgMachineParam;
|
||||
import com.njcn.advance.pojo.po.govern.voltage.SgMachine;
|
||||
import com.njcn.advance.pojo.vo.govern.voltage.SgMachineVO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author hongawen
|
||||
* @since 2024-03-14
|
||||
*/
|
||||
public interface ISgMachineService extends IService<SgMachine> {
|
||||
|
||||
Page<SgMachineVO> sgMachineListByProductLineId(SgMachineParam.SgMachineQueryParam sgMachineQueryParam);
|
||||
|
||||
String addMachine(SgMachineParam sgMachineParam);
|
||||
|
||||
boolean updateSgMachine(SgMachineParam.SgMachineUpdateParam updateParam);
|
||||
|
||||
boolean deleteSgMachineData(List<String> ids);
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package com.njcn.advance.service.govern.voltage;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.njcn.advance.pojo.param.govern.voltage.SgProductLineParam;
|
||||
import com.njcn.advance.pojo.po.govern.voltage.SgProductLine;
|
||||
import com.njcn.advance.pojo.vo.govern.voltage.SgProductLineVO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author hongawen
|
||||
* @since 2024-03-14
|
||||
*/
|
||||
public interface ISgProductLineService extends IService<SgProductLine> {
|
||||
|
||||
Page<SgProductLineVO> sgProductLineListByUserId(SgProductLineParam.SgProductLineQueryParam sgProductLineQueryParam);
|
||||
|
||||
String addProductLine(SgProductLineParam sgProductLineParam);
|
||||
|
||||
boolean updateSgProductLine(SgProductLineParam.SgProductLineUpdateParam updateParam);
|
||||
|
||||
boolean deleteSgProductData(List<String> ids);
|
||||
|
||||
List<SgProductLine> querySgProductLineByUserId(String userId);
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.njcn.advance.service.govern.voltage;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.njcn.advance.pojo.param.govern.voltage.SgSensitiveUnitParam;
|
||||
import com.njcn.advance.pojo.po.govern.voltage.SgSensitiveUnit;
|
||||
import com.njcn.advance.pojo.vo.govern.voltage.SgSensitiveUnitVO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author hongawen
|
||||
* @since 2024-03-14
|
||||
*/
|
||||
public interface ISgSensitiveUnitService extends IService<SgSensitiveUnit> {
|
||||
|
||||
Page<SgSensitiveUnitVO> sgSensitiveListByMachineId(SgSensitiveUnitParam.SgSensitiveUnitQueryParam sgSensitiveUnitQueryParam);
|
||||
|
||||
String addSensitiveUnit(SgSensitiveUnitParam sgSensitiveUnitParam);
|
||||
|
||||
boolean updateSgSensitiveUnit(SgSensitiveUnitParam.SgSensitiveUnitUpdateParam updateParam);
|
||||
|
||||
boolean deleteSgSensitiveUnitData(List<String> ids);
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
package com.njcn.advance.service.govern.voltage.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.njcn.advance.enums.AdvanceResponseEnum;
|
||||
import com.njcn.advance.mapper.govern.voltage.SgMachineMapper;
|
||||
import com.njcn.advance.pojo.param.govern.voltage.SgMachineParam;
|
||||
import com.njcn.advance.pojo.param.govern.voltage.SgProductLineParam;
|
||||
import com.njcn.advance.pojo.po.govern.voltage.SgMachine;
|
||||
import com.njcn.advance.pojo.po.govern.voltage.SgProductLine;
|
||||
import com.njcn.advance.pojo.vo.govern.voltage.SgMachineVO;
|
||||
import com.njcn.advance.pojo.vo.govern.voltage.SgProductLineVO;
|
||||
import com.njcn.advance.service.govern.voltage.ISgMachineService;
|
||||
import com.njcn.common.pojo.enums.common.DataStateEnum;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.web.factory.PageFactory;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author hongawen
|
||||
* @since 2024-03-14
|
||||
*/
|
||||
@Service
|
||||
public class SgMachineServiceImpl extends ServiceImpl<SgMachineMapper, SgMachine> implements ISgMachineService {
|
||||
|
||||
@Override
|
||||
public Page<SgMachineVO> sgMachineListByProductLineId(SgMachineParam.SgMachineQueryParam sgMachineQueryParam) {
|
||||
if(StrUtil.isBlank(sgMachineQueryParam.getProductLineId())){
|
||||
throw new BusinessException(AdvanceResponseEnum.SG_PRODUCT_LINE_ID_MISS);
|
||||
}
|
||||
QueryWrapper<SgMachineVO> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("sg_machine.product_line_id",sgMachineQueryParam.getProductLineId())
|
||||
.eq("sg_machine.state", DataStateEnum.ENABLE.getCode())
|
||||
.orderByDesc("sg_machine.create_time");
|
||||
|
||||
return this.baseMapper.page(new Page<>(PageFactory.getPageNum(sgMachineQueryParam), PageFactory.getPageSize(sgMachineQueryParam)), queryWrapper);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增设备
|
||||
* @param sgMachineParam 设备数据
|
||||
*/
|
||||
@Override
|
||||
public String addMachine(SgMachineParam sgMachineParam) {
|
||||
SgMachine sgMachine = new SgMachine();
|
||||
BeanUtil.copyProperties(sgMachineParam, sgMachine);
|
||||
//默认为正常状态
|
||||
sgMachine.setState(DataStateEnum.ENABLE.getCode());
|
||||
this.save(sgMachine);
|
||||
return sgMachine.getId();
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新设备
|
||||
* @param updateParam 设备数据
|
||||
*/
|
||||
@Override
|
||||
public boolean updateSgMachine(SgMachineParam.SgMachineUpdateParam updateParam) {
|
||||
SgMachine sgMachine = new SgMachine();
|
||||
BeanUtil.copyProperties(updateParam, sgMachine);
|
||||
return this.updateById(sgMachine);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据id逻辑删除设备
|
||||
*/
|
||||
@Override
|
||||
public boolean deleteSgMachineData(List<String> ids) {
|
||||
return this.lambdaUpdate()
|
||||
.set(SgMachine::getState, DataStateEnum.DELETED.getCode())
|
||||
.in(SgMachine::getId, ids)
|
||||
.update();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,164 @@
|
||||
package com.njcn.advance.service.govern.voltage.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.njcn.advance.enums.AdvanceResponseEnum;
|
||||
import com.njcn.advance.mapper.govern.voltage.SgProductLineMapper;
|
||||
import com.njcn.advance.pojo.param.govern.voltage.SgProductLineParam;
|
||||
import com.njcn.advance.pojo.param.govern.voltage.SgUserParam;
|
||||
import com.njcn.advance.pojo.po.govern.voltage.SgMachine;
|
||||
import com.njcn.advance.pojo.po.govern.voltage.SgProductLine;
|
||||
import com.njcn.advance.pojo.po.govern.voltage.SgUser;
|
||||
import com.njcn.advance.pojo.vo.govern.voltage.SgProductLineVO;
|
||||
import com.njcn.advance.pojo.vo.govern.voltage.SgUserVO;
|
||||
import com.njcn.advance.service.govern.voltage.ISgMachineService;
|
||||
import com.njcn.advance.service.govern.voltage.ISgProductLineService;
|
||||
import com.njcn.common.pojo.enums.common.DataStateEnum;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.web.factory.PageFactory;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.apache.poi.util.StringUtil;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author hongawen
|
||||
* @since 2024-03-14
|
||||
*/
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class SgProductLineServiceImpl extends ServiceImpl<SgProductLineMapper, SgProductLine> implements ISgProductLineService {
|
||||
|
||||
private final ISgMachineService machineService;
|
||||
|
||||
|
||||
/**
|
||||
* 因为理论上不会超过5条生产线,所以该分页其实也没有多大的必要
|
||||
* 根据业务用户id查询该用户下的所有生产线信息
|
||||
*
|
||||
* @param sgProductLineQueryParam 查询条件
|
||||
*/
|
||||
@Override
|
||||
public Page<SgProductLineVO> sgProductLineListByUserId(SgProductLineParam.SgProductLineQueryParam sgProductLineQueryParam) {
|
||||
String userId = sgProductLineQueryParam.getUserId();
|
||||
QueryWrapper<SgProductLineVO> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("sg_product_line.user_id", userId)
|
||||
.eq("sg_product_line.state", DataStateEnum.ENABLE.getCode())
|
||||
.orderByDesc("sg_product_line.create_time");
|
||||
Page<SgProductLineVO> data = this.baseMapper.page(new Page<>(PageFactory.getPageNum(sgProductLineQueryParam), PageFactory.getPageSize(sgProductLineQueryParam)), queryWrapper);
|
||||
List<SgProductLineVO> records = data.getRecords();
|
||||
//循环遍历处理下生产线总功率、设备损失、原料损失
|
||||
if(CollectionUtil.isNotEmpty(records)){
|
||||
//根据生产线获取下面所有设备
|
||||
List<String> productLineIdList = records.stream().map(SgProductLineVO::getId).collect(Collectors.toList());
|
||||
LambdaQueryWrapper<SgMachine> sgMachineLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
sgMachineLambdaQueryWrapper.in(SgMachine::getProductLineId,productLineIdList)
|
||||
.eq(SgMachine::getState,DataStateEnum.ENABLE.getCode());
|
||||
List<SgMachine> machineList = machineService.list(sgMachineLambdaQueryWrapper);
|
||||
//判断是否有设备数据,有的话,进行java分组,以生产线id为key
|
||||
Map<String, List<SgMachine>> stringListMap = machineList.stream().collect(Collectors.groupingBy(SgMachine::getProductLineId));
|
||||
for (SgProductLineVO sgProductLineVO : records) {
|
||||
String productLineId = sgProductLineVO.getId();
|
||||
List<SgMachine> machineListTemp = stringListMap.get(productLineId);
|
||||
if(CollectionUtil.isNotEmpty(machineListTemp)){
|
||||
//设备总损失
|
||||
double machineLossSum = machineListTemp.stream().mapToDouble(SgMachine::getMachineLoss).sum();
|
||||
sgProductLineVO.setMachineLoss(machineLossSum);
|
||||
//原料总损失
|
||||
double materialLossSum = machineListTemp.stream().mapToDouble(SgMachine::getMaterialLoss).sum();
|
||||
sgProductLineVO.setMaterialLoss(materialLossSum);
|
||||
//总功率
|
||||
double machinePowerSum = machineListTemp.stream().mapToDouble(SgMachine::getMachinePower).sum();
|
||||
sgProductLineVO.setMachinePower(machinePowerSum);
|
||||
}
|
||||
}
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增生产线
|
||||
* @param sgProductLineParam 数据内容
|
||||
*/
|
||||
@Override
|
||||
public String addProductLine(SgProductLineParam sgProductLineParam) {
|
||||
checkSgProductName(sgProductLineParam, false);
|
||||
SgProductLine sgProductLine = new SgProductLine();
|
||||
BeanUtil.copyProperties(sgProductLineParam, sgProductLine);
|
||||
//默认为正常状态
|
||||
sgProductLine.setState(DataStateEnum.ENABLE.getCode());
|
||||
this.save(sgProductLine);
|
||||
return sgProductLine.getId();
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新生产线
|
||||
* @param updateParam 数据内容
|
||||
*/
|
||||
@Override
|
||||
public boolean updateSgProductLine(SgProductLineParam.SgProductLineUpdateParam updateParam) {
|
||||
checkSgProductName(updateParam, true);
|
||||
SgProductLine sgProductLine = new SgProductLine();
|
||||
BeanUtil.copyProperties(updateParam, sgProductLine);
|
||||
return this.updateById(sgProductLine);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据id逻辑删除生产线数据
|
||||
* @param ids id集合
|
||||
*/
|
||||
@Override
|
||||
public boolean deleteSgProductData(List<String> ids) {
|
||||
return this.lambdaUpdate()
|
||||
.set(SgProductLine::getState, DataStateEnum.DELETED.getCode())
|
||||
.in(SgProductLine::getId, ids)
|
||||
.update();
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据用户id获取生产线信息
|
||||
* @param userId 用户id
|
||||
*/
|
||||
@Override
|
||||
public List<SgProductLine> querySgProductLineByUserId(String userId) {
|
||||
LambdaQueryWrapper<SgProductLine> sgProductLineLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
sgProductLineLambdaQueryWrapper
|
||||
.eq(SgProductLine::getUserId, userId)
|
||||
.eq(SgProductLine::getState, DataStateEnum.ENABLE.getCode());
|
||||
return this.list(sgProductLineLambdaQueryWrapper);
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验参数,检查是否存在相同名称的生产线
|
||||
*/
|
||||
private void checkSgProductName(SgProductLineParam sgProductLineParam, boolean isExcludeSelf) {
|
||||
LambdaQueryWrapper<SgProductLine> sgProductLineLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
sgProductLineLambdaQueryWrapper
|
||||
.eq(SgProductLine::getName, sgProductLineParam.getName())
|
||||
.eq(SgProductLine::getUserId, sgProductLineParam.getUserId())
|
||||
.eq(SgProductLine::getState, DataStateEnum.ENABLE.getCode());
|
||||
//更新的时候,需排除当前记录
|
||||
if (isExcludeSelf) {
|
||||
if (sgProductLineParam instanceof SgProductLineParam.SgProductLineUpdateParam) {
|
||||
sgProductLineLambdaQueryWrapper.ne(SgProductLine::getId, ((SgProductLineParam.SgProductLineUpdateParam) sgProductLineParam).getId());
|
||||
}
|
||||
}
|
||||
int countByAccount = this.count(sgProductLineLambdaQueryWrapper);
|
||||
//大于等于1个则表示重复
|
||||
if (countByAccount >= 1) {
|
||||
throw new BusinessException(AdvanceResponseEnum.SG_PRODUCT_LINE_NAME_REPEAT);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
package com.njcn.advance.service.govern.voltage.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.njcn.advance.enums.AdvanceResponseEnum;
|
||||
import com.njcn.advance.mapper.govern.voltage.SgSensitiveUnitMapper;
|
||||
import com.njcn.advance.pojo.param.govern.voltage.SgSensitiveUnitParam;
|
||||
import com.njcn.advance.pojo.po.govern.voltage.SgMachine;
|
||||
import com.njcn.advance.pojo.po.govern.voltage.SgSensitiveUnit;
|
||||
import com.njcn.advance.pojo.vo.govern.voltage.SgMachineVO;
|
||||
import com.njcn.advance.pojo.vo.govern.voltage.SgSensitiveUnitVO;
|
||||
import com.njcn.advance.service.govern.voltage.ISgSensitiveUnitService;
|
||||
import com.njcn.common.pojo.enums.common.DataStateEnum;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.web.factory.PageFactory;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author hongawen
|
||||
* @since 2024-03-14
|
||||
*/
|
||||
@Service
|
||||
public class SgSensitiveUnitServiceImpl extends ServiceImpl<SgSensitiveUnitMapper, SgSensitiveUnit> implements ISgSensitiveUnitService {
|
||||
|
||||
/**
|
||||
* 根据设备id查询下属所有的元器件数据
|
||||
*
|
||||
* @param sgSensitiveUnitQueryParam 查询条件
|
||||
*/
|
||||
@Override
|
||||
public Page<SgSensitiveUnitVO> sgSensitiveListByMachineId(SgSensitiveUnitParam.SgSensitiveUnitQueryParam sgSensitiveUnitQueryParam) {
|
||||
if(StrUtil.isBlank(sgSensitiveUnitQueryParam.getMachineId())){
|
||||
throw new BusinessException(AdvanceResponseEnum.SG_MACHINE_ID_MISS);
|
||||
}
|
||||
QueryWrapper<SgSensitiveUnitVO> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("sg_sensitive_unit.machine_id",sgSensitiveUnitQueryParam.getMachineId())
|
||||
.eq("sg_sensitive_unit.state", DataStateEnum.ENABLE.getCode())
|
||||
.orderByDesc("sg_sensitive_unit.create_time");
|
||||
return this.baseMapper.page(new Page<>(PageFactory.getPageNum(sgSensitiveUnitQueryParam), PageFactory.getPageSize(sgSensitiveUnitQueryParam)), queryWrapper);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增元器件
|
||||
* @param sgSensitiveUnitParam 元器件数据
|
||||
*/
|
||||
@Override
|
||||
public String addSensitiveUnit(SgSensitiveUnitParam sgSensitiveUnitParam) {
|
||||
SgSensitiveUnit sgSensitiveUnit = new SgSensitiveUnit();
|
||||
BeanUtil.copyProperties(sgSensitiveUnitParam, sgSensitiveUnit);
|
||||
//默认为正常状态
|
||||
sgSensitiveUnit.setState(DataStateEnum.ENABLE.getCode());
|
||||
this.save(sgSensitiveUnit);
|
||||
return sgSensitiveUnit.getId();
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新元器件
|
||||
*
|
||||
* @param updateParam 元器件数据
|
||||
*/
|
||||
@Override
|
||||
public boolean updateSgSensitiveUnit(SgSensitiveUnitParam.SgSensitiveUnitUpdateParam updateParam) {
|
||||
SgSensitiveUnit sgSensitiveUnit = new SgSensitiveUnit();
|
||||
BeanUtil.copyProperties(updateParam, sgSensitiveUnit);
|
||||
return this.updateById(sgSensitiveUnit);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除元器件
|
||||
*/
|
||||
@Override
|
||||
public boolean deleteSgSensitiveUnitData(List<String> ids) {
|
||||
return this.lambdaUpdate()
|
||||
.set(SgSensitiveUnit::getState, DataStateEnum.DELETED.getCode())
|
||||
.in(SgSensitiveUnit::getId, ids)
|
||||
.update();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user