Browse Source

主业务流程代码更新

lmstack 3 years ago
parent
commit
4d95a9faac

+ 0 - 20
src/main/java/cn/fastfun/controller/api/ApiAppDeviceController.java

@@ -76,26 +76,6 @@ public class ApiAppDeviceController {
         }
     }
 
-
-    @ApiOperation(value = "查询信息")
-    @RequestMapping(value = "get", method = RequestMethod.POST)
-    public ApiDTO get(@RequestBody @ApiParam(name = "批次编号", required = true) IdParam param) {
-        List<AppDevice> appDevicesOnOneBatch = appDeviceService.findAll(
-                QueryParamExp.eq("batchNum", param.getId()));
-        return ApiDTO.ok("查询成功!", appDevicesOnOneBatch);
-    }
-
-//    @ApiOperation(value = "设备分页搜索")
-//    @RequestMapping(value = "pageQuery", method = RequestMethod.POST)
-//    public ApiPageDTO pageQuery(@RequestBody DeviceQueryParam param) {
-//
-//        Page<AppDeviceLog> byParam = appDeviceLogService.findByParam(param);
-//        Page<AppDevice> devicePage = appDeviceService.findByParam(param);
-//        devicePage.getContent().forEach(p -> appDeviceService.addSnTitle(p));
-//        return new ApiPageDTO(null, devicePage);
-//    }
-
-
     @ApiOperation(value = "导入模板下载")
     @GetMapping("excelTemplate")
     public void excelTemplate(HttpServletResponse response, @RequestParam String name) {

+ 50 - 44
src/main/java/cn/fastfun/controller/api/ApiAppDeviceLogController.java

@@ -53,7 +53,7 @@ public class ApiAppDeviceLogController {
     public ApiPageDTO inStorageBatchQuery(@RequestBody DeviceBatchQueryParam param) {
 
         StringBuffer sql = new StringBuffer();
-        sql.append("select t1.batch_num,t1.sn,t1.imei,t1.deliver_time,count(0) as total,count(if(status = 1,true,null)) as in_storage,count(if(status = 2,true,null)) as transfer,");
+        sql.append("select t1.batch_num,t1.sn,t1.check_status,t1.imei,t1.deliver_time,count(0) as total,count(if(status = 1,true,null)) as in_storage,count(if(status = 2,true,null)) as transfer,");
         sql.append("count(if(status = 3,true,null)) as out_storage,count(if(status = 4,true,null)) as handle,");
         sql.append("t1.add_time,t1.received_place from app_device t1");
 
@@ -87,45 +87,20 @@ public class ApiAppDeviceLogController {
         }
         return page;
     }
-//    @ApiOperation(value = "批次入库 --> 入库 搜索 & 重置")
-//    @RequestMapping(value = "instorage/batch/inStorageQuery", method = RequestMethod.POST)
-//    public ApiPageDTO inStorageBatchQuery(@RequestBody DeviceBatchQueryParam param) {
-//
-//        StringBuffer sql = new StringBuffer();
-//        sql.append("select t1.batch_num,t1.sn,t1.imei,t1.deliver_time,count(0) as total,count(if(status = 1,true,null)) as in_storage,count(if(status = 2,true,null)) as transfer,");
-//        sql.append("count(if(status = 3,true,null)) as out_storage,count(if(status = 4,true,null)) as handle,");
-//        sql.append("t1.add_time,t1.received_place from app_device t1");
-//
-//        if (!StringUtils.isEmpty(param.getBatchNum())) {
-//            sql.append(" where t1.batch_num like '%").append(param.getBatchNum()).append("%'");
-//        }
-//        sql.append(" group by t1.batch_num");
-//        if (!StringUtils.isEmpty(param.getOrderBy())) {
-//            sql.append(param.getOrderBy());
-//        }
-//        log.info("SQL: {}", sql.toString());
-//
-//
-//        ApiPageDTO page = appDeviceService.getListBySQL(sql.toString(), new HashMap<>(), param);
-//        if (null != page.getData()) {
-//            // 组装数据
-//            List<Map<String, Object>> list = (List<Map<String, Object>>) page.getData();
-//            for (Map<String, Object> p : list) {
-//                AppDevice device = new AppDevice();
-//                device.setImei(ObjectUtil.obj2String(p.get("imei")));
-//                appDeviceService.addImeiTitle(device);
-//
-//
-//                p.put("type_title", device.getTypeTitle());
-//                p.put("pack_title", device.getPackTitle());
-//                p.put("deliver_time", DateUtils.toString(ObjectUtil.obj2Date(p.get("deliver_time")), DateUtils.YMD));
-//                p.put("add_time", DateUtils.toString(ObjectUtil.obj2Date(p.get("add_time")), DateUtils.YMDHMS));
-//                p.put("operator", "admin");
-//            }
-//            page.setData(list);
-//        }
-//        return page;
-//    }
+    @ApiOperation(value = "批次入库 --> 入库 搜索 & 重置")
+    @RequestMapping(value = "instorage/batch/inStorageQuery", method = RequestMethod.POST)
+    public ApiPageDTO inStorageBatchInStorageQuery(@RequestBody DeviceBatchQueryParam param) {
+
+        QueryParam query = new QueryParam();
+        if (!StringUtils.isEmpty(param)) {
+            query.addParam(QueryParamExp.like("batchNum", "%".concat(param.getBatchNum()).concat("%")));
+        }
+        Page<AppDevice> devicePage = appDeviceService.findByParam(query);
+        devicePage.getContent().forEach(p -> {
+            appDeviceService.addImeiTitle(p);
+        });
+        return new ApiPageDTO(null, devicePage);
+    }
 
     @ApiOperation(value = "设备入库 搜索 & 重置")
     @RequestMapping(value = "instorage/pageQuery", method = RequestMethod.POST)
@@ -229,6 +204,8 @@ public class ApiAppDeviceLogController {
         Page<AppDeviceLog> deviceLogPage = deviceLogService.findByParam(query);
 
         deviceLogPage.getContent().forEach(p -> {
+
+            // 查看自检状态
             AppDevice device = new AppDevice();
             device.setImei(p.getImei());
             appDeviceService.addImeiTitle(device);
@@ -241,7 +218,7 @@ public class ApiAppDeviceLogController {
     @RequestMapping(value = "transfer/byBatch/pageQuery", method = RequestMethod.POST)
     public ApiPageDTO transferByBatchPageQuery(@RequestBody DeviceBatchQueryParam param) {
         StringBuffer sql = new StringBuffer();
-        sql.append("select t1.batch_num,t1.sn,t1.deliver_time,count(0) as total,count(if(status = 1,true,null)) as in_storage,count(if(status = 2,true,null)) as transfer,");
+        sql.append("select t1.batch_num,t1.sn,t1.imei,t1.deliver_time,count(0) as total,count(if(status = 1,true,null)) as in_storage,count(if(status = 2,true,null)) as transfer,");
         sql.append("count(if(status = 3,true,null)) as out_storage,count(if(status = 4,true,null)) as handle,");
         sql.append("t1.add_time,t1.received_place from app_device t1");
 
@@ -261,7 +238,7 @@ public class ApiAppDeviceLogController {
             List<Map<String, Object>> list = (List<Map<String, Object>>) page.getData();
             for (Map<String, Object> p : list) {
                 AppDevice device = new AppDevice();
-                device.setSn(ObjectUtil.obj2String(p.get("sn")));
+                device.setImei(ObjectUtil.obj2String(p.get("imei")));
                 appDeviceService.addImeiTitle(device);
 
                 p.put("type_title", device.getTypeTitle());
@@ -275,6 +252,21 @@ public class ApiAppDeviceLogController {
         return page;
     }
 
+    @ApiOperation(value = "新增调拨 --> 选择批次 查看")
+    @RequestMapping(value = "transfer/batch/detailQuery", method = RequestMethod.POST)
+    public ApiPageDTO transferByBatchDetailQuery(@RequestBody DeviceBatchQueryParam param) {
+
+        QueryParam query = new QueryParam();
+        if (!StringUtils.isEmpty(param)) {
+            query.addParam(QueryParamExp.like("batchNum", "%".concat(param.getBatchNum()).concat("%")));
+        }
+        Page<AppDevice> devicePage = appDeviceService.findByParam(query);
+        devicePage.getContent().forEach(p -> {
+            appDeviceService.addImeiTitle(p);
+        });
+        return new ApiPageDTO(null, devicePage);
+    }
+
     @ApiOperation(value = "调回平台 搜索 & 重置")
     @RequestMapping(value = "transferBack/pageQuery", method = RequestMethod.POST)
     public ApiPageDTO transferBackPageQuery(@RequestBody TransferBySnQueryParam param) {
@@ -288,7 +280,6 @@ public class ApiAppDeviceLogController {
     }
 
 
-
     @ApiOperation(value = "根据sn或batch出库")
     @RequestMapping(value = "outstorage", method = RequestMethod.POST)
     public ApiDTO outStorage(@RequestBody @ApiParam(name = "出库参数", value = "传入json格式", required = true) LibraryOutFormParam param) {
@@ -332,6 +323,21 @@ public class ApiAppDeviceLogController {
         return page;
     }
 
+    @ApiOperation(value = "批次出库 --> 查看")
+    @RequestMapping(value = "outstorage/batch/detailQuery", method = RequestMethod.POST)
+    public ApiPageDTO outByBatchDetailQuery(@RequestBody DeviceBatchQueryParam param) {
+
+        QueryParam query = new QueryParam();
+        if (!StringUtils.isEmpty(param)) {
+            query.addParam(QueryParamExp.like("batchNum", "%".concat(param.getBatchNum()).concat("%")));
+        }
+        Page<AppDevice> devicePage = appDeviceService.findByParam(query);
+        devicePage.getContent().forEach(p -> {
+            appDeviceService.addImeiTitle(p);
+        });
+        return new ApiPageDTO(null, devicePage);
+    }
+
     @ApiOperation(value = "批次出库 搜索 & 重置")
     @RequestMapping(value = "outstorage/byBatch/pageQuery", method = RequestMethod.POST)
     public ApiPageDTO outByBatchPageQuery(@RequestBody OutByBatchQueryParam param) {
@@ -356,7 +362,7 @@ public class ApiAppDeviceLogController {
     @ApiOperation(value = "处置 搜索 & 重置")
     @RequestMapping(value = "handle/pageQuery", method = RequestMethod.POST)
     public ApiPageDTO deviceLogPageQuery(@RequestBody HandelQueryParam param) {
-        param.addParam(QueryParamExp.eq("type", 3));
+        param.addParam(QueryParamExp.eq("type", 4));
         return new ApiPageDTO(null, deviceLogService.findByParam(param));
     }
 

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

@@ -189,5 +189,4 @@ public class AppDeviceLog extends DateEntity {
         setSpecTitle(device.getSpecTitle());
         setExpandTitle(device.getExpandTitle());
     }
-
 }

+ 23 - 4
src/main/java/cn/fastfun/service/impl/AppDeviceLogServiceImpl.java

@@ -20,7 +20,7 @@ import javax.transaction.Transactional;
 import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
-import java.util.UUID;
+import java.util.concurrent.atomic.AtomicBoolean;
 
 @Slf4j
 @Service
@@ -59,19 +59,38 @@ public class AppDeviceLogServiceImpl extends JpaServiceImp<AppDeviceLog, String>
     @Override
     @Transactional
     public void transfer(TransferFormParam param) {
-        if (StringUtils.isEmpty(param.getSn()) && !StringUtils.isEmpty(param.getBatchNum())) {
+        if (CollectionUtils.isEmpty(param.getSn()) && !StringUtils.isEmpty(param.getBatchNum())) {
             List<AppDevice> deviceList = appDeviceService.findAll(QueryParamExp.in("batchNum", param.getBatchNum().toArray(new String[]{})));
             param.setSn(new ArrayList<>());
             deviceList.forEach(p -> param.getSn().add(p.getSn()));
         }
         if (!CollectionUtils.isEmpty(param.getSn())) {
             Date time = new Date();
+            AtomicBoolean allowTransfer = new AtomicBoolean(true);
+            //批量调拨时,若有不符合调拨条件的电池,则停止本次批量调拨
+
+            param.getSn().forEach(p -> {
+                AppDevice appDevice = appDeviceService.getOne(QueryParamExp.eq("sn", p));
+                if (null == appDevice) {
+                    allowTransfer.set(false);
+                    throw new ApiRuntimeException(p + "设备信息不存在!");
+                }
+//                if (1 != appDevice.getStatus() && 3 != appDevice.getStatus()) {
+//                    allowTransfer.set(false);
+//                    throw new ApiRuntimeException(p + "不是入库或出库状态,不能调拨!");
+//                }
+                if (1 != appDevice.getCheckStatus()) {
+                    allowTransfer.set(false);
+                    throw new ApiRuntimeException(p + "自检未通过,不能调拨!");
+                }
+            });
             param.getSn().forEach(p -> {
                 String batchNum;
                 AppDevice appDevice = appDeviceService.getOne(QueryParamExp.eq("sn", p));
-                if (null == appDevice) throw new ApiRuntimeException("设备信息不存在!");
-                if (1 != appDevice.getStatus() && 3 != appDevice.getStatus()) throw new ApiRuntimeException("设备不能调拨!");
                 batchNum = appDevice.getBatchNum();
+                if (2 == appDevice.getStatus()) {
+                    return;
+                }
                 appDevice.setStatus(2); // 已划拨
                 appDevice.setOwnerId(param.getCustomId()); // 设置归属
                 appDeviceService.save(appDevice);