@@ -20,6 +20,10 @@ public class Config { | |||
* 设备唯一码 | |||
*/ | |||
public String autoKey = "1"; | |||
/** | |||
* 管理权限 | |||
*/ | |||
public int adminType = 0; | |||
public Application app; | |||
@@ -37,6 +41,7 @@ public class Config { | |||
public static final String SHARE_KEY_isWeight = "SHARE_KEY_isWeight";//是否是称重模式 | |||
public static final String SHARE_KEY_account = "SHARE_KEY_account";//登录账号 | |||
public static final String SHARE_KEY_password = "SHARE_KEY_password";//登录密码 | |||
public static final String SHARE_KEY_adminType = "SHARE_KEY_adminType";//登录密码 | |||
public static void Test(){ | |||
PreferenceUtils.setString(Config.SHARE_KEY_autoKey,"1"); | |||
@@ -67,6 +72,7 @@ public class Config { | |||
} | |||
isWeight = PreferenceUtils.getBoolean(Config.SHARE_KEY_isWeight,false); | |||
autoKey = PreferenceUtils.getString(Config.SHARE_KEY_autoKey,"1"); | |||
adminType = PreferenceUtils.getInt(Config.SHARE_KEY_adminType,0); | |||
LogUtils.d(" Config.getInstance().autoKey="+Config.getInstance().autoKey); | |||
} | |||
@@ -240,11 +240,7 @@ public class BatchingRecordActivity extends ActivityBase { | |||
float number = 0f; | |||
for(BPA_RecipeBathingUseDetail bean:totalList){ | |||
number = number+bean.getUseWeight(); | |||
// 创建一个DecimalFormat对象,指定格式 | |||
DecimalFormat decimalFormat = new DecimalFormat("#.00"); | |||
// 格式化数字 | |||
String formattedNumber = decimalFormat.format(number); | |||
number = Float.parseFloat(formattedNumber); | |||
} | |||
List<SliceValue> values = new ArrayList<SliceValue>(); | |||
@@ -254,6 +250,11 @@ public class BatchingRecordActivity extends ActivityBase { | |||
nameList.get(i).getColor()).setLabel("["+useNumList.get(i).getName()+"]"+useNumList.get(i).getUseNum()+"")); | |||
number = number-useNumList.get(i).getUseNum();//去掉已选中的 | |||
} | |||
// 创建一个DecimalFormat对象,指定格式 | |||
DecimalFormat decimalFormat = new DecimalFormat("#.00"); | |||
// 格式化数字 | |||
String formattedNumber = decimalFormat.format(number); | |||
number = Float.parseFloat(formattedNumber); | |||
if(number<0){ | |||
number = 0; | |||
} | |||
@@ -155,6 +155,7 @@ public class LoginActivity extends AppCompatActivity { | |||
ToastUtil.showInfo("登录成功!"); | |||
PreferenceUtils.setString(Config.SHARE_KEY_account,binding.etAccount.getText().toString()); | |||
PreferenceUtils.setString(Config.SHARE_KEY_password,binding.etPassword.getText().toString()); | |||
PreferenceUtils.setInt(Config.SHARE_KEY_adminType,userInfo.getAdminType()); | |||
finish(); | |||
}else { | |||
if(!isGetUser){ | |||
@@ -271,6 +271,7 @@ public class RecipeExecuteDialog extends DialogFragment { | |||
BPA_BatchingDao.Properties.Id.eq(bean.getBatchingId())); | |||
if(batching!=null){ | |||
BPA_RecipeBathingUseDetail useDetail1 = new BPA_RecipeBathingUseDetail(); | |||
useDetail1.setRecipeUseId(useDetail.getId()); | |||
useDetail1.setBatchingName(batching.getName()); | |||
useDetail1.setUseWeight(bean.getWeight()); | |||
useDetail1.setUseDate(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date())); | |||
@@ -11,10 +11,12 @@ import androidx.fragment.app.Fragment; | |||
import androidx.lifecycle.ViewModelProvider; | |||
import com.jdzh.jdzhandroid.ActionNotify.NotifyEvent; | |||
import com.jdzh.jdzhandroid.Config.Config; | |||
import com.jdzh.jdzhandroid.Enum.Status; | |||
import com.jdzh.jdzhandroid.databinding.FragmentDebugBinding; | |||
import com.jdzh.jdzhandroid.databinding.FragmentParSetBinding; | |||
import com.jdzh.jdzhandroid.util.DisplayManager; | |||
import com.jdzh.jdzhandroid.util.ToastUtil; | |||
import com.jdzh.jdzhandroid.viewmodel.DebugViewModel; | |||
public class DebugFragment extends Fragment { | |||
@@ -31,20 +33,22 @@ public class DebugFragment extends Fragment { | |||
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { | |||
super.onViewCreated(view, savedInstanceState); | |||
DisplayManager.scaleViewGroup(binding.main); | |||
mViewModel = new ViewModelProvider(this).get(DebugViewModel.class); | |||
binding.setData(mViewModel); | |||
binding.setLifecycleOwner(this); | |||
NotifyEvent.get().<Status>Register("LoadingBtn",(s)->{ | |||
if(s==Status.任务开始){ | |||
binding.loadingBtn.post(()->{ | |||
binding.loadingBtn.start(); | |||
}); | |||
}else if (s==Status.任务结束){ | |||
binding.loadingBtn.post(()->{ | |||
binding.loadingBtn.complete(true); | |||
}); | |||
} | |||
}); | |||
if(Config.getInstance().adminType!=0){ | |||
mViewModel = new ViewModelProvider(this).get(DebugViewModel.class); | |||
binding.setData(mViewModel); | |||
binding.setLifecycleOwner(this); | |||
NotifyEvent.get().<Status>Register("LoadingBtn",(s)->{ | |||
if(s==Status.任务开始){ | |||
binding.loadingBtn.post(()->{ | |||
binding.loadingBtn.start(); | |||
}); | |||
}else if (s==Status.任务结束){ | |||
binding.loadingBtn.post(()->{ | |||
binding.loadingBtn.complete(true); | |||
}); | |||
} | |||
}); | |||
} | |||
} | |||
@@ -10,6 +10,7 @@ import androidx.annotation.NonNull; | |||
import androidx.annotation.Nullable; | |||
import androidx.fragment.app.Fragment; | |||
import com.jdzh.jdzhandroid.Config.Config; | |||
import com.jdzh.jdzhandroid.Enum.DialogButton; | |||
import com.jdzh.jdzhandroid.Interface.IRunT; | |||
import com.jdzh.jdzhandroid.Sqlite.Model.BPA_Batching; | |||
@@ -56,16 +57,28 @@ public class ParSetFragment extends Fragment { | |||
private void ViewInit(){ | |||
binding.MaterialManager.setOnClickListener((v)->{ | |||
if(Config.getInstance().adminType==0){ | |||
ToastUtil.showInfo("对不起,当前账号暂无权限!"); | |||
return; | |||
} | |||
Intent intent = new Intent(getActivity(), MaterialManagerActivity.class); | |||
startActivity(intent); | |||
}); | |||
binding.RecipeManager.setOnClickListener((v)->{ | |||
if(Config.getInstance().adminType==0){ | |||
ToastUtil.showInfo("对不起,当前账号暂无权限!"); | |||
return; | |||
} | |||
Intent intent = new Intent(getActivity(), RecipeManagerActivity.class); | |||
startActivity(intent); | |||
}); | |||
binding.ChannelManager.setOnClickListener((v)->{ | |||
if(Config.getInstance().adminType==0){ | |||
ToastUtil.showInfo("对不起,当前账号暂无权限!"); | |||
return; | |||
} | |||
Intent intent = new Intent(getActivity(), ChannelManagerActivity.class); | |||
startActivity(intent); | |||
}); | |||
@@ -85,6 +98,8 @@ public class ParSetFragment extends Fragment { | |||
uploadBatching(); | |||
}); | |||
binding.btnDownloadRecipe.setVisibility(Config.getInstance().adminType==0?View.GONE:View.VISIBLE); | |||
binding.btnUploadRecipe.setVisibility(Config.getInstance().adminType==0?View.GONE:View.VISIBLE); | |||
} | |||
/** | |||
@@ -11,6 +11,7 @@ import androidx.annotation.NonNull; | |||
import androidx.annotation.Nullable; | |||
import androidx.fragment.app.Fragment; | |||
import com.jdzh.jdzhandroid.Config.Config; | |||
import com.jdzh.jdzhandroid.Enum.DialogButton; | |||
import com.jdzh.jdzhandroid.Sqlite.DAO.BPA_RecipeUseDetailDao; | |||
import com.jdzh.jdzhandroid.Sqlite.Model.BPA_RecipeUseDetail; | |||
@@ -62,6 +63,10 @@ public class RecordFragment extends Fragment { | |||
startActivity(intent); | |||
}); | |||
binding.btnUploadUse.setVisibility(Config.getInstance().adminType==0?View.GONE:View.VISIBLE); | |||
binding.btnUploadCrash.setVisibility(Config.getInstance().adminType==0?View.GONE:View.VISIBLE); | |||
binding.btnUploadLog.setVisibility(Config.getInstance().adminType==0?View.GONE:View.VISIBLE); | |||
binding.btnUploadUse.setOnClickListener(v->{ | |||
uploadRecipeUseDetail(); | |||
}); | |||
@@ -1,5 +1,6 @@ | |||
package com.jdzh.jdzhandroid.UI.fragment; | |||
import android.annotation.SuppressLint; | |||
import android.content.Intent; | |||
import android.os.Bundle; | |||
import android.view.LayoutInflater; | |||
@@ -55,7 +56,10 @@ public class SystemSetFragment extends Fragment { | |||
dataBean.setContactPhone(PreferenceUtils.getString(Config.SHARE_KEY_wePhone,"")); | |||
changeView(dataBean); | |||
binding.btnSave.setOnClickListener(v->{ | |||
if(Config.getInstance().adminType==0){ | |||
ToastUtil.showInfo("对不起,当前账号暂无权限!"); | |||
return; | |||
} | |||
Config.getInstance().autoKey = binding.edtDeviceKey.getText().toString(); | |||
PreferenceUtils.setString(Config.SHARE_KEY_autoKey,Config.getInstance().autoKey); | |||
@@ -95,6 +99,7 @@ public class SystemSetFragment extends Fragment { | |||
} | |||
@SuppressLint("SetTextI18n") | |||
private void changeView(DeviceInfoDataBean data){ | |||
if(data!=null){ | |||
PreferenceUtils.setString(Config.SHARE_KEY_deviceId,data.getDeviceId()); | |||
@@ -104,12 +109,12 @@ public class SystemSetFragment extends Fragment { | |||
PreferenceUtils.setString(Config.SHARE_KEY_storePhone,data.getStorePhone()); | |||
PreferenceUtils.setString(Config.SHARE_KEY_wePhone,data.getContactPhone()); | |||
binding.tvDeviceKey.setText("设备编号:"+data.getDeviceId()); | |||
binding.tvCompanyName.setText("主体单位:"+data.getOrgName()); | |||
binding.tvDeviceLocation.setText("设备位置:"+data.getDevicePosition()); | |||
binding.tvStoreLocation.setText("门店信息:"+data.getStoreName()); | |||
binding.tvPhoneNumber.setText("联系电话:"+data.getStorePhone()); | |||
binding.tvPhoneAdmin.setText("联系我们:"+data.getContactPhone()); | |||
binding.tvDeviceKey.setText("设备编号:"+(data.getDeviceId()==null?"":data.getDeviceId())); | |||
binding.tvCompanyName.setText("主体单位:"+(data.getOrgName()==null?"":data.getOrgName())); | |||
binding.tvDeviceLocation.setText("设备位置:"+(data.getDevicePosition()==null?"":data.getDevicePosition())); | |||
binding.tvStoreLocation.setText("门店信息:"+(data.getStoreName()==null?"":data.getStoreName())); | |||
binding.tvPhoneNumber.setText("联系电话:"+(data.getStorePhone()==null?"":data.getStorePhone())); | |||
binding.tvPhoneAdmin.setText("联系我们:"+(data.getContactPhone()==null?"":data.getContactPhone())); | |||
// binding.tvLocationAdmin.setText(""); | |||
}else { | |||
binding.tvDeviceKey.setText("设备编号:"); | |||
@@ -31,8 +31,8 @@ | |||
android:layout_alignParentEnd="true" | |||
/> | |||
<TextView | |||
android:layout_width="20dp" | |||
android:layout_height="20dp" | |||
android:layout_width="@dimen/dp40" | |||
android:layout_height="@dimen/dp40" | |||
android:background="@mipmap/ic_clear_white_48dp" | |||
android:layout_alignParentEnd="true" | |||
/> | |||