|
@@ -7,6 +7,7 @@ import cn.fastfun.service.AppDeviceService;
|
|
|
import cn.fastfun.service.SysExcelFieldService;
|
|
|
import cn.fastfun.service.entity.AppDevice;
|
|
|
import cn.fastfun.service.entity.Product;
|
|
|
+import cn.fastfun.util.DateUtils;
|
|
|
import cn.fastfun.util.VerifyUtil;
|
|
|
import cn.fastfun.util.ObjectUtil;
|
|
|
import com.bridge.dto.ApiDTO;
|
|
@@ -17,7 +18,10 @@ import com.bridge.service.JpaService;
|
|
|
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;
|
|
|
|
|
@@ -31,6 +35,7 @@ import java.util.Map;
|
|
|
/**
|
|
|
* @author Bridge AutoGen
|
|
|
*/
|
|
|
+@Slf4j
|
|
|
@Api(tags = {"设备信息"})
|
|
|
@RestController
|
|
|
@RequestMapping("/api/v1/appdevice")
|
|
@@ -51,20 +56,20 @@ public class ApiAppDeviceController {
|
|
|
// 此处定义的sn实际上是指的表中的imei,也就是实体类的属性imei
|
|
|
String checkSnResult = VerifyUtil.checkSn(entity.getImei());
|
|
|
List<AppDevice> checkDuplicatedResultOnImei = appDeviceService.findAll(
|
|
|
- QueryParamExp.eq("imei",entity.getImei()));
|
|
|
- if(!checkDuplicatedResultOnImei.isEmpty()){
|
|
|
- return ApiDTO.error(500,"该imei已经被录入",checkDuplicatedResultOnImei);
|
|
|
+ QueryParamExp.eq("imei", entity.getImei()));
|
|
|
+ if (!checkDuplicatedResultOnImei.isEmpty()) {
|
|
|
+ return ApiDTO.error(500, "该imei已经被录入", checkDuplicatedResultOnImei);
|
|
|
}
|
|
|
List<AppDevice> checkDuplicatedResultOnSn = appDeviceService.findAll(
|
|
|
- QueryParamExp.eq("sn",entity.getSn()));
|
|
|
- if(!checkDuplicatedResultOnSn.isEmpty()){
|
|
|
- return ApiDTO.error(500,"该sn已经被录入",checkDuplicatedResultOnSn);
|
|
|
+ QueryParamExp.eq("sn", entity.getSn()));
|
|
|
+ if (!checkDuplicatedResultOnSn.isEmpty()) {
|
|
|
+ return ApiDTO.error(500, "该sn已经被录入", checkDuplicatedResultOnSn);
|
|
|
}
|
|
|
- if(checkSnResult.equals("passed")){
|
|
|
+ if (checkSnResult.equals("passed")) {
|
|
|
AppDevice tmp = appDeviceService.save(entity);
|
|
|
- return ApiDTO.ok("保存成功",tmp);}
|
|
|
- else{
|
|
|
- return ApiDTO.error(500,checkSnResult);
|
|
|
+ return ApiDTO.ok("保存成功", tmp);
|
|
|
+ } else {
|
|
|
+ return ApiDTO.error(500, checkSnResult);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -73,7 +78,7 @@ public class ApiAppDeviceController {
|
|
|
@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()));
|
|
|
+ QueryParamExp.eq("batchNum", param.getId()));
|
|
|
return ApiDTO.ok("查询成功!", appDevicesOnOneBatch);
|
|
|
}
|
|
|
|
|
@@ -87,7 +92,10 @@ public class ApiAppDeviceController {
|
|
|
@ApiOperation(value = "分页搜索")
|
|
|
@RequestMapping(value = "pageQuery", method = RequestMethod.POST)
|
|
|
public ApiPageDTO pageQuery(@RequestBody DeviceQueryParam param) {
|
|
|
- return new ApiPageDTO(null, appDeviceService.findByParam(param));
|
|
|
+
|
|
|
+ Page<AppDevice> devicePage = appDeviceService.findByParam(param);
|
|
|
+ devicePage.getContent().forEach(p -> p.setInStorage("未入库"));
|
|
|
+ return new ApiPageDTO(null, devicePage);
|
|
|
}
|
|
|
|
|
|
@ApiOperation(value = "导入模板下载")
|
|
@@ -114,8 +122,13 @@ public class ApiAppDeviceController {
|
|
|
@ApiOperation(value = "设备批次分页搜索")
|
|
|
@RequestMapping(value = "batchNum/pageQuery", method = RequestMethod.POST)
|
|
|
public ApiPageDTO batchNumPageQuery(@RequestBody DeviceBathQueryParam param) {
|
|
|
- StringBuffer sql = new StringBuffer("select t.batch_num,t.sn,t.deliver_time,count(0) as total from app_device t");
|
|
|
- sql.append(" group by t.batch_num");
|
|
|
+ StringBuffer sql = new StringBuffer("select t1.batch_num,t1.sn,t1.deliver_time,count(0) as total,t1.add_time,t1.deliver_addr from app_device t1");
|
|
|
+ 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);
|
|
|
// 组装数据
|
|
@@ -124,6 +137,10 @@ public class ApiAppDeviceController {
|
|
|
DeviceAttrDTO attr = appDeviceService.sn2Attr(ObjectUtil.obj2String(p.get("sn")));
|
|
|
p.put("type_title", attr.getTypeTitle());
|
|
|
p.put("pack_title", attr.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("in_storage", 0);
|
|
|
+ p.put("operator", "admin");
|
|
|
}
|
|
|
page.setData(list);
|
|
|
return page;
|