@@ -7,8 +7,8 @@ | |||
<option name="testRunner" value="GRADLE" /> | |||
<option name="distributionType" value="DEFAULT_WRAPPED" /> | |||
<option name="externalProjectPath" value="$PROJECT_DIR$" /> | |||
<option name="gradleHome" value="D:/gradle-8.0.2-all/gradle-8.0.2" /> | |||
<option name="gradleJvm" value="Android Studio default JDK" /> | |||
<option name="gradleHome" value="$PROJECT_DIR$/../../../gradle-8.0.2-all/gradle-8.0.2" /> | |||
<option name="gradleJvm" value="JDK" /> | |||
<option name="modules"> | |||
<set> | |||
<option value="$PROJECT_DIR$" /> | |||
@@ -24,6 +24,7 @@ import androidx.recyclerview.widget.RecyclerView; | |||
import com.example.bpa.Model.OrderA; | |||
import com.example.bpa.Model.ReceiveOrder; | |||
import com.example.bpa.Model.ResVersion; | |||
import com.example.bpa.Model.SuOrderA; | |||
import com.example.bpa.app.Main; | |||
import com.example.bpa.config.ConfigName; | |||
@@ -42,6 +43,7 @@ import com.example.bpa.helper.UpdateManager; | |||
import com.example.bpa.helper.WrapContentLinearLayoutManager; | |||
import com.example.bpa.message.MessageLooper; | |||
import com.example.bpa.message.MessageManager; | |||
import com.example.bpa.service.BusinessServer; | |||
import com.example.bpa.service.DeviceData; | |||
import com.example.bpa.service.OrderServer; | |||
import com.example.bpa.service.ScanCodeServer; | |||
@@ -56,6 +58,7 @@ import com.example.bpa.view.fragment.SystemSetFragment; | |||
import com.example.bpa.view.mode.MakeStatus; | |||
import com.example.bpa.view.mode.ResGoodsMake; | |||
import com.example.bpa.view.mode.ResGoodsRecipe; | |||
import com.example.bpa.view.mode.mainGoods; | |||
import java.net.IDN; | |||
import java.util.ArrayList; | |||
@@ -174,7 +177,9 @@ public class MainActivity extends FragmentActivity implements View.OnClickListen | |||
* 检测版本更新 | |||
*/ | |||
public void UpdateVersion() { | |||
mUpdateManager.checkVersion(); | |||
//检测版本更新 | |||
//Main.getInstance().UpdateVersion(); | |||
mUpdateManager.checkVersion(null); | |||
} | |||
//endregion | |||
@@ -198,7 +203,29 @@ public class MainActivity extends FragmentActivity implements View.OnClickListen | |||
ShowFragment(systemSetFragment, "系统设置"); | |||
break; | |||
case R.id.SystemHelp://系统帮助按钮 | |||
//Main.getInstance().GetOrder("455953173786529792"); | |||
// BPA_ORDER order=new BPA_ORDER(); | |||
// order.thirdPartyID="手动下单"; | |||
// order.status=0; | |||
// order.deviceID = ConfigName.getInstance().DeviceId; | |||
// order.userID = ConfigName.getInstance().user.userID; | |||
// QueryDB.AddOrder(order); | |||
// for (mainGoods mode: DataBus.getInstance().mainGoods) | |||
// { | |||
// BPA_SUBORDER suborder=new BPA_SUBORDER(); | |||
// suborder.deviceID = ConfigName.getInstance().DeviceId; | |||
// suborder.userID = ConfigName.getInstance().user.userID; | |||
// suborder.orderID = order.id; | |||
// suborder.goodsID = mode.id; | |||
// suborder.number = 1; | |||
// suborder.status=0; | |||
// suborder.goodImg=mode.url; | |||
// QueryDB.AddSubOrder(suborder); | |||
// } | |||
// MessageManager.getInstance().sendMessage(MessageName.ShowOrderMakeForm.name(),order.id); | |||
//Main.getInstance().GetOrder("456715513230397440"); | |||
if(OrderID.isEmpty()) | |||
{ | |||
T.show(MainActivity.this, "无制作中饮品!"); | |||
@@ -206,6 +233,8 @@ public class MainActivity extends FragmentActivity implements View.OnClickListen | |||
{ | |||
ShowDialog(OrderID); | |||
} | |||
//Main.getInstance().GetOrder(OrderID); | |||
//ShowFragment(heplerFragment, "系统帮助"); | |||
break; | |||
@@ -299,13 +328,11 @@ public class MainActivity extends FragmentActivity implements View.OnClickListen | |||
suborder.id=item.id; | |||
suborder.deviceID = ConfigName.getInstance().DeviceId; | |||
suborder.userID = ConfigName.getInstance().user.userID; | |||
suborder.orderID = item.orderInfo_Id; | |||
suborder.goodsID = item.goods_Id;//QueryDB.GetGoodsALL().get(0).id;//"2f064965-8d63-4b00-9d14-c8d118791898";//item.goods_Id; | |||
suborder.orderID = order.id; | |||
suborder.goodsID = item.goods_Id; | |||
suborder.number = 1; | |||
suborder.status = 0; | |||
suborder.goodImg = item.goodImg; | |||
suborder.originalMoney = item.originalMoney; | |||
suborder.realMoney = item.realMoney; | |||
QueryDB.AddSubOrder(suborder); | |||
} | |||
} | |||
@@ -368,36 +395,46 @@ public class MainActivity extends FragmentActivity implements View.OnClickListen | |||
return; | |||
} | |||
if (alg == null) { | |||
alg = new AlertDialog.Builder(MainActivity.this).create(); | |||
} | |||
if (!alg.isShowing()) | |||
alg.show(); | |||
Window win = alg.getWindow(); | |||
win.setContentView(R.layout.order_dialog); | |||
WindowManager m = getWindowManager(); | |||
Display d = m.getDefaultDisplay(); //为获取屏幕宽、高 | |||
android.view.WindowManager.LayoutParams p = win.getAttributes(); //获取对话框当前的参数值 | |||
p.height = (int) (d.getHeight() * 1); //高度设置为屏幕的0.3 | |||
p.width = (int) (d.getWidth() * 1); //宽度设置为屏幕的0.5 | |||
win.setAttributes(p); //设置生效 | |||
ImageView gongneng_fanhui = win.findViewById(R.id.gongneng_fanhui); | |||
TextView gongneng_title = win.findViewById(R.id.gongneng_title); | |||
RecyclerView Order = win.findViewById(R.id.Order); | |||
gongneng_title.setText("制作订单详情"); | |||
Order.setLayoutManager(new WrapContentLinearLayoutManager(win.getContext(), LinearLayoutManager.HORIZONTAL, false)); | |||
DataBus.getInstance().orderadapter = new order_adapter(win.getContext()); | |||
Order.setAdapter(DataBus.getInstance().orderadapter); | |||
gongneng_fanhui.setOnClickListener(new View.OnClickListener() { | |||
runOnUiThread(new Runnable() { | |||
@Override | |||
public void onClick(View view) { | |||
alg.dismiss(); | |||
public void run() { | |||
if (alg == null) { | |||
alg = new AlertDialog.Builder(MainActivity.this).create(); | |||
} | |||
if (!MainActivity.this.isFinishing()) | |||
{ | |||
if (!alg.isShowing()) | |||
alg.show(); | |||
Window win = alg.getWindow(); | |||
win.setContentView(R.layout.order_dialog); | |||
WindowManager m = getWindowManager(); | |||
Display d = m.getDefaultDisplay(); //为获取屏幕宽、高 | |||
android.view.WindowManager.LayoutParams p = win.getAttributes(); //获取对话框当前的参数值 | |||
p.height = (int) (d.getHeight() * 1); //高度设置为屏幕的0.3 | |||
p.width = (int) (d.getWidth() * 1); //宽度设置为屏幕的0.5 | |||
win.setAttributes(p); //设置生效 | |||
ImageView gongneng_fanhui = win.findViewById(R.id.gongneng_fanhui); | |||
TextView gongneng_title = win.findViewById(R.id.gongneng_title); | |||
RecyclerView Order = win.findViewById(R.id.Order); | |||
gongneng_title.setText("制作订单详情"); | |||
Order.setLayoutManager(new WrapContentLinearLayoutManager(win.getContext(), LinearLayoutManager.HORIZONTAL, false)); | |||
DataBus.getInstance().orderadapter = new order_adapter(win.getContext()); | |||
Order.setAdapter(DataBus.getInstance().orderadapter); | |||
gongneng_fanhui.setOnClickListener(new View.OnClickListener() { | |||
@Override | |||
public void onClick(View view) { | |||
alg.dismiss(); | |||
} | |||
}); | |||
} | |||
} | |||
}); | |||
//初始化数据 | |||
} catch (Exception ex) { | |||
} | |||
@@ -426,24 +463,14 @@ public class MainActivity extends FragmentActivity implements View.OnClickListen | |||
if ((msg != null) && (((String) msg).length() > 2)) { | |||
ReceiveOrder model = new Json<ReceiveOrder>().jsonToobject(ReceiveOrder.class, ((String) msg)); | |||
if (model.data != null) { | |||
runOnUiThread(new Runnable() { | |||
@Override | |||
public void run() { | |||
AddOrder(model.data); | |||
T.show(MainActivity.this, "查询成功!"); | |||
} | |||
}); | |||
AddOrder(model.data); | |||
T.show(MainActivity.this, "查询成功!"); | |||
}else | |||
{ | |||
T.show(MainActivity.this, "没有查询到该订单!"); | |||
} | |||
} else { | |||
runOnUiThread(new Runnable() { | |||
@Override | |||
public void run() { | |||
T.show(MainActivity.this, "服务器异常,请稍后重试!"); | |||
} | |||
}); | |||
T.show(MainActivity.this, "服务器异常,请稍后重试!"); | |||
} | |||
} | |||
} | |||
@@ -453,12 +480,7 @@ public class MainActivity extends FragmentActivity implements View.OnClickListen | |||
@Override | |||
public void onMessage(Object msg) { | |||
if (msg != null) { | |||
runOnUiThread(new Runnable() { | |||
@Override | |||
public void run() { | |||
ShowDialog((String) msg); | |||
} | |||
}); | |||
ShowDialog((String) msg); | |||
} | |||
} | |||
}); | |||
@@ -473,6 +495,26 @@ public class MainActivity extends FragmentActivity implements View.OnClickListen | |||
}); | |||
} | |||
}); | |||
//版本更新 | |||
MessageManager.getInstance().registerMessageReceiver(this, MessageName.UpdateVersion.name(), new MessageLooper.OnMessageListener() { | |||
@Override | |||
public void onMessage(Object msg) { | |||
if (msg != null) { | |||
if ((msg != null) && (((String) msg).length() > 2)) { | |||
ResVersion model = new Json<ResVersion>().jsonToobject(ResVersion.class, ((String) msg)); | |||
runOnUiThread(new Runnable() { | |||
@Override | |||
public void run() { | |||
mUpdateManager.checkVersion(model.data); | |||
} | |||
}); | |||
} else { | |||
T.show(MainActivity.this, "服务器异常,请稍后重试!"); | |||
} | |||
} | |||
} | |||
}); | |||
} | |||
//endregion | |||
} |
@@ -0,0 +1,14 @@ | |||
package com.example.bpa.Model; | |||
import java.util.List; | |||
/** | |||
* 接收版本信息 | |||
*/ | |||
public class ResVersion { | |||
public String trackId; | |||
public String code; | |||
public String message; | |||
public String isSuccess; | |||
public VersionResponse data; | |||
} |
@@ -0,0 +1,8 @@ | |||
package com.example.bpa.Model; | |||
public class VersionMode { | |||
public String productCode; | |||
public String moduleCode; | |||
public String serverCode; | |||
public String branchCode; | |||
} |
@@ -0,0 +1,40 @@ | |||
package com.example.bpa.Model; | |||
/** | |||
* 版本响应 | |||
*/ | |||
public class VersionResponse { | |||
/** | |||
* 版本编号 | |||
*/ | |||
public String id; | |||
/** | |||
* 版本号 | |||
*/ | |||
public String versionNo; | |||
/** | |||
* 分支编号 | |||
*/ | |||
public String branchId; | |||
/** | |||
* 分支名称 | |||
*/ | |||
public String branchName; | |||
/** | |||
* 服务状态 | |||
*/ | |||
public int serverStatus; | |||
/** | |||
* 版本描述 | |||
*/ | |||
public String description; | |||
/** | |||
* 下载地址 | |||
*/ | |||
public String downloadLink; | |||
/** | |||
* 发布日期 | |||
*/ | |||
public String releaseDate; | |||
} |
@@ -15,6 +15,7 @@ import com.example.bpa.db.mode.BPA_SILOSANDMATERIAL; | |||
import com.example.bpa.db.mode.BPA_SUBORDER; | |||
import com.example.bpa.db.mode.BPA_USER; | |||
import com.example.bpa.helper.AES; | |||
import com.example.bpa.helper.CrashHandler; | |||
import com.example.bpa.helper.MessageLog; | |||
import com.example.bpa.helper.SdCart; | |||
import com.example.bpa.helper.ToastUtil; | |||
@@ -31,6 +32,8 @@ public class ICSApp extends Application { | |||
@Override | |||
public void onCreate() { | |||
super.onCreate(); | |||
//0.全局异常捕获 | |||
CrashHandler.getInstance().init(this); | |||
//1.设置程序active,初始化Main函数进程,初始化消息日志 | |||
InitMsgLog();ConfigName.getInstance().dishesCon = this;ToastUtil.init(this); | |||
//2.初始化SD卡,数据库DB | |||
@@ -5,6 +5,7 @@ import android.util.Log; | |||
import com.example.bpa.Model.OrderStatusChange; | |||
import com.example.bpa.Model.ReceiveOrder; | |||
import com.example.bpa.Model.VersionMode; | |||
import com.example.bpa.config.ConfigName; | |||
import com.example.bpa.config.DataBus; | |||
import com.example.bpa.config.MessageName; | |||
@@ -217,7 +218,7 @@ public class Main { | |||
ConfigName.getInstance().user.account = ConfigUtil.read(ConfigName.getInstance().dishesCon, "username", ConfigName.getInstance().user.account); | |||
ConfigName.getInstance().user.pass = ConfigUtil.read(ConfigName.getInstance().dishesCon, "password", ConfigName.getInstance().user.pass); | |||
ConfigName.getInstance().IsUserDownOrder = ConfigUtil.read(ConfigName.getInstance().dishesCon, "IsUserDownOrder", ConfigName.getInstance().IsUserDownOrder); | |||
ConfigName.getInstance().Version = ConfigUtil.read(ConfigName.getInstance().dishesCon, "Version", ConfigName.getInstance().Version); | |||
} | |||
/** | |||
@@ -232,7 +233,8 @@ public class Main { | |||
ConfigUtil.write(ConfigName.getInstance().dishesCon,"username", ConfigName.getInstance().user.account); | |||
ConfigUtil.write(ConfigName.getInstance().dishesCon,"password", ConfigName.getInstance().user.pass); | |||
ConfigUtil.write(ConfigName.getInstance().dishesCon,"IsUserDownOrder", ConfigName.getInstance().IsUserDownOrder); | |||
ConfigUtil.write(ConfigName.getInstance().dishesCon,"IsUserDownOrder", ConfigName.getInstance().IsUserDownOrder); | |||
ConfigUtil.write(ConfigName.getInstance().dishesCon,"Version", ConfigName.getInstance().Version); | |||
} | |||
/** | |||
@@ -260,5 +262,19 @@ public class Main { | |||
String msg= new Json<OrderStatusChange>().objectToJson(OrderStatusChange.class, data); | |||
HttpUtils.httpPost(MessageName.UpdateOrderStatus.name(),ConfigName.getInstance().SaasAddress+ConfigName.getInstance().OrderChange,msg); | |||
} | |||
/** | |||
* 更新版本 | |||
*/ | |||
public void UpdateVersion() | |||
{ | |||
VersionMode mode=new VersionMode(); | |||
mode.productCode="1668085292913659904"; | |||
mode.moduleCode="naichaji"; | |||
mode.serverCode="1668175205545807872"; | |||
mode.branchCode="1668801915890962433"; | |||
String msg= new Json<VersionMode>().objectToJson(VersionMode.class, mode); | |||
HttpUtils.httpPost(MessageName.UpdateVersion.name(),ConfigName.getInstance().UpdateVersion,msg); | |||
} | |||
//endregion | |||
} |
@@ -98,6 +98,13 @@ public class ConfigName { | |||
public BPA_USER user=new BPA_USER(); | |||
//endregion | |||
//region 版本信息 | |||
/** | |||
* 版本更新 | |||
*/ | |||
public String Version="1.0"; | |||
//endregion | |||
//region 是否手动下单 | |||
/** | |||
* 是否手动下单 | |||
@@ -169,5 +176,7 @@ public class ConfigName { | |||
public String GetOrder="order/order/fullorderbynumber/"; | |||
//POST | |||
public String OrderChange="order/order/robotstatuschange"; | |||
public String UpdateVersion="http://111.9.47.105:18097/api/Version/GetLatest"; | |||
//endregion | |||
} |
@@ -14,4 +14,6 @@ public enum MessageName { | |||
ShowOrderMakeForm,//显示弹窗 | |||
CloseOrderMakeForm,//关闭弹窗 | |||
UpdateVersion,//更新版本 | |||
} |
@@ -1,4 +1,5 @@ | |||
package com.example.bpa.db; | |||
import android.content.ContentValues; | |||
import android.database.Cursor; | |||
import android.database.sqlite.SQLiteDatabase; | |||
@@ -38,6 +39,8 @@ import java.util.ArrayList; | |||
import java.util.Date; | |||
import java.util.List; | |||
import java.util.Map; | |||
import java.util.concurrent.locks.Lock; | |||
import java.util.concurrent.locks.ReentrantLock; | |||
/** | |||
* 数据库数据访问类库 | |||
@@ -63,6 +66,11 @@ public class QueryDB { | |||
* 排序、优先顺序 | |||
*/ | |||
public static String Desc_Sort_Up = "Sort"; | |||
/** | |||
* 加锁 | |||
*/ | |||
public static Lock lock = new ReentrantLock(); //注意这个地方 | |||
//endregion | |||
//region BPA_MATERIAL 物料表 | |||
@@ -134,7 +142,6 @@ public class QueryDB { | |||
// } | |||
/** | |||
* 获取所有物料信息 | |||
* | |||
@@ -151,20 +158,21 @@ public class QueryDB { | |||
} | |||
return data; | |||
} | |||
/** | |||
* 根据物料id获取物料 | |||
* | |||
* @param | |||
* @return | |||
*/ | |||
public static BPA_MATERIAL GetMaterialbyid(String id){ | |||
String orderby=Desc_Time_Up;//时间 | |||
String where="isDelete=? and id=?"; | |||
String[] args=new String[] { "0" ,id}; | |||
BPA_MATERIAL data=new BPA_MATERIAL(); | |||
ArrayList<Object> obj=Get(BPA_MATERIAL.class,where,args,orderby); | |||
public static BPA_MATERIAL GetMaterialbyid(String id) { | |||
String orderby = Desc_Time_Up;//时间 | |||
String where = "isDelete=? and id=?"; | |||
String[] args = new String[]{"0", id}; | |||
BPA_MATERIAL data = new BPA_MATERIAL(); | |||
ArrayList<Object> obj = Get(BPA_MATERIAL.class, where, args, orderby); | |||
return obj.size()>0? (BPA_MATERIAL)obj.get(0):null; | |||
return obj.size() > 0 ? (BPA_MATERIAL) obj.get(0) : null; | |||
} | |||
@@ -194,7 +202,7 @@ public class QueryDB { | |||
* @return | |||
*/ | |||
public static BPA_MATERIAL GetMaterialID(String id) { | |||
try{ | |||
try { | |||
BPA_MATERIAL bpa_material = null; | |||
boolean isSucess = false; | |||
String orderby = Desc_Time_Up;//出料顺序 | |||
@@ -206,9 +214,8 @@ public class QueryDB { | |||
bpa_material = (BPA_MATERIAL) k; | |||
} | |||
return bpa_material; | |||
}catch (Exception e) | |||
{ | |||
Log.d("物料ID查询物料信息", "物料ID查询物料信息异常: "+e.getMessage()); | |||
} catch (Exception e) { | |||
Log.d("物料ID查询物料信息", "物料ID查询物料信息异常: " + e.getMessage()); | |||
return null; | |||
} | |||
@@ -376,7 +383,7 @@ public class QueryDB { | |||
* @param data | |||
*/ | |||
public static boolean UpdateSilosAndMaterial(BPA_SILOSANDMATERIAL data) { | |||
return Update(BPA_SILOSANDMATERIAL.class, data,"silosID"); | |||
return Update(BPA_SILOSANDMATERIAL.class, data, "silosID"); | |||
} | |||
/** | |||
@@ -393,6 +400,7 @@ public class QueryDB { | |||
/** | |||
* 删除料仓物料关联:根据料仓id 删除料仓与物料关联 | |||
* add fengyoufu 20230413 | |||
* | |||
* @return 是否成功 | |||
*/ | |||
public static boolean DeleteSilosAndMaterial(String id) { | |||
@@ -406,13 +414,14 @@ public class QueryDB { | |||
} | |||
return true; | |||
} | |||
/** | |||
* 获取所有料仓物料关联 | |||
* | |||
* @return | |||
*/ | |||
public static ArrayList<BPA_SILOSANDMATERIAL> GetSilosAndMaterialALL() { | |||
String orderby = Desc_Time_Up;//先按排序 创建时间倒序 | |||
String orderby = Desc_Time_Up;//先按排序 创建时间倒序 | |||
String where = "isDelete=?"; | |||
String[] args = new String[]{"0"}; | |||
ArrayList<BPA_SILOSANDMATERIAL> data = new ArrayList<>(); | |||
@@ -425,6 +434,7 @@ public class QueryDB { | |||
/** | |||
* 根据料仓id查询物料id | |||
* | |||
* @param id | |||
* @return | |||
*/ | |||
@@ -439,39 +449,41 @@ public class QueryDB { | |||
} | |||
return data; | |||
} | |||
/** | |||
* 根据物料id查询料仓ID | |||
* | |||
* @param id | |||
* @return | |||
*/ | |||
public static ArrayList<String> GetSilosLIst(String id) | |||
{ | |||
String orderby=Desc_Time_Up;//先按排序 创建时间倒序 | |||
String where="isDelete=? and materialID=?"; | |||
String[] args=new String[] { "0",id }; | |||
ArrayList<String> data=new ArrayList<>(); | |||
ArrayList<Object> obj=Get(BPA_SILOSANDMATERIAL.class,where,args,orderby); | |||
for (Object k:obj) { | |||
data.add(((BPA_SILOSANDMATERIAL)k).silosID); | |||
public static ArrayList<String> GetSilosLIst(String id) { | |||
String orderby = Desc_Time_Up;//先按排序 创建时间倒序 | |||
String where = "isDelete=? and materialID=?"; | |||
String[] args = new String[]{"0", id}; | |||
ArrayList<String> data = new ArrayList<>(); | |||
ArrayList<Object> obj = Get(BPA_SILOSANDMATERIAL.class, where, args, orderby); | |||
for (Object k : obj) { | |||
data.add(((BPA_SILOSANDMATERIAL) k).silosID); | |||
} | |||
return data; | |||
} | |||
/** | |||
* 根据物料id查询料仓 | |||
* | |||
* @param id | |||
* @return | |||
*/ | |||
public static List<BPA_SILOS> GetSolisByMaterialID(String id){ | |||
public static List<BPA_SILOS> GetSolisByMaterialID(String id) { | |||
List<String> solisids = GetSilosLIst(id); | |||
List<BPA_SILOS> data = new ArrayList<>(); | |||
if (solisids.size() == 0){ | |||
if (solisids.size() == 0) { | |||
return data; | |||
} | |||
for (String s : solisids) { | |||
BPA_SILOS silos = GetSilosID(s); | |||
if (silos!= null) { | |||
if (silos != null) { | |||
data.add(silos); | |||
} | |||
} | |||
@@ -480,23 +492,26 @@ public class QueryDB { | |||
/** | |||
* 根据料仓id查询物料 | |||
* | |||
* @param id | |||
* @return | |||
*/ | |||
public static List<BPA_MATERIAL> GetMaterialBySilosID(String id){ | |||
public static List<BPA_MATERIAL> GetMaterialBySilosID(String id) { | |||
List<BPA_MATERIAL> data = new ArrayList<>(); | |||
List<String> res = GetMaterialList(id);//根据料仓ID获取物料ID | |||
if (res.size() == 0){ | |||
if (res.size() == 0) { | |||
return data; | |||
} | |||
if (res.get(0).equals("")) { | |||
return data; | |||
} | |||
if (res.get(0).equals("")){return data;} | |||
//根据物料id查询物料 | |||
String orderby=Desc_Time_Up;//先按排序 创建时间倒序 | |||
String where="isDelete=? and id=?"; | |||
String orderby = Desc_Time_Up;//先按排序 创建时间倒序 | |||
String where = "isDelete=? and id=?"; | |||
for (String s : res) { | |||
String[] args=new String[] { "0",s }; | |||
List<Object> obj=Get(BPA_MATERIAL.class,where,args,orderby); | |||
String[] args = new String[]{"0", s}; | |||
List<Object> obj = Get(BPA_MATERIAL.class, where, args, orderby); | |||
for (Object o : obj) { | |||
data.add((BPA_MATERIAL) o); | |||
} | |||
@@ -557,6 +572,7 @@ public class QueryDB { | |||
} | |||
return data; | |||
} | |||
/** | |||
* 获取所有启用的商品 | |||
* | |||
@@ -565,7 +581,7 @@ public class QueryDB { | |||
public static ArrayList<BPA_GOODS> GetGoodsStateALL() { | |||
String orderby = Desc_Sort_Up + ',' + Desc_Time_Up;//先按排序 创建时间倒序 | |||
String where = "isDelete=? and status=?"; | |||
String[] args = new String[]{"0","1"}; | |||
String[] args = new String[]{"0", "1"}; | |||
ArrayList<BPA_GOODS> data = new ArrayList<>(); | |||
ArrayList<Object> obj = Get(BPA_GOODS.class, where, args, orderby); | |||
for (Object k : obj) { | |||
@@ -582,17 +598,15 @@ public class QueryDB { | |||
public static BPA_GOODS GetGoodsId(String id) { | |||
String orderby = Desc_Sort_Up + ',' + Desc_Time_Up;//先按排序 创建时间倒序 | |||
String where = "isDelete=? and id=?"; | |||
String[] args = new String[]{"0",id}; | |||
String[] args = new String[]{"0", id}; | |||
ArrayList<BPA_GOODS> data = new ArrayList<>(); | |||
ArrayList<Object> obj = Get(BPA_GOODS.class, where, args, orderby); | |||
for (Object k : obj) { | |||
data.add((BPA_GOODS) k); | |||
} | |||
if(data.size()>0) | |||
{ | |||
if (data.size() > 0) { | |||
return data.get(0); | |||
}else | |||
{ | |||
} else { | |||
return new BPA_GOODS(); | |||
} | |||
} | |||
@@ -750,9 +764,11 @@ public class QueryDB { | |||
ArrayList<Object> obj = Get(BPA_GOODSRECIPE.class, where, args, orderby); | |||
for (Object item : obj) { | |||
BPA_GOODSRECIPE k = (BPA_GOODSRECIPE) item; | |||
String name = ""; | |||
String name = ""; | |||
BPA_MATERIAL res = GetMaterialID(k.materialID); | |||
if (res!= null) { name = GetMaterialID(k.materialID).name;} | |||
if (res != null) { | |||
name = GetMaterialID(k.materialID).name; | |||
} | |||
// if (k.materialType ==1){ | |||
// }else if (k.materialType ==2){ | |||
// BPA_SUGAR res = GetsugarId(k.materialID); | |||
@@ -794,6 +810,7 @@ public class QueryDB { | |||
SQLiteDatabase db = helper.getWritableDatabase(); | |||
long delete = db.delete(BPA_GOODSRECIPE.class.getSimpleName(), "goodsID=?", | |||
new String[]{id}); | |||
db.close(); | |||
return delete > 0; | |||
} | |||
@@ -852,6 +869,7 @@ public class QueryDB { | |||
/** | |||
* 判断订单是否存在在 | |||
* | |||
* @param id | |||
* @return | |||
*/ | |||
@@ -940,6 +958,7 @@ public class QueryDB { | |||
/** | |||
* 根据条件查询子订单 | |||
* | |||
* @param sta | |||
* @param stp | |||
* @param lx | |||
@@ -949,77 +968,71 @@ public class QueryDB { | |||
public static ArrayList<ResSubOrder> GetSubOrders(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) | |||
{ | |||
String[] args = new String[]{"0", sta, stp}; | |||
if (lx >= 0) { | |||
where = "isDelete=? and createTime>=? and createTime<=? and status=?"; | |||
args = new String[]{"0", sta,stp,String.valueOf(lx)}; | |||
args = new String[]{"0", sta, stp, String.valueOf(lx)}; | |||
} | |||
ArrayList<BPA_GOODS> goods= GetGoodsALL(); | |||
ArrayList<BPA_GOODS> goods = GetGoodsALL(); | |||
ArrayList<ResSubOrder> data = new ArrayList<>(); | |||
ArrayList<Object> obj = Get(BPA_SUBORDER.class, where, args, orderby); | |||
for (Object k : obj) { | |||
ResSubOrder sub=new ResSubOrder(); | |||
BPA_SUBORDER o=(BPA_SUBORDER) k; | |||
sub.orderID=o.orderID; | |||
sub.goodsID=o.goodsID; | |||
sub.number=o.number; | |||
sub.status=o.status; | |||
sub.id=o.id; | |||
sub.createTime=o.createTime; | |||
sub.updateTime=o.updateTime; | |||
sub.deleteTime=o.deleteTime; | |||
sub.deviceID=o.deviceID; | |||
sub.userID=o.userID; | |||
sub.isDelete=o.isDelete; | |||
sub.exp=o.exp; | |||
BPA_GOODS good=null; | |||
for (BPA_GOODS i:goods) | |||
{ | |||
if(i.id.equals(o.goodsID)){good =i; break;} | |||
ResSubOrder sub = new ResSubOrder(); | |||
BPA_SUBORDER o = (BPA_SUBORDER) k; | |||
sub.orderID = o.orderID; | |||
sub.goodsID = o.goodsID; | |||
sub.number = o.number; | |||
sub.status = o.status; | |||
sub.id = o.id; | |||
sub.createTime = o.createTime; | |||
sub.updateTime = o.updateTime; | |||
sub.deleteTime = o.deleteTime; | |||
sub.deviceID = o.deviceID; | |||
sub.userID = o.userID; | |||
sub.isDelete = o.isDelete; | |||
sub.exp = o.exp; | |||
BPA_GOODS good = null; | |||
for (BPA_GOODS i : goods) { | |||
if (i.id.equals(o.goodsID)) { | |||
good = i; | |||
break; | |||
} | |||
} | |||
if(good!=null) | |||
{ | |||
sub.goodsName=good.name; | |||
switch (o.status) | |||
{ | |||
if (good != null) { | |||
sub.goodsName = good.name; | |||
switch (o.status) { | |||
case 0: | |||
sub.statusText="未开始"; | |||
sub.statusText = "未开始"; | |||
break; | |||
case 1: | |||
sub.statusText="制作中"; | |||
sub.statusText = "制作中"; | |||
break; | |||
case 2: | |||
sub.statusText="已制作"; | |||
sub.statusText = "已制作"; | |||
break; | |||
case 3: | |||
sub.statusText="已超时"; | |||
sub.statusText = "已超时"; | |||
break; | |||
} | |||
} | |||
boolean IsText=false; | |||
if(!text.isEmpty()) | |||
{ | |||
if(sub.goodsName.contains(text)) | |||
{ | |||
IsText=true; | |||
}else | |||
{ | |||
IsText=false; | |||
boolean IsText = false; | |||
if (!text.isEmpty()) { | |||
if (sub.goodsName.contains(text)) { | |||
IsText = true; | |||
} else { | |||
IsText = false; | |||
} | |||
}else | |||
{ | |||
IsText=true; | |||
} else { | |||
IsText = true; | |||
} | |||
if(IsText) | |||
{ | |||
if (IsText) { | |||
data.add(sub); | |||
} | |||
} | |||
@@ -1077,53 +1090,50 @@ public class QueryDB { | |||
} | |||
return data; | |||
} | |||
/** | |||
* | |||
* @return | |||
*/ | |||
public static ArrayList<ResAlertLog> GetAlertlogs(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) | |||
{ | |||
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()) | |||
{ | |||
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)}; | |||
args = new String[]{"0", sta, stp, "%" + text + "%", String.valueOf(lx)}; | |||
} | |||
}else | |||
{ | |||
if(!text.isEmpty()) | |||
{ | |||
} else { | |||
if (!text.isEmpty()) { | |||
where = "isDelete=? and createTime>=? and createTime<=? and text like ?"; | |||
args = new String[]{"0", sta,stp,"%"+text+"%"}; | |||
args = new String[]{"0", sta, stp, "%" + text + "%"}; | |||
} | |||
} | |||
ArrayList<BPA_USER> Users=GetUserALL(); | |||
ArrayList<BPA_USER> Users = GetUserALL(); | |||
ArrayList<ResAlertLog> data = new ArrayList<>(); | |||
ArrayList<Object> obj = Get(BPA_ALERTLOG.class, where, args, orderby); | |||
for (Object k : obj) { | |||
BPA_ALERTLOG o=(BPA_ALERTLOG) k; | |||
ResAlertLog log=new ResAlertLog(); | |||
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_ALERTLOG o = (BPA_ALERTLOG) k; | |||
ResAlertLog log = new ResAlertLog(); | |||
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; | |||
data.add(log); | |||
} | |||
return data; | |||
} | |||
/** | |||
* 获取所有今日预警日志 | |||
* | |||
@@ -1195,55 +1205,51 @@ public class QueryDB { | |||
} | |||
/** | |||
* | |||
* @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) | |||
{ | |||
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()) | |||
{ | |||
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)}; | |||
args = new String[]{"0", sta, stp, "%" + text + "%", String.valueOf(lx)}; | |||
} | |||
}else | |||
{ | |||
if(!text.isEmpty()) | |||
{ | |||
} else { | |||
if (!text.isEmpty()) { | |||
where = "isDelete=? and createTime>=? and createTime<=? and text like ?"; | |||
args = new String[]{"0", sta,stp,"%"+text+"%"}; | |||
args = new String[]{"0", sta, stp, "%" + text + "%"}; | |||
} | |||
} | |||
ArrayList<BPA_USER> Users=GetUserALL(); | |||
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;} | |||
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; | |||
if (user != null) { | |||
log.Name = user.name; | |||
} | |||
data.add(log); | |||
} | |||
@@ -1638,6 +1644,7 @@ public class QueryDB { | |||
//endregion | |||
//region BPA_SUGAR 果糖辅料表 | |||
/** | |||
* 新增果糖 | |||
* | |||
@@ -1688,11 +1695,11 @@ public class QueryDB { | |||
public static BPA_SUGAR GetsugarId(String id) { | |||
String orderby = Desc_Time_Up;//先按排序 创建时间倒序 | |||
String where = "isDelete=? and id=?"; | |||
String[] args = new String[]{"0",id}; | |||
String[] args = new String[]{"0", id}; | |||
BPA_SUGAR data = new BPA_SUGAR(); | |||
ArrayList<Object> obj = Get(BPA_SUGAR.class, where, args, orderby); | |||
for (Object k : obj) { | |||
data =(BPA_SUGAR) k; | |||
data = (BPA_SUGAR) k; | |||
} | |||
return data; | |||
} | |||
@@ -1807,7 +1814,7 @@ public class QueryDB { | |||
public static ArrayList<BPA_CRAFTPROCESS> GetCraftProcessId(String id) { | |||
String orderby = Desc_Time_Up;//先按排序 创建时间倒序 | |||
String where = "isDelete=? and gyid=?"; | |||
String[] args = new String[]{"0",id}; | |||
String[] args = new String[]{"0", id}; | |||
ArrayList<BPA_CRAFTPROCESS> data = new ArrayList<>(); | |||
ArrayList<Object> obj = Get(BPA_CRAFTPROCESS.class, where, args, orderby); | |||
for (Object k : obj) { | |||
@@ -1827,6 +1834,9 @@ public class QueryDB { | |||
* @return | |||
*/ | |||
private static boolean Add(Class c, Object data) { | |||
lock.lock(); | |||
boolean isSucess = false; | |||
SQLiteDatabase db = helper.getWritableDatabase(); | |||
try { | |||
ContentValues cv = new ContentValues(); | |||
Map<String, Object> map = Tools.getObjValue(data); | |||
@@ -1852,15 +1862,16 @@ public class QueryDB { | |||
// cv.put(key, (Date) value); | |||
// } | |||
} | |||
SQLiteDatabase db = helper.getWritableDatabase(); | |||
long insert = db.insert(c.getSimpleName(), null, cv); | |||
db.close(); | |||
return insert > 0; | |||
isSucess= insert > 0; | |||
} catch (Exception e) { | |||
return false; | |||
db.close(); | |||
isSucess= false; | |||
}finally { | |||
lock.unlock(); | |||
} | |||
return isSucess; | |||
} | |||
/** | |||
@@ -1871,91 +1882,99 @@ public class QueryDB { | |||
* @return | |||
*/ | |||
private static boolean Update(Class c, Object data) { | |||
lock.lock(); | |||
boolean isSucess = false; | |||
SQLiteDatabase db = helper.getWritableDatabase(); | |||
try { | |||
ContentValues cv = new ContentValues(); | |||
Map<String, Object> map = Tools.getObjValue(data); | |||
String id = map.get("id").toString(); | |||
if (id.isEmpty()) | |||
return false; | |||
for (String key : map.keySet()) { | |||
if (!key.equals("id")) { | |||
Object value = map.get(key); | |||
if (value instanceof String) { | |||
cv.put(key, (String) value); | |||
} else if (value instanceof Integer) { | |||
cv.put(key, ((Integer) value).intValue()); | |||
} else if (value instanceof Double) { | |||
cv.put(key, ((Double) value).doubleValue()); | |||
} else if (value instanceof Float) { | |||
cv.put(key, ((Float) value).floatValue()); | |||
} else if (value instanceof Long) { | |||
cv.put(key, ((Long) value).longValue()); | |||
} else if (value instanceof Boolean) { | |||
cv.put(key, ((Boolean) value).booleanValue()); | |||
ContentValues cv = new ContentValues(); | |||
Map<String, Object> map = Tools.getObjValue(data); | |||
String id = map.get("id").toString(); | |||
if (id.isEmpty()) | |||
return false; | |||
for (String key : map.keySet()) { | |||
if (!key.equals("id")) { | |||
Object value = map.get(key); | |||
if (value instanceof String) { | |||
cv.put(key, (String) value); | |||
} else if (value instanceof Integer) { | |||
cv.put(key, ((Integer) value).intValue()); | |||
} else if (value instanceof Double) { | |||
cv.put(key, ((Double) value).doubleValue()); | |||
} else if (value instanceof Float) { | |||
cv.put(key, ((Float) value).floatValue()); | |||
} else if (value instanceof Long) { | |||
cv.put(key, ((Long) value).longValue()); | |||
} else if (value instanceof Boolean) { | |||
cv.put(key, ((Boolean) value).booleanValue()); | |||
} | |||
} | |||
} | |||
// else if (value instanceof Date) | |||
// { | |||
// cv.put(key, (Date) value); | |||
// } | |||
} | |||
SQLiteDatabase db = helper.getWritableDatabase(); | |||
db.update(c.getSimpleName(), cv, "id = ?", new String[]{id}); | |||
db.close(); | |||
return true; | |||
} | |||
db.update(c.getSimpleName(), cv, "id = ?", new String[]{id}); | |||
db.close(); | |||
isSucess= true; | |||
} catch (Exception e) { | |||
return false; | |||
db.close(); | |||
isSucess= false; | |||
}finally { | |||
lock.unlock(); | |||
} | |||
return isSucess; | |||
} | |||
/** | |||
* 修改 | |||
* | |||
* @param c | |||
* @param data | |||
* @param where | |||
* @return | |||
*/ | |||
private static boolean Update(Class c,Object data,String where) | |||
{ | |||
ContentValues cv = new ContentValues(); | |||
Map<String, Object> map= Tools.getObjValue(data); | |||
String id=map.get(where).toString(); | |||
if (id.isEmpty()) | |||
return false; | |||
for (String key : map.keySet()) { | |||
if(!key.equals(where)) | |||
{ | |||
Object value = map.get(key); | |||
if(value instanceof String) | |||
{ | |||
cv.put(key, (String) value); | |||
}else if (value instanceof Integer) | |||
{ | |||
cv.put(key, ((Integer) value).intValue()); | |||
}else if (value instanceof Double) | |||
{ | |||
cv.put(key, ((Double) value).doubleValue()); | |||
}else if (value instanceof Float) | |||
{ | |||
cv.put(key, ((Float) value).floatValue()); | |||
}else if (value instanceof Long) | |||
{ | |||
cv.put(key, ((Long) value).longValue()); | |||
}else if (value instanceof Boolean) | |||
{ | |||
cv.put(key, ((Boolean) value).booleanValue()); | |||
private static boolean Update(Class c, Object data, String where) { | |||
lock.lock(); | |||
SQLiteDatabase db = helper.getWritableDatabase(); | |||
try { | |||
ContentValues cv = new ContentValues(); | |||
Map<String, Object> map = Tools.getObjValue(data); | |||
String id = map.get(where).toString(); | |||
if (id.isEmpty()) | |||
return false; | |||
for (String key : map.keySet()) { | |||
if (!key.equals(where)) { | |||
Object value = map.get(key); | |||
if (value instanceof String) { | |||
cv.put(key, (String) value); | |||
} else if (value instanceof Integer) { | |||
cv.put(key, ((Integer) value).intValue()); | |||
} else if (value instanceof Double) { | |||
cv.put(key, ((Double) value).doubleValue()); | |||
} else if (value instanceof Float) { | |||
cv.put(key, ((Float) value).floatValue()); | |||
} else if (value instanceof Long) { | |||
cv.put(key, ((Long) value).longValue()); | |||
} else if (value instanceof Boolean) { | |||
cv.put(key, ((Boolean) value).booleanValue()); | |||
} | |||
} | |||
} | |||
// else if (value instanceof Date) | |||
// { | |||
// cv.put(key, (Date) value); | |||
// } | |||
} | |||
int i = db.update(c.getSimpleName(), cv, where + " = ?", new String[]{id}); | |||
db.close(); | |||
} catch (Exception e) { | |||
Log.d("修改异常", "修改异常: " + e.getMessage()); | |||
db.close(); | |||
} finally { | |||
lock.unlock(); | |||
} | |||
SQLiteDatabase db = helper.getWritableDatabase(); | |||
int i = db.update(c.getSimpleName(),cv,where+" = ?", new String[] { id }); | |||
db.close(); | |||
return true; | |||
} | |||
/** | |||
* 删除 | |||
* | |||
@@ -1964,13 +1983,23 @@ public class QueryDB { | |||
* @return | |||
*/ | |||
private static boolean Delete(Class c, String id) { | |||
if (id.isEmpty()) | |||
return false; | |||
lock.lock(); | |||
SQLiteDatabase db = helper.getWritableDatabase(); | |||
long delete = db.delete(c.getSimpleName(), "id = ?", | |||
new String[]{id}); | |||
db.close(); | |||
return delete > 0; | |||
boolean isSucess = false; | |||
try { | |||
if (id.isEmpty()) | |||
return false; | |||
long delete = db.delete(c.getSimpleName(), "id = ?", | |||
new String[]{id}); | |||
db.close(); | |||
isSucess = delete > 0; | |||
} catch (Exception e) { | |||
Log.d("删除异常", "删除异常: " + e.getMessage()); | |||
db.close(); | |||
} finally { | |||
lock.unlock(); | |||
} | |||
return isSucess; | |||
} | |||
/** | |||
@@ -1983,6 +2012,7 @@ public class QueryDB { | |||
* @return | |||
*/ | |||
private static ArrayList<Object> Get(Class c, String whereClause, String[] Args, String orderby) { | |||
lock.lock(); | |||
ArrayList<Object> rlts = new ArrayList<Object>(); | |||
SQLiteDatabase db = helper.getReadableDatabase(); | |||
try { | |||
@@ -2109,20 +2139,20 @@ public class QueryDB { | |||
case "BPA_SUGAR": | |||
data = new BPA_SUGAR(); | |||
//私有 | |||
((BPA_SUGAR)data).sugarName = cursor.getString((int) cursor.getColumnIndex("sugarName")); | |||
((BPA_SUGAR)data).plcvar = cursor.getString((int) cursor.getColumnIndex("plcvar")); | |||
((BPA_SUGAR) data).sugarName = cursor.getString((int) cursor.getColumnIndex("sugarName")); | |||
((BPA_SUGAR) data).plcvar = cursor.getString((int) cursor.getColumnIndex("plcvar")); | |||
case "BPA_CRAFT": | |||
data = new BPA_CRAFT(); | |||
//私有 | |||
((BPA_CRAFT)data).status = cursor.getInt((int) cursor.getColumnIndex("status")); | |||
((BPA_CRAFT)data).name = cursor.getString((int) cursor.getColumnIndex("name")); | |||
((BPA_CRAFT) data).status = cursor.getInt((int) cursor.getColumnIndex("status")); | |||
((BPA_CRAFT) data).name = cursor.getString((int) cursor.getColumnIndex("name")); | |||
case "BPA_CRAFTPROCESS": | |||
data = new BPA_CRAFTPROCESS(); | |||
//私有 | |||
((BPA_CRAFTPROCESS)data).gyid = cursor.getString((int) cursor.getColumnIndex("gyid")); | |||
((BPA_CRAFTPROCESS)data).pfid = cursor.getString((int) cursor.getColumnIndex("pfid")); | |||
((BPA_CRAFTPROCESS)data).sort = cursor.getInt((int) cursor.getColumnIndex("sort")); | |||
((BPA_CRAFTPROCESS)data).value = cursor.getInt((int) cursor.getColumnIndex("value")); | |||
((BPA_CRAFTPROCESS) data).gyid = cursor.getString((int) cursor.getColumnIndex("gyid")); | |||
((BPA_CRAFTPROCESS) data).pfid = cursor.getString((int) cursor.getColumnIndex("pfid")); | |||
((BPA_CRAFTPROCESS) data).sort = cursor.getInt((int) cursor.getColumnIndex("sort")); | |||
((BPA_CRAFTPROCESS) data).value = cursor.getInt((int) cursor.getColumnIndex("value")); | |||
} | |||
((ModeBase) data).id = cursor.getString((int) cursor.getColumnIndex("id")); | |||
@@ -2137,10 +2167,11 @@ public class QueryDB { | |||
} | |||
cursor.close(); | |||
db.close(); | |||
}catch (Exception e) | |||
{ | |||
Log.d("查询异常", "查询异常: "+e.getMessage()); | |||
} catch (Exception e) { | |||
Log.d("查询异常", "查询异常: " + e.getMessage()); | |||
db.close(); | |||
} finally { | |||
lock.unlock(); | |||
} | |||
return rlts; | |||
} | |||
@@ -0,0 +1,235 @@ | |||
package com.example.bpa.helper; | |||
import android.annotation.SuppressLint; | |||
import android.content.Context; | |||
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; | |||
import java.util.HashMap; | |||
import java.util.Map; | |||
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; | |||
@SuppressLint("SimpleDateFormat") | |||
public class CrashHandler implements Thread.UncaughtExceptionHandler { | |||
public static String TAG = "MyCrash"; | |||
// ϵͳĬ�ϵ�UncaughtException������ | |||
private Thread.UncaughtExceptionHandler mDefaultHandler; | |||
private static CrashHandler instance = new CrashHandler(); | |||
private Context mContext; | |||
// �����洢�豸��Ϣ���쳣��Ϣ | |||
private Map<String, String> infos = new HashMap<String, String>(); | |||
// ���ڸ�ʽ������,��Ϊ��־�ļ�����һ���� | |||
private DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd"); | |||
/** ��ֻ֤��һ��CrashHandlerʵ�� */ | |||
private CrashHandler() { | |||
} | |||
/** ��ȡCrashHandlerʵ�� ,����ģʽ */ | |||
public static CrashHandler getInstance() { | |||
return instance; | |||
} | |||
/** | |||
* ��ʼ�� | |||
* | |||
* @param context | |||
*/ | |||
public void init(Context context) { | |||
mContext = context; | |||
mDefaultHandler = Thread.getDefaultUncaughtExceptionHandler(); | |||
Thread.setDefaultUncaughtExceptionHandler(this); | |||
autoClear(120); | |||
} | |||
/** | |||
* ��UncaughtException����ʱ��ת��ú��������� | |||
*/ | |||
@Override | |||
public void uncaughtException(Thread thread, Throwable ex) { | |||
if (!handleException(ex) && mDefaultHandler != null) { | |||
mDefaultHandler.uncaughtException(thread, ex); | |||
} else { | |||
SystemClock.sleep(3000); | |||
android.os.Process.killProcess(android.os.Process.myPid()); | |||
System.exit(1); | |||
} | |||
} | |||
/** | |||
* �Զ��������,�ռ�������Ϣ ���ʹ���Ȳ������ڴ����. | |||
* | |||
* @param ex | |||
* @return true:��������˸��쳣��Ϣ; ����false. | |||
*/ | |||
private boolean handleException(Throwable ex) { | |||
if (ex == null) | |||
return false; | |||
try { | |||
new Thread() { | |||
@Override | |||
public void run() { | |||
Looper.prepare(); | |||
Toast.makeText(mContext, "大爷我崩溃了.自动修复中!!!", | |||
Toast.LENGTH_LONG).show(); | |||
Looper.loop(); | |||
} | |||
}.start(); | |||
collectDeviceInfo(mContext); | |||
saveCrashInfoFile(ex); | |||
Intent intent = mContext.getPackageManager().getLaunchIntentForPackage(mContext.getPackageName()); | |||
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); | |||
mContext.startActivity(intent); | |||
SystemClock.sleep(3000); | |||
} catch (Exception e) { | |||
e.printStackTrace(); | |||
} | |||
return true; | |||
} | |||
/** | |||
* �ռ��豸������Ϣ | |||
* | |||
* @param ctx | |||
*/ | |||
public void collectDeviceInfo(Context ctx) { | |||
try { | |||
PackageManager pm = ctx.getPackageManager(); | |||
PackageInfo pi = pm.getPackageInfo(ctx.getPackageName(), | |||
PackageManager.GET_ACTIVITIES); | |||
if (pi != null) { | |||
String versionName = pi.versionName + ""; | |||
String versionCode = pi.versionCode + ""; | |||
infos.put("versionName", versionName); | |||
infos.put("versionCode", versionCode); | |||
} | |||
} catch (NameNotFoundException e) { | |||
Log.e(TAG, "an error occured when collect package info", e); | |||
} | |||
Field[] fields = Build.class.getDeclaredFields(); | |||
for (Field field : fields) { | |||
try { | |||
field.setAccessible(true); | |||
infos.put(field.getName(), field.get(null).toString()); | |||
} catch (Exception e) { | |||
Log.e(TAG, "an error occured when collect crash info", e); | |||
} | |||
} | |||
} | |||
/** | |||
* ���������Ϣ���ļ��� | |||
* @param ex | |||
* @return �����ļ�����,���ڽ��ļ����͵������� | |||
* @throws Exception | |||
*/ | |||
private String saveCrashInfoFile(Throwable ex) throws Exception { | |||
StringBuffer sb = new StringBuffer(); | |||
try { | |||
SimpleDateFormat sDateFormat = new SimpleDateFormat( | |||
"yyyy-MM-dd HH:mm:ss"); | |||
String date = sDateFormat.format(new java.util.Date()); | |||
sb.append("\r\n" + date + "\n"); | |||
for (Map.Entry<String, String> entry : infos.entrySet()) { | |||
String key = entry.getKey(); | |||
String value = entry.getValue(); | |||
sb.append(key + "=" + value + "\n"); | |||
} | |||
Writer writer = new StringWriter(); | |||
PrintWriter printWriter = new PrintWriter(writer); | |||
ex.printStackTrace(printWriter); | |||
Throwable cause = ex.getCause(); | |||
while (cause != null) { | |||
cause.printStackTrace(printWriter); | |||
cause = cause.getCause(); | |||
} | |||
printWriter.flush(); | |||
printWriter.close(); | |||
String result = writer.toString(); | |||
sb.append(result); | |||
String fileName = writeFile(sb.toString()); | |||
return fileName; | |||
} catch (Exception e) { | |||
Log.e(TAG, "an error occured while writing file...", e); | |||
sb.append("an error occured while writing file...\r\n"); | |||
writeFile(sb.toString()); | |||
} | |||
return null; | |||
} | |||
private String writeFile(String sb) throws Exception { | |||
String time = formatter.format(new Date()); | |||
String fileName = "crash-" + time + ".log"; | |||
if (FileUtil.hasSdcard()) { | |||
String path = getGlobalpath(); | |||
File dir = new File(path); | |||
if (!dir.exists()) | |||
dir.mkdirs(); | |||
FileOutputStream fos = new FileOutputStream(path + fileName, true); | |||
fos.write(sb.getBytes()); | |||
fos.flush(); | |||
fos.close(); | |||
} | |||
return fileName; | |||
} | |||
public static String getGlobalpath() { | |||
return Environment.getExternalStorageDirectory().getAbsolutePath() | |||
+ File.separator + "crash" + File.separator; | |||
} | |||
public static void setTag(String tag) { | |||
TAG = tag; | |||
} | |||
/** | |||
* �ļ�ɾ�� | |||
* @param �ļ��������� | |||
*/ | |||
public void autoClear(final int autoClearDay) { | |||
FileUtil.delete(getGlobalpath(), new FilenameFilter() { | |||
@Override | |||
public boolean accept(File file, String filename) { | |||
String s = FileUtil.getFileNameWithoutExtension(filename); | |||
int day = autoClearDay < 0 ? autoClearDay : -1 * autoClearDay; | |||
String date = "crash-" + DateUtil.getOtherDay(day); | |||
return date.compareTo(s) >= 0; | |||
} | |||
}); | |||
} | |||
} |
@@ -0,0 +1,372 @@ | |||
package com.example.bpa.helper; | |||
import java.text.ParseException; | |||
import java.text.SimpleDateFormat; | |||
import java.util.Calendar; | |||
import java.util.Date; | |||
import android.annotation.SuppressLint; | |||
@SuppressLint("SimpleDateFormat") | |||
public final class DateUtil { | |||
/** yyyy-MM-dd HH:mm:ss�ַ��� */ | |||
public static final String DEFAULT_DATE_TIME_FORMAT = "yyyy-MM-dd HH:mm:ss"; | |||
/** yyyy-MM-dd�ַ��� */ | |||
public static final String DEFAULT_FORMAT_DATE = "yyyy-MM-dd"; | |||
/** HH:mm:ss�ַ��� */ | |||
public static final String DEFAULT_FORMAT_TIME = "HH:mm:ss"; | |||
/** yyyy-MM-dd HH:mm:ss��ʽ */ | |||
public static final ThreadLocal<SimpleDateFormat> defaultDateTimeFormat = new ThreadLocal<SimpleDateFormat>() { | |||
@Override | |||
protected SimpleDateFormat initialValue() { | |||
return new SimpleDateFormat(DEFAULT_DATE_TIME_FORMAT); | |||
} | |||
}; | |||
/** yyyy-MM-dd��ʽ */ | |||
public static final ThreadLocal<SimpleDateFormat> defaultDateFormat = new ThreadLocal<SimpleDateFormat>() { | |||
@Override | |||
protected SimpleDateFormat initialValue() { | |||
return new SimpleDateFormat(DEFAULT_FORMAT_DATE); | |||
} | |||
}; | |||
/** HH:mm:ss��ʽ */ | |||
public static final ThreadLocal<SimpleDateFormat> defaultTimeFormat = new ThreadLocal<SimpleDateFormat>() { | |||
@Override | |||
protected SimpleDateFormat initialValue() { | |||
return new SimpleDateFormat(DEFAULT_FORMAT_TIME); | |||
} | |||
}; | |||
private DateUtil() { | |||
throw new RuntimeException("�� 3��"); | |||
} | |||
/** | |||
* ��longʱ��ת��yyyy-MM-dd HH:mm:ss�ַ���<br> | |||
* @param timeInMillis ʱ��longֵ | |||
* @return yyyy-MM-dd HH:mm:ss | |||
*/ | |||
public static String getDateTimeFromMillis(long timeInMillis) { | |||
return getDateTimeFormat(new Date(timeInMillis)); | |||
} | |||
/** | |||
* ��longʱ��ת��yyyy-MM-dd�ַ���<br> | |||
* @param timeInMillis | |||
* @return yyyy-MM-dd | |||
*/ | |||
public static String getDateFromMillis(long timeInMillis) { | |||
return getDateFormat(new Date(timeInMillis)); | |||
} | |||
/** | |||
* ��dateת��yyyy-MM-dd HH:mm:ss�ַ��� | |||
* <br> | |||
* @param date Date���� | |||
* @return yyyy-MM-dd HH:mm:ss | |||
*/ | |||
public static String getDateTimeFormat(Date date) { | |||
return dateSimpleFormat(date, defaultDateTimeFormat.get()); | |||
} | |||
/** | |||
* �������յ�intת��yyyy-MM-dd���ַ��� | |||
* @param year �� | |||
* @param month �� 1-12 | |||
* @param day �� | |||
* ע���±�ʾCalendar���£���ʵ��С1 | |||
* ��������δ���ж� | |||
*/ | |||
public static String getDateFormat(int year, int month, int day) { | |||
return getDateFormat(getDate(year, month, day)); | |||
} | |||
/** | |||
* ��dateת��yyyy-MM-dd�ַ���<br> | |||
* @param date Date���� | |||
* @return yyyy-MM-dd | |||
*/ | |||
public static String getDateFormat(Date date) { | |||
return dateSimpleFormat(date, defaultDateFormat.get()); | |||
} | |||
/** | |||
* ���HH:mm:ss��ʱ�� | |||
* @param date | |||
* @return | |||
*/ | |||
public static String getTimeFormat(Date date) { | |||
return dateSimpleFormat(date, defaultTimeFormat.get()); | |||
} | |||
/** | |||
* ��ʽ��������ʾ��ʽ | |||
* @param sdate ԭʼ���ڸ�ʽ "yyyy-MM-dd" | |||
* @param format ��ʽ�������ڸ�ʽ | |||
* @return ��ʽ�����������ʾ | |||
*/ | |||
public static String dateFormat(String sdate, String format) { | |||
SimpleDateFormat formatter = new SimpleDateFormat(format); | |||
java.sql.Date date = java.sql.Date.valueOf(sdate); | |||
return dateSimpleFormat(date, formatter); | |||
} | |||
/** | |||
* ��ʽ��������ʾ��ʽ | |||
* @param date Date���� | |||
* @param format ��ʽ�������ڸ�ʽ | |||
* @return ��ʽ�����������ʾ | |||
*/ | |||
public static String dateFormat(Date date, String format) { | |||
SimpleDateFormat formatter = new SimpleDateFormat(format); | |||
return dateSimpleFormat(date, formatter); | |||
} | |||
/** | |||
* ��dateת���ַ��� | |||
* @param date Date | |||
* @param format SimpleDateFormat | |||
* <br> | |||
* ע�� SimpleDateFormatΪ��ʱ������Ĭ�ϵ�yyyy-MM-dd HH:mm:ss��ʽ | |||
* @return yyyy-MM-dd HH:mm:ss | |||
*/ | |||
public static String dateSimpleFormat(Date date, SimpleDateFormat format) { | |||
if (format == null) | |||
format = defaultDateTimeFormat.get(); | |||
return (date == null ? "" : format.format(date)); | |||
} | |||
/** | |||
* ��"yyyy-MM-dd HH:mm:ss" ��ʽ���ַ���ת��Date | |||
* @param strDate ʱ���ַ��� | |||
* @return Date | |||
*/ | |||
public static Date getDateByDateTimeFormat(String strDate) { | |||
return getDateByFormat(strDate, defaultDateTimeFormat.get()); | |||
} | |||
/** | |||
* ��"yyyy-MM-dd" ��ʽ���ַ���ת��Date | |||
* @param strDate | |||
* @return Date | |||
*/ | |||
public static Date getDateByDateFormat(String strDate) { | |||
return getDateByFormat(strDate, defaultDateFormat.get()); | |||
} | |||
/** | |||
* ��ָ����ʽ��ʱ���ַ���ת��Date���� | |||
* @param strDate ʱ���ַ��� | |||
* @param format ��ʽ���ַ��� | |||
* @return Date | |||
*/ | |||
public static Date getDateByFormat(String strDate, String format) { | |||
return getDateByFormat(strDate, new SimpleDateFormat(format)); | |||
} | |||
/** | |||
* ��String�ַ�������һ����ʽת��Date<br> | |||
* ע�� SimpleDateFormatΪ��ʱ������Ĭ�ϵ�yyyy-MM-dd HH:mm:ss��ʽ | |||
* @param strDate ʱ���ַ��� | |||
* @param format SimpleDateFormat���� | |||
* @exception ParseException ���ڸ�ʽת������ | |||
*/ | |||
private static Date getDateByFormat(String strDate, SimpleDateFormat format) { | |||
if (format == null) | |||
format = defaultDateTimeFormat.get(); | |||
try { | |||
return format.parse(strDate); | |||
} catch (ParseException e) { | |||
e.printStackTrace(); | |||
} | |||
return null; | |||
} | |||
/** | |||
* �������յ�intת��date | |||
* @param year �� | |||
* @param month �� 1-12 | |||
* @param day �� | |||
* ע���±�ʾCalendar���£���ʵ��С1 | |||
*/ | |||
public static Date getDate(int year, int month, int day) { | |||
Calendar mCalendar = Calendar.getInstance(); | |||
mCalendar.set(year, month - 1, day); | |||
return mCalendar.getTime(); | |||
} | |||
/** | |||
* ����������������� | |||
* | |||
* @param strat ��ʼ���ڣ���ʽyyyy-MM-dd | |||
* @param end ��ֹ���ڣ���ʽyyyy-MM-dd | |||
* @return ��������������� | |||
*/ | |||
public static long getIntervalDays(String strat, String end) { | |||
return ((java.sql.Date.valueOf(end)).getTime() - (java.sql.Date | |||
.valueOf(strat)).getTime()) / (3600 * 24 * 1000); | |||
} | |||
/** | |||
* ��õ�ǰ��� | |||
* @return year(int) | |||
*/ | |||
public static int getCurrentYear() { | |||
Calendar mCalendar = Calendar.getInstance(); | |||
return mCalendar.get(Calendar.YEAR); | |||
} | |||
/** | |||
* ��õ�ǰ�·� | |||
* @return month(int) 1-12 | |||
*/ | |||
public static int getCurrentMonth() { | |||
Calendar mCalendar = Calendar.getInstance(); | |||
return mCalendar.get(Calendar.MONTH) + 1; | |||
} | |||
/** | |||
* ��õ��¼��� | |||
* @return day(int) | |||
*/ | |||
public static int getDayOfMonth() { | |||
Calendar mCalendar = Calendar.getInstance(); | |||
return mCalendar.get(Calendar.DAY_OF_MONTH); | |||
} | |||
/** | |||
* ��ý��������(��ʽ��yyyy-MM-dd) | |||
* @return yyyy-MM-dd | |||
*/ | |||
public static String getToday() { | |||
Calendar mCalendar = Calendar.getInstance(); | |||
return getDateFormat(mCalendar.getTime()); | |||
} | |||
/** | |||
* ������������(��ʽ��yyyy-MM-dd) | |||
* @return yyyy-MM-dd | |||
*/ | |||
public static String getYesterday() { | |||
Calendar mCalendar = Calendar.getInstance(); | |||
mCalendar.add(Calendar.DATE, -1); | |||
return getDateFormat(mCalendar.getTime()); | |||
} | |||
/** | |||
* ���ǰ�������(��ʽ��yyyy-MM-dd) | |||
* @return yyyy-MM-dd | |||
*/ | |||
public static String getBeforeYesterday() { | |||
Calendar mCalendar = Calendar.getInstance(); | |||
mCalendar.add(Calendar.DATE, -2); | |||
return getDateFormat(mCalendar.getTime()); | |||
} | |||
/** | |||
* ��ü���֮ǰ������֮������� | |||
* @param diff ��ֵ�����������ƣ�������ǰ�� | |||
* @return | |||
*/ | |||
public static String getOtherDay(int diff) { | |||
Calendar mCalendar = Calendar.getInstance(); | |||
mCalendar.add(Calendar.DATE, diff); | |||
return getDateFormat(mCalendar.getTime()); | |||
} | |||
/** | |||
* ȡ�ø������ڼ���һ������������ڶ���. | |||
* | |||
* @param date ���������ڶ��� | |||
* @param amount ��Ҫ��ӵ��������������ǰ��������ʹ�ø����Ϳ���. | |||
* @return Date ����һ�������Ժ��Date����. | |||
*/ | |||
public static String getCalcDateFormat(String sDate, int amount) { | |||
Date date = getCalcDate(getDateByDateFormat(sDate), amount); | |||
return getDateFormat(date); | |||
} | |||
/** | |||
* ȡ�ø������ڼ���һ������������ڶ���. | |||
* | |||
* @param date ���������ڶ��� | |||
* @param amount ��Ҫ��ӵ��������������ǰ��������ʹ�ø����Ϳ���. | |||
* @return Date ����һ�������Ժ��Date����. | |||
*/ | |||
public static Date getCalcDate(Date date, int amount) { | |||
Calendar cal = Calendar.getInstance(); | |||
cal.setTime(date); | |||
cal.add(Calendar.DATE, amount); | |||
return cal.getTime(); | |||
} | |||
/** | |||
* ���һ������ʮ����֮������ڶ��� | |||
* @param date | |||
* @param hOffset ʱƫ��������Ϊ�� | |||
* @param mOffset ��ƫ��������Ϊ�� | |||
* @param sOffset ��ƫ��������Ϊ�� | |||
* @return | |||
*/ | |||
public static Date getCalcTime(Date date, int hOffset, int mOffset, int sOffset) { | |||
Calendar cal = Calendar.getInstance(); | |||
if (date != null) | |||
cal.setTime(date); | |||
cal.add(Calendar.HOUR_OF_DAY, hOffset); | |||
cal.add(Calendar.MINUTE, mOffset); | |||
cal.add(Calendar.SECOND, sOffset); | |||
return cal.getTime(); | |||
} | |||
/** | |||
* ����ָ����������Сʱ���룬����һ��java.Util.Date���� | |||
* | |||
* @param year �� | |||
* @param month �� 0-11 | |||
* @param date �� | |||
* @param hourOfDay Сʱ 0-23 | |||
* @param minute �� 0-59 | |||
* @param second �� 0-59 | |||
* @return һ��Date���� | |||
*/ | |||
public static Date getDate(int year, int month, int date, int hourOfDay, | |||
int minute, int second) { | |||
Calendar cal = Calendar.getInstance(); | |||
cal.set(year, month, date, hourOfDay, minute, second); | |||
return cal.getTime(); | |||
} | |||
/** | |||
* ������������� | |||
* @param sDate yyyy-MM-dd��ʽ | |||
* @return arr[0]:�꣬ arr[1]:�� 0-11 , arr[2]�� | |||
*/ | |||
public static int[] getYearMonthAndDayFrom(String sDate) { | |||
return getYearMonthAndDayFromDate(getDateByDateFormat(sDate)); | |||
} | |||
/** | |||
* ������������� | |||
* @return arr[0]:�꣬ arr[1]:�� 0-11 , arr[2]�� | |||
*/ | |||
public static int[] getYearMonthAndDayFromDate(Date date) { | |||
Calendar calendar = Calendar.getInstance(); | |||
calendar.setTime(date); | |||
int[] arr = new int[3]; | |||
arr[0] = calendar.get(Calendar.YEAR); | |||
arr[1] = calendar.get(Calendar.MONTH); | |||
arr[2] = calendar.get(Calendar.DAY_OF_MONTH); | |||
return arr; | |||
} | |||
} |
@@ -0,0 +1,588 @@ | |||
package com.example.bpa.helper; | |||
import java.io.BufferedReader; | |||
import java.io.File; | |||
import java.io.FileInputStream; | |||
import java.io.FileOutputStream; | |||
import java.io.FileWriter; | |||
import java.io.FilenameFilter; | |||
import java.io.IOException; | |||
import java.io.InputStream; | |||
import java.io.InputStreamReader; | |||
import java.io.OutputStream; | |||
import java.util.ArrayList; | |||
import java.util.Collections; | |||
import java.util.List; | |||
import android.os.Environment; | |||
import android.text.TextUtils; | |||
public final class FileUtil { | |||
private FileUtil() { | |||
throw new Error("���n��"); | |||
} | |||
/** �ָ���. */ | |||
public final static String FILE_EXTENSION_SEPARATOR = "."; | |||
/**"/"*/ | |||
public final static String SEP = File.separator; | |||
/** SD����Ŀ¼ */ | |||
public static final String SDPATH = Environment | |||
.getExternalStorageDirectory() + File.separator; | |||
/** | |||
* �ж�SD���Ƿ���� | |||
* @return SD�����÷���true | |||
*/ | |||
public static boolean hasSdcard() { | |||
String status = Environment.getExternalStorageState(); | |||
return Environment.MEDIA_MOUNTED.equals(status); | |||
} | |||
/** | |||
* ��ȡ�ļ������� | |||
* <br> | |||
* Ĭ��utf-8���� | |||
* @param filePath �ļ�·�� | |||
* @return �ַ��� | |||
* @throws IOException | |||
*/ | |||
public static String readFile(String filePath) throws IOException { | |||
return readFile(filePath, "utf-8"); | |||
} | |||
/** | |||
* ��ȡ�ļ������� | |||
* @param filePath �ļ�Ŀ¼ | |||
* @param charsetName �ַ����� | |||
* @return String�ַ��� | |||
*/ | |||
public static String readFile(String filePath, String charsetName) | |||
throws IOException { | |||
if (TextUtils.isEmpty(filePath)) | |||
return null; | |||
if (TextUtils.isEmpty(charsetName)) | |||
charsetName = "utf-8"; | |||
File file = new File(filePath); | |||
StringBuilder fileContent = new StringBuilder(""); | |||
if (file == null || !file.isFile()) | |||
return null; | |||
BufferedReader reader = null; | |||
try { | |||
InputStreamReader is = new InputStreamReader(new FileInputStream( | |||
file), charsetName); | |||
reader = new BufferedReader(is); | |||
String line = null; | |||
while ((line = reader.readLine()) != null) { | |||
if (!fileContent.toString().equals("")) { | |||
fileContent.append("\r\n"); | |||
} | |||
fileContent.append(line); | |||
} | |||
return fileContent.toString(); | |||
} finally { | |||
if (reader != null) { | |||
try { | |||
reader.close(); | |||
} catch (IOException e) { | |||
e.printStackTrace(); | |||
} | |||
} | |||
} | |||
} | |||
/** | |||
* ��ȡ�ı��ļ���List�ַ���������(Ĭ��utf-8����) | |||
* @param filePath �ļ�Ŀ¼ | |||
* @return �ļ������ڷ���null�������ַ������� | |||
* @throws IOException | |||
*/ | |||
public static List<String> readFileToList(String filePath) | |||
throws IOException { | |||
return readFileToList(filePath, "utf-8"); | |||
} | |||
/** | |||
* ��ȡ�ı��ļ���List�ַ��������� | |||
* @param filePath �ļ�Ŀ¼ | |||
* @param charsetName �ַ����� | |||
* @return �ļ������ڷ���null�������ַ������� | |||
*/ | |||
public static List<String> readFileToList(String filePath, | |||
String charsetName) throws IOException { | |||
if (TextUtils.isEmpty(filePath)) | |||
return null; | |||
if (TextUtils.isEmpty(charsetName)) | |||
charsetName = "utf-8"; | |||
File file = new File(filePath); | |||
List<String> fileContent = new ArrayList<String>(); | |||
if (file == null || !file.isFile()) { | |||
return null; | |||
} | |||
BufferedReader reader = null; | |||
try { | |||
InputStreamReader is = new InputStreamReader(new FileInputStream( | |||
file), charsetName); | |||
reader = new BufferedReader(is); | |||
String line = null; | |||
while ((line = reader.readLine()) != null) { | |||
fileContent.add(line); | |||
} | |||
return fileContent; | |||
} finally { | |||
if (reader != null) { | |||
try { | |||
reader.close(); | |||
} catch (IOException e) { | |||
e.printStackTrace(); | |||
} | |||
} | |||
} | |||
} | |||
/** | |||
* ���ļ���д������ | |||
* @param filePath �ļ�Ŀ¼ | |||
* @param content Ҫд������� | |||
* @param append ���Ϊ true��������д���ļ�ĩβ����������д���ļ���ʼ�� | |||
* @return д��ɹ�����true�� д��ʧ�ܷ���false | |||
* @throws IOException | |||
*/ | |||
public static boolean writeFile(String filePath, String content, | |||
boolean append) throws IOException { | |||
if (TextUtils.isEmpty(filePath)) | |||
return false; | |||
if (TextUtils.isEmpty(content)) | |||
return false; | |||
FileWriter fileWriter = null; | |||
try { | |||
createFile(filePath); | |||
fileWriter = new FileWriter(filePath, append); | |||
fileWriter.write(content); | |||
fileWriter.flush(); | |||
return true; | |||
} finally { | |||
if (fileWriter != null) { | |||
try { | |||
fileWriter.close(); | |||
} catch (IOException e) { | |||
e.printStackTrace(); | |||
} | |||
} | |||
} | |||
} | |||
/** | |||
* ���ļ���д������<br> | |||
* Ĭ�����ļ���ʼ������д������ | |||
* @param filePath �ļ�Ŀ¼ | |||
* @param stream �ֽ������� | |||
* @return д��ɹ�����true������false | |||
* @throws IOException | |||
*/ | |||
public static boolean writeFile(String filePath, InputStream stream) | |||
throws IOException { | |||
return writeFile(filePath, stream, false); | |||
} | |||
/** | |||
* ���ļ���д������ | |||
* @param filePath �ļ�Ŀ¼ | |||
* @param stream �ֽ������� | |||
* @param append ���Ϊ true��������д���ļ�ĩβ���� | |||
* Ϊfalseʱ�����ԭ�������ݣ���ͷ��ʼд | |||
* @return д��ɹ�����true������false | |||
* @throws IOException | |||
*/ | |||
public static boolean writeFile(String filePath, InputStream stream, | |||
boolean append) throws IOException { | |||
if (TextUtils.isEmpty(filePath)) | |||
throw new NullPointerException("filePath is Empty"); | |||
if (stream == null) | |||
throw new NullPointerException("InputStream is null"); | |||
return writeFile(new File(filePath), stream, | |||
append); | |||
} | |||
/** | |||
* ���ļ���д������ | |||
* Ĭ�����ļ���ʼ������д������ | |||
* @param file ָ���ļ� | |||
* @param stream �ֽ������� | |||
* @return д��ɹ�����true������false | |||
* @throws IOException | |||
*/ | |||
public static boolean writeFile(File file, InputStream stream) | |||
throws IOException { | |||
return writeFile(file, stream, false); | |||
} | |||
/** | |||
* ���ļ���д������ | |||
* @param file ָ���ļ� | |||
* @param stream �ֽ������� | |||
* @param append Ϊtrueʱ�����ļ���ʼ������д�����ݣ� | |||
* Ϊfalseʱ�����ԭ�������ݣ���ͷ��ʼд | |||
* @return д��ɹ�����true������false | |||
* @throws IOException | |||
*/ | |||
public static boolean writeFile(File file, InputStream stream, | |||
boolean append) throws IOException { | |||
if (file == null) | |||
throw new NullPointerException("file = null"); | |||
OutputStream out = null; | |||
try { | |||
createFile(file.getAbsolutePath()); | |||
out = new FileOutputStream(file, append); | |||
byte data[] = new byte[1024]; | |||
int length = -1; | |||
while ((length = stream.read(data)) != -1) { | |||
out.write(data, 0, length); | |||
} | |||
out.flush(); | |||
return true; | |||
} finally { | |||
if (out != null) { | |||
try { | |||
out.close(); | |||
stream.close(); | |||
} catch (IOException e) { | |||
e.printStackTrace(); | |||
} | |||
} | |||
} | |||
} | |||
/** | |||
* �����ļ� | |||
* @param sourceFilePath Դ�ļ�Ŀ¼��Ҫ���Ƶ��ļ�Ŀ¼�� | |||
* @param destFilePath Ŀ���ļ�Ŀ¼�����ƺ���ļ�Ŀ¼�� | |||
* @return �����ļ��ɹ�����true������false | |||
* @throws IOException | |||
*/ | |||
public static boolean copyFile(String sourceFilePath, String destFilePath) | |||
throws IOException { | |||
InputStream inputStream = null; | |||
inputStream = new FileInputStream(sourceFilePath); | |||
return writeFile(destFilePath, inputStream); | |||
} | |||
/** | |||
* ��ȡij��Ŀ¼�µ��ļ��� | |||
* @param dirPath Ŀ¼ | |||
* @param fileFilter ������ | |||
* @return ij��Ŀ¼�µ������ļ��� | |||
*/ | |||
public static List<String> getFileNameList(String dirPath, | |||
FilenameFilter fileFilter) { | |||
if (fileFilter == null) | |||
return getFileNameList(dirPath); | |||
if (TextUtils.isEmpty(dirPath)) | |||
return Collections.emptyList(); | |||
File dir = new File(dirPath); | |||
File[] files = dir.listFiles(fileFilter); | |||
if (files == null) | |||
return Collections.emptyList(); | |||
List<String> conList = new ArrayList<String>(); | |||
for (File file : files) { | |||
if (file.isFile()) | |||
conList.add(file.getName()); | |||
} | |||
return conList; | |||
} | |||
/** | |||
* ��ȡij��Ŀ¼�µ��ļ��� | |||
* @param dirPath Ŀ¼ | |||
* @return ij��Ŀ¼�µ������ļ��� | |||
*/ | |||
public static List<String> getFileNameList(String dirPath) { | |||
if (TextUtils.isEmpty(dirPath)) | |||
return Collections.emptyList(); | |||
File dir = new File(dirPath); | |||
File[] files = dir.listFiles(); | |||
if (files == null) | |||
return Collections.emptyList(); | |||
List<String> conList = new ArrayList<String>(); | |||
for (File file : files) { | |||
if (file.isFile()) | |||
conList.add(file.getName()); | |||
} | |||
return conList; | |||
} | |||
/** | |||
* ��ȡij��Ŀ¼�µ�ָ����չ�����ļ����� | |||
* @param dirPath Ŀ¼ | |||
* @return ij��Ŀ¼�µ������ļ��� | |||
*/ | |||
public static List<String> getFileNameList(String dirPath, | |||
final String extension) { | |||
if (TextUtils.isEmpty(dirPath)) | |||
return Collections.emptyList(); | |||
File dir = new File(dirPath); | |||
File[] files = dir.listFiles(new FilenameFilter() { | |||
@Override | |||
public boolean accept(File dir, String filename) { | |||
if (filename.indexOf("." + extension) > 0) | |||
return true; | |||
return false; | |||
} | |||
}); | |||
if (files == null) | |||
return Collections.emptyList(); | |||
List<String> conList = new ArrayList<String>(); | |||
for (File file : files) { | |||
if (file.isFile()) | |||
conList.add(file.getName()); | |||
} | |||
return conList; | |||
} | |||
/** | |||
* ����ļ�����չ�� | |||
* @param filePath �ļ�·�� | |||
* @return ���û����չ��������"" | |||
*/ | |||
public static String getFileExtension(String filePath) { | |||
if (TextUtils.isEmpty(filePath)) { | |||
return filePath; | |||
} | |||
int extenPosi = filePath.lastIndexOf(FILE_EXTENSION_SEPARATOR); | |||
int filePosi = filePath.lastIndexOf(File.separator); | |||
if (extenPosi == -1) { | |||
return ""; | |||
} | |||
return (filePosi >= extenPosi) ? "" : filePath.substring(extenPosi + 1); | |||
} | |||
/** | |||
* �����ļ� | |||
* @param path �ļ��ľ���·�� | |||
* @return | |||
*/ | |||
public static boolean createFile(String path) { | |||
if (TextUtils.isEmpty(path)) | |||
return false; | |||
return createFile(new File(path)); | |||
} | |||
/** | |||
* �����ļ� | |||
* @param file | |||
* @return �����ɹ�����true | |||
*/ | |||
public static boolean createFile(File file) { | |||
if (file == null || !makeDirs(getFolderName(file.getAbsolutePath()))) | |||
return false; | |||
if (!file.exists()) | |||
try { | |||
return file.createNewFile(); | |||
} catch (IOException e) { | |||
e.printStackTrace(); | |||
return false; | |||
} | |||
return false; | |||
} | |||
/** | |||
* ����Ŀ¼�������Ƕ���� | |||
* @param filePath Ŀ¼·�� | |||
* @return ���·��Ϊ��ʱ������false�����Ŀ¼�����ɹ�����true������false | |||
*/ | |||
public static boolean makeDirs(String filePath) { | |||
if (TextUtils.isEmpty(filePath)) { | |||
return false; | |||
} | |||
File folder = new File(filePath); | |||
return (folder.exists() && folder.isDirectory()) ? true : folder | |||
.mkdirs(); | |||
} | |||
/** | |||
* ����Ŀ¼�������Ƕ���� | |||
* @param dir Ŀ¼ | |||
* @return ���Ŀ¼�����ɹ�����true������false | |||
*/ | |||
public static boolean makeDirs(File dir) { | |||
if (dir == null) | |||
return false; | |||
return (dir.exists() && dir.isDirectory()) ? true : dir.mkdirs(); | |||
} | |||
/** | |||
* �ж��ļ��Ƿ���� | |||
* @param filePath �ļ�·�� | |||
* @return ���·��Ϊ�ջ���Ϊ�հ��ַ������ͷ���false������ļ����ڣ������ļ��� | |||
* �ͷ���true����������ļ����߲����ڣ���false | |||
*/ | |||
public static boolean isFileExist(String filePath) { | |||
if (TextUtils.isEmpty(filePath)) { | |||
return false; | |||
} | |||
File file = new File(filePath); | |||
return (file.exists() && file.isFile()); | |||
} | |||
/** | |||
* ��ò�����չ�����ļ����� | |||
* @param filePath �ļ�·�� | |||
* @return | |||
*/ | |||
public static String getFileNameWithoutExtension(String filePath) { | |||
if (TextUtils.isEmpty(filePath)) { | |||
return filePath; | |||
} | |||
int extenPosi = filePath.lastIndexOf(FILE_EXTENSION_SEPARATOR); | |||
int filePosi = filePath.lastIndexOf(File.separator); | |||
if (filePosi == -1) { | |||
return (extenPosi == -1 ? filePath : filePath.substring(0, | |||
extenPosi)); | |||
} | |||
if (extenPosi == -1) { | |||
return filePath.substring(filePosi + 1); | |||
} | |||
return (filePosi < extenPosi ? filePath.substring(filePosi + 1, | |||
extenPosi) : filePath.substring(filePosi + 1)); | |||
} | |||
/** | |||
* ����ļ��� | |||
* @param filePath �ļ�·�� | |||
* @return ���·��Ϊ�ջ�մ�������·��������Ϊ��ʱ�������ļ��� | |||
*/ | |||
public static String getFileName(String filePath) { | |||
if (TextUtils.isEmpty(filePath)) { | |||
return filePath; | |||
} | |||
int filePosi = filePath.lastIndexOf(File.separator); | |||
return (filePosi == -1) ? filePath : filePath.substring(filePosi + 1); | |||
} | |||
/** | |||
* �������Ŀ¼���� | |||
* @param filePath �ļ��ľ���·�� | |||
* @return ���·��Ϊ�ջ�մ�������·��������Ϊ��ʱ�����Ϊ��Ŀ¼������""; | |||
* ������Ǹ�Ŀ¼����������Ŀ¼���ƣ���ʽ�磺C:/Windows/Boot | |||
*/ | |||
public static String getFolderName(String filePath) { | |||
if (TextUtils.isEmpty(filePath)) { | |||
return filePath; | |||
} | |||
int filePosi = filePath.lastIndexOf(File.separator); | |||
return (filePosi == -1) ? "" : filePath.substring(0, filePosi); | |||
} | |||
/** | |||
* �ж�Ŀ¼�Ƿ���� | |||
* @param ¼·�� | |||
* @return ���·��Ϊ�ջ�հ��ַ���������false�����Ŀ¼�����ң�ȷʵ��Ŀ¼�ļ��У� | |||
* ����true����������ļ��л��߲����ڣ���false | |||
*/ | |||
public static boolean isFolderExist(String directoryPath) { | |||
if (TextUtils.isEmpty(directoryPath)) { | |||
return false; | |||
} | |||
File dire = new File(directoryPath); | |||
return (dire.exists() && dire.isDirectory()); | |||
} | |||
/** | |||
* ɾ��ָ���ļ���ָ��Ŀ¼�ڵ������ļ� | |||
* @param path �ļ���Ŀ¼�ľ���·�� | |||
* @return ·��Ϊ�ջ�հ��ַ���������true���ļ������ڣ�����true���ļ�ɾ������true�� | |||
* �ļ�ɾ���쳣����false | |||
*/ | |||
public static boolean deleteFile(String path) { | |||
if (TextUtils.isEmpty(path)) { | |||
return true; | |||
} | |||
return deleteFile(new File(path)); | |||
} | |||
/** | |||
* ɾ��ָ���ļ���ָ��Ŀ¼�ڵ������ļ� | |||
* @param file | |||
* @return ·��Ϊ�ջ�հ��ַ���������true���ļ������ڣ�����true���ļ�ɾ������true�� | |||
* �ļ�ɾ���쳣����false | |||
*/ | |||
public static boolean deleteFile(File file) { | |||
if (file == null) | |||
throw new NullPointerException("file is null"); | |||
if (!file.exists()) { | |||
return true; | |||
} | |||
if (file.isFile()) { | |||
return file.delete(); | |||
} | |||
if (!file.isDirectory()) { | |||
return false; | |||
} | |||
File[] files = file.listFiles(); | |||
if (files == null) | |||
return true; | |||
for (File f : files) { | |||
if (f.isFile()) { | |||
f.delete(); | |||
} else if (f.isDirectory()) { | |||
deleteFile(f.getAbsolutePath()); | |||
} | |||
} | |||
return file.delete(); | |||
} | |||
/** | |||
* ɾ��ָ��Ŀ¼���ض����ļ� | |||
* @param dir | |||
* @param filter | |||
*/ | |||
public static void delete(String dir, FilenameFilter filter) { | |||
if (TextUtils.isEmpty(dir)) | |||
return; | |||
File file = new File(dir); | |||
if (!file.exists()) | |||
return; | |||
if (file.isFile()) | |||
file.delete(); | |||
if (!file.isDirectory()) | |||
return; | |||
File[] lists = null; | |||
if (filter != null) | |||
lists = file.listFiles(filter); | |||
else | |||
lists = file.listFiles(); | |||
if (lists == null) | |||
return; | |||
for (File f : lists) { | |||
if (f.isFile()) { | |||
f.delete(); | |||
} | |||
} | |||
} | |||
/** | |||
* ����ļ����ļ��еĴ�С | |||
* @param path �ļ���Ŀ¼�ľ���·�� | |||
* @return ���ص�ǰĿ¼�Ĵ�С ��ע�����ļ������ڣ�Ϊ�գ�����Ϊ�հ��ַ��������� -1 | |||
*/ | |||
public static long getFileSize(String path) { | |||
if (TextUtils.isEmpty(path)) { | |||
return -1; | |||
} | |||
File file = new File(path); | |||
return (file.exists() && file.isFile() ? file.length() : -1); | |||
} | |||
} |
@@ -6,6 +6,7 @@ import android.util.Log; | |||
import com.example.bpa.Model.IReadCallBack; | |||
import com.example.bpa.Model.IThread; | |||
import com.example.bpa.Model.IWriteCallBack; | |||
import com.example.bpa.Model.ResVersion; | |||
import com.example.bpa.config.ConfigName; | |||
import com.example.bpa.service.BusinessServer; | |||
import com.example.bpa.service.DeviceData; | |||
@@ -180,7 +181,7 @@ public class ModbusTcpServer { | |||
/** | |||
* 连接 | |||
*/ | |||
public void Connect() { | |||
public void Connect() throws InterruptedException { | |||
boolean status = false; | |||
while (!status) { | |||
try { | |||
@@ -201,13 +202,19 @@ public class ModbusTcpServer { | |||
.setRetries(0) | |||
.setEncapsulated(false) | |||
.setKeepAlive(true); | |||
ConnectPLC(); | |||
while (DataBus.getInstance().PlcIsConnect==false) | |||
{ | |||
ConnectPLC(); | |||
Thread.sleep(5000); | |||
} | |||
} | |||
/** | |||
* 连接PLC | |||
*/ | |||
public void ConnectPLC() | |||
public void ConnectPLC() | |||
{ | |||
ModbusTcpHelper.get().init(param, new ModbusCallback<ModbusMaster>() { | |||
@Override | |||
@@ -246,38 +253,38 @@ public class ModbusTcpServer { | |||
}); | |||
} | |||
/** | |||
* 重新连接Modbus | |||
*/ | |||
public void ReconnectModbus() | |||
{ | |||
try { | |||
ThreadManager.Get().StartLong("PLC断线重连线程", true, new IThread() { | |||
@Override | |||
public void Run() throws InterruptedException { | |||
try { | |||
boolean status =ping2(ConfigName.getInstance().Address,1,1); | |||
if(status) | |||
{ | |||
ModbusMaster master= ModbusTcpHelper.get().getModbusMaster(); | |||
if (master==null || master.isConnected() == false) { | |||
ConnectPLC(); | |||
} | |||
Thread.sleep(20000); | |||
} | |||
} catch (Exception e) { | |||
Log.i("PLC", "PLC重连接失败!"+e.getMessage()); | |||
} | |||
} | |||
@Override | |||
public void RunComplete() throws InterruptedException { | |||
} | |||
}); | |||
}catch (Exception e) { | |||
MessageLog.ShowInfo("重新连接Modbus异常," +e.getMessage()); | |||
} | |||
} | |||
// /** | |||
// * 重新连接Modbus | |||
// */ | |||
// public void ReconnectModbus() | |||
// { | |||
// try { | |||
// | |||
// ThreadManager.Get().StartLong("PLC断线重连线程", true, new IThread() { | |||
// @Override | |||
// public void Run() throws InterruptedException { | |||
// try { | |||
// boolean status =ping2(ConfigName.getInstance().Address,1,1); | |||
// if(status) | |||
// { | |||
// ModbusMaster master= ModbusTcpHelper.get().getModbusMaster(); | |||
// if (master==null || master.isConnected() == false) { | |||
// ConnectPLC(); | |||
// } | |||
// Thread.sleep(20000); | |||
// } | |||
// } catch (Exception e) { | |||
// Log.i("PLC", "PLC重连接失败!"+e.getMessage()); | |||
// } | |||
// } | |||
// @Override | |||
// public void RunComplete() throws InterruptedException { | |||
// } | |||
// }); | |||
// }catch (Exception e) { | |||
// MessageLog.ShowInfo("重新连接Modbus异常," +e.getMessage()); | |||
// } | |||
// } | |||
private Float BytesToFloat(byte[] buffers, DataFormat df) { | |||
if (buffers.length == 4) { | |||
@@ -18,8 +18,16 @@ import android.widget.TextView; | |||
import androidx.core.content.FileProvider; | |||
import com.capton.colorfulprogressbar.ColorfulProgressbar; | |||
import com.example.bpa.MainActivity; | |||
import com.example.bpa.Model.ReceiveOrder; | |||
import com.example.bpa.Model.ResVersion; | |||
import com.example.bpa.Model.VersionResponse; | |||
import com.example.bpa.R; | |||
import com.example.bpa.app.Main; | |||
import com.example.bpa.config.ConfigName; | |||
import com.example.bpa.config.MessageName; | |||
import com.example.bpa.message.MessageLooper; | |||
import com.example.bpa.message.MessageManager; | |||
import org.json.JSONObject; | |||
import java.io.File; | |||
@@ -106,14 +114,100 @@ public class UpdateManager { | |||
//构造函数 | |||
public UpdateManager(Context context) { | |||
this.mContext = context; | |||
} | |||
/** | |||
* 如果版本1 大于 版本2 返回true 否则返回fasle 支持 2.2 2.2.1 比较 | |||
* 支持不同位数的比较 2.0.0.0.0.1 2.0 对比 | |||
* | |||
* @param v1 版本服务器版本 " 1.1.2 " | |||
* @param v2 版本 当前版本 " 1.2.1 " | |||
* @return ture :需要更新 false : 不需要更新 | |||
*/ | |||
public static boolean compareVersions(String v1, String v2) { | |||
//判断是否为空数据 | |||
if (v1.isEmpty() || v2.isEmpty()) { | |||
return false; | |||
} | |||
String[] str1 = v1.split("\\."); | |||
String[] str2 = v2.split("\\."); | |||
if (str1.length == str2.length) { | |||
for (int i = 0; i < str1.length; i++) { | |||
if (Integer.parseInt(str1[i]) > Integer.parseInt(str2[i])) { | |||
return true; | |||
} else if (Integer.parseInt(str1[i]) < Integer.parseInt(str2[i])) { | |||
return false; | |||
} else if (Integer.parseInt(str1[i]) == Integer.parseInt(str2[i])) { | |||
} | |||
} | |||
} else { | |||
if (str1.length > str2.length) { | |||
for (int i = 0; i < str2.length; i++) { | |||
if (Integer.parseInt(str1[i]) > Integer.parseInt(str2[i])) { | |||
return true; | |||
} else if (Integer.parseInt(str1[i]) < Integer.parseInt(str2[i])) { | |||
return false; | |||
} else if (Integer.parseInt(str1[i]) == Integer.parseInt(str2[i])) { | |||
if (str2.length == 1) { | |||
continue; | |||
} | |||
if (i == str2.length - 1) { | |||
for (int j = i; j < str1.length; j++) { | |||
if (Integer.parseInt(str1[j]) != 0) { | |||
return true; | |||
} | |||
if (j == str1.length - 1) { | |||
return false; | |||
} | |||
} | |||
return true; | |||
} | |||
} | |||
} | |||
} else { | |||
for (int i = 0; i < str1.length; i++) { | |||
if (Integer.parseInt(str1[i]) > Integer.parseInt(str2[i])) { | |||
return true; | |||
} else if (Integer.parseInt(str1[i]) < Integer.parseInt(str2[i])) { | |||
return false; | |||
} else if (Integer.parseInt(str1[i]) == Integer.parseInt(str2[i])) { | |||
if (str1.length == 1) { | |||
continue; | |||
} | |||
if (i == str1.length - 1) { | |||
return false; | |||
} | |||
} | |||
} | |||
} | |||
} | |||
return false; | |||
} | |||
/* | |||
* 检查新版本 | |||
*/ | |||
public void checkVersion() | |||
public void checkVersion(VersionResponse mode) | |||
{ | |||
// if(compareVersions(mode.versionNo,ConfigName.getInstance().Version))//需要更新 | |||
// { | |||
// Message message = mHandler.obtainMessage(NEW_VERSION); | |||
// message.obj = mode; | |||
// mHandler.sendMessage(message); | |||
// }else //不需要更新 | |||
// { | |||
// T.show(mContext,"当前无更新内容!"); | |||
// } | |||
android.util.Log.i("UpdateManager","checkVersion"); | |||
Runnable checkVersionRunnable = new Runnable(){ | |||
@Override | |||
public void run() | |||
@@ -49,16 +49,22 @@ public class ScanCodeServer { | |||
//3.制作订单信息 | |||
//4.回馈订单信息 | |||
Code=s; | |||
T.show(ConfigName.getInstance().dishesCon, "扫码成功:"+Code+",查询订单中请稍后!"); | |||
Main.getInstance().GetOrder(Code); | |||
DeviceData.Get().setCodeClear(new IWriteCallBack() { | |||
@Override | |||
public void onSuccess() { | |||
} | |||
@Override | |||
public void onFailure(String ErrorMsg) { | |||
} | |||
}); | |||
if (BusinessServer.Get().Commoditys.size() > 0) { | |||
T.show(ConfigName.getInstance().dishesCon, "请等待前一饮品制作完成,在扫码!"); | |||
return; | |||
}else | |||
{ | |||
T.show(ConfigName.getInstance().dishesCon, "扫码成功:"+Code+",查询订单中请稍后!"); | |||
Main.getInstance().GetOrder(Code); | |||
DeviceData.Get().setCodeClear(new IWriteCallBack() { | |||
@Override | |||
public void onSuccess() { | |||
} | |||
@Override | |||
public void onFailure(String ErrorMsg) { | |||
} | |||
}); | |||
} | |||
} | |||
}; | |||
} | |||