|
|
@@ -6,6 +6,8 @@ import com.uas.platform.b2c.core.support.SystemSession;
|
|
|
import com.uas.platform.b2c.core.support.log.UsageBufferedLogger;
|
|
|
import com.uas.platform.b2c.core.utils.StringUtilB2C;
|
|
|
import com.uas.platform.b2c.prod.commodity.dao.GoodsDao;
|
|
|
+import com.uas.platform.b2c.prod.commodity.dao.ProductDao;
|
|
|
+import com.uas.platform.b2c.prod.commodity.model.Product;
|
|
|
import com.uas.platform.b2c.prod.product.brand.dao.BrandDao;
|
|
|
import com.uas.platform.b2c.prod.product.brand.modal.Brand;
|
|
|
import com.uas.platform.b2c.prod.product.component.dao.ComponentDao;
|
|
|
@@ -98,6 +100,9 @@ public class SeekPurchaseBomServiceImpl implements SeekPurchaseBomService {
|
|
|
@Autowired
|
|
|
private SearcherService searcherService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private ProductDao productDao;
|
|
|
+
|
|
|
private static final UsageBufferedLogger logger = BufferedLoggerManager.getLogger(UsageBufferedLogger.class);
|
|
|
|
|
|
/**
|
|
|
@@ -116,11 +121,11 @@ public class SeekPurchaseBomServiceImpl implements SeekPurchaseBomService {
|
|
|
public final int CODENUM = 2;
|
|
|
// 品牌
|
|
|
public final int BRANDNUM = 0;
|
|
|
-// // 截止日期
|
|
|
+ // // 截止日期
|
|
|
// public final int DEADLINENUM = 4;
|
|
|
// 采购数量
|
|
|
public final int AMOUNTNUM = 4;
|
|
|
-// public static final int CURRENCYNUM = 6;
|
|
|
+ // public static final int CURRENCYNUM = 6;
|
|
|
// public static final int UNITPRICENUM = 7;
|
|
|
// public static final int ENCAPSULATIONNUM = 8;
|
|
|
// public static final int PRODUCEDATENUM = 9;
|
|
|
@@ -132,6 +137,7 @@ public class SeekPurchaseBomServiceImpl implements SeekPurchaseBomService {
|
|
|
|
|
|
/**
|
|
|
* 导入bom
|
|
|
+ *
|
|
|
* @param workbook
|
|
|
* @param bomName
|
|
|
* @return
|
|
|
@@ -200,6 +206,7 @@ public class SeekPurchaseBomServiceImpl implements SeekPurchaseBomService {
|
|
|
|
|
|
/**
|
|
|
* 校验第二行是否为商城示例
|
|
|
+ *
|
|
|
* @param row
|
|
|
* @return
|
|
|
*/
|
|
|
@@ -218,6 +225,7 @@ public class SeekPurchaseBomServiceImpl implements SeekPurchaseBomService {
|
|
|
|
|
|
/**
|
|
|
* 验证是否为商城模板
|
|
|
+ *
|
|
|
* @param headerRow
|
|
|
* @return
|
|
|
*/
|
|
|
@@ -255,6 +263,7 @@ public class SeekPurchaseBomServiceImpl implements SeekPurchaseBomService {
|
|
|
|
|
|
/**
|
|
|
* 将列信息注入到求购临时实体中
|
|
|
+ *
|
|
|
* @param row
|
|
|
* @param seekPurchaseByBatch
|
|
|
* @param rowNum
|
|
|
@@ -404,13 +413,14 @@ public class SeekPurchaseBomServiceImpl implements SeekPurchaseBomService {
|
|
|
|
|
|
/**
|
|
|
* 判断输入是否合法
|
|
|
+ *
|
|
|
* @param code
|
|
|
* @return
|
|
|
*/
|
|
|
private String match(String code) {
|
|
|
List<String> filterList = Arrays.asList("空", "没", "无", "—", "-", "null", "#N/A");
|
|
|
for (String s : filterList) {
|
|
|
- if (s.equals(code)){
|
|
|
+ if (s.equals(code)) {
|
|
|
return null;
|
|
|
}
|
|
|
}
|
|
|
@@ -419,6 +429,7 @@ public class SeekPurchaseBomServiceImpl implements SeekPurchaseBomService {
|
|
|
|
|
|
/**
|
|
|
* 读取excel
|
|
|
+ *
|
|
|
* @return
|
|
|
*/
|
|
|
private Object readWorkBookCell(Cell cell, int cellType, int r, int n) {
|
|
|
@@ -426,7 +437,7 @@ public class SeekPurchaseBomServiceImpl implements SeekPurchaseBomService {
|
|
|
try {
|
|
|
if (cell != null && cell.getCellType() != Cell.CELL_TYPE_BLANK) {
|
|
|
switch (cellType) {
|
|
|
- case Cell.CELL_TYPE_STRING :
|
|
|
+ case Cell.CELL_TYPE_STRING:
|
|
|
cell.setCellType(HSSFCell.CELL_TYPE_STRING);
|
|
|
String str = cell.getStringCellValue().trim();
|
|
|
if (str.indexOf("\u00A0") > 0) {
|
|
|
@@ -435,7 +446,7 @@ public class SeekPurchaseBomServiceImpl implements SeekPurchaseBomService {
|
|
|
str = StringUtilB2C.replaceTabAndLineBreak(str);
|
|
|
obj = str.trim();
|
|
|
break;
|
|
|
- case Cell.CELL_TYPE_NUMERIC :
|
|
|
+ case Cell.CELL_TYPE_NUMERIC:
|
|
|
cell.setCellType(Cell.CELL_TYPE_NUMERIC);
|
|
|
obj = cell.getNumericCellValue();
|
|
|
if (obj != null) {
|
|
|
@@ -445,7 +456,7 @@ public class SeekPurchaseBomServiceImpl implements SeekPurchaseBomService {
|
|
|
}
|
|
|
}
|
|
|
break;
|
|
|
- default :
|
|
|
+ default:
|
|
|
if (cell.getCellType() == Cell.CELL_TYPE_STRING) {
|
|
|
String productTime = cell.getStringCellValue();
|
|
|
Pattern p = Pattern.compile("\\s*|\t|\r|\n");
|
|
|
@@ -475,7 +486,7 @@ public class SeekPurchaseBomServiceImpl implements SeekPurchaseBomService {
|
|
|
}
|
|
|
Page<SeekPurchaseByBatch> pageSeeks = seekPurchaseByBatchDao.findAll(new Specification<SeekPurchaseByBatch>() {
|
|
|
public Predicate toPredicate(Root<SeekPurchaseByBatch> root, CriteriaQuery<?> query,
|
|
|
- CriteriaBuilder builder) {
|
|
|
+ CriteriaBuilder builder) {
|
|
|
query.where(pageInfo.getPredicates(root, query, builder));
|
|
|
return null;
|
|
|
}
|
|
|
@@ -509,6 +520,7 @@ public class SeekPurchaseBomServiceImpl implements SeekPurchaseBomService {
|
|
|
|
|
|
/**
|
|
|
* 根据型号和品牌类目匹配
|
|
|
+ *
|
|
|
* @param brand
|
|
|
* @param code
|
|
|
* @return
|
|
|
@@ -562,7 +574,7 @@ public class SeekPurchaseBomServiceImpl implements SeekPurchaseBomService {
|
|
|
pageInfo.sorting("releaseDate", Direction.DESC);
|
|
|
Page<SeekPurchaseBomList> pageSeeks = seekPurchaseBomListDao.findAll(new Specification<SeekPurchaseBomList>() {
|
|
|
public Predicate toPredicate(Root<SeekPurchaseBomList> root, CriteriaQuery<?> query,
|
|
|
- CriteriaBuilder builder) {
|
|
|
+ CriteriaBuilder builder) {
|
|
|
query.where(pageInfo.getPredicates(root, query, builder));
|
|
|
return null;
|
|
|
}
|
|
|
@@ -625,7 +637,7 @@ public class SeekPurchaseBomServiceImpl implements SeekPurchaseBomService {
|
|
|
public Page<SeekPurchaseBom> findAllByPageInfo(final PageInfo pageInfo, String keyword) {
|
|
|
Sort sort = new Sort(Sort.Direction.DESC, "id");
|
|
|
pageInfo.setSort(sort);
|
|
|
- pageInfo.setOffset((pageInfo.getPageNumber() -1 ) * pageInfo.getPageSize());
|
|
|
+ pageInfo.setOffset((pageInfo.getPageNumber() - 1) * pageInfo.getPageSize());
|
|
|
if (!StringUtils.isEmpty(keyword)) {
|
|
|
pageInfo.expression(PredicateUtils.like("name", keyword, false));
|
|
|
}
|
|
|
@@ -758,10 +770,10 @@ public class SeekPurchaseBomServiceImpl implements SeekPurchaseBomService {
|
|
|
/**
|
|
|
* 部分发布,bom明细非全选时
|
|
|
*
|
|
|
- * @param detailIds detail id串 1,2,3,4...
|
|
|
- * @param endTime 截止时间 时间戳
|
|
|
- * @param count 采购套数
|
|
|
- * @param url 询价服务地址
|
|
|
+ * @param detailIds detail id串 1,2,3,4...
|
|
|
+ * @param endTime 截止时间 时间戳
|
|
|
+ * @param count 采购套数
|
|
|
+ * @param url 询价服务地址
|
|
|
* @return 处理结果
|
|
|
*/
|
|
|
@Override
|
|
|
@@ -795,10 +807,11 @@ public class SeekPurchaseBomServiceImpl implements SeekPurchaseBomService {
|
|
|
|
|
|
/**
|
|
|
* 发布bom询价
|
|
|
- * @param url 询价服务url
|
|
|
- * @param seekPurchaseByBatchList bom明细List
|
|
|
- * @param endTime 截止时间 时间戳
|
|
|
- * @param count 采购套数
|
|
|
+ *
|
|
|
+ * @param url 询价服务url
|
|
|
+ * @param seekPurchaseByBatchList bom明细List
|
|
|
+ * @param endTime 截止时间 时间戳
|
|
|
+ * @param count 采购套数
|
|
|
* @return 处理结果
|
|
|
*/
|
|
|
private ResultMap publishBomInquiry(String url, List<SeekPurchaseByBatch> seekPurchaseByBatchList, SeekPurchaseBom seekPurchaseBom, Long endTime, Integer count) {
|
|
|
@@ -858,10 +871,10 @@ public class SeekPurchaseBomServiceImpl implements SeekPurchaseBomService {
|
|
|
inquiry.setInquiryItems(inquiryItems);
|
|
|
String res = "";
|
|
|
try {
|
|
|
- res = HttpUtil.doPost(url + "/inquiry/buyer/save", FlexJsonUtils.toJsonDeep(inquiry));
|
|
|
- logger.log("bom求购确认发布成功",user.getUserUU() + ",参数:" + FlexJsonUtils.toJsonDeep(inquiry));
|
|
|
+ res = HttpUtil.doPost(url + "/inquiry/buyer/save", FlexJsonUtils.toJsonDeep(inquiry));
|
|
|
+ logger.log("bom求购确认发布成功", user.getUserUU() + ",参数:" + FlexJsonUtils.toJsonDeep(inquiry));
|
|
|
} catch (Exception e) {
|
|
|
- logger.log("bom求购确认发布报错",user.getUserUU() + ",错误:" + e.getMessage() + "参数:" + FlexJsonUtils.toJsonDeep(inquiry));
|
|
|
+ logger.log("bom求购确认发布报错", user.getUserUU() + ",错误:" + e.getMessage() + "参数:" + FlexJsonUtils.toJsonDeep(inquiry));
|
|
|
e.printStackTrace();
|
|
|
throw new IllegalOperatorException("发布失败");
|
|
|
}
|
|
|
@@ -870,4 +883,55 @@ public class SeekPurchaseBomServiceImpl implements SeekPurchaseBomService {
|
|
|
return ResultMap.success(result);
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public ModelMap saveNewProducts(List<SeekPurchaseByBatch> newProducts) {
|
|
|
+ ModelMap map = new ModelMap();
|
|
|
+ try {
|
|
|
+ List<Product> products = new ArrayList<>();
|
|
|
+ //判断传入参数是否为空
|
|
|
+ if (CollectionUtils.isEmpty(newProducts)) {
|
|
|
+ map.put("success", false);
|
|
|
+ map.put("message", "参数为空");
|
|
|
+ }
|
|
|
+ //获取传入参数第一个Bomid,为判断新增物料是否为同一个Bom清单里的
|
|
|
+ Long bomId = newProducts.get(0).getBomId();
|
|
|
+ for (SeekPurchaseByBatch newProduct : newProducts) {
|
|
|
+ if (newProduct.getBomId() == null && !Objects.equals(newProduct.getBomId(), bomId)) {
|
|
|
+ map.put("success", false);
|
|
|
+ map.put("message", "没有找到Bom清单id或者bomId不一致");
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+ Date now = new Date();
|
|
|
+ newProduct.setReleaseDate(now);
|
|
|
+ //如果该物料在物料表中不存在,则将新增物料添加到物料表中
|
|
|
+ Product product = new Product();
|
|
|
+ if (!CollectionUtils.isEmpty(productDao.findProductByPcmpcodeAndPbrandenAndEnUU(newProduct.getCode(), newProduct.getBrand(), SystemSession.getUser().getEnterprise().getUu()))){
|
|
|
+ product.setEnUU(SystemSession.getUser().getEnterprise().getUu());
|
|
|
+ product.setUserUU(SystemSession.getUser().getUserUU());
|
|
|
+ product.setProdNum(System.currentTimeMillis() + StringUtilB2C.getRandomNumber(5));
|
|
|
+ product.setBrand(newProduct.getBrand());
|
|
|
+ product.setCmpCode(newProduct.getCode());
|
|
|
+ product.setPbranden(newProduct.getBrand());
|
|
|
+ product.setPcmpcode(newProduct.getCode());
|
|
|
+ product.setSpec(newProduct.getSpec());
|
|
|
+ product.setProdName(newProduct.getKind());
|
|
|
+ product.setKind(newProduct.getKind());
|
|
|
+ products.add(product);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ seekPurchaseByBatchDao.save(newProducts);
|
|
|
+ SeekPurchaseBom bom = seekPurchaseBomDao.findOne(bomId);
|
|
|
+ //bom清单中数量按照传入条数增加
|
|
|
+ bom.setAmount(bom.getAmount() + newProducts.size());
|
|
|
+ seekPurchaseBomDao.save(bom);
|
|
|
+ if (!CollectionUtils.isEmpty(products)) {
|
|
|
+ productDao.save(products);
|
|
|
+ }
|
|
|
+ map.put("success", true);
|
|
|
+ } catch (Exception e) {
|
|
|
+ map.put("success", false);
|
|
|
+ map.put("message", e.getMessage());
|
|
|
+ }
|
|
|
+ return map;
|
|
|
+ }
|
|
|
}
|