Browse Source

商品批量上传修改

master
pry 5 months ago
parent
commit
7e866e0799
5 changed files with 486 additions and 262 deletions
  1. +81
    -23
      app/src/main/java/com/bonait/bnframework/business/UpDataModel.java
  2. +317
    -0
      app/src/main/java/com/bonait/bnframework/common/helper/BatchSync.java
  3. +66
    -0
      app/src/main/java/com/bonait/bnframework/common/helper/WaitDialog.java
  4. +14
    -0
      app/src/main/java/com/bonait/bnframework/common/model/APIResult.java
  5. +8
    -239
      app/src/main/java/com/bonait/bnframework/modules/home/activity/BottomNavigation2Activity.java

+ 81
- 23
app/src/main/java/com/bonait/bnframework/business/UpDataModel.java View File

@@ -1,6 +1,7 @@
package com.bonait.bnframework.business;


import android.app.Activity;
import android.content.Context;
import android.util.Log;

@@ -12,13 +13,20 @@ import com.bonait.bnframework.common.db.mode.BPA_GOODSRECIPE;
import com.bonait.bnframework.common.helper.I.IRunT;
import com.bonait.bnframework.common.http.callback.json.JsonDialogCallback;
import com.bonait.bnframework.common.message.MessageManager;
import com.bonait.bnframework.common.model.APIResult;
import com.bonait.bnframework.common.model.ResAPI;
import com.bonait.bnframework.common.model.mode.ActionJsonMode;
import com.bonait.bnframework.common.model.mode.BPA_GoodsAttributeValue;
import com.bonait.bnframework.common.model.mode.BPA_GoodsTechnologyAction;
import com.bonait.bnframework.common.model.mode.BatchingInfo;
import com.bonait.bnframework.common.model.mode.BomTechnologyActionInfo;
import com.bonait.bnframework.common.model.mode.BomTypeInfo;
import com.bonait.bnframework.common.model.mode.CloudGood;
import com.bonait.bnframework.common.model.mode.FoodMenuInfo;
import com.bonait.bnframework.common.model.mode.GoodsParentTypeInfo;
import com.bonait.bnframework.common.model.mode.GoodsTechnology;
import com.bonait.bnframework.common.model.mode.GoodsTypeInfo;
import com.bonait.bnframework.common.model.mode.GoodsUintInfo;
import com.bonait.bnframework.common.model.mode.TechnologyAction;
import com.bonait.bnframework.common.model.mode.UpdateBomInfo;
import com.bonait.bnframework.common.model.mode.UpdateCloudGood;
@@ -31,7 +39,9 @@ import com.lzy.okgo.model.Response;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

import okhttp3.MediaType;
import okhttp3.RequestBody;
@@ -39,10 +49,57 @@ import okhttp3.RequestBody;
public class UpDataModel {
private BPA_GOODS good;
private Context context;
public UpDataModel(Context ct,BPA_GOODS Good){
private Activity activity;

Map<String,String> map_cp = new LinkedHashMap<>();
Map<String,String> map_dl = new LinkedHashMap<>();
Map<String,String> map_xl = new LinkedHashMap<>();
Map<String,String> map_dw = new LinkedHashMap<>();
Map<String,String> map_fl = new LinkedHashMap<>();
Map<String,String> map_sx = new LinkedHashMap<>();
String sp, dl, xl, dw, fl, sxid;

public UpDataModel(Activity ac,Context ct,BPA_GOODS Good){
good=Good;
context=ct;
activity=ac;
DataInit();
}

private void DataInit(){
for (FoodMenuInfo item:ConfigName.getInstance().cloudData.foodMenuInfo)
{
map_cp.put(item.name,item.id);
}
for (GoodsParentTypeInfo item:ConfigName.getInstance().cloudData.goodsParentTypeInfo)
{
map_dl.put(item.name,item.id);
}
for (GoodsTypeInfo item:ConfigName.getInstance().cloudData.goodsTypeInfo)
{
map_xl.put(item.goodsType_Name,item.id);
}
for (GoodsUintInfo item:ConfigName.getInstance().cloudData.goodsUintInfo)
{
map_dw.put(item.name,item.id);
}
for (BomTypeInfo item:ConfigName.getInstance().cloudData.bomTypeInfo)
{
map_fl.put(item.name,item.id);
}

for (BPA_GoodsAttributeValue item:ConfigName.getInstance().cloudData.goodsAttributeValue)
{
map_sx.put(item.attributeValue,item.id);
}
sp = map_cp.get("小炒");
dl=map_dl.get("默认分类");
xl=map_xl.get("默认分类");
dw=map_dw.get("默认单位");
fl=map_fl.get("炒菜");
sxid=map_sx.get("默认属性值");
}

public Thread task;

public boolean Status=false;
@@ -99,11 +156,11 @@ public class UpDataModel {
update.goodsInfo.goods_Name = good.name;

//选择菜谱 大类id 小类id 单位id
update.foodMenuId = "小炒";
update.foodMenuId = sp;
update.goodsInfo.goods_ImgUrl = good.url;//图片地址
update.goodsInfo.parentTypeID = "默认分类";//大类
update.goodsInfo.goods_TypeID = "默认分类";//小类
update.goodsInfo.goodsUintId = "默认单位";//单位
update.goodsInfo.parentTypeID = dl;//大类
update.goodsInfo.goods_TypeID = xl;//小类
update.goodsInfo.goodsUintId = dw;//单位

String id = good.gyid;
if (good.gyid == null) {
@@ -114,7 +171,7 @@ public class UpDataModel {

UpdateBomInfo bom = new UpdateBomInfo();
bom.id = id;
bom.bomType = "炒菜";
bom.bomType = fl;
bom.name = good.name;
bom.code = java.util.UUID.randomUUID().toString();
bom.isMain = true;
@@ -210,7 +267,7 @@ public class UpDataModel {
info2.sort = item.sort;
info2.goodsId = good.id;
info2.deviceId = ConfigName.getInstance().DeviceId;
info2.goodsAttributeId = "默认属性值";
info2.goodsAttributeId = sxid;
update.goodsTechnologyActionInfo.add(info2);
}
}
@@ -222,22 +279,23 @@ public class UpDataModel {
if (isSuceess) {
try {
String str = ConfigName.getInstance().SaasAddress + ConfigName.getInstance().UpdateGoods;
// String str="http://192.168.1.7:5000/api/CommInteface/SendGoodsInfo";
OkGo.<ResAPI<Boolean>>post(str).tag(this)
.upRequestBody(RequestBody.create(MediaType.parse("application/json; charset=utf-8"), new Gson().toJson(update)))
.headers(new HttpHeaders("TenantId", ConfigName.getInstance().organizeMode.companyId))
.execute(new JsonDialogCallback<ResAPI<Boolean>>(context) {
@Override
public void onSuccess(Response<ResAPI<Boolean>> response) {
ResAPI<Boolean> allDataResAPI = response.body();
if (allDataResAPI.succeeded) {
MessageManager.getInstance().sendMessage(MessageName.ScGood, "GoodUpdate");
Status=true;
} else {
ToastUtils.warning("上传菜品失败!!!");
}
}
});
okhttp3.Response result = OkGo.<ResAPI<Boolean>>post(str).tag(this)
.upRequestBody(RequestBody.create(MediaType.parse("application/json; charset=utf-8"), new Gson().toJson(update)))
.headers(new HttpHeaders("TenantId", ConfigName.getInstance().organizeMode.companyId))
.execute();

if(result!=null&&result.isSuccessful()){

APIResult res = new Gson().fromJson(result.body().string(),APIResult.class);
if (res.succeeded) {
MessageManager.getInstance().sendMessage(MessageName.ScGood, "GoodUpdate");
Status=true;
Log.i("sync", "同步成功");
} else {
Log.i("sync", "上传菜品失败,失败原因:"+res.errors);
Status=true;
}
}
} catch (Exception ex) {
ToastUtils.info("上传菜品异常:" + ex.getMessage());
}


+ 317
- 0
app/src/main/java/com/bonait/bnframework/common/helper/BatchSync.java View File

@@ -0,0 +1,317 @@
package com.bonait.bnframework.common.helper;

import android.app.Activity;
import android.content.Context;
import android.util.Log;

import com.bonait.bnframework.common.constant.ConfigName;
import com.bonait.bnframework.common.constant.MessageName;
import com.bonait.bnframework.common.db.QueryDB;
import com.bonait.bnframework.common.db.mode.BPA_GOODS;
import com.bonait.bnframework.common.db.mode.BPA_GOODSRECIPE;
import com.bonait.bnframework.common.helper.I.IRunT;
import com.bonait.bnframework.common.message.MessageManager;
import com.bonait.bnframework.common.model.APIResult;
import com.bonait.bnframework.common.model.ResAPI;
import com.bonait.bnframework.common.model.mode.ActionJsonMode;
import com.bonait.bnframework.common.model.mode.BPA_GoodsAttributeValue;
import com.bonait.bnframework.common.model.mode.BPA_GoodsTechnologyAction;
import com.bonait.bnframework.common.model.mode.BatchingInfo;
import com.bonait.bnframework.common.model.mode.BomTechnologyActionInfo;
import com.bonait.bnframework.common.model.mode.BomTypeInfo;
import com.bonait.bnframework.common.model.mode.CloudGood;
import com.bonait.bnframework.common.model.mode.FoodMenuInfo;
import com.bonait.bnframework.common.model.mode.GoodsParentTypeInfo;
import com.bonait.bnframework.common.model.mode.GoodsTechnology;
import com.bonait.bnframework.common.model.mode.GoodsTypeInfo;
import com.bonait.bnframework.common.model.mode.GoodsUintInfo;
import com.bonait.bnframework.common.model.mode.TechnologyAction;
import com.bonait.bnframework.common.model.mode.UpdateBomInfo;
import com.bonait.bnframework.common.model.mode.UpdateCloudGood;
import com.bonait.bnframework.common.oss.OssHelper;
import com.bonait.bnframework.common.utils.ToastUtils;
import com.google.gson.Gson;
import com.lzy.okgo.OkGo;
import com.lzy.okgo.model.HttpHeaders;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

import okhttp3.MediaType;
import okhttp3.RequestBody;

public class BatchSync {

ArrayList<BPA_GOODS> goods;
private Context context;
private Activity activity;

Map<String,String> map_cp = new LinkedHashMap<>();
Map<String,String> map_dl = new LinkedHashMap<>();
Map<String,String> map_xl = new LinkedHashMap<>();
Map<String,String> map_dw = new LinkedHashMap<>();
Map<String,String> map_fl = new LinkedHashMap<>();
Map<String,String> map_sx = new LinkedHashMap<>();
String sp, dl, xl, dw, fl, sxid;
int CompleteCount=0;
int FaultCount=0;
List<String> FaultGoodName=new ArrayList<>();
public BatchSync(Activity ac, Context ct, ArrayList<BPA_GOODS> bpa_goods){
goods= bpa_goods;
context=ct;
activity=ac;
DataInit();
}
private void DataInit(){
for (FoodMenuInfo item: ConfigName.getInstance().cloudData.foodMenuInfo)
{
map_cp.put(item.name,item.id);
}
for (GoodsParentTypeInfo item:ConfigName.getInstance().cloudData.goodsParentTypeInfo)
{
map_dl.put(item.name,item.id);
}
for (GoodsTypeInfo item:ConfigName.getInstance().cloudData.goodsTypeInfo)
{
map_xl.put(item.goodsType_Name,item.id);
}
for (GoodsUintInfo item:ConfigName.getInstance().cloudData.goodsUintInfo)
{
map_dw.put(item.name,item.id);
}
for (BomTypeInfo item:ConfigName.getInstance().cloudData.bomTypeInfo)
{
map_fl.put(item.name,item.id);
}

for (BPA_GoodsAttributeValue item:ConfigName.getInstance().cloudData.goodsAttributeValue)
{
map_sx.put(item.attributeValue,item.id);
}
sp = map_cp.get("小炒");
dl=map_dl.get("默认分类");
xl=map_xl.get("默认分类");
dw=map_dw.get("默认单位");
fl=map_fl.get("炒菜");
sxid=map_sx.get("默认属性值");
}

public void Start(){
if(context==null)return;
if(goods==null)return;
WaitDialog.Show("商品同步","开始商品同步",context,activity);
for (BPA_GOODS good:goods){
WaitDialog.AddText("总数:"+goods.size()+",成功:"+CompleteCount+",失败:"+FaultCount +"\r\n \r\n正在同步商品:"+good.name);
Log.i("sync", "总数:"+goods.size()+",成功:"+CompleteCount+",失败:"+FaultCount +",正在同步商品:"+good.name);
Boolean isSuceess = false;
try {
final Boolean[] boom = {false};
OssHelper.getInstance().OnCharge = new IRunT() {
@Override
public void Run(Object o) {
ResAPI<String> resAPI = (ResAPI<String>) o;
if (resAPI.succeeded) {
good.url = resAPI.data;
QueryDB.UpdateGoods(good);
}
boom[0] = true;
}
};
if(good.url!=null){
OssHelper.getInstance().UpdataFile(context, good.url);
int time=0;
while (!boom[0]&&time<20) {
Thread.sleep(100);
time++;
}
}
} catch (Exception ex) {
}
UpdateCloudGood update = new UpdateCloudGood();
try {
update.storeId = ConfigName.getInstance().organizeMode.id;
update.deviceId = ConfigName.getInstance().DeviceId;
update.userId = ConfigName.getInstance().user.name;
update.goodsInfo = new CloudGood();
update.bomTechnologyActionInfo = new ArrayList<BomTechnologyActionInfo>();
update.goodsTechnologyActionInfo = new ArrayList<BPA_GoodsTechnologyAction>();

update.goodsInfo.id = good.id;
update.goodsInfo.createAt = good.createTime;
update.goodsInfo.isDeleted = 0;
update.goodsInfo.status = 0;
update.goodsInfo.groupId = ConfigName.getInstance().organizeMode.companyId;
update.goodsInfo.autoKey = 0;
update.goodsInfo.isWeigh = false;
update.goodsInfo.vipPrice = 0;
update.goodsInfo.price = 0;
update.goodsInfo.code = good.id;
update.goodsInfo.goods_Sort = good.sort;
update.goodsInfo.goods_Descritption = "设备上传商品";
update.goodsInfo.goods_Name = good.name;

//选择菜谱 大类id 小类id 单位id
update.foodMenuId = sp;
update.goodsInfo.goods_ImgUrl = good.url;//图片地址
update.goodsInfo.parentTypeID = dl;//大类
update.goodsInfo.goods_TypeID = xl;//小类
update.goodsInfo.goodsUintId = dw;//单位

String id = good.gyid;
if (good.gyid == null) {
id = java.util.UUID.randomUUID().toString();
QueryDB.UpdateGoodsGY(good.id, id);
}
QueryDB.UpdateGoodsTypeId(good.id,"默认分类");

UpdateBomInfo bom = new UpdateBomInfo();
bom.id = id;
bom.bomType = fl;
bom.name = good.name;
bom.code = java.util.UUID.randomUUID().toString();
bom.isMain = true;
bom.sort = 0;
update.bomInfo = bom;

ArrayList<BPA_GOODSRECIPE> goodsrecipes = QueryDB.GetGoodsSrecipeID(good.id);
for (BPA_GOODSRECIPE item : goodsrecipes) {
GoodsTechnology goodsTechnology = null;
for (GoodsTechnology _find : ConfigName.getInstance().cloudData.goodsTechnology) {
if (_find.name.equals(item.processname)) {
goodsTechnology = _find;
break;
}
}

if (goodsTechnology != null) {
//2.根据工序变量集合-获取变量名称和值
List<String> names = new ArrayList<>();
final HashMap<String, String> formulation = new HashMap<>();
//region 获取变量名称和值
String text = item.processvalue;
List<String> data = new ArrayList<>();
if (text.contains("|")) {
String[] res = text.split("[|]");
for (int i = 0; i < res.length; i++) {
data.add(res[i]);
}
} else {
data.add(text);
}
for (String item1 : data) {
if (!item1.isEmpty() && item1.contains(",")) {
String[] wl = item1.split("[,]");
if (wl != null && wl.length == 2) {
String name = wl[0];
String val = wl[1];
names.add(name);
formulation.put(name, val);
}
}
}
//endregion

List<ActionJsonMode> actionJsonModes = new ArrayList<>();
//region 获取工艺集合
if (item.materialType == 0)//物料
{
for (String f : names) {
BatchingInfo batchingInfo = null;
for (BatchingInfo _find : ConfigName.getInstance().cloudData.batchingInfo) {
if (_find.batching_Name.equals(f)) {
batchingInfo = _find;
break;
}
}
ActionJsonMode m = new ActionJsonMode();
m.technologyactionId = batchingInfo != null ? batchingInfo.id :"";//模型id
m.batchingId = "";//物料id
m.actionName = f;
m.actionValue = formulation.get(f);
actionJsonModes.add(m);
}
} else//模型
{
for (String f : names) {
TechnologyAction technologyAction = null;
for (TechnologyAction _find : ConfigName.getInstance().cloudData.technologyAction) {
if (_find.actionName.equals(f) && _find.goodstechnologyId.equals(goodsTechnology.id)) {
technologyAction = _find;
break;
}
}
ActionJsonMode m = new ActionJsonMode();
m.technologyactionId = technologyAction != null ? technologyAction.id : "";//模型id
m.batchingId = "";//物料id
m.actionName = f;
m.actionValue = formulation.get(f);
actionJsonModes.add(m);
}
}
//endregion

BPA_GoodsTechnologyAction info2 = new BPA_GoodsTechnologyAction();
info2.stepName = item.processname;
info2.actionJson = new Gson().toJson(actionJsonModes);
info2.isBatch = (item.materialType == 0 ? false:true);
info2.chnologyId = goodsTechnology.id;//工艺名称id
info2.createAt = item.createTime;
info2.groupId = ConfigName.getInstance().organizeMode.companyId;
info2.id = item.id;
info2.isDeleted = 0;
info2.sort = item.sort;
info2.goodsId = good.id;
info2.deviceId = ConfigName.getInstance().DeviceId;
info2.goodsAttributeId = sxid;
update.goodsTechnologyActionInfo.add(info2);
}
}
isSuceess = true;
} catch (Exception ex) {
isSuceess = false;
ToastUtils.info("上传菜品异常:" + ex.getMessage());
}
if (isSuceess) {
try {
String str = ConfigName.getInstance().SaasAddress + ConfigName.getInstance().UpdateGoods;
okhttp3.Response result = OkGo.<ResAPI<Boolean>>post(str).tag(this)
.upRequestBody(RequestBody.create(MediaType.parse("application/json; charset=utf-8"), new Gson().toJson(update)))
.headers(new HttpHeaders("TenantId", ConfigName.getInstance().organizeMode.companyId))
.execute();

if(result!=null&&result.isSuccessful()){

APIResult res = new Gson().fromJson(result.body().string(),APIResult.class);
if (res.succeeded) {
MessageManager.getInstance().sendMessage(MessageName.ScGood, "GoodUpdate");
CompleteCount++;
Log.i("sync", "同步成功");
} else {
Log.i("sync", "上传菜品失败,失败原因:"+res.errors);
FaultCount++;
FaultGoodName.add(good.name);
}
}
} catch (Exception ex) {
ToastUtils.info("上传菜品异常:" + ex.getMessage());
}
}
}
if(CompleteCount==goods.size()) {
WaitDialog.TimeOut("商品同步完成!成功:"+CompleteCount+",失败:"+FaultCount);
Log.i("sync", "商品同步完成!成功:"+CompleteCount+",失败:"+FaultCount);
}
else{
StringBuffer sb = new StringBuffer();
for (String error:FaultGoodName){
sb.append(error).append("、");
}
WaitDialog.TimeOut("商品同步完成!成功:"+CompleteCount+",失败:"+FaultCount+"\r\n \r\n失败商品:"+sb.toString().substring(0,sb.toString().length()-1));
Log.i("sync", "商品同步完成!成功:"+CompleteCount+",失败:"+FaultCount+"\r\n \r\n失败商品:"+sb.toString().substring(0,sb.toString().length()-1));
}
}

}

+ 66
- 0
app/src/main/java/com/bonait/bnframework/common/helper/WaitDialog.java View File

@@ -0,0 +1,66 @@
package com.bonait.bnframework.common.helper;

import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Context;

import com.bonait.bnframework.common.utils.AlertDialogUtils;
import com.qmuiteam.qmui.widget.dialog.QMUIDialog;
import com.qmuiteam.qmui.widget.dialog.QMUIDialogAction;

public class WaitDialog {
static Context context;
static Activity activity;
static ProgressDialog progressDialog;

public static void Show(String title, String msg, Context _context, Activity _activity){
context=_context;
activity=_activity;
if(context==null) return;
if(activity==null) return;
activity.runOnUiThread(()->{
progressDialog = new ProgressDialog(context);
progressDialog.setTitle(title);
progressDialog.setCancelable(false);
progressDialog.setMessage(msg);
progressDialog.show();
});
}

public static void AddText(String info){
// if(context==null) return;
if(activity==null) return;
if(progressDialog==null) return;
activity.runOnUiThread(()->{ progressDialog.setMessage(info);});
}

public static void Dismiss(){
try{
if(activity!=null) activity.runOnUiThread(()->{if(progressDialog!=null) progressDialog.dismiss();});
else {
if(progressDialog!=null) progressDialog.dismiss();
}
context=null;
activity=null;
}catch (Exception E){

}
}

public static void TimeOut(String info){
if(activity==null) return;
if(progressDialog==null) return;
activity.runOnUiThread(()->{ progressDialog.dismiss();});

activity.runOnUiThread(()->{
AlertDialogUtils.showDialog(context, "提示", info, new QMUIDialogAction.ActionListener() {
@Override
public void onClick(QMUIDialog dialog, int index) {
context=null;
activity=null;
dialog.dismiss();
}
});
});
}
}

+ 14
- 0
app/src/main/java/com/bonait/bnframework/common/model/APIResult.java View File

@@ -0,0 +1,14 @@
package com.bonait.bnframework.common.model;

import kotlin.text.UStringsKt;

public class APIResult {
public int statusCode;
public Object data;
public boolean succeeded;
public String errors;

public Object extras;

public long timestamp;
}

+ 8
- 239
app/src/main/java/com/bonait/bnframework/modules/home/activity/BottomNavigation2Activity.java View File

@@ -11,6 +11,7 @@ import com.bonait.bnframework.common.constant.DataBus;
import com.bonait.bnframework.common.db.QueryDB;
import com.bonait.bnframework.common.db.mode.BPA_GOODS;
import com.bonait.bnframework.common.db.mode.BPA_GOODSRECIPE;
import com.bonait.bnframework.common.helper.BatchSync;
import com.bonait.bnframework.common.helper.HttpServer;
import com.bonait.bnframework.common.helper.I.IRunT;
import com.bonait.bnframework.common.helper.I.IThread;
@@ -20,6 +21,7 @@ import com.bonait.bnframework.common.helper.ThreadManager;
import com.bonait.bnframework.common.http.callback.json.JsonDialogCallback;
import com.bonait.bnframework.common.modbus.ModbusTcpMainServer;
import com.bonait.bnframework.common.modbus.ModbusTcpServer;
import com.bonait.bnframework.common.model.APIResult;
import com.bonait.bnframework.common.model.ResAPI;
import com.bonait.bnframework.common.model.mode.ActionJsonMode;
import com.bonait.bnframework.common.model.mode.BPA_GoodsTechnologyAction;
@@ -95,6 +97,10 @@ public class BottomNavigation2Activity extends BaseActivity {
// test();
// }catch (Exception e){}
// }).start();




if(ConfigName.getInstance().versionSelectionEnum.contains("一拖")){
hs = new HttpServer();
new Thread(()->{
@@ -116,251 +122,14 @@ public class BottomNavigation2Activity extends BaseActivity {
//AliyunIOTManager.getInstance().CloseDev();
super.onDestroy();
}

int count=0;

List<UpDataModel> uds = new ArrayList<>();
private void test(){
if (ConfigName.getInstance().organizeMode == null && ConfigName.getInstance().cloudData != null) {
ToastUtils.warning("无组织信息不能上传,请设置当前店铺信息!!!");
return;
}
ArrayList<BPA_GOODS> goods = QueryDB.GetGoodsALL();
for (BPA_GOODS good:goods){
uds.add(new UpDataModel(this,good));
break;

// Boolean isSuceess = false;
// try {
// final Boolean[] boom = {false};
// OssHelper.getInstance().OnCharge = new IRunT() {
// @Override
// public void Run(Object o) {
// ResAPI<String> resAPI = (ResAPI<String>) o;
// if (resAPI.succeeded) {
// good.url = resAPI.data;
// QueryDB.UpdateGoods(good);
// }
// boom[0] = true;
// }
// };
// if(good.url!=null){
// OssHelper.getInstance().UpdataFile(this, good.url);
// while (!boom[0]) {
// Thread.sleep(100);
// }
// }
// } catch (Exception ex) {
//
// }
// UpdateCloudGood update = new UpdateCloudGood();
// try {
// update.storeId = ConfigName.getInstance().organizeMode.id;
// update.deviceId = ConfigName.getInstance().DeviceId;
// update.userId = ConfigName.getInstance().user.name;
// update.goodsInfo = new CloudGood();
// update.bomTechnologyActionInfo = new ArrayList<BomTechnologyActionInfo>();
// update.goodsTechnologyActionInfo = new ArrayList<BPA_GoodsTechnologyAction>();
//
// update.goodsInfo.id = good.id;
// update.goodsInfo.createAt = good.createTime;
// update.goodsInfo.isDeleted = 0;
// update.goodsInfo.status = 0;
// update.goodsInfo.groupId = ConfigName.getInstance().organizeMode.companyId;
// update.goodsInfo.autoKey = 0;
// update.goodsInfo.isWeigh = false;
// update.goodsInfo.vipPrice = 0;
// update.goodsInfo.price = 0;
// update.goodsInfo.code = good.id;
// update.goodsInfo.goods_Sort = good.sort;
// update.goodsInfo.goods_Descritption = "设备上传商品";
// update.goodsInfo.goods_Name = good.name;
//
// //选择菜谱 大类id 小类id 单位id
// update.foodMenuId = "小炒";
// update.goodsInfo.goods_ImgUrl = good.url;//图片地址
// update.goodsInfo.parentTypeID = "默认分类";//大类
// update.goodsInfo.goods_TypeID = "默认分类";//小类
// update.goodsInfo.goodsUintId = "默认单位";//单位
//
// String id = good.gyid;
// if (good.gyid == null) {
// id = java.util.UUID.randomUUID().toString();
// QueryDB.UpdateGoodsGY(good.id, id);
// }
// QueryDB.UpdateGoodsTypeId(good.id,"默认分类");
//
// UpdateBomInfo bom = new UpdateBomInfo();
// bom.id = id;
// bom.bomType = "炒菜";
// bom.name = good.name;
// bom.code = java.util.UUID.randomUUID().toString();
// bom.isMain = true;
// bom.sort = 0;
// update.bomInfo = bom;
//
// ArrayList<BPA_GOODSRECIPE> goodsrecipes = QueryDB.GetGoodsSrecipeID(good.id);
// for (BPA_GOODSRECIPE item : goodsrecipes) {
// GoodsTechnology goodsTechnology = null;
// for (GoodsTechnology _find : ConfigName.getInstance().cloudData.goodsTechnology) {
// if (_find.name.equals(item.processname)) {
// goodsTechnology = _find;
// break;
// }
// }
//
// if (goodsTechnology != null) {
// //2.根据工序变量集合-获取变量名称和值
// List<String> names = new ArrayList<>();
// final HashMap<String, String> formulation = new HashMap<>();
// //region 获取变量名称和值
// String text = item.processvalue;
// List<String> data = new ArrayList<>();
// if (text.contains("|")) {
// String[] res = text.split("[|]");
// for (int i = 0; i < res.length; i++) {
// data.add(res[i]);
// }
// } else {
// data.add(text);
// }
// for (String item1 : data) {
// if (!item1.isEmpty() && item1.contains(",")) {
// String[] wl = item1.split("[,]");
// if (wl != null && wl.length == 2) {
// String name = wl[0];
// String val = wl[1];
// names.add(name);
// formulation.put(name, val);
// }
// }
// }
// //endregion
//
// List<ActionJsonMode> actionJsonModes = new ArrayList<>();
// //region 获取工艺集合
// if (item.materialType == 0)//物料
// {
// for (String f : names) {
// BatchingInfo batchingInfo = null;
// for (BatchingInfo _find : ConfigName.getInstance().cloudData.batchingInfo) {
// if (_find.batching_Name.equals(f)) {
// batchingInfo = _find;
// break;
// }
// }
// ActionJsonMode m = new ActionJsonMode();
// m.technologyactionId = batchingInfo != null ? batchingInfo.id :"";//模型id
// m.batchingId = "";//物料id
// m.actionName = f;
// m.actionValue = formulation.get(f);
// actionJsonModes.add(m);
// }
// } else//模型
// {
// for (String f : names) {
// TechnologyAction technologyAction = null;
// for (TechnologyAction _find : ConfigName.getInstance().cloudData.technologyAction) {
// if (_find.actionName.equals(f) && _find.goodstechnologyId.equals(goodsTechnology.id)) {
// technologyAction = _find;
// break;
// }
// }
// ActionJsonMode m = new ActionJsonMode();
// m.technologyactionId = technologyAction != null ? technologyAction.id : "";//模型id
// m.batchingId = "";//物料id
// m.actionName = f;
// m.actionValue = formulation.get(f);
// actionJsonModes.add(m);
// }
// }
// //endregion
//
// BPA_GoodsTechnologyAction info2 = new BPA_GoodsTechnologyAction();
// info2.stepName = item.processname;
// info2.actionJson = new Gson().toJson(actionJsonModes);
// info2.isBatch = (item.materialType == 0 ? false:true);
// info2.chnologyId = goodsTechnology.id;//工艺名称id
// info2.createAt = item.createTime;
// info2.groupId = ConfigName.getInstance().organizeMode.companyId;
// info2.id = item.id;
// info2.isDeleted = 0;
// info2.sort = item.sort;
// info2.goodsId = good.id;
// info2.deviceId = ConfigName.getInstance().DeviceId;
// info2.goodsAttributeId = "默认属性值";
// update.goodsTechnologyActionInfo.add(info2);
// }
// }
// isSuceess = true;
// } catch (Exception ex) {
// isSuceess = true;
// ToastUtils.info("上传菜品异常:" + ex.getMessage());
// }
//
//
// if (isSuceess) {
// try {
// String str = ConfigName.getInstance().SaasAddress + ConfigName.getInstance().UpdateGoods;
// // String str="http://192.168.1.7:5000/api/CommInteface/SendGoodsInfo";
//
//
//
// okhttp3.Response res = OkGo.<ResAPI<Boolean>>post(str).tag(this)
// .upRequestBody(RequestBody.create(MediaType.parse("application/json; charset=utf-8"), new Gson().toJson(update)))
// .headers(new HttpHeaders("TenantId", ConfigName.getInstance().organizeMode.companyId))
// .execute();
// if(res.isSuccessful()){
// count++;
// Log.i("count", "onSuccess: "+count);
// }
//
//
//// OkGo.<ResAPI<Boolean>>post(str).tag(this)
//// .upRequestBody(RequestBody.create(MediaType.parse("application/json; charset=utf-8"), new Gson().toJson(update)))
//// .headers(new HttpHeaders("TenantId", ConfigName.getInstance().organizeMode.companyId))
//// .execute(new JsonDialogCallback<ResAPI<Boolean>>(this) {
//// @Override
//// public void onSuccess(Response<ResAPI<Boolean>> response) {
//// ResAPI<Boolean> allDataResAPI = response.body();
//// if (allDataResAPI.succeeded) {
//// count++;
//// ToastUtils.info("上传菜品成功!!!"+count);
//// Log.i("count", "onSuccess: "+count);
//// MessageManager.getInstance().sendMessage(MessageName.ScGood, "GoodUpdate");
//// } else {
//// ToastUtils.warning("上传菜品失败!!!");
//// }
//// }
//// });
// } catch (Exception ex) {
// ToastUtils.info("上传菜品异常:" + ex.getMessage());
// }
// }

}
for(UpDataModel item:uds){
item.Start();
break;
}

new Thread(()->{
try {
while (true){
int count=0;
for (UpDataModel item:uds){
if(item.Status)count++;
}
if(count==uds.size())break;
Thread.sleep(1000);
}
Log.i("tongbu", "test: 同步完成");
uds.clear();
}catch (Exception e){

}
}).start();

BatchSync bs = new BatchSync(this,this,goods);
bs.Start();
}




Loading…
Cancel
Save