|
@@ -268,59 +268,19 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
|
|
|
Long enUU = SystemSession.getUser().getEnterprise().getUu();
|
|
Long enUU = SystemSession.getUser().getEnterprise().getUu();
|
|
|
if (!isAPerson) {
|
|
if (!isAPerson) {
|
|
|
//1:比较品牌、型号、是否重复,一个EXCEL中只能有一条物料信息
|
|
//1:比较品牌、型号、是否重复,一个EXCEL中只能有一条物料信息
|
|
|
- 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("");
|
|
|
|
|
- releaseProductByBatch.addErrmsg(ErrorInfoConstant.REPEAT_IN_EXCEL.getInfo());
|
|
|
|
|
- releaseProductByBatch.setReleaseStatus(ReleaseStatus.had_exists.getPhrase());
|
|
|
|
|
- releaseProductByBatch.setReleaseCode(ReleaseStatus.had_exists.value());
|
|
|
|
|
- if (releaseProductByBatch.getErrmsg().substring(0, 1).equals(",")) {
|
|
|
|
|
- releaseProductByBatch.setErrmsg(releaseProductByBatch.getErrmsg().substring(1));
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ judgeSameReleaseProductByBatch(releaseProductByBatchs);
|
|
|
}
|
|
}
|
|
|
commonDao.save(releaseProductByBatchs, ReleaseProductByBatch.class);
|
|
commonDao.save(releaseProductByBatchs, ReleaseProductByBatch.class);
|
|
|
releaseProductByBatchDao.callReleaseExistValidProcedure(batch, enUU);
|
|
releaseProductByBatchDao.callReleaseExistValidProcedure(batch, enUU);
|
|
|
if (isAPerson) {
|
|
if (isAPerson) {
|
|
|
- for (ReleaseProductByBatch releaseProductByBatch : releaseProductByBatchs) {
|
|
|
|
|
- Long productid = releaseProductByBatch.getProductid();
|
|
|
|
|
- if (productid != null) {
|
|
|
|
|
- List<ProductPerson> productPersonList = productPersonDao.findByProductId(productid);
|
|
|
|
|
- if (!CollectionUtils.isEmpty(productPersonList)) {
|
|
|
|
|
- releaseProductByBatch.setErrmsg(ErrorInfoConstant.REPEAT_INFO.getInfo());
|
|
|
|
|
- releaseProductByBatch.setReleaseCode(ReleaseStatus.had_exists.value());
|
|
|
|
|
- releaseProductByBatch.setReleaseStatus(ReleaseStatus.had_exists.getPhrase());
|
|
|
|
|
- total --;
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ List<ReleaseProductByBatch> productByBatches = releaseProductByBatchDao.findByRelbatchid(batch);
|
|
|
|
|
+ judgeReleaseProductByBatchExistInProducts(productByBatches, total);
|
|
|
}
|
|
}
|
|
|
String strCount = "0";
|
|
String strCount = "0";
|
|
|
if (isPcb) {
|
|
if (isPcb) {
|
|
|
releaseProductByBatchDao.callValidProcedurePcb(enUU, batch);
|
|
releaseProductByBatchDao.callValidProcedurePcb(enUU, batch);
|
|
|
} else {
|
|
} else {
|
|
|
- final Object[] obj = new Object[]{enUU, batch};
|
|
|
|
|
- String sql = "/*#mycat:db_type=master*/ set @enuu = %s; set @batch = '%s'; call PRODUCT_RELEASE_VALID_V5(@enuu, @batch, @out); select @out";
|
|
|
|
|
- final String updateSql = String.format(sql, obj);
|
|
|
|
|
- strCount = jdbcTemplate.execute(new StatementCallback<String>() {
|
|
|
|
|
-
|
|
|
|
|
- @Override
|
|
|
|
|
- public String doInStatement(Statement stmt) throws SQLException, DataAccessException {
|
|
|
|
|
- stmt.executeQuery(updateSql);
|
|
|
|
|
- ResultSet rs = stmt.getResultSet();
|
|
|
|
|
- if (null != rs) {
|
|
|
|
|
- rs.next();
|
|
|
|
|
- return rs.getString(1);
|
|
|
|
|
- }
|
|
|
|
|
- return "0";
|
|
|
|
|
- }
|
|
|
|
|
- });
|
|
|
|
|
|
|
+ strCount = productReleaseValid(enUU, batch);
|
|
|
}
|
|
}
|
|
|
Integer filter = 0, failure = 0, success = 0;
|
|
Integer filter = 0, failure = 0, success = 0;
|
|
|
if (!StringUtilB2C.isEmpty(strCount)) {
|
|
if (!StringUtilB2C.isEmpty(strCount)) {
|
|
@@ -349,6 +309,93 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
|
|
|
return modelMap;
|
|
return modelMap;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 判断是存在相同的信息
|
|
|
|
|
+ * @param releaseProductByBatchs
|
|
|
|
|
+ */
|
|
|
|
|
+ private void judgeSameReleaseProductByBatch(List<ReleaseProductByBatch> releaseProductByBatchs) {
|
|
|
|
|
+ if (CollectionUtils.isEmpty(releaseProductByBatchs)) {
|
|
|
|
|
+ return ;
|
|
|
|
|
+ }
|
|
|
|
|
+ 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("");
|
|
|
|
|
+ releaseProductByBatch.addErrmsg(ErrorInfoConstant.REPEAT_IN_EXCEL.getInfo());
|
|
|
|
|
+ releaseProductByBatch.setReleaseStatus(ReleaseStatus.had_exists.getPhrase());
|
|
|
|
|
+ releaseProductByBatch.setReleaseCode(ReleaseStatus.had_exists.value());
|
|
|
|
|
+ if (releaseProductByBatch.getErrmsg().substring(0, 1).equals(",")) {
|
|
|
|
|
+ releaseProductByBatch.setErrmsg(releaseProductByBatch.getErrmsg().substring(1));
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 根据上传的信息,查看是否在个人物料库已存在。
|
|
|
|
|
+ * @param releaseProductByBatchs
|
|
|
|
|
+ * @param total
|
|
|
|
|
+ */
|
|
|
|
|
+ private void judgeReleaseProductByBatchExistInProducts(List<ReleaseProductByBatch> releaseProductByBatchs, Integer total) {
|
|
|
|
|
+ List<Long> ids = new ArrayList<>();
|
|
|
|
|
+ for (ReleaseProductByBatch releaseProductByBatch : releaseProductByBatchs) {
|
|
|
|
|
+ Long productid = releaseProductByBatch.getProductid();
|
|
|
|
|
+ if (productid != null) {
|
|
|
|
|
+ ids.add(productid);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ if (CollectionUtils.isNotEmpty(ids)) {
|
|
|
|
|
+ List<ProductPerson> productPersons = productPersonDao.findByProductIds(ids);
|
|
|
|
|
+ if (!CollectionUtils.isEmpty(productPersons)) {
|
|
|
|
|
+ for (ReleaseProductByBatch releaseProductByBatch : releaseProductByBatchs) {
|
|
|
|
|
+ if (releaseProductByBatch.getProductid() != null) {
|
|
|
|
|
+ for (ProductPerson productPerson : productPersons) {
|
|
|
|
|
+ if (releaseProductByBatch.getProductid().longValue() == productPerson.getProductId().longValue()) {
|
|
|
|
|
+ releaseProductByBatch.setErrmsg(ErrorInfoConstant.REPEAT_INFO.getInfo());
|
|
|
|
|
+ releaseProductByBatch.setReleaseCode(ReleaseStatus.had_exists.value());
|
|
|
|
|
+ releaseProductByBatch.setReleaseStatus(ReleaseStatus.had_exists.getPhrase());
|
|
|
|
|
+ total --;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 调用存储过程
|
|
|
|
|
+ * @param enUU 企业的enUU
|
|
|
|
|
+ * @param batch 批次
|
|
|
|
|
+ * @return 验证结果
|
|
|
|
|
+ */
|
|
|
|
|
+ private String productReleaseValid(Long enUU, String batch) {
|
|
|
|
|
+ final Object[] obj = new Object[]{enUU, batch};
|
|
|
|
|
+ String sql = "/*#mycat:db_type=master*/ set @enuu = %s; set @batch = '%s'; call PRODUCT_RELEASE_VALID_V5(@enuu, @batch, @out); select @out";
|
|
|
|
|
+ final String updateSql = String.format(sql, obj);
|
|
|
|
|
+ String strCount = jdbcTemplate.execute(new StatementCallback<String>() {
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public String doInStatement(Statement stmt) throws SQLException, DataAccessException {
|
|
|
|
|
+ stmt.executeQuery(updateSql);
|
|
|
|
|
+ ResultSet rs = stmt.getResultSet();
|
|
|
|
|
+ if (null != rs) {
|
|
|
|
|
+ rs.next();
|
|
|
|
|
+ return rs.getString(1);
|
|
|
|
|
+ }
|
|
|
|
|
+ return "0";
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ return strCount;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
@Override
|
|
@Override
|
|
|
public ModelMap modifyByWorkbook(Workbook workbook) {
|
|
public ModelMap modifyByWorkbook(Workbook workbook) {
|
|
|
ModelMap modelMap = new ModelMap();
|
|
ModelMap modelMap = new ModelMap();
|