|
|
@@ -117,6 +117,54 @@ public class MissionDao {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ public boolean updataOrCreate(MissionModel mission) {
|
|
|
+ if (mission == null || StringUtils.isEmpty(mission.getVisitTime()))return false;
|
|
|
+ show("updataOrCreate");
|
|
|
+ SQLiteDatabase db = null;
|
|
|
+ long i = 0;
|
|
|
+ try {
|
|
|
+ String master = CommonUtil.getSharedPreferences(MyApplication.getInstance(), "erp_master");
|
|
|
+ String emcode = CommonUtil.getSharedPreferences(MyApplication.getInstance(), "erp_username");
|
|
|
+ if (StringUtils.isEmpty(master) || StringUtils.isEmpty(emcode)) return false;
|
|
|
+ db = helper.getWritableDatabase();
|
|
|
+ ContentValues values = null;
|
|
|
+ show("MissionPlanEntity");
|
|
|
+ //对象为空或是拜访时间没有情况下不插入数据库
|
|
|
+ values = new ContentValues();
|
|
|
+ values.put("id", mission.getId());
|
|
|
+ values.put("master", master);
|
|
|
+ values.put("emcode", emcode);
|
|
|
+ values.put("company", mission.getCompanyName());
|
|
|
+ values.put("companyAddr", mission.getCompanyAddr());
|
|
|
+ if (mission.getLatLng() != null) {
|
|
|
+ values.put("latitude", mission.getLatLng().latitude);
|
|
|
+ values.put("longitude", mission.getLatLng().longitude);
|
|
|
+ }
|
|
|
+ values.put("visittime", mission.getVisitTime());
|
|
|
+ values.put("realvisitTime", mission.getRealTime());
|
|
|
+ values.put("realLeaveTime", mission.getRealLeave());
|
|
|
+ values.put("distance", mission.getDistance());
|
|
|
+ values.put("location", mission.getLocation());
|
|
|
+ values.put("recorddate", mission.getRecorddate());
|
|
|
+ values.put("date", getDateByString(mission.getVisitTime()));//拜访日期
|
|
|
+ i = db.insert(tibleName, "status", values);
|
|
|
+ if (i == -1) {
|
|
|
+ String where = "master=? and emcode=? and id=? ";
|
|
|
+ String[] whereArgs = {master, emcode, String.valueOf(mission.getId())};
|
|
|
+ i = db.update(tibleName, values, where, whereArgs);
|
|
|
+ show("update i=" + i);
|
|
|
+ }
|
|
|
+ show("i====" + i);
|
|
|
+ } catch (android.database.SQLException e) {
|
|
|
+ show("SQLException=" + e.getMessage());
|
|
|
+ } catch (Exception e) {
|
|
|
+ show("Exception=" + e.getMessage());
|
|
|
+ } finally {
|
|
|
+ if (db != null)
|
|
|
+ db.close();
|
|
|
+ return i > 0;
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
public boolean updataOrCreate(List<MissionModel> entities) {
|
|
|
if (ListUtils.isEmpty(entities)) return false;
|