// 药品结算数据同步
private void getUpdatePrescriptionCharge(String clientVersion) {
// TODO Auto-generated method stub
HashMap<String, String> paramPrescriptionCharge = new HashMap<String, String>();
paramPrescriptionCharge.put("clientVersion",clientVersion);
BaseProtocol updateProtocol = new BaseProtocol(paramPrescriptionCharge);
final String jsonPrescriptionCharge = updateProtocol.toJson();
paramsPrescriptionCharge = new RequestParams();
paramsPrescriptionCharge.addQueryStringParameter("detail", jsonPrescriptionCharge+"&"+DesityUtil.Random());
if(com.hospital.mine.util.Util.prescriptionChargeVO.size()==0)
NetUtils.getData(HttpMethod.POST, ConstantValue.COMMON + ConstantValue.UPDATEDRUGCLEARING_URL , paramsPrescriptionCharge, new RequestCallBack<String>() {
@Override
public void onSuccess(ResponseInfo<String> responseInfo) {
Gson gsonPrescriptionCharge = new Gson();
if (HispitalProtocol.checkResult(responseInfo)) {
final List<PrescriptionChargeVO> fromJsonPrescriptionCharge = gsonPrescriptionCharge.fromJson(
HispitalProtocol.getContentObj(responseInfo)
.toString(),
new TypeToken<List<PrescriptionChargeVO>>() {
}.getType());
new Thread(){
public void run(){
try {
db = DBManager.getInstance(new DBHelper(getActivity())).openDatabase();
db.beginTransaction();
daoPrescriptionCharge = new PrescriptionChargeDaoImpl(db);
List<PrescriptionChargeVO> findAll = daoPrescriptionCharge.findAll();
fromJsonPrescriptionCharge.removeAll(findAll);
for (PrescriptionChargeVO prescriptionChargeVO : fromJsonPrescriptionCharge) {
daoPrescriptionCharge.insert(prescriptionChargeVO);
}
} catch (Exception e) {
e.printStackTrace();
} finally {
if (null != db)
db.endTransaction();
}
}
}.start();
}
}
@Override
public void onFailure(HttpException error, String msg) {
}
});
}
// 处方数据同步
private void getUpdatePrescriptionMain(String clientVersion) {
// TODO Auto-generated method stub
HashMap<String, String> paramPrescriptionMain = new HashMap<String, String>();
paramPrescriptionMain.put("clientVersion",clientVersion);
BaseProtocol updateProtocol = new BaseProtocol(paramPrescriptionMain);
final String jsonPrescriptionMain = updateProtocol.toJson();
paramsPrescriptionMain = new RequestParams();
paramsPrescriptionMain.addQueryStringParameter("detail", jsonPrescriptionMain+"&"+DesityUtil.Random());
if(com.hospital.mine.util.Util.prescriptionMainVO.size()==0)
NetUtils.getData(HttpMethod.POST, ConstantValue.COMMON + ConstantValue.UPDATEPRESCRIPTIONMAIN_URL, paramsPrescriptionMain, new RequestCallBack<String>() {
@Override
public void onSuccess(ResponseInfo<String> responseInfo) {
Gson gsonPrescriptionMain = new Gson();
if (HispitalProtocol.checkResult(responseInfo)) {
final List<PrescriptionMainVO> fromJsonPrescriptionMain = gsonPrescriptionMain.fromJson(
HispitalProtocol.getContentObj(responseInfo)
.toString(),
new TypeToken<List<PrescriptionMainVO>>() {
}.getType());
new Thread(){
public void run(){
try {
db = DBManager.getInstance(new DBHelper(getActivity())).openDatabase();
db.beginTransaction();
daoPrescriptionMain = new PrescriptionMainDaoImpl(db);
List<PrescriptionMainVO> findAll = daoPrescriptionMain.findAll();
fromJsonPrescriptionMain.removeAll(findAll);
for (PrescriptionMainVO prescriptionMainVO : fromJsonPrescriptionMain) {
daoPrescriptionMain.insert(prescriptionMainVO);
}
} catch (Exception e) {
e.printStackTrace();
} finally {
if (null != db)
db.endTransaction();
}
}
}.start();
}
}
@Override
public void onFailure(HttpException error, String msg) {
}
});
}
// 商品数据同步
private void getUpdateCommodityMain(String clientVersion) {
// TODO Auto-generated method stub
HashMap<String, String> paramCommodityMain = new HashMap<String, String>();
paramCommodityMain.put("clientVersion",clientVersion);
BaseProtocol updateProtocol = new BaseProtocol(paramCommodityMain);
final String jsonCommodityMain = updateProtocol.toJson();
paramsCommodityMain = new RequestParams();
paramsCommodityMain.addQueryStringParameter("detail", jsonCommodityMain+"&"+DesityUtil.Random());
if(com.hospital.mine.util.Util.commodityMainVO.size()==0)
NetUtils.getData(HttpMethod.POST, ConstantValue.COMMON + ConstantValue.UPDATECOMMODITYMAIN_URL, paramsCommodityMain, new RequestCallBack<String>() {
@Override
public void onSuccess(ResponseInfo<String> responseInfo) {
Gson gsonCommodityMain = new Gson();
if (HispitalProtocol.checkResult(responseInfo)) {
final List<CommodityMainVO> fromJsonCommodityMain = gsonCommodityMain.fromJson(
HispitalProtocol.getContentObj(responseInfo)
.toString(),
new TypeToken<List<CommodityMainVO>>() {
}.getType());
new Thread(){
public void run(){
try {
db = DBManager.getInstance(new DBHelper(getActivity())).openDatabase();
db.beginTransaction();
daoCommodityMain = new CommodityMainDaoImpl(db);
List<CommodityMainVO> findAll = daoCommodityMain.findAll();
fromJsonCommodityMain.removeAll(findAll);
for (CommodityMainVO commodityMainVO : fromJsonCommodityMain) {
daoCommodityMain.insert(commodityMainVO);
}
} catch (Exception e) {
e.printStackTrace();
} finally {
if (null != db)
db.endTransaction();
}
}
}.start();
}
}
@Override
public void onFailure(HttpException error, String msg) {
}
});
}
// 患者数据同步
private void getUpdatePatient(String clientVersion) {
// TODO Auto-generated method stub
HashMap<String, String> paramPatient = new HashMap<String, String>();
paramPatient.put("clientVersion",clientVersion);
BaseProtocol updateProtocol = new BaseProtocol(paramPatient);
final String jsonPatient = updateProtocol.toJson();
paramsPatient = new RequestParams();
paramsPatient.addQueryStringParameter("detail", jsonPatient+"&"+DesityUtil.Random());
if(com.hospital.mine.util.Util.patientVOPatientVO.size()==0)
NetUtils.getData(HttpMethod.POST, ConstantValue.COMMON + ConstantValue.UPDATEPATIENT_URL, paramsPatient, new RequestCallBack<String>() {
@Override
public void onSuccess(ResponseInfo<String> responseInfo) {
Gson gsonPatient = new Gson();
if (HispitalProtocol.checkResult(responseInfo)) {
final List<PatientVO> fromJsonPatient = gsonPatient.fromJson(
HispitalProtocol.getContentObj(responseInfo)
.toString(),
new TypeToken<List<PatientVO>>() {
}.getType());
new Thread(){
public void run(){
try {
db = DBManager.getInstance(new DBHelper(getActivity())).openDatabase();
db.beginTransaction();
daoPatient = new PatientDaoImpl(db);
List<PatientVO> findAll = daoPatient.findAll();
fromJsonPatient.removeAll(findAll);
for (PatientVO patientVO : fromJsonPatient) {
daoPatient.insert(patientVO);
}
} catch (Exception e) {
e.printStackTrace();
} finally {
if (null != db)
db.endTransaction();
}
}
}.start();
}
}
@Override
public void onFailure(HttpException error, String msg) {
}
});
}
// 字典数据同步
private void getUpdateDictionary(final String clientVersion) {
// TODO Auto-generated method stub
HashMap<String, String> paramDictionary = new HashMap<String, String>();
paramDictionary.put("clientVersion",clientVersion);
BaseProtocol updateProtocol = new BaseProtocol(paramDictionary);
final String jsonDictionary = updateProtocol.toJson();
paramsDictionary = new RequestParams();
paramsDictionary.addQueryStringParameter("detail", jsonDictionary+"&"+DesityUtil.Random());
if(com.hospital.mine.util.Util.sysDicVOListDictionary.size()==0)
NetUtils.getData(HttpMethod.POST, ConstantValue.COMMON + ConstantValue.UPDATEDICTIONARY_URL, paramsDictionary, new RequestCallBack<String>() {
@Override
public void onSuccess(ResponseInfo<String> responseInfo) {
Gson gsonDictionary = new Gson();
if (HispitalProtocol.checkResult(responseInfo)) {
System.out.println("=======responseInfo");
final List<SysDicVO> fromJsonDictionary = gsonDictionary.fromJson(
HispitalProtocol.getContentObj(responseInfo)
.toString(),
new TypeToken<List<SysDicVO>>() {
}.getType());
new Thread(){
public void run(){
try {
db = DBManager.getInstance(new DBHelper(getActivity())).openDatabase();
db.beginTransaction();
daoDictionary = new SysDicDaoImpl(db);
List<SysDicVO> findAll = daoDictionary.findAll();
// for (SysDicVO sysDicVO : fromJsonDictionary) {
//// if(!findAll.contains(sysDicVO)){
//// dao.insert(sysDicVO);
//// }
// for (SysDicVO sysDicVO2 : findAll) {
//
// }
// }
fromJsonDictionary.removeAll(findAll);
for (SysDicVO sysDicVO : fromJsonDictionary) {
daoDictionary.insert(sysDicVO);
}
} catch (Exception e) {
e.printStackTrace();
} finally {
if (null != db)
db.endTransaction();
}
}
}.start();
}
}
@Override
public void onFailure(HttpException error, String msg) {
}
});
}
});