lmstack преди 3 години
родител
ревизия
5619bebdfb

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

@@ -23,8 +23,10 @@ import org.springframework.web.bind.annotation.*;
 import org.springframework.web.multipart.MultipartFile;
 
 import javax.annotation.Resource;
+import javax.persistence.criteria.CriteriaBuilder;
 import javax.servlet.http.HttpServletResponse;
 import java.math.BigInteger;
+import java.text.SimpleDateFormat;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -104,17 +106,28 @@ public class ApiAppDeviceController {
         return ApiDTO.ok();
     }
 
-    @ApiOperation(value = "入库状态统计")
+    @ApiOperation(value = "设备统计")
     @RequestMapping(value = "count", method = RequestMethod.POST)
     public ApiDTO deviceCountStat() {
+
         DevicePageStatDTO dto = new DevicePageStatDTO();
         Long deviceCount = appDeviceService.getCount();
-        Long inStorage = appDeviceService.getCount(QueryParamExp.eq("status", 0));
+        Long notInStorage = appDeviceService.getCount(QueryParamExp.eq("status", 0));
+        Long inStorage = deviceCount - notInStorage;
+        Long transfer = appDeviceService.getCount(QueryParamExp.eq("status", 2));
+        Long transferAble = appDeviceService.getCount(QueryParamExp.eq("status", 1));
+        Long outStorage = appDeviceService.getCount(QueryParamExp.eq("status", 3));
+        Long handle = appDeviceService.getCount(QueryParamExp.eq("status", 4));
         dto.setTotal(deviceCount);
-        dto.setNotInStorage(deviceCount - inStorage);
+        dto.setNotInStorage(notInStorage);
+        dto.setInStorage(inStorage);
+        dto.setTransfer(transfer);
+        dto.setTransferAble(transferAble);
+        dto.setOutStorage(outStorage);
+        dto.setOutStorageAble(transfer);
+        dto.setHandle(handle);
         return ApiDTO.ok(dto);
     }
-
     @ApiOperation(value = "设备录入 搜索 & 重置")
     @RequestMapping(value = "pageQuery", method = RequestMethod.POST)
     public ApiPageDTO batchNumPageQuery(@RequestBody DeviceBatchQueryParam param) {
@@ -124,14 +137,29 @@ public class ApiAppDeviceController {
         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");
 
+        Integer conditionCount = new Integer(0);
         if (!StringUtils.isEmpty(param.getBatchNum())) {
-            sql.append(" where t1.batch_num like '%").append(param.getBatchNum()).append("%'");
+            sql.append(conditionCount == 0 ? " where" : " and").append(" t1.batch_num like '%").append(param.getBatchNum()).append("%'");
+            conditionCount++;
+        }
+
+        if (!StringUtils.isEmpty(param.getRecordTimeStart())) {
+            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+            sql.append(conditionCount == 0 ? " where" : " and").append(" t1.add_time >= '").append(sdf.format(param.getRecordTimeStart())).append("'");
+            conditionCount++;
+        }
+
+        if (!StringUtils.isEmpty(param.getRecordTimeEnd())) {
+            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+            sql.append(conditionCount == 0 ? " where" : " and").append(" t1.add_time <= '").append(sdf.format(param.getRecordTimeEnd())).append("'");
+            conditionCount++;
         }
 
         sql.append(" group by t1.operate_id");
         if (!StringUtils.isEmpty(param.getOrderBy())) {
             sql.append(param.getOrderBy());
         }
+
         log.info("SQL: {}", sql.toString());
 
 

+ 68 - 5
src/main/java/cn/fastfun/controller/api/ApiAppDeviceLogController.java

@@ -1,5 +1,6 @@
 package cn.fastfun.controller.api;
 
+import cn.fastfun.controller.dto.DevicePageStatDTO;
 import cn.fastfun.controller.param.*;
 import cn.fastfun.service.AppDeviceLogService;
 import cn.fastfun.service.AppDeviceService;
@@ -22,6 +23,7 @@ import org.springframework.web.bind.annotation.RestController;
 
 import javax.annotation.Resource;
 import java.math.BigInteger;
+import java.text.SimpleDateFormat;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
@@ -117,11 +119,30 @@ public class ApiAppDeviceLogController {
     public ApiPageDTO inStoragePageQuery(@RequestBody LibraryInQueryParam param) {
 
         StringBuffer sql = new StringBuffer();
-        if (StringUtils.isEmpty(param.getCheckStatus())) {
-            sql.append("SELECT * FROM app_device_log WHERE type=1");
-        } else {
-            sql.append("SELECT * FROM app_device_log WHERE type=1 AND sn IN(SELECT sn FROM app_device WHERE check_status=" +
-                    param.getCheckStatus().toString() + ")");
+
+        sql.append("SELECT * FROM app_device_log WHERE type=1");
+        if (!StringUtils.isEmpty(param.getCheckStatus()) || !StringUtils.isEmpty(param.getRecordTimeStart()) || !StringUtils.isEmpty(param.getRecordTimeEnd())) {
+            sql.append(" AND sn IN(SELECT sn FROM app_device ");
+
+            Integer conditionCount = new Integer(0);
+            if (!StringUtils.isEmpty(param.getCheckStatus())) {
+                sql.append(conditionCount == 0? " where":" and").append(" check_status=").append(param.getCheckStatus().toString());
+                conditionCount ++;
+            }
+
+            if (!StringUtils.isEmpty(param.getRecordTimeStart())) {
+                SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+                sql.append(conditionCount == 0? " where":" and").append(" instorage_time >= '").append(sdf.format(param.getRecordTimeStart())).append("'");
+                conditionCount ++;
+            }
+
+            if (!StringUtils.isEmpty(param.getRecordTimeEnd())) {
+                SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+                sql.append(conditionCount == 0? " where":" and").append(" instorage_time <= '").append(sdf.format(param.getRecordTimeEnd())).append("'");
+                conditionCount ++;
+            }
+            sql.append(")");
+
         }
 
         if (!StringUtils.isEmpty(param.getSn())) {
@@ -172,6 +193,8 @@ public class ApiAppDeviceLogController {
         return ApiDTO.ok();
     }
 
+
+
     @ApiOperation(value = "设备调拨 查看详情")
     @RequestMapping(value = "transfer/detialQuery", method = RequestMethod.POST)
     public ApiPageDTO transferDetialQuery(@RequestBody detialQueryParam param) {
@@ -203,6 +226,25 @@ public class ApiAppDeviceLogController {
         if (!StringUtils.isEmpty(param.getType())) {
             sql.append(" and t.tf_device_type = ").append(param.getType());
         }
+
+        if ( !StringUtils.isEmpty(param.getRecordTimeStart()) || !StringUtils.isEmpty(param.getRecordTimeEnd())) {
+            sql.append(" AND t.sn IN(SELECT sn FROM app_device ");
+
+            Integer conditionCount = new Integer(0);
+
+            if (!StringUtils.isEmpty(param.getRecordTimeStart())) {
+                SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+                sql.append(conditionCount == 0 ? " where" : " and").append(" transfer_time >= '").append(sdf.format(param.getRecordTimeStart())).append("'");
+                conditionCount++;
+            }
+
+            if (!StringUtils.isEmpty(param.getRecordTimeEnd())) {
+                SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+                sql.append(conditionCount == 0 ? " where" : " and").append(" transfer_time <= '").append(sdf.format(param.getRecordTimeEnd())).append("'");
+                conditionCount++;
+            }
+            sql.append(")");
+        }
         sql.append(" group by t.operate_id");
         if (!StringUtils.isEmpty(param.getOrderBy())) {
             sql.append(param.getOrderBy());
@@ -351,10 +393,31 @@ public class ApiAppDeviceLogController {
         if (!StringUtils.isEmpty(param.getOutType())) {
             sql.append(" and t.out_type = ").append(param.getOutType());
         }
+
+        if ( !StringUtils.isEmpty(param.getRecordTimeStart()) || !StringUtils.isEmpty(param.getRecordTimeEnd())) {
+            sql.append(" AND t.sn IN(SELECT sn FROM app_device ");
+
+            Integer conditionCount = new Integer(0);
+
+            if (!StringUtils.isEmpty(param.getRecordTimeStart())) {
+                SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+                sql.append(conditionCount == 0 ? " where" : " and").append(" outstorage_time >= '").append(sdf.format(param.getRecordTimeStart())).append("'");
+                conditionCount++;
+            }
+
+            if (!StringUtils.isEmpty(param.getRecordTimeEnd())) {
+                SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+                sql.append(conditionCount == 0 ? " where" : " and").append(" outstorage_time <= '").append(sdf.format(param.getRecordTimeEnd())).append("'");
+                conditionCount++;
+            }
+            sql.append(")");
+        }
         sql.append(" group by t.operate_id");
         if (!StringUtils.isEmpty(param.getOrderBy())) {
             sql.append(param.getOrderBy());
         }
+
+
         log.info("SQL: {}", sql.toString());
 
         ApiPageDTO page = appDeviceService.getListBySQL(sql.toString(), new HashMap<>(), param);

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

@@ -58,7 +58,8 @@ public class ApiSysUserController {
         SysUser sysUser = sysUserService.get(param.getId());
 
         sysUser.setRoleIds(new ArrayList<>());
-        sysUserRoleService.findAll(QueryParamExp.eq("userId", param.getId())).forEach(p -> sysUser.getRoleIds().add(p.getRoleCode()));
+        sysUserRoleService.findAll(QueryParamExp.eq("userId", param.getId()))
+                .forEach(p -> sysUser.getRoleIds().add(p.getRoleCode()));
         return ApiDTO.ok("查询成功!", sysUser);
     }
 

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

@@ -154,12 +154,13 @@ public class SysController {
     @RequestMapping(value = "role/tree", method = RequestMethod.POST)
     public ApiDTO menuTree(@RequestBody IdParam param) {
         if (StringUtils.isEmpty(param.getId())) throw new ApiRuntimeException("没有角色编码");
-        SysRole sysRole = sysRoleService.getOne(QueryParamExp.eq("code", param.getId()));
+        SysUserRole sysUserRole = sysUserRoleService.getOne(QueryParamExp.eq("userId", param.getId()));
+        SysRole sysRole = sysRoleService.getOne(QueryParamExp.eq("code", sysUserRole.getRoleCode()));
         if (null == sysRole) throw new ApiRuntimeException("没有找对应角色");
         Map<String, Object> objectMap = new HashMap<>();
         objectMap.put("name", sysRole.getTitle());
 
-        List<SysRoleComponent> sysRoleComponentList = sysRoleComponentService.findAll(QueryParamExp.eq("roleCode", param.getId()));
+        List<SysRoleComponent> sysRoleComponentList = sysRoleComponentService.findAll(QueryParamExp.eq("roleCode", sysUserRole.getRoleCode()));
         List<String> checked = new ArrayList<>();
         sysRoleComponentList.forEach(p -> {
                 checked.add(p.getComponentId());

+ 18 - 0
src/main/java/cn/fastfun/controller/dto/DevicePageStatDTO.java

@@ -17,4 +17,22 @@ public class DevicePageStatDTO {
     @ApiModelProperty(value = "未入库总量", name = "notInStorage", required = true)
     private Long notInStorage = 0l;
 
+    @ApiModelProperty(value = "已入库总量", name = "inStorage", required = true)
+    private Long inStorage = 0l;
+
+    @ApiModelProperty(value = "已调拨总量", name = "transfer", required = true)
+    private Long transfer = 0l;
+
+    @ApiModelProperty(value = "可调拨总量", name = "transferAble", required = true)
+    private Long transferAble = 0l;
+
+    @ApiModelProperty(value = "已出库总量", name = "outStorage", required = true)
+    private Long outStorage = 0l;
+
+    @ApiModelProperty(value = "可出库总量", name = "outStorageAble", required = true)
+    private Long outStorageAble = 0l;
+
+    @ApiModelProperty(value = "已处置总量", name = "outStorageAble", required = true)
+    private Long handle = 0l;
+
 }

+ 15 - 1
src/main/java/cn/fastfun/controller/param/DeviceBatchQueryParam.java

@@ -3,16 +3,30 @@ package cn.fastfun.controller.param;
 import com.bridge.dto.QueryParam;
 
 import com.bridge.dto.QueryParamExp;
+import com.fasterxml.jackson.annotation.JsonFormat;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Getter;
 import lombok.Setter;
+import org.springframework.format.annotation.DateTimeFormat;
 import org.springframework.util.StringUtils;
 
+import java.util.Date;
+
 @Setter
 @Getter
 public class DeviceBatchQueryParam extends QueryParam {
 
-    @ApiModelProperty(value = "", name = "batchNum", required = true)
+    @ApiModelProperty(value = "批次号", name = "batchNum", required = true)
     private String batchNum;
 
+    @ApiModelProperty(value = "录入时间起始", name = "recordTimeStart", required = true)
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+    private Date recordTimeStart;
+
+    @ApiModelProperty(value = "录入时间结束", name = "recordTimeEnd", required = true)
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+    private Date recordTimeEnd;
+
 }

+ 13 - 0
src/main/java/cn/fastfun/controller/param/LibraryInQueryParam.java

@@ -2,13 +2,16 @@ package cn.fastfun.controller.param;
 
 import com.bridge.dto.QueryParam;
 import com.bridge.dto.QueryParamExp;
+import com.fasterxml.jackson.annotation.JsonFormat;
 import io.swagger.annotations.ApiModelProperty;
 import io.swagger.models.auth.In;
 import lombok.Getter;
 import lombok.Setter;
+import org.springframework.format.annotation.DateTimeFormat;
 import org.springframework.util.CollectionUtils;
 import org.springframework.util.StringUtils;
 
+import java.util.Date;
 import java.util.List;
 
 @Getter
@@ -22,5 +25,15 @@ public class LibraryInQueryParam extends QueryParam{
     @ApiModelProperty(value = "自检状态", name = "checkStatus", example = "0, 0:未通过 ; 1:已通过;  空:全部")
     private Integer checkStatus;
 
+    @ApiModelProperty(value = "入库时间起始", name = "recordTimeStart", required = true)
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+    private Date recordTimeStart;
+
+    @ApiModelProperty(value = "入库时间结束", name = "recordTimeEnd", required = true)
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+    private Date recordTimeEnd;
+
 
 }

+ 14 - 0
src/main/java/cn/fastfun/controller/param/LogTransferQueryParam.java

@@ -1,9 +1,13 @@
 package cn.fastfun.controller.param;
 
 import com.bridge.dto.QueryParam;
+import com.fasterxml.jackson.annotation.JsonFormat;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Getter;
 import lombok.Setter;
+import org.springframework.format.annotation.DateTimeFormat;
+
+import java.util.Date;
 
 @Setter
 @Getter
@@ -15,4 +19,14 @@ public class LogTransferQueryParam extends QueryParam {
     @ApiModelProperty(value = "调拨类型", name = "type")
     private Integer type;
 
+    @ApiModelProperty(value = "调拨时间起始", name = "recordTimeStart", required = true)
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+    private Date recordTimeStart;
+
+    @ApiModelProperty(value = "调拨时间结束", name = "recordTimeEnd", required = true)
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+    private Date recordTimeEnd;
+
 }

+ 14 - 0
src/main/java/cn/fastfun/controller/param/OutQueryParam.java

@@ -2,11 +2,15 @@ package cn.fastfun.controller.param;
 
 import com.bridge.dto.QueryParam;
 import com.bridge.dto.QueryParamExp;
+import com.fasterxml.jackson.annotation.JsonFormat;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Getter;
 import lombok.Setter;
+import org.springframework.format.annotation.DateTimeFormat;
 import org.springframework.util.StringUtils;
 
+import java.util.Date;
+
 @Setter
 @Getter
 public class OutQueryParam extends QueryParam {
@@ -17,4 +21,14 @@ public class OutQueryParam extends QueryParam {
 
     @ApiModelProperty(value = "出库类型", name = "outType")
     private Integer outType;
+
+    @ApiModelProperty(value = "出库时间起始", name = "recordTimeStart", required = true)
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+    private Date recordTimeStart;
+
+    @ApiModelProperty(value = "出库时间结束", name = "recordTimeEnd", required = true)
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+    private Date recordTimeEnd;
 }