From 10f6f4bd6a9679dfec34307007299824bc843020 Mon Sep 17 00:00:00 2001 From: zhaochengke Date: Mon, 17 Jul 2023 16:31:41 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BB=BB=E5=8A=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/nsgk/agentcentersdk/NSMain.java | 9 +- .../nsgk/agentcentersdk/entity/NSEntity.java | 3 + .../agentcenter/AgentCenterController.java | 4 + ruoyi-agentcenter/pom.xml | 4 + .../ruoyi/agentcenter/domain/TAgentTask.java | 93 +++-- .../listener/ContractionListener.java | 57 ++- .../agentcenter/mapper/TAgentTaskMapper.java | 4 +- .../service/ITAgentTaskService.java | 6 +- .../service/impl/TAgentTaskServiceImpl.java | 54 ++- .../mapper/agentcenter/TAgentTaskMapper.xml | 329 ++++++++++++------ .../common/core/domain/entity/SysDept.java | 79 ++++- .../com/ruoyi/common/utils/DeptUtils.java | 148 ++++++++ .../com/ruoyi/common/utils/sql/SqlUtil.java | 46 +++ .../ruoyi/system/mapper/SysDeptMapper.java | 7 + .../ruoyi/system/service/ISysDeptService.java | 7 + .../service/impl/SysDeptServiceImpl.java | 10 + .../resources/mapper/system/SysDeptMapper.xml | 60 +++- 17 files changed, 751 insertions(+), 169 deletions(-) create mode 100644 ruoyi-common/src/main/java/com/ruoyi/common/utils/DeptUtils.java diff --git a/agentcenter-sdk/src/main/java/com/nsgk/agentcentersdk/NSMain.java b/agentcenter-sdk/src/main/java/com/nsgk/agentcentersdk/NSMain.java index e02bef8..f7d216f 100644 --- a/agentcenter-sdk/src/main/java/com/nsgk/agentcentersdk/NSMain.java +++ b/agentcenter-sdk/src/main/java/com/nsgk/agentcentersdk/NSMain.java @@ -50,7 +50,14 @@ public final class NSMain entity = new NSEntity(); entity.setDeptId(187L) .setBookId(166L) - .setOrgCode("371081") + .setOrgCode("371002100005") + .setBookName("张村账套") + .setOrgCode("3710021000050001") + .setBookName("张村1组账套") + .setOrgCode("371002100") + .setBookName("张村镇账套") + .setOrgCode("371002") + .setBookName("环翠区账套") ; entity.Parm("buildingTime", "2000-12-25"); entity.Parm("name", "测试合同"); diff --git a/agentcenter-sdk/src/main/java/com/nsgk/agentcentersdk/entity/NSEntity.java b/agentcenter-sdk/src/main/java/com/nsgk/agentcentersdk/entity/NSEntity.java index d99d0ea..1cf0e71 100644 --- a/agentcenter-sdk/src/main/java/com/nsgk/agentcentersdk/entity/NSEntity.java +++ b/agentcenter-sdk/src/main/java/com/nsgk/agentcentersdk/entity/NSEntity.java @@ -34,6 +34,9 @@ public class NSEntity implements Serializable /** 外部ID */ protected String orgCode; + /** 账套名称 */ + protected String bookName; + // 存储其他没有声明的属性, 用于当客户端与服务端字段不一致时, 在不更新sdk的情况下, 保持兼容性 // 不会覆盖已设置的属性 protected Map parms; diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/agentcenter/AgentCenterController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/agentcenter/AgentCenterController.java index 6d62cc1..fe1f681 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/agentcenter/AgentCenterController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/agentcenter/AgentCenterController.java @@ -62,6 +62,10 @@ public class AgentCenterController extends BaseController { return NSSDKServer.Fail(e.getErrno(), e.getMessage()); } + catch(IllegalArgumentException e) + { + return NSSDKServer.Fail(NSErrno.ERRNO_ERROR, e.getMessage()); + } } private NSApiResult response(Result result) diff --git a/ruoyi-agentcenter/pom.xml b/ruoyi-agentcenter/pom.xml index 6d60ef2..787a48f 100644 --- a/ruoyi-agentcenter/pom.xml +++ b/ruoyi-agentcenter/pom.xml @@ -26,6 +26,10 @@ com.nsgk agentcenter-sdk + + com.ruoyi + ruoyi-system + diff --git a/ruoyi-agentcenter/src/main/java/com/ruoyi/agentcenter/domain/TAgentTask.java b/ruoyi-agentcenter/src/main/java/com/ruoyi/agentcenter/domain/TAgentTask.java index 302bfed..716ca2e 100644 --- a/ruoyi-agentcenter/src/main/java/com/ruoyi/agentcenter/domain/TAgentTask.java +++ b/ruoyi-agentcenter/src/main/java/com/ruoyi/agentcenter/domain/TAgentTask.java @@ -14,7 +14,7 @@ import com.ruoyi.common.core.domain.BaseEntity; * 任务清单对象 t_agent_task * * @author zhao - * @date 2023-05-06 + * @date 2023-07-14 */ @Data @Accessors(chain = true) @@ -26,7 +26,7 @@ public class TAgentTask extends BaseEntity private Long id; /** 所属中心 字典 agent_center */ - @Excel(name = "所属中心", dictType = "agent_center") + @Excel(name = "所属中心 字典 agent_center") private String agentCenter; /** 县代码 */ @@ -53,9 +53,21 @@ public class TAgentTask extends BaseEntity @Excel(name = "村名称") private String orgName; - /** 账套数 */ - @Excel(name = "账套数") - private Integer bookCount; + /** 账套id */ + @Excel(name = "账套id") + private Long bookId; + + /** 账套名称 */ + @Excel(name = "账套名称") + private String bookName; + + /** 任务年度 */ + @Excel(name = "任务年度") + private String orderYear; + + /** 任务月份 */ + @Excel(name = "任务月份") + private String orderMonth; /** 凭证数 */ @Excel(name = "凭证数") @@ -63,7 +75,7 @@ public class TAgentTask extends BaseEntity /** 合同数 */ @Excel(name = "合同数") - private Integer contractionCount; + private Integer contracCount; /** 资产数 */ @Excel(name = "资产数") @@ -73,55 +85,76 @@ public class TAgentTask extends BaseEntity @Excel(name = "任务总数") private Integer allCount; - /** 任务年度 */ - @Excel(name = "任务年度") - private String orderYear; + /** 完成数 */ + @Excel(name = "完成数") + private Integer finishCount; - /** 任务月份 */ - @Excel(name = "任务月份") - private String orderMonth; - - /** 任务状态 字典 agent_status (任务人全部完成后交任务的动作) */ - @Excel(name = "任务状态", dictType = "agent_status") + /** 任务状态 字典 agent_status */ + @Excel(name = "任务状态 字典 agent_status") private String agentStatus; - /** 分配主管(用user_name) */ - @Excel(name = "分配主管") - private String distributionChief; + /** 分配用户(用user_name) */ + @Excel(name = "分配用户(用user_name)") + private String distriUser; + + /** 分配人(用nick_name) */ + @Excel(name = "分配人(用nick_name)") + private String distriNick; /** 分配时间 */ @JsonFormat(pattern = "yyyy-MM-dd") @Excel(name = "分配时间", width = 30, dateFormat = "yyyy-MM-dd") - private Date distributionDate; + private Date distriDate; /** 任务截止日期 */ @Excel(name = "任务截止日期") private String endAt; - /** 记账会计(即被分配人,用user_name) */ - @Excel(name = "记账会计") - private String handleAccount; + /** 记账用户(用user_name) */ + @Excel(name = "记账用户(用user_name)") + private String handleUser; + + /** 记账会计(用nick_name) */ + @Excel(name = "记账会计(用nick_name)") + private String handleNick; + + /** 记账备注 */ + @Excel(name = "记账备注") + private String handleRemark; /** 记账完成时间 */ @JsonFormat(pattern = "yyyy-MM-dd") @Excel(name = "记账完成时间", width = 30, dateFormat = "yyyy-MM-dd") private Date handleDate; - /** 审核会计(用user_name) */ - @Excel(name = "审核会计(用user_name)") - private String auditAccount; + /** 审核用户(用user_name) */ + @Excel(name = "审核用户(用user_name)") + private String auditUser; + + /** 审核人(用nick_name) */ + @Excel(name = "审核人(用nick_name)") + private String auditNick; /** 审核时间 */ @JsonFormat(pattern = "yyyy-MM-dd") @Excel(name = "审核时间", width = 30, dateFormat = "yyyy-MM-dd") private Date auditDate; - /** 任务评分(分配主管来评价) */ + /** 评价用户(用user_name) */ + @Excel(name = "评价用户(用user_name)") + private String appraiseUser; + + /** 评价人(用nick_name) */ + @Excel(name = "评价人(用nick_name)") + private String appraiseNick; + + /** 任务评分 */ @Excel(name = "任务评分") - private BigDecimal taskScore; + private BigDecimal appraiseScore; + + /** 评价备注 */ + @Excel(name = "评价备注") + private String appraiseRemark; - /** 任务评价 */ - @Excel(name = "任务评价") - private String taskAppraise; } diff --git a/ruoyi-agentcenter/src/main/java/com/ruoyi/agentcenter/listener/ContractionListener.java b/ruoyi-agentcenter/src/main/java/com/ruoyi/agentcenter/listener/ContractionListener.java index b9dac8b..b50450f 100644 --- a/ruoyi-agentcenter/src/main/java/com/ruoyi/agentcenter/listener/ContractionListener.java +++ b/ruoyi-agentcenter/src/main/java/com/ruoyi/agentcenter/listener/ContractionListener.java @@ -1,14 +1,20 @@ package com.ruoyi.agentcenter.listener; +import cn.hutool.core.lang.Assert; import com.alibaba.fastjson2.JSONObject; import com.google.common.eventbus.Subscribe; import com.nsgk.agentcentersdk.entity.NSContractionEntity; import com.ruoyi.agentcenter.domain.TAgentContraction; +import com.ruoyi.agentcenter.domain.TAgentTask; import com.ruoyi.agentcenter.object.ContractionSession; import com.ruoyi.agentcenter.object.Message; import com.ruoyi.agentcenter.object.Result; import com.ruoyi.agentcenter.service.ITAgentContractionService; +import com.ruoyi.agentcenter.service.ITAgentTaskService; +import com.ruoyi.common.core.domain.entity.SysDept; import com.ruoyi.common.utils.EventBusEngine; +import com.ruoyi.common.utils.sql.SqlUtil; +import com.ruoyi.system.service.ISysDeptService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @@ -20,6 +26,10 @@ public class ContractionListener { @Autowired private ITAgentContractionService itAgentContractionService; + @Autowired + private ITAgentTaskService itAgentTaskService; + @Autowired + private ISysDeptService iSysDeptService; @PostConstruct public void init() @@ -34,7 +44,11 @@ public class ContractionListener TAgentContraction contraction = conv(session.message); Result result = session.result; - itAgentContractionService.insertTAgentContraction(contraction); + SqlUtil.transaction(() -> { + TAgentTask task = syncTask(session.message.getData(), contraction); + contraction.setTaskId(task.getId()); + itAgentContractionService.insertTAgentContraction(contraction); + }); result.setData(contraction); } @@ -56,4 +70,45 @@ public class ContractionListener ; return contraction; } + + private TAgentTask syncTask(NSContractionEntity entity, TAgentContraction contraction) + { + String orgCode = contraction.getOrgCode(); + TAgentTask task = new TAgentTask(); + task.setOrgCode(orgCode) + .setOrderYear(contraction.getOrderYear()) + .setOrderMonth(contraction.getOrderMonth()) + ; + TAgentTask tAgentTask = itAgentTaskService.selectTAgentTask(task); + if(null == tAgentTask) + { + SysDept deptCond = new SysDept(); + deptCond.setOrgCode(orgCode); + SysDept dept = iSysDeptService.selectSysDept(deptCond); + Assert.notNull(dept, "部门不存在: {}", orgCode); + task.setBookId(contraction.getBookId()) + .setBookName(entity.getBookName()) + + .setContracCount(0) + .setVoucherCount(0) + .setAssetCount(0) + .setAllCount(0) + .setFinishCount(0) + + .setAgentCenter(dept.getAgentCenter()) + .setAgentStatus("1") + ; + itAgentTaskService.fillTAgentTaskOrg(task); + task.setCreateBy("admin"); + itAgentTaskService.insertTAgentTask(task); + tAgentTask = task; + } + + task = new TAgentTask(); + task.setContracCount(1); + task.setId(tAgentTask.getId()); + itAgentTaskService.updateTAgentTaskCount(task); + + return task; + } } diff --git a/ruoyi-agentcenter/src/main/java/com/ruoyi/agentcenter/mapper/TAgentTaskMapper.java b/ruoyi-agentcenter/src/main/java/com/ruoyi/agentcenter/mapper/TAgentTaskMapper.java index 15361a6..fcb6cef 100644 --- a/ruoyi-agentcenter/src/main/java/com/ruoyi/agentcenter/mapper/TAgentTaskMapper.java +++ b/ruoyi-agentcenter/src/main/java/com/ruoyi/agentcenter/mapper/TAgentTaskMapper.java @@ -7,7 +7,7 @@ import com.ruoyi.agentcenter.domain.TAgentTask; * 任务清单Mapper接口 * * @author zhao - * @date 2023-05-06 + * @date 2023-07-14 */ public interface TAgentTaskMapper { @@ -99,4 +99,6 @@ public interface TAgentTaskMapper * @return 任务清单是否存在 */ public int selectTAgentTaskExists(TAgentTask tAgentTask); + + public int updateTAgentTaskCount(TAgentTask tAgentTask); } diff --git a/ruoyi-agentcenter/src/main/java/com/ruoyi/agentcenter/service/ITAgentTaskService.java b/ruoyi-agentcenter/src/main/java/com/ruoyi/agentcenter/service/ITAgentTaskService.java index b7d6938..7576055 100644 --- a/ruoyi-agentcenter/src/main/java/com/ruoyi/agentcenter/service/ITAgentTaskService.java +++ b/ruoyi-agentcenter/src/main/java/com/ruoyi/agentcenter/service/ITAgentTaskService.java @@ -7,7 +7,7 @@ import com.ruoyi.agentcenter.domain.TAgentTask; * 任务清单Service接口 * * @author zhao - * @date 2023-05-06 + * @date 2023-07-14 */ public interface ITAgentTaskService { @@ -99,4 +99,8 @@ public interface ITAgentTaskService * @return 任务清单是否存在 */ public boolean selectTAgentTaskExists(TAgentTask tAgentTask); + + public int updateTAgentTaskCount(TAgentTask tAgentTask); + + public void fillTAgentTaskOrg(TAgentTask tAgentTask); } diff --git a/ruoyi-agentcenter/src/main/java/com/ruoyi/agentcenter/service/impl/TAgentTaskServiceImpl.java b/ruoyi-agentcenter/src/main/java/com/ruoyi/agentcenter/service/impl/TAgentTaskServiceImpl.java index 87eaf0e..2d4e39c 100644 --- a/ruoyi-agentcenter/src/main/java/com/ruoyi/agentcenter/service/impl/TAgentTaskServiceImpl.java +++ b/ruoyi-agentcenter/src/main/java/com/ruoyi/agentcenter/service/impl/TAgentTaskServiceImpl.java @@ -1,26 +1,33 @@ package com.ruoyi.agentcenter.service.impl; import java.util.List; + +import cn.hutool.core.lang.Assert; +import com.ruoyi.common.core.domain.entity.SysDept; import com.ruoyi.common.utils.DateUtils; -import org.apache.commons.collections4.ListUtils; +import com.ruoyi.common.utils.DeptUtils; +import com.ruoyi.system.mapper.SysDeptMapper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import org.apache.commons.collections4.ListUtils; import com.ruoyi.agentcenter.mapper.TAgentTaskMapper; import com.ruoyi.agentcenter.domain.TAgentTask; import com.ruoyi.agentcenter.service.ITAgentTaskService; -import org.springframework.transaction.annotation.Transactional; /** * 任务清单Service业务层处理 * * @author zhao - * @date 2023-05-06 + * @date 2023-07-14 */ @Service public class TAgentTaskServiceImpl implements ITAgentTaskService { @Autowired private TAgentTaskMapper tAgentTaskMapper; + @Autowired + private SysDeptMapper sysDeptMapper; /** * 查询任务清单 @@ -161,4 +168,45 @@ public class TAgentTaskServiceImpl implements ITAgentTaskService public boolean selectTAgentTaskExists(TAgentTask tAgentTask) { return tAgentTaskMapper.selectTAgentTaskExists(tAgentTask) > 0; } + + @Override + public int updateTAgentTaskCount(TAgentTask tAgentTask) + { + return tAgentTaskMapper.updateTAgentTaskCount(tAgentTask); + } + + @Override + public void fillTAgentTaskOrg(TAgentTask tAgentTask) + { + String orgCode = tAgentTask.getOrgCode(); + int level = DeptUtils.parseOrgCodeLevel(orgCode); + Assert.isTrue(level >= DeptUtils.LEVEL_TOWN, "orgCode必须是镇级或镇以下级别"); + + SysDept deptCond = new SysDept(); + deptCond.setOrgCode(orgCode); + SysDept org = sysDeptMapper.selectSysDept(deptCond); + Assert.notNull(org, "orgCode对应的地区不存在: {} - {}", orgCode, level); + List levelIds = org.makeAncestorsIdList(true); + + SysDept town; + SysDept county; + + if(level > DeptUtils.LEVEL_TOWN) // 镇级以下 + { + town = sysDeptMapper.selectDeptById(levelIds.get(DeptUtils.LEVEL_TOWN)); + Assert.notNull(town, "orgCode对应的镇级地区不存在: {} - {}", orgCode, level); + } + else + town = org; + + county = sysDeptMapper.selectDeptById(levelIds.get(DeptUtils.LEVEL_COUNTY)); + Assert.notNull(county, "orgCode对应的区级地区不存在: {} - {}", orgCode, level); + + tAgentTask.setCountyCode(county.getOrgCode()) + .setCountyName(county.getDeptName()) + .setTownCode(town.getOrgCode()) + .setTownName(town.getDeptName()) + .setOrgName(org.getDeptName()) + ; + } } diff --git a/ruoyi-agentcenter/src/main/resources/mapper/agentcenter/TAgentTaskMapper.xml b/ruoyi-agentcenter/src/main/resources/mapper/agentcenter/TAgentTaskMapper.xml index 7758197..cf80301 100644 --- a/ruoyi-agentcenter/src/main/resources/mapper/agentcenter/TAgentTaskMapper.xml +++ b/ruoyi-agentcenter/src/main/resources/mapper/agentcenter/TAgentTaskMapper.xml @@ -13,23 +13,31 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - + + + + - + - - + - - + + + - + + + - + + - - + + + + @@ -37,7 +45,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - select id, agent_center, county_code, county_name, town_code, town_name, org_code, org_name, book_count, voucher_count, contraction_count, asset_count, all_count, order_year, order_month, agent_status, distribution_chief, distribution_date, end_at, handle_account, handle_date, audit_account, audit_date, task_score, task_appraise, create_by, create_time, update_by, update_time from t_agent_task + select id, agent_center, county_code, county_name, town_code, town_name, org_code, org_name, book_id, book_name, order_year, order_month, voucher_count, contrac_count, asset_count, all_count, finish_count, agent_status, distri_user, distri_nick, distri_date, end_at, handle_user, handle_nick, handle_remark, handle_date, audit_user, audit_nick, audit_date, appraise_user, appraise_nick, appraise_score, appraise_remark, create_by, create_time, update_by, update_time from t_agent_task @@ -51,23 +59,31 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" and town_name like concat('%', #{townName}, '%') and org_code = #{orgCode} and org_name like concat('%', #{orgName}, '%') - and book_count = #{bookCount} + and book_id = #{bookId} + and book_name like concat('%', #{bookName}, '%') + and order_year = #{orderYear} + and order_month = #{orderMonth} and voucher_count = #{voucherCount} - and contraction_count = #{contractionCount} + and contrac_count = #{contracCount} and asset_count = #{assetCount} and all_count = #{allCount} - and order_year = #{orderYear} - and order_month = #{orderMonth} + and finish_count = #{finishCount} and agent_status = #{agentStatus} - and distribution_chief = #{distributionChief} - and distribution_date = #{distributionDate} + and distri_user = #{distriUser} + and distri_nick = #{distriNick} + and distri_date = #{distriDate} and end_at = #{endAt} - and handle_account = #{handleAccount} + and handle_user = #{handleUser} + and handle_nick = #{handleNick} + and handle_remark = #{handleRemark} and handle_date = #{handleDate} - and audit_account = #{auditAccount} + and audit_user = #{auditUser} + and audit_nick = #{auditNick} and audit_date = #{auditDate} - and task_score = #{taskScore} - and task_appraise = #{taskAppraise} + and appraise_user = #{appraiseUser} + and appraise_nick = #{appraiseNick} + and appraise_score = #{appraiseScore} + and appraise_remark = #{appraiseRemark} @@ -88,23 +104,31 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" town_name, org_code, org_name, - book_count, + book_id, + book_name, + order_year, + order_month, voucher_count, - contraction_count, + contrac_count, asset_count, all_count, - order_year, - order_month, + finish_count, agent_status, - distribution_chief, - distribution_date, + distri_user, + distri_nick, + distri_date, end_at, - handle_account, + handle_user, + handle_nick, + handle_remark, handle_date, - audit_account, + audit_user, + audit_nick, audit_date, - task_score, - task_appraise, + appraise_user, + appraise_nick, + appraise_score, + appraise_remark, create_by, create_time, update_by, @@ -118,23 +142,31 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" #{townName}, #{orgCode}, #{orgName}, - #{bookCount}, + #{bookId}, + #{bookName}, + #{orderYear}, + #{orderMonth}, #{voucherCount}, - #{contractionCount}, + #{contracCount}, #{assetCount}, #{allCount}, - #{orderYear}, - #{orderMonth}, + #{finishCount}, #{agentStatus}, - #{distributionChief}, - #{distributionDate}, + #{distriUser}, + #{distriNick}, + #{distriDate}, #{endAt}, - #{handleAccount}, + #{handleUser}, + #{handleNick}, + #{handleRemark}, #{handleDate}, - #{auditAccount}, + #{auditUser}, + #{auditNick}, #{auditDate}, - #{taskScore}, - #{taskAppraise}, + #{appraiseUser}, + #{appraiseNick}, + #{appraiseScore}, + #{appraiseRemark}, #{createBy}, #{createTime}, #{updateBy}, @@ -153,23 +185,31 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" town_name, org_code, org_name, - book_count, + book_id, + book_name, + order_year, + order_month, voucher_count, - contraction_count, + contrac_count, asset_count, all_count, - order_year, - order_month, + finish_count, agent_status, - distribution_chief, - distribution_date, + distri_user, + distri_nick, + distri_date, end_at, - handle_account, + handle_user, + handle_nick, + handle_remark, handle_date, - audit_account, + audit_user, + audit_nick, audit_date, - task_score, - task_appraise, + appraise_user, + appraise_nick, + appraise_score, + appraise_remark, create_by, create_time, update_by, @@ -185,23 +225,31 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" #{item.townName}, #{item.orgCode}, #{item.orgName}, - #{item.bookCount}, + #{item.bookId}, + #{item.bookName}, + #{item.orderYear}, + #{item.orderMonth}, #{item.voucherCount}, - #{item.contractionCount}, + #{item.contracCount}, #{item.assetCount}, #{item.allCount}, - #{item.orderYear}, - #{item.orderMonth}, + #{item.finishCount}, #{item.agentStatus}, - #{item.distributionChief}, - #{item.distributionDate}, + #{item.distriUser}, + #{item.distriNick}, + #{item.distriDate}, #{item.endAt}, - #{item.handleAccount}, + #{item.handleUser}, + #{item.handleNick}, + #{item.handleRemark}, #{item.handleDate}, - #{item.auditAccount}, + #{item.auditUser}, + #{item.auditNick}, #{item.auditDate}, - #{item.taskScore}, - #{item.taskAppraise}, + #{item.appraiseUser}, + #{item.appraiseNick}, + #{item.appraiseScore}, + #{item.appraiseRemark}, #{item.createBy}, #{item.createTime}, #{item.updateBy}, @@ -221,23 +269,31 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" town_name = #{townName}, org_code = #{orgCode}, org_name = #{orgName}, - book_count = #{bookCount}, + book_id = #{bookId}, + book_name = #{bookName}, + order_year = #{orderYear}, + order_month = #{orderMonth}, voucher_count = #{voucherCount}, - contraction_count = #{contractionCount}, + contrac_count = #{contracCount}, asset_count = #{assetCount}, all_count = #{allCount}, - order_year = #{orderYear}, - order_month = #{orderMonth}, + finish_count = #{finishCount}, agent_status = #{agentStatus}, - distribution_chief = #{distributionChief}, - distribution_date = #{distributionDate}, + distri_user = #{distriUser}, + distri_nick = #{distriNick}, + distri_date = #{distriDate}, end_at = #{endAt}, - handle_account = #{handleAccount}, + handle_user = #{handleUser}, + handle_nick = #{handleNick}, + handle_remark = #{handleRemark}, handle_date = #{handleDate}, - audit_account = #{auditAccount}, + audit_user = #{auditUser}, + audit_nick = #{auditNick}, audit_date = #{auditDate}, - task_score = #{taskScore}, - task_appraise = #{taskAppraise}, + appraise_user = #{appraiseUser}, + appraise_nick = #{appraiseNick}, + appraise_score = #{appraiseScore}, + appraise_remark = #{appraiseRemark}, create_by = #{createBy}, create_time = #{createTime}, update_by = #{updateBy}, @@ -259,23 +315,31 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" town_name = #{item.townName}, org_code = #{item.orgCode}, org_name = #{item.orgName}, - book_count = #{item.bookCount}, + book_id = #{item.bookId}, + book_name = #{item.bookName}, + order_year = #{item.orderYear}, + order_month = #{item.orderMonth}, voucher_count = #{item.voucherCount}, - contraction_count = #{item.contractionCount}, + contrac_count = #{item.contracCount}, asset_count = #{item.assetCount}, all_count = #{item.allCount}, - order_year = #{item.orderYear}, - order_month = #{item.orderMonth}, + finish_count = #{item.finishCount}, agent_status = #{item.agentStatus}, - distribution_chief = #{item.distributionChief}, - distribution_date = #{item.distributionDate}, + distri_user = #{item.distriUser}, + distri_nick = #{item.distriNick}, + distri_date = #{item.distriDate}, end_at = #{item.endAt}, - handle_account = #{item.handleAccount}, + handle_user = #{item.handleUser}, + handle_nick = #{item.handleNick}, + handle_remark = #{item.handleRemark}, handle_date = #{item.handleDate}, - audit_account = #{item.auditAccount}, + audit_user = #{item.auditUser}, + audit_nick = #{item.auditNick}, audit_date = #{item.auditDate}, - task_score = #{item.taskScore}, - task_appraise = #{item.taskAppraise}, + appraise_user = #{item.appraiseUser}, + appraise_nick = #{item.appraiseNick}, + appraise_score = #{item.appraiseScore}, + appraise_remark = #{item.appraiseRemark}, create_by = #{item.createBy}, create_time = #{item.createTime}, update_by = #{item.updateBy}, @@ -311,23 +375,31 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" and town_name like concat('%', #{townName}, '%') and org_code = #{orgCode} and org_name like concat('%', #{orgName}, '%') - and book_count = #{bookCount} + and book_id = #{bookId} + and book_name like concat('%', #{bookName}, '%') + and order_year = #{orderYear} + and order_month = #{orderMonth} and voucher_count = #{voucherCount} - and contraction_count = #{contractionCount} + and contrac_count = #{contracCount} and asset_count = #{assetCount} and all_count = #{allCount} - and order_year = #{orderYear} - and order_month = #{orderMonth} + and finish_count = #{finishCount} and agent_status = #{agentStatus} - and distribution_chief = #{distributionChief} - and distribution_date = #{distributionDate} + and distri_user = #{distriUser} + and distri_nick = #{distriNick} + and distri_date = #{distriDate} and end_at = #{endAt} - and handle_account = #{handleAccount} + and handle_user = #{handleUser} + and handle_nick = #{handleNick} + and handle_remark = #{handleRemark} and handle_date = #{handleDate} - and audit_account = #{auditAccount} + and audit_user = #{auditUser} + and audit_nick = #{auditNick} and audit_date = #{auditDate} - and task_score = #{taskScore} - and task_appraise = #{taskAppraise} + and appraise_user = #{appraiseUser} + and appraise_nick = #{appraiseNick} + and appraise_score = #{appraiseScore} + and appraise_remark = #{appraiseRemark} limit 1 @@ -343,23 +415,31 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" and town_name like concat('%', #{townName}, '%') and org_code = #{orgCode} and org_name like concat('%', #{orgName}, '%') - and book_count = #{bookCount} + and book_id = #{bookId} + and book_name like concat('%', #{bookName}, '%') + and order_year = #{orderYear} + and order_month = #{orderMonth} and voucher_count = #{voucherCount} - and contraction_count = #{contractionCount} + and contrac_count = #{contracCount} and asset_count = #{assetCount} and all_count = #{allCount} - and order_year = #{orderYear} - and order_month = #{orderMonth} + and finish_count = #{finishCount} and agent_status = #{agentStatus} - and distribution_chief = #{distributionChief} - and distribution_date = #{distributionDate} + and distri_user = #{distriUser} + and distri_nick = #{distriNick} + and distri_date = #{distriDate} and end_at = #{endAt} - and handle_account = #{handleAccount} + and handle_user = #{handleUser} + and handle_nick = #{handleNick} + and handle_remark = #{handleRemark} and handle_date = #{handleDate} - and audit_account = #{auditAccount} + and audit_user = #{auditUser} + and audit_nick = #{auditNick} and audit_date = #{auditDate} - and task_score = #{taskScore} - and task_appraise = #{taskAppraise} + and appraise_user = #{appraiseUser} + and appraise_nick = #{appraiseNick} + and appraise_score = #{appraiseScore} + and appraise_remark = #{appraiseRemark} @@ -375,25 +455,52 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" and town_name like concat('%', #{townName}, '%') and org_code = #{orgCode} and org_name like concat('%', #{orgName}, '%') - and book_count = #{bookCount} + and book_id = #{bookId} + and book_name like concat('%', #{bookName}, '%') + and order_year = #{orderYear} + and order_month = #{orderMonth} and voucher_count = #{voucherCount} - and contraction_count = #{contractionCount} + and contrac_count = #{contracCount} and asset_count = #{assetCount} and all_count = #{allCount} - and order_year = #{orderYear} - and order_month = #{orderMonth} + and finish_count = #{finishCount} and agent_status = #{agentStatus} - and distribution_chief = #{distributionChief} - and distribution_date = #{distributionDate} + and distri_user = #{distriUser} + and distri_nick = #{distriNick} + and distri_date = #{distriDate} and end_at = #{endAt} - and handle_account = #{handleAccount} + and handle_user = #{handleUser} + and handle_nick = #{handleNick} + and handle_remark = #{handleRemark} and handle_date = #{handleDate} - and audit_account = #{auditAccount} + and audit_user = #{auditUser} + and audit_nick = #{auditNick} and audit_date = #{auditDate} - and task_score = #{taskScore} - and task_appraise = #{taskAppraise} + and appraise_user = #{appraiseUser} + and appraise_nick = #{appraiseNick} + and appraise_score = #{appraiseScore} + and appraise_remark = #{appraiseRemark} limit 1 ) + + + + update t_agent_task + + voucher_count = voucher_count + #{voucherCount}, + contrac_count = contrac_count + #{contracCount}, + asset_count = asset_count + #{assetCount}, + finish_count = finish_count + #{finishCount}, + + + all_count = all_count + #{allCount}, + + all_count = voucher_count + contrac_count + asset_count, + + + + where id = #{id} + \ No newline at end of file diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/SysDept.java b/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/SysDept.java index fb18c5c..0d0e06a 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/SysDept.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/SysDept.java @@ -1,18 +1,23 @@ package com.ruoyi.common.core.domain.entity; import java.util.ArrayList; +import java.util.Arrays; import java.util.List; +import java.util.stream.Collectors; import javax.validation.constraints.Email; import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotNull; import javax.validation.constraints.Size; + +import cn.hutool.core.util.StrUtil; +import com.ruoyi.common.utils.StringUtils; import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringStyle; import com.ruoyi.common.core.domain.BaseEntity; /** * 部门表 sys_dept - * + * * @author ruoyi */ public class SysDept extends BaseEntity @@ -51,7 +56,59 @@ public class SysDept extends BaseEntity /** 父部门名称 */ private String parentName; - + + /** 行政区划代码 */ + private String orgCode; + + /** 所属中心 字典 agent_center */ + private String agentCenter; + + /** 客户地址(推送数据的项目接口地址,区县级维护即可) */ + private String remoteUrl; + + /** 账套数 */ + private Integer bookCount; + + public String getRemoteUrl() + { + return remoteUrl; + } + + public void setRemoteUrl(String remoteUrl) + { + this.remoteUrl = remoteUrl; + } + + public Integer getBookCount() + { + return bookCount; + } + + public void setBookCount(Integer bookCount) + { + this.bookCount = bookCount; + } + + public String getAgentCenter() + { + return agentCenter; + } + + public void setAgentCenter(String agentCenter) + { + this.agentCenter = agentCenter; + } + + public String getOrgCode() + { + return orgCode; + } + + public void setOrgCode(String orgCode) + { + this.orgCode = orgCode; + } + /** 子部门 */ private List children = new ArrayList(); @@ -200,4 +257,22 @@ public class SysDept extends BaseEntity .append("updateTime", getUpdateTime()) .toString(); } + + public List makeAncestorsIdList(boolean...removeZero) + { + if(StringUtils.isEmpty(ancestors)) + return new ArrayList<>(); + boolean bRemoveZero = null == removeZero || removeZero.length == 0 || removeZero[0]; + return Arrays.stream(StrUtil.split(ancestors, ",")) + .filter((x) -> !bRemoveZero || !"0".equals(x)) + .map(Long::valueOf) + .collect(Collectors.toList()); + } + + public int orgCodeLength() + { + if(null == orgCode) + return 0; + return orgCode.length(); + } } diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/utils/DeptUtils.java b/ruoyi-common/src/main/java/com/ruoyi/common/utils/DeptUtils.java new file mode 100644 index 0000000..3f8fb34 --- /dev/null +++ b/ruoyi-common/src/main/java/com/ruoyi/common/utils/DeptUtils.java @@ -0,0 +1,148 @@ +package com.ruoyi.common.utils; + +public final class DeptUtils +{ + public static final int LEVEL_INVALID = 0; // 无效 + public static final int LEVEL_PROVINCE = 1; // 省 + public static final int LEVEL_CITY = 2; // 市 + public static final int LEVEL_COUNTY = 3; // 区 + public static final int LEVEL_TOWN = 4; // 镇 + public static final int LEVEL_VILLAGE = 5; // 村 + public static final int LEVEL_GROUP = 6; // 组 + + public static String[] parseOrgCode(String orgCode) + { + String[] res = new String[7]; // 0-6(0无效), 1省, 2市, 3区, 4镇, 5村, 6组 + + res[0] = levelStr(LEVEL_INVALID); + if(StringUtils.isEmpty(orgCode)) + return res; + + int length = orgCode.length(); + if(length >= 2) + { + res[1] = orgCode.substring(0, 2); + res[0] = levelStr(LEVEL_PROVINCE); + } + if(length >= 4) + { + res[2] = orgCode.substring(2, 2); + res[0] = levelStr(LEVEL_CITY); + } + if(length >= 6) + { + res[3] = orgCode.substring(4, 6); + res[0] = levelStr(LEVEL_COUNTY); + } + if(length >= 9) + { + res[4] = orgCode.substring(6, 9); + res[0] = levelStr(LEVEL_TOWN); + } + if(length >= 12) + { + res[5] = orgCode.substring(9, 12); + res[0] = levelStr(LEVEL_VILLAGE); + } + if(length >= 16) + { + res[6] = orgCode.substring(12, 16); + res[0] = levelStr(LEVEL_GROUP); + } + + return res; + } + + public static String[] parseFullOrgCode(String orgCode) + { + String[] res = new String[7]; // 0-6(0无效), 1省, 2市, 3区, 4镇, 5村, 6组 + + res[0] = levelStr(LEVEL_INVALID); + if(StringUtils.isEmpty(orgCode)) + return res; + + int length = orgCode.length(); + if(length >= 2) + { + res[1] = orgCode.substring(0, 2); + res[0] = levelStr(LEVEL_PROVINCE); + } + if(length >= 4) + { + res[2] = orgCode.substring(0, 2); + res[0] = levelStr(LEVEL_CITY); + } + if(length >= 6) + { + res[3] = orgCode.substring(0, 6); + res[0] = levelStr(LEVEL_COUNTY); + } + if(length >= 9) + { + res[4] = orgCode.substring(0, 9); + res[0] = levelStr(LEVEL_TOWN); + } + if(length >= 12) + { + res[5] = orgCode.substring(0, 12); + res[0] = levelStr(LEVEL_VILLAGE); + } + if(length >= 16) + { + res[6] = orgCode.substring(0, 16); + res[0] = levelStr(LEVEL_GROUP); + } + + return res; + } + + public static int parseOrgCodeLevel(String orgCode) + { + return StringUtils.isEmpty(orgCode) ? LEVEL_INVALID : parseOrgCodeLevel(orgCode.length()); + } + + + public static int parseOrgCodeLevel(int length) + { + int res = LEVEL_INVALID; + + if(length >= 16) + { + res = LEVEL_GROUP; + } + else if(length >= 12) + { + res = LEVEL_VILLAGE; + } + else if(length >= 9) + { + res = LEVEL_TOWN; + } + else if(length >= 6) + { + res = LEVEL_COUNTY; + } + else if(length >= 4) + { + res = LEVEL_CITY; + } + else if(length >= 2) + { + res = LEVEL_PROVINCE; + } + + return res; + } + + public static String levelStr(int level) + { + return "" + level; + } + + public static int levelInt(String level) + { + return null == level ? LEVEL_INVALID : Integer.parseInt(level); + } + + private DeptUtils() {} +} diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/utils/sql/SqlUtil.java b/ruoyi-common/src/main/java/com/ruoyi/common/utils/sql/SqlUtil.java index 51e1f92..d748ba2 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/utils/sql/SqlUtil.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/utils/sql/SqlUtil.java @@ -2,6 +2,12 @@ package com.ruoyi.common.utils.sql; import com.ruoyi.common.exception.UtilException; import com.ruoyi.common.utils.StringUtils; +import com.ruoyi.common.utils.spring.SpringUtils; +import org.springframework.transaction.PlatformTransactionManager; +import org.springframework.transaction.TransactionDefinition; +import org.springframework.transaction.TransactionStatus; + +import java.util.function.Supplier; /** * sql操作工具类 @@ -58,4 +64,44 @@ public class SqlUtil } } } + + public static void transaction(Runnable runnable) + { + PlatformTransactionManager manager = SpringUtils.getBean(PlatformTransactionManager.class); + TransactionDefinition definition = SpringUtils.getBean(TransactionDefinition.class); + TransactionStatus transaction = manager.getTransaction(definition); + try + { + runnable.run(); + manager.commit(transaction); + } + catch(Exception e) + { + e.printStackTrace(); + manager.rollback(transaction); + throw new RuntimeException(e); + } + } + + public static T transaction(Supplier runnable, T...ifExceptRet) + { + PlatformTransactionManager manager = SpringUtils.getBean(PlatformTransactionManager.class); + TransactionDefinition definition = SpringUtils.getBean(TransactionDefinition.class); + TransactionStatus transaction = manager.getTransaction(definition); + try + { + T res = runnable.get(); + manager.commit(transaction); + return res; + } + catch(Exception e) + { + e.printStackTrace(); + manager.rollback(transaction); + if(null != ifExceptRet && ifExceptRet.length > 0) + return ifExceptRet[0]; + else + throw new RuntimeException(e); + } + } } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysDeptMapper.java b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysDeptMapper.java index 384a9b6..c7c657d 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysDeptMapper.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysDeptMapper.java @@ -115,4 +115,11 @@ public interface SysDeptMapper * @return 结果 */ public int deleteDeptById(Long deptId); + /** + * 条件单条查询部门 + * + * @param sysDept 部门 + * @return 部门条目 + */ + public SysDept selectSysDept(SysDept sysDept); } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysDeptService.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysDeptService.java index f228208..bbd6e31 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysDeptService.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysDeptService.java @@ -121,4 +121,11 @@ public interface ISysDeptService * @return 结果 */ public int deleteDeptById(Long deptId); + /** + * 条件单条查询部门 + * + * @param sysDept 部门 + * @return 部门条目 + */ + public SysDept selectSysDept(SysDept sysDept); } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDeptServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDeptServiceImpl.java index f7fb088..7d8bd9e 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDeptServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDeptServiceImpl.java @@ -335,4 +335,14 @@ public class SysDeptServiceImpl implements ISysDeptService { return getChildList(list, t).size() > 0; } + /** + * 单条条件查询部门 + * + * @param sysDept 部门 + * @return 部门条目 + */ + @Override + public SysDept selectSysDept(SysDept sysDept) { + return deptMapper.selectSysDept(sysDept); + } } diff --git a/ruoyi-system/src/main/resources/mapper/system/SysDeptMapper.xml b/ruoyi-system/src/main/resources/mapper/system/SysDeptMapper.xml index cf439f6..fbbbc4a 100644 --- a/ruoyi-system/src/main/resources/mapper/system/SysDeptMapper.xml +++ b/ruoyi-system/src/main/resources/mapper/system/SysDeptMapper.xml @@ -5,27 +5,30 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - - - - - - - - - + + + + + + + + + + + + + - - - - - + + + + - + - select d.dept_id, d.parent_id, d.ancestors, d.dept_name, d.order_num, d.leader, d.phone, d.email, d.status, d.del_flag, d.create_by, d.create_time - from sys_dept d - + select d.dept_id, d.parent_id, d.ancestors, d.dept_name, d.agent_center, d.org_code, d.remote_url, d.book_count, d.order_num, d.leader, d.phone, d.email, d.status, d.del_flag, d.create_by, d.create_time, d.update_by, d.update_time + from sys_dept d + + + + and parent_id = #{parentId} + and ancestors = #{ancestors} + and dept_name like concat('%', #{deptName}, '%') + and agent_center = #{agentCenter} + and org_code = #{orgCode} + and remote_url = #{remoteUrl} + and book_count = #{bookCount} + and order_num = #{orderNum} + and leader = #{leader} + and phone = #{phone} + and email = #{email} + and status = #{status} + + limit 1 + \ No newline at end of file