@@ -0,0 +1,46 @@ | |||
package com.ruoyi.web.controller.agentcenter; | |||
import com.ruoyi.agentcenter.domain.TAgentTask; | |||
import com.ruoyi.agentcenter.service.ITAgentTaskService; | |||
import com.ruoyi.common.core.controller.BaseController; | |||
import com.ruoyi.common.core.page.TableDataInfo; | |||
import com.ruoyi.common.utils.PageUtils; | |||
import org.springframework.beans.factory.annotation.Autowired; | |||
import org.springframework.security.access.prepost.PreAuthorize; | |||
import org.springframework.web.bind.annotation.GetMapping; | |||
import org.springframework.web.bind.annotation.RequestMapping; | |||
import org.springframework.web.bind.annotation.RestController; | |||
import java.util.Arrays; | |||
import java.util.List; | |||
/** | |||
* 任务清单Controller | |||
* | |||
* @author zhao | |||
* @date 2023-05-06 | |||
*/ | |||
@RestController | |||
@RequestMapping("/accounting/task") | |||
public class AccountingAgentTaskController extends BaseController | |||
{ | |||
@Autowired | |||
private ITAgentTaskService tAgentTaskService; | |||
/** | |||
* 获取任务清单列表(按镇村分组) | |||
*/ | |||
@PreAuthorize("@ss.hasPermi('agentcenter:task:list')") | |||
@GetMapping(value = "/todoTaskList") | |||
public TableDataInfo todoTaskList(TAgentTask task) | |||
{ | |||
startPage(); | |||
PageUtils.orderBy("org_code"); | |||
task.putParam("agentStatusList", Arrays.asList(TAgentTask.AGENT_STATUS_READY, TAgentTask.AGENT_STATUS_PROCESSING)); | |||
List<TAgentTask> tAgentTasks = tAgentTaskService.selectTAgentTaskList(task); | |||
tAgentTasks.forEach((x) -> { | |||
x.setOtherCount(x.getAllCount() - x.getContracCount() - x.getVoucherCount()); | |||
}); | |||
return getDataTable(tAgentTasks); | |||
} | |||
} |
@@ -44,7 +44,6 @@ public class AgentTaskController extends BaseController | |||
public TableDataInfo taskList(TAgentTask task) | |||
{ | |||
startPage(); | |||
task.setEndAt(DateUtils.getDate()); | |||
return getDataTable(tAgentTaskService.getTownTaskList(task)); | |||
} | |||
} |
@@ -68,11 +68,11 @@ public class TAgentContraction extends BaseEntity | |||
private String orderMonth; | |||
/** 任务状态 字典 agent_status */ | |||
@Excel(name = "任务状态 字典 agent_status") | |||
@Excel(name = "任务状态", dictType = "agent_status") | |||
private String agentStatus; | |||
/** 记账状态 字典 order_status */ | |||
@Excel(name = "记账状态 字典 order_status") | |||
@Excel(name = "记账状态", dictType = "order_status") | |||
private String orderStatus; | |||
public void normalized() | |||
@@ -80,4 +80,6 @@ public class TAgentContraction extends BaseEntity | |||
orderYear = DateUtil.format(orderAt, "yyyy"); | |||
orderMonth = DateUtil.format(orderAt, "MM"); | |||
} | |||
private Long rootId; | |||
} |
@@ -168,4 +168,7 @@ public class TAgentTask extends BaseEntity | |||
@Excel(name = "是否评价", dictType = "sys_yes_no") | |||
private String isAppraise; | |||
/** 其他数 */ | |||
@Excel(name = "其他数") | |||
private Integer otherCount; | |||
} |
@@ -99,4 +99,6 @@ public interface TAgentContractionMapper | |||
* @return 合同任务是否存在 | |||
*/ | |||
public int selectTAgentContractionExists(TAgentContraction tAgentContraction); | |||
public List<TAgentContraction> getAgentContractionGroupByDept(TAgentContraction tAgentContraction); | |||
} |
@@ -36,10 +36,10 @@ public class AgentCenterImpl implements IAgentCenter | |||
return protocol; | |||
} | |||
public Session<?> createSession(NSSDKServer server, HttpServletRequest request) | |||
public Session<? extends NSMessage> createSession(NSSDKServer server, HttpServletRequest request) | |||
{ | |||
NSReportObject<? extends NSMessage> reportObject; | |||
Session<?> session; | |||
Session<? extends NSMessage> session; | |||
Class<? extends NSMessage> clazz; | |||
int protocol; | |||
@@ -64,7 +64,7 @@ public class AgentCenterImpl implements IAgentCenter | |||
return session; | |||
} | |||
private void check(Session<?> session, HttpServletRequest request) | |||
private void check(Session<? extends NSMessage> session, HttpServletRequest request) | |||
{ | |||
Assert.notNull(session, "无效消息"); | |||
String identifier = session.identifier; | |||
@@ -73,6 +73,8 @@ public class AgentCenterImpl implements IAgentCenter | |||
Assert.notNull(dept, "不支持的地区: {}", identifier); | |||
String remoteUrl = dept.getRemoteUrl(); | |||
Assert.notBlank(remoteUrl, "该地区无项目: {}", identifier); | |||
session.data.setDeptId(dept.getDeptId()); | |||
/*try | |||
{ | |||
URL url = new URL(remoteUrl); | |||
@@ -94,7 +96,7 @@ public class AgentCenterImpl implements IAgentCenter | |||
@Override | |||
public Session<?> postHandle(NSSDKServer server, HttpServletRequest request) | |||
{ | |||
Session<?> session; | |||
Session<? extends NSMessage> session; | |||
session = createSession(server, request); | |||
check(session, request); | |||
@@ -4,15 +4,20 @@ import java.util.ArrayList; | |||
import java.util.List; | |||
import java.util.Map; | |||
import java.util.function.Consumer; | |||
import java.util.stream.Collectors; | |||
import cn.hutool.core.collection.CollectionUtil; | |||
import cn.hutool.core.lang.Assert; | |||
import com.ruoyi.agentcenter.domain.TAgentContraction; | |||
import com.ruoyi.agentcenter.mapper.TAgentContractionMapper; | |||
import com.ruoyi.agentcenter.vo.AgentTaskTownGroup; | |||
import com.ruoyi.agentcenter.vo.AgentTaskVillageGroup; | |||
import com.ruoyi.common.core.domain.entity.SysDept; | |||
import com.ruoyi.common.enums.Enums; | |||
import com.ruoyi.common.utils.ContainerUtils; | |||
import com.ruoyi.common.utils.DateUtils; | |||
import com.ruoyi.common.utils.DeptUtils; | |||
import com.ruoyi.common.utils.StringUtils; | |||
import com.ruoyi.system.mapper.SysDeptMapper; | |||
import org.springframework.beans.factory.annotation.Autowired; | |||
import org.springframework.stereotype.Service; | |||
@@ -34,7 +39,9 @@ public class TAgentTaskServiceImpl implements ITAgentTaskService | |||
@Autowired | |||
private TAgentTaskMapper tAgentTaskMapper; | |||
@Autowired | |||
private SysDeptMapper sysDeptMapper; | |||
private SysDeptMapper sysDeptMapper; | |||
@Autowired | |||
private TAgentContractionMapper agentContractionMapper; | |||
/** | |||
* 查询任务清单 | |||
@@ -286,9 +293,26 @@ public class TAgentTaskServiceImpl implements ITAgentTaskService | |||
List<AgentTaskTownGroup> agentTaskGroupByTown = tAgentTaskMapper.getAgentTaskGroupByTown(tAgentTask); | |||
if(CollectionUtil.isNotEmpty(agentTaskGroupByTown)) | |||
{ | |||
List<SysDept> deptList = sysDeptMapper.getDeptList(new SysDept()); | |||
Long rootId; | |||
if(StringUtils.isNotEmpty(tAgentTask.getTownCode())) | |||
rootId = deptList.stream().filter((x) -> tAgentTask.getTownCode().equals(x.getOrgCode())).map(SysDept::getParentId).findFirst().get(); | |||
else | |||
rootId = deptList.stream().filter((x) -> tAgentTask.getCountyCode().equals(x.getOrgCode())).map(SysDept::getDeptId).findFirst().get(); | |||
TAgentContraction contractionCond = new TAgentContraction(); | |||
contractionCond.setOrderStatus(Enums.OrderStatus.PAUSE); | |||
contractionCond.putParam("task", tAgentTask); | |||
List<TAgentContraction> contractionList = agentContractionMapper.getAgentContractionGroupByDept(contractionCond); | |||
Map<Long, Long> townExceptMap = DeptUtils.groupByDept(rootId, deptList, contractionList, TAgentContraction::getDeptId, Collectors.mapping(TAgentContraction::getId, Collectors.reducing(0L, Long::sum)), null); | |||
List<String> townCodeList = ContainerUtils.mapToList(agentTaskGroupByTown, AgentTaskTownGroup::getTownCode); | |||
Map<String, Long> contractionMap = ContainerUtils.toMap(contractionList, TAgentContraction::getOrgCode, TAgentContraction::getId); | |||
List<AgentTaskVillageGroup> villageGroups = tAgentTaskMapper.getAgentTaskGroupByVillage(new TAgentTask().putParam("townCodeList", townCodeList)); | |||
villageGroups.forEach((x) -> { | |||
x.setNumExcept(contractionMap.getOrDefault(x.getOrgCode(), 0L)); | |||
}); | |||
Map<String, List<AgentTaskVillageGroup>> villageMap = ContainerUtils.groupingBy(villageGroups, AgentTaskVillageGroup::getTownCode); | |||
List<String> orgCodeList = ContainerUtils.mapToList(villageGroups, AgentTaskVillageGroup::getOrgCode); | |||
@@ -298,7 +322,9 @@ public class TAgentTaskServiceImpl implements ITAgentTaskService | |||
List<TAgentTask> tAgentTasks = tAgentTaskMapper.selectTAgentTaskList(agentTaskCond); | |||
Map<String, List<TAgentTask>> bookGroup = ContainerUtils.groupingBy(tAgentTasks, TAgentTask::getOrgCode); | |||
Map<String, Long> deptIdMap = ContainerUtils.toMap(deptList, SysDept::getOrgCode, SysDept::getDeptId); | |||
agentTaskGroupByTown.forEach((town) -> { | |||
town.setNumExcept(townExceptMap.getOrDefault(deptIdMap.get(town.getTownCode()), 0L)); | |||
town.setVillageList(villageMap.getOrDefault(town.getTownCode(), new ArrayList<>())); | |||
town.getVillageList().forEach((village) -> { | |||
village.setTaskList(bookGroup.getOrDefault(village.getOrgCode(), new ArrayList<>())); | |||
@@ -247,6 +247,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" | |||
<if test="orderMonth != null and orderMonth != ''"> and order_month = #{orderMonth}</if> | |||
<if test="agentStatus != null and agentStatus != ''"> and agent_status = #{agentStatus}</if> | |||
<if test="orderStatus != null and orderStatus != ''"> and order_status = #{orderStatus}</if> | |||
<if test="rootId != null "> and (dept_id = #{rootId} OR dept_id IN (SELECT dept_id FROM sys_dept WHERE FIND_IN_SET(#{rootId}, ancestors)))</if> | |||
</where> | |||
</select> | |||
@@ -271,4 +272,37 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" | |||
limit 1 | |||
) | |||
</select> | |||
<select id="getAgentContractionGroupByDept" parameterType="TAgentContraction" resultMap="TAgentContractionResult"> | |||
select count(*) as id, org_code, dept_id from t_agent_contraction | |||
<where> | |||
<if test="taskId != null "> and task_id = #{taskId}</if> | |||
<if test="orgCode != null and orgCode != ''"> and org_code = #{orgCode}</if> | |||
<if test="outId != null "> and out_id = #{outId}</if> | |||
<if test="bookId != null "> and book_id = #{bookId}</if> | |||
<if test="deptId != null "> and dept_id = #{deptId}</if> | |||
<if test="name != null and name != ''"> and name like concat('%', #{name}, '%')</if> | |||
<if test="buildingTime != null and buildingTime != ''"> and building_time = #{buildingTime}</if> | |||
<if test="orderAt != null "> and order_at = #{orderAt}</if> | |||
<if test="orderYear != null and orderYear != ''"> and order_year = #{orderYear}</if> | |||
<if test="orderMonth != null and orderMonth != ''"> and order_month = #{orderMonth}</if> | |||
<if test="agentStatus != null and agentStatus != ''"> and agent_status = #{agentStatus}</if> | |||
<if test="orderStatus != null and orderStatus != ''"> and order_status = #{orderStatus}</if> | |||
<if test="rootId != null "> and (dept_id = #{rootId} OR dept_id IN (SELECT dept_id FROM sys_dept WHERE FIND_IN_SET(#{rootId}, ancestors)))</if> | |||
<if test="params != null"> | |||
<if test="params.task != null"> | |||
AND task_id IN (SELECT id FROM t_agent_task | |||
<where> | |||
<if test="params.task.agentCenter != null and params.task.agentCenter != ''"> and agent_center = #{params.task.agentCenter}</if> | |||
<if test="params.task.townCode != null and params.task.townCode != ''"> and town_code = #{params.task.townCode}</if> | |||
<if test="params.task.countyCode != null and params.task.countyCode != ''"> and county_code = #{params.task.countyCode}</if> | |||
<if test="params.task.orderYear != null and params.task.orderYear != ''"> and order_year = #{params.task.orderYear}</if> | |||
<if test="params.task.orderMonth != null and params.task.orderMonth != ''"> and order_month = #{params.task.orderMonth}</if> | |||
</where> | |||
) | |||
</if> | |||
</if> | |||
</where> | |||
GROUP BY org_code | |||
</select> | |||
</mapper> |
@@ -91,6 +91,9 @@ | |||
<if test="params.orgCodeList != null"> | |||
AND org_code IN (null <foreach collection="params.orgCodeList" item="i">,#{i}</foreach> ) | |||
</if> | |||
<if test="params.agentStatusList != null"> | |||
AND agent_status IN (null <foreach collection="params.agentStatusList" item="i">,#{i}</foreach> ) | |||
</if> | |||
</if> | |||
</where> | |||
</select> | |||
@@ -538,7 +541,6 @@ | |||
COUNT(*) as num, | |||
IFNULL(SUM(IF(agent_status = '3', 1, 0)), 0) as num_process_finish, | |||
IFNULL(SUM(IF(is_audit = 'Y', 1, 0)), 0) as num_approval_finish, | |||
IFNULL(SUM(IF(agent_status != '3' AND end_at < #{endAt}, 1, 0)), 0) as num_except, | |||
town_name, town_code, | |||
order_year, order_month | |||
FROM | |||
@@ -546,6 +548,7 @@ | |||
<where> | |||
<if test="agentCenter != null and agentCenter != ''"> and agent_center = #{agentCenter}</if> | |||
<if test="countyCode != null and countyCode != ''"> and county_code = #{countyCode}</if> | |||
<if test="townCode != null and townCode != ''"> and town_code = #{townCode}</if> | |||
<if test="orderYear != null and orderYear != ''"> and order_year = #{orderYear}</if> | |||
<if test="orderMonth != null and orderMonth != ''"> and order_month = #{orderMonth}</if> | |||
</where> | |||
@@ -574,7 +577,6 @@ | |||
COUNT(*) as num, | |||
IFNULL(SUM(IF(agent_status = '3', 1, 0)), 0) as num_process_finish, | |||
IFNULL(SUM(IF(is_audit = 'Y', 1, 0)), 0) as num_approval_finish, | |||
IFNULL(SUM(IF(agent_status != '3' AND end_at < #{endAt}, 1, 0)), 0) as num_except, | |||
org_name, org_code, town_code, | |||
MAX(end_at) as end_at, MAX(handle_date) as handle_date, MAX(end_at) as end_at, handle_nick | |||
FROM | |||
@@ -53,6 +53,14 @@ public class BaseController | |||
* 设置请求分页数据 | |||
*/ | |||
protected void startPage() | |||
{ | |||
PageUtils.startPageIf(); | |||
} | |||
/** | |||
* 设置请求分页数据 | |||
*/ | |||
protected void mustPage() | |||
{ | |||
PageUtils.startPage(); | |||
} | |||
@@ -301,4 +301,27 @@ public class SysDept extends BaseEntity | |||
{ | |||
this.orgCodeLength = orgCodeLength; | |||
} | |||
private List<Long> childrenIdList; | |||
private List<Long> ancestorsIdList; | |||
public List<Long> getChildrenIdList() | |||
{ | |||
return childrenIdList; | |||
} | |||
public void setChildrenIdList(List<Long> childrenIdList) | |||
{ | |||
this.childrenIdList = childrenIdList; | |||
} | |||
public List<Long> getAncestorsIdList() | |||
{ | |||
return ancestorsIdList; | |||
} | |||
public void setAncestorsIdList(List<Long> ancestorsIdList) | |||
{ | |||
this.ancestorsIdList = ancestorsIdList; | |||
} | |||
} |
@@ -49,6 +49,17 @@ public class TableSupport | |||
return pageDomain; | |||
} | |||
public static PageDomain getPageDomain(Integer pageNum, Integer pageSize) | |||
{ | |||
PageDomain pageDomain = new PageDomain(); | |||
pageDomain.setPageNum(Convert.toInt(ServletUtils.getParameter(PAGE_NUM), pageNum)); | |||
pageDomain.setPageSize(Convert.toInt(ServletUtils.getParameter(PAGE_SIZE), pageSize)); | |||
pageDomain.setOrderByColumn(ServletUtils.getParameter(ORDER_BY_COLUMN)); | |||
pageDomain.setIsAsc(ServletUtils.getParameter(IS_ASC)); | |||
pageDomain.setReasonable(ServletUtils.getParameterToBool(REASONABLE)); | |||
return pageDomain; | |||
} | |||
public static PageDomain buildPageRequest() | |||
{ | |||
return getPageDomain(); | |||
@@ -0,0 +1,11 @@ | |||
package com.ruoyi.common.enums; | |||
public final class Enums | |||
{ | |||
public final static class OrderStatus | |||
{ | |||
public static final String READY = "2"; // 待记账 | |||
public static final String FINISHED = "3"; // 已记账 | |||
public static final String PAUSE = "4"; // 已挂起 | |||
} | |||
} |
@@ -1,5 +1,17 @@ | |||
package com.ruoyi.common.utils; | |||
import cn.hutool.core.collection.CollectionUtil; | |||
import com.ruoyi.common.core.domain.entity.SysDept; | |||
import java.util.ArrayList; | |||
import java.util.Collections; | |||
import java.util.HashMap; | |||
import java.util.List; | |||
import java.util.Map; | |||
import java.util.function.Function; | |||
import java.util.stream.Collector; | |||
import java.util.stream.Collectors; | |||
public final class DeptUtils | |||
{ | |||
public static final int LEVEL_INVALID = 0; // 无效 | |||
@@ -144,5 +156,58 @@ public final class DeptUtils | |||
return null == level ? LEVEL_INVALID : Integer.parseInt(level); | |||
} | |||
public static List<SysDept> getSubDepts_selfAndAllChildren(Long deptId, List<SysDept> depts) | |||
{ | |||
if(CollectionUtil.isEmpty(depts)) | |||
return new ArrayList<>(); | |||
if(depts.size() == 1) | |||
{ | |||
SysDept dept = depts.get(0); | |||
if(deptId.equals(dept.getDeptId())) | |||
{ | |||
dept.setChildren(new ArrayList<>(depts)); | |||
dept.setChildrenIdList(new ArrayList<>(Collections.singletonList(dept.getDeptId()))); | |||
return depts; | |||
} | |||
else | |||
return new ArrayList<>(); | |||
} | |||
//depts.removeIf((x) -> deptId.equals(x.getDeptId())); | |||
depts.forEach((x) -> x.setAncestorsIdList(x.makeAncestorsIdList(true))); | |||
List<SysDept> res = depts.stream() | |||
.filter((x) -> deptId.equals(x.getParentId())) | |||
.peek((x) -> x.setChildren(new ArrayList<>(Collections.singletonList(x)))) | |||
.peek((x) -> x.setChildrenIdList(new ArrayList<>(Collections.singletonList(x.getDeptId())))) | |||
.peek((x) -> x.getChildren().addAll(depts.stream().filter((y) -> CollectionUtil.contains(y.getAncestorsIdList(), x.getDeptId())).collect(Collectors.toList()))) | |||
.peek((x) -> x.getChildrenIdList().addAll(depts.stream().filter((y) -> CollectionUtil.contains(y.getAncestorsIdList(), x.getDeptId())).map(SysDept::getDeptId).collect(Collectors.toList()))) | |||
.collect(Collectors.toList()); | |||
return res; | |||
} | |||
public static <T> Map<Long, List<T>> groupByDept(Long deptId, List<SysDept> allDepts, List<T> list, Function<T, Long> getDeptId, List<SysDept> returnDeptList) | |||
{ | |||
return groupByDept(deptId, allDepts, list, getDeptId, Collectors.toList(), returnDeptList); | |||
} | |||
public static <T, A, R> Map<Long, R> groupByDept(Long deptId, List<SysDept> allDepts, List<T> list, Function<T, Long> getDeptId, Collector<T, A, R> collector, List<SysDept> returnDeptList) | |||
{ | |||
List<SysDept> depts = getSubDepts_selfAndAllChildren(deptId, allDepts); | |||
Map<Long, Long> deptMap = new HashMap<>(); | |||
depts.forEach((x) -> { | |||
deptMap.put(x.getDeptId(), x.getDeptId()); | |||
x.getChildrenIdList().forEach((y) -> { | |||
deptMap.put(y, x.getDeptId()); | |||
}); | |||
}); | |||
Map<Long, R> collect = list.stream() | |||
.collect(Collectors.groupingBy((x) -> deptMap.getOrDefault(getDeptId.apply(x), 0L), collector)); | |||
if(null != returnDeptList) | |||
{ | |||
returnDeptList.addAll(depts); | |||
} | |||
return collect; | |||
} | |||
private DeptUtils() {} | |||
} |
@@ -25,6 +25,30 @@ public class PageUtils extends PageHelper | |||
PageHelper.startPage(pageNum, pageSize, orderBy).setReasonable(reasonable); | |||
} | |||
/** | |||
* 设置请求分页数据 | |||
*/ | |||
public static void startPageIf() | |||
{ | |||
PageDomain pageDomain = TableSupport.getPageDomain(null, null); | |||
Integer pageNum = pageDomain.getPageNum(); | |||
Integer pageSize = pageDomain.getPageSize(); | |||
if(null != pageNum && null != pageSize) | |||
{ | |||
PageHelper.startPage(pageNum, pageSize); | |||
} | |||
String orderBy = SqlUtil.escapeOrderBySql(pageDomain.getOrderBy()); | |||
if(StringUtils.isNotEmpty(orderBy)) | |||
{ | |||
PageHelper.orderBy(orderBy); | |||
} | |||
if(null != PageHelper.getLocalPage()) | |||
{ | |||
Boolean reasonable = pageDomain.getReasonable(); | |||
PageHelper.getLocalPage().setReasonable(reasonable); | |||
} | |||
} | |||
/** | |||
* 清理分页的线程变量 | |||
*/ | |||
@@ -139,4 +139,5 @@ public interface ISysDeptService | |||
public List<SysDept> getDeptTree(SysDept dept); | |||
public List<SysDept> getCityTree(SysDept dept); | |||
public SysDept selectSysDeptByOrgCode(String orgCode); | |||
} |
@@ -382,4 +382,10 @@ public class SysDeptServiceImpl implements ISysDeptService | |||
depts.removeIf((x) -> x.orgCodeLength() != 6); | |||
return depts; | |||
} | |||
@Override | |||
public SysDept selectSysDeptByOrgCode(String orgCode) | |||
{ | |||
return deptMapper.selectSysDeptByOrgCode(orgCode); | |||
} | |||
} |