|
|
@@ -51,7 +51,7 @@ public class DataChange {
|
|
|
try {
|
|
|
decimal = new BigDecimal(str);
|
|
|
} catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
+ System.out.println(data + ":数据解析失败!返回0");
|
|
|
return new BigDecimal(0);
|
|
|
}
|
|
|
}
|
|
|
@@ -90,7 +90,12 @@ public class DataChange {
|
|
|
for (String s : key) {
|
|
|
//从map中取 date的值 并转换成字符串类型的日期
|
|
|
String stringDate = dateToDayDate(map.get(s));
|
|
|
- map.put(s, stringDate);
|
|
|
+ if(stringDate.length() == 0){
|
|
|
+ break;
|
|
|
+ }else {
|
|
|
+ //修改map中的值
|
|
|
+ map.put(s, stringDate);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -105,10 +110,15 @@ public class DataChange {
|
|
|
for (Map<String, Object> map : list) {
|
|
|
for (String s : key) {
|
|
|
//修改数据为带两位小数
|
|
|
- BigDecimal oldDate = (BigDecimal) map.get(s);
|
|
|
- DecimalFormat df = new DecimalFormat("0.00");
|
|
|
- String resultDeduction = df.format(oldDate.doubleValue());
|
|
|
- map.put(s, resultDeduction);
|
|
|
+ try {
|
|
|
+ BigDecimal oldDate = (BigDecimal) map.get(s);
|
|
|
+ DecimalFormat df = new DecimalFormat("0.00");
|
|
|
+ String resultDeduction = df.format(oldDate.doubleValue());
|
|
|
+ map.put(s, resultDeduction);
|
|
|
+ } catch (Exception e) {
|
|
|
+ System.out.println("原料扣减量数据有误");
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -156,4 +166,26 @@ public class DataChange {
|
|
|
return sb.toString();
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 根据时间段查询数据
|
|
|
+ * @Author TXF
|
|
|
+ * @Date 2022/1/10 23:21
|
|
|
+ * @param startTime
|
|
|
+ * @param endTime
|
|
|
+ * @param map
|
|
|
+ * @param sdf
|
|
|
+ * @return
|
|
|
+ **/
|
|
|
+ public static void queryDataByDate(String startTime, String endTime, Map<String, Object> map, SimpleDateFormat sdf){
|
|
|
+ if (startTime != null && !"null".equals(startTime) && endTime != null && !"null".equals(endTime)) {
|
|
|
+ map.put("startDate", sdf.format(new Date(Long.parseLong(startTime))));
|
|
|
+ map.put("endDate", sdf.format(new Date(Long.parseLong(endTime) + 86400000)));
|
|
|
+ } else if (startTime != null && !"null".equals(startTime)) {
|
|
|
+ map.put("oneDate", sdf.format(new Date(Long.parseLong(startTime))));
|
|
|
+ } else if (endTime != null && !"null".equals(endTime)) {
|
|
|
+ map.put("oneDate", sdf.format(new Date(Long.parseLong(endTime))));
|
|
|
+ } else {
|
|
|
+ map.put("oneDate", sdf.format(new Date()));
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|