|
|
@ -10,6 +10,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; |
|
|
|
import org.apache.commons.collections4.CollectionUtils; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
import org.nl.common.base.CommonPage; |
|
|
|
import org.nl.common.enums.wms.EasBillTypeEnum; |
|
|
|
import org.nl.common.exception.BadRequestException; |
|
|
@ -28,6 +29,7 @@ import org.nl.wms.ext.eas.WmsToEasService; |
|
|
|
import org.nl.wms.ext.srm.WmsToSrmService; |
|
|
|
import org.springframework.beans.BeanUtils; |
|
|
|
import org.springframework.beans.factory.annotation.Qualifier; |
|
|
|
import org.springframework.scheduling.annotation.Async; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.transaction.annotation.Propagation; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
@ -144,7 +146,7 @@ public class EasOutInBillServiceImpl extends ServiceImpl<EasOutInBillMapper, Eas |
|
|
|
List<WarehouseInfo> second = warehouseInfoList.stream() |
|
|
|
.filter(r -> r.getCkmc().contains("三期")) |
|
|
|
.collect(Collectors.toList()); |
|
|
|
//三期原材料库放在最前面
|
|
|
|
//三期原材料库放在最前面
|
|
|
|
Optional<WarehouseInfo> first = second.stream() |
|
|
|
.filter(r -> r.getCkbm().equals("3.03.013")) |
|
|
|
.findFirst(); |
|
|
@ -159,6 +161,22 @@ public class EasOutInBillServiceImpl extends ServiceImpl<EasOutInBillMapper, Eas |
|
|
|
return sortedList; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 获取仓库信息 |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public List<WarehouseInfo> getUserInfo() { |
|
|
|
return easOutInBillMapper.getWarehouseInfo(); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 获取仓库信息 |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public List<WarehouseInfo> getOrganizationInfo() { |
|
|
|
return easOutInBillMapper.getWarehouseInfo(); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
public JSONArray appUpdate() { |
|
|
@ -184,6 +202,7 @@ public class EasOutInBillServiceImpl extends ServiceImpl<EasOutInBillMapper, Eas |
|
|
|
.lambda() |
|
|
|
.eq(ObjectUtil.isNotEmpty(params.getDjlx()), EasOutInBill::getDjlx, params.getDjlx()) |
|
|
|
.eq(ObjectUtil.isNotEmpty(params.getCkbm()), EasOutInBill::getCkbm, params.getCkbm()) |
|
|
|
.eq(ObjectUtil.isNotEmpty(params.getCgybm()), EasOutInBill::getCgybm, params.getCgybm()) |
|
|
|
//.eq(ObjectUtil.isNotEmpty(params.getDjzt()), EasOutInBill::getDjzt, "1".equals(params.getDjzt()) ? "提交" : "审核")
|
|
|
|
.eq(ObjectUtil.isNotEmpty(params.getDjzt()), EasOutInBill::getDjzt, "提交") |
|
|
|
.nested(ObjectUtil.isNotEmpty(params.getFuzzy()), |
|
|
@ -257,14 +276,7 @@ public class EasOutInBillServiceImpl extends ServiceImpl<EasOutInBillMapper, Eas |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
public void insertOrUpdateBills(List<EasOutInBillDetail> easOutInBillDetails, List<EasOutInBillDetail> existingIds) { |
|
|
|
CompletableFuture.runAsync(() -> { |
|
|
|
try { |
|
|
|
insertBills(easOutInBillDetails, existingIds); |
|
|
|
} catch (Exception e) { |
|
|
|
log.error("异常信息:" + e); |
|
|
|
} |
|
|
|
}, pool); |
|
|
|
public void updateOrDeleteBills(List<EasOutInBillDetail> easOutInBillDetails, List<EasOutInBillDetail> existingIds) { |
|
|
|
CompletableFuture.runAsync(() -> { |
|
|
|
try { |
|
|
|
updateBills(easOutInBillDetails, existingIds); |
|
|
@ -279,7 +291,8 @@ public class EasOutInBillServiceImpl extends ServiceImpl<EasOutInBillMapper, Eas |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void insertBills(List<EasOutInBillDetail> easOutInBillDetails, List<EasOutInBillDetail> existingIds) { |
|
|
|
@Override |
|
|
|
public void insertInOutBills(List<EasOutInBillDetail> easOutInBillDetails, List<EasOutInBillDetail> existingIds) { |
|
|
|
Set<String> ids = existingIds.stream().map(EasOutInBillDetail::getFlid).collect(Collectors.toSet()); |
|
|
|
// 过滤出需要插入的新单据,并根据来源设置 ID
|
|
|
|
List<EasOutInBillDetail> insertEasBills = easOutInBillDetails.stream() |
|
|
@ -339,6 +352,8 @@ public class EasOutInBillServiceImpl extends ServiceImpl<EasOutInBillMapper, Eas |
|
|
|
bill.setCksj(detail.getCksj()); |
|
|
|
bill.setLlr(detail.getLlr()); |
|
|
|
bill.setDjly(detail.getDjly()); |
|
|
|
bill.setCgybm(detail.getCgybm()); |
|
|
|
bill.setCgymc(detail.getCgymc()); |
|
|
|
return bill; |
|
|
|
}) |
|
|
|
.collect(Collectors.toList()); |
|
|
@ -588,10 +603,31 @@ public class EasOutInBillServiceImpl extends ServiceImpl<EasOutInBillMapper, Eas |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Async("taskExecutor") |
|
|
|
public void confirmDtl(String billJson, String id) { |
|
|
|
try { |
|
|
|
SrmMsgDto srmMsgDto = wmsToSrmService.sendWebPostData(billJson, 2); |
|
|
|
if (srmMsgDto != null) { |
|
|
|
if ("false".equals(srmMsgDto.getSuccess())) { |
|
|
|
ReceiptBill bill = new ReceiptBill(); |
|
|
|
bill.setDjid(id); |
|
|
|
bill.setShjg(srmMsgDto.getMessage()); |
|
|
|
receiptBillMapper.updateById(bill); |
|
|
|
} |
|
|
|
} |
|
|
|
} catch (Exception e) { |
|
|
|
log.error("审核失败,异常原因:" + e.toString()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* 单个单据审核 |
|
|
|
*/ |
|
|
|
@Async("taskExecutor") |
|
|
|
public void asyncAuditBill(EasOutInBillDto bill) { |
|
|
|
String msg = ""; |
|
|
|
try { |
|
|
|
if ("1".equals(bill.getDjly())) { |
|
|
|
MsgDto msgDto; |
|
|
@ -601,7 +637,7 @@ public class EasOutInBillServiceImpl extends ServiceImpl<EasOutInBillMapper, Eas |
|
|
|
msgDto = wmsToEasService.sendWebService(billJson); |
|
|
|
if (msgDto != null) { |
|
|
|
if (msgDto.getResult() == 0) { |
|
|
|
throw new BadRequestException(msgDto.getMsg()); |
|
|
|
msg = msgDto.getMsg(); |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
@ -610,14 +646,14 @@ public class EasOutInBillServiceImpl extends ServiceImpl<EasOutInBillMapper, Eas |
|
|
|
srmMsgDto = wmsToSrmService.sendWebPostData(billJson, 1); |
|
|
|
if (srmMsgDto != null) { |
|
|
|
if ("false".equals(srmMsgDto.getSuccess())) { |
|
|
|
throw new BadRequestException(srmMsgDto.getMessage()); |
|
|
|
msg = srmMsgDto.getMessage(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
updateBills(bill); |
|
|
|
updateBills(bill, "审核成功!"); |
|
|
|
} catch (Exception e) { |
|
|
|
updateBills(bill, msg); |
|
|
|
log.error("推送Eas单据失败,单据号为:[" + bill.getBillId() + "]异常原因:" + e.toString()); |
|
|
|
throw new BadRequestException(e.toString()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
@ -632,7 +668,7 @@ public class EasOutInBillServiceImpl extends ServiceImpl<EasOutInBillMapper, Eas |
|
|
|
easData.setData(bill); |
|
|
|
String billJson = com.alibaba.fastjson.JSON.toJSONString(easData, SerializerFeature.WriteMapNullValue); |
|
|
|
wmsToEasService.sendWebService(billJson); |
|
|
|
updateBills(bill); |
|
|
|
updateBills(bill,"审核成功!"); |
|
|
|
} catch (Exception e) { |
|
|
|
log.error("推送Eas单据失败,单据号为:[" + bill.getBillId() + "]异常原因:" + e.toString()); |
|
|
|
//throw new BadRequestException(e.toString());
|
|
|
@ -649,7 +685,7 @@ public class EasOutInBillServiceImpl extends ServiceImpl<EasOutInBillMapper, Eas |
|
|
|
try { |
|
|
|
String billJson = com.alibaba.fastjson.JSON.toJSONString(bill, SerializerFeature.WriteMapNullValue); |
|
|
|
wmsToSrmService.sendWebPostData(billJson, 1); |
|
|
|
updateBills(bill); |
|
|
|
updateBills(bill,"审核成功!"); |
|
|
|
} catch (Exception e) { |
|
|
|
log.error("推送Eas单据失败,单据号为:[" + bill.getBillId() + "]异常原因:" + e.toString()); |
|
|
|
//throw new BadRequestException(e.toString());
|
|
|
@ -658,8 +694,14 @@ public class EasOutInBillServiceImpl extends ServiceImpl<EasOutInBillMapper, Eas |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void updateBills(EasOutInBillDto bill) { |
|
|
|
easOutInBillMapper.update(null, new UpdateWrapper<EasOutInBill>().set("djzt", "审核").set("update_id", SecurityUtils.getCurrentUserId()).set("update_name", SecurityUtils.getCurrentNickName()).set("update_time", DateUtil.format(DateUtil.beginOfDay(DateUtil.date()), "yyyy-MM-dd")).eq("djid", bill.getBillId())); |
|
|
|
private void updateBills(EasOutInBillDto bill, String msg) { |
|
|
|
UpdateWrapper<EasOutInBill> updateWrapper = new UpdateWrapper<EasOutInBill>().set("update_id", SecurityUtils.getCurrentUserId()).set("update_name", SecurityUtils.getCurrentNickName()).set("update_time", DateUtil.format(DateUtil.beginOfDay(DateUtil.date()), "yyyy-MM-dd")).eq("djid", bill.getBillId()); |
|
|
|
if (StringUtils.isNotBlank(msg)) { |
|
|
|
updateWrapper.set("djzt", "审核"); |
|
|
|
} else { |
|
|
|
updateWrapper.set("shjg", msg); |
|
|
|
} |
|
|
|
easOutInBillMapper.update(null, updateWrapper); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|