|
|
@@ -19,6 +19,7 @@ import com.bonait.bnframework.common.db.mode.BPA_PROCESS; |
|
|
|
import com.bonait.bnframework.common.db.mode.BPA_PROCESSModel; |
|
|
|
import com.bonait.bnframework.common.db.mode.BPA_SYSTEMSET; |
|
|
|
import com.bonait.bnframework.common.db.mode.Res_PLCADDRESS; |
|
|
|
import com.bonait.bnframework.common.db.res.ResGoodsRecipe; |
|
|
|
import com.bonait.bnframework.common.helper.ConfigUtil; |
|
|
|
import com.bonait.bnframework.common.helper.Json; |
|
|
|
import com.bonait.bnframework.common.http.callback.json.JsonDialogCallback; |
|
|
@@ -42,6 +43,8 @@ import com.bonait.bnframework.common.model.mode.GoodsUintInfo; |
|
|
|
import com.bonait.bnframework.common.model.mode.OrganizeMode; |
|
|
|
import com.bonait.bnframework.common.model.mode.ResALLData; |
|
|
|
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.utils.NetworkUtils; |
|
|
|
import com.bonait.bnframework.common.utils.ToastUtils; |
|
|
|
import com.google.gson.Gson; |
|
|
@@ -55,10 +58,14 @@ import java.util.Arrays; |
|
|
|
import java.util.Collections; |
|
|
|
import java.util.Comparator; |
|
|
|
import java.util.Date; |
|
|
|
import java.util.HashMap; |
|
|
|
import java.util.IdentityHashMap; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Map; |
|
|
|
|
|
|
|
import okhttp3.MediaType; |
|
|
|
import okhttp3.RequestBody; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* 主函数进程 |
|
|
@@ -224,28 +231,21 @@ public class ConfigData { |
|
|
|
ConfigName.getInstance().cloudData = new ResALLData(); |
|
|
|
for (BPA_CLOUDDATA item : data) { |
|
|
|
if (item.name.equals("物料集合")) { |
|
|
|
ConfigName.getInstance().cloudData.batchingInfo = |
|
|
|
new Json<BatchingInfo>().jsonToListobject(BatchingInfo.class, item.text); |
|
|
|
ConfigName.getInstance().cloudData.batchingInfo = new Json<BatchingInfo>().jsonToListobject(BatchingInfo.class, item.text); |
|
|
|
} else if (item.name.equals("工艺模型")) { |
|
|
|
ConfigName.getInstance().cloudData.goodsTechnology = |
|
|
|
new Json<GoodsTechnology>().jsonToListobject(GoodsTechnology.class, item.text); |
|
|
|
ConfigName.getInstance().cloudData.goodsTechnology = new Json<GoodsTechnology>().jsonToListobject(GoodsTechnology.class, item.text); |
|
|
|
} else if (item.name.equals("工艺模型详细信息")) { |
|
|
|
ConfigName.getInstance().cloudData.technologyAction = |
|
|
|
new Json<TechnologyAction>().jsonToListobject(TechnologyAction.class, item.text); |
|
|
|
ConfigName.getInstance().cloudData.technologyAction = new Json<TechnologyAction>().jsonToListobject(TechnologyAction.class, item.text); |
|
|
|
} else if (item.name.equals("菜谱信息")) { |
|
|
|
ConfigName.getInstance().cloudData.foodMenuInfo = |
|
|
|
new Json<FoodMenuInfo>().jsonToListobject(FoodMenuInfo.class, item.text); |
|
|
|
ConfigName.getInstance().cloudData.foodMenuInfo = new Json<FoodMenuInfo>().jsonToListobject(FoodMenuInfo.class, item.text); |
|
|
|
} else if (item.name.equals("商品小类")) { |
|
|
|
ConfigName.getInstance().cloudData.goodsTypeInfo = |
|
|
|
new Json<GoodsTypeInfo>().jsonToListobject(GoodsTypeInfo.class, item.text); |
|
|
|
ConfigName.getInstance().cloudData.goodsTypeInfo = new Json<GoodsTypeInfo>().jsonToListobject(GoodsTypeInfo.class, item.text); |
|
|
|
|
|
|
|
} else if (item.name.equals("商品大类")) { |
|
|
|
ConfigName.getInstance().cloudData.goodsParentTypeInfo = |
|
|
|
new Json<GoodsParentTypeInfo>().jsonToListobject(GoodsParentTypeInfo.class, item.text); |
|
|
|
ConfigName.getInstance().cloudData.goodsParentTypeInfo = new Json<GoodsParentTypeInfo>().jsonToListobject(GoodsParentTypeInfo.class, item.text); |
|
|
|
|
|
|
|
} else if (item.name.equals("商品单位")) { |
|
|
|
ConfigName.getInstance().cloudData.goodsUintInfo = |
|
|
|
new Json<GoodsUintInfo>().jsonToListobject(GoodsUintInfo.class, item.text); |
|
|
|
ConfigName.getInstance().cloudData.goodsUintInfo = new Json<GoodsUintInfo>().jsonToListobject(GoodsUintInfo.class, item.text); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
@@ -261,35 +261,28 @@ public class ConfigData { |
|
|
|
if (NetworkUtils.isNetworkConnected(context)) { |
|
|
|
|
|
|
|
//获取店铺信息 |
|
|
|
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) |
|
|
|
.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; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
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; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
@@ -301,151 +294,150 @@ public class ConfigData { |
|
|
|
public void SyncDataInTheCloud(Context context, Handler mHandler) { |
|
|
|
if (NetworkUtils.isNetworkConnected(context)) { |
|
|
|
//region 拉取物料数据 |
|
|
|
OkGo.<ResAPI<ResALLData>>get(String.format(ConfigName.getInstance().SaasAddress + ConfigName.getInstance().GetBaseDataModel, |
|
|
|
ConfigName.getInstance().organizeMode.id, ConfigName.getInstance().DeviceAutoKey)) |
|
|
|
.tag(context) |
|
|
|
.headers(new HttpHeaders("TenantId", ConfigName.getInstance().organizeMode.companyId)) |
|
|
|
.execute(new JsonDialogCallback<ResAPI<ResALLData>>(context) { |
|
|
|
@Override |
|
|
|
public void onSuccess(Response<ResAPI<ResALLData>> response) { |
|
|
|
ResAPI<ResALLData> allDataResAPI = response.body(); |
|
|
|
if (allDataResAPI.succeeded && allDataResAPI.data != null) { |
|
|
|
BPA_CLOUDDATA data = new BPA_CLOUDDATA(); |
|
|
|
ConfigName.getInstance().cloudData = allDataResAPI.data; |
|
|
|
ArrayList<BPA_CLOUDDATA> arrayList = QueryDB.GetClouddataALL(); |
|
|
|
for (BPA_CLOUDDATA item : arrayList) { |
|
|
|
QueryDB.DeleteClouddata(item); |
|
|
|
} |
|
|
|
if (ConfigName.getInstance().organizeMode == null) { |
|
|
|
return; |
|
|
|
} |
|
|
|
OkGo.<ResAPI<ResALLData>>get(String.format(ConfigName.getInstance().SaasAddress + ConfigName.getInstance().GetBaseDataModel, ConfigName.getInstance().organizeMode.id, ConfigName.getInstance().DeviceAutoKey)).tag(context).headers(new HttpHeaders("TenantId", ConfigName.getInstance().organizeMode.companyId)).execute(new JsonDialogCallback<ResAPI<ResALLData>>(context) { |
|
|
|
@Override |
|
|
|
public void onSuccess(Response<ResAPI<ResALLData>> response) { |
|
|
|
ResAPI<ResALLData> allDataResAPI = response.body(); |
|
|
|
if (allDataResAPI.succeeded && allDataResAPI.data != null) { |
|
|
|
BPA_CLOUDDATA data = new BPA_CLOUDDATA(); |
|
|
|
ConfigName.getInstance().cloudData = allDataResAPI.data; |
|
|
|
ArrayList<BPA_CLOUDDATA> arrayList = QueryDB.GetClouddataALL(); |
|
|
|
for (BPA_CLOUDDATA item : arrayList) { |
|
|
|
QueryDB.DeleteClouddata(item); |
|
|
|
} |
|
|
|
|
|
|
|
//region 物料管理 |
|
|
|
List<BatchingInfo> bayc = allDataResAPI.data.batchingInfo; |
|
|
|
if (allDataResAPI.data.batchingInfo != null) { |
|
|
|
data = new BPA_CLOUDDATA(); |
|
|
|
data.id = java.util.UUID.randomUUID().toString(); |
|
|
|
data.name = "物料集合"; |
|
|
|
data.text = new Gson().toJson(bayc); |
|
|
|
QueryDB.AddClouddata(data); |
|
|
|
|
|
|
|
ArrayList<BPA_MATERIAL> materials = QueryDB.GetMaterialALL(); |
|
|
|
for (BPA_MATERIAL wl : materials) { |
|
|
|
QueryDB.DeleteMaterial(wl); |
|
|
|
} |
|
|
|
//region 物料管理 |
|
|
|
List<BatchingInfo> bayc = allDataResAPI.data.batchingInfo; |
|
|
|
if (allDataResAPI.data.batchingInfo != null) { |
|
|
|
data = new BPA_CLOUDDATA(); |
|
|
|
data.id = java.util.UUID.randomUUID().toString(); |
|
|
|
data.name = "物料集合"; |
|
|
|
data.text = new Gson().toJson(bayc); |
|
|
|
QueryDB.AddClouddata(data); |
|
|
|
|
|
|
|
ArrayList<BPA_MATERIAL> materials = QueryDB.GetMaterialALL(); |
|
|
|
for (BPA_MATERIAL wl : materials) { |
|
|
|
QueryDB.DeleteMaterial(wl); |
|
|
|
} |
|
|
|
|
|
|
|
Integer I = 0; |
|
|
|
for (BatchingInfo item : bayc) { |
|
|
|
BPA_MATERIAL bpa_material = new BPA_MATERIAL(); |
|
|
|
bpa_material.id = item.id; |
|
|
|
bpa_material.name = item.batching_Name; |
|
|
|
bpa_material.imgUrl = ""; |
|
|
|
bpa_material.createTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date(new Date().getTime() + I * 1000)); |
|
|
|
; |
|
|
|
bpa_material.deviceID = ConfigName.getInstance().DeviceId; |
|
|
|
bpa_material.userID = ConfigName.getInstance().user.userID; |
|
|
|
QueryDB.AddMaterial(bpa_material); |
|
|
|
I++; |
|
|
|
} |
|
|
|
} |
|
|
|
//endregion |
|
|
|
|
|
|
|
//region 工艺模型 |
|
|
|
if (allDataResAPI.data.goodsTechnology != null) { |
|
|
|
data = new BPA_CLOUDDATA(); |
|
|
|
data.id = java.util.UUID.randomUUID().toString(); |
|
|
|
data.name = "工艺模型"; |
|
|
|
data.text = new Gson().toJson(allDataResAPI.data.goodsTechnology); |
|
|
|
QueryDB.AddClouddata(data); |
|
|
|
|
|
|
|
ArrayList<BPA_PROCESS> processes = QueryDB.GetProcessALL(); |
|
|
|
for (BPA_PROCESS pro : processes) { |
|
|
|
QueryDB.DeleteProcess(pro); |
|
|
|
} |
|
|
|
Integer I = 0; |
|
|
|
for (GoodsTechnology item : allDataResAPI.data.goodsTechnology) { |
|
|
|
BPA_PROCESS bpa_process = new BPA_PROCESS(); |
|
|
|
bpa_process.id = item.id; |
|
|
|
bpa_process.name = item.name; |
|
|
|
bpa_process.createTime = item.createAt; |
|
|
|
bpa_process.sort = I; |
|
|
|
QueryDB.AddProcess(bpa_process); |
|
|
|
I++; |
|
|
|
} |
|
|
|
} |
|
|
|
//endregion |
|
|
|
|
|
|
|
//region 工艺模型详细信息 |
|
|
|
if (allDataResAPI.data.technologyAction != null) { |
|
|
|
data = new BPA_CLOUDDATA(); |
|
|
|
data.id = java.util.UUID.randomUUID().toString(); |
|
|
|
data.name = "工艺模型详细信息"; |
|
|
|
data.text = new Gson().toJson(allDataResAPI.data.technologyAction); |
|
|
|
QueryDB.AddClouddata(data); |
|
|
|
|
|
|
|
ArrayList<BPA_PROCESSModel> processes = QueryDB.GetProcessModelALL(); |
|
|
|
for (BPA_PROCESSModel pro : processes) { |
|
|
|
QueryDB.DeleteProcessModel(pro); |
|
|
|
} |
|
|
|
for (TechnologyAction item : allDataResAPI.data.technologyAction) { |
|
|
|
BPA_PROCESSModel bpa_process = new BPA_PROCESSModel(); |
|
|
|
bpa_process.id = item.id; |
|
|
|
bpa_process.processid = item.goodstechnologyId; |
|
|
|
bpa_process.name = item.actionName; |
|
|
|
bpa_process.createTime = item.createAt; |
|
|
|
bpa_process.sort = item.sort; |
|
|
|
bpa_process.datatype = (item.actionType.equals("digit") ? 0 : ((item.actionType.equals("text") || item.actionType.equals("textarea") || item.actionType.equals("switch")) ? 1 : 2)); |
|
|
|
bpa_process.data = ""; |
|
|
|
if (item.actionType.equals("select") && !item.actionValue.isEmpty()) { |
|
|
|
List<TechnologyValueMode> val = new Json<TechnologyValueMode>().jsonToListobject(TechnologyValueMode.class, item.actionValue); |
|
|
|
for (int i = 0; i < val.size(); i++) { |
|
|
|
if (i < val.size() - 1) { |
|
|
|
bpa_process.data += val.get(i).actionValueName + "、"; |
|
|
|
} else { |
|
|
|
bpa_process.data += val.get(i).actionValueName; |
|
|
|
} |
|
|
|
} |
|
|
|
Integer I = 0; |
|
|
|
for (BatchingInfo item : bayc) { |
|
|
|
BPA_MATERIAL bpa_material = new BPA_MATERIAL(); |
|
|
|
bpa_material.id = item.id; |
|
|
|
bpa_material.name = item.batching_Name; |
|
|
|
bpa_material.imgUrl = ""; |
|
|
|
bpa_material.createTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date(new Date().getTime() + I * 1000)); |
|
|
|
; |
|
|
|
bpa_material.deviceID = ConfigName.getInstance().DeviceId; |
|
|
|
bpa_material.userID = ConfigName.getInstance().user.userID; |
|
|
|
QueryDB.AddMaterial(bpa_material); |
|
|
|
I++; |
|
|
|
} |
|
|
|
} |
|
|
|
//endregion |
|
|
|
|
|
|
|
//region 工艺模型 |
|
|
|
if (allDataResAPI.data.goodsTechnology != null) { |
|
|
|
data = new BPA_CLOUDDATA(); |
|
|
|
data.id = java.util.UUID.randomUUID().toString(); |
|
|
|
data.name = "工艺模型"; |
|
|
|
data.text = new Gson().toJson(allDataResAPI.data.goodsTechnology); |
|
|
|
QueryDB.AddClouddata(data); |
|
|
|
|
|
|
|
ArrayList<BPA_PROCESS> processes = QueryDB.GetProcessALL(); |
|
|
|
for (BPA_PROCESS pro : processes) { |
|
|
|
QueryDB.DeleteProcess(pro); |
|
|
|
} |
|
|
|
Integer I = 0; |
|
|
|
for (GoodsTechnology item : allDataResAPI.data.goodsTechnology) { |
|
|
|
BPA_PROCESS bpa_process = new BPA_PROCESS(); |
|
|
|
bpa_process.id = item.id; |
|
|
|
bpa_process.name = item.name; |
|
|
|
bpa_process.createTime = item.createAt; |
|
|
|
bpa_process.sort = I; |
|
|
|
QueryDB.AddProcess(bpa_process); |
|
|
|
I++; |
|
|
|
} |
|
|
|
} |
|
|
|
//endregion |
|
|
|
|
|
|
|
//region 工艺模型详细信息 |
|
|
|
if (allDataResAPI.data.technologyAction != null) { |
|
|
|
data = new BPA_CLOUDDATA(); |
|
|
|
data.id = java.util.UUID.randomUUID().toString(); |
|
|
|
data.name = "工艺模型详细信息"; |
|
|
|
data.text = new Gson().toJson(allDataResAPI.data.technologyAction); |
|
|
|
QueryDB.AddClouddata(data); |
|
|
|
|
|
|
|
ArrayList<BPA_PROCESSModel> processes = QueryDB.GetProcessModelALL(); |
|
|
|
for (BPA_PROCESSModel pro : processes) { |
|
|
|
QueryDB.DeleteProcessModel(pro); |
|
|
|
} |
|
|
|
for (TechnologyAction item : allDataResAPI.data.technologyAction) { |
|
|
|
BPA_PROCESSModel bpa_process = new BPA_PROCESSModel(); |
|
|
|
bpa_process.id = item.id; |
|
|
|
bpa_process.processid = item.goodstechnologyId; |
|
|
|
bpa_process.name = item.actionName; |
|
|
|
bpa_process.createTime = item.createAt; |
|
|
|
bpa_process.sort = item.sort; |
|
|
|
bpa_process.datatype = (item.actionType.equals("digit") ? 0 : ((item.actionType.equals("text") || item.actionType.equals("textarea") || item.actionType.equals("switch")) ? 1 : 2)); |
|
|
|
bpa_process.data = ""; |
|
|
|
if (item.actionType.equals("select") && !item.actionValue.isEmpty()) { |
|
|
|
List<TechnologyValueMode> val = new Json<TechnologyValueMode>().jsonToListobject(TechnologyValueMode.class, item.actionValue); |
|
|
|
for (int i = 0; i < val.size(); i++) { |
|
|
|
if (i < val.size() - 1) { |
|
|
|
bpa_process.data += val.get(i).actionValueName + "、"; |
|
|
|
} else { |
|
|
|
bpa_process.data += val.get(i).actionValueName; |
|
|
|
} |
|
|
|
QueryDB.AddProcessModel(bpa_process); |
|
|
|
} |
|
|
|
} |
|
|
|
//endegion |
|
|
|
QueryDB.AddProcessModel(bpa_process); |
|
|
|
} |
|
|
|
} |
|
|
|
//endegion |
|
|
|
|
|
|
|
|
|
|
|
if (allDataResAPI.data.foodMenuInfo != null) { |
|
|
|
data = new BPA_CLOUDDATA(); |
|
|
|
data.id = java.util.UUID.randomUUID().toString(); |
|
|
|
data.name = "菜谱信息"; |
|
|
|
data.text = new Gson().toJson(allDataResAPI.data.foodMenuInfo); |
|
|
|
QueryDB.AddClouddata(data); |
|
|
|
} |
|
|
|
if (allDataResAPI.data.foodMenuInfo != null) { |
|
|
|
data = new BPA_CLOUDDATA(); |
|
|
|
data.id = java.util.UUID.randomUUID().toString(); |
|
|
|
data.name = "菜谱信息"; |
|
|
|
data.text = new Gson().toJson(allDataResAPI.data.foodMenuInfo); |
|
|
|
QueryDB.AddClouddata(data); |
|
|
|
} |
|
|
|
|
|
|
|
if (allDataResAPI.data.goodsTypeInfo != null) { |
|
|
|
data = new BPA_CLOUDDATA(); |
|
|
|
data.id = java.util.UUID.randomUUID().toString(); |
|
|
|
data.name = "商品小类"; |
|
|
|
data.text = new Gson().toJson(allDataResAPI.data.goodsTypeInfo); |
|
|
|
QueryDB.AddClouddata(data); |
|
|
|
} |
|
|
|
if (allDataResAPI.data.goodsTypeInfo != null) { |
|
|
|
data = new BPA_CLOUDDATA(); |
|
|
|
data.id = java.util.UUID.randomUUID().toString(); |
|
|
|
data.name = "商品小类"; |
|
|
|
data.text = new Gson().toJson(allDataResAPI.data.goodsTypeInfo); |
|
|
|
QueryDB.AddClouddata(data); |
|
|
|
} |
|
|
|
|
|
|
|
if (allDataResAPI.data.goodsParentTypeInfo != null) { |
|
|
|
data = new BPA_CLOUDDATA(); |
|
|
|
data.id = java.util.UUID.randomUUID().toString(); |
|
|
|
data.name = "商品大类"; |
|
|
|
data.text = new Gson().toJson(allDataResAPI.data.goodsParentTypeInfo); |
|
|
|
QueryDB.AddClouddata(data); |
|
|
|
} |
|
|
|
if (allDataResAPI.data.goodsParentTypeInfo != null) { |
|
|
|
data = new BPA_CLOUDDATA(); |
|
|
|
data.id = java.util.UUID.randomUUID().toString(); |
|
|
|
data.name = "商品大类"; |
|
|
|
data.text = new Gson().toJson(allDataResAPI.data.goodsParentTypeInfo); |
|
|
|
QueryDB.AddClouddata(data); |
|
|
|
} |
|
|
|
|
|
|
|
if (allDataResAPI.data.goodsUintInfo != null) { |
|
|
|
data = new BPA_CLOUDDATA(); |
|
|
|
data.id = java.util.UUID.randomUUID().toString(); |
|
|
|
data.name = "商品单位"; |
|
|
|
data.text = new Gson().toJson(allDataResAPI.data.goodsUintInfo); |
|
|
|
QueryDB.AddClouddata(data); |
|
|
|
} |
|
|
|
Message msg = new Message(); |
|
|
|
msg.obj = "MSG_REFRESH"; |
|
|
|
mHandler.sendMessage(msg); |
|
|
|
} |
|
|
|
if (allDataResAPI.data.goodsUintInfo != null) { |
|
|
|
data = new BPA_CLOUDDATA(); |
|
|
|
data.id = java.util.UUID.randomUUID().toString(); |
|
|
|
data.name = "商品单位"; |
|
|
|
data.text = new Gson().toJson(allDataResAPI.data.goodsUintInfo); |
|
|
|
QueryDB.AddClouddata(data); |
|
|
|
} |
|
|
|
}); |
|
|
|
Message msg = new Message(); |
|
|
|
msg.obj = "MSG_REFRESH"; |
|
|
|
mHandler.sendMessage(msg); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
//endregion |
|
|
|
} else { |
|
|
|
ToastUtils.warning("无网络,请先连接网络!!!"); |
|
|
@@ -459,22 +451,21 @@ public class ConfigData { |
|
|
|
*/ |
|
|
|
public void GetGevGood(Context context, Handler mHandler) { |
|
|
|
if (NetworkUtils.isNetworkConnected(context)) { |
|
|
|
OkGo.<ResAPI<List<CloudGood>>>get(String.format(ConfigName.getInstance().SaasAddress + ConfigName.getInstance().GetGoods, |
|
|
|
ConfigName.getInstance().organizeMode.id, ConfigName.getInstance().DeviceId)) |
|
|
|
.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>> allDataResAPI = response.body(); |
|
|
|
if (allDataResAPI.succeeded && allDataResAPI.data != null && allDataResAPI.data.size() > 0) { |
|
|
|
ConfigName.getInstance().cloudGoods = allDataResAPI.data; |
|
|
|
Message msg = new Message(); |
|
|
|
msg.obj = "MSG_REFRESH"; |
|
|
|
mHandler.sendMessage(msg); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
if (ConfigName.getInstance().organizeMode == null) { |
|
|
|
return; |
|
|
|
} |
|
|
|
OkGo.<ResAPI<List<CloudGood>>>get(String.format(ConfigName.getInstance().SaasAddress + ConfigName.getInstance().GetGoods, ConfigName.getInstance().organizeMode.id, ConfigName.getInstance().DeviceId)).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>> allDataResAPI = response.body(); |
|
|
|
if (allDataResAPI.succeeded && allDataResAPI.data != null && allDataResAPI.data.size() > 0) { |
|
|
|
ConfigName.getInstance().cloudGoods = allDataResAPI.data; |
|
|
|
Message msg = new Message(); |
|
|
|
msg.obj = "MSG_REFRESH"; |
|
|
|
mHandler.sendMessage(msg); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
} else { |
|
|
|
ToastUtils.warning("无网络,请先连接网络!!!"); |
|
|
|
} |
|
|
@@ -487,95 +478,268 @@ public class ConfigData { |
|
|
|
* @param context |
|
|
|
*/ |
|
|
|
public void GetGoodProcess(Context context, String goodid) { |
|
|
|
Boolean IsXZ= QueryDB.GetGoodsIDIs(goodid); |
|
|
|
if(IsXZ) |
|
|
|
{ |
|
|
|
Boolean IsXZ = QueryDB.GetGoodsIDIs(goodid); |
|
|
|
if (IsXZ) { |
|
|
|
ToastUtils.warning("请勿重复下载,本地商品已存在!!!"); |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
if (NetworkUtils.isNetworkConnected(context)) { |
|
|
|
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) { |
|
|
|
@Override |
|
|
|
public void onSuccess(Response<ResAPI<ResGoodProcess>> response) { |
|
|
|
ResAPI<ResGoodProcess> allDataResAPI = response.body(); |
|
|
|
if (allDataResAPI.succeeded && allDataResAPI.data != null) { |
|
|
|
|
|
|
|
CloudGood cloudGood = null; |
|
|
|
for (CloudGood item : ConfigName.getInstance().cloudGoods) { |
|
|
|
if (item.id.equals(goodid)) { |
|
|
|
cloudGood = item; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
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) { |
|
|
|
@Override |
|
|
|
public void onSuccess(Response<ResAPI<ResGoodProcess>> response) { |
|
|
|
ResAPI<ResGoodProcess> allDataResAPI = response.body(); |
|
|
|
if (allDataResAPI.succeeded && allDataResAPI.data != null) { |
|
|
|
|
|
|
|
CloudGood cloudGood = null; |
|
|
|
for (CloudGood item : ConfigName.getInstance().cloudGoods) { |
|
|
|
if (item.id.equals(goodid)) { |
|
|
|
cloudGood = item; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if (cloudGood != null) { |
|
|
|
//1.增加商品 |
|
|
|
BPA_GOODS good = new BPA_GOODS(); |
|
|
|
good.id = cloudGood.id; |
|
|
|
good.name = cloudGood.goods_Name; |
|
|
|
good.status = 1; |
|
|
|
good.sort = QueryDB.GetGoodsALL().size() + 1; |
|
|
|
good.maketime = 180; |
|
|
|
good.issc = 0; |
|
|
|
good.url = cloudGood.goods_ImgUrl; |
|
|
|
good.exp="云端商品"; |
|
|
|
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>() { |
|
|
|
@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; |
|
|
|
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) { |
|
|
|
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 = k.stepName + "(" + desc.substring(0, desc.length() - 1) + ")"; |
|
|
|
} |
|
|
|
item.materialType=iswl?0:1; |
|
|
|
if (cloudGood != null) { |
|
|
|
//1.增加商品 |
|
|
|
BPA_GOODS good = new BPA_GOODS(); |
|
|
|
good.id = cloudGood.id; |
|
|
|
good.name = cloudGood.goods_Name; |
|
|
|
good.status = 1; |
|
|
|
good.sort = QueryDB.GetGoodsALL().size() + 1; |
|
|
|
good.maketime = 180; |
|
|
|
good.issc = 0; |
|
|
|
good.url = cloudGood.goods_ImgUrl; |
|
|
|
good.exp = "云端商品"; |
|
|
|
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>() { |
|
|
|
@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; |
|
|
|
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) { |
|
|
|
data += m.ActionName + "," + m.ActionValue + "|"; |
|
|
|
desc += m.ActionValue + ","; |
|
|
|
if (!m.BatchingId.isEmpty()) { |
|
|
|
iswl = true; |
|
|
|
} |
|
|
|
QueryDB.AddGoodsSrecipe(item); |
|
|
|
} |
|
|
|
if (data.contains("|")) { |
|
|
|
item.processvalue = data.substring(0, data.length() - 1); |
|
|
|
} |
|
|
|
if (desc.contains(",")) { |
|
|
|
item.processms = k.stepName + "(" + desc.substring(0, desc.length() - 1) + ")"; |
|
|
|
} |
|
|
|
item.materialType = iswl ? 0 : 1; |
|
|
|
} |
|
|
|
ToastUtils.info("下载菜品成功!!!"); |
|
|
|
MessageManager.getInstance().sendMessage(MessageName.ScGood,"Good"); |
|
|
|
QueryDB.AddGoodsSrecipe(item); |
|
|
|
} |
|
|
|
} |
|
|
|
ToastUtils.info("下载菜品成功!!!"); |
|
|
|
MessageManager.getInstance().sendMessage(MessageName.ScGood, "Good"); |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
} else { |
|
|
|
ToastUtils.warning("无网络,请先连接网络!!!"); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 上传商品信息 |
|
|
|
* |
|
|
|
* @param context |
|
|
|
* @param goodid |
|
|
|
*/ |
|
|
|
public void UploadGoods(Context context, String goodid) { |
|
|
|
try { |
|
|
|
if (NetworkUtils.isNetworkConnected(context)) { |
|
|
|
if (ConfigName.getInstance().organizeMode == null && ConfigName.getInstance().cloudData!=null) { |
|
|
|
ToastUtils.warning("无组织信息不能上传,请设置当前店铺信息!!!"); |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
Boolean isSuceess = false; |
|
|
|
BPA_GOODS good = QueryDB.GetGoodsId(goodid); |
|
|
|
UpdateCloudGood update = new UpdateCloudGood(); |
|
|
|
update.storeId=ConfigName.getInstance().organizeMode.id; |
|
|
|
update.goodsInfo=new CloudGood(); |
|
|
|
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="设备上传商品";//图片地址 |
|
|
|
update.goodsInfo.parentTypeID="";//大类 |
|
|
|
update.goodsInfo.goods_TypeID="";//小类 |
|
|
|
update.goodsInfo.goodsUintId="";//单位 |
|
|
|
|
|
|
|
UpdateBomInfo bom=new UpdateBomInfo(); |
|
|
|
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="";//模型id |
|
|
|
m.BatchingId=batchingInfo!=null?batchingInfo.id:"";//物料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; |
|
|
|
update.bomTechnologyActionInfo.add(info); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if (isSuceess) { |
|
|
|
OkGo.<ResAPI<Boolean>>post(ConfigName.getInstance().SaasAddress + ConfigName.getInstance().UpdateGoods).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.data) { |
|
|
|
ToastUtils.info("上传菜品成功!!!"); |
|
|
|
MessageManager.getInstance().sendMessage(MessageName.ScGood, "Good"); |
|
|
|
} else { |
|
|
|
ToastUtils.warning("上传菜品失败!!!"); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
} else { |
|
|
|
ToastUtils.warning("无网络,请先连接网络!!!"); |
|
|
|
} |
|
|
|
} catch (Exception ex) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 增加本地图片 |
|
|
|
*/ |
|
|
|