添加项圈解绑功能

This commit is contained in:
zyq 2024-03-07 14:04:53 +08:00
parent 3f5504d44c
commit 9a916030c3
1 changed files with 48 additions and 1 deletions

View File

@ -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<Record> 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<Record> 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<Record> 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();
}
}
}