fix:修改一键修改处理状态的处理方式并不能重复处理

dev
郭承 3 months ago
parent 52f9c2daae
commit 243e226df4

@ -5,6 +5,7 @@ import com.xydl.cac.entity.Warning;
import com.xydl.cac.exception.BusinessException;
import com.xydl.cac.model.ConditionModel;
import com.xydl.cac.model.Response;
import com.xydl.cac.service.DataService;
import com.xydl.cac.service.ReportService;
import com.xydl.cac.service.WarningService;
import io.swagger.annotations.Api;
@ -28,6 +29,9 @@ public class WarningController extends BasicController {
@Resource
WarningService service;
@Resource
DataService dataService;
@GetMapping("list")
@ApiOperation("查询列表")
public Response<Page<Warning>> list(@Validated ConditionModel condition) throws Exception {
@ -65,13 +69,20 @@ public class WarningController extends BasicController {
}
Boolean isFlat = false;
@PostMapping("oneKeyUpdateState")
@ApiOperation("一键修改处理状态")
public Response<String> oneKeyUpdateState() throws Exception {
ConditionModel condition = new ConditionModel();
condition.setState("1");
List<Warning> warnings = service.listAll(condition);
service.oneKeyUpdateState(warnings);
return Response.success("OK");
try {
if (isFlat) {
throw new BusinessException("相同请求正在处理中, 请勿重复处理");
}
isFlat = true;
dataService.updateWarningState("warning" , "0" , "1");
return Response.success("OK");
} finally {
isFlat = false;
}
}
}

@ -23,4 +23,6 @@ public interface DataService {
Map<String, Object> getLastOneData(String tableName, Integer devId, ModevTypePoint point) throws Exception;
void insertData(String tableName, Integer devId, String time, String colname, String value);
void updateWarningState(String tableName, String frontState , String afterState);
}

@ -322,4 +322,10 @@ public class DataServiceImpl implements DataService {
}
}
@Override
public void updateWarningState(String tableName, String frontState, String afterState) {
String sql = "UPDATE " + tableName + " set state = " + frontState + " where state = " + afterState;
jdbcTemplate.execute(sql);
}
}

Loading…
Cancel
Save