|
|
@@ -33,6 +33,8 @@ import com.bonait.bnframework.common.modbus.ModbusTcpHelper; |
|
|
|
import com.bonait.bnframework.common.modbus.ModbusTcpServer; |
|
|
|
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.BomTechnologyActionInfo; |
|
|
|
import com.bonait.bnframework.common.model.mode.BomTypeInfo; |
|
|
|
import com.bonait.bnframework.common.model.mode.ProcessT; |
|
|
@@ -284,6 +286,8 @@ public class ConfigData { |
|
|
|
ConfigName.getInstance().cloudData.goodsUintInfo = new Json<GoodsUintInfo>().jsonToListobject(GoodsUintInfo.class, item.text); |
|
|
|
} else if (item.name.equals("配方分类")) { |
|
|
|
ConfigName.getInstance().cloudData.bomTypeInfo = new Json<BomTypeInfo>().jsonToListobject(BomTypeInfo.class, item.text); |
|
|
|
} else if (item.name.equals("商品属性")) { |
|
|
|
ConfigName.getInstance().cloudData.goodsAttributeValue = new Json<BomTypeInfo>().jsonToListobject(BPA_GoodsAttributeValue.class, item.text); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@@ -300,27 +304,27 @@ public class ConfigData { |
|
|
|
OkGo.<ResAPI<OrganizeMode>>get(ConfigName.getInstance().SaasAddress + ConfigName.getInstance().GetStore + ConfigName.getInstance().ClientAutoKey) |
|
|
|
.tag(context) |
|
|
|
.execute(new JsonDialogCallback<ResAPI<OrganizeMode>>(context) { |
|
|
|
@Override |
|
|
|
public void onSuccess(Response<ResAPI<OrganizeMode>> response) { |
|
|
|
ResAPI<OrganizeMode> organize = response.body(); |
|
|
|
if (organize.isSuccess) { |
|
|
|
ConfigName.getInstance().organizeMode = organize.data; |
|
|
|
OkGo.<ResAPI<DeviceInformation>>get(String.format(ConfigName.getInstance().SaasAddress + ConfigName.getInstance().GetDeviceInformation, ConfigName.getInstance().organizeMode.id, ConfigName.getInstance().DeviceAutoKey)).tag(context).headers(new HttpHeaders("TenantId", ConfigName.getInstance().organizeMode.companyId)).execute(new JsonDialogCallback<ResAPI<DeviceInformation>>(context) { |
|
|
|
@Override |
|
|
|
public void onSuccess(Response<ResAPI<DeviceInformation>> response) { |
|
|
|
ResAPI<DeviceInformation> deviceInformation = response.body(); |
|
|
|
if (deviceInformation.succeeded) { |
|
|
|
ConfigName.getInstance().deviceInformation = deviceInformation.data; |
|
|
|
if (ConfigName.getInstance().deviceInformation != null) { |
|
|
|
ConfigName.getInstance().DeviceId = ConfigName.getInstance().deviceInformation.id; |
|
|
|
MessageManager.getInstance().sendMessage(MessageName.GetOrganize, "GetOrganize"); |
|
|
|
@Override |
|
|
|
public void onSuccess(Response<ResAPI<OrganizeMode>> response) { |
|
|
|
ResAPI<OrganizeMode> organize = response.body(); |
|
|
|
if (organize.isSuccess) { |
|
|
|
ConfigName.getInstance().organizeMode = organize.data; |
|
|
|
OkGo.<ResAPI<DeviceInformation>>get(String.format(ConfigName.getInstance().SaasAddress + ConfigName.getInstance().GetDeviceInformation, ConfigName.getInstance().organizeMode.id, ConfigName.getInstance().DeviceAutoKey)).tag(context).headers(new HttpHeaders("TenantId", ConfigName.getInstance().organizeMode.companyId)).execute(new JsonDialogCallback<ResAPI<DeviceInformation>>(context) { |
|
|
|
@Override |
|
|
|
public void onSuccess(Response<ResAPI<DeviceInformation>> response) { |
|
|
|
ResAPI<DeviceInformation> deviceInformation = response.body(); |
|
|
|
if (deviceInformation.succeeded) { |
|
|
|
ConfigName.getInstance().deviceInformation = deviceInformation.data; |
|
|
|
if (ConfigName.getInstance().deviceInformation != null) { |
|
|
|
ConfigName.getInstance().DeviceId = ConfigName.getInstance().deviceInformation.id; |
|
|
|
MessageManager.getInstance().sendMessage(MessageName.GetOrganize, "GetOrganize"); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
}); |
|
|
|
} else { |
|
|
|
ToastUtils.warning("无网络,请先连接网络!!!"); |
|
|
|
} |
|
|
@@ -479,6 +483,14 @@ public class ConfigData { |
|
|
|
QueryDB.AddClouddata(data); |
|
|
|
} |
|
|
|
|
|
|
|
if (allDataResAPI.data.goodsAttributeValue != null) { |
|
|
|
data = new BPA_CLOUDDATA(); |
|
|
|
data.id = java.util.UUID.randomUUID().toString(); |
|
|
|
data.name = "商品属性"; |
|
|
|
data.text = new Gson().toJson(allDataResAPI.data.goodsAttributeValue); |
|
|
|
QueryDB.AddClouddata(data); |
|
|
|
} |
|
|
|
|
|
|
|
Message msg = new Message(); |
|
|
|
msg.obj = "MSG_REFRESH"; |
|
|
|
mHandler.sendMessage(msg); |
|
|
@@ -507,8 +519,7 @@ public class ConfigData { |
|
|
|
ResAPI<List<CloudGood>> allDataResAPI = response.body(); |
|
|
|
if (allDataResAPI.succeeded && allDataResAPI.data != null && allDataResAPI.data.size() > 0) { |
|
|
|
ConfigName.getInstance().cloudGoods = allDataResAPI.data; |
|
|
|
if(mHandler!=null) |
|
|
|
{ |
|
|
|
if (mHandler != null) { |
|
|
|
Message msg = new Message(); |
|
|
|
msg.obj = "MSG_REFRESH"; |
|
|
|
mHandler.sendMessage(msg); |
|
|
@@ -526,7 +537,7 @@ public class ConfigData { |
|
|
|
* |
|
|
|
* @param context |
|
|
|
*/ |
|
|
|
public void GetGoodProcess(Context context, String goodid,Boolean isSX) { |
|
|
|
public void GetGoodProcess(Context context, String goodid, Boolean isSX) { |
|
|
|
Boolean IsXZ = QueryDB.GetGoodsIDIs(goodid); |
|
|
|
if (IsXZ) { |
|
|
|
ToastUtils.warning("请勿重复下载,本地商品已存在!!!"); |
|
|
@@ -537,7 +548,7 @@ public class ConfigData { |
|
|
|
if (ConfigName.getInstance().organizeMode == null) { |
|
|
|
return; |
|
|
|
} |
|
|
|
OkGo.<ResAPI<ResGoodProcess>>get(String.format(ConfigName.getInstance().SaasAddress + ConfigName.getInstance().GetGoodsBom, goodid)).tag(context).headers(new HttpHeaders("TenantId", ConfigName.getInstance().organizeMode.companyId)).execute(new JsonDialogCallback<ResAPI<ResGoodProcess>>(context) { |
|
|
|
OkGo.<ResAPI<ResGoodProcess>>get(String.format(ConfigName.getInstance().SaasAddress + ConfigName.getInstance().GetGoodsBom, goodid, ConfigName.getInstance().DeviceId)).tag(context).headers(new HttpHeaders("TenantId", ConfigName.getInstance().organizeMode.companyId)).execute(new JsonDialogCallback<ResAPI<ResGoodProcess>>(context) { |
|
|
|
@Override |
|
|
|
public void onSuccess(Response<ResAPI<ResGoodProcess>> response) { |
|
|
|
ResAPI<ResGoodProcess> allDataResAPI = response.body(); |
|
|
@@ -562,61 +573,122 @@ public class ConfigData { |
|
|
|
good.issc = 0; |
|
|
|
good.url = cloudGood.goods_ImgUrl; |
|
|
|
good.exp = "云端商品"; |
|
|
|
good.gyid=allDataResAPI.data.bomInfo.get(0).id; |
|
|
|
good.gyid=""; |
|
|
|
if(allDataResAPI.data.bomInfo!=null && allDataResAPI.data.bomInfo.size()>0) |
|
|
|
{ |
|
|
|
good.gyid =allDataResAPI.data.bomInfo.get(0).id; |
|
|
|
} |
|
|
|
QueryDB.AddGoods(good); |
|
|
|
//2.增加配方 |
|
|
|
if (allDataResAPI.data.bomTechnologyActionInfo != null && allDataResAPI.data.bomTechnologyActionInfo.size() > 0) { |
|
|
|
List<BomTechnologyActionInfo> bayc = allDataResAPI.data.bomTechnologyActionInfo; |
|
|
|
Collections.sort(bayc, new Comparator<BomTechnologyActionInfo>() { |
|
|
|
// if (allDataResAPI.data.bomTechnologyActionInfo != null && allDataResAPI.data.bomTechnologyActionInfo.size() > 0) { |
|
|
|
// List<BomTechnologyActionInfo> bayc = allDataResAPI.data.bomTechnologyActionInfo; |
|
|
|
// Collections.sort(bayc, new Comparator<BomTechnologyActionInfo>() { |
|
|
|
// @Override |
|
|
|
// public int compare(BomTechnologyActionInfo o1, BomTechnologyActionInfo o2) { |
|
|
|
// |
|
|
|
// return Double.valueOf(o1.sort).compareTo(Double.valueOf(o2.sort)); |
|
|
|
// } |
|
|
|
// }); |
|
|
|
// for (BomTechnologyActionInfo k : allDataResAPI.data.bomTechnologyActionInfo) { |
|
|
|
// BPA_GOODSRECIPE item = new BPA_GOODSRECIPE(); |
|
|
|
// item.goodsID = good.id; |
|
|
|
// item.sort = k.sort; |
|
|
|
// if(k.stepName.contains("液体料")) |
|
|
|
// { |
|
|
|
// item.processname="液体料"; |
|
|
|
// }else if(k.stepName.contains("搅拌")) |
|
|
|
// { |
|
|
|
// item.processname="搅拌"; |
|
|
|
// }else if(k.stepName.contains("位置")) |
|
|
|
// { |
|
|
|
// item.processname="位置"; |
|
|
|
// }else if(k.stepName.contains("加热")) |
|
|
|
// { |
|
|
|
// item.processname="加热"; |
|
|
|
// }else if(k.stepName.contains("主料")) |
|
|
|
// { |
|
|
|
// item.processname="主料"; |
|
|
|
// }else if(k.stepName.contains("延迟")) |
|
|
|
// { |
|
|
|
// item.processname="延迟"; |
|
|
|
// }else if(k.stepName.contains("出菜")) |
|
|
|
// { |
|
|
|
// item.processname="出菜"; |
|
|
|
// }else |
|
|
|
// { |
|
|
|
// item.processname = k.stepName; |
|
|
|
// } |
|
|
|
// |
|
|
|
// if (!k.actionJson.isEmpty()) { |
|
|
|
// String data = ""; |
|
|
|
// String desc = ""; |
|
|
|
// boolean iswl = false; |
|
|
|
// List<ActionJsonMode> gyActions = new Json<List<ActionJsonMode>>().jsonToListobject(ActionJsonMode.class, ((String) k.actionJson)); |
|
|
|
// for (ActionJsonMode m : gyActions) { |
|
|
|
// if(m.ActionName!=null && m.ActionValue!="") |
|
|
|
// { |
|
|
|
// data += m.ActionName + "," + m.ActionValue + "|"; |
|
|
|
// desc += m.ActionValue + ","; |
|
|
|
// if (!m.BatchingId.isEmpty()) { |
|
|
|
// iswl = true; |
|
|
|
// } |
|
|
|
// } |
|
|
|
// } |
|
|
|
// if (data.contains("|")) { |
|
|
|
// item.processvalue = data.substring(0, data.length() - 1); |
|
|
|
// } |
|
|
|
// if (desc.contains(",")) { |
|
|
|
// item.processms = item.processname + "(" + desc.substring(0, desc.length() - 1) + ")"; |
|
|
|
// } |
|
|
|
// item.materialType = iswl ? 0 : 1; |
|
|
|
// } |
|
|
|
// QueryDB.AddGoodsSrecipe(item); |
|
|
|
// } |
|
|
|
// } |
|
|
|
|
|
|
|
if (allDataResAPI.data.goodsTechnologyActionInfo != null && allDataResAPI.data.goodsTechnologyActionInfo.size() > 0) { |
|
|
|
List<BPA_GoodsTechnologyAction> bayc = allDataResAPI.data.goodsTechnologyActionInfo; |
|
|
|
Collections.sort(bayc, new Comparator<BPA_GoodsTechnologyAction>() { |
|
|
|
@Override |
|
|
|
public int compare(BomTechnologyActionInfo o1, BomTechnologyActionInfo o2) { |
|
|
|
public int compare(BPA_GoodsTechnologyAction o1, BPA_GoodsTechnologyAction o2) { |
|
|
|
|
|
|
|
return Double.valueOf(o1.sort).compareTo(Double.valueOf(o2.sort)); |
|
|
|
} |
|
|
|
}); |
|
|
|
for (BomTechnologyActionInfo k : allDataResAPI.data.bomTechnologyActionInfo) { |
|
|
|
for (BPA_GoodsTechnologyAction k : allDataResAPI.data.goodsTechnologyActionInfo) { |
|
|
|
BPA_GOODSRECIPE item = new BPA_GOODSRECIPE(); |
|
|
|
item.goodsID = good.id; |
|
|
|
item.sort = k.sort; |
|
|
|
if(k.stepName.contains("液体料")) |
|
|
|
{ |
|
|
|
item.processname="液体料"; |
|
|
|
}else if(k.stepName.contains("搅拌")) |
|
|
|
{ |
|
|
|
item.processname="搅拌"; |
|
|
|
}else if(k.stepName.contains("位置")) |
|
|
|
{ |
|
|
|
item.processname="位置"; |
|
|
|
}else if(k.stepName.contains("加热")) |
|
|
|
{ |
|
|
|
item.processname="加热"; |
|
|
|
}else if(k.stepName.contains("主料")) |
|
|
|
{ |
|
|
|
item.processname="主料"; |
|
|
|
}else if(k.stepName.contains("延迟")) |
|
|
|
{ |
|
|
|
item.processname="延迟"; |
|
|
|
}else if(k.stepName.contains("出菜")) |
|
|
|
{ |
|
|
|
item.processname="出菜"; |
|
|
|
}else |
|
|
|
{ |
|
|
|
if (k.stepName.contains("液体料")) { |
|
|
|
item.processname = "液体料"; |
|
|
|
} else if (k.stepName.contains("搅拌")) { |
|
|
|
item.processname = "搅拌"; |
|
|
|
} else if (k.stepName.contains("位置")) { |
|
|
|
item.processname = "位置"; |
|
|
|
} else if (k.stepName.contains("加热")) { |
|
|
|
item.processname = "加热"; |
|
|
|
} else if (k.stepName.contains("主料")) { |
|
|
|
item.processname = "主料"; |
|
|
|
} else if (k.stepName.contains("延迟")) { |
|
|
|
item.processname = "延迟"; |
|
|
|
} else if (k.stepName.contains("出菜")) { |
|
|
|
item.processname = "出菜"; |
|
|
|
} else { |
|
|
|
item.processname = k.stepName; |
|
|
|
} |
|
|
|
|
|
|
|
if (!k.actionJson.isEmpty()) { |
|
|
|
String data = ""; |
|
|
|
String desc = ""; |
|
|
|
boolean iswl = false; |
|
|
|
//boolean iswl = false; |
|
|
|
List<ActionJsonMode> gyActions = new Json<List<ActionJsonMode>>().jsonToListobject(ActionJsonMode.class, ((String) k.actionJson)); |
|
|
|
for (ActionJsonMode m : gyActions) { |
|
|
|
if(m.ActionName!=null && m.ActionValue!="") |
|
|
|
{ |
|
|
|
data += m.ActionName + "," + m.ActionValue + "|"; |
|
|
|
desc += m.ActionValue + ","; |
|
|
|
if (!m.BatchingId.isEmpty()) { |
|
|
|
iswl = true; |
|
|
|
} |
|
|
|
if (m.actionName != null && m.actionValue != "") { |
|
|
|
data += m.actionName + "," + m.actionValue + "|"; |
|
|
|
desc += m.actionValue + ","; |
|
|
|
// if (!m.batchingId.isEmpty()) { |
|
|
|
// iswl = true; |
|
|
|
// } |
|
|
|
} |
|
|
|
} |
|
|
|
if (data.contains("|")) { |
|
|
@@ -625,15 +697,14 @@ public class ConfigData { |
|
|
|
if (desc.contains(",")) { |
|
|
|
item.processms = item.processname + "(" + desc.substring(0, desc.length() - 1) + ")"; |
|
|
|
} |
|
|
|
item.materialType = iswl ? 0 : 1; |
|
|
|
item.materialType =k.isBatch ? 1 : 0; |
|
|
|
} |
|
|
|
QueryDB.AddGoodsSrecipe(item); |
|
|
|
} |
|
|
|
} |
|
|
|
ToastUtils.info("下载菜品成功!!!"); |
|
|
|
|
|
|
|
if(isSX) |
|
|
|
{ |
|
|
|
if (isSX) { |
|
|
|
MessageManager.getInstance().sendMessage(MessageName.ScGood, "Good"); |
|
|
|
} |
|
|
|
} |
|
|
@@ -659,209 +730,265 @@ public class ConfigData { |
|
|
|
ToastUtils.warning("无组织信息不能上传,请设置当前店铺信息!!!"); |
|
|
|
return; |
|
|
|
} |
|
|
|
final GoodEditDialog editDialog = new GoodEditDialog(context); |
|
|
|
editDialog.setTitle("上传菜谱界面"); |
|
|
|
editDialog.setYesOnclickListener("确定", new GoodEditDialog.onYesOnclickListener() { |
|
|
|
@Override |
|
|
|
public void onYesClick(String sp, String dl, String xl, String dw, String fl) { |
|
|
|
|
|
|
|
Boolean isSuceess = false; |
|
|
|
BPA_GOODS good = QueryDB.GetGoodsId(goodid); |
|
|
|
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) |
|
|
|
BPA_GOODS good = QueryDB.GetGoodsId(goodid);//ConfigName.getInstance().SaasAddress |
|
|
|
OkGo.<ResAPI<List<CloudGood>>>get(String.format(ConfigName.getInstance().SaasAddress + ConfigName.getInstance().GetGoodIsCloud, good.name)) |
|
|
|
.tag(context) |
|
|
|
.tag(context).headers(new HttpHeaders("TenantId", ConfigName.getInstance().organizeMode.companyId)) |
|
|
|
.execute(new JsonDialogCallback<ResAPI<List<CloudGood>>>(context) { |
|
|
|
@Override |
|
|
|
public void onSuccess(Response<ResAPI<List<CloudGood>>> response) { |
|
|
|
ResAPI<List<CloudGood>> organize = response.body(); |
|
|
|
//商品配方 |
|
|
|
if (organize.data.isEmpty()) { |
|
|
|
|
|
|
|
} else { |
|
|
|
CloudGood good_p= organize.data.get(0); |
|
|
|
if(!good.id.equals(good_p.id)) //如果商品id 不一致 需要删除商品并且新建商品 |
|
|
|
{ |
|
|
|
good.url=resAPI.data; |
|
|
|
QueryDB.UpdateGoods(good); |
|
|
|
QueryDB.DeleteGoods(good); |
|
|
|
|
|
|
|
ArrayList<BPA_GOODSRECIPE> goodsrecipes1 = QueryDB.GetGoodsSrecipeID(good.id); |
|
|
|
for (BPA_GOODSRECIPE k:goodsrecipes1) |
|
|
|
{ |
|
|
|
QueryDB.DeleteGoodsSrecipe(k); |
|
|
|
k.goodsID=good_p.id; |
|
|
|
QueryDB.AddGoodsSrecipe(k); |
|
|
|
} |
|
|
|
|
|
|
|
good.id =good_p.id; |
|
|
|
QueryDB.AddGoods(good); |
|
|
|
} |
|
|
|
boom[0] =true; |
|
|
|
} |
|
|
|
}; |
|
|
|
OssHelper.getInstance().UpdataFile(context,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.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); |
|
|
|
} |
|
|
|
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; |
|
|
|
//创建商品bom清单 |
|
|
|
if(good.gyid == null && good_p.goodsBomInfo!=null && good_p.goodsBomInfo.size()>0) |
|
|
|
{ |
|
|
|
good.gyid =good_p.goodsBomInfo.get(0).bomId; |
|
|
|
QueryDB.UpdateGoodsGY(good.id, good.gyid); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
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; |
|
|
|
final GoodEditDialog editDialog = new GoodEditDialog(context); |
|
|
|
editDialog.setTitle("上传菜谱界面"); |
|
|
|
editDialog.setYesOnclickListener("确定", new GoodEditDialog.onYesOnclickListener() { |
|
|
|
@Override |
|
|
|
public void onYesClick(String sp, String dl, String xl, String dw, String fl, String sxid) { |
|
|
|
|
|
|
|
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); |
|
|
|
while (!boom[0]) { |
|
|
|
Thread.sleep(100); |
|
|
|
} |
|
|
|
} |
|
|
|
ActionJsonMode m = new ActionJsonMode(); |
|
|
|
m.TechnologyactionId = "";//模型id |
|
|
|
m.BatchingId = batchingInfo != null ? batchingInfo.id : "";//物料id |
|
|
|
m.ActionName = f; |
|
|
|
m.ActionValue = formulation.get(f); |
|
|
|
actionJsonModes.add(m); |
|
|
|
} catch (Exception ex) { |
|
|
|
|
|
|
|
} |
|
|
|
} 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; |
|
|
|
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); |
|
|
|
} |
|
|
|
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 |
|
|
|
|
|
|
|
// BomTechnologyActionInfo info = new BomTechnologyActionInfo(); |
|
|
|
// info.stepName = item.processname; |
|
|
|
// info.actionJson = new Gson().toJson(actionJsonModes); |
|
|
|
// info.isBatch = (item.materialType == 0 ? true : false); |
|
|
|
// info.chnologyId = goodsTechnology.id;//工艺名称id |
|
|
|
// info.createAt = item.createTime; |
|
|
|
// info.groupId = ConfigName.getInstance().organizeMode.companyId; |
|
|
|
// info.id = item.id; |
|
|
|
// info.isDeleted = 0; |
|
|
|
// info.sort = item.sort; |
|
|
|
// info.bomId=bom.id; |
|
|
|
// update.bomTechnologyActionInfo.add(info); |
|
|
|
|
|
|
|
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); |
|
|
|
} |
|
|
|
} |
|
|
|
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); |
|
|
|
isSuceess = true; |
|
|
|
} catch (Exception ex) { |
|
|
|
isSuceess = true; |
|
|
|
ToastUtils.info("上传菜品异常:" + ex.getMessage()); |
|
|
|
} |
|
|
|
} |
|
|
|
//endregion |
|
|
|
|
|
|
|
BomTechnologyActionInfo info = new BomTechnologyActionInfo(); |
|
|
|
info.stepName = item.processname; |
|
|
|
info.actionJson = new Gson().toJson(actionJsonModes); |
|
|
|
info.isBatch = (item.materialType == 0 ? true : false); |
|
|
|
info.chnologyId = goodsTechnology.id;//工艺名称id |
|
|
|
info.createAt = item.createTime; |
|
|
|
info.groupId = ConfigName.getInstance().organizeMode.companyId; |
|
|
|
info.id = item.id; |
|
|
|
info.isDeleted = 0; |
|
|
|
info.sort = item.sort; |
|
|
|
info.bomId=bom.id; |
|
|
|
update.bomTechnologyActionInfo.add(info); |
|
|
|
} |
|
|
|
} |
|
|
|
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.64:5001/api/CommInteface/SendGoodsInfo"; |
|
|
|
OkGo.<ResAPI<Boolean>>post(str).tag(context).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) { |
|
|
|
ToastUtils.info("上传菜品成功!!!"); |
|
|
|
MessageManager.getInstance().sendMessage(MessageName.ScGood, "GoodUpdate"); |
|
|
|
editDialog.dismiss(); |
|
|
|
} else { |
|
|
|
ToastUtils.warning("上传菜品失败!!!"); |
|
|
|
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(context).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) { |
|
|
|
ToastUtils.info("上传菜品成功!!!"); |
|
|
|
MessageManager.getInstance().sendMessage(MessageName.ScGood, "GoodUpdate"); |
|
|
|
editDialog.dismiss(); |
|
|
|
} else { |
|
|
|
ToastUtils.warning("上传菜品失败!!!"); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
} catch (Exception ex) { |
|
|
|
ToastUtils.info("上传菜品异常:" + ex.getMessage()); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
} catch (Exception ex) { |
|
|
|
ToastUtils.info("上传菜品异常:" + ex.getMessage()); |
|
|
|
editDialog.setNoOnclickListener("取消", new GoodEditDialog.onNoOnclickListener() { |
|
|
|
@Override |
|
|
|
public void onNoClick() { |
|
|
|
editDialog.dismiss(); |
|
|
|
} |
|
|
|
}); |
|
|
|
editDialog.show(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
editDialog.setNoOnclickListener("取消", new GoodEditDialog.onNoOnclickListener() { |
|
|
|
@Override |
|
|
|
public void onNoClick() { |
|
|
|
editDialog.dismiss(); |
|
|
|
} |
|
|
|
}); |
|
|
|
editDialog.show(); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
} else { |
|
|
|
ToastUtils.warning("无网络,请先连接网络!!!"); |
|
|
|
} |
|
|
@@ -875,7 +1002,7 @@ public class ConfigData { |
|
|
|
public void AddImage(Context context) { |
|
|
|
BitmapFactory.Options options = new BitmapFactory.Options(); |
|
|
|
//options.inSampleSize = 2;//宽高压缩为原来的1/2 |
|
|
|
options.inPreferredConfig=Bitmap.Config.RGB_565; |
|
|
|
options.inPreferredConfig = Bitmap.Config.RGB_565; |
|
|
|
|
|
|
|
Bitmap bitmap1 = BitmapFactory.decodeResource(context.getResources(), R.mipmap.image1, options); |
|
|
|
Bitmap bitmap2 = BitmapFactory.decodeResource(context.getResources(), R.mipmap.image2, options); |
|
|
@@ -905,14 +1032,13 @@ public class ConfigData { |
|
|
|
List<Res_PLCADDRESS> plcaddresses = ConfigName.getInstance().PlcAddress_大炒; |
|
|
|
List<ProcessT> processTS = ConfigName.getInstance().Process_大炒; |
|
|
|
|
|
|
|
if(ConfigName.getInstance().versionSelectionEnum.equals("大炒版本")) |
|
|
|
{ |
|
|
|
if (ConfigName.getInstance().versionSelectionEnum.equals("大炒版本")) { |
|
|
|
plcaddresses = ConfigName.getInstance().PlcAddress_大炒; |
|
|
|
processTS = ConfigName.getInstance().Process_大炒; |
|
|
|
} else if (ConfigName.getInstance().versionSelectionEnum.equals("大炒自动投料版本")) { |
|
|
|
plcaddresses = ConfigName.getInstance().PlcAddress_大炒自动投料; |
|
|
|
processTS = ConfigName.getInstance().Process_大炒自动投料; |
|
|
|
}else if (ConfigName.getInstance().versionSelectionEnum.equals("小炒版本")) { |
|
|
|
} else if (ConfigName.getInstance().versionSelectionEnum.equals("小炒版本")) { |
|
|
|
plcaddresses = ConfigName.getInstance().PlcAddress_小炒; |
|
|
|
processTS = ConfigName.getInstance().Process_小炒; |
|
|
|
} |
|
|
@@ -958,7 +1084,7 @@ public class ConfigData { |
|
|
|
processModel.processid = process.id; |
|
|
|
processModel.name = item; |
|
|
|
processModel.sort = chidindex; |
|
|
|
processModel.data=ConfigName.getInstance().GetProcessTypeVal(item); |
|
|
|
processModel.data = ConfigName.getInstance().GetProcessTypeVal(item); |
|
|
|
processModel.datatype = ((item.equals("主料名称") ? 1 : (processModel.data.isEmpty() ? 0 : 2))); |
|
|
|
QueryDB.AddProcessModel(processModel); |
|
|
|
chidindex++; |
|
|
@@ -974,6 +1100,7 @@ public class ConfigData { |
|
|
|
//endregion |
|
|
|
|
|
|
|
//region PLC初始化 |
|
|
|
|
|
|
|
/** |
|
|
|
* 连接PLC |
|
|
|
*/ |
|
|
@@ -989,13 +1116,15 @@ public class ConfigData { |
|
|
|
} |
|
|
|
}).start(); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 关闭PLC |
|
|
|
*/ |
|
|
|
public void ColsePLC() { |
|
|
|
ModbusTcpHelper.get().release();//释放modbus |
|
|
|
ConfigName.getInstance().PlcIsConnect=false; |
|
|
|
ConfigName.getInstance().PlcIsConnect = false; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* PLC初始化完成时,需要注册的服务 |
|
|
|
*/ |
|
|
|