Просмотр исходного кода

批量上传电池,添加发货时间ymd处理

zyg 1 год назад
Родитель
Сommit
36cfaf10bf

+ 1 - 1
src/main/java/cn/fastfun/service/entity/AppDevice.java

@@ -178,7 +178,7 @@ public class AppDevice extends DateEntity {
         setBatchNum(ObjectUtil.obj2String(param.get("pathId")));
         setSn(ObjectUtil.obj2String(param.get("sn")));
         setImei(ObjectUtil.obj2String(param.get("imei")));
-        setDeliverTime(ObjectUtil.obj2Date(param.get("deliverTime")));
+        setDeliverTime(ObjectUtil.obj2Date1(param.get("deliverTime")));
         setReceivedPlace(ObjectUtil.obj2String(param.get("receivedPlace")));
         setPackModel(ObjectUtil.obj2String(param.get("packModel")));
         setCellModel(ObjectUtil.obj2String(param.get("cellModel")));

+ 5 - 1
src/main/java/cn/fastfun/service/impl/AppDeviceServiceImp.java

@@ -24,6 +24,7 @@ import javax.annotation.Resource;
 
 import java.math.BigInteger;
 import java.util.*;
+import java.util.stream.Collectors;
 
 /**
  * 服务实现类 Created by Bridge.
@@ -64,7 +65,10 @@ public class AppDeviceServiceImp extends JpaServiceImp<AppDevice, String> implem
         List<Map<String, Object>> data = (List<Map<String, Object>>) page.getData();
         BigInteger operateID = (BigInteger)data.get(0).get("max_opid");
         operateID = operateID.add(BigInteger.valueOf(1));
-        for (Map<String, Object> p : list) {
+        List<Map<String, Object>> mapList = list.stream()
+                .filter(o -> null!=o.get("sn") && !"".equals(o.get("sn") .toString()))
+                .collect(Collectors.toList());
+        for (Map<String, Object> p : mapList) {
             AppDevice device = new AppDevice(p);
             if (null == device.getDeliverTime()) throw new ApiRuntimeException("发货时间读取错误");
             // 数据效验

+ 4 - 0
src/main/java/cn/fastfun/util/ObjectUtil.java

@@ -25,6 +25,10 @@ public final class ObjectUtil {
         return null == object ? null : DateUtils.toDate(obj2String(object), DateUtils.YMDHMS);
     }
 
+    public static Date obj2Date1(Object object) {
+        return null == object ? null : DateUtils.toDate(obj2String(object), DateUtils.YMD);
+    }
+
     public static int obj2Integer(Object object) {
         return null == object ? 0 : Integer.parseInt(obj2String(object));
     }