|
@@ -3,16 +3,22 @@ package com.kmall.admin.service.impl;
|
|
import com.alibaba.fastjson.JSON;
|
|
import com.alibaba.fastjson.JSON;
|
|
import com.google.common.base.Joiner;
|
|
import com.google.common.base.Joiner;
|
|
import com.google.gson.Gson;
|
|
import com.google.gson.Gson;
|
|
|
|
+import com.google.gson.internal.LinkedTreeMap;
|
|
import com.kmall.admin.dao.GoodsProductDao;
|
|
import com.kmall.admin.dao.GoodsProductDao;
|
|
import com.kmall.admin.dto.GoodsProductDto;
|
|
import com.kmall.admin.dto.GoodsProductDto;
|
|
import com.kmall.admin.dto.PdProductDtoInfo;
|
|
import com.kmall.admin.dto.PdProductDtoInfo;
|
|
import com.kmall.admin.entity.GoodsProductEntity;
|
|
import com.kmall.admin.entity.GoodsProductEntity;
|
|
|
|
+import com.kmall.admin.entity.SysCusNationCodeEntity;
|
|
|
|
+import com.kmall.admin.entity.SysCusUnitCodeEntity;
|
|
import com.kmall.admin.service.GoodsProductService;
|
|
import com.kmall.admin.service.GoodsProductService;
|
|
import com.kmall.admin.service.GoodsService;
|
|
import com.kmall.admin.service.GoodsService;
|
|
|
|
+import com.kmall.admin.service.SysCusNationCodeService;
|
|
|
|
+import com.kmall.admin.service.SysCusUnitCodeService;
|
|
import com.kmall.admin.utils.ShiroUtils;
|
|
import com.kmall.admin.utils.ShiroUtils;
|
|
import com.kmall.admin.utils.data.response.ResponseMessage;
|
|
import com.kmall.admin.utils.data.response.ResponseMessage;
|
|
import com.kmall.admin.utils.oms.OmsSign;
|
|
import com.kmall.admin.utils.oms.OmsSign;
|
|
import com.kmall.common.constant.Dict;
|
|
import com.kmall.common.constant.Dict;
|
|
|
|
+import com.kmall.common.utils.DateUtils;
|
|
import com.kmall.common.utils.R;
|
|
import com.kmall.common.utils.R;
|
|
import com.kmall.common.utils.RRException;
|
|
import com.kmall.common.utils.RRException;
|
|
import com.kmall.manager.manager.merch.OmsMerchProperties;
|
|
import com.kmall.manager.manager.merch.OmsMerchProperties;
|
|
@@ -50,6 +56,11 @@ public class GoodsProductServiceImpl implements GoodsProductService {
|
|
@Autowired
|
|
@Autowired
|
|
private OmsMerchProperties omsMerchProperties;
|
|
private OmsMerchProperties omsMerchProperties;
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
+ private SysCusNationCodeService sysCusNationCodeService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private SysCusUnitCodeService sysCusUnitCodeService;
|
|
|
|
+
|
|
@Override
|
|
@Override
|
|
public GoodsProductEntity queryObject(Integer mallGoodsProductSn) {
|
|
public GoodsProductEntity queryObject(Integer mallGoodsProductSn) {
|
|
return goodsProductDao.queryObject(mallGoodsProductSn);
|
|
return goodsProductDao.queryObject(mallGoodsProductSn);
|
|
@@ -123,9 +134,13 @@ public class GoodsProductServiceImpl implements GoodsProductService {
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@Transactional
|
|
@Transactional
|
|
- public void uploadExcel(List<GoodsProductDto> goodsProductDtoList) {
|
|
|
|
|
|
+ public int uploadExcel(List<GoodsProductDto> goodsProductDtoList) {
|
|
|
|
+ //获取 原产国信息
|
|
|
|
+ List<SysCusNationCodeEntity> cusNationCodeEntityList = sysCusNationCodeService.findCusNationByAll();
|
|
|
|
+ // 获取单位代码
|
|
|
|
+ List<SysCusUnitCodeEntity> cusUnitCodeEntityList = sysCusUnitCodeService.getAll();
|
|
if (Objects.nonNull(goodsProductDtoList) && goodsProductDtoList.size() > 0) {
|
|
if (Objects.nonNull(goodsProductDtoList) && goodsProductDtoList.size() > 0) {
|
|
- int count = 1;
|
|
|
|
|
|
+ int count = 0;
|
|
for (GoodsProductDto goodsProductDto : goodsProductDtoList) {
|
|
for (GoodsProductDto goodsProductDto : goodsProductDtoList) {
|
|
if (StringUtils.isEmpty(goodsProductDto.getMerchSn())) {
|
|
if (StringUtils.isEmpty(goodsProductDto.getMerchSn())) {
|
|
throw new RRException("第" + count + "行的商户编号为空!");
|
|
throw new RRException("第" + count + "行的商户编号为空!");
|
|
@@ -141,6 +156,9 @@ public class GoodsProductServiceImpl implements GoodsProductService {
|
|
}
|
|
}
|
|
if (StringUtils.isEmpty(goodsProductDto.getProdName())) {
|
|
if (StringUtils.isEmpty(goodsProductDto.getProdName())) {
|
|
throw new RRException("第" + count + "行的商品中文名为空!");
|
|
throw new RRException("第" + count + "行的商品中文名为空!");
|
|
|
|
+ }else {
|
|
|
|
+ String prodName = goodsProductDto.getProdName();
|
|
|
|
+ goodsProductDto.setProdRecordName(prodName);
|
|
}
|
|
}
|
|
if (StringUtils.isEmpty(goodsProductDto.getProdEname())) {
|
|
if (StringUtils.isEmpty(goodsProductDto.getProdEname())) {
|
|
throw new RRException("第" + count + "行的商品英文名为空!");
|
|
throw new RRException("第" + count + "行的商品英文名为空!");
|
|
@@ -152,7 +170,7 @@ public class GoodsProductServiceImpl implements GoodsProductService {
|
|
throw new RRException("第" + count + "行的品牌中文或品牌英文必填其中之一!");
|
|
throw new RRException("第" + count + "行的品牌中文或品牌英文必填其中之一!");
|
|
}
|
|
}
|
|
if (!StringUtils.isEmpty(goodsProductDto.getProdBrandCn()) && !StringUtils.isEmpty(goodsProductDto.getProdBrandEn())) {
|
|
if (!StringUtils.isEmpty(goodsProductDto.getProdBrandCn()) && !StringUtils.isEmpty(goodsProductDto.getProdBrandEn())) {
|
|
- goodsProductDto.setProdBrand(goodsProductDto.getProdBrandCn() + "#&#" + goodsProductDto.getProdBrandEn());
|
|
|
|
|
|
+ goodsProductDto.setProdBrand(goodsProductDto.getProdBrandCn() + goodsProductDto.getProdBrandEn());
|
|
} else if (!StringUtils.isEmpty(goodsProductDto.getProdBrandCn()) && StringUtils.isEmpty(goodsProductDto.getProdBrandEn())) {
|
|
} else if (!StringUtils.isEmpty(goodsProductDto.getProdBrandCn()) && StringUtils.isEmpty(goodsProductDto.getProdBrandEn())) {
|
|
goodsProductDto.setProdBrand(goodsProductDto.getProdBrandCn());
|
|
goodsProductDto.setProdBrand(goodsProductDto.getProdBrandCn());
|
|
} else {
|
|
} else {
|
|
@@ -160,15 +178,40 @@ public class GoodsProductServiceImpl implements GoodsProductService {
|
|
}
|
|
}
|
|
if (StringUtils.isEmpty(goodsProductDto.getUnitCode())) {
|
|
if (StringUtils.isEmpty(goodsProductDto.getUnitCode())) {
|
|
throw new RRException("第" + count + "行的计量单位为空!");
|
|
throw new RRException("第" + count + "行的计量单位为空!");
|
|
|
|
+ }else {
|
|
|
|
+ String unitCode = goodsProductDto.getUnitCode();
|
|
|
|
+ for (SysCusUnitCodeEntity sysCusUnitCodeEntity : cusUnitCodeEntityList) {
|
|
|
|
+ String code = sysCusUnitCodeEntity.getCode();
|
|
|
|
+ String name = sysCusUnitCodeEntity.getName();
|
|
|
|
+ if (unitCode.equals(name)) {
|
|
|
|
+ goodsProductDto.setUnitCode(code);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|
|
if (StringUtils.isEmpty(goodsProductDto.getCusGoodsCode())) {
|
|
if (StringUtils.isEmpty(goodsProductDto.getCusGoodsCode())) {
|
|
throw new RRException("第" + count + "行的海关商品编码为空!");
|
|
throw new RRException("第" + count + "行的海关商品编码为空!");
|
|
|
|
+ }else {
|
|
|
|
+ String cusGoodsCode = goodsProductDto.getCusGoodsCode();
|
|
|
|
+ cusGoodsCode = new BigDecimal(cusGoodsCode).toPlainString();
|
|
|
|
+ goodsProductDto.setCusGoodsCode(cusGoodsCode);
|
|
}
|
|
}
|
|
if (StringUtils.isEmpty(goodsProductDto.getCusDeclEle())) {
|
|
if (StringUtils.isEmpty(goodsProductDto.getCusDeclEle())) {
|
|
throw new RRException("第" + count + "行的申报要素为空!");
|
|
throw new RRException("第" + count + "行的申报要素为空!");
|
|
|
|
+ }else {
|
|
|
|
+ String trim = goodsProductDto.getCusDeclEle().trim();
|
|
|
|
+ goodsProductDto.setCusDeclEle(trim);
|
|
}
|
|
}
|
|
if (StringUtils.isEmpty(goodsProductDto.getOriCntCode())) {
|
|
if (StringUtils.isEmpty(goodsProductDto.getOriCntCode())) {
|
|
throw new RRException("第" + count + "行的原产国代码为空!");
|
|
throw new RRException("第" + count + "行的原产国代码为空!");
|
|
|
|
+ }else {
|
|
|
|
+ String oriCntCode = goodsProductDto.getOriCntCode();
|
|
|
|
+ for (SysCusNationCodeEntity sysCusNationCodeEntity : cusNationCodeEntityList) {
|
|
|
|
+ String code = sysCusNationCodeEntity.getCode();
|
|
|
|
+ String name = sysCusNationCodeEntity.getName();
|
|
|
|
+ if (oriCntCode.equals(name)) {
|
|
|
|
+ goodsProductDto.setOriCntCode(code);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|
|
if (StringUtils.isEmpty(goodsProductDto.getCiqProdModel())) {
|
|
if (StringUtils.isEmpty(goodsProductDto.getCiqProdModel())) {
|
|
throw new RRException("第" + count + "行的规格型号为空!");
|
|
throw new RRException("第" + count + "行的规格型号为空!");
|
|
@@ -185,20 +228,55 @@ public class GoodsProductServiceImpl implements GoodsProductService {
|
|
if (StringUtils.isEmpty(goodsProductDto.getDeclPrice())) {
|
|
if (StringUtils.isEmpty(goodsProductDto.getDeclPrice())) {
|
|
throw new RRException("第" + count + "行的申报价格为空!");
|
|
throw new RRException("第" + count + "行的申报价格为空!");
|
|
}
|
|
}
|
|
- if (StringUtils.isEmpty(goodsProductDto.getLegalUnit1Qty())) {
|
|
|
|
|
|
+ /*if (StringUtils.isEmpty(goodsProductDto.getLegalUnit1Qty())) {
|
|
throw new RRException("第" + count + "行的第一法定单位数量为空!");
|
|
throw new RRException("第" + count + "行的第一法定单位数量为空!");
|
|
}
|
|
}
|
|
if (StringUtils.isEmpty(goodsProductDto.getLegalUnit2Qty())) {
|
|
if (StringUtils.isEmpty(goodsProductDto.getLegalUnit2Qty())) {
|
|
throw new RRException("第" + count + "行的第二法定单位数量为空!");
|
|
throw new RRException("第" + count + "行的第二法定单位数量为空!");
|
|
|
|
+ }*/
|
|
|
|
+ if (StringUtils.isEmpty(goodsProductDto.getSupplierName())){
|
|
|
|
+ throw new RRException("第" + count + "行的供应商企业名称为空!");
|
|
|
|
+ }
|
|
|
|
+ if (StringUtils.isEmpty(goodsProductDto.getSupplierCntCode())){
|
|
|
|
+ throw new RRException("第" + count + "行的供应商国别名称为空!");
|
|
|
|
+ }else {
|
|
|
|
+ String supplierCntCode = goodsProductDto.getSupplierCntCode();
|
|
|
|
+ for (SysCusNationCodeEntity sysCusNationCodeEntity : cusNationCodeEntityList) {
|
|
|
|
+ String code = sysCusNationCodeEntity.getCode();
|
|
|
|
+ String name = sysCusNationCodeEntity.getName();
|
|
|
|
+ if (supplierCntCode.equals(name)) {
|
|
|
|
+ goodsProductDto.setSupplierCntCode(code);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|
|
- GoodsProductEntity queryProduct = goodsProductDao.selectByParams(goodsProductDto.getSku(), goodsProductDto.getMerchSn(), goodsProductDto.getThirdMerchSn());
|
|
|
|
|
|
+ if (StringUtils.isEmpty(goodsProductDto.getProdCompName())){
|
|
|
|
+ throw new RRException("第" + count + "行的生产企业名称为空!");
|
|
|
|
+ }
|
|
|
|
+ if (StringUtils.isEmpty(goodsProductDto.getProdCompCntCode())){
|
|
|
|
+ throw new RRException("第" + count + "行的生产国别名称为空!");
|
|
|
|
+ }else {
|
|
|
|
+ String prodCompCntCode = goodsProductDto.getProdCompCntCode();
|
|
|
|
+ for (SysCusNationCodeEntity sysCusNationCodeEntity : cusNationCodeEntityList) {
|
|
|
|
+ String code = sysCusNationCodeEntity.getCode();
|
|
|
|
+ String name = sysCusNationCodeEntity.getName();
|
|
|
|
+ if (prodCompCntCode.equals(name)) {
|
|
|
|
+ goodsProductDto.setProdCompCntCode(code);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ GoodsProductEntity queryProduct = goodsProductDao.selectByParams(goodsProductDto.getSku(), goodsProductDto.getMerchSn(), goodsProductDto.getThirdMerchSn(),goodsProductDto.getProdBarcode());
|
|
if (Objects.nonNull(queryProduct)) {
|
|
if (Objects.nonNull(queryProduct)) {
|
|
- throw new RRException("该sku:" + queryProduct.getSku() + "已存在!");
|
|
|
|
|
|
+ throw new RRException("该sku:" + queryProduct.getSku() + " 商品条形码:"+goodsProductDto.getProdBarcode()+"已存在!");
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ count++;
|
|
|
|
+ }
|
|
|
|
+ List<GoodsProductEntity> insertList = new ArrayList<>();
|
|
|
|
+ for (GoodsProductDto goodsProductDto : goodsProductDtoList) {
|
|
GoodsProductEntity goodsProductEntity = new GoodsProductEntity();
|
|
GoodsProductEntity goodsProductEntity = new GoodsProductEntity();
|
|
BeanUtils.copyProperties(goodsProductDto, goodsProductEntity);
|
|
BeanUtils.copyProperties(goodsProductDto, goodsProductEntity);
|
|
- goodsProductEntity.setLegalUnit1Qty(new BigDecimal(goodsProductDto.getLegalUnit1Qty()));
|
|
|
|
- goodsProductEntity.setLegalUnit2Qty(new BigDecimal(goodsProductDto.getLegalUnit2Qty()));
|
|
|
|
|
|
+// goodsProductEntity.setLegalUnit1Qty(new BigDecimal(goodsProductDto.getLegalUnit1Qty()));
|
|
|
|
+// goodsProductEntity.setLegalUnit2Qty(new BigDecimal(goodsProductDto.getLegalUnit2Qty()));
|
|
goodsProductEntity.setNetWeight(new BigDecimal(goodsProductDto.getNetWeight()));
|
|
goodsProductEntity.setNetWeight(new BigDecimal(goodsProductDto.getNetWeight()));
|
|
if (!StringUtils.isEmpty(goodsProductDto.getGrossWeight())) {
|
|
if (!StringUtils.isEmpty(goodsProductDto.getGrossWeight())) {
|
|
goodsProductEntity.setGrossWeight(new BigDecimal(goodsProductDto.getGrossWeight()));
|
|
goodsProductEntity.setGrossWeight(new BigDecimal(goodsProductDto.getGrossWeight()));
|
|
@@ -209,10 +287,12 @@ public class GoodsProductServiceImpl implements GoodsProductService {
|
|
goodsProductEntity.setCreateTime(new Date());
|
|
goodsProductEntity.setCreateTime(new Date());
|
|
goodsProductEntity.setCreaterSn(ShiroUtils.getUserId().toString());
|
|
goodsProductEntity.setCreaterSn(ShiroUtils.getUserId().toString());
|
|
goodsProductEntity.setStatus(Dict.productRecordStatus.item_00.getItem());
|
|
goodsProductEntity.setStatus(Dict.productRecordStatus.item_00.getItem());
|
|
- goodsProductDao.save(goodsProductEntity);
|
|
|
|
- count++;
|
|
|
|
|
|
+ insertList.add(goodsProductEntity);
|
|
}
|
|
}
|
|
|
|
+ goodsProductDao.saveBatch(insertList);
|
|
|
|
+ return count;
|
|
}
|
|
}
|
|
|
|
+ return 0;
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@@ -260,8 +340,8 @@ public class GoodsProductServiceImpl implements GoodsProductService {
|
|
for (GoodsProductEntity goodsProductEntity : goodsProductEntityList) {
|
|
for (GoodsProductEntity goodsProductEntity : goodsProductEntityList) {
|
|
GoodsProductDto dto = new GoodsProductDto();
|
|
GoodsProductDto dto = new GoodsProductDto();
|
|
BeanUtils.copyProperties(goodsProductEntity, dto);
|
|
BeanUtils.copyProperties(goodsProductEntity, dto);
|
|
- dto.setLegalUnit1Qty(goodsProductEntity.getLegalUnit1Qty().toString());
|
|
|
|
- dto.setLegalUnit2Qty(goodsProductEntity.getLegalUnit2Qty().toString());
|
|
|
|
|
|
+// dto.setLegalUnit1Qty(goodsProductEntity.getLegalUnit1Qty().toString());
|
|
|
|
+// dto.setLegalUnit2Qty(goodsProductEntity.getLegalUnit2Qty().toString());
|
|
dto.setNetWeight(goodsProductEntity.getNetWeight().toString());
|
|
dto.setNetWeight(goodsProductEntity.getNetWeight().toString());
|
|
dto.setGrossWeight(goodsProductEntity.getGrossWeight().toString());
|
|
dto.setGrossWeight(goodsProductEntity.getGrossWeight().toString());
|
|
dto.setDeclPrice(goodsProductEntity.getDeclPrice().toString());
|
|
dto.setDeclPrice(goodsProductEntity.getDeclPrice().toString());
|
|
@@ -307,8 +387,8 @@ public class GoodsProductServiceImpl implements GoodsProductService {
|
|
for (GoodsProductEntity goodsProductEntity : goodsProductEntityList) {
|
|
for (GoodsProductEntity goodsProductEntity : goodsProductEntityList) {
|
|
GoodsProductDto dto = new GoodsProductDto();
|
|
GoodsProductDto dto = new GoodsProductDto();
|
|
BeanUtils.copyProperties(goodsProductEntity, dto);
|
|
BeanUtils.copyProperties(goodsProductEntity, dto);
|
|
- dto.setLegalUnit1Qty(goodsProductEntity.getLegalUnit1Qty().toString());
|
|
|
|
- dto.setLegalUnit2Qty(goodsProductEntity.getLegalUnit2Qty().toString());
|
|
|
|
|
|
+// dto.setLegalUnit1Qty(goodsProductEntity.getLegalUnit1Qty().toString());
|
|
|
|
+// dto.setLegalUnit2Qty(goodsProductEntity.getLegalUnit2Qty().toString());
|
|
dto.setNetWeight(goodsProductEntity.getNetWeight().toString());
|
|
dto.setNetWeight(goodsProductEntity.getNetWeight().toString());
|
|
dto.setGrossWeight(goodsProductEntity.getGrossWeight().toString());
|
|
dto.setGrossWeight(goodsProductEntity.getGrossWeight().toString());
|
|
dto.setDeclPrice(goodsProductEntity.getDeclPrice().toString());
|
|
dto.setDeclPrice(goodsProductEntity.getDeclPrice().toString());
|
|
@@ -377,14 +457,126 @@ public class GoodsProductServiceImpl implements GoodsProductService {
|
|
@Override
|
|
@Override
|
|
public String pullFromOms() {
|
|
public String pullFromOms() {
|
|
try {
|
|
try {
|
|
-
|
|
|
|
|
|
+ Map<String, Object> condition = new HashMap<>();
|
|
|
|
+ condition.put("status", Dict.productRecordStatus.item_02.getItem() + "," + Dict.productRecordStatus.item_12.getItem());
|
|
|
|
+ List<GoodsProductEntity> goodsProductEntityList = goodsProductDao.queryList(condition);
|
|
|
|
+ if (goodsProductEntityList == null || goodsProductEntityList.size() == 0) {
|
|
|
|
+ return "没有要发送的数据";
|
|
|
|
+ }
|
|
|
|
+ List<String> skuList = goodsProductEntityList.stream().map(GoodsProductEntity::getSku).collect(Collectors.toList());
|
|
|
|
+ List<String> prodBarCodeList = goodsProductEntityList.stream().map(GoodsProductEntity::getProdBarcode).collect(Collectors.toList());
|
|
|
|
+ String merchSn = goodsProductEntityList.get(0).getMerchSn();
|
|
|
|
+ String emsClassCode = goodsProductEntityList.get(0).getEmsClassCode();
|
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
|
+ map.put("merchSn",merchSn);
|
|
|
|
+ map.put("emsClassCode",emsClassCode);
|
|
|
|
+ map.put("skuList",skuList);
|
|
|
|
+ map.put("prodBarCodeList",prodBarCodeList);
|
|
|
|
+ ResponseMessage result = requestOmsProductList(map);
|
|
|
|
+ if (!"0".equals(result.getCode())) {
|
|
|
|
+ return result.getMsg();
|
|
|
|
+ }
|
|
|
|
+ List<GoodsProductEntity> updateList = new ArrayList<>();
|
|
|
|
+ List<GoodsProductEntity> insertList = new ArrayList<>();
|
|
|
|
+ List rows = (List) result.getData().getRows().get(0);
|
|
|
|
+ for(int i = 0 ; i < rows.size() ; i ++) {
|
|
|
|
+ LinkedTreeMap<String, Object> treeMap = (LinkedTreeMap<String, Object>) rows.get(i);
|
|
|
|
+ String merchSn1 = treeMap.get("merchSn").toString(); //商户编号
|
|
|
|
+ String sku = treeMap.get("sku").toString(); //sku
|
|
|
|
+ String prodBarcode = treeMap.get("prodBarcode").toString(); //产品条形码
|
|
|
|
+ String prodBrand = treeMap.get("prodBrand").toString(); //品牌
|
|
|
|
+ String netWeight = treeMap.get("netWeight").toString(); //净重,kg
|
|
|
|
+ String grossWeight = treeMap.get("grossWeight").toString(); //毛重,kg
|
|
|
|
+ String ciqMainEle = treeMap.get("ciqMainEle").toString(); //主要成分
|
|
|
|
+ String cusCode = treeMap.get("cusCode").toString(); //
|
|
|
|
+ String bondedCode = treeMap.get("bondedCode").toString(); //海关商品编码
|
|
|
|
+ String localEmsNo = treeMap.get("localEmsNo").toString(); //园区账册编号
|
|
|
|
+ String itemRecordNo = treeMap.get("itemRecordNo").toString(); //园区商品序号
|
|
|
|
+ String remark = null ;
|
|
|
|
+ if (treeMap.get("remark") != null) {
|
|
|
|
+ remark = treeMap.get("remark").toString(); //备注
|
|
|
|
+ }
|
|
|
|
+ String legalUnit1Qty = treeMap.get("legalUnit1Qty").toString(); //法1
|
|
|
|
+ String legalUnit2Qty = treeMap.get("legalUnit2Qty").toString(); //法2
|
|
|
|
+ String cusDeclEle = treeMap.get("cusDeclEle").toString(); //申报要素
|
|
|
|
+ String modTime = null ;
|
|
|
|
+ if (treeMap.get("modTime")!=null) {
|
|
|
|
+ modTime = treeMap.get("modTime").toString();
|
|
|
|
+ }
|
|
|
|
+ for (GoodsProductEntity goodsProductEntity : goodsProductEntityList) {
|
|
|
|
+ if (merchSn1.equals(goodsProductEntity.getMerchSn()) && sku.equals(goodsProductEntity.getSku()) && prodBarcode.equals(goodsProductEntity.getProdBarcode())) {
|
|
|
|
+ goodsProductEntity.setGrossWeight(new BigDecimal(grossWeight));
|
|
|
|
+ goodsProductEntity.setNetWeight(new BigDecimal(netWeight));
|
|
|
|
+ goodsProductEntity.setLegalUnit1Qty(new BigDecimal(legalUnit1Qty));
|
|
|
|
+ goodsProductEntity.setLegalUnit2Qty(new BigDecimal(legalUnit2Qty));
|
|
|
|
+ goodsProductEntity.setCiqMainEle(ciqMainEle);
|
|
|
|
+ goodsProductEntity.setCusDeclEle(cusDeclEle);
|
|
|
|
+ goodsProductEntity.setOmsAuditRemark(remark);
|
|
|
|
+ goodsProductEntity.setItemRecordNo(itemRecordNo);
|
|
|
|
+ goodsProductEntity.setLocalEmsNo(localEmsNo);
|
|
|
|
+ goodsProductEntity.setProdBrand(prodBrand);
|
|
|
|
+ if (modTime!=null) {
|
|
|
|
+ goodsProductEntity.setOmsAuditTime(DateUtils.strToDate(modTime));
|
|
|
|
+ }
|
|
|
|
+ goodsProductEntity.setOmsAuditStatus("2");
|
|
|
|
+ goodsProductEntity.setModTime(new Date());
|
|
|
|
+ goodsProductEntity.setModerSn(ShiroUtils.getUserId().toString());
|
|
|
|
+ goodsProductEntity.setStatus(Dict.productRecordStatus.item_22.getItem());
|
|
|
|
+ updateList.add(goodsProductEntity);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if (updateList.size()>0) {
|
|
|
|
+ int i = goodsProductDao.updateBatch(updateList);
|
|
|
|
+ if (i>0) {
|
|
|
|
+ return result.getMsg();
|
|
|
|
+ }else {
|
|
|
|
+ return "暂无更新!";
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}catch (Exception e){
|
|
}catch (Exception e){
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
- return "同步产品备案信息失败,请联系管理员";
|
|
|
|
|
|
+ throw new RuntimeException("拉取产品备案信息失败,请联系管理员");
|
|
}
|
|
}
|
|
- return "同步成功";
|
|
|
|
|
|
+ return "拉取暂无最新产品备案信息!";
|
|
}
|
|
}
|
|
|
|
+ private ResponseMessage requestOmsProductList(Map map) {
|
|
|
|
+ Map<String, String> sParaTemp = new TreeMap<String, String>();
|
|
|
|
+ sParaTemp.put("data", JSON.toJSONString(map));
|
|
|
|
+ LOGGER.info("请求omsdata数据:" + sParaTemp.get("data"));
|
|
|
|
+ sParaTemp.put("merchId", omsMerchProperties.getMerchSn());
|
|
|
|
+ String timestamp = String.valueOf(System.currentTimeMillis() / 1000);
|
|
|
|
+ sParaTemp.put("timestamp", timestamp);
|
|
|
|
+ //生成要请求给oms秘钥
|
|
|
|
+// String sign = OmsSign.sign(sParaTemp,cus.getWaybill().get("secret-key"));
|
|
|
|
+ LOGGER.info("md5混淆码参数:" + omsMerchProperties.getMd5Salt());
|
|
|
|
+ String sign = OmsSign.sign(sParaTemp, omsMerchProperties.getMd5Salt());
|
|
|
|
+ sParaTemp.put("sign", sign);
|
|
|
|
+ //构建Request
|
|
|
|
+ String url = omsMerchProperties.getQuerydProductRecordListUrl();
|
|
|
|
+ Request request = com.kmall.admin.utils.oms.OkHttpUtils.buildRequest(url, JSON.toJSONString(sParaTemp));
|
|
|
|
+ LOGGER.info("oms的请求报文:" + request);
|
|
|
|
+ // 同步访问,返回结果字符串
|
|
|
|
+ String responseString = null;
|
|
|
|
+ try {
|
|
|
|
|
|
|
|
+ responseString = com.kmall.admin.utils.oms.OkHttpUtils.post(request);
|
|
|
|
+
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ LOGGER.info("oms的响应报文" + responseString);
|
|
|
|
+ //解析响应数据
|
|
|
|
+ Gson gson = new Gson();
|
|
|
|
+ ResponseMessage result = gson.fromJson(responseString, ResponseMessage.class);
|
|
|
|
+ if (result == null) {
|
|
|
|
+ String info = "解析响应数据Result失败";
|
|
|
|
+ LOGGER.error("--- {}", info);
|
|
|
|
+ throw new RuntimeException(info);
|
|
|
|
+ }
|
|
|
|
+ return result;
|
|
|
|
+ }
|
|
|
|
|
|
private ResponseMessage requestOmsProduct(List<GoodsProductDto> goodsProductDtoList) {
|
|
private ResponseMessage requestOmsProduct(List<GoodsProductDto> goodsProductDtoList) {
|
|
Map<String, String> sParaTemp = new TreeMap<String, String>();
|
|
Map<String, String> sParaTemp = new TreeMap<String, String>();
|