Commit 9c9b3549 authored by AfirSraftGarrier's avatar AfirSraftGarrier

Merge remote-tracking branch 'origin/master'

# Conflicts:
#	license/src/main/java/iot/sixiang/license/service/impl/TerminalDeviceServiceImpl.java
parents be730734 8ee22feb
...@@ -15,6 +15,8 @@ import org.springframework.web.bind.annotation.RequestBody; ...@@ -15,6 +15,8 @@ import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import java.util.List;
@RestController @RestController
@RequestMapping("/iot_license/terminal_device") @RequestMapping("/iot_license/terminal_device")
@Api(value = "终端设备模块", tags = {"终端设备模块"}) @Api(value = "终端设备模块", tags = {"终端设备模块"})
...@@ -30,7 +32,7 @@ public class TerminalDeviceController { ...@@ -30,7 +32,7 @@ public class TerminalDeviceController {
@PostMapping("/report_error_msg") @PostMapping("/report_error_msg")
@ApiOperation(value = "终端设备上报错误信息", notes = "终端设备上报错误信息") @ApiOperation(value = "终端设备上报错误信息", notes = "终端设备上报错误信息")
public BaseResult reportErrorMsg(@RequestBody ReportErrorMsgDTO reportErrorMsgDTO) { public BaseResult reportErrorMsg(@RequestBody List<ReportErrorMsgDTO> reportErrorMsgDTO) {
return terminalDeviceService.reportErrorMsg(reportErrorMsgDTO); return terminalDeviceService.reportErrorMsg(reportErrorMsgDTO);
} }
......
...@@ -19,4 +19,6 @@ public interface PmsUseService { ...@@ -19,4 +19,6 @@ public interface PmsUseService {
PageInfoModel<PmsUseLog> getPmsUseLogList(int pageNo, int pageSize, String sn, Integer status); PageInfoModel<PmsUseLog> getPmsUseLogList(int pageNo, int pageSize, String sn, Integer status);
boolean reportErrorMsg(ReportErrorMsgDTO reportErrorMsgDTO); boolean reportErrorMsg(ReportErrorMsgDTO reportErrorMsgDTO);
boolean deletePmsUseLogById(Integer id);
} }
...@@ -6,10 +6,12 @@ import iot.sixiang.license.model.dto.GetTerminalDeviceTokenDTO; ...@@ -6,10 +6,12 @@ import iot.sixiang.license.model.dto.GetTerminalDeviceTokenDTO;
import iot.sixiang.license.model.dto.ReportErrorMsgDTO; import iot.sixiang.license.model.dto.ReportErrorMsgDTO;
import iot.sixiang.license.model.dto.TerminalDevieBindDTO; import iot.sixiang.license.model.dto.TerminalDevieBindDTO;
import java.util.List;
public interface TerminalDeviceService { public interface TerminalDeviceService {
ResResult getToken(GetTerminalDeviceTokenDTO getTerminalDeviceTokenDTO); ResResult getToken(GetTerminalDeviceTokenDTO getTerminalDeviceTokenDTO);
BaseResult reportErrorMsg(ReportErrorMsgDTO reportErrorMsgDTO); BaseResult reportErrorMsg(List<ReportErrorMsgDTO> reportErrorMsgDTO);
BaseResult terminalDeviceBind(TerminalDevieBindDTO terminalDevieBindDTO); BaseResult terminalDeviceBind(TerminalDevieBindDTO terminalDevieBindDTO);
} }
...@@ -35,6 +35,7 @@ public class PmsUseServiceImpl implements PmsUseService { ...@@ -35,6 +35,7 @@ public class PmsUseServiceImpl implements PmsUseService {
@Override @Override
public void createFailUseLog(String sn, String message) { public void createFailUseLog(String sn, String message) {
PmsUseLog pmsUseLog = getPmsUseLog(sn); PmsUseLog pmsUseLog = getPmsUseLog(sn);
pmsUseLog.setStatus(0);
pmsUseLog.setMessage(message); pmsUseLog.setMessage(message);
pmsUseLogMapper.insert(pmsUseLog); pmsUseLogMapper.insert(pmsUseLog);
} }
...@@ -76,11 +77,18 @@ public class PmsUseServiceImpl implements PmsUseService { ...@@ -76,11 +77,18 @@ public class PmsUseServiceImpl implements PmsUseService {
pmsUseLog.setMessage(errorMsg); pmsUseLog.setMessage(errorMsg);
pmsUseLog.setUpdateTime(new Date()); pmsUseLog.setUpdateTime(new Date());
int res = pmsUseLogMapper.updateById(pmsUseLog); int res = pmsUseLogMapper.updateById(pmsUseLog);
if (res >= 0) { return res > 0;
return true; }
} else {
return false; @Override
} public boolean deletePmsUseLogById(Integer id) {
PmsUseLog pmsUseLog = new PmsUseLog();
pmsUseLog.setId(id);
pmsUseLog.setStatus(0);
pmsUseLog.setUpdateTime(new Date());
pmsUseLog.setDeleted(0);
int res = pmsUseLogMapper.updateById(pmsUseLog);
return res > 0;
} }
private PmsUseLog getPmsUseLog(String sn) { private PmsUseLog getPmsUseLog(String sn) {
......
...@@ -19,6 +19,8 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -19,6 +19,8 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.Comparator;
import java.util.List;
@Slf4j @Slf4j
@Service @Service
...@@ -59,16 +61,34 @@ public class TerminalDeviceServiceImpl implements TerminalDeviceService { ...@@ -59,16 +61,34 @@ public class TerminalDeviceServiceImpl implements TerminalDeviceService {
} }
@Override @Override
public BaseResult reportErrorMsg(ReportErrorMsgDTO reportErrorMsgDTO) { public BaseResult reportErrorMsg(List<ReportErrorMsgDTO> reportErrorMsgDTOs) {
Integer id = reportErrorMsgDTO.getId(); if (reportErrorMsgDTOs == null || reportErrorMsgDTOs.size() == 0) {
if (id == null || id == 0) {
return BaseResult.validate_failed(); return BaseResult.validate_failed();
} }
boolean res = pmsUseService.reportErrorMsg(reportErrorMsgDTO); reportErrorMsgDTOs.sort(Comparator.comparingInt(ReportErrorMsgDTO::getId));
if (res) { for (int i = 0; i < reportErrorMsgDTOs.size() - 1; i++) {
return BaseResult.success(); ReportErrorMsgDTO reportErrorMsgDTO = reportErrorMsgDTOs.get(i);
Integer id = reportErrorMsgDTO.getId();
if (id == null || id == 0) {
return BaseResult.validate_failed();
}
pmsUseService.deletePmsUseLogById(id);
}
ReportErrorMsgDTO reportErrorMsgDTO = reportErrorMsgDTOs.get(reportErrorMsgDTOs.size() - 1);
if (reportErrorMsgDTO.getId() == null || reportErrorMsgDTO.getId() == 0 || reportErrorMsgDTO.getErrorCode() == null) {
return BaseResult.validate_failed();
} else { } else {
return BaseResult.failed(); if ("0".equals(reportErrorMsgDTO.getErrorCode())) {
pmsUseService.success(reportErrorMsgDTO.getId());
return BaseResult.success();
} else {
boolean res = pmsUseService.reportErrorMsg(reportErrorMsgDTO);
if (res) {
return BaseResult.success();
} else {
return BaseResult.failed();
}
}
} }
} }
......
...@@ -10,5 +10,7 @@ ...@@ -10,5 +10,7 @@
<if test="null != status"> <if test="null != status">
and status = #{status} and status = #{status}
</if> </if>
and deleted = 0
order by create_time desc
</select> </select>
</mapper> </mapper>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment