加入个人限购
This commit is contained in:
parent
4acd698325
commit
6d88a71514
|
|
@ -740,11 +740,17 @@ public class OperationActivity extends BaseActivity<ActivityCanteenOperationBind
|
|||
String dishesId = b.getDishesId();
|
||||
String prefPrice = b.getPrefPrice();
|
||||
String salePrice = b.getSalePrice();
|
||||
int supplyNum = b.getSupplyNum();
|
||||
int surplusNum = b.getSurplusNum();
|
||||
int restrictNum = b.getRestrictNum();
|
||||
Map<String, String> productListMap = new HashMap<>();
|
||||
productListMap.put("detailId", detailId);
|
||||
productListMap.put("dishesId", dishesId);
|
||||
productListMap.put("prefPrice", prefPrice);
|
||||
productListMap.put("salePrice", salePrice);
|
||||
productListMap.put("supplyNum", String.valueOf(supplyNum));
|
||||
productListMap.put("surplusNum", String.valueOf(surplusNum));
|
||||
productListMap.put("restrictNum", String.valueOf(restrictNum));
|
||||
mealList.add(dishesId);
|
||||
iproductList.add(productListMap);
|
||||
}
|
||||
|
|
@ -803,6 +809,7 @@ public class OperationActivity extends BaseActivity<ActivityCanteenOperationBind
|
|||
}
|
||||
//取出当前餐品的所有类别及餐品数据
|
||||
for (IssueRecipeDetailCompressVO dishItem : currentDishList) {
|
||||
Log.d(TAG, "initMenuData dishItem:" + dishItem.toString());
|
||||
//从menuList 中获取当前的餐品
|
||||
for (IssueRecipeMealCompressVO mealItem : menuList) {
|
||||
if (mealItem.getDishesId().equals(dishItem.getDishesId())) {
|
||||
|
|
@ -810,12 +817,12 @@ public class OperationActivity extends BaseActivity<ActivityCanteenOperationBind
|
|||
if (originalTypeId != -1 && Objects.equals(mealItem.getTypeId(), originalTypeId)) {
|
||||
dishEntityList.add(new DishEntity(dishItem.getDishesId(), mealItem.getProductName(), dishItem.getPrefPrice(), dishItem.getSalePrice()
|
||||
, jsonObject.getRecipeType(), jsonObject.getRecipeId(), mealItem.getCustomId(), mealItem.getTypeId(), mealItem.getTypeName(),
|
||||
mealItem.getCalories(), mealItem.getProtein(), mealItem.getFat(), mealItem.getSodium(), mealItem.getCarbohydrate()));
|
||||
mealItem.getCalories(), mealItem.getProtein(), mealItem.getFat(), mealItem.getSodium(), mealItem.getCarbohydrate(),dishItem.getSupplyNum(), dishItem.getSurplusNum(), dishItem.getRestrictNum()));
|
||||
}
|
||||
if (originalTypeId == -1) {
|
||||
dishEntityList.add(new DishEntity(dishItem.getDishesId(), mealItem.getProductName(), dishItem.getPrefPrice(), dishItem.getSalePrice()
|
||||
, jsonObject.getRecipeType(), jsonObject.getRecipeId(), mealItem.getCustomId(), mealItem.getTypeId(), mealItem.getTypeName(),
|
||||
mealItem.getCalories(), mealItem.getProtein(), mealItem.getFat(), mealItem.getSodium(), mealItem.getCarbohydrate()));
|
||||
mealItem.getCalories(), mealItem.getProtein(), mealItem.getFat(), mealItem.getSodium(), mealItem.getCarbohydrate(),dishItem.getSupplyNum(), dishItem.getSurplusNum(), dishItem.getRestrictNum()));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,6 +30,9 @@ import android.widget.TextView;
|
|||
import com.bonus.canteen.activity.OperationActivity;
|
||||
import com.bonus.canteen.adapter.menu.entity.DishEntity;
|
||||
import com.bonus.canteen.adapter.menu.entity.SalesMenuEntity;
|
||||
import com.bonus.canteen.utils.sound.Sound;
|
||||
import com.bonus.canteen.utils.sound.SoundManager;
|
||||
import com.xuexiang.xui.utils.XToastUtils;
|
||||
|
||||
import org.easydarwin.easypusher.R;
|
||||
|
||||
|
|
@ -90,6 +93,7 @@ public class DishListAdapter extends BaseAdapter {
|
|||
holder.dishItem.setOnClickListener(v -> {
|
||||
// 通过 position 参数直接获取数据
|
||||
DishEntity clickedBean = list.get(i);
|
||||
Log.e("点击了", "ThreadUpdatesUI clickedBean" + clickedBean);
|
||||
// 使用唯一标识符(如ID)而非 position
|
||||
ThreadUpdatesUI(clickedBean);
|
||||
});
|
||||
|
|
@ -108,9 +112,15 @@ public class DishListAdapter extends BaseAdapter {
|
|||
((Activity) context).runOnUiThread(() -> {
|
||||
// 根据 dishId 更新UI或处理业务逻辑
|
||||
Log.e("点击了", "ThreadUpdatesUI" + bean.getDishesId());
|
||||
Log.e("点击了", "ThreadUpdatesUI" + bean);
|
||||
if (!"-1".equals(bean.getDishesId())){
|
||||
for (SalesMenuEntity salesMenuEntity : salesMenuEntityList) {
|
||||
if (salesMenuEntity.getId().equals(bean.getDishesId())) {
|
||||
if (bean.getRestrictNum() <= salesMenuEntity.getNum().intValue()){
|
||||
XToastUtils.warning("该菜品已达个人限购上限!");
|
||||
SoundManager.getInstance().play(Sound.createSimpleSound(R.raw.purchase_limit));
|
||||
return;
|
||||
}
|
||||
salesMenuEntity.setNum(salesMenuEntity.getNum().add(BigDecimal.valueOf(1)));
|
||||
salesMenuEntity.setSubtotal(salesMenuEntity.getNum().multiply(salesMenuEntity.getPrice()));
|
||||
salesMenuEntity.setCalories(bean.getCalories().multiply(salesMenuEntity.getNum()));
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@
|
|||
package com.bonus.canteen.adapter.menu;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.text.InputType;
|
||||
import android.view.LayoutInflater;
|
||||
|
|
@ -28,6 +29,12 @@ import android.widget.TextView;
|
|||
|
||||
import com.bonus.canteen.activity.OperationActivity;
|
||||
import com.bonus.canteen.adapter.menu.entity.SalesMenuEntity;
|
||||
import com.bonus.canteen.db.AppDatabase;
|
||||
import com.bonus.canteen.db.entity.base.CookMeetDetailInfo;
|
||||
import com.bonus.canteen.db.entity.base.CookMeetTimesInfo;
|
||||
import com.bonus.canteen.utils.ThreadPoolManager;
|
||||
import com.bonus.canteen.utils.sound.Sound;
|
||||
import com.bonus.canteen.utils.sound.SoundManager;
|
||||
import com.xuexiang.xui.utils.XToastUtils;
|
||||
import com.xuexiang.xui.widget.dialog.materialdialog.GravityEnum;
|
||||
import com.xuexiang.xui.widget.dialog.materialdialog.MaterialDialog;
|
||||
|
|
@ -92,10 +99,26 @@ public class SalesMenuAdapter extends BaseAdapter {
|
|||
setSalesData();
|
||||
});
|
||||
holder.tvAdd.setOnClickListener(view -> {
|
||||
bean.setNum(bean.getNum().add(BigDecimal.valueOf(1)));
|
||||
bean.setSubtotal(bean.getNum().multiply(bean.getPrice()));
|
||||
notifyDataSetChanged();
|
||||
setSalesData();
|
||||
//查询限购
|
||||
ThreadPoolManager.getExecutor().execute(() -> {
|
||||
CookMeetTimesInfo cookMeetTimesInfo = AppDatabase.getDatabase(context).cookMeetTimesDao().getDefaultCookMeetTime();
|
||||
CookMeetDetailInfo cookMeetDetailInfo = AppDatabase.getDatabase(context).cookMeetDetailDao().getCookMeetDetailByIdAndTime(bean.getId(), cookMeetTimesInfo.getIntervalId());
|
||||
int restrictNum = cookMeetDetailInfo.getRestrictNum();
|
||||
if(restrictNum > 0 && restrictNum < Integer.parseInt(bean.getNum().add(BigDecimal.valueOf(1)) + "")){
|
||||
((Activity) context).runOnUiThread(() -> {
|
||||
XToastUtils.warning("该菜品已达个人限购上限!");
|
||||
SoundManager.getInstance().play(Sound.createSimpleSound(R.raw.purchase_limit));
|
||||
});
|
||||
return;
|
||||
}
|
||||
((Activity) context).runOnUiThread(() -> {
|
||||
bean.setNum(bean.getNum().add(BigDecimal.valueOf(1)));
|
||||
bean.setSubtotal(bean.getNum().multiply(bean.getPrice()));
|
||||
notifyDataSetChanged();
|
||||
setSalesData();
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
holder.tvRemove.setOnClickListener(view -> {
|
||||
bean.setNum(bean.getNum().subtract(BigDecimal.valueOf(1)));
|
||||
|
|
@ -149,10 +172,24 @@ public class SalesMenuAdapter extends BaseAdapter {
|
|||
dialog.getInputEditText().setText("");
|
||||
//阻止弹窗消失
|
||||
}else{
|
||||
bean.setNum(BigDecimal.valueOf(Long.parseLong(input.toString())));
|
||||
bean.setSubtotal(bean.getNum().multiply(bean.getPrice()));
|
||||
notifyDataSetChanged();
|
||||
setSalesData();
|
||||
ThreadPoolManager.getExecutor().execute(() -> {
|
||||
CookMeetTimesInfo cookMeetTimesInfo = AppDatabase.getDatabase(context).cookMeetTimesDao().getDefaultCookMeetTime();
|
||||
CookMeetDetailInfo cookMeetDetailInfo = AppDatabase.getDatabase(context).cookMeetDetailDao().getCookMeetDetailByIdAndTime(bean.getId(), cookMeetTimesInfo.getIntervalId());
|
||||
int restrictNum = cookMeetDetailInfo.getRestrictNum();
|
||||
if(restrictNum > 0 && restrictNum < Integer.parseInt(bean.getNum().add(BigDecimal.valueOf(1)) + "")){
|
||||
((Activity) context).runOnUiThread(() -> {
|
||||
XToastUtils.warning("该菜品已达个人限购上限!");
|
||||
SoundManager.getInstance().play(Sound.createSimpleSound(R.raw.purchase_limit));
|
||||
});
|
||||
return;
|
||||
}
|
||||
((Activity) context).runOnUiThread(() -> {
|
||||
bean.setNum(BigDecimal.valueOf(Long.parseLong(input.toString())));
|
||||
bean.setSubtotal(bean.getNum().multiply(bean.getPrice()));
|
||||
notifyDataSetChanged();
|
||||
setSalesData();
|
||||
});
|
||||
});
|
||||
dialog.dismiss();
|
||||
}
|
||||
}))
|
||||
|
|
|
|||
|
|
@ -44,9 +44,13 @@ public class DishEntity {
|
|||
|
||||
private BigDecimal carbohydrate;
|
||||
|
||||
private Integer supplyNum;
|
||||
private Integer surplusNum;
|
||||
private Integer restrictNum;
|
||||
|
||||
public DishEntity(Long dishesId, String productName, Integer prefPrice, Integer salePrice,
|
||||
Integer recipeType, Long recipeId, Integer customId, Long typeId, String typeName, BigDecimal calories, BigDecimal protein, BigDecimal fat,
|
||||
BigDecimal sodium, BigDecimal carbohydrate) {
|
||||
BigDecimal sodium, BigDecimal carbohydrate, Integer supplyNum, Integer surplusNum, Integer restrictNum) {
|
||||
this.dishesId = dishesId.toString();
|
||||
this.productName = productName;
|
||||
this.prefPrice = new BigDecimal(prefPrice).divide(new BigDecimal(100)).setScale(2, BigDecimal.ROUND_HALF_UP);
|
||||
|
|
@ -61,9 +65,36 @@ public class DishEntity {
|
|||
this.fat = fat;
|
||||
this.sodium = sodium;
|
||||
this.carbohydrate = carbohydrate;
|
||||
this.supplyNum = supplyNum;
|
||||
this.surplusNum = surplusNum;
|
||||
this.restrictNum = restrictNum;
|
||||
|
||||
}
|
||||
|
||||
public Integer getSupplyNum() {
|
||||
return supplyNum;
|
||||
}
|
||||
|
||||
public void setSupplyNum(Integer supplyNum) {
|
||||
this.supplyNum = supplyNum;
|
||||
}
|
||||
|
||||
public Integer getSurplusNum() {
|
||||
return surplusNum;
|
||||
}
|
||||
|
||||
public void setSurplusNum(Integer surplusNum) {
|
||||
this.surplusNum = surplusNum;
|
||||
}
|
||||
|
||||
public Integer getRestrictNum() {
|
||||
return restrictNum;
|
||||
}
|
||||
|
||||
public void setRestrictNum(Integer restrictNum) {
|
||||
this.restrictNum = restrictNum;
|
||||
}
|
||||
|
||||
public String getRecipeId() {
|
||||
return recipeId;
|
||||
}
|
||||
|
|
@ -193,6 +224,9 @@ public class DishEntity {
|
|||
", fat=" + fat +
|
||||
", sodium=" + sodium +
|
||||
", carbohydrate=" + carbohydrate +
|
||||
", supplyNum=" + supplyNum +
|
||||
", surplusNum=" + surplusNum +
|
||||
", restrictNum=" + restrictNum +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,6 +9,9 @@ public class IssueRecipeDetailCompressVO implements Serializable {
|
|||
private Integer prefPrice;
|
||||
private Integer salePrice;
|
||||
|
||||
private Integer supplyNum;
|
||||
private Integer surplusNum;
|
||||
private Integer restrictNum;
|
||||
public Long getDetailId() {
|
||||
return this.detailId;
|
||||
}
|
||||
|
|
@ -41,4 +44,40 @@ public class IssueRecipeDetailCompressVO implements Serializable {
|
|||
this.salePrice = salePrice;
|
||||
}
|
||||
|
||||
public Integer getSupplyNum() {
|
||||
return supplyNum;
|
||||
}
|
||||
|
||||
public void setSupplyNum(Integer supplyNum) {
|
||||
this.supplyNum = supplyNum;
|
||||
}
|
||||
|
||||
public Integer getSurplusNum() {
|
||||
return surplusNum;
|
||||
}
|
||||
|
||||
public void setSurplusNum(Integer surplusNum) {
|
||||
this.surplusNum = surplusNum;
|
||||
}
|
||||
|
||||
public Integer getRestrictNum() {
|
||||
return restrictNum;
|
||||
}
|
||||
|
||||
public void setRestrictNum(Integer restrictNum) {
|
||||
this.restrictNum = restrictNum;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "IssueRecipeDetailCompressVO{" +
|
||||
"detailId=" + detailId +
|
||||
", dishesId=" + dishesId +
|
||||
", prefPrice=" + prefPrice +
|
||||
", salePrice=" + salePrice +
|
||||
", supplyNum=" + supplyNum +
|
||||
", surplusNum=" + surplusNum +
|
||||
", restrictNum=" + restrictNum +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
|
@ -13,7 +13,12 @@ public class ProductBean {
|
|||
|
||||
@SerializedName("salePrice")
|
||||
private String salePrice;
|
||||
|
||||
@SerializedName("supplyNum")
|
||||
private Integer supplyNum;
|
||||
@SerializedName("surplusNum")
|
||||
private Integer surplusNum;
|
||||
@SerializedName("restrictNum")
|
||||
private Integer restrictNum;
|
||||
public String getDetailId() {
|
||||
return detailId;
|
||||
}
|
||||
|
|
@ -46,6 +51,30 @@ public class ProductBean {
|
|||
this.salePrice = salePrice;
|
||||
}
|
||||
|
||||
public Integer getSupplyNum() {
|
||||
return supplyNum;
|
||||
}
|
||||
|
||||
public void setSupplyNum(Integer supplyNum) {
|
||||
this.supplyNum = supplyNum;
|
||||
}
|
||||
|
||||
public Integer getSurplusNum() {
|
||||
return surplusNum;
|
||||
}
|
||||
|
||||
public void setSurplusNum(Integer surplusNum) {
|
||||
this.surplusNum = surplusNum;
|
||||
}
|
||||
|
||||
public Integer getRestrictNum() {
|
||||
return restrictNum;
|
||||
}
|
||||
|
||||
public void setRestrictNum(Integer restrictNum) {
|
||||
this.restrictNum = restrictNum;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ProductBean{" +
|
||||
|
|
@ -53,6 +82,9 @@ public class ProductBean {
|
|||
", dishesId='" + dishesId + '\'' +
|
||||
", prefPrice='" + prefPrice + '\'' +
|
||||
", salePrice='" + salePrice + '\'' +
|
||||
", supplyNum=" + supplyNum +
|
||||
", surplusNum=" + surplusNum +
|
||||
", restrictNum=" + restrictNum +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,4 +37,6 @@ public interface CookMeetDetailDao {
|
|||
void deleteAll(); // 删除数据
|
||||
@Query("select * from cook_meet_detail_info where dishesId=:dishesId and intervalId =:intervalId")
|
||||
CookMeetDetailInfo getCookMeetDetailByDishIdAndMealTypeId(String dishesId, String intervalId);
|
||||
@Query("select * from cook_meet_detail_info where dishesId=:dishId and intervalId =:intervalId")
|
||||
CookMeetDetailInfo getCookMeetDetailByIdAndTime(String dishId, String intervalId);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
package com.bonus.canteen.db.entity.base;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import androidx.room.ColumnInfo;
|
||||
import androidx.room.Entity;
|
||||
import androidx.room.PrimaryKey;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* 菜谱详情
|
||||
*/
|
||||
|
|
@ -30,6 +30,13 @@ public class CookMeetDetailInfo {
|
|||
@ColumnInfo
|
||||
private String salePrice;
|
||||
|
||||
@ColumnInfo
|
||||
private Integer supplyNum;
|
||||
@ColumnInfo
|
||||
private Integer surplusNum;
|
||||
@ColumnInfo
|
||||
private Integer restrictNum;
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
|
@ -94,6 +101,30 @@ public class CookMeetDetailInfo {
|
|||
this.applyDate = applyDate;
|
||||
}
|
||||
|
||||
public Integer getSupplyNum() {
|
||||
return supplyNum;
|
||||
}
|
||||
|
||||
public void setSupplyNum(Integer supplyNum) {
|
||||
this.supplyNum = supplyNum;
|
||||
}
|
||||
|
||||
public Integer getSurplusNum() {
|
||||
return surplusNum;
|
||||
}
|
||||
|
||||
public void setSurplusNum(Integer surplusNum) {
|
||||
this.surplusNum = surplusNum;
|
||||
}
|
||||
|
||||
public Integer getRestrictNum() {
|
||||
return restrictNum;
|
||||
}
|
||||
|
||||
public void setRestrictNum(Integer restrictNum) {
|
||||
this.restrictNum = restrictNum;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "CookMeetDetailInfo{" +
|
||||
|
|
@ -105,6 +136,9 @@ public class CookMeetDetailInfo {
|
|||
", dishesId='" + dishesId + '\'' +
|
||||
", prefPrice='" + prefPrice + '\'' +
|
||||
", salePrice='" + salePrice + '\'' +
|
||||
", supplyNum=" + supplyNum +
|
||||
", surplusNum=" + surplusNum +
|
||||
", restrictNum=" + restrictNum +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -71,9 +71,9 @@ public class UpdateBasicData {
|
|||
public ResponseVo getRecipeInformation() {
|
||||
try {
|
||||
int code = getMealTime();
|
||||
if (code == 1){
|
||||
if (code == 1) {
|
||||
return new ResponseVo(true, 0, "获取菜谱数据成功!");
|
||||
}else{
|
||||
} else {
|
||||
return new ResponseVo(false, 1, "获取餐次信息失败!");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
|
|
@ -88,16 +88,16 @@ public class UpdateBasicData {
|
|||
*
|
||||
* @return
|
||||
*/
|
||||
public ResponseVo getPersonInfo(String time,String type,int userId) {
|
||||
public ResponseVo getPersonInfo(String time, String type, int userId) {
|
||||
try {
|
||||
personNum = 0;
|
||||
DeviceInfo deviceInfo = AppDatabase.getDatabase(context).deviceInfoDao().getDeviceInfoOne();
|
||||
JSONObject json = new JSONObject();
|
||||
if (deviceInfo != null) {
|
||||
if (ObjectUtil.isNull(time)){
|
||||
if (ObjectUtil.isNull(time)) {
|
||||
time = deviceInfo.getFaceUpdateTime();
|
||||
}
|
||||
json.put("updateTime",time);
|
||||
json.put("updateTime", time);
|
||||
} else {
|
||||
json.put("updateTime", "");
|
||||
}
|
||||
|
|
@ -113,7 +113,7 @@ public class UpdateBasicData {
|
|||
Log.i("getPersonMessage result", result);
|
||||
if (!ObjectUtil.isEmpty(result)) {
|
||||
JSONObject jsonObject = JSONObject.parseObject(result);
|
||||
if (jsonObject.containsKey("data")){
|
||||
if (jsonObject.containsKey("data")) {
|
||||
Log.d(TAG, "人员信息更新完成!更新list:" + jsonObject.getString("data"));
|
||||
List<UserInfo> list = new Gson().fromJson(jsonObject.getString("data"), new TypeToken<List<UserInfo>>() {
|
||||
}.getType());
|
||||
|
|
@ -122,10 +122,10 @@ public class UpdateBasicData {
|
|||
AppDatabase.getDatabase(context).userDao().insert(userInfo);
|
||||
}
|
||||
DeviceInfoDao deviceInfoDao = AppDatabase.getDatabase(context).deviceInfoDao();
|
||||
deviceInfoDao.updateUserTime(DateTimeHelper.getTime(),deviceInfoDao.getDeviceInfoOne().getCanteenId());
|
||||
deviceInfoDao.updateUserTime(DateTimeHelper.getTime(), deviceInfoDao.getDeviceInfoOne().getCanteenId());
|
||||
personNum = list.size();
|
||||
Log.d(TAG, "人员更新完成!更新" + personNum + "条数据");
|
||||
}else{
|
||||
} else {
|
||||
return new ResponseVo(true, 0, "获取人员信息成功!更新" + personFaceNum + "条数据");
|
||||
}
|
||||
} else {
|
||||
|
|
@ -151,10 +151,10 @@ public class UpdateBasicData {
|
|||
DeviceInfo deviceInfo = AppDatabase.getDatabase(context).deviceInfoDao().getDeviceInfoOne();
|
||||
JSONObject json = new JSONObject();
|
||||
if (deviceInfo != null) {
|
||||
if (ObjectUtil.isNull(time)){
|
||||
if (ObjectUtil.isNull(time)) {
|
||||
time = deviceInfo.getFaceUpdateTime();
|
||||
}
|
||||
json.put("updateTime",time);
|
||||
json.put("updateTime", time);
|
||||
} else {
|
||||
json.put("updateTime", "");
|
||||
}
|
||||
|
|
@ -174,18 +174,18 @@ public class UpdateBasicData {
|
|||
Log.i("getFacePhoto result", result);
|
||||
if (!ObjectUtil.isEmpty(result)) {
|
||||
JSONObject jsonObject = JSONObject.parseObject(result);
|
||||
if (jsonObject.containsKey("data")){
|
||||
if (jsonObject.containsKey("data")) {
|
||||
List<CustPhotoFulInfo> list = new Gson().fromJson(jsonObject.getString("data"), new TypeToken<List<CustPhotoFulInfo>>() {
|
||||
}.getType());
|
||||
for (CustPhotoFulInfo custPhotoFulInfo : list) {
|
||||
AppDatabase.getDatabase(context).custPhotoFulDao().insert(custPhotoFulInfo);
|
||||
}
|
||||
DeviceInfoDao deviceInfoDao = AppDatabase.getDatabase(context).deviceInfoDao();
|
||||
deviceInfoDao.updateFaceTime(DateTimeHelper.getTime(),deviceInfoDao.getDeviceInfoOne().getCanteenId());
|
||||
deviceInfoDao.updateFaceTime(DateTimeHelper.getTime(), deviceInfoDao.getDeviceInfoOne().getCanteenId());
|
||||
personFaceNum = list.size();
|
||||
Log.d(TAG, "人脸更新完成!更新" + personFaceNum + "条数据");
|
||||
}else{
|
||||
return new ResponseVo(true, 0, "获取人脸信息成功!更新" + personFaceNum + "条数据");
|
||||
} else {
|
||||
return new ResponseVo(true, 0, "获取人脸信息成功!更新" + personFaceNum + "条数据");
|
||||
}
|
||||
} else {
|
||||
Log.d(TAG, "人脸信息更新成功");
|
||||
|
|
@ -219,7 +219,7 @@ public class UpdateBasicData {
|
|||
try {
|
||||
String result = service.httpPost(url, body, context, request);
|
||||
Log.i(TAG, "getMealTime result" + result);
|
||||
if (ObjectUtil.isEmpty(result)){
|
||||
if (ObjectUtil.isEmpty(result)) {
|
||||
return 0;
|
||||
}
|
||||
JSONObject firstJson = JSONObject.parseObject(result);
|
||||
|
|
@ -261,7 +261,6 @@ public class UpdateBasicData {
|
|||
private void getCookBook(MealTimeInfo mealTimeInfo) {
|
||||
JSONObject json = new JSONObject();
|
||||
String jsonString = json.toString();
|
||||
Log.i(TAG, "getCookBook jsonString" + jsonString);
|
||||
// 定义 JSON 的 MediaType
|
||||
MediaType JSON = MediaType.parse("application/json; charset=utf-8");
|
||||
// 创建 RequestBody
|
||||
|
|
@ -336,6 +335,9 @@ public class UpdateBasicData {
|
|||
String dishesId = productBean.getDishesId();
|
||||
String prefPrice = productBean.getPrefPrice();
|
||||
String salePrice = productBean.getSalePrice();
|
||||
int supplyNum = productBean.getSupplyNum();
|
||||
int surplusNum = productBean.getSurplusNum();
|
||||
int restrictNum = productBean.getRestrictNum();
|
||||
cookMeetDetailInfo.setApplyDate(applyDate);
|
||||
cookMeetDetailInfo.setRecipeId(recipeId);
|
||||
cookMeetDetailInfo.setIntervalId(intervalId);
|
||||
|
|
@ -343,6 +345,9 @@ public class UpdateBasicData {
|
|||
cookMeetDetailInfo.setDishesId(dishesId);
|
||||
cookMeetDetailInfo.setPrefPrice(prefPrice);
|
||||
cookMeetDetailInfo.setSalePrice(salePrice);
|
||||
cookMeetDetailInfo.setSupplyNum(supplyNum);
|
||||
cookMeetDetailInfo.setSurplusNum(surplusNum);
|
||||
cookMeetDetailInfo.setRestrictNum(restrictNum);
|
||||
//添加菜品详情信息
|
||||
Log.d(TAG, "getCookBook result cookMeetDetailInfo" + cookMeetDetailInfo);
|
||||
AppDatabase.getDatabase(context).cookMeetDetailDao().insert(cookMeetDetailInfo);
|
||||
|
|
@ -372,11 +377,11 @@ public class UpdateBasicData {
|
|||
try {
|
||||
String result = service.httpPost(url, body, context, request);
|
||||
Log.i("getDeviceBase result", result);
|
||||
if (ObjectUtil.isNotEmpty(result)){
|
||||
if (ObjectUtil.isNotEmpty(result)) {
|
||||
JSONObject jsonObject = JSONObject.parseObject(result);
|
||||
if (jsonObject.getInteger("code") == 200){
|
||||
if (jsonObject.getInteger("code") == 200) {
|
||||
boolean hasData = jsonObject.containsKey("data");
|
||||
if (hasData){
|
||||
if (hasData) {
|
||||
JSONObject data = jsonObject.getJSONObject("data");
|
||||
Log.i("getDeviceBase result", data.toString());
|
||||
DeviceInfo bean = new DeviceInfo();
|
||||
|
|
@ -398,13 +403,13 @@ public class UpdateBasicData {
|
|||
deviceInfoDao.deleteAll();
|
||||
deviceInfoDao.insert(bean);
|
||||
return new ResponseVo(true, 0, "获取设备信息成功!");
|
||||
}else{
|
||||
} else {
|
||||
return new ResponseVo(false, 1, "获取设备信息失败!");
|
||||
}
|
||||
}else{
|
||||
} else {
|
||||
return new ResponseVo(false, 1, jsonObject.getString("msg"));
|
||||
}
|
||||
}else{
|
||||
} else {
|
||||
return new ResponseVo(false, 1, "获取设备信息失败!");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
|
|
@ -428,17 +433,17 @@ public class UpdateBasicData {
|
|||
try {
|
||||
String result = service.httpPost(url, body, context, request);
|
||||
Log.i("getParamSettingInfo result", result);
|
||||
if (result != null){
|
||||
if (result != null) {
|
||||
JSONObject firstJson = JSONObject.parseObject(result);
|
||||
if (firstJson.containsKey("data")) {
|
||||
String data = firstJson.getString("data");
|
||||
ParamSettingInfo paramSettingInfo = AppDatabase.getDatabase(context).parameterInfoDao().getOneInfo();
|
||||
Gson gson = new Gson();
|
||||
ParamSettingInfo bean = gson.fromJson(data, new TypeToken<ParamSettingInfo>() {
|
||||
ParamSettingInfo bean = gson.fromJson(data, new TypeToken<ParamSettingInfo>() {
|
||||
}.getType());
|
||||
if (paramSettingInfo == null){
|
||||
if (paramSettingInfo == null) {
|
||||
AppDatabase.getDatabase(context).parameterInfoDao().insert(bean);
|
||||
}else if (!paramSettingInfo.getVersion().equals(bean.getVersion())){
|
||||
} else if (!paramSettingInfo.getVersion().equals(bean.getVersion())) {
|
||||
AppDatabase.getDatabase(context).parameterInfoDao().deleteAll();
|
||||
AppDatabase.getDatabase(context).parameterInfoDao().insert(bean);
|
||||
}
|
||||
|
|
@ -446,7 +451,7 @@ public class UpdateBasicData {
|
|||
Log.d(TAG, "获取参数设置信息失败!");
|
||||
}
|
||||
Log.d(TAG, "getMealTime result" + result);
|
||||
}else{
|
||||
} else {
|
||||
Log.d(TAG, "获取参数设置信息失败!");
|
||||
return new ResponseVo(true, 1, "获取参数设置信息失败!");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,8 +26,10 @@ import com.bonus.canteen.db.entity.base.ParamSettingInfo;
|
|||
|
||||
public class WorkConfig {
|
||||
//本地
|
||||
protected static String baseUrl = "http://36.33.26.201:48380/smart-canteen";
|
||||
protected static String prefixesUrl = "http://36.33.26.201:48380";
|
||||
protected static String baseUrl = "http://192.168.0.34:48380/smart-canteen";
|
||||
protected static String prefixesUrl = "http://192.168.0.34:48380";
|
||||
// protected static String baseUrl = "http://36.33.26.201:48380/smart-canteen";
|
||||
// protected static String prefixesUrl = "http://36.33.26.201:48380";
|
||||
|
||||
protected static String fileUrl = "http://36.33.26.201:48380/lnyst/";
|
||||
|
||||
|
|
|
|||
Binary file not shown.
Loading…
Reference in New Issue