|
|
@@ -160,8 +160,9 @@ public class PurchaseNoticeServiceImpl implements PurchaseNoticeService {
|
|
|
@Override
|
|
|
public Predicate toPredicate(Root<PurchaseNotice> root, CriteriaQuery<?> query, CriteriaBuilder builder) {
|
|
|
if (filter != null) {
|
|
|
- if (!CollectionUtils.isEmpty(filter.getDistribute()))
|
|
|
+ if (!CollectionUtils.isEmpty(filter.getDistribute())) {
|
|
|
pageInfo.expression(PredicateUtils.in("enUU", filter.getDistribute(), false));
|
|
|
+ }
|
|
|
}
|
|
|
if (StringUtils.hasText(keyword)) {
|
|
|
List<Object> lists = new ArrayList<>();
|
|
|
@@ -171,12 +172,14 @@ public class PurchaseNoticeServiceImpl implements PurchaseNoticeService {
|
|
|
}
|
|
|
pageInfo.expression(PredicateUtils.in("id", lists, false));
|
|
|
}
|
|
|
- if (fromDate != null)
|
|
|
+ if (fromDate != null) {
|
|
|
pageInfo.expression(PredicateUtils.in("id", purchaseNoticeDao.findByFromDate(
|
|
|
SystemSession.getUser().getEnterprise().getUu(), new Date(fromDate)), false));
|
|
|
- if (endDate != null)
|
|
|
+ }
|
|
|
+ if (endDate != null) {
|
|
|
pageInfo.expression(PredicateUtils.in("id", purchaseNoticeDao
|
|
|
.findByEndDate(SystemSession.getUser().getEnterprise().getUu(), new Date(endDate)), false));
|
|
|
+ }
|
|
|
return query.where(pageInfo.getPredicates(root, query, builder)).getRestriction();
|
|
|
}
|
|
|
}, pageInfo);
|
|
|
@@ -188,12 +191,15 @@ public class PurchaseNoticeServiceImpl implements PurchaseNoticeService {
|
|
|
@Override
|
|
|
public Predicate toPredicate(Root<PurchaseNotice> root, CriteriaQuery<?> query, CriteriaBuilder builder) {
|
|
|
if (filter != null) {
|
|
|
- if (!CollectionUtils.isEmpty(filter.getDistribute()))
|
|
|
+ if (!CollectionUtils.isEmpty(filter.getDistribute())) {
|
|
|
pageInfo.expression(PredicateUtils.in("enUU", filter.getDistribute(), false));
|
|
|
- if (filter.getFromDate() != null)
|
|
|
+ }
|
|
|
+ if (filter.getFromDate() != null) {
|
|
|
pageInfo.expression(PredicateUtils.gte("date", new Date(filter.getFromDate()), false));
|
|
|
- if (filter.getEndDate() != null)
|
|
|
+ }
|
|
|
+ if (filter.getEndDate() != null) {
|
|
|
pageInfo.expression(PredicateUtils.lte("date", new Date(filter.getEndDate()), false));
|
|
|
+ }
|
|
|
}
|
|
|
return query.where(pageInfo.getPredicates(root, query, builder)).getRestriction();
|
|
|
}
|
|
|
@@ -213,12 +219,15 @@ public class PurchaseNoticeServiceImpl implements PurchaseNoticeService {
|
|
|
@Override
|
|
|
public Predicate toPredicate(Root<PurchaseNotice> root, CriteriaQuery<?> query, CriteriaBuilder builder) {
|
|
|
if (filter != null) {
|
|
|
- if (!CollectionUtils.isEmpty(filter.getDistribute()))
|
|
|
+ if (!CollectionUtils.isEmpty(filter.getDistribute())) {
|
|
|
pageInfo.expression(PredicateUtils.in("enUU", filter.getDistribute(), false));
|
|
|
- if (filter.getFromDate() != null)
|
|
|
+ }
|
|
|
+ if (filter.getFromDate() != null) {
|
|
|
pageInfo.expression(PredicateUtils.gte("date", new Date(filter.getFromDate()), false));
|
|
|
- if (filter.getEndDate() != null)
|
|
|
+ }
|
|
|
+ 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)));
|
|
|
@@ -238,6 +247,7 @@ public class PurchaseNoticeServiceImpl implements PurchaseNoticeService {
|
|
|
public Page<PurchaseNotice> findDoneByPageInfo(final PageInfo pageInfo, final String keyword, final Long fromDate,
|
|
|
final Long endDate) {
|
|
|
return purchaseNoticeDao.findAll(new Specification<PurchaseNotice>() {
|
|
|
+ @Override
|
|
|
public Predicate toPredicate(Root<PurchaseNotice> root, CriteriaQuery<?> query, CriteriaBuilder builder) {
|
|
|
pageInfo.filter("status", Status.REPLIED.value());
|
|
|
pageInfo.expression(
|
|
|
@@ -250,12 +260,14 @@ public class PurchaseNoticeServiceImpl implements PurchaseNoticeService {
|
|
|
}
|
|
|
pageInfo.expression(PredicateUtils.in("id", lists, false));
|
|
|
}
|
|
|
- if (fromDate != null)
|
|
|
+ if (fromDate != null) {
|
|
|
pageInfo.expression(PredicateUtils.in("id", purchaseNoticeDao.findByFromDate(
|
|
|
SystemSession.getUser().getEnterprise().getUu(), new Date(fromDate)), false));
|
|
|
- if (endDate != null)
|
|
|
+ }
|
|
|
+ if (endDate != null) {
|
|
|
pageInfo.expression(PredicateUtils.in("id", purchaseNoticeDao
|
|
|
.findByEndDate(SystemSession.getUser().getEnterprise().getUu(), new Date(endDate)), false));
|
|
|
+ }
|
|
|
return query.where(pageInfo.getPredicates(root, query, builder)).getRestriction();
|
|
|
}
|
|
|
}, pageInfo);
|
|
|
@@ -270,8 +282,9 @@ public class PurchaseNoticeServiceImpl implements PurchaseNoticeService {
|
|
|
public void send(List<SaleSendItem> sendItems) {
|
|
|
saleSendItemDao.save(sendItems);
|
|
|
for (SaleSendItem item : sendItems) {
|
|
|
- if (item.getNoticeId() != null)
|
|
|
+ if (item.getNoticeId() != null) {
|
|
|
purchaseNoticeDao.updateBySend(item.getNoticeId());
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -388,14 +401,17 @@ public class PurchaseNoticeServiceImpl implements PurchaseNoticeService {
|
|
|
// if (sends.size() > 0) {
|
|
|
// throw new IllegalOperatorException("发货单号重复,无法发货!提示:多个物料一起发货请选择批量发货。");
|
|
|
// }
|
|
|
- if (notice.getEnd() != null && notice.getEnd() == Constant.YES)
|
|
|
+ if (notice.getEnd() != null && notice.getEnd() == Constant.YES) {
|
|
|
throw new IllegalOperatorException("客户已经取消了本次送货提醒,请刷新重试!");
|
|
|
+ }
|
|
|
double thisQty = 0;
|
|
|
- for (SaleSendItem item : send.getSendItems())
|
|
|
+ for (SaleSendItem item : send.getSendItems()) {
|
|
|
thisQty += item.getQty();
|
|
|
+ }
|
|
|
double endQty = (notice.getEndQty() == null ? 0.0 : notice.getEndQty()) + thisQty;
|
|
|
- if (endQty > notice.getQty())
|
|
|
+ if (endQty > notice.getQty()) {
|
|
|
throw new IllegalOperatorException("累计发货数量将超出本次送货提醒的需求数!");
|
|
|
+ }
|
|
|
PurchaseOrder order = notice.getOrderItem().getOrder();
|
|
|
send.setCurrency(order.getCurrency());
|
|
|
send.setBackStatus((short) Status.NOT_UPLOAD.value());
|
|
|
@@ -466,8 +482,9 @@ public class PurchaseNoticeServiceImpl implements PurchaseNoticeService {
|
|
|
} else {
|
|
|
double thisQty = item.getQty();
|
|
|
double endQty = (notice.getEndQty() == null ? 0.0 : notice.getEndQty()) + thisQty;
|
|
|
- if (endQty > notice.getQty())
|
|
|
+ if (endQty > notice.getQty()) {
|
|
|
throw new IllegalOperatorException("累计发货数量将超出本次送货提醒的需求数!");
|
|
|
+ }
|
|
|
item.setNotice(notice);
|
|
|
if (item.getNumber() == null || item.getNumber() == 0) {// 带了序号则不重设序号,不带这重设序号
|
|
|
item.setNumber(++number);
|
|
|
@@ -510,8 +527,9 @@ public class PurchaseNoticeServiceImpl implements PurchaseNoticeService {
|
|
|
@Override
|
|
|
public Predicate toPredicate(Root<SaleSendAll> root, CriteriaQuery<?> query, CriteriaBuilder builder) {
|
|
|
if (filter != null) {
|
|
|
- if (!CollectionUtils.isEmpty(filter.getDistribute()))
|
|
|
+ if (!CollectionUtils.isEmpty(filter.getDistribute())) {
|
|
|
pageInfo.expression(PredicateUtils.in("custUU", filter.getDistribute(), false));
|
|
|
+ }
|
|
|
}
|
|
|
if (StringUtils.hasText(keyword)) {
|
|
|
List<Object> lists = new ArrayList<>();
|
|
|
@@ -524,12 +542,14 @@ public class PurchaseNoticeServiceImpl implements PurchaseNoticeService {
|
|
|
}
|
|
|
pageInfo.expression(PredicateUtils.in("id", lists, false));
|
|
|
}
|
|
|
- if (fromDate != null)
|
|
|
+ if (fromDate != null) {
|
|
|
pageInfo.expression(PredicateUtils.in("id", saleSendAllDao.findByFromDate(
|
|
|
SystemSession.getUser().getEnterprise().getUu(), new Date(fromDate)), false));
|
|
|
- if (endDate != null)
|
|
|
+ }
|
|
|
+ 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);
|
|
|
@@ -587,18 +607,20 @@ public class PurchaseNoticeServiceImpl implements PurchaseNoticeService {
|
|
|
SaleSendItem sendItem = saleSendItemDao.findOne(sendItemId);
|
|
|
int totalCount = saleSendItemDao.getTotalCountBySendId(sendItem.getSend().getId());
|
|
|
int verifyCount = saleSendItemDao.getFullVerifyCountBySendId(sendItem.getSend().getId());
|
|
|
- if (verifyCount == totalCount)
|
|
|
+ if (verifyCount == totalCount) {
|
|
|
sendItem.getSend().setVerifystatus(Constant.YES);
|
|
|
- else
|
|
|
+ } else {
|
|
|
sendItem.getSend().setVerifystatus(Constant.NO);
|
|
|
+ }
|
|
|
saleSendItemDao.save(sendItem);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public SaleSendAll findSaleSendById(Long id) {
|
|
|
SaleSendAll send = saleSendAllDao.findOne(id);
|
|
|
- if (send == null)
|
|
|
+ if (send == null) {
|
|
|
throw new IllegalOperatorException("您查找的发货单不存在!");
|
|
|
+ }
|
|
|
return send;
|
|
|
}
|
|
|
|
|
|
@@ -640,7 +662,7 @@ public class PurchaseNoticeServiceImpl implements PurchaseNoticeService {
|
|
|
// 获取条码生成规则,判断规则是否审核,已审核,根据规则拼接
|
|
|
B2bCodeSet barcodeSet = b2bCodeSetDao.findByEnUUAndType(custUU, "BATCH");
|
|
|
if (barcodeSet != null) {// 条码生成规则不为空,已审核
|
|
|
- if (!barcodeSet.getStatuscode().equals("AUDITED")) {
|
|
|
+ if (!"AUDITED".equals(barcodeSet.getStatuscode())) {
|
|
|
throw new IllegalOperatorException("请先审核条码生成规则!");
|
|
|
}
|
|
|
} else {
|
|
|
@@ -651,7 +673,7 @@ public class PurchaseNoticeServiceImpl implements PurchaseNoticeService {
|
|
|
if (outboxSet == null) {
|
|
|
throw new IllegalOperatorException("请先维护外箱生成规则!");
|
|
|
}
|
|
|
- if (!outboxSet.getStatuscode().equals("AUDITED")) {
|
|
|
+ if (!"AUDITED".equals(outboxSet.getStatuscode())) {
|
|
|
throw new IllegalOperatorException("请先审核外箱生成规则!");
|
|
|
}
|
|
|
for (SaleSendItem item : sendItem) {
|
|
|
@@ -756,19 +778,19 @@ public class PurchaseNoticeServiceImpl implements PurchaseNoticeService {
|
|
|
// 拼接
|
|
|
code.append(formPlat);// 平台标识
|
|
|
code.append(lpad(lenprid, pr_id));// PR_ID物料ID的长度
|
|
|
- if (dataStr.equals("YYMMDD")) {// 日期
|
|
|
+ if ("YYMMDD".equals(dataStr)) {// 日期
|
|
|
SimpleDateFormat YMD = new SimpleDateFormat("yyMMdd");
|
|
|
date = YMD.format(new Date());
|
|
|
- } else if (dataStr.equals("YYMM")) {
|
|
|
+ } else if ("YYMM".equals(dataStr)) {
|
|
|
SimpleDateFormat YM = new SimpleDateFormat("yyMM");
|
|
|
date = YM.format(new Date());
|
|
|
- } else if (dataStr.equals("MMDD")) {
|
|
|
+ } else if ("MMDD".equals(dataStr)) {
|
|
|
SimpleDateFormat MD = new SimpleDateFormat("MMdd");
|
|
|
date = MD.format(new Date());
|
|
|
}
|
|
|
code.append(date);// 日期
|
|
|
barcodeSet.setMaxdate(date);
|
|
|
- if (!("").equals(maxdate) && null != maxdate && (!date.equals("0"))
|
|
|
+ if (!("").equals(maxdate) && null != maxdate && (!"0".equals(date))
|
|
|
&& (Integer.valueOf(maxdate) > Integer.valueOf(date))) {// 如果当前日期大于上次日期
|
|
|
code.append(lpad(lennum, "1"));// 流水重新开始
|
|
|
barcodeSet.setMaxnum((long) 2);// 流水号增加1
|
|
|
@@ -790,19 +812,19 @@ public class PurchaseNoticeServiceImpl implements PurchaseNoticeService {
|
|
|
lenprid = barcodeSet.getLenprid().intValue();
|
|
|
code.append(formPlat);// 平台标识
|
|
|
code.append(lpad(lenprid, pr_id));// PR_ID物料ID的长度
|
|
|
- if (dataStr.equals("YYMMDD")) {
|
|
|
+ if ("YYMMDD".equals(dataStr)) {
|
|
|
SimpleDateFormat YMD = new SimpleDateFormat("yyMMdd");
|
|
|
date = YMD.format(new Date());
|
|
|
- } else if (dataStr.equals("YYMM")) {
|
|
|
+ } else if ("YYMM".equals(dataStr)) {
|
|
|
SimpleDateFormat YM = new SimpleDateFormat("yyMM");
|
|
|
date = YM.format(new Date());
|
|
|
- } else if (dataStr.equals("MMDD")) {
|
|
|
+ } else if ("MMDD".equals(dataStr)) {
|
|
|
SimpleDateFormat MD = new SimpleDateFormat("MMdd");
|
|
|
date = MD.format(new Date());
|
|
|
}
|
|
|
code.append(date);// 日期
|
|
|
barcodeSet.setMaxdate(date);
|
|
|
- if (!("").equals(maxdate) && null != maxdate && (!date.equals("0"))
|
|
|
+ if (!("").equals(maxdate) && null != maxdate && (!"0".equals(date))
|
|
|
&& (Integer.valueOf(maxdate) > Integer.valueOf(date))) {// 如果当前日期大于上次日期
|
|
|
code.append(lpad(lennum, "1"));// 流水重新开始
|
|
|
barcodeSet.setMaxnum((long) 2);// 流水号增加1
|
|
|
@@ -911,7 +933,7 @@ public class PurchaseNoticeServiceImpl implements PurchaseNoticeService {
|
|
|
SaleSend saleSend = saleSendDao.findOne(id);
|
|
|
Long custUU = saleSend.getCustUU();
|
|
|
String caller;
|
|
|
- if (type.equals("Bar")) {
|
|
|
+ if ("Bar".equals(type)) {
|
|
|
caller = "B2B!BarPrint";
|
|
|
} else {
|
|
|
caller = "B2B!OutBoxPrint";
|
|
|
@@ -997,12 +1019,40 @@ public class PurchaseNoticeServiceImpl implements PurchaseNoticeService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public List<Object[]> getNoticeCount(String category) {
|
|
|
- List<Long> ids = getUnreadIds(category);
|
|
|
- if (CollectionUtils.isEmpty(ids)){
|
|
|
- return new ArrayList<>();
|
|
|
+ public Map<String, Integer> getNoticeCount(String category) {
|
|
|
+ List<Long> unreadIds = getUnreadIds(category);
|
|
|
+ Map<String, Integer> map = new HashMap<>(3);
|
|
|
+ // 已回复数量
|
|
|
+ Integer repliedCount = 0;
|
|
|
+ // 未回复数量
|
|
|
+ Integer notReplyCount = 0;
|
|
|
+ if (CollectionUtils.isEmpty(unreadIds)){
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+ // 超过1000条需要拆分,不然会报错
|
|
|
+ if (unreadIds.size() > 1000) {
|
|
|
+ List<List<Long>> idsArray = SplitArray.splitAry(unreadIds, SplitArray.QUERY_MAX_NUMBER);
|
|
|
+ for (List<Long> ids : idsArray) {
|
|
|
+ // 超过100不再查询,页面显示99+,减少服务器负担
|
|
|
+ if (repliedCount < 100) {
|
|
|
+ repliedCount = repliedCount + purchaseNoticeDao.findRepliedId(ids).size();
|
|
|
+ }
|
|
|
+ if (notReplyCount < 100) {
|
|
|
+ notReplyCount = notReplyCount + purchaseNoticeDao.findNotReplyId(ids).size();
|
|
|
+ }
|
|
|
+ // 当需要查询的数量大于99时停止循环,减少不必要的操作
|
|
|
+ if (notReplyCount > 99 && repliedCount > 99) {
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ repliedCount = repliedCount + purchaseNoticeDao.findRepliedId(unreadIds).size();
|
|
|
+ notReplyCount = notReplyCount + purchaseNoticeDao.findNotReplyId(unreadIds).size();
|
|
|
}
|
|
|
- return purchaseNoticeDao.getUnreadCountEveryStatus(ids);
|
|
|
+ map.put("replied", repliedCount);
|
|
|
+ map.put("notReply", notReplyCount);
|
|
|
+ map.put("all", repliedCount + notReplyCount);
|
|
|
+ return map;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -1031,14 +1081,14 @@ public class PurchaseNoticeServiceImpl implements PurchaseNoticeService {
|
|
|
repliedIds = purchaseNoticeDao.findRepliedId(ids);
|
|
|
if (repliedIds.size() != 0) {
|
|
|
deleteCount = deleteCount + userOrderDao.delete(SystemSession.getUser().getEnterprise().getUu(),
|
|
|
- SystemSession.getUser().getUserUU(), "purc$notice", category, (Long[]) repliedIds.toArray());
|
|
|
+ SystemSession.getUser().getUserUU(), "purc$notice", category, repliedIds.toArray(new Long[repliedIds.size()]));
|
|
|
}
|
|
|
}
|
|
|
} else {
|
|
|
repliedIds = purchaseNoticeDao.findRepliedId(unreadIds);
|
|
|
if (repliedIds.size() != 0) {
|
|
|
deleteCount = deleteCount + userOrderDao.delete(SystemSession.getUser().getEnterprise().getUu(),
|
|
|
- SystemSession.getUser().getUserUU(), "purc$notice", category, (Long[]) repliedIds.toArray());
|
|
|
+ SystemSession.getUser().getUserUU(), "purc$notice", category, repliedIds.toArray(new Long[repliedIds.size()]));
|
|
|
}
|
|
|
}
|
|
|
return deleteCount;
|