|
@@ -2,16 +2,15 @@ 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;
|
|
|
-import cn.fastfun.service.SysExcelFieldService;
|
|
|
-import cn.fastfun.service.UtilService;
|
|
|
+import cn.fastfun.service.*;
|
|
|
import cn.fastfun.service.entity.AppDevice;
|
|
|
import cn.fastfun.service.entity.AppDeviceLog;
|
|
|
+import cn.fastfun.service.entity.PackModel;
|
|
|
import cn.fastfun.util.DateUtils;
|
|
|
import cn.fastfun.util.ObjectUtil;
|
|
|
import cn.fastfun.util.VerifyUtil;
|
|
|
import com.bridge.dto.*;
|
|
|
+import com.bridge.exception.ApiRuntimeException;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import io.swagger.annotations.ApiParam;
|
|
@@ -30,6 +29,7 @@ import javax.persistence.criteria.CriteriaBuilder;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
import java.math.BigInteger;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
+import java.util.Arrays;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
@@ -58,12 +58,15 @@ public class ApiAppDeviceController {
|
|
|
@Resource
|
|
|
JdbcTemplate jdbcTemplate;
|
|
|
|
|
|
+ @Resource
|
|
|
+ PackModelService packModelService;
|
|
|
+
|
|
|
/**
|
|
|
* 数据保存
|
|
|
*/
|
|
|
|
|
|
@ApiOperation(value = "新增电池")
|
|
|
- @RequestMapping(value = "save", method = RequestMethod.POST)
|
|
|
+ @PostMapping("save")
|
|
|
public ApiDTO save(@RequestBody @ApiParam(name = "设备信息对象", value = "传入json格式", required = true) DeviceFormParam param) {
|
|
|
// 此处定义的sn实际上是指的表中的imei,也就是实体类的属性imei
|
|
|
String checkSnResult = VerifyUtil.checkImei(param.getImei());
|
|
@@ -91,6 +94,18 @@ public class ApiAppDeviceController {
|
|
|
}catch (EmptyResultDataAccessException e) {
|
|
|
gpsData.put("devcode",null);
|
|
|
}
|
|
|
+ //pack和cell 校验
|
|
|
+ if (!org.apache.commons.lang3.StringUtils.isNotBlank(param.getCellModel())){
|
|
|
+ throw new ApiRuntimeException("单体型号缺失");
|
|
|
+ }
|
|
|
+ if (!org.apache.commons.lang3.StringUtils.isNotBlank(param.getPackModel())){
|
|
|
+ throw new ApiRuntimeException("包型号缺失");
|
|
|
+ }
|
|
|
+ PackModel packModel = packModelService.getOne(Arrays.asList(QueryParamExp.eq("cellModel", param.getCellModel()),
|
|
|
+ QueryParamExp.eq("packModel", param.getPackModel())));
|
|
|
+ if (packModel==null){
|
|
|
+ throw new ApiRuntimeException("包型号和单体型号配置错误");
|
|
|
+ }
|
|
|
|
|
|
if(StringUtils.isEmpty(bmsData.get("devcode")) && StringUtils.isEmpty(gpsData.get("devcode"))){
|
|
|
return ApiDTO.error(500, "该电池未产生过数据,禁止录入");
|
|
@@ -108,6 +123,8 @@ public class ApiAppDeviceController {
|
|
|
AppDevice entity = new AppDevice().fromFormParam(param);// 实体
|
|
|
entity.setOperateID(operateID.intValue());
|
|
|
entity.setOperator(utilService.getUserName());
|
|
|
+ entity.setPackModel(param.getPackModel());
|
|
|
+ entity.setCellModel(param.getCellModel());
|
|
|
appDeviceService.save(entity);
|
|
|
return ApiDTO.ok("保存成功");
|
|
|
} else {
|