|
|
@@ -2,6 +2,7 @@ package com.uas.platform.b2c.trade.seek.service.impl;
|
|
|
|
|
|
import com.uas.platform.b2c.common.account.model.User;
|
|
|
import com.uas.platform.b2c.common.search.service.SearcherService;
|
|
|
+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;
|
|
|
@@ -32,11 +33,13 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.dao.DataAccessException;
|
|
|
import org.springframework.data.domain.Page;
|
|
|
import org.springframework.data.domain.PageImpl;
|
|
|
+import org.springframework.data.domain.Sort;
|
|
|
import org.springframework.data.domain.Sort.Direction;
|
|
|
import org.springframework.data.jpa.domain.Specification;
|
|
|
import org.springframework.jdbc.core.JdbcTemplate;
|
|
|
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.ui.ModelMap;
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
import org.springframework.util.StringUtils;
|
|
|
|
|
|
@@ -154,6 +157,8 @@ public class SeekPurchaseBomServiceImpl implements SeekPurchaseBomService {
|
|
|
seekPurchaseBom.setReleaseDate(new Date(System.currentTimeMillis()));
|
|
|
seekPurchaseBom.setName(bomName);
|
|
|
seekPurchaseBom.setStatus(0);
|
|
|
+ seekPurchaseBom.setUu(SystemSession.getUser().getUserUU());
|
|
|
+ seekPurchaseBom.setEnuu(SystemSession.getUser().getEnterprise().getUu());
|
|
|
seekPurchaseBom = seekPurchaseBomDao.save(seekPurchaseBom);
|
|
|
// 获取第一行的信息
|
|
|
Row headerRow = sheet.getRow(0);
|
|
|
@@ -184,6 +189,8 @@ public class SeekPurchaseBomServiceImpl implements SeekPurchaseBomService {
|
|
|
seekPurchaseBomDao.delete(seekPurchaseBom.getId());
|
|
|
return new ResultMap(CodeType.PARAMETER_ERROR, "上传的excel内容为空,请填写完整后上传");
|
|
|
} else {
|
|
|
+ seekPurchaseBom.setAmount(seekPurchaseByBatchList.size());
|
|
|
+ seekPurchaseBomDao.save(seekPurchaseBom);
|
|
|
seekPurchaseByBatchDao.save(seekPurchaseByBatchList);
|
|
|
}
|
|
|
}
|
|
|
@@ -488,6 +495,7 @@ public class SeekPurchaseBomServiceImpl implements SeekPurchaseBomService {
|
|
|
return new PageImpl<SeekPurchaseByBatch>(seekPurchaseByBatchList, pageInfo, pageSeeks.getTotalElements());
|
|
|
}
|
|
|
|
|
|
+
|
|
|
@Override
|
|
|
public ResultMap confirmBom(Long bomId, User user, String url) {
|
|
|
SeekPurchaseBom seekPurchaseBom = seekPurchaseBomDao.findOne(bomId);
|
|
|
@@ -499,7 +507,7 @@ public class SeekPurchaseBomServiceImpl implements SeekPurchaseBomService {
|
|
|
// 商城现货的数量
|
|
|
int haveGoodsCount = 0;
|
|
|
Set<PurcInquiryItem> inquiryItems = new HashSet<>();
|
|
|
- List<SeekPurchaseByBatch> deleteBatchList = new ArrayList<>();
|
|
|
+// List<SeekPurchaseByBatch> deleteBatchList = new ArrayList<>();
|
|
|
Date endDate = null;
|
|
|
for (SeekPurchaseByBatch batch : seekPurchaseByBatchList) {
|
|
|
SeekPurchase seekPurchase = new SeekPurchase();
|
|
|
@@ -538,13 +546,13 @@ public class SeekPurchaseBomServiceImpl implements SeekPurchaseBomService {
|
|
|
if (goods != null && goods.size() > 0) {
|
|
|
haveGoodsCount++;
|
|
|
}
|
|
|
- deleteBatchList.add(batch);
|
|
|
+// deleteBatchList.add(batch);
|
|
|
inquiryItems.add(inquiryItem);
|
|
|
}
|
|
|
}
|
|
|
- seekPurchaseByBatchDao.delete(deleteBatchList);
|
|
|
+// seekPurchaseByBatchDao.delete(deleteBatchList);
|
|
|
// 询价单数据插入
|
|
|
- inquiry.setAmount(deleteBatchList.size());
|
|
|
+ inquiry.setAmount(inquiryItems.size());
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddsss");
|
|
|
try {
|
|
|
inquiry.setCode("MALL" + sdf.parse(sdf.format(new Date())).getTime());
|
|
|
@@ -571,8 +579,8 @@ public class SeekPurchaseBomServiceImpl implements SeekPurchaseBomService {
|
|
|
throw new IllegalOperatorException("发布失败");
|
|
|
}
|
|
|
// 删除bom的临时数据
|
|
|
- seekPurchaseBomDao.delete(seekPurchaseBom.getId());
|
|
|
- seekPurchaseBomListDao.deleteByBomId(seekPurchaseBom.getId());
|
|
|
+// seekPurchaseBomDao.delete(seekPurchaseBom.getId());
|
|
|
+// seekPurchaseBomListDao.deleteByBomId(seekPurchaseBom.getId());
|
|
|
Map<String, Object> result = new HashMap<>();
|
|
|
result.put("successAmount", inquiryItems.size());
|
|
|
result.put("goodsAmount", haveGoodsCount);
|
|
|
@@ -686,4 +694,123 @@ public class SeekPurchaseBomServiceImpl implements SeekPurchaseBomService {
|
|
|
return seekPurchaseBomListDao.findOne(bomId);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 通过分页信息和过滤条件查询bom列表
|
|
|
+ *
|
|
|
+ * @param pageInfo 分页参数
|
|
|
+ * @param keyword 关键词
|
|
|
+ * @return bom列表分页
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public Page<SeekPurchaseBom> findAllByPageInfo(PageInfo pageInfo, String keyword) {
|
|
|
+ Sort sort = new Sort(Sort.Direction.DESC, "id");
|
|
|
+ pageInfo.setSort(sort);
|
|
|
+ if (!StringUtils.isEmpty(keyword)) {
|
|
|
+ pageInfo.expression(PredicateUtils.like("name", keyword, false));
|
|
|
+ }
|
|
|
+ return seekPurchaseBomDao.findAll(new Specification<SeekPurchaseBom>() {
|
|
|
+ @Override
|
|
|
+ public Predicate toPredicate(Root<SeekPurchaseBom> root, CriteriaQuery<?> query, CriteriaBuilder cb) {
|
|
|
+ query.where(pageInfo.getPredicates(root, query, cb));
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ }, pageInfo);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取单个bom的信息
|
|
|
+ *
|
|
|
+ * @param bomId bom id
|
|
|
+ * @return bom的详情信息
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public SeekPurchaseBom findOne(Long bomId) {
|
|
|
+ List<SeekPurchaseByBatch> seekPurchaseByBatches = seekPurchaseByBatchDao.findByBomId(bomId);
|
|
|
+ SeekPurchaseBom bom = seekPurchaseBomDao.findOne(bomId);
|
|
|
+ bom.setSeekPurchaseByBatchs(seekPurchaseByBatches);
|
|
|
+ return bom;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 编辑bom信息
|
|
|
+ *
|
|
|
+ * @param bom 编辑完的bom信息
|
|
|
+ * @return 处理结果
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public ModelMap editBom(SeekPurchaseBom bom) {
|
|
|
+ ModelMap map = new ModelMap();
|
|
|
+ try {
|
|
|
+ List<SeekPurchaseByBatch> seekPurchaseByBatches = bom.getSeekPurchaseByBatchs();
|
|
|
+ if (!CollectionUtils.isEmpty(seekPurchaseByBatches)) {
|
|
|
+ seekPurchaseByBatchDao.save(seekPurchaseByBatches);
|
|
|
+ }
|
|
|
+ seekPurchaseBomDao.save(bom);
|
|
|
+ map.put("success", true);
|
|
|
+ } catch (Exception e) {
|
|
|
+ map.put("success", false);
|
|
|
+ map.put("message", e.getMessage());
|
|
|
+ }
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 删除bom信息
|
|
|
+ *
|
|
|
+ * @param bomId bomId
|
|
|
+ * @return 处理结果
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public ModelMap deleteBom(Long bomId) {
|
|
|
+ ModelMap map = new ModelMap();
|
|
|
+ try {
|
|
|
+ SeekPurchaseBom bom = seekPurchaseBomDao.findOne(bomId);
|
|
|
+ if (null != bom) {
|
|
|
+ List<SeekPurchaseByBatch> seekPurchaseByBatches = seekPurchaseByBatchDao.findByBomId(bomId);
|
|
|
+ if (!CollectionUtils.isEmpty(seekPurchaseByBatches)) {
|
|
|
+ seekPurchaseByBatchDao.delete(seekPurchaseByBatches);
|
|
|
+ }
|
|
|
+ seekPurchaseBomDao.delete(bom);
|
|
|
+ map.put("success", true);
|
|
|
+ } else {
|
|
|
+ map.put("success", false);
|
|
|
+ map.put("message", "未查找到对应bom记录");
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ map.put("success", false);
|
|
|
+ map.put("message", e.getMessage());
|
|
|
+ }
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 删除bom中的物料明细信息
|
|
|
+ *
|
|
|
+ * @param detailIds detail id串 1,2,3,4...
|
|
|
+ * @return 处理结果
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public ModelMap deleteBomProducts(String detailIds) {
|
|
|
+ ModelMap map = new ModelMap();
|
|
|
+ try {
|
|
|
+ List<Long> ids = new ArrayList<>();
|
|
|
+ String[] idArray = detailIds.split(",");
|
|
|
+ for (String idString : idArray) {
|
|
|
+ ids.add(Long.valueOf(idString));
|
|
|
+ }
|
|
|
+ List<SeekPurchaseByBatch> batches = seekPurchaseByBatchDao.findAll(ids);
|
|
|
+ if (!CollectionUtils.isEmpty(batches)) {
|
|
|
+ seekPurchaseByBatchDao.delete(batches);
|
|
|
+ map.put("success", true);
|
|
|
+ } else {
|
|
|
+ map.put("success", false);
|
|
|
+ map.put("message", "未找到对应bom明细产品记录");
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ map.put("success", false);
|
|
|
+ map.put("message", e.getMessage());
|
|
|
+ }
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+
|
|
|
}
|