|
|
@@ -13,6 +13,7 @@ import com.uas.platform.b2b.model.*;
|
|
|
import com.uas.platform.b2b.ps.service.PersonalProductService;
|
|
|
import com.uas.platform.b2b.search.SearchService;
|
|
|
import com.uas.platform.b2b.service.PurchaseNoticeService;
|
|
|
+import com.uas.platform.b2b.support.SPageUtils;
|
|
|
import com.uas.platform.b2b.support.SystemSession;
|
|
|
import com.uas.platform.b2b.support.UsageBufferedLogger;
|
|
|
import com.uas.platform.b2b.support.XingePusher;
|
|
|
@@ -22,14 +23,13 @@ import com.uas.platform.core.model.Constant;
|
|
|
import com.uas.platform.core.model.PageInfo;
|
|
|
import com.uas.platform.core.model.Status;
|
|
|
import com.uas.platform.core.persistence.criteria.PredicateUtils;
|
|
|
-import com.uas.search.b2b.model.PageParams;
|
|
|
+import com.uas.search.b2b.model.SPage;
|
|
|
import org.apache.commons.collections.CollectionUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.data.domain.Page;
|
|
|
import org.springframework.data.jpa.domain.Specification;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
-import org.springframework.ui.ModelMap;
|
|
|
import org.springframework.util.StringUtils;
|
|
|
|
|
|
import javax.persistence.criteria.CriteriaBuilder;
|
|
|
@@ -40,6 +40,11 @@ import java.math.BigDecimal;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.util.*;
|
|
|
|
|
|
+/**
|
|
|
+ * 发货提醒
|
|
|
+ *
|
|
|
+ * @author US50
|
|
|
+ */
|
|
|
@Service
|
|
|
public class PurchaseNoticeServiceImpl implements PurchaseNoticeService {
|
|
|
|
|
|
@@ -83,9 +88,6 @@ public class PurchaseNoticeServiceImpl implements PurchaseNoticeService {
|
|
|
@Autowired
|
|
|
private SearchService searchService;
|
|
|
|
|
|
- @Autowired
|
|
|
- private PagingReleaseCountDao pagingReleaseCountDao;
|
|
|
-
|
|
|
@Autowired
|
|
|
private DistributeDao distributeDao;
|
|
|
|
|
|
@@ -104,6 +106,11 @@ public class PurchaseNoticeServiceImpl implements PurchaseNoticeService {
|
|
|
@Autowired
|
|
|
private PersonalProductService personalProductService;
|
|
|
|
|
|
+ /**
|
|
|
+ * 最多数量
|
|
|
+ */
|
|
|
+ final Integer MAX_SIZE = 1000;
|
|
|
+
|
|
|
@Override
|
|
|
public List<PurchaseNotice> save(List<PurchaseNotice> notices) {
|
|
|
notices = purchaseNoticeDao.save(notices);
|
|
|
@@ -369,7 +376,8 @@ public class PurchaseNoticeServiceImpl implements PurchaseNoticeService {
|
|
|
send.setCurrency(order.getCurrency());
|
|
|
send.setBackStatus((short) Status.NOT_UPLOAD.value());
|
|
|
send.setSendStatus((short) Status.NOT_UPLOAD.value());
|
|
|
- send.setVerifystatus(Constant.NO);// 未收料
|
|
|
+ // 未收料
|
|
|
+ send.setVerifystatus(Constant.NO);
|
|
|
send.setCustUU(notice.getEnUU());
|
|
|
send.setCustUserUU(order.getUserUU());
|
|
|
send.setDate(new Date());
|
|
|
@@ -419,7 +427,8 @@ public class PurchaseNoticeServiceImpl implements PurchaseNoticeService {
|
|
|
saleSend.setEnUU(SystemSession.getUser().getEnterprise().getUu());
|
|
|
saleSend.setRecorder(SystemSession.getUser().getUserName());
|
|
|
saleSend.setDate(new Date());
|
|
|
- saleSend.setVerifystatus(Constant.NO);// 未收料
|
|
|
+ // 未收料
|
|
|
+ saleSend.setVerifystatus(Constant.NO);
|
|
|
short number = 0;
|
|
|
List<SaleSendItem> sendItems = new ArrayList<SaleSendItem>();
|
|
|
for (SaleSendItem item : saleSend.getSendItems()) {
|
|
|
@@ -436,7 +445,8 @@ public class PurchaseNoticeServiceImpl implements PurchaseNoticeService {
|
|
|
throw new IllegalOperatorException("累计发货数量将超出本次送货提醒的需求数!");
|
|
|
}
|
|
|
item.setNotice(notice);
|
|
|
- if (item.getNumber() == null || item.getNumber() == 0) {// 带了序号则不重设序号,不带这重设序号
|
|
|
+ // 带了序号则不重设序号,不带这重设序号
|
|
|
+ if (item.getNumber() == null || item.getNumber() == 0) {
|
|
|
item.setNumber(++number);
|
|
|
}
|
|
|
item.setOrderItem(notice.getOrderItem());
|
|
|
@@ -474,41 +484,6 @@ public class PurchaseNoticeServiceImpl implements PurchaseNoticeService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- @Override
|
|
|
- public Page<SaleSendAll> findSendsByPageInfo(final PageInfo pageInfo, final String keyword, final Long fromDate,
|
|
|
- final Long endDate, final SearchFilter filter) {
|
|
|
- return saleSendAllDao.findAll(new Specification<SaleSendAll>() {
|
|
|
- @Override
|
|
|
- public Predicate toPredicate(Root<SaleSendAll> root, CriteriaQuery<?> query, CriteriaBuilder builder) {
|
|
|
- if (filter != null) {
|
|
|
- if (!CollectionUtils.isEmpty(filter.getDistribute())) {
|
|
|
- pageInfo.expression(PredicateUtils.in("custUU", filter.getDistribute(), false));
|
|
|
- }
|
|
|
- }
|
|
|
- if (StringUtils.hasText(keyword)) {
|
|
|
- List<Object> lists = new ArrayList<>();
|
|
|
- PageParams pageParams = new PageParams();
|
|
|
- ModelMap map = new ModelMap();
|
|
|
- map.put("pm_venduu", SystemSession.getUser().getEnterprise().getUu());
|
|
|
- pageParams.setFilters(map);
|
|
|
- for (SaleSendAll list : searchService.searchSaleSendIds(keyword, pageParams).getContent()) {
|
|
|
- lists.add(list.getId());
|
|
|
- }
|
|
|
- pageInfo.expression(PredicateUtils.in("id", lists, false));
|
|
|
- }
|
|
|
- if (fromDate != null) {
|
|
|
- pageInfo.expression(PredicateUtils.in("id", saleSendAllDao.findByFromDate(
|
|
|
- SystemSession.getUser().getEnterprise().getUu(), new Date(fromDate)), false));
|
|
|
- }
|
|
|
- if (endDate != null) {
|
|
|
- pageInfo.expression(PredicateUtils.in("id", saleSendAllDao
|
|
|
- .findByEndDate(SystemSession.getUser().getEnterprise().getUu(), new Date(endDate)), false));
|
|
|
- }
|
|
|
- return query.where(pageInfo.getPredicates(root, query, builder)).getRestriction();
|
|
|
- }
|
|
|
- }, pageInfo);
|
|
|
- }
|
|
|
-
|
|
|
@Override
|
|
|
public void onSaleSendChange(List<SaleSendItem> sendItems) {
|
|
|
List<Long> ids = new ArrayList<>();
|
|
|
@@ -622,13 +597,14 @@ public class PurchaseNoticeServiceImpl implements PurchaseNoticeService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- @Transactional
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
public void generateBarcodes(Long id, List<SaleSendItem> sendItem, Long enUU) {
|
|
|
SaleSend saleSend = saleSendDao.findOne(id);
|
|
|
Long custUU = saleSend.getCustUU();
|
|
|
// 获取条码生成规则,判断规则是否审核,已审核,根据规则拼接
|
|
|
B2bCodeSet barcodeSet = b2bCodeSetDao.findByEnUUAndType(custUU, "BATCH");
|
|
|
- if (barcodeSet != null) {// 条码生成规则不为空,已审核
|
|
|
+ // 条码生成规则不为空,已审核
|
|
|
+ if (barcodeSet != null) {
|
|
|
if (!"AUDITED".equals(barcodeSet.getStatuscode())) {
|
|
|
throw new IllegalOperatorException("请先审核条码生成规则!");
|
|
|
}
|
|
|
@@ -640,7 +616,8 @@ public class PurchaseNoticeServiceImpl implements PurchaseNoticeService {
|
|
|
if (outboxSet == null) {
|
|
|
throw new IllegalOperatorException("请先维护外箱生成规则!");
|
|
|
}
|
|
|
- if (!"AUDITED".equals(outboxSet.getStatuscode())) {
|
|
|
+ String AUDITED_STATUS = "AUDITED";
|
|
|
+ if (!AUDITED_STATUS.equals(outboxSet.getStatuscode())) {
|
|
|
throw new IllegalOperatorException("请先审核外箱生成规则!");
|
|
|
}
|
|
|
for (SaleSendItem item : sendItem) {
|
|
|
@@ -656,28 +633,31 @@ public class PurchaseNoticeServiceImpl implements PurchaseNoticeService {
|
|
|
}
|
|
|
}
|
|
|
barSendNotifyDao.deleteAllBySiid(item.getId());
|
|
|
- // logger.log("发货单", "清除条码",
|
|
|
- // "清除发货单:"+sitem.getSend().getCode()+",明细行序号:"+sitem.getNumber()+",所有条码!");
|
|
|
// 获取明细,最小包装数,外箱容量等信息
|
|
|
SaleSendItem sItem = saleSendItemDao.findOne(item.getId());
|
|
|
double pQty = sItem.getPackageQty(), bQty = sItem.getOutBoxQty(), qty = sItem.getQty();
|
|
|
String bar_code, pr_code = sItem.getOrderItem().getProduct().getCode();
|
|
|
- int aNum = (int) (qty / pQty);// 最小包装数件数
|
|
|
+ // 最小包装数件数
|
|
|
+ int aNum = (int) (qty / pQty);
|
|
|
double aqtyA = (new BigDecimal(Double.toString(qty))).subtract(new BigDecimal(Double.toString(aNum * pQty)))
|
|
|
.doubleValue(); // 小于最小包装数的
|
|
|
- String sourceId = String.valueOf(sItem.getOrderItem().getProduct().getSourceId());// ERP中对应的物料ID
|
|
|
+ // ERP中对应的物料ID
|
|
|
+ String sourceId = String.valueOf(sItem.getOrderItem().getProduct().getSourceId());
|
|
|
// 获取是否勾选了生成外箱
|
|
|
- if (item.getIsOutboxChecked()) {// 勾选了生成外箱
|
|
|
+ if (item.getIsOutboxChecked()) {
|
|
|
// 判断外箱容量是否为最小包装数的整数倍
|
|
|
String out_boxcode = null;
|
|
|
Long pa_id = null;
|
|
|
- int sumJ = (int) (bQty / pQty);// 每箱件数
|
|
|
+ // 每箱件数
|
|
|
+ int sumJ = (int) (bQty / pQty);
|
|
|
if (sumJ * pQty != bQty) {
|
|
|
throw new IllegalOperatorException("序号:" + sItem.getNumber() + ",外箱容量不是最小包装数的整数倍!");
|
|
|
}
|
|
|
- int bNum = (int) (qty / bQty); // 整数箱数
|
|
|
+ // 整数箱数
|
|
|
+ int bNum = (int) (qty / bQty);
|
|
|
+ // 零散数
|
|
|
double bqtyB = (new BigDecimal(Double.toString(qty)))
|
|
|
- .subtract(new BigDecimal(Double.toString(bNum * bQty))).doubleValue(); // 零散数
|
|
|
+ .subtract(new BigDecimal(Double.toString(bNum * bQty))).doubleValue();
|
|
|
if (aNum >= 1) {
|
|
|
for (int i = 0; i < aNum; i++) {
|
|
|
if (i % sumJ == 0) {
|
|
|
@@ -734,7 +714,33 @@ public class PurchaseNoticeServiceImpl implements PurchaseNoticeService {
|
|
|
return number;
|
|
|
}
|
|
|
|
|
|
- // 生成条码号
|
|
|
+ /**
|
|
|
+ * YYMMDD 日期格式
|
|
|
+ */
|
|
|
+ final String YYMMDD_PATTERN = "YYMMDD";
|
|
|
+
|
|
|
+ /**
|
|
|
+ * YYMM日期格式
|
|
|
+ */
|
|
|
+ final String YYMM_PATTERN= "YYMM";
|
|
|
+
|
|
|
+ /**
|
|
|
+ * MMDD日期格式
|
|
|
+ */
|
|
|
+ final String MMDD_PATTERN = "MMDD";
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 默认数量
|
|
|
+ */
|
|
|
+ final Integer NULL_COUNT = 0;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 生成条码号
|
|
|
+ *
|
|
|
+ * @param pr_id
|
|
|
+ * @param barcodeSet
|
|
|
+ * @return
|
|
|
+ */
|
|
|
public String barcodeMethod(String pr_id, B2bCodeSet barcodeSet) {
|
|
|
StringBuffer code = new StringBuffer();
|
|
|
String date = "0";
|
|
|
@@ -743,33 +749,46 @@ public class PurchaseNoticeServiceImpl implements PurchaseNoticeService {
|
|
|
int lennum = barcodeSet.getLennum().intValue(), maxnum = barcodeSet.getMaxnum().intValue(),
|
|
|
lenprid = barcodeSet.getLenprid().intValue();
|
|
|
// 拼接
|
|
|
- code.append(formPlat);// 平台标识
|
|
|
- code.append(lpad(lenprid, pr_id));// PR_ID物料ID的长度
|
|
|
- if ("YYMMDD".equals(dataStr)) {// 日期
|
|
|
+ // 平台标识
|
|
|
+ code.append(formPlat);
|
|
|
+ // PR_ID物料ID的长度
|
|
|
+ code.append(lpad(lenprid, pr_id));
|
|
|
+ if (YYMMDD_PATTERN.equals(dataStr)) {
|
|
|
SimpleDateFormat YMD = new SimpleDateFormat("yyMMdd");
|
|
|
date = YMD.format(new Date());
|
|
|
- } else if ("YYMM".equals(dataStr)) {
|
|
|
+ } else if (YYMM_PATTERN.equals(dataStr)) {
|
|
|
SimpleDateFormat YM = new SimpleDateFormat("yyMM");
|
|
|
date = YM.format(new Date());
|
|
|
- } else if ("MMDD".equals(dataStr)) {
|
|
|
+ } else if (MMDD_PATTERN.equals(dataStr)) {
|
|
|
SimpleDateFormat MD = new SimpleDateFormat("MMdd");
|
|
|
date = MD.format(new Date());
|
|
|
}
|
|
|
- code.append(date);// 日期
|
|
|
+ code.append(date);
|
|
|
barcodeSet.setMaxdate(date);
|
|
|
- if (!("").equals(maxdate) && null != maxdate && (!"0".equals(date))
|
|
|
- && (Integer.valueOf(maxdate) > Integer.valueOf(date))) {// 如果当前日期大于上次日期
|
|
|
- code.append(lpad(lennum, "1"));// 流水重新开始
|
|
|
- barcodeSet.setMaxnum((long) 2);// 流水号增加1
|
|
|
+ // 如果当前日期大于上次日期
|
|
|
+ if (!("").equals(maxdate) && null != maxdate && (!NULL_COUNT.equals(date))
|
|
|
+ && (Integer.valueOf(maxdate) > Integer.valueOf(date))) {
|
|
|
+ // 流水重新开始
|
|
|
+ code.append(lpad(lennum, "1"));
|
|
|
+ // 流水号增加1
|
|
|
+ barcodeSet.setMaxnum((long) 2);
|
|
|
} else {
|
|
|
- code.append(lpad(lennum, String.valueOf(maxnum)));// 当前流水号
|
|
|
- barcodeSet.setMaxnum((long) (maxnum + 1));// 流水号增加1
|
|
|
+ // 当前流水号
|
|
|
+ code.append(lpad(lennum, String.valueOf(maxnum)));
|
|
|
+ // 流水号增加1
|
|
|
+ barcodeSet.setMaxnum((long) (maxnum + 1));
|
|
|
}
|
|
|
b2bCodeSetDao.save(barcodeSet);
|
|
|
return code.toString();
|
|
|
}
|
|
|
|
|
|
- // 生成外箱号
|
|
|
+ /**
|
|
|
+ * 生成外箱号
|
|
|
+ *
|
|
|
+ * @param pr_id
|
|
|
+ * @param barcodeSet
|
|
|
+ * @return
|
|
|
+ */
|
|
|
public String outboxMethod(String pr_id, B2bCodeSet barcodeSet) {
|
|
|
StringBuffer code = new StringBuffer();
|
|
|
String date = "0";
|
|
|
@@ -777,27 +796,34 @@ public class PurchaseNoticeServiceImpl implements PurchaseNoticeService {
|
|
|
maxdate = barcodeSet.getMaxdate();
|
|
|
int lennum = barcodeSet.getLennum().intValue(), maxnum = barcodeSet.getMaxnum().intValue(),
|
|
|
lenprid = barcodeSet.getLenprid().intValue();
|
|
|
- code.append(formPlat);// 平台标识
|
|
|
- code.append(lpad(lenprid, pr_id));// PR_ID物料ID的长度
|
|
|
- if ("YYMMDD".equals(dataStr)) {
|
|
|
+ // 平台标识
|
|
|
+ code.append(formPlat);
|
|
|
+ // PR_ID物料ID的长度
|
|
|
+ code.append(lpad(lenprid, pr_id));
|
|
|
+ if (YYMMDD_PATTERN.equals(dataStr)) {
|
|
|
SimpleDateFormat YMD = new SimpleDateFormat("yyMMdd");
|
|
|
date = YMD.format(new Date());
|
|
|
- } else if ("YYMM".equals(dataStr)) {
|
|
|
+ } else if (YYMM_PATTERN.equals(dataStr)) {
|
|
|
SimpleDateFormat YM = new SimpleDateFormat("yyMM");
|
|
|
date = YM.format(new Date());
|
|
|
- } else if ("MMDD".equals(dataStr)) {
|
|
|
+ } else if (MMDD_PATTERN.equals(dataStr)) {
|
|
|
SimpleDateFormat MD = new SimpleDateFormat("MMdd");
|
|
|
date = MD.format(new Date());
|
|
|
}
|
|
|
- code.append(date);// 日期
|
|
|
+ code.append(date);
|
|
|
barcodeSet.setMaxdate(date);
|
|
|
- if (!("").equals(maxdate) && null != maxdate && (!"0".equals(date))
|
|
|
- && (Integer.valueOf(maxdate) > Integer.valueOf(date))) {// 如果当前日期大于上次日期
|
|
|
- code.append(lpad(lennum, "1"));// 流水重新开始
|
|
|
- barcodeSet.setMaxnum((long) 2);// 流水号增加1
|
|
|
+ // 如果当前日期大于上次日期
|
|
|
+ if (!("").equals(maxdate) && null != maxdate && (!NULL_COUNT.equals(date))
|
|
|
+ && (Integer.valueOf(maxdate) > Integer.valueOf(date))) {
|
|
|
+ // 流水重新开始
|
|
|
+ code.append(lpad(lennum, "1"));
|
|
|
+ // 流水号增加1
|
|
|
+ barcodeSet.setMaxnum((long) 2);
|
|
|
} else {
|
|
|
- code.append(lpad(lennum, String.valueOf(maxnum)));// 当前流水号
|
|
|
- barcodeSet.setMaxnum((long) (maxnum + 1));// 流水号增加1
|
|
|
+ // 当前流水号
|
|
|
+ code.append(lpad(lennum, String.valueOf(maxnum)));
|
|
|
+ // 流水号增加1
|
|
|
+ barcodeSet.setMaxnum((long) (maxnum + 1));
|
|
|
}
|
|
|
b2bCodeSetDao.save(barcodeSet);
|
|
|
return code.toString();
|
|
|
@@ -821,13 +847,15 @@ public class PurchaseNoticeServiceImpl implements PurchaseNoticeService {
|
|
|
barSendNotify.setSscode(sItem.getSend().getCode());
|
|
|
barSendNotify.setSsid(sItem.getSend().getId());
|
|
|
barSendNotify.setVendcode(enUU);
|
|
|
- barSendNotifyDao.save(barSendNotify); // 保存发货单明细中的条码
|
|
|
+ // 保存发货单明细中的条码
|
|
|
+ barSendNotifyDao.save(barSendNotify);
|
|
|
|
|
|
BarPackageDetail barPackageDetail = new BarPackageDetail();
|
|
|
barPackageDetail.setBarcode(bar_code);
|
|
|
barPackageDetail.setBarpackage(barPackageDao.findOne(pa_id));
|
|
|
barPackageDetail.setInnerqty(qty);
|
|
|
- barPackageDetailDao.save(barPackageDetail);// 保存包装箱明细
|
|
|
+ // 保存包装箱明细
|
|
|
+ barPackageDetailDao.save(barPackageDetail);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -854,7 +882,8 @@ public class PurchaseNoticeServiceImpl implements PurchaseNoticeService {
|
|
|
barSendNotify.setSscode(sItem.getSend().getCode());
|
|
|
barSendNotify.setSsid(sItem.getSend().getId());
|
|
|
barSendNotify.setVendcode(enUU);
|
|
|
- barSendNotifyDao.save(barSendNotify); // 保存发货单明细中的条码
|
|
|
+ // 保存发货单明细中的条码
|
|
|
+ barSendNotifyDao.save(barSendNotify);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -900,7 +929,8 @@ public class PurchaseNoticeServiceImpl implements PurchaseNoticeService {
|
|
|
SaleSend saleSend = saleSendDao.findOne(id);
|
|
|
Long custUU = saleSend.getCustUU();
|
|
|
String caller;
|
|
|
- if ("Bar".equals(type)) {
|
|
|
+ String BAR_TYPE = "Bar";
|
|
|
+ if (BAR_TYPE.equals(type)) {
|
|
|
caller = "B2B!BarPrint";
|
|
|
} else {
|
|
|
caller = "B2B!OutBoxPrint";
|
|
|
@@ -951,17 +981,6 @@ public class PurchaseNoticeServiceImpl implements PurchaseNoticeService {
|
|
|
saleSendItemDao.save(items);
|
|
|
}
|
|
|
|
|
|
- @Override
|
|
|
- public Long getSaleSendCount() {
|
|
|
- return saleSendAllDao.findByVendUU(SystemSession.getUser().getEnterprise().getUu());
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public Long getSaleSendVerify() {
|
|
|
- return saleSendAllDao.findByVendUUAndVerifystatus(SystemSession.getUser().getEnterprise().getUu(),
|
|
|
- Constant.YES);
|
|
|
- }
|
|
|
-
|
|
|
@Override
|
|
|
public void printCount(Long id) {
|
|
|
SaleSendAll send = saleSendAllDao.findOne(id);
|
|
|
@@ -973,18 +992,6 @@ public class PurchaseNoticeServiceImpl implements PurchaseNoticeService {
|
|
|
saleSendAllDao.save(send);
|
|
|
}
|
|
|
|
|
|
- @Override
|
|
|
- public Integer getNoticeUnreadCount() {
|
|
|
- return pagingReleaseCountDao.getUnreadCount(SystemSession.getUser().getEnterprise().getUu(),
|
|
|
- SystemSession.getUser().getUserUU(), "sale", "PURC$NOTICE");
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public Integer getSendUnreadCount() {
|
|
|
- return pagingReleaseCountDao.getUnreadCount(SystemSession.getUser().getEnterprise().getUu(),
|
|
|
- SystemSession.getUser().getUserUU(), "purc", "SALE$SEND");
|
|
|
- }
|
|
|
-
|
|
|
@Override
|
|
|
public Map<String, Integer> getNoticeCount(String category) {
|
|
|
List<Long> unreadIds = getUnreadIds(category);
|
|
|
@@ -997,7 +1004,7 @@ public class PurchaseNoticeServiceImpl implements PurchaseNoticeService {
|
|
|
return map;
|
|
|
}
|
|
|
// 超过1000条需要拆分,不然会报错
|
|
|
- if (unreadIds.size() > 1000) {
|
|
|
+ if (unreadIds.size() > MAX_SIZE) {
|
|
|
List<List<Long>> idsArray = SplitArray.splitAry(unreadIds, SplitArray.QUERY_MAX_NUMBER);
|
|
|
for (List<Long> ids : idsArray) {
|
|
|
// 超过100不再查询,页面显示99+,减少服务器负担
|
|
|
@@ -1022,19 +1029,80 @@ public class PurchaseNoticeServiceImpl implements PurchaseNoticeService {
|
|
|
return map;
|
|
|
}
|
|
|
|
|
|
- @Override
|
|
|
+ @Override
|
|
|
+ public SPage<PurchaseNotice> findDoneNoticesByPageInfo(final PageInfo pageInfo, String keyword, final SearchFilter filter) {
|
|
|
+ Page<PurchaseNotice> notices = purchaseNoticeDao.findAll(new Specification<PurchaseNotice>() {
|
|
|
+ @Override
|
|
|
+ public Predicate toPredicate(Root<PurchaseNotice> root, CriteriaQuery<?> query, CriteriaBuilder builder) {
|
|
|
+ if (filter != null) {
|
|
|
+ if (!CollectionUtils.isEmpty(filter.getDistribute())) {
|
|
|
+ pageInfo.expression(PredicateUtils.in("enUU", filter.getDistribute(), false));
|
|
|
+ }
|
|
|
+ if (filter.getFromDate() != null) {
|
|
|
+ pageInfo.expression(PredicateUtils.gte("date", new Date(filter.getFromDate()), false));
|
|
|
+ }
|
|
|
+ if (filter.getEndDate() != null) {
|
|
|
+ pageInfo.expression(PredicateUtils.lte("date", new Date(filter.getEndDate()), false));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ pageInfo.expression(
|
|
|
+ PredicateUtils.or(PredicateUtils.isNull("end"), PredicateUtils.ne("end", Constant.YES, false)));
|
|
|
+ return query.where(pageInfo.getPredicates(root, query, builder)).getRestriction();
|
|
|
+ }
|
|
|
+ }, pageInfo);
|
|
|
+ return SPageUtils.covertSPage(notices);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询未阅读数量
|
|
|
+ *
|
|
|
+ * @param category 表名
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
public List<Long> getUnreadIds(String category) {
|
|
|
return userOrderDao.getUnreadIds(SystemSession.getUser().getEnterprise().getUu(), SystemSession.getUser().getUserUU(), "purc$notice", category);
|
|
|
}
|
|
|
|
|
|
- @Override
|
|
|
- @Transactional
|
|
|
+ /**
|
|
|
+ * 查询发货提醒
|
|
|
+ *
|
|
|
+ * @param pageInfo 分页信息
|
|
|
+ * @param keyword 关键字
|
|
|
+ * @param filter 过滤条件
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public SPage<PurchaseNotice> findAllNoticesByPageInfo(final PageInfo pageInfo, String keyword, final SearchFilter filter) {
|
|
|
+ Page<PurchaseNotice> notices = purchaseNoticeDao.findAll(new Specification<PurchaseNotice>() {
|
|
|
+ @Override
|
|
|
+ public Predicate toPredicate(Root<PurchaseNotice> root, CriteriaQuery<?> query, CriteriaBuilder builder) {
|
|
|
+ if (filter != null) {
|
|
|
+ if (!CollectionUtils.isEmpty(filter.getDistribute())) {
|
|
|
+ pageInfo.expression(PredicateUtils.in("enUU", filter.getDistribute(), false));
|
|
|
+ }
|
|
|
+ if (filter.getFromDate() != null) {
|
|
|
+ pageInfo.expression(PredicateUtils.gte("date", new Date(filter.getFromDate()), false));
|
|
|
+ }
|
|
|
+ if (filter.getEndDate() != null) {
|
|
|
+ pageInfo.expression(PredicateUtils.lte("date", new Date(filter.getEndDate()), false));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ pageInfo.expression(PredicateUtils.isNull("end"));
|
|
|
+ return query.where(pageInfo.getPredicates(root, query, builder)).getRestriction();
|
|
|
+ }
|
|
|
+ }, pageInfo);
|
|
|
+ return SPageUtils.covertSPage(notices);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
public void setReadByOrder(String category, Long[] sourceId) {
|
|
|
userOrderDao.setReadStatus(SystemSession.getUser().getEnterprise().getUu(), SystemSession.getUser().getUserUU(), "purc$notice", category, (short) Status.READ.value(), sourceId);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- @Transactional
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
public Integer setReadByState(String category) {
|
|
|
List<Long> unreadIds = getUnreadIds(category);
|
|
|
Integer deleteCount = 0;
|
|
|
@@ -1042,7 +1110,7 @@ public class PurchaseNoticeServiceImpl implements PurchaseNoticeService {
|
|
|
return deleteCount;
|
|
|
}
|
|
|
List<Long> repliedIds = null;
|
|
|
- if (unreadIds.size() > 1000) {
|
|
|
+ if (unreadIds.size() > MAX_SIZE) {
|
|
|
List<List<Long>> idsArray = SplitArray.splitAry(unreadIds, SplitArray.QUERY_MAX_NUMBER);
|
|
|
for (List<Long> ids : idsArray) {
|
|
|
repliedIds = purchaseNoticeDao.findRepliedId(ids);
|
|
|
@@ -1060,4 +1128,15 @@ public class PurchaseNoticeServiceImpl implements PurchaseNoticeService {
|
|
|
}
|
|
|
return deleteCount;
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 通过ids查询发货信息
|
|
|
+ *
|
|
|
+ * @param ids
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public List<PurchaseNotice> findByIds(List<Long> ids) {
|
|
|
+ return purchaseNoticeDao.findAll(ids);
|
|
|
+ }
|
|
|
}
|