|
|
@@ -20,6 +20,9 @@ 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;
|
|
|
@@ -31,6 +34,7 @@ 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 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.*;
|
|
|
@@ -104,6 +108,26 @@ 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;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private V_ProductPrivateDao v_productPrivateDao;
|
|
|
+
|
|
|
+ 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 +145,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 +164,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 +177,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 +193,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 +224,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 +244,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 +697,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 +721,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 +751,6 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -954,8 +963,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 +982,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.addErrmsg(ErrorInfoConstant.KIND_UNSTANDARD.getInfo());
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
Object codeValue = readWorkBookCell(row.getCell(UploadConstant.PRODUCT_CODE), Cell.CELL_TYPE_STRING,
|
|
|
rowNum, UploadConstant.PRODUCT_CODE);
|
|
|
@@ -1004,6 +1023,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 +1061,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 +1129,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_STRING,
|
|
|
+ rowNum, UploadConstant.PRICE_START);
|
|
|
if (isImport) {
|
|
|
firstValue = readWorkBookCell(row.getCell(UploadConstant.PRICE_START), Cell.CELL_TYPE_STRING,
|
|
|
rowNum, UploadConstant.PRICE_START);
|
|
|
@@ -1104,14 +1145,19 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
|
|
|
if (StringUtils.isEmpty(firstValue)) {
|
|
|
aProduct.addErrmsg(ErrorInfoConstant.PRICE_INFO.getInfo());
|
|
|
} else {
|
|
|
- Double cellPrice = Double.valueOf(firstValue.toString());
|
|
|
- if (validatePrice(cellPrice)) {
|
|
|
- GoodsQtyPrice qtyPrice = getOneQtyPrice(aProduct.getMinBuyQty(), DoubleConstant.maxMinPackageQty,
|
|
|
- cellPrice, aProduct.getRmbTaxRate(), aProduct.getCurrency());
|
|
|
- qtyPriceList.add(qtyPrice);
|
|
|
+ if (RegexConstant.isNumber(firstValue.toString())) {
|
|
|
+ Double cellPrice = Double.valueOf(firstValue.toString());
|
|
|
+ if (validatePrice(cellPrice)) {
|
|
|
+ GoodsQtyPrice qtyPrice = getOneQtyPrice(aProduct.getMinBuyQty(), DoubleConstant.maxMinPackageQty,
|
|
|
+ cellPrice, aProduct.getRmbTaxRate(), aProduct.getCurrency());
|
|
|
+ qtyPriceList.add(qtyPrice);
|
|
|
+ } else {
|
|
|
+ aProduct.addErrmsg(ErrorInfoConstant.PRICE_INFO.getInfo());
|
|
|
+ }
|
|
|
} else {
|
|
|
aProduct.addErrmsg(ErrorInfoConstant.PRICE_INFO.getInfo());
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
|
|
|
if (!CollectionUtils.isEmpty(qtyPriceList)) {
|
|
|
@@ -1183,16 +1229,18 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
|
|
|
rowNum, ModifyConstant.PRICE_SECOND);
|
|
|
}
|
|
|
if (!StringUtils.isEmpty(startValue) && !StringUtils.isEmpty(priceValue)) {
|
|
|
- Double price = Double.valueOf(priceValue.toString());
|
|
|
- Double start = Double.valueOf(startValue.toString());
|
|
|
- if (validatePrice(price) && validateStartNumber(start, aProduct.getMinBuyQty())) {
|
|
|
- GoodsQtyPrice qtyPrice = getOneQtyPrice(Double.valueOf(startValue.toString()), DoubleConstant.maxMinPackageQty,
|
|
|
- price, aProduct.getRmbTaxRate(), aProduct.getCurrency());
|
|
|
- qtyPriceList.add(qtyPrice);
|
|
|
- qtyPriceList.get(0).setEnd(Double.valueOf(startValue.toString()) - 1);
|
|
|
- setThirdPrice(row, isImport, rowNum, qtyPriceList, aProduct);
|
|
|
+ if (RegexConstant.isNumber(startValue.toString()) && RegexConstant.isNumber(priceValue.toString())) {
|
|
|
+ Double price = Double.valueOf(priceValue.toString());
|
|
|
+ Double start = Double.valueOf(startValue.toString());
|
|
|
+ if (validatePrice(price) && validateStartNumber(start, aProduct.getMinBuyQty())) {
|
|
|
+ GoodsQtyPrice qtyPrice = getOneQtyPrice(Double.valueOf(startValue.toString()), DoubleConstant.maxMinPackageQty,
|
|
|
+ price, aProduct.getRmbTaxRate(), aProduct.getCurrency());
|
|
|
+ qtyPriceList.add(qtyPrice);
|
|
|
+ qtyPriceList.get(0).setEnd(Double.valueOf(startValue.toString()) - 1);
|
|
|
+ setThirdPrice(row, isImport, rowNum, qtyPriceList, aProduct);
|
|
|
+ }
|
|
|
+ return ;
|
|
|
}
|
|
|
- return ;
|
|
|
}
|
|
|
if (StringUtils.isEmpty(startValue) && StringUtils.isEmpty(priceValue)) {
|
|
|
setThirdPrice(row, isImport, rowNum, qtyPriceList, aProduct);
|
|
|
@@ -1221,14 +1269,16 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
|
|
|
rowNum, ModifyConstant.PRICE_THIRD);
|
|
|
}
|
|
|
if (!StringUtils.isEmpty(startValue) && !StringUtils.isEmpty(priceValue)) {
|
|
|
- Double price = Double.valueOf(priceValue.toString());
|
|
|
- Double start = Double.valueOf(startValue.toString());
|
|
|
- Double lastEnd = qtyPriceList.get(qtyPriceList.size() - 1).getStart();
|
|
|
- if (validatePrice(price) && validateStartNumber(start, lastEnd)) {
|
|
|
- GoodsQtyPrice qtyPrice = getOneQtyPrice(start, DoubleConstant.maxMinPackageQty,
|
|
|
- price, aProduct.getRmbTaxRate(), aProduct.getCurrency());
|
|
|
- qtyPriceList.get(qtyPriceList.size() - 1).setEnd(start - 1);
|
|
|
- qtyPriceList.add(qtyPrice);
|
|
|
+ if (RegexConstant.isNumber(startValue.toString()) && RegexConstant.isNumber(priceValue.toString())) {
|
|
|
+ Double price = Double.valueOf(priceValue.toString());
|
|
|
+ Double start = Double.valueOf(startValue.toString());
|
|
|
+ Double lastEnd = qtyPriceList.get(qtyPriceList.size() - 1).getStart();
|
|
|
+ if (validatePrice(price) && validateStartNumber(start, lastEnd)) {
|
|
|
+ GoodsQtyPrice qtyPrice = getOneQtyPrice(start, DoubleConstant.maxMinPackageQty,
|
|
|
+ price, aProduct.getRmbTaxRate(), aProduct.getCurrency());
|
|
|
+ qtyPriceList.get(qtyPriceList.size() - 1).setEnd(start - 1);
|
|
|
+ qtyPriceList.add(qtyPrice);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -1296,7 +1346,11 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
|
|
|
if (cell != null && cell.getCellType() != Cell.CELL_TYPE_BLANK) {
|
|
|
switch (cellType) {
|
|
|
case Cell.CELL_TYPE_STRING :
|
|
|
- cell.setCellType(HSSFCell.CELL_TYPE_STRING);
|
|
|
+ try {
|
|
|
+ cell.setCellType(HSSFCell.CELL_TYPE_STRING);
|
|
|
+ } catch (Exception e) {
|
|
|
+ throw new IllegalOperatorException("读取表格中"+ (r + 1)+"行"+ (n+1)+ "列的内容错误,需要文本格式的信息");
|
|
|
+ }
|
|
|
String str = cell.getStringCellValue().trim();
|
|
|
// Object data = getCellData(cell);
|
|
|
// String str = data == null ? "" : data.toString();
|
|
|
@@ -1307,7 +1361,11 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
|
|
|
obj = str.trim();
|
|
|
break;
|
|
|
case Cell.CELL_TYPE_NUMERIC :
|
|
|
- cell.setCellType(Cell.CELL_TYPE_NUMERIC);
|
|
|
+ try {
|
|
|
+ cell.setCellType(Cell.CELL_TYPE_NUMERIC);
|
|
|
+ } catch (Exception e) {
|
|
|
+ throw new IllegalOperatorException("读取表格中"+ (r + 1)+"行"+ (n+1)+ "列的内容错误,需要数字格式的信息");
|
|
|
+ }
|
|
|
obj = cell.getNumericCellValue();
|
|
|
if (obj != null) {
|
|
|
if(obj.toString().indexOf("E") > 0) {
|
|
|
@@ -1334,7 +1392,12 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
|
|
|
}
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
- throw new IllegalOperatorException("读取表格中"+r+"行"+ (n+1)+ "列的内容错误,有可能是该单元格的格式不正确");
|
|
|
+ String message = e.getMessage();
|
|
|
+ if (message.contains("读取表格")) {
|
|
|
+ throw new IllegalOperatorException(message);
|
|
|
+ } else {
|
|
|
+ throw new IllegalOperatorException("读取表格中"+(r + 1)+"行"+ (n+1)+ "列的内容错误,有可能是该单元格的格式不正确");
|
|
|
+ }
|
|
|
}
|
|
|
return obj;
|
|
|
}
|
|
|
@@ -1543,14 +1606,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 +1629,45 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
|
|
|
productPrivates.add(productPrivate);
|
|
|
}
|
|
|
productPrivateList = productPrivateDao.save(productPrivates);
|
|
|
+
|
|
|
+ //根据更新的规格信息,更新在售产品的信息
|
|
|
+ List<V_ProductPrivate> v_productPrivates = v_productPrivateDao.findProductInIdAndSpecIsNotNull(productIds);
|
|
|
+ List<Goods> goodses = goodsDao.findByProductIds(productIds);
|
|
|
+ goodsService.updateSpecByProducts(v_productPrivates, goodses);
|
|
|
+
|
|
|
+ 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 +1731,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())) {
|
|
|
@@ -1655,17 +1771,41 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
|
|
|
product.setStandard(releaseProductByBatch.getComponentUuId() == null ? (short)0 : (short)1);
|
|
|
product.setCmpUuid(releaseProductByBatch.getComponentUuId());
|
|
|
product.setCreateTime(new Date(System.currentTimeMillis()));
|
|
|
+ product.setSpec(releaseProductByBatch.getSpec());
|
|
|
// 产品导入默认可销售
|
|
|
product.setIsSale((short) 1);
|
|
|
- if (isAPerson) {
|
|
|
- product.setSpec(releaseProductByBatch.getPackaging());
|
|
|
- }
|
|
|
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 +1813,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);
|