|
|
|
|
@ -4,6 +4,7 @@ import cn.hutool.core.collection.CollUtil;
|
|
|
|
|
import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
|
|
|
|
|
import cn.iocoder.yudao.framework.common.util.collection.MapUtils;
|
|
|
|
|
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
|
|
|
|
import cn.iocoder.yudao.module.erp.controller.admin.autocode.util.AutoCodeUtil;
|
|
|
|
|
import cn.iocoder.yudao.module.iot.dal.dataobject.device.DeviceDO;
|
|
|
|
|
import cn.iocoder.yudao.module.iot.dal.devicecontactmodel.DeviceContactModelDO;
|
|
|
|
|
import cn.iocoder.yudao.module.iot.dal.mysql.device.DeviceMapper;
|
|
|
|
|
@ -21,6 +22,7 @@ import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
|
|
|
|
|
import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
|
|
|
|
|
|
|
@ -56,6 +58,9 @@ public class OrganizationServiceImpl implements OrganizationService {
|
|
|
|
|
private DeviceContactModelMapper deviceContactModelMapper;
|
|
|
|
|
@Resource
|
|
|
|
|
private DeviceMapper deviceMapper;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private AutoCodeUtil autoCodeUtil;
|
|
|
|
|
@Override
|
|
|
|
|
public Long createOrganization(OrganizationSaveReqVO createReqVO) {
|
|
|
|
|
// 校验父组织id的有效性
|
|
|
|
|
@ -66,14 +71,16 @@ public class OrganizationServiceImpl implements OrganizationService {
|
|
|
|
|
OrganizationDO organization = BeanUtils.toBean(createReqVO, OrganizationDO.class);
|
|
|
|
|
if (StringUtils.isEmpty(organization.getCode())) {
|
|
|
|
|
// 1.4 编码,并校验唯一性
|
|
|
|
|
String no = null;
|
|
|
|
|
if(organization.getOrgClass().equals(OrgClassEnum.工位.getValue())){
|
|
|
|
|
no = noRedisDAO.generate2(MesNoRedisDAO.ORG_WORKPLACE);
|
|
|
|
|
if (organizationMapper.selectByNo(no) != null) {
|
|
|
|
|
throw exception(PURCHASE_ORDER_NO_EXISTS);
|
|
|
|
|
}
|
|
|
|
|
organization.setCode(no);
|
|
|
|
|
}
|
|
|
|
|
// String no = null;
|
|
|
|
|
// if(organization.getOrgClass().equals(OrgClassEnum.工位.getValue())){
|
|
|
|
|
// no = noRedisDAO.generate2(MesNoRedisDAO.ORG_WORKPLACE);
|
|
|
|
|
// if (organizationMapper.selectByNo(no) != null) {
|
|
|
|
|
// throw exception(PURCHASE_ORDER_NO_EXISTS);
|
|
|
|
|
// }
|
|
|
|
|
// organization.setCode(no);
|
|
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
organization.setCode(autoCodeUtil.genSerialCode("ORG_CODE",null));
|
|
|
|
|
}
|
|
|
|
|
organizationMapper.insert(organization);
|
|
|
|
|
// 返回
|
|
|
|
|
@ -252,8 +259,7 @@ public class OrganizationServiceImpl implements OrganizationService {
|
|
|
|
|
if (CollUtil.isEmpty(ids)) {
|
|
|
|
|
return Collections.emptyList();
|
|
|
|
|
}
|
|
|
|
|
List<OrganizationDO> list = organizationMapper.selectBatchIds(ids);
|
|
|
|
|
return list;
|
|
|
|
|
return(organizationMapper.selectBatchIds(ids));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|