暂降治理一期工作内容

This commit is contained in:
2024-03-14 18:44:15 +08:00
parent fd57278abe
commit ec8c4e27ce
28 changed files with 1514 additions and 1 deletions

View File

@@ -0,0 +1,20 @@
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.SgEventParam;
import com.njcn.advance.pojo.po.govern.voltage.SgEvent;
import com.njcn.advance.pojo.vo.govern.voltage.SgEventVO;
/**
* <p>
* 服务类
* </p>
*
* @author hongawen
* @since 2024-02-29
*/
public interface ISgEventService extends IService<SgEvent> {
Page<SgEventVO> sgEventList(SgEventParam.SgEventParamQueryParam sgEventParamQueryParam);
}

View File

@@ -0,0 +1,27 @@
package com.njcn.advance.service.govern.voltage;
import com.baomidou.mybatisplus.extension.service.IService;
import com.njcn.advance.pojo.param.govern.voltage.IncomingLineParam;
import com.njcn.advance.pojo.po.govern.voltage.SgIncomingLine;
import com.njcn.advance.pojo.vo.govern.voltage.IncomingLineVO;
import java.util.List;
/**
* <p>
* 服务类
* </p>
*
* @author hongawen
* @since 2024-02-29
*/
public interface ISgIncomingLineService extends IService<SgIncomingLine> {
List<IncomingLineVO> incomingLineList(String userId);
String addIncomingLine(IncomingLineParam incomingLineParam);
boolean updateIncomingLine(IncomingLineParam.IncomingLineUpdateParam updateParam);
boolean deleteIncomingLineData(List<String> ids);
}

View File

@@ -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.SgUserParam;
import com.njcn.advance.pojo.po.govern.voltage.SgUser;
import com.njcn.advance.pojo.vo.govern.voltage.SgUserVO;
import java.util.List;
/**
* <p>
* 服务类
* </p>
*
* @author hongawen
* @since 2024-02-29
*/
public interface ISgUserService extends IService<SgUser> {
Page<SgUserVO> sgUserList(SgUserParam.SgUserQueryParam sgUserQueryParam);
String addUserInfo(SgUserParam sgUserParam);
boolean updateSgUser(SgUserParam.SgUserUpdateParam updateParam);
boolean deleteSgUserData(List<String> ids);
}

View File

@@ -0,0 +1,34 @@
package com.njcn.advance.service.govern.voltage.impl;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.njcn.advance.mapper.govern.voltage.SgEventMapper;
import com.njcn.advance.pojo.param.govern.voltage.SgEventParam;
import com.njcn.advance.pojo.po.govern.voltage.SgEvent;
import com.njcn.advance.pojo.vo.govern.voltage.SgEventVO;
import com.njcn.advance.service.govern.voltage.ISgEventService;
import org.springframework.stereotype.Service;
/**
* <p>
* 服务实现类
* </p>
*
* @author hongawen
* @since 2024-02-29
*/
@Service
public class SgEventServiceImpl extends ServiceImpl<SgEventMapper, SgEvent> implements ISgEventService {
/**
* 根据查询条件返回分页的暂降数据
* @param sgEventParamQueryParam 查询条件
*/
@Override
public Page<SgEventVO> sgEventList(SgEventParam.SgEventParamQueryParam sgEventParamQueryParam) {
//暂降数据实际跟进线耦合的需要根据所传的生产线获取进线id
String productId = sgEventParamQueryParam.getProductId();
return null;
}
}

View File

@@ -0,0 +1,109 @@
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.extension.service.impl.ServiceImpl;
import com.njcn.advance.enums.AdvanceResponseEnum;
import com.njcn.advance.mapper.govern.voltage.SgIncomingLineMapper;
import com.njcn.advance.pojo.param.govern.voltage.IncomingLineParam;
import com.njcn.advance.pojo.param.govern.voltage.SgUserParam;
import com.njcn.advance.pojo.po.govern.voltage.SgIncomingLine;
import com.njcn.advance.pojo.po.govern.voltage.SgUser;
import com.njcn.advance.pojo.vo.govern.voltage.IncomingLineVO;
import com.njcn.advance.service.govern.voltage.ISgIncomingLineService;
import com.njcn.common.pojo.enums.common.DataStateEnum;
import com.njcn.common.pojo.exception.BusinessException;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* <p>
* 服务实现类
* </p>
*
* @author hongawen
* @since 2024-02-29
*/
@Service
public class SgIncomingLineServiceImpl extends ServiceImpl<SgIncomingLineMapper, SgIncomingLine> implements ISgIncomingLineService {
/**
* 根据用户id查询进线数据
* @param userId 用户id
*/
@Override
public List<IncomingLineVO> incomingLineList(String userId) {
if(StrUtil.isBlank(userId)){
throw new BusinessException(AdvanceResponseEnum.SG_USER_ID_MISS);
}
return this.baseMapper.queryLineByUserId(userId);
}
/**
* 新增业务用户的进线数据
*
* @param incomingLineParam 业务用户数据
*/
@Override
public String addIncomingLine(IncomingLineParam incomingLineParam) {
checkIncomingLineName(incomingLineParam, false);
SgIncomingLine sgIncomingLine = new SgIncomingLine();
BeanUtil.copyProperties(incomingLineParam, sgIncomingLine);
//默认为正常状态
sgIncomingLine.setState(DataStateEnum.ENABLE.getCode());
this.save(sgIncomingLine);
return sgIncomingLine.getId();
}
/**
* 修改业务用户的进线数据
*
* @param updateParam 业务用户数据
*/
@Override
public boolean updateIncomingLine(IncomingLineParam.IncomingLineUpdateParam updateParam) {
checkIncomingLineName(updateParam, true);
SgIncomingLine sgIncomingLine = new SgIncomingLine();
BeanUtil.copyProperties(updateParam, sgIncomingLine);
return this.updateById(sgIncomingLine);
}
/**
* 逻辑删除进线数据
* @param ids 进线id
*/
@Override
public boolean deleteIncomingLineData(List<String> ids) {
return this.lambdaUpdate()
.set(SgIncomingLine::getState, DataStateEnum.DELETED.getCode())
.in(SgIncomingLine::getId, ids)
.update();
}
/**
* 校验进线名称是否有重复的
* @param incomingLineParam 进线数据
* @param isExcludeSelf 是否排除自己
*/
private void checkIncomingLineName(IncomingLineParam incomingLineParam, boolean isExcludeSelf) {
LambdaQueryWrapper<SgIncomingLine> sgUserLambdaQueryWrapper = new LambdaQueryWrapper<>();
sgUserLambdaQueryWrapper
.eq(SgIncomingLine::getName, incomingLineParam.getName())
.eq(SgIncomingLine::getUserId, incomingLineParam.getUserId())
.eq(SgIncomingLine::getState, DataStateEnum.ENABLE.getCode());
//更新的时候,需排除当前记录
if (isExcludeSelf) {
if (incomingLineParam instanceof IncomingLineParam.IncomingLineUpdateParam) {
sgUserLambdaQueryWrapper.ne(SgIncomingLine::getId, ((IncomingLineParam.IncomingLineUpdateParam) incomingLineParam).getId());
}
}
int countByAccount = this.count(sgUserLambdaQueryWrapper);
//大于等于1个则表示重复
if (countByAccount >= 1) {
throw new BusinessException(AdvanceResponseEnum.SG_USER_NAME_REPEAT);
}
}
}

View File

@@ -0,0 +1,126 @@
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.ObjectUtil;
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.mapper.govern.voltage.SgUserMapper;
import com.njcn.advance.pojo.param.govern.voltage.SgUserParam;
import com.njcn.advance.pojo.po.govern.voltage.SgUser;
import com.njcn.advance.pojo.vo.govern.voltage.SgUserVO;
import com.njcn.advance.service.govern.voltage.ISgUserService;
import com.njcn.common.pojo.enums.common.DataStateEnum;
import com.njcn.common.pojo.exception.BusinessException;
import com.njcn.db.constant.DbConstant;
import com.njcn.advance.enums.AdvanceResponseEnum;
import com.njcn.web.factory.PageFactory;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* <p>
* 服务实现类
* </p>
*
* @author hongawen
* @since 2024-02-29
*/
@Service
public class SgUserServiceImpl extends ServiceImpl<SgUserMapper, SgUser> implements ISgUserService {
@Override
public Page<SgUserVO> sgUserList(SgUserParam.SgUserQueryParam sgUserQueryParam) {
QueryWrapper<SgUserVO> queryWrapper = new QueryWrapper<>();
//关键字查询,仅支持用户名、行业模糊查询
if (StrUtil.isNotBlank(sgUserQueryParam.getSearchValue())) {
queryWrapper
.and(param -> param
.like("sg_user.user_name", sgUserQueryParam.getSearchValue())
.or()
.like("sg_user.industry", sgUserQueryParam.getSearchValue()));
}
//addr可能是个集合多选N个区域查询
if (CollectionUtil.isNotEmpty(sgUserQueryParam.getAddrStrOption())) {
queryWrapper.in("sg_user.addr", sgUserQueryParam.getAddrStrOption());
}
//排序
if (ObjectUtil.isAllNotEmpty(sgUserQueryParam.getSortBy(), sgUserQueryParam.getOrderBy())) {
queryWrapper.orderBy(true, sgUserQueryParam.getOrderBy().equals(DbConstant.ASC), StrUtil.toUnderlineCase(sgUserQueryParam.getSortBy()));
} else {
//没有排序参数默认根据sort字段排序没有排序字段的根据createTime更新时间排序
queryWrapper.orderByDesc("sg_user.create_time");
}
queryWrapper.eq("sg_user.state", DataStateEnum.ENABLE.getCode());
return this.baseMapper.page(new Page<>(PageFactory.getPageNum(sgUserQueryParam), PageFactory.getPageSize(sgUserQueryParam)), queryWrapper);
}
/**
* 新增业务用户数据
*
* @param sgUserParam 业务用户数据
*/
@Override
public String addUserInfo(SgUserParam sgUserParam) {
checkSgUserName(sgUserParam, false);
SgUser sgUser = new SgUser();
BeanUtil.copyProperties(sgUserParam, sgUser);
//默认为正常状态
sgUser.setState(DataStateEnum.ENABLE.getCode());
sgUser.setAddr(sgUserParam.getAddrStrOption());
this.save(sgUser);
return sgUser.getId();
}
/**
* 更新业务用户数据
*
* @param updateParam 待更新的业务用户数据
*/
@Override
public boolean updateSgUser(SgUserParam.SgUserUpdateParam updateParam) {
checkSgUserName(updateParam, true);
SgUser sgUser = new SgUser();
BeanUtil.copyProperties(updateParam, sgUser);
return this.updateById(sgUser);
}
/**
* 逻辑删除所有指定的业务用户
*
* @param ids 用户id集合
*/
@Override
public boolean deleteSgUserData(List<String> ids) {
return this.lambdaUpdate()
.set(SgUser::getState, DataStateEnum.DELETED.getCode())
.in(SgUser::getId, ids)
.update();
}
/**
* 校验参数,检查是否存在相同名称的业务用户
*/
private void checkSgUserName(SgUserParam sgUserParam, boolean isExcludeSelf) {
LambdaQueryWrapper<SgUser> sgUserLambdaQueryWrapper = new LambdaQueryWrapper<>();
sgUserLambdaQueryWrapper
.eq(SgUser::getUserName, sgUserParam.getUserName())
.eq(SgUser::getState, DataStateEnum.ENABLE.getCode());
//更新的时候,需排除当前记录
if (isExcludeSelf) {
if (sgUserParam instanceof SgUserParam.SgUserUpdateParam) {
sgUserLambdaQueryWrapper.ne(SgUser::getId, ((SgUserParam.SgUserUpdateParam) sgUserParam).getId());
}
}
int countByAccount = this.count(sgUserLambdaQueryWrapper);
//大于等于1个则表示重复
if (countByAccount >= 1) {
throw new BusinessException(AdvanceResponseEnum.SG_USER_NAME_REPEAT);
}
}
}