|
|
@@ -4,16 +4,19 @@ import com.alibaba.fastjson.JSON;
|
|
|
import com.uas.platform.b2b.core.util.BoundedExecutor;
|
|
|
import com.uas.platform.b2b.core.util.DateFormatUtils;
|
|
|
import com.uas.platform.b2b.core.util.DateUtils;
|
|
|
+import com.uas.platform.b2b.core.util.StringUtil;
|
|
|
import com.uas.platform.b2b.core.util.ThreadTask;
|
|
|
import com.uas.platform.b2b.core.util.ThreadUtils;
|
|
|
import com.uas.platform.b2b.dao.CommonDao;
|
|
|
import com.uas.platform.b2b.dao.PurchaseApCheckDao;
|
|
|
+import com.uas.platform.b2b.dao.PurchaseApCheckItemInfoDao;
|
|
|
import com.uas.platform.b2b.dao.VendorDao;
|
|
|
import com.uas.platform.b2b.model.ApcheckKeyWord;
|
|
|
import com.uas.platform.b2b.model.DateFilter;
|
|
|
import com.uas.platform.b2b.model.ErpProdIODetail;
|
|
|
import com.uas.platform.b2b.model.ErpProdIo;
|
|
|
import com.uas.platform.b2b.model.PurchaseApCheck;
|
|
|
+import com.uas.platform.b2b.model.PurchaseApCheckItemInfo;
|
|
|
import com.uas.platform.b2b.model.Vendor;
|
|
|
import com.uas.platform.b2b.publicapi.model.ApCheckAmount;
|
|
|
import com.uas.platform.b2b.service.ErpProdIODetailService;
|
|
|
@@ -62,13 +65,16 @@ public class ErpProdIODetailServiceImpl implements ErpProdIODetailService {
|
|
|
|
|
|
private final BoundedExecutor executor;
|
|
|
|
|
|
+ private final PurchaseApCheckItemInfoDao apCheckItemInfoDao;
|
|
|
+
|
|
|
@Autowired
|
|
|
public ErpProdIODetailServiceImpl(CommonDao commonDao, PurchaseApCheckService apCheckService,
|
|
|
- VendorDao vendorDao, PurchaseApCheckDao apCheckDao) {
|
|
|
+ VendorDao vendorDao, PurchaseApCheckDao apCheckDao, PurchaseApCheckItemInfoDao apCheckItemInfoDao) {
|
|
|
this.commonDao = commonDao;
|
|
|
this.apCheckService = apCheckService;
|
|
|
this.vendorDao = vendorDao;
|
|
|
this.apCheckDao = apCheckDao;
|
|
|
+ this.apCheckItemInfoDao = apCheckItemInfoDao;
|
|
|
ExecutorService executorService = Executors.newCachedThreadPool();
|
|
|
executor = new BoundedExecutor(executorService, 1600);
|
|
|
}
|
|
|
@@ -137,48 +143,65 @@ public class ErpProdIODetailServiceImpl implements ErpProdIODetailService {
|
|
|
threadsSignal.await();
|
|
|
ErpProdIo erpProdIo = new ErpProdIo();
|
|
|
erpProdIo.setDetails(details);
|
|
|
- // 应收总额
|
|
|
- if (null != keyword.getCustomerUU()) {
|
|
|
- List<ApCheckAmount> totalTrades = apCheckService.getDueTrade(enUU, keyword.getCustomerUU());
|
|
|
- if (!CollectionUtil.isEmpty(totalTrades)) {
|
|
|
- List<Vendor> vendors = vendorDao.findByMyEnUUAndVendUU(keyword.getCustomerUU(), enUU);
|
|
|
- erpProdIo.setTotalCount(totalTrades);
|
|
|
- if (!CollectionUtil.isEmpty(vendors)) {
|
|
|
- String tradeString = JSON.toJSONString(totalTrades);
|
|
|
- ThreadUtils.task(()
|
|
|
- -> commonDao.getJdbcTemplate().update(String.format(ApCheckTask.UPDATE_COUNT_SQL, tradeString, vendors.get(0).getId()))
|
|
|
- );
|
|
|
- }
|
|
|
- }
|
|
|
- // 本月应收
|
|
|
- List<ApCheckAmount> thisMonthTrades = apCheckService.getThisMonthTrade(enUU, keyword.getCustomerUU(), checkDate, fromDate, endDate);
|
|
|
- erpProdIo.setThisMonthCount(thisMonthTrades);
|
|
|
- if (!CollectionUtil.isEmpty(thisMonthTrades)) {
|
|
|
- // 本月应收(未收)
|
|
|
- List<ApCheckAmount> thisMonthTodoTrades = null;
|
|
|
- try {
|
|
|
- thisMonthTodoTrades = apCheckService.getThisMonthTodoTrade(enUU, keyword.getCustomerUU(), checkDate, fromDate, endDate);
|
|
|
- } catch (InterruptedException e) {
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
- erpProdIo.setThisMonthTodoCount(thisMonthTodoTrades);
|
|
|
- // 本月应收(已收)
|
|
|
- List<ApCheckAmount> thisMonthDoneTrades = null;
|
|
|
- try {
|
|
|
- thisMonthDoneTrades = apCheckService.getThisMonthDoneTrade(enUU, keyword.getCustomerUU(), checkDate, fromDate, endDate);
|
|
|
- } catch (InterruptedException e) {
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
- erpProdIo.setThisMonthDoneCount(thisMonthDoneTrades);
|
|
|
- }
|
|
|
- }
|
|
|
- // 查询已生成的对账单(需进行转换)
|
|
|
- List<PurchaseApCheck> apCheckList = findApCheckList(enUU, keyword.getCustomerUU(), checkDate, fromDate, endDate);
|
|
|
- List<ErpProdIODetail> detailList = covertApCheckToErpIo(apCheckList);
|
|
|
- erpProdIo.getDetails().addAll(detailList);
|
|
|
+ if (null != keyword.getCustomerUU()) {
|
|
|
+ // 设置对账金额信息
|
|
|
+ setCheckAmount(erpProdIo, enUU, keyword.getCustomerUU(), checkDate, fromDate, endDate);
|
|
|
+ // 查询已生成的对账单(需进行转换)
|
|
|
+ List<PurchaseApCheckItemInfo> apCheckList = findApCheckList(enUU, keyword.getCustomerUU(), checkDate, fromDate, endDate, keyword);
|
|
|
+ List<ErpProdIODetail> detailList = covertApCheckToErpIo(apCheckList);
|
|
|
+ erpProdIo.getDetails().addAll(detailList);
|
|
|
+ }
|
|
|
return erpProdIo;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 设置对账金额信息
|
|
|
+ *
|
|
|
+ * @param erpProdIo ERP出入库单
|
|
|
+ * @param vendorUU 供应商UU
|
|
|
+ * @param customerUU 客户UU
|
|
|
+ * @param checkDate 对账月份
|
|
|
+ * @param fromDate 对账起始时间
|
|
|
+ * @param endDate 对账截止时间
|
|
|
+ * @throws InterruptedException 线程中断异常
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public void setCheckAmount(ErpProdIo erpProdIo, Long vendorUU, Long customerUU, String checkDate, Long fromDate, Long endDate) throws InterruptedException {
|
|
|
+ // 应收总额
|
|
|
+ List<ApCheckAmount> totalTrades = apCheckService.getDueTrade(vendorUU, customerUU);
|
|
|
+ if (!CollectionUtil.isEmpty(totalTrades)) {
|
|
|
+ List<Vendor> vendors = vendorDao.findByMyEnUUAndVendUU(customerUU, vendorUU);
|
|
|
+ erpProdIo.setTotalCount(totalTrades);
|
|
|
+ if (!CollectionUtil.isEmpty(vendors)) {
|
|
|
+ String tradeString = JSON.toJSONString(totalTrades);
|
|
|
+ ThreadUtils.task(()
|
|
|
+ -> commonDao.getJdbcTemplate().update(String.format(ApCheckTask.UPDATE_COUNT_SQL, tradeString, vendors.get(0).getId()))
|
|
|
+ );
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 本月应收
|
|
|
+ List<ApCheckAmount> thisMonthTrades = apCheckService.getThisMonthTrade(vendorUU, customerUU, checkDate, fromDate, endDate);
|
|
|
+ erpProdIo.setThisMonthCount(thisMonthTrades);
|
|
|
+ if (!CollectionUtil.isEmpty(thisMonthTrades)) {
|
|
|
+ // 本月应收(未收)
|
|
|
+ List<ApCheckAmount> thisMonthTodoTrades = null;
|
|
|
+ try {
|
|
|
+ thisMonthTodoTrades = apCheckService.getThisMonthTodoTrade(vendorUU, customerUU, checkDate, fromDate, endDate);
|
|
|
+ } catch (InterruptedException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ erpProdIo.setThisMonthTodoCount(thisMonthTodoTrades);
|
|
|
+ // 本月应收(已收)
|
|
|
+ List<ApCheckAmount> thisMonthDoneTrades = null;
|
|
|
+ try {
|
|
|
+ thisMonthDoneTrades = apCheckService.getThisMonthDoneTrade(vendorUU, customerUU, checkDate, fromDate, endDate);
|
|
|
+ } catch (InterruptedException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ erpProdIo.setThisMonthDoneCount(thisMonthDoneTrades);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 通过相关条件查询生成的对账单
|
|
|
*
|
|
|
@@ -187,20 +210,30 @@ public class ErpProdIODetailServiceImpl implements ErpProdIODetailService {
|
|
|
* @param checkDate 对账月份
|
|
|
* @param fromDate 起始时间
|
|
|
* @param endDate 截止时间
|
|
|
+ * @param keyword 过滤条件
|
|
|
*/
|
|
|
@Override
|
|
|
- public List<PurchaseApCheck> findApCheckList(Long vendUU, Long customerUU, String checkDate, Long fromDate, Long endDate) {
|
|
|
+ public List<PurchaseApCheckItemInfo> findApCheckList(Long vendUU, Long customerUU, String checkDate, Long fromDate, Long endDate, ApcheckKeyWord keyword) {
|
|
|
PageInfo pageInfo = new PageInfo();
|
|
|
- pageInfo.filter("enUu", vendUU);
|
|
|
- pageInfo.filter("custUu", customerUU);
|
|
|
+ pageInfo.filter("apCheck.enUu", vendUU);
|
|
|
+ pageInfo.filter("apCheck.custUu", customerUU);
|
|
|
DateFilter filter = initFilter(fromDate, endDate, checkDate);
|
|
|
if (filter.getSqlEndDate() != null) {
|
|
|
- pageInfo.expression(PredicateUtils.gte("recordDate", filter.getSqlFromDate(), false));
|
|
|
+ pageInfo.expression(PredicateUtils.gte("sourceDate", filter.getSqlFromDate(), false));
|
|
|
}
|
|
|
if (filter.getSqlEndDate() != null) {
|
|
|
- pageInfo.expression(PredicateUtils.lt("recordDate", filter.getSqlEndDate(), false));
|
|
|
+ pageInfo.expression(PredicateUtils.lt("sourceDate", filter.getSqlEndDate(), false));
|
|
|
+ }
|
|
|
+ if (!StringUtils.isEmpty(keyword.getProdTitle())) {
|
|
|
+ pageInfo.expression(PredicateUtils.like("prodTitle", keyword.getProdTitle(), true));
|
|
|
+ }
|
|
|
+ if (!StringUtils.isEmpty(keyword.getProdSpec())) {
|
|
|
+ pageInfo.expression(PredicateUtils.like("prodSpec", keyword.getProdSpec(), true));
|
|
|
+ }
|
|
|
+ if (null != keyword.getTaxRate()) {
|
|
|
+ pageInfo.filter("taxrate", keyword.getTaxRate());
|
|
|
}
|
|
|
- return apCheckDao.findAll((Root<PurchaseApCheck> root, CriteriaQuery<?> query, CriteriaBuilder builder) ->
|
|
|
+ return apCheckItemInfoDao.findAll((Root<PurchaseApCheckItemInfo> root, CriteriaQuery<?> query, CriteriaBuilder builder) ->
|
|
|
query.where(pageInfo.getPredicates(root, query, builder)).getRestriction());
|
|
|
}
|
|
|
|
|
|
@@ -211,11 +244,10 @@ public class ErpProdIODetailServiceImpl implements ErpProdIODetailService {
|
|
|
* @return 转换成ErpProdIODetail的数据
|
|
|
*/
|
|
|
@Override
|
|
|
- public List<ErpProdIODetail> covertApCheckToErpIo(List<PurchaseApCheck> apCheckList) {
|
|
|
+ public List<ErpProdIODetail> covertApCheckToErpIo(List<PurchaseApCheckItemInfo> apCheckList) {
|
|
|
List<ErpProdIODetail> details = new ArrayList<>();
|
|
|
apCheckList.forEach(
|
|
|
- apCheck -> apCheck.getItems().forEach(
|
|
|
- item -> details.add(new ErpProdIODetail(apCheck, item)))
|
|
|
+ apCheck -> details.add(new ErpProdIODetail(apCheck))
|
|
|
);
|
|
|
return details;
|
|
|
}
|