|
|
@@ -1,5 +1,7 @@
|
|
|
package com.uas.platform.b2c.prod.commodity.service.impl;
|
|
|
|
|
|
+import static com.uas.platform.b2c.core.utils.NumberUtil.fractionNumCeil;
|
|
|
+
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.uas.platform.b2c.common.account.model.Enterprise;
|
|
|
import com.uas.platform.b2c.common.account.service.EnterpriseService;
|
|
|
@@ -12,14 +14,34 @@ import com.uas.platform.b2c.core.support.SystemSession;
|
|
|
import com.uas.platform.b2c.core.utils.NumberUtil;
|
|
|
import com.uas.platform.b2c.core.utils.RegexConstant;
|
|
|
import com.uas.platform.b2c.core.utils.StringUtilB2C;
|
|
|
-import com.uas.platform.b2c.prod.commodity.constant.*;
|
|
|
-import com.uas.platform.b2c.prod.commodity.dao.*;
|
|
|
-import com.uas.platform.b2c.prod.commodity.model.*;
|
|
|
+import com.uas.platform.b2c.prod.commodity.constant.DoubleConstant;
|
|
|
+import com.uas.platform.b2c.prod.commodity.constant.ErrorInfoConstant;
|
|
|
+import com.uas.platform.b2c.prod.commodity.constant.ModifyConstant;
|
|
|
+import com.uas.platform.b2c.prod.commodity.constant.ShortConstant;
|
|
|
+import com.uas.platform.b2c.prod.commodity.constant.UploadConstant;
|
|
|
+import com.uas.platform.b2c.prod.commodity.dao.GoodsDao;
|
|
|
+import com.uas.platform.b2c.prod.commodity.dao.PCBDao;
|
|
|
+import com.uas.platform.b2c.prod.commodity.dao.PcbPropertyvalueDao;
|
|
|
+import com.uas.platform.b2c.prod.commodity.dao.ProductDao;
|
|
|
+import com.uas.platform.b2c.prod.commodity.dao.ProductPersonDao;
|
|
|
+import com.uas.platform.b2c.prod.commodity.dao.ProductPrivateDao;
|
|
|
+import com.uas.platform.b2c.prod.commodity.dao.ReleaseProductByBatchDao;
|
|
|
+import com.uas.platform.b2c.prod.commodity.model.Goods;
|
|
|
+import com.uas.platform.b2c.prod.commodity.model.GoodsQtyPrice;
|
|
|
+import com.uas.platform.b2c.prod.commodity.model.PCB;
|
|
|
+import com.uas.platform.b2c.prod.commodity.model.PCBPropertyValue;
|
|
|
+import com.uas.platform.b2c.prod.commodity.model.Product;
|
|
|
+import com.uas.platform.b2c.prod.commodity.model.ProductPerson;
|
|
|
+import com.uas.platform.b2c.prod.commodity.model.ProductPrivate;
|
|
|
+import com.uas.platform.b2c.prod.commodity.model.ReleaseProductByBatch;
|
|
|
import com.uas.platform.b2c.prod.commodity.service.GoodsService;
|
|
|
import com.uas.platform.b2c.prod.commodity.service.ReleaseProductByBatchService;
|
|
|
import com.uas.platform.b2c.prod.commodity.util.GoodsUtil;
|
|
|
import com.uas.platform.b2c.prod.commodity.util.SheetUtil;
|
|
|
import com.uas.platform.b2c.prod.product.common.service.CreateNumberService;
|
|
|
+import com.uas.platform.b2c.prod.product.kind.dao.KindInfoDao;
|
|
|
+import com.uas.platform.b2c.prod.product.kind.model.KindInfo;
|
|
|
+import com.uas.platform.b2c.prod.product.property.dao.PropertyDao;
|
|
|
import com.uas.platform.b2c.prod.store.model.StoreIn;
|
|
|
import com.uas.platform.b2c.prod.store.model.StoreStatus;
|
|
|
import com.uas.platform.b2c.prod.store.service.StoreInService;
|
|
|
@@ -30,10 +52,37 @@ import com.uas.platform.core.model.PageInfo;
|
|
|
import com.uas.platform.core.persistence.criteria.CriterionExpression;
|
|
|
import com.uas.platform.core.persistence.criteria.PredicateUtils;
|
|
|
import com.uas.platform.core.persistence.criteria.SimpleExpression;
|
|
|
+import java.math.BigDecimal;
|
|
|
+import java.sql.ResultSet;
|
|
|
+import java.sql.SQLException;
|
|
|
+import java.sql.Statement;
|
|
|
+import java.text.DateFormat;
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.Arrays;
|
|
|
+import java.util.Collections;
|
|
|
+import java.util.Comparator;
|
|
|
+import java.util.Date;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.HashSet;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+import java.util.Set;
|
|
|
+import java.util.regex.Matcher;
|
|
|
+import java.util.regex.Pattern;
|
|
|
+import javax.persistence.criteria.CriteriaBuilder;
|
|
|
+import javax.persistence.criteria.CriteriaQuery;
|
|
|
+import javax.persistence.criteria.Predicate;
|
|
|
+import javax.persistence.criteria.Root;
|
|
|
import org.apache.commons.collections.CollectionUtils;
|
|
|
+import org.apache.commons.collections.map.HashedMap;
|
|
|
import org.apache.poi.hssf.usermodel.HSSFCell;
|
|
|
import org.apache.poi.hssf.usermodel.HSSFDateUtil;
|
|
|
-import org.apache.poi.ss.usermodel.*;
|
|
|
+import org.apache.poi.ss.usermodel.Cell;
|
|
|
+import org.apache.poi.ss.usermodel.DateUtil;
|
|
|
+import org.apache.poi.ss.usermodel.Row;
|
|
|
+import org.apache.poi.ss.usermodel.Sheet;
|
|
|
+import org.apache.poi.ss.usermodel.Workbook;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.dao.DataAccessException;
|
|
|
@@ -46,22 +95,6 @@ import org.springframework.ui.ModelMap;
|
|
|
import org.springframework.util.StringUtils;
|
|
|
import org.springframework.web.client.RestTemplate;
|
|
|
|
|
|
-import javax.persistence.criteria.CriteriaBuilder;
|
|
|
-import javax.persistence.criteria.CriteriaQuery;
|
|
|
-import javax.persistence.criteria.Predicate;
|
|
|
-import javax.persistence.criteria.Root;
|
|
|
-import java.math.BigDecimal;
|
|
|
-import java.sql.ResultSet;
|
|
|
-import java.sql.SQLException;
|
|
|
-import java.sql.Statement;
|
|
|
-import java.text.DateFormat;
|
|
|
-import java.text.SimpleDateFormat;
|
|
|
-import java.util.*;
|
|
|
-import java.util.regex.Matcher;
|
|
|
-import java.util.regex.Pattern;
|
|
|
-
|
|
|
-import static com.uas.platform.b2c.core.utils.NumberUtil.fractionNumCeil;
|
|
|
-
|
|
|
@Service
|
|
|
public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchService {
|
|
|
|
|
|
@@ -104,6 +137,23 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
|
|
|
@Autowired
|
|
|
private ProductPersonDao productPersonDao;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private KindInfoDao kindInfoDao;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private PCBDao pcbDao;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private PropertyDao propertyDao;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private PcbPropertyvalueDao pcbPropertyvalueDao;
|
|
|
+
|
|
|
+ private static final String SIZE = "尺寸";
|
|
|
+ private static final String COLOR = "颜色";
|
|
|
+ private static final String THICKCOPPER = "铜厚";
|
|
|
+ private static final String THICK = "厚度";
|
|
|
+
|
|
|
@Value("#{sys.productServiceIp}")
|
|
|
private String productServiceIp;
|
|
|
|
|
|
@@ -121,7 +171,7 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
|
|
|
* @author hejq
|
|
|
*/
|
|
|
@Override
|
|
|
- public ModelMap releaseByWorkbook(Workbook workbook, Boolean selfSale, String currency, Integer isPerson, Integer repeatImport) {
|
|
|
+ public ModelMap releaseByWorkbook(Workbook workbook, Boolean selfSale, String currency, Integer isPerson, Integer repeatImport, boolean isPcb) {
|
|
|
// 是否上传个人物料
|
|
|
boolean isAPerson = false;
|
|
|
boolean isImport = false;
|
|
|
@@ -140,15 +190,12 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
|
|
|
if (colNum != UploadConstant.TOTAL_COLUMN_PERSON && colNum != UploadConstant.MAX_TOTAL_COLUMN_PERSON) {
|
|
|
throw new IllegalOperatorException("表格模板不正确!请重新下载最新模板");
|
|
|
}
|
|
|
- } else {
|
|
|
- if (colNum != UploadConstant.TOTAL_COLUMN && colNum != UploadConstant.MAX_TOTAL_COLUMN) {
|
|
|
+ } else if ((isPcb && colNum != UploadConstant.TOTAL_COLUMN_PCB && colNum != UploadConstant.MAX_TOTAL_COLUMN_PCB) || (!isPcb && colNum != UploadConstant.TOTAL_COLUMN && colNum != UploadConstant.MAX_TOTAL_COLUMN)) {
|
|
|
throw new IllegalOperatorException("表格模板不正确!请重新下载最新模板");
|
|
|
}
|
|
|
- }
|
|
|
- int rowNum = SheetUtil.getSheetLastNum(sheet, UploadConstant.MAX_TOTAL_COLUMN);
|
|
|
+ int rowNum = SheetUtil.getSheetLastNum(sheet, isPcb ? UploadConstant.MAX_TOTAL_COLUMN_PCB : UploadConstant.MAX_TOTAL_COLUMN);
|
|
|
if (rowNum > 2000) {
|
|
|
- throw new IllegalOperatorException
|
|
|
- ("您上传的信息超过2000条,请拆分成2000以下再上传");
|
|
|
+ throw new IllegalOperatorException ("您上传的信息超过2000条,请拆分成2000以下再上传");
|
|
|
}
|
|
|
List<ReleaseProductByBatch> releaseProductByBatchs = new ArrayList<>(rowNum);
|
|
|
String batch = createNumberService.getTimeNumber("product$goods", 8, rowNum);
|
|
|
@@ -156,11 +203,9 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
|
|
|
Row headerRow = sheet.getRow(0);
|
|
|
int total = 0;
|
|
|
int blankNum = 0;
|
|
|
- long time1 = new Date().getTime();
|
|
|
- System.err.println();
|
|
|
if (headerRow != null) {
|
|
|
// 验证模板是否为商城模板
|
|
|
- validateTemplate(headerRow, colNum, currency, isAPerson);
|
|
|
+ validateTemplate(headerRow, colNum, currency, isAPerson, isPcb);
|
|
|
for (int r = 2; r <= rowNum; r++) {
|
|
|
Row row = sheet.getRow(r);
|
|
|
// 英文品牌名称
|
|
|
@@ -174,7 +219,7 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
|
|
|
setProductDefaultInfo(releaseProductByBatch, batch, currency, storeIn);
|
|
|
// TODO 个人库验证
|
|
|
// 将excel内容对应到ReleaseProductByBatch的字段当中
|
|
|
- blankNum = convertValueToProduct(row, releaseProductByBatch, r, isAPerson);
|
|
|
+ blankNum = convertValueToProduct(row, releaseProductByBatch, r, isAPerson, isPcb);
|
|
|
// TODO 个人库验证
|
|
|
if (!isAPerson) {
|
|
|
// 解析返回分段价格list
|
|
|
@@ -205,15 +250,11 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- long time2 = new Date().getTime();
|
|
|
- System.err.println((time2 - time1) + "**********************************1");
|
|
|
Long userUU = SystemSession.getUser().getUserUU();
|
|
|
Long enUU = SystemSession.getUser().getEnterprise().getUu();
|
|
|
List<ReleaseProductByBatch> addList = new ArrayList<>(releaseProductByBatchs.size());
|
|
|
addList.addAll(releaseProductByBatchs);
|
|
|
resetRepeatData(addList, isImport, isAPerson);
|
|
|
- long time3 = new Date().getTime();
|
|
|
- System.err.println((time3 - time2) + "**********************************2");
|
|
|
if (isAPerson) {
|
|
|
for (ReleaseProductByBatch releaseProductByBatch : addList) {
|
|
|
List<Product> productList = productDao.findByEnUUAndPcmpcodeAndPbrandenAndB2cEnabled(enUU,releaseProductByBatch.getB2cCode(),
|
|
|
@@ -229,23 +270,17 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- long time4 = new Date().getTime();
|
|
|
- System.err.println((time4 - time3) + "**********************************3");
|
|
|
commonDao.save(addList, ReleaseProductByBatch.class);
|
|
|
- long time5 = new Date().getTime();
|
|
|
- System.err.println((time5 - time4) + "**********************************4");
|
|
|
- releaseProductByBatchDao.callValidProcedure(enUU, batch);
|
|
|
- long time6 = new Date().getTime();
|
|
|
- System.err.println((time6 - time5) + "**********************************5");
|
|
|
+
|
|
|
+ if (isPcb) {
|
|
|
+ releaseProductByBatchDao.callValidProcedurePcb(enUU, batch);
|
|
|
+ } else {
|
|
|
+ releaseProductByBatchDao.callValidProcedure(enUU, batch);
|
|
|
+ }
|
|
|
+
|
|
|
Integer filter = releaseProductByBatchDao.getCountOfImportFail(userUU, batch, failCode);
|
|
|
- long time7 = new Date().getTime();
|
|
|
- System.err.println((time7 - time6) + "**********************************6");
|
|
|
Integer failure = releaseProductByBatchDao.getCountPublisherUuAndBatchAndReleaseCode(userUU, batch, ReleaseStatus.failure.value());
|
|
|
- long time8 = new Date().getTime();
|
|
|
- System.err.println((time8 - time7) + "**********************************7");
|
|
|
Integer success = releaseProductByBatchDao.getCountPublisherUuAndBatchAndReleaseCode(userUU, batch, ReleaseStatus.success.value());
|
|
|
- long time9 = new Date().getTime();
|
|
|
- System.err.println((time9 - time8) + "**********************************8");
|
|
|
modelMap.put("total", total);
|
|
|
modelMap.put("success", success);
|
|
|
modelMap.put("failure", failure);
|
|
|
@@ -688,8 +723,9 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
|
|
|
* @param headerRow 首行
|
|
|
* @param colNum 总列
|
|
|
* @param currency 币别
|
|
|
+ * @param isPcb 是否pcb模块
|
|
|
*/
|
|
|
- private void validateTemplate(Row headerRow, int colNum, String currency, boolean isAPerson) {
|
|
|
+ private void validateTemplate(Row headerRow, int colNum, String currency, boolean isAPerson, boolean isPcb) {
|
|
|
if (isAPerson) {
|
|
|
if (colNum == UploadConstant.MAX_TOTAL_COLUMN_PERSON) {
|
|
|
Cell errorCell = headerRow.getCell(UploadConstant.MAX_TOTAL_COLUMN_PERSON - 1);
|
|
|
@@ -711,8 +747,8 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
|
|
|
throw new IllegalOperatorException("您上传的信息列信息不正确,请与模板的列做比较");
|
|
|
}
|
|
|
} else {
|
|
|
- if (colNum == UploadConstant.MAX_TOTAL_COLUMN) {
|
|
|
- Cell errorCell = headerRow.getCell(UploadConstant.MAX_TOTAL_COLUMN - 1);
|
|
|
+ if (colNum == (isPcb ? UploadConstant.MAX_TOTAL_COLUMN_PCB : UploadConstant.MAX_TOTAL_COLUMN)) {
|
|
|
+ Cell errorCell = headerRow.getCell(isPcb ? UploadConstant.MAX_TOTAL_COLUMN_PCB - 1 : UploadConstant.MAX_TOTAL_COLUMN - 1);
|
|
|
Object errorCellObj = readWorkBookCell(errorCell, Cell.CELL_TYPE_STRING, 0, 0);
|
|
|
String errorHead = StringUtilB2C.replaceLineBreak(String.valueOf(errorCellObj));
|
|
|
if (StringUtils.isEmpty(errorHead) || !("错误提示".equals(errorHead))) {
|
|
|
@@ -741,7 +777,6 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -954,8 +989,9 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
|
|
|
* @param row 行对象
|
|
|
* @param aProduct 验证单行数据
|
|
|
* @param rowNum 行数
|
|
|
+ * @param isPcb 是否pcb模块
|
|
|
*/
|
|
|
- private int convertValueToProduct(Row row, ReleaseProductByBatch aProduct, int rowNum, boolean isAPerson) {
|
|
|
+ private int convertValueToProduct(Row row, ReleaseProductByBatch aProduct, int rowNum, boolean isAPerson, boolean isPcb) {
|
|
|
// 统计为空的个数
|
|
|
int result = 0;
|
|
|
|
|
|
@@ -972,6 +1008,15 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
|
|
|
result += 1;
|
|
|
}
|
|
|
aProduct.setKindByExcel(kindValue);
|
|
|
+ // pcb模块判断类目是否为商城标准pcb类目
|
|
|
+ if (isPcb && !StringUtils.isEmpty(aProduct.getKindName())) {
|
|
|
+ KindInfo kindInfo = kindInfoDao.findByNameCn(aProduct.getKindName());
|
|
|
+ if (kindInfo != null && kindInfo.getId() != null && (kindInfoDao.existsChildByParentId(UploadConstant.PCB_PARENTID, kindInfo.getId()) > 0)) {
|
|
|
+ aProduct.setKindUuid(kindInfo.getId());
|
|
|
+ } else {
|
|
|
+ aProduct.setErrmsg(ErrorInfoConstant.KIND_UNSTANDARD.getInfo());
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
Object codeValue = readWorkBookCell(row.getCell(UploadConstant.PRODUCT_CODE), Cell.CELL_TYPE_STRING,
|
|
|
rowNum, UploadConstant.PRODUCT_CODE);
|
|
|
@@ -1004,6 +1049,7 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
|
|
|
String productStr = sdf.format(productCell.getDateCellValue());
|
|
|
aProduct.setProductDateByExcel(productStr);
|
|
|
} else {
|
|
|
+ aProduct.setProductDateByExcel("");
|
|
|
aProduct.setProductDateByExcel(readWorkBookCell(row.getCell(ModifyConstant.PRODUCE_DATE), Cell.CELL_TYPE_STRING,
|
|
|
rowNum, ModifyConstant.PRODUCE_DATE));
|
|
|
}
|
|
|
@@ -1041,6 +1087,26 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
|
|
|
if (aProduct.getCode() != null && aProduct.getBrandNameEn() != null && aProduct.getTag() != null) {
|
|
|
resetTag(aProduct);
|
|
|
}
|
|
|
+
|
|
|
+ // 如果是pcb模块,解析尺寸、颜色、铜厚、厚度
|
|
|
+ if (isPcb) {
|
|
|
+ Object sizeValue = readWorkBookCell(row.getCell(UploadConstant.SIZE), Cell.CELL_TYPE_STRING,
|
|
|
+ rowNum, UploadConstant.SIZE);
|
|
|
+ aProduct.setSizeByExcel(sizeValue);
|
|
|
+
|
|
|
+ Object colorValue = readWorkBookCell(row.getCell(UploadConstant.COLOR), Cell.CELL_TYPE_STRING,
|
|
|
+ rowNum, UploadConstant.COLOR);
|
|
|
+ aProduct.setColorByExcel(colorValue);
|
|
|
+
|
|
|
+ Object thickCopperValue = readWorkBookCell(row.getCell(UploadConstant.THICK_COPPER), Cell.CELL_TYPE_STRING,
|
|
|
+ rowNum, UploadConstant.THICK_COPPER);
|
|
|
+ aProduct.setThickCopperByExcel(thickCopperValue);
|
|
|
+
|
|
|
+ Object thickValue = readWorkBookCell(row.getCell(UploadConstant.THICK), Cell.CELL_TYPE_STRING,
|
|
|
+ rowNum, UploadConstant.THICK);
|
|
|
+ aProduct.setThickByExcel(thickValue);
|
|
|
+ }
|
|
|
+
|
|
|
} else {
|
|
|
Object packageMethodValue = readWorkBookCell(row.getCell(UploadConstant.SPECIFICATION), Cell.CELL_TYPE_STRING,
|
|
|
rowNum, UploadConstant.SPECIFICATION);
|
|
|
@@ -1089,7 +1155,8 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
|
|
|
*/
|
|
|
private List<GoodsQtyPrice> initQtyPriceByExcel(Row row, boolean isImport, ReleaseProductByBatch aProduct, int rowNum) {
|
|
|
List<GoodsQtyPrice> qtyPriceList = new ArrayList<>();
|
|
|
- Object firstValue = null;
|
|
|
+ Object firstValue = readWorkBookCell(row.getCell(UploadConstant.PRICE_START), Cell.CELL_TYPE_NUMERIC,
|
|
|
+ rowNum, UploadConstant.PRICE_START);
|
|
|
if (isImport) {
|
|
|
firstValue = readWorkBookCell(row.getCell(UploadConstant.PRICE_START), Cell.CELL_TYPE_STRING,
|
|
|
rowNum, UploadConstant.PRICE_START);
|
|
|
@@ -1543,14 +1610,14 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public String publishByBatch(String batch) {
|
|
|
-
|
|
|
+ public String publishByBatch(String batch, boolean isPcb) {
|
|
|
List<ReleaseProductByBatch> releaseProductByBatchList =
|
|
|
releaseProductByBatchDao.findByRelbatchid(batch);
|
|
|
List<Long> productIds = null;
|
|
|
List<ProductPrivate> productPrivateList = null;
|
|
|
if (!CollectionUtils.isEmpty(releaseProductByBatchList)) {
|
|
|
- List<com.uas.ps.entity.Product> products = convertProduct(releaseProductByBatchList,false);
|
|
|
+ Map<String, Object> map = convertProduct(releaseProductByBatchList,false, isPcb);
|
|
|
+ List<com.uas.ps.entity.Product> products = (List<com.uas.ps.entity.Product>) map.get("products");
|
|
|
// TODO 什么接口
|
|
|
String result = restTemplate.postForEntity(productServiceIp + "/product/update", products, String.class).getBody();
|
|
|
productIds = JSON.parseArray(result, Long.class);
|
|
|
@@ -1566,6 +1633,40 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
|
|
|
productPrivates.add(productPrivate);
|
|
|
}
|
|
|
productPrivateList = productPrivateDao.save(productPrivates);
|
|
|
+
|
|
|
+ if (isPcb) {
|
|
|
+ List<PCB> pcbList = new ArrayList<>();
|
|
|
+ List<PCBPropertyValue> propertyValueList = new ArrayList<>();
|
|
|
+
|
|
|
+ for (Long prId : idSet) {
|
|
|
+ Product product = productDao.findOne(prId);
|
|
|
+ if (product != null) {
|
|
|
+ List<PCB> pcbs = pcbDao.findByProductid(prId);
|
|
|
+ if (CollectionUtils.isEmpty(pcbs)) {
|
|
|
+ PCB pcb = new PCB();
|
|
|
+ pcb.setProductid(prId);
|
|
|
+ pcb.setBrandid(product.getPbrandid());
|
|
|
+ pcb.setKindid(product.getKindid());
|
|
|
+ pcbList.add(pcb);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ List<PCBPropertyValue> propertyValues = (List<PCBPropertyValue>) map.get(product.getEnUU().toString().concat(product.getProdNum()));
|
|
|
+ if (CollectionUtils.isNotEmpty(propertyValues)) {
|
|
|
+ for (PCBPropertyValue propertyValue : propertyValues) {
|
|
|
+ propertyValue.setProductid(prId);
|
|
|
+ propertyValueList.add(propertyValue);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (CollectionUtils.isNotEmpty(pcbList)) {
|
|
|
+ pcbDao.save(pcbList);
|
|
|
+ }
|
|
|
+ if (CollectionUtils.isNotEmpty(propertyValueList)) {
|
|
|
+ pcbPropertyvalueDao.save(propertyValueList);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
Enterprise enterprise = SystemSession.getUser().getEnterprise();
|
|
|
final Object[] obj = new Object[]{enterprise.getUu(), enterprise.getEnName(), batch};
|
|
|
@@ -1629,11 +1730,25 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
|
|
|
}
|
|
|
|
|
|
|
|
|
- private List<com.uas.ps.entity.Product> convertProduct (List<ReleaseProductByBatch> releaseProductByBatchList, boolean isAPerson ) {
|
|
|
+ private Map<String, Object> convertProduct (List<ReleaseProductByBatch> releaseProductByBatchList, boolean isAPerson , boolean isPcb) {
|
|
|
if (CollectionUtils.isEmpty(releaseProductByBatchList)) {
|
|
|
return null;
|
|
|
}
|
|
|
+ Map<String, Object> map = new HashedMap();
|
|
|
List<com.uas.ps.entity.Product> products = new ArrayList<>();
|
|
|
+ Map<String, List<PCBPropertyValue>> propertyMap = new HashedMap();
|
|
|
+
|
|
|
+ Long sizeProId = null;
|
|
|
+ Long colorProId = null;
|
|
|
+ Long thickCopperProId = null;
|
|
|
+ Long thickProId = null;
|
|
|
+ if (isPcb) {
|
|
|
+ sizeProId = propertyDao.findIdByLabelCn(SIZE);
|
|
|
+ colorProId = propertyDao.findIdByLabelCn(COLOR);
|
|
|
+ thickCopperProId = propertyDao.findIdByLabelCn(THICKCOPPER);
|
|
|
+ thickProId = propertyDao.findIdByLabelCn(THICK);
|
|
|
+ }
|
|
|
+
|
|
|
for (ReleaseProductByBatch releaseProductByBatch : releaseProductByBatchList) {
|
|
|
if (releaseProductByBatch.getReleaseCode().equals(ReleaseStatus.failure.value()) ||
|
|
|
releaseProductByBatch.getReleaseCode().equals(ReleaseStatus.success.value())) {
|
|
|
@@ -1662,10 +1777,36 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
|
|
|
}
|
|
|
String batchCode = "PNUM" + createNumberService.getTimeNumber("trade$product_import_num", 8);
|
|
|
product.setCode(batchCode);
|
|
|
+
|
|
|
+ if (isPcb) {
|
|
|
+ List<PCBPropertyValue> propertyValues = new ArrayList<>();
|
|
|
+ if (!StringUtils.isEmpty(releaseProductByBatch.getSize())) {
|
|
|
+ PCBPropertyValue propertyValue = new PCBPropertyValue(sizeProId, releaseProductByBatch.getSize());
|
|
|
+ propertyValues.add(propertyValue);
|
|
|
+ }
|
|
|
+ if (!StringUtils.isEmpty(releaseProductByBatch.getColor())) {
|
|
|
+ PCBPropertyValue propertyValue = new PCBPropertyValue(colorProId, releaseProductByBatch.getColor());
|
|
|
+ propertyValues.add(propertyValue);
|
|
|
+ }
|
|
|
+ if (!StringUtils.isEmpty(releaseProductByBatch.getThickCopper())) {
|
|
|
+ PCBPropertyValue propertyValue = new PCBPropertyValue(thickCopperProId, releaseProductByBatch.getThickCopper());
|
|
|
+ propertyValues.add(propertyValue);
|
|
|
+ }
|
|
|
+ if (!StringUtils.isEmpty(releaseProductByBatch.getThick())) {
|
|
|
+ PCBPropertyValue propertyValue = new PCBPropertyValue(thickProId, releaseProductByBatch.getThick());
|
|
|
+ propertyValues.add(propertyValue);
|
|
|
+ }
|
|
|
+ if (CollectionUtils.isNotEmpty(propertyValues)) {
|
|
|
+ propertyMap.put(product.getEnUU().toString().concat(product.getCode()), propertyValues);
|
|
|
+ }
|
|
|
+ }
|
|
|
products.add(product);
|
|
|
}
|
|
|
}
|
|
|
- return products;
|
|
|
+
|
|
|
+ map.put("products", products);
|
|
|
+ map.put("propertyvalues", propertyMap);
|
|
|
+ return map;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -1673,7 +1814,8 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
|
|
|
List<ReleaseProductByBatch> releaseProductByBatchList =
|
|
|
releaseProductByBatchDao.findByRelbatchid(batch);
|
|
|
if (!CollectionUtils.isEmpty(releaseProductByBatchList)) {
|
|
|
- List<com.uas.ps.entity.Product> products = convertProduct(releaseProductByBatchList,true);
|
|
|
+ Map<String, Object> map = convertProduct(releaseProductByBatchList,false, false);
|
|
|
+ List<com.uas.ps.entity.Product> products = (List<com.uas.ps.entity.Product>) map.get("products");
|
|
|
// TODO 什么接口
|
|
|
String result = restTemplate.postForEntity(productServiceIp + "/product/update", products, String.class).getBody();
|
|
|
List<Long> productIds = JSON.parseArray(result, Long.class);
|