浏览代码

将过期时间从2分钟修改为30分钟

zhuoning 3 年之前
父节点
当前提交
cfb4f05e78

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

@@ -212,4 +212,9 @@ public class ErpDataController {
         }
         return new Result(ResultCode.SUCCESS,erpDataService.getPigletSurvivalRate(startDate,endDate,farmID));
     }
+
+    @RequestMapping("/getTStockHistory")
+    public Result getTStockHistory(@RequestParam(value = "farmID",required = true) String farmID){
+        return new Result(ResultCode.SUCCESS,erpDataService.getTStockHistory(farmID));
+    }
 }

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

@@ -424,7 +424,7 @@ public interface TDeliveryRepo extends JpaRepository<TDeliveryEntity, String>, J
             "FPigdieMainStruID = TPigdie.FID  " +
             "AND FDIEDATE BETWEEN ?1  " +
             "AND ?2 " +
-            "and FPIGSEX = 3 AND FPIGSTATE = 15 " +
+            "and FPIGSEX = 3 AND FPIGSTATE = 15 and  TPigDie.FBillState in(3,4,6) " +
             "GROUP BY " +
             "PIGHOUSEID ) tdie on tdie.PIGHOUSEID = td.HOGPENDID " +
             "LEFT JOIN (SELECT isnull(ISNULL(sum(TPigLoseChild.FpigLoseCount),0)+ISNULL(sum(TPigLoseChild.FweakPigLoseCount),0),0) as csamount,PIGHOUSEID FROM TPigLoseChild, " +
@@ -434,7 +434,7 @@ public interface TDeliveryRepo extends JpaRepository<TDeliveryEntity, String>, J
             "AND FPIGLOSEDATE BETWEEN ?1  " +
             "AND ?2  " +
             "AND FSEX = 3  " +
-            "AND FPIGSTATE = 15 " +
+            "AND FPIGSTATE = 15 and TPigLose.FBillState in(3,4,6) " +
             "GROUP BY " +
             "PIGHOUSEID ) tlose on tlose.PIGHOUSEID = td.HOGPENDID " +
             "WHERE " +
@@ -764,62 +764,142 @@ public interface TDeliveryRepo extends JpaRepository<TDeliveryEntity, String>, J
      * @Date        : 2021/6/30       
      * @Time        : 13:31
      */
+    @Query(nativeQuery = true,value = "select  " +
+            " (SELECT  CASE WHEN DATEDIFF ( dd , '2021-02-01' , '2021-03-09' ) >=31  THEN  " +
+            " case when ISNULL(cszrjcl.ZCZS,0)!=0 then 1-(isnull(die.教槽,0)+isnull(lose.教槽,0))/cszrjcl.ZCZS else 0 end ELSE  " +
+            " case when ISNULL(zrjcl.RJAmount,0)!=0 then 1-(isnull(die.教槽,0)+isnull(lose.教槽,0))/zrjcl.RJAmount else 0 end END )AS '仔猪存活率', " +
+            " TOrganizeCell.FName 'ZCNAME' " +
+            "from(select tmp_tblcl.ZCID as 'ZCID',sum(tmp_tblcl.ZCL) as 'ZCL',sum(tmp_tblcl.JCMZ) as 'JCMZ',sum(tmp_tblcl.HBMZ) as 'HBMZ',sum(tmp_tblcl.GZ) as 'GZ',sum(tmp_tblcl.HBGZ) as 'HBGZ',sum(tmp_tblcl.BRZZ) as 'BRZZ',sum(tmp_tblcl.BYZ) as 'BYZ',sum(tmp_tblcl.YFZ) as 'YFZ',sum(tmp_tblcl.HBSPZ) as 'HBSPZ'  " +
+            "  from(select TStockHistory.hogpenDID as 'ZCID', sum(TStockHistory.FAmountChangeInt) as 'ZCL',  " +
+            "    case when TStockHistory.FPigStatee in(3,4,5,6,7,10,12,13) and TStockHistory.FPigClassE=2 then sum(TStockHistory.FAmountChangeInt) end as 'JCMZ',  " +
+            "    case when TStockHistory.FPigStatee in(11) and TStockHistory.FPigClassE=2 then sum(TStockHistory.FAmountChangeInt) end as 'HBMZ',  " +
+            "    case when TStockHistory.FPigStatee in(2) and TStockHistory.FPigClassE=1 then sum(TStockHistory.FAmountChangeInt) end as 'GZ',  " +
+            "    case when TStockHistory.FPigStatee in(11) and TStockHistory.FPigClassE=1 then sum(TStockHistory.FAmountChangeInt) end as 'HBGZ',  " +
+            "    case when TStockHistory.FPigStatee in(15) and TStockHistory.FPigClassE in (1,2,3) then sum(TStockHistory.FAmountChangeInt) end as 'BRZZ',  " +
+            "    case when TStockHistory.FPigStatee in(14) and TStockHistory.FPigClassE in (1,2,3) then sum(TStockHistory.FAmountChangeInt) end as 'BYZ',  " +
+            "    case when (TStockHistory.FPigStatee in(1,22,21,16) or TStockHistory.FPigStatee is null) and TStockHistory.FPigClassE in (1,2,3) then sum(TStockHistory.FAmountChangeInt) end as 'YFZ',  " +
+            "    case when  TStockHistory.FPigStatee in(11) and TStockHistory.FPigClassE=3 then sum(TStockHistory.FAmountChangeInt) end as 'HBSPZ'  " +
+            "   from TStockHistory where TStockHistory.FdateChange<='2021-03-09' and TStockHistory.FPigClassE in(1,2,3)  " +
+            "  and (TStockHistory.hogpenDID in( ?3)) " +
+            "  group by TStockHistory.hogpenDID,TStockHistory.FPigStatee,TStockHistory.FPigClassE ) tmp_tblcl group by tmp_tblcl.ZCID " +
+            "  ) tmp_tblcl  " +
+            "left join ( select temp.PigHouseID,sum(isnull(temp.教槽,0)) as 教槽 " +
+            "  from " +
+            "  (select TPigDie.PigHouseID  , " +
+            "    case when TPigDieChild.FPigState in(15) and TPigDieChild.FPigSex IN(1,2,3) then sum(TPigDieChild.FweakpigdieCount)+sum(TPigDieChild.Fpigdiecount)  end'教槽'  " +
+            "   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 in (14,15,1,21,22,11,2,3,7,12,13,5,6,16) " +
+            "      and TPigDie.PigHouseID in( ?3)  " +
+            "   and ( datediff(dd,'2021-02-01', TPigDie.FDieDate)>=0 and datediff(dd,'2021-03-09',TPigDie.FDieDate) <=0)  " +
+            "   group by TPigDieChild.FPigState,TPigDieChild.FPigSex ,TPigDie.PigHouseID  )temp " +
+            "   group by temp.PigHouseID " +
+            "   ) die on die.PigHouseID=tmp_tblcl.ZCID  " +
+            "left join (   select temp.PigHouseID,sum(isnull(temp.教槽,0)) as 教槽 " +
+            "  from " +
+            "  (select TPigLose.PigHouseID, " +
+            "    case when TPigLoseChild.FPigState in(15) and TPigLoseChild.FSEX IN(1,2,3) then sum(TPigLoseChild.FpigLoseCount)+sum(TPigLoseChild.FweakPigLoseCount)  end'教槽' " +
+            "   from TPigLose left join TPigLoseChild on TPigLoseChild.FPigLoseMainStruID=TPigLose.FID  " +
+            "   where TPigLose.FBillState in(3,4,6) and TPigLoseChild.FSEX in(1,2,3) and FPIGSTATE in (14,15,1,21,22,11,2,3,7,12,13,5,6,16) " +
+            "   and TPigLose.PigHouseID in( ?3)  " +
+            "    and (datediff(dd,'2021-02-01', TPigLose.Fpiglosedate )>=0 and datediff(dd,'2021-03-09',TPigLose.Fpiglosedate ) <=0)  " +
+            "   group by TPigLoseChild.FPigState,TPigLoseChild.FSEX ,TPigLose.PigHouseID  )temp " +
+            "   group by temp.PigHouseID " +
+            "   ) lose on lose.PigHouseID=tmp_tblcl.ZCID  " +
+            "left join (select tmp_zzchl.ZCID as 'ZCID',SUM(tmp_zzchl.zczc ) as 'ZCZS' from  " +
+            "          (select TBorn.HOGPENDID as 'ZCID',count(TBornNewStru.FWAREPIGNOSTR) as 'zczc' " +
+            "           from TBorn left join TBornNewStru on TBornNewStru.FBornMainStruID = TBorn.FID  " +
+            "                      left join TPigArchives on TPigArchives.FID = TBornNewStru.PIGFIDID " +
+            "           where TBorn.FLOGSTATEE in (3,4,6)  " +
+            "             and TBorn.HOGPENDID in ( ?3) and  datediff(dd,'2021-02-01',TBorn.FDATEBORN)>=0 and datediff(dd,'2021-03-09',TBorn.FDATEBORN) <=0 " +
+            "             group by TBorn.HOGPENDID " +
+            "             ) tmp_zzchl group by tmp_zzchl.ZCID )cszrjcl on cszrjcl.ZCID=tmp_tblcl.ZCID " +
+            "left join (select tmp_tbl.ZCID, AVG(tmp_tbl.FAmount) 'RJAmount' " +
+            " from (select tppa.HogpendID 'ZCID',tppa.FDay 'FDate',SUM(tppa.FAmount) 'FAmount' from TPigStateAmountForGoods tppa where 1=1  " +
+            "        and tppa.FDay>='2021-02-01' " +
+            "           and tppa.FDay<='2021-03-09' and FPigState=15 " +
+            "              and tppa.HogpendID in ( ?3) " +
+            "           group by tppa.HogpendID,tppa.FDay) tmp_tbl group by tmp_tbl.ZCID )zrjcl on zrjcl.ZCID=tmp_tblcl.ZCID " +
+            " left join TOrganizeCell on tmp_tblcl.ZCID=TOrganizeCell.FID ")
+    List<Object[]> getPigletSurvivalRate(String startDate, String endDate, String farmID);
+
+    @Query(nativeQuery = true,value = "select COUNT(FID) from TStockHistory")
+    List<Object[]> getTStockHistory(String farmID);
+
+    /**
+     * @Method      : getPigletSurvivalRate2
+     * @Description : 获取仔猪存活率
+     * @Params      : [startDate, endDate, farmID]
+     * @Return      : java.util.List<java.lang.Object[]>
+     *
+     * @Author      : ZhuoNing
+     * @Date        : 2021/8/17
+     * @Time        : 15:55
+     */
     @Query(nativeQuery = true,value = "select \n" +
-            " (SELECT  CASE WHEN DATEDIFF ( dd , '2021-02-01' , '2021-03-09' ) >=31  THEN \n" +
-            " case when ISNULL(cszrjcl.ZCZS,0)!=0 then 1-(isnull(die.教槽,0)+isnull(lose.教槽,0))/cszrjcl.ZCZS else 0 end ELSE \n" +
-            " case when ISNULL(zrjcl.RJAmount,0)!=0 then 1-(isnull(die.教槽,0)+isnull(lose.教槽,0))/zrjcl.RJAmount else 0 end END )AS '仔猪存活率',\n" +
-            " TOrganizeCell.FName 'ZCNAME'\n" +
-            "from(select tmp_tblcl.ZCID as 'ZCID',sum(tmp_tblcl.ZCL) as 'ZCL',sum(tmp_tblcl.JCMZ) as 'JCMZ',sum(tmp_tblcl.HBMZ) as 'HBMZ',sum(tmp_tblcl.GZ) as 'GZ',sum(tmp_tblcl.HBGZ) as 'HBGZ',sum(tmp_tblcl.BRZZ) as 'BRZZ',sum(tmp_tblcl.BYZ) as 'BYZ',sum(tmp_tblcl.YFZ) as 'YFZ',sum(tmp_tblcl.HBSPZ) as 'HBSPZ' \n" +
-            "  from(select TStockHistory.hogpenDID as 'ZCID', sum(TStockHistory.FAmountChangeInt) as 'ZCL', \n" +
-            "    case when TStockHistory.FPigStatee in(3,4,5,6,7,10,12,13) and TStockHistory.FPigClassE=2 then sum(TStockHistory.FAmountChangeInt) end as 'JCMZ', \n" +
-            "    case when TStockHistory.FPigStatee in(11) and TStockHistory.FPigClassE=2 then sum(TStockHistory.FAmountChangeInt) end as 'HBMZ', \n" +
-            "    case when TStockHistory.FPigStatee in(2) and TStockHistory.FPigClassE=1 then sum(TStockHistory.FAmountChangeInt) end as 'GZ', \n" +
-            "    case when TStockHistory.FPigStatee in(11) and TStockHistory.FPigClassE=1 then sum(TStockHistory.FAmountChangeInt) end as 'HBGZ', \n" +
-            "    case when TStockHistory.FPigStatee in(15) and TStockHistory.FPigClassE in (1,2,3) then sum(TStockHistory.FAmountChangeInt) end as 'BRZZ', \n" +
-            "    case when TStockHistory.FPigStatee in(14) and TStockHistory.FPigClassE in (1,2,3) then sum(TStockHistory.FAmountChangeInt) end as 'BYZ', \n" +
-            "    case when (TStockHistory.FPigStatee in(1,22,21,16) or TStockHistory.FPigStatee is null) and TStockHistory.FPigClassE in (1,2,3) then sum(TStockHistory.FAmountChangeInt) end as 'YFZ', \n" +
-            "    case when  TStockHistory.FPigStatee in(11) and TStockHistory.FPigClassE=3 then sum(TStockHistory.FAmountChangeInt) end as 'HBSPZ' \n" +
-            "   from TStockHistory where TStockHistory.FdateChange<='2021-03-09' and TStockHistory.FPigClassE in(1,2,3) \n" +
-            "  and (TStockHistory.hogpenDID in('31025DA4-F9E1-46B8-BF38-5F2FA25E9C07'))\n" +
-            "  group by TStockHistory.hogpenDID,TStockHistory.FPigStatee,TStockHistory.FPigClassE ) tmp_tblcl group by tmp_tblcl.ZCID\n" +
-            "  ) tmp_tblcl \n" +
-            "left join ( select temp.PigHouseID,sum(isnull(temp.教槽,0)) as 教槽\n" +
-            "  from\n" +
+            " (SELECT  CASE WHEN DATEDIFF ( dd ,   ?1 ,   ?2 ) >=31  THEN \n" +
+            "case when ISNULL(cszrjcl.ZCZS,0)!=0 then 1-(isnull(die.教槽,0)+isnull(lose.教槽,0))/cszrjcl.ZCZS else 0 end ELSE \n" +
+            "case when isnull(clqc.仔猪日均存栏,0)+isnull(clbd.仔猪日均存栏,0) !=0\n" +
+            "then 1-(isnull(die.教槽,0)+isnull(lose.教槽,0))/(isnull(clqc.仔猪日均存栏,0)+isnull(clbd.仔猪日均存栏,0) ) else 0 end END )AS '仔猪存活率',\n" +
+            "TOrganizeCell.FName 'ZCNAME'\n" +
+            "from( \n" +
+            " select TStockHistory.hogpenDID as 'ZCID',   \n" +
+            "  sum(case when TStockHistory.FPigStatee in(15) and TStockHistory.FPigClassE in (1,2,3) then isnull(TStockHistory.FAmountChangeInt,0)end)  as '仔猪日均存栏'    \n" +
+            "    from TStockHistory \n" +
+            "      where  datediff(dd,  ?1, TStockHistory.FdateChange)<0  \n" +
+            "                  and TStockHistory.FPigClassE in(1,2,3) \n" +
+            " and (TStockHistory.hogpenDID in(  ?3) )\n" +
+            " group by TStockHistory.hogpenDID)clqc \n" +
+            "left join (select tmp_tblcl.ZCID as 'ZCID'\n" +
+            "  ,round(avg(isnull(tmp_tblcl.仔猪日均存栏,0)*1.00000),0) as '仔猪日均存栏'\n" +
+            " from(  \n" +
+            " select TStockHistory.hogpenDID as 'ZCID', sum(TStockHistory.FAmountChangeInt) as 'ZCL', \n" +
+            "    sum(case when TStockHistory.FPigStatee in(15) and TStockHistory.FPigClassE in (1,2,3) then isnull(TStockHistory.FAmountChangeInt,0)end)  as '仔猪日均存栏', \n" +
+            "    qj.time as billdate\n" +
+            "    from TStockHistory \n" +
+            "            left join ( select   CONVERT(varchar(10), CONVERT(datetime,   ?1)+d,120) as  [time] \n" +
+            "                from\n" +
+            "                (\n" +
+            "                    select   top   (datediff(day,  ?1,  ?2)+1)   row_number()   \n" +
+            "                    over(order   by   getdate())-1   d   from   sys.objects\n" +
+            "                ) as a) qj on 1=1\n" +
+            "                where TStockHistory.FdateChange<=qj.time\n" +
+            "          and  datediff(dd,  ?1, TStockHistory.FdateChange)>=0  \n" +
+            "                  and TStockHistory.FPigClassE in(1,2,3) \n" +
+            " and (TStockHistory.hogpenDID in(  ?3) )\n" +
+            " group by TStockHistory.hogpenDID,qj.time ) tmp_tblcl\n" +
+            "   group by tmp_tblcl.ZCID)clbd on clqc.ZCID =clbd.ZCID\n" +
+            "left join (\tselect temp.PigHouseID,sum(isnull(temp.教槽,0)) as 教槽\n" +
+            " from\n" +
             "  (select TPigDie.PigHouseID  ,\n" +
-            "    case when TPigDieChild.FPigState in(15) and TPigDieChild.FPigSex IN(1,2,3) then sum(TPigDieChild.FweakpigdieCount)+sum(TPigDieChild.Fpigdiecount)  end'教槽' \n" +
-            "   from TPigDie \n" +
-            "    left join TPigDieChild on TPigDieChild.FPigDieMainStruID=TPigDie.FID \n" +
-            "   where TPigDie.FBillState in(3,4,6) and TPigDieChild.FPigSex in(1,2,3) and FPIGSTATE in (14,15,1,21,22,11,2,3,7,12,13,5,6,16)\n" +
-            "      and TPigDie.PigHouseID in('31025DA4-F9E1-46B8-BF38-5F2FA25E9C07') \n" +
-            "   and ( datediff(dd,'2021-02-01', TPigDie.FDieDate)>=0 and datediff(dd,'2021-03-09',TPigDie.FDieDate) <=0) \n" +
-            "   group by TPigDieChild.FPigState,TPigDieChild.FPigSex ,TPigDie.PigHouseID  )temp\n" +
-            "   group by temp.PigHouseID\n" +
-            "   ) die on die.PigHouseID=tmp_tblcl.ZCID \n" +
-            "left join (   select temp.PigHouseID,sum(isnull(temp.教槽,0)) as 教槽\n" +
-            "  from\n" +
-            "  (select TPigLose.PigHouseID,\n" +
-            "    case when TPigLoseChild.FPigState in(15) and TPigLoseChild.FSEX IN(1,2,3) then sum(TPigLoseChild.FpigLoseCount)+sum(TPigLoseChild.FweakPigLoseCount)  end'教槽'\n" +
-            "   from TPigLose left join TPigLoseChild on TPigLoseChild.FPigLoseMainStruID=TPigLose.FID \n" +
-            "   where TPigLose.FBillState in(3,4,6) and TPigLoseChild.FSEX in(1,2,3) and FPIGSTATE in (14,15,1,21,22,11,2,3,7,12,13,5,6,16)\n" +
-            "   and TPigLose.PigHouseID in('31025DA4-F9E1-46B8-BF38-5F2FA25E9C07') \n" +
-            "    and (datediff(dd,'2021-02-01', TPigLose.Fpiglosedate )>=0 and datediff(dd,'2021-03-09',TPigLose.Fpiglosedate ) <=0) \n" +
-            "   group by TPigLoseChild.FPigState,TPigLoseChild.FSEX ,TPigLose.PigHouseID  )temp\n" +
-            "   group by temp.PigHouseID\n" +
-            "   ) lose on lose.PigHouseID=tmp_tblcl.ZCID \n" +
+            "   case\twhen TPigDieChild.FPigState in(15) and TPigDieChild.FPigSex IN(1,2,3) then sum(TPigDieChild.FweakpigdieCount)+sum(TPigDieChild.Fpigdiecount)  end'教槽'   \n" +
+            "  from TPigDie \n" +
+            "   left join TPigDieChild on TPigDieChild.FPigDieMainStruID=TPigDie.FID \n" +
+            "  where TPigDie.FBillState in(3,4,6) and TPigDieChild.FPigSex in(1,2,3) and FPIGSTATE in (14,15,1,21,22,11,2,3,7,12,13,5,6,16)\n" +
+            "     and TPigDie.PigHouseID in(  ?3) \n" +
+            "  and ( datediff(dd,  ?1, TPigDie.FDieDate)>=0 and datediff(dd,  ?2,TPigDie.FDieDate) <=0) \n" +
+            "  group by TPigDieChild.FPigState,TPigDieChild.FPigSex ,TPigDie.PigHouseID  )temp\n" +
+            "  group by temp.PigHouseID\n" +
+            "   ) die on die.PigHouseID=clqc.ZCID  \n" +
+            "left join (  \tselect temp.PigHouseID,sum(isnull(temp.教槽,0)) as 教槽\n" +
+            " from\n" +
+            "  (select TPigLose.PigHouseID   , \n" +
+            "   case\twhen TPigLoseChild.FPigState in(15) and TPigLoseChild.FSEX IN(1,2,3) then sum(TPigLoseChild.FpigLoseCount)+sum(TPigLoseChild.FweakPigLoseCount)  end'教槽' \n" +
+            "  from TPigLose left join TPigLoseChild on TPigLoseChild.FPigLoseMainStruID=TPigLose.FID \n" +
+            "  where TPigLose.FBillState in(3,4,6) and TPigLoseChild.FSEX in(1,2,3) and FPIGSTATE in (14,15,1,21,22,11,2,3,7,12,13,5,6,16)\n" +
+            "  and TPigLose.PigHouseID in(  ?3) \n" +
+            "   and (datediff(dd,  ?1, TPigLose.Fpiglosedate )>=0 and datediff(dd,  ?2,TPigLose.Fpiglosedate ) <=0) \n" +
+            "  group by TPigLoseChild.FPigState,TPigLoseChild.FSEX ,TPigLose.PigHouseID  )temp\n" +
+            "  group by temp.PigHouseID\n" +
+            "   ) lose on lose.PigHouseID=clqc.ZCID \n" +
             "left join (select tmp_zzchl.ZCID as 'ZCID',SUM(tmp_zzchl.zczc ) as 'ZCZS' from \n" +
             "          (select TBorn.HOGPENDID as 'ZCID',count(TBornNewStru.FWAREPIGNOSTR) as 'zczc'\n" +
             "           from TBorn left join TBornNewStru on TBornNewStru.FBornMainStruID = TBorn.FID \n" +
             "                      left join TPigArchives on TPigArchives.FID = TBornNewStru.PIGFIDID\n" +
             "           where TBorn.FLOGSTATEE in (3,4,6) \n" +
-            "             and TBorn.HOGPENDID in ('31025DA4-F9E1-46B8-BF38-5F2FA25E9C07') and  datediff(dd,'2021-02-01',TBorn.FDATEBORN)>=0 and datediff(dd,'2021-03-09',TBorn.FDATEBORN) <=0\n" +
+            "             and TBorn.HOGPENDID in (  ?3) and  datediff(dd,  ?1,TBorn.FDATEBORN)>=0 and datediff(dd,  ?2,TBorn.FDATEBORN) <=0\n" +
             "             group by TBorn.HOGPENDID\n" +
-            "             ) tmp_zzchl group by tmp_zzchl.ZCID )cszrjcl on cszrjcl.ZCID=tmp_tblcl.ZCID\n" +
-            "left join (select tmp_tbl.ZCID, AVG(tmp_tbl.FAmount) 'RJAmount'\n" +
-            " from (select tppa.HogpendID 'ZCID',tppa.FDay 'FDate',SUM(tppa.FAmount) 'FAmount' from TPigStateAmountForGoods tppa where 1=1 \n" +
-            "        and tppa.FDay>='2021-02-01'\n" +
-            "           and tppa.FDay<='2021-03-09' and FPigState=15\n" +
-            "              and tppa.HogpendID in ('31025DA4-F9E1-46B8-BF38-5F2FA25E9C07')\n" +
-            "           group by tppa.HogpendID,tppa.FDay) tmp_tbl group by tmp_tbl.ZCID )zrjcl on zrjcl.ZCID=tmp_tblcl.ZCID\n" +
-            " left join TOrganizeCell on tmp_tblcl.ZCID=TOrganizeCell.FID\n")
-    List<Object[]> getPigletSurvivalRate(String startDate, String endDate, String farmID);
+            "             ) tmp_zzchl group by tmp_zzchl.ZCID )cszrjcl on cszrjcl.ZCID=clqc.ZCID\n" +
+            "left join TOrganizeCell on clqc.ZCID=TOrganizeCell.FID")
+    List<Object[]> getPigletSurvivalRate2(String startDate, String endDate, String farmID);
 }

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

@@ -19,4 +19,6 @@ public interface IErpDataService {
     String getAllStorage(String farmName);
 
     Object getPigletSurvivalRate(String startDate, String endDate, String farmID);
+
+    Object getTStockHistory(String farmID);
 }

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

@@ -322,7 +322,8 @@ public class ErpDataServiceImpl implements IErpDataService {
         log.info(" 开始日期(仔猪存活率) startDate:" + startDate);
         log.info(" 结束日期(仔猪存活率) endDate:" + endDate);
         log.info(" 牧场名称(仔猪存活率) farmID:" + farmID);
-        List<Object[]> fieldList = tDeliveryRepo.getPigletSurvivalRate(startDate, endDate, farmID);
+//        List<Object[]> fieldList = tDeliveryRepo.getPigletSurvivalRate(startDate, endDate, farmID);
+        List<Object[]> fieldList = tDeliveryRepo.getPigletSurvivalRate2(startDate, endDate, farmID);
         log.info(" 仔猪存活率查询数量:" + fieldList.size());
         JSONArray resultJa = new JSONArray();
         for (Object[] fieldObj : fieldList) {
@@ -336,4 +337,17 @@ public class ErpDataServiceImpl implements IErpDataService {
         System.out.println("resultJa>>" + resultJa);
         return resultJa.toJSONString();
     }
+
+    @Override
+    public Object getTStockHistory(String farmID) {
+        List<Object[]> fieldList = tDeliveryRepo.getTStockHistory(farmID);
+        log.info(" SQL:" + fieldList.size());
+        String countFid = "";
+        for (Object[] fieldObj : fieldList) {
+            countFid = fieldObj[0].toString();
+            System.out.println("countFid:"+countFid);
+        }
+        return countFid;
+    }
+
 }

+ 1 - 1
huimv-hy-production/huimv.hy.erp.datasource/src/main/java/com/huimv/production/datasource/utils/TokenUtil.java

@@ -25,7 +25,7 @@ import java.util.Date;
 @Slf4j
 public class TokenUtil {
     // 过期时间设为30分钟
-    private static final long EXPIRE_TIME = 1 * 2 * 60 * 1000;  //有效时长
+    private static final long EXPIRE_TIME = 1 * 30 * 60 * 1000;  //有效时长
     private static final String TOKEN_SECRET = "qinglian";       // 秘钥
 
     /**