53 changed files with 454 additions and 502 deletions
@ -1,14 +1,12 @@ |
|||
package com.win.module.mes.controller.workstation.vo; |
|||
|
|||
import lombok.*; |
|||
import java.util.*; |
|||
import io.swagger.v3.oas.annotations.media.Schema; |
|||
import javax.validation.constraints.*; |
|||
|
|||
@Schema(description = "管理后台 - 工位设备关联创建 Request VO") |
|||
@Data |
|||
@EqualsAndHashCode(callSuper = true) |
|||
@ToString(callSuper = true) |
|||
public class EquipmentCreateReqVO extends EquipmentBaseVO { |
|||
public class WorkstationEquipmentCreateReqVO extends WorkstationEquipmentBaseVO { |
|||
|
|||
} |
@ -1,14 +1,12 @@ |
|||
package com.win.module.mes.controller.workstation.vo; |
|||
|
|||
import lombok.*; |
|||
import java.util.*; |
|||
import io.swagger.v3.oas.annotations.media.Schema; |
|||
import javax.validation.constraints.*; |
|||
|
|||
@Schema(description = "管理后台 - 班组创建 Request VO") |
|||
@Data |
|||
@EqualsAndHashCode(callSuper = true) |
|||
@ToString(callSuper = true) |
|||
public class TeamCreateReqVO extends TeamBaseVO { |
|||
public class WorkstationTeamCreateReqVO extends WorkstationTeamBaseVO { |
|||
|
|||
} |
@ -1,13 +1,11 @@ |
|||
package com.win.module.mes.controller.workstation.vo; |
|||
|
|||
import lombok.*; |
|||
import java.util.*; |
|||
import io.swagger.v3.oas.annotations.media.Schema; |
|||
import com.win.framework.common.pojo.PageParam; |
|||
|
|||
@Schema(description = "管理后台 - 班组 Excel 导出 Request VO,参数和 TeamPageReqVO 是一致的") |
|||
@Data |
|||
public class TeamExportReqVO { |
|||
public class WorkstationTeamExportReqVO { |
|||
|
|||
@Schema(description = "代码") |
|||
private String code; |
@ -1,17 +1,14 @@ |
|||
package com.win.module.mes.controller.workstation.vo; |
|||
|
|||
import lombok.*; |
|||
import java.util.*; |
|||
import io.swagger.v3.oas.annotations.media.Schema; |
|||
import com.win.framework.common.pojo.PageParam; |
|||
|
|||
import javax.validation.constraints.NotNull; |
|||
|
|||
@Schema(description = "管理后台 - 班组分页 Request VO") |
|||
@Data |
|||
@EqualsAndHashCode(callSuper = true) |
|||
@ToString(callSuper = true) |
|||
public class TeamPageReqVO extends PageParam { |
|||
public class WorkstationTeamPageReqVO extends PageParam { |
|||
@Schema(description = "工位code") |
|||
private String workstationCode; |
|||
|
@ -1,38 +0,0 @@ |
|||
package com.win.module.mes.convert.team; |
|||
|
|||
import java.util.*; |
|||
|
|||
import com.win.framework.common.pojo.PageResult; |
|||
|
|||
import com.win.module.mes.controller.workstation.vo.TeamCreateReqVO; |
|||
import com.win.module.mes.controller.workstation.vo.TeamExcelVO; |
|||
import com.win.module.mes.controller.workstation.vo.TeamRespVO; |
|||
import com.win.module.mes.controller.workstation.vo.TeamUpdateReqVO; |
|||
import com.win.module.mes.dal.dataobject.workstation.MesTeamDO; |
|||
import org.mapstruct.Mapper; |
|||
import org.mapstruct.factory.Mappers; |
|||
|
|||
/** |
|||
* 班组 Convert |
|||
* |
|||
* @author 超级管理员 |
|||
*/ |
|||
@Mapper |
|||
public interface TeamConvert { |
|||
|
|||
TeamConvert INSTANCE = Mappers.getMapper(TeamConvert.class); |
|||
|
|||
MesTeamDO convert(TeamCreateReqVO bean); |
|||
|
|||
MesTeamDO convert(TeamUpdateReqVO bean); |
|||
|
|||
TeamRespVO convert(MesTeamDO bean); |
|||
|
|||
List<TeamRespVO> convertList(List<MesTeamDO> list); |
|||
|
|||
PageResult<TeamRespVO> convertPage(PageResult<MesTeamDO> page); |
|||
|
|||
List<TeamExcelVO> convertList02(List<MesTeamDO> list); |
|||
|
|||
MesTeamDO convert(TeamExcelVO item); |
|||
} |
@ -0,0 +1,37 @@ |
|||
package com.win.module.mes.convert.workstation; |
|||
|
|||
import java.util.*; |
|||
|
|||
import com.win.framework.common.pojo.PageResult; |
|||
|
|||
import com.win.module.mes.controller.workstation.vo.*; |
|||
import com.win.module.mes.controller.workstation.vo.WorkstationTeamUpdateReqVO; |
|||
import com.win.module.mes.controller.workstation.vo.WorkstationTeamRespVO; |
|||
import com.win.module.mes.dal.dataobject.workstation.WorkstationTeamDO; |
|||
import org.mapstruct.Mapper; |
|||
import org.mapstruct.factory.Mappers; |
|||
|
|||
/** |
|||
* 班组 Convert |
|||
* |
|||
* @author 超级管理员 |
|||
*/ |
|||
@Mapper |
|||
public interface WorkstationTeamConvert { |
|||
|
|||
WorkstationTeamConvert INSTANCE = Mappers.getMapper(WorkstationTeamConvert.class); |
|||
|
|||
WorkstationTeamDO convert(WorkstationTeamCreateReqVO bean); |
|||
|
|||
WorkstationTeamDO convert(WorkstationTeamUpdateReqVO bean); |
|||
|
|||
WorkstationTeamRespVO convert(WorkstationTeamDO bean); |
|||
|
|||
List<WorkstationTeamRespVO> convertList(List<WorkstationTeamDO> list); |
|||
|
|||
PageResult<WorkstationTeamRespVO> convertPage(PageResult<WorkstationTeamDO> page); |
|||
|
|||
List<WorkstationTeamExcelVO> convertList02(List<WorkstationTeamDO> list); |
|||
|
|||
WorkstationTeamDO convert(WorkstationTeamExcelVO item); |
|||
} |
@ -1,42 +0,0 @@ |
|||
package com.win.module.mes.dal.mysql.workstation; |
|||
|
|||
import java.util.*; |
|||
|
|||
import com.win.framework.common.pojo.PageResult; |
|||
import com.win.framework.mybatis.core.query.LambdaQueryWrapperX; |
|||
import com.win.framework.mybatis.core.mapper.BaseMapperX; |
|||
import com.win.module.mes.controller.workstation.vo.TeamExportReqVO; |
|||
import com.win.module.mes.controller.workstation.vo.TeamPageReqVO; |
|||
import com.win.module.mes.controller.workstation.vo.TeamRelationReqVO; |
|||
import com.win.module.mes.dal.dataobject.workstation.MesTeamDO; |
|||
import org.apache.ibatis.annotations.Mapper; |
|||
import org.apache.ibatis.annotations.Param; |
|||
|
|||
/** |
|||
* 班组 Mapper |
|||
* |
|||
* @author 超级管理员 |
|||
*/ |
|||
@Mapper |
|||
public interface MesTeamMapper extends BaseMapperX<MesTeamDO> { |
|||
default PageResult<MesTeamDO> selectPage(TeamPageReqVO reqVO) { |
|||
return selectPage(reqVO, new LambdaQueryWrapperX<MesTeamDO>() |
|||
.eqIfPresent(MesTeamDO::getCode, reqVO.getWorkstationCode()) |
|||
.likeIfPresent(MesTeamDO::getName, reqVO.getName()) |
|||
.orderByDesc(MesTeamDO::getId)); |
|||
} |
|||
|
|||
default List<MesTeamDO> selectList(TeamExportReqVO reqVO) { |
|||
return selectList(new LambdaQueryWrapperX<MesTeamDO>() |
|||
.eqIfPresent(MesTeamDO::getCode, reqVO.getCode()) |
|||
.likeIfPresent(MesTeamDO::getName, reqVO.getName()) |
|||
.orderByDesc(MesTeamDO::getId)); |
|||
} |
|||
default MesTeamDO selectByCode(String code) { |
|||
return null; |
|||
} |
|||
Long count(String workstationCode); |
|||
List<MesTeamDO> listByWorkstationCode(String workstationCode); |
|||
Long checkCountByWorkstationCode(String workstationCode,boolean productionLineCodeCheck); |
|||
List<MesTeamDO> checkListByWorkstationCode(String workstationCode,boolean productionLineCodeCheck); |
|||
} |
@ -0,0 +1,40 @@ |
|||
package com.win.module.mes.dal.mysql.workstation; |
|||
|
|||
import java.util.*; |
|||
|
|||
import com.win.framework.common.pojo.PageResult; |
|||
import com.win.framework.mybatis.core.query.LambdaQueryWrapperX; |
|||
import com.win.framework.mybatis.core.mapper.BaseMapperX; |
|||
import com.win.module.mes.controller.workstation.vo.WorkstationTeamExportReqVO; |
|||
import com.win.module.mes.controller.workstation.vo.WorkstationTeamPageReqVO; |
|||
import com.win.module.mes.dal.dataobject.workstation.WorkstationTeamDO; |
|||
import org.apache.ibatis.annotations.Mapper; |
|||
|
|||
/** |
|||
* 班组 Mapper |
|||
* |
|||
* @author 超级管理员 |
|||
*/ |
|||
@Mapper |
|||
public interface WorkstationTeamMapper extends BaseMapperX<WorkstationTeamDO> { |
|||
default PageResult<WorkstationTeamDO> selectPage(WorkstationTeamPageReqVO reqVO) { |
|||
return selectPage(reqVO, new LambdaQueryWrapperX<WorkstationTeamDO>() |
|||
.eqIfPresent(WorkstationTeamDO::getCode, reqVO.getWorkstationCode()) |
|||
.likeIfPresent(WorkstationTeamDO::getName, reqVO.getName()) |
|||
.orderByDesc(WorkstationTeamDO::getId)); |
|||
} |
|||
|
|||
default List<WorkstationTeamDO> selectList(WorkstationTeamExportReqVO reqVO) { |
|||
return selectList(new LambdaQueryWrapperX<WorkstationTeamDO>() |
|||
.eqIfPresent(WorkstationTeamDO::getCode, reqVO.getCode()) |
|||
.likeIfPresent(WorkstationTeamDO::getName, reqVO.getName()) |
|||
.orderByDesc(WorkstationTeamDO::getId)); |
|||
} |
|||
default WorkstationTeamDO selectByCode(String code) { |
|||
return null; |
|||
} |
|||
Long count(String workstationCode); |
|||
List<WorkstationTeamDO> listByWorkstationCode(String workstationCode); |
|||
Long checkCountByWorkstationCode(String workstationCode,boolean productionLineCodeCheck); |
|||
List<WorkstationTeamDO> checkListByWorkstationCode(String workstationCode, boolean productionLineCodeCheck); |
|||
} |
@ -1,143 +0,0 @@ |
|||
package com.win.module.mes.service.workstation; |
|||
|
|||
import cn.hutool.core.collection.CollUtil; |
|||
import com.win.module.mes.controller.workstation.vo.*; |
|||
import com.win.module.mes.convert.team.TeamConvert; |
|||
import com.win.module.mes.dal.dataobject.workstation.MesTeamDO; |
|||
import com.win.module.mes.dal.mysql.workstation.MesTeamMapper; |
|||
import com.win.module.mes.dal.mysql.workstation.MesWorkstationMapper; |
|||
import org.springframework.stereotype.Service; |
|||
import javax.annotation.Resource; |
|||
import javax.validation.Valid; |
|||
|
|||
import org.springframework.validation.annotation.Validated; |
|||
|
|||
import java.util.*; |
|||
import com.win.framework.common.pojo.PageResult; |
|||
|
|||
import static com.win.framework.common.exception.util.ServiceExceptionUtil.exception; |
|||
import static com.win.module.mes.enums.ErrorCodeConstants.TEAM_IMPORT_LIST_IS_EMPTY; |
|||
import static com.win.module.mes.enums.ErrorCodeConstants.TEAM_NOT_EXISTS; |
|||
|
|||
/** |
|||
* 班组 Service 实现类 |
|||
* |
|||
* @author 超级管理员 |
|||
*/ |
|||
@Service(value = "mesTeamService") |
|||
@Validated |
|||
public class TeamServiceImpl implements TeamService { |
|||
|
|||
@Resource |
|||
private MesTeamMapper mesTeamMapper; |
|||
@Resource |
|||
private MesWorkstationMapper mesWorkstationMapper; |
|||
@Override |
|||
public Long createTeam(TeamCreateReqVO createReqVO) { |
|||
// 插入
|
|||
MesTeamDO team = TeamConvert.INSTANCE.convert(createReqVO); |
|||
mesTeamMapper.insert(team); |
|||
// 返回
|
|||
return team.getId(); |
|||
} |
|||
|
|||
@Override |
|||
public Integer updateTeam(TeamUpdateReqVO updateReqVO) { |
|||
// 校验存在
|
|||
validateTeamExists(updateReqVO.getId()); |
|||
// 更新
|
|||
MesTeamDO updateObj = TeamConvert.INSTANCE.convert(updateReqVO); |
|||
return mesTeamMapper.updateById(updateObj); |
|||
} |
|||
|
|||
@Override |
|||
public Integer deleteTeam(Long id) { |
|||
// 校验存在
|
|||
validateTeamExists(id); |
|||
// 删除
|
|||
return mesTeamMapper.deleteById(id); |
|||
} |
|||
|
|||
private void validateTeamExists(Long id) { |
|||
if (mesTeamMapper.selectById(id) == null) { |
|||
throw exception(TEAM_NOT_EXISTS); |
|||
} |
|||
} |
|||
|
|||
@Override |
|||
public MesTeamDO getTeam(Long id) { |
|||
return mesTeamMapper.selectById(id); |
|||
} |
|||
|
|||
@Override |
|||
public List<MesTeamDO> getTeamList(Collection<Long> ids) { |
|||
return mesTeamMapper.selectBatchIds(ids); |
|||
} |
|||
|
|||
@Override |
|||
public PageResult<MesTeamDO> pageListByWorkstationCode(TeamPageReqVO pageVO) { |
|||
Long count = mesTeamMapper.count(pageVO.getWorkstationCode()); |
|||
PageResult<MesTeamDO> pageResult = new PageResult(); |
|||
if (count > 0){ |
|||
pageResult.setList(mesTeamMapper.listByWorkstationCode(pageVO.getWorkstationCode())); |
|||
pageResult.setTotal(count); |
|||
} |
|||
return pageResult; |
|||
} |
|||
|
|||
@Override |
|||
public PageResult<MesTeamDO> pageCheckListByWorkstationCode(TeamPageReqVO pageVO) { |
|||
Long count = mesTeamMapper.checkCountByWorkstationCode(pageVO.getWorkstationCode(),false); |
|||
PageResult<MesTeamDO> pageResult = new PageResult(); |
|||
if (count > 0){ |
|||
pageResult.setList(mesTeamMapper.checkListByWorkstationCode(pageVO.getWorkstationCode(),false)); |
|||
pageResult.setTotal(count); |
|||
} |
|||
return pageResult; |
|||
} |
|||
|
|||
@Override |
|||
public PageResult<MesTeamDO> getTeamPage(TeamPageReqVO pageReqVO) { |
|||
return mesTeamMapper.selectPage(pageReqVO); |
|||
} |
|||
|
|||
@Override |
|||
public List<MesTeamDO> getTeamList(TeamExportReqVO exportReqVO) { |
|||
return mesTeamMapper.selectList(exportReqVO); |
|||
} |
|||
|
|||
@Override |
|||
public List<TeamExcelVO> importTeamList(List<TeamExcelVO> datas, Integer mode, boolean updatePart) { |
|||
if (CollUtil.isEmpty(datas)) { |
|||
throw exception(TEAM_IMPORT_LIST_IS_EMPTY); |
|||
} |
|||
|
|||
List<TeamExcelVO> errorList = new ArrayList<>(); |
|||
datas.forEach(item -> { |
|||
if(errorList == null){ |
|||
// 判断如果不存在,在进行插入
|
|||
MesTeamDO obj = mesTeamMapper.selectByCode(item.getCode()); |
|||
if (obj == null&& mode != 3) { |
|||
mesTeamMapper.insert(TeamConvert.INSTANCE.convert(item)); |
|||
} |
|||
else if (obj != null && mode != 2) {// 如果存在,判断是否允许更新
|
|||
MesTeamDO teamDO = TeamConvert.INSTANCE.convert(item); |
|||
teamDO.setId(obj.getId()); |
|||
mesTeamMapper.updateById(obj); |
|||
} |
|||
} |
|||
}); |
|||
|
|||
return errorList; |
|||
} |
|||
|
|||
@Override |
|||
public Object createRelation(TeamRelationReqVO teamRelationReqVO) { |
|||
return mesWorkstationMapper.createRelation(teamRelationReqVO); |
|||
} |
|||
|
|||
@Override |
|||
public Object deleteRelation(TeamRelationReqVO teamRelationReqVO) { |
|||
return mesWorkstationMapper.deleteRelation(teamRelationReqVO); |
|||
} |
|||
} |
@ -0,0 +1,142 @@ |
|||
package com.win.module.mes.service.workstation; |
|||
|
|||
import cn.hutool.core.collection.CollUtil; |
|||
import com.win.module.mes.controller.workstation.vo.*; |
|||
import com.win.module.mes.convert.workstation.WorkstationTeamConvert; |
|||
import com.win.module.mes.dal.dataobject.workstation.WorkstationTeamDO; |
|||
import com.win.module.mes.dal.mysql.workstation.WorkstationTeamMapper; |
|||
import com.win.module.mes.dal.mysql.workstation.MesWorkstationMapper; |
|||
import org.springframework.stereotype.Service; |
|||
import javax.annotation.Resource; |
|||
|
|||
import org.springframework.validation.annotation.Validated; |
|||
|
|||
import java.util.*; |
|||
import com.win.framework.common.pojo.PageResult; |
|||
|
|||
import static com.win.framework.common.exception.util.ServiceExceptionUtil.exception; |
|||
import static com.win.module.mes.enums.ErrorCodeConstants.TEAM_IMPORT_LIST_IS_EMPTY; |
|||
import static com.win.module.mes.enums.ErrorCodeConstants.TEAM_NOT_EXISTS; |
|||
|
|||
/** |
|||
* 班组 Service 实现类 |
|||
* |
|||
* @author 超级管理员 |
|||
*/ |
|||
@Service(value = "mesTeamService") |
|||
@Validated |
|||
public class WorkstationTeamServiceImpl implements WorkstationTeamService { |
|||
|
|||
@Resource |
|||
private WorkstationTeamMapper workstationTeamMapper; |
|||
@Resource |
|||
private MesWorkstationMapper mesWorkstationMapper; |
|||
@Override |
|||
public Long createTeam(WorkstationTeamCreateReqVO createReqVO) { |
|||
// 插入
|
|||
WorkstationTeamDO team = WorkstationTeamConvert.INSTANCE.convert(createReqVO); |
|||
workstationTeamMapper.insert(team); |
|||
// 返回
|
|||
return team.getId(); |
|||
} |
|||
|
|||
@Override |
|||
public Integer updateTeam(WorkstationTeamUpdateReqVO updateReqVO) { |
|||
// 校验存在
|
|||
validateTeamExists(updateReqVO.getId()); |
|||
// 更新
|
|||
WorkstationTeamDO updateObj = WorkstationTeamConvert.INSTANCE.convert(updateReqVO); |
|||
return workstationTeamMapper.updateById(updateObj); |
|||
} |
|||
|
|||
@Override |
|||
public Integer deleteTeam(Long id) { |
|||
// 校验存在
|
|||
validateTeamExists(id); |
|||
// 删除
|
|||
return workstationTeamMapper.deleteById(id); |
|||
} |
|||
|
|||
private void validateTeamExists(Long id) { |
|||
if (workstationTeamMapper.selectById(id) == null) { |
|||
throw exception(TEAM_NOT_EXISTS); |
|||
} |
|||
} |
|||
|
|||
@Override |
|||
public WorkstationTeamDO getTeam(Long id) { |
|||
return workstationTeamMapper.selectById(id); |
|||
} |
|||
|
|||
@Override |
|||
public List<WorkstationTeamDO> getTeamList(Collection<Long> ids) { |
|||
return workstationTeamMapper.selectBatchIds(ids); |
|||
} |
|||
|
|||
@Override |
|||
public PageResult<WorkstationTeamDO> pageListByWorkstationCode(WorkstationTeamPageReqVO pageVO) { |
|||
Long count = workstationTeamMapper.count(pageVO.getWorkstationCode()); |
|||
PageResult<WorkstationTeamDO> pageResult = new PageResult(); |
|||
if (count > 0){ |
|||
pageResult.setList(workstationTeamMapper.listByWorkstationCode(pageVO.getWorkstationCode())); |
|||
pageResult.setTotal(count); |
|||
} |
|||
return pageResult; |
|||
} |
|||
|
|||
@Override |
|||
public PageResult<WorkstationTeamDO> pageCheckListByWorkstationCode(WorkstationTeamPageReqVO pageVO) { |
|||
Long count = workstationTeamMapper.checkCountByWorkstationCode(pageVO.getWorkstationCode(),false); |
|||
PageResult<WorkstationTeamDO> pageResult = new PageResult(); |
|||
if (count > 0){ |
|||
pageResult.setList(workstationTeamMapper.checkListByWorkstationCode(pageVO.getWorkstationCode(),false)); |
|||
pageResult.setTotal(count); |
|||
} |
|||
return pageResult; |
|||
} |
|||
|
|||
@Override |
|||
public PageResult<WorkstationTeamDO> getTeamPage(WorkstationTeamPageReqVO pageReqVO) { |
|||
return workstationTeamMapper.selectPage(pageReqVO); |
|||
} |
|||
|
|||
@Override |
|||
public List<WorkstationTeamDO> getTeamList(WorkstationTeamExportReqVO exportReqVO) { |
|||
return workstationTeamMapper.selectList(exportReqVO); |
|||
} |
|||
|
|||
@Override |
|||
public List<WorkstationTeamExcelVO> importTeamList(List<WorkstationTeamExcelVO> datas, Integer mode, boolean updatePart) { |
|||
if (CollUtil.isEmpty(datas)) { |
|||
throw exception(TEAM_IMPORT_LIST_IS_EMPTY); |
|||
} |
|||
|
|||
List<WorkstationTeamExcelVO> errorList = new ArrayList<>(); |
|||
datas.forEach(item -> { |
|||
if(errorList == null){ |
|||
// 判断如果不存在,在进行插入
|
|||
WorkstationTeamDO obj = workstationTeamMapper.selectByCode(item.getCode()); |
|||
if (obj == null&& mode != 3) { |
|||
workstationTeamMapper.insert(WorkstationTeamConvert.INSTANCE.convert(item)); |
|||
} |
|||
else if (obj != null && mode != 2) {// 如果存在,判断是否允许更新
|
|||
WorkstationTeamDO teamDO = WorkstationTeamConvert.INSTANCE.convert(item); |
|||
teamDO.setId(obj.getId()); |
|||
workstationTeamMapper.updateById(obj); |
|||
} |
|||
} |
|||
}); |
|||
|
|||
return errorList; |
|||
} |
|||
|
|||
@Override |
|||
public Object createRelation(WorkstationTeamRelationReqVO workstationTeamRelationReqVO) { |
|||
return mesWorkstationMapper.createRelation(workstationTeamRelationReqVO); |
|||
} |
|||
|
|||
@Override |
|||
public Object deleteRelation(WorkstationTeamRelationReqVO workstationTeamRelationReqVO) { |
|||
return mesWorkstationMapper.deleteRelation(workstationTeamRelationReqVO); |
|||
} |
|||
} |
Loading…
Reference in new issue