|
|
|
|
@ -1,21 +1,32 @@
|
|
|
|
|
package cn.iocoder.yudao.module.mes.service.orgworker;
|
|
|
|
|
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
|
|
|
|
import java.util.*;
|
|
|
|
|
import cn.iocoder.yudao.module.mes.controller.admin.orgworker.vo.*;
|
|
|
|
|
import cn.iocoder.yudao.module.mes.dal.dataobject.orgworker.OrgWorkerDO;
|
|
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
|
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
|
|
|
|
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
|
|
|
|
import cn.iocoder.yudao.framework.common.util.collection.MapUtils;
|
|
|
|
|
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
|
|
|
|
|
|
|
|
|
import cn.iocoder.yudao.module.mes.controller.admin.organization.vo.OrganizationListReqVO;
|
|
|
|
|
import cn.iocoder.yudao.module.mes.controller.admin.orgworker.vo.OrgWorkerPageReqVO;
|
|
|
|
|
import cn.iocoder.yudao.module.mes.controller.admin.orgworker.vo.OrgWorkerRespVO;
|
|
|
|
|
import cn.iocoder.yudao.module.mes.controller.admin.orgworker.vo.OrgWorkerSaveReqVO;
|
|
|
|
|
import cn.iocoder.yudao.module.mes.dal.dataobject.organization.OrganizationDO;
|
|
|
|
|
import cn.iocoder.yudao.module.mes.dal.dataobject.orgworker.OrgWorkerDO;
|
|
|
|
|
import cn.iocoder.yudao.module.mes.dal.mysql.orgworker.OrgWorkerMapper;
|
|
|
|
|
import cn.iocoder.yudao.module.mes.service.organization.OrganizationService;
|
|
|
|
|
import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
|
|
|
|
|
import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
|
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
|
import java.util.Collections;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
|
|
|
|
import static cn.iocoder.yudao.module.mes.enums.ErrorCodeConstants.*;
|
|
|
|
|
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet;
|
|
|
|
|
import static cn.iocoder.yudao.module.mes.enums.ErrorCodeConstants.ORG_WORKER_NOT_EXISTS;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 工位安排 Service 实现类
|
|
|
|
|
@ -67,8 +78,39 @@ public class OrgWorkerServiceImpl implements OrgWorkerService {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public PageResult<OrgWorkerDO> getOrgWorkerPage(OrgWorkerPageReqVO pageReqVO) {
|
|
|
|
|
return orgWorkerMapper.selectPage(pageReqVO);
|
|
|
|
|
public PageResult<OrgWorkerRespVO> getOrgWorkerPage(OrgWorkerPageReqVO pageReqVO) {
|
|
|
|
|
//查询工位类型时
|
|
|
|
|
if(pageReqVO.getOrgId()==null && StringUtils.isNotEmpty(pageReqVO.getOrgType())){
|
|
|
|
|
OrganizationListReqVO reqVO = new OrganizationListReqVO();
|
|
|
|
|
reqVO.setOrgType(pageReqVO.getOrgType());
|
|
|
|
|
List<OrganizationDO> list = organizationService.getOrganizationListNoParent(reqVO);
|
|
|
|
|
List<Long> ids = list.stream()
|
|
|
|
|
.map(OrganizationDO::getId)
|
|
|
|
|
.collect(Collectors.toList());
|
|
|
|
|
pageReqVO.setOrgIds(ids);
|
|
|
|
|
}
|
|
|
|
|
PageResult<OrgWorkerDO> pageResult = orgWorkerMapper.selectPage(pageReqVO);
|
|
|
|
|
return new PageResult<>(buildVOList(pageResult.getList()),pageResult.getTotal());
|
|
|
|
|
}
|
|
|
|
|
@Resource
|
|
|
|
|
private OrganizationService organizationService;
|
|
|
|
|
@Resource
|
|
|
|
|
private AdminUserApi adminUserApi;
|
|
|
|
|
@Override
|
|
|
|
|
public List<OrgWorkerRespVO> buildVOList(List<OrgWorkerDO> list) {
|
|
|
|
|
if (CollUtil.isEmpty(list)) {
|
|
|
|
|
return Collections.emptyList();
|
|
|
|
|
}
|
|
|
|
|
Map<Long, OrganizationDO> map = organizationService.getMap(
|
|
|
|
|
convertSet(list, OrgWorkerDO::getOrgId));
|
|
|
|
|
// 1.4 管理员信息
|
|
|
|
|
Map<Long, AdminUserRespDTO> userMap = adminUserApi.getUserMap(
|
|
|
|
|
convertSet(list, OrgWorkerDO::getWorkerId));
|
|
|
|
|
return BeanUtils.toBean(list, OrgWorkerRespVO.class, item -> {
|
|
|
|
|
MapUtils.findAndThen(map, item.getOrgId(),
|
|
|
|
|
org -> item.setOrgName(org.getName()));
|
|
|
|
|
MapUtils.findAndThen(userMap, item.getWorkerId(),
|
|
|
|
|
user -> item.setWorkerName(user.getNickname()));
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|