|
@@ -21,6 +21,7 @@ import org.springframework.web.bind.annotation.RequestMethod;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
@@ -40,22 +41,103 @@ public class ApiAppDeviceLogController {
|
|
|
@Resource
|
|
|
AppDeviceLogService deviceLogService;
|
|
|
|
|
|
- @ApiOperation(value = "入库")
|
|
|
+ @ApiOperation(value = "新增入库 单个 or 批次")
|
|
|
@RequestMapping(value = "instorage", method = RequestMethod.POST)
|
|
|
- public ApiDTO inStorage(@RequestBody @ApiParam(name = "入库参数", value = "传入json格式", required = true) LibraryInFormParam param) {
|
|
|
+ public ApiDTO inStorage(@RequestBody @ApiParam(name = "入库参数", value = "指定sn", required = true) LibraryInFormParam param) {
|
|
|
deviceLogService.putInStorage(param);
|
|
|
return ApiDTO.ok();
|
|
|
}
|
|
|
|
|
|
+ @ApiOperation(value = "批次入库 搜索 & 重置")
|
|
|
+ @RequestMapping(value = "instorage/batch/Query", 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/pageQuery", method = RequestMethod.POST)
|
|
|
+ public ApiPageDTO inStoragePageQuery(@RequestBody LibraryInQueryParam param) {
|
|
|
+
|
|
|
+ StringBuffer sql = new StringBuffer();
|
|
|
+ if(CollectionUtils.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().get(0).toString()+")");
|
|
|
+ }
|
|
|
+
|
|
|
+ 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();
|
|
|
+ List<Map<String, Object>> listRes = new ArrayList<>();
|
|
|
+ for (Map<String, Object> p : list) {
|
|
|
+ Map<String, Object> pTemp = new HashMap<>();
|
|
|
+ AppDevice device = new AppDevice();
|
|
|
+ device.setImei(ObjectUtil.obj2String(p.get("imei")));
|
|
|
+ appDeviceService.addImeiTitle(device);
|
|
|
+ AppDevice appDevice = appDeviceService.getOne(QueryParamExp.eq("sn", p.get("sn")));
|
|
|
+ pTemp.put("sn", p.get("sn"));
|
|
|
+ pTemp.put("add_time", DateUtils.toString(ObjectUtil.obj2Date(p.get("add_time")), DateUtils.YMDHMS));
|
|
|
+ pTemp.put("type_title", device.getTypeTitle());
|
|
|
+ pTemp.put("pack_title", device.getPackTitle());
|
|
|
+ pTemp.put("batch_num", appDevice.getBatchNum());
|
|
|
+ pTemp.put("status", device.getStatus());
|
|
|
+ pTemp.put("received_place", appDevice.getReceivedPlace());
|
|
|
+ pTemp.put("operator", "admin");
|
|
|
+ listRes.add(pTemp);
|
|
|
+ }
|
|
|
+ page.setData(listRes);
|
|
|
+ }
|
|
|
+ return page;
|
|
|
+ }
|
|
|
+
|
|
|
@ApiOperation(value = "划拨")
|
|
|
@RequestMapping(value = "transfer", method = RequestMethod.POST)
|
|
|
public ApiDTO transfer(@RequestBody @ApiParam(name = "划拨参数", value = "传入json格式", required = true) TransferFormParam param) {
|
|
|
if (CollectionUtils.isEmpty(param.getBatchNum()) && CollectionUtils.isEmpty(param.getSn()))
|
|
|
- return ApiDTO.error("未设定批次号和设备号");
|
|
|
+ return ApiDTO.error("未设定设备号或sn");
|
|
|
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) {
|
|
@@ -63,6 +145,8 @@ public class ApiAppDeviceLogController {
|
|
|
return ApiDTO.ok();
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
@ApiOperation(value = "出库详细分页搜索")
|
|
|
@RequestMapping(value = "outstorage/pageQuery", method = RequestMethod.POST)
|
|
|
public ApiPageDTO outPageQuery(@RequestBody OutQueryParam param) {
|
|
@@ -70,8 +154,8 @@ public class ApiAppDeviceLogController {
|
|
|
Page<AppDeviceLog> deviceLogPage = deviceLogService.findByParam(param);
|
|
|
deviceLogPage.getContent().forEach(p -> {
|
|
|
AppDevice device = new AppDevice();
|
|
|
- device.setSn(p.getSn());
|
|
|
- appDeviceService.addSnTitle(device);
|
|
|
+ device.setImei(p.getImei());
|
|
|
+ appDeviceService.addImeiTitle(device);
|
|
|
p.appendFormDevice(device);
|
|
|
});
|
|
|
return new ApiPageDTO(null, deviceLogPage);
|
|
@@ -98,8 +182,8 @@ public class ApiAppDeviceLogController {
|
|
|
|
|
|
deviceLogPage.getContent().forEach(p -> {
|
|
|
AppDevice device = new AppDevice();
|
|
|
- device.setSn(p.getSn());
|
|
|
- appDeviceService.addSnTitle(device);
|
|
|
+ device.setImei(p.getImei());
|
|
|
+ appDeviceService.addImeiTitle(device);
|
|
|
p.appendFormDevice(device);
|
|
|
});
|
|
|
return new ApiPageDTO(null, deviceLogPage);
|