|
|
@@ -29,6 +29,7 @@ import org.springframework.ui.ModelMap;
|
|
|
import org.springframework.util.StringUtils;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
+import java.util.Arrays;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.HashSet;
|
|
|
import java.util.List;
|
|
|
@@ -69,6 +70,12 @@ public class PurchaseProductServiceImpl implements PurchaseProductService {
|
|
|
*/
|
|
|
private static final org.apache.log4j.Logger LOGGER = org.apache.log4j.Logger.getLogger(PurchaseProductServiceImpl.class);
|
|
|
|
|
|
+ /**
|
|
|
+ * 不需要传入的状态码
|
|
|
+ */
|
|
|
+ private final static List<Integer> failCode = Arrays.asList(ReleaseStatus.lack_info.value(),
|
|
|
+ ReleaseStatus.personal_had_exists.value());
|
|
|
+
|
|
|
/**
|
|
|
* 通过excel批量导入个人物料
|
|
|
*
|
|
|
@@ -84,6 +91,10 @@ public class PurchaseProductServiceImpl implements PurchaseProductService {
|
|
|
if (sheet.getRow(0) == null) {
|
|
|
return ResultMap.error(new IllegalOperatorException("表格模板不正确!请重新下载最新模板"));
|
|
|
}
|
|
|
+ int headNum = sheet.getRow(0).getPhysicalNumberOfCells();
|
|
|
+ if (headNum != UploadConstant.TOTAL_COLUMN_PERSON && headNum != UploadConstant.MAX_TOTAL_COLUMN_PERSON) {
|
|
|
+ return ResultMap.error(new IllegalOperatorException("表格模板不正确!请重新下载最新模板"));
|
|
|
+ }
|
|
|
int rowNum = SheetUtil.getSheetLastNum(sheet, UploadConstant.MAX_TOTAL_COLUMN);
|
|
|
// 表头占用行数
|
|
|
int minExcelNumber = 2;
|
|
|
@@ -134,13 +145,16 @@ public class PurchaseProductServiceImpl implements PurchaseProductService {
|
|
|
Long enUU = SystemSession.getUser().getEnterprise().getUu();
|
|
|
// 验证数据信息是否重复
|
|
|
releaseProductByBatchDao.callReleaseExistValidProcedure(batch, enUU);
|
|
|
+ // 验证数是否存在个人物料库
|
|
|
+ Long userUU = SystemSession.getUser().getUserUU();
|
|
|
+ releaseProductByBatchDao.callReleasePersonExistValidProcedure(batch, enUU, userUU);
|
|
|
ModelMap modelMap = new ModelMap();
|
|
|
// 处理上传数据
|
|
|
assignmentProductInfo(enUU, modelMap, batch);
|
|
|
// 验证成功后进行绑定处理
|
|
|
Integer assignNumber = 0;
|
|
|
// 去重后的数据
|
|
|
- List<ReleaseProductByBatch> uniqueBatchList = releaseProductByBatchDao.findByRelbatchidAndReleaseCodeNot(batch, ReleaseStatus.lack_info.value());
|
|
|
+ List<ReleaseProductByBatch> uniqueBatchList = releaseProductByBatchDao.findByRelbatchidAndReleaseCodeNot(userUU, batch, failCode);
|
|
|
if (!CollectionUtils.isEmpty(uniqueBatchList)) {
|
|
|
assignNumber = assignBatch(uniqueBatchList);
|
|
|
}
|
|
|
@@ -153,6 +167,17 @@ public class PurchaseProductServiceImpl implements PurchaseProductService {
|
|
|
return ResultMap.success();
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 通过批号查询导入失败的数据
|
|
|
+ *
|
|
|
+ * @param batch 批号
|
|
|
+ * @return List<ReleaseProductByBatch>
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public List<ReleaseProductByBatch> findFailureReleaseProductByBatch(String batch) {
|
|
|
+ return releaseProductByBatchDao.findByPublisherUuAndRelbatchidAndFailCode(SystemSession.getUser().getUserUU(), batch, failCode);
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 初始化赋值
|
|
|
*
|
|
|
@@ -272,7 +297,7 @@ public class PurchaseProductServiceImpl implements PurchaseProductService {
|
|
|
params.put("data", data);
|
|
|
HttpUtil.Response res = null;
|
|
|
try {
|
|
|
- res = HttpUtil.sendPostRequest(productServiceIp + "/productuser/coverToUserByIds", params);
|
|
|
+ res = HttpUtil.sendPostRequest("http://10.1.51.24" + "/productuser/coverToUserByIds", params);
|
|
|
return Integer.valueOf(res.getResponseText());
|
|
|
} catch (Exception e) {
|
|
|
String resultCode = null != res ? String.valueOf(res.getStatusCode()) : "access error";
|