Bladeren bron

32232322211312312

master
fyf 1 jaar geleden
bovenliggende
commit
91c0efe3c9
17 gewijzigde bestanden met toevoegingen van 840 en 180 verwijderingen
  1. +2
    -0
      app/build.gradle
  2. +3
    -1
      app/src/main/java/com/example/bpa/LoginActivity.java
  3. +9
    -1
      app/src/main/java/com/example/bpa/Model/IMessageLogNotify.java
  4. +27
    -141
      app/src/main/java/com/example/bpa/app/BusinessServer.java
  5. +45
    -1
      app/src/main/java/com/example/bpa/app/ICSApp.java
  6. +11
    -0
      app/src/main/java/com/example/bpa/config/DataBus.java
  7. +56
    -0
      app/src/main/java/com/example/bpa/db/QueryDB.java
  8. +86
    -0
      app/src/main/java/com/example/bpa/helper/DateUtils.java
  9. +37
    -1
      app/src/main/java/com/example/bpa/helper/MessageLog.java
  10. +109
    -0
      app/src/main/java/com/example/bpa/view/adapter/ygcarz_adapter.java
  11. +0
    -24
      app/src/main/java/com/example/bpa/view/fragment/SystemSetFragment.java
  12. +159
    -4
      app/src/main/java/com/example/bpa/view/from/ygczrz_activity.java
  13. +8
    -0
      app/src/main/java/com/example/bpa/view/mode/AlertLogEnum.java
  14. +13
    -0
      app/src/main/java/com/example/bpa/view/mode/ResLog.java
  15. +9
    -0
      app/src/main/java/com/example/bpa/view/mode/UserLogEnum.java
  16. +77
    -0
      app/src/main/res/layout/datatab/layout/ygcarz_item.xml
  17. +189
    -7
      app/src/main/res/layout/from/layout/activity_ygczrz.xml

+ 2
- 0
app/build.gradle Bestand weergeven

@@ -65,6 +65,8 @@ dependencies {
implementation files('libs\\sdkapi.jar')
compileOnly files('libs/sdkapi.jar')
implementation files('libs/modbus4Android-1.2.jar')
implementation 'com.contrarywind:Android-PickerView:3.2.6'

// implementation 'androidx.databinding:databinding-runtime:4.1.4'
// implementation 'androidx.appcompat:appcompat:1.3.1'
// implementation 'androidx.core:core-ktx:1.6.0'


+ 3
- 1
app/src/main/java/com/example/bpa/LoginActivity.java Bestand weergeven

@@ -14,6 +14,7 @@ import com.example.bpa.db.QueryDB;
import com.example.bpa.db.mode.BPA_USER;
import com.example.bpa.helper.MessageLog;
import com.example.bpa.helper.T;
import com.example.bpa.view.mode.UserLogEnum;

public class LoginActivity extends Activity implements View.OnClickListener {
//region 界面变量
@@ -65,7 +66,7 @@ public class LoginActivity extends Activity implements View.OnClickListener {
if (user!=null) {
ConfigName.getInstance().user = user;
Main.getInstance().SavePZ();//保存配置
MessageLog.ShowInfo("登录");
MessageLog.ShowUserMessage(UserLogEnum.登录日志,user.name+"-登录成功");
T.show(LoginActivity.this, "登录成功!");
try {
Intent intent = new Intent(LoginActivity.this, MainActivity.class);
@@ -74,6 +75,7 @@ public class LoginActivity extends Activity implements View.OnClickListener {
throw new RuntimeException(e);
}
} else {
MessageLog.ShowUserMessage(UserLogEnum.登录日志,user+"-用户密码错误!");
T.show(LoginActivity.this, "用户密码错误!");
}
}


+ 9
- 1
app/src/main/java/com/example/bpa/Model/IMessageLogNotify.java Bestand weergeven

@@ -1,9 +1,17 @@
package com.example.bpa.Model;

import com.example.bpa.view.mode.AlertLogEnum;
import com.example.bpa.view.mode.UserLogEnum;

public interface IMessageLogNotify {
void ErrorMsg(String msg);

void InfoMsg(String msg,String datetiem);
void InfoMsg(String msg);

void WarnMsg(String msg);

void UserMsg(UserLogEnum type,String msg);

void AlertMsg(AlertLogEnum type, String msg);

}

+ 27
- 141
app/src/main/java/com/example/bpa/app/BusinessServer.java Bestand weergeven

@@ -14,6 +14,7 @@ import com.example.bpa.helper.MessageLog;
import com.example.bpa.helper.ThreadManager;
import com.example.bpa.view.mode.MakeStatus;
import com.example.bpa.view.mode.ResGoodsRecipe;
import com.example.bpa.view.mode.UserLogEnum;

import java.sql.Ref;
import java.text.SimpleDateFormat;
@@ -54,142 +55,26 @@ public class BusinessServer {
}

/**
* 订单制作线程
* 订单制作线程新->增加物料检查(物料检测临时屏蔽-后续 需放开)
*/
public void Init() {
ThreadManager.Get().StartLong("订单执行业务流程", true, new IThread() {
@Override
public void Run() throws InterruptedException {
while (Commoditys.size() > 0) {
//0.验证物料是否充足【待编写】
//1.取出需要制作的订单商品
String GoodId = Commoditys.poll();
//2.获取商品的配方信息
ArrayList<ResGoodsRecipe> goods = QueryDB.GetGoodsSrecipeList(GoodId);
BPA_GOODS good= QueryDB.GetGoodsId(GoodId);
//3.根据物料配方排序Sort步骤分组
//region 根据物料配方排序Sort步骤分组
LinkedHashMap<Integer, List<ResGoodsRecipe>> rgrs = new LinkedHashMap<>();
for (int i = 0; i < goods.size(); i++) {
if (!rgrs.containsKey(goods.get(i).sort))
rgrs.put(goods.get(i).sort, new ArrayList<>());
rgrs.get(goods.get(i).sort).add(goods.get(i));
}
//endregion
//4.根据步骤分组进行物料下发
//region 物料下发
int count=0;
for (LinkedHashMap.Entry<Integer, List<ResGoodsRecipe>> entry : rgrs.entrySet()) {
final Integer key=entry.getKey();
//当前一次性下发物料集合
List<ResGoodsRecipe> goodsRecipes= entry.getValue();
String RecipesNames="";
for (ResGoodsRecipe item:goodsRecipes ){RecipesNames+=item.materialName+",";}
DataBus.getInstance().UpdateGoodsMake(good.id,"步骤【" + key+ "】准备下发物料:"+RecipesNames,count);
for (int m = 0; m < goodsRecipes.size(); m++) {
ResGoodsRecipe recipe=goodsRecipes.get(m);
int materialType = recipe.materialType;
final String message="步骤【" + key+ "】下发【"+recipe.materialName+"】";
if(materialType==1)//1.正常物料
{
//获取物料关联的料仓信息
BPA_SILOS silos=null;
List<BPA_SILOS> siloslist = QueryDB.GetSolisByMaterialID(recipe.materialID);
for (BPA_SILOS item:siloslist)
{
//临时屏蔽物料量检测
// if(DeviceData.Get().getCallCurrentWeight(item.num)>=recipe.value){silos=item;break;}
silos=item;break;
}
if (silos==null)
{
MessageLog.ShowInfo(message+"下发失败!物料没有管理料仓!");
}else
{
MessageLog.ShowInfo(message+"准备下发【" + silos.num + "】号料仓PLC控制命令,需求量:=" + recipe.value);
DeviceData.Get().setDemandValue((short) recipe.value, silos.num, new IWriteCallBack() {
@Override
public void onSuccess() {
MessageLog.ShowInfo(message+"下发成功!");
}
@Override
public void onFailure(String ErrorMsg) {
MessageLog.ShowInfo(message+"下发失败!"+ErrorMsg);
}
});
}
}else if (materialType == 2)//果糖
{
BPA_SUGAR bs = QueryDB.GetsugarId(recipe.materialID);
ModbusTcpServer.get().WriteBool(bs.plcvar, true);
Thread.sleep(200);
ModbusTcpServer.get().WriteBool(bs.plcvar, false);
MessageLog.ShowInfo(message+"下发成功!");
}
}
//启动配料
DeviceData.Get().setChargeMixtureStart(new IWriteCallBack() {
@Override
public void onSuccess() {
MessageLog.ShowInfo("步骤【" + key+ "】启动配料成功!");
}
@Override
public void onFailure(String ErrorMsg) {
MessageLog.ShowInfo("步骤【" + key+ "】启动配料失败!");
}
});

//等待配料完成,一直等待
final boolean[] IsComplete = {false};
DeviceData.Get().OnChargeMixtureCompleteNotify = new IRun() {
@Override
public void Run() {
IsComplete[0] = true;
MessageLog.ShowInfo("步骤【" + key+ "】配料完成!");
}
};
while (!IsComplete[0]) {
Thread.sleep(100);
}
//更新缓存商品制作列表状态
count+=goodsRecipes.size();
DataBus.getInstance().UpdateGoodsMake(good.id,"步骤【" + key+ "】:"+RecipesNames+"-配料完成",count);
MessageLog.ShowInfo("步骤【" + key + "】执行完成");
}
//endregion
//5.设置数据中心商品已制作完成
DataBus.getInstance().DeleteGoodsMake(GoodId);
MessageLog.ShowInfo(good.name+"-订单执行完成");
}
Thread.sleep(1000);
}
@Override
public void RunComplete() throws InterruptedException {
}
});
}

/**
* 订单制作线程新->增加物料检查
*/
public void InitNew() {
ThreadManager.Get().StartLong("订单执行业务流程-新", true, new IThread() {
@Override
public void Run() throws InterruptedException {
while (Commoditys.size() > 0) {
//1.取出需要制作的订单商品 验证物料是否充足
String GoodId = Commoditys.poll();
boolean IsMake=true;
ResultA resultA= DataBus.getInstance().InspectMaterial(GoodId);
if(resultA.IsMake==false)//如果商品物料不足
{
DataBus.getInstance().UpdateGoodsMake(GoodId,resultA.Message,0);
IsMake=false;
}
while (!IsMake) {
IsMake=DataBus.getInstance().InspectMaterial(GoodId).IsMake;
Thread.sleep(2000);
}
// boolean IsMake=true;
// ResultA resultA= DataBus.getInstance().InspectMaterial(GoodId);
// if(resultA.IsMake==false)//如果商品物料不足
// {
// DataBus.getInstance().UpdateGoodsMake(GoodId,resultA.Message,0);
// IsMake=false;
// }
// while (!IsMake) {
// IsMake=DataBus.getInstance().InspectMaterial(GoodId).IsMake;
// Thread.sleep(2000);
// }
//2.获取商品的配方信息
ArrayList<ResGoodsRecipe> goods = QueryDB.GetGoodsSrecipeList(GoodId);
BPA_GOODS good= QueryDB.GetGoodsId(GoodId);
@@ -215,7 +100,7 @@ public class BusinessServer {
for (int m = 0; m < goodsRecipes.size(); m++) {
ResGoodsRecipe recipe=goodsRecipes.get(m);
int materialType = recipe.materialType;
final String message="步骤【" + key+ "】下发【"+recipe.materialName+"】";
final String message="["+good.name+"]步骤【" + key+ "】下发【"+recipe.materialName+"】";
if(materialType==1)//1.正常物料
{
//获取物料关联的料仓信息
@@ -224,22 +109,23 @@ public class BusinessServer {
for (BPA_SILOS item:siloslist)
{
//临时屏蔽物料量检测
if(DeviceData.Get().getCallCurrentWeight(item.num)>=recipe.value){silos=item;break;}
// if(DeviceData.Get().getCallCurrentWeight(item.num)>=recipe.value){silos=item;break;}
silos=item;
}
if (silos==null)
{
MessageLog.ShowInfo(message+"下发失败!物料没有管理料仓!");
MessageLog.ShowUserMessage(UserLogEnum.订单处理日志,message+"下发失败!物料没有管理料仓!");
}else
{
MessageLog.ShowInfo(message+"准备下发【" + silos.num + "】号料仓PLC控制命令,需求量:=" + recipe.value);
MessageLog.ShowUserMessage(UserLogEnum.订单处理日志,message+"准备下发【" + silos.num + "】号料仓PLC控制命令,需求量:=" + recipe.value);
DeviceData.Get().setDemandValue((short) recipe.value, silos.num, new IWriteCallBack() {
@Override
public void onSuccess() {
MessageLog.ShowInfo(message+"下发成功!");
MessageLog.ShowUserMessage(UserLogEnum.订单处理日志,message+"下发成功!");
}
@Override
public void onFailure(String ErrorMsg) {
MessageLog.ShowInfo(message+"下发失败!"+ErrorMsg);
MessageLog.ShowUserMessage(UserLogEnum.订单处理日志,message+"下发失败!"+ErrorMsg);
}
});
}
@@ -249,18 +135,18 @@ public class BusinessServer {
ModbusTcpServer.get().WriteBool(bs.plcvar, true);
Thread.sleep(200);
ModbusTcpServer.get().WriteBool(bs.plcvar, false);
MessageLog.ShowInfo(message+"下发成功!");
MessageLog.ShowUserMessage(UserLogEnum.订单处理日志,message+"下发成功!");
}
}
//启动配料
DeviceData.Get().setChargeMixtureStart(new IWriteCallBack() {
@Override
public void onSuccess() {
MessageLog.ShowInfo("步骤【" + key+ "】启动配料成功!");
MessageLog.ShowInfo("["+good.name+"]步骤【" + key+ "】启动配料成功!");
}
@Override
public void onFailure(String ErrorMsg) {
MessageLog.ShowInfo("步骤【" + key+ "】启动配料失败!");
MessageLog.ShowInfo("["+good.name+"]步骤【" + key+ "】启动配料失败!");
}
});

@@ -270,7 +156,7 @@ public class BusinessServer {
@Override
public void Run() {
IsComplete[0] = true;
MessageLog.ShowInfo("步骤【" + key+ "】配料完成!");
MessageLog.ShowUserMessage(UserLogEnum.订单处理日志,"["+good.name+"]步骤【" + key+ "】配料完成!");
}
};
while (!IsComplete[0]) {
@@ -278,13 +164,13 @@ public class BusinessServer {
}
//更新缓存商品制作列表状态
count+=goodsRecipes.size();
DataBus.getInstance().UpdateGoodsMake(good.id,"步骤【" + key+ "】:"+RecipesNames+"-配料完成",count);
MessageLog.ShowInfo("步骤【" + key + "】执行完成");
DataBus.getInstance().UpdateGoodsMake(good.id,"步骤【" + key+ "】:"+RecipesNames+"-配料完成!",count);
MessageLog.ShowUserMessage(UserLogEnum.订单处理日志,"["+good.name+"]步骤【" + key + "】执行完成!");
}
//endregion
//5.设置数据中心商品已制作完成
DataBus.getInstance().DeleteGoodsMake(GoodId);
MessageLog.ShowInfo(good.name+"-订单执行完成");
MessageLog.ShowUserMessage(UserLogEnum.订单处理日志,"["+good.name+"]-订单执行完成,请取餐!");
}
Thread.sleep(1000);
}


+ 45
- 1
app/src/main/java/com/example/bpa/app/ICSApp.java Bestand weergeven

@@ -7,6 +7,7 @@ import android.util.Log;
import com.example.bpa.Model.IMessageLogNotify;
import com.example.bpa.config.ConfigName;
import com.example.bpa.db.QueryDB;
import com.example.bpa.db.mode.BPA_ALERTLOG;
import com.example.bpa.db.mode.BPA_LOG;
import com.example.bpa.db.mode.BPA_MATERIAL;
import com.example.bpa.db.mode.BPA_SILOS;
@@ -17,6 +18,8 @@ import com.example.bpa.helper.Json;
import com.example.bpa.helper.MessageLog;
import com.example.bpa.helper.SdCart;
import com.example.bpa.helper.ToastUtil;
import com.example.bpa.view.mode.AlertLogEnum;
import com.example.bpa.view.mode.UserLogEnum;

import java.util.ArrayList;

@@ -39,6 +42,8 @@ public class ICSApp extends Application {
Main.getInstance();
//5.PLC数据监控
ModbusTcpServer.get().Connect(ConfigName.getInstance().Address, ConfigName.getInstance().Post);

//BusinessServer.Get().Init();
}

/**
@@ -51,13 +56,52 @@ public class ICSApp extends Application {
Log.e("Error", msg);
}
@Override
public void InfoMsg(String msg, String datetime) {
public void InfoMsg(String msg) {
Log.i("Info", msg);
}
@Override
public void WarnMsg(String msg) {
Log.w("Warn", msg);
}
@Override
public void UserMsg(UserLogEnum type, String msg) {
BPA_LOG log = new BPA_LOG();
log.userID = ConfigName.getInstance().user.userID;
switch (type.toString())
{
case "登录日志":log.type=1;
break;
case "角色操作日志":log.type=2;
break;
case "数据接收":log.type=3;
break;
case "上传日志":log.type=4;
break;
case "订单处理日志":log.type=5;
break;
}
log.text = msg;
QueryDB.Addlog(log);
}

@Override
public void AlertMsg(AlertLogEnum type, String msg) {
BPA_ALERTLOG log = new BPA_ALERTLOG();
log.userID = ConfigName.getInstance().user.userID;
switch (type.toString())
{
case "异常订单未制作日志":log.type=1;
break;
case "料仓缺料日志":log.type=2;
break;
case "传感器异常日志":log.type=3;
break;
case "其他":log.type=4;
break;
}
log.text = msg;
QueryDB.AddAlertlog(log);
}
};
}
/**


+ 11
- 0
app/src/main/java/com/example/bpa/config/DataBus.java Bestand weergeven

@@ -4,7 +4,9 @@ import com.example.bpa.Model.ResultA;
import com.example.bpa.R;
import com.example.bpa.app.DeviceData;
import com.example.bpa.db.QueryDB;
import com.example.bpa.db.mode.BPA_ALERTLOG;
import com.example.bpa.db.mode.BPA_GOODS;
import com.example.bpa.db.mode.BPA_LOG;
import com.example.bpa.db.mode.BPA_SILOS;
import com.example.bpa.view.adapter.maingoods_adapter;
import com.example.bpa.view.adapter.makegood_adapter;
@@ -195,5 +197,14 @@ public class DataBus {
}
}
}

/**
* 员工操作日志
*/
public List<BPA_LOG> bpa_logs = new ArrayList<BPA_LOG>();
/**
* 订单操作日志
*/
public List<BPA_ALERTLOG> bpa_alertlogs = new ArrayList<BPA_ALERTLOG>();
//endregion
}

+ 56
- 0
app/src/main/java/com/example/bpa/db/QueryDB.java Bestand weergeven

@@ -23,6 +23,7 @@ import com.example.bpa.db.mode.BPA_USER;
import com.example.bpa.db.mode.ModeBase;
import com.example.bpa.helper.Tools;
import com.example.bpa.view.mode.ResGoodsRecipe;
import com.example.bpa.view.mode.ResLog;
import com.example.bpa.view.mode.ResSilosMode;
import java.lang.reflect.Field;
import java.text.SimpleDateFormat;
@@ -1009,6 +1010,61 @@ public class QueryDB {
return data;
}

/**
*
* @return
*/
public static ArrayList<ResLog> Getlogs(String sta, String stp, int lx, String text) {
String orderby = Desc_Time_Down;//先按排序 创建时间倒序
String where = "isDelete=? and createTime>=? and createTime<=?";
String[] args = new String[]{"0", sta,stp};
if(lx!=0)
{
where = "isDelete=? and createTime>=? and createTime<=? and type=?";
args = new String[]{"0", sta,stp,String.valueOf(lx)};
if(!text.isEmpty())
{
where = "isDelete=? and createTime>=? and createTime<=? and text like ? and type=?";
args = new String[]{"0", sta,stp,"%"+text+"%",String.valueOf(lx)};
}
}else
{
if(!text.isEmpty())
{
where = "isDelete=? and createTime>=? and createTime<=? and text like ?";
args = new String[]{"0", sta,stp,"%"+text+"%"};
}
}
ArrayList<BPA_USER> Users=GetUserALL();
ArrayList<ResLog> data = new ArrayList<>();
ArrayList<Object> obj = Get(BPA_LOG.class, where, args, orderby);
for (Object k : obj) {
BPA_LOG o=(BPA_LOG) k;
ResLog log=new ResLog();
log.type=o.type;
log.text=o.text;
log.id=o.id;
log.createTime=o.createTime;
log.updateTime=o.updateTime;
log.deleteTime=o.deleteTime;
log.deviceID=o.deviceID;
log.userID=o.userID;
log.isDelete=o.isDelete;
log.exp=o.exp;

BPA_USER user=null;
for (BPA_USER i:Users)
{
if(i.id.equals(log.userID)){user =i; break;}
}
if(user!=null)
{
log.Name=user.name;
}
data.add(log);
}
return data;
}

/**
* 获取所有今日日志


+ 86
- 0
app/src/main/java/com/example/bpa/helper/DateUtils.java Bestand weergeven

@@ -0,0 +1,86 @@
package com.example.bpa.helper;


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;
}
}

}


+ 37
- 1
app/src/main/java/com/example/bpa/helper/MessageLog.java Bestand weergeven

@@ -2,6 +2,8 @@ package com.example.bpa.helper;

import com.example.bpa.Model.IMessageLogNotify;
import com.example.bpa.Model.IRun;
import com.example.bpa.view.mode.AlertLogEnum;
import com.example.bpa.view.mode.UserLogEnum;

import java.text.SimpleDateFormat;
import java.util.Date;
@@ -22,7 +24,7 @@ public class MessageLog {
String tempMsg = formatter.format(date) + ":" + msg;
MsgInfo = tempMsg + "\r\n" + MsgInfo;
if (MsgNotify != null)
MsgNotify.InfoMsg(tempMsg, formatter.format(date));
MsgNotify.InfoMsg(tempMsg);
if (AddNotify != null) AddNotify.Run();
}

@@ -45,4 +47,38 @@ public class MessageLog {
MsgNotify.ErrorMsg(tempMsg);
if (AddNotify != null) AddNotify.Run();
}

/**
* 用户操作日志
* @param type
* @param msg
*/
public static void ShowUserMessage(UserLogEnum type, String msg)
{
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date date = new Date();
String tempMsg = formatter.format(date) + ":" + msg;
MsgInfo = tempMsg + "\r\n" + MsgInfo;
if (MsgNotify != null)
MsgNotify.UserMsg(type,tempMsg);
if (AddNotify != null) AddNotify.Run();
}

/**
* 预警日志
* @param type
* @param msg
*/
public static void ShowAlertMessage(AlertLogEnum type, String msg)
{
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date date = new Date();
String tempMsg = formatter.format(date) + ":" + msg;
MsgInfo = tempMsg + "\r\n" + MsgInfo;
if (MsgNotify != null)
MsgNotify.AlertMsg(type,tempMsg);
if (AddNotify != null) AddNotify.Run();
}


}

+ 109
- 0
app/src/main/java/com/example/bpa/view/adapter/ygcarz_adapter.java Bestand weergeven

@@ -0,0 +1,109 @@
package com.example.bpa.view.adapter;

import android.app.Activity;
import android.content.Context;
import android.content.ContextWrapper;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.ProgressBar;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.recyclerview.widget.RecyclerView;

import com.example.bpa.R;
import com.example.bpa.config.ConfigName;
import com.example.bpa.config.DataBus;
import com.example.bpa.db.mode.BPA_LOG;
import com.example.bpa.db.mode.BPA_MATERIAL;
import com.example.bpa.helper.T;
import com.example.bpa.view.inteface.MyClickListener;
import com.example.bpa.view.mode.MakeStatus;
import com.example.bpa.view.mode.ResGoodsMake;
import com.example.bpa.view.mode.ResLog;

import java.util.List;

public class ygcarz_adapter extends ArrayAdapter<ResLog> {
private List<ResLog> datas;
private Context context;

private int resource;

public ygcarz_adapter(@NonNull Context context, int resource, @NonNull List<ResLog> objects) {
super(context, resource, objects);
this.context = context;
this.resource=resource;
datas=objects;
}
//每个子项被滚动到屏幕内的时候会被调用
@NonNull
@Override
public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) {
ResLog log = (ResLog) getItem(position);//得到当前项选中item实例
//为每一个子项加载设定的布局
View view = LayoutInflater.from(getContext()).inflate(this.resource, parent, false);
//分别获取 image view 和 textview 的实例
TextView name,type,time,message;
name = (TextView) view.findViewById(R.id.name);
type = (TextView) view.findViewById(R.id.type);
time = (TextView) view.findViewById(R.id.time);
message = (TextView) view.findViewById(R.id.message);
name.setText(log.Name);
switch (log.type)
{
case 1:
type.setText("登录日志");
break;
case 2:
type.setText("角色操作日志");
break;
case 3:
type.setText("数据接收");
break;
case 4:
type.setText("上传日志");
break;
case 5:
type.setText("订单处理日志");
break;
}
time.setText(log.createTime);
message.setText(log.text);
return view;
}
private Activity findActivity(@NonNull Context context) {
if (context instanceof Activity) {
return (Activity) context;
} else if (context instanceof ContextWrapper) {
return findActivity(((ContextWrapper) context).getBaseContext());
} else {
return null;
}
}
/**
* 刷新
* @param
*/
public void refresh(){
Activity activity= findActivity(context);
if(activity!=null)
{
activity.runOnUiThread(new Runnable() {
@Override
public void run() {
try {
notifyDataSetChanged();
} catch (Exception e) {

}
}
});
}
}
}

+ 0
- 24
app/src/main/java/com/example/bpa/view/fragment/SystemSetFragment.java Bestand weergeven

@@ -54,30 +54,6 @@ public class SystemSetFragment extends Fragment implements View.OnClickListener
Systemparameter = new systemparameter();
btn_system_set = view.findViewById(R.id.stparameter);
btn_lc_set = view.findViewById(R.id.lcparameter);
MessageLog.MsgNotify = new IMessageLogNotify() {
@Override
public void ErrorMsg(String msg) {
Log.e("Error", msg);

}

@Override
public void InfoMsg(String msg, String datetime) {
BPA_LOG log = new BPA_LOG();
log.userID = ConfigName.getInstance().user.userID;
log.createTime = datetime;
log.type = 1;
log.text = msg;
QueryDB.Addlog(log);
Log.i("Info", msg);
}

@Override
public void WarnMsg(String msg) {
Log.w("Warn", msg);
}
};

//默认打开参数设置界面
ShowFragment(Systemparameter);
}


+ 159
- 4
app/src/main/java/com/example/bpa/view/from/ygczrz_activity.java Bestand weergeven

@@ -1,20 +1,45 @@
package com.example.bpa.view.from;

import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.LinearLayoutManager;

import android.graphics.Color;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.Spinner;
import android.widget.TextView;

import com.bigkoo.pickerview.TimePickerView;
import com.example.bpa.R;
import com.example.bpa.config.DataBus;
import com.example.bpa.db.QueryDB;
import com.example.bpa.db.mode.BPA_LOG;
import com.example.bpa.db.mode.BPA_MATERIAL;
import com.example.bpa.helper.DateUtils;
import com.example.bpa.helper.T;
import com.example.bpa.view.adapter.makegood_adapter;
import com.example.bpa.view.adapter.wl_adapter;
import com.example.bpa.view.adapter.ygcarz_adapter;
import com.example.bpa.view.mode.ResLog;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.LinkedHashMap;
import java.util.Map;

/**
* 员工操作日志
*/
public class ygczrz_activity extends AppCompatActivity implements View.OnClickListener{
public class ygczrz_activity extends AppCompatActivity implements View.OnClickListener {
//region 变量
/**
* 返回按钮
@@ -26,6 +51,42 @@ public class ygczrz_activity extends AppCompatActivity implements View.OnClickLi
TextView gongneng_title;
//endregion

//region 操作变量
/**
* 输入框
*/
TextView edittext;
/**
* 查询按钮
*/
Button button;
/**
* 表格显示
*/
ListView datatab;
/**
* 日志数据
*/
ArrayList<ResLog> bpa_logs = new ArrayList<>();
/**
* 员工操作日志控制器
*/
ygcarz_adapter ygcarz_adapter;
/**
* 日期选择器
*/
TimePickerView pvTime;
/**
* 开始时间-结束时间
*/
EditText starttime, stoptime;
/**
* 日志类型
*/
Spinner rzlx;
Map<String,Integer> lx_map = new LinkedHashMap<>();
//endregion

//region 私有函数
@Override
protected void onCreate(Bundle savedInstanceState) {
@@ -43,14 +104,81 @@ public class ygczrz_activity extends AppCompatActivity implements View.OnClickLi
/**
* 初始化
*/
private void Init(){
private void Init() {
gongneng_fanhui = this.findViewById(R.id.gongneng_fanhui);
gongneng_title = this.findViewById(R.id.gongneng_title);
edittext = this.findViewById(R.id.edittext);
button = this.findViewById(R.id.button);
datatab = this.findViewById(R.id.datatab);
starttime = this.findViewById(R.id.starttime);
stoptime = this.findViewById(R.id.stoptime);
rzlx = this.findViewById(R.id.rzlx);
//通过Activity.getIntent()获取当前页面接收到的Intent。 getXxxExtra方法获取Intent传递过来的数据
String msg=getIntent().getStringExtra("data");
String msg = getIntent().getStringExtra("data");
gongneng_title.setText(msg);
lx_map.put("全部日志",0);
lx_map.put("登录日志",1);
lx_map.put("角色操作日志",2);
lx_map.put("数据接收",3);
lx_map.put("上传日志",4);
lx_map.put("订单处理日志",5);
ArrayAdapter<String> adapter2 = new ArrayAdapter<>(this, R.layout.spinner_text_item, new ArrayList<>(lx_map.keySet()));
adapter2.setDropDownViewResource(R.layout.spinner_dropdown_item);
rzlx.setAdapter(adapter2);

starttime.setText(new SimpleDateFormat("yyyy-MM-dd 00:00:00").format(new Date()));
stoptime.setText(new SimpleDateFormat("yyyy-MM-dd 23:59:59").format(new Date()));
starttime.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (pvTime != null) {
pvTime.show(starttime);
}
}
});
stoptime.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (pvTime != null) {
pvTime.show(stoptime);
}
}
});
CalendarTime();
Initdata();
}

((TextView)this.findViewById(R.id.test_view)).setText(msg);
/**
* 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;
btn.setText(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(date));
}
})
//年月日时分秒 的显示与否,不设置则默认全部显示
.setType(new boolean[]{true, true, true, true, true, false})
.setLabel("年", "月", "日", "时", "分", "秒")
.isCenterLabel(true)
.setDividerColor(Color.DKGRAY)
.setContentSize(16)//字号
.setDate(selectedDate)
.setRangDate(startDate, endDate)
.setDecorView(null)
.build();
}

/**
@@ -58,10 +186,34 @@ public class ygczrz_activity extends AppCompatActivity implements View.OnClickLi
*/
private void initEvents() {
gongneng_fanhui.setOnClickListener(this);
button.setOnClickListener(this);
}

/**
* 初始化数据加载
*/
public void Initdata() {
try {
String str= starttime.getText().toString();
String stop= stoptime.getText().toString();
if(DateUtils.compareDate(stop,str))
{
T.show(ygczrz_activity.this,"开始时间不能大于结束时间!!!");
return;
}
String lx= rzlx.getSelectedItem().toString();
String text= edittext.getText().toString();
bpa_logs= QueryDB.Getlogs(str,stop, lx_map.get(lx),text);
ygcarz_adapter = new ygcarz_adapter(ygczrz_activity.this,R.layout.ygcarz_item,bpa_logs);
datatab.setAdapter(ygcarz_adapter);
} catch (Exception e) {

}
}
//endregion

//region 点击事件

/**
* 本页面点击事件监听
*
@@ -73,6 +225,9 @@ public class ygczrz_activity extends AppCompatActivity implements View.OnClickLi
case R.id.gongneng_fanhui://返回按钮
this.finish();
break;
case R.id.button://查询按钮
Initdata();
break;
}
}
//endregion

+ 8
- 0
app/src/main/java/com/example/bpa/view/mode/AlertLogEnum.java Bestand weergeven

@@ -0,0 +1,8 @@
package com.example.bpa.view.mode;

public enum AlertLogEnum {
异常订单未制作日志,
料仓缺料日志,
传感器异常日志,
其他
}

+ 13
- 0
app/src/main/java/com/example/bpa/view/mode/ResLog.java Bestand weergeven

@@ -0,0 +1,13 @@
package com.example.bpa.view.mode;

import com.example.bpa.db.mode.BPA_LOG;

/**
* 返回Log信息
*/
public class ResLog extends BPA_LOG {
/**
* 用户名称
*/
public String Name;
}

+ 9
- 0
app/src/main/java/com/example/bpa/view/mode/UserLogEnum.java Bestand weergeven

@@ -0,0 +1,9 @@
package com.example.bpa.view.mode;

public enum UserLogEnum {
登录日志,
角色操作日志,
数据接收,
上传日志,
订单处理日志
}

+ 77
- 0
app/src/main/res/layout/datatab/layout/ygcarz_item.xml Bestand weergeven

@@ -0,0 +1,77 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<TableLayout
android:background="@mipmap/bgxz"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:layout_gravity="center"
android:stretchColumns="0">
<TableRow
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal">
<RelativeLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1">
<TextView
android:id="@+id/name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_alignParentLeft="true"
android:text="员工名称"
android:textColor="@color/foreground"
android:textSize="@dimen/textSize" />
</RelativeLayout>
<RelativeLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1">
<TextView
android:id="@+id/type"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_alignParentLeft="true"
android:text="日志类型"
android:textColor="@color/foreground"
android:textSize="@dimen/textSize" />
</RelativeLayout>
<RelativeLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="2">
<TextView
android:id="@+id/time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_alignParentLeft="true"
android:text="日志时间"
android:textColor="@color/foreground"
android:textSize="@dimen/textSize" />
</RelativeLayout>
<RelativeLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="4">
<TextView
android:id="@+id/message"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_alignParentLeft="true"
android:text="日志描述日志描述"
android:textColor="@color/foreground"
android:textSize="@dimen/textSize" />
</RelativeLayout>

</TableRow>
</TableLayout>
</RelativeLayout>

+ 189
- 7
app/src/main/res/layout/from/layout/activity_ygczrz.xml Bestand weergeven

@@ -79,13 +79,195 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="10dp">
<TextView
android:id="@+id/test_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/foreground"
android:textSize="@dimen/TitleSize">
</TextView>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="50dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true">
<EditText
android:id="@+id/starttime"
android:layout_width="140dp"
android:layout_height="wrap_content"
android:inputType="text"
android:padding="3dp"
android:textColor="@color/foreground"
android:theme="@style/MyEditText1"
android:background="@drawable/round_corners_bg"
android:layout_marginLeft="5dp"
android:maxLines="1"
android:focusable="false"
android:text="2023-02-33 00:00:00"
android:textSize="@dimen/textSize"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:textColor="@color/foreground"
android:text="--">
</TextView>
<EditText
android:id="@+id/stoptime"
android:layout_width="140dp"
android:layout_height="wrap_content"
android:inputType="text"
android:padding="3dp"
android:focusable="false"
android:textColor="@color/foreground"
android:theme="@style/MyEditText1"
android:background="@drawable/round_corners_bg"
android:layout_marginLeft="5dp"
android:maxLines="1"
android:text="2023-02-33 00:00:00"
android:textSize="@dimen/textSize"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:textColor="@color/foreground"
android:text="日志类型">
</TextView>
<Spinner
android:id="@+id/rzlx"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="@style/commonSpinnerStyle"/>
<EditText
android:id="@+id/edittext"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:inputType="text"
android:padding="3dp"
android:textColor="@color/foreground"
android:theme="@style/MyEditText1"
android:background="@drawable/round_corners_bg"
android:layout_marginLeft="5dp"
android:hint="请输入查询条件"
android:maxLines="1"
android:textSize="@dimen/textSize"/>
<Button
android:id="@+id/button"
android:text="查询"
android:background="@drawable/btn_button"
android:textSize="@dimen/textSize"
android:textColor="@color/foreground"
android:layout_marginLeft="5dp"
android:layout_gravity="center"
android:layout_width="60dp"
android:layout_height="26dp"
/>
</LinearLayout>

</RelativeLayout>

<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="10dp"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:background="@mipmap/bgbtbj"
android:layout_height="26dp">
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#FF03668F" />
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_alignParentBottom="true"
android:background="#FF03668F" />
<TableLayout
android:layout_centerVertical="true"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:layout_gravity="center"
android:stretchColumns="0">
<TableRow
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal">
<RelativeLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_alignParentLeft="true"
android:text="员工名称"
android:textColor="@color/dataGridColumnHeaderColor"
android:textSize="@dimen/textSize" />
</RelativeLayout>
<RelativeLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_alignParentLeft="true"
android:text="日志类型"
android:textColor="@color/dataGridColumnHeaderColor"
android:textSize="@dimen/textSize" />
</RelativeLayout>
<RelativeLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="2">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_alignParentLeft="true"
android:text="日志时间"
android:textColor="@color/dataGridColumnHeaderColor"
android:textSize="@dimen/textSize" />
</RelativeLayout>
<RelativeLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="4">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_alignParentLeft="true"
android:text="日志描述"
android:textColor="@color/dataGridColumnHeaderColor"
android:textSize="@dimen/textSize" />
</RelativeLayout>

</TableRow>
</TableLayout>
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ListView
android:id="@+id/datatab"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:divider="#00000000"
android:dividerHeight="3dp"
android:layout_marginTop="3dp"
/>
</RelativeLayout>
</LinearLayout>
</RelativeLayout>
</LinearLayout>
</RelativeLayout>
</RelativeLayout>
</LinearLayout>

Laden…
Annuleren
Opslaan