Przeglądaj źródła

修复获取psy参数中缺乏输入参数中的起始和截止日期区间问题。

zhuoning 4 lat temu
rodzic
commit
de6824402f

+ 2 - 2
huimv-hy-production/huimv.hy.erp.datasource/src/main/java/com/huimv/production/datasource/controller/ErpDataController.java

@@ -40,13 +40,13 @@ public class ErpDataController {
      * @Time        : 20:57
      */
     @RequestMapping("/getPsy")
-    public Result getPsy(@RequestParam(value = "accessToken",required = true) String accessToken){
+    public Result getPsy(@Param(value="startDate") String startDate,@Param(value="endDate") String endDate,@RequestParam(value = "accessToken",required = true) String accessToken){
         // 验证token
         Result result = tokenUtil.verifyToken(accessToken);
         if(!result.isSuccess()){
             return result;
         }
-        return new Result(ResultCode.SUCCESS,erpDataService.getPsy());
+        return new Result(ResultCode.SUCCESS,erpDataService.getPsy(startDate,endDate));
     }
 
     /**

+ 6 - 6
huimv-hy-production/huimv.hy.erp.datasource/src/main/java/com/huimv/production/datasource/dao/repo/TDeliveryRepo.java

@@ -21,25 +21,25 @@ public interface TDeliveryRepo extends JpaRepository<TDeliveryEntity, String>, J
      */
     @Query(nativeQuery = true,value = "select CAST(PJWCHZ*chl*NLYWS AS DEC(8,2)) AS 'PSY' from (select avg(TNewStru7743.FamountLiveInt*1.0) as 'PJWCHZ'" +
             " from TDelivery left join TNewStru7743 on TNewStru7743.FDeliveryMainStruID=TDelivery.FID " +
-            " where TDelivery.FLogStatee in(3,4,6) and TDelivery.FDateDelivery between '2021-03-01' and '2021-03-09')PJWCHZ, " +
+            " where TDelivery.FLogStatee in(3,4,6) and TDelivery.FDateDelivery between ?1 and ?2)PJWCHZ, " +
             " (SELECT case WHEN zczc = 0 THEN 0 ELSE 1-sw/zczc END  as 'chl' from ( select count(TBornNewStru.Fid) as 'zczc' " +
             "  from TBorn left join TBornNewStru on TBornNewStru.FBornMainStruID = TBorn.FID " +
             "  where TBorn.FLOGSTATEE in (3,4,6) " +
-            "  and TBorn.FDATEBORN between  '2020-03-01' and '2021-03-09')cs,(select sum(isnull(TPigDieChild.FweakpigdieCount,0))+sum(isnull(TPigDieChild.Fpigdiecount,0)) as sw " +
+            "  and TBorn.FDATEBORN between  ?1 and ?2)cs,(select sum(isnull(TPigDieChild.FweakpigdieCount,0))+sum(isnull(TPigDieChild.Fpigdiecount,0)) as sw " +
             " from TPigDie left join TPigDieChild on TPigDieChild.FPigDieMainStruID=TPigDie.FID " +
             " where TPigDie.FBillState in(3,4,6) and TPigDieChild.FPigSex in(1,2,3) and FPIGSTATE=15 " +
-            " and (TPigDie.FDieDate BETWEEN  '2020-03-01' and '2021-03-09'))sw )chl,(select  CAST(365*1.0/avg(tjj) as dec(7,4)) as 'NLYWS' " +
+            " and (TPigDie.FDieDate BETWEEN  ?1 and ?2))sw )chl,(select  CAST(365*1.0/avg(tjj) as dec(7,4)) as 'NLYWS' " +
             " from " +
             "  (SELECT " +
             " case when isnull(TNewStru7743.FtyreDistance,0)!=0 then  TNewStru7743.FtyreDistance  end  as 'tjj' " +
             " FROM TDelivery " +
             " LEFT JOIN TNewStru7743  on TNewStru7743.FDeliveryMainStruID = TDelivery.FID " +
             "  WHERE  TDelivery.FlogStateE in(3,4,6) " +
-            " And ( datediff(dd,'2020-03-01',TDelivery.FDATEDELIVERY)>=0 ) " +
-            " And (datediff(dd,'2021-03-04',TDelivery.FDATEDELIVERY)<=0 ) " +
+            " And ( datediff(dd,?1,TDelivery.FDATEDELIVERY)>=0 ) " +
+            " And (datediff(dd,?2,TDelivery.FDATEDELIVERY)<=0 ) " +
             " ) tmp_tbl " +
             " having avg(tjj)>0)ncws ")
-    List<Object[]> getPsy();
+    List<Object[]> getPsy(String startDate,String endDate);
 
     /**
      * @Method      : getReEstrusRate

+ 1 - 1
huimv-hy-production/huimv.hy.erp.datasource/src/main/java/com/huimv/production/datasource/service/IErpDataService.java

@@ -2,7 +2,7 @@ package com.huimv.production.datasource.service;
 
 public interface IErpDataService {
 
-    String getPsy();
+    String getPsy(String startDate,String endDate);
 
     String getReEstrusRate(String startDate,String endDate);
 

+ 2 - 2
huimv-hy-production/huimv.hy.erp.datasource/src/main/java/com/huimv/production/datasource/service/impl/ErpDataServiceImpl.java

@@ -36,8 +36,8 @@ public class ErpDataServiceImpl implements IErpDataService {
      * @Time        : 11:40
      */
     @Override
-    public String getPsy() {
-        List<Object[]> psyFieldList = tDeliveryRepo.getPsy();
+    public String getPsy(String startDate,String endDate) {
+        List<Object[]> psyFieldList = tDeliveryRepo.getPsy(startDate,endDate);
 //        System.out.println("psyFieldList.size: "+psyFieldList.size());
         String psy = "";
         for (Object[] goodsObj : psyFieldList) {