Browse Source

add: 增加各类单据表头物料搜索

master1
gongbaoxiong 4 months ago
parent
commit
2e81e85bb0
  1. 3
      nlsso-server/src/main/java/org/nl/wms/database/eas/controller/AllocationBillController.java
  2. 3
      nlsso-server/src/main/java/org/nl/wms/database/eas/controller/ReceiptBillController.java
  3. 5
      nlsso-server/src/main/java/org/nl/wms/database/eas/dao/EasOutInBill.java
  4. 5
      nlsso-server/src/main/java/org/nl/wms/database/eas/dao/mapper/EasOutInBillMapper.java
  5. 35
      nlsso-server/src/main/java/org/nl/wms/database/eas/dao/xml/AllocationBillMapper.xml
  6. 32
      nlsso-server/src/main/java/org/nl/wms/database/eas/dao/xml/EasOutInBillMapper.xml
  7. 1
      nlsso-server/src/main/java/org/nl/wms/database/eas/dao/xml/ReceiptBillMapper.xml
  8. 5
      nlsso-server/src/main/java/org/nl/wms/database/eas/dto/EasOutInBillQuery.java
  9. 5
      nlsso-server/src/main/java/org/nl/wms/database/eas/service/impl/EasOutInBillDetailServiceImpl.java
  10. 275
      nlsso-server/src/main/java/org/nl/wms/database/eas/service/impl/EasOutInBillServiceImpl.java

3
nlsso-server/src/main/java/org/nl/wms/database/eas/controller/AllocationBillController.java

@ -98,8 +98,7 @@ public class AllocationBillController {
if (params.isEmpty()) { if (params.isEmpty()) {
throw new BadRequestException("参数为空!"); throw new BadRequestException("参数为空!");
} }
return RestBusinessTemplate.execute(() -> allocationBillService.allocationConfirm(params)); return RestBusinessTemplate.execute1(() -> allocationBillService.allocationConfirm(params));
//return RestBusinessTemplate.execute(() -> null);
} }

3
nlsso-server/src/main/java/org/nl/wms/database/eas/controller/ReceiptBillController.java

@ -90,8 +90,7 @@ public class ReceiptBillController {
if (params.isEmpty()) { if (params.isEmpty()) {
throw new BadRequestException("参数为空!"); throw new BadRequestException("参数为空!");
} }
return RestBusinessTemplate.execute(() -> receiptBillService.receiptConfirm(params)); return RestBusinessTemplate.execute1(() -> receiptBillService.receiptConfirm(params));
//return RestBusinessTemplate.execute(() -> null);
} }
/** /**

5
nlsso-server/src/main/java/org/nl/wms/database/eas/dao/EasOutInBill.java

@ -173,6 +173,11 @@ public class EasOutInBill extends Model<EasOutInBill> {
*/ */
private String shjg; private String shjg;
/**
* 物料编码
*/
private String wlbm;
/** /**
* 获取主键值 * 获取主键值
* *

5
nlsso-server/src/main/java/org/nl/wms/database/eas/dao/mapper/EasOutInBillMapper.java

@ -21,6 +21,11 @@ import java.util.Set;
*/ */
public interface EasOutInBillMapper extends BaseMapper<EasOutInBill> { public interface EasOutInBillMapper extends BaseMapper<EasOutInBill> {
Page<EasOutInBill> selectPageList(Page<EasOutInBill> page, @Param("fuzzy") String fuzzy,@Param("djlx") String djlx, @Param("cgybm") String cgybm,@Param("ckbm") String ckbm);
@DS("oracle_eas") @DS("oracle_eas")
List<EasOutInBillDetail> getEasBills(); List<EasOutInBillDetail> getEasBills();

35
nlsso-server/src/main/java/org/nl/wms/database/eas/dao/xml/AllocationBillMapper.xml

@ -3,17 +3,11 @@
<mapper namespace="org.nl.wms.database.eas.dao.mapper.AllocationBillMapper"> <mapper namespace="org.nl.wms.database.eas.dao.mapper.AllocationBillMapper">
<select id="getAllocationCount" resultType="java.lang.Long"> <select id="getAllocationCount" resultType="java.lang.Long">
WITH ranked_data AS ( SELECT t.*, ROW_NUMBER ( ) OVER ( PARTITION BY djbh ORDER BY CJSJ DESC ) AS rn FROM WITH ranked_data AS ( SELECT t.*, ROW_NUMBER ( ) OVER ( PARTITION BY djbh ORDER BY CJSJ DESC ) AS rn FROM
EAS_NOBLE.V_UC_STOCKTRANSFERBILL t ), EAS_NOBLE.V_UC_STOCKTRANSFERBILL t WHERE 1=1
grouped_data AS ( SELECT * FROM ranked_data WHERE rn = 1 ) SELECT
COUNT( 1 )
FROM
( SELECT temp.*, ROWNUM AS row_num FROM ( SELECT * FROM grouped_data
WHERE 1=1
<if test="fuzzy != null and fuzzy != ''"> <if test="fuzzy != null and fuzzy != ''">
AND (wlmc LIKE '%' || #{fuzzy} || '%' AND (wlmc LIKE '%' || #{fuzzy} || '%'
OR djbh LIKE '%' || #{fuzzy} || '%' OR djbh LIKE '%' || #{fuzzy} || '%'
OR wlbm LIKE '%' || #{fuzzy} || '%' OR wlbm LIKE '%' || #{fuzzy} || '%'
OR wlmc LIKE '%' || #{fuzzy} || '%'
OR dckcmc LIKE '%' || #{fuzzy} || '%' OR dckcmc LIKE '%' || #{fuzzy} || '%'
OR dcckmc LIKE '%' || #{fuzzy} || '%' OR dcckmc LIKE '%' || #{fuzzy} || '%'
OR drkcmc LIKE '%' || #{fuzzy} || '%' OR drkcmc LIKE '%' || #{fuzzy} || '%'
@ -24,30 +18,33 @@
</if> </if>
<if test="dckcbm != null and dckcbm != ''"> <if test="dckcbm != null and dckcbm != ''">
AND (dckcbm = #{dckcbm}) AND (dckcbm = #{dckcbm})
</if> </if> ),
grouped_data AS ( SELECT * FROM ranked_data WHERE rn = 1 ) SELECT
COUNT( 1 )
FROM
( SELECT temp.*, ROWNUM AS row_num FROM ( SELECT * FROM grouped_data
ORDER BY CJSJ DESC ) temp ) ORDER BY CJSJ DESC ) temp )
</select> </select>
<select id="allocationPage" resultType="org.nl.wms.database.eas.dto.AllocationBillQuery"> <select id="allocationPage" resultType="org.nl.wms.database.eas.dto.AllocationBillQuery">
WITH ranked_data AS ( SELECT t.*, ROW_NUMBER ( ) OVER ( PARTITION BY djbh ORDER BY CJSJ DESC ) AS rn FROM WITH ranked_data AS ( SELECT t.*, ROW_NUMBER ( ) OVER ( PARTITION BY djbh ORDER BY CJSJ DESC ) AS rn FROM
EAS_NOBLE.V_UC_STOCKTRANSFERBILL t ), EAS_NOBLE.V_UC_STOCKTRANSFERBILL t WHERE 1=1
grouped_data AS ( SELECT * FROM ranked_data WHERE rn = 1 ) SELECT * FROM
( SELECT temp.*, ROWNUM AS row_num FROM ( SELECT * FROM grouped_data WHERE 1=1
<if test="fuzzy != null and fuzzy != ''"> <if test="fuzzy != null and fuzzy != ''">
AND (wlmc LIKE '%' || #{fuzzy} || '%' AND (wlmc LIKE '%' || #{fuzzy} || '%'
OR djbh LIKE '%' || #{fuzzy} || '%' OR djbh LIKE '%' || #{fuzzy} || '%'
OR wlbm LIKE '%' || #{fuzzy} || '%' OR wlbm LIKE '%' || #{fuzzy} || '%'
OR wlmc LIKE '%' || #{fuzzy} || '%' OR dckcmc LIKE '%' || #{fuzzy} || '%'
OR dckcmc LIKE '%' || #{fuzzy} || '%' OR dcckmc LIKE '%' || #{fuzzy} || '%'
OR dcckmc LIKE '%' || #{fuzzy} || '%' OR drkcmc LIKE '%' || #{fuzzy} || '%'
OR drkcmc LIKE '%' || #{fuzzy} || '%' )
)
</if> </if>
<if test="drkcbm != null and drkcbm != ''"> <if test="drkcbm != null and drkcbm != ''">
AND (drkcbm = #{drkcbm}) AND (drkcbm = #{drkcbm})
</if> </if>
<if test="dckcbm != null and dckcbm != ''"> <if test="dckcbm != null and dckcbm != ''">
AND (dckcbm = #{dckcbm}) AND (dckcbm = #{dckcbm})
</if> </if> ),
grouped_data AS ( SELECT * FROM ranked_data WHERE rn = 1 ) SELECT * FROM
( SELECT temp.*, ROWNUM AS row_num FROM ( SELECT * FROM grouped_data
ORDER BY CJSJ DESC ) temp WHERE <![CDATA[ ROWNUM <= #{size} * #{page} ]]>) WHERE ORDER BY CJSJ DESC ) temp WHERE <![CDATA[ ROWNUM <= #{size} * #{page} ]]>) WHERE
<![CDATA[ row_num > #{size} * (#{page} - 1) ]]> <![CDATA[ row_num > #{size} * (#{page} - 1) ]]>
</select> </select>

32
nlsso-server/src/main/java/org/nl/wms/database/eas/dao/xml/EasOutInBillMapper.xml

@ -1,6 +1,38 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="org.nl.wms.database.eas.dao.mapper.EasOutInBillMapper"> <mapper namespace="org.nl.wms.database.eas.dao.mapper.EasOutInBillMapper">
<select id="selectPageList" resultType="org.nl.wms.database.eas.dao.EasOutInBill">
SELECT *
FROM eas_out_in_bill
WHERE 1=1
AND djzt ='提交'
<if test="ckbm != null and ckbm != ''">
AND ckbm = #{ckbm}
</if>
<if test="cgybm != null and cgybm != ''">
AND cgybm = #{cgybm}
</if>
<if test="djlx != null and djlx != ''">
AND djlx = #{djlx}
</if>
<if test="fuzzy != null and fuzzy != ''">
AND DJID IN (
SELECT djid
FROM eas_out_in_bill_detail
WHERE djbh LIKE CONCAT('%', #{fuzzy}, '%')
OR wlmc LIKE CONCAT('%', #{fuzzy}, '%')
OR wlbm LIKE CONCAT('%', #{fuzzy}, '%')
OR zzbm LIKE CONCAT('%', #{fuzzy}, '%')
OR bmmc LIKE CONCAT('%', #{fuzzy}, '%')
OR zzmc LIKE CONCAT('%', #{fuzzy}, '%')
OR ckmc LIKE CONCAT('%', #{fuzzy}, '%')
OR cjr LIKE CONCAT('%', #{fuzzy}, '%')
OR cgybm LIKE CONCAT('%', #{fuzzy}, '%')
GROUP BY djid
)
</if>
ORDER BY cjsj DESC
</select>
<select id="getEasBills" resultType="org.nl.wms.database.eas.dao.EasOutInBillDetail"> <select id="getEasBills" resultType="org.nl.wms.database.eas.dao.EasOutInBillDetail">

1
nlsso-server/src/main/java/org/nl/wms/database/eas/dao/xml/ReceiptBillMapper.xml

@ -8,6 +8,7 @@
<if test="fuzzy != null and fuzzy != ''"> <if test="fuzzy != null and fuzzy != ''">
AND(djbh LIKE CONCAT('%', #{fuzzy}, '%') AND(djbh LIKE CONCAT('%', #{fuzzy}, '%')
OR wlmc LIKE CONCAT('%', #{fuzzy}, '%') OR wlmc LIKE CONCAT('%', #{fuzzy}, '%')
OR wlbm LIKE CONCAT('%', #{fuzzy}, '%')
OR ggxh LIKE CONCAT('%', #{fuzzy}, '%') OR ggxh LIKE CONCAT('%', #{fuzzy}, '%')
OR djbh LIKE CONCAT('%', #{fuzzy}, '%') OR djbh LIKE CONCAT('%', #{fuzzy}, '%')
OR cggs LIKE CONCAT('%', #{fuzzy}, '%') OR cggs LIKE CONCAT('%', #{fuzzy}, '%')

5
nlsso-server/src/main/java/org/nl/wms/database/eas/dto/EasOutInBillQuery.java

@ -123,4 +123,9 @@ public class EasOutInBillQuery extends BaseQuery<EasOutInBill> {
private String cgybm; private String cgybm;
/**
* 物料编码
*/
private String wlbm;
} }

5
nlsso-server/src/main/java/org/nl/wms/database/eas/service/impl/EasOutInBillDetailServiceImpl.java

@ -42,7 +42,7 @@ public class EasOutInBillDetailServiceImpl extends ServiceImpl<EasOutInBillDetai
private EasOutInBillDetailMapper easOutInBillDetailMapper; private EasOutInBillDetailMapper easOutInBillDetailMapper;
@Resource @Resource
private IeasOutInBillService ieasOutInBillService; private IeasOutInBillService ieasOutInBillService;
/** /**
@ -185,6 +185,9 @@ public class EasOutInBillDetailServiceImpl extends ServiceImpl<EasOutInBillDetai
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public void updateBillDetail(List<EasOutInBillDetailVO> entityList) { public void updateBillDetail(List<EasOutInBillDetailVO> entityList) {
if (CollectionUtils.isNotEmpty(entityList)) { if (CollectionUtils.isNotEmpty(entityList)) {
if (StringUtils.isBlank(entityList.get(0).getKwbm())) {
throw new BadRequestException("库位信息不能为空");
}
UpdateWrapper<EasOutInBillDetail> updateWrapper = new UpdateWrapper<>(); UpdateWrapper<EasOutInBillDetail> updateWrapper = new UpdateWrapper<>();
updateWrapper.in("flid", entityList.stream().map(EasOutInBillDetailVO::getFlid).collect(Collectors.toSet())); updateWrapper.in("flid", entityList.stream().map(EasOutInBillDetailVO::getFlid).collect(Collectors.toSet()));
updateWrapper.set("kwbm", entityList.get(0).getKwbm()); updateWrapper.set("kwbm", entityList.get(0).getKwbm());

275
nlsso-server/src/main/java/org/nl/wms/database/eas/service/impl/EasOutInBillServiceImpl.java

@ -162,21 +162,13 @@ public class EasOutInBillServiceImpl extends ServiceImpl<EasOutInBillMapper, Eas
public List<WarehouseInfo> getWarehouseInfo() { public List<WarehouseInfo> getWarehouseInfo() {
List<WarehouseInfo> warehouseInfoList = easOutInBillMapper.getWarehouseInfo(); List<WarehouseInfo> warehouseInfoList = easOutInBillMapper.getWarehouseInfo();
//三期的仓库放在前面 //三期的仓库放在前面
List<WarehouseInfo> second = warehouseInfoList.stream() List<WarehouseInfo> second = warehouseInfoList.stream().filter(r -> r.getCkmc().contains("三期")).collect(Collectors.toList());
.filter(r -> r.getCkmc().contains("三期"))
.collect(Collectors.toList());
//三期原材料库放在最前面 //三期原材料库放在最前面
Optional<WarehouseInfo> first = second.stream() Optional<WarehouseInfo> first = second.stream().filter(r -> r.getCkbm().equals("3.03.013")).findFirst();
.filter(r -> r.getCkbm().equals("3.03.013"))
.findFirst();
List<WarehouseInfo> sortedList = new ArrayList<>(); List<WarehouseInfo> sortedList = new ArrayList<>();
first.ifPresent(sortedList::add); first.ifPresent(sortedList::add);
second.stream() second.stream().filter(r -> !r.equals(first.orElse(null))).forEach(sortedList::add);
.filter(r -> !r.equals(first.orElse(null))) warehouseInfoList.stream().filter(r -> !second.contains(r)).forEach(sortedList::add);
.forEach(sortedList::add);
warehouseInfoList.stream()
.filter(r -> !second.contains(r))
.forEach(sortedList::add);
return sortedList; return sortedList;
} }
@ -217,31 +209,36 @@ public class EasOutInBillServiceImpl extends ServiceImpl<EasOutInBillMapper, Eas
@Override @Override
@SaIgnore @SaIgnore
public CommonPage<EasOutInBill> page(EasOutInBillQuery params) { public CommonPage<EasOutInBill> page(EasOutInBillQuery params) {
Page<EasOutInBill> easOutInBills = easOutInBillMapper.selectPage(new Page<>(params.getPage(), params.getSize()), new QueryWrapper<EasOutInBill>() Page<EasOutInBill> pageObject = new Page<>(params.getPage(), params.getSize());
.lambda() Page<EasOutInBill> receiptBills = easOutInBillMapper.selectPageList(pageObject, params.getFuzzy(),params.getDjlx(),params.getCgybm(), params.getCkbm());
.eq(ObjectUtil.isNotEmpty(params.getDjlx()), EasOutInBill::getDjlx, params.getDjlx()) // Page<EasOutInBill> easOutInBills = easOutInBillMapper.selectPage(new Page<>(params.getPage(), params.getSize()), new QueryWrapper<EasOutInBill>()
.eq(ObjectUtil.isNotEmpty(params.getCkbm()), EasOutInBill::getCkbm, params.getCkbm()) // .lambda()
.eq(ObjectUtil.isNotEmpty(params.getCgybm()), EasOutInBill::getCgybm, params.getCgybm()) // .eq(ObjectUtil.isNotEmpty(params.getDjlx()), EasOutInBill::getDjlx, params.getDjlx())
//.eq(ObjectUtil.isNotEmpty(params.getDjzt()), EasOutInBill::getDjzt, "1".equals(params.getDjzt()) ? "提交" : "审核") // .eq(ObjectUtil.isNotEmpty(params.getWlbm()), EasOutInBill::getWlbm, params.getCkbm())
.eq(EasOutInBill::getDjzt, "提交") // .eq(ObjectUtil.isNotEmpty(params.getCkbm()), EasOutInBill::getCkbm, params.getCkbm())
.nested(ObjectUtil.isNotEmpty(params.getFuzzy()), // .eq(ObjectUtil.isNotEmpty(params.getCgybm()), EasOutInBill::getCgybm, params.getCgybm())
i -> i.like(EasOutInBill::getDjid, params.getFuzzy()) // //.eq(ObjectUtil.isNotEmpty(params.getDjzt()), EasOutInBill::getDjzt, "1".equals(params.getDjzt()) ? "提交" : "审核")
.or() // .eq(EasOutInBill::getDjzt, "提交")
.like(EasOutInBill::getDjbh, params.getFuzzy()) // .nested(ObjectUtil.isNotEmpty(params.getFuzzy()),
.or() // i -> i.like(EasOutInBill::getDjid, params.getFuzzy())
.like(EasOutInBill::getZzbm, params.getFuzzy()) // .or()
.or() // .like(EasOutInBill::getDjbh, params.getFuzzy())
.like(EasOutInBill::getZzmc, params.getFuzzy()) // .or()
.or() // .like(EasOutInBill::getZzbm, params.getFuzzy())
.like(EasOutInBill::getCkmc, params.getFuzzy()) // .or()
.or() // .like(EasOutInBill::getZzmc, params.getFuzzy())
.like(EasOutInBill::getCkbm, params.getFuzzy()) // .or()
.or() // .like(EasOutInBill::getCkmc, params.getFuzzy())
.like(EasOutInBill::getCjr, params.getFuzzy() // .or()
) // .like(EasOutInBill::getWlbm, params.getFuzzy())
).orderByDesc(EasOutInBill::getCjsj) // .or()
); // .like(EasOutInBill::getCkbm, params.getFuzzy())
return CommonPage.getPage(easOutInBills); // .or()
// .like(EasOutInBill::getCjr, params.getFuzzy()
// )
// ).orderByDesc(EasOutInBill::getCjsj)
// );
return CommonPage.getPage(receiptBills);
} }
@ -252,12 +249,7 @@ public class EasOutInBillServiceImpl extends ServiceImpl<EasOutInBillMapper, Eas
*/ */
@Override @Override
public List<EasOutInBill> query(EasOutInBillQuery params) { public List<EasOutInBill> query(EasOutInBillQuery params) {
return easOutInBillMapper.selectList(new QueryWrapper<EasOutInBill>() return easOutInBillMapper.selectList(new QueryWrapper<EasOutInBill>().lambda().eq(ObjectUtil.isNotEmpty(params), EasOutInBill::getYwlx, params.getFuzzy()).or().eq(ObjectUtil.isNotEmpty(params), EasOutInBill::getDjid, params.getFuzzy()));
.lambda()
.eq(ObjectUtil.isNotEmpty(params), EasOutInBill::getYwlx, params.getFuzzy())
.or()
.eq(ObjectUtil.isNotEmpty(params), EasOutInBill::getDjid, params.getFuzzy())
);
} }
/** /**
@ -324,31 +316,28 @@ public class EasOutInBillServiceImpl extends ServiceImpl<EasOutInBillMapper, Eas
public void insertInOutBills(List<EasOutInBillDetail> easOutInBillDetails, List<EasOutInBillDetail> existingIds) { public void insertInOutBills(List<EasOutInBillDetail> easOutInBillDetails, List<EasOutInBillDetail> existingIds) {
Set<String> ids = existingIds.stream().map(EasOutInBillDetail::getFlid).collect(Collectors.toSet()); Set<String> ids = existingIds.stream().map(EasOutInBillDetail::getFlid).collect(Collectors.toSet());
// 过滤出需要插入的新单据,并根据来源设置 ID // 过滤出需要插入的新单据,并根据来源设置 ID
List<EasOutInBillDetail> insertEasBills = easOutInBillDetails.stream() List<EasOutInBillDetail> insertEasBills = easOutInBillDetails.stream().filter(bill -> !ids.contains(bill.getFlid())).peek(bill -> {
.filter(bill -> !ids.contains(bill.getFlid())) bill.setId(IdUtil.getStringId());
.peek(bill -> { bill.setCode(IdUtil.getStringId());
bill.setId(IdUtil.getStringId()); bill.setTjkwbm(bill.getKwbm());
bill.setCode(IdUtil.getStringId()); bill.setCzsl(BigDecimal.ZERO);
bill.setTjkwbm(bill.getKwbm()); bill.setCzsl(BigDecimal.ZERO);
bill.setCzsl(BigDecimal.ZERO); bill.setKcsl(BigDecimal.ZERO);
bill.setCzsl(BigDecimal.ZERO); // if (bill.getSl().compareTo(BigDecimal.ZERO) < 0) {
bill.setKcsl(BigDecimal.ZERO); // bill.setSl(bill.getSl().abs());
// if (bill.getSl().compareTo(BigDecimal.ZERO) < 0) { // }
// bill.setSl(bill.getSl().abs()); bill.setSysl(bill.getSl());
// } if (bill.getDjly() == null) {
bill.setSysl(bill.getSl()); bill.setCjsj(LocalDateTime.parse(bill.getCjsj(), DateTimeFormatter.ofPattern("yyyy/MM/dd HH:mm:ss")).toLocalDate().toString());
if (bill.getDjly() == null) { bill.setDjly("1");
bill.setCjsj(LocalDateTime.parse(bill.getCjsj(), DateTimeFormatter.ofPattern("yyyy/MM/dd HH:mm:ss")).toLocalDate().toString()); } else {
bill.setDjly("1"); //srm的未入库改为提交
} else { bill.setDjzt("提交");
//srm的未入库改为提交 bill.setYwrq(LocalDateTime.parse(bill.getYwrq(), DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")).toLocalDate().toString());
bill.setDjzt("提交"); bill.setCjsj(LocalDateTime.parse(bill.getCjsj(), DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")).toLocalDate().toString());
bill.setYwrq(LocalDateTime.parse(bill.getYwrq(), DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")).toLocalDate().toString()); bill.setDjly("2");
bill.setCjsj(LocalDateTime.parse(bill.getCjsj(), DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")).toLocalDate().toString()); }
bill.setDjly("2"); }).collect(Collectors.toList());
}
})
.collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(insertEasBills)) { if (CollectionUtils.isNotEmpty(insertEasBills)) {
this.insertBills(insertEasBills); this.insertBills(insertEasBills);
} }
@ -356,37 +345,33 @@ public class EasOutInBillServiceImpl extends ServiceImpl<EasOutInBillMapper, Eas
private void insertBills(List<EasOutInBillDetail> detailList) { private void insertBills(List<EasOutInBillDetail> detailList) {
List<EasOutInBillDetail> distinctDetailList = new ArrayList<>(detailList.stream() List<EasOutInBillDetail> distinctDetailList = new ArrayList<>(detailList.stream().collect(Collectors.toMap(EasOutInBillDetail::getDjid, Function.identity(), (existing, replacement) -> existing)).values());
.collect(Collectors.toMap(EasOutInBillDetail::getDjid, Function.identity(), (existing, replacement) -> existing)) List<EasOutInBill> billList = distinctDetailList.stream().map(detail -> {
.values()); EasOutInBill bill = new EasOutInBill();
List<EasOutInBill> billList = distinctDetailList.stream() bill.setId(IdUtil.getStringId());
.map(detail -> { bill.setBmbm(detail.getBmbm());
EasOutInBill bill = new EasOutInBill(); bill.setBmmc(detail.getBmmc());
bill.setId(IdUtil.getStringId()); bill.setDjid(detail.getDjid());
bill.setBmbm(detail.getBmbm()); bill.setDjid(detail.getDjid());
bill.setBmmc(detail.getBmmc()); bill.setDjbh(detail.getDjbh());
bill.setDjid(detail.getDjid()); bill.setDjlx(detail.getDjlx());
bill.setDjid(detail.getDjid()); bill.setYwlx(detail.getYwlx());
bill.setDjbh(detail.getDjbh()); bill.setZzbm(detail.getZzbm());
bill.setDjlx(detail.getDjlx()); bill.setZzmc(detail.getZzmc());
bill.setYwlx(detail.getYwlx()); bill.setCkmc(detail.getCkmc());
bill.setZzbm(detail.getZzbm()); bill.setCkbm(detail.getCkbm());
bill.setZzmc(detail.getZzmc()); bill.setDjzt(detail.getDjzt());
bill.setCkmc(detail.getCkmc()); bill.setCjsj(detail.getCjsj());
bill.setCkbm(detail.getCkbm()); bill.setYwrq(detail.getYwrq());
bill.setDjzt(detail.getDjzt()); bill.setCjr(detail.getCjr());
bill.setCjsj(detail.getCjsj()); bill.setBtbz(detail.getBtbz());
bill.setYwrq(detail.getYwrq()); bill.setCksj(detail.getCksj());
bill.setCjr(detail.getCjr()); bill.setLlr(detail.getLlr());
bill.setBtbz(detail.getBtbz()); bill.setDjly(detail.getDjly());
bill.setCksj(detail.getCksj()); bill.setCgybm(detail.getCgybm());
bill.setLlr(detail.getLlr()); bill.setCgymc(detail.getCgymc());
bill.setDjly(detail.getDjly()); return bill;
bill.setCgybm(detail.getCgybm()); }).collect(Collectors.toList());
bill.setCgymc(detail.getCgymc());
return bill;
})
.collect(Collectors.toList());
CompletableFuture.runAsync(() -> { CompletableFuture.runAsync(() -> {
//主表 //主表
for (EasOutInBill entity : billList) { for (EasOutInBill entity : billList) {
@ -411,28 +396,23 @@ public class EasOutInBillServiceImpl extends ServiceImpl<EasOutInBillMapper, Eas
private void updateBills(List<EasOutInBillDetail> easOutInBillDetails, List<EasOutInBillDetail> existingIds) { private void updateBills(List<EasOutInBillDetail> easOutInBillDetails, List<EasOutInBillDetail> existingIds) {
// 过滤出需要插入的新单据,并根据来源设置 ID // 过滤出需要插入的新单据,并根据来源设置 ID
List<EasOutInBillDetail> updateEasBills = easOutInBillDetails.stream() List<EasOutInBillDetail> updateEasBills = easOutInBillDetails.stream().filter(r -> r.getXgsj() != null).collect(Collectors.toList());
.filter(r -> r.getXgsj() != null)
.collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(updateEasBills)) { if (CollectionUtils.isNotEmpty(updateEasBills)) {
//比较insertEasBills与existingIds的修改时间进行按需更新 //比较insertEasBills与existingIds的修改时间进行按需更新
for (EasOutInBillDetail entity : updateEasBills) { for (EasOutInBillDetail entity : updateEasBills) {
EasOutInBillDetail existing = existingIds.stream() EasOutInBillDetail existing = existingIds.stream().filter(e -> {
.filter(e -> { boolean isUpdate = false;
boolean isUpdate = false; try {
try { if (e.getFlid().equals(entity.getFlid())) {
if (e.getFlid().equals(entity.getFlid())) { if (e.getXgsj() == null || org.nl.common.utils.DateUtil.getDate(entity.getXgsj()).after(org.nl.common.utils.DateUtil.getDate(e.getXgsj()))) {
if (e.getXgsj() == null || org.nl.common.utils.DateUtil.getDate(entity.getXgsj()).after(org.nl.common.utils.DateUtil.getDate(e.getXgsj()))) { isUpdate = true;
isUpdate = true;
}
}
} catch (ParseException ex) {
throw new RuntimeException(ex);
} }
return isUpdate; }
}) } catch (ParseException ex) {
.findFirst() throw new RuntimeException(ex);
.orElse(null); }
return isUpdate;
}).findFirst().orElse(null);
if (existing != null) { if (existing != null) {
EasOutInBillDetail updateEntity = new EasOutInBillDetail(); EasOutInBillDetail updateEntity = new EasOutInBillDetail();
updateEntity.setDjid(entity.getDjid()); updateEntity.setDjid(entity.getDjid());
@ -483,29 +463,20 @@ public class EasOutInBillServiceImpl extends ServiceImpl<EasOutInBillMapper, Eas
try { try {
// 获取距离今天30天前的日期 // 获取距离今天30天前的日期
LocalDate eightDaysAgo = LocalDate.now().minusDays(30); LocalDate eightDaysAgo = LocalDate.now().minusDays(30);
existingIds = existingIds.stream() existingIds = existingIds.stream().filter(e -> "提交".equals(e.getDjzt()) || "未入库".equals(e.getDjzt())).filter(e -> {
.filter(e -> "提交".equals(e.getDjzt()) || "未入库".equals(e.getDjzt())) try {
.filter(e -> { return org.nl.common.utils.DateUtil.getDateFormat(e.getCjsj()).toInstant().atZone(ZoneId.systemDefault()).toLocalDate().isAfter(eightDaysAgo);
try { } catch (ParseException ex) {
return org.nl.common.utils.DateUtil.getDateFormat(e.getCjsj()).toInstant().atZone(ZoneId.systemDefault()).toLocalDate().isAfter(eightDaysAgo); throw new RuntimeException(ex);
} catch (ParseException ex) { }
throw new RuntimeException(ex); }).collect(Collectors.toList());
}
})
.collect(Collectors.toList());
// 获取easOutInBillDetails中flid字段的集合 // 获取easOutInBillDetails中flid字段的集合
Set<String> easFlidSet = easOutInBillDetails.stream() Set<String> easFlidSet = easOutInBillDetails.stream().map(EasOutInBillDetail::getFlid).collect(Collectors.toSet());
.map(EasOutInBillDetail::getFlid)
.collect(Collectors.toSet());
// 找出existingIds中flid字段集合不在easOutInBillDetails中flid字段集合中的记录 // 找出existingIds中flid字段集合不在easOutInBillDetails中flid字段集合中的记录
List<EasOutInBillDetail> idsToDelete = existingIds.stream() List<EasOutInBillDetail> idsToDelete = existingIds.stream().filter(e -> !easFlidSet.contains(e.getFlid())).collect(Collectors.toList());
.filter(e -> !easFlidSet.contains(e.getFlid()))
.collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(idsToDelete)) { if (CollectionUtils.isNotEmpty(idsToDelete)) {
Map<String, Long> idCount1 = idsToDelete.stream() Map<String, Long> idCount1 = idsToDelete.stream().collect(Collectors.groupingBy(EasOutInBillDetail::getDjid, Collectors.counting()));
.collect(Collectors.groupingBy(EasOutInBillDetail::getDjid, Collectors.counting())); Map<String, Long> idCount2 = existingIds.stream().collect(Collectors.groupingBy(EasOutInBillDetail::getDjid, Collectors.counting()));
Map<String, Long> idCount2 = existingIds.stream()
.collect(Collectors.groupingBy(EasOutInBillDetail::getDjid, Collectors.counting()));
Set<String> billIds = new HashSet<>(); Set<String> billIds = new HashSet<>();
idCount1.forEach((k, v) -> { idCount1.forEach((k, v) -> {
//遍历idCount1中的djid,与idCount2的比较,如果相等,判断value的个等于idCount2,则记录key到一个新的set集合中 //遍历idCount1中的djid,与idCount2的比较,如果相等,判断value的个等于idCount2,则记录key到一个新的set集合中
@ -528,17 +499,9 @@ public class EasOutInBillServiceImpl extends ServiceImpl<EasOutInBillMapper, Eas
//查询主单据进行对比 //查询主单据进行对比
Set<String> bills = queryBills(); Set<String> bills = queryBills();
Set<String> easBills = easOutInBillDetails.stream().map(EasOutInBillDetail::getDjid).collect(Collectors.toSet()); Set<String> easBills = easOutInBillDetails.stream().map(EasOutInBillDetail::getDjid).collect(Collectors.toSet());
Set<String> notInExits = bills.stream() Set<String> notInExits = bills.stream().filter(r -> !easBills.contains(r)).collect(Collectors.toSet());
.filter(r -> !easBills.contains(r))
.collect(Collectors.toSet());
if (CollectionUtils.isNotEmpty(notInExits)) { if (CollectionUtils.isNotEmpty(notInExits)) {
UpdateWrapper<EasOutInBill> updateWrapper = new UpdateWrapper<EasOutInBill>() 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")).set("djzt", "审核").set("btbz", "扫描EAS,此单据在EAS已查询不到,或为已审核状态。").in("djid", notInExits);
.set("update_id", SecurityUtils.getCurrentUserId())
.set("update_name", SecurityUtils.getCurrentNickName())
.set("update_time", DateUtil.format(DateUtil.beginOfDay(DateUtil.date()), "yyyy-MM-dd"))
.set("djzt", "审核")
.set("btbz", "扫描EAS,此单据在EAS已查询不到,或为已审核状态。")
.in("djid", notInExits);
easOutInBillMapper.update(null, updateWrapper); easOutInBillMapper.update(null, updateWrapper);
} }
@ -592,11 +555,10 @@ public class EasOutInBillServiceImpl extends ServiceImpl<EasOutInBillMapper, Eas
easOutInBillDto.setBizDate(easBillDetailList.get(0).getBizDate()); easOutInBillDto.setBizDate(easBillDetailList.get(0).getBizDate());
List<EasOutInBillDetailDto> entrys = new ArrayList<>(); List<EasOutInBillDetailDto> entrys = new ArrayList<>();
easBillDetailList.forEach(r -> { easBillDetailList.forEach(r -> {
EasOutInBillDetailDto dto = new EasOutInBillDetailDto(); EasOutInBillDetailDto dto = new EasOutInBillDetailDto();
BeanUtils.copyProperties(r, dto); BeanUtils.copyProperties(r, dto);
entrys.add(dto); entrys.add(dto);
} });
);
easOutInBillDto.setEntrys(entrys); easOutInBillDto.setEntrys(entrys);
if ("1".equals(easOutInBillDto.getDjly())) { if ("1".equals(easOutInBillDto.getDjly())) {
easBills.add(easOutInBillDto); easBills.add(easOutInBillDto);
@ -615,8 +577,7 @@ public class EasOutInBillServiceImpl extends ServiceImpl<EasOutInBillMapper, Eas
//报文组合 //报文组合
if (CollectionUtils.isNotEmpty(easOutInBillList)) { if (CollectionUtils.isNotEmpty(easOutInBillList)) {
easOutInBillList.forEach(b -> { easOutInBillList.forEach(b -> {
List<EasOutInBillDetailDto> billDetails = easOutInBillDetailList.stream().filter(d -> List<EasOutInBillDetailDto> billDetails = easOutInBillDetailList.stream().filter(d -> Objects.equals(d.getDjid(), b.getBillId())).collect(Collectors.toList());
Objects.equals(d.getDjid(), b.getBillId())).collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(billDetails)) { if (CollectionUtils.isNotEmpty(billDetails)) {
if (b.getYwlx().contains(EasBillTypeEnum.OUT.getCode())) { if (b.getYwlx().contains(EasBillTypeEnum.OUT.getCode())) {
//只提交大于数量大于0的物料明细 //只提交大于数量大于0的物料明细
@ -729,11 +690,7 @@ public class EasOutInBillServiceImpl extends ServiceImpl<EasOutInBillMapper, Eas
private void updateBills(EasOutInBillDto bill, String msg) { private void updateBills(EasOutInBillDto bill, String msg) {
UpdateWrapper<EasOutInBill> updateWrapper = new UpdateWrapper<EasOutInBill>() 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());
.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.isNoneBlank(msg)) { if (StringUtils.isNoneBlank(msg)) {
updateWrapper.set("shjg", msg); updateWrapper.set("shjg", msg);
} else { } else {

Loading…
Cancel
Save