diff --git a/src/main/java/au/com/royalpay/payment/manage/management/clearing/core/SettleTasksService.java b/src/main/java/au/com/royalpay/payment/manage/management/clearing/core/SettleTasksService.java new file mode 100644 index 000000000..421c82062 --- /dev/null +++ b/src/main/java/au/com/royalpay/payment/manage/management/clearing/core/SettleTasksService.java @@ -0,0 +1,11 @@ +package au.com.royalpay.payment.manage.management.clearing.core; + +import com.alibaba.fastjson.JSONObject; + +import java.util.List; + +public interface SettleTasksService { + List listLiveTasks(); + + JSONObject currentProcessingStatus(); +} diff --git a/src/main/java/au/com/royalpay/payment/manage/management/clearing/core/impl/CleanServiceImpl.java b/src/main/java/au/com/royalpay/payment/manage/management/clearing/core/impl/CleanServiceImpl.java index 755076ee1..7b8cb566e 100644 --- a/src/main/java/au/com/royalpay/payment/manage/management/clearing/core/impl/CleanServiceImpl.java +++ b/src/main/java/au/com/royalpay/payment/manage/management/clearing/core/impl/CleanServiceImpl.java @@ -278,7 +278,7 @@ public class CleanServiceImpl implements CleanService, ManagerTodoNoticeProvider data.put("clients", cleanDaysDetails.size()); data.put("reports", cleanDaysDetails.size() < 20 ? cleanDaysDetails : cleanDaysDetails.subList(0, 20)); return data; - }).collect(HashMap::new, (map, data) -> map.put("T+" + data.getIntValue("clean_days"), data), Map::putAll); + }).collect(HashMap::new, (map, data) -> map.put(data.getString("clean_days"), data), Map::putAll); log.put("clean_days", cleanDaysStatistics); if (StringUtils.isNotEmpty(log.getString("plan_detail"))) { diff --git a/src/main/java/au/com/royalpay/payment/manage/management/clearing/core/impl/SettleTaskServiceImpl.java b/src/main/java/au/com/royalpay/payment/manage/management/clearing/core/impl/SettleTaskServiceImpl.java new file mode 100644 index 000000000..384d22d3a --- /dev/null +++ b/src/main/java/au/com/royalpay/payment/manage/management/clearing/core/impl/SettleTaskServiceImpl.java @@ -0,0 +1,51 @@ +package au.com.royalpay.payment.manage.management.clearing.core.impl; + +import au.com.royalpay.payment.manage.management.clearing.core.SettleTasksService; +import au.com.royalpay.payment.manage.mappers.system.SysSettlePlanMapper; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.data.redis.core.StringRedisTemplate; +import org.springframework.stereotype.Service; + +import java.util.List; + +@Service +public class SettleTaskServiceImpl implements SettleTasksService { + private SysSettlePlanMapper planMapper; + private StringRedisTemplate redisTemplate; + private String prefix; + + public SettleTaskServiceImpl(SysSettlePlanMapper planMapper, StringRedisTemplate redisTemplate, + @Value("${app.redis.prefix}") String prefix) { + this.planMapper = planMapper; + this.redisTemplate = redisTemplate; + this.prefix = prefix; + } + + @Override + public List listLiveTasks() { + return planMapper.listPlans(); + } + + private String statusKey() { + return prefix + ":settlement_progress"; + } + + @Override + public JSONObject currentProcessingStatus() { + String std = redisTemplate.boundValueOps(statusKey()).get(); + if (StringUtils.isEmpty(std)) { + JSONObject idleStatus = new JSONObject(); + idleStatus.put("processing", false); + idleStatus.put("interrupted", false); + return idleStatus; + } + JSONObject stdObj = JSON.parseObject(std); + if (!stdObj.getBooleanValue("processing")) { + stdObj.put("interrupted", true); + } + return stdObj; + } +} diff --git a/src/main/java/au/com/royalpay/payment/manage/management/clearing/web/SettleTasksController.java b/src/main/java/au/com/royalpay/payment/manage/management/clearing/web/SettleTasksController.java new file mode 100644 index 000000000..bcc2f2d66 --- /dev/null +++ b/src/main/java/au/com/royalpay/payment/manage/management/clearing/web/SettleTasksController.java @@ -0,0 +1,30 @@ +package au.com.royalpay.payment.manage.management.clearing.web; + +import au.com.royalpay.payment.manage.management.clearing.core.SettleTasksService; +import au.com.royalpay.payment.manage.permission.manager.ManagerMapping; +import au.com.royalpay.payment.tools.permission.enums.ManagerRole; +import com.alibaba.fastjson.JSONObject; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +import java.util.List; + +@RestController +@ManagerMapping(value = "/sys/settle_tasks", role = {ManagerRole.FINANCIAL_STAFF, ManagerRole.DEVELOPER}) +public class SettleTasksController { + private SettleTasksService svc; + + public SettleTasksController(SettleTasksService svc) { + this.svc = svc; + } + + @GetMapping + public List listTasks() { + return svc.listLiveTasks(); + } + + @GetMapping("/current_progress") + public JSONObject getProcessingStatus() { + return svc.currentProcessingStatus(); + } +} diff --git a/src/main/java/au/com/royalpay/payment/manage/mappers/system/SysSettlePlanMapper.java b/src/main/java/au/com/royalpay/payment/manage/mappers/system/SysSettlePlanMapper.java new file mode 100644 index 000000000..2f5219da5 --- /dev/null +++ b/src/main/java/au/com/royalpay/payment/manage/mappers/system/SysSettlePlanMapper.java @@ -0,0 +1,20 @@ +package au.com.royalpay.payment.manage.mappers.system; + +import com.alibaba.fastjson.JSONObject; +import com.yixsoft.support.mybatis.autosql.annotations.AdvanceSelect; +import com.yixsoft.support.mybatis.autosql.annotations.AutoMapper; +import com.yixsoft.support.mybatis.autosql.annotations.AutoSql; +import com.yixsoft.support.mybatis.autosql.annotations.SqlType; + +import java.util.List; + +@AutoMapper(tablename = "sys_settlement_plan", pkName = "plan_id") +public interface SysSettlePlanMapper { + @AdvanceSelect(excludeColumns = "whitelist_clients") + List listPlans(); + + @AutoSql(SqlType.SELECT) + JSONObject findPlanDetail(String planId); + + +}