Procházet zdrojové kódy

业务流程

master
pry před 1 rokem
rodič
revize
b604f2acfb
4 změnil soubory, kde provedl 49 přidání a 53 odebrání
  1. +3
    -2
      app/src/main/java/com/example/bpa/app/BusinessServer.java
  2. +3
    -1
      app/src/main/java/com/example/bpa/app/ICSApp.java
  3. +2
    -0
      app/src/main/java/com/example/bpa/app/ModbusTcpServer.java
  4. +41
    -50
      app/src/main/java/com/example/bpa/view/from/yfpf_activity.java

+ 3
- 2
app/src/main/java/com/example/bpa/app/BusinessServer.java Zobrazit soubor

@@ -19,7 +19,7 @@ import java.util.concurrent.ConcurrentLinkedQueue;
public class BusinessServer {
private static volatile BusinessServer _instance;

public static BusinessServer get() {
public static BusinessServer Get() {
if (_instance == null)
_instance = new BusinessServer();
return _instance;
@@ -32,6 +32,7 @@ public class BusinessServer {
* 商品制作队列
*/
ConcurrentLinkedQueue<String> Commoditys = new ConcurrentLinkedQueue<String>();

/**
* 添加配方
*
@@ -44,7 +45,7 @@ public class BusinessServer {
/**
* 订单制作线程
*/
public void Start() {
public void Init() {
//DeviceData.Get().TestInit();

ThreadManager.Get().StartLong("配方执行业务流程", true, new IThread() {


+ 3
- 1
app/src/main/java/com/example/bpa/app/ICSApp.java Zobrazit soubor

@@ -36,10 +36,12 @@ public class ICSApp extends Application {
Log.e("Error", msg);

}

@Override
public void InfoMsg(String msg, String datetime) {
Log.i("Info", msg);
}

@Override
public void WarnMsg(String msg) {
Log.w("Warn", msg);
@@ -53,7 +55,7 @@ public class ICSApp extends Application {

//2.初始化SD卡,数据库DB
SdCart.getInstance().initSD();
BusinessServer.get().Start();
ModbusTcpServer.get().Connect("", 502);
//3.初始化数据
InitDBdata();
//4.初始化Main


+ 2
- 0
app/src/main/java/com/example/bpa/app/ModbusTcpServer.java Zobrazit soubor

@@ -116,6 +116,8 @@ public class ModbusTcpServer {
@Override
public void onSuccess(ModbusMaster modbusMaster) {
MessageLog.ShowInfo("设备 " + host + " 连接成功");
DeviceData.Get().Init();
BusinessServer.Get().Init();
}

@Override


+ 41
- 50
app/src/main/java/com/example/bpa/view/from/yfpf_activity.java Zobrazit soubor

@@ -54,7 +54,7 @@ public class yfpf_activity extends AppCompatActivity implements View.OnClickList
/**
* 商品数据
*/
ArrayList<BPA_GOODS> bpa_goods=new ArrayList<>();
ArrayList<BPA_GOODS> bpa_goods = new ArrayList<>();
//endregion

//region 私有函数
@@ -72,13 +72,13 @@ public class yfpf_activity extends AppCompatActivity implements View.OnClickList
/**
* 初始化
*/
private void Init(){
private void Init() {
gongneng_fanhui = this.findViewById(R.id.gongneng_fanhui);
gongneng_title = this.findViewById(R.id.gongneng_title);
buttonaddpf=this.findViewById(R.id.buttonaddpf);
datatab= this.findViewById(R.id.datatab);
buttonaddpf = this.findViewById(R.id.buttonaddpf);
datatab = this.findViewById(R.id.datatab);
//通过Activity.getIntent()获取当前页面接收到的Intent。 getXxxExtra方法获取Intent传递过来的数据
String msg=getIntent().getStringExtra("data");
String msg = getIntent().getStringExtra("data");
gongneng_title.setText(msg);
Initdata();//初始化数据
RegisterMessage();//消息中心事件接收
@@ -95,19 +95,19 @@ public class yfpf_activity extends AppCompatActivity implements View.OnClickList
/**
* 初始化数据加载
*/
public void Initdata()
{
try{
bpa_goods= QueryDB.GetGoodsALL();
sp_adapter adapter = new sp_adapter(yfpf_activity.this, R.layout.sp_item, bpa_goods,this);
public void Initdata() {
try {
bpa_goods = QueryDB.GetGoodsALL();
sp_adapter adapter = new sp_adapter(yfpf_activity.this, R.layout.sp_item, bpa_goods, this);
datatab.setAdapter(adapter);
}catch(Exception e){
} catch (Exception e) {

}
}
//endregion

//region 点击事件

/**
* 本页面点击事件监听22
*
@@ -132,89 +132,82 @@ public class yfpf_activity extends AppCompatActivity implements View.OnClickList
* 接口方法,响应ListView按钮点击事件
*/
@Override
public void clickListener(View v,Object data) {
switch (v.getId())
{
public void clickListener(View v, Object data) {
switch (v.getId()) {
case R.id.button_item://删除按钮
int sort=((BPA_GOODS)data).sort;
String id=((BPA_GOODS)data).id;
Log.i("日志",sort + "--- "+id);
QueryDB.DeleteGoods((BPA_GOODS)data);
int sort = ((BPA_GOODS) data).sort;
String id = ((BPA_GOODS) data).id;
Log.i("日志", sort + "--- " + id);
QueryDB.DeleteGoods((BPA_GOODS) data);
Initdata();
for (BPA_GOODS k:bpa_goods) {
if(k.sort>sort)
{
QueryDB.GetGoodsSort(k,1);
for (BPA_GOODS k : bpa_goods) {
if (k.sort > sort) {
QueryDB.GetGoodsSort(k, 1);
}
}
Initdata();
break;
case R.id.button_item_Up://上移动按钮
BPA_GOODS good=(BPA_GOODS)data;
if(good.sort==1)
{
BPA_GOODS good = (BPA_GOODS) data;
if (good.sort == 1) {
T.show(this, "已是最顶部!");
return;
}
QueryDB.GetGoodsSort((BPA_GOODS)data,1);
QueryDB.GetGoodsSort((BPA_GOODS) data, 1);
Initdata();
break;
case R.id.button_item_Down://下移动按钮
BPA_GOODS good2=(BPA_GOODS)data;
if(good2.sort==bpa_goods.size())
{
BPA_GOODS good2 = (BPA_GOODS) data;
if (good2.sort == bpa_goods.size()) {
T.show(this, "已是最底部!");
return;
}
QueryDB.GetGoodsSort((BPA_GOODS)data,0);
QueryDB.GetGoodsSort((BPA_GOODS) data, 0);
Initdata();
break;
case R.id.button_item_update://修改按钮
Intent intent = new Intent(this, add_pf_activity.class);
intent.putExtra("title", "修改配方");
intent.putExtra("data",new Json().objectToJson(BPA_GOODS.class,data));
intent.putExtra("data", new Json().objectToJson(BPA_GOODS.class, data));
startActivity(intent);
break;
case R.id.button_xf://下发按钮
BusinessServer.get().AddCommodity(((BPA_GOODS)data).id);
BusinessServer.Get().AddCommodity(((BPA_GOODS) data).id);
T.show(this, "下发成功!");
break;
case R.id.button_qy://启用按钮
BPA_GOODS good3=(BPA_GOODS)data;
good3.status=1;
BPA_GOODS good3 = (BPA_GOODS) data;
good3.status = 1;
QueryDB.UpdateGoods(good3);
Initdata();
T.show(this, good3.name+"-启用成功!");
T.show(this, good3.name + "-启用成功!");
break;
case R.id.button_jy://下发按钮
BPA_GOODS good4=(BPA_GOODS)data;
good4.status=0;
BPA_GOODS good4 = (BPA_GOODS) data;
good4.status = 0;
QueryDB.UpdateGoods(good4);
Initdata();
T.show(this, good4.name+"-禁用成功!");
T.show(this, good4.name + "-禁用成功!");
break;
}
}
//endregion

//region 接收事件
public void RegisterMessage()
{
public void RegisterMessage() {
//配方界面关闭事件
MessageManager.getInstance().registerMessageReceiver(this, MessageName.PF_From_Close.name(), new MessageLooper.OnMessageListener() {
@Override
public void onMessage(Object msg) {
if (msg != null) {
if(msg.equals("Close"))
{
if (msg.equals("Close")) {
Initdata();
}
}else
{
} else {
runOnUiThread(new Runnable() {
@Override
public void run() {
T.show(yfpf_activity.this,"服务器异常,请稍后重试!");
T.show(yfpf_activity.this, "服务器异常,请稍后重试!");
}
});
}
@@ -225,16 +218,14 @@ public class yfpf_activity extends AppCompatActivity implements View.OnClickList
@Override
public void onMessage(Object msg) {
if (msg != null) {
if(msg.equals("Close"))
{
if (msg.equals("Close")) {
Initdata();
}
}else
{
} else {
runOnUiThread(new Runnable() {
@Override
public void run() {
T.show(yfpf_activity.this,"服务器异常,请稍后重试!");
T.show(yfpf_activity.this, "服务器异常,请稍后重试!");
}
});
}


Načítá se…
Zrušit
Uložit