| | |
| | | package cn.com.basic.face.service;
|
| | |
|
| | | import android.widget.Toast;
|
| | |
|
| | | import cn.com.basic.face.base.BaseApplication;
|
| | | import cn.com.basic.face.base.MainActivity;
|
| | | import cn.com.basic.face.dialog.CountryDialog;
|
| | | import cn.com.basic.face.dialog.SelectDialog;
|
| | | import cn.com.basic.face.discern.query.condition.DictionaryQueryCondition;
|
| | | import cn.com.basic.face.discern.query.item.PhoneCallQueryItem;
|
| | | import cn.com.basic.face.util.AppApi;
|
| | |
|
| | | import org.xutils.http.RequestParams;
|
| | |
| | | import cn.com.basic.face.discern.common.CommonVariables;
|
| | | import cn.com.basic.face.discern.entity.Dictionary;
|
| | | import cn.com.basic.face.util.CharacterParser;
|
| | | import cn.com.basic.face.util.Constant;
|
| | |
|
| | | public class DictionaryMng {
|
| | | public class DictionaryMng extends BaseMng {
|
| | |
|
| | | public static DictionaryMng instance = new DictionaryMng();
|
| | |
|
| | |
| | | return instance;
|
| | | }
|
| | |
|
| | | public Map<String, String> idMap = new HashMap<String, String>();
|
| | |
|
| | | public String getId(String name) {
|
| | | return idMap.get(name);
|
| | | }
|
| | |
|
| | | public void loadAllDictionaryData() {
|
| | | if (!BaseApplication.deviceAvailable) {
|
| | | return;
|
| | | }
|
| | | loadCountries();
|
| | | loadIdTypeList();
|
| | | loadGenderList();
|
| | | loadVisitReasonList();
|
| | | loadVisitorTypeList();
|
| | | loadResolutionList();
|
| | | loadProtocolList();
|
| | | loadCameraBrandList();
|
| | | DepartmentMng.getInstance().loadDepartmentDictionary();
|
| | | PostMng.getInstance().loadPostDictionary();
|
| | | }
|
| | |
|
| | | public void loadCountries() {
|
| | | if (!BaseApplication.deviceAvailable) {
|
| | | return;
|
| | | }
|
| | | RequestParams params = new RequestParams(AppApi.BASE_URL +AppApi.Query.DICTIONARY_QUERY);
|
| | | params.addParameter(DictionaryQueryCondition.FieldNames.type, CommonVariables.DictionaryType.COUNTRY);
|
| | | x.http().get(params, new BaseCommonCallBack() {
|
| | |
| | | }
|
| | |
|
| | | private void sortCountries(List<Dictionary> countries) {
|
| | | if (!BaseApplication.deviceAvailable) {
|
| | | return;
|
| | | }
|
| | | Collections.sort(countries, new Comparator<Dictionary>() {
|
| | | @Override
|
| | | public int compare(Dictionary t1, Dictionary t2) {
|
| | |
| | | }
|
| | |
|
| | | public void loadIdTypeList() {
|
| | | if (!BaseApplication.deviceAvailable) {
|
| | | return;
|
| | | }
|
| | | RequestParams params = new RequestParams(AppApi.BASE_URL +AppApi.Query.DICTIONARY_QUERY);
|
| | | params.addParameter(DictionaryQueryCondition.FieldNames.type, CommonVariables.DictionaryType.ID_TYPE);
|
| | | x.http().get(params, new BaseCommonCallBack() {
|
| | |
| | | }
|
| | |
|
| | | private void loadGenderList() {
|
| | | if (!BaseApplication.deviceAvailable) {
|
| | | return;
|
| | | }
|
| | | RequestParams params = new RequestParams(AppApi.BASE_URL +AppApi.Query.DICTIONARY_QUERY);
|
| | | params.addParameter(DictionaryQueryCondition.FieldNames.type, CommonVariables.DictionaryType.GENDER);
|
| | | x.http().get(params, new BaseCommonCallBack() {
|
| | |
| | | }
|
| | |
|
| | | public void loadVisitReasonList() {
|
| | | if (!BaseApplication.deviceAvailable) {
|
| | | return;
|
| | | }
|
| | | RequestParams params = new RequestParams(AppApi.BASE_URL +AppApi.Query.DICTIONARY_QUERY);
|
| | | params.addParameter(DictionaryQueryCondition.FieldNames.type, CommonVariables.DictionaryType.VISIT_REASON);
|
| | | x.http().get(params, new BaseCommonCallBack() {
|
| | |
| | | });
|
| | | }
|
| | |
|
| | | public List<String> getDictionaryNameList(List<Dictionary> dictionaryList) {
|
| | | List nameList = new ArrayList();
|
| | | for (Dictionary dictionary : dictionaryList) {
|
| | | idMap.put(dictionary.getName(), dictionary.getDictId()+"");
|
| | | nameList.add(dictionary.getName());
|
| | | public void loadResolutionList() {
|
| | | if (!BaseApplication.deviceAvailable) {
|
| | | return;
|
| | | }
|
| | | return nameList;
|
| | | RequestParams params = new RequestParams(AppApi.BASE_URL +AppApi.Query.DICTIONARY_QUERY);
|
| | | params.addParameter(DictionaryQueryCondition.FieldNames.type, CommonVariables.DictionaryType.RESOLUTION);
|
| | | x.http().get(params, new BaseCommonCallBack() {
|
| | | public void success() {
|
| | | SelectDialog.setResolutionList(getDictionaryNameList(getList(Dictionary.class)));
|
| | | }
|
| | | });
|
| | | }
|
| | |
|
| | | public void loadProtocolList() {
|
| | | if (!BaseApplication.deviceAvailable) {
|
| | | return;
|
| | | }
|
| | | RequestParams params = new RequestParams(AppApi.BASE_URL +AppApi.Query.DICTIONARY_QUERY);
|
| | | params.addParameter(DictionaryQueryCondition.FieldNames.type, CommonVariables.DictionaryType.PROTOCOL);
|
| | | x.http().get(params, new BaseCommonCallBack() {
|
| | | public void success() {
|
| | | SelectDialog.setProtocolList(getDictionaryNameList(getList(Dictionary.class)));
|
| | | }
|
| | | });
|
| | | }
|
| | |
|
| | | public void loadCameraBrandList() {
|
| | | if (!BaseApplication.deviceAvailable) {
|
| | | return;
|
| | | }
|
| | | RequestParams params = new RequestParams(AppApi.BASE_URL +AppApi.Query.DICTIONARY_QUERY);
|
| | | params.addParameter(DictionaryQueryCondition.FieldNames.type, CommonVariables.DictionaryType.CAMERA_BRAND);
|
| | | x.http().get(params, new BaseCommonCallBack() {
|
| | | public void success() {
|
| | | SelectDialog.setCameraBrandList(getDictionaryNameList(getList(Dictionary.class)));
|
| | | }
|
| | | });
|
| | | }
|
| | |
|
| | | private void loadVisitorTypeList() {
|
| | | if (!BaseApplication.deviceAvailable) {
|
| | | return;
|
| | | }
|
| | | RequestParams params = new RequestParams(AppApi.BASE_URL +AppApi.Query.DICTIONARY_QUERY);
|
| | | params.addParameter(DictionaryQueryCondition.FieldNames.type, CommonVariables.DictionaryType.VISIT_TYPE);
|
| | | params.addParameter(DictionaryQueryCondition.FieldNames.type, CommonVariables.DictionaryType.VISITOR_TYPE);
|
| | | x.http().get(params, new BaseCommonCallBack() {
|
| | | public void success() {
|
| | | SelectDialog.setVisitorTypeList(getDictionaryNameList(getList(Dictionary.class)));
|
| | |
| | | });
|
| | | }
|
| | |
|
| | |
|
| | | private void loadAttenderTypeList() {
|
| | | if (!BaseApplication.deviceAvailable) {
|
| | | return;
|
| | | }
|
| | | RequestParams params = new RequestParams(AppApi.BASE_URL +AppApi.Query.DICTIONARY_QUERY);
|
| | | params.addParameter(DictionaryQueryCondition.FieldNames.type, CommonVariables.DictionaryType.ATTENDER_TYPE);
|
| | | x.http().get(params, new BaseCommonCallBack() {
|
| | | public void success() {
|
| | | SelectDialog.setAttenderTypeList(getDictionaryNameList(getList(Dictionary.class)));
|
| | | }
|
| | | });
|
| | | }
|
| | |
|
| | | public void addDictionary(final int type, String type1, String name) {
|
| | | RequestParams params = new RequestParams(AppApi.BASE_URL +AppApi.DICTIONARY_ADD);
|
| | | params.addBodyParameter(Dictionary.FieldNames.type, type1);
|
| | | params.addBodyParameter(Dictionary.FieldNames.name, name);
|
| | | params.addBodyParameter(Dictionary.FieldNames.orderBy, "10");
|
| | | x.http().post(params, new BaseCommonCallBack() {
|
| | | public void success() {
|
| | | List<Dictionary> items = getList(Dictionary.class);
|
| | | switch (type) {
|
| | | case Constant.DialogSelectType.VISIT_REASON:
|
| | | break;
|
| | | case Constant.DialogSelectType.RESOLUTION:
|
| | | SelectDialog.setResolutionList(getDictionaryNameList(getList(Dictionary.class)));
|
| | | break;
|
| | | case Constant.DialogSelectType.PROTOCOL:
|
| | | SelectDialog.setProtocolList(getDictionaryNameList(getList(Dictionary.class)));
|
| | | break;
|
| | | case Constant.DialogSelectType.CAMERA_BRAND:
|
| | | SelectDialog.setCameraBrandList(getDictionaryNameList(getList(Dictionary.class)));
|
| | | break;
|
| | | }
|
| | | Toast.makeText(MainActivity.getInstance(), "添加成功", Toast.LENGTH_SHORT).show();
|
| | | }
|
| | | });
|
| | | }
|
| | |
|
| | | }
|