TreeviewCopyright © aleen42 all right reserved, powered by aleen42
预警任务
预警类型分为报表订阅模式和接口模式,这里主要说下接口模式。
具体步骤
一、定义预警类型
- 操作路径:【数字化建模】→【系统管理】→【预警任务】→【预警类型】
- 选择【接口模式】,输入预警类型回调的接口,定义接口的入参(条件)和出参(结果集)
二、接口代码实现
例子:注意tenantId和其他入参,以及结果集result的数据结构 ```java @Slf4j @RestController @RequiredArgsConstructor @RequestMapping(Constant.PATH_INNER_PREFIX) public class YyCustomerWarningController {
private static final Logger logger = LoggerFactory.getLogger(YyCustomerWarningController.class);
@Resource private PrewarningMerchantService prewarningMerchantService;
@Value("${yycustomer.prewarning.url}") private String yyCustomerWarningUrl;
@RequestMapping(value = "yycustomerWarningSync", method = RequestMethod.POST) public void customerWarningSync(@RequestBody Object object, HttpServletRequest request, HttpServletResponse response){
int days = Integer.parseInt(((Map)object).get("days").toString()); String tenantId = request.getHeader("tenantId"); String orgId = ((Map)object).get("orgId").toString(); Map<String, Object> conditionMap = new HashMap<>(); conditionMap.put("days", days); conditionMap.put("tenantId", tenantId); conditionMap.put("orgId", orgId); logger.info("医药客户证照预警开始,入参:" + JSONUtils.toJSONString(conditionMap)); boolean flag = false; // 返回结果 JSONObject result = new JSONObject(); List<Map<String, Object>> list = Lists.newArrayList(); try { flag = prewarningMerchantService.yyCustomerPrewarning(conditionMap); if (flag) { Map<String, Object> test = new HashMap<>(); test.put("warningmsg", "点击查看医药客户证照有效期小于等于" + days + "天客户档案列表"); list.add(test); result.put("status", 1); result.put("url", yyCustomerWarningUrl); } else { result.put("status", 1); } } catch (Exception e) { result.put("status", 0); result.put("msg", e.getMessage()); logger.error(e.getMessage(), e); } result.put("asynchronized", false); result.put("data", list); ResponseUtils.renderJson(response, JSONUtils.toJSONString(result));
}
}
```