From 9a916030c328ba7c0aaf40d0b742ebd6769293a4 Mon Sep 17 00:00:00 2001 From: zyq Date: Thu, 7 Mar 2024 14:04:53 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E9=A1=B9=E5=9C=88=E8=A7=A3?= =?UTF-8?q?=E7=BB=91=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/cyx/event/Edit.java | 49 ++++++++++++++++++++++++++- 1 file changed, 48 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/cyx/event/Edit.java b/src/main/java/com/cyx/event/Edit.java index 82a5520..38fbed7 100644 --- a/src/main/java/com/cyx/event/Edit.java +++ b/src/main/java/com/cyx/event/Edit.java @@ -1,6 +1,7 @@ package com.cyx.event; import com.alibaba.fastjson2.JSONObject; +import com.cyx.find.EventFind; import com.cyx.log.EventLog; import com.jfinal.plugin.activerecord.Db; import com.jfinal.plugin.activerecord.Record; @@ -18,19 +19,33 @@ public class Edit { /** * 淘汰 */ + EventLog.info("......牛只开始淘汰......"); Out(sourceCow,startDate,endDate); + EventLog.info("......牛只结束淘汰......"); /** * 死亡 */ + EventLog.info("......牛只开始死亡......"); Death(sourceCow,startDate,endDate); + EventLog.info("......牛只结束死亡......"); /** * 转场 */ + EventLog.info("......牛只开始转场......"); Turn(sourceCow,startDate,endDate); + EventLog.info("......牛只结束转场......"); /** * 犊牛出岛 */ + EventLog.info("......犊牛开始出岛......"); DoOut(sourceCow,startDate,endDate); + EventLog.info("......犊牛结束出岛......"); + /** + * 离场解绑 + */ + EventLog.info("......项圈开始解绑......"); + Unbind(sourceCow,startDate,endDate); + EventLog.info("......项圈结束解绑......"); }catch (Exception e){ EventLog.error("......轮回异常......"); e.printStackTrace(); @@ -461,7 +476,7 @@ public class Edit { * @param endDate */ public static void DoOut(String sourceCow,String startDate,String endDate) { - List list = Db.find("select cow_no as cowNo,event_date as eventDate,out_type as outType,oper_name as operName,create_time as createTime from t_event_out_group where source_cow='"+sourceCow+"' and date_format(event_date,'%Y-%m-%d') between date_format('"+startDate+"','%Y-%m-%d') and date_format('"+endDate+"','%Y-%m-%d')"); + List list = EventFind.getOffCowByData(sourceCow,startDate,endDate); if(list.size()>0){ for (Record record : list) { Record record1 = Db.findFirst("select calve_number as num from t_calve_cowshed where source_cow='"+sourceCow+"' and cow_no='"+record.getStr("cowNo")+"' limit 1"); @@ -490,5 +505,37 @@ public class Edit { } } } + EventLog.info("..........等待2秒.........."); + try { + Thread.sleep(2000L); + } catch (InterruptedException E) { + E.printStackTrace(); + } + } + + /** + * 项圈解绑 + * @param sourceCow + * @param startDate + * @param endDate + */ + public static void Unbind(String sourceCow,String startDate,String endDate){ + List list = EventFind.getOffCowByData(sourceCow,startDate,endDate); + if(list.size()>0) { + for (Record record : list) { + Record record1 = Db.findFirst("select id as Id,device_id as deviceId,sb_id as sbId from t_breed_device where source_cow='"+sourceCow+"' and cow_no='"+record.getStr("cowNo")+"'"); + if(record1 != null){ + Db.update("insert into t_breed_device_wear(device_id,sb_id,source_cow,cow_no,type,operator,operate_date,create_date,update_date) values ('"+record1.getStr("deviceId")+"','"+record1.getStr("sbId")+"','"+sourceCow+"','"+record.getStr("cowNo")+"','1','系统自动解绑','"+record.getStr("eventDate")+"','"+record.getStr("createTime")+"','"+record.getStr("createTime")+"')"); + Db.update("update t_breed_device set cow_no='' where id ='"+record1.getLong("Id")+"'"); + EventLog.info("...["+record.getStr("cowNo")+"]...设备...["+record1.getStr("deviceId")+"]...SBID...["+record1.getStr("sbId")+"]..."); + } + } + } + EventLog.info("..........等待2秒.........."); + try { + Thread.sleep(2000L); + } catch (InterruptedException E) { + E.printStackTrace(); + } } }