Browse Source

opt:数据查询修改

master1
gongbx 6 months ago
parent
commit
ed9642dbf0
  1. 13
      nlsso-server/src/main/java/org/nl/common/base/CommonPage.java
  2. 2
      nlsso-server/src/main/java/org/nl/common/domain/query/BaseQuery.java
  3. 3
      nlsso-server/src/main/java/org/nl/wms/database/eas/controller/AllocationBillController.java
  4. 2
      nlsso-server/src/main/java/org/nl/wms/database/eas/controller/EasOutInBillDetailController.java
  5. 3
      nlsso-server/src/main/java/org/nl/wms/database/eas/controller/ReceiptBillController.java
  6. 14
      nlsso-server/src/main/java/org/nl/wms/database/eas/dao/mapper/AllocationBillMapper.java
  7. 3
      nlsso-server/src/main/java/org/nl/wms/database/eas/dao/mapper/ReceiptBillMapper.java
  8. 100
      nlsso-server/src/main/java/org/nl/wms/database/eas/dao/xml/AllocationBillMapper.xml
  9. 6
      nlsso-server/src/main/java/org/nl/wms/database/eas/dao/xml/ReceiptBillMapper.xml
  10. 2
      nlsso-server/src/main/java/org/nl/wms/database/eas/service/IallocationBillService.java
  11. 2
      nlsso-server/src/main/java/org/nl/wms/database/eas/service/IreceiptBillService.java
  12. 19
      nlsso-server/src/main/java/org/nl/wms/database/eas/service/impl/AllocationBillServiceImpl.java
  13. 8
      nlsso-server/src/main/java/org/nl/wms/database/eas/service/impl/ReceiptBillServiceImpl.java
  14. 2
      nlsso-server/src/main/java/org/nl/wms/schedule/EasBillSchedule.java

13
nlsso-server/src/main/java/org/nl/common/base/CommonPage.java

@ -4,6 +4,7 @@ import cn.hutool.core.convert.Convert;
import cn.hutool.http.HttpStatus;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.Data;
import org.checkerframework.checker.units.qual.C;
import java.util.List;
@ -56,6 +57,18 @@ public class CommonPage<T> {
return result;
}
public static <T> CommonPage<T> getPage(List<T> list,Long total,Integer page,Integer size) {
CommonPage<T> commonPage = new CommonPage<>();
commonPage.setPageNum(page);
commonPage.setPageSize(size);
commonPage.setTotalElements(total);
commonPage.setTotalPage(Convert.toInt(total/ size+1));
commonPage.setResult(list);
commonPage.setCode(1);
commonPage.setDesc("查询成功");
return commonPage;
}
public static <T> CommonPage<T> getPage(Page<T> page) {
List<T> list = page.getRecords();
CommonPage<T> commonPage = new CommonPage<>();

2
nlsso-server/src/main/java/org/nl/common/domain/query/BaseQuery.java

@ -30,7 +30,7 @@ public class BaseQuery<T> {
/**
* 当前页数
*/
private Integer page=0;
private Integer page=1;
/**
* 排序列

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

@ -31,6 +31,7 @@ import org.nl.wms.database.eas.service.IallocationBillService;
@RequiredArgsConstructor
@RequestMapping("/api/allocationBill")
@Slf4j
@SaIgnore
public class AllocationBillController {
@ -57,7 +58,7 @@ public class AllocationBillController {
*/
@PostMapping("/page")
@Log("分页查询")
public ResponseEntity<CommonPage<AllocationBill>> page(@RequestBody AllocationBillQuery params) {
public ResponseEntity<CommonPage<AllocationBillQuery>> page(@RequestBody AllocationBillQuery params) {
return new ResponseEntity<>(allocationBillService.page(params), HttpStatus.OK);
}

2
nlsso-server/src/main/java/org/nl/wms/database/eas/controller/EasOutInBillDetailController.java

@ -3,6 +3,7 @@ package org.nl.wms.database.eas.controller;
import java.util.List;
import java.util.Set;
import cn.dev33.satoken.annotation.SaIgnore;
import org.nl.common.base.CommonPage;
import org.nl.common.base.CommonResult;
import org.nl.common.base.RestBusinessTemplate;
@ -32,6 +33,7 @@ import org.nl.wms.database.eas.service.IeasOutInBillDetailService;
@RequiredArgsConstructor
@RequestMapping("/api/easOutInBillDetail")
@Slf4j
@SaIgnore
public class EasOutInBillDetailController {

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

@ -32,6 +32,7 @@ import org.nl.wms.database.eas.service.IreceiptBillService;
@RequiredArgsConstructor
@RequestMapping("/api/receiptBill")
@Slf4j
@SaIgnore
public class ReceiptBillController {
@ -57,7 +58,7 @@ public class ReceiptBillController {
*/
@PostMapping("/page")
@Log("分页查询")
public ResponseEntity<CommonPage<ReceiptBill>> page(@RequestBody ReceiptBillVO params) {
public ResponseEntity<CommonPage<ReceiptBillQuery>> page(@RequestBody ReceiptBillVO params) {
return new ResponseEntity<>(receiptBillService.page(params), HttpStatus.OK);
}

14
nlsso-server/src/main/java/org/nl/wms/database/eas/dao/mapper/AllocationBillMapper.java

@ -6,6 +6,9 @@ import io.lettuce.core.dynamic.annotation.Param;
import org.apache.ibatis.annotations.Select;
import org.nl.wms.database.eas.dao.AllocationBill;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.nl.wms.database.eas.dto.AllocationBillQuery;
import java.util.List;
/**
* {@code @Description:} (AllocationBill)数据持久层
@ -15,18 +18,19 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
*/
public interface AllocationBillMapper extends BaseMapper<AllocationBill> {
@Select("SELECT COUNT(*) FROM receiptBill")
@DS("oracle_eas")
Long getAllocationCount();
Long getAllocationCount(@Param("fuzzy") String fuzzy);
@DS("oracle_eas")
Page<AllocationBill> allocationPage(Page<AllocationBill> page, @Param("fuzzy") String fuzzy);
List<AllocationBill> allocationPage(@Param("fuzzy") String fuzzy, @Param("page") Integer page, @Param("size") Integer size );
@Select("SELECT COUNT(*) FROM EAS_NOBLE.receiptBill WHERE DJBH = #{djbh}")
@Select("SELECT COUNT(*) FROM EAS_NOBLE.V_UC_STOCKTRANSFERBILL WHERE DJBH = #{djbh}")
@DS("oracle_eas")
Long getTotalCount(@Param("djbh") String djbh);
Page<AllocationBill> allocationDetailPage(Page<AllocationBill> page, @Param("djbh") String djbh, @Param("fuzzy") String fuzzy);
@DS("oracle_eas")
List<AllocationBillQuery> allocationDetailPage(@Param("page") Integer page, @Param("size") Integer size, @Param("djbh") String djbh, @Param("fuzzy") String fuzzy);
}

3
nlsso-server/src/main/java/org/nl/wms/database/eas/dao/mapper/ReceiptBillMapper.java

@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.lettuce.core.dynamic.annotation.Param;
import org.nl.wms.database.eas.dao.ReceiptBill;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.nl.wms.database.eas.dto.ReceiptBillQuery;
/**
* {@code @Description:} (ReceiptBill)数据持久层
@ -17,5 +18,5 @@ public interface ReceiptBillMapper extends BaseMapper<ReceiptBill> {
Page<ReceiptBill> receiptPage(Page<ReceiptBill> page, @Param("fuzzy") String fuzzy);
@DS("mysql_srm")
Page<ReceiptBill> receiptDetailPage(Page<ReceiptBill> page, @Param("djbh") String djbh, @Param("fuzzy") String fuzzy);
Page<ReceiptBillQuery> receiptDetailPage(Page<ReceiptBillQuery> page, @Param("djbh") String djbh, @Param("fuzzy") String fuzzy);
}

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

@ -1,71 +1,53 @@
<?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">
<mapper namespace="org.nl.wms.database.eas.dao.mapper.AllocationBillMapper">
<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 jhdrrq DESC) AS rn
FROM
EAS_NOBLE.V_UC_STOCKTRANSFERBILL t
),
grouped_data AS (
SELECT *
<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
EAS_NOBLE.V_UC_STOCKTRANSFERBILL t ),
grouped_data AS ( SELECT * FROM ranked_data WHERE rn = 1 ) SELECT
COUNT( 1 )
FROM
ranked_data
WHERE
rn = 1
)
SELECT *
FROM (
SELECT
temp.*,
ROWNUM AS row_num
FROM (
SELECT *
FROM grouped_data
WHERE
( SELECT temp.*, ROWNUM AS row_num FROM ( SELECT * FROM grouped_data
<if test="fuzzy != null and fuzzy != ''">
WHERE (wlmc LIKE '%' || #{fuzzy} || '%'
OR djbh LIKE '%' || #{fuzzy} || '%'
OR wlbm LIKE '%' || #{fuzzy} || '%'
OR wlmc LIKE '%' || #{fuzzy} || '%'
OR dckcmc LIKE '%' || #{fuzzy} || '%'
OR dcckmc LIKE '%' || #{fuzzy} || '%'
OR drkcmc LIKE '%' || #{fuzzy} || '%'
)
</if>
ORDER BY CJSJ DESC ) temp )
</select>
<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
EAS_NOBLE.V_UC_STOCKTRANSFERBILL t ),
grouped_data AS ( SELECT * FROM ranked_data WHERE rn = 1 ) SELECT * FROM
( SELECT temp.*, ROWNUM AS row_num FROM ( SELECT * FROM grouped_data
<if test="fuzzy != null and fuzzy != ''">
(djbh LIKE '%' || #{fuzzy} || '%' OR
wlbm LIKE '%' || #{fuzzy} || '%' OR
wlmc LIKE '%' || #{fuzzy} || '%' OR
ggxh LIKE '%' || #{fuzzy} || '%' OR
dckcmc LIKE '%' || #{fuzzy} || '%' OR
dcckmc LIKE '%' || #{fuzzy} || '%' OR
drkcmc LIKE '%' || #{fuzzy} || '%' OR)
WHERE (wlmc LIKE '%' || #{fuzzy} || '%'
OR djbh LIKE '%' || #{fuzzy} || '%'
OR wlbm LIKE '%' || #{fuzzy} || '%'
OR wlmc LIKE '%' || #{fuzzy} || '%'
OR dckcmc LIKE '%' || #{fuzzy} || '%'
OR dcckmc LIKE '%' || #{fuzzy} || '%'
OR drkcmc LIKE '%' || #{fuzzy} || '%'
)
</if>
ORDER BY jhdrrq DESC
) temp
WHERE
<![CDATA[ ROWNUM <= #{size} * #{page} ]]>
)
WHERE <![CDATA[ row_num > #{size} * (#{page} - 1) ]]>
ORDER BY CJSJ DESC ) temp WHERE <![CDATA[ ROWNUM <= #{size} * #{page} ]]>) WHERE
<![CDATA[ row_num > #{size} * (#{page} - 1) ]]>
</select>
<select id="allocationDetailPage" resultType="org.nl.wms.database.eas.dto.AllocationBillQuery">
SELECT *
FROM EAS_NOBLE.allocation
WHERE DJBH = #{djbh}
<!-- <if test="fuzzy != null and fuzzy != ''">-->
<!-- AND (-->
<!-- djbh LIKE CONCAT('%', #{fuzzy}, '%')-->
<!-- OR wlmc LIKE CONCAT('%', #{fuzzy}, '%')-->
<!-- OR ggxh LIKE CONCAT('%', #{fuzzy}, '%')-->
<!-- OR fzsl LIKE CONCAT('%', #{fuzzy}, '%')-->
<!-- OR jldw LIKE CONCAT('%', #{fuzzy}, '%')-->
<!-- OR sl LIKE CONCAT('%', #{fuzzy}, '%')-->
<!-- OR kclx LIKE CONCAT('%', #{fuzzy}, '%')-->
<!-- OR kczt LIKE CONCAT('%', #{fuzzy}, '%')-->
<!-- OR dcck LIKE CONCAT('%', #{fuzzy}, '%')-->
<!-- OR dccw LIKE CONCAT('%', #{fuzzy}, '%')-->
<!-- OR drck LIKE CONCAT('%', #{fuzzy}, '%')-->
<!-- OR drcw LIKE CONCAT('%', #{fuzzy}, '%')-->
<!-- OR trackno LIKE CONCAT('%', #{fuzzy}, '%')-->
<!-- OR ywrq LIKE CONCAT('%', #{fuzzy}, '%')-->
<!-- OR bz LIKE CONCAT('%', #{fuzzy}, '%')-->
<!-- )-->
<!-- </if>-->
ORDER BY djbh ASC
SELECT * FROM (
SELECT V.*, ROW_NUMBER() OVER (ORDER BY V.CJSJ DESC) AS RNUM
FROM EAS_NOBLE.V_UC_STOCKTRANSFERBILL V
WHERE V.DJBH = #{djbh}
)
WHERE RNUM BETWEEN (#{page} - 1) * #{size} + 1 AND #{page} * #{size}
</select>
</mapper>

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

@ -1,9 +1,9 @@
<?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">
<mapper namespace="org.nl.wms.database.eas.dao.mapper.ReceiptBillMapper">
<select id="receiptPage" resultType="org.nl.wms.database.eas.dto.ReceiptBillQuery">
<select id="receiptPage" resultType="org.nl.wms.database.eas.dto.ReceiptBillQuery">
SELECT *
FROM EAS_NOBLE.receiptBill
FROM v_wms_recbill_third
<if test="fuzzy != null and fuzzy != ''">
WHERE djbh LIKE CONCAT('%', #{fuzzy}, '%')
OR wlmc LIKE CONCAT('%', #{fuzzy}, '%')
@ -27,7 +27,7 @@
</select>
<select id="receiptDetailPage" resultType="org.nl.wms.database.eas.dto.ReceiptBillQuery">
SELECT *
FROM EAS_NOBLE.receiptBill
FROM v_wms_recbill_third
WHERE DJBH = #{djbh}
<!-- <if test="fuzzy != null and fuzzy != ''">-->
<!-- AND (-->

2
nlsso-server/src/main/java/org/nl/wms/database/eas/service/IallocationBillService.java

@ -34,7 +34,7 @@ public interface IallocationBillService extends IService<AllocationBill> {
* @param params 查询条件
* @return CommonPage<AllocationBill>
*/
CommonPage<AllocationBill> page(AllocationBillQuery params);
CommonPage<AllocationBillQuery> page(AllocationBillQuery params);
/**
* 条件查询

2
nlsso-server/src/main/java/org/nl/wms/database/eas/service/IreceiptBillService.java

@ -32,7 +32,7 @@ public interface IreceiptBillService extends IService<ReceiptBill> {
* @param params 查询条件
* @return CommonPage<ReceiptBill>
*/
CommonPage<ReceiptBill> page(ReceiptBillVO params);
CommonPage<ReceiptBillQuery> page(ReceiptBillVO params);
/**
* 条件查询

19
nlsso-server/src/main/java/org/nl/wms/database/eas/service/impl/AllocationBillServiceImpl.java

@ -4,6 +4,7 @@ import cn.dev33.satoken.annotation.SaIgnore;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import io.lettuce.core.dynamic.annotation.Param;
import org.apache.commons.lang3.StringUtils;
import org.nl.common.exception.BadRequestException;
import org.nl.common.utils.SecurityUtils;
@ -56,10 +57,9 @@ public class AllocationBillServiceImpl extends ServiceImpl<AllocationBillMapper,
@SaIgnore
public CommonPage<AllocationBill> allocationPage(AllocationBillQuery params) {
// 查询总记录数
long totalCount = allocationBillMapper.getAllocationCount();
Page<AllocationBill> pageObject = new Page<>(params.getPage(), params.getSize());
Page<AllocationBill> allocationBills = allocationBillMapper.allocationPage(pageObject, params.getFuzzy());
return CommonPage.getPage(allocationBills, totalCount);
long totalCount = allocationBillMapper.getAllocationCount(params.getFuzzy());
List<AllocationBill> allocationBills = allocationBillMapper.allocationPage(params.getFuzzy(),params.getPage(),params.getSize());
return CommonPage.getPage(allocationBills, totalCount,params.getPage(),params.getSize());
}
@ -69,15 +69,13 @@ public class AllocationBillServiceImpl extends ServiceImpl<AllocationBillMapper,
* @param params 查询条件
*/
@Override
public CommonPage<AllocationBill> page(AllocationBillQuery params) {
public CommonPage<AllocationBillQuery> page(AllocationBillQuery params) {
if (StringUtils.isBlank(params.getDjbh())) {
throw new BadRequestException("单据编号不能为空");
}
// 查询总记录数
long totalCount = allocationBillMapper.getTotalCount(params.getDjbh());
Page<AllocationBill> pageObject = new Page<>(params.getPage(), params.getSize());
Page<AllocationBill> allocationBills = allocationBillMapper.allocationDetailPage(pageObject, params.getDjbh(), params.getFuzzy());
List<AllocationBill> allocationBillList = allocationBills.getRecords();
List<AllocationBillQuery> allocationBillList = allocationBillMapper.allocationDetailPage(params.getPage(),params.getSize(), params.getDjbh(), params.getFuzzy());
if (!allocationBillList.isEmpty()) {
// 获取更新列表
List<AllocationBill> updateList = allocationBillMapper.selectList(
@ -100,15 +98,14 @@ public class AllocationBillServiceImpl extends ServiceImpl<AllocationBillMapper,
allocationBill.setDrkwbm(updatedBill.getDrkwbm());
allocationBill.setJhdrrq(updatedBill.getJhdrrq());
allocationBill.setJhdcrq(updatedBill.getJhdcrq());
allocationBill.setBz(updatedBill.getBz());
allocationBill.setBtbz(updatedBill.getBz());
}
return allocationBill;
})
.collect(Collectors.toList());
}
}
allocationBills.setRecords(allocationBillList);
return CommonPage.getPage(allocationBills, totalCount);
return CommonPage.getPage(allocationBillList, totalCount,params.getPage(), params.getSize());
}

8
nlsso-server/src/main/java/org/nl/wms/database/eas/service/impl/ReceiptBillServiceImpl.java

@ -66,13 +66,13 @@ public class ReceiptBillServiceImpl extends ServiceImpl<ReceiptBillMapper, Recei
* @param params 查询条件
*/
@Override
public CommonPage<ReceiptBill> page(ReceiptBillVO params) {
public CommonPage<ReceiptBillQuery> page(ReceiptBillVO params) {
if (StringUtils.isBlank(params.getDjbh())) {
throw new BadRequestException("单据编号不能为空");
}
Page<ReceiptBill> pageObject = new Page<>(params.getPage(), params.getSize());
Page<ReceiptBill> receiptBills = receiptBillMapper.receiptDetailPage(pageObject, params.getDjbh(), params.getFuzzy());
List<ReceiptBill> receiptBillList = receiptBills.getRecords();
Page<ReceiptBillQuery> pageObject = new Page<>(params.getPage(), params.getSize());
Page<ReceiptBillQuery> receiptBills = receiptBillMapper.receiptDetailPage(pageObject, params.getDjbh(), params.getFuzzy());
List<ReceiptBillQuery> receiptBillList = receiptBills.getRecords();
if (!receiptBillList.isEmpty()) {
List<ReceiptBill> updateList = receiptBillMapper.selectList(
new LambdaQueryWrapper<ReceiptBill>().eq(ReceiptBill::getDjid, receiptBillList.get(0).getDjid()));

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

@ -59,7 +59,7 @@ public class EasBillSchedule {
* eas单据数据同步
*/
@Async("taskExecutor")
@Scheduled(cron = "0/120 * * * * *")
//@Scheduled(cron = "0/120 * * * * *")
public void getEasOutInBills() {
// 获取eas视图查询未提交的单据
List<EasOutInBillDetail> easOutInBillDetails = easOutInBillDetailMapper.selectPageWithInventory();

Loading…
Cancel
Save