erp type 优化
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
package com.zt.plat.module.erp.job;
|
||||
|
||||
public class erpJob {
|
||||
|
||||
public void execute() throws Exception {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
}
|
||||
@@ -50,6 +50,8 @@ public class ErpFactoryServiceImpl implements ErpFactoryService {
|
||||
|
||||
@Override
|
||||
public ErpFactoryRespVO createErpFactory(ErpFactorySaveReqVO createReqVO) {
|
||||
// 校验存在
|
||||
validateErpFactoryExistsNumber(createReqVO.getNumber());
|
||||
// 插入
|
||||
ErpFactoryDO erpFactory = BeanUtils.toBean(createReqVO, ErpFactoryDO.class);
|
||||
// 工厂编码自动生成,格式 GC-0001,依次新增
|
||||
@@ -65,7 +67,7 @@ public class ErpFactoryServiceImpl implements ErpFactoryService {
|
||||
erpFactory.setNumber(nextCode);
|
||||
}
|
||||
}
|
||||
erpFactory.setType("供应链");
|
||||
erpFactory.setType("SPLY");
|
||||
erpFactory.setIsEnable("1");
|
||||
erpFactoryMapper.insert(erpFactory);
|
||||
// 返回
|
||||
@@ -113,6 +115,14 @@ public class ErpFactoryServiceImpl implements ErpFactoryService {
|
||||
}
|
||||
}
|
||||
|
||||
private void validateErpFactoryExistsNumber(String number) {
|
||||
List<ErpFactoryDO> list = erpFactoryMapper.selectList(new LambdaQueryWrapperX<ErpFactoryDO>())
|
||||
.stream().filter(erpFactoryDO -> erpFactoryDO.getNumber().equals(number)).toList();
|
||||
if (!list.isEmpty()) {
|
||||
throw exception(ERP_FACTORY_EXISTS);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ErpFactoryDO getErpFactory(Long id) {
|
||||
return erpFactoryMapper.selectById(id);
|
||||
@@ -165,7 +175,7 @@ public class ErpFactoryServiceImpl implements ErpFactoryService {
|
||||
// 1. 调用ERP接口获取数据
|
||||
Map<String, Object> req = new HashMap<>();
|
||||
JSONArray dataArrayALL = new JSONArray();
|
||||
String companykey = "erp" + OftenEnum.FuncnrEnum.公司代码.getFuncnr();
|
||||
String companykey = "erpMap" + OftenEnum.FuncnrEnum.公司代码.getFuncnr();
|
||||
Map<String,Long> redisCache = myRedisConfig.getRedisCacheMap(companykey);
|
||||
if (CollUtil.isEmpty(redisCache)) {
|
||||
throw exception(ERP_COMPANY_REDIS_NOT_EXISTS);
|
||||
|
||||
@@ -7,6 +7,7 @@ import com.xxl.job.core.handler.annotation.XxlJob;
|
||||
import com.zt.plat.framework.common.pojo.PageResult;
|
||||
import com.zt.plat.framework.common.util.object.BeanUtils;
|
||||
import com.zt.plat.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import com.zt.plat.module.erp.dal.dataobject.erp.ErpWarehouseDO;
|
||||
import com.zt.plat.module.erp.utils.ErpConfig;
|
||||
import com.zt.plat.module.erp.utils.MyRedisConfig;
|
||||
import com.zt.plat.module.erp.enums.OftenEnum;
|
||||
@@ -50,6 +51,8 @@ public class ErpMaterialServiceImpl implements ErpMaterialService {
|
||||
|
||||
@Override
|
||||
public ErpMaterialRespVO createErpMaterial(ErpMaterialSaveReqVO createReqVO) {
|
||||
// 校验存在
|
||||
validateErpFactoryExistsNumber(createReqVO.getDownCenterNumber());
|
||||
// 插入
|
||||
ErpMaterialDO erpMaterial = BeanUtils.toBean(createReqVO, ErpMaterialDO.class);
|
||||
// 工厂编码自动生成,格式 GC-0001,依次新增
|
||||
@@ -65,6 +68,7 @@ public class ErpMaterialServiceImpl implements ErpMaterialService {
|
||||
erpMaterial.setDownCenterNumber(nextCode);
|
||||
}
|
||||
}
|
||||
erpMaterial.setType("SPLY");
|
||||
erpMaterialMapper.insert(erpMaterial);
|
||||
// 返回
|
||||
return BeanUtils.toBean(erpMaterial, ErpMaterialRespVO.class);
|
||||
@@ -76,7 +80,7 @@ public class ErpMaterialServiceImpl implements ErpMaterialService {
|
||||
validateErpMaterialExists(updateReqVO.getId());
|
||||
// 更新
|
||||
ErpMaterialDO updateObj = BeanUtils.toBean(updateReqVO, ErpMaterialDO.class);
|
||||
if (updateObj.getType().equals("供应链")) {
|
||||
if (updateObj.getType().equals("SPLY")) {
|
||||
erpMaterialMapper.updateById(updateObj);
|
||||
} else {
|
||||
throw exception(ERP_MATERIAL_NOT_ALLOW_UPDATE);
|
||||
@@ -128,6 +132,15 @@ public class ErpMaterialServiceImpl implements ErpMaterialService {
|
||||
}
|
||||
}
|
||||
|
||||
private void validateErpFactoryExistsNumber(String number) {
|
||||
List<ErpMaterialDO> list = erpMaterialMapper.selectList(new LambdaQueryWrapperX<ErpMaterialDO>()).stream()
|
||||
.filter(erpWarehouseDO -> erpWarehouseDO.getDownCenterNumber().equals(number))
|
||||
.toList();
|
||||
if (!list.isEmpty()) {
|
||||
throw exception(ERP_MATERIAL_EXISTS);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ErpMaterialDO getErpMaterial(Long id) {
|
||||
return erpMaterialMapper.selectById(id);
|
||||
|
||||
@@ -51,6 +51,8 @@ public class ErpWarehouseServiceImpl implements ErpWarehouseService {
|
||||
|
||||
@Override
|
||||
public ErpWarehouseRespVO createErpWarehouse(ErpWarehouseSaveReqVO createReqVO) {
|
||||
// 校验存在
|
||||
validateErpFactoryExistsNumber(createReqVO.getNumber(), createReqVO.getFactoryNumber());
|
||||
// 插入
|
||||
ErpWarehouseDO warehouse = BeanUtils.toBean(createReqVO, ErpWarehouseDO.class);
|
||||
// 库位编码自动生成,格式 KW-0001,依次新增
|
||||
@@ -66,7 +68,7 @@ public class ErpWarehouseServiceImpl implements ErpWarehouseService {
|
||||
warehouse.setNumber(nextCode);
|
||||
}
|
||||
}
|
||||
warehouse.setType("供应链");
|
||||
warehouse.setType("SPLY");
|
||||
warehouse.setIsEnable("1");
|
||||
erpWarehouseMapper.insert(warehouse);
|
||||
// 返回
|
||||
@@ -79,7 +81,7 @@ public class ErpWarehouseServiceImpl implements ErpWarehouseService {
|
||||
validateErpWarehouseExists(updateReqVO.getId());
|
||||
// 更新
|
||||
ErpWarehouseDO updateObj = BeanUtils.toBean(updateReqVO, ErpWarehouseDO.class);
|
||||
if (updateObj.getType().equals("供应链")&&updateObj.getIsEnable().equals("0")){
|
||||
if (updateObj.getType().equals("SPLY")&&updateObj.getIsEnable().equals("0")){
|
||||
erpWarehouseMapper.updateById(updateObj);
|
||||
}else {
|
||||
throw exception(ERP_WAREHOUSE_NOT_ALLOW_UPDATE);
|
||||
@@ -115,6 +117,16 @@ public class ErpWarehouseServiceImpl implements ErpWarehouseService {
|
||||
}
|
||||
}
|
||||
|
||||
private void validateErpFactoryExistsNumber(String number, String factoryNumber) {
|
||||
List<ErpWarehouseDO> list = erpWarehouseMapper.selectList(new LambdaQueryWrapperX<ErpWarehouseDO>()).stream()
|
||||
.filter(erpWarehouseDO -> erpWarehouseDO.getNumber().equals(number))
|
||||
.filter(erpWarehouseDO -> erpWarehouseDO.getFactoryNumber().equals(factoryNumber))
|
||||
.toList();
|
||||
if (!list.isEmpty()) {
|
||||
throw exception(ERP_WAREHOUSE_EXISTS);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ErpWarehouseDO getErpWarehouse(Long id) {
|
||||
return erpWarehouseMapper.selectById(id);
|
||||
|
||||
Reference in New Issue
Block a user