浏览代码

修改账单表中的金额数据类型

Xieshengqi 6 年之前
父节点
当前提交
cb39a58f3a

+ 6 - 6
MoneyNote_Sqlite/src/main/java/com/kuxuan/sqlite/dao/CategoryDBDao.java

@@ -30,7 +30,7 @@ public class CategoryDBDao extends AbstractDao<CategoryDB, Long> {
30 30
         public final static Property Name = new Property(3, String.class, "name", false, "NAME");
31 31
         public final static Property Type = new Property(4, int.class, "type", false, "TYPE");
32 32
         public final static Property Image_path = new Property(5, String.class, "image_path", false, "IMAGE_PATH");
33
-        public final static Property Account = new Property(6, long.class, "account", false, "ACCOUNT");
33
+        public final static Property Account = new Property(6, double.class, "account", false, "ACCOUNT");
34 34
         public final static Property Category_id = new Property(7, int.class, "category_id", false, "CATEGORY_ID");
35 35
         public final static Property Year = new Property(8, int.class, "year", false, "YEAR");
36 36
         public final static Property Month = new Property(9, int.class, "month", false, "MONTH");
@@ -59,7 +59,7 @@ public class CategoryDBDao extends AbstractDao<CategoryDB, Long> {
59 59
                 "\"NAME\" TEXT," + // 3: name
60 60
                 "\"TYPE\" INTEGER NOT NULL ," + // 4: type
61 61
                 "\"IMAGE_PATH\" TEXT," + // 5: image_path
62
-                "\"ACCOUNT\" INTEGER NOT NULL ," + // 6: account
62
+                "\"ACCOUNT\" REAL NOT NULL ," + // 6: account
63 63
                 "\"CATEGORY_ID\" INTEGER NOT NULL ," + // 7: category_id
64 64
                 "\"YEAR\" INTEGER NOT NULL ," + // 8: year
65 65
                 "\"MONTH\" INTEGER NOT NULL ," + // 9: month
@@ -104,7 +104,7 @@ public class CategoryDBDao extends AbstractDao<CategoryDB, Long> {
104 104
         if (image_path != null) {
105 105
             stmt.bindString(6, image_path);
106 106
         }
107
-        stmt.bindLong(7, entity.getAccount());
107
+        stmt.bindDouble(7, entity.getAccount());
108 108
         stmt.bindLong(8, entity.getCategory_id());
109 109
         stmt.bindLong(9, entity.getYear());
110 110
         stmt.bindLong(10, entity.getMonth());
@@ -143,7 +143,7 @@ public class CategoryDBDao extends AbstractDao<CategoryDB, Long> {
143 143
         if (image_path != null) {
144 144
             stmt.bindString(6, image_path);
145 145
         }
146
-        stmt.bindLong(7, entity.getAccount());
146
+        stmt.bindDouble(7, entity.getAccount());
147 147
         stmt.bindLong(8, entity.getCategory_id());
148 148
         stmt.bindLong(9, entity.getYear());
149 149
         stmt.bindLong(10, entity.getMonth());
@@ -167,7 +167,7 @@ public class CategoryDBDao extends AbstractDao<CategoryDB, Long> {
167 167
             cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // name
168 168
             cursor.getInt(offset + 4), // type
169 169
             cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // image_path
170
-            cursor.getLong(offset + 6), // account
170
+            cursor.getDouble(offset + 6), // account
171 171
             cursor.getInt(offset + 7), // category_id
172 172
             cursor.getInt(offset + 8), // year
173 173
             cursor.getInt(offset + 9), // month
@@ -187,7 +187,7 @@ public class CategoryDBDao extends AbstractDao<CategoryDB, Long> {
187 187
         entity.setName(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3));
188 188
         entity.setType(cursor.getInt(offset + 4));
189 189
         entity.setImage_path(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5));
190
-        entity.setAccount(cursor.getLong(offset + 6));
190
+        entity.setAccount(cursor.getDouble(offset + 6));
191 191
         entity.setCategory_id(cursor.getInt(offset + 7));
192 192
         entity.setYear(cursor.getInt(offset + 8));
193 193
         entity.setMonth(cursor.getInt(offset + 9));

+ 10 - 4
MoneyNote_Sqlite/src/main/java/com/kuxuan/sqlite/db/CategoryDB.java

@@ -62,7 +62,7 @@ public class CategoryDB {
62 62
     /**
63 63
      * 账单金额
64 64
      */
65
-    private long account;
65
+    private double account;
66 66
 
67 67
     /**
68 68
      * 类别id
@@ -102,9 +102,9 @@ public class CategoryDB {
102 102
 
103 103
 
104 104
 
105
-    @Generated(hash = 708261383)
105
+    @Generated(hash = 1427463647)
106 106
     public CategoryDB(Long id, String bill_id, String demo, String name, int type,
107
-            String image_path, long account, int category_id, int year, int month,
107
+            String image_path, double account, int category_id, int year, int month,
108 108
             int day, long createTime, long updateTime, int user_id) {
109 109
         this.id = id;
110 110
         this.bill_id = bill_id;
@@ -190,7 +190,7 @@ public class CategoryDB {
190 190
 
191 191
 
192 192
 
193
-    public long getAccount() {
193
+    public Double getAccount() {
194 194
         return this.account;
195 195
     }
196 196
 
@@ -296,4 +296,10 @@ public class CategoryDB {
296 296
         this.image_path = image_path;
297 297
     }
298 298
 
299
+
300
+
301
+    public void setAccount(double account) {
302
+        this.account = account;
303
+    }
304
+
299 305
 }

+ 3 - 3
app/src/main/java/com/kuxuan/moneynote/db/CategoryDBbean.java

@@ -38,7 +38,7 @@ public class CategoryDBbean implements Serializable{
38 38
     /**
39 39
      * 账单金额
40 40
      */
41
-    private long account;
41
+    private double account;
42 42
 
43 43
     /**
44 44
      * 类别id
@@ -124,11 +124,11 @@ public class CategoryDBbean implements Serializable{
124 124
         this.type = type;
125 125
     }
126 126
 
127
-    public long getAccount() {
127
+    public double getAccount() {
128 128
         return account;
129 129
     }
130 130
 
131
-    public void setAccount(long account) {
131
+    public void setAccount(double account) {
132 132
         this.account = account;
133 133
     }
134 134
 

+ 2 - 2
app/src/main/java/com/kuxuan/moneynote/ui/activitys/account/AccountModel.java

@@ -107,7 +107,7 @@ public class AccountModel implements AccountContract.AccountModel {
107 107
         categoryDBbean.setDemo(billBody.getDemo());
108 108
         categoryDBbean.setName(name);
109 109
         categoryDBbean.setType_imagepath(BillCategoreDaoOperator.newInstance().getDetaillIconUrlById(Integer.parseInt(billBody.getCategory_id())));
110
-        categoryDBbean.setAccount(Long.parseLong(billBody.getAccount()));
110
+        categoryDBbean.setAccount(Double.parseDouble(billBody.getAccount()));
111 111
         categoryDBbean.setBill_id(bill_id);
112 112
         CategoryDaoOperator.newInstance().updateData(categoryDBbean);
113 113
         listMVPListener.onSuccess(new Object());
@@ -137,7 +137,7 @@ public class AccountModel implements AccountContract.AccountModel {
137 137
         categoryDBbean.setDemo(billBody.getDemo());
138 138
         categoryDBbean.setName(name);
139 139
         categoryDBbean.setType_imagepath(BillCategoreDaoOperator.newInstance().getDetaillIconUrlById(Integer.parseInt(billBody.getCategory_id())));
140
-        categoryDBbean.setAccount(Long.parseLong(billBody.getAccount()));
140
+        categoryDBbean.setAccount(Double.parseDouble(billBody.getAccount()));
141 141
         Random random = new Random();
142 142
         boolean insert = CategoryDaoOperator.newInstance().insert(categoryDBbean, false);
143 143
         if (insert) {

+ 1 - 1
app/src/main/java/com/kuxuan/moneynote/ui/activitys/account/AccountPresenter.java

@@ -114,7 +114,7 @@ public class AccountPresenter extends AccountContract.AccountPresent {
114 114
 
115 115
             @Override
116 116
             public void onFail(String msg) {
117
-                view.hideProgress();
117
+                    view.hideProgress();
118 118
                 view.showMsg(msg);
119 119
             }
120 120
         }, billBody, name);

+ 4 - 4
app/src/main/java/com/kuxuan/moneynote/ui/fragments/details/DetialDBOpertor.java

@@ -86,15 +86,15 @@ public class DetialDBOpertor {
86 86
         } else {
87 87
             billData = new BillData();
88 88
         }
89
-        long pay_account = 0;
90
-        long inCome_account = 0;
89
+        double pay_account = 0;
90
+        double inCome_account = 0;
91 91
         for (TypeDataJson typeDataJson : day_datas) {
92 92
             if (typeDataJson.getType() == 1) {
93 93
                 //收入
94
-                inCome_account += Long.parseLong(typeDataJson.getAccount());
94
+                inCome_account += Double.parseDouble(typeDataJson.getAccount());
95 95
             } else {
96 96
                 //支出
97
-                pay_account += Long.parseLong(typeDataJson.getAccount());
97
+                pay_account += Double.parseDouble(typeDataJson.getAccount());
98 98
             }
99 99
         }
100 100
         billData.setDay_income_account((int) inCome_account);

+ 19 - 19
app/src/main/java/com/kuxuan/moneynote/ui/fragments/reportsingle/ReportSingleDBOpertor.java

@@ -174,16 +174,16 @@ public class ReportSingleDBOpertor {
174 174
         }
175 175
         if (category_id == -1) {
176 176
             ArrayList<TypeDataJson> categLists = getCategLists(typeDataJsonLists);
177
-            long account = 0;
177
+            double account = 0;
178 178
             for (TypeDataJson typeDataJson : categLists) {
179
-                account += Long.parseLong(typeDataJson.getAccount());
179
+                account += Double.parseDouble(typeDataJson.getAccount());
180 180
             }
181 181
             newCategoryJson.setAccount(account + "");
182 182
             newCategoryJson.setCategory(typeDataJsonLists);
183 183
         } else {
184
-            long account = 0;
184
+            double account = 0;
185 185
             for (TypeDataJson typeDataJson : detialDataLists) {
186
-                account += Long.parseLong(typeDataJson.getAccount());
186
+                account += Double.parseDouble(typeDataJson.getAccount());
187 187
             }
188 188
             newCategoryJson.setAccount(account + "");
189 189
             newCategoryJson.setDetial_data(detialDataLists);
@@ -222,16 +222,16 @@ public class ReportSingleDBOpertor {
222 222
         }
223 223
         if (category_id == -1) {
224 224
             ArrayList<TypeDataJson> categLists = getCategLists(typeDataJsonLists);
225
-            long account = 0;
225
+            double account = 0;
226 226
             for (TypeDataJson typeDataJson : categLists) {
227
-                account += Long.parseLong(typeDataJson.getAccount());
227
+                account += Double.parseDouble(typeDataJson.getAccount());
228 228
             }
229 229
             newCategoryJson.setAccount(account + "");
230 230
             newCategoryJson.setCategory(typeDataJsonLists);
231 231
         } else {
232
-            long account = 0;
232
+            double account = 0;
233 233
             for (TypeDataJson typeDataJson : detialDataLists) {
234
-                account += Long.parseLong(typeDataJson.getAccount());
234
+                account += Double.parseDouble(typeDataJson.getAccount());
235 235
             }
236 236
             newCategoryJson.setAccount(account + "");
237 237
             newCategoryJson.setDetial_data(detialDataLists);
@@ -267,16 +267,16 @@ public class ReportSingleDBOpertor {
267 267
         }
268 268
         if (category_id == -1) {
269 269
             ArrayList<TypeDataJson> categLists = getCategLists(typeDataJsonLists);
270
-            long account = 0;
270
+            double account = 0;
271 271
             for (TypeDataJson typeDataJson : categLists) {
272
-                account += Long.parseLong(typeDataJson.getAccount());
272
+                account += Double.parseDouble(typeDataJson.getAccount());
273 273
             }
274 274
             newCategoryJson.setAccount(account + "");
275 275
             newCategoryJson.setCategory(typeDataJsonLists);
276 276
         } else {
277
-            long account = 0;
277
+            double account = 0;
278 278
             for (TypeDataJson typeDataJson : detialDataLists) {
279
-                account += Long.parseLong(typeDataJson.getAccount());
279
+                account += Double.parseDouble(typeDataJson.getAccount());
280 280
             }
281 281
             newCategoryJson.setAccount(account + "");
282 282
             newCategoryJson.setDetial_data(detialDataLists);
@@ -309,9 +309,9 @@ public class ReportSingleDBOpertor {
309 309
             typeDataJson.setTime(year + "/" + String.format("%02d", month) + "/" + String.format("%02d", day));
310 310
             data.add(typeDataJson);
311 311
         }
312
-        long account = 0;
312
+        double account = 0;
313 313
         for (PopCharData typeDataJson : data) {
314
-            account += Long.parseLong(typeDataJson.getAccount());
314
+            account += Double.parseDouble(typeDataJson.getAccount());
315 315
         }
316 316
         timeDataJson.setData(data);
317 317
         if (account > 0) {
@@ -344,9 +344,9 @@ public class ReportSingleDBOpertor {
344 344
             typeDataJson.setTime(year + "/" + String.format("%02d", month) + "/" + String.format("%02d", day));
345 345
             data.add(typeDataJson);
346 346
         }
347
-        long account = 0;
347
+        double account = 0;
348 348
         for (PopCharData typeDataJson : data) {
349
-            account += Long.parseLong(typeDataJson.getAccount());
349
+            account += Double.parseDouble(typeDataJson.getAccount());
350 350
         }
351 351
         timeDataJson.setData(data);
352 352
         if (account > 0) {
@@ -380,9 +380,9 @@ public class ReportSingleDBOpertor {
380 380
             typeDataJson.setTime(year + "/" + String.format("%02d", month) + "/" + String.format("%02d", monthData.get(i).getDay()));
381 381
             data.add(typeDataJson);
382 382
         }
383
-        long account = 0;
383
+        double account = 0;
384 384
         for (PopCharData typeDataJson : data) {
385
-            account += Long.parseLong(typeDataJson.getAccount());
385
+            account += Double.parseDouble(typeDataJson.getAccount());
386 386
         }
387 387
         timeDataJson.setData(data);
388 388
         if (account > 0) {
@@ -420,7 +420,7 @@ public class ReportSingleDBOpertor {
420 420
                         t.setType(typeDataJson.getType());
421 421
                     } else {
422 422
                         //累加总值
423
-                        t.setAccount(Long.parseLong(t.getAccount()) + Long.parseLong(typeDataJson.getAccount()) + "");
423
+                        t.setAccount(Double.parseDouble(t.getAccount()) + Double.parseDouble(typeDataJson.getAccount()) + "");
424 424
                     }
425 425
                 }
426 426
             }