Browse Source

opt: 优化定时清理源头已删除单据

test-20240527
龚宝雄 7 months ago
parent
commit
e9235a8f3f
  1. 4
      nlsso-server/src/main/java/org/nl/wms/database/eas/dao/mapper/EasOutInBillDetailMapper.java
  2. 5
      nlsso-server/src/main/java/org/nl/wms/database/eas/dao/mapper/EasOutInBillMapper.java
  3. 14
      nlsso-server/src/main/java/org/nl/wms/database/eas/dao/xml/EasOutInBillDetailMapper.xml
  4. 13
      nlsso-server/src/main/java/org/nl/wms/database/eas/dao/xml/EasOutInBillMapper.xml
  5. 9
      nlsso-server/src/main/java/org/nl/wms/database/eas/service/IeasOutInBillService.java
  6. 17
      nlsso-server/src/main/java/org/nl/wms/database/eas/service/impl/EasOutInBillServiceImpl.java
  7. 28
      nlsso-server/src/main/java/org/nl/wms/schedule/EasBillSchedule.java

4
nlsso-server/src/main/java/org/nl/wms/database/eas/dao/mapper/EasOutInBillDetailMapper.java

@ -34,6 +34,10 @@ public interface EasOutInBillDetailMapper extends BaseMapper<EasOutInBillDetail>
@DS("oracle_eas")
List<EasOutInBillDetail> selectPageWithInventory();
@DS("oracle_eas")
Set<String> selectEasIds();
@DS("mysql_srm")
Set<String> selectSrmIds();
@DS("mysql_srm")
List<EasOutInBillDetail> selectSrmPageWithInventory();

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

@ -25,7 +25,10 @@ public interface EasOutInBillMapper extends BaseMapper<EasOutInBill> {
List<EasOutInBillDetail> getSrmBills();
//AND STR_TO_DATE( cjsj, '%Y-%m-%d' ) >= CURDATE() - INTERVAL 1 MONTH;
List<String> queryExistBills();
Set<String> queryExistBills();
Set<String> queryLocalBills();
List<EasOutInBillDto> queryBillList(@Param("ids") Set<String> ids);

14
nlsso-server/src/main/java/org/nl/wms/database/eas/dao/xml/EasOutInBillDetailMapper.xml

@ -9,12 +9,26 @@
WHERE DJZT = '提交'
AND TO_DATE(cjsj, 'YYYY-MM-DD') >= TRUNC(SYSDATE) - INTERVAL '91' DAY(3)
</select>
<select id="selectEasIds" resultType="java.lang.String">
SELECT
FLID
FROM
EAS_NOBLE.V_UC_OUTINBILL
WHERE DJZT = '提交'
AND TO_DATE(cjsj, 'YYYY-MM-DD') >= TRUNC(SYSDATE) - INTERVAL '7' DAY(3)
</select>
<select id="selectSrmPageWithInventory" resultType="org.nl.wms.database.eas.dao.EasOutInBillDetail">
SELECT
*
FROM V_WMS_INBILL_THIRD
WHERE DJZT='未入库' AND CJSJ >= DATE_SUB(CURDATE(), INTERVAL 91 DAY)
</select>
<select id="selectSrmIds" resultType="java.lang.String">
SELECT
FLID
FROM V_WMS_INBILL_THIRD
WHERE DJZT='未入库' AND CJSJ >= DATE_SUB(CURDATE(), INTERVAL 7 DAY)
</select>
<select id="selectByConditions" resultType="org.nl.wms.database.eas.dao.InventoryInfo">
SELECT
stono as zzbm,

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

@ -33,9 +33,18 @@
<select id="queryExistBills" resultType="java.lang.String">
SELECT
djid
DJID
FROM
eas_out_in_bill
EAS_OUT_IN_BILL
</select>
<select id="queryLocalBills" resultType="java.lang.String">
SELECT
FLID
FROM
EAS_OUT_IN_BILL_DETAIL
WHERE
djzt = '提交'
</select>
<select id="getBillsCount" resultType="org.nl.wms.database.eas.dao.HomeBillCounts">

9
nlsso-server/src/main/java/org/nl/wms/database/eas/service/IeasOutInBillService.java

@ -65,12 +65,17 @@ public interface IeasOutInBillService extends IService<EasOutInBill> {
/**
* 查询本地未提交的出入库单据
* 查询本地的出入库单据
* @return List<EasOutInBill>
*/
List<String> queryExistBills();
Set<String> queryExistBills();
/**
* 查询本地未提交的出入库单据
* @return List<EasOutInBill>
*/
Set<String> queryLocalBills();

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

@ -78,11 +78,9 @@ public class EasOutInBillServiceImpl extends ServiceImpl<EasOutInBillMapper, Eas
JSONArray jsonArray = new JSONArray();
JSONObject version= new JSONObject();
// 获取静态文件的路径
String staticFilePath = Objects.requireNonNull(getClass().getClassLoader().getResource("sq.apk")).getPath();
// 构建下载链接
String downloadUrl = "http://localhost/download/" + staticFilePath;
String downloadUrl = "http://10.10.188.45:8011/app.apk";
version.put("url", downloadUrl); // 将下载链接放入JSON对象中
version.put("versionName", "1.0.0");
version.put("versionName", "1.0.1");
jsonArray.add(version);
return jsonArray;
}
@ -141,13 +139,20 @@ public class EasOutInBillServiceImpl extends ServiceImpl<EasOutInBillMapper, Eas
}
/**
* 查询本地未提交的出入库单据
* 查询本地的出入库单据
*/
@Override
public List<String> queryExistBills() {
public Set<String> queryExistBills() {
return easOutInBillMapper.queryExistBills();
}
/**
* 查询本地未提交的出入库单据
*/
@Override
public Set<String> queryLocalBills() {
return easOutInBillMapper.queryLocalBills();
}
/**
* 创建

28
nlsso-server/src/main/java/org/nl/wms/schedule/EasBillSchedule.java

@ -61,7 +61,7 @@ public class EasBillSchedule {
List<EasOutInBillDetail> srmOutInBillDetails = easOutInBillDetailMapper.selectSrmPageWithInventory();
if (CollectionUtils.isNotEmpty(easOutInBillDetails) || CollectionUtils.isNotEmpty(srmOutInBillDetails)) {
// 查询已存在的单据
Set<String> existingIds = new HashSet<>(easOutInBillService.queryExistBills());
Set<String> existingIds = easOutInBillService.queryExistBills();
// 过滤出需要插入的新单据,并根据来源设置 ID
List<EasOutInBillDetail> insertEasBills = easOutInBillDetails.stream()
.filter(bill -> !existingIds.contains(bill.getDjid()))
@ -117,6 +117,32 @@ public class EasBillSchedule {
//System.out.println("1task-首页及头部信息推送-sendHomeInfoTask-花费时间----------------------------------------------------------------****************************************************************= totalTime = " + stopWatch.getTotalTimeMillis());
}
/**
* 定时删除源头已删除单据
*/
@Async("taskExecutor")
@Scheduled(cron = "0/180 * * * * *")
public void autoDeleteBill() {
// 获取eas视图查询未提交的单据
Set<String> easIds = easOutInBillDetailMapper.selectEasIds();
// 获取srm视图查询未提交的单据
Set<String> srmIds = easOutInBillDetailMapper.selectSrmIds();
if (CollectionUtils.isNotEmpty(easIds) || CollectionUtils.isNotEmpty(srmIds)) {
// 查询已存在的单据
Set<String> existingIds = easOutInBillService.queryLocalBills();
easIds.addAll(srmIds);
// 需要删除的ID集合
Set<String> idsToDelete = existingIds.stream()
.filter(r -> !easIds.contains(r))
.collect(Collectors.toSet());
if (CollectionUtils.isNotEmpty(idsToDelete)) {
LambdaQueryWrapper<EasOutInBillDetail> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.in(EasOutInBillDetail::getFlid, idsToDelete);
easOutInBillDetailMapper.delete(queryWrapper);
}
}
}
/**
* 定时清空单据
*/

Loading…
Cancel
Save