|
|
@@ -10,10 +10,32 @@ 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.service.*;
|
|
|
+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.StringConstant;
|
|
|
+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.ReleaseProductByBatchDao;
|
|
|
+import com.uas.platform.b2c.prod.commodity.model.Goods;
|
|
|
+import com.uas.platform.b2c.prod.commodity.model.GoodsHistory;
|
|
|
+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.GoodsHistoryService;
|
|
|
+import com.uas.platform.b2c.prod.commodity.service.GoodsService;
|
|
|
+import com.uas.platform.b2c.prod.commodity.service.ProductPrivateService;
|
|
|
+import com.uas.platform.b2c.prod.commodity.service.ProductService;
|
|
|
+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.brand.dao.BrandInfoDao;
|
|
|
@@ -41,7 +63,11 @@ import org.apache.commons.collections.map.HashedMap;
|
|
|
import org.apache.log4j.Logger;
|
|
|
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;
|
|
|
@@ -68,7 +94,16 @@ import java.sql.SQLException;
|
|
|
import java.sql.Statement;
|
|
|
import java.text.DateFormat;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
-import java.util.*;
|
|
|
+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.concurrent.ExecutorService;
|
|
|
import java.util.concurrent.Executors;
|
|
|
import java.util.regex.Matcher;
|
|
|
@@ -76,6 +111,11 @@ import java.util.regex.Pattern;
|
|
|
|
|
|
import static com.uas.platform.b2c.core.utils.NumberUtil.fractionNumCeil;
|
|
|
|
|
|
+/**
|
|
|
+ * 批量上传物料
|
|
|
+ *
|
|
|
+ * @author hejq
|
|
|
+ */
|
|
|
@Service
|
|
|
public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchService {
|
|
|
|
|
|
@@ -109,9 +149,6 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
|
|
|
@Autowired
|
|
|
private RestTemplate restTemplate;
|
|
|
|
|
|
- @Autowired
|
|
|
- private ProductPrivateDao productPrivateDao;
|
|
|
-
|
|
|
@Autowired
|
|
|
private ProductPersonDao productPersonDao;
|
|
|
|
|
|
@@ -127,9 +164,6 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
|
|
|
@Autowired
|
|
|
private PcbPropertyvalueDao pcbPropertyvalueDao;
|
|
|
|
|
|
- @Autowired
|
|
|
- private V_ProductPrivateDao v_productPrivateDao;
|
|
|
-
|
|
|
@Autowired
|
|
|
private ProductService productService;
|
|
|
|
|
|
@@ -266,27 +300,8 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
|
|
|
}
|
|
|
Long enUU = SystemSession.getUser().getEnterprise().getUu();
|
|
|
if (!isAPerson) {
|
|
|
- //1:比较品牌、型号、自定义标签是否重复,2:比较六要素是否重复
|
|
|
- for(int i = releaseProductByBatchs.size() - 1; i > -1; i--) {
|
|
|
- ReleaseProductByBatch releaseProductByBatch = releaseProductByBatchs.get(i);
|
|
|
- for(int j = i - 1; j > -1; j--) {
|
|
|
- ReleaseProductByBatch byBatch = releaseProductByBatchs.get(j);
|
|
|
- if(releaseProductByBatch.compareSameProductTagInfo(byBatch)) {
|
|
|
- releaseProductByBatch.setTag("");
|
|
|
- releaseProductByBatch.setTagstr("");
|
|
|
- if (releaseProductByBatch.compareSameProductSixEle(byBatch)) {
|
|
|
- releaseProductByBatch.addErrmsg(ErrorInfoConstant.REPEAT_IN_EXCEL.getInfo());
|
|
|
- releaseProductByBatch.setReleaseStatus(ReleaseStatus.had_exists.getPhrase());
|
|
|
- releaseProductByBatch.setReleaseCode(ReleaseStatus.had_exists.value());
|
|
|
- if (!StringUtilB2C.isEmpty(releaseProductByBatch.getErrmsg())) {
|
|
|
- if (releaseProductByBatch.getErrmsg().substring(0, 1).equals(",")) {
|
|
|
- releaseProductByBatch.setErrmsg(releaseProductByBatch.getErrmsg().substring(1));
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+ //1:比较品牌、型号、自定义标签是否重复,2:比较六要素是否重复
|
|
|
+ checkReleaseProductByBatch(releaseProductByBatchs);
|
|
|
}
|
|
|
commonDao.save(releaseProductByBatchs, ReleaseProductByBatch.class);
|
|
|
releaseProductByBatchDao.callReleaseExistValidProcedure(batch, isAPerson, enUU);
|
|
|
@@ -325,34 +340,76 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
- Integer filter = 0, failure = 0, success = 0;
|
|
|
if (!StringUtilB2C.isEmpty(strCount)) {
|
|
|
- String[] split = strCount.split(SplitChar.HYPHEN);
|
|
|
- if (split.length == 3) {
|
|
|
- filter = Integer.valueOf(split[0]);
|
|
|
- failure = Integer.valueOf(split[1]);
|
|
|
- success = Integer.valueOf(split[2]);
|
|
|
- } else {
|
|
|
- //上面的代码只能在正式上获取到返回值,为了在测试上执行,增加获取结果的代码
|
|
|
- Long userUU = SystemSession.getUser().getUserUU();
|
|
|
- filter = releaseProductByBatchDao.getCountOfImportFail(userUU, batch, failCode);
|
|
|
- failure = releaseProductByBatchDao.getCountPublisherUuAndBatchAndReleaseCode(userUU, batch, ReleaseStatus.failure.value());
|
|
|
- success = releaseProductByBatchDao.getCountPublisherUuAndBatchAndReleaseCode(userUU, batch, ReleaseStatus.success.value());
|
|
|
- }
|
|
|
+ // 统计上传数据相关
|
|
|
+ checkReleaseCount(modelMap, strCount, batch);
|
|
|
}
|
|
|
if (!isAPerson && !isPcb) {
|
|
|
String publish = publishByBatch(batch, isPcb);
|
|
|
modelMap.put("publish", publish);
|
|
|
}
|
|
|
modelMap.put("total", total);
|
|
|
- modelMap.put("success", success);
|
|
|
- modelMap.put("failure", failure);
|
|
|
- modelMap.put("filter", filter);
|
|
|
modelMap.put("batch", batch);
|
|
|
return modelMap;
|
|
|
}
|
|
|
|
|
|
- @Override
|
|
|
+ /**
|
|
|
+ * 统计上传数据相关
|
|
|
+ *
|
|
|
+ * @param modelMap ModelMap
|
|
|
+ * @param strCount
|
|
|
+ * @param batch
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public void checkReleaseCount(ModelMap modelMap, String strCount, String batch) {
|
|
|
+ Integer filter, failure, success;
|
|
|
+ String[] split = strCount.split(SplitChar.HYPHEN);
|
|
|
+ if (split.length == 3) {
|
|
|
+ filter = Integer.valueOf(split[0]);
|
|
|
+ failure = Integer.valueOf(split[1]);
|
|
|
+ success = Integer.valueOf(split[2]);
|
|
|
+ } else {
|
|
|
+ //上面的代码只能在正式上获取到返回值,为了在测试上执行,增加获取结果的代码
|
|
|
+ Long userUU = SystemSession.getUser().getUserUU();
|
|
|
+ filter = releaseProductByBatchDao.getCountOfImportFail(userUU, batch, failCode);
|
|
|
+ failure = releaseProductByBatchDao.getCountPublisherUuAndBatchAndReleaseCode(userUU, batch, ReleaseStatus.failure.value());
|
|
|
+ success = releaseProductByBatchDao.getCountPublisherUuAndBatchAndReleaseCode(userUU, batch, ReleaseStatus.success.value());
|
|
|
+ }
|
|
|
+ modelMap.put("success", success);
|
|
|
+ modelMap.put("failure", failure);
|
|
|
+ modelMap.put("filter", filter);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 1:比较品牌、型号、自定义标签是否重复,2:比较六要素是否重复
|
|
|
+ * @param releaseProductByBatchs 批量上传商品建立临时表存储相关信息
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public void checkReleaseProductByBatch(List<ReleaseProductByBatch> releaseProductByBatchs) {
|
|
|
+ for (int i = releaseProductByBatchs.size() - 1; i > -1; i--) {
|
|
|
+ ReleaseProductByBatch releaseProductByBatch = releaseProductByBatchs.get(i);
|
|
|
+ for (int j = i - 1; j > -1; j--) {
|
|
|
+ ReleaseProductByBatch byBatch = releaseProductByBatchs.get(j);
|
|
|
+ if (releaseProductByBatch.compareSameProductTagInfo(byBatch)) {
|
|
|
+ releaseProductByBatch.setTag("");
|
|
|
+ releaseProductByBatch.setTagstr("");
|
|
|
+ if (releaseProductByBatch.compareSameProductSixEle(byBatch)) {
|
|
|
+ releaseProductByBatch.addErrmsg(ErrorInfoConstant.REPEAT_IN_EXCEL.getInfo());
|
|
|
+ releaseProductByBatch.setReleaseStatus(ReleaseStatus.had_exists.getPhrase());
|
|
|
+ releaseProductByBatch.setReleaseCode(ReleaseStatus.had_exists.value());
|
|
|
+ if (!StringUtilB2C.isEmpty(releaseProductByBatch.getErrmsg())) {
|
|
|
+ if (releaseProductByBatch.getErrmsg().substring(0, 1).equals(",")) {
|
|
|
+ releaseProductByBatch.setErrmsg(releaseProductByBatch.getErrmsg().substring(1));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
public ModelMap modifyByWorkbook(Workbook workbook) {
|
|
|
ModelMap modelMap = new ModelMap();
|
|
|
StoreIn self = getStoreIn(true);
|
|
|
@@ -788,7 +845,8 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
|
|
|
* @param currency 币别
|
|
|
* @param isPcb 是否pcb模块
|
|
|
*/
|
|
|
- private void validateTemplate(Row headerRow, int colNum, String currency, boolean isAPerson, boolean isPcb) {
|
|
|
+ @Override
|
|
|
+ public 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);
|
|
|
@@ -848,7 +906,8 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
|
|
|
* @param rowNum 行号
|
|
|
* @return
|
|
|
*/
|
|
|
- private boolean validateExcelData(Row row, int rowNum) {
|
|
|
+ @Override
|
|
|
+ public boolean validateExcelData(Row row, int rowNum) {
|
|
|
Object codeValue = readWorkBookCell(row.getCell(UploadConstant.PRODUCT_CODE), Cell.CELL_TYPE_STRING,
|
|
|
rowNum, UploadConstant.PRODUCT_CODE);
|
|
|
if ("只能填数字、英文、英文特殊符号".equals(StringUtilB2C.getStr(codeValue)) || "SJ-S-112DMH(举例)".equals(StringUtilB2C.getStr(codeValue)))
|
|
|
@@ -936,7 +995,8 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
|
|
|
* @param selfSale
|
|
|
* @return
|
|
|
*/
|
|
|
- private StoreIn getStoreInfo(Boolean selfSale) {
|
|
|
+ @Override
|
|
|
+ public StoreIn getStoreInfo(Boolean selfSale) {
|
|
|
StoreIn storeIn = null;
|
|
|
if(selfSale) {
|
|
|
storeIn = storeInService.findByEnUU(SystemSession.getUser().getEnterprise().getUu());
|
|
|
@@ -1054,7 +1114,8 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
|
|
|
* @param rowNum 行数
|
|
|
* @param isPcb 是否pcb模块
|
|
|
*/
|
|
|
- private int convertValueToProduct(Row row, ReleaseProductByBatch aProduct, int rowNum, boolean isAPerson, boolean isPcb) {
|
|
|
+ @Override
|
|
|
+ public int convertValueToProduct(Row row, ReleaseProductByBatch aProduct, int rowNum, boolean isAPerson, boolean isPcb) {
|
|
|
// 统计为空的个数
|
|
|
int result = 0;
|
|
|
aProduct.setNum(rowNum - 2);
|