|
@@ -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);
|