@@ -89,7 +89,7 @@ android { | |||
//数据库配置 | |||
greendao { | |||
//指定数据库schema版本号,迁移等操作会用到 | |||
schemaVersion 6 | |||
schemaVersion 7 | |||
//设置生成数据库文件的目录,默认是在build中,可以将生成的文件放到我们的java目录中 | |||
targetGenDir 'src/main/java' | |||
//设置生成的数据库相关文件的包名,默认为entity所在的包名 | |||
@@ -183,4 +183,5 @@ dependencies { | |||
//调试okhttp请求(建议debug使用) | |||
api 'com.localebro:okhttpprofiler:1.0.8' | |||
} |
@@ -133,7 +133,24 @@ | |||
android:theme="@style/Theme.AppCompat" | |||
android:label="料仓一键校准" | |||
tools:ignore="Instantiatable" /> | |||
<activity | |||
android:name=".UI.activity.LogRecordActivity" | |||
android:exported="true" | |||
android:launchMode="singleTask" | |||
android:screenOrientation="landscape" | |||
android:theme="@style/Theme.AppCompat" | |||
android:label="日志记录" | |||
tools:ignore="Instantiatable" /> | |||
<receiver | |||
android:name=".Receiver.BootReceiver" | |||
android:exported="true"> | |||
<intent-filter> | |||
<action android:name="android.intent.action.BOOT_COMPLETED" /> | |||
<category android:name="android.intent.category.LAUNCHER" /> | |||
</intent-filter> | |||
</receiver> | |||
<meta-data | |||
android:name="design_width_in_dp" | |||
android:value="1280" /> | |||
@@ -2,7 +2,9 @@ package com.jdzh.jdzhandroid.Business; | |||
import com.jdzh.jdzhandroid.Communication.Modbus.ModbusHelper; | |||
import com.jdzh.jdzhandroid.Enum.DataFormat; | |||
import com.jdzh.jdzhandroid.Enum.LogType; | |||
import com.jdzh.jdzhandroid.Log.MessageLog; | |||
import com.jdzh.jdzhandroid.Log.RecordManager; | |||
import com.jdzh.jdzhandroid.Task.Task; | |||
import com.jdzh.jdzhandroid.Task.TaskManager; | |||
@@ -16,6 +18,7 @@ public class ElectoronicScales extends ModbusHelper { | |||
private ElectoronicScales(){} | |||
public void start(){ | |||
RecordManager.getInstance().addLogRecord(LogType.plc记录,"电子秤重量获取线程start"); | |||
RtuConnect("/dev/ttyS1",9600).OnSource(()->{ | |||
TaskManager.get().StartLong("电子秤重量获取",true,()->{ | |||
if(IsConnected){ | |||
@@ -1,10 +1,14 @@ | |||
package com.jdzh.jdzhandroid.Business; | |||
import com.apkfuns.logutils.LogUtils; | |||
import com.google.gson.Gson; | |||
import com.google.gson.reflect.TypeToken; | |||
import com.jdzh.jdzhandroid.Enum.LogType; | |||
import com.jdzh.jdzhandroid.Interface.IRunT; | |||
import com.jdzh.jdzhandroid.Interface.IRunT2; | |||
import com.jdzh.jdzhandroid.Interface.IRunT3; | |||
import com.jdzh.jdzhandroid.Log.MessageLog; | |||
import com.jdzh.jdzhandroid.Log.RecordManager; | |||
import com.jdzh.jdzhandroid.Task.Task; | |||
import com.jdzh.jdzhandroid.Task.TaskManager; | |||
import com.jdzh.jdzhandroid.Config.Config; | |||
@@ -25,7 +29,7 @@ public class PlcControl extends ModbusHelper { | |||
} | |||
private PlcControl(){ | |||
String jsonString = Util.readJson(); | |||
calibrationValue=new Gson().fromJson(jsonString,new TypeToken<LinkedHashMap<Integer,LinkedHashMap<Integer,Float>>>(){}.getType()); | |||
calibrationValue=new Gson().fromJson(jsonString,new TypeToken<LinkedHashMap<String,LinkedHashMap<Integer,Float>>>(){}.getType()); | |||
if(calibrationValue == null){ | |||
calibrationValue = new LinkedHashMap<>(); | |||
} | |||
@@ -37,6 +41,7 @@ public class PlcControl extends ModbusHelper { | |||
private boolean multipleComplete = false;//单次批量配料完成 | |||
public void start(){ | |||
RecordManager.getInstance().addLogRecord(LogType.plc记录,"PLC状态获取线程start "); | |||
RtuConnect("/dev/ttyS7",9600).OnSource(()->{ | |||
TaskManager.get().StartLong("PLC状态获取",true,()->{ | |||
if(IsConnected){ | |||
@@ -64,6 +69,8 @@ public class PlcControl extends ModbusHelper { | |||
* @param value | |||
*/ | |||
public void multipleControl(LinkedHashMap<Integer,Integer> value){ | |||
RecordManager.getInstance().addLogRecord(LogType.订单处理,"批量出料控制multipleControl value="+value.toString()); | |||
boolean[] controlStatus = new boolean[16]; | |||
int[] controlValue = new int[16]; | |||
for(int i=0;i<16;i++){ | |||
@@ -83,6 +90,8 @@ public class PlcControl extends ModbusHelper { | |||
* 通道复位 | |||
*/ | |||
public void resetAllChannel(){ | |||
RecordManager.getInstance().addLogRecord(LogType.订单处理,"通道复位resetAllChannel "); | |||
boolean[] controlStatus = new boolean[16]; | |||
int[] controlValue = new int[16]; | |||
for(int i=0;i<16;i++){ | |||
@@ -95,10 +104,14 @@ public class PlcControl extends ModbusHelper { | |||
public boolean getComplete(int chNum){ | |||
if(chNum-1<0)return false; | |||
RecordManager.getInstance().addLogRecord(LogType.plc记录,"获取通道出料复位getComplete chNum="+chNum+" chDischargeComplete[chNum-1]="+chDischargeComplete[chNum-1]); | |||
return chDischargeComplete[chNum-1]; | |||
} | |||
public void resetChComplete(int chNum){ | |||
RecordManager.getInstance().addLogRecord(LogType.plc记录,"通道出料完成复位resetChComplete chNum="+chNum); | |||
if(chNum-1<0)return; | |||
Write(String.valueOf(chNum-1+20),false);//通道出料完成复位 | |||
} | |||
@@ -109,7 +122,8 @@ public class PlcControl extends ModbusHelper { | |||
* @param weight 出料重量 | |||
* @param isClearZero 配料之前是否清零 | |||
*/ | |||
public float singleControl(int chNum, float weight,boolean isClearZero){ | |||
public float singleControl(int chNum,String batchingName, float weight,boolean isClearZero){ | |||
RecordManager.getInstance().addLogRecord(LogType.plc记录,"单通道出料singleControl chNum="+chNum+";batchingName="+batchingName+";weight="+weight+";isClearZero="+isClearZero); | |||
if(chNum-1<0)return-1; | |||
if(isClearZero){ | |||
@@ -121,7 +135,7 @@ public class PlcControl extends ModbusHelper { | |||
} | |||
} | |||
float time = getOutCalibrationTime(chNum,weight); | |||
float time = getOutCalibrationTime(chNum,batchingName,weight); | |||
resetChComplete(chNum);//通道出料完成复位 | |||
Write(String.valueOf((chNum-1)*2+4408),(int)(time/10));//通道出料时间控制,出料时间除以10是因为PLC定时器的时基是10ms定时器 | |||
Write(String.valueOf(chNum-1),true);//通道出料控制 | |||
@@ -134,13 +148,15 @@ public class PlcControl extends ModbusHelper { | |||
*/ | |||
public void jogDischarge(int chNum,boolean value){ | |||
if(chNum-1<0)return; | |||
RecordManager.getInstance().addLogRecord(LogType.plc记录,"单通道点动出料控制jogDischarge chNum="+chNum+";value="+value); | |||
if(value) Write("17",true); | |||
Write(String.valueOf(chNum-1),value); | |||
if(!value)Write("17",false); | |||
} | |||
//LinkedHashMap<通道号,LinkedHashMap<出料时间,实际出料重量>> | |||
public LinkedHashMap<Integer,LinkedHashMap<Integer,Float>> calibrationValue=new LinkedHashMap<>(); | |||
//LinkedHashMap<物料名,LinkedHashMap<出料时间,实际出料重量>> | |||
public LinkedHashMap<String,LinkedHashMap<Integer,Float>> calibrationValue=new LinkedHashMap<>(); | |||
/** | |||
* 校准基本配置,key:校准时间基数,value:校准次数 | |||
@@ -153,46 +169,60 @@ public class PlcControl extends ModbusHelper { | |||
/** | |||
* 单通道校准 | |||
* @param chNum | |||
* @param chNum 通道号 | |||
* @param batchingName 物料名 | |||
*/ | |||
public void singleCalibration(int type,int chNum, IRunT2<Boolean,String> callback,IRunT<String> complete){ | |||
public void singleCalibration(int type, int chNum, String batchingName, IRunT3<Boolean,String,Integer> callback, IRunT<String> complete){ | |||
RecordManager.getInstance().addLogRecord(LogType.plc记录,"单通道校准singleCalibration type="+type+";chNum="+chNum+";batchingName="+batchingName); | |||
String desc = "通道 "+chNum+",物料【"+batchingName+"】"; | |||
try{ | |||
if(Config.isTest){ | |||
int timeTest=0; | |||
Task.Delay(200); | |||
if(callback!=null)callback.Run(true,"通道"+chNum+"正在校准..."); | |||
for(int i=0;i<16;i++){ | |||
Task.Delay(100); | |||
if(callback!=null)callback.Run(true,desc+"正在校准...",i); | |||
} | |||
float num = 100f; | |||
for (Map.Entry<Integer,Integer> item: type==1?CalibrationBase.entrySet():CalibrationBase2.entrySet()){ | |||
for(int i=1;i<=item.getValue();i++){ | |||
timeTest+=item.getKey(); | |||
if(!calibrationValue.containsKey(chNum)){ calibrationValue.put(chNum,new LinkedHashMap<>()); } | |||
if(calibrationValue.get(chNum)==null){ calibrationValue.put(chNum,new LinkedHashMap<>());} | |||
if(!calibrationValue.containsKey(batchingName)){ calibrationValue.put(batchingName,new LinkedHashMap<>()); } | |||
if(calibrationValue.get(batchingName)==null){ calibrationValue.put(batchingName,new LinkedHashMap<>());} | |||
num = (float) (num+ Math.random() * 50f); | |||
calibrationValue.get(chNum).put(timeTest,num); | |||
calibrationValue.get(batchingName).put(timeTest,num); | |||
} | |||
} | |||
return; | |||
} | |||
if(chNum-1<0)return; | |||
if(calibrationValue.containsKey(chNum))calibrationValue.get(chNum).clear(); | |||
if(calibrationValue.containsKey(batchingName))calibrationValue.get(batchingName).clear(); | |||
if(callback!=null)callback.Run(true,"电子秤清零中..."); | |||
if(callback!=null)callback.Run(true,"电子秤清零中...",1); | |||
RecordManager.getInstance().addLogRecord(LogType.plc记录,"单通道校准singleCalibration type="+type+ | |||
";chNum="+chNum+";batchingName="+batchingName+" 步骤:"+"电子秤清零中"); | |||
//电子秤清零 | |||
ElectoronicScales.get().clearZero((short) 1);//电子称去皮 | |||
boolean timeOutWeight = Util.WaitingConditions(()->{return Global.currentWeight.<Float>getValue()<=0.5f;},2000,null);//等待电子秤清零完成 | |||
if(!timeOutWeight){ | |||
if(callback!=null)callback.Run(false,"电子秤清零失败,请检查后重试"); | |||
RecordManager.getInstance().addLogRecord(LogType.plc记录,"单通道校准singleCalibration type="+type+ | |||
";chNum="+chNum+";batchingName="+batchingName+" 步骤:"+"电子秤清零失败,请检查后重试"); | |||
if(callback!=null)callback.Run(false,"电子秤清零失败,请检查后重试",0); | |||
return; | |||
} | |||
//管道满管 | |||
if(callback!=null)callback.Run(true,"通道满管中..."); | |||
if(callback!=null)callback.Run(true,"通道满管中...",2); | |||
RecordManager.getInstance().addLogRecord(LogType.plc记录,"单通道校准singleCalibration type="+type+ | |||
";chNum="+chNum+";batchingName="+batchingName+" 步骤:"+"通道满管中"); | |||
jogDischarge(chNum,true);//控制通道出料 | |||
boolean timeOut1= Util.WaitingConditions(()->{return Global.currentWeight.<Float>getValue()>=2.0f;},15000,null);//等待重量大于等于2g | |||
jogDischarge(chNum,false);//停止出料 | |||
if(!timeOut1){ | |||
if(callback!=null)callback.Run(false,"满管超时,请检查后重试"); | |||
if(callback!=null)callback.Run(false,"满管超时,请检查后重试",0); | |||
RecordManager.getInstance().addLogRecord(LogType.plc记录,"单通道校准singleCalibration type="+type+ | |||
";chNum="+chNum+";batchingName="+batchingName+" 步骤:"+"满管超时,请检查后重试"); | |||
return; | |||
} | |||
@@ -207,12 +237,14 @@ public class PlcControl extends ModbusHelper { | |||
return; | |||
} | |||
count++; | |||
if(callback!=null)callback.Run(true,"通道 "+chNum+" 第 "+count+" 次校准中..."); | |||
if(callback!=null)callback.Run(true,desc+" 第 "+count+" 次校准中...",count+2); | |||
CalibrationTime+=item.getKey(); | |||
ElectoronicScales.get().clearZero((short) 1);//电子称去皮 | |||
boolean timeOutWeight1 = Util.WaitingConditions(()->{return Global.currentWeight.<Float>getValue()<=0.5f;},2000,null);//等待电子秤清零完成 | |||
if(!timeOutWeight1){ | |||
if(callback!=null)callback.Run(false,"第 "+count+" 次校准,电子秤清零失败,请检查后重试"); | |||
if(callback!=null)callback.Run(false,"第 "+count+" 次校准,电子秤清零失败,请检查后重试",0); | |||
RecordManager.getInstance().addLogRecord(LogType.plc记录,"单通道校准singleCalibration type="+type+ | |||
";chNum="+chNum+";batchingName="+batchingName+" 步骤:"+desc+"第 "+count+" 次校准,电子秤清零失败,请检查后重试"); | |||
return; | |||
} | |||
@@ -224,25 +256,33 @@ public class PlcControl extends ModbusHelper { | |||
boolean isTimeOut = Util.WaitingConditions(()->{return chDischargeComplete[chNum-1];},CalibrationTime+2000,null);//等待单通道出料完成 | |||
PlcControl.get().resetChComplete(chNum);//复位完成通道 | |||
if(!isTimeOut){ | |||
if(callback!=null)callback.Run(false,"第 "+count+" 次通道校准失败,请检查后重试"); | |||
if(callback!=null)callback.Run(false,desc+" 第 "+count+" 次通道校准失败,请检查后重试",0); | |||
RecordManager.getInstance().addLogRecord(LogType.plc记录,"单通道校准singleCalibration type="+type+ | |||
";chNum="+chNum+";batchingName="+batchingName+" 步骤:"+desc+" 第 "+count+" 次通道校准失败,请检查后重试"); | |||
isFail=true; | |||
break; | |||
} | |||
if(callback!=null)callback.Run(true,"通道 "+chNum+" 第 "+count+" 次校准完成"); | |||
if(callback!=null)callback.Run(true,desc+" 第 "+count+" 次校准完成",count+2); | |||
RecordManager.getInstance().addLogRecord(LogType.plc记录,"单通道校准singleCalibration type="+type+ | |||
";chNum="+chNum+";batchingName="+batchingName+" 步骤:"+desc+" 第 "+count+" 次校准完成"); | |||
Task.Delay(1000);//等待1000毫秒获取电子秤稳定数据 | |||
//记录通道出料时间以及实际重量 | |||
if(!calibrationValue.containsKey(chNum)){ calibrationValue.put(chNum,new LinkedHashMap<>()); } | |||
if(calibrationValue.get(chNum)==null){ calibrationValue.put(chNum,new LinkedHashMap<>());} | |||
calibrationValue.get(chNum).put(CalibrationTime,Global.currentWeight.<Float>getValue()); | |||
if(!calibrationValue.containsKey(batchingName)){ calibrationValue.put(batchingName,new LinkedHashMap<>()); } | |||
if(calibrationValue.get(batchingName)==null){ calibrationValue.put(batchingName,new LinkedHashMap<>());} | |||
calibrationValue.get(batchingName).put(CalibrationTime,Global.currentWeight.<Float>getValue()); | |||
} | |||
} | |||
//自动保存校准结果到本地 | |||
Util.writeJson(calibrationValue); | |||
if(complete!=null&&!isFail)complete.Run("通道 "+chNum+" 校准完成"); | |||
if(complete!=null&&!isFail)complete.Run(desc+" 校准完成"); | |||
RecordManager.getInstance().addLogRecord(LogType.plc记录,"单通道校准singleCalibration type="+type+ | |||
";chNum="+chNum+";batchingName="+batchingName+" 步骤:"+desc+" 校准完成"); | |||
Task.Delay(500); | |||
}catch (Exception e){ | |||
MessageLog.ShowError("通道 "+chNum +" 校准异常! " + e.getMessage()); | |||
MessageLog.ShowError(desc +" 校准异常! " + e.getMessage()); | |||
RecordManager.getInstance().addLogRecord(LogType.plc记录,"单通道校准singleCalibration type="+type+ | |||
";chNum="+chNum+";batchingName="+batchingName+" 步骤:"+desc+" 校准异常!"); | |||
} | |||
} | |||
@@ -252,6 +292,8 @@ public class PlcControl extends ModbusHelper { | |||
*/ | |||
public void singleFullSilo(int type,int chNum, IRunT2<Boolean,String> callback,IRunT<String> complete){ | |||
try{ | |||
RecordManager.getInstance().addLogRecord(LogType.plc记录,"单通道补满管道singleFullSilo type="+type+ | |||
";chNum="+chNum); | |||
if(Config.isTest){ | |||
Task.Delay(200); | |||
if(callback!=null)callback.Run(true,"通道"+chNum+"正在满管..."); | |||
@@ -260,55 +302,67 @@ public class PlcControl extends ModbusHelper { | |||
if(chNum-1<0)return; | |||
if(callback!=null)callback.Run(true,"电子秤清零中..."); | |||
RecordManager.getInstance().addLogRecord(LogType.plc记录,"单通道补满管道singleFullSilo type="+type+ | |||
";chNum="+chNum+" 步骤:"+"电子秤清零中"); | |||
//电子秤清零 | |||
ElectoronicScales.get().clearZero((short) 1);//电子称去皮 | |||
boolean timeOutWeight = Util.WaitingConditions(()->{return Global.currentWeight.<Float>getValue()<=0.5f;},2000,null);//等待电子秤清零完成 | |||
if(!timeOutWeight){ | |||
if(callback!=null)callback.Run(false,"电子秤清零失败,请检查后重试"); | |||
RecordManager.getInstance().addLogRecord(LogType.plc记录,"单通道补满管道singleFullSilo type="+type+ | |||
";chNum="+chNum+" 步骤:"+"电子秤清零失败,请检查后重试"); | |||
return; | |||
} | |||
//管道满管 | |||
if(callback!=null)callback.Run(true,"通道满管中..."); | |||
RecordManager.getInstance().addLogRecord(LogType.plc记录,"单通道补满管道singleFullSilo type="+type+ | |||
";chNum="+chNum+" 步骤:"+"通道满管中"); | |||
jogDischarge(chNum,true);//控制通道出料 | |||
boolean timeOut1= Util.WaitingConditions(()->{return Global.currentWeight.<Float>getValue()>=2.0f;},15000,null);//等待重量大于等于2g | |||
jogDischarge(chNum,false);//停止出料 | |||
if(!timeOut1){ | |||
if(callback!=null)callback.Run(false,"满管超时,请检查后重试"); | |||
RecordManager.getInstance().addLogRecord(LogType.plc记录,"单通道补满管道singleFullSilo type="+type+ | |||
";chNum="+chNum+" 步骤:"+"满管超时,请检查后重试"); | |||
return; | |||
} | |||
complete.Run("通道 "+chNum+" 已填满管道"); | |||
RecordManager.getInstance().addLogRecord(LogType.plc记录,"单通道补满管道singleFullSilo type="+type+ | |||
";chNum="+chNum+" 步骤:"+"已填满管道"); | |||
Task.Delay(1000);//等待1S去除波动 | |||
}catch (Exception e){ | |||
MessageLog.ShowError("通道 "+chNum +" 校准异常! " + e.getMessage()); | |||
MessageLog.ShowError("通道 "+chNum +" 满管异常! " + e.getMessage()); | |||
RecordManager.getInstance().addLogRecord(LogType.plc记录,"单通道补满管道singleFullSilo type="+type+ | |||
";chNum="+chNum+" 步骤:"+"满管异常!"); | |||
} | |||
} | |||
/** | |||
* 根据重量获取出料时间 | |||
* @param chNum | |||
* @param chNum 通道号 | |||
* @param batchingName 物料名 | |||
* @param weight | |||
* @return | |||
*/ | |||
public float getOutCalibrationTime(int chNum,float weight){ | |||
public float getOutCalibrationTime(int chNum,String batchingName,float weight){ | |||
try{ | |||
if(chNum-1<0)return -1; | |||
if(calibrationValue.containsKey(chNum)){ | |||
if(calibrationValue.containsKey(batchingName)){ | |||
int minTime=0,maxTime=0; | |||
float minWeight=0,maxWeight=0; | |||
float maxValue = Collections.max( calibrationValue.get(chNum).values()); | |||
float maxValue = Collections.max( calibrationValue.get(batchingName).values()); | |||
int maxKey=0; | |||
for (Map.Entry<Integer,Float> item:calibrationValue.get(chNum).entrySet()) { | |||
for (Map.Entry<Integer,Float> item:calibrationValue.get(batchingName).entrySet()) { | |||
if(maxValue==item.getValue()){ | |||
maxKey=item.getKey(); | |||
break; | |||
} | |||
} | |||
float minValue = Collections.min(calibrationValue.get(chNum).values()); | |||
float minValue = Collections.min(calibrationValue.get(batchingName).values()); | |||
int minKey=0; | |||
for (Map.Entry<Integer,Float> item:calibrationValue.get(chNum).entrySet()) { | |||
for (Map.Entry<Integer,Float> item:calibrationValue.get(batchingName).entrySet()) { | |||
if(minValue==item.getValue()){ | |||
minKey=item.getKey(); | |||
break; | |||
@@ -316,11 +370,15 @@ public class PlcControl extends ModbusHelper { | |||
} | |||
if(weight>maxValue){ | |||
return Math.round( (weight/maxValue)*maxKey); | |||
float time = Math.round( (weight/maxValue)*maxKey); | |||
LogUtils.d("获取通道 "+chNum +"【"+batchingName+"】"+" 出料时间 time="+time); | |||
return time; | |||
}else if(weight<minValue){ | |||
return Math.round( (weight/minValue)*minKey); | |||
float time = Math.round( (weight/minValue)*minKey); | |||
LogUtils.d("获取通道 "+chNum +"【"+batchingName+"】"+" 出料时间 time="+time); | |||
return time; | |||
}else{ | |||
for(Map.Entry<Integer, Float> item: calibrationValue.get(chNum).entrySet()){ | |||
for(Map.Entry<Integer, Float> item: calibrationValue.get(batchingName).entrySet()){ | |||
if (weight >= item.getValue() && (minWeight < item.getValue() || minWeight == 0)) | |||
{ | |||
minTime = item.getKey(); | |||
@@ -332,11 +390,15 @@ public class PlcControl extends ModbusHelper { | |||
maxWeight = item.getValue(); | |||
} | |||
} | |||
return Math.round( Scale(weight, maxWeight,minWeight,(float) maxTime,(float)minTime )); | |||
float time = Math.round( Scale(weight, maxWeight,minWeight,(float) maxTime,(float)minTime )); | |||
LogUtils.d("获取通道 "+chNum +"【"+batchingName+"】"+" 出料时间 time="+time); | |||
return time; | |||
} | |||
} | |||
}catch (Exception e){ | |||
MessageLog.ShowError("获取通道 "+chNum +" 出料时间失败!"); | |||
MessageLog.ShowError("获取通道 "+chNum +"【"+batchingName+"】"+" 出料时间失败!"); | |||
RecordManager.getInstance().addLogRecord(LogType.plc记录,"根据重量获取出料时间getOutCalibrationTime chNum="+chNum+ | |||
";batchingName="+batchingName+";weight="+"weight 出料时间失败!"); | |||
} | |||
return -1; | |||
} | |||
@@ -1,8 +1,10 @@ | |||
package com.jdzh.jdzhandroid.Business; | |||
import com.jdzh.jdzhandroid.Enum.LogType; | |||
import com.jdzh.jdzhandroid.Enum.SiloChannel; | |||
import com.jdzh.jdzhandroid.Enum.Status; | |||
import com.jdzh.jdzhandroid.Interface.IRunT; | |||
import com.jdzh.jdzhandroid.Log.RecordManager; | |||
import com.jdzh.jdzhandroid.Sqlite.DAO.BPA_BatchingDao; | |||
import com.jdzh.jdzhandroid.Sqlite.DAO.BPA_RecipeConfigDetailDao; | |||
import com.jdzh.jdzhandroid.Sqlite.DAO.BPA_RecipeInfoDao; | |||
@@ -23,11 +25,14 @@ public class TaskControl { | |||
/** | |||
* 启动单通道配料 | |||
* @param chNum 通道编号(1-16) | |||
* @param batchingName 物料名 | |||
* @param weight 出料重量 g | |||
* @param callBack 任务执行反馈 | |||
*/ | |||
public static void startBatchComplete(int chNum, float weight, IRunT<Status> callBack){ | |||
float time = PlcControl.get().singleControl(chNum,weight,true);//控制出料并获取出料时间 | |||
public static void startBatchComplete(int chNum,String batchingName, float weight, IRunT<Status> callBack){ | |||
RecordManager.getInstance().addLogRecord(LogType.plc记录,"启动单通道配料startBatchComplete"+ | |||
" chNum="+chNum+";batchingName="+batchingName+";weight="+weight); | |||
float time = PlcControl.get().singleControl(chNum,batchingName,weight,true);//控制出料并获取出料时间 | |||
if(time<0){ | |||
ToastUtil.showError("出料重量计算错误,请检查需求量或重新校准通道!"); | |||
if(callBack!=null)callBack.Run( Status.任务错误); | |||
@@ -43,6 +48,10 @@ public class TaskControl { | |||
* @param callBack 任务执行反馈 | |||
*/ | |||
public static void startBatchList(String recipeId,String configId, RecipeExecuteDialog.ExecuteCallBack callBack){ | |||
BPA_RecipeInfo recipeInfo = SqliteHelper.get().queryByBuilderEntity(BPA_RecipeInfo.class, | |||
BPA_RecipeInfoDao.Properties.Id.eq(recipeId)); | |||
RecordManager.getInstance().addLogRecord(LogType.订单处理,"启动多通道配料startBatchList"+ | |||
" recipeId="+recipeId+";recipeName="+recipeInfo.getName()+";configId="+configId); | |||
if(Config.isTest){ | |||
callBack.onSuccess(3200); | |||
return; | |||
@@ -54,15 +63,17 @@ public class TaskControl { | |||
int totalTime = 0; | |||
float scale = 1f; | |||
if(Config.getInstance().isWeight){ | |||
BPA_RecipeInfo recipeInfo = SqliteHelper.get().queryByBuilderEntity(BPA_RecipeInfo.class, | |||
BPA_RecipeInfoDao.Properties.Id.eq(recipeId)); | |||
float weight = recipeInfo.getReferenceWeight(); | |||
if(weight == 0){ | |||
ToastUtil.showError("基准克数不能为0!"); | |||
RecordManager.getInstance().addLogRecord(LogType.订单处理,"启动多通道配料startBatchList"+ | |||
" recipeId="+recipeId+";recipeName="+recipeInfo.getName()+";configId="+configId + " 步骤:"+"基准克数不能为0!"); | |||
return; | |||
} | |||
if(Global.currentWeight.<Float>getValue()<RecipeExecuteDialog.baseWeight){ | |||
ToastUtil.showError("称重读数不准确!"); | |||
ToastUtil.showError("实际重量小于100g,请重新清零放碗!"); | |||
RecordManager.getInstance().addLogRecord(LogType.订单处理,"启动多通道配料startBatchList"+ | |||
" recipeId="+recipeId+";recipeName="+recipeInfo.getName()+";configId="+configId + " 步骤:"+"实际重量小于100g,请重新清零放碗!"); | |||
return; | |||
} | |||
scale = Global.currentWeight.<Float>getValue()/weight; | |||
@@ -79,9 +90,11 @@ public class TaskControl { | |||
if(callBack!=null){ | |||
callBack.onError("【"+batching.getName()+"】未绑定通道!"); | |||
} | |||
RecordManager.getInstance().addLogRecord(LogType.订单处理,"启动多通道配料startBatchList"+ | |||
" recipeId="+recipeId+";recipeName="+recipeInfo.getName()+";configId="+configId + " 步骤:"+"【"+batching.getName()+"】未绑定通道!"); | |||
return; | |||
}else { | |||
float time = PlcControl.get().getOutCalibrationTime(num,detail.getWeight()*scale); | |||
float time = PlcControl.get().getOutCalibrationTime(num,batching.getName(),detail.getWeight()*scale); | |||
value.put(num, (int) time); | |||
totalTime = totalTime+((int) time); | |||
} | |||
@@ -89,6 +102,8 @@ public class TaskControl { | |||
if(callBack!=null){ | |||
callBack.onError("未找到物料id:"+detail.getBatchingId()); | |||
} | |||
RecordManager.getInstance().addLogRecord(LogType.订单处理,"启动多通道配料startBatchList"+ | |||
" recipeId="+recipeId+";recipeName="+recipeInfo.getName()+";configId="+configId + " 步骤:"+"未找到物料id:"+detail.getBatchingId()); | |||
return; | |||
} | |||
} | |||
@@ -97,16 +112,22 @@ public class TaskControl { | |||
if(callBack!=null){ | |||
callBack.onError("所有物料重量为0,请确定物料重量是否正常"); | |||
} | |||
RecordManager.getInstance().addLogRecord(LogType.订单处理,"启动多通道配料startBatchList"+ | |||
" recipeId="+recipeId+";recipeName="+recipeInfo.getName()+";configId="+configId + " 步骤:"+"所有物料重量为0,请确定物料重量是否正常"); | |||
return; | |||
} | |||
if(totalTime<=0){ | |||
if(callBack!=null){ | |||
callBack.onError("获取出料时间为0,请检测配方或料仓配置"); | |||
callBack.onError("获取出料时间为0,请检测配方、校准或料仓配置"); | |||
} | |||
RecordManager.getInstance().addLogRecord(LogType.订单处理,"启动多通道配料startBatchList"+ | |||
" recipeId="+recipeId+";recipeName="+recipeInfo.getName()+";configId="+configId + " 步骤:"+"获取出料时间为0,请检测配方、校准或料仓配置"); | |||
return; | |||
} | |||
if(callBack!=null){ | |||
callBack.onSuccess(totalTime); | |||
RecordManager.getInstance().addLogRecord(LogType.订单处理,"启动多通道配料startBatchList"+ | |||
" recipeId="+recipeId+";recipeName="+recipeInfo.getName()+";configId="+configId + " 步骤:onSuccess totalTime"+totalTime); | |||
} | |||
TaskManager.get().execute(new Runnable() { | |||
@Override | |||
@@ -115,8 +136,4 @@ public class TaskControl { | |||
} | |||
}); | |||
} | |||
public static void stopBatchList(){ | |||
} | |||
} |
@@ -3,7 +3,9 @@ package com.jdzh.jdzhandroid.Communication.Modbus; | |||
import com.jdzh.jdzhandroid.DataUtil.DataConvertLib; | |||
import com.jdzh.jdzhandroid.DataUtil.NotifyPropVar; | |||
import com.jdzh.jdzhandroid.Enum.DataFormat; | |||
import com.jdzh.jdzhandroid.Enum.LogType; | |||
import com.jdzh.jdzhandroid.Log.MessageLog; | |||
import com.jdzh.jdzhandroid.Log.RecordManager; | |||
import com.jdzh.jdzhandroid.Result.OperateResult; | |||
import com.jdzh.jdzhandroid.Result.OperateResultT; | |||
import com.jdzh.jdzhandroid.Task.Task; | |||
@@ -52,6 +54,8 @@ public class ModbusHelper extends AbsRead implements IWrite,IModbusMaster { | |||
private int ConnectionType; | |||
private void ReConnect(String error){ | |||
RecordManager.getInstance().addLogRecord(LogType.plc记录,"ModbusHelper Plc重连 ReConnect error="+error); | |||
if(!IsReconnect)return; | |||
if(ConnectionType==1){ | |||
if(error.contains("Connection refused")||error.contains("SocketException")||error.contains("SocketTimeoutException")){ | |||
@@ -12,6 +12,14 @@ import com.jdzh.jdzhandroid.util.PreferenceUtils; | |||
*/ | |||
public class Config { | |||
public static final boolean isTest = true; | |||
/** | |||
* 账户 | |||
*/ | |||
public String account = ""; | |||
/** | |||
* 是否登录 | |||
*/ | |||
public boolean isLogin = false; | |||
/** | |||
* 是否是称重模式 | |||
*/ | |||
@@ -44,11 +52,11 @@ public class Config { | |||
public static final String SHARE_KEY_adminType = "SHARE_KEY_adminType";//登录密码 | |||
public static void Test(){ | |||
PreferenceUtils.setString(Config.SHARE_KEY_autoKey,"1"); | |||
PreferenceUtils.setString(Config.SHARE_KEY_storeName,"门店1"); | |||
PreferenceUtils.setString(Config.SHARE_KEY_storeId,"930f754e-31c0-4aa7-af77-9d860f58a816"); | |||
PreferenceUtils.setString(Config.SHARE_KEY_deviceName,"设备1"); | |||
PreferenceUtils.setString(Config.SHARE_KEY_deviceId,"006ad902-64c3-4078-a0f3-c241a871bbe1"); | |||
// PreferenceUtils.setString(Config.SHARE_KEY_autoKey,"1"); | |||
// PreferenceUtils.setString(Config.SHARE_KEY_storeName,"门店1"); | |||
// PreferenceUtils.setString(Config.SHARE_KEY_storeId,"930f754e-31c0-4aa7-af77-9d860f58a816"); | |||
// PreferenceUtils.setString(Config.SHARE_KEY_deviceName,"设备1"); | |||
// PreferenceUtils.setString(Config.SHARE_KEY_deviceId,"006ad902-64c3-4078-a0f3-c241a871bbe1"); | |||
} | |||
private static volatile Config mInstance = null; //实例变量设置私有,防止直接通过类名访问 | |||
@@ -73,6 +81,7 @@ public class Config { | |||
isWeight = PreferenceUtils.getBoolean(Config.SHARE_KEY_isWeight,false); | |||
autoKey = PreferenceUtils.getString(Config.SHARE_KEY_autoKey,"1"); | |||
adminType = PreferenceUtils.getInt(Config.SHARE_KEY_adminType,0); | |||
account = PreferenceUtils.getString(Config.SHARE_KEY_account,""); | |||
LogUtils.d(" Config.getInstance().autoKey="+Config.getInstance().autoKey); | |||
} | |||
@@ -3,30 +3,20 @@ package com.jdzh.jdzhandroid; | |||
import android.annotation.SuppressLint; | |||
import android.content.Context; | |||
import android.content.Intent; | |||
import android.content.pm.PackageInfo; | |||
import android.content.pm.PackageManager; | |||
import android.content.pm.PackageManager.NameNotFoundException; | |||
import android.os.Build; | |||
import android.os.Environment; | |||
import android.os.Looper; | |||
import android.os.SystemClock; | |||
import android.util.Log; | |||
import android.widget.Toast; | |||
import com.apkfuns.logutils.LogUtils; | |||
import com.jdzh.jdzhandroid.Enum.LogType; | |||
import com.jdzh.jdzhandroid.Log.RecordManager; | |||
import com.jdzh.jdzhandroid.api.IHttpCallBack; | |||
import com.jdzh.jdzhandroid.api.ServerManager; | |||
import com.jdzh.jdzhandroid.util.ToastUtil; | |||
import java.io.File; | |||
import java.io.FileOutputStream; | |||
import java.io.FilenameFilter; | |||
import java.io.PrintWriter; | |||
import java.io.StringWriter; | |||
import java.io.Writer; | |||
import java.lang.Thread.UncaughtExceptionHandler; | |||
import java.lang.reflect.Field; | |||
import java.text.DateFormat; | |||
import java.text.SimpleDateFormat; | |||
import java.util.Date; | |||
@@ -102,6 +92,7 @@ public class CrashHandler implements UncaughtExceptionHandler { | |||
sb.append("VERSION_NAME=").append(BuildConfig.VERSION_NAME).append("\n"); | |||
sb.append(sw.toString()); | |||
try{ | |||
RecordManager.getInstance().addLogRecord(LogType.设备异常,sb.toString()); | |||
// File logFile = new File(Environment.getExternalStorageDirectory(),"/jdzhandroid/crash.log"); | |||
File folder = new File(Environment.getExternalStorageDirectory()+"/jdzhandroid"); | |||
if(!folder.exists())folder.mkdir(); | |||
@@ -125,6 +116,7 @@ public class CrashHandler implements UncaughtExceptionHandler { | |||
// } | |||
// }); | |||
RecordManager.getInstance().addLogRecord(LogType.设备异常,"崩溃重启"); | |||
Intent intent = mContext.getPackageManager().getLaunchIntentForPackage(mContext.getPackageName()); | |||
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP|Intent.FLAG_ACTIVITY_NEW_TASK); | |||
mContext.startActivity(intent); | |||
@@ -0,0 +1,13 @@ | |||
package com.jdzh.jdzhandroid.Enum; | |||
public enum LogType { | |||
登录, | |||
角色操作, | |||
数据接收, | |||
数据上传, | |||
订单处理, | |||
设备异常, | |||
页面上报, | |||
配方编辑, | |||
plc记录, | |||
} |
@@ -0,0 +1,5 @@ | |||
package com.jdzh.jdzhandroid.Interface; | |||
public interface IRunT3<T1,T2,T3> { | |||
void Run(T1 t1, T2 t2,T3 t3);; | |||
} |
@@ -3,6 +3,7 @@ package com.jdzh.jdzhandroid.Log; | |||
import android.util.Log; | |||
import com.apkfuns.logutils.LogUtils; | |||
import com.jdzh.jdzhandroid.Enum.LogType; | |||
import java.util.concurrent.ConcurrentLinkedQueue; | |||
@@ -14,19 +15,20 @@ public class MessageLog { | |||
@Override | |||
public void ErrorMsg(String msg) { | |||
LogUtils.e("msg "+msg); | |||
Log.d("msg", "msg "+msg); | |||
RecordManager.getInstance().addLogRecord(LogType.plc记录,"MessageLog ErrorMsg msg="+msg); | |||
} | |||
@Override | |||
public void InfoMsg(String msg) { | |||
LogUtils.d("msg "+msg); | |||
Log.d("msg", "msg "+msg); | |||
RecordManager.getInstance().addLogRecord(LogType.plc记录,"MessageLog InfoMsg msg="+msg); | |||
} | |||
@Override | |||
public void WarnMsg(String msg) { | |||
LogUtils.d("msg "+msg); | |||
Log.d("msg", "msg "+msg); | |||
RecordManager.getInstance().addLogRecord(LogType.plc记录,"MessageLog WarnMsg msg="+msg); | |||
} | |||
}; | |||
// ThreadManager.get().StartLong("日志信息保存",true, () -> { | |||
@@ -1,5 +1,10 @@ | |||
package com.jdzh.jdzhandroid.Log; | |||
import com.jdzh.jdzhandroid.Config.Config; | |||
import com.jdzh.jdzhandroid.Enum.LogType; | |||
import com.jdzh.jdzhandroid.Sqlite.Model.BPA_LogRecord; | |||
import com.jdzh.jdzhandroid.Sqlite.SqliteHelper; | |||
import com.jdzh.jdzhandroid.Task.TaskManager; | |||
/** | |||
@@ -27,108 +32,37 @@ public class RecordManager { | |||
* @param typeName | |||
* @param desc | |||
*/ | |||
public void addLogRecord(String typeName,String desc){ | |||
public void addLogRecord(LogType typeName, String desc){ | |||
TaskManager.get().execute(new Thread(()->{ | |||
try{ | |||
// BPA_LOG_RECORD log = new BPA_LOG_RECORD(); | |||
// log.userID = ConfigName.getInstance().user.userID; | |||
// log.typeName = typeName; | |||
// log.describe = desc; | |||
// log.userName = ConfigName.getInstance().user.name; | |||
// switch (typeName){ | |||
// case "登录日志":log.typeId=1; | |||
// break; | |||
// case "角色操作日志":log.typeId=2; | |||
// break; | |||
// case "数据接收":log.typeId=3; | |||
// break; | |||
// case "上传日志":log.typeId=4; | |||
// break; | |||
// case "订单处理日志":log.typeId=5; | |||
// break; | |||
// case "设备异常日志":log.typeId=6; | |||
// break; | |||
// case "页面上报日志":log.typeId=7; | |||
// break; | |||
// } | |||
// LogRecordUtil.add(log); | |||
BPA_LogRecord log = new BPA_LogRecord(); | |||
log.userName = Config.getInstance().account; | |||
log.typeName = typeName.toString(); | |||
log.describe = desc; | |||
switch (typeName.toString()){ | |||
case "登录":log.typeId=1; | |||
break; | |||
case "角色操作":log.typeId=2; | |||
break; | |||
case "数据接收":log.typeId=3; | |||
break; | |||
case "数据上传":log.typeId=4; | |||
break; | |||
case "订单处理":log.typeId=5; | |||
break; | |||
case "设备异常":log.typeId=6; | |||
break; | |||
case "页面上报":log.typeId=7; | |||
break; | |||
case "配方编辑":log.typeId=8; | |||
break; | |||
case "plc记录":log.typeId=9; | |||
break; | |||
} | |||
SqliteHelper.get().insert(log); | |||
}catch (Exception e){ | |||
e.printStackTrace(); | |||
} | |||
})); | |||
} | |||
// | |||
// /** | |||
// * 添加订单记录 | |||
// * @param group | |||
// * @param type 1完成 2取消 3异常 | |||
// */ | |||
// public void addOrderRecord(BPA_GOODS_SUBATTRIBUTE_GROUP group, String type){ | |||
// if(group==null||type==null||type.isEmpty()){ | |||
// return; | |||
// } | |||
// TaskManager.get().execute(new Thread(()->{ | |||
// try{ | |||
// BPA_ORDER_LIST order = new BPA_ORDER_LIST(); | |||
// BPA_GOODS goods = GoodsDBUtil.getById(group.goodsId); | |||
// if(goods==null){ | |||
// return; | |||
// } | |||
// order.groupName = group.name; | |||
// order.groupId = group.id; | |||
// order.goodsName = goods.name; | |||
// order.classifyId = goods.propClassifyId; | |||
// order.goodsId = goods.id; | |||
// switch (type){ | |||
// case "完成": | |||
// order.status = 1; | |||
// break; | |||
// case "取消": | |||
// order.status = 2; | |||
// break; | |||
// case "异常": | |||
// order.status = 3; | |||
// break; | |||
// } | |||
// OrderListUtil.add(order); | |||
// }catch (Exception e){ | |||
// e.printStackTrace(); | |||
// } | |||
// })); | |||
// } | |||
// | |||
// /** | |||
// * 添加订单记录 | |||
// * @param group | |||
// * @param type 1完成 2取消 3异常 | |||
// */ | |||
// public void addOrderRecords(BPA_ORDER_DETAIL group, String type){ | |||
// if(group==null||type==null||type.isEmpty()){ | |||
// return; | |||
// } | |||
// ThreadManager.get().execute(new Thread(()->{ | |||
// try{ | |||
// BPA_ORDER_LIST order = new BPA_ORDER_LIST(); | |||
// order.groupName = group.groupName; | |||
// order.groupId = group.groupId; | |||
// order.goodsName = group.goodsName; | |||
// order.classifyId = group.classifyId; | |||
// order.goodsId = group.goodsId; | |||
// switch (type){ | |||
// case "完成": | |||
// order.status = 1; | |||
// break; | |||
// case "取消": | |||
// order.status = 2; | |||
// break; | |||
// case "异常": | |||
// order.status = 3; | |||
// break; | |||
// } | |||
// OrderListUtil.add(order); | |||
// }catch (Exception e){ | |||
// e.printStackTrace(); | |||
// } | |||
// })); | |||
// } | |||
} |
@@ -3,6 +3,10 @@ package com.jdzh.jdzhandroid; | |||
import android.annotation.SuppressLint; | |||
import android.graphics.drawable.ColorDrawable; | |||
import android.os.Bundle; | |||
import android.os.Environment; | |||
import android.os.Handler; | |||
import android.os.Looper; | |||
import android.os.Message; | |||
import android.view.KeyEvent; | |||
import android.view.View; | |||
import android.view.WindowManager; | |||
@@ -10,6 +14,7 @@ import android.view.WindowManager; | |||
import androidx.activity.ComponentActivity; | |||
import androidx.activity.EdgeToEdge; | |||
import androidx.annotation.NonNull; | |||
import androidx.appcompat.app.ActionBarDrawerToggle; | |||
import androidx.appcompat.app.AppCompatActivity; | |||
import androidx.core.graphics.Insets; | |||
@@ -17,10 +22,18 @@ import androidx.core.view.GravityCompat; | |||
import androidx.core.view.ViewCompat; | |||
import androidx.core.view.WindowInsetsCompat; | |||
import com.apkfuns.logutils.LogUtils; | |||
import com.jdzh.jdzhandroid.Business.ElectoronicScales; | |||
import com.jdzh.jdzhandroid.Business.Global; | |||
import com.jdzh.jdzhandroid.Business.PlcControl; | |||
import com.jdzh.jdzhandroid.Business.RecipeModeMgr; | |||
import com.jdzh.jdzhandroid.Config.Config; | |||
import com.jdzh.jdzhandroid.Enum.DialogButton; | |||
import com.jdzh.jdzhandroid.Enum.LogType; | |||
import com.jdzh.jdzhandroid.Interface.IRunT; | |||
import com.jdzh.jdzhandroid.Log.RecordManager; | |||
import com.jdzh.jdzhandroid.Sqlite.Model.BPA_LogRecord; | |||
import com.jdzh.jdzhandroid.Sqlite.SqliteHelper; | |||
import com.jdzh.jdzhandroid.Task.Task; | |||
import com.jdzh.jdzhandroid.Test.EnumParse; | |||
import com.jdzh.jdzhandroid.UI.fragment.DebugFragment; | |||
@@ -29,14 +42,37 @@ import com.jdzh.jdzhandroid.UI.fragment.ParSetFragment; | |||
import com.jdzh.jdzhandroid.UI.fragment.RecordFragment; | |||
import com.jdzh.jdzhandroid.UI.fragment.SystemSetFragment; | |||
import com.jdzh.jdzhandroid.databinding.ActivityMainBinding; | |||
import com.jdzh.jdzhandroid.util.Dialog.DialogManager; | |||
import com.jdzh.jdzhandroid.util.DisplayManager; | |||
import com.jdzh.jdzhandroid.util.FileUtil; | |||
import com.jdzh.jdzhandroid.util.GlobalContext; | |||
import com.jdzh.jdzhandroid.util.PreferenceUtils; | |||
import java.io.File; | |||
public class MainActivity extends AppCompatActivity { | |||
private ActivityMainBinding binding; | |||
private ActionBarDrawerToggle mDrawerToggle; | |||
private boolean isFileWarn = false;//数据文件太大警告 | |||
private Handler handler = new Handler(Looper.getMainLooper()){ | |||
@Override | |||
public void handleMessage(@NonNull Message msg) { | |||
super.handleMessage(msg); | |||
if(msg.what==1){ | |||
if(hasMessages(1)){ | |||
removeMessages(1); | |||
} | |||
sendEmptyMessageDelayed(1,500); | |||
binding.tvBarRecipeMode.setText(Config.getInstance().isWeight?"计量模式":"配方模式"); | |||
binding.weight.setText("当前重量:"+Global.currentWeight.getValue()); | |||
binding.plcStatus.setText(PlcControl.get().ConnectStatus.getValue()?"PLC设备:已连接":"PLC设备:未连接"); | |||
binding.electoronicScalesStatus.setText(ElectoronicScales.get().ConnectStatus.getValue()?"电子秤:已连接":"电子秤:未连接"); | |||
} | |||
} | |||
}; | |||
@SuppressLint("ResourceAsColor") | |||
@Override | |||
protected void onCreate(Bundle savedInstanceState) { | |||
@@ -50,7 +86,7 @@ public class MainActivity extends AppCompatActivity { | |||
v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom); | |||
return insets; | |||
}); | |||
Config.getInstance().account = PreferenceUtils.getString(Config.SHARE_KEY_account,""); | |||
//初始化首页显示 | |||
getSupportFragmentManager().beginTransaction().replace(R.id.fragmentContainerView,new HomeFragment()).commit(); | |||
binding.navigationView.setCheckedItem(R.id.home);//显示Home页选中状态 | |||
@@ -103,6 +139,44 @@ public class MainActivity extends AppCompatActivity { | |||
EnumParse.aa(); | |||
} | |||
@Override | |||
protected void onStop() { | |||
super.onStop(); | |||
handler.removeCallbacksAndMessages(null); | |||
} | |||
@Override | |||
protected void onResume() { | |||
super.onResume(); | |||
handler.sendEmptyMessageDelayed(1,500); | |||
if(!isFileWarn){ | |||
long folderSize = FileUtil.getFolderSize(new File(Environment.getExternalStorageDirectory().getAbsolutePath()+"/jdzhdb")); | |||
LogUtils.d(" /jdzhdb folderSize="+folderSize); | |||
if(folderSize>1024*100*1024){//1024*1024*100 | |||
LogUtils.d(" /jdzhdb folderSize>"+folderSize); | |||
handler.postDelayed(new Runnable() { | |||
@Override | |||
public void run() { | |||
isFileWarn = true; | |||
DialogManager.showWarn("日志文件大小超过100MB,是否清除日志记录?", DialogButton.YesNo, new IRunT<Boolean>() { | |||
@Override | |||
public void Run(Boolean aBoolean) { | |||
if(aBoolean){ | |||
SqliteHelper.get().deleteAll(BPA_LogRecord.class); | |||
RecordManager.getInstance().addLogRecord(LogType.角色操作,"数据文件大于100Mb 提示删除"); | |||
RecordManager.getInstance().addLogRecord(LogType.角色操作,"数据文件大于100Mb 删除日志记录"); | |||
}else { | |||
RecordManager.getInstance().addLogRecord(LogType.角色操作,"数据文件大于100Mb 提示删除 - 取消"); | |||
} | |||
} | |||
}); | |||
} | |||
},2000); | |||
} | |||
} | |||
} | |||
@Override | |||
@@ -118,21 +192,21 @@ public class MainActivity extends AppCompatActivity { | |||
* 设备初始化 | |||
*/ | |||
private void deviceInit(){ | |||
Global.currentWeight.ChangeNotify=(s)->{ | |||
this.runOnUiThread(()->{ | |||
binding.weight.setText("当前重量:"+s); | |||
}); | |||
}; | |||
PlcControl.get().ConnectStatus.ChangeNotify=(s)->{ | |||
this.runOnUiThread(()->{ | |||
binding.plcStatus.setText(s?"PLC设备:已连接":"PLC设备:未连接"); | |||
}); | |||
}; | |||
ElectoronicScales.get().ConnectStatus.ChangeNotify=(s)->{ | |||
this.runOnUiThread(()->{ | |||
binding.electoronicScalesStatus.setText(s?"电子秤:已连接":"电子秤:未连接"); | |||
}); | |||
}; | |||
// Global.currentWeight.ChangeNotify=(s)->{ | |||
// this.runOnUiThread(()->{ | |||
// binding.weight.setText("当前重量:"+s); | |||
// }); | |||
// }; | |||
// PlcControl.get().ConnectStatus.ChangeNotify=(s)->{ | |||
// this.runOnUiThread(()->{ | |||
// binding.plcStatus.setText(s?"PLC设备:已连接":"PLC设备:未连接"); | |||
// }); | |||
// }; | |||
// ElectoronicScales.get().ConnectStatus.ChangeNotify=(s)->{ | |||
// this.runOnUiThread(()->{ | |||
// binding.electoronicScalesStatus.setText(s?"电子秤:已连接":"电子秤:未连接"); | |||
// }); | |||
// }; | |||
Task.Run(()->{PlcControl.get().start();}); | |||
Task.Run(()->{ ElectoronicScales.get().start();}); | |||
} | |||
@@ -59,7 +59,6 @@ public class MainApplication extends Application { | |||
@Override | |||
public void onActivityCreated(@NonNull Activity activity, @Nullable Bundle bundle) { | |||
GlobalContext.setActivity(activity); | |||
MessageLog.ShowInfo("1111"); | |||
} | |||
@Override | |||
@@ -70,7 +69,6 @@ public class MainApplication extends Application { | |||
@Override | |||
public void onActivityResumed(@NonNull Activity activity) { | |||
GlobalContext.setActivity(activity); | |||
MessageLog.ShowInfo("3333"); | |||
} | |||
@Override | |||
@@ -0,0 +1,15 @@ | |||
package com.jdzh.jdzhandroid.Receiver; | |||
import android.content.BroadcastReceiver; | |||
import android.content.Context; | |||
import android.content.Intent; | |||
public class BootReceiver extends BroadcastReceiver { | |||
@Override | |||
public void onReceive(Context context, Intent intent) { | |||
if (intent.getAction().equals("android.intent.action.BOOT_COMPLETED")) { | |||
Intent toIntent = context.getPackageManager().getLaunchIntentForPackage(context.getPackageName()); | |||
context.startActivity(toIntent); | |||
} | |||
} | |||
} |
@@ -0,0 +1,89 @@ | |||
package com.jdzh.jdzhandroid.Sqlite.Model; | |||
import org.greenrobot.greendao.annotation.Entity; | |||
import org.greenrobot.greendao.annotation.Id; | |||
import java.text.SimpleDateFormat; | |||
import java.util.Date; | |||
import java.util.UUID; | |||
import org.greenrobot.greendao.annotation.Generated; | |||
/** | |||
* @author: liup | |||
* @description: 记录日志 | |||
* @date: 2024/10/24 9:32. | |||
*/ | |||
@Entity | |||
public class BPA_LogRecord{ | |||
@Id | |||
private String id; | |||
public String typeName; | |||
public String userName; | |||
public int typeId; | |||
public String describe;//日志描述 | |||
public String createAt;//用户名 | |||
public BPA_LogRecord(){ | |||
id= UUID.randomUUID().toString(); | |||
createAt= new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()); | |||
} | |||
@Generated(hash = 1270469972) | |||
public BPA_LogRecord(String id, String typeName, String userName, int typeId, | |||
String describe, String createAt) { | |||
this.id = id; | |||
this.typeName = typeName; | |||
this.userName = userName; | |||
this.typeId = typeId; | |||
this.describe = describe; | |||
this.createAt = createAt; | |||
} | |||
public String getId() { | |||
return this.id; | |||
} | |||
public void setId(String id) { | |||
this.id = id; | |||
} | |||
public String getTypeName() { | |||
return this.typeName; | |||
} | |||
public void setTypeName(String typeName) { | |||
this.typeName = typeName; | |||
} | |||
public String getUserName() { | |||
return this.userName; | |||
} | |||
public void setUserName(String userName) { | |||
this.userName = userName; | |||
} | |||
public int getTypeId() { | |||
return this.typeId; | |||
} | |||
public void setTypeId(int typeId) { | |||
this.typeId = typeId; | |||
} | |||
public String getDescribe() { | |||
return this.describe; | |||
} | |||
public void setDescribe(String describe) { | |||
this.describe = describe; | |||
} | |||
public String getCreateAt() { | |||
return this.createAt; | |||
} | |||
public void setCreateAt(String createAt) { | |||
this.createAt = createAt; | |||
} | |||
} |
@@ -1,23 +1,18 @@ | |||
package com.jdzh.jdzhandroid.UI.activity; | |||
import android.os.Build; | |||
import android.os.Bundle; | |||
import android.view.MenuItem; | |||
import android.view.View; | |||
import androidx.annotation.NonNull; | |||
import androidx.annotation.Nullable; | |||
import androidx.appcompat.app.ActionBar; | |||
import androidx.appcompat.app.AppCompatActivity; | |||
import androidx.core.graphics.Insets; | |||
import androidx.core.view.ViewCompat; | |||
import androidx.core.view.WindowInsetsCompat; | |||
import com.apkfuns.logutils.LogUtils; | |||
import com.jdzh.jdzhandroid.Enum.LogType; | |||
import com.jdzh.jdzhandroid.Log.RecordManager; | |||
import com.jdzh.jdzhandroid.R; | |||
public class ActivityBase extends AppCompatActivity { | |||
public class BaseActivity extends AppCompatActivity { | |||
@Override | |||
protected void onCreate(@Nullable Bundle savedInstanceState) { | |||
super.onCreate(savedInstanceState); | |||
@@ -26,7 +21,7 @@ public class ActivityBase extends AppCompatActivity { | |||
ActionBar abr = getSupportActionBar(); | |||
if(abr!=null) getSupportActionBar().setDisplayHomeAsUpEnabled(true); | |||
if(getClassName()!=null && !getClassName().isEmpty()){ | |||
RecordManager.getInstance().addLogRecord("页面上报日志",getClassName()+"-启动"); | |||
RecordManager.getInstance().addLogRecord(LogType.页面上报,getClassName()+"-启动"); | |||
} | |||
} | |||
@@ -35,7 +30,7 @@ public class ActivityBase extends AppCompatActivity { | |||
super.onPause(); | |||
LogUtils.d(getClassName()+"生命周期 onPause()"); | |||
if(getClassName()!=null && !getClassName().isEmpty()){ | |||
RecordManager.getInstance().addLogRecord("页面上报日志",getClassName()+"-退出"); | |||
RecordManager.getInstance().addLogRecord(LogType.页面上报,getClassName()+"-退出"); | |||
} | |||
} | |||
@@ -53,7 +48,7 @@ public class ActivityBase extends AppCompatActivity { | |||
protected void onDestroy() { | |||
super.onDestroy(); | |||
if(getClassName()!=null && !getClassName().isEmpty()){ | |||
RecordManager.getInstance().addLogRecord("页面上报日志",getClassName()+"-销毁"); | |||
RecordManager.getInstance().addLogRecord(LogType.页面上报,getClassName()+"-销毁"); | |||
} | |||
} | |||
@@ -11,6 +11,8 @@ import androidx.annotation.Nullable; | |||
import com.apkfuns.logutils.LogUtils; | |||
import com.bigkoo.pickerview.TimePickerView; | |||
import com.jdzh.jdzhandroid.Enum.LogType; | |||
import com.jdzh.jdzhandroid.Log.RecordManager; | |||
import com.jdzh.jdzhandroid.Sqlite.DAO.BPA_RecipeBathingUseDetailDao; | |||
import com.jdzh.jdzhandroid.Sqlite.Model.BPA_Batching; | |||
import com.jdzh.jdzhandroid.Sqlite.Model.BPA_RecipeBathingUseDetail; | |||
@@ -22,7 +24,6 @@ import com.jdzh.jdzhandroid.databinding.FragmentRoundLineChartBinding; | |||
import com.jdzh.jdzhandroid.model.BatchingUseNum; | |||
import com.jdzh.jdzhandroid.model.NameColorBean; | |||
import com.jdzh.jdzhandroid.util.DisplayManager; | |||
import com.jdzh.jdzhandroid.util.PreferenceUtils; | |||
import com.jdzh.jdzhandroid.util.ToastUtil; | |||
import java.text.DecimalFormat; | |||
@@ -51,7 +52,12 @@ import lecho.lib.hellocharts.model.ValueShape; | |||
* @description: 配料1-12月使用统计 折现走势图 饼状图 | |||
* @date: 2024/10/8 16:56. | |||
*/ | |||
public class BatchingRecordActivity extends ActivityBase { | |||
public class BatchingRecordActivity extends BaseActivity { | |||
@Override | |||
protected String getClassName() { | |||
return "BatchingRecordActivity物料记录页"; | |||
} | |||
private FragmentRoundLineChartBinding binding; | |||
private TimePickerView pvTime; | |||
@@ -91,6 +97,8 @@ public class BatchingRecordActivity extends ActivityBase { | |||
adapter.setNewData(nameList); | |||
binding.recycle.setAdapter(adapter); | |||
binding.selectName.setOnClickListener(v->{ | |||
RecordManager.getInstance().addLogRecord(LogType.角色操作,getClassName()+" click选择物料名字"); | |||
BatchingNameListRecordDialog dialog = new BatchingNameListRecordDialog(); | |||
dialog.setListener(new BatchingNameListRecordDialog.OnDialogClickListener() { | |||
@Override | |||
@@ -113,6 +121,7 @@ public class BatchingRecordActivity extends ActivityBase { | |||
binding.starttime.setText( new SimpleDateFormat("yyyy").format(new Date())); | |||
binding.starttime.setOnClickListener(v->{ | |||
RecordManager.getInstance().addLogRecord(LogType.角色操作,getClassName()+" click选择时间"); | |||
if(Config.getInstance().isFastClick()){ | |||
ToastUtil.showInfo("点击过快!"); | |||
return; | |||
@@ -124,6 +133,8 @@ public class BatchingRecordActivity extends ActivityBase { | |||
binding.btnQuery.setVisibility(View.GONE); | |||
binding.btnQuery.setOnClickListener(v->{ | |||
RecordManager.getInstance().addLogRecord(LogType.角色操作,getClassName()+" click查询"); | |||
if(nameList.isEmpty()){ | |||
ToastUtil.showInfo("请至少选择一个配方"); | |||
return; | |||
@@ -5,12 +5,18 @@ import android.view.MenuItem; | |||
import android.view.View; | |||
import androidx.annotation.Nullable; | |||
import androidx.lifecycle.Observer; | |||
import androidx.lifecycle.ViewModelProvider; | |||
import com.apkfuns.logutils.LogUtils; | |||
import com.jdzh.jdzhandroid.Business.PlcControl; | |||
import com.jdzh.jdzhandroid.Enum.DialogButton; | |||
import com.jdzh.jdzhandroid.Enum.LogType; | |||
import com.jdzh.jdzhandroid.Log.RecordManager; | |||
import com.jdzh.jdzhandroid.R; | |||
import com.jdzh.jdzhandroid.Sqlite.DAO.BPA_BatchingDao; | |||
import com.jdzh.jdzhandroid.Sqlite.Model.BPA_Batching; | |||
import com.jdzh.jdzhandroid.Sqlite.SqliteHelper; | |||
import com.jdzh.jdzhandroid.UI.dialog.CalibrationDataDialog; | |||
import com.jdzh.jdzhandroid.databinding.ActivityChannelCalibrationBinding; | |||
import com.jdzh.jdzhandroid.util.Dialog.DialogManager; | |||
@@ -18,11 +24,15 @@ import com.jdzh.jdzhandroid.util.DisplayManager; | |||
import com.jdzh.jdzhandroid.util.ToastUtil; | |||
import com.jdzh.jdzhandroid.viewmodel.ChannelViewModel; | |||
/** | |||
* 通道校准 一键校准 | |||
*/ | |||
public class ChannelCalibrationActivity extends ActivityBase { | |||
public class ChannelCalibrationActivity extends BaseActivity implements View.OnClickListener { | |||
@Override | |||
protected String getClassName() { | |||
return "ChannelCalibrationActivity一键校准页"; | |||
} | |||
private ActivityChannelCalibrationBinding binding; | |||
private ChannelViewModel mViewModel; | |||
@@ -41,19 +51,16 @@ public class ChannelCalibrationActivity extends ActivityBase { | |||
private void initView(){ | |||
binding.progress.setEnabled(false); | |||
binding.progress.setOnTouchListener((v, event) -> true); | |||
mViewModel.progressNum.observe(this, data->{ | |||
binding.llDesc.setVisibility(data==0?View.GONE:View.VISIBLE); | |||
if(data == 0){ | |||
binding.imgCurChannel.setImageResource(0); | |||
}else if(data<=6){ | |||
binding.imgCurChannel.setImageResource(R.mipmap.ic_powder_silo400); | |||
}else if(data<=12){ | |||
binding.imgCurChannel.setImageResource(R.mipmap.ic_matrial_silo300); | |||
}else { | |||
binding.imgCurChannel.setImageResource(0); | |||
mViewModel.progressMax.observe(this, new Observer<Integer>() { | |||
@Override | |||
public void onChanged(Integer integer) { | |||
binding.progress.setMax(integer); | |||
} | |||
}); | |||
binding.btnChartData.setOnClickListener(v->{ | |||
RecordManager.getInstance().addLogRecord(LogType.角色操作,getClassName()+" click查询校准数据"); | |||
if(mViewModel.isCalibrating){ | |||
ToastUtil.showWarn("正在校准中..."); | |||
return; | |||
@@ -61,6 +68,18 @@ public class ChannelCalibrationActivity extends ActivityBase { | |||
CalibrationDataDialog dialog = new CalibrationDataDialog(); | |||
dialog.show(getSupportFragmentManager(),"CalibrationDataDialog"); | |||
}); | |||
binding.img1.setOnClickListener(this); | |||
binding.img2.setOnClickListener(this); | |||
binding.img3.setOnClickListener(this); | |||
binding.img4.setOnClickListener(this); | |||
binding.img5.setOnClickListener(this); | |||
binding.img6.setOnClickListener(this); | |||
binding.img7.setOnClickListener(this); | |||
binding.img8.setOnClickListener(this); | |||
binding.img9.setOnClickListener(this); | |||
binding.img10.setOnClickListener(this); | |||
binding.img11.setOnClickListener(this); | |||
binding.img12.setOnClickListener(this); | |||
} | |||
@Override | |||
@@ -84,4 +103,71 @@ public class ChannelCalibrationActivity extends ActivityBase { | |||
} | |||
} | |||
@Override | |||
public void onClick(View view) { | |||
int num = 0; | |||
switch (view.getId()){ | |||
case R.id.img1: | |||
num = 1; | |||
break; | |||
case R.id.img2: | |||
num = 2; | |||
break; | |||
case R.id.img3: | |||
num = 3; | |||
break; | |||
case R.id.img4: | |||
num = 4; | |||
break; | |||
case R.id.img5: | |||
num = 5; | |||
break; | |||
case R.id.img6: | |||
num = 6; | |||
break; | |||
case R.id.img7: | |||
num =7; | |||
break; | |||
case R.id.img8: | |||
num = 8; | |||
break; | |||
case R.id.img9: | |||
num = 9; | |||
break; | |||
case R.id.img10: | |||
num = 10; | |||
break; | |||
case R.id.img11: | |||
num = 11; | |||
break; | |||
case R.id.img12: | |||
num = 12; | |||
break; | |||
} | |||
RecordManager.getInstance().addLogRecord(LogType.角色操作,getClassName()+" click选中通道"+num); | |||
if(num<=6){ | |||
binding.imgCurChannel.setImageResource(R.mipmap.ic_powder_silo400); | |||
}else{ | |||
binding.imgCurChannel.setImageResource(R.mipmap.ic_matrial_silo300); | |||
} | |||
BPA_Batching batching = SqliteHelper.get().queryByBuilderEntity(BPA_Batching.class, | |||
BPA_BatchingDao.Properties.SiloChannelNum.eq(num > 6?("液体通道"+(num-6)):("粉料通道"+num))); | |||
if(batching!=null){ | |||
binding.btnStart.setText("启动校准#"+(num>6?(num-6):num)); | |||
binding.tvCurChannel.setText(batching.getName()+"-#"+(num>6?(num-6):num)); | |||
mViewModel.channelNum = num; | |||
mViewModel.batchingName = batching.getName(); | |||
mViewModel.type = num>6?2:1; | |||
if(!PlcControl.get().calibrationValue.containsKey(batching.getName())){ | |||
mViewModel.desc.setValue("已选中"+(num>6?"液体":"粉料")+"通道#"+(num>6?(num-6):num)+" 绑定物料:"+batching.getName()+" (无校准数据)"); | |||
}else { | |||
mViewModel.desc.setValue("已选中"+(num>6?"液体":"粉料")+"通道#"+(num>6?(num-6):num)+" 绑定物料:"+batching.getName()+" (有校准数据)"); | |||
} | |||
}else { | |||
ToastUtil.showWarn("该通道未绑定物料,请绑定后重试!"); | |||
} | |||
} | |||
} |
@@ -19,8 +19,11 @@ import com.jdzh.jdzhandroid.viewmodel.ChannelViewModel; | |||
/** | |||
* 通道 一键满管 | |||
*/ | |||
public class ChannelFullActivity extends ActivityBase { | |||
public class ChannelFullActivity extends BaseActivity { | |||
@Override | |||
protected String getClassName() { | |||
return "ChannelFullActivity一键满管页"; | |||
} | |||
private ActivityChannelFullBinding binding; | |||
private ChannelViewModel mViewModel; | |||
@@ -5,23 +5,21 @@ import android.os.Bundle; | |||
import android.view.View; | |||
import androidx.annotation.Nullable; | |||
import androidx.core.graphics.Insets; | |||
import androidx.core.view.ViewCompat; | |||
import androidx.core.view.WindowInsetsCompat; | |||
import com.jdzh.jdzhandroid.R; | |||
import com.jdzh.jdzhandroid.UI.fragment.MaterialSiloFragment; | |||
import com.jdzh.jdzhandroid.UI.fragment.PowderSiloFragment; | |||
import com.jdzh.jdzhandroid.UI.fragment.RecipeUseLineChartFragment; | |||
import com.jdzh.jdzhandroid.UI.fragment.RecipeUseRankFragment; | |||
import com.jdzh.jdzhandroid.databinding.ActivityChannelManagerBinding; | |||
import com.jdzh.jdzhandroid.util.DisplayManager; | |||
/** | |||
* 通道管理 | |||
*/ | |||
public class ChannelManagerActivity extends ActivityBase { | |||
public class ChannelManagerActivity extends BaseActivity { | |||
@Override | |||
protected String getClassName() { | |||
return "ChannelManagerActivity通道管理页"; | |||
} | |||
private ActivityChannelManagerBinding binding; | |||
@Override | |||
@@ -0,0 +1,265 @@ | |||
package com.jdzh.jdzhandroid.UI.activity; | |||
import android.annotation.SuppressLint; | |||
import android.graphics.Color; | |||
import android.os.Bundle; | |||
import android.os.Environment; | |||
import android.view.View; | |||
import android.view.ViewGroup; | |||
import android.widget.ArrayAdapter; | |||
import android.widget.TextView; | |||
import androidx.annotation.NonNull; | |||
import com.apkfuns.logutils.LogUtils; | |||
import com.bigkoo.pickerview.TimePickerView; | |||
import com.jdzh.jdzhandroid.Config.Config; | |||
import com.jdzh.jdzhandroid.Enum.DialogButton; | |||
import com.jdzh.jdzhandroid.Enum.LogType; | |||
import com.jdzh.jdzhandroid.Interface.IRunT; | |||
import com.jdzh.jdzhandroid.Log.RecordManager; | |||
import com.jdzh.jdzhandroid.R; | |||
import com.jdzh.jdzhandroid.Sqlite.DAO.BPA_LogRecordDao; | |||
import com.jdzh.jdzhandroid.Sqlite.Model.BPA_LogRecord; | |||
import com.jdzh.jdzhandroid.Sqlite.SqliteHelper; | |||
import com.jdzh.jdzhandroid.Task.TaskManager; | |||
import com.jdzh.jdzhandroid.UI.adapter.record.LocalLogAdapter; | |||
import com.jdzh.jdzhandroid.databinding.ActivityLogRecordBinding; | |||
import com.jdzh.jdzhandroid.util.DateUtils; | |||
import com.jdzh.jdzhandroid.util.Dialog.DialogManager; | |||
import com.jdzh.jdzhandroid.util.DisplayManager; | |||
import com.jdzh.jdzhandroid.util.FileUtil; | |||
import com.jdzh.jdzhandroid.util.ToastUtil; | |||
import java.io.File; | |||
import java.text.DecimalFormat; | |||
import java.text.SimpleDateFormat; | |||
import java.util.ArrayList; | |||
import java.util.Calendar; | |||
import java.util.Date; | |||
import java.util.List; | |||
/** | |||
* 日志页面 | |||
*/ | |||
public class LogRecordActivity extends BaseActivity { | |||
@NonNull | |||
@Override | |||
public String getLocalClassName() { | |||
return "日志页面LogRecordActivity"; | |||
} | |||
private ActivityLogRecordBinding viewBinding; | |||
/** | |||
* 日志数据 | |||
*/ | |||
ArrayList<BPA_LogRecord> dataLogs = new ArrayList<>(); | |||
private LocalLogAdapter adapter; | |||
/** | |||
* 日志类型 | |||
*/ | |||
List<String> typeMap = new ArrayList<>(); | |||
private TimePickerView pvTime; | |||
private ViewGroup view; | |||
@Override | |||
protected void onCreate(Bundle savedInstanceState) { | |||
super.onCreate(savedInstanceState); | |||
viewBinding = ActivityLogRecordBinding.inflate(getLayoutInflater()); | |||
setContentView(viewBinding.getRoot()); | |||
view=(ViewGroup)getWindow().getDecorView(); | |||
DisplayManager.scaleViewGroup(viewBinding.getRoot()); | |||
Init(); | |||
} | |||
@Override | |||
protected void onResume() { | |||
super.onResume(); | |||
} | |||
/** | |||
* 初始化 | |||
*/ | |||
@SuppressLint("SimpleDateFormat") | |||
private void Init(){ | |||
viewBinding.btnQuery.requestFocus(); | |||
viewBinding.tvFileSize.setText("缓存大小:"+ FileUtil.getCacheSize()); | |||
viewBinding.btnDeleteAll.setVisibility(Config.getInstance().adminType==0?View.GONE:View.VISIBLE); | |||
viewBinding.btnDeleteAll.setOnClickListener(v->{ | |||
DialogManager.showWarn("是否删除本地所有日志记录?", DialogButton.YesNo, new IRunT<Boolean>() { | |||
@Override | |||
public void Run(Boolean aBoolean) { | |||
if(aBoolean){ | |||
SqliteHelper.get().deleteAll(BPA_LogRecord.class); | |||
RecordManager.getInstance().addLogRecord(LogType.角色操作,"删除所有日志记录"); | |||
Initdata(); | |||
viewBinding.tvFileSize.setText("缓存大小:"+FileUtil.getCacheSize()); | |||
} | |||
} | |||
}); | |||
}); | |||
typeMap.add("全部日志"); | |||
typeMap.add("登录"); | |||
typeMap.add("角色操作"); | |||
typeMap.add("数据接收"); | |||
typeMap.add("数据上传"); | |||
typeMap.add("订单处理"); | |||
typeMap.add("设备异常"); | |||
typeMap.add("页面上报"); | |||
typeMap.add("配方编辑"); | |||
typeMap.add("plc记录"); | |||
viewBinding.btnQuery.setOnClickListener(v->{ | |||
if(Config.getInstance().isFastClick()){ | |||
ToastUtil.showWarn("点击过快!"); | |||
return; | |||
} | |||
Initdata(); | |||
}); | |||
ArrayAdapter<String> adapter2 = new ArrayAdapter<>(this, R.layout.spinner_text_item,typeMap); | |||
adapter2.setDropDownViewResource(R.layout.spinner_dropdown_item); | |||
viewBinding.spinner.setAdapter(adapter2); | |||
viewBinding.starttime.setText( new SimpleDateFormat("yyyy-MM-dd 00:00:00").format(new Date())); | |||
viewBinding.stoptime.setText(new SimpleDateFormat("yyyy-MM-dd 23:59:59").format(new Date())); | |||
viewBinding.starttime.setOnClickListener(new View.OnClickListener() { | |||
@Override | |||
public void onClick(View view) { | |||
if(Config.getInstance().isFastClick()){ | |||
ToastUtil.showWarn("点击过快!"); | |||
return; | |||
} | |||
if (pvTime != null) { | |||
pvTime.show(viewBinding.starttime); | |||
} | |||
} | |||
}); | |||
viewBinding.stoptime.setOnClickListener(new View.OnClickListener() { | |||
@Override | |||
public void onClick(View view) { | |||
if(Config.getInstance().isFastClick()){ | |||
ToastUtil.showWarn("点击过快!"); | |||
return; | |||
} | |||
if (pvTime != null) { | |||
pvTime.show(viewBinding.stoptime); | |||
} | |||
} | |||
}); | |||
adapter = new LocalLogAdapter(); | |||
adapter.setCallBack(new LocalLogAdapter.ClickCallBack() { | |||
@Override | |||
public void onDescClick(View v, int position) { | |||
DialogManager.showWarn(adapter.getData().get(position).getTypeName()+"\n"+adapter.getData().get(position).describe+"", | |||
DialogButton.OK,null); | |||
} | |||
}); | |||
adapter.setNewData(dataLogs); | |||
viewBinding.recycleView.setAdapter(adapter); | |||
CalendarTime(); | |||
Initdata(); | |||
} | |||
/** | |||
* CalendarTime | |||
* 时间选择器 | |||
*/ | |||
public void CalendarTime() { | |||
//控制时间范围(如果不设置范围,则使用默认时间1900-2100年,此段代码可注释) | |||
//因为系统Calendar的月份是从0-11的,所以如果是调用Calendar的set方法来设置时间,月份的范围也要是从0-11 | |||
Calendar selectedDate = Calendar.getInstance(); | |||
Calendar startDate = Calendar.getInstance(); | |||
startDate.set(2023, 0, 23); | |||
Calendar endDate = Calendar.getInstance(); | |||
endDate.set(2099, 11, 28); | |||
//时间选择器 | |||
pvTime = new TimePickerView.Builder(this, new TimePickerView.OnTimeSelectListener() { | |||
@Override | |||
public void onTimeSelect(Date date, View v) {//选中事件回调 | |||
// 这里回调过来的v,就是show()方法里面所添加的 View 参数,如果show的时候没有添加参数,v则为null | |||
TextView btn = (TextView) v; | |||
String time = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(date); | |||
btn.setText(time); | |||
} | |||
}) | |||
//年月日时分秒 的显示与否,不设置则默认全部显示 | |||
.setType(new boolean[]{true, true, true, true, true, true}) | |||
.setLabel("年", "月", "日", "时", "分", "秒") | |||
.isCenterLabel(true) | |||
.setDividerColor(Color.DKGRAY) | |||
.setContentSize(26)//字号 | |||
.setDate(selectedDate) | |||
.setRangDate(startDate, endDate) | |||
.setDecorView(view) | |||
.build(); | |||
} | |||
/** | |||
* 初始化数据加载 | |||
*/ | |||
public void Initdata() { | |||
try { | |||
if(DateUtils.compareDate( viewBinding.stoptime.getText().toString(),viewBinding.starttime.getText().toString())) | |||
{ | |||
ToastUtil.showWarn("开始时间不能大于结束时间!!!"); | |||
return; | |||
} | |||
TaskManager.get().execute(new Runnable() { | |||
@Override | |||
public void run() { | |||
String lx= viewBinding.spinner.getSelectedItem().toString(); | |||
String text= viewBinding.edittext.getText().toString(); | |||
dataLogs.clear(); | |||
if(lx.equals("全部日志")){ | |||
dataLogs.addAll(SqliteHelper.get().queryByQueryBuilder(BPA_LogRecord.class, | |||
BPA_LogRecordDao.Properties.CreateAt.ge(viewBinding.starttime.getText().toString()), | |||
BPA_LogRecordDao.Properties.CreateAt.le(viewBinding.stoptime.getText().toString()), | |||
BPA_LogRecordDao.Properties.Describe.like("%"+text+"%") | |||
)); | |||
}else { | |||
dataLogs.addAll(SqliteHelper.get().queryByQueryBuilder(BPA_LogRecord.class, | |||
BPA_LogRecordDao.Properties.CreateAt.ge(viewBinding.starttime.getText().toString()), | |||
BPA_LogRecordDao.Properties.CreateAt.le(viewBinding.stoptime.getText().toString()), | |||
BPA_LogRecordDao.Properties.TypeName.eq(lx), | |||
BPA_LogRecordDao.Properties.Describe.like("%"+text+"%") | |||
)); | |||
} | |||
runOnUiThread(()->{ | |||
if(adapter!=null){ | |||
adapter.notifyDataSetChanged(); | |||
} | |||
}); | |||
} | |||
}); | |||
} catch (Exception e) { | |||
} | |||
} | |||
@Override | |||
public void onDestroy() { | |||
super.onDestroy(); | |||
if(dataLogs!=null){ | |||
dataLogs.clear(); | |||
dataLogs = null; | |||
} | |||
if(adapter!=null){ | |||
adapter = null; | |||
} | |||
viewBinding.recycleView.setAdapter(null); | |||
viewBinding.spinner.setAdapter(null); | |||
if(typeMap!=null){ | |||
typeMap.clear(); | |||
typeMap = null; | |||
} | |||
} | |||
} |
@@ -13,15 +13,15 @@ import android.view.WindowManager; | |||
import android.widget.EditText; | |||
import android.widget.ImageView; | |||
import androidx.appcompat.app.AppCompatActivity; | |||
import androidx.core.graphics.Insets; | |||
import androidx.core.view.ViewCompat; | |||
import androidx.core.view.WindowInsetsCompat; | |||
import androidx.lifecycle.LifecycleObserver; | |||
import com.apkfuns.logutils.LogUtils; | |||
import com.jdzh.jdzhandroid.Config.Config; | |||
import com.jdzh.jdzhandroid.Enum.DialogButton; | |||
import com.jdzh.jdzhandroid.Enum.LogType; | |||
import com.jdzh.jdzhandroid.Log.RecordManager; | |||
import com.jdzh.jdzhandroid.MainActivity; | |||
import com.jdzh.jdzhandroid.R; | |||
import com.jdzh.jdzhandroid.Sqlite.DAO.BPA_UserInfoDao; | |||
@@ -31,7 +31,6 @@ import com.jdzh.jdzhandroid.UI.view.WaitProcessUtil; | |||
import com.jdzh.jdzhandroid.api.IHttpCallBack; | |||
import com.jdzh.jdzhandroid.api.ServerManager; | |||
import com.jdzh.jdzhandroid.databinding.ActivityLoginBinding; | |||
import com.jdzh.jdzhandroid.databinding.ActivityWelcomeBinding; | |||
import com.jdzh.jdzhandroid.model.get.UsersDataBean; | |||
import com.jdzh.jdzhandroid.util.Dialog.DialogManager; | |||
import com.jdzh.jdzhandroid.util.DisplayManager; | |||
@@ -45,8 +44,11 @@ import java.util.ArrayList; | |||
import java.util.List; | |||
public class LoginActivity extends AppCompatActivity { | |||
public class LoginActivity extends BaseActivity { | |||
@Override | |||
protected String getClassName() { | |||
return "LoginActivity登录页"; | |||
} | |||
private ActivityLoginBinding binding; | |||
private boolean isGetUser = false; | |||
@SuppressLint("ResourceAsColor") | |||
@@ -129,12 +131,15 @@ public class LoginActivity extends AppCompatActivity { | |||
} | |||
private void startLogin(){ | |||
RecordManager.getInstance().addLogRecord(LogType.登录,getClassName()+" 开始登录startLogin"); | |||
if(binding.etAccount.getText().toString().equals("admin")&&binding.etPassword.getText().toString().equals("hbl123456")){ | |||
ToastUtil.showInfo("管理员登录成功!"); | |||
RecordManager.getInstance().addLogRecord(LogType.登录,getClassName()+" admin hbl123456 管理员登录成功"); | |||
KeyboardToolUtils.hideSoftInput(this); | |||
Config.getInstance().isLogin = true; | |||
Intent intent = new Intent(this, MainActivity.class); | |||
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP|Intent.FLAG_ACTIVITY_NEW_TASK); | |||
startActivity(intent); | |||
ToastUtil.showInfo("管理员登录成功!"); | |||
PreferenceUtils.setString(Config.SHARE_KEY_account,binding.etAccount.getText().toString()); | |||
PreferenceUtils.setString(Config.SHARE_KEY_password,binding.etPassword.getText().toString()); | |||
finish(); | |||
@@ -147,12 +152,15 @@ public class LoginActivity extends AppCompatActivity { | |||
); | |||
if(userInfo!=null){ | |||
RecordManager.getInstance().addLogRecord(LogType.登录,getClassName()+" 验证本地账号数据成功"); | |||
ToastUtil.showInfo("登录成功!"); | |||
// 隐藏软键盘 | |||
KeyboardToolUtils.hideSoftInput(this); | |||
Config.getInstance().isLogin = true; | |||
Intent intent = new Intent(this, MainActivity.class); | |||
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP|Intent.FLAG_ACTIVITY_NEW_TASK); | |||
startActivity(intent); | |||
ToastUtil.showInfo("登录成功!"); | |||
PreferenceUtils.setString(Config.SHARE_KEY_account,binding.etAccount.getText().toString()); | |||
PreferenceUtils.setString(Config.SHARE_KEY_password,binding.etPassword.getText().toString()); | |||
PreferenceUtils.setInt(Config.SHARE_KEY_adminType,userInfo.getAdminType()); | |||
@@ -170,6 +178,7 @@ public class LoginActivity extends AppCompatActivity { | |||
* 获取账号信息 | |||
*/ | |||
private void getUserInfo(){ | |||
RecordManager.getInstance().addLogRecord(LogType.登录,getClassName()+" 验证本地账号数据失败 请求账号信息接口"); | |||
WaitProcessUtil.getInstance().show(this,"请稍等","正在请求登录接口,请耐心等待...",false); | |||
ServerManager.getUsers(new IHttpCallBack<ArrayList<UsersDataBean>>() { | |||
@Override | |||
@@ -194,17 +203,22 @@ public class LoginActivity extends AppCompatActivity { | |||
} | |||
WaitProcessUtil.getInstance().dismiss(); | |||
startLogin(); | |||
RecordManager.getInstance().addLogRecord(LogType.数据接收,"登录接口请求成功"); | |||
RecordManager.getInstance().addLogRecord(LogType.登录,getClassName()+" 将云端账号信息写入本地"); | |||
} | |||
@Override | |||
public void onError(int failCode, String msg) { | |||
DialogManager.showWarn("登录接口请求报错:failCode="+failCode+"description="+msg, DialogButton.OK,null); | |||
WaitProcessUtil.getInstance().dismiss(); | |||
RecordManager.getInstance().addLogRecord(LogType.数据接收,"登录接口请求报错:failCode="+failCode+"description="+msg); | |||
} | |||
@Override | |||
public void onFailed(int failCode, Throwable throwable, String message) { | |||
DialogManager.showWarn("登录接口请求失败:failCode="+failCode+" description="+message, DialogButton.OK,null); | |||
RecordManager.getInstance().addLogRecord(LogType.数据接收,"登录接口请求失败:failCode="+failCode+" description="+message); | |||
WaitProcessUtil.getInstance().dismiss(); | |||
} | |||
}); | |||
@@ -7,7 +7,9 @@ import androidx.annotation.Nullable; | |||
import androidx.recyclerview.widget.LinearLayoutManager; | |||
import com.jdzh.jdzhandroid.Enum.DialogButton; | |||
import com.jdzh.jdzhandroid.Enum.LogType; | |||
import com.jdzh.jdzhandroid.Enum.SiloChannel; | |||
import com.jdzh.jdzhandroid.Log.RecordManager; | |||
import com.jdzh.jdzhandroid.Sqlite.DAO.BPA_BatchingDao; | |||
import com.jdzh.jdzhandroid.Sqlite.Model.BPA_Batching; | |||
import com.jdzh.jdzhandroid.Sqlite.SqliteHelper; | |||
@@ -24,8 +26,11 @@ import java.util.ArrayList; | |||
import java.util.List; | |||
import java.util.concurrent.atomic.AtomicBoolean; | |||
public class MaterialManagerActivity extends ActivityBase { | |||
public class MaterialManagerActivity extends BaseActivity { | |||
@Override | |||
protected String getClassName() { | |||
return "MaterialManagerActivity物料管理页"; | |||
} | |||
private ActivityMaterialBinding binding; | |||
private MaterialAdapter recipeAdapter=new MaterialAdapter(); | |||
@@ -67,15 +72,18 @@ public class MaterialManagerActivity extends ActivityBase { | |||
if(batchingWC2==null){ | |||
SqliteHelper.get().insert(s.Content); | |||
ToastUtil.showInfo("添加物料成功"); | |||
RecordManager.getInstance().addLogRecord(LogType.角色操作,getClassName()+" 添加物料成功"); | |||
} | |||
else{ | |||
AtomicBoolean isExit=new AtomicBoolean(false); | |||
AlertDialogUtil.show("该料仓已绑定到物料-["+batchingWC2.getName()+"]-上,是否重置绑定关系?",DialogButton.YesNo,(res->{ | |||
RecordManager.getInstance().addLogRecord(LogType.角色操作,getClassName()+" 该料仓已绑定到物料-["+batchingWC2.getName()+"]-上,是否重置绑定关系? res="+res); | |||
if(res){ | |||
batchingWC2.setSiloChannelNum(SiloChannel.未设置.toString()); | |||
SqliteHelper.get().update(batchingWC2); | |||
SqliteHelper.get().insert(s.Content); | |||
ToastUtil.showInfo("添加物料成功"); | |||
RecordManager.getInstance().addLogRecord(LogType.角色操作,getClassName()+" 添加物料成功"); | |||
}else{ | |||
isExit.set(true); | |||
} | |||
@@ -10,6 +10,8 @@ import androidx.annotation.Nullable; | |||
import com.apkfuns.logutils.LogUtils; | |||
import com.bigkoo.pickerview.TimePickerView; | |||
import com.jdzh.jdzhandroid.Enum.LogType; | |||
import com.jdzh.jdzhandroid.Log.RecordManager; | |||
import com.jdzh.jdzhandroid.Sqlite.DAO.BPA_RecipeUseDetailDao; | |||
import com.jdzh.jdzhandroid.Sqlite.Model.BPA_RecipeInfo; | |||
import com.jdzh.jdzhandroid.Sqlite.Model.BPA_RecipeUseDetail; | |||
@@ -28,8 +30,11 @@ import java.util.Calendar; | |||
import java.util.Date; | |||
import java.util.List; | |||
public class RecipeBillingActivity extends ActivityBase { | |||
public class RecipeBillingActivity extends BaseActivity { | |||
@Override | |||
protected String getClassName() { | |||
return "RecipeBillingActivity配方流水页"; | |||
} | |||
private ActivityRecipeBillingBinding binding; | |||
private RecipeBillingAdapter adapter; | |||
private List<BPA_RecipeUseDetail> recipeUseDetails = new ArrayList<>(); | |||
@@ -63,6 +68,7 @@ public class RecipeBillingActivity extends ActivityBase { | |||
binding.starttime.setText( new SimpleDateFormat("yyyy-MM-01 00:00:00").format(new Date())); | |||
binding.endtime.setText(new SimpleDateFormat("yyyy-MM-dd 23:59:59").format(new Date())); | |||
binding.starttime.setOnClickListener(v->{ | |||
if(Config.getInstance().isFastClick()){ | |||
ToastUtil.showInfo("点击过快!"); | |||
return; | |||
@@ -86,6 +92,7 @@ public class RecipeBillingActivity extends ActivityBase { | |||
ToastUtil.showInfo("开始时间不能大于结束时间!!!"); | |||
return; | |||
} | |||
RecordManager.getInstance().addLogRecord(LogType.角色操作,getClassName()+" click查询"); | |||
initData(); | |||
}); | |||
List<BPA_RecipeInfo> recipeInfos = SqliteHelper.get().queryAll(BPA_RecipeInfo.class); | |||
@@ -94,6 +101,7 @@ public class RecipeBillingActivity extends ActivityBase { | |||
binding.recipeName1.setText(recipeInfos.get(0).getName()); | |||
} | |||
binding.recipeName1.setOnClickListener(v->{ | |||
RecordManager.getInstance().addLogRecord(LogType.角色操作,getClassName()+" click选择配方名"); | |||
RecipeNameRecordDialog dialog = new RecipeNameRecordDialog(this); | |||
dialog.setListener(new RecipeNameRecordDialog.OnDialogClickListener() { | |||
@Override | |||
@@ -4,15 +4,21 @@ import android.app.AlertDialog; | |||
import android.content.Context; | |||
import android.graphics.Rect; | |||
import android.os.Bundle; | |||
import android.os.Handler; | |||
import android.os.Looper; | |||
import android.os.Message; | |||
import android.util.DisplayMetrics; | |||
import android.view.View; | |||
import androidx.annotation.NonNull; | |||
import androidx.annotation.Nullable; | |||
import androidx.recyclerview.widget.GridLayoutManager; | |||
import androidx.recyclerview.widget.LinearLayoutManager; | |||
import androidx.recyclerview.widget.RecyclerView; | |||
import com.apkfuns.logutils.LogUtils; | |||
import com.jdzh.jdzhandroid.Enum.LogType; | |||
import com.jdzh.jdzhandroid.Log.RecordManager; | |||
import com.jdzh.jdzhandroid.R; | |||
import com.jdzh.jdzhandroid.Sqlite.DAO.BPA_RecipeConfigDao; | |||
import com.jdzh.jdzhandroid.Sqlite.DAO.BPA_RecipeConfigDetailDao; | |||
@@ -23,6 +29,7 @@ import com.jdzh.jdzhandroid.Sqlite.Model.BPA_RecipeConfigDetail; | |||
import com.jdzh.jdzhandroid.Sqlite.Model.BPA_RecipeGroup; | |||
import com.jdzh.jdzhandroid.Sqlite.Model.BPA_RecipeInfo; | |||
import com.jdzh.jdzhandroid.Sqlite.SqliteHelper; | |||
import com.jdzh.jdzhandroid.Task.TaskManager; | |||
import com.jdzh.jdzhandroid.UI.adapter.edit.RecipeEditAdapter; | |||
import com.jdzh.jdzhandroid.UI.adapter.edit.RecipeGroupEditAdapter; | |||
import com.jdzh.jdzhandroid.UI.dialog.RecipeEditDialog; | |||
@@ -35,8 +42,11 @@ import com.jdzh.jdzhandroid.util.ToastUtil; | |||
import java.util.ArrayList; | |||
import java.util.List; | |||
public class RecipeManagerActivity extends ActivityBase { | |||
public class RecipeManagerActivity extends BaseActivity { | |||
@Override | |||
protected String getClassName() { | |||
return "RecipeManagerActivity配方管理页"; | |||
} | |||
private ActivityRecipeManagerBinding binding; | |||
private RecipeGroupEditAdapter menuGourpAdapter; | |||
private RecipeEditAdapter recipeAdapter; | |||
@@ -45,7 +55,12 @@ public class RecipeManagerActivity extends ActivityBase { | |||
private List<BPA_RecipeGroup> recipeGroups = new ArrayList<>(); | |||
private List<BPA_RecipeInfo> recipeInfos = new ArrayList<>(); | |||
private List<BPA_RecipeInfo> recipeInfoAll = new ArrayList<>(); | |||
private int recipeType= 1; | |||
private Handler handler = new Handler(Looper.getMainLooper()){ | |||
@Override | |||
public void handleMessage(@NonNull Message msg) { | |||
super.handleMessage(msg); | |||
} | |||
}; | |||
public static RecipeManagerActivity newInstance() { | |||
return new RecipeManagerActivity(); | |||
@@ -61,56 +76,85 @@ public class RecipeManagerActivity extends ActivityBase { | |||
mContext=this; | |||
initData(); | |||
binding.btnGroupAdd.setOnClickListener(view -> { | |||
List<BPA_RecipeGroup> groups = SqliteHelper.get().queryByBuilder(BPA_RecipeGroup.class, | |||
BPA_RecipeGroupDao.Properties.IsWeight.eq(Config.getInstance().isWeight)); | |||
List<String> nameList = new ArrayList<>(); | |||
for(BPA_RecipeGroup bean:groups){ | |||
nameList.add(bean.getName()); | |||
if(Config.getInstance().isFastClick()){ | |||
ToastUtil.showWarn("请勿点击过快"); | |||
return; | |||
} | |||
RecordManager.getInstance().addLogRecord(LogType.角色操作,getClassName()+" click添加配方分组 自动添加一页配方"); | |||
TaskManager.get().execute(()->{ | |||
ToastUtil.showInfo("正在添加分组..."); | |||
List<BPA_RecipeGroup> groups = SqliteHelper.get().queryByBuilder(BPA_RecipeGroup.class, | |||
BPA_RecipeGroupDao.Properties.IsWeight.eq(Config.getInstance().isWeight)); | |||
List<String> nameList = new ArrayList<>(); | |||
for(BPA_RecipeGroup bean:groups){ | |||
nameList.add(bean.getName()); | |||
} | |||
String name = "未命名1"; | |||
for(int i=1;i<=nameList.size()+2;i++){ | |||
if(nameList.contains("未命名"+i)){ | |||
name = "未命名"+(i+1); | |||
String name = "未命名1"; | |||
for(int i=1;i<=nameList.size()+2;i++){ | |||
if(nameList.contains("未命名"+i)){ | |||
name = "未命名"+(i+1); | |||
} | |||
} | |||
} | |||
BPA_RecipeGroup recipeGroup = new BPA_RecipeGroup(); | |||
recipeGroup.setName(name); | |||
recipeGroup.setSort(recipeGroups.size()+1); | |||
recipeGroup.setIsWeight(Config.getInstance().isWeight); | |||
BPA_RecipeGroup recipeGroup = new BPA_RecipeGroup(); | |||
recipeGroup.setName(name); | |||
recipeGroup.setSort(recipeGroups.size()+1); | |||
recipeGroup.setIsWeight(Config.getInstance().isWeight); | |||
recipeGroups.add(recipeGroup); | |||
SqliteHelper.get().insert(recipeGroup); | |||
//添加一个配方 | |||
RecipeEditUtil.addRecipePage(recipeGroup.getId(),1); | |||
recipeGroups.add(recipeGroup); | |||
SqliteHelper.get().insert(recipeGroup); | |||
//添加一页配方 | |||
RecipeEditUtil.addRecipePage(recipeGroup.getId(),1); | |||
if(handler!=null){ | |||
handler.post(()->{ | |||
menuGourpAdapter.setSelectedPosition(recipeGroups.size()-1); | |||
menuGourpAdapter.notifyDataSetChanged(); | |||
binding.recGroupEdit.smoothScrollToPosition(recipeGroups.size()-1); | |||
ToastUtil.showInfo("添加分组成功"); | |||
}); | |||
} | |||
}); | |||
menuGourpAdapter.setSelectedPosition(recipeGroups.size()-1); | |||
menuGourpAdapter.notifyDataSetChanged(); | |||
binding.recGroupEdit.smoothScrollToPosition(recipeGroups.size()-1); | |||
}); | |||
binding.btnRecipePageAdd.setOnClickListener(view -> { | |||
//添加一个配方 | |||
RecipeEditUtil.addRecipePage(recipeGroups.get(menuGourpAdapter.getSelectedPosition()).getId(), | |||
recipeInfoAll.isEmpty()?1:recipeInfoAll.get(recipeInfoAll.size()-1).getSort()); | |||
resetRecipeGroupData(); | |||
if(Config.getInstance().isFastClick()){ | |||
ToastUtil.showWarn("请勿点击过快"); | |||
return; | |||
} | |||
RecordManager.getInstance().addLogRecord(LogType.角色操作,getClassName()+" click添加一页配方"); | |||
TaskManager.get().execute(()->{ | |||
ToastUtil.showInfo("正在新增一页配方..."); | |||
//添加一页配方 | |||
RecipeEditUtil.addRecipePage(recipeGroups.get(menuGourpAdapter.getSelectedPosition()).getId(), | |||
recipeInfoAll.isEmpty()?1:recipeInfoAll.get(recipeInfoAll.size()-1).getSort()); | |||
resetRecipeGroupData(); | |||
ToastUtil.showInfo("新增一页配方成功"); | |||
}); | |||
}); | |||
binding.pageBarEdit.setOnPageSelectedChanged(page -> { | |||
resetRecipeData(page); | |||
}); | |||
binding.btnDeletePage.setOnClickListener(view->{ | |||
if(Config.getInstance().isFastClick()){ | |||
ToastUtil.showWarn("请勿点击过快"); | |||
return; | |||
} | |||
if(binding.pageBarEdit.getTotalPages()>0){ | |||
new AlertDialog.Builder(this) | |||
.setTitle("确认删除") | |||
.setMessage("确认删除当前页所有配方数据?") | |||
.setPositiveButton("确认", (dialogInterface, w) -> { | |||
recipeInfoAll.removeAll(recipeInfos); | |||
//删除配方 | |||
RecipeEditUtil.deleteRecipe(recipeInfos); | |||
TaskManager.get().execute(()->{ | |||
ToastUtil.showInfo("正在删除此页配方..."); | |||
//删除配方 | |||
RecipeEditUtil.deleteRecipe(recipeInfos); | |||
resetRecipeGroupData(); | |||
ToastUtil.showInfo("删除此页配方成功"); | |||
}); | |||
resetRecipeGroupData(); | |||
ToastUtil.showInfo("删除成功"); | |||
dialogInterface.dismiss(); | |||
}) | |||
.setNegativeButton("取消", (dialogInterface, i) -> { | |||
@@ -123,16 +167,16 @@ public class RecipeManagerActivity extends ActivityBase { | |||
}); | |||
} | |||
private void initData(){ | |||
recipeGroups.clear(); | |||
if(Config.getInstance().isWeight){ | |||
recipeGroups.addAll(SqliteHelper.get().queryByQueryBuilder(BPA_RecipeGroup.class, | |||
BPA_RecipeGroupDao.Properties.IsWeight.eq(true))); | |||
}else { | |||
recipeGroups.addAll(SqliteHelper.get().queryByQueryBuilder(BPA_RecipeGroup.class, | |||
BPA_RecipeGroupDao.Properties.IsWeight.eq(false))); | |||
@Override | |||
protected void onDestroy() { | |||
super.onDestroy(); | |||
if(handler!=null){ | |||
handler = null; | |||
} | |||
} | |||
private void initData(){ | |||
recipeGroups.clear(); | |||
recipeInfos.clear(); | |||
recipeAdapter = new RecipeEditAdapter(); | |||
@@ -159,6 +203,7 @@ public class RecipeManagerActivity extends ActivityBase { | |||
.setTitle("确认删除") | |||
.setMessage("确认删除["+recipe.getName()+"]配方数据?") | |||
.setPositiveButton("确认", (dialogInterface, i) -> { | |||
RecordManager.getInstance().addLogRecord(LogType.角色操作,getClassName()+" 删除配方 "+recipe.getName()); | |||
//删除配方详情 | |||
List<BPA_RecipeConfig> recipeConfigs = SqliteHelper.get().queryByBuilder(BPA_RecipeConfig.class, | |||
BPA_RecipeConfigDao.Properties.RecipeId.eq(recipe.getId())); | |||
@@ -199,6 +244,7 @@ public class RecipeManagerActivity extends ActivityBase { | |||
menuGourpAdapter.setOnItemClickListener(new RecipeGroupEditAdapter.OnItemClickListener() { | |||
@Override | |||
public void onItemClick(int position, BPA_RecipeGroup recipeGroup) { | |||
binding.recGroupEdit.scrollToPosition(position); | |||
resetRecipeGroupData(); | |||
} | |||
}); | |||
@@ -208,6 +254,22 @@ public class RecipeManagerActivity extends ActivityBase { | |||
} else { | |||
menuGourpAdapter.notifyDataSetChanged(); | |||
} | |||
TaskManager.get().execute(()->{ | |||
if(Config.getInstance().isWeight){ | |||
recipeGroups.addAll(SqliteHelper.get().queryByQueryBuilder(BPA_RecipeGroup.class, | |||
BPA_RecipeGroupDao.Properties.IsWeight.eq(true))); | |||
}else { | |||
recipeGroups.addAll(SqliteHelper.get().queryByQueryBuilder(BPA_RecipeGroup.class, | |||
BPA_RecipeGroupDao.Properties.IsWeight.eq(false))); | |||
} | |||
if(handler!=null){ | |||
handler.post(()->{ | |||
menuGourpAdapter.notifyDataSetChanged(); | |||
menuGourpAdapter.setSelectedPosition(0); | |||
}); | |||
} | |||
}); | |||
} | |||
/** | |||
@@ -219,20 +281,27 @@ public class RecipeManagerActivity extends ActivityBase { | |||
resetRecipeData(1); | |||
return; | |||
} | |||
recipeInfoAll.clear(); | |||
recipeInfoAll.addAll(SqliteHelper.get().queryByQueryBuilder(BPA_RecipeInfo.class, | |||
BPA_RecipeInfoDao.Properties.RecipeGroupId.eq(recipeGroups.get(menuGourpAdapter.getSelectedPosition()).getId()))); | |||
int total = recipeInfoAll.size(); | |||
int pageCount ; | |||
if(total%20 == 0){ | |||
pageCount = total/20; | |||
}else{ | |||
pageCount = total/20 + 1; | |||
} | |||
binding.btnDeletePage.setVisibility(pageCount>0?View.VISIBLE:View.GONE); | |||
binding.pageBarEdit.setPages(pageCount); | |||
binding.pageBarEdit.setPageSelected(1); | |||
resetRecipeData(1); | |||
TaskManager.get().execute(()->{ | |||
recipeInfoAll.clear(); | |||
recipeInfoAll.addAll(SqliteHelper.get().queryByQueryBuilder(BPA_RecipeInfo.class, | |||
BPA_RecipeInfoDao.Properties.RecipeGroupId.eq(recipeGroups.get(menuGourpAdapter.getSelectedPosition()).getId()))); | |||
int total = recipeInfoAll.size(); | |||
int pageCount ; | |||
if(total%20 == 0){ | |||
pageCount = total/20; | |||
}else{ | |||
pageCount = total/20 + 1; | |||
} | |||
if(handler!=null){ | |||
handler.post(()->{ | |||
binding.btnDeletePage.setVisibility(pageCount>0?View.VISIBLE:View.GONE); | |||
binding.pageBarEdit.setPages(pageCount); | |||
binding.pageBarEdit.setPageSelected(1); | |||
}); | |||
} | |||
resetRecipeData(1); | |||
}); | |||
} | |||
/** | |||
@@ -240,17 +309,21 @@ public class RecipeManagerActivity extends ActivityBase { | |||
* @param pageNum | |||
*/ | |||
private void resetRecipeData(int pageNum){ | |||
recipeInfos.clear(); | |||
if(recipeInfoAll!=null && !recipeInfoAll.isEmpty()){ | |||
int index=(pageNum-1)*20; | |||
int count= Math.min((recipeInfoAll.size() - index), 20); | |||
LogUtils.d("resetRecipeData index="+index+";count="+count+";recipeInfoAll.size="+recipeInfoAll.size()); | |||
recipeInfos.addAll(recipeInfoAll.subList(index, index + count)); | |||
} | |||
recipeAdapter.setmDatas(recipeInfos); | |||
recipeAdapter.notifyDataSetChanged(); | |||
TaskManager.get().execute(()->{ | |||
recipeInfos.clear(); | |||
if(recipeInfoAll!=null && !recipeInfoAll.isEmpty()){ | |||
int index=(pageNum-1)*20; | |||
int count= Math.min((recipeInfoAll.size() - index), 20); | |||
LogUtils.d("resetRecipeData index="+index+";count="+count+";recipeInfoAll.size="+recipeInfoAll.size()); | |||
recipeInfos.addAll(recipeInfoAll.subList(index, index + count)); | |||
} | |||
if(handler!=null){ | |||
handler.post(()->{ | |||
recipeAdapter.setmDatas(recipeInfos); | |||
recipeAdapter.notifyDataSetChanged(); | |||
}); | |||
} | |||
}); | |||
} | |||
@@ -11,8 +11,11 @@ import com.jdzh.jdzhandroid.UI.fragment.RecipeUseLineChartFragment; | |||
import com.jdzh.jdzhandroid.databinding.ActivityRecipeRecordBinding; | |||
import com.jdzh.jdzhandroid.util.DisplayManager; | |||
public class RecipeRecordActivity extends ActivityBase { | |||
public class RecipeRecordActivity extends BaseActivity { | |||
@Override | |||
protected String getClassName() { | |||
return "RecipeRecordActivity配方记录页"; | |||
} | |||
private ActivityRecipeRecordBinding binding; | |||
private RecipeUseRankFragment columnChartFragment; | |||
private RecipeUseLineChartFragment roundLineChartFragment; | |||
@@ -4,15 +4,17 @@ import android.annotation.SuppressLint; | |||
import android.content.Intent; | |||
import android.os.Bundle; | |||
import androidx.appcompat.app.AppCompatActivity; | |||
import com.jdzh.jdzhandroid.Config.Config; | |||
import com.jdzh.jdzhandroid.MainActivity; | |||
import com.jdzh.jdzhandroid.databinding.ActivityWelcomeBinding; | |||
import com.jdzh.jdzhandroid.util.DisplayManager; | |||
public class WelcomeActivity extends AppCompatActivity { | |||
public class WelcomeActivity extends BaseActivity { | |||
@Override | |||
protected String getClassName() { | |||
return "WelcomeActivity欢迎页"; | |||
} | |||
private ActivityWelcomeBinding binding; | |||
@SuppressLint("ResourceAsColor") | |||
@Override | |||
@@ -22,17 +24,34 @@ public class WelcomeActivity extends AppCompatActivity { | |||
setContentView(binding.getRoot()); | |||
DisplayManager.setReferenceMaxWidthHeight(1280, 800); | |||
DisplayManager.updateDisplayInfo(this); | |||
Intent intent = new Intent(WelcomeActivity.this, LoginActivity.class); | |||
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); | |||
startActivity(intent); | |||
DisplayManager.scaleViewGroup(binding.getRoot()); | |||
if(Config.getInstance().isLogin){ | |||
Intent intent2 = new Intent(WelcomeActivity.this, MainActivity.class); | |||
intent2.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); | |||
startActivity(intent2); | |||
}else { | |||
Intent intent = new Intent(WelcomeActivity.this, LoginActivity.class); | |||
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); | |||
startActivity(intent); | |||
} | |||
} | |||
@Override | |||
protected void onNewIntent(Intent intent) { | |||
super.onNewIntent(intent); | |||
Intent intent2 = new Intent(WelcomeActivity.this, LoginActivity.class); | |||
intent2.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); | |||
startActivity(intent2); | |||
if(Config.getInstance().isLogin){ | |||
Intent intent2 = new Intent(WelcomeActivity.this, MainActivity.class); | |||
intent2.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); | |||
startActivity(intent2); | |||
}else{ | |||
Intent intent2 = new Intent(WelcomeActivity.this, LoginActivity.class); | |||
intent2.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); | |||
startActivity(intent2); | |||
} | |||
} | |||
@Override | |||
@@ -15,6 +15,8 @@ import androidx.annotation.NonNull; | |||
import androidx.recyclerview.widget.RecyclerView; | |||
import com.daimajia.swipe.SwipeLayout; | |||
import com.jdzh.jdzhandroid.Enum.LogType; | |||
import com.jdzh.jdzhandroid.Log.RecordManager; | |||
import com.jdzh.jdzhandroid.R; | |||
import com.jdzh.jdzhandroid.Sqlite.DAO.BPA_RecipeGroupDao; | |||
import com.jdzh.jdzhandroid.Sqlite.Model.BPA_RecipeGroup; | |||
@@ -100,6 +102,7 @@ public class RecipeGroupEditAdapter extends RecyclerView.Adapter<RecipeGroupEdit | |||
ToastUtil.showWarn("已存在分组名,请换一个名称!"); | |||
return; | |||
} | |||
RecordManager.getInstance().addLogRecord(LogType.角色操作," 修改配方分组名 "+mDatas.get(position).getName()+"==>>"+holder.et_group_name.getText().toString()); | |||
holder.swipeLayout.close(); | |||
holder.ll_group_edit.setVisibility(View.GONE); | |||
mDatas.get(position).setName(holder.et_group_name.getText().toString()); | |||
@@ -108,16 +111,19 @@ public class RecipeGroupEditAdapter extends RecyclerView.Adapter<RecipeGroupEdit | |||
SqliteHelper.get().update((mDatas.get(position))); | |||
}); | |||
holder.btn_group_del.setOnClickListener(view -> { | |||
holder.swipeLayout.close(); | |||
new AlertDialog.Builder(holder.name.getContext()) | |||
.setTitle("确认删除") | |||
.setMessage(String.format("确认删除[%s]及其下属所有配方数据?",mDatas.get(position).getName())) | |||
.setPositiveButton("确认", (dialogInterface, i) -> { | |||
holder.swipeLayout.close(); | |||
ToastUtil.showInfo("删除分组配方..."); | |||
//删除配方 | |||
RecipeEditUtil.deleteRecipeGroup(mDatas.get(position)); | |||
mDatas.remove(mDatas.get(position)); | |||
setSelectedPosition(0); | |||
dialogInterface.dismiss(); | |||
ToastUtil.showInfo("删除分组配方成功"); | |||
}) | |||
.setNegativeButton("取消", (dialogInterface, i) -> { | |||
dialogInterface.dismiss(); | |||
@@ -13,8 +13,10 @@ import androidx.recyclerview.widget.RecyclerView; | |||
import com.jdzh.jdzhandroid.DataUtil.ByteLib; | |||
import com.jdzh.jdzhandroid.Enum.DialogButton; | |||
import com.jdzh.jdzhandroid.Enum.LogType; | |||
import com.jdzh.jdzhandroid.Enum.SiloChannel; | |||
import com.jdzh.jdzhandroid.Log.MessageLog; | |||
import com.jdzh.jdzhandroid.Log.RecordManager; | |||
import com.jdzh.jdzhandroid.R; | |||
import com.jdzh.jdzhandroid.Sqlite.DAO.BPA_BatchingDao; | |||
import com.jdzh.jdzhandroid.Sqlite.DAO.BPA_RecipeConfigDetailDao; | |||
@@ -62,6 +64,8 @@ public class MaterialAdapter extends BaseAdapter<BPA_Batching,MaterialAdapter.Ma | |||
ToastUtil.showWarn("有配方正在使用该物料,无法删除!"); | |||
return; | |||
} | |||
RecordManager.getInstance().addLogRecord(LogType.角色操作," 删除物料信息成功 "+mData.get(position).getName() | |||
+"-"+ mData.get(position).getId()+"-"+mData.get(position).getSiloChannelNum()); | |||
SqliteHelper.get().delete(mData.get(position)); | |||
mData.remove(position); | |||
notifyDataSetChanged(); | |||
@@ -79,6 +83,8 @@ public class MaterialAdapter extends BaseAdapter<BPA_Batching,MaterialAdapter.Ma | |||
WhereCondition wc1= BPA_BatchingDao.Properties.Name.eq(s.Content.getName()); | |||
BPA_Batching batchingWC1= SqliteHelper.get().queryByBuilderEntity(BPA_Batching.class,wc1); | |||
if(batchingWC1==null){ | |||
RecordManager.getInstance().addLogRecord(LogType.角色操作," 修改物料名称成功 "+mData.get(position).getName() | |||
+"==>>"+ s.Content.getName()); | |||
mData.get(position).setName(s.Content.getName()); | |||
SqliteHelper.get().update(mData.get(position)); | |||
notifyDataSetChanged(); | |||
@@ -94,12 +100,15 @@ public class MaterialAdapter extends BaseAdapter<BPA_Batching,MaterialAdapter.Ma | |||
if(!mData.get(position).getSiloChannelNum().equals(s.Content.getSiloChannelNum())){ | |||
if(batchingWC2==null || s.Content.getSiloChannelNum().equals("未设置")){ | |||
RecordManager.getInstance().addLogRecord(LogType.角色操作," 修改料仓成功 "+mData.get(position).getSiloChannelNum() | |||
+"==>>"+ s.Content.getSiloChannelNum()); | |||
mData.get(position).setSiloChannelNum(s.Content.getSiloChannelNum()); | |||
SqliteHelper.get().update(mData.get(position)); | |||
notifyDataSetChanged(); | |||
ToastUtil.showInfo("修改料仓成功!"); | |||
}else{ | |||
AlertDialogUtil.show("该料仓已绑定到物料-["+batchingWC2.getName()+"]-上,是否重置绑定关系?",DialogButton.YesNo,(res->{ | |||
RecordManager.getInstance().addLogRecord(LogType.角色操作,"该料仓已绑定到物料-["+batchingWC2.getName()+"]-上,是否重置绑定关系? res="+res); | |||
if(res){ | |||
batchingWC2.setSiloChannelNum(SiloChannel.未设置.toString()); | |||
SqliteHelper.get().update(batchingWC2); | |||
@@ -1,6 +1,7 @@ | |||
package com.jdzh.jdzhandroid.UI.adapter.recipe; | |||
import android.annotation.SuppressLint; | |||
import android.graphics.Color; | |||
import android.view.LayoutInflater; | |||
import android.view.View; | |||
import android.view.ViewGroup; | |||
@@ -12,8 +13,10 @@ import androidx.recyclerview.widget.RecyclerView; | |||
import com.jdzh.jdzhandroid.R; | |||
import com.jdzh.jdzhandroid.Sqlite.Model.BPA_RecipeInfo; | |||
import com.jdzh.jdzhandroid.model.NameColorBean; | |||
import com.jdzh.jdzhandroid.util.DisplayManager; | |||
import java.util.ArrayList; | |||
import java.util.List; | |||
public class RecipeAdapter extends RecyclerView.Adapter<RecipeAdapter.RecipeViewHolder> { | |||
@@ -24,6 +27,10 @@ public class RecipeAdapter extends RecyclerView.Adapter<RecipeAdapter.RecipeView | |||
public RecipeAdapter(List<BPA_RecipeInfo> datas){ | |||
mDatas=datas; | |||
} | |||
private List<NameColorBean> nameList = new ArrayList<>(); | |||
public void setNameList(List<NameColorBean> nameList) { | |||
this.nameList = nameList; | |||
} | |||
public List<BPA_RecipeInfo> getmDatas() { | |||
return mDatas; | |||
@@ -77,6 +84,14 @@ public class RecipeAdapter extends RecyclerView.Adapter<RecipeAdapter.RecipeView | |||
onItemClickListener.onItemClick(position,mDatas.get(selectedPosition)); | |||
} | |||
}); | |||
holder.v.setTextColor(Color.parseColor("#000000")); | |||
if(nameList!=null && !nameList.isEmpty()){ | |||
for(NameColorBean bean : nameList){ | |||
if(bean.getName().equals(mDatas.get(position).getName())){ | |||
holder.v.setTextColor(Color.parseColor("#039BE5")); | |||
} | |||
} | |||
} | |||
} | |||
public void setOnItemClickListener(OnItemClickListener itemClickListener){ | |||
@@ -0,0 +1,74 @@ | |||
package com.jdzh.jdzhandroid.UI.adapter.record; | |||
import android.annotation.SuppressLint; | |||
import android.view.LayoutInflater; | |||
import android.view.View; | |||
import android.view.ViewGroup; | |||
import androidx.annotation.NonNull; | |||
import androidx.recyclerview.widget.RecyclerView; | |||
import com.jdzh.jdzhandroid.Sqlite.Model.BPA_LogRecord; | |||
import com.jdzh.jdzhandroid.UI.adapter.BaseAdapter; | |||
import com.jdzh.jdzhandroid.databinding.ItemLogBinding; | |||
import com.jdzh.jdzhandroid.util.DisplayManager; | |||
/** | |||
* @author: liup | |||
* @description: 日志 | |||
* @date: 2024/6/3 15:46. | |||
*/ | |||
public class LocalLogAdapter extends BaseAdapter<BPA_LogRecord, LocalLogAdapter.ViewHolder> { | |||
@NonNull | |||
@Override | |||
public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { | |||
return new ViewHolder(ItemLogBinding.inflate(LayoutInflater.from(parent.getContext()), parent, false)); | |||
} | |||
@SuppressLint("SetTextI18n") | |||
@Override | |||
public void onBindViewHolder(@NonNull ViewHolder holder, @SuppressLint("RecyclerView") int position) { | |||
BPA_LogRecord log = mData.get(position); | |||
if(holder.binding.getRoot().getWidth()==0){ | |||
DisplayManager.scaleViewGroup(holder.binding.getRoot()); | |||
} | |||
holder.binding.type.setText(log.getTypeName()+""); | |||
holder.binding.time.setText(log.getCreateAt()+""); | |||
if(log.userName!=null){ | |||
holder.binding.desc.setText(log.userName+"-"+log.describe+""); | |||
}else { | |||
holder.binding.desc.setText(log.describe+""); | |||
} | |||
holder.binding.getRoot().setOnClickListener(v->{ | |||
if(callBack!=null){ | |||
callBack.onDescClick(v,position); | |||
} | |||
}); | |||
} | |||
@Override | |||
protected void onItemClick(View v, int position) { | |||
} | |||
public static class ViewHolder extends RecyclerView.ViewHolder { | |||
private ItemLogBinding binding; | |||
public ViewHolder(ItemLogBinding view) { | |||
super(view.getRoot()); | |||
binding = view; | |||
} | |||
} | |||
private ClickCallBack callBack; | |||
public void setCallBack(ClickCallBack callBack) { | |||
this.callBack = callBack; | |||
} | |||
public interface ClickCallBack{ | |||
void onDescClick(View v,int position); | |||
} | |||
} | |||
@@ -55,9 +55,9 @@ public class RecipeNameRecordAdapter extends BaseAdapter<RecipeUseNum, RecipeNam | |||
holder.binding.tvBg.setLayoutParams(layoutParams); | |||
holder.binding.tvBg.setVisibility(View.VISIBLE); | |||
holder.binding.name.setText("【"+mData.get(position).getName()+"】"+"使用次数:"+mData.get(position).getUseNum()); | |||
holder.binding.name.setText("【"+mData.get(position).getName()+"】"); | |||
holder.binding.sort.setText("排名:"+(position+1)+""); | |||
holder.binding.sort.setText(mData.get(position).getUseNum()+"次"); | |||
holder.binding.getRoot().setOnClickListener(v->{ | |||
if(listener!=null){ | |||
listener.onSelectClick(position,mData.get(position)); | |||
@@ -8,6 +8,8 @@ import android.view.WindowManager; | |||
import androidx.annotation.NonNull; | |||
import androidx.appcompat.app.AlertDialog; | |||
import com.jdzh.jdzhandroid.Enum.LogType; | |||
import com.jdzh.jdzhandroid.Log.RecordManager; | |||
import com.jdzh.jdzhandroid.R; | |||
import com.jdzh.jdzhandroid.Sqlite.DAO.BPA_RecipeConfigDetailDao; | |||
import com.jdzh.jdzhandroid.Sqlite.DAO.BPA_RecipeattributeDao; | |||
@@ -27,7 +29,7 @@ import java.util.List; | |||
/** | |||
* @author: liup | |||
* @description: 属性编辑 | |||
* @description: 属性编辑弹窗 | |||
* @date: 2024/10/11 14:05. | |||
*/ | |||
public class AttributeEditDialog extends Dialog { | |||
@@ -52,7 +54,7 @@ public class AttributeEditDialog extends Dialog { | |||
params.width = WindowManager.LayoutParams.MATCH_PARENT; | |||
params.height = WindowManager.LayoutParams.MATCH_PARENT; | |||
getWindow().setAttributes(params); | |||
RecordManager.getInstance().addLogRecord(LogType.页面上报," 属性编辑弹窗 onStart "); | |||
initView(); | |||
initAttribute(); | |||
} | |||
@@ -95,6 +97,7 @@ public class AttributeEditDialog extends Dialog { | |||
dismiss(); | |||
}); | |||
binding.btnSave.setOnClickListener(v->{ | |||
RecordManager.getInstance().addLogRecord(LogType.角色操作," 保存属性修改 "); | |||
//先删除之前的 | |||
List<BPA_Recipeattribute> recipeattributes = SqliteHelper.get().queryByBuilder(BPA_Recipeattribute.class, | |||
BPA_RecipeattributeDao.Properties.RecipeId.eq(recipeInfo.getId())); | |||
@@ -15,6 +15,8 @@ import androidx.annotation.NonNull; | |||
import androidx.annotation.Nullable; | |||
import androidx.fragment.app.DialogFragment; | |||
import com.jdzh.jdzhandroid.Enum.LogType; | |||
import com.jdzh.jdzhandroid.Log.RecordManager; | |||
import com.jdzh.jdzhandroid.R; | |||
import com.jdzh.jdzhandroid.Sqlite.Model.BPA_Batching; | |||
import com.jdzh.jdzhandroid.Sqlite.SqliteHelper; | |||
@@ -91,6 +93,7 @@ public class BatchingNameListRecordDialog extends DialogFragment { | |||
window.setAttributes(params); | |||
} | |||
DisplayManager.scaleViewGroup(binding.getRoot()); | |||
RecordManager.getInstance().addLogRecord(LogType.页面上报," 原料名称多选弹窗 onStart "); | |||
initView(); | |||
} | |||
@@ -109,6 +112,7 @@ public class BatchingNameListRecordDialog extends DialogFragment { | |||
return; | |||
} | |||
} | |||
RecordManager.getInstance().addLogRecord(LogType.角色操作," 原料名称多选弹窗BatchingNameListRecordDialog nameList="+nameList.toString()); | |||
nameList.add(new NameColorBean(batching.getName(), COLORS[(int) nameList.size()%6])); | |||
StringBuilder stringBuilder = new StringBuilder(); | |||
for(NameColorBean bean : nameList){ | |||
@@ -20,7 +20,9 @@ import androidx.fragment.app.DialogFragment; | |||
import com.apkfuns.logutils.LogUtils; | |||
import com.jdzh.jdzhandroid.Business.PlcControl; | |||
import com.jdzh.jdzhandroid.Enum.LogType; | |||
import com.jdzh.jdzhandroid.Log.MessageLog; | |||
import com.jdzh.jdzhandroid.Log.RecordManager; | |||
import com.jdzh.jdzhandroid.R; | |||
import com.jdzh.jdzhandroid.Sqlite.DAO.BPA_BatchingDao; | |||
import com.jdzh.jdzhandroid.Sqlite.DAO.BPA_RecipeUseDetailDao; | |||
@@ -55,7 +57,7 @@ import lecho.lib.hellocharts.model.PointValue; | |||
import lecho.lib.hellocharts.model.ValueShape; | |||
/** | |||
* 原料名称多选弹窗 | |||
* 校准数据图表 | |||
*/ | |||
public class CalibrationDataDialog extends DialogFragment { | |||
@@ -68,6 +70,8 @@ public class CalibrationDataDialog extends DialogFragment { | |||
private int COLOR_RED = Color.parseColor("#FF4444"); | |||
private int COLOR_6 = Color.parseColor("#8577FF"); | |||
private int[] COLORS = new int[]{COLOR_6, COLOR_GREEN, COLOR_ORANGE, COLOR_RED,COLOR_BLUE, COLOR_VIOLET}; | |||
private List<String> selNameList1 = new ArrayList<>(); | |||
private List<String> selNameList2 = new ArrayList<>(); | |||
@Override | |||
public void onCreate(@Nullable Bundle savedInstanceState) { | |||
@@ -97,6 +101,7 @@ public class CalibrationDataDialog extends DialogFragment { | |||
window.setAttributes(params); | |||
} | |||
DisplayManager.scaleViewGroup(binding.getRoot()); | |||
RecordManager.getInstance().addLogRecord(LogType.页面上报," 校准数据图表onStart "); | |||
initView(); | |||
} | |||
@@ -107,6 +112,14 @@ public class CalibrationDataDialog extends DialogFragment { | |||
binding.tvBack.setOnClickListener(v->{ | |||
dismiss(); | |||
}); | |||
for(BPA_Batching bean :SqliteHelper.get().queryByBuilder(BPA_Batching.class, | |||
BPA_BatchingDao.Properties.SiloChannelNum.like("粉料%"))){ | |||
selNameList1.add(bean.getName()); | |||
} | |||
for(BPA_Batching bean :SqliteHelper.get().queryByBuilder(BPA_Batching.class, | |||
BPA_BatchingDao.Properties.SiloChannelNum.like("液体%"))){ | |||
selNameList2.add(bean.getName()); | |||
} | |||
List<CalibrationDataBean> list1 = getData(1); | |||
List<CalibrationDataBean> list2 = getData(2); | |||
@@ -120,6 +133,14 @@ public class CalibrationDataDialog extends DialogFragment { | |||
TextNameView nameView = new TextNameView(binding.llChart1.getContext()); | |||
nameView.setData(bean.getName(),bean.getColor()); | |||
nameView.setOnClickListener(v->{ | |||
if(selNameList1.contains(nameView.batchingName)){ | |||
selNameList1.remove(nameView.batchingName); | |||
}else { | |||
selNameList1.add(nameView.batchingName); | |||
} | |||
binding.chartLine1.setLineChartData(initLineChart1(getData(1))); | |||
}); | |||
linearLayout.addView(nameView); | |||
for(int i=0;i<bean.getValueList().size();i++){ | |||
TextValueView valueView = new TextValueView(binding.llChart1.getContext()); | |||
@@ -138,6 +159,14 @@ public class CalibrationDataDialog extends DialogFragment { | |||
TextNameView nameView = new TextNameView(binding.llChart2.getContext()); | |||
nameView.setData(bean.getName(),bean.getColor()); | |||
nameView.setOnClickListener(v->{ | |||
if(selNameList2.contains(nameView.batchingName)){ | |||
selNameList2.remove(nameView.batchingName); | |||
}else { | |||
selNameList2.add(nameView.batchingName); | |||
} | |||
binding.chartLine2.setLineChartData(initLineChart1(getData(2))); | |||
}); | |||
linearLayout.addView(nameView); | |||
for(int i=0;i<bean.getValueList().size();i++){ | |||
TextValueView valueView = new TextValueView(binding.llChart2.getContext()); | |||
@@ -242,32 +271,41 @@ public class CalibrationDataDialog extends DialogFragment { | |||
private List<CalibrationDataBean> getData(int type){ | |||
List<CalibrationDataBean> list1 = new ArrayList<>(); | |||
CalibrationDataBean dataBean1 = new CalibrationDataBean(); | |||
dataBean1.setName("通道[物料]"); | |||
dataBean1.setName("物料/时间ms"); | |||
dataBean1.setColor( Color.parseColor("#000000")); | |||
List<CalibrationDataBean.CalibrationValueBean> valueBeans1 = new ArrayList<>(); | |||
List<BPA_Batching> batchings = new ArrayList<>(); | |||
if(type==1){ | |||
if(selNameList1!=null && !selNameList1.isEmpty()){ | |||
LogUtils.d(" selNameList1="+selNameList1); | |||
batchings.addAll(SqliteHelper.get().queryByBuilder(BPA_Batching.class, | |||
BPA_BatchingDao.Properties.Name.in(selNameList1))); | |||
} | |||
}else { | |||
if(selNameList2!=null && !selNameList2.isEmpty()){ | |||
batchings.addAll(SqliteHelper.get().queryByBuilder(BPA_Batching.class, | |||
BPA_BatchingDao.Properties.Name.in(selNameList2))); | |||
} | |||
} | |||
try { | |||
for(int i=(type==1?1:7);i<=(type==1?6:12);i++){ | |||
int lineNum = 0; | |||
for(BPA_Batching bean : batchings){ | |||
lineNum++; | |||
CalibrationDataBean dataBean = new CalibrationDataBean(); | |||
List<CalibrationDataBean.CalibrationValueBean> valueBeans = new ArrayList<>(); | |||
BPA_Batching batching = SqliteHelper.get().queryByBuilderEntity(BPA_Batching.class, | |||
BPA_BatchingDao.Properties.SiloChannelNum.eq(type==1?("粉料通道"+i):("液体通道"+(i-6)))); | |||
if(batching!=null){ | |||
dataBean.setName("通道"+i+"["+batching.getName()+"]"); | |||
}else { | |||
dataBean.setName("通道"+i); | |||
} | |||
dataBean.setColor(COLORS[i%6]); | |||
if(PlcControl.get().calibrationValue.containsKey(i)){ | |||
for (Map.Entry<Integer,Float> item:PlcControl.get().calibrationValue.get(i).entrySet()) { | |||
if(i==(type==1?1:7)){ | |||
dataBean.setName(bean.getName()); | |||
dataBean.setColor(COLORS[lineNum%6]); | |||
if(PlcControl.get().calibrationValue.containsKey(bean.getName())){ | |||
for (Map.Entry<Integer,Float> item:PlcControl.get().calibrationValue.get(bean.getName()).entrySet()) { | |||
if(lineNum==1){ | |||
valueBeans1.add(new CalibrationDataBean.CalibrationValueBean(item.getKey()+"", Color.parseColor("#000000"))); | |||
} | |||
valueBeans.add(new CalibrationDataBean.CalibrationValueBean(item.getValue()+"", COLORS[i%6])); | |||
valueBeans.add(new CalibrationDataBean.CalibrationValueBean(item.getValue()+"", COLORS[lineNum%6])); | |||
} | |||
dataBean.setValueList(valueBeans); | |||
list1.add(dataBean); | |||
} | |||
dataBean.setValueList(valueBeans); | |||
list1.add(dataBean); | |||
} | |||
dataBean1.setValueList(valueBeans1); | |||
list1.add(0,dataBean1); | |||
@@ -11,6 +11,8 @@ import android.view.WindowManager; | |||
import androidx.annotation.NonNull; | |||
import com.apkfuns.logutils.LogUtils; | |||
import com.jdzh.jdzhandroid.Enum.LogType; | |||
import com.jdzh.jdzhandroid.Log.RecordManager; | |||
import com.jdzh.jdzhandroid.R; | |||
import com.jdzh.jdzhandroid.Sqlite.DAO.BPA_RecipeBaseConfigDao; | |||
import com.jdzh.jdzhandroid.Sqlite.DAO.BPA_RecipeConfigDao; | |||
@@ -41,6 +43,9 @@ import java.util.Collections; | |||
import java.util.Comparator; | |||
import java.util.List; | |||
/** | |||
* 配方编辑弹窗 | |||
*/ | |||
public class RecipeEditDialog extends Dialog { | |||
private DialogRecipeEditBinding binding; | |||
@@ -72,6 +77,7 @@ public class RecipeEditDialog extends Dialog { | |||
params.width = WindowManager.LayoutParams.MATCH_PARENT; | |||
params.height = WindowManager.LayoutParams.MATCH_PARENT; | |||
getWindow().setAttributes(params); | |||
RecordManager.getInstance().addLogRecord(LogType.页面上报," 配方编辑弹窗 onStart "); | |||
initView(); | |||
@@ -26,6 +26,8 @@ import com.jdzh.jdzhandroid.Business.Global; | |||
import com.jdzh.jdzhandroid.Business.PlcControl; | |||
import com.jdzh.jdzhandroid.Business.TaskControl; | |||
import com.jdzh.jdzhandroid.Enum.DialogButton; | |||
import com.jdzh.jdzhandroid.Enum.LogType; | |||
import com.jdzh.jdzhandroid.Log.RecordManager; | |||
import com.jdzh.jdzhandroid.R; | |||
import com.jdzh.jdzhandroid.Sqlite.DAO.BPA_BatchingDao; | |||
import com.jdzh.jdzhandroid.Sqlite.DAO.BPA_RecipeBaseConfigDao; | |||
@@ -59,12 +61,16 @@ import java.util.ArrayList; | |||
import java.util.Date; | |||
import java.util.List; | |||
/** | |||
* 配方执行弹窗 | |||
*/ | |||
public class RecipeExecuteDialog extends DialogFragment { | |||
private BPA_RecipeInfo recipe; | |||
private RecipeAttributeAdapter recipeAttributeAdapter; | |||
private DialogRecipeExcuteBinding binding; | |||
private boolean hasClear = false; | |||
public static int baseWeight = 100; | |||
private String model = ""; | |||
private Handler handler = new Handler(Looper.getMainLooper()){ | |||
@Override | |||
@@ -81,6 +87,7 @@ public class RecipeExecuteDialog extends DialogFragment { | |||
binding.llAttribute.setVisibility(View.VISIBLE); | |||
binding.llClear.setVisibility(View.GONE); | |||
removeMessages(1); | |||
RecordManager.getInstance().addLogRecord(LogType.订单处理," 配方执行弹窗 称重检测到放入碗 显示属性列表 "); | |||
} | |||
} | |||
} | |||
@@ -135,7 +142,8 @@ public class RecipeExecuteDialog extends DialogFragment { | |||
window.setAttributes(params); | |||
} | |||
DisplayManager.scaleViewGroup(binding.getRoot()); | |||
model = !Config.getInstance().isWeight ?"配方模式":"计量模式"; | |||
RecordManager.getInstance().addLogRecord(LogType.页面上报,model+" 配方执行弹窗 onStart "); | |||
if(getArguments()!=null){ | |||
recipe = SqliteHelper.get().queryByBuilderEntity(BPA_RecipeInfo.class, BPA_RecipeInfoDao.Properties.Id.eq(getArguments().get("id"))); | |||
} | |||
@@ -161,6 +169,7 @@ public class RecipeExecuteDialog extends DialogFragment { | |||
TaskManager.get().execute(new Runnable() { | |||
@Override | |||
public void run() { | |||
RecordManager.getInstance().addLogRecord(LogType.订单处理,model+" 配方执行弹窗 电子秤清零中 "); | |||
//电子秤清零 | |||
ElectoronicScales.get().clearZero((short) 1);//电子称去皮 | |||
boolean timeOutWeight = Util.WaitingConditions(()->{return Global.currentWeight.<Float>getValue()<=0.5f;},2000,null);//等待电子秤清零完成 | |||
@@ -170,6 +179,7 @@ public class RecipeExecuteDialog extends DialogFragment { | |||
@Override | |||
public void run() { | |||
binding.tvPut.setText("电子秤清零失败,请重试"); | |||
RecordManager.getInstance().addLogRecord(LogType.订单处理,model+" 配方执行弹窗 电子秤清零失败,请重试 "); | |||
} | |||
}); | |||
} | |||
@@ -180,6 +190,7 @@ public class RecipeExecuteDialog extends DialogFragment { | |||
public void run() { | |||
hasClear = true; | |||
binding.tvPut.setText("请放入碗"); | |||
RecordManager.getInstance().addLogRecord(LogType.订单处理,model+" 配方执行弹窗 电子秤清零成功,请放入碗 "); | |||
} | |||
}); | |||
} | |||
@@ -230,7 +241,7 @@ public class RecipeExecuteDialog extends DialogFragment { | |||
}else { | |||
recordUsed(names,configId); | |||
executeRecipe(names,configId); | |||
RecordManager.getInstance().addLogRecord(LogType.订单处理,model+" 配方执行弹窗 执行配方 names="+names+";configId="+configId); | |||
} | |||
}); | |||
binding.btnExcuteCancel.setOnClickListener(view -> dismiss()); | |||
@@ -238,6 +249,7 @@ public class RecipeExecuteDialog extends DialogFragment { | |||
if(countDownTimer!=null){ | |||
countDownTimer.cancel(); | |||
} | |||
RecordManager.getInstance().addLogRecord(LogType.订单处理,model+" 配方执行弹窗 强制终止"); | |||
resetChannel(); | |||
dismiss(); | |||
}); | |||
@@ -389,6 +401,7 @@ public class RecipeExecuteDialog extends DialogFragment { | |||
} | |||
ToastUtil.showInfo("执行配方【"+names+"】"); | |||
RecordManager.getInstance().addLogRecord(LogType.订单处理,recipe.getName()+" 属性组合名="+names); | |||
binding.progress.setProgress(0); | |||
binding.llAttribute.setVisibility(View.GONE); | |||
binding.rlExecute.setVisibility(View.VISIBLE); | |||
@@ -14,6 +14,8 @@ import androidx.recyclerview.widget.GridLayoutManager; | |||
import androidx.recyclerview.widget.LinearLayoutManager; | |||
import androidx.recyclerview.widget.RecyclerView; | |||
import com.jdzh.jdzhandroid.Enum.LogType; | |||
import com.jdzh.jdzhandroid.Log.RecordManager; | |||
import com.jdzh.jdzhandroid.R; | |||
import com.jdzh.jdzhandroid.Sqlite.DAO.BPA_RecipeGroupDao; | |||
import com.jdzh.jdzhandroid.Sqlite.DAO.BPA_RecipeInfoDao; | |||
@@ -53,7 +55,24 @@ public class RecipeNameListRecordDialog extends Dialog { | |||
private int[] COLORS = new int[]{COLOR_6, COLOR_GREEN, COLOR_ORANGE, COLOR_RED,COLOR_BLUE, COLOR_VIOLET}; | |||
private boolean isWeight; | |||
public RecipeNameListRecordDialog(@NonNull Context context,boolean isWeight) { | |||
public List<NameColorBean> getNameList() { | |||
return nameList; | |||
} | |||
public void setNameList(List<NameColorBean> nameList) { | |||
this.nameList = nameList; | |||
StringBuilder stringBuilder = new StringBuilder(); | |||
for(NameColorBean bean : nameList){ | |||
stringBuilder.append(bean.getName()).append(","); | |||
} | |||
if(stringBuilder.length()>0){ | |||
binding.names.setText(stringBuilder.substring(0,stringBuilder.length()-1)); | |||
} | |||
recipeAdapter.setNameList(nameList); | |||
recipeAdapter.notifyDataSetChanged(); | |||
} | |||
public RecipeNameListRecordDialog(@NonNull Context context, boolean isWeight) { | |||
super(context); | |||
this.mContext = context; | |||
this.isWeight = isWeight; | |||
@@ -62,6 +81,8 @@ public class RecipeNameListRecordDialog extends Dialog { | |||
setCanceledOnTouchOutside(true); | |||
setCancelable(true); | |||
DisplayManager.scaleViewGroup(binding.getRoot()); | |||
RecordManager.getInstance().addLogRecord(LogType.页面上报," 配方名称多选弹窗 onStart "); | |||
initView(); | |||
} | |||
@@ -70,6 +91,7 @@ public class RecipeNameListRecordDialog extends Dialog { | |||
dismiss(); | |||
}); | |||
recipeAdapter = new RecipeAdapter(); | |||
recipeAdapter.setNameList(nameList); | |||
recipeAdapter.setmDatas(recipeInfoAll); | |||
GridLayoutManager rightManager = new GridLayoutManager(mContext, 5); | |||
binding.recRight.addItemDecoration(new RecyclerView.ItemDecoration() { | |||
@@ -90,24 +112,34 @@ public class RecipeNameListRecordDialog extends Dialog { | |||
ToastUtil.showInfo("请先创建配方!"); | |||
return; | |||
} | |||
if(nameList.size()>=6){ | |||
ToastUtil.showInfo("最多选择6个配方!"); | |||
return; | |||
} | |||
boolean has = false; | |||
for(NameColorBean bean:nameList){ | |||
if(bean.getName().equals(recipe.getName())){ | |||
ToastUtil.showInfo("已选择"); | |||
nameList.remove(bean); | |||
has = true; | |||
break; | |||
} | |||
} | |||
if(!has){ | |||
if(nameList.size()>=6){ | |||
ToastUtil.showInfo("最多选择6个配方!"); | |||
return; | |||
}else { | |||
nameList.add(new NameColorBean(recipe.getName(), COLORS[(int) nameList.size()%6])); | |||
} | |||
} | |||
nameList.add(new NameColorBean(recipe.getName(), COLORS[(int) nameList.size()%6])); | |||
StringBuilder stringBuilder = new StringBuilder(); | |||
for(NameColorBean bean : nameList){ | |||
stringBuilder.append(bean.getName()).append(","); | |||
} | |||
if(stringBuilder.length()>0){ | |||
binding.names.setText(stringBuilder.substring(0,stringBuilder.length()-1)); | |||
}else { | |||
binding.names.setText(""); | |||
} | |||
recipeAdapter.setNameList(nameList); | |||
recipeAdapter.notifyDataSetChanged(); | |||
} | |||
}); | |||
@@ -13,6 +13,8 @@ import androidx.recyclerview.widget.GridLayoutManager; | |||
import androidx.recyclerview.widget.LinearLayoutManager; | |||
import androidx.recyclerview.widget.RecyclerView; | |||
import com.jdzh.jdzhandroid.Enum.LogType; | |||
import com.jdzh.jdzhandroid.Log.RecordManager; | |||
import com.jdzh.jdzhandroid.R; | |||
import com.jdzh.jdzhandroid.Sqlite.DAO.BPA_RecipeGroupDao; | |||
import com.jdzh.jdzhandroid.Sqlite.DAO.BPA_RecipeInfoDao; | |||
@@ -29,6 +31,9 @@ import com.jdzh.jdzhandroid.util.ToastUtil; | |||
import java.util.ArrayList; | |||
import java.util.List; | |||
/** | |||
* 配方使用记录选择名称弹窗 | |||
*/ | |||
public class RecipeNameRecordDialog extends Dialog { | |||
private DialogRecipeNameRecordBinding binding; | |||
@@ -48,6 +53,7 @@ public class RecipeNameRecordDialog extends Dialog { | |||
setCanceledOnTouchOutside(true); | |||
setCancelable(true); | |||
DisplayManager.scaleViewGroup(binding.getRoot()); | |||
RecordManager.getInstance().addLogRecord(LogType.页面上报," 配方使用记录选择名称弹窗 onStart "); | |||
initView(); | |||
} | |||
@@ -0,0 +1,45 @@ | |||
package com.jdzh.jdzhandroid.UI.fragment; | |||
import android.os.Bundle; | |||
import android.view.LayoutInflater; | |||
import android.view.View; | |||
import android.view.ViewGroup; | |||
import androidx.annotation.NonNull; | |||
import androidx.annotation.Nullable; | |||
import androidx.fragment.app.Fragment; | |||
import com.apkfuns.logutils.LogUtils; | |||
import com.jdzh.jdzhandroid.Enum.LogType; | |||
import com.jdzh.jdzhandroid.Log.RecordManager; | |||
/** | |||
* @author: liup | |||
* @description: | |||
* @date: 2024/10/24 17:20. | |||
*/ | |||
public class BaseFragment extends Fragment { | |||
@Nullable | |||
@Override | |||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { | |||
if(getClassName()!=null && !getClassName().isEmpty()){ | |||
RecordManager.getInstance().addLogRecord(LogType.页面上报,getClassName()+"-启动"); | |||
} | |||
return super.onCreateView(inflater, container, savedInstanceState); | |||
} | |||
@Override | |||
public void onDestroyView() { | |||
super.onDestroyView(); | |||
if(getClassName()!=null && !getClassName().isEmpty()){ | |||
RecordManager.getInstance().addLogRecord(LogType.页面上报,getClassName()+"-销毁"); | |||
} | |||
} | |||
protected String getClassName(){ | |||
return ""; | |||
} | |||
} |
@@ -19,7 +19,12 @@ import com.jdzh.jdzhandroid.util.DisplayManager; | |||
import com.jdzh.jdzhandroid.util.ToastUtil; | |||
import com.jdzh.jdzhandroid.viewmodel.DebugViewModel; | |||
public class DebugFragment extends Fragment { | |||
public class DebugFragment extends BaseFragment { | |||
@Override | |||
protected String getClassName() { | |||
return "DebugFragment调试页"; | |||
} | |||
private DebugViewModel mViewModel; | |||
private FragmentDebugBinding binding; | |||
@Override | |||
@@ -61,4 +66,6 @@ public class DebugFragment extends Fragment { | |||
public void onDestroy() { | |||
super.onDestroy(); | |||
} | |||
} |
@@ -3,6 +3,10 @@ package com.jdzh.jdzhandroid.UI.fragment; | |||
import android.content.Context; | |||
import android.graphics.Rect; | |||
import android.os.Bundle; | |||
import android.os.Environment; | |||
import android.os.Handler; | |||
import android.os.Looper; | |||
import android.os.Message; | |||
import android.util.DisplayMetrics; | |||
import android.view.LayoutInflater; | |||
import android.view.View; | |||
@@ -16,32 +20,52 @@ import androidx.recyclerview.widget.LinearLayoutManager; | |||
import androidx.recyclerview.widget.RecyclerView; | |||
import com.apkfuns.logutils.LogUtils; | |||
import com.jdzh.jdzhandroid.Enum.DialogButton; | |||
import com.jdzh.jdzhandroid.Enum.LogType; | |||
import com.jdzh.jdzhandroid.Interface.IRunT; | |||
import com.jdzh.jdzhandroid.Log.RecordManager; | |||
import com.jdzh.jdzhandroid.R; | |||
import com.jdzh.jdzhandroid.Sqlite.DAO.BPA_RecipeGroupDao; | |||
import com.jdzh.jdzhandroid.Sqlite.DAO.BPA_RecipeInfoDao; | |||
import com.jdzh.jdzhandroid.Sqlite.Model.BPA_LogRecord; | |||
import com.jdzh.jdzhandroid.Sqlite.Model.BPA_RecipeGroup; | |||
import com.jdzh.jdzhandroid.Sqlite.Model.BPA_RecipeInfo; | |||
import com.jdzh.jdzhandroid.Sqlite.SqliteHelper; | |||
import com.jdzh.jdzhandroid.Task.Task; | |||
import com.jdzh.jdzhandroid.Task.TaskManager; | |||
import com.jdzh.jdzhandroid.UI.adapter.recipe.RecipeAdapter; | |||
import com.jdzh.jdzhandroid.UI.adapter.recipe.RecipeGroupAdapter; | |||
import com.jdzh.jdzhandroid.UI.dialog.RecipeExecuteDialog; | |||
import com.jdzh.jdzhandroid.Config.Config; | |||
import com.jdzh.jdzhandroid.databinding.FragmentHomeBinding; | |||
import com.jdzh.jdzhandroid.util.Dialog.DialogManager; | |||
import com.jdzh.jdzhandroid.util.DisplayManager; | |||
import com.jdzh.jdzhandroid.util.FileUtil; | |||
import com.jdzh.jdzhandroid.util.PreferenceUtils; | |||
import com.jdzh.jdzhandroid.util.ToastUtil; | |||
import java.io.File; | |||
import java.util.ArrayList; | |||
import java.util.List; | |||
public class HomeFragment extends Fragment { | |||
public class HomeFragment extends BaseFragment { | |||
@Override | |||
protected String getClassName() { | |||
return "HomeFragment配方首页"; | |||
} | |||
private FragmentHomeBinding binding; | |||
private List<BPA_RecipeGroup> recipeGroups = new ArrayList<>(); | |||
private List<BPA_RecipeInfo> recipeInfos = new ArrayList<>(); | |||
private List<BPA_RecipeInfo> recipeInfoAll = new ArrayList<>(); | |||
private boolean isWeight= false; | |||
private RecipeExecuteDialog dialog; | |||
private Handler handler = new Handler(Looper.getMainLooper()){ | |||
@Override | |||
public void handleMessage(@NonNull Message msg) { | |||
super.handleMessage(msg); | |||
} | |||
}; | |||
@Override | |||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { | |||
@@ -68,8 +92,6 @@ public class HomeFragment extends Fragment { | |||
private void init() { | |||
isWeight = Config.getInstance().isWeight; | |||
recipeGroups.clear(); | |||
recipeGroups.addAll(SqliteHelper.get().queryByBuilder(BPA_RecipeGroup.class, | |||
BPA_RecipeGroupDao.Properties.IsWeight.eq(isWeight))); | |||
recipeInfos.clear(); | |||
rightManager = new GridLayoutManager(mContext, 5); | |||
@@ -109,6 +131,8 @@ public class HomeFragment extends Fragment { | |||
binding.tbRecipeMode.setChecked(Config.getInstance().isWeight); | |||
binding.tbRecipeMode.setOnCheckedChangeListener((compoundButton, b) -> { | |||
Config.getInstance().isWeight = !Config.getInstance().isWeight; | |||
RecordManager.getInstance().addLogRecord(LogType.角色操作,getClassName()+" isweight="+Config.getInstance().isWeight); | |||
PreferenceUtils.setBoolean(Config.SHARE_KEY_isWeight,Config.getInstance().isWeight); | |||
resetAllData(); | |||
}); | |||
@@ -130,6 +154,7 @@ public class HomeFragment extends Fragment { | |||
} | |||
}); | |||
resetAllData(); | |||
} | |||
/** | |||
@@ -137,12 +162,27 @@ public class HomeFragment extends Fragment { | |||
*/ | |||
private void resetAllData(){ | |||
isWeight = Config.getInstance().isWeight; | |||
recipeGroups.clear(); | |||
recipeGroups.addAll(SqliteHelper.get().queryByBuilder(BPA_RecipeGroup.class, | |||
BPA_RecipeGroupDao.Properties.IsWeight.eq(isWeight))); | |||
recipeInfos.clear(); | |||
recipeAdapter.notifyDataSetChanged(); | |||
menuGourpAdapter.setSelectedPosition(0); | |||
TaskManager.get().execute(()->{ | |||
recipeGroups.clear(); | |||
recipeGroups.addAll(SqliteHelper.get().queryByBuilder(BPA_RecipeGroup.class, | |||
BPA_RecipeGroupDao.Properties.IsWeight.eq(isWeight))); | |||
recipeInfos.clear(); | |||
if(handler!=null){ | |||
handler.post(()->{ | |||
recipeAdapter.notifyDataSetChanged(); | |||
menuGourpAdapter.setSelectedPosition(0); | |||
}); | |||
} | |||
}); | |||
} | |||
@Override | |||
public void onDestroyView() { | |||
super.onDestroyView(); | |||
if(handler!=null){ | |||
handler = null; | |||
} | |||
} | |||
/** | |||
@@ -152,20 +192,30 @@ public class HomeFragment extends Fragment { | |||
if(recipeGroups==null || recipeGroups.isEmpty()){ | |||
return; | |||
} | |||
recipeInfoAll.clear(); | |||
recipeInfoAll.addAll(SqliteHelper.get().queryByQueryBuilder(BPA_RecipeInfo.class, | |||
BPA_RecipeInfoDao.Properties.RecipeGroupId.eq(recipeGroups.get(menuGourpAdapter.getSelectedPosition()).getId()))); | |||
LogUtils.d("resetRecipeGroupData recipeInfoAll.size="+recipeInfoAll.size()); | |||
int total = recipeInfoAll.size(); | |||
int pageCount ; | |||
if(total%20 == 0){ | |||
pageCount = total/20; | |||
}else{ | |||
pageCount = total/20 + 1; | |||
} | |||
binding.pageBar.setPages(pageCount); | |||
binding.pageBar.setPageSelected(1); | |||
resetRecipeData(1); | |||
TaskManager.get().execute(new Runnable() { | |||
@Override | |||
public void run() { | |||
recipeInfoAll.clear(); | |||
recipeInfoAll.addAll(SqliteHelper.get().queryByQueryBuilder(BPA_RecipeInfo.class, | |||
BPA_RecipeInfoDao.Properties.RecipeGroupId.eq(recipeGroups.get(menuGourpAdapter.getSelectedPosition()).getId()))); | |||
LogUtils.d("resetRecipeGroupData recipeInfoAll.size="+recipeInfoAll.size()); | |||
int total = recipeInfoAll.size(); | |||
int pageCount ; | |||
if(total%20 == 0){ | |||
pageCount = total/20; | |||
}else{ | |||
pageCount = total/20 + 1; | |||
} | |||
if(handler!=null){ | |||
handler.post(() -> { | |||
binding.pageBar.setPages(pageCount); | |||
binding.pageBar.setPageSelected(1); | |||
}); | |||
} | |||
resetRecipeData(1); | |||
} | |||
}); | |||
} | |||
/** | |||
@@ -173,17 +223,23 @@ public class HomeFragment extends Fragment { | |||
* @param pageNum | |||
*/ | |||
private void resetRecipeData(int pageNum){ | |||
recipeInfos.clear(); | |||
TaskManager.get().execute(() -> { | |||
recipeInfos.clear(); | |||
if(recipeInfoAll!=null && !recipeInfoAll.isEmpty()){ | |||
int index=(pageNum-1)*20; | |||
int count= Math.min((recipeInfoAll.size() - index), 20); | |||
LogUtils.d("resetRecipeData index="+index+";count="+count+";recipeInfoAll.size="+recipeInfoAll.size()); | |||
recipeInfos.addAll(recipeInfoAll.subList(index, index + count)); | |||
} | |||
if(recipeInfoAll!=null && !recipeInfoAll.isEmpty()){ | |||
int index=(pageNum-1)*20; | |||
int count= Math.min((recipeInfoAll.size() - index), 20); | |||
LogUtils.d("resetRecipeData index="+index+";count="+count+";recipeInfoAll.size="+recipeInfoAll.size()); | |||
recipeInfos.addAll(recipeInfoAll.subList(index, index + count)); | |||
} | |||
recipeAdapter.setmDatas(recipeInfos); | |||
if(handler!=null){ | |||
handler.post(()->{ | |||
recipeAdapter.notifyDataSetChanged(); | |||
}); | |||
} | |||
}); | |||
recipeAdapter.setmDatas(recipeInfos); | |||
recipeAdapter.notifyDataSetChanged(); | |||
} | |||
/** | |||
@@ -210,4 +266,5 @@ public class HomeFragment extends Fragment { | |||
DisplayMetrics displayMetrics = context.getResources().getDisplayMetrics(); | |||
return (int) ((dp * displayMetrics.density) + 0.5f); | |||
} | |||
} |
@@ -1,143 +0,0 @@ | |||
package com.jdzh.jdzhandroid.UI.fragment; | |||
import android.graphics.Color; | |||
import android.os.Bundle; | |||
import android.util.Log; | |||
import android.view.LayoutInflater; | |||
import android.view.View; | |||
import android.view.ViewGroup; | |||
import androidx.annotation.NonNull; | |||
import androidx.annotation.Nullable; | |||
import androidx.fragment.app.Fragment; | |||
import com.jdzh.jdzhandroid.databinding.FragmentColumnChartBinding; | |||
import com.jdzh.jdzhandroid.util.DisplayManager; | |||
import java.util.ArrayList; | |||
import java.util.List; | |||
import lecho.lib.hellocharts.gesture.ZoomType; | |||
import lecho.lib.hellocharts.listener.ColumnChartOnValueSelectListener; | |||
import lecho.lib.hellocharts.listener.ViewportChangeListener; | |||
import lecho.lib.hellocharts.model.Axis; | |||
import lecho.lib.hellocharts.model.Column; | |||
import lecho.lib.hellocharts.model.ColumnChartData; | |||
import lecho.lib.hellocharts.model.SubcolumnValue; | |||
import lecho.lib.hellocharts.model.Viewport; | |||
import lecho.lib.hellocharts.util.ChartUtils; | |||
/** | |||
* @author: liup | |||
* @description: 线性图 | |||
* @date: 2024/10/8 16:56. | |||
*/ | |||
public class LineChartFragment extends Fragment { | |||
private FragmentColumnChartBinding binding; | |||
private ColumnChartData data; | |||
private ColumnChartData previewData; | |||
@Override | |||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { | |||
binding= FragmentColumnChartBinding.inflate(inflater,container,false); | |||
return binding.getRoot(); | |||
} | |||
@Override | |||
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { | |||
super.onViewCreated(view, savedInstanceState); | |||
DisplayManager.scaleViewGroup(binding.getRoot()); | |||
init(); | |||
} | |||
public void update(String time1,String time2){ | |||
} | |||
private void init(){ | |||
generateDefaultData(); | |||
binding.chart.setColumnChartData(data); | |||
binding.chart.setZoomEnabled(true); | |||
binding.chart.setScrollEnabled(true); | |||
binding.chart.setOnValueTouchListener(new ColumnChartOnValueSelectListener() { | |||
@Override | |||
public void onValueSelected(int columnIndex, int subcolumnIndex, SubcolumnValue value) { | |||
Log.d("///","columnIndex="+columnIndex+";subcolumnIndex="+subcolumnIndex+";value="+value); | |||
int num = (int) value.getValue(); | |||
binding.desc.setText("选中:"+"[xxx]"+" 排名:"+(columnIndex+1)+" 使用次数:"+num); | |||
} | |||
@Override | |||
public void onValueDeselected() { | |||
Log.d("///","onValueDeselected"); | |||
} | |||
}); | |||
binding.previewChart.setColumnChartData(previewData); | |||
binding.previewChart.setViewportChangeListener(new ViewportListener()); | |||
previewX(false); | |||
} | |||
private void previewX(boolean animate) { | |||
Viewport tempViewport = new Viewport(binding.chart.getMaximumViewport()); | |||
float dx = tempViewport.width() / 4; | |||
tempViewport.inset(dx, 0); | |||
if (animate) { | |||
binding.previewChart.setCurrentViewportWithAnimation(tempViewport); | |||
} else { | |||
binding.previewChart.setCurrentViewport(tempViewport); | |||
} | |||
binding.previewChart.setZoomType(ZoomType.HORIZONTAL); | |||
} | |||
private class ViewportListener implements ViewportChangeListener { | |||
@Override | |||
public void onViewportChanged(Viewport newViewport) { | |||
// don't use animation, it is unnecessary when using preview chart because usually viewport changes | |||
// happens to often. | |||
binding.chart.setCurrentViewport(newViewport); | |||
} | |||
} | |||
private void generateDefaultData() { | |||
int numSubcolumns = 1; | |||
int numColumns = 60; | |||
List<Column> columns = new ArrayList<Column>(); | |||
List<SubcolumnValue> values; | |||
for (int i = 0; i < numColumns; ++i) { | |||
values = new ArrayList<SubcolumnValue>(); | |||
for (int j = 0; j < numSubcolumns; ++j) { | |||
values.add(new SubcolumnValue((float) (60f-i), Color.parseColor("#33B5E5"))); | |||
} | |||
Column column = new Column(values); | |||
column.setHasLabels(true); | |||
column.setHasLabelsOnlyForSelected(true); | |||
columns.add(column); | |||
} | |||
data = new ColumnChartData(columns); | |||
data.setAxisXBottom(new Axis()); | |||
data.setAxisYLeft(new Axis().setHasLines(true)); | |||
previewData = new ColumnChartData(data); | |||
for (Column column : previewData.getColumns()) { | |||
for (SubcolumnValue value : column.getValues()) { | |||
value.setColor(ChartUtils.DEFAULT_DARKEN_COLOR); | |||
} | |||
} | |||
} | |||
@Override | |||
public void onDestroy() { | |||
super.onDestroy(); | |||
} | |||
} |
@@ -14,7 +14,9 @@ import androidx.fragment.app.Fragment; | |||
import com.jdzh.jdzhandroid.Business.ElectoronicScales; | |||
import com.jdzh.jdzhandroid.Business.PlcControl; | |||
import com.jdzh.jdzhandroid.Enum.DialogButton; | |||
import com.jdzh.jdzhandroid.Enum.LogType; | |||
import com.jdzh.jdzhandroid.Enum.SiloChannel; | |||
import com.jdzh.jdzhandroid.Log.RecordManager; | |||
import com.jdzh.jdzhandroid.Sqlite.Model.BPA_Batching; | |||
import com.jdzh.jdzhandroid.Sqlite.SqliteHelper; | |||
import com.jdzh.jdzhandroid.Config.Config; | |||
@@ -30,7 +32,11 @@ import java.util.List; | |||
* @description: 液体料仓 | |||
* @date: 2024/10/8 16:56. | |||
*/ | |||
public class MaterialSiloFragment extends Fragment { | |||
public class MaterialSiloFragment extends BaseFragment { | |||
@Override | |||
protected String getClassName() { | |||
return "MaterialSiloFragment液体通道页"; | |||
} | |||
private FragmentMaterialSiloBinding binding; | |||
@@ -125,7 +131,7 @@ public class MaterialSiloFragment extends Fragment { | |||
@SuppressLint("SetTextI18n") | |||
private void updateSilo(int num, String batchName){ | |||
String name = "料仓"+num+"\n["+batchName+"]"; | |||
String name = "液体通道"+(num-6)+"\n["+batchName+"]"; | |||
switch (num){ | |||
case 7: | |||
binding.silo1.setText(name); | |||
@@ -12,10 +12,18 @@ import androidx.fragment.app.Fragment; | |||
import com.jdzh.jdzhandroid.Config.Config; | |||
import com.jdzh.jdzhandroid.Enum.DialogButton; | |||
import com.jdzh.jdzhandroid.Enum.LogType; | |||
import com.jdzh.jdzhandroid.Interface.IRunT; | |||
import com.jdzh.jdzhandroid.Log.RecordManager; | |||
import com.jdzh.jdzhandroid.Sqlite.Model.BPA_Batching; | |||
import com.jdzh.jdzhandroid.Sqlite.Model.BPA_LogRecord; | |||
import com.jdzh.jdzhandroid.Sqlite.Model.BPA_RecipeBaseConfig; | |||
import com.jdzh.jdzhandroid.Sqlite.Model.BPA_RecipeConfig; | |||
import com.jdzh.jdzhandroid.Sqlite.Model.BPA_RecipeConfigDetail; | |||
import com.jdzh.jdzhandroid.Sqlite.Model.BPA_RecipeGroup; | |||
import com.jdzh.jdzhandroid.Sqlite.Model.BPA_RecipeInfo; | |||
import com.jdzh.jdzhandroid.Sqlite.Model.BPA_Recipeattribute; | |||
import com.jdzh.jdzhandroid.Sqlite.Model.BPA_RecipeattributeValue; | |||
import com.jdzh.jdzhandroid.Sqlite.SqliteHelper; | |||
import com.jdzh.jdzhandroid.Task.TaskManager; | |||
import com.jdzh.jdzhandroid.UI.activity.ChannelManagerActivity; | |||
@@ -34,7 +42,12 @@ import com.jdzh.jdzhandroid.util.ToastUtil; | |||
import java.util.ArrayList; | |||
import java.util.List; | |||
public class ParSetFragment extends Fragment { | |||
public class ParSetFragment extends BaseFragment { | |||
@Override | |||
protected String getClassName() { | |||
return "ParSetFragment参数设置"; | |||
} | |||
private FragmentParSetBinding binding; | |||
@Override | |||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { | |||
@@ -111,18 +124,23 @@ public class ParSetFragment extends Fragment { | |||
@Override | |||
public void onSuccess(ArrayList<BPA_Batching> bpaBatchings) { | |||
getRecipeList(bpaBatchings); | |||
RecordManager.getInstance().addLogRecord(LogType.数据接收,"获取物料信息成功"); | |||
} | |||
@Override | |||
public void onError(int failCode, String msg) { | |||
DialogManager.showWarn("获取物料接口请求报错:failCode="+failCode+"description="+msg, DialogButton.OK,null); | |||
WaitProcessUtil.getInstance().dismiss(); | |||
RecordManager.getInstance().addLogRecord(LogType.数据接收,"获取物料接口请求报错:failCode="+failCode+"description="+msg); | |||
} | |||
@Override | |||
public void onFailed(int failCode, Throwable throwable, String message) { | |||
DialogManager.showWarn("获取物料接口请求失败:failCode="+failCode+"description="+message, DialogButton.OK,null); | |||
WaitProcessUtil.getInstance().dismiss(); | |||
RecordManager.getInstance().addLogRecord(LogType.数据接收,"获取物料接口请求失败:failCode="+failCode+"description="+message); | |||
} | |||
}); | |||
@@ -138,17 +156,20 @@ public class ParSetFragment extends Fragment { | |||
public void onSuccess(RecipeListBean recipeListBean) { | |||
WaitProcessUtil.getInstance().dismiss(); | |||
synchronizeData(bpaBatchings,recipeListBean); | |||
RecordManager.getInstance().addLogRecord(LogType.数据接收,"获取所有配方成功"); | |||
} | |||
@Override | |||
public void onError(int failCode, String msg) { | |||
DialogManager.showWarn("获取所有配方接口请求报错:failCode="+failCode+"description="+msg, DialogButton.OK,null); | |||
RecordManager.getInstance().addLogRecord(LogType.数据接收,"获取所有配方接口请求报错:failCode="+failCode+"description="+msg); | |||
WaitProcessUtil.getInstance().dismiss(); | |||
} | |||
@Override | |||
public void onFailed(int failCode, Throwable throwable, String message) { | |||
DialogManager.showWarn("获取所有配方请求失败:failCode="+failCode+"description="+message, DialogButton.OK,null); | |||
RecordManager.getInstance().addLogRecord(LogType.数据接收,"获取所有配方请求失败:failCode="+failCode+"description="+message); | |||
WaitProcessUtil.getInstance().dismiss(); | |||
} | |||
}); | |||
@@ -190,10 +211,15 @@ public class ParSetFragment extends Fragment { | |||
//删除所有配方 | |||
ToastUtil.showInfo("删除所有配方数据..."); | |||
result.append("删除所有配方数据..."); | |||
SqliteHelper.get().deleteMulti(SqliteHelper.get().queryAll(BPA_RecipeGroup.class)); | |||
SqliteHelper.get().deleteMulti(SqliteHelper.get().queryAll(BPA_RecipeGroup.class)); | |||
SqliteHelper.get().deleteMulti(SqliteHelper.get().queryAll(BPA_RecipeGroup.class)); | |||
SqliteHelper.get().deleteMulti(SqliteHelper.get().queryAll(BPA_RecipeGroup.class)); | |||
SqliteHelper.get().deleteAll(BPA_RecipeGroup.class); | |||
SqliteHelper.get().deleteAll(BPA_RecipeInfo.class); | |||
SqliteHelper.get().deleteAll(BPA_RecipeBaseConfig.class); | |||
SqliteHelper.get().deleteAll(BPA_RecipeConfigDetail.class); | |||
SqliteHelper.get().deleteAll(BPA_RecipeConfig.class); | |||
SqliteHelper.get().deleteAll(BPA_Recipeattribute.class); | |||
SqliteHelper.get().deleteAll(BPA_RecipeattributeValue.class); | |||
RecordManager.getInstance().addLogRecord(LogType.角色操作,"下载云端数据成功,删除所有配方数据"); | |||
result.append("删除所有配方数据完成"); | |||
if(recipeListBean!=null){ | |||
if(recipeListBean.getRecipeGroupList()!=null){ | |||
@@ -233,8 +259,10 @@ public class ParSetFragment extends Fragment { | |||
} | |||
} | |||
DialogManager.showWarn("同步完成,请检查物料通道绑定是否有变动,若有变动则需重新校准", DialogButton.OK,null); | |||
RecordManager.getInstance().addLogRecord(LogType.角色操作,"下载云端数据成功,同步数据成功\n"+result.toString()); | |||
}catch (Exception e){ | |||
DialogManager.showWarn("同步数据异常! mgs="+ e.getMessage() +"\n"+result.toString(), DialogButton.OK,null); | |||
RecordManager.getInstance().addLogRecord(LogType.角色操作,"下载云端数据成功,同步数据异常"+e.getMessage() +"\n"+result.toString()); | |||
}finally { | |||
WaitProcessUtil.getInstance().dismiss(); | |||
} | |||
@@ -255,6 +283,7 @@ public class ParSetFragment extends Fragment { | |||
@Override | |||
public void onSuccess(Object responseData) { | |||
ToastUtil.showInfo("上传物料成功"); | |||
RecordManager.getInstance().addLogRecord(LogType.数据上传,"上传物料成功"); | |||
uploadRecipeGroup(); | |||
} | |||
@@ -267,6 +296,7 @@ public class ParSetFragment extends Fragment { | |||
@Override | |||
public void onFailed(int failCode, Throwable throwable, String message) { | |||
DialogManager.showWarn("上传物料失败:"+message, DialogButton.OK,null); | |||
RecordManager.getInstance().addLogRecord(LogType.数据上传,"上传物料失败"); | |||
WaitProcessUtil.getInstance().dismiss(); | |||
} | |||
}); | |||
@@ -280,6 +310,7 @@ public class ParSetFragment extends Fragment { | |||
@Override | |||
public void onSuccess(Object responseData) { | |||
ToastUtil.showInfo("上传配方分组成功"); | |||
RecordManager.getInstance().addLogRecord(LogType.数据上传,"上传配方分组成功"); | |||
uploadRecipeInfo(0); | |||
} | |||
@@ -292,6 +323,7 @@ public class ParSetFragment extends Fragment { | |||
@Override | |||
public void onFailed(int failCode, Throwable throwable, String message) { | |||
DialogManager.showWarn("上传配方分组失败:"+message, DialogButton.OK,null); | |||
RecordManager.getInstance().addLogRecord(LogType.数据上传,"上传配方分组失败"); | |||
WaitProcessUtil.getInstance().dismiss(); | |||
} | |||
}); | |||
@@ -310,6 +342,7 @@ public class ParSetFragment extends Fragment { | |||
@Override | |||
public void onSuccess(Object responseData) { | |||
ToastUtil.showInfo("上传分组["+list.get(position).getName()+"]下的配方信息成功"); | |||
RecordManager.getInstance().addLogRecord(LogType.数据上传,"上传分组["+list.get(position).getName()+"]下的配方信息成功"); | |||
uploadRecipeInfo(position+1); | |||
} | |||
@@ -323,6 +356,7 @@ public class ParSetFragment extends Fragment { | |||
public void onFailed(int failCode, Throwable throwable, String message) { | |||
DialogManager.showWarn("上传分组["+list.get(position).getName()+"]下的配方信息失败:"+message, | |||
DialogButton.OK,null); | |||
RecordManager.getInstance().addLogRecord(LogType.数据上传,"上传分组["+list.get(position).getName()+"]下的配方信息失败"); | |||
WaitProcessUtil.getInstance().dismiss(); | |||
} | |||
}); | |||
@@ -337,6 +371,7 @@ public class ParSetFragment extends Fragment { | |||
@Override | |||
public void onSuccess(Object responseData) { | |||
ToastUtil.showInfo("上传多属性成功"); | |||
RecordManager.getInstance().addLogRecord(LogType.数据上传,"上传多属性成功"); | |||
uploadRecipeBatching(); | |||
} | |||
@@ -349,6 +384,7 @@ public class ParSetFragment extends Fragment { | |||
@Override | |||
public void onFailed(int failCode, Throwable throwable, String message) { | |||
DialogManager.showWarn("上传多属性失败:"+message, DialogButton.OK,null); | |||
RecordManager.getInstance().addLogRecord(LogType.数据上传,"上传多属性失败:"+message); | |||
WaitProcessUtil.getInstance().dismiss(); | |||
} | |||
}); | |||
@@ -363,6 +399,7 @@ public class ParSetFragment extends Fragment { | |||
@Override | |||
public void onSuccess(Object responseData) { | |||
ToastUtil.showInfo("上传配方物料成功"); | |||
RecordManager.getInstance().addLogRecord(LogType.数据上传,"上传配方物料成功"); | |||
WaitProcessUtil.getInstance().dismiss(); | |||
} | |||
@@ -375,6 +412,7 @@ public class ParSetFragment extends Fragment { | |||
@Override | |||
public void onFailed(int failCode, Throwable throwable, String message) { | |||
DialogManager.showWarn("上传配方物料失败:"+message, DialogButton.OK,null); | |||
RecordManager.getInstance().addLogRecord(LogType.数据上传,"上传配方物料失败"); | |||
WaitProcessUtil.getInstance().dismiss(); | |||
} | |||
}); | |||
@@ -30,7 +30,11 @@ import java.util.List; | |||
* @description: 粉料仓图 | |||
* @date: 2024/10/8 16:56. | |||
*/ | |||
public class PowderSiloFragment extends Fragment { | |||
public class PowderSiloFragment extends BaseFragment { | |||
@Override | |||
protected String getClassName() { | |||
return "PowderSiloFragment粉料通道页"; | |||
} | |||
private FragmentPowderSiloBinding binding; | |||
@@ -123,7 +127,7 @@ public class PowderSiloFragment extends Fragment { | |||
@SuppressLint("SetTextI18n") | |||
private void updateSilo(int num, String batchName){ | |||
String name = "料仓"+num+"\n["+batchName+"]"; | |||
String name = "粉料通道"+num+"\n["+batchName+"]"; | |||
switch (num){ | |||
case 1: | |||
binding.silo1.setText(name); | |||
@@ -152,7 +156,7 @@ public class PowderSiloFragment extends Fragment { | |||
*/ | |||
public boolean handStart(int num){ | |||
try{ | |||
ToastUtil.showInfo("仓位"+num+":正在出料"); | |||
ToastUtil.showInfo("粉料通道"+num+":正在出料"); | |||
if(Config.isTest){ | |||
return false; | |||
} | |||
@@ -172,7 +176,7 @@ public class PowderSiloFragment extends Fragment { | |||
*/ | |||
public void handStop(int num){ | |||
try{ | |||
ToastUtil.showInfo("仓位"+num+":停止出料"); | |||
ToastUtil.showInfo("粉料通道"+num+":停止出料"); | |||
if(Config.isTest){ | |||
return; | |||
} | |||
@@ -57,7 +57,11 @@ import lecho.lib.hellocharts.model.ValueShape; | |||
* @description: 配方1-12月使用统计 折现走势图 饼状图 | |||
* @date: 2024/10/8 16:56. | |||
*/ | |||
public class RecipeUseLineChartFragment extends Fragment { | |||
public class RecipeUseLineChartFragment extends BaseFragment { | |||
@Override | |||
protected String getClassName() { | |||
return "RecipeUseLineChartFragment配方使用图表页"; | |||
} | |||
private FragmentRoundLineChartBinding binding; | |||
private TimePickerView pvTime; | |||
@@ -100,14 +104,14 @@ public class RecipeUseLineChartFragment extends Fragment { | |||
dialog.setListener(new RecipeNameListRecordDialog.OnDialogClickListener() { | |||
@Override | |||
public void onSelectName(List<NameColorBean> list) { | |||
nameList.clear(); | |||
nameList.addAll(list); | |||
adapter.notifyDataSetChanged(); | |||
queryData(); | |||
initChart(); | |||
} | |||
}); | |||
dialog.show(); | |||
dialog.setNameList(nameList); | |||
}); | |||
List<RecipeUseNum> defaultList = new ArrayList<>(); | |||
@@ -54,11 +54,14 @@ import lecho.lib.hellocharts.util.ChartUtils; | |||
* @description: 配方使用排行榜 | |||
* @date: 2024/10/8 16:56. | |||
*/ | |||
public class RecipeUseRankFragment extends Fragment { | |||
public class RecipeUseRankFragment extends BaseFragment { | |||
@Override | |||
protected String getClassName() { | |||
return "RecipeUseRankFragment配方使用排行榜"; | |||
} | |||
private FragmentColumnChartBinding binding; | |||
private ColumnChartData chartData; | |||
private ColumnChartData previewData; | |||
private TimePickerView pvTime; | |||
private List<RecipeUseNum> nameList = new ArrayList<>(); | |||
private RecipeNameRecordAdapter adapter; | |||
@@ -121,110 +124,8 @@ public class RecipeUseRankFragment extends Fragment { | |||
return; | |||
} | |||
queryData(); | |||
initChart(); | |||
}); | |||
queryData(); | |||
initChart(); | |||
} | |||
/** | |||
* 初始化图表 | |||
*/ | |||
private void initChart(){ | |||
initChartData(); | |||
binding.chart.setColumnChartData(chartData); | |||
binding.chart.setZoomEnabled(true); | |||
binding.chart.setScrollEnabled(true); | |||
binding.chart.setOnValueTouchListener(new ColumnChartOnValueSelectListener() { | |||
@Override | |||
public void onValueSelected(int position, int subcolumnIndex, SubcolumnValue value) { | |||
Log.d("///"," chart onValueSelected position="+position+";subcolumnIndex="+subcolumnIndex+";value="+value); | |||
binding.desc.setText((position+1)+".【"+nameList.get(position).getName()+"】 使用次数:"+nameList.get(position).getUseNum()); | |||
} | |||
@Override | |||
public void onValueDeselected() { | |||
Log.d("///","onValueDeselected"); | |||
} | |||
}); | |||
binding.previewChart.setColumnChartData(previewData); | |||
binding.previewChart.setViewportChangeListener(new ViewportListener()); | |||
Viewport tempViewport = new Viewport(binding.chart.getCurrentViewport()); | |||
if(nameList.size()>2){ | |||
tempViewport.left = 0; | |||
tempViewport.right = 15; | |||
} | |||
// tempViewport.inset(nameList.size(), 0); | |||
binding.previewChart.setCurrentViewport(tempViewport); | |||
binding.previewChart.setZoomType(ZoomType.HORIZONTAL); | |||
} | |||
private class ViewportListener implements ViewportChangeListener { | |||
@Override | |||
public void onViewportChanged(Viewport newViewport) { | |||
// don't use animation, it is unnecessary when using preview chart because usually viewport changes | |||
// happens to often. | |||
binding.chart.setCurrentViewport(newViewport); | |||
} | |||
} | |||
private void initChartData() { | |||
int numSubcolumns = 1; | |||
List<Column> columns = new ArrayList<Column>(); | |||
List<SubcolumnValue> values; | |||
for (int i = 0; i < nameList.size(); i++) { | |||
values = new ArrayList<SubcolumnValue>(); | |||
for (int j = 0; j < numSubcolumns; ++j) { | |||
values.add(new SubcolumnValue((float) (nameList.get(i).getUseNum()), Color.parseColor("#33B5E5"))); | |||
} | |||
Column column = new Column(values); | |||
column.setHasLabels(true); | |||
// column.setHasLabelsOnlyForSelected(false); | |||
columns.add(column); | |||
} | |||
List<AxisValue> valueList = new ArrayList<>(); | |||
List<String> list2 = new ArrayList<>(); | |||
for(int i=0;i<nameList.size();i++){ | |||
valueList.add(new AxisValue(i).setLabel((i+1)+"")); | |||
String s = String.valueOf(nameList.get(i).getUseNum()); | |||
if(i==0){ | |||
s = String.valueOf(nameList.get(i).getUseNum()+10); | |||
} | |||
list2.add(s); | |||
} | |||
Set<String> set = new HashSet<>(list2); | |||
List<String> uniqueList = new ArrayList<>(set); | |||
List<AxisValue> valueList2 = new ArrayList<>(); | |||
for(int i=0;i<uniqueList.size();i++){ | |||
valueList2.add(new AxisValue(Float.parseFloat(uniqueList.get(i)))); | |||
} | |||
chartData = new ColumnChartData(columns); | |||
Axis axisX = new Axis().setName("排序").setHasLines(true); | |||
axisX.setValues(valueList); | |||
chartData.setAxisXBottom(axisX); | |||
Axis axisY = new Axis().setHasLines(true).setName("配方使用次数"); | |||
axisY.setValues(valueList2); | |||
chartData.setAxisYLeft(axisY); | |||
previewData = new ColumnChartData(chartData); | |||
for (Column column : previewData.getColumns()) { | |||
for (SubcolumnValue value : column.getValues()) { | |||
value.setColor(ChartUtils.DEFAULT_DARKEN_COLOR); | |||
} | |||
} | |||
} | |||
/** | |||
@@ -13,11 +13,14 @@ import androidx.fragment.app.Fragment; | |||
import com.jdzh.jdzhandroid.Config.Config; | |||
import com.jdzh.jdzhandroid.Enum.DialogButton; | |||
import com.jdzh.jdzhandroid.Enum.LogType; | |||
import com.jdzh.jdzhandroid.Log.RecordManager; | |||
import com.jdzh.jdzhandroid.Sqlite.DAO.BPA_RecipeUseDetailDao; | |||
import com.jdzh.jdzhandroid.Sqlite.Model.BPA_RecipeUseDetail; | |||
import com.jdzh.jdzhandroid.Sqlite.SqliteHelper; | |||
import com.jdzh.jdzhandroid.Task.TaskManager; | |||
import com.jdzh.jdzhandroid.UI.activity.BatchingRecordActivity; | |||
import com.jdzh.jdzhandroid.UI.activity.LogRecordActivity; | |||
import com.jdzh.jdzhandroid.UI.activity.RecipeBillingActivity; | |||
import com.jdzh.jdzhandroid.UI.activity.RecipeRecordActivity; | |||
import com.jdzh.jdzhandroid.UI.view.WaitProcessUtil; | |||
@@ -31,7 +34,13 @@ import com.jdzh.jdzhandroid.util.ToastUtil; | |||
import java.io.File; | |||
import java.util.List; | |||
public class RecordFragment extends Fragment { | |||
public class RecordFragment extends BaseFragment { | |||
@Override | |||
protected String getClassName() { | |||
return "RecordFragment记录页"; | |||
} | |||
private FragmentRecordBinding binding; | |||
@Override | |||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { | |||
@@ -50,6 +59,10 @@ public class RecordFragment extends Fragment { | |||
private void initView(){ | |||
binding.btnLog.setOnClickListener(v->{ | |||
Intent intent = new Intent(getActivity(), LogRecordActivity.class); | |||
startActivity(intent); | |||
}); | |||
binding.recipeReocrd.setOnClickListener((v)->{ | |||
Intent intent = new Intent(getActivity(), RecipeRecordActivity.class); | |||
startActivity(intent); | |||
@@ -89,6 +102,7 @@ public class RecordFragment extends Fragment { | |||
for(BPA_RecipeUseDetail bean:useDetails){ | |||
bean.setUpLoad(true); | |||
} | |||
RecordManager.getInstance().addLogRecord(LogType.数据上传,"上传配方使用记录成功"); | |||
TaskManager.get().execute(new Runnable() { | |||
@Override | |||
public void run() { | |||
@@ -106,6 +120,7 @@ public class RecordFragment extends Fragment { | |||
@Override | |||
public void onFailed(int failCode, Throwable throwable, String message) { | |||
DialogManager.showWarn("上传配方使用记录失败:"+message, DialogButton.OK,null); | |||
RecordManager.getInstance().addLogRecord(LogType.数据上传,"上传配方使用记录失败"); | |||
WaitProcessUtil.getInstance().dismiss(); | |||
} | |||
}); | |||
@@ -120,6 +135,7 @@ public class RecordFragment extends Fragment { | |||
@Override | |||
public void onSuccess(Object responseData) { | |||
ToastUtil.showInfo("上传文件成功"); | |||
RecordManager.getInstance().addLogRecord(LogType.数据上传,"上传文件成功"); | |||
WaitProcessUtil.getInstance().dismiss(); | |||
} | |||
@@ -132,6 +148,7 @@ public class RecordFragment extends Fragment { | |||
@Override | |||
public void onFailed(int failCode, Throwable throwable, String message) { | |||
DialogManager.showWarn("上传文件失败:"+message, DialogButton.OK,null); | |||
RecordManager.getInstance().addLogRecord(LogType.数据上传,"上传文件失败"); | |||
WaitProcessUtil.getInstance().dismiss(); | |||
} | |||
}); | |||
@@ -14,6 +14,9 @@ import androidx.fragment.app.Fragment; | |||
import com.apkfuns.logutils.LogUtils; | |||
import com.jdzh.jdzhandroid.Config.Config; | |||
import com.jdzh.jdzhandroid.Enum.DialogButton; | |||
import com.jdzh.jdzhandroid.Enum.LogType; | |||
import com.jdzh.jdzhandroid.Interface.IRunT; | |||
import com.jdzh.jdzhandroid.Log.RecordManager; | |||
import com.jdzh.jdzhandroid.UI.activity.LoginActivity; | |||
import com.jdzh.jdzhandroid.UI.activity.WelcomeActivity; | |||
import com.jdzh.jdzhandroid.UI.view.WaitProcessUtil; | |||
@@ -26,7 +29,12 @@ import com.jdzh.jdzhandroid.util.DisplayManager; | |||
import com.jdzh.jdzhandroid.util.PreferenceUtils; | |||
import com.jdzh.jdzhandroid.util.ToastUtil; | |||
public class SystemSetFragment extends Fragment { | |||
public class SystemSetFragment extends BaseFragment { | |||
@Override | |||
protected String getClassName() { | |||
return "SystemSetFragment系统设置"; | |||
} | |||
private FragmentSystemSetBinding binding; | |||
@Override | |||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { | |||
@@ -52,6 +60,7 @@ public class SystemSetFragment extends Fragment { | |||
dataBean.setOrgName(PreferenceUtils.getString(Config.SHARE_KEY_company,"")); | |||
dataBean.setDevicePosition(PreferenceUtils.getString(Config.SHARE_KEY_deviceLocation,"")); | |||
dataBean.setStoreName(PreferenceUtils.getString(Config.SHARE_KEY_storeName,"")); | |||
dataBean.setDeviceName(PreferenceUtils.getString(Config.SHARE_KEY_deviceName,"")); | |||
dataBean.setStorePhone(PreferenceUtils.getString(Config.SHARE_KEY_storePhone,"")); | |||
dataBean.setContactPhone(PreferenceUtils.getString(Config.SHARE_KEY_wePhone,"")); | |||
changeView(dataBean); | |||
@@ -60,30 +69,43 @@ public class SystemSetFragment extends Fragment { | |||
ToastUtil.showInfo("对不起,当前账号暂无权限!"); | |||
return; | |||
} | |||
Config.getInstance().autoKey = binding.edtDeviceKey.getText().toString(); | |||
PreferenceUtils.setString(Config.SHARE_KEY_autoKey,Config.getInstance().autoKey); | |||
WaitProcessUtil.getInstance().show(getContext(),"请稍等","正在获取设备信息,请耐心等待...",false); | |||
ServerManager.getDeviceInfo(new IHttpCallBack<DeviceInfoDataBean>() { | |||
DialogManager.showWarn("请确认平台提供的设备autokey是否正确?", DialogButton.YesNo, new IRunT<Boolean>() { | |||
@Override | |||
public void onSuccess(DeviceInfoDataBean deviceInfoDataBean) { | |||
ToastUtil.showInfo("获取设备信息成功"); | |||
changeView(deviceInfoDataBean); | |||
WaitProcessUtil.getInstance().dismiss(); | |||
} | |||
public void Run(Boolean aBoolean) { | |||
if(aBoolean){ | |||
RecordManager.getInstance().addLogRecord(LogType.角色操作,getClassName()+" 保存设备autokey="+binding.edtDeviceKey.getText().toString()); | |||
@Override | |||
public void onError(int failCode, String msg) { | |||
DialogManager.showWarn("获取设备信息报错:failCode="+failCode+" description="+msg, DialogButton.OK,null); | |||
changeView(null); | |||
WaitProcessUtil.getInstance().dismiss(); | |||
} | |||
Config.getInstance().autoKey = binding.edtDeviceKey.getText().toString(); | |||
PreferenceUtils.setString(Config.SHARE_KEY_autoKey,Config.getInstance().autoKey); | |||
WaitProcessUtil.getInstance().show(getContext(),"请稍等","正在获取设备信息,请耐心等待...",false); | |||
ServerManager.getDeviceInfo(new IHttpCallBack<DeviceInfoDataBean>() { | |||
@Override | |||
public void onSuccess(DeviceInfoDataBean deviceInfoDataBean) { | |||
ToastUtil.showInfo("获取设备信息成功"); | |||
changeView(deviceInfoDataBean); | |||
WaitProcessUtil.getInstance().dismiss(); | |||
RecordManager.getInstance().addLogRecord(LogType.数据接收,"获取设备信息成功"); | |||
@Override | |||
public void onFailed(int failCode, Throwable throwable, String message) { | |||
DialogManager.showWarn("获取设备信息失败:failCode="+failCode+" description="+message, DialogButton.OK,null); | |||
changeView(null); | |||
WaitProcessUtil.getInstance().dismiss(); | |||
} | |||
@Override | |||
public void onError(int failCode, String msg) { | |||
DialogManager.showWarn("获取设备信息报错:failCode="+failCode+" description="+msg, DialogButton.OK,null); | |||
changeView(null); | |||
RecordManager.getInstance().addLogRecord(LogType.数据接收,"获取设备信息报错:failCode="+failCode+" description="+msg); | |||
WaitProcessUtil.getInstance().dismiss(); | |||
} | |||
@Override | |||
public void onFailed(int failCode, Throwable throwable, String message) { | |||
DialogManager.showWarn("获取设备信息失败:failCode="+failCode+" description="+message, DialogButton.OK,null); | |||
changeView(null); | |||
RecordManager.getInstance().addLogRecord(LogType.数据接收,"获取设备信息失败:failCode="+failCode+" description="+message); | |||
WaitProcessUtil.getInstance().dismiss(); | |||
} | |||
}); | |||
} | |||
} | |||
}); | |||
}); | |||
@@ -92,6 +114,7 @@ public class SystemSetFragment extends Fragment { | |||
if(getActivity()!=null){ | |||
getActivity().finish(); | |||
} | |||
Config.getInstance().isLogin = false; | |||
Intent intent = new Intent(getContext(), LoginActivity.class); | |||
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); | |||
startActivity(intent); | |||
@@ -105,11 +128,13 @@ public class SystemSetFragment extends Fragment { | |||
PreferenceUtils.setString(Config.SHARE_KEY_deviceId,data.getDeviceId()); | |||
PreferenceUtils.setString(Config.SHARE_KEY_company,data.getOrgName()); | |||
PreferenceUtils.setString(Config.SHARE_KEY_deviceLocation,data.getDevicePosition()); | |||
PreferenceUtils.setString(Config.SHARE_KEY_storeId,data.getStoreId()); | |||
PreferenceUtils.setString(Config.SHARE_KEY_storeName,data.getStoreName()); | |||
PreferenceUtils.setString(Config.SHARE_KEY_storePhone,data.getStorePhone()); | |||
PreferenceUtils.setString(Config.SHARE_KEY_wePhone,data.getContactPhone()); | |||
PreferenceUtils.setString(Config.SHARE_KEY_deviceName,data.getDeviceName()); | |||
binding.tvDeviceKey.setText("设备编号:"+(data.getDeviceId()==null?"":data.getDeviceId())); | |||
binding.tvDeviceKey.setText("设备编号:"+Config.getInstance().autoKey); | |||
binding.tvCompanyName.setText("主体单位:"+(data.getOrgName()==null?"":data.getOrgName())); | |||
binding.tvDeviceLocation.setText("设备位置:"+(data.getDevicePosition()==null?"":data.getDevicePosition())); | |||
binding.tvStoreLocation.setText("门店信息:"+(data.getStoreName()==null?"":data.getStoreName())); | |||
@@ -117,7 +142,7 @@ public class SystemSetFragment extends Fragment { | |||
binding.tvPhoneAdmin.setText("联系我们:"+(data.getContactPhone()==null?"":data.getContactPhone())); | |||
// binding.tvLocationAdmin.setText(""); | |||
}else { | |||
binding.tvDeviceKey.setText("设备编号:"); | |||
binding.tvDeviceKey.setText("设备编号:"+Config.getInstance().autoKey); | |||
binding.tvCompanyName.setText("主体单位:"); | |||
binding.tvDeviceLocation.setText("设备位置:"); | |||
binding.tvStoreLocation.setText("门店信息:"); | |||
@@ -22,6 +22,7 @@ import com.jdzh.jdzhandroid.databinding.ItemTextValueBinding; | |||
public class TextNameView extends FrameLayout { | |||
private ItemTextNameBinding binding; | |||
private String name; | |||
public String batchingName; | |||
private int color; | |||
public TextNameView(Context context){ | |||
@@ -32,6 +33,12 @@ public class TextNameView extends FrameLayout { | |||
public void setData(String name, int color){ | |||
this.name = name; | |||
this.color = color; | |||
if(name.contains("-")){ | |||
String[] split = name.split("-"); | |||
this.batchingName = split[0]; | |||
}else { | |||
this.batchingName = name; | |||
} | |||
init(); | |||
} | |||
@@ -2,6 +2,8 @@ package com.jdzh.jdzhandroid.api; | |||
import android.content.Context; | |||
import com.jdzh.jdzhandroid.Enum.LogType; | |||
import com.jdzh.jdzhandroid.Log.RecordManager; | |||
import com.jdzh.jdzhandroid.Sqlite.DAO.BPA_RecipeBaseConfigDao; | |||
import com.jdzh.jdzhandroid.Sqlite.DAO.BPA_RecipeBathingUseDetailDao; | |||
import com.jdzh.jdzhandroid.Sqlite.DAO.BPA_RecipeConfigDao; | |||
@@ -57,6 +59,7 @@ public class ServerManager { | |||
*/ | |||
public static void getBatching(IHttpCallBack<ArrayList<BPA_Batching>> callback) { | |||
String url = mainUrl + "/api/interface/getBatching"; | |||
RecordManager.getInstance().addLogRecord(LogType.数据接收,"获取物料信息"+url); | |||
Call call = HttpUtil.getService(Api.class).getBatching(url); | |||
resEnqueue(call, callback); | |||
} | |||
@@ -66,6 +69,7 @@ public class ServerManager { | |||
*/ | |||
public static void getUsers(IHttpCallBack<ArrayList<UsersDataBean>> callback) { | |||
String url = mainUrl + "/api/interface/getUsers"; | |||
RecordManager.getInstance().addLogRecord(LogType.数据接收,"获取账号"+url); | |||
Call call = HttpUtil.getService(Api.class).getUsers(url); | |||
resEnqueue(call, callback); | |||
} | |||
@@ -75,6 +79,7 @@ public class ServerManager { | |||
*/ | |||
public static void getDeviceInfo(IHttpCallBack<DeviceInfoDataBean> callback) { | |||
String url = mainUrl + "/api/interface/getDeviceInfo"; | |||
RecordManager.getInstance().addLogRecord(LogType.数据接收,"获取设备信息"+url); | |||
Call call = HttpUtil.getService(Api.class).getDeviceInfo(url); | |||
resEnqueue(call, callback); | |||
} | |||
@@ -84,6 +89,7 @@ public class ServerManager { | |||
*/ | |||
public static void getRecipeList(IHttpCallBack<RecipeListBean> callback) { | |||
String url = mainUrl + "/api/interface/getRecipeList"; | |||
RecordManager.getInstance().addLogRecord(LogType.数据接收,"获取所有配方"+url); | |||
Call call = HttpUtil.getService(Api.class).getRecipeList(url); | |||
resEnqueue(call, callback); | |||
} | |||
@@ -94,7 +100,7 @@ public class ServerManager { | |||
public static void uploadBatching(Context context,IHttpCallBack<Object> callback) { | |||
WaitProcessUtil.getInstance().show(context,"请稍等","正在上传物料信息,请耐心等待...",false); | |||
String url = mainUrl + "/api/interface/uploadBatching"; | |||
RecordManager.getInstance().addLogRecord(LogType.数据上传,"上传物料信息"+url); | |||
List<BatchBean> dataList = new ArrayList<>(); | |||
for(BPA_Batching bean : SqliteHelper.get().queryAll(BPA_Batching.class)){ | |||
BatchBean data = new BatchBean(); | |||
@@ -117,6 +123,7 @@ public class ServerManager { | |||
public static void uploadRecipeGroup(Context context,IHttpCallBack<Object> callback) { | |||
WaitProcessUtil.getInstance().show(context,"请稍等","正在上传所有配方分组,请耐心等待...",false); | |||
String url = mainUrl + "/api/interface/uploadRecipeGroup"; | |||
RecordManager.getInstance().addLogRecord(LogType.数据上传,"上传配方分组"+url); | |||
List<RecipeGroupBean> dataList = new ArrayList<>(); | |||
for(BPA_RecipeGroup bean : SqliteHelper.get().queryAll(BPA_RecipeGroup.class)){ | |||
RecipeGroupBean data = new RecipeGroupBean(); | |||
@@ -138,6 +145,7 @@ public class ServerManager { | |||
public static void uploadRecipeInfo(Context context,BPA_RecipeGroup recipeGroup,IHttpCallBack<Object> callback) { | |||
WaitProcessUtil.getInstance().show(context,"请稍等","正在上传配方分组["+recipeGroup.getName()+"]下的所有配方,请耐心等待...",false); | |||
String url = mainUrl + "/api/interface/uploadRecipeInfo"; | |||
RecordManager.getInstance().addLogRecord(LogType.数据上传,"上传配方信息"+url); | |||
RecipeInfoBean recipeInfoBean = new RecipeInfoBean(); | |||
recipeInfoBean.setRecipeGroupId(recipeGroup.getId()); | |||
@@ -171,6 +179,7 @@ public class ServerManager { | |||
public static void uploadRecipeAttr(Context context,IHttpCallBack<Object> callback) { | |||
WaitProcessUtil.getInstance().show(context,"请稍等","正在上传多属性,请耐心等待...",false); | |||
String url = mainUrl + "/api/interface/uploadRecipeAttr"; | |||
RecordManager.getInstance().addLogRecord(LogType.数据上传,"上传配方多属性"+url); | |||
List<RecipeAttributeBean> recipeAttributeList = new ArrayList<>(); | |||
for(BPA_RecipeInfo bean:SqliteHelper.get().queryAll(BPA_RecipeInfo.class)){ | |||
RecipeAttributeBean recipeAttributeBean = new RecipeAttributeBean(); | |||
@@ -215,6 +224,7 @@ public class ServerManager { | |||
WaitProcessUtil.getInstance().show(context,"请稍等","正在上传所有配方物料详情,请耐心等待...",false); | |||
String url = mainUrl + "/api/interface/uploadRecipeBatching"; | |||
List<RecipeBatchBean> recipeBatchBeans = new ArrayList<>(); | |||
RecordManager.getInstance().addLogRecord(LogType.数据上传,"上传配方物料详情"+url); | |||
for(BPA_RecipeInfo bean:SqliteHelper.get().queryByQueryBuilder(BPA_RecipeInfo.class, | |||
BPA_RecipeInfoDao.Properties.Name.notEq(""))){ | |||
@@ -281,6 +291,7 @@ public class ServerManager { | |||
WaitProcessUtil.getInstance().show(context,"请稍等","正在上传所有配方详情,请耐心等待...",false); | |||
String url = mainUrl + "/api/interface/uploadRecipeUseDetail"; | |||
List<RecipeUseDetailBean> recipeUseDetailBeans = new ArrayList<>(); | |||
RecordManager.getInstance().addLogRecord(LogType.数据上传,"上传配方使用详情"+url); | |||
for(BPA_RecipeUseDetail bean:SqliteHelper.get().queryByQueryBuilder(BPA_RecipeUseDetail.class, | |||
BPA_RecipeUseDetailDao.Properties.UpLoad.eq(false))){ | |||
@@ -314,6 +325,7 @@ public class ServerManager { | |||
*/ | |||
public static void uploadDeviceLog(Context context,File file,IHttpCallBack<Object> callback) { | |||
String url = mainUrl + "/api/interface/uploadDeviceLog"; | |||
RecordManager.getInstance().addLogRecord(LogType.数据上传,"上传日志文件"+url+" filename:"+file.getName()); | |||
WaitProcessUtil.getInstance().show(context,"请稍等","正在上传文件,请耐心等待...",false); | |||
RequestBody body = new MultipartBody.Builder().setType(MultipartBody.FORM) | |||
.addFormDataPart("formFile",file.getName()+"-"+new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()), | |||
@@ -328,6 +340,7 @@ public class ServerManager { | |||
public static void uploadCrashLog(File file,IHttpCallBack<Object> callback) { | |||
String url = mainUrl + "/api/interface/uploadDeviceLog"; | |||
RecordManager.getInstance().addLogRecord(LogType.数据上传,"上传崩溃日志文件"+url+" filename:"+file.getName()); | |||
RequestBody body = new MultipartBody.Builder().setType(MultipartBody.FORM) | |||
.addFormDataPart("formFile",file.getName()+"-"+new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()), | |||
RequestBody.create(MediaType.parse("application/octet-stream"),file)) | |||
@@ -0,0 +1,119 @@ | |||
package com.jdzh.jdzhandroid.util; | |||
import java.text.ParseException; | |||
import java.text.SimpleDateFormat; | |||
import java.util.Date; | |||
public class DateUtils { | |||
/** | |||
* 比较两个日期的大小,日期格式为yyyy-MM-dd | |||
* | |||
* @param str1 the first date | |||
* @param str2 the second date | |||
* @return true <br/>false | |||
*/ | |||
public static boolean isDateOneBigger(String str1, String str2) { | |||
boolean isBigger = false; | |||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); | |||
Date dt1 = null; | |||
Date dt2 = null; | |||
try { | |||
dt1 = sdf.parse(str1); | |||
dt2 = sdf.parse(str2); | |||
} catch (ParseException e) { | |||
e.printStackTrace(); | |||
} | |||
if (dt1.getTime() > dt2.getTime()) { | |||
isBigger = true; | |||
} else if (dt1.getTime() < dt2.getTime()) { | |||
isBigger = false; | |||
} | |||
return isBigger; | |||
} | |||
/** | |||
* 比较两个日期的大小,日期格式为yyyy-MM-dd | |||
* | |||
* @param str1 the first date | |||
* @param str2 the second date | |||
* @return true <br/>false | |||
*/ | |||
public static boolean isDate2Bigger(String str1, String str2) { | |||
boolean isBigger = false; | |||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); | |||
Date dt1 = null; | |||
Date dt2 = null; | |||
try { | |||
dt1 = sdf.parse(str1); | |||
dt2 = sdf.parse(str2); | |||
} catch (ParseException e) { | |||
e.printStackTrace(); | |||
} | |||
if (dt1.getTime() > dt2.getTime()) { | |||
isBigger = false; | |||
} else if (dt1.getTime() <= dt2.getTime()) { | |||
isBigger = true; | |||
} | |||
return isBigger; | |||
} | |||
/** | |||
* 比较当前时间和服务器返回时间大小 | |||
* | |||
* @param nowDate | |||
* @param compareDate | |||
* @return | |||
*/ | |||
public static boolean compareDate(String nowDate, String compareDate) { | |||
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); | |||
try { | |||
Date now = df.parse(nowDate); | |||
Date compare = df.parse(compareDate); | |||
if (now.before(compare)) { | |||
return true; | |||
} else { | |||
return false; | |||
} | |||
} catch (ParseException e) { | |||
e.printStackTrace(); | |||
return false; | |||
} | |||
} | |||
/*** | |||
* 获取当前日期距离过期时间的日期差值 | |||
* @param endTime | |||
* @return | |||
*/ | |||
public static long dateDiff(String endTime) { | |||
long strTime = 0; | |||
// 按照传入的格式生成一个simpledateformate对象 | |||
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm"); | |||
long nd = 1000 * 24 * 60 * 60;// 一天的毫秒数 | |||
long nh = 1000 * 60 * 60;// 一小时的毫秒数 | |||
long nm = 1000 * 60;// 一分钟的毫秒数 | |||
long ns = 1000;// 一秒钟的毫秒数 | |||
long diff; | |||
long day = 0; | |||
String nowtime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date());; | |||
try { | |||
// 获得两个时间的毫秒时间差异 | |||
diff = simpleDateFormat.parse(nowtime).getTime() - simpleDateFormat.parse(endTime).getTime(); | |||
day = diff / nd;// 计算差多少天 | |||
long hour = diff % nd / nh;// 计算差多少小时 | |||
long min = diff % nd % nh / nm;// 计算差多少分钟 | |||
long sec = diff % nd % nh % nm / ns;// 计算差多少秒 | |||
// 输出结果 | |||
strTime = sec; | |||
return strTime; | |||
} catch (ParseException e) { | |||
e.printStackTrace(); | |||
} | |||
return strTime; | |||
} | |||
} | |||
@@ -0,0 +1,50 @@ | |||
package com.jdzh.jdzhandroid.util; | |||
import android.os.Environment; | |||
import java.io.File; | |||
import java.text.DecimalFormat; | |||
/** | |||
* @author: liup | |||
* @description: | |||
* @date: 2024/10/25 13:26. | |||
*/ | |||
public class FileUtil { | |||
/** | |||
* 获取数据库文件夹内存大小 | |||
* @return | |||
*/ | |||
public static String getCacheSize(){ | |||
String sizeString = ""; | |||
try { | |||
File folder = new File(Environment.getExternalStorageDirectory().getAbsolutePath()+"/jdzhdb"); // 替换为你的文件夹路径 | |||
long folderSize = getFolderSize(folder); | |||
sizeString = formatSize(folderSize); // 将大小转换为可读的格式(可选) | |||
}catch (Exception e){ | |||
e.printStackTrace(); | |||
} | |||
return sizeString; | |||
} | |||
public static long getFolderSize(File dir) { | |||
long size = 0; | |||
if (dir != null && dir.isDirectory()) { | |||
File[] files = dir.listFiles(); | |||
for (File file : files) { | |||
if (file.isFile()) { | |||
size += file.length(); | |||
} else if (file.isDirectory()) { | |||
size += getFolderSize(file); // 递归调用以获取子文件夹的大小 | |||
} | |||
} | |||
} | |||
return size; | |||
} | |||
public static String formatSize(long size) { | |||
if (size <= 0) return "0 Bytes"; | |||
final String[] units = {"Bytes", "KB", "MB", "GB", "TB"}; | |||
int digitGroups = (int) (Math.log10(size) / Math.log10(1024)); | |||
return new DecimalFormat("#,##0.#").format(size / Math.pow(1024, digitGroups)) + " " + units[digitGroups]; | |||
} | |||
} |
@@ -1,5 +1,7 @@ | |||
package com.jdzh.jdzhandroid.util; | |||
import com.jdzh.jdzhandroid.Enum.LogType; | |||
import com.jdzh.jdzhandroid.Log.RecordManager; | |||
import com.jdzh.jdzhandroid.Sqlite.DAO.BPA_RecipeBaseConfigDao; | |||
import com.jdzh.jdzhandroid.Sqlite.DAO.BPA_RecipeConfigDao; | |||
import com.jdzh.jdzhandroid.Sqlite.DAO.BPA_RecipeConfigDetailDao; | |||
@@ -63,7 +65,11 @@ public class RecipeEditUtil { | |||
* @param recipeInfos | |||
*/ | |||
public static void deleteRecipe(List<BPA_RecipeInfo> recipeInfos){ | |||
List<String> names = new ArrayList<>(); | |||
for(BPA_RecipeInfo recipeInfo:recipeInfos){ | |||
if(recipeInfo.getName()!=null && !recipeInfo.getName().isEmpty()){ | |||
names.add(recipeInfo.getName()); | |||
} | |||
List<BPA_RecipeConfig> recipeConfigs = SqliteHelper.get().queryByBuilder(BPA_RecipeConfig.class, | |||
BPA_RecipeConfigDao.Properties.RecipeId.eq(recipeInfo.getId())); | |||
for(BPA_RecipeConfig config:recipeConfigs){ | |||
@@ -94,6 +100,8 @@ public class RecipeEditUtil { | |||
//删除多属性 | |||
SqliteHelper.get().deleteMulti(recipeattributes); | |||
} | |||
RecordManager.getInstance().addLogRecord(LogType.角色操作," 删除配方页 "+names.toString()); | |||
//删除配方 | |||
SqliteHelper.get().deleteMulti(recipeInfos); | |||
} | |||
@@ -104,10 +112,15 @@ public class RecipeEditUtil { | |||
* @param recipeGroup | |||
*/ | |||
public static void deleteRecipeGroup(BPA_RecipeGroup recipeGroup){ | |||
List<String> names = new ArrayList<>(); | |||
//删除配方 | |||
List<BPA_RecipeInfo> recipeInfos = SqliteHelper.get().queryByBuilder(BPA_RecipeInfo.class, | |||
BPA_RecipeInfoDao.Properties.RecipeGroupId.eq(recipeGroup.getId())); | |||
for(BPA_RecipeInfo recipeInfo:recipeInfos){ | |||
if(recipeInfo.getName()!=null && !recipeInfo.getName().isEmpty()){ | |||
names.add(recipeInfo.getName()); | |||
} | |||
List<BPA_RecipeConfig> recipeConfigs = SqliteHelper.get().queryByBuilder(BPA_RecipeConfig.class, | |||
BPA_RecipeConfigDao.Properties.RecipeId.eq(recipeInfo.getId())); | |||
for(BPA_RecipeConfig config:recipeConfigs){ | |||
@@ -138,6 +151,9 @@ public class RecipeEditUtil { | |||
//删除多属性 | |||
SqliteHelper.get().deleteMulti(recipeattributes); | |||
} | |||
RecordManager.getInstance().addLogRecord(LogType.角色操作," 删除配方分组 "+recipeGroup.getName()); | |||
RecordManager.getInstance().addLogRecord(LogType.角色操作," 删除配方分组 下所有配方 "+names.toString()); | |||
//删除配方 | |||
SqliteHelper.get().deleteMulti(recipeInfos); | |||
//删除分类 | |||
@@ -9,8 +9,10 @@ import com.jdzh.jdzhandroid.Business.Global; | |||
import com.jdzh.jdzhandroid.Business.PlcControl; | |||
import com.jdzh.jdzhandroid.Business.TaskControl; | |||
import com.jdzh.jdzhandroid.Enum.DialogButton; | |||
import com.jdzh.jdzhandroid.Enum.LogType; | |||
import com.jdzh.jdzhandroid.Enum.Status; | |||
import com.jdzh.jdzhandroid.Log.MessageLog; | |||
import com.jdzh.jdzhandroid.Log.RecordManager; | |||
import com.jdzh.jdzhandroid.Task.Task; | |||
import com.jdzh.jdzhandroid.Config.Config; | |||
import com.jdzh.jdzhandroid.util.Dialog.DialogManager; | |||
@@ -24,33 +26,32 @@ import java.util.Objects; | |||
import java.util.concurrent.atomic.AtomicBoolean; | |||
public class ChannelViewModel extends ViewModel { | |||
public MutableLiveData<String> chNum=new MutableLiveData<>("1"); | |||
public MutableLiveData<String> weight=new MutableLiveData<>("1"); | |||
public MutableLiveData<String> log=new MutableLiveData<>(""); | |||
/** | |||
* 精度条 | |||
*/ | |||
public MutableLiveData<String> progress = new MutableLiveData<>(""); | |||
public MutableLiveData<Integer> progressNum = new MutableLiveData<>(0); | |||
/** | |||
* 当前校准通道名称 | |||
*/ | |||
public MutableLiveData<Integer> progressMax = new MutableLiveData<>(16); | |||
public MutableLiveData<String> curChannelName = new MutableLiveData<>(""); | |||
/** | |||
* 正在执行描述 | |||
*/ | |||
public MutableLiveData<String> desc = new MutableLiveData<>(""); | |||
public MutableLiveData<String> CalibrationTimeBase1=new MutableLiveData<>("100"); | |||
public MutableLiveData<String> CalibrationTimeBase2=new MutableLiveData<>("1000"); | |||
public MutableLiveData<String> CalibrationTimeCount1=new MutableLiveData<>("10"); | |||
public MutableLiveData<String> CalibrationTimeCount2=new MutableLiveData<>("4"); | |||
public int type = 1;//1粉料 2液体 | |||
public int channelNum=0;//通道号 | |||
public String batchingName;//绑定的物料名 | |||
public int CalibrationTimeBase1= 100; | |||
public int CalibrationTimeBase2=1000; | |||
public int CalibrationTimeCount1=10; | |||
public int CalibrationTimeCount2=4; | |||
public MutableLiveData<String> CalibrationTimeBase3=new MutableLiveData<>("100"); | |||
public MutableLiveData<String> CalibrationTimeBase4=new MutableLiveData<>("1000"); | |||
public MutableLiveData<String> CalibrationTimeCount3=new MutableLiveData<>("10"); | |||
public MutableLiveData<String> CalibrationTimeCount4=new MutableLiveData<>("4"); | |||
public int CalibrationTimeBase3=100; | |||
public int CalibrationTimeBase4=1000; | |||
public int CalibrationTimeCount3=10; | |||
public int CalibrationTimeCount4=4; | |||
/** | |||
* 正在校准 | |||
@@ -62,31 +63,17 @@ public class ChannelViewModel extends ViewModel { | |||
} | |||
private void CalibrationParConfig(){ | |||
try{ | |||
int _calibrationTimeBase1,_calibrationTimeBase2,_calibrationTimeCount1,_calibrationTimeCount2; | |||
_calibrationTimeBase1=Integer.parseInt(CalibrationTimeBase1.getValue()); | |||
_calibrationTimeBase2=Integer.parseInt(CalibrationTimeBase2.getValue()); | |||
_calibrationTimeCount1=Integer.parseInt(CalibrationTimeCount1.getValue()); | |||
_calibrationTimeCount2=Integer.parseInt(CalibrationTimeCount2.getValue()); | |||
PlcControl.get().CalibrationBase.clear(); | |||
PlcControl.get().CalibrationBase.put(_calibrationTimeBase1,_calibrationTimeCount1); | |||
PlcControl.get().CalibrationBase.put(_calibrationTimeBase2,_calibrationTimeCount2); | |||
PlcControl.get().CalibrationBase.clear(); | |||
PlcControl.get().CalibrationBase.put(CalibrationTimeBase1,CalibrationTimeCount1); | |||
PlcControl.get().CalibrationBase.put(CalibrationTimeBase2,CalibrationTimeCount2); | |||
int _calibrationTimeBase3,_calibrationTimeBase4,_calibrationTimeCount3,_calibrationTimeCount4; | |||
_calibrationTimeBase3=Integer.parseInt(CalibrationTimeBase3.getValue()); | |||
_calibrationTimeBase4=Integer.parseInt(CalibrationTimeBase4.getValue()); | |||
_calibrationTimeCount3=Integer.parseInt(CalibrationTimeCount3.getValue()); | |||
_calibrationTimeCount4=Integer.parseInt(CalibrationTimeCount4.getValue()); | |||
PlcControl.get().CalibrationBase2.clear(); | |||
PlcControl.get().CalibrationBase2.put(_calibrationTimeBase3,_calibrationTimeCount3); | |||
PlcControl.get().CalibrationBase2.put(_calibrationTimeBase4,_calibrationTimeCount4); | |||
}catch (Exception e){ | |||
MessageLog.ShowError("CalibrationParConfig " +e); | |||
} | |||
PlcControl.get().CalibrationBase2.clear(); | |||
PlcControl.get().CalibrationBase2.put(CalibrationTimeBase3,CalibrationTimeCount3); | |||
PlcControl.get().CalibrationBase2.put(CalibrationTimeBase4,CalibrationTimeCount4); | |||
} | |||
/** | |||
* 一键校准 通道校准 | |||
* 通道校准 | |||
*/ | |||
public void calibration(){ | |||
if(isCalibrating){ | |||
@@ -99,97 +86,54 @@ public class ChannelViewModel extends ViewModel { | |||
return; | |||
} | |||
} | |||
if(Objects.equals(CalibrationTimeBase1.getValue(), "") || | |||
Objects.equals(CalibrationTimeBase2.getValue(), "")|| | |||
Objects.equals(CalibrationTimeBase3.getValue(), "")|| | |||
Objects.equals(CalibrationTimeBase4.getValue(), "")|| | |||
Objects.equals(CalibrationTimeCount1.getValue(), "")|| | |||
Objects.equals(CalibrationTimeCount2.getValue(), "")|| | |||
Objects.equals(CalibrationTimeCount3.getValue(), "")|| | |||
Objects.equals(CalibrationTimeCount4.getValue(), "") | |||
){ | |||
DialogManager.showWarn("参数不能为空!", DialogButton.OK,null); | |||
return; | |||
} | |||
if(Integer.parseInt(CalibrationTimeBase1.getValue())<=0|| | |||
Integer.parseInt(CalibrationTimeBase2.getValue())<=0|| | |||
Integer.parseInt(CalibrationTimeCount1.getValue())<=0|| | |||
Integer.parseInt(CalibrationTimeCount2.getValue())<=0|| | |||
Integer.parseInt(CalibrationTimeBase3.getValue())<=0|| | |||
Integer.parseInt(CalibrationTimeBase4.getValue())<=0|| | |||
Integer.parseInt(CalibrationTimeCount3.getValue())<=0|| | |||
Integer.parseInt(CalibrationTimeCount4.getValue())<=0 | |||
){ | |||
DialogManager.showWarn("参数不能小于等于0!", DialogButton.OK,null); | |||
return; | |||
} | |||
if(CalibrationTimeBase1.getValue().equals(CalibrationTimeBase2.getValue())|| | |||
CalibrationTimeBase3.getValue().equals(CalibrationTimeBase4.getValue())){ | |||
DialogManager.showWarn("步长时间1与步长时间2不能相同!", DialogButton.OK,null); | |||
if(channelNum==0){ | |||
DialogManager.showWarn("请选择已绑定物料的通道进行校准!", DialogButton.OK,null); | |||
return; | |||
} | |||
DialogManager.showWarn("请问是否开始进行通道校准?",DialogButton.YesNo,(s)->{ | |||
if(s){ | |||
RecordManager.getInstance().addLogRecord(LogType.角色操作,"ChannelViewModel calibration开始进行通道校准 type="+type+";channelNum="+channelNum+";batchingName="+batchingName); | |||
isCalibrating = true; | |||
Task.Run(()->{ | |||
CalibrationParConfig(); | |||
PlcControl.get().calibrationError = false; | |||
PlcControl.get().calibrationStop = false; | |||
try{ | |||
PlcControl.get().calibrationValue = new LinkedHashMap<>(); | |||
for(int i=1;i<=12;i++){ | |||
if(!isCalibrating){ | |||
ToastUtil.showInfo("已停止校准"); | |||
return; | |||
} | |||
if(PlcControl.get().calibrationError){ | |||
return; | |||
} | |||
// PlcControl.get().calibrationValue = new LinkedHashMap<>(); | |||
int totalProcess = type==1?(CalibrationTimeCount1+CalibrationTimeCount2+2):(CalibrationTimeCount3+CalibrationTimeCount4+2); | |||
GlobalContext.getActivity().runOnUiThread(()->{ | |||
progressMax.setValue(totalProcess); | |||
double p = 0; | |||
String process = String.format("%.1f", p); | |||
progress.setValue(process+"%"); | |||
progressNum.setValue(0); | |||
}); | |||
int finalI = i; | |||
PlcControl.get().singleCalibration(type,channelNum,batchingName,(status, msg,pos)->{ | |||
GlobalContext.getActivity().runOnUiThread(()->{ | |||
double p = finalI*100/13.0; | |||
desc.setValue(msg); | |||
double p = pos*100.0 /totalProcess; | |||
String process = String.format("%.1f", p); | |||
progress.setValue(process+"%"); | |||
curChannelName.setValue("#"+ (finalI>6?finalI-6:finalI)); | |||
progressNum.setValue(finalI); | |||
progressNum.setValue(pos); | |||
}); | |||
PlcControl.get().singleCalibration(1,i,(status, msg)->{ | |||
GlobalContext.getActivity().runOnUiThread(()->{ | |||
desc.setValue(msg); | |||
}); | |||
PlcControl.get().calibrationError = !status; | |||
},(com)->{ | |||
ToastUtil.showInfo(com); | |||
int key = Integer.parseInt(chNum.getValue()); | |||
if(PlcControl.get().calibrationValue.containsKey(key)){ | |||
int count=0; | |||
String info = ""; | |||
for (Map.Entry<Integer,Float> item:PlcControl.get().calibrationValue.get(key).entrySet()){ | |||
count++; | |||
info=info+"通道 "+chNum.getValue()+" 第 "+count+ " 次,校准时间:"+item.getKey()+" ms;校准重量:"+item.getValue()+"g\r\n"; | |||
} | |||
String finalInfo = info; | |||
GlobalContext.getActivity().runOnUiThread(()->{ | |||
desc.setValue(finalInfo); | |||
}); | |||
log.postValue(info+"\r\n"+log.getValue()); | |||
} | |||
}); | |||
} | |||
PlcControl.get().calibrationError = !status; | |||
},(com)->{ | |||
ToastUtil.showInfo(com); | |||
}); | |||
Util.writeJson(PlcControl.get().calibrationValue); | |||
RecordManager.getInstance().addLogRecord(LogType.角色操作,"ChannelViewModel calibration开始进行通道校准 type="+type+";channelNum=" | |||
+channelNum+";batchingName="+batchingName+" 步骤:校准结束"); | |||
GlobalContext.getActivity().runOnUiThread(()->{ | |||
desc.setValue("校准结束"); | |||
desc.setValue("通道"+channelNum+" ["+batchingName+"] 校准结束"); | |||
progress.setValue("100%"); | |||
progressNum.setValue(13); | |||
curChannelName.setValue(""); | |||
progressNum.setValue(progressMax.getValue()); | |||
}); | |||
}catch (Exception e){ | |||
GlobalContext.getActivity().runOnUiThread(()->{ | |||
desc.setValue("校准异常 "+e.getMessage()); | |||
desc.setValue("通道"+channelNum+" ["+batchingName+"] 校准异常 "+e.getMessage()); | |||
}); | |||
RecordManager.getInstance().addLogRecord(LogType.角色操作,"ChannelViewModel calibration开始进行通道校准 type="+type+";channelNum=" | |||
+channelNum+";batchingName="+batchingName+" 步骤:校准异常"); | |||
}finally { | |||
isCalibrating = false; | |||
} | |||
@@ -261,103 +205,4 @@ public class ChannelViewModel extends ViewModel { | |||
}); | |||
} | |||
/** | |||
* 通道出料 | |||
*/ | |||
public void discharge(){ | |||
if(!PlcControl.get().IsConnected) { | |||
DialogManager.showWarn("设备未连接!", DialogButton.OK,null); | |||
return; | |||
} | |||
if(Integer.parseInt(chNum.getValue())<1||Integer.parseInt(chNum.getValue())>16) { | |||
DialogManager.showWarn("通道号错误,请输入(1-16)的通道编号", DialogButton.OK,null); | |||
return; | |||
} | |||
NotifyEvent.get().Send("LoadingBtn",Status.任务开始); | |||
Task.Run(()->{ | |||
ToastUtil.showInfo("开始出料"); | |||
int chNumValue = Integer.parseInt(chNum.getValue()); | |||
float weightValue = Float.parseFloat(weight.getValue()); | |||
AtomicBoolean isError =new AtomicBoolean(false); | |||
TaskControl.startBatchComplete(chNumValue,weightValue,(s)->{ | |||
ToastUtil.showInfo(String.valueOf(s)); | |||
isError.set(s==Status.任务错误); | |||
}); | |||
if(isError.get()){ | |||
NotifyEvent.get().Send("LoadingBtn",Status.任务结束); | |||
return; | |||
} | |||
Task.Delay(2000); | |||
float errorValue = Math.abs(weightValue-Global.currentWeight.<Float>getValue()); | |||
log.postValue("设定出料重量:"+weight.getValue()+", 实际出料重量:"+ Global.currentWeight.getValue()+", 误差值:"+errorValue+"\r\n"+log.getValue()); | |||
NotifyEvent.get().Send("LoadingBtn",Status.任务结束); | |||
}); | |||
} | |||
/** | |||
* 重量清零 | |||
*/ | |||
public void clearWeight(){ | |||
ElectoronicScales.get().clearZero((short) 1);//电子称去皮 | |||
} | |||
/** | |||
* 手动启动出料 | |||
* @return | |||
*/ | |||
public boolean handStart(){ | |||
try{ | |||
if(!PlcControl.get().IsConnected||!ElectoronicScales.get().IsConnected) { | |||
DialogManager.showWarn("设备未连接!", DialogButton.OK,null); | |||
return true;//返回值的状态,true:代表该事件任务执行完成,不用再执行后面事件的任务,false:表示该事件任务未执行完成,需要后面的事件继续执行 | |||
} | |||
PlcControl.get(). jogDischarge(Integer.parseInt(chNum.getValue()),true); | |||
}catch (Exception e){ | |||
ToastUtil.showError("手动启动错误:"+e.getMessage()); | |||
} | |||
return false; | |||
} | |||
/** | |||
* 手动停止 | |||
*/ | |||
public void handStop(){ | |||
try{ | |||
if(!PlcControl.get().IsConnected||!ElectoronicScales.get().IsConnected) { | |||
DialogManager.showWarn("设备未连接!", DialogButton.OK,null); | |||
return; | |||
} | |||
PlcControl.get(). jogDischarge(Integer.parseInt(chNum.getValue()),false); | |||
}catch (Exception e){ | |||
ToastUtil.showError("手动停止错误:"+e.getMessage()); | |||
} | |||
} | |||
/** | |||
* 查看参数 | |||
*/ | |||
public void ViewParameters(){ | |||
try{ | |||
int key = Integer.parseInt(chNum.getValue()); | |||
if(PlcControl.get().calibrationValue.containsKey(key)){ | |||
int count=0; | |||
String info = ""; | |||
for (Map.Entry<Integer,Float> item:PlcControl.get().calibrationValue.get(key).entrySet()){ | |||
count++; | |||
info=info+"通道 "+chNum.getValue()+" 第 "+count+ " 次,校准时间:"+item.getKey()+" ms;校准重量:"+item.getValue()+"g\r\n"; | |||
} | |||
log.postValue(info+"\r\n"+log.getValue()); | |||
} | |||
}catch (Exception e){ | |||
MessageLog.ShowError(e); | |||
} | |||
} | |||
/** | |||
* 清除日志 | |||
*/ | |||
public void ClearLog(){ | |||
log.postValue(""); | |||
} | |||
} |
@@ -9,8 +9,13 @@ import com.jdzh.jdzhandroid.Business.Global; | |||
import com.jdzh.jdzhandroid.Business.PlcControl; | |||
import com.jdzh.jdzhandroid.Business.TaskControl; | |||
import com.jdzh.jdzhandroid.Enum.DialogButton; | |||
import com.jdzh.jdzhandroid.Enum.LogType; | |||
import com.jdzh.jdzhandroid.Enum.Status; | |||
import com.jdzh.jdzhandroid.Log.MessageLog; | |||
import com.jdzh.jdzhandroid.Log.RecordManager; | |||
import com.jdzh.jdzhandroid.Sqlite.DAO.BPA_BatchingDao; | |||
import com.jdzh.jdzhandroid.Sqlite.Model.BPA_Batching; | |||
import com.jdzh.jdzhandroid.Sqlite.SqliteHelper; | |||
import com.jdzh.jdzhandroid.Task.Task; | |||
import com.jdzh.jdzhandroid.util.Dialog.DialogManager; | |||
import com.jdzh.jdzhandroid.util.Dialog.WaitDialog; | |||
@@ -51,6 +56,7 @@ public class DebugViewModel extends ViewModel { | |||
* 通道校准 | |||
*/ | |||
public void calibration(){ | |||
RecordManager.getInstance().addLogRecord(LogType.页面上报,"DebugViewModel 通道校准calibration "); | |||
// DialogManager.showDialog(); | |||
if(!PlcControl.get().IsConnected||!ElectoronicScales.get().IsConnected) { | |||
DialogManager.showWarn("设备未连接!", DialogButton.OK,null); | |||
@@ -60,9 +66,18 @@ public class DebugViewModel extends ViewModel { | |||
DialogManager.showWarn("请问是否开始进行通道校准?",DialogButton.YesNo,(s)->{ | |||
if(s){ | |||
Task.Run(()->{ | |||
BPA_Batching batching = SqliteHelper.get().queryByBuilderEntity(BPA_Batching.class, | |||
BPA_BatchingDao.Properties.SiloChannelNum.eq("粉料通道"+chNum.getValue())); | |||
if(batching == null){ | |||
batching = SqliteHelper.get().queryByBuilderEntity(BPA_Batching.class, | |||
BPA_BatchingDao.Properties.SiloChannelNum.eq("液体通道"+(Integer.parseInt(chNum.getValue())-6))); | |||
} | |||
if(batching == null){ | |||
DialogManager.showWarn("该通道未绑定物料!请绑定物料并校准后重试", DialogButton.OK,null); | |||
return; | |||
} | |||
WaitDialog.Show("通道 "+ chNum.getValue()+" 校准","开始进行通道校准"); | |||
PlcControl.get().singleCalibration(1,Integer.parseInt(chNum.getValue()),(status,msg)->{ | |||
PlcControl.get().singleCalibration(1,Integer.parseInt(chNum.getValue()),batching.getName(),(status,msg,pos)->{ | |||
if(status) WaitDialog.AddText(msg); | |||
else WaitDialog.TimeOut(msg); | |||
},(com)->{ | |||
@@ -88,12 +103,14 @@ public class DebugViewModel extends ViewModel { | |||
* 通道出料 | |||
*/ | |||
public void discharge(){ | |||
RecordManager.getInstance().addLogRecord(LogType.页面上报,"DebugViewModel 通道出料 discharge"); | |||
if(!PlcControl.get().IsConnected) { | |||
DialogManager.showWarn("设备未连接!", DialogButton.OK,null); | |||
return; | |||
} | |||
if(Integer.parseInt(chNum.getValue())<1||Integer.parseInt(chNum.getValue())>16) { | |||
DialogManager.showWarn("通道号错误,请输入(1-16)的通道编号", DialogButton.OK,null); | |||
if(Integer.parseInt(chNum.getValue())<1||Integer.parseInt(chNum.getValue())>12) { | |||
DialogManager.showWarn("通道号错误,请输入(1-12)的通道编号", DialogButton.OK,null); | |||
return; | |||
} | |||
NotifyEvent.get().Send("LoadingBtn",Status.任务开始); | |||
@@ -101,8 +118,18 @@ public class DebugViewModel extends ViewModel { | |||
ToastUtil.showInfo("开始出料"); | |||
int chNumValue = Integer.parseInt(chNum.getValue()); | |||
float weightValue = Float.parseFloat(weight.getValue()); | |||
BPA_Batching batching = SqliteHelper.get().queryByBuilderEntity(BPA_Batching.class, | |||
BPA_BatchingDao.Properties.SiloChannelNum.eq("粉料通道"+chNumValue)); | |||
if(batching == null){ | |||
batching = SqliteHelper.get().queryByBuilderEntity(BPA_Batching.class, | |||
BPA_BatchingDao.Properties.SiloChannelNum.eq("液体通道"+(chNumValue-6))); | |||
} | |||
if(batching == null){ | |||
DialogManager.showWarn("该通道未绑定物料!请绑定物料并校准后重试", DialogButton.OK,null); | |||
return; | |||
} | |||
AtomicBoolean isError =new AtomicBoolean(false); | |||
TaskControl.startBatchComplete(chNumValue,weightValue,(s)->{ | |||
TaskControl.startBatchComplete(chNumValue,batching.getName(),weightValue,(s)->{ | |||
ToastUtil.showInfo(String.valueOf(s)); | |||
isError.set(s==Status.任务错误); | |||
}); | |||
@@ -121,6 +148,7 @@ public class DebugViewModel extends ViewModel { | |||
* 重量清零 | |||
*/ | |||
public void clearWeight(){ | |||
RecordManager.getInstance().addLogRecord(LogType.页面上报,"DebugViewModel 重量清零 clearWeight"); | |||
ElectoronicScales.get().clearZero((short) 1);//电子称去皮 | |||
} | |||
@@ -130,6 +158,8 @@ public class DebugViewModel extends ViewModel { | |||
*/ | |||
public boolean handStart(){ | |||
try{ | |||
RecordManager.getInstance().addLogRecord(LogType.页面上报,"DebugViewModel 手动启动出料 handStart"); | |||
if(!PlcControl.get().IsConnected||!ElectoronicScales.get().IsConnected) { | |||
DialogManager.showWarn("设备未连接!", DialogButton.OK,null); | |||
return true;//返回值的状态,true:代表该事件任务执行完成,不用再执行后面事件的任务,false:表示该事件任务未执行完成,需要后面的事件继续执行 | |||
@@ -146,6 +176,7 @@ public class DebugViewModel extends ViewModel { | |||
*/ | |||
public void handStop(){ | |||
try{ | |||
RecordManager.getInstance().addLogRecord(LogType.页面上报,"DebugViewModel 手动停止 handStop"); | |||
if(!PlcControl.get().IsConnected||!ElectoronicScales.get().IsConnected) { | |||
DialogManager.showWarn("设备未连接!", DialogButton.OK,null); | |||
return; | |||
@@ -0,0 +1,18 @@ | |||
<?xml version="1.0" encoding="utf-8"?> | |||
<!-- 在Topbar下方的Tab面板的背景,带底部分割线 --> | |||
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" | |||
> | |||
<item | |||
android:left="-10dp" | |||
android:right="-10dp" | |||
android:top="-10dp"> | |||
<shape> | |||
<!-- <solid android:color="@color/tab_panel_bg" />--> | |||
<stroke | |||
android:width="1dp" | |||
android:color="@color/button_border" /> | |||
</shape> | |||
</item> | |||
</layer-list> |
@@ -0,0 +1,28 @@ | |||
<?xml version="1.0" encoding="utf-8"?> | |||
<layer-list xmlns:android="http://schemas.android.com/apk/res/android"> | |||
<!-- 第一组item:设置Spinner背景边框 --> | |||
<item> | |||
<shape> | |||
<stroke | |||
android:width="1dp" | |||
android:color="@color/button_border"> | |||
</stroke> | |||
<corners android:radius="10dp" /> | |||
<!-- 设置背景颜色 --> | |||
<padding | |||
android:bottom="0dp" | |||
android:left="30dp" | |||
android:right="5dp" | |||
android:top="0dp" > | |||
</padding> | |||
</shape> | |||
<!-- 第二组item:设置spinner箭头图片 --> | |||
</item> | |||
<item> | |||
<bitmap | |||
android:gravity="end" | |||
android:src="@mipmap/spinner_down_2"> | |||
</bitmap> | |||
</item> | |||
</layer-list> |
@@ -55,6 +55,7 @@ | |||
android:layout_height="wrap_content"> | |||
<ImageView | |||
android:id="@+id/img1" | |||
android:background="@mipmap/ic_powder_silo300" | |||
android:layout_width="80dp" | |||
android:text="#1" | |||
@@ -63,6 +64,7 @@ | |||
android:textColor="@color/black" | |||
android:layout_height="80dp"/> | |||
<ImageView | |||
android:id="@+id/img2" | |||
android:background="@mipmap/ic_powder_silo300" | |||
android:layout_width="80dp" | |||
android:text="#2" | |||
@@ -71,6 +73,7 @@ | |||
android:textColor="@color/black" | |||
android:layout_height="80dp"/> | |||
<ImageView | |||
android:id="@+id/img3" | |||
android:background="@mipmap/ic_powder_silo300" | |||
android:layout_width="80dp" | |||
android:text="#3" | |||
@@ -79,6 +82,7 @@ | |||
android:textColor="@color/black" | |||
android:layout_height="80dp"/> | |||
<ImageView | |||
android:id="@+id/img4" | |||
android:background="@mipmap/ic_powder_silo300" | |||
android:layout_width="80dp" | |||
android:text="#4" | |||
@@ -87,6 +91,7 @@ | |||
android:textColor="@color/black" | |||
android:layout_height="80dp"/> | |||
<ImageView | |||
android:id="@+id/img5" | |||
android:background="@mipmap/ic_powder_silo300" | |||
android:layout_width="80dp" | |||
android:text="#5" | |||
@@ -95,6 +100,7 @@ | |||
android:textColor="@color/black" | |||
android:layout_height="80dp"/> | |||
<ImageView | |||
android:id="@+id/img6" | |||
android:background="@mipmap/ic_powder_silo300" | |||
android:layout_width="80dp" | |||
android:text="#6" | |||
@@ -115,42 +121,42 @@ | |||
android:text="#1" | |||
android:textSize="22sp" | |||
android:gravity="center" | |||
android:textColor="@color/black" | |||
android:textColor="@color/light_blue_600" | |||
android:layout_height="wrap_content"/> | |||
<TextView | |||
android:layout_width="80dp" | |||
android:text="#2" | |||
android:textSize="22sp" | |||
android:gravity="center" | |||
android:textColor="@color/black" | |||
android:textColor="@color/light_blue_600" | |||
android:layout_height="wrap_content"/> | |||
<TextView | |||
android:layout_width="80dp" | |||
android:text="#3" | |||
android:textSize="22sp" | |||
android:gravity="center" | |||
android:textColor="@color/black" | |||
android:textColor="@color/light_blue_600" | |||
android:layout_height="wrap_content"/> | |||
<TextView | |||
android:layout_width="80dp" | |||
android:text="#4" | |||
android:textSize="22sp" | |||
android:gravity="center" | |||
android:textColor="@color/black" | |||
android:textColor="@color/light_blue_600" | |||
android:layout_height="wrap_content"/> | |||
<TextView | |||
android:layout_width="80dp" | |||
android:text="#5" | |||
android:textSize="22sp" | |||
android:gravity="center" | |||
android:textColor="@color/black" | |||
android:textColor="@color/light_blue_600" | |||
android:layout_height="wrap_content"/> | |||
<TextView | |||
android:layout_width="80dp" | |||
android:text="#6" | |||
android:textSize="22sp" | |||
android:gravity="center" | |||
android:textColor="@color/black" | |||
android:textColor="@color/light_blue_600" | |||
android:layout_height="wrap_content"/> | |||
</LinearLayout> | |||
@@ -169,17 +175,16 @@ | |||
android:textSize="20sp" | |||
android:text="步长时间1(ms):"/> | |||
<EditText | |||
<TextView | |||
android:layout_width="120dp" | |||
android:layout_height="match_parent" | |||
android:layout_gravity="center" | |||
android:text="@={data.CalibrationTimeBase1}" | |||
android:textColor="@color/light_blue_600" | |||
android:textColor="#000000" | |||
android:textSize="20sp" | |||
android:inputType="number" | |||
android:layout_marginEnd="20dp" | |||
android:focusable="true" | |||
android:focusableInTouchMode="true" | |||
android:text="100" | |||
android:gravity="center" | |||
android:background="@drawable/textview_border" /> | |||
<TextView | |||
@@ -190,17 +195,16 @@ | |||
android:gravity="center" | |||
android:text="校准次数:"/> | |||
<EditText | |||
<TextView | |||
android:layout_width="60dp" | |||
android:layout_height="match_parent" | |||
android:layout_gravity="center" | |||
android:text="@={data.CalibrationTimeCount1}" | |||
android:textColor="@color/light_blue_600" | |||
android:textColor="#000000" | |||
android:textSize="20sp" | |||
android:inputType="number" | |||
android:layout_marginEnd="20dp" | |||
android:focusable="true" | |||
android:focusableInTouchMode="true" | |||
android:text="10" | |||
android:gravity="center" | |||
android:background="@drawable/textview_border" /> | |||
</LinearLayout> | |||
<LinearLayout | |||
@@ -217,17 +221,16 @@ | |||
android:textSize="20sp" | |||
android:text="步长时间2(ms):"/> | |||
<EditText | |||
<TextView | |||
android:layout_width="120dp" | |||
android:layout_height="match_parent" | |||
android:layout_gravity="center" | |||
android:text="@={data.CalibrationTimeBase2}" | |||
android:textColor="@color/light_blue_600" | |||
android:textColor="#000000" | |||
android:textSize="20sp" | |||
android:inputType="number" | |||
android:layout_marginEnd="20dp" | |||
android:focusable="true" | |||
android:focusableInTouchMode="true" | |||
android:text="1000" | |||
android:gravity="center" | |||
android:background="@drawable/textview_border" /> | |||
<TextView | |||
@@ -238,17 +241,16 @@ | |||
android:gravity="center" | |||
android:text="校准次数:"/> | |||
<EditText | |||
<TextView | |||
android:layout_width="60dp" | |||
android:layout_height="match_parent" | |||
android:layout_gravity="center" | |||
android:text="@={data.CalibrationTimeCount2}" | |||
android:textColor="@color/light_blue_600" | |||
android:textColor="#000000" | |||
android:textSize="20sp" | |||
android:inputType="number" | |||
android:layout_marginEnd="20dp" | |||
android:focusable="true" | |||
android:focusableInTouchMode="true" | |||
android:text="4" | |||
android:gravity="center" | |||
android:background="@drawable/textview_border" /> | |||
</LinearLayout> | |||
@@ -269,6 +271,7 @@ | |||
android:layout_height="wrap_content"> | |||
<ImageView | |||
android:id="@+id/img7" | |||
android:background="@mipmap/ic_matrial_silo300" | |||
android:layout_width="80dp" | |||
android:text="#1" | |||
@@ -277,6 +280,7 @@ | |||
android:textColor="@color/black" | |||
android:layout_height="80dp"/> | |||
<ImageView | |||
android:id="@+id/img8" | |||
android:background="@mipmap/ic_matrial_silo300" | |||
android:layout_width="80dp" | |||
android:text="#2" | |||
@@ -285,6 +289,7 @@ | |||
android:textColor="@color/black" | |||
android:layout_height="80dp"/> | |||
<ImageView | |||
android:id="@+id/img9" | |||
android:background="@mipmap/ic_matrial_silo300" | |||
android:layout_width="80dp" | |||
android:text="#3" | |||
@@ -293,6 +298,7 @@ | |||
android:textColor="@color/black" | |||
android:layout_height="80dp"/> | |||
<ImageView | |||
android:id="@+id/img10" | |||
android:background="@mipmap/ic_matrial_silo300" | |||
android:layout_width="80dp" | |||
android:text="#4" | |||
@@ -301,6 +307,7 @@ | |||
android:textColor="@color/black" | |||
android:layout_height="80dp"/> | |||
<ImageView | |||
android:id="@+id/img11" | |||
android:background="@mipmap/ic_matrial_silo300" | |||
android:layout_width="80dp" | |||
android:text="#5" | |||
@@ -309,6 +316,7 @@ | |||
android:textColor="@color/black" | |||
android:layout_height="80dp"/> | |||
<ImageView | |||
android:id="@+id/img12" | |||
android:background="@mipmap/ic_matrial_silo300" | |||
android:layout_width="80dp" | |||
android:text="#6" | |||
@@ -329,42 +337,42 @@ | |||
android:text="#1" | |||
android:textSize="22sp" | |||
android:gravity="center" | |||
android:textColor="@color/black" | |||
android:textColor="@color/light_blue_600" | |||
android:layout_height="wrap_content"/> | |||
<TextView | |||
android:layout_width="80dp" | |||
android:text="#2" | |||
android:textSize="22sp" | |||
android:gravity="center" | |||
android:textColor="@color/black" | |||
android:textColor="@color/light_blue_600" | |||
android:layout_height="wrap_content"/> | |||
<TextView | |||
android:layout_width="80dp" | |||
android:text="#3" | |||
android:textSize="22sp" | |||
android:gravity="center" | |||
android:textColor="@color/black" | |||
android:textColor="@color/light_blue_600" | |||
android:layout_height="wrap_content"/> | |||
<TextView | |||
android:layout_width="80dp" | |||
android:text="#4" | |||
android:textSize="22sp" | |||
android:gravity="center" | |||
android:textColor="@color/black" | |||
android:textColor="@color/light_blue_600" | |||
android:layout_height="wrap_content"/> | |||
<TextView | |||
android:layout_width="80dp" | |||
android:text="#5" | |||
android:textSize="22sp" | |||
android:gravity="center" | |||
android:textColor="@color/black" | |||
android:textColor="@color/light_blue_600" | |||
android:layout_height="wrap_content"/> | |||
<TextView | |||
android:layout_width="80dp" | |||
android:text="#6" | |||
android:textSize="22sp" | |||
android:gravity="center" | |||
android:textColor="@color/black" | |||
android:textColor="@color/light_blue_600" | |||
android:layout_height="wrap_content"/> | |||
</LinearLayout> | |||
<LinearLayout | |||
@@ -381,17 +389,16 @@ | |||
android:textSize="20sp" | |||
android:text="步长时间1(ms):"/> | |||
<EditText | |||
<TextView | |||
android:layout_width="120dp" | |||
android:layout_height="match_parent" | |||
android:layout_gravity="center" | |||
android:text="@={data.CalibrationTimeBase3}" | |||
android:textColor="@color/light_blue_600" | |||
android:textColor="#000000" | |||
android:textSize="20sp" | |||
android:inputType="number" | |||
android:layout_marginEnd="20dp" | |||
android:focusable="true" | |||
android:focusableInTouchMode="true" | |||
android:text="100" | |||
android:gravity="center" | |||
android:background="@drawable/textview_border" /> | |||
<TextView | |||
@@ -402,17 +409,16 @@ | |||
android:gravity="center" | |||
android:text="校准次数:"/> | |||
<EditText | |||
<TextView | |||
android:layout_width="60dp" | |||
android:layout_height="match_parent" | |||
android:layout_gravity="center" | |||
android:text="@={data.CalibrationTimeCount3}" | |||
android:textColor="@color/light_blue_600" | |||
android:textColor="#000000" | |||
android:textSize="20sp" | |||
android:inputType="number" | |||
android:layout_marginEnd="20dp" | |||
android:focusable="true" | |||
android:focusableInTouchMode="true" | |||
android:text="10" | |||
android:gravity="center" | |||
android:background="@drawable/textview_border" /> | |||
</LinearLayout> | |||
<LinearLayout | |||
@@ -429,17 +435,16 @@ | |||
android:textSize="20sp" | |||
android:text="步长时间2(ms):"/> | |||
<EditText | |||
<TextView | |||
android:layout_width="120dp" | |||
android:layout_height="match_parent" | |||
android:layout_gravity="center" | |||
android:text="@={data.CalibrationTimeBase4}" | |||
android:textColor="@color/light_blue_600" | |||
android:textColor="#000000" | |||
android:textSize="20sp" | |||
android:inputType="number" | |||
android:layout_marginEnd="20dp" | |||
android:focusable="true" | |||
android:focusableInTouchMode="true" | |||
android:text="1000" | |||
android:gravity="center" | |||
android:background="@drawable/textview_border" /> | |||
<TextView | |||
@@ -450,17 +455,16 @@ | |||
android:gravity="center" | |||
android:text="校准次数:"/> | |||
<EditText | |||
<TextView | |||
android:layout_width="60dp" | |||
android:layout_height="match_parent" | |||
android:layout_gravity="center" | |||
android:text="@={data.CalibrationTimeCount4}" | |||
android:textColor="@color/light_blue_600" | |||
android:textColor="#000000" | |||
android:textSize="20sp" | |||
android:inputType="number" | |||
android:layout_marginEnd="20dp" | |||
android:focusable="true" | |||
android:focusableInTouchMode="true" | |||
android:text="4" | |||
android:gravity="center" | |||
android:background="@drawable/textview_border" /> | |||
</LinearLayout> | |||
</RelativeLayout> | |||
@@ -509,7 +513,6 @@ | |||
android:layout_height="wrap_content" | |||
android:layout_below="@id/rl_1" | |||
android:layout_toEndOf="@id/btn_start" | |||
android:max="12" | |||
android:focusable="false" | |||
android:maxHeight="@dimen/dp30" | |||
android:minHeight="@dimen/dp30" | |||
@@ -555,7 +558,6 @@ | |||
<TextView | |||
android:id="@+id/tv_cur_channel" | |||
android:layout_width="wrap_content" | |||
android:text="@={data.curChannelName}" | |||
android:textSize="28sp" | |||
android:gravity="center" | |||
tools:text="#1" | |||
@@ -227,42 +227,42 @@ | |||
<TextView | |||
android:layout_width="80dp" | |||
android:text="#7" | |||
android:text="#1" | |||
android:textSize="22sp" | |||
android:gravity="center" | |||
android:textColor="@color/black" | |||
android:layout_height="wrap_content"/> | |||
<TextView | |||
android:layout_width="80dp" | |||
android:text="#8" | |||
android:text="#2" | |||
android:textSize="22sp" | |||
android:gravity="center" | |||
android:textColor="@color/black" | |||
android:layout_height="wrap_content"/> | |||
<TextView | |||
android:layout_width="80dp" | |||
android:text="#9" | |||
android:text="#3" | |||
android:textSize="22sp" | |||
android:gravity="center" | |||
android:textColor="@color/black" | |||
android:layout_height="wrap_content"/> | |||
<TextView | |||
android:layout_width="80dp" | |||
android:text="#10" | |||
android:text="#4" | |||
android:textSize="22sp" | |||
android:gravity="center" | |||
android:textColor="@color/black" | |||
android:layout_height="wrap_content"/> | |||
<TextView | |||
android:layout_width="80dp" | |||
android:text="#11" | |||
android:text="#5" | |||
android:textSize="22sp" | |||
android:gravity="center" | |||
android:textColor="@color/black" | |||
android:layout_height="wrap_content"/> | |||
<TextView | |||
android:layout_width="80dp" | |||
android:text="#12" | |||
android:text="#6" | |||
android:textSize="22sp" | |||
android:gravity="center" | |||
android:textColor="@color/black" | |||
@@ -0,0 +1,201 @@ | |||
<?xml version="1.0" encoding="utf-8"?> | |||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" | |||
xmlns:app="http://schemas.android.com/apk/res-auto" | |||
xmlns:tools="http://schemas.android.com/tools" | |||
android:layout_width="match_parent" | |||
android:layout_height="match_parent" | |||
android:orientation="vertical" | |||
android:background="@color/white" | |||
android:id="@+id/root" | |||
android:fitsSystemWindows="true"> | |||
<LinearLayout | |||
android:layout_marginTop="@dimen/dp_10" | |||
android:id="@+id/ll_time" | |||
android:layout_width="match_parent" | |||
android:layout_height="@dimen/dp_70" | |||
android:orientation="horizontal" | |||
> | |||
<TextView | |||
android:layout_width="wrap_content" | |||
android:layout_height="match_parent" | |||
android:layout_marginLeft="@dimen/dp_5" | |||
android:gravity="center_vertical" | |||
android:textColor="@color/black" | |||
android:textSize="@dimen/sp_26" | |||
android:text="时间:" | |||
android:focusableInTouchMode="true" | |||
android:focusable="true" | |||
> | |||
<requestFocus/> | |||
</TextView> | |||
<TextView | |||
android:id="@+id/starttime" | |||
android:layout_width="@dimen/dp_150" | |||
android:layout_height="match_parent" | |||
android:padding="3dp" | |||
android:textColor="@color/light_blue_600" | |||
android:background="@drawable/edit_input_bg" | |||
android:layout_marginLeft="@dimen/dp_5" | |||
tools:text="2023-02-33 00:00:00" | |||
android:gravity="center" | |||
android:textSize="@dimen/sp_26"/> | |||
<TextView | |||
android:layout_width="wrap_content" | |||
android:layout_height="match_parent" | |||
android:layout_marginLeft="5dp" | |||
android:gravity="center_vertical" | |||
android:textColor="@color/black" | |||
android:textSize="@dimen/sp_26" | |||
android:text="—"/> | |||
<EditText | |||
android:id="@+id/stoptime" | |||
android:layout_width="@dimen/dp_150" | |||
android:layout_height="match_parent" | |||
android:focusable="false" | |||
android:textColor="@color/light_blue_600" | |||
android:background="@drawable/edit_input_bg" | |||
android:layout_marginLeft="@dimen/dp_5" | |||
android:text="2023-02-33 00:00:00" | |||
android:gravity="center" | |||
android:textSize="@dimen/sp_26"/> | |||
<TextView | |||
android:layout_width="wrap_content" | |||
android:layout_height="match_parent" | |||
android:layout_marginLeft="@dimen/dp_5" | |||
android:gravity="center_vertical" | |||
android:textColor="@color/black" | |||
android:textSize="@dimen/sp_26" | |||
android:text="类型:"/> | |||
<Spinner | |||
android:id="@+id/spinner" | |||
android:layout_width="@dimen/dp_250" | |||
android:layout_height="match_parent" | |||
style="@style/commonSpinnerStyle"/> | |||
<EditText | |||
android:id="@+id/edittext" | |||
android:layout_width="@dimen/dp_250" | |||
android:layout_height="match_parent" | |||
android:inputType="text" | |||
android:padding="3dp" | |||
android:textColor="@color/black" | |||
android:background="@drawable/edit_input_bg" | |||
android:hint="筛选条件" | |||
android:textColorHint="@color/text_gray" | |||
android:maxLines="1" | |||
android:layout_marginStart="20dp" | |||
android:textSize="@dimen/sp_26"/> | |||
<TextView | |||
android:id="@+id/btn_deleteAll" | |||
android:text="删除所有" | |||
android:background="@color/white" | |||
android:textSize="22sp" | |||
android:layout_marginStart="@dimen/dp_10" | |||
android:layout_gravity="center" | |||
android:layout_width="wrap_content" | |||
android:layout_height="@dimen/dp_70" | |||
android:gravity="center" | |||
android:textColor="@color/red" | |||
android:layout_alignParentEnd="true" | |||
android:layout_marginEnd="@dimen/dp_10" | |||
/> | |||
</LinearLayout> | |||
<LinearLayout | |||
android:layout_below="@id/ll_time" | |||
android:layout_width="match_parent" | |||
android:layout_height="match_parent" | |||
android:layout_marginTop="10dp" | |||
android:orientation="vertical"> | |||
<TextView | |||
android:id="@+id/tv_fileSize" | |||
android:layout_width="match_parent" | |||
android:layout_height="wrap_content" | |||
android:text="缓存大小:" | |||
android:textSize="18sp" | |||
android:gravity="end" | |||
android:textColor="@color/button_border" | |||
/> | |||
<LinearLayout | |||
android:layout_width="match_parent" | |||
android:background="@color/button_border" | |||
android:orientation="horizontal" | |||
android:layout_height="@dimen/dp_50"> | |||
<RelativeLayout | |||
android:layout_width="0dp" | |||
android:layout_height="wrap_content" | |||
android:layout_weight="1.5"> | |||
<TextView | |||
android:layout_width="match_parent" | |||
android:layout_height="match_parent" | |||
android:gravity="center" | |||
android:textSize="@dimen/sp_26" | |||
android:layout_marginLeft="20dp" | |||
android:layout_alignParentLeft="true" | |||
android:text="日志类型" | |||
android:textStyle="bold" | |||
android:textColor="@color/white" /> | |||
</RelativeLayout> | |||
<RelativeLayout | |||
android:layout_width="0dp" | |||
android:layout_height="wrap_content" | |||
android:layout_weight="2.5"> | |||
<TextView | |||
android:layout_width="match_parent" | |||
android:layout_height="match_parent" | |||
android:gravity="center" | |||
android:textSize="@dimen/sp_26" | |||
android:layout_marginLeft="20dp" | |||
android:layout_alignParentLeft="true" | |||
android:text="日志时间" | |||
android:textStyle="bold" | |||
android:textColor="@color/white"/> | |||
</RelativeLayout> | |||
<RelativeLayout | |||
android:layout_width="0dp" | |||
android:layout_height="wrap_content" | |||
android:layout_weight="4"> | |||
<TextView | |||
android:layout_width="match_parent" | |||
android:layout_height="match_parent" | |||
android:gravity="center" | |||
android:textSize="@dimen/sp_26" | |||
android:layout_marginLeft="20dp" | |||
android:layout_alignParentLeft="true" | |||
android:text="日志描述" | |||
android:textStyle="bold" | |||
android:textColor="@color/white"/> | |||
</RelativeLayout> | |||
</LinearLayout> | |||
<androidx.recyclerview.widget.RecyclerView | |||
android:id="@+id/recycle_view" | |||
android:layout_width="match_parent" | |||
android:layout_height="match_parent" | |||
android:orientation="vertical" | |||
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" | |||
/> | |||
</LinearLayout> | |||
<Button | |||
android:id="@+id/btn_query" | |||
android:text="查 询" | |||
android:background="@drawable/btn_normal_bg" | |||
android:textSize="@dimen/sp_32" | |||
android:layout_marginLeft="@dimen/dp_10" | |||
android:layout_gravity="center" | |||
android:layout_width="@dimen/dp_150" | |||
android:layout_height="@dimen/dp_70" | |||
android:layout_marginTop="@dimen/dp_10" | |||
android:textColor="@color/white" | |||
android:layout_alignParentEnd="true" | |||
android:layout_marginEnd="@dimen/dp_10" | |||
/> | |||
</RelativeLayout> |
@@ -87,31 +87,11 @@ | |||
android:gravity="center_vertical" | |||
android:layout_weight="0.5" | |||
android:layout_width="0dp"> | |||
<TextView | |||
style="@style/TextStatusBarStyle" | |||
android:text="计量["></TextView> | |||
<TextView | |||
style="@style/TextStatusBarStyle" | |||
android:text="500"></TextView> | |||
<TextView | |||
style="@style/TextStatusBarStyle" | |||
android:text="]"></TextView> | |||
<TextView | |||
style="@style/TextStatusBarStyle" | |||
android:layout_marginLeft="@dimen/dp5" | |||
android:layout_marginEnd="@dimen/dp5" | |||
android:text="|" /> | |||
<TextView | |||
style="@style/TextStatusBarStyle" | |||
android:text="工作模式["></TextView> | |||
<TextView | |||
android:id="@+id/tv_bar_recipe_mode" | |||
style="@style/TextStatusBarStyle" | |||
android:text="配方模式"></TextView> | |||
<TextView | |||
style="@style/TextStatusBarStyle" | |||
android:text="]"></TextView> | |||
android:layout_marginStart="10dp" | |||
android:text="配方模式"/> | |||
</LinearLayout> | |||
<LinearLayout | |||
android:layout_gravity="center_vertical|right" | |||
@@ -124,45 +104,36 @@ | |||
<TextView | |||
style="@style/TextStatusBarStyle" | |||
android:id="@+id/weight" | |||
android:text="当前重量:55g" /> | |||
android:text="当前重量:55g" /> | |||
<TextView | |||
style="@style/TextStatusBarStyle" | |||
android:layout_marginLeft="10dp" | |||
android:layout_marginStart="10dp" | |||
android:layout_marginEnd="10dp" | |||
android:text="-----" /> | |||
<TextView | |||
style="@style/TextStatusBarStyle" | |||
android:id="@+id/plcStatus" | |||
android:text="PLC:未连接" /> | |||
android:id="@+id/electoronicScalesStatus" | |||
android:text="电子秤:未连接" /> | |||
<TextView | |||
style="@style/TextStatusBarStyle" | |||
android:layout_marginLeft="10dp" | |||
android:layout_marginStart="10dp" | |||
android:layout_marginEnd="10dp" | |||
android:text="-----" /> | |||
<TextView | |||
style="@style/TextStatusBarStyle" | |||
android:id="@+id/electoronicScalesStatus" | |||
android:text="电子秤:未连接" /> | |||
android:id="@+id/plcStatus" | |||
android:text="PLC:未连接" /> | |||
<TextView | |||
style="@style/TextStatusBarStyle" | |||
android:layout_marginLeft="10dp" | |||
android:layout_marginStart="10dp" | |||
android:layout_marginEnd="10dp" | |||
android:text="-----" /> | |||
<TextView | |||
style="@style/TextStatusBarStyle" | |||
android:text="设备状态["></TextView> | |||
<TextView | |||
style="@style/TextStatusBarStyle" | |||
android:text="未知"></TextView> | |||
<TextView | |||
style="@style/TextStatusBarStyle" | |||
android:text="]"></TextView> | |||
</LinearLayout> | |||
</LinearLayout> | |||
</RelativeLayout> |
@@ -11,8 +11,8 @@ | |||
<ImageView | |||
android:id="@+id/logo" | |||
android:layout_width="@dimen/dp_500" | |||
android:layout_height="@dimen/dp_500" | |||
android:layout_width="@dimen/dp_300" | |||
android:layout_height="@dimen/dp_300" | |||
android:layout_centerInParent="true" | |||
android:src="@mipmap/login_ico" /> | |||
@@ -1,10 +1,10 @@ | |||
<?xml version="1.0" encoding="utf-8"?> | |||
<shape xmlns:android="http://schemas.android.com/apk/res/android" | |||
android:shape="rectangle"> | |||
<stroke | |||
android:color="#BBBBBB" | |||
android:dashWidth="5dp" | |||
android:dashGap="@dimen/dp10" | |||
android:width="@dimen/dp1"/> | |||
<solid android:color="@color/white"></solid> | |||
<!-- <stroke--> | |||
<!-- android:color="#BBBBBB"--> | |||
<!-- android:dashWidth="5dp"--> | |||
<!-- android:dashGap="@dimen/dp10"--> | |||
<!-- android:width="@dimen/dp1"/>--> | |||
<solid android:color="@color/white"/> | |||
</shape> |
@@ -1,10 +1,10 @@ | |||
<?xml version="1.0" encoding="utf-8"?> | |||
<shape xmlns:android="http://schemas.android.com/apk/res/android" | |||
android:shape="rectangle"> | |||
<stroke | |||
android:color="@color/simple_button_bg" | |||
android:dashWidth="5dp" | |||
android:dashGap="@dimen/dp10" | |||
android:width="@dimen/dp1"/> | |||
<!-- <stroke--> | |||
<!-- android:color="@color/simple_button_bg"--> | |||
<!-- android:dashWidth="5dp"--> | |||
<!-- android:dashGap="@dimen/dp10"--> | |||
<!-- android:width="@dimen/dp1"/>--> | |||
<solid android:color="@color/white"></solid> | |||
</shape> |
@@ -1,11 +1,11 @@ | |||
<?xml version="1.0" encoding="utf-8"?> | |||
<shape xmlns:android="http://schemas.android.com/apk/res/android" | |||
android:shape="rectangle"> | |||
<stroke | |||
android:color="#BBBBBB" | |||
android:dashWidth="5dp" | |||
android:dashGap="@dimen/dp10" | |||
android:width="@dimen/dp1"/> | |||
<solid android:color="@color/white"></solid> | |||
<!-- <stroke--> | |||
<!-- android:color="#BBBBBB"--> | |||
<!-- android:dashWidth="5dp"--> | |||
<!-- android:dashGap="@dimen/dp10"--> | |||
<!-- android:width="@dimen/dp1"/>--> | |||
<solid android:color="@color/white"/> | |||
<corners android:radius="10dp"/> | |||
</shape> |
@@ -68,7 +68,8 @@ | |||
android:layout_marginHorizontal="@dimen/dp10" | |||
android:textColor="@color/black" | |||
android:layout_width="@dimen/dp100" | |||
android:inputType="number" | |||
android:inputType="text" | |||
android:digits="0123456789." | |||
android:textSize="@dimen/sp28" | |||
android:text="200" | |||
android:paddingEnd="5dp" | |||
@@ -33,7 +33,7 @@ | |||
android:layout_marginTop="@dimen/dp10" | |||
android:layout_marginStart="@dimen/dp50" | |||
android:layout_width="@dimen/dp120" | |||
android:text="仓位7\n[未设置]" | |||
android:text="液体通道1\n[未设置]" | |||
android:clickable="true" | |||
app:layout_constraintStart_toStartOf="parent" | |||
app:layout_constraintTop_toTopOf="parent" | |||
@@ -59,7 +59,7 @@ | |||
android:layout_marginStart="@dimen/dp50" | |||
android:clickable="true" | |||
android:layout_width="@dimen/dp120" | |||
android:text="仓位8\n[未设置]" | |||
android:text="液体通道2\n[未设置]" | |||
app:layout_constraintStart_toStartOf="parent" | |||
app:layout_constraintTop_toTopOf="parent" | |||
android:gravity="center" | |||
@@ -83,7 +83,7 @@ | |||
android:layout_marginStart="@dimen/dp50" | |||
android:clickable="true" | |||
android:layout_width="@dimen/dp120" | |||
android:text="仓位9\n[未设置]" | |||
android:text="液体通道3\n[未设置]" | |||
app:layout_constraintStart_toStartOf="parent" | |||
app:layout_constraintTop_toTopOf="parent" | |||
android:gravity="center" | |||
@@ -108,7 +108,7 @@ | |||
android:layout_marginEnd="@dimen/dp50" | |||
android:clickable="true" | |||
android:layout_width="@dimen/dp120" | |||
android:text="仓位10\n[未设置]" | |||
android:text="液体通道4\n[未设置]" | |||
app:layout_constraintEnd_toEndOf="parent" | |||
app:layout_constraintTop_toTopOf="parent" | |||
android:gravity="center" | |||
@@ -132,7 +132,7 @@ | |||
android:layout_marginEnd="@dimen/dp50" | |||
android:clickable="true" | |||
android:layout_width="@dimen/dp120" | |||
android:text="仓位11\n[未设置]" | |||
android:text="液体通道5\n[未设置]" | |||
app:layout_constraintEnd_toEndOf="parent" | |||
app:layout_constraintTop_toTopOf="parent" | |||
android:gravity="center" | |||
@@ -156,7 +156,7 @@ | |||
android:layout_marginEnd="@dimen/dp50" | |||
android:layout_width="@dimen/dp120" | |||
android:clickable="true" | |||
android:text="仓位12\n[未设置]" | |||
android:text="液体通道6\n[未设置]" | |||
app:layout_constraintEnd_toEndOf="parent" | |||
app:layout_constraintTop_toTopOf="parent" | |||
android:gravity="center" | |||
@@ -35,7 +35,7 @@ | |||
android:layout_marginStart="@dimen/dp50" | |||
android:clickable="true" | |||
android:layout_width="@dimen/dp120" | |||
android:text="仓位1\n[未设置]" | |||
android:text="粉料通道1\n[未设置]" | |||
app:layout_constraintStart_toStartOf="parent" | |||
app:layout_constraintTop_toTopOf="parent" | |||
android:gravity="center" | |||
@@ -60,7 +60,7 @@ | |||
android:layout_marginStart="@dimen/dp50" | |||
android:layout_width="@dimen/dp120" | |||
android:clickable="true" | |||
android:text="仓位2\n[未设置]" | |||
android:text="粉料通道2\n[未设置]" | |||
app:layout_constraintStart_toStartOf="parent" | |||
app:layout_constraintTop_toTopOf="parent" | |||
android:gravity="center" | |||
@@ -84,7 +84,7 @@ | |||
android:layout_marginStart="@dimen/dp50" | |||
android:clickable="true" | |||
android:layout_width="@dimen/dp120" | |||
android:text="仓位3\n[未设置]" | |||
android:text="粉料通道3\n[未设置]" | |||
app:layout_constraintStart_toStartOf="parent" | |||
app:layout_constraintTop_toTopOf="parent" | |||
android:gravity="center" | |||
@@ -109,7 +109,7 @@ | |||
android:layout_marginEnd="@dimen/dp50" | |||
android:clickable="true" | |||
android:layout_width="@dimen/dp120" | |||
android:text="仓位4\n[未设置]" | |||
android:text="粉料通道4\n[未设置]" | |||
app:layout_constraintEnd_toEndOf="parent" | |||
app:layout_constraintTop_toTopOf="parent" | |||
android:gravity="center" | |||
@@ -134,7 +134,7 @@ | |||
android:layout_marginEnd="@dimen/dp50" | |||
android:clickable="true" | |||
android:layout_width="@dimen/dp120" | |||
android:text="仓位5\n[未设置]" | |||
android:text="粉料通道5\n[未设置]" | |||
app:layout_constraintEnd_toEndOf="parent" | |||
app:layout_constraintTop_toTopOf="parent" | |||
android:gravity="center" | |||
@@ -158,7 +158,7 @@ | |||
android:layout_marginEnd="@dimen/dp50" | |||
android:clickable="true" | |||
android:layout_width="@dimen/dp120" | |||
android:text="仓位6\n[未设置]" | |||
android:text="粉料通道6\n[未设置]" | |||
app:layout_constraintEnd_toEndOf="parent" | |||
app:layout_constraintTop_toTopOf="parent" | |||
android:gravity="center" | |||
@@ -10,6 +10,8 @@ | |||
android:orientation="horizontal" | |||
android:layout_column="3"> | |||
<LinearLayout | |||
android:layout_width="match_parent" | |||
android:layout_height="match_parent" | |||
@@ -134,4 +136,14 @@ | |||
android:background="@drawable/btn_normal_bg"/> | |||
</LinearLayout> | |||
<TextView | |||
android:id="@+id/btn_log" | |||
android:layout_width="150dp" | |||
android:layout_height="70dp" | |||
android:text="日志记录" | |||
android:textColor="@color/light_blue_600" | |||
android:textSize="22sp" | |||
android:layout_gravity="end" | |||
android:gravity="center" | |||
/> | |||
</FrameLayout> |
@@ -13,7 +13,6 @@ | |||
android:orientation="horizontal" | |||
> | |||
<ToggleButton | |||
android:layout_marginHorizontal="@dimen/dp20" | |||
android:id="@+id/tb_recipe_mode" | |||
@@ -0,0 +1,57 @@ | |||
<?xml version="1.0" encoding="utf-8"?> | |||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | |||
android:layout_width="match_parent" | |||
xmlns:tools="http://schemas.android.com/tools" | |||
android:orientation="horizontal" | |||
android:paddingBottom="@dimen/dp_3" | |||
android:paddingTop="@dimen/dp_3" | |||
android:background="@drawable/bg_bottom_line" | |||
android:layout_height="wrap_content"> | |||
<RelativeLayout | |||
android:layout_width="0dp" | |||
android:layout_height="wrap_content" | |||
android:layout_weight="1.6"> | |||
<TextView | |||
android:id="@+id/type" | |||
android:layout_width="match_parent" | |||
android:layout_height="wrap_content" | |||
android:gravity="center" | |||
android:textSize="@dimen/sp_22" | |||
android:paddingTop="10dp" | |||
android:paddingBottom="10dp" | |||
android:layout_alignParentLeft="true" | |||
tools:text="角色操作日志" | |||
android:textColor="@color/black" /> | |||
</RelativeLayout> | |||
<RelativeLayout | |||
android:layout_width="0dp" | |||
android:layout_height="wrap_content" | |||
android:layout_weight="2.8"> | |||
<TextView | |||
android:id="@+id/time" | |||
android:layout_width="match_parent" | |||
android:layout_height="wrap_content" | |||
android:gravity="center" | |||
android:textSize="@dimen/sp_22" | |||
android:layout_marginLeft="10dp" | |||
tools:text="yyyy-MM-dd 00:00:00" | |||
android:textColor="@color/black"/> | |||
</RelativeLayout> | |||
<RelativeLayout | |||
android:layout_width="0dp" | |||
android:layout_height="wrap_content" | |||
android:layout_weight="4"> | |||
<TextView | |||
android:id="@+id/desc" | |||
android:layout_width="match_parent" | |||
android:layout_height="wrap_content" | |||
android:gravity="center" | |||
android:textSize="@dimen/sp_22" | |||
android:ellipsize="end" | |||
android:maxLines="1" | |||
android:singleLine="true" | |||
android:layout_alignParentLeft="true" | |||
tools:text="日志描述" | |||
android:textColor="@color/black"/> | |||
</RelativeLayout> | |||
</LinearLayout> |
@@ -0,0 +1,14 @@ | |||
<?xml version="1.0" encoding="utf-8"?> | |||
<CheckedTextView xmlns:android="http://schemas.android.com/apk/res/android" | |||
android:id="@+id/checkedTextViewCustom_1" | |||
style="?android:attr/spinnerDropDownItemStyle" | |||
android:layout_width="match_parent" | |||
android:layout_height="wrap_content" | |||
android:paddingBottom="5dp" | |||
android:paddingTop="5dp" | |||
android:background="@color/button_border" | |||
android:ellipsize="marquee" | |||
android:singleLine="true" | |||
android:text="11111" | |||
android:textAlignment="inherit" | |||
android:textSize="22sp"/> |
@@ -0,0 +1,19 @@ | |||
<?xml version="1.0" encoding="utf-8"?> | |||
<TextView xmlns:android="http://schemas.android.com/apk/res/android" | |||
android:id="@+id/textViewCustom" | |||
style="?android:attr/spinnerItemStyle" | |||
android:layout_width="match_parent" | |||
android:layout_height="wrap_content" | |||
android:paddingBottom="5dp" | |||
android:paddingTop="5dp" | |||
android:ellipsize="marquee" | |||
android:singleLine="true" | |||
android:textAlignment="inherit" | |||
android:gravity="center_vertical" | |||
android:text="请选择" | |||
android:textSize="22sp" | |||
android:textColor="@color/black"> | |||
</TextView> | |||
@@ -31,8 +31,8 @@ | |||
android:layout_alignParentEnd="true" | |||
/> | |||
<TextView | |||
android:layout_width="@dimen/dp40" | |||
android:layout_height="@dimen/dp40" | |||
android:layout_width="@dimen/dp30" | |||
android:layout_height="@dimen/dp30" | |||
android:background="@mipmap/ic_clear_white_48dp" | |||
android:layout_alignParentEnd="true" | |||
/> | |||
@@ -66,4 +66,17 @@ | |||
<item name="android:windowEnterAnimation">@null</item> | |||
<item name="android:windowExitAnimation">@null</item> | |||
</style> | |||
<style name="commonSpinnerStyle" parent="Widget.AppCompat.Spinner"> | |||
<item name="android:background">@drawable/spinner_border</item> | |||
<!-- <item name="android:popupBackground">@color/main_background</item>--> | |||
<item name="android:dropDownVerticalOffset">@dimen/dp_40</item> | |||
<item name="android:paddingLeft">0dp</item> | |||
<item name="android:paddingRight">4dp</item> | |||
<item name="android:paddingTop">0dp</item> | |||
<item name="android:paddingBottom">0dp</item> | |||
<item name="android:layout_height">26dp</item> | |||
<item name="android:layout_marginLeft">5dp</item> | |||
<item name="android:textColor">@color/black</item> | |||
</style> | |||
</resources> |