|
|
|
@ -6,18 +6,21 @@ import com.glxp.sale.admin.constant.ConstantStatus;
|
|
|
|
|
import com.glxp.sale.admin.entity.basic.BasicThirdSysEntity;
|
|
|
|
|
import com.glxp.sale.admin.entity.basic.UdiInfoEntity;
|
|
|
|
|
import com.glxp.sale.admin.entity.basic.UdiRelevanceEntity;
|
|
|
|
|
import com.glxp.sale.admin.entity.info.CompanyEntity;
|
|
|
|
|
import com.glxp.sale.admin.entity.thrsys.ThrProductsEntity;
|
|
|
|
|
import com.glxp.sale.admin.entity.udid.UdiEntity;
|
|
|
|
|
import com.glxp.sale.admin.httpclient.ErpBasicClient;
|
|
|
|
|
import com.glxp.sale.admin.req.basic.CombineRequest;
|
|
|
|
|
import com.glxp.sale.admin.req.basic.FilterErpGoodsRequest;
|
|
|
|
|
import com.glxp.sale.admin.req.basic.FilterUdiInfoRequest;
|
|
|
|
|
import com.glxp.sale.admin.req.basic.UdiInfoExportRequest;
|
|
|
|
|
import com.glxp.sale.admin.req.thrsys.FilterThrProductsRequest;
|
|
|
|
|
import com.glxp.sale.admin.res.PageSimpleResponse;
|
|
|
|
|
import com.glxp.sale.admin.res.basic.ErpProductsResponse;
|
|
|
|
|
import com.glxp.sale.admin.service.basic.BasicThirdSysService;
|
|
|
|
|
import com.glxp.sale.admin.service.basic.UdiInfoService;
|
|
|
|
|
import com.glxp.sale.admin.service.basic.UdiRelevanceService;
|
|
|
|
|
import com.glxp.sale.admin.service.info.CompanyService;
|
|
|
|
|
import com.glxp.sale.admin.service.thrsys.ThrProductsService;
|
|
|
|
|
import com.glxp.sale.admin.util.CustomUtil;
|
|
|
|
|
import com.glxp.sale.admin.util.DateUtil;
|
|
|
|
@ -51,7 +54,10 @@ public class BasicUpdateProductService {
|
|
|
|
|
BasicThirdSysService basicThirdSysService;
|
|
|
|
|
@Resource
|
|
|
|
|
private ErpBasicClient erpBasicClient;
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
CompanyService companyService;
|
|
|
|
|
@Resource
|
|
|
|
|
private CompanyProductsRelService companyProductsRelService;
|
|
|
|
|
|
|
|
|
|
public String addProduct(CombineRequest combineRequest, String url) {
|
|
|
|
|
String errMsg = null;
|
|
|
|
@ -119,7 +125,76 @@ public class BasicUpdateProductService {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public String addLocalProduct(CombineRequest combineRequest) {
|
|
|
|
|
String errMsg = null;
|
|
|
|
|
String errMsg = "";
|
|
|
|
|
List<String> inventoryCodes = new ArrayList<>();
|
|
|
|
|
if (combineRequest.getThirdIds() == null)
|
|
|
|
|
inventoryCodes.add(combineRequest.getThirdId());
|
|
|
|
|
else {
|
|
|
|
|
inventoryCodes = combineRequest.getThirdIds();
|
|
|
|
|
}
|
|
|
|
|
if (inventoryCodes.size() > 0) {
|
|
|
|
|
for (String inventoryCode : inventoryCodes) {
|
|
|
|
|
UdiRelevanceEntity udiRelevanceEntity1 = new UdiRelevanceEntity();
|
|
|
|
|
udiRelevanceEntity1.setThirdId(inventoryCode);
|
|
|
|
|
FilterThrProductsRequest filterThrProductsRequest = new FilterThrProductsRequest();
|
|
|
|
|
filterThrProductsRequest.setCode(inventoryCode);
|
|
|
|
|
List<ThrProductsEntity> thrProductsEntities = thrProductsService.selectThrProducts(filterThrProductsRequest);
|
|
|
|
|
if (thrProductsEntities != null && thrProductsEntities.size() > 0) {
|
|
|
|
|
ThrProductsEntity thrProductsEntity = thrProductsEntities.get(0);
|
|
|
|
|
ErpProductsResponse erpProductsResponse = new ErpProductsResponse();
|
|
|
|
|
BeanUtils.copyProperties(thrProductsEntity, erpProductsResponse);
|
|
|
|
|
UdiInfoEntity udiInfoEntity = udiInfoService.findByNameCode(thrProductsEntity.getCode());
|
|
|
|
|
if (udiInfoEntity == null) {
|
|
|
|
|
udiInfoEntity = new UdiInfoEntity();
|
|
|
|
|
BeanUtils.copyProperties(thrProductsEntity, udiInfoEntity);
|
|
|
|
|
udiInfoEntity.setNameCode(thrProductsEntity.getCode());
|
|
|
|
|
udiInfoEntity.setCpmctymc(thrProductsEntity.getName());
|
|
|
|
|
udiInfoEntity.setManufactory(thrProductsEntity.getManufactory());
|
|
|
|
|
udiInfoEntity.setYlqxzcrbarmc(thrProductsEntity.getManufactory());
|
|
|
|
|
udiInfoEntity.setGgxh(thrProductsEntity.getSpec());
|
|
|
|
|
udiInfoEntity.setZczbhhzbapzbh(thrProductsEntity.getRegisterNo());
|
|
|
|
|
udiInfoEntity.setUuid(CustomUtil.getUUId());
|
|
|
|
|
udiInfoEntity.setProductType(ConstantStatus.PRODUCT_TYPE_THIRD);
|
|
|
|
|
udiInfoEntity.setDiType(1);
|
|
|
|
|
udiInfoService.insertUdiInfo(udiInfoEntity);
|
|
|
|
|
}
|
|
|
|
|
udiRelevanceEntity1.setUuid(udiInfoEntity.getUuid());
|
|
|
|
|
udiRelevanceEntity1.setThirdName(thrProductsEntity.getName());
|
|
|
|
|
udiRelevanceEntity1.setUpdateTime(DateUtil.getDateTime());
|
|
|
|
|
|
|
|
|
|
BasicThirdSysEntity basicThirdSysEntity = basicThirdSysService.selectMainThrSys();
|
|
|
|
|
String mainSys = basicThirdSysEntity.getThirdId();
|
|
|
|
|
if (mainSys.equals("thirdId")) {
|
|
|
|
|
udiRelevanceEntity1.setMainId(udiRelevanceEntity1.getThirdId());
|
|
|
|
|
udiRelevanceEntity1.setMainName(udiRelevanceEntity1.getThirdName());
|
|
|
|
|
} else if (mainSys.equals("thirdId1")) {
|
|
|
|
|
udiRelevanceEntity1.setMainId(udiRelevanceEntity1.getThirdId1());
|
|
|
|
|
udiRelevanceEntity1.setMainName(udiRelevanceEntity1.getThirdName1());
|
|
|
|
|
} else if (mainSys.equals("thirdId2")) {
|
|
|
|
|
udiRelevanceEntity1.setMainId(udiRelevanceEntity1.getThirdId2());
|
|
|
|
|
udiRelevanceEntity1.setMainName(udiRelevanceEntity1.getThirdName2());
|
|
|
|
|
} else if (mainSys.equals("thirdId3")) {
|
|
|
|
|
udiRelevanceEntity1.setMainId(udiRelevanceEntity1.getThirdId3());
|
|
|
|
|
udiRelevanceEntity1.setMainName(udiRelevanceEntity1.getThirdName3());
|
|
|
|
|
} else if (mainSys.equals("thirdId4")) {
|
|
|
|
|
udiRelevanceEntity1.setMainId(udiRelevanceEntity1.getThirdId4());
|
|
|
|
|
udiRelevanceEntity1.setMainName(udiRelevanceEntity1.getThirdName4());
|
|
|
|
|
}
|
|
|
|
|
UdiRelevanceEntity udiRelevanceEntity = udiRelevanceService.selectUpteaByAll(udiRelevanceEntity1.getUuid(), udiRelevanceEntity1.getMainId());
|
|
|
|
|
if (udiRelevanceEntity == null) {
|
|
|
|
|
udiRelevanceService.insertUdiRelevanceignore(udiRelevanceEntity1);
|
|
|
|
|
} else {
|
|
|
|
|
errMsg = errMsg + "产品编码:" + udiRelevanceEntity1.getMainId() + "已存在!;";
|
|
|
|
|
}
|
|
|
|
|
udiRelevanceService.insertUdiRelevanceignore(udiRelevanceEntity1);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return errMsg;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public String addSupLocalProduct(CombineRequest combineRequest) {
|
|
|
|
|
String errMsg = "";
|
|
|
|
|
List<String> inventoryCodes = new ArrayList<>();
|
|
|
|
|
if (combineRequest.getThirdIds() == null)
|
|
|
|
|
inventoryCodes.add(combineRequest.getThirdId());
|
|
|
|
@ -127,6 +202,7 @@ public class BasicUpdateProductService {
|
|
|
|
|
inventoryCodes = combineRequest.getThirdIds();
|
|
|
|
|
}
|
|
|
|
|
if (inventoryCodes.size() > 0) {
|
|
|
|
|
List<String> rlIds = new ArrayList<>();
|
|
|
|
|
for (String inventoryCode : inventoryCodes) {
|
|
|
|
|
UdiRelevanceEntity udiRelevanceEntity1 = new UdiRelevanceEntity();
|
|
|
|
|
udiRelevanceEntity1.setThirdId(inventoryCode);
|
|
|
|
@ -137,21 +213,25 @@ public class BasicUpdateProductService {
|
|
|
|
|
ThrProductsEntity thrProductsEntity = thrProductsEntities.get(0);
|
|
|
|
|
ErpProductsResponse erpProductsResponse = new ErpProductsResponse();
|
|
|
|
|
BeanUtils.copyProperties(thrProductsEntity, erpProductsResponse);
|
|
|
|
|
UdiInfoEntity udiInfoEntity = new UdiInfoEntity();
|
|
|
|
|
BeanUtils.copyProperties(thrProductsEntity, udiInfoEntity);
|
|
|
|
|
udiInfoEntity.setNameCode(thrProductsEntity.getCode());
|
|
|
|
|
udiInfoEntity.setCpmctymc(thrProductsEntity.getName());
|
|
|
|
|
udiInfoEntity.setManufactory(thrProductsEntity.getManufactory());
|
|
|
|
|
udiInfoEntity.setYlqxzcrbarmc(thrProductsEntity.getManufactory());
|
|
|
|
|
udiInfoEntity.setGgxh(thrProductsEntity.getSpec());
|
|
|
|
|
udiInfoEntity.setZczbhhzbapzbh(thrProductsEntity.getRegisterNo());
|
|
|
|
|
udiInfoEntity.setUuid(CustomUtil.getUUId());
|
|
|
|
|
udiInfoEntity.setProductType(ConstantStatus.PRODUCT_TYPE_THIRD);
|
|
|
|
|
udiInfoEntity.setDiType(1);
|
|
|
|
|
udiInfoService.insertUdiInfo(udiInfoEntity);
|
|
|
|
|
UdiInfoEntity udiInfoEntity = udiInfoService.findByNameCode(thrProductsEntity.getCode());
|
|
|
|
|
if (udiInfoEntity == null) {
|
|
|
|
|
udiInfoEntity = new UdiInfoEntity();
|
|
|
|
|
BeanUtils.copyProperties(thrProductsEntity, udiInfoEntity);
|
|
|
|
|
udiInfoEntity.setNameCode(thrProductsEntity.getCode());
|
|
|
|
|
udiInfoEntity.setCpmctymc(thrProductsEntity.getName());
|
|
|
|
|
udiInfoEntity.setManufactory(thrProductsEntity.getManufactory());
|
|
|
|
|
udiInfoEntity.setYlqxzcrbarmc(thrProductsEntity.getManufactory());
|
|
|
|
|
udiInfoEntity.setGgxh(thrProductsEntity.getSpec());
|
|
|
|
|
udiInfoEntity.setZczbhhzbapzbh(thrProductsEntity.getRegisterNo());
|
|
|
|
|
udiInfoEntity.setUuid(CustomUtil.getUUId());
|
|
|
|
|
udiInfoEntity.setProductType(ConstantStatus.PRODUCT_TYPE_THIRD);
|
|
|
|
|
udiInfoEntity.setDiType(1);
|
|
|
|
|
udiInfoService.insertUdiInfo(udiInfoEntity);
|
|
|
|
|
}
|
|
|
|
|
udiRelevanceEntity1.setUuid(udiInfoEntity.getUuid());
|
|
|
|
|
udiRelevanceEntity1.setThirdName(thrProductsEntity.getName());
|
|
|
|
|
udiRelevanceEntity1.setUpdateTime(DateUtil.getDateTime());
|
|
|
|
|
udiRelevanceEntity1.setSupName(thrProductsEntity.getSupName());
|
|
|
|
|
|
|
|
|
|
BasicThirdSysEntity basicThirdSysEntity = basicThirdSysService.selectMainThrSys();
|
|
|
|
|
String mainSys = basicThirdSysEntity.getThirdId();
|
|
|
|
@ -171,9 +251,23 @@ public class BasicUpdateProductService {
|
|
|
|
|
udiRelevanceEntity1.setMainId(udiRelevanceEntity1.getThirdId4());
|
|
|
|
|
udiRelevanceEntity1.setMainName(udiRelevanceEntity1.getThirdName4());
|
|
|
|
|
}
|
|
|
|
|
udiRelevanceService.insertUdiRelevance(udiRelevanceEntity1);
|
|
|
|
|
UdiRelevanceEntity udiRelevanceEntity = udiRelevanceService.selectUpteaByAll(udiRelevanceEntity1.getUuid(), udiRelevanceEntity1.getMainId());
|
|
|
|
|
if (udiRelevanceEntity == null) {
|
|
|
|
|
udiRelevanceService.insertUdiRelevanceignore(udiRelevanceEntity1);
|
|
|
|
|
} else {
|
|
|
|
|
errMsg = errMsg + "产品编码:" + udiRelevanceEntity1.getMainId() + "已存在,将直接选入!;";
|
|
|
|
|
}
|
|
|
|
|
UdiRelevanceEntity temp = udiRelevanceService.selectUpteaByAll(udiRelevanceEntity1.getUuid(), udiRelevanceEntity1.getMainId());
|
|
|
|
|
rlIds.add(temp.getId());
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
CompanyEntity companyEntity = companyService.findCompany(combineRequest.getCustomerId());
|
|
|
|
|
UdiInfoExportRequest udiInfoExportRequest = new UdiInfoExportRequest();
|
|
|
|
|
udiInfoExportRequest.setRlIds(rlIds);
|
|
|
|
|
udiInfoExportRequest.setUnitFk(companyEntity.getUnitIdFk());
|
|
|
|
|
udiInfoExportRequest.setCustomerId(combineRequest.getCustomerId());
|
|
|
|
|
companyProductsRelService.insertCompanyProducts(udiInfoExportRequest);
|
|
|
|
|
}
|
|
|
|
|
return errMsg;
|
|
|
|
|
}
|
|
|
|
|