Browse Source

重构表结构

jaikuai 3 years ago
parent
commit
00e69704e3
23 changed files with 442 additions and 600 deletions
  1. 2 2
      src/main/java/cn/fastfun/controller/api/ApiAppDeviceController.java
  2. 81 0
      src/main/java/cn/fastfun/controller/api/ApiAppDeviceLogController.java
  3. 0 62
      src/main/java/cn/fastfun/controller/api/ApiAppHandleFormController.java
  4. 0 111
      src/main/java/cn/fastfun/controller/api/ApiAppLibraryLogController.java
  5. 0 62
      src/main/java/cn/fastfun/controller/api/ApiAppTransferLogController.java
  6. 25 0
      src/main/java/cn/fastfun/controller/param/HandelFormParam.java
  7. 9 0
      src/main/java/cn/fastfun/controller/param/LibraryInFormParam.java
  8. 35 0
      src/main/java/cn/fastfun/controller/param/TransferFormParam.java
  9. 43 0
      src/main/java/cn/fastfun/service/AppDeviceLogService.java
  10. 0 36
      src/main/java/cn/fastfun/service/AppLibraryLogService.java
  11. 5 5
      src/main/java/cn/fastfun/service/entity/AppDevice.java
  12. 140 0
      src/main/java/cn/fastfun/service/entity/AppDeviceLog.java
  13. 0 56
      src/main/java/cn/fastfun/service/entity/AppHandleForm.java
  14. 0 68
      src/main/java/cn/fastfun/service/entity/AppLibraryLog.java
  15. 0 73
      src/main/java/cn/fastfun/service/entity/AppTransferLog.java
  16. 88 0
      src/main/java/cn/fastfun/service/impl/AppDeviceLogServiceImpl.java
  17. 0 15
      src/main/java/cn/fastfun/service/impl/AppHandleFormServiceImp.java
  18. 0 59
      src/main/java/cn/fastfun/service/impl/AppLibraryLogServiceImp.java
  19. 0 15
      src/main/java/cn/fastfun/service/impl/AppTransferLogServiceImp.java
  20. 14 0
      src/main/java/cn/fastfun/service/repository/AppDeviceLogRepository.java
  21. 0 12
      src/main/java/cn/fastfun/service/repository/AppHandleFormRepository.java
  22. 0 12
      src/main/java/cn/fastfun/service/repository/AppLibraryLogRepository.java
  23. 0 12
      src/main/java/cn/fastfun/service/repository/AppTransferLogRepository.java

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

@@ -36,7 +36,7 @@ import java.util.Map;
  * @author Bridge AutoGen
  */
 @Slf4j
-@Api(tags = {"设备信息"})
+@Api(tags = {"2.0 设备信息"})
 @RestController
 @RequestMapping("/api/v1/appdevice")
 public class ApiAppDeviceController {
@@ -94,7 +94,7 @@ public class ApiAppDeviceController {
     public ApiPageDTO pageQuery(@RequestBody DeviceQueryParam param) {
 
         Page<AppDevice> devicePage = appDeviceService.findByParam(param);
-        devicePage.getContent().forEach(p -> p.setInStorage("未入库"));
+//        devicePage.getContent().forEach(p -> p.setInStorage("未入库"));
         return new ApiPageDTO(null, devicePage);
     }
 

+ 81 - 0
src/main/java/cn/fastfun/controller/api/ApiAppDeviceLogController.java

@@ -0,0 +1,81 @@
+package cn.fastfun.controller.api;
+
+import cn.fastfun.controller.dto.DeviceAttrDTO;
+import cn.fastfun.controller.param.*;
+import cn.fastfun.service.AppDeviceLogService;
+import cn.fastfun.service.AppDeviceService;
+import cn.fastfun.service.SysExcelFieldService;
+import cn.fastfun.service.entity.AppDevice;
+import cn.fastfun.util.DateUtils;
+import cn.fastfun.util.ObjectUtil;
+import cn.fastfun.util.VerifyUtil;
+import com.bridge.dto.ApiDTO;
+import com.bridge.dto.ApiPageDTO;
+import com.bridge.dto.IdParam;
+import com.bridge.dto.QueryParamExp;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.ApiParam;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.poi.hssf.usermodel.HSSFWorkbook;
+import org.springframework.data.domain.Page;
+import org.springframework.util.StringUtils;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
+
+import javax.annotation.Resource;
+import javax.servlet.http.HttpServletResponse;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @author Bridge AutoGen
+ */
+@Slf4j
+@Api(tags = {"2.1 设备操作信息"})
+@RestController
+@RequestMapping("/api/v1/app/device/log")
+public class ApiAppDeviceLogController {
+    //业务类
+    @Resource(name = "appDeviceService")
+    AppDeviceService appDeviceService;
+
+    @Resource
+    SysExcelFieldService sysExcelFieldService;
+
+    @Resource
+    AppDeviceLogService deviceLogService;
+
+
+    @ApiOperation(value = "入库")
+    @RequestMapping(value = "instorage", method = RequestMethod.POST)
+    public ApiDTO inStorage(@RequestBody @ApiParam(name = "入库参数", value = "传入json格式", required = true) LibraryInFormParam param) {
+        deviceLogService.putInStorage(param);
+        return ApiDTO.ok();
+    }
+
+    @ApiOperation(value = "划拨")
+    @RequestMapping(value = "transfer", method = RequestMethod.POST)
+    public ApiDTO transfer(@RequestBody @ApiParam(name = "划拨参数", value = "传入json格式", required = true) TransferFormParam param) {
+        deviceLogService.transfer(param);
+        return ApiDTO.ok();
+    }
+
+    @ApiOperation(value = "出库")
+    @RequestMapping(value = "outstorage", method = RequestMethod.POST)
+    public ApiDTO outStorage(@RequestBody @ApiParam(name = "出库参数", value = "传入json格式", required = true) LibraryOutFormParam param) {
+        deviceLogService.outStorage(param);
+        return ApiDTO.ok();
+    }
+
+    @ApiOperation(value = "处置")
+    @RequestMapping(value = "handle", method = RequestMethod.POST)
+    public ApiDTO handle(@RequestBody @ApiParam(name = "出库参数", value = "传入json格式", required = true) HandelFormParam param) {
+        deviceLogService.handle(param);
+        return ApiDTO.ok();
+    }
+
+
+
+}

+ 0 - 62
src/main/java/cn/fastfun/controller/api/ApiAppHandleFormController.java

@@ -1,62 +0,0 @@
-package cn.fastfun.controller.api;
-
-import cn.fastfun.service.entity.AppHandleForm;
-import com.bridge.dto.ApiDTO;
-import com.bridge.dto.ApiPageDTO;
-import com.bridge.dto.IdParam;
-import com.bridge.dto.QueryParam;
-import com.bridge.service.JpaService;
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiOperation;
-import io.swagger.annotations.ApiParam;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
-import org.springframework.web.bind.annotation.RestController;
-
-import javax.annotation.Resource;
-import java.util.Arrays;
-
-/**
-* @author Bridge AutoGen
-*
-*/
-@Api(tags = { "设备处置单" })
-@RestController
-@RequestMapping("/api/v1/apphandleform")
-public class ApiAppHandleFormController {
-    //业务类
-	@Resource(name = "appHandleFormService")
-	JpaService<AppHandleForm, String> appHandleFormService;
-
-    
-	/**
-	 * 数据保存
-	 */
-	@ApiOperation(value = "保存信息")
-	@RequestMapping(value = "save", method = RequestMethod.POST)
-	public ApiDTO save(@RequestBody @ApiParam(name = "设备处置单对象", value = "传入json格式", required = true) AppHandleForm entity) {
-		return ApiDTO.ok("保存成功", appHandleFormService.save(entity));
-	}
-
-    @ApiOperation(value = "查询信息")
-	@RequestMapping(value = "get", method = RequestMethod.POST)
-	public ApiDTO get(@RequestBody @ApiParam(name = "设备处置单id", required = true) IdParam param) {
-		return ApiDTO.ok("查询成功!", appHandleFormService.get(param.getId()));
-	}
-
-    @ApiOperation(value = "删除信息")
-	@RequestMapping(value = "delete", method = RequestMethod.POST)
-	public ApiDTO delete(@RequestBody @ApiParam(name = "设备处置单id", required = true) IdParam param) {
-		appHandleFormService.delete(Arrays.asList(param.getId().split(",")));
-		return ApiDTO.ok("删除成功!");
-	}
-
-	@ApiOperation(value = "分页搜索")
-    @RequestMapping(value = "pageQuery", method = RequestMethod.POST)
-    public ApiPageDTO pageQuery(@RequestBody QueryParam param) {
-        
-        return new ApiPageDTO(null, appHandleFormService.findByParam(param));
-    }
-
-}

+ 0 - 111
src/main/java/cn/fastfun/controller/api/ApiAppLibraryLogController.java

@@ -1,111 +0,0 @@
-package cn.fastfun.controller.api;
-
-import cn.fastfun.controller.param.LibraryOutFormParam;
-import cn.fastfun.controller.param.LibraryQueryParam;
-import cn.fastfun.service.AppDeviceService;
-import cn.fastfun.service.AppLibraryLogService;
-import cn.fastfun.service.entity.AppDevice;
-import cn.fastfun.service.entity.AppLibraryLog;
-import cn.fastfun.service.entity.Product;
-import com.bridge.dto.ApiDTO;
-import com.bridge.dto.ApiPageDTO;
-import com.bridge.dto.IdParam;
-import com.bridge.service.JpaService;
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiOperation;
-import io.swagger.annotations.ApiParam;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
-import org.springframework.web.bind.annotation.RestController;
-
-import javax.annotation.Resource;
-import java.util.Arrays;
-import java.util.Comparator;
-import java.util.List;
-
-/**
- * @author Bridge AutoGen
- */
-@Api(tags = {"设备出入库记录"})
-@RestController
-@RequestMapping("/api/v1/applibrarylog")
-public class ApiAppLibraryLogController {
-    //业务类
-    @Resource(name = "appLibraryLogService")
-    AppLibraryLogService appLibraryLogService;
-
-    @ApiOperation(value = "设备入库")
-    @RequestMapping(value = "in", method = RequestMethod.POST)
-    public ApiDTO in(@RequestBody @ApiParam(name = "设备出入库记录对象", value = "传入json格式", required = true) AppLibraryLog entity) {
-        return ApiDTO.ok("保存成功", appLibraryLogService.save(entity));
-    }
-
-    @ApiOperation(value = "设备出库")
-    @RequestMapping(value = "out", method = RequestMethod.POST)
-    public ApiDTO out(@RequestBody @ApiParam(name = "设备出库记录", value = "传入json格式", required = true) LibraryOutFormParam param) {
-        appLibraryLogService.outAppDevice(param);
-        return ApiDTO.ok("保存成功");
-    }
-
-    /**
-     * 数据保存
-     */
-    @ApiOperation(value = "保存信息")
-    @RequestMapping(value = "save", method = RequestMethod.POST)
-    public ApiDTO save(@RequestBody @ApiParam(name = "设备出入库记录对象", value = "传入json格式", required = true) AppLibraryLog entity) {
-        return ApiDTO.ok("保存成功", appLibraryLogService.save(entity));
-    }
-
-    @ApiOperation(value = "查询信息")
-    @RequestMapping(value = "get", method = RequestMethod.POST)
-    public ApiDTO get(@RequestBody @ApiParam(name = "设备出入库记录id", required = true) IdParam param) {
-        return ApiDTO.ok("查询成功!", appLibraryLogService.get(param.getId()));
-    }
-
-    @ApiOperation(value = "删除信息")
-    @RequestMapping(value = "delete", method = RequestMethod.POST)
-    public ApiDTO delete(@RequestBody @ApiParam(name = "设备出入库记录id", required = true) IdParam param) {
-        appLibraryLogService.delete(Arrays.asList(param.getId().split(",")));
-        return ApiDTO.ok("删除成功!");
-    }
-
-    @ApiOperation(value = "分页搜索")
-    @RequestMapping(value = "pageQuery", method = RequestMethod.POST)
-    public ApiPageDTO pageQuery(@RequestBody LibraryQueryParam param) {
-        return new ApiPageDTO(null, appLibraryLogService.findByParam(param));
-    }
-
-
-    @ApiOperation(value = "显示批次待入库的电池")
-    @RequestMapping(value = "showAppDevice", method = RequestMethod.POST)
-    public ApiDTO showRestDevice(@RequestBody LibraryQueryParam param) {
-        List<AppDevice> appDevices = appLibraryLogService.showAppDevice(param.getBatchName());
-        appDevices.sort(Comparator.comparing(AppDevice::getAddTime).reversed());
-        int resultSize = appDevices.size();
-        int startIndex = (param.getIndex() - 1) * param.getLength();
-        int endIndex = startIndex + param.getLength();
-        List<AppDevice> appDevicesByPage;
-        try {
-            if (endIndex > resultSize) {
-                endIndex = resultSize;
-                appDevicesByPage = appDevices.subList(startIndex, endIndex);
-            } else {
-                appDevicesByPage = appDevices.subList(startIndex, endIndex);
-            }
-        } catch (IllegalArgumentException e) {
-            return ApiDTO.error("分页索引越界!");
-        }
-        ApiPageDTO result = new ApiPageDTO("搜索成功!", appDevicesByPage);
-        result.setTotal(appDevicesByPage.size());
-        return result;
-    }
-
-    @ApiOperation(value = "入库批次待入库的电池")
-    @RequestMapping(value = "importAppDevice", method = RequestMethod.POST)
-    public ApiDTO importRestDevice(@RequestBody LibraryQueryParam param) {
-        int snSize = appLibraryLogService.importAppDevices(param.getSnArray());
-        return ApiDTO.ok("入库成功", snSize);
-    }
-
-}

+ 0 - 62
src/main/java/cn/fastfun/controller/api/ApiAppTransferLogController.java

@@ -1,62 +0,0 @@
-package cn.fastfun.controller.api;
-
-import cn.fastfun.service.entity.AppTransferLog;
-import com.bridge.dto.ApiDTO;
-import com.bridge.dto.ApiPageDTO;
-import com.bridge.dto.IdParam;
-import com.bridge.dto.QueryParam;
-import com.bridge.service.JpaService;
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiOperation;
-import io.swagger.annotations.ApiParam;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
-import org.springframework.web.bind.annotation.RestController;
-
-import javax.annotation.Resource;
-import java.util.Arrays;
-
-/**
-* @author Bridge AutoGen
-*
-*/
-@Api(tags = { "调拨日志" })
-@RestController
-@RequestMapping("/api/v1/apptransferlog")
-public class ApiAppTransferLogController {
-    //业务类
-	@Resource(name = "appTransferLogService")
-	JpaService<AppTransferLog, String> appTransferLogService;
-
-    
-	/**
-	 * 数据保存
-	 */
-	@ApiOperation(value = "保存信息")
-	@RequestMapping(value = "save", method = RequestMethod.POST)
-	public ApiDTO save(@RequestBody @ApiParam(name = "调拨日志对象", value = "传入json格式", required = true) AppTransferLog entity) {
-		return ApiDTO.ok("保存成功", appTransferLogService.save(entity));
-	}
-
-    @ApiOperation(value = "查询信息")
-	@RequestMapping(value = "get", method = RequestMethod.POST)
-	public ApiDTO get(@RequestBody @ApiParam(name = "调拨日志id", required = true) IdParam param) {
-		return ApiDTO.ok("查询成功!", appTransferLogService.get(param.getId()));
-	}
-
-    @ApiOperation(value = "删除信息")
-	@RequestMapping(value = "delete", method = RequestMethod.POST)
-	public ApiDTO delete(@RequestBody @ApiParam(name = "调拨日志id", required = true) IdParam param) {
-		appTransferLogService.delete(Arrays.asList(param.getId().split(",")));
-		return ApiDTO.ok("删除成功!");
-	}
-
-	@ApiOperation(value = "分页搜索")
-    @RequestMapping(value = "pageQuery", method = RequestMethod.POST)
-    public ApiPageDTO pageQuery(@RequestBody QueryParam param) {
-        
-        return new ApiPageDTO(null, appTransferLogService.findByParam(param));
-    }
-
-}

+ 25 - 0
src/main/java/cn/fastfun/controller/param/HandelFormParam.java

@@ -0,0 +1,25 @@
+package cn.fastfun.controller.param;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Getter;
+import lombok.Setter;
+
+import javax.persistence.Column;
+import java.util.List;
+
+@Setter
+@Getter
+public class HandelFormParam {
+
+    @ApiModelProperty(value = "设备编号", name = "sn", required = false)
+    private List<String> sn;
+
+
+    @ApiModelProperty(value = "处置类型", name = "event", required = true)
+    private Integer event;
+
+
+    @ApiModelProperty(value = "处置内容", name = "handleContent", required = true)
+    private String handleContent;
+
+}

+ 9 - 0
src/main/java/cn/fastfun/controller/param/LibraryInFormParam.java

@@ -1,12 +1,21 @@
 package cn.fastfun.controller.param;
 
+import io.swagger.annotations.ApiModelProperty;
 import lombok.Getter;
 import lombok.Setter;
 
+import java.util.List;
+
 /**
  * 入库参数
  */
 @Setter
 @Getter
 public class LibraryInFormParam {
+
+    @ApiModelProperty(value = "批次号", name = "batchNum", required = false)
+    private String batchNum;
+
+    @ApiModelProperty(value = "设备编号", name = "sn", required = false)
+    private List<String> sn;
 }

+ 35 - 0
src/main/java/cn/fastfun/controller/param/TransferFormParam.java

@@ -0,0 +1,35 @@
+package cn.fastfun.controller.param;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Getter;
+import lombok.Setter;
+
+import java.util.List;
+
+@Setter
+@Getter
+public class TransferFormParam {
+
+    @ApiModelProperty(value = "设备编号", name = "sn", required = false)
+    private List<String> sn;
+
+    @ApiModelProperty(value = "划拨设备类型", name = "deviceType", required = true)
+    private String deviceType;
+
+
+    @ApiModelProperty(value = "用途", name = "used", required = true)
+    private String used;
+
+
+    @ApiModelProperty(value = "描述", name = "describe", required = true)
+    private String describe;
+
+
+    @ApiModelProperty(value = "划拨动作", name = "event", required = true)
+    private Integer event;
+
+    @ApiModelProperty(value = "客户ID", name = "outCustomId", required = true)
+    private String customId;
+}
+
+

+ 43 - 0
src/main/java/cn/fastfun/service/AppDeviceLogService.java

@@ -0,0 +1,43 @@
+package cn.fastfun.service;
+
+import cn.fastfun.controller.param.HandelFormParam;
+import cn.fastfun.controller.param.LibraryInFormParam;
+import cn.fastfun.controller.param.LibraryOutFormParam;
+import cn.fastfun.controller.param.TransferFormParam;
+import cn.fastfun.service.entity.AppDeviceLog;
+import com.bridge.service.JpaService;
+
+/**
+ * 设备操作日志
+ */
+public interface AppDeviceLogService extends JpaService<AppDeviceLog, String> {
+
+    /**
+     * 入库动作
+     *
+     * @param param
+     */
+    void putInStorage(LibraryInFormParam param);
+
+    /**
+     * 设备划拨
+     *
+     * @param param
+     */
+    void transfer(TransferFormParam param);
+
+    /**
+     * 设备出库
+     *
+     * @param param
+     */
+    void outStorage(LibraryOutFormParam param);
+
+    /**
+     * 设备处置
+     *
+     * @param param
+     */
+    void handle(HandelFormParam param);
+
+}

+ 0 - 36
src/main/java/cn/fastfun/service/AppLibraryLogService.java

@@ -1,36 +0,0 @@
-package cn.fastfun.service;
-
-
-import cn.fastfun.controller.param.LibraryOutFormParam;
-import cn.fastfun.service.entity.AppDevice;
-import cn.fastfun.service.entity.AppLibraryLog;
-import com.bridge.service.JpaService;
-
-import java.util.List;
-
-public interface AppLibraryLogService extends JpaService<AppLibraryLog, String> {
-
-    /**
-     * 获得指定批次号的设备
-     *
-     * @param batchNum
-     * @return
-     */
-    List<AppDevice> showAppDevice(String batchNum);
-
-    /**
-     * 完成多个设备的入库
-     *
-     * @param sns
-     * @return
-     */
-    int importAppDevices(String[] sns);
-
-
-    /**
-     * 出库
-     *
-     * @param param
-     */
-    void outAppDevice(LibraryOutFormParam param);
-}

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

@@ -1,7 +1,6 @@
 package cn.fastfun.service.entity;
 
 
-import cn.fastfun.service.ProductService;
 import cn.fastfun.util.ObjectUtil;
 import com.bridge.entity.DateEntity;
 import com.fasterxml.jackson.annotation.JsonFormat;
@@ -16,7 +15,6 @@ import org.hibernate.annotations.JoinColumnsOrFormulas;
 import org.hibernate.annotations.JoinFormula;
 import org.springframework.format.annotation.DateTimeFormat;
 
-import javax.annotation.Resource;
 import javax.persistence.*;
 import java.util.Date;
 import java.util.Map;
@@ -97,6 +95,11 @@ public class AppDevice extends DateEntity {
     }
 
 
+    @ApiModelProperty(value = "归属", name = "ownerId", required = true)
+    @Column(name = "owner_id")
+    private String ownerId;
+
+
     public AppDevice(Map<String, Object> param) {
         setBatchNum(ObjectUtil.obj2String(param.get("pathId")));
         setSn(ObjectUtil.obj2String(param.get("sn")));
@@ -106,9 +109,6 @@ public class AppDevice extends DateEntity {
         setStatus(1);
     }
 
-    @Transient
-    private String inStorage;
-
     // 类型
     public String getType() {
         return sn.substring(0, 1);

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

@@ -0,0 +1,140 @@
+package cn.fastfun.service.entity;
+
+
+import cn.fastfun.controller.param.HandelFormParam;
+import cn.fastfun.controller.param.LibraryInFormParam;
+import cn.fastfun.controller.param.LibraryOutFormParam;
+import cn.fastfun.controller.param.TransferFormParam;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+import lombok.Setter;
+
+import javax.persistence.*;
+import javax.persistence.Entity;
+import javax.persistence.Table;
+
+import com.bridge.entity.DateEntity;
+
+
+@Entity
+@Table(name = "app_device_log")
+@Setter
+@Getter
+@NoArgsConstructor
+public class AppDeviceLog extends DateEntity {
+
+    private static final long serialVersionUID = 1L;
+
+
+    @ApiModelProperty(value = "类型", name = "type", required = true)
+    @Column(name = "type")
+    private Integer type;
+
+
+    @ApiModelProperty(value = "IMEI", name = "imei", required = true)
+    @Column(name = "imei")
+    private String imei;
+
+
+    @ApiModelProperty(value = "SN", name = "sn", required = true)
+    @Column(name = "sn")
+    private String sn;
+
+
+    @ApiModelProperty(value = "出库类型", name = "outType", required = true)
+    @Column(name = "out_type")
+    private Integer outType;
+
+
+    @ApiModelProperty(value = "联系人", name = "receiverName", required = true)
+    @Column(name = "receiver_name")
+    private String receiverName;
+
+
+    @ApiModelProperty(value = "电话", name = "receiverPhone", required = true)
+    @Column(name = "receiver_phone")
+    private String receiverPhone;
+
+
+    @ApiModelProperty(value = "出库客户", name = "outCustomId", required = true)
+    @Column(name = "out_custom_id")
+    private String outCustomId;
+
+
+    @ApiModelProperty(value = "备注", name = "remarks", required = true)
+    @Column(name = "remarks")
+    private String remarks;
+
+
+    @ApiModelProperty(value = "划拨设备类型", name = "tfDeviceType", required = true)
+    @Column(name = "tf_device_type")
+    private String tfDeviceType;
+
+
+    @ApiModelProperty(value = "用途", name = "tfUsed", required = true)
+    @Column(name = "tf_used")
+    private String tfUsed;
+
+
+    @ApiModelProperty(value = "描述", name = "tfDescribe", required = true)
+    @Column(name = "tf_describe")
+    private String tfDescribe;
+
+
+    @ApiModelProperty(value = "划拨动作", name = "tfEvent", required = true)
+    @Column(name = "tf_event")
+    private Integer tfEvent;
+
+
+    @ApiModelProperty(value = "处置类型", name = "hfEvent", required = true)
+    @Column(name = "hf_event")
+    private Integer hfEvent;
+
+
+    @ApiModelProperty(value = "处置内容", name = "hfHandleContent", required = true)
+    @Column(name = "hf_handle_content")
+    private String hfHandleContent;
+
+
+    public AppDeviceLog(String sn, String imei) {
+        setSn(sn);
+        setImei(imei);
+    }
+
+    // 入库属性
+    public AppDeviceLog toInStorage() {
+        setType(1); // 入库
+        return this;
+    }
+
+    // 划拨
+    public AppDeviceLog toTransfer(TransferFormParam param) {
+        setType(2); // 划拨
+        setTfEvent(param.getEvent()); //
+        setTfDeviceType(param.getDeviceType());
+        setTfDescribe(param.getDescribe());
+        setTfUsed(param.getUsed());
+        setOutCustomId(param.getCustomId());
+        return this;
+    }
+
+    // 出库
+    public AppDeviceLog outStorage(LibraryOutFormParam param) {
+        setType(3); // 出库
+        setOutType(param.getOutType());
+        setReceiverName(param.getReceiverName());
+        setReceiverPhone(param.getReceiverPhone());
+        return this;
+    }
+
+    // 处置
+    public AppDeviceLog toHandle(HandelFormParam param) {
+        setType(4);
+        setHfEvent(param.getEvent());
+        setHfHandleContent(param.getHandleContent());
+        return this;
+    }
+
+
+}

+ 0 - 56
src/main/java/cn/fastfun/service/entity/AppHandleForm.java

@@ -1,56 +0,0 @@
-package cn.fastfun.service.entity;
-
-
-import com.bridge.entity.DateEntity;
-import com.fasterxml.jackson.annotation.JsonFormat;
-import io.swagger.annotations.ApiModelProperty;
-import lombok.Getter;
-import lombok.Setter;
-import org.springframework.format.annotation.DateTimeFormat;
-
-import javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.Table;
-import java.util.Date;
-
-
-@Entity
-@Table(name = "app_handle_form")
-@Setter
-@Getter
-public class AppHandleForm extends DateEntity{
-
-	private static final long serialVersionUID = 1L;
-	
-
-	
-	   
-	   @ApiModelProperty(value="设备编号", name="sn", required=true)
-	   @Column(name = "sn")
-	   private String sn;
-
-	
-	   
-	   @ApiModelProperty(value="处置类型", name="eventType", required=true)
-	   @Column(name = "event_type")
-	   private Integer eventType;
-
-	
-	   
-	   @ApiModelProperty(value="处置时间", name="handleTime", required=true)
-	   @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
-	   @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
-	   @Column(name = "handle_time")
-	   private Date handleTime;
-
-	
-
-
-
-
-	   @ApiModelProperty(value="处置说明", name="handleContent", required=true)
-	   @Column(name = "handle_content")
-	   private String handleContent;
-
-	
-}

+ 0 - 68
src/main/java/cn/fastfun/service/entity/AppLibraryLog.java

@@ -1,68 +0,0 @@
-package cn.fastfun.service.entity;
-
-
-import cn.fastfun.controller.param.LibraryOutFormParam;
-import com.bridge.entity.DateEntity;
-import com.fasterxml.jackson.annotation.JsonFormat;
-import io.swagger.annotations.ApiModelProperty;
-import lombok.Getter;
-import lombok.NoArgsConstructor;
-import lombok.Setter;
-import org.springframework.format.annotation.DateTimeFormat;
-
-import javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.Table;
-import java.util.Date;
-
-
-@Entity
-@Table(name = "app_library_log")
-@Setter
-@Getter
-@NoArgsConstructor
-public class AppLibraryLog extends DateEntity {
-
-    private static final long serialVersionUID = 1L;
-
-
-    @ApiModelProperty(value = "设备编号", name = "sn", required = true)
-    @Column(name = "sn")
-    private String sn;
-
-
-    @ApiModelProperty(value = "类型", name = "type", required = true)
-    @Column(name = "type")
-    private Integer type;
-
-    @ApiModelProperty(value = "出库类型", name = "outType", required = true)
-    @Column(name = "out_type")
-    private Integer outType;
-
-    @ApiModelProperty(value = "客户ID", name = "outCustomId", required = true)
-    @Column(name = "out_custom_id")
-    private String outCustomId;
-
-
-    @ApiModelProperty(value = "接收人姓名", name = "receiverName", required = true)
-    @Column(name = "receiver_name")
-    private String receiverName;
-
-
-    @ApiModelProperty(value = "接收人电话", name = "receiverPhone", required = true)
-    @Column(name = "receiver_phone")
-    private String receiverPhone;
-
-
-    @ApiModelProperty(value = "出库备注", name = "outRemarks", required = true)
-    @Column(name = "out_remarks")
-    private String outRemarks;
-
-    public AppLibraryLog(String sn, LibraryOutFormParam param) {
-        setType(1);
-        setSn(sn);
-        setOutType(param.getOutType());
-        setReceiverName(param.getReceiverName());
-        setReceiverPhone(param.getReceiverPhone());
-    }
-}

+ 0 - 73
src/main/java/cn/fastfun/service/entity/AppTransferLog.java

@@ -1,73 +0,0 @@
-package cn.fastfun.service.entity;
-
-
-import com.bridge.entity.DateEntity;
-import com.fasterxml.jackson.annotation.JsonIgnore;
-import com.fasterxml.jackson.annotation.JsonInclude;
-import io.swagger.annotations.ApiModelProperty;
-import lombok.Getter;
-import lombok.Setter;
-import org.hibernate.annotations.JoinColumnOrFormula;
-import org.hibernate.annotations.JoinColumnsOrFormulas;
-import org.hibernate.annotations.JoinFormula;
-
-import javax.persistence.*;
-
-
-@Entity
-@Table(name = "app_transfer_log")
-@Setter
-@Getter
-public class AppTransferLog extends DateEntity {
-
-    private static final long serialVersionUID = 1L;
-
-
-    @ApiModelProperty(value = "设备编号", name = "sn", required = true)
-    @Column(name = "sn")
-    private String sn;
-
-
-    @ApiModelProperty(value = "设备类型", name = "deviceType", required = true)
-    @Column(name = "device_type")
-    private String deviceType;
-
-
-    @ApiModelProperty(value = "客户", name = "customId", required = true)
-    @Column(name = "custom_id")
-    private String customId;
-
-
-    @ApiModelProperty(value = "动作", name = "event", required = true)
-    @Column(name = "event")
-    private Integer event = 0;
-
-    // 关联
-    @JsonIgnore
-    @ManyToOne(targetEntity = SysDict.class)
-    @JoinColumnsOrFormulas(value = {
-            @JoinColumnOrFormula(column = @JoinColumn(name = "event", referencedColumnName = "name", insertable = false, updatable = false, nullable = false)),
-            @JoinColumnOrFormula(formula = @JoinFormula(value = "'app_transfer_log_event'", referencedColumnName = "group_name"))
-    })
-    private SysDict eventDict;
-
-    @Transient
-    @JsonInclude(value = JsonInclude.Include.NON_NULL)
-    public String getEventTitle() {
-        return null != eventDict ? eventDict.getValue() : "";
-    }
-
-
-    @ApiModelProperty(value = "回退备注", name = "remarks", required = true)
-    @Column(name = "remarks")
-    private String remarks;
-
-    @ApiModelProperty(value = "设备说明", name = "describe", required = true)
-    @Column(name = "describe")
-    private String describe;
-
-    @ApiModelProperty(value = "用途", name = "used", required = true)
-    @Column(name = "used")
-    private String used;
-
-}

+ 88 - 0
src/main/java/cn/fastfun/service/impl/AppDeviceLogServiceImpl.java

@@ -0,0 +1,88 @@
+package cn.fastfun.service.impl;
+
+import cn.fastfun.controller.param.HandelFormParam;
+import cn.fastfun.controller.param.LibraryInFormParam;
+import cn.fastfun.controller.param.LibraryOutFormParam;
+import cn.fastfun.controller.param.TransferFormParam;
+import cn.fastfun.service.AppDeviceLogService;
+import cn.fastfun.service.AppDeviceService;
+import cn.fastfun.service.entity.AppDevice;
+import cn.fastfun.service.entity.AppDeviceLog;
+import com.bridge.dto.QueryParamExp;
+import com.bridge.exception.ApiRuntimeException;
+import com.bridge.service.impl.JpaServiceImp;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Service;
+import org.springframework.util.CollectionUtils;
+import org.springframework.util.StringUtils;
+
+import javax.annotation.Resource;
+import javax.transaction.Transactional;
+
+@Slf4j
+@Service
+public class AppDeviceLogServiceImpl extends JpaServiceImp<AppDeviceLog, String> implements AppDeviceLogService {
+
+    @Resource
+    AppDeviceService appDeviceService;
+
+    @Override
+    @Transactional
+    public void putInStorage(LibraryInFormParam param) {
+        if (!StringUtils.isEmpty(param.getBatchNum())) {
+
+        }
+        if (!CollectionUtils.isEmpty(param.getSn())) {
+            param.getSn().forEach(p -> {
+                AppDevice appDevice = appDeviceService.getOne(QueryParamExp.eq("sn", p));
+                if (null == appDevice) throw new ApiRuntimeException("设备信息不存在!");
+                if (0 != appDevice.getStatus()) throw new ApiRuntimeException("设备已经入库!");
+                appDevice.setStatus(1); // 已入库
+                appDeviceService.save(appDevice);
+                save(new AppDeviceLog(p, appDevice.getImei()).toInStorage()); // 记录入库日志
+            });
+        }
+    }
+
+    @Override
+    @Transactional
+    public void transfer(TransferFormParam param) {
+        if (!CollectionUtils.isEmpty(param.getSn())) {
+            param.getSn().forEach(p -> {
+                AppDevice appDevice = appDeviceService.getOne(QueryParamExp.eq("sn", p));
+                if (null == appDevice) throw new ApiRuntimeException("设备信息不存在!");
+                if (1 != appDevice.getStatus() && 3 != appDevice.getStatus()) throw new ApiRuntimeException("设备不能调拨!");
+                appDevice.setStatus(2); // 已划拨
+                appDevice.setOwnerId(param.getCustomId()); // 设置归属
+                appDeviceService.save(appDevice);
+                save(new AppDeviceLog(p, appDevice.getImei()).toTransfer(param)); // 记录划拨日志
+            });
+        }
+    }
+
+    @Override
+    @Transactional
+    public void outStorage(LibraryOutFormParam param) {
+        param.getSn().forEach(p -> {
+            AppDevice appDevice = appDeviceService.getOne(QueryParamExp.eq("sn", p));
+            if (null == appDevice) throw new ApiRuntimeException("设备信息不存在!");
+            if (2 != appDevice.getStatus()) throw new ApiRuntimeException("设备不是划拨状态!");
+            appDevice.setStatus(3); // 已出库
+            appDeviceService.save(appDevice);
+            save(new AppDeviceLog(p, appDevice.getImei()).outStorage(param)); // 记录出库日志
+        });
+    }
+
+    @Override
+    @Transactional
+    public void handle(HandelFormParam param) {
+        param.getSn().forEach(p -> {
+            AppDevice appDevice = appDeviceService.getOne(QueryParamExp.eq("sn", p));
+            if (null == appDevice) throw new ApiRuntimeException("设备信息不存在!");
+            if (1 != appDevice.getStatus()) throw new ApiRuntimeException("设备不是入库状态!");
+            appDevice.setStatus(4); // 处置
+            appDeviceService.save(appDevice);
+            save(new AppDeviceLog(p, appDevice.getImei()).toHandle(param)); // 记录处置日志
+        });
+    }
+}

+ 0 - 15
src/main/java/cn/fastfun/service/impl/AppHandleFormServiceImp.java

@@ -1,15 +0,0 @@
-package cn.fastfun.service.impl;
-
-import cn.fastfun.service.entity.AppHandleForm;
-import com.bridge.service.JpaService;
-import com.bridge.service.impl.JpaServiceImp;
-import org.springframework.stereotype.Service;
-
-/**
-* 服务实现类
-* Created by Bridge.
-*/
-@Service("appHandleFormService")
-public class AppHandleFormServiceImp extends JpaServiceImp<AppHandleForm, String> implements JpaService<AppHandleForm, String> {
-
-}

+ 0 - 59
src/main/java/cn/fastfun/service/impl/AppLibraryLogServiceImp.java

@@ -1,59 +0,0 @@
-package cn.fastfun.service.impl;
-
-import cn.fastfun.controller.param.LibraryOutFormParam;
-import cn.fastfun.service.AppDeviceService;
-import cn.fastfun.service.AppLibraryLogService;
-import cn.fastfun.service.entity.AppDevice;
-import cn.fastfun.service.entity.AppLibraryLog;
-import cn.fastfun.service.repository.AppDeviceRepository;
-import com.bridge.dto.QueryParamExp;
-import com.bridge.service.JpaService;
-import com.bridge.service.impl.JpaServiceImp;
-import org.springframework.stereotype.Service;
-
-import javax.annotation.Resource;
-import javax.transaction.Transactional;
-import java.util.Arrays;
-import java.util.List;
-import java.util.Map;
-
-/**
- * 服务实现类
- * Created by Bridge.
- */
-@Service("appLibraryLogService")
-public class AppLibraryLogServiceImp extends JpaServiceImp<AppLibraryLog, String> implements AppLibraryLogService {
-
-
-    @Resource
-    AppDeviceService appDeviceService;
-
-    @Override
-    public List<AppDevice> showAppDevice(String batchNum) {
-        List<AppDevice> restAppDevice = appDeviceService.findAll(
-                QueryParamExp.eq("batchNum", batchNum));
-        return restAppDevice;
-    }
-
-    @Override
-    public int importAppDevices(String[] sns) {
-        int snSize = 0;
-        for (String sn : sns) {
-            List<AppDevice> appDevice = appDeviceService.findAll(
-                    QueryParamExp.eq("imei", sn));
-            appDevice.get(0).setStatus(1);
-            appDeviceService.save(appDevice.get(0));
-            snSize += 1;
-        }
-        return snSize;
-    }
-
-    @Override
-    @Transactional
-    public void outAppDevice(LibraryOutFormParam param) {
-        param.getSn().forEach(p -> {
-            AppDevice appDevice = appDeviceService.getOne(QueryParamExp.eq("sn", p));
-            save(new AppLibraryLog(p, param));
-        });
-    }
-}

+ 0 - 15
src/main/java/cn/fastfun/service/impl/AppTransferLogServiceImp.java

@@ -1,15 +0,0 @@
-package cn.fastfun.service.impl;
-
-import cn.fastfun.service.entity.AppTransferLog;
-import com.bridge.service.JpaService;
-import com.bridge.service.impl.JpaServiceImp;
-import org.springframework.stereotype.Service;
-
-/**
-* 服务实现类
-* Created by Bridge.
-*/
-@Service("appTransferLogService")
-public class AppTransferLogServiceImp extends JpaServiceImp<AppTransferLog, String> implements JpaService<AppTransferLog, String> {
-
-}

+ 14 - 0
src/main/java/cn/fastfun/service/repository/AppDeviceLogRepository.java

@@ -0,0 +1,14 @@
+package cn.fastfun.service.repository;
+
+import cn.fastfun.service.entity.AppDeviceLog;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
+
+/**
+ * Created by Eye
+ *
+ * @Author Bridge
+ */
+public interface AppDeviceLogRepository extends JpaRepository<AppDeviceLog, String>, JpaSpecificationExecutor<AppDeviceLog> {
+
+}

+ 0 - 12
src/main/java/cn/fastfun/service/repository/AppHandleFormRepository.java

@@ -1,12 +0,0 @@
-package cn.fastfun.service.repository;
-
-import cn.fastfun.service.entity.AppHandleForm;
-import org.springframework.data.jpa.repository.JpaRepository;
-import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
-
-/**
-* Created by Eye
-* @Author Bridge
-*/
-public interface AppHandleFormRepository extends JpaRepository<AppHandleForm, String>, JpaSpecificationExecutor<AppHandleForm> {
-}

+ 0 - 12
src/main/java/cn/fastfun/service/repository/AppLibraryLogRepository.java

@@ -1,12 +0,0 @@
-package cn.fastfun.service.repository;
-
-import cn.fastfun.service.entity.AppLibraryLog;
-import org.springframework.data.jpa.repository.JpaRepository;
-import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
-
-/**
-* Created by Eye
-* @Author Bridge
-*/
-public interface AppLibraryLogRepository extends JpaRepository<AppLibraryLog, String>, JpaSpecificationExecutor<AppLibraryLog> {
-}

+ 0 - 12
src/main/java/cn/fastfun/service/repository/AppTransferLogRepository.java

@@ -1,12 +0,0 @@
-package cn.fastfun.service.repository;
-
-import cn.fastfun.service.entity.AppTransferLog;
-import org.springframework.data.jpa.repository.JpaRepository;
-import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
-
-/**
-* Created by Eye
-* @Author Bridge
-*/
-public interface AppTransferLogRepository extends JpaRepository<AppTransferLog, String>, JpaSpecificationExecutor<AppTransferLog> {
-}