|
@@ -20,6 +20,9 @@ import lombok.extern.slf4j.Slf4j;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.util.StringUtils;
|
|
import org.springframework.util.StringUtils;
|
|
|
|
|
|
|
|
+import javax.persistence.CascadeType;
|
|
|
|
+import javax.persistence.FetchType;
|
|
|
|
+import javax.persistence.OneToMany;
|
|
import java.time.LocalDateTime;
|
|
import java.time.LocalDateTime;
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
import java.util.Date;
|
|
import java.util.Date;
|
|
@@ -239,6 +242,45 @@ public class ChuanyunServiceImpl implements ChuanyunService {
|
|
chuanyunOperationInformationDao.save(chuanyunOperationInformationDO);
|
|
chuanyunOperationInformationDao.save(chuanyunOperationInformationDO);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
+ public void importProduct(List<ChuanyunProductDO> list) {
|
|
|
|
+ try {
|
|
|
|
+ ChuanyunProductLibraryDO chuanyunProductLibraryDO = new ChuanyunProductLibraryDO();
|
|
|
|
+ List<ChuanyunProductLibrarySpecificationsDO> list1 = new ArrayList<>();
|
|
|
|
+ list.forEach(chuanyunProductDO -> {
|
|
|
|
+ if (!StringUtils.isEmpty(chuanyunProductDO.getProductModel())){
|
|
|
|
+ chuanyunProductLibraryDO.setProductModel(chuanyunProductDO.getProductModel());
|
|
|
|
+ }
|
|
|
|
+ ChuanyunProductLibrarySpecificationsDO chuanyunProductLibrarySpecificationsDO = new ChuanyunProductLibrarySpecificationsDO();
|
|
|
|
+ chuanyunProductLibrarySpecificationsDO.setSpecName(chuanyunProductDO.getSpecName());
|
|
|
|
+ chuanyunProductLibrarySpecificationsDO.setSpecValue(chuanyunProductDO.getSpecValue());
|
|
|
|
+ chuanyunProductLibrarySpecificationsDO.setRemark(chuanyunProductDO.getRemark());
|
|
|
|
+ list1.add(chuanyunProductLibrarySpecificationsDO);
|
|
|
|
+ });
|
|
|
|
+ var objectMapper=new ObjectMapper();
|
|
|
|
+ List<String> matchers = new ArrayList<>();
|
|
|
|
+ matchers.add("F0000004_2,"+chuanyunProductLibraryDO.getProductModel());
|
|
|
|
+ var filter= Filter.instance(0,1,true,"And",matchers);
|
|
|
|
+ var chuanyunFindAllResponse=chuanYunManager.findAll(ChuanyunProductLibraryDO.SCHEMA_CODE,filter);
|
|
|
|
+ if (chuanyunFindAllResponse.getReturnData()!=null) {
|
|
|
|
+ List<ChuanyunProductLibraryDO> result=objectMapper.convertValue(chuanyunFindAllResponse.getReturnData().getBizObjectArray(), new TypeReference<>(){});
|
|
|
|
+ chuanYunManager.delete(ChuanyunProductLibraryDO.SCHEMA_CODE,result.get(0).getObjectId());
|
|
|
|
+ }
|
|
|
|
+ ProductLibraryDTO productLibraryDTO = new ProductLibraryDTO(chuanyunProductLibraryDO);
|
|
|
|
+ productLibraryDTO.setList(list1);
|
|
|
|
+ var productString = objectMapper.writeValueAsString(productLibraryDTO);
|
|
|
|
+ ChuanyunSaveDTO chuanyunSaveDTO = chuanYunManager.save(ChuanyunProductLibraryDO.SCHEMA_CODE,productString,true);
|
|
|
|
+ if(chuanyunSaveDTO.getSuccessful()){
|
|
|
|
+ log.info("更新产品库成功");
|
|
|
|
+ }else{
|
|
|
|
+ log.warn("更新产品库失败");
|
|
|
|
+ }
|
|
|
|
+ }catch (Exception e){
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ log.error(e.getMessage());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 更新外部部门名称
|
|
* 更新外部部门名称
|
|
* @param
|
|
* @param
|
|
@@ -343,6 +385,25 @@ public class ChuanyunServiceImpl implements ChuanyunService {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @Data
|
|
|
|
+ static class ProductLibraryDTO{
|
|
|
|
+
|
|
|
|
+ @JsonProperty("F0000004")
|
|
|
|
+ private String productModel;
|
|
|
|
+
|
|
|
|
+ @JsonProperty("D001789F4d732f3541934286b97c21a1ea1e5398")
|
|
|
|
+ @OneToMany(cascade = CascadeType.ALL, orphanRemoval = true,fetch = FetchType.EAGER)
|
|
|
|
+ private List<ChuanyunProductLibrarySpecificationsDO> list;
|
|
|
|
+
|
|
|
|
+ public ProductLibraryDTO(ChuanyunProductLibraryDO chuanyunProductLibraryDO) {
|
|
|
|
+ if(null!=chuanyunProductLibraryDO){
|
|
|
|
+ if (null!=chuanyunProductLibraryDO.getProductModel()){
|
|
|
|
+ this.productModel=chuanyunProductLibraryDO.getProductModel();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
|
|
@Data
|
|
@Data
|
|
class outDepartmentDTO {
|
|
class outDepartmentDTO {
|