Browse Source

opt: 优化库存查询

test-20240527
龚宝雄 7 months ago
parent
commit
ed33d706ea
  1. 1
      nlsso-server/src/main/java/org/nl/wms/database/eas/controller/EasOutInBillController.java
  2. 4
      nlsso-server/src/main/java/org/nl/wms/database/eas/dao/xml/EasOutInBillDetailMapper.xml
  3. 70
      nlsso-server/src/main/java/org/nl/wms/database/eas/service/impl/EasOutInBillDetailServiceImpl.java
  4. 13
      nlsso-server/src/main/java/org/nl/wms/database/eas/service/impl/EasOutInBillServiceImpl.java
  5. 13
      nlsso-server/src/main/java/org/nl/wms/schedule/EasBillSchedule.java
  6. 2
      nlsso-server/src/main/resources/config/application-dev.yml
  7. 18
      nlsso-server/src/main/resources/config/application-devLocal.yml
  8. 4
      nlsso-server/src/main/resources/config/application.yml
  9. 2
      nlsso-server/src/test/java/org/nl/test/EventTest.java

1
nlsso-server/src/main/java/org/nl/wms/database/eas/controller/EasOutInBillController.java

@ -50,6 +50,7 @@ public class EasOutInBillController {
*/
@PostMapping("/audit")
@Log("审核")
@SaIgnore
//@SaCheckPermission("@el.check(EasOutInBill:edit')")
public CommonResult audit(@RequestBody Set<String> ids) {
if (ids == null || ids.isEmpty()) {

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

@ -7,13 +7,13 @@
FROM
EAS_NOBLE.V_UC_OUTINBILL
WHERE DJZT = '提交'
AND TO_DATE(cjsj, 'YYYY-MM-DD') >= TRUNC(SYSDATE) - INTERVAL '90' DAY(3)
AND TO_DATE(cjsj, 'YYYY-MM-DD') >= TRUNC(SYSDATE) - INTERVAL '91' 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 90 DAY)
WHERE DJZT='未入库' AND CJSJ >= DATE_SUB(CURDATE(), INTERVAL 91 DAY)
</select>
<select id="selectByConditions" resultType="org.nl.wms.database.eas.dao.InventoryInfo">
SELECT

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

@ -53,35 +53,35 @@ public class EasOutInBillDetailServiceImpl extends ServiceImpl<EasOutInBillDetai
.eq(ObjectUtil.isNotEmpty(params), EasOutInBillDetail::getDjid, params.getDjid())
);
List<EasOutInBillDetail> easOutInBillDetailList = result.getRecords();
// List<InventoryInfo> inventoryInfoList = queryInventoryInfoList(easOutInBillDetailList);
// easOutInBillDetailList.forEach(bill -> {
// //查询库存信息
// List<InventoryInfo> matchedInventory = inventoryInfoList.stream()
// .filter(inventory -> {
// boolean isMatched = true;
// if (bill.getZzbm() != null && !bill.getZzbm().isEmpty()) {
// isMatched &= Objects.equals(inventory.getZzbm(), bill.getZzbm());
// }
// if (bill.getCkbm() != null && !bill.getCkbm().isEmpty()) {
// isMatched &= Objects.equals(inventory.getCkbm(), bill.getCkbm());
// }
// if (bill.getWlbm() != null && !bill.getWlbm().isEmpty()) {
// isMatched &= Objects.equals(inventory.getWlbm(), bill.getWlbm());
// }
// // 批次
// if (bill.getPc() != null && !bill.getPc().isEmpty()) {
// isMatched &= Objects.equals(inventory.getPc(), bill.getPc());
// }
// // 跟踪号
// if (bill.getTrackno() != null && !bill.getTrackno().isEmpty()) {
// isMatched &= Objects.equals(inventory.getTrackno(), bill.getTrackno());
// }
// if (bill.getKwbm() != null && !bill.getKwbm().isEmpty()) {
// isMatched &= Objects.equals(inventory.getKwbm(), bill.getKwbm());
// }
// return isMatched;
// })
// .collect(Collectors.toList());
List<InventoryInfo> inventoryInfoList = queryInventoryInfoList(easOutInBillDetailList);
easOutInBillDetailList.forEach(bill -> {
//查询库存信息
List<InventoryInfo> matchedInventory = inventoryInfoList.stream()
.filter(inventory -> {
boolean isMatched = true;
if (bill.getZzbm() != null && !bill.getZzbm().isEmpty()) {
isMatched &= Objects.equals(inventory.getZzbm(), bill.getZzbm());
}
if (bill.getCkbm() != null && !bill.getCkbm().isEmpty()) {
isMatched &= Objects.equals(inventory.getCkbm(), bill.getCkbm());
}
if (bill.getWlbm() != null && !bill.getWlbm().isEmpty()) {
isMatched &= Objects.equals(inventory.getWlbm(), bill.getWlbm());
}
// 批次
if (bill.getPc() != null && !bill.getPc().isEmpty()) {
isMatched &= Objects.equals(inventory.getPc(), bill.getPc());
}
// 跟踪号
if (bill.getTrackno() != null && !bill.getTrackno().isEmpty()) {
isMatched &= Objects.equals(inventory.getTrackno(), bill.getTrackno());
}
if (bill.getKwbm() != null && !bill.getKwbm().isEmpty()) {
isMatched &= Objects.equals(inventory.getKwbm(), bill.getKwbm());
}
return isMatched;
})
.collect(Collectors.toList());
// List<InventoryInfo> matchedInventory = inventoryInfoList.stream()
// .filter(inventory -> Objects.equals(inventory.getZzbm(), bill.getZzbm())
// && Objects.equals(inventory.getCkbm(), bill.getCkbm())
@ -91,12 +91,12 @@ public class EasOutInBillDetailServiceImpl extends ServiceImpl<EasOutInBillDetai
// && Objects.equals(inventory.getKwbm(), bill.getKwbm()))
// .collect(Collectors.toList());
//将库存数量赋值给单据
// Optional<InventoryInfo> minKcsl = matchedInventory.stream()
// .min(Comparator.comparing(InventoryInfo::getKcsl));
// minKcsl.ifPresent(m -> {
// bill.setKcsl(m.getKcsl());
// });
// });
Optional<InventoryInfo> minKcsl = matchedInventory.stream()
.min(Comparator.comparing(InventoryInfo::getKcsl));
minKcsl.ifPresent(m -> {
bill.setKcsl(m.getKcsl());
});
});
result.setRecords(easOutInBillDetailList);
return CommonPage.getPage(result);
}

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

@ -248,9 +248,12 @@ public class EasOutInBillServiceImpl extends ServiceImpl<EasOutInBillMapper, Eas
List<EasOutInBillDto> easOutInBillList = easOutInBillMapper.queryBillList(ids);
//所有明细表
List<EasOutInBillDetailDto> easOutInBillDetailList = easOutInBillDetailMapper.queryBillDetailList(ids);
long count= easOutInBillDetailList.stream().filter(r->r.getQty().compareTo(BigDecimal.ZERO)==0).count();
if(count==easOutInBillDetailList.size()){
throw new BadRequestException("该单据无任何出入库操作,请检查");
}
//报文组合
if (CollectionUtils.isNotEmpty(easOutInBillList)) {
easOutInBillList.forEach(b -> {
List<EasOutInBillDetailDto> billDetails = easOutInBillDetailList.stream().filter(d ->
Objects.equals(d.getDjid(), b.getBillId())).collect(Collectors.toList());
@ -284,8 +287,8 @@ public class EasOutInBillServiceImpl extends ServiceImpl<EasOutInBillMapper, Eas
try {
EasData easData = new EasData();
easData.setData(bill);
// String billJson = com.alibaba.fastjson.JSON.toJSONString(easData, SerializerFeature.WriteMapNullValue);
// wmsToEasService.sendWebService(billJson);
String billJson = com.alibaba.fastjson.JSON.toJSONString(easData, SerializerFeature.WriteMapNullValue);
wmsToEasService.sendWebService(billJson);
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()));
} catch (Exception e) {
log.error("推送Eas单据失败,单据号为:[" + bill.getBillId() + "]异常原因:" + e.toString());
@ -302,8 +305,8 @@ public class EasOutInBillServiceImpl extends ServiceImpl<EasOutInBillMapper, Eas
public void syncSrmAuditBills(List<EasOutInBillDto> bills) {
for (EasOutInBillDto bill : bills) {
try {
// String billJson = com.alibaba.fastjson.JSON.toJSONString(bill, SerializerFeature.WriteMapNullValue);
// wmsToSrmService.sendWebPostData(billJson);
String billJson = com.alibaba.fastjson.JSON.toJSONString(bill, SerializerFeature.WriteMapNullValue);
wmsToSrmService.sendWebPostData(billJson);
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()));
} catch (Exception e) {
log.error("推送Eas单据失败,单据号为:[" + bill.getBillId() + "]异常原因:" + e.toString());

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

@ -53,7 +53,7 @@ public class EasBillSchedule {
* eas单据数据同步
*/
@Async("taskExecutor")
//@Scheduled(cron = "0/30 * * * * *")
@Scheduled(cron = "0/30 * * * * *")
public void getEasOutInBills() {
// 获取eas视图查询未提交的单据
List<EasOutInBillDetail> easOutInBillDetails = easOutInBillDetailMapper.selectPageWithInventory();
@ -129,10 +129,13 @@ public class EasBillSchedule {
LambdaQueryWrapper<EasOutInBill> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.lt(EasOutInBill::getCjsj, days);
List<EasOutInBill> oldBills = easOutInBillService.list(queryWrapper);
Set<String> ids = oldBills.stream().map(EasOutInBill::getDjid).collect(Collectors.toSet());
easOutInBillDetailMapper.deleteInfo(days);
if (CollectionUtils.isNotEmpty(ids)) {
easOutInBillDetailMapper.deleteDetail(ids);
if(CollectionUtils.isNotEmpty(oldBills))
{
Set<String> ids = oldBills.stream().map(EasOutInBill::getDjid).collect(Collectors.toSet());
if (CollectionUtils.isNotEmpty(ids)) {
easOutInBillDetailMapper.deleteDetail(ids);
}
easOutInBillDetailMapper.deleteInfo(days);
}
}

2
nlsso-server/src/main/resources/config/application-dev.yml

@ -1,5 +1,5 @@
server:
port: 8012
port: 8011
#配置数据源
spring:
autoconfigure:

18
nlsso-server/src/main/resources/config/application-devLocal.yml

@ -1,5 +1,5 @@
server:
port: 8012
port: 8011
#配置数据源
spring:
autoconfigure:
@ -20,18 +20,22 @@ spring:
username: ${DB_USER:wms_third}
password: ${DB_PWD:NOBLElift@!#wms}
type: com.alibaba.druid.pool.DruidDataSource
# driver-class-name: net.sf.log4jdbc.sql.jdbcapi.DriverSpy
# url: jdbc:log4jdbc:mysql://${DB_HOST:10.10.188.30}:${DB_PORT:3306}/${DB_NAME:nuoli_v1.0}?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false&useOldAliasMetadataBehavior=true
# username: ${DB_USER:wms_third}
# password: ${DB_PWD:NOBLElift@!#wms}
# type: com.alibaba.druid.pool.DruidDataSource
oracle_eas:
driver-class-name: oracle.jdbc.OracleDriver
url: jdbc:oracle:thin:@localhost:1521:orcl
username: ${DB_USER:user1}
password: ${DB_PWD:Noble12319}
type: com.alibaba.druid.pool.DruidDataSource
sqlserver:
driver-class-name: com.microsoft.sqlserver.jdbc.SQLServerDriver
url: jdbc:sqlserver://10.93.41.2\WINCC;DatabaseName=马钢_RH
username: ${DB_USER:sa}
password: ${DB_PWD:123}
type: com.alibaba.druid.pool.DruidDataSource
# driver-class-name: oracle.jdbc.OracleDriver
# url: jdbc:oracle:thin:@192.168.100.97:1521:orcl
# username: ${DB_USER:stuser}
# password: ${DB_PWD:stuser123}
# type: com.alibaba.druid.pool.DruidDataSource
redis:
#数据库索引
host: ${REDIS_HOST:127.0.0.1}

4
nlsso-server/src/main/resources/config/application.yml

@ -4,7 +4,7 @@ server:
relaxed-path-chars: [ '|','{','}','[',']' ] #字符问题: https://blog.csdn.net/weixin_41996632/article/details/90715118
spring:
profiles:
active: dev
active: devLocal
datasource:
druid:
initial-size: 5 #初始化时建立物理连接的个数
@ -205,7 +205,7 @@ jetcache:
easConfig:
host: http://192.168.100.100:8080//ormrpc/services/
user: user
password: Noble123!9
password: NOBLE123!9
datacenter: test
wsdlService: WSNLMESFacade
operationName: dealTask

2
nlsso-server/src/test/java/org/nl/test/EventTest.java

@ -64,7 +64,7 @@ public class EventTest {
public void webServiceTest() {
String http="http://188.188.5.18:6888/ormrpc/services/";
String user = "user"; //用户
String password = "noble123666"; //密码
String password = "NOBLE123666"; //密码
String datacenter = "cs"; //数据中心
String wsdlservice = "WSNLMESFacade"; //服务
String operationName = "dealTask"; //方法

Loading…
Cancel
Save