This commit is contained in:
2025-09-02 11:36:10 +08:00
parent 57b0cc2244
commit d4f1795f22
95 changed files with 10034 additions and 6213 deletions
@@ -9,6 +9,8 @@ import cn.hutool.json.JSONObject;
import cn.wizzer.framework.base.model.BaseModel;
import io.v.nutz.web.commons.utils.ShiroUtil;
import java.util.Date;
import lombok.Data;
import org.nutz.dao.entity.annotation.ColDefine;
import org.nutz.dao.entity.annotation.ColType;
import org.nutz.dao.entity.annotation.Column;
@@ -20,6 +22,7 @@ import org.nutz.dao.entity.annotation.Table;
import org.nutz.dao.interceptor.annotation.PrevInsert;
@Table("audit")
@Data
public class Audit extends BaseModel {
@Column
@Name
@@ -108,6 +111,12 @@ public class Audit extends BaseModel {
@ColDefine(type = ColType.MYSQL_JSON)
private JSONObject ext;
@Column
@Comment("父级ID")
@ColDefine(type = ColType.VARCHAR, width = 32)
private String parentId;
public Date nowDate() {
return new Date();
}
+16 -1
View File
@@ -189,7 +189,7 @@ public interface Roles {
/**
* 校工会会计
*/
String XGHKJ = "4f72d9259837486a8092c19897fa9dd6";
String SCHOOL_UNION_ACCOUNTANT = "4f72d9259837486a8092c19897fa9dd6";
/**
* 校工会管理员
@@ -294,4 +294,19 @@ public interface Roles {
* 校工会活动报销管理员
*/
String SchoolUnionActivityReimburseAdmin = "9426526f497542cb8351e0cac8fc9816";
/**
* 宣传与文体工作办公室负责人
*/
String XCYWT = "ff0e310a1d954054824c0ed85f1904b7";
/**
* 校工会分管主席
*/
String XGH02 = "7449096aef204965bf6071b30605997d";
/**
* 工会委员会主席
*/
String WYH01 = "26fa82e6f7dd4641aa1655d9fa5c875a";
}
@@ -12,4 +12,6 @@ public interface SysClubService extends BaseService<Sys_club> {
Pagination pageData(Cnd cnd, PageForm page, Integer year, String name);
Boolean getInviteAgree(Sys_club club);
}
@@ -145,8 +145,7 @@ public class ClubExamineRegisterServiceImpl extends ViServiceImpl implements Clu
@Override
public Object getXghBkMoney(String id) {
jf_club club = dao().fetch(jf_club.class, Cnd.where("club_id", "=", id));
Double total_quota = Double.valueOf(club.getTotal_quota());
return total_quota;
return club.getTotalQuota();
}
@Override
@@ -0,0 +1,136 @@
package io.v.nutz.zhgh.activityBudget.conteoller;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONObject;
import io.v.nutz.base.annontation.ViReturn;
import io.v.nutz.base.model.Audit;
import io.v.nutz.base.query.PageForm;
import io.v.nutz.base.utils.DateUtil;
import io.v.nutz.sys.models.Sys_file;
import io.v.nutz.zhgh.activityBudget.models.ActivityBudget;
import io.v.nutz.zhgh.activityBudget.service.ActivityBudgetApplyStatisticsService;
import io.v.nutz.zhgh.jf.model.jf_club;
import io.v.nutz.zhgh.jf.model.jf_school;
import io.v.nutz.zhgh.jf.model.jf_yjgh;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.nutz.aop.interceptor.ioc.TransAop;
import org.nutz.dao.Chain;
import org.nutz.dao.Cnd;
import org.nutz.dao.sql.Sql;
import org.nutz.ioc.aop.Aop;
import org.nutz.ioc.loader.annotation.Inject;
import org.nutz.ioc.loader.annotation.IocBean;
import org.nutz.lang.util.NutMap;
import org.nutz.mvc.annotation.At;
import org.nutz.mvc.annotation.Ok;
import java.math.BigDecimal;
import java.util.List;
import java.util.Map;
/**
* @author zhf
* @date 2025/5/26 14:25
* @description 预算指定某个人修改
*/
@IocBean
@Ok("json:full")
@At("/platform/activity/budget/allocationEdit")
public class ActivityBudgetAllocationEditController {
@Inject
private ActivityBudgetApplyStatisticsService applyStatisticsService;
@At("")
@Ok("beetl:platform/activityBudget/allocationEdit.html")
@RequiresPermissions("activity.budget.allocationEdit")
public void index() {
}
@At
@ViReturn
@RequiresPermissions("activity.budget.allocationEdit")
public Object pageData(PageForm pageForm, Integer year, String unionId, String clubId, String budgetTypeCode, String activityMatter) {
Sql sql = applyStatisticsService.getsql(year, unionId, clubId, budgetTypeCode, activityMatter);
return applyStatisticsService.listPageMap(pageForm.getPageNumber(), pageForm.getPageSize(), sql);
}
@At
@ViReturn
@RequiresPermissions("activity.budget.allocationEdit")
public Object getApplyMoney(Integer year, String unionId, String clubId, String budgetTypeCode, String activityMatter) {
Sql sql = applyStatisticsService.getsql(year, unionId, clubId, budgetTypeCode, activityMatter);
List<NutMap> list = applyStatisticsService.listMap(sql);
list = list.stream().filter(v -> !v.getBoolean("isSchoolBudget")).toList();
double declareTotalBudgetMoney = list.stream().mapToDouble(map -> map.getDouble("declareTotalBudgetMoney")).sum();
double totalBudgetMoney = list.stream().mapToDouble(map -> map.getDouble("totalBudgetMoney")).sum();
return Map.of("declareTotalBudgetMoney", declareTotalBudgetMoney, "totalBudgetMoney", totalBudgetMoney);
}
@At
@ViReturn
@Aop(TransAop.READ_COMMITTED)
@RequiresPermissions("activity.budget.allocationEdit")
public Object doSubmit(String id, String totalBudgetMoney, Sys_file[] files, Audit audit) {
ActivityBudget budget = applyStatisticsService.dao().fetch(ActivityBudget.class, id);
JSONObject jsonObject = new JSONObject();
jsonObject.set("money", budget.getTotalBudgetMoney());
jsonObject.set("files", files);
audit.setExt(jsonObject);
audit.setParentId(id);
applyStatisticsService.insert(audit);
applyStatisticsService.dao().update(ActivityBudget.class, Chain.make("totalBudgetMoney", totalBudgetMoney), Cnd.where("id", "=", id));
BigDecimal newTotalBudgetMoney = new BigDecimal(totalBudgetMoney);
if (budget.getBudgetTypeCode().equals("ACTIVITY_BUDGET_TYPE_ONE")) {
jf_school school = applyStatisticsService.dao().fetch(jf_school.class, Cnd.where("year", "=", DateUtil.getYear()));
if (ObjectUtil.isNotEmpty(school)) {
if (StrUtil.isNotBlank(budget.getId())) {
school.setTotalQuota(school.getTotalQuota().subtract(budget.getTotalBudgetMoney()));
}
school.setTotalQuota(school.getTotalQuota().add(newTotalBudgetMoney));
applyStatisticsService.updateIgnoreNull(school);
}
} else if (budget.getBudgetTypeCode().equals("ACTIVITY_BUDGET_TYPE_TWO")) {
// 更新分工会活动经费表
jf_yjgh jfYjgh = applyStatisticsService.dao().fetch(jf_yjgh.class, Cnd.where("year", "=", DateUtil.getYear())
.and("unionId", "=", budget.getUnionId()));
if (ObjectUtil.isNotEmpty(jfYjgh)) {
if (StrUtil.isNotBlank(budget.getId())) {
jfYjgh.setTotalQuota(jfYjgh.getTotalQuota().subtract(budget.getTotalBudgetMoney()));
}
jfYjgh.setTotalQuota(jfYjgh.getTotalQuota().add(newTotalBudgetMoney));
applyStatisticsService.updateIgnoreNull(jfYjgh);
}
} else if (budget.getBudgetTypeCode().equals("ACTIVITY_BUDGET_TYPE_THREE")) {
//如果不等于校工会预算才往表里面加预算
if (!budget.getIsSchoolBudget()) {
// 更新社团经费表
jf_club jfClub = applyStatisticsService.dao().fetch(jf_club.class, Cnd.where("year", "=", DateUtil.getYear())
.and("club_id", "=", budget.getClubId()));
if (ObjectUtil.isNotEmpty(jfClub)) {
if (StrUtil.isNotBlank(budget.getId())) {
jfClub.setTotalQuota(jfClub.getTotalQuota().subtract(budget.getTotalBudgetMoney()));
}
jfClub.setTotalQuota(jfClub.getTotalQuota().add(newTotalBudgetMoney));
applyStatisticsService.updateIgnoreNull(jfClub);
}
}
} else if (budget.getBudgetTypeCode().equals("ACTIVITY_BUDGET_TYPE_FOUR")) {
// 更新其他经费表
/* JfOther jfOther = applyStatisticsService.dao().fetch(JfOther.class, Cnd.where("year", "=", DateUtil.getYear()));
if (ObjectUtil.isNotEmpty(jfOther)) {
if (StrUtil.isNotBlank(budget.getId())) {
jfOther.setTotalQuota(jfOther.getTotalQuota().subtract(budget.getTotalBudgetMoney()));
}
jfOther.setTotalQuota(jfOther.getTotalQuota().add(newTotalBudgetMoney));
applyStatisticsService.updateIgnoreNull(jfOther);
}*/
}
return null;
}
}
@@ -0,0 +1,173 @@
package io.v.nutz.zhgh.activityBudget.conteoller;
import cn.hutool.core.util.StrUtil;
import io.v.nutz.base.annontation.ViReturn;
import io.v.nutz.base.result.Result;
import io.v.nutz.base.service.ViService;
import io.v.nutz.base.utils.Vi;
import io.v.nutz.web.commons.utils.ShiroUtil;
import io.v.nutz.zhgh.activityBudget.handler.ActivityBudgetUserApplyToDoHandler;
import io.v.nutz.zhgh.activityBudget.models.ActivityBudget;
import io.v.nutz.zhgh.activityBudget.models.ActivityBudgetDetails;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.nutz.aop.interceptor.ioc.TransAop;
import org.nutz.dao.Cnd;
import org.nutz.dao.Dao;
import org.nutz.dao.Sqls;
import org.nutz.dao.sql.Sql;
import org.nutz.dao.util.cri.Static;
import org.nutz.ioc.aop.Aop;
import org.nutz.ioc.loader.annotation.Inject;
import org.nutz.ioc.loader.annotation.IocBean;
import org.nutz.lang.Lang;
import org.nutz.mvc.annotation.At;
import org.nutz.mvc.annotation.Ok;
import org.nutz.mvc.annotation.Param;
import java.util.List;
/**
* @ClassName ActivityBudgetApplyController
* @Description 预算申报
* @Author zhf
* @Date 2024/12/3 11:05
*/
@IocBean
@Ok("json:full")
@At("/platform/activity/budget/apply")
public class ActivityBudgetApplyController {
@Inject("ActivityBudget")
private ViService<ActivityBudget> baseService;
@At("")
@Ok("beetl:platform/activityBudget/apply.html")
@RequiresPermissions("activity.budget.apply")
public void index() {
}
@At
@Aop(TransAop.READ_COMMITTED)
@RequiresPermissions("activity.budget.apply")
public Result doSubmit(@Param("activityBudget") ActivityBudget activityBudget, Boolean flag) {
Dao dao = baseService.dao();
if (flag) {
activityBudget.setAuditState(1);
}
if (StrUtil.isEmpty(activityBudget.getId())) {
activityBudget.setUserId(ShiroUtil.getUserId());
activityBudget.setLoginName(ShiroUtil.getPlatformLoginname());
activityBudget.setUserName(ShiroUtil.getPlatformUsername());
if (List.of("ACTIVITY_BUDGET_TYPE_TWO").contains(activityBudget.getBudgetTypeCode())) {
int activityMatterCount = dao.count(ActivityBudget.class,
Cnd.where("activityMatter", "=", activityBudget.getActivityMatter()).and("unionId", "=", Vi.getUnionId()));
if (flag && activityMatterCount > 0) {
return Result.error(activityBudget.getActivityMatter() + "已填写申请!");
}
}
}
if (StrUtil.isNotBlank(activityBudget.getId()) && Lang.isNotEmpty(activityBudget.getBudgetDetails())) {
dao.clear(ActivityBudgetDetails.class, Cnd.where("budgetId", "=", activityBudget.getId()));
}
/* if (List.of( "superadmin").contains(ShiroUtil.getPlatformLoginname())) {
if (flag) {
activityBudget.setAuditState(4);
activityBudget.setTotalBudgetMoney(activityBudget.getDeclareTotalBudgetMoney());
ActivityBudget budget = null;
if (StrUtil.isNotBlank(activityBudget.getId())) {
budget = dao.fetch(ActivityBudget.class, activityBudget.getId());
}
if (activityBudget.getBudgetTypeCode().equals("ACTIVITY_BUDGET_TYPE_ONE")) {
jf_school school = dao.fetch(jf_school.class, Cnd.where("year", "=", DateUtil.getYear()));
if (ObjectUtil.isNotEmpty(school)) {
if (StrUtil.isNotBlank(activityBudget.getId())) {
school.setTotalQuota(school.getTotalQuota().subtract(budget.getTotalBudgetMoney()));
}
school.setTotalQuota(school.getTotalQuota().add(activityBudget.getTotalBudgetMoney()));
dao.updateIgnoreNull(school);
}
} else if (activityBudget.getBudgetTypeCode().equals("ACTIVITY_BUDGET_TYPE_TWO")) {
// 更新分工会活动经费表
jf_yjgh jfYjgh = dao.fetch(jf_yjgh.class, Cnd.where("year", "=", DateUtil.getYear())
.and("unionId", "=", activityBudget.getUnionId()));
if (ObjectUtil.isNotEmpty(jfYjgh)) {
if (StrUtil.isNotBlank(activityBudget.getId())) {
jfYjgh.setTotalQuota(jfYjgh.getTotalQuota().subtract(budget.getTotalBudgetMoney()));
}
jfYjgh.setTotalQuota(jfYjgh.getTotalQuota().add(activityBudget.getTotalBudgetMoney()));
dao.updateIgnoreNull(jfYjgh);
}
} else if (activityBudget.getBudgetTypeCode().equals("ACTIVITY_BUDGET_TYPE_THREE")) {
//如果不等于校工会预算才往表里面加预算
if (!activityBudget.getIsSchoolBudget()){
// 更新社团经费表
jf_club jfClub = dao.fetch(jf_club.class, Cnd.where("year", "=", DateUtil.getYear())
.and("club_id", "=", activityBudget.getClubId()));
if (ObjectUtil.isNotEmpty(jfClub)) {
if (StrUtil.isNotBlank(activityBudget.getId())) {
jfClub.setTotalQuota(jfClub.getTotalQuota().subtract(budget.getTotalBudgetMoney()));
}
jfClub.setTotalQuota(jfClub.getTotalQuota().add(activityBudget.getTotalBudgetMoney()));
dao.updateIgnoreNull(jfClub);
}
}
} else if (activityBudget.getBudgetTypeCode().equals("ACTIVITY_BUDGET_TYPE_FOUR")) {
// 更新其他经费表
*//* JfOther jfOther = dao.fetch(JfOther.class, Cnd.where("year", "=", DateUtil.getYear()));
if (ObjectUtil.isNotEmpty(jfOther)) {
if (StrUtil.isNotBlank(activityBudget.getId())) {
jfOther.setTotalQuota(jfOther.getTotalQuota().subtract(budget.getTotalBudgetMoney()));
}
jfOther.setTotalQuota(jfOther.getTotalQuota().add(activityBudget.getTotalBudgetMoney()));
dao.updateIgnoreNull(jfOther);
}*//*
}
}
}*/
dao.insertOrUpdate(activityBudget);
for (ActivityBudgetDetails details : activityBudget.getBudgetDetails()) {
details.setBudgetId(activityBudget.getId());
}
dao.insert(activityBudget.getBudgetDetails());
if (flag) {
//插入后,发起待办流程
ActivityBudgetUserApplyToDoHandler.START_PROCESS.exec(activityBudget,null);
//发任务给校工会审核
ActivityBudgetUserApplyToDoHandler.CREATE_SCHOOL_TASK.exec(activityBudget,null);
//完成申请人的任务(申请拒绝的情况)
ActivityBudgetUserApplyToDoHandler.COMPLETE_APPLY_TASK.exec(activityBudget,null);
}
return Result.success();
}
@At
@ViReturn
public Object getClubsByUser() {
Sql sql = Sqls.create("""
SELECT
id ,
name as clubName
FROM
sys_club
$condition
""");
Cnd cnd = Cnd.NEW();
if (!List.of("9810051","superadmin").contains(ShiroUtil.getPlatformLoginname())){
cnd.and(new Static(" id in (select clubid from sys_club_user where userid = '%s')"
.formatted(ShiroUtil.getPrincipalProperty("id"))));
}
cnd.and("state", "=", 930);
sql.setCondition(cnd);
List list = baseService.listMap(sql);
return list;
}
@At
@ViReturn
public Object getSchoolBudget() {
return baseService.query(Cnd.where("budgetTypeCode", "=", "ACTIVITY_BUDGET_TYPE_ONE").and("auditState", "=", 4));
}
}
@@ -0,0 +1,459 @@
package io.v.nutz.zhgh.activityBudget.conteoller;
import cn.afterturn.easypoi.entity.BaseTypeConstants;
import cn.afterturn.easypoi.excel.ExcelExportUtil;
import cn.afterturn.easypoi.excel.ExcelImportUtil;
import cn.afterturn.easypoi.excel.entity.ExportParams;
import cn.afterturn.easypoi.excel.entity.ImportParams;
import cn.afterturn.easypoi.excel.entity.enmus.ExcelType;
import cn.afterturn.easypoi.excel.entity.params.ExcelExportEntity;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import cn.wizzer.framework.base.Result;
import io.v.nutz.base.annontation.ViReturn;
import io.v.nutz.base.query.PageForm;
import io.v.nutz.base.utils.Roles;
import io.v.nutz.base.utils.Vi;
import io.v.nutz.base.utils.ViTool;
import io.v.nutz.sys.models.Sys_club;
import io.v.nutz.sys.models.Sys_dict;
import io.v.nutz.sys.services.SysClubService;
import io.v.nutz.sys.services.SysDictService;
import io.v.nutz.web.commons.utils.ShiroUtil;
import io.v.nutz.zhgh.activityBudget.models.ActivityBudget;
import io.v.nutz.zhgh.activityBudget.models.ActivityBudgetDetails;
import io.v.nutz.zhgh.activityBudget.service.ActivityBudgetApplyStatisticsService;
import io.v.nutz.zhgh.activityBudget.service.ActivityBudgetService;
import io.v.nutz.zhgh.activityBudget.template.ActivityBudgetTemp;
import org.apache.commons.io.IOUtils;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.nutz.aop.interceptor.ioc.TransAop;
import org.nutz.dao.Cnd;
import org.nutz.dao.Sqls;
import org.nutz.dao.sql.Sql;
import org.nutz.dao.util.cri.SqlExpressionGroup;
import org.nutz.ioc.aop.Aop;
import org.nutz.ioc.loader.annotation.Inject;
import org.nutz.ioc.loader.annotation.IocBean;
import org.nutz.lang.Lang;
import org.nutz.lang.util.NutMap;
import org.nutz.mvc.annotation.AdaptBy;
import org.nutz.mvc.annotation.At;
import org.nutz.mvc.annotation.Ok;
import org.nutz.mvc.annotation.Param;
import org.nutz.mvc.upload.TempFile;
import org.nutz.mvc.upload.UploadAdaptor;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import java.io.InputStream;
import java.math.BigDecimal;
import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* @ClassName ActivityBudgetApplyListController
* @Description TODO
* @Author zhf
* @Date 2024/12/3 11:06
*/
@IocBean
@Ok("json:full")
@At("/platform/activity/budget/applyList")
public class ActivityBudgetApplyListController {
@Inject
private ActivityBudgetService activityBudgetService;
@Inject
private ActivityBudgetApplyStatisticsService activityBudgetApplyStatisticsService;
@Inject
private SysDictService sysDictService;
@Inject
private SysClubService sysClubService;
@At("")
@Ok("beetl:platform/activityBudget/applyList.html")
@RequiresPermissions("activity.budget.applyList")
public void index() {
}
@At
@ViReturn
@RequiresPermissions("activity.budget.applyList")
public Object pageData(PageForm pageForm, Integer year, String activityMatter) {
Sql sql = Sqls.create("""
SELECT
YEAR(ab.applyDate) year,
ab.*
FROM
activity_budget ab
$condition
""");
Cnd cnd = Cnd.NEW();
// cnd.andEX("userId", "=", ShiroUtil.getUserId());
if (StrUtil.isNotBlank(activityMatter)) {
cnd.andEX("ab.activityMatter", "like", "%" + activityMatter + "%");
}
SqlExpressionGroup group = new SqlExpressionGroup();
if (ShiroUtil.hasAnyRoles("gh14,gh01")) {
SqlExpressionGroup group1 = new SqlExpressionGroup();
group1.or("ab.budgetTypeCode", "=", "ACTIVITY_BUDGET_TYPE_TWO");
group1.and("ab.unionId", "=", Vi.getUnionId());
group.or(group1);
}
if (ShiroUtil.hasAnyRoles("club01,club05")) {
SqlExpressionGroup group1 = new SqlExpressionGroup();
SqlExpressionGroup group2 = new SqlExpressionGroup();
group2.or("ab.budgetTypeCode", "=", "ACTIVITY_BUDGET_TYPE_THREE");
group2.or("ab.budgetTypeCode", "=", "ACTIVITY_BUDGET_TYPE_FOUR");
List<String> clubIds = this.getClubsByRole().stream().map(v -> v.getString("id")).toList();
group1.and("ab.clubId", "in", clubIds);
group1.and(group2);
group.or(group1);
}
if (ShiroUtil.hasAnyRoles("sysadmin,A06,xghjf" )) {
SqlExpressionGroup group1 = new SqlExpressionGroup();
group1.and("ab.budgetTypeCode", "=", "ACTIVITY_BUDGET_TYPE_ONE");
group1.or("ab.loginName", "=", ShiroUtil.getPlatformLoginname());
group.or(group1);
}
cnd.and(group);
cnd.andEX("YEAR(ab.applyDate)", "=", year);
cnd.asc("auditState").desc("applyDate");
sql.setCondition(cnd);
return activityBudgetService.listPageMap(pageForm.getPageNumber(), pageForm.getPageSize(), sql);
}
@At
@ViReturn
@Aop(TransAop.READ_COMMITTED)
@RequiresPermissions("activity.budget.applyList")
public Object doDelete(String id) {
activityBudgetService.dao().delete(ActivityBudget.class, id);
activityBudgetService.dao().clear(ActivityBudgetDetails.class, Cnd.where("budgetId", "=", id));
return null;
}
@At
@ViReturn
@RequiresPermissions("activity.budget.applyList")
public Object findOne(String id) {
return activityBudgetService.findOne(id);
}
@At
@RequiresPermissions("activity.budget.applyList")
public Object batchSubmit(@Valid @Param("ids[]") String[] ids) {
List<ActivityBudget> budgetList = activityBudgetService.query(Cnd.where("id", "in", ids));
List<ActivityBudget> budgets = budgetList.stream().filter(a ->
ObjectUtil.isEmpty(a.getDeclareTotalBudgetMoney())
|| ObjectUtil.isEmpty(a.getHelpUnitName())
|| ObjectUtil.isEmpty(a.getBudgetTypeCode())).toList();
List<String> names = budgets.stream().map(ActivityBudget::getActivityMatter).toList();
if (ObjectUtil.isNotEmpty(names)) {
return Result.error("请完善活动预算信息【:" + StrUtil.join(",", names) + "");
}
budgetList.forEach(b -> {
b.setTotalBudgetMoney(b.getDeclareTotalBudgetMoney());
b.setAuditState(1);
});
activityBudgetService.update(budgetList);
return Result.success();
}
@At
@RequiresPermissions("activity.budget.applyList")
public Object batchDelete(@Valid @Param("ids[]") String[] ids) {
if (ObjectUtil.isNotEmpty(ids)) {
activityBudgetService.clear(Cnd.where("id", "in", ids));
activityBudgetService.dao().clear(ActivityBudgetDetails.class, Cnd.where("budgetId", "in", ids));
}
return Result.success();
}
@At
@Ok("void")
public void downloadImport(HttpServletResponse response) {
try {
response.setHeader("Content-Disposition", "attachment;filename="
.concat(String.valueOf(URLEncoder.encode("预算申报模版.xlsx", "UTF-8"))));
InputStream fin = Thread.currentThread().getContextClassLoader().getResourceAsStream("templates/budget/budgetImport.xlsx");
IOUtils.copy(fin, response.getOutputStream());
} catch (Exception e) {
e.printStackTrace();
}
}
@At
@Ok("void")
@RequiresPermissions("activity.budget.applyList")
public void doExport(@Valid Integer year, String activityMatter, HttpServletResponse response) {
Sql sql = Sqls.create("""
SELECT
YEAR(ab.applyDate) year,
ab.*
FROM
activity_budget ab
$condition
""");
Cnd cnd = Cnd.NEW();
if (StrUtil.isNotBlank(activityMatter)) {
cnd.andEX("ab.activityMatter", "like", "%" + activityMatter + "%");
}
SqlExpressionGroup group = new SqlExpressionGroup();
if (ShiroUtil.hasAnyRoles("gh14,gh01")) {
SqlExpressionGroup group1 = new SqlExpressionGroup();
group1.or("ab.budgetTypeCode", "=", "ACTIVITY_BUDGET_TYPE_TWO");
group1.and("ab.unionId", "=", Vi.getUnionId());
group.or(group1);
}
if (ShiroUtil.hasAnyRoles("club01,club05")) {
SqlExpressionGroup group1 = new SqlExpressionGroup();
SqlExpressionGroup group2 = new SqlExpressionGroup();
group2.or("ab.budgetTypeCode", "=", "ACTIVITY_BUDGET_TYPE_THREE");
group2.or("ab.budgetTypeCode", "=", "ACTIVITY_BUDGET_TYPE_FOUR");
List<String> clubIds = this.getClubsByRole().stream().map(v -> v.getString("id")).toList();
group1.and("ab.clubId", "in", clubIds);
group1.and(group2);
group.or(group1);
}
if (ShiroUtil.hasAnyRoles("sysadmin,A06,xghjf")) {
SqlExpressionGroup group1 = new SqlExpressionGroup();
group1.and("ab.budgetTypeCode", "=", "ACTIVITY_BUDGET_TYPE_ONE");
group1.or("ab.loginName", "=", ShiroUtil.getPlatformLoginname());
group.or(group1);
}
cnd.and(group);
cnd.andEX("YEAR(ab.applyDate)", "=", year);
cnd.asc("auditState").desc("applyDate");
sql.setCondition(cnd);
List<NutMap> mapList = activityBudgetService.listMap(sql);
List<Sys_dict> dictList = sysDictService.getSubListByCode("ACTIVITY_BUDGET_TYPE");
mapList.forEach(map -> {
Sys_dict dict = dictList.stream().filter(d -> d.getCode().equals(map.getString("budgetTypeCode"))).findFirst().orElse(null);
map.put("budgetTypeCode", dict.getName());
});
ArrayList<ExcelExportEntity> entities = new ArrayList<>();
entities.add(new ExcelExportEntity("年度", "year", 20));
entities.add(new ExcelExportEntity("申报人姓名", "userName", 20));
entities.add(new ExcelExportEntity("申报人工号", "loginName", 20));
entities.add(new ExcelExportEntity("联系方式", "mobile", 20));
entities.add(new ExcelExportEntity("申报类型", "budgetTypeCode", 20));
entities.add(new ExcelExportEntity("申报单位", "helpUnitName", 20));
entities.add(new ExcelExportEntity("事项", "activityMatter", 20));
ExcelExportEntity draftCodeEntity = new ExcelExportEntity("申报预算金额", "declareTotalBudgetMoney", 20);
draftCodeEntity.setType(BaseTypeConstants.DOUBLE_TYPE);
entities.add(draftCodeEntity);
ExcelExportEntity draftCodeEntity2 = new ExcelExportEntity("审核预算金额", "totalBudgetMoney", 20);
draftCodeEntity2.setType(BaseTypeConstants.DOUBLE_TYPE);
entities.add(draftCodeEntity2);
entities.add(new ExcelExportEntity("申报时间", "applyDate", 20));
try {
ViTool.excelResponse(response, "预算申报汇总表.xlsx");
ExportParams exportParams = new ExportParams();
exportParams.setType(ExcelType.XSSF);
Workbook workbook = ExcelExportUtil.exportExcel(exportParams, entities, mapList);
workbook.write(response.getOutputStream());
} catch (Exception e) {
e.printStackTrace();
}
}
@At
@Aop(TransAop.READ_COMMITTED)
@AdaptBy(type = UploadAdaptor.class, args = {"ioc:fileUpload"})
public Object doImport(TempFile file) {
try {
List<ActivityBudgetTemp> activityBudgetTempList = ExcelImportUtil.importExcel(file.getFile(), ActivityBudgetTemp.class, new ImportParams());
List<ActivityBudgetTemp> activityBudgetTempList2 = activityBudgetTempList.stream().filter(temp ->
StrUtil.isAllNotEmpty(temp.getDeclareTotalBudgetMoney(), temp.getBudgetTypeCode())).toList();
List<ActivityBudget> budgetList = activityBudgetService.query(Cnd.where("YEAR(applyDate)", "=", DateUtil.thisYear())
.andEX("userId", "=", ShiroUtil.getUserId()));
List<Sys_dict> budgetTypeList = sysDictService.getSubListByCode("ACTIVITY_BUDGET_TYPE");
List<Sys_club> clubList = sysDictService.dao().query(Sys_club.class, Cnd.NEW());
List<ActivityBudgetTemp> errorInfos = new ArrayList<>();
List<ActivityBudget> successList = new ArrayList<>();
for (ActivityBudgetTemp temp : activityBudgetTempList2) {
if (StrUtil.isAllNotEmpty(temp.getDeclareTotalBudgetMoney(), temp.getBudgetTypeCode())) {
if (ObjectUtil.isEmpty(temp.getActivityMatter())) {
temp.setErrorInfo("活动项目不能为空!");
errorInfos.add(temp);
continue;
}
if (ObjectUtil.isEmpty(temp.getBudgetTypeCode())) {
temp.setErrorInfo("预算类型不能为空!");
errorInfos.add(temp);
continue;
}
if (List.of("协会活动").contains(temp.getBudgetTypeCode()) && ObjectUtil.isEmpty(temp.getHelpUnitName())) {
temp.setErrorInfo("协会活动申报单位不能为空!");
errorInfos.add(temp);
continue;
}
if (List.of("协会活动").contains(temp.getBudgetTypeCode())) {
Sys_club sysClub = clubList.stream().filter(sys_club -> List.of("南京大学" + temp.getHelpUnitName(), temp.getHelpUnitName()).contains(sys_club.getName())).findFirst().orElse(null);
if (ObjectUtil.isEmpty(sysClub)) {
temp.setErrorInfo("当前申报单位在系统中不存在,请核对!");
errorInfos.add(temp);
continue;
}
// 判断当前用户是否有申请社团活动预算的权限
//自己管理的协会
List<NutMap> clubsByRoleList = this.getClubsByRole();
NutMap clubRole = clubsByRoleList.stream().filter(c -> c.getString("id").equals(sysClub.getId())).findFirst().orElse(null);
if (ObjectUtil.isEmpty(clubRole)) {
temp.setErrorInfo("您没有申请社团活动预算的权限,请联系社团负责人!");
errorInfos.add(temp);
continue;
}
}
Sys_dict dict = budgetTypeList.stream().filter(sys_dict -> sys_dict.getName().equals(temp.getBudgetTypeCode())).findFirst().orElse(null);
if (ObjectUtil.isEmpty(dict)) {
temp.setErrorInfo("预算类型错误,请在下拉框选择!");
errorInfos.add(temp);
continue;
}
ActivityBudget budget = budgetList.stream().filter(activityBudget -> activityBudget.getActivityMatter().equals(temp.getActivityMatter())).findFirst().orElse(null);
if (ObjectUtil.isNotEmpty(budget)) {
temp.setErrorInfo("活动项目在本年度中重复请核对!可以在系统【我的申报】界面,直接编辑提交。");
errorInfos.add(temp);
continue;
}
ActivityBudget activityBudget = new ActivityBudget();
activityBudget.setUserId(ShiroUtil.getUserId());
activityBudget.setUserName(ShiroUtil.getPlatformUsername());
activityBudget.setLoginName(ShiroUtil.getPlatformLoginname());
activityBudget.setActivityDate(temp.getActivityDate());
activityBudget.setActivityMatter(temp.getActivityMatter());
activityBudget.setActivityContent(temp.getActivityContent());
activityBudget.setMobile(temp.getMobile());
activityBudget.setBudgetTypeCode(dict.getCode());
activityBudget.setDeclareTotalBudgetMoney(new BigDecimal(temp.getDeclareTotalBudgetMoney()));
activityBudget.setApplyDate(DateUtil.today());
activityBudget.setAuditState(0);
if (List.of("协会活动").contains(temp.getBudgetTypeCode())) {
Sys_club sysClub = clubList.stream().filter(sys_club -> sys_club.getName().equals(temp.getHelpUnitName())).findFirst().orElse(null);
activityBudget.setHelpUnitName(sysClub.getName());
activityBudget.setClubId(sysClub.getId());
} else if (List.of("校工会活动", "其他项目").contains(temp.getBudgetTypeCode())) {
activityBudget.setHelpUnitName("校工会");
} else {
activityBudget.setUnionId(Vi.getUnionId());
activityBudget.setHelpUnitName(Vi.getUnion().getUnionname());
}
successList.add(activityBudget);
}
}
activityBudgetService.insert(successList);
//如果有错误数据就返回给前端
if (Lang.isNotEmpty(errorInfos)) {
NutMap nutMap = NutMap.NEW();
nutMap.setv("totalCount", activityBudgetTempList2.size());
nutMap.setv("successCount", Math.max(successList.size() - errorInfos.size(), 0));
nutMap.setv("errorCount", errorInfos.size());
nutMap.setv("errorList", errorInfos.stream().map(v -> NutMap.NEW().addv("活动项目", v.getActivityMatter()).addv("错误原因", v.getErrorInfo())).collect(Collectors.toList()));
return io.v.nutz.base.result.Result.success(nutMap);
}
return Result.success().addMsg("导入成功");
} catch (Exception e) {
e.printStackTrace();
return Result.error();
}
}
public List<NutMap> getClubsByRole() {
Cnd cnd = Cnd.NEW();
Sql sql = Sqls.create("""
SELECT
club.id
FROM
sys_club club
LEFT JOIN `sys_user_role` role ON club.id = role.stid
$condition
""");
cnd.and("role.roleId", "in", Lang.array(Roles.club01, Roles.club02, Roles.club03, Roles.club04));
cnd.and("role.userId", "=", ShiroUtil.getUserId());
cnd.and("club.isjs", "=", false);
cnd.and("club.state", "=", 930);
cnd.groupBy("club.id");
cnd.asc("club.`code`");
sql.setCondition(cnd);
return activityBudgetService.listMap(sql);
}
@At
@ViReturn
@RequiresPermissions("activity.budget.applyList")
public Object getApplyMoney(Integer year, String activityMatter) {
Sql sql = Sqls.create("""
SELECT
ab.declareTotalBudgetMoney,
ab.totalBudgetMoney
FROM
activity_budget ab
$condition
""");
Cnd cnd = Cnd.NEW();
if (StrUtil.isNotBlank(activityMatter)) {
cnd.andEX("ab.activityMatter", "like", "%" + activityMatter + "%");
}
SqlExpressionGroup group = new SqlExpressionGroup();
if (ShiroUtil.hasAnyRoles("gh14,gh01")) {
SqlExpressionGroup group1 = new SqlExpressionGroup();
group1.or("ab.budgetTypeCode", "=", "ACTIVITY_BUDGET_TYPE_TWO");
group1.and("ab.unionId", "=", Vi.getUnionId());
group.or(group1);
}
if (ShiroUtil.hasAnyRoles("club01,club05")) {
SqlExpressionGroup group1 = new SqlExpressionGroup();
SqlExpressionGroup group2 = new SqlExpressionGroup();
group2.or("ab.budgetTypeCode", "=", "ACTIVITY_BUDGET_TYPE_THREE");
group2.or("ab.budgetTypeCode", "=", "ACTIVITY_BUDGET_TYPE_FOUR");
List<String> clubIds = this.getClubsByRole().stream().map(v -> v.getString("id")).toList();
group1.and("ab.clubId", "in", clubIds);
group1.and(group2);
group.or(group1);
}
if (ShiroUtil.hasAnyRoles("sysadmin,A06,xghjf")) {
SqlExpressionGroup group1 = new SqlExpressionGroup();
group1.and("ab.budgetTypeCode", "=", "ACTIVITY_BUDGET_TYPE_ONE");
group1.or("ab.loginName", "=", ShiroUtil.getPlatformLoginname());
group.or(group1);
}
cnd.and(group);
cnd.andEX("ab.isSchoolBudget", "=", 0);
cnd.andEX("YEAR(ab.applyDate)", "=", year);
cnd.andEX("ab.auditState", "=", 4);
cnd.asc("auditState").desc("applyDate");
sql.setCondition(cnd);
List<NutMap> list = activityBudgetService.listMap(sql);
double declareTotalBudgetMoney = list.stream().mapToDouble(map -> map.getDouble("declareTotalBudgetMoney")).sum();
double totalBudgetMoney = list.stream().mapToDouble(map -> map.getDouble("totalBudgetMoney")).sum();
return Map.of("declareTotalBudgetMoney", declareTotalBudgetMoney, "totalBudgetMoney", totalBudgetMoney);
}
}
@@ -0,0 +1,162 @@
package io.v.nutz.zhgh.activityBudget.conteoller;
import cn.afterturn.easypoi.entity.BaseTypeConstants;
import cn.afterturn.easypoi.excel.ExcelExportUtil;
import cn.afterturn.easypoi.excel.entity.ExportParams;
import cn.afterturn.easypoi.excel.entity.enmus.ExcelType;
import cn.afterturn.easypoi.excel.entity.params.ExcelExportEntity;
import cn.hutool.core.util.ObjectUtil;
import io.v.nutz.base.annontation.ViReturn;
import io.v.nutz.base.query.PageForm;
import io.v.nutz.base.utils.ViTool;
import io.v.nutz.sys.models.Sys_dict;
import io.v.nutz.sys.services.SysDictService;
import io.v.nutz.zhgh.activityBudget.models.ActivityBudget;
import io.v.nutz.zhgh.activityBudget.models.ActivityBudgetDetails;
import io.v.nutz.zhgh.activityBudget.service.ActivityBudgetApplyStatisticsService;
import io.v.nutz.zhgh.jf.model.jf_club;
import io.v.nutz.zhgh.jf.model.jf_school;
import io.v.nutz.zhgh.jf.model.jf_yjgh;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.nutz.aop.interceptor.ioc.TransAop;
import org.nutz.dao.Cnd;
import org.nutz.dao.sql.Sql;
import org.nutz.ioc.aop.Aop;
import org.nutz.ioc.loader.annotation.Inject;
import org.nutz.ioc.loader.annotation.IocBean;
import org.nutz.lang.util.NutMap;
import org.nutz.mvc.annotation.At;
import org.nutz.mvc.annotation.Ok;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
* @ClassName ActivityBudgetApplyStatisticsController
* @Description TODO
* @Author zhf
* @Date 2025/3/5 下午8:10
*/
@IocBean
@Ok("json:full")
@At("/platform/activity/budget/applyStatistics")
public class ActivityBudgetApplyStatisticsController {
@Inject
private ActivityBudgetApplyStatisticsService activityBudgetService;
@Inject
private SysDictService sysDictService;
@At("")
@Ok("beetl:platform/activityBudget/applyStatistics.html")
@RequiresPermissions("activity.budget.applyStatistics")
public void index() {
}
@At
@ViReturn
@RequiresPermissions("activity.budget.applyStatistics")
public Object pageData(PageForm pageForm, Integer year, String unionId, String clubId, String budgetTypeCode, String activityMatter) {
Sql sql = activityBudgetService.getsql(year, unionId, clubId, budgetTypeCode, activityMatter);
return activityBudgetService.listPageMap(pageForm.getPageNumber(), pageForm.getPageSize(), sql);
}
@At
@Ok("void")
@RequiresPermissions("activity.budget.applyStatistics")
public void doExport(@Valid Integer year, String clubId, String unionId, @Valid String budgetTypeCode, HttpServletResponse response) {
Sql sql = activityBudgetService.getsql(year, unionId, clubId, budgetTypeCode, null);
List<NutMap> mapList = activityBudgetService.listMap(sql);
List<Sys_dict> dictList = sysDictService.getSubListByCode("ACTIVITY_BUDGET_TYPE");
mapList.forEach(map -> {
Sys_dict dict = dictList.stream().filter(d -> d.getCode().equals(map.getString("budgetTypeCode"))).findFirst().orElse(null);
map.put("budgetTypeCode", dict.getName());
});
ArrayList<ExcelExportEntity> entities = new ArrayList<>();
entities.add(new ExcelExportEntity("年度", "year", 20));
entities.add(new ExcelExportEntity("申报人姓名", "userName", 20));
entities.add(new ExcelExportEntity("申报人工号", "loginName", 20));
entities.add(new ExcelExportEntity("联系方式", "mobile", 20));
entities.add(new ExcelExportEntity("申报类型", "budgetTypeCode", 20));
entities.add(new ExcelExportEntity("申报单位", "helpUnitName", 20));
entities.add(new ExcelExportEntity("事项", "activityMatter", 20));
ExcelExportEntity draftCodeEntity = new ExcelExportEntity("申报预算金额", "declareTotalBudgetMoney", 20);
draftCodeEntity.setType(BaseTypeConstants.DOUBLE_TYPE);
entities.add(draftCodeEntity);
ExcelExportEntity draftCodeEntity2 = new ExcelExportEntity("审核预算金额", "totalBudgetMoney", 20);
draftCodeEntity2.setType(BaseTypeConstants.DOUBLE_TYPE);
entities.add(draftCodeEntity2);
entities.add(new ExcelExportEntity("申报时间", "applyDate", 20));
try {
ViTool.excelResponse(response, "预算申报汇总表.xlsx");
ExportParams exportParams = new ExportParams();
exportParams.setType(ExcelType.XSSF);
Workbook workbook = ExcelExportUtil.exportExcel(exportParams, entities, mapList);
workbook.write(response.getOutputStream());
} catch (Exception e) {
e.printStackTrace();
}
}
@At
@ViReturn
@RequiresPermissions("activity.budget.applyStatistics")
public Object getApplyMoney(Integer year, String unionId, String clubId, String budgetTypeCode, String activityMatter) {
Sql sql = activityBudgetService.getsql(year, unionId, clubId, budgetTypeCode, activityMatter);
List<NutMap> list = activityBudgetService.listMap(sql);
list = list.stream().filter(v -> !v.getBoolean("isSchoolBudget")).toList();
double declareTotalBudgetMoney = list.stream().mapToDouble(map -> map.getDouble("declareTotalBudgetMoney")).sum();
double totalBudgetMoney = list.stream().mapToDouble(map -> map.getDouble("totalBudgetMoney")).sum();
return Map.of("declareTotalBudgetMoney", declareTotalBudgetMoney, "totalBudgetMoney", totalBudgetMoney);
}
@At
@ViReturn
@Aop(TransAop.READ_COMMITTED)
@RequiresPermissions("activity.budget.applyStatistics")
public Object doDelete(String id) {
ActivityBudget budget = sysDictService.dao().fetch(ActivityBudget.class, id);
if (budget.getBudgetTypeCode().equals("ACTIVITY_BUDGET_TYPE_ONE")) {
jf_school school = activityBudgetService.dao().fetch(jf_school.class, Cnd.where("year", "=", io.v.nutz.base.utils.DateUtil.getYear()));
if (ObjectUtil.isNotEmpty(school)) {
school.setTotalQuota(school.getTotalQuota().subtract(budget.getTotalBudgetMoney()));
activityBudgetService.updateIgnoreNull(school);
}
} else if (budget.getBudgetTypeCode().equals("ACTIVITY_BUDGET_TYPE_TWO")) {
// 更新分工会活动经费表
jf_yjgh jfYjgh = activityBudgetService.dao().fetch(jf_yjgh.class, Cnd.where("year", "=", io.v.nutz.base.utils.DateUtil.getYear())
.and("unionId", "=", budget.getUnionId()));
if (ObjectUtil.isNotEmpty(jfYjgh)) {
jfYjgh.setTotalQuota(jfYjgh.getTotalQuota().subtract(budget.getTotalBudgetMoney()));
activityBudgetService.updateIgnoreNull(jfYjgh);
}
} else if (budget.getBudgetTypeCode().equals("ACTIVITY_BUDGET_TYPE_THREE")) {
// 更新社团经费表
jf_club jfClub = activityBudgetService.dao().fetch(jf_club.class, Cnd.where("year", "=", io.v.nutz.base.utils.DateUtil.getYear())
.and("club_id", "=", budget.getClubId()));
if (ObjectUtil.isNotEmpty(jfClub)) {
jfClub.setTotalQuota(jfClub.getTotalQuota().subtract(budget.getTotalBudgetMoney()));
activityBudgetService.updateIgnoreNull(jfClub);
}
} else if (budget.getBudgetTypeCode().equals("ACTIVITY_BUDGET_TYPE_FOUR")) {
// 更新其他经费表
/* JfOther jfOther = activityBudgetService.dao().fetch(JfOther.class, Cnd.where("year", "=", io.v.nutz.base.utils.DateUtil.getYear()));
if (ObjectUtil.isNotEmpty(jfOther)) {
jfOther.setTotalQuota(jfOther.getTotalQuota().subtract(budget.getTotalBudgetMoney()));
activityBudgetService.updateIgnoreNull(jfOther);
}*/
}
activityBudgetService.dao().delete(ActivityBudget.class, id);
activityBudgetService.dao().clear(ActivityBudgetDetails.class, Cnd.where("budgetId", "=", id));
return null;
}
}
@@ -0,0 +1,93 @@
package io.v.nutz.zhgh.activityBudget.conteoller;
import cn.afterturn.easypoi.entity.BaseTypeConstants;
import cn.afterturn.easypoi.excel.ExcelExportUtil;
import cn.afterturn.easypoi.excel.entity.ExportParams;
import cn.afterturn.easypoi.excel.entity.enmus.ExcelType;
import cn.afterturn.easypoi.excel.entity.params.ExcelExportEntity;
import cn.hutool.core.util.StrUtil;
import io.v.nutz.base.annontation.ViReturn;
import io.v.nutz.base.utils.ViTool;
import io.v.nutz.zhgh.activityBudget.service.ActivityBudgetQueryStatisticsService;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.nutz.ioc.loader.annotation.Inject;
import org.nutz.ioc.loader.annotation.IocBean;
import org.nutz.lang.util.NutMap;
import org.nutz.mvc.annotation.At;
import org.nutz.mvc.annotation.Ok;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import java.util.ArrayList;
import java.util.List;
/**
* @ClassName ActivityBudgetQueryStatisticsController
* @Description TODO
* @Author zhf
* @Date 2024/12/16 14:17
*/
@IocBean
@Ok("json:full")
@At("/platform/activity/budget/queryStatistics")
public class ActivityBudgetQueryStatisticsController {
@Inject
private ActivityBudgetQueryStatisticsService statisticsService;
@At("")
@Ok("beetl:platform/activityBudget/queryStatistics.html")
@RequiresPermissions("activity.budget.queryStatistics")
public void index() {
}
@At
@ViReturn
@RequiresPermissions("activity.budget.queryStatistics")
public Object pageData(@Valid Integer year, String clubId, String unionId, @Valid String budgetTypeCode) {
return statisticsService.getDataByBudgetTypeCode(year, clubId, unionId, budgetTypeCode);
}
@At
@Ok("void")
@RequiresPermissions("activity.budget.queryStatistics")
public void doExport(@Valid Integer year, String clubId, String unionId, @Valid String budgetTypeCode, HttpServletResponse response) {
List<NutMap> mapList = statisticsService.getDataByBudgetTypeCode(year, clubId, unionId, budgetTypeCode);
if (budgetTypeCode.equals("ACTIVITY_BUDGET_TYPE_TWO")){
mapList.forEach(m->{
if (StrUtil.isEmpty(m.getString("unionName"))){
m.put("unionName",m.getString("unitName"));
m.put("unionCode",m.getString("unionId"));
}
});
}
ArrayList<ExcelExportEntity> entities = new ArrayList<>();
entities.add(new ExcelExportEntity("年度", "year", 20));
if (List.of("ACTIVITY_BUDGET_TYPE_ONE", "ACTIVITY_BUDGET_TYPE_FOUR").contains(budgetTypeCode)) {
entities.add(new ExcelExportEntity("事项", "activityMatter", 50));
}else if (budgetTypeCode.equals("ACTIVITY_BUDGET_TYPE_TWO")) {
entities.add(new ExcelExportEntity("编码", "unionCode", 20));
entities.add(new ExcelExportEntity("分工会", "unionName", 20));
}else if (budgetTypeCode.equals("ACTIVITY_BUDGET_TYPE_THREE")) {
entities.add(new ExcelExportEntity("编码", "clubCode", 20));
entities.add(new ExcelExportEntity("协会名称", "clubName", 20));
}
ExcelExportEntity draftCodeEntity = new ExcelExportEntity("预算金额", "totalBudgetMoney", 20);
draftCodeEntity.setType(BaseTypeConstants.DOUBLE_TYPE);
entities.add(draftCodeEntity);
try {
ViTool.excelResponse(response, "预算申报汇总表.xlsx");
ExportParams exportParams = new ExportParams();
exportParams.setType(ExcelType.XSSF);
Workbook workbook = ExcelExportUtil.exportExcel(exportParams, entities, mapList);
workbook.write(response.getOutputStream());
} catch (Exception e) {
e.printStackTrace();
}
}
}
@@ -0,0 +1,135 @@
package io.v.nutz.zhgh.activityBudget.conteoller;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import io.v.nutz.base.annontation.ViReturn;
import io.v.nutz.base.model.Audit;
import io.v.nutz.base.query.PageForm;
import io.v.nutz.sys.services.SysLocalProcessService;
import io.v.nutz.web.commons.utils.ShiroUtil;
import io.v.nutz.zhgh.activityBudget.handler.ActivityBudgetUserApplyToDoHandler;
import io.v.nutz.zhgh.activityBudget.models.ActivityBudget;
import io.v.nutz.zhgh.activityBudget.service.ActivityBudgetService;
import io.v.nutz.zhgh.zgfw.handler.condolence.CondolenceToDoHandler;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.nutz.aop.interceptor.ioc.TransAop;
import org.nutz.dao.Chain;
import org.nutz.dao.Cnd;
import org.nutz.dao.Sqls;
import org.nutz.dao.sql.Sql;
import org.nutz.dao.util.cri.SqlExpressionGroup;
import org.nutz.ioc.aop.Aop;
import org.nutz.ioc.loader.annotation.Inject;
import org.nutz.ioc.loader.annotation.IocBean;
import org.nutz.json.Json;
import org.nutz.lang.Lang;
import org.nutz.lang.Strings;
import org.nutz.mvc.annotation.At;
import org.nutz.mvc.annotation.Ok;
import javax.validation.Valid;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
/**
* @ClassName ActivityBudgetSchoolAuditController
* @Description TODO
* @Author zhf
* @Date 2024/12/16 10:47
*/
@IocBean
@Ok("json:full")
@At("/platform/activity/budget/schoolAudit")
public class ActivityBudgetSchoolAuditController {
@Inject
private ActivityBudgetService activityBudgetService;
@Inject
private SysLocalProcessService localProcessService;
@At("")
@Ok("beetl:platform/activityBudget/schoolAudit.html")
@RequiresPermissions("activity.budget.schoolAudit")
public void index() {
}
@At
@ViReturn
@RequiresPermissions("activity.budget.schoolAudit")
public Object pageData(PageForm pageForm, Integer year, String unionId, String clubId, Integer auditState, String budgetTypeCode, String activityMatter) {
Sql sql = Sqls.create("""
SELECT
YEAR(ab.applyDate) year,
ab.*
FROM
activity_budget ab
$condition
""");
Cnd cnd = Cnd.NEW();
if (StrUtil.isNotBlank(activityMatter)) {
cnd.andEX("ab.activityMatter", "like", "%" + activityMatter + "%");
}
if (Strings.isNotBlank(pageForm.getSearchKeyword())) {
SqlExpressionGroup seg = new SqlExpressionGroup();
seg.orLike("ab.userName", pageForm.getSearchKeyword());
seg.orLike("ab.loginName", pageForm.getSearchKeyword());
cnd.and(seg);
}
cnd.andEX("YEAR(ab.applyDate)", "=", year);
cnd.andEX("ab.auditState", ">=", 1);
cnd.andEX("ab.unionId", "=", unionId);
cnd.andEX("ab.clubId", "=", clubId);
cnd.andEX("ab.budgetTypeCode", "=", budgetTypeCode);
if (auditState != 0) {
cnd.and("ab.auditState", auditState == 1 ? ">" : "=", 1);
}
cnd.desc("ab.applyDate");
sql.setCondition(cnd);
return activityBudgetService.listPageMap(pageForm.getPageNumber(), pageForm.getPageSize(), sql);
}
@At
@ViReturn
@Aop(TransAop.READ_COMMITTED)
@RequiresPermissions("activity.budget.schoolAudit")
public Object doSubmit(String id, Integer auditState, String totalBudgetMoney, Audit audit) {
audit.setUsername(ShiroUtil.getPlatformUsername());
audit.setLoginname(ShiroUtil.getPlatformLoginname());
audit.setAuditor(ShiroUtil.getUserId());
audit.setAuditTime(new Date());
activityBudgetService.insert(audit);
activityBudgetService.update(Chain.make("auditState", auditState)
.add("schoolAuditId", audit.getId()).add("totalBudgetMoney", totalBudgetMoney), Cnd.where("id", "=", id));
ActivityBudget activityBudget = activityBudgetService.fetch(id);
ActivityBudgetUserApplyToDoHandler.COMPLETE_SCHOOL_TASK.exec(activityBudget, audit.getAuditOpinion());
if (auditState == 4) {
ActivityBudgetUserApplyToDoHandler.COMPLETE_PROCESS.exec(activityBudget, audit.getAuditOpinion());
} else if (auditState == 3) {
ActivityBudgetUserApplyToDoHandler.CREATE_BACK_SCHOOL_TASK.exec(activityBudget, audit.getAuditOpinion());
}
return null;
}
@At
@ViReturn
@Aop(TransAop.READ_COMMITTED)
@RequiresPermissions("activity.budget.schoolAudit")
public Object doRevoke(@Valid String id) {
ActivityBudget budget = activityBudgetService.fetch(id);
budget.setAuditState(1);
budget.setTotalBudgetMoney(null);
activityBudgetService.update(budget);
localProcessService.revokeTask("activity_budget@" + id, "校工会审核");
return null;
}
}
@@ -0,0 +1,173 @@
package io.v.nutz.zhgh.activityBudget.handler;
import io.v.nutz.base.utils.Roles;
import io.v.nutz.base.utils.ViResource;
import io.v.nutz.sys.models.Sys_user;
import io.v.nutz.sys.services.SysLocalProcessService;
import io.v.nutz.sys.services.impl.SysLocalProcessServiceImpl;
import io.v.nutz.web.commons.utils.ShiroUtil;
import io.v.nutz.zhgh.activityBudget.models.ActivityBudget;
import io.v.nutz.zhgh.zgfw.model.condolence.Condolence;
import lombok.Getter;
import org.nutz.dao.Dao;
import org.nutz.dao.Sqls;
import org.nutz.dao.sql.Sql;
import org.nutz.lang.Lang;
import java.util.List;
/**
* 活动申请待办处理
*/
/**
* @Author: zhf
* @Date: 2025/8/30 11:06
* @Version: v1.0.0
* @Description: 活动申请待办处理
**/
@Getter
public enum ActivityBudgetUserApplyToDoHandler {
/**
* 流程开始
*/
START_PROCESS() {
@Override
public void exec(ActivityBudget activityBudget, String option) {
Sys_user sysUser = dao.fetch(Sys_user.class, activityBudget.getUserId());
localProcessService.startProcess(
"【年度预算】" + sysUser.getUsername(),
"activity_budget@" + activityBudget.getId(),
"年度预算申报",
sysUser.getId(),
"/platform/activity/budget/applyList",
"/platform/activity/budget/applyList"
);
}
},
/**
* 完成申请人的任务(申请拒绝的情况)
*/
COMPLETE_APPLY_TASK() {
@Override
public void exec(ActivityBudget activityBudget, String option) {
localProcessService.completeTask(
"apply_activity_budget_modify",
"activity_budget@" + activityBudget.getId(),
ShiroUtil.getUserId(),
""
);
}
},
/**
* 创建校工会任务
*/
CREATE_SCHOOL_TASK() {
@Override
public void exec(ActivityBudget activityBudget, String option) {
Sql sql = Sqls.create("""
SELECT
u.loginname
FROM
sys_user_role sur
LEFT JOIN sys_user u ON u.id = sur.userid
WHERE
sur.roleId = @SchoolUnionAdmin
GROUP BY
sur.userId
""").setParam("SchoolUnionAdmin", Roles.XGHGLY);
sql.setCallback(Sqls.callback.strs());
dao.execute(sql);
List<String> loginNames = sql.getList(String.class);
if (Lang.isEmpty(loginNames)) {
throw new RuntimeException("找不到下一步审核人,请联系管理员设置。");
}
localProcessService.createTask(
"activity_budget@" + activityBudget.getId(),
"school_audit",
"校工会审核",
ShiroUtil.getUserId(),
loginNames,
"/platform/activity/budget/schoolAudit",
"/platform/activity/budget/schoolAudit",
"/platform/activity/budget/schoolAudit",
"/platform/activity/budget/schoolAudit"
);
localProcessService.updateProcessNodeName("activity_budget@" + activityBudget.getId(), "校工会审核");
}
},
/**
* 校工会退回,退回给个人节点
*/
CREATE_BACK_SCHOOL_TASK() {
@Override
public void exec(ActivityBudget activityBudget, String option) {
localProcessService.createTask(
"activity_budget@" + activityBudget.getId(),
"school_back",
"校工会退回",
ShiroUtil.getUserId(),
List.of(activityBudget.getLoginName()),
"/platform/activity/budget/applyList",
"/platform/activity/budget/applyList",
"/platform/activity/budget/applyList",
"/platform/activity/budget/applyList"
);
localProcessService.updateProcessNodeName("activity_budget@" + activityBudget.getId(), "校工会退回");
}
},
/**
* 校工会完成
*/
COMPLETE_SCHOOL_TASK() {
@Override
public void exec(ActivityBudget activityBudget, String option) {
localProcessService.completeTask(
"school_audit",
"activity_budget@" + activityBudget.getId(),
ShiroUtil.getUserId(),
option
);
}
},
/**
* 流程结束
*/
COMPLETE_PROCESS() {
@Override
public void exec(ActivityBudget activityBudget, String option) {
localProcessService.completeProcess("activity_budget@" + activityBudget.getId());
}
},
/**
* 删除
*/
DELETE_PROCESS() {
@Override
public void exec(ActivityBudget activityBudget, String option) {
localProcessService.deleteProcessInstance("activity_budget@" + activityBudget.getId());
}
};
public abstract void exec(ActivityBudget activityBudget, String option);
public Dao dao = ViResource.dao;
public SysLocalProcessService localProcessService = ViResource.ioc.get(SysLocalProcessServiceImpl.class);
}
@@ -0,0 +1,138 @@
package io.v.nutz.zhgh.activityBudget.models;
import cn.wizzer.framework.base.model.BaseModel;
import io.v.nutz.base.model.Audit;
import lombok.Data;
import lombok.experimental.Accessors;
import org.nutz.dao.entity.annotation.*;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.List;
/**
* @ClassName ActivityBudget
* @Description TODO
* @Author zhf
* @Date 2024/12/3 10:09
*/
@Table
@Data
@Comment("活动预算")
@Accessors(chain = true)
public class ActivityBudget extends BaseModel implements Serializable {
@Column
@Name
@Comment("ID")
@ColDefine(type = ColType.VARCHAR, width = 32)
@Prev(els = {@EL("uuid()")})
private String id;
@Column
@Comment("用户ID")
@ColDefine(type = ColType.VARCHAR, width = 32)
private String userId;
@Column
@Comment("用户姓名")
@ColDefine(type = ColType.VARCHAR, width = 50)
private String userName;
@Column
@Comment("用户工号")
@ColDefine(type = ColType.VARCHAR, width = 50)
private String loginName;
@Column
@Comment("联系方式")
@ColDefine(type = ColType.VARCHAR, width = 50)
private String mobile;
@Column
@Comment("活动时间")
@ColDefine(type = ColType.VARCHAR, width = 50)
private String activityDate;
@Column
@Comment("活动事项")
@ColDefine(type = ColType.VARCHAR, width = 200)
private String activityMatter;
@Column
@Comment("活动内容")
@ColDefine(type = ColType.TEXT)
private String activityContent;
@Column
@Comment("预算金额")
@ColDefine(customType = "decimal(10,2)")
private BigDecimal totalBudgetMoney;
@Column
@Comment("申报金额")
@ColDefine(customType = "decimal(10,2)")
private BigDecimal declareTotalBudgetMoney;
@Column
@Comment("预算类型")
@ColDefine(type = ColType.VARCHAR, width = 200)
private String budgetTypeCode;
@Column
@Comment("创建人工会")
@ColDefine(type = ColType.VARCHAR, width = 32)
private String unionId;
@Column
@Comment("创建人所属社团")
@ColDefine(type = ColType.VARCHAR, width = 32)
private String clubId;
@Column
@Comment("举办单位")
@ColDefine(type = ColType.VARCHAR, width = 32)
private String helpUnitName;
@Column
@Comment("申报时间")
@ColDefine(type = ColType.VARCHAR, width = 32)
private String applyDate;
@Column
@Comment("校工会审核")
@ColDefine(type = ColType.VARCHAR, width = 32)
private String schoolAuditId;
@Column
@Comment("签字")
@ColDefine(type = ColType.VARCHAR, width = 200)
private String applySign;
@Column
@Comment("审核状态")
@Default("0")
@ColDefine(type = ColType.INT)
private Integer auditState;
@Column
@Comment("是否属于校工会预算")
@Default("0")
@ColDefine(type = ColType.BOOLEAN)
private Boolean isSchoolBudget;
@Column
@Comment("是否属于校工会预算")
@Default("1")
@ColDefine(type = ColType.BOOLEAN)
private Boolean isRepeatReimbursement;
@Column
@Comment("校工会预算")
@ColDefine(type = ColType.VARCHAR,width = 32)
private String schoolBudgetId;
@Many(field = "budgetId")
private List<ActivityBudgetDetails> budgetDetails;
private Audit schoolAudit;
private List<Audit> allocationEditAuditList;
}
@@ -0,0 +1,55 @@
package io.v.nutz.zhgh.activityBudget.models;
import cn.wizzer.framework.base.model.BaseModel;
import lombok.Data;
import lombok.experimental.Accessors;
import org.nutz.dao.entity.annotation.*;
import java.io.Serializable;
import java.math.BigDecimal;
/**
* @ClassName ActivityBudgetDetails
* @Description TODO
* @Author zhf
* @Date 2024/12/3 10:15
*/
@Table
@Data
@Comment("活动预算记录详情")
@Accessors(chain = true)
public class ActivityBudgetDetails extends BaseModel implements Serializable {
@Column
@Name
@Comment("ID")
@ColDefine(type = ColType.VARCHAR, width = 32)
@Prev(els = {@EL("uuid()")})
private String id;
@Column
@Comment("申报id")
@ColDefine(type = ColType.VARCHAR, width = 32)
private String budgetId;
@Column
@Comment("类别")
@ColDefine(type = ColType.VARCHAR, width = 50)
private String detailName;
@Column
@Comment("预算金额")
@ColDefine(customType = "decimal(10,2)")
private BigDecimal budgetMoney;
@Column
@Comment("金额")
@ColDefine(customType = "decimal(10,2)")
private BigDecimal money;
@Column
@Comment("排序")
@ColDefine(type = ColType.INT)
private Integer detailsOrder;
}
@@ -0,0 +1,53 @@
package io.v.nutz.zhgh.activityBudget.models;
import cn.wizzer.framework.base.model.BaseModel;
import lombok.Data;
import lombok.experimental.Accessors;
import org.nutz.dao.entity.annotation.*;
import java.io.Serializable;
/**
* @ClassName ActivityBudgetType
* @Description TODO
* @Author zhf
* @Date 2024/12/3 14:55
*/
@Table
@Data
@Comment("活动预算类型")
@Accessors(chain = true)
public class ActivityBudgetType extends BaseModel implements Serializable {
@Column
@Name
@Comment("ID")
@ColDefine(type = ColType.VARCHAR, width = 32)
@Prev(els = {@EL("uuid()")})
private String id;
@Column
@Comment("类型")
@ColDefine(type = ColType.VARCHAR, width = 32)
private String budgetTypeName;
@Column
@Comment("金额")
@ColDefine(type = ColType.FLOAT, width = 10, precision = 2)
private Double budgetTypeMoney;
@Column
@Comment("备注")
@ColDefine(type = ColType.VARCHAR, width = 500)
private String note;
@Column
@Comment("年度")
@ColDefine(type = ColType.INT)
private Integer year;
@Column
@Comment("排序")
@ColDefine(type = ColType.INT)
private Integer location;
}
@@ -0,0 +1,9 @@
package io.v.nutz.zhgh.activityBudget.service;
import io.v.nutz.base.service.BaseService;
import org.nutz.dao.sql.Sql;
public interface ActivityBudgetApplyStatisticsService extends BaseService {
Sql getsql(Integer year, String unionId,String clubId, String budgetTypeCode,String activityMatter);
}
@@ -0,0 +1,11 @@
package io.v.nutz.zhgh.activityBudget.service;
import io.v.nutz.base.service.BaseService;
import org.nutz.lang.util.NutMap;
import java.util.List;
public interface ActivityBudgetQueryStatisticsService extends BaseService {
List<NutMap> getDataByBudgetTypeCode(Integer year, String clubId, String unionId, String budgetTypeCode);
}
@@ -0,0 +1,10 @@
package io.v.nutz.zhgh.activityBudget.service;
import io.v.nutz.base.service.ViService;
import io.v.nutz.zhgh.activityBudget.models.ActivityBudget;
public interface ActivityBudgetService extends ViService<ActivityBudget> {
ActivityBudget findOne(String id);
}
@@ -0,0 +1,51 @@
package io.v.nutz.zhgh.activityBudget.service.impl;
import cn.hutool.core.util.StrUtil;
import io.v.nutz.base.service.impl.BaseServiceImpl;
import io.v.nutz.zhgh.activityBudget.service.ActivityBudgetApplyStatisticsService;
import org.nutz.dao.Cnd;
import org.nutz.dao.Dao;
import org.nutz.dao.Sqls;
import org.nutz.dao.sql.Sql;
import org.nutz.ioc.loader.annotation.IocBean;
/**
* @ClassName ActivityBudgetApplyStatisticsServiceImpl
* @Description TODO
* @Author zhf
* @Date 2025/3/5 下午8:21
*/
@IocBean(args = {"refer:dao"})
public class ActivityBudgetApplyStatisticsServiceImpl extends BaseServiceImpl implements ActivityBudgetApplyStatisticsService {
public ActivityBudgetApplyStatisticsServiceImpl(Dao dao) {
super(dao);
}
@Override
public Sql getsql(Integer year, String unionId, String clubId, String budgetTypeCode, String activityMatter) {
Sql sql = Sqls.create("""
SELECT
YEAR(ab.applyDate) year,
ab.*
FROM
activity_budget ab
$condition
""");
Cnd cnd = Cnd.NEW();
if (StrUtil.isNotBlank(activityMatter)) {
cnd.andEX("ab.activityMatter", "like", "%" + activityMatter + "%");
}
cnd.andEX("YEAR(ab.applyDate)", "=", year);
cnd.andEX("ab.unionId", "=", unionId);
/* if (budgetTypeCode.equals("ACTIVITY_BUDGET_TYPE_TWO")) {
cnd.andEX("ab.isSchoolBudget", "=", 0);
}*/
cnd.andEX("ab.clubId", "=", clubId);
cnd.andEX("ab.budgetTypeCode", "=", budgetTypeCode);
cnd.andEX("ab.auditState", "=", 4);
cnd.desc("ab.applyDate");
sql.setCondition(cnd);
return sql;
}
}
@@ -0,0 +1,88 @@
package io.v.nutz.zhgh.activityBudget.service.impl;
import io.v.nutz.base.service.impl.BaseServiceImpl;
import io.v.nutz.zhgh.activityBudget.service.ActivityBudgetQueryStatisticsService;
import org.nutz.dao.Cnd;
import org.nutz.dao.Dao;
import org.nutz.dao.Sqls;
import org.nutz.dao.sql.Sql;
import org.nutz.ioc.loader.annotation.IocBean;
import org.nutz.lang.util.NutMap;
import java.util.ArrayList;
import java.util.List;
/**
* @ClassName ActivityBudgetQueryStatisticsServiceImpl
* @Description TODO
* @Author zhf
* @Date 2025/3/5 下午7:16
*/
@IocBean(args = {"refer:dao"})
public class ActivityBudgetQueryStatisticsServiceImpl extends BaseServiceImpl implements ActivityBudgetQueryStatisticsService {
public ActivityBudgetQueryStatisticsServiceImpl(Dao dao) {
super(dao);
}
@Override
public List<NutMap> getDataByBudgetTypeCode(Integer year, String clubId, String unionId, String budgetTypeCode) {
if (List.of("ACTIVITY_BUDGET_TYPE_ONE", "ACTIVITY_BUDGET_TYPE_FOUR").contains(budgetTypeCode)) {
Sql sql = Sqls.create("SELECT @year `year`,activityMatter,totalBudgetMoney FROM activity_budget $condition").setParam("year", year);
Cnd cnd = Cnd.NEW();
cnd.andEX("YEAR(applyDate)", "=", year);
cnd.andEX("budgetTypeCode", "=", budgetTypeCode);
cnd.andEX("auditState", "=", 4);
sql.setCondition(cnd);
return listMap(sql);
} else if (budgetTypeCode.equals("ACTIVITY_BUDGET_TYPE_TWO")) {
//分工会
Sql sql = Sqls.create("""
SELECT
@year `year`,
un.unioncode AS unionCode,
un.unionname AS unionName,
it.`name` unitName,
ab.unionId,
COALESCE ( SUM( ab.totalBudgetMoney ), 0 ) AS totalBudgetMoney
FROM
activity_budget ab
LEFT JOIN sys_union un ON ab.unionId = un.id
LEFT JOIN sys_unit it ON it.id = ab.unionId
$condition
""").setParam("year", year);
Cnd cnd = Cnd.NEW();
cnd.andEX("ab.unionId", "=", unionId);
cnd.andEX("ab.isSchoolBudget", "=", 0);
cnd.andEX("ab.budgetTypeCode", "=", "ACTIVITY_BUDGET_TYPE_TWO");
cnd.andEX("ab.auditState", "=", 4);
cnd.andEX("YEAR(ab.applyDate)", "=", year);
cnd.groupBy("ab.unionId");
cnd.asc("un.unioncode");
sql.setCondition(cnd);
return listMap(sql);
} else if (budgetTypeCode.equals("ACTIVITY_BUDGET_TYPE_THREE")) {
Sql sql = Sqls.create("""
SELECT
@year `year`,
sc.`code` AS clubCode,
sc.`name` AS clubName,
COALESCE ( SUM( ab.totalBudgetMoney ), 0 ) AS totalBudgetMoney
FROM
sys_club sc
LEFT JOIN activity_budget ab ON ab.clubId = sc.id
AND ab.budgetTypeCode = 'ACTIVITY_BUDGET_TYPE_THREE'
AND ab.auditState = 4
AND YEAR(ab.applyDate)=@year
$condition
""").setParam("year", year);
Cnd cnd = Cnd.NEW();
cnd.andEX("sc.id", "=", clubId);
cnd.groupBy("sc.id");
cnd.asc("sc.`code`");
sql.setCondition(cnd);
return listMap(sql);
}
return new ArrayList<>();
}
}
@@ -0,0 +1,30 @@
package io.v.nutz.zhgh.activityBudget.service.impl;
import io.v.nutz.base.model.Audit;
import io.v.nutz.base.service.impl.ViServiceImpl;
import io.v.nutz.zhgh.activityBudget.models.ActivityBudget;
import io.v.nutz.zhgh.activityBudget.service.ActivityBudgetService;
import org.nutz.dao.Cnd;
import org.nutz.dao.Dao;
import org.nutz.ioc.loader.annotation.IocBean;
/**
* @ClassName ActivityBudgetServiceImpl
* @Description TODO
* @Author zhf
* @Date 2024/12/3 17:56
*/
@IocBean(args = {"refer:dao"})
public class ActivityBudgetServiceImpl extends ViServiceImpl<ActivityBudget> implements ActivityBudgetService {
public ActivityBudgetServiceImpl(Dao dao) {
super(dao);
}
@Override
public ActivityBudget findOne(String id) {
ActivityBudget activityBudget = fetchLinks(fetch(id), "budgetDetails", Cnd.NEW().asc("detailsOrder"));
activityBudget.setSchoolAudit(dao().fetch(Audit.class, Cnd.where("id", "=", activityBudget.getSchoolAuditId())));
activityBudget.setAllocationEditAuditList(dao().query(Audit.class, Cnd.where("parentId", "=", activityBudget.getId())));
return activityBudget;
}
}
@@ -0,0 +1,47 @@
package io.v.nutz.zhgh.activityBudget.template;
import cn.afterturn.easypoi.excel.annotation.Excel;
import lombok.Data;
/**
* @ClassName ActivityBudgetTemp
* @Description TODO
* @Author zhf
* @Date 2025/3/12 上午11:13
*/
@Data
public class ActivityBudgetTemp {
@Excel(name = "活动时间", format = "yyyy-MM-dd", needMerge = true)
private String activityDate;
@Excel(name = "活动项目名称")
private String activityMatter;
@Excel(name = "活动内容概述")
private String activityContent;
@Excel(name = "联系方式")
private String mobile;
@Excel(name = "预算类型(请在下拉菜单中选择)")
private String budgetTypeCode;
@Excel(name = "审核预算")
private String totalBudgetMoney;
@Excel(name = "预算金额")
private String declareTotalBudgetMoney;
@Excel(name = "审核意见")
private String auditOpinion;
@Excel(name = "申报单位(仅社团申报时可在下拉菜单中选择,其他类型不用填写)")
private String helpUnitName;
private String errorInfo;
}
@@ -89,7 +89,7 @@ public class ClubDataInputController {
@POST
@AdaptBy(type = UploadAdaptor.class, args = {"ioc:fileUpload"})
public Object doExport(TempFile file, String park_id) {
int count = 0;
/*int count = 0;
int success_count = 0;
try {
// 查出现在已交协会表中的已交协会
@@ -136,8 +136,8 @@ public class ClubDataInputController {
} catch (Exception e) {
} finally {
return Result.success().addData(NutMap.NEW().setv("count", count).setv("success_count", success_count));
}
}*/
return Result.success();
}
}
@@ -4,33 +4,34 @@ package io.v.nutz.zhgh.jf.controller.club;
import cn.wizzer.framework.base.Result;
import cn.wizzer.framework.page.Pagination;
import io.v.nutz.base.annontation.ViReturn;
import io.v.nutz.base.utils.DateUtil;
import io.v.nutz.base.utils.PageUtil;
import io.v.nutz.zhgh.jf.model.CostsSet;
import io.v.nutz.sys.models.Sys_club;
import io.v.nutz.zhgh.activityBudget.models.ActivityBudget;
import io.v.nutz.zhgh.jf.model.jf_club;
import io.v.nutz.zhgh.jf.service.CostsSetService;
import io.v.nutz.zhgh.jf.service.jfClubService;
import org.apache.shiro.authz.annotation.RequiresAuthentication;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.nutz.dao.Chain;
import org.nutz.dao.Cnd;
import org.nutz.dao.Sqls;
import org.nutz.dao.entity.Record;
import org.nutz.dao.sql.Sql;
import org.nutz.ioc.loader.annotation.Inject;
import org.nutz.ioc.loader.annotation.IocBean;
import org.nutz.lang.Strings;
import org.nutz.mvc.annotation.At;
import org.nutz.mvc.annotation.Ok;
import org.nutz.mvc.annotation.Param;
import org.nutz.trans.Trans;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;
import java.util.Objects;
/**
* @author zhf
* @date 2020/11/5 10:24
* @description 协会活动经费分配
* @description 社团活动经费分配
*/
@IocBean
@At("/platform/jf/st/fp")
@@ -44,7 +45,7 @@ public class clubController {
@Inject
private CostsSetService costsSetService;
private int year = Calendar.getInstance().get(Calendar.YEAR);
private final int year = Calendar.getInstance().get(Calendar.YEAR);
@At("")
@Ok("beetl:/platform/jf/club/clubys.html")
@@ -55,8 +56,8 @@ public class clubController {
// 获取最近的一年
@At
@ViReturn
@RequiresPermissions("sys.jf.st.fp")
public Object lastYear() {
Sql sql = Sqls.create("""
select max(year) year from jf_club where state=1
""");
@@ -69,13 +70,15 @@ public class clubController {
@ViReturn
@RequiresPermissions("sys.jf.st.fp")
public Object reset() {
return jfClubService.update(Chain.make("state", 0), Cnd.where("year", "=", year).and("state", "=", 1));
jfClubService.clear(Cnd.where("year", "=", DateUtil.getYear()));
return null;
}
//查询是否已下发
@At
@ViReturn
@RequiresPermissions("sys.jf.st.fp")
public Object isSet() {
return jfClubService.count(Cnd.where("state", "=", 1).and("year", "=", year));
}
@@ -86,87 +89,57 @@ public class clubController {
@ViReturn
@RequiresPermissions("sys.jf.st.fp")
public Object issue() {
Trans.exec(() -> {
Sql sql = Sqls.create("""
SELECT
jf.club_id,club.id cid,
( SELECT count( 1 ) FROM sys_club_user scu WHERE scu.clubid = club.id AND scu.`status` = 5 and scu.isNormal is true) cynum,
( SELECT count( 1 ) FROM sys_club_user scu WHERE scu.clubid = club.id AND scu.`status` = 5 and scu.isNormal is true and scu.giveMoney is true) bfnum,
( SELECT count( 1 ) FROM sys_club_user scu WHERE scu.clubid = club.id AND scu.`status` = 5 and scu.isNormal is true and scu.giveMoney is false) wbfnum
FROM
`sys_club` club
LEFT JOIN jf_club jf ON jf.club_id = club.id
AND jf.`year` = @year
""");
List<ActivityBudget> budgetList = jfClubService.dao().query(ActivityBudget.class,
Cnd.where("YEAR(applyDate)", "=", DateUtil.getYear())
.and("auditState", "=", 4)
.and("isSchoolBudget", "=", false)
.and("budgetTypeCode", "=", "ACTIVITY_BUDGET_TYPE_THREE"));
List<Sys_club> clubsList = jfClubService.dao().query(Sys_club.class,
Cnd.where("state", "=", 930));
sql.setParam("year", year);
CostsSet costsSet = costsSetService.fetch(Cnd.where("year", "=", this.year));
List<Record> list = jfClubService.list(sql);
list.forEach(record -> {
String cid = record.getString("cid");
int cynum = record.getInt("cynum");
int bfnum = record.getInt("bfnum");
int wbfnum = record.getInt("wbfnum");
Double clubLeastMoney = costsSet.getClubLeastMoney();
Double clubAtMostMoney = costsSet.getClubAtMostMoney();
Double money = clubLeastMoney;
//如果人数超过基础人数人
if (bfnum > costsSet.getClubExceedNum()) {
money = clubLeastMoney + (bfnum - costsSet.getClubExceedNum()) * costsSet.getClub_avg();
}
if (money > clubAtMostMoney) {
money = clubAtMostMoney;
}
Chain add = Chain.make("total_quota", money)
.add("state", 1)
.add("history_club_avg", costsSet.getClub_avg())
.add("history_member", cynum)
.add("history_y_giveMoney_member", bfnum)
.add("history_w_giveMoney_member", wbfnum);
jfClubService.update(add, Cnd.where("year", "=", year).and("club_id", "=", cid));
});
List<jf_club> jfClubList = new ArrayList<>();
clubsList.forEach(v -> {
BigDecimal totalBudgetMoney = budgetList.stream()
.filter(budget -> budget.getClubId().equals(v.getId()))
.map(ActivityBudget::getTotalBudgetMoney) // 提取 money 属性
.filter(Objects::nonNull) // 过滤掉空值
.reduce(BigDecimal.ZERO, BigDecimal::add);
jf_club yjgh = new jf_club();
yjgh.setClub_id(v.getId());
yjgh.setYear(DateUtil.getYear());
yjgh.setTotalQuota(totalBudgetMoney);
yjgh.setState(1);
jfClubList.add(yjgh);
});
jfClubService.insert(jfClubList);
return null;
}
@At
@ViReturn
@RequiresPermissions("sys.jf.st.fp")
public Object pageData(@Param(value = "pageNumber", required = false) int pageNumber,
@Param(value = "pageSize", required = false) int pageSize,
@Param(value = "year", required = false) Integer year,
@Param(value = "pageOrderName", required = false) String pageOrderName,
@Param(value = "pageOrderBy", required = false) String pageOrderBy,
@Param(value = "club_id", required = false) String club_id) {
public Object pageData(int pageNumber, int pageSize, Integer year, String pageOrderName, String pageOrderBy, String club_id) {
try {
Sql sql = Sqls.create("""
SELECT
jf.*,
club.`name`,
club.id cid,
club.code,
(SELECT count( 1 ) FROM sys_club_user scu WHERE
scu.clubid = club.id
AND scu.`status` = 5
AND scu.isNormal IS TRUE ) cynum
club.code
FROM
`sys_club` club
LEFT JOIN jf_club jf ON jf.club_id = club.id
AND jf.`year` = @year
$condition
""");
Cnd cnd = Cnd.NEW();
if (Strings.isNotBlank(pageOrderBy) && Strings.isNotBlank(pageOrderName)) {
cnd.orderBy(pageOrderName, PageUtil.getOrder(pageOrderBy));
} else if (Strings.isNotBlank(club_id)) {
cnd.and("club_id", "=", club_id);
cnd.and("club.id", "=", club_id);
} else {
cnd.asc("club.`name`");
cnd.asc("club.`code`");
}
cnd.and("jf.state", "=", 1);
cnd.and("club.state", "=", 930);
cnd.and("jf.`year`", "=", year);
sql.setParam("year", year);
sql.setCondition(cnd);
Pagination listPage = jfClubService.listPageMap(pageNumber, pageSize, sql);
@@ -178,47 +151,14 @@ public class clubController {
@At
@RequiresPermissions("sys.jf.st.fp")
public Object changeYs(String club_id, Integer year, Double total_quota) {
public Object changeYs(String clubId, Integer year, String totalQuota) {
try {
total_quota = total_quota == null ? 0 : total_quota;
jf_club jf_club = jfClubService.fetch(Cnd.where("club_id", "=", club_id).and("year", "=", year));
if (jf_club != null) {
jf_club.setTotal_quota(total_quota);
jfClubService.updateIgnoreNull(jf_club);
} else {
jf_club = new jf_club();
jf_club.setClub_id(club_id);
jf_club.setYear(year);
jf_club.setTotal_quota(total_quota);
jfClubService.insert(jf_club);
}
jf_club jf_club = jfClubService.fetch(Cnd.where("club_id", "=", clubId).and("year", "=", year));
jf_club.setTotalQuota(new BigDecimal(totalQuota));
jfClubService.updateIgnoreNull(jf_club);
return Result.success();
} catch (Exception e) {
return Result.error();
}
}
@At
@ViReturn
@RequiresPermissions("sys.jf.st.fp")
public Object doAdd(jf_club club){
Sql sql = Sqls.create("""
SELECT
sc.`name`,
YEAR(sc.create_time) `year`,
( SELECT count( 1 ) FROM `sys_club_user` scu WHERE scu.clubid = @clubId ) clubUser
FROM
`sys_club` sc
WHERE
sc.id = @clubId
""").setParam("clubId",club.getClub_id());
Record record = jfClubService.list(sql).get(0);
club.setHistory_member(Integer.parseInt(record.getString("clubUser")));
club.setHistory_y_giveMoney_member(Integer.parseInt(record.getString("clubUser")));
club.setYear(Integer.parseInt(record.getString("year")));
club.setState(1);
jfClubService.dao().insert(club);
return null;
}
}
@@ -5,9 +5,10 @@ import cn.wizzer.framework.page.Pagination;
import io.v.nutz.base.utils.ExcelUtil;
import io.v.nutz.base.utils.PageUtil;
import io.v.nutz.base.utils.Roles;
import io.v.nutz.zhgh.jf.service.jfClubService;
import io.v.nutz.sys.models.Sys_user_role;
import io.v.nutz.base.utils.Vi;
import io.v.nutz.sys.services.SysClubService;
import io.v.nutz.web.commons.utils.ShiroUtil;
import io.v.nutz.zhgh.jf.service.jfClubService;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.shiro.authz.annotation.RequiresAuthentication;
import org.apache.shiro.authz.annotation.RequiresPermissions;
@@ -18,7 +19,9 @@ import org.nutz.dao.entity.Record;
import org.nutz.dao.sql.Sql;
import org.nutz.ioc.loader.annotation.Inject;
import org.nutz.ioc.loader.annotation.IocBean;
import org.nutz.lang.Lang;
import org.nutz.lang.Strings;
import org.nutz.lang.util.NutMap;
import org.nutz.log.Log;
import org.nutz.log.Logs;
import org.nutz.mvc.annotation.At;
@@ -28,7 +31,6 @@ import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.OutputStream;
import java.util.List;
import java.util.stream.Collectors;
/**
* @author zhf
@@ -46,6 +48,11 @@ public class clubTzController {
@Inject
private jfClubService jfClubService;
@Inject
private SysClubService sysClubService;
@Inject
private Vi vi;
@At("")
@@ -56,7 +63,8 @@ public class clubTzController {
@At
public Object data(int pageNumber, int pageSize, Integer year, String club_id, String pageOrderName, String pageOrderBy) {
@RequiresPermissions("sys.jf.st.tz")
public Object data(int pageNumber, int pageSize, Integer year, String pageOrderName, String pageOrderBy) {
try {
Sql sql = Sqls.create("""
SELECT
@@ -67,26 +75,42 @@ public class clubTzController {
FROM
`sys_club` club
LEFT JOIN jf_club jf ON jf.club_id = club.id
AND jf.`year` = @year
$condition
""");
Cnd cnd = Cnd.NEW();
if (ShiroUtil.hasAnyRoles("sysadmin")) {
cnd.andEX("club.id", "=", club_id);
} else {
List<Sys_user_role> roleids = jfClubService.dao().query(Sys_user_role.class, Cnd.where("roleId", "=", Roles.club01));
List<String> ids = roleids.stream().map(Sys_user_role::getStid).collect(Collectors.toList());
cnd.andEX("club.id", "in", ids);
if (!ShiroUtil.hasRole("sysadmin") || ShiroUtil.hasRole("A06")) {
Cnd cnd1 = Cnd.NEW();
Sql sql1 = Sqls.create("""
SELECT
club.id
FROM
sys_club club
LEFT JOIN `sys_user_role` role ON club.id = role.stid
$condition
""");
if (!ShiroUtil.hasRole("sysadmin")) {
cnd.and("role.roleId", "in", Lang.array(Roles.club01, Roles.club02, Roles.club03, Roles.club04));
cnd.and("role.userId", "=", ShiroUtil.getUserId());
}
cnd1.and("club.isjs", "=", false);
cnd1.and("club.state", "=", 930);
cnd1.groupBy("club.id");
cnd1.asc("club.`code`");
sql.setCondition(cnd1);
List<NutMap> nutMapList = jfClubService.listMap(sql1);
List<String> ids = nutMapList.stream().map(v -> v.getString("id")).toList();
cnd.and("club.id", "in", ids);
}
cnd.and("jf.total_quota", "IS NOT", null);
cnd.and("jf.totalQuota", "IS NOT", null);
if (Strings.isNotBlank(pageOrderBy) && Strings.isNotBlank(pageOrderName)) {
cnd.orderBy(pageOrderName, PageUtil.getOrder(pageOrderBy));
} else {
cnd.asc("club.`name`");
}
cnd.andEX("jf.`year`","=",year);
sql.setParam("year", year);
sql.setCondition(cnd);
Pagination listPage = jfClubService.listPage(pageNumber, pageSize, sql);
Pagination listPage = jfClubService.listPageMap(pageNumber, pageSize, sql);
return Result.success().addData(listPage);
} catch (Exception e) {
return Result.error();
@@ -94,6 +118,7 @@ public class clubTzController {
}
@At
@RequiresPermissions("sys.jf.st.tz")
public Object modifyJf(String id, Integer usedQuota, String reason) {
try {
Chain chain = Chain.make("usedQuota", usedQuota).add("reason", reason);
@@ -106,28 +131,23 @@ public class clubTzController {
}
@At
@RequiresPermissions("sys.jf.st.tz")
public void exportExcel(HttpServletResponse response, Integer year) {
Sql sql = Sqls.create("""
SELECT
jf.*,
club.`name`,
club.`code`,
club.id cid
FROM
`jf_club` jf
LEFT JOIN `sys_club` club ON jf.club_id = club.id
$condition
""");
Sql sql = Sqls.create("SELECT\n" +
"\tjf.* ,club.`name`,club.id cid\n" +
"FROM\n" +
"`sys_club` club\n" +
"LEFT JOIN jf_club jf ON jf.club_id = club.id\n" +
"AND jf.`year` = @year $condition");
Cnd cnd = Cnd.NEW();
if (ShiroUtil.hasRole("sysadmin") || ShiroUtil.hasRole("A06")) {
} else {
List<Sys_user_role> roleids = jfClubService.dao().query(Sys_user_role.class, Cnd.where("roleId", "=", Roles.club01));
List<String> ids = roleids.stream().map(Sys_user_role::getStid).collect(Collectors.toList());
cnd.andEX("club.id", "in", ids);
} else if (ShiroUtil.hasRole("D02")) {
//基层工会管理员
cnd.and("club.fzr", "=", ShiroUtil.getPrincipalProperty("id"));
}
cnd.asc("club.name");
cnd.and("jf.`year`","=",year);
sql.setParam("year", year);
sql.setCondition(cnd);
List<Record> list = jfClubService.list(sql);
@@ -139,13 +159,13 @@ public class clubTzController {
String sheetName = year + "年协会经费使用情况表";
String[][] content = new String[list.size()][title.length];
for (int i = 0; i < list.size(); i++) {
Double zed = list.get(i).getDouble("total_quota");
Double ysyed = list.get(i).getDouble("used_quota");
Float zed = Strings.isBlank(list.get(i).getString("total_quota")) ? 0 : Float.parseFloat(list.get(i).getString("total_quota"));
int ysyed = Strings.isBlank(list.get(i).getString("used_quota")) ? 0 : Integer.parseInt(list.get(i).getString("used_quota"));
content[i][0] = list.get(i).getString("year");
content[i][1] = list.get(i).getString("name");
content[i][2] = String.valueOf(zed);
content[i][3] = String.valueOf(ysyed);
content[i][4] = String.valueOf(zed - ysyed);
content[i][4] = String.format("%.2f", zed - ysyed);
}
HSSFWorkbook wb = ExcelUtil.getHSSFWorkbook(sheetName, title, content, null);
try {
@@ -1,118 +0,0 @@
package io.v.nutz.zhgh.jf.controller.costsSet;
import io.v.nutz.base.annontation.ViReturn;
import io.v.nutz.base.utils.DateUtil;
import io.v.nutz.zhgh.jf.model.CostsSet;
import io.v.nutz.zhgh.jf.model.jf_club;
import io.v.nutz.zhgh.jf.model.jf_school;
import io.v.nutz.zhgh.jf.model.jf_yjgh;
import io.v.nutz.zhgh.jf.service.CostsSetService;
import io.v.nutz.sys.models.Sys_club;
import io.v.nutz.sys.models.Sys_union;
import io.v.nutz.sys.services.SysClubService;
import io.v.nutz.sys.services.SysUnionService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.nutz.dao.Cnd;
import org.nutz.ioc.loader.annotation.Inject;
import org.nutz.ioc.loader.annotation.IocBean;
import org.nutz.mvc.annotation.At;
import org.nutz.mvc.annotation.Ok;
import org.nutz.trans.Trans;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;
/**
* @Author:xsb
* @Description: 费用设置
* @Date:Created in 9:25 2021/1/23
*/
@IocBean
@At("/platform/jf/costsSet/costsSet")
@Ok("json:full")
public class CostsSetController {
@Inject
private io.v.nutz.zhgh.jf.service.jfYjghService jfYjghService;
@Inject
private SysUnionService sysUnionService;
@Inject
private io.v.nutz.zhgh.jf.service.jfClubService jfClubService;
@Inject
private SysClubService sysClubService;
@Inject // 经费设置
private CostsSetService costsSetService;
private int year = Calendar.getInstance().get(Calendar.YEAR);
@At("")
@Ok("beetl:/platform/jf/costsSet/costsSet.html")
@RequiresPermissions("sys.manager.jf.costsSet")
public void index() {
}
// 设置人均额度
@At
@ViReturn
@RequiresPermissions("sys.manager.jf.costsSet")
public Object set(CostsSet costsSet) {
Trans.exec(() -> {
costsSet.setYear(DateUtil.getYear());
costsSetService.insertOrUpdate(costsSet);
jfYjghService.dao().clear(jf_school.class, Cnd.where("year", "=", DateUtil.getYear()));
jf_school jf_school = new jf_school();
jf_school.setTotalQuota(costsSet.getSchoolMoney());
jf_school.setUsedQuota(0D);
jf_school.setYear(this.year);
jf_school.setState(1);
jfYjghService.insert(jf_school);
jfYjghService.clear(Cnd.where("year", "=", DateUtil.getYear()));
List<Sys_union> query = sysUnionService.query();
List<jf_yjgh> jfYjghList = new ArrayList<>();
for (Sys_union sys_union : query) {
jf_yjgh jf_yjgh = new jf_yjgh();
jf_yjgh.setUnionId(sys_union.getId());
jf_yjgh.setUsedQuota(0D);
jf_yjgh.setYear(DateUtil.getYear());
jfYjghList.add(jf_yjgh);
}
jfYjghService.insert(jfYjghList);
jfClubService.clear(Cnd.where("year", "=", DateUtil.getYear()));
List<Sys_club> Sys_clubs = sysClubService.query(Cnd.where("state", "=", 930));
List<jf_club> jfClubList = new ArrayList<>();
Sys_clubs.forEach(s -> {
jf_club jf_club = new jf_club();
jf_club.setClub_id(s.getId());
jf_club.setUsed_quota(0D);
jf_club.setYear(this.year);
jfClubList.add(jf_club);
});
jfClubService.insert(jfClubList);
});
return null;
}
// 回显额度
@At
@ViReturn
@RequiresPermissions("sys.manager.jf.costsSet")
public Object echo() {
return costsSetService.fetch(Cnd.where("year", "=", year));
}
}
@@ -59,7 +59,7 @@ import java.util.stream.Collectors;
@Slf4j
public class FinancialImportController {
@Inject
/* @Inject
private Dao dao;
@Inject
private BaseService baseService;
@@ -71,10 +71,10 @@ public class FinancialImportController {
}
/**
*//**
* 财务数据导入模版
* @param response
*/
*//*
@At
@Ok("void")
@RequiresPermissions("sys.jf.financial.import")
@@ -95,12 +95,12 @@ public class FinancialImportController {
/**
*//**
* 读取excel数据
*
* @param tempFile 临时文件
* @return {@link Object}
*/
*//*
@At
@ViReturn
@AdaptBy(type = UploadAdaptor.class, args = {"ioc:fileUpload"})
@@ -142,11 +142,11 @@ public class FinancialImportController {
}
/**
*//**
* 数据导入
* @param excelModeArr
* @return
*/
*//*
@At
@Ok("json:full")
@RequiresPermissions("sys.jf.financial.import")
@@ -175,7 +175,7 @@ public class FinancialImportController {
jf_yjgh yjgh = dao.fetch(jf_yjgh.class, Cnd.where("unionId", "=", s).and("`year`","like", v.getYear()));
if (!StringUtils.isEmpty(yjgh)){
str=yjgh.getId();
BigDecimal residueQuota = new BigDecimal(yjgh.getTotalQuota()).subtract(new BigDecimal(yjgh.getUsedQuota()));
BigDecimal residueQuota = yjgh.getTotalQuota().subtract(new BigDecimal(yjgh.getUsedQuota()));
if (residueQuota.compareTo(new BigDecimal(v.getAdjust_money())) > 0) {
dao.update(jf_yjgh.class, Chain.make("usedQuota", yjgh.getUsedQuota() + v.getAdjust_money()), Cnd.where("id", "=", str));
} else {
@@ -225,5 +225,5 @@ public class FinancialImportController {
Trans.rollback();
return Result.error("财务数据导入失败");
}
}
}*/
}
@@ -1,190 +0,0 @@
package io.v.nutz.zhgh.jf.controller.jfbx;
import cn.wizzer.framework.base.Result;
import cn.wizzer.framework.page.Pagination;
import io.v.nutz.base.utils.DateUtil;
import io.v.nutz.zhgh.jf.model.jf_bxyy;
import io.v.nutz.zhgh.jf.service.jfBxYyFjService;
import io.v.nutz.sys.models.Sys_user;
import io.v.nutz.sys.services.SysUserService;
import io.v.nutz.web.commons.utils.ShiroUtil;
import org.apache.shiro.authz.annotation.RequiresAuthentication;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.nutz.dao.Cnd;
import org.nutz.dao.Sqls;
import org.nutz.dao.sql.Sql;
import org.nutz.ioc.loader.annotation.Inject;
import org.nutz.ioc.loader.annotation.IocBean;
import org.nutz.lang.Strings;
import org.nutz.lang.util.NutMap;
import org.nutz.log.Log;
import org.nutz.log.Logs;
import org.nutz.mvc.annotation.At;
import org.nutz.mvc.annotation.Ok;
/**
* @author 1V
* @date 2020/11/5 14:21
* @description 经费报销审核
*/
@IocBean
@At("/platform/jf/jfbx/bxsh")
@Ok("json:full")
@RequiresAuthentication
public class bxshController {
private static final Log log = Logs.get();
@Inject
public jfBxYyFjService jfBxYyFjService;
@Inject
private io.v.nutz.zhgh.jf.service.jfBxyyService jfBxyyService;
@Inject
private io.v.nutz.zhgh.jf.service.jfYjghService jfYjghService;
@Inject
private SysUserService sysUserService;
@At("")
@Ok("beetl:/platform/jf/bxyy/bxsh.html")
@RequiresPermissions("sys.jf.bx.sh")
public void index() {
}
//获取预约报销列表
@At
public Object data(String startTime, String endTime, String saerchsfsh, String searchName,
String searchKeyword, int pageNumber, int pageSize) {
Cnd cnd = Cnd.NEW();
Sys_user user = (Sys_user) ShiroUtil.getPrincipal();
int identity = 0;
//07193 杜达金
if (ShiroUtil.hasRole("gh01")) {
identity = 1;
int audit_status[] = {1, 2, 3, 4, 5};
cnd.and("audit_status", "in", audit_status);
}
//07001 谢群泽
else if (ShiroUtil.hasRole("gh12")) {
identity = 2;
int audit_status[] = {2, 3, 4, 5};
cnd.and("audit_status", "in", audit_status);
} else if (ShiroUtil.hasRole("sysadmin")) {
identity = 3;
int audit_status[] = {1, 2, 3, 4, 5};
cnd.and("audit_status", "in", audit_status);
}
//查询
if (Strings.isNotBlank(saerchsfsh)) {
if (identity == 1 && saerchsfsh.equals("1")) {
cnd.and("audit_status", "=", "2");
}
if (identity == 1 && saerchsfsh.equals("2")) {
int audit_status[] = {3, 4, 5};
cnd.and("audit_status", "in", audit_status);
}
if (identity == 2 && saerchsfsh.equals("1")) {
cnd.and("audit_status", "=", "1");
}
if (identity == 2 && saerchsfsh.equals("2")) {
int audit_status[] = {2, 3, 4, 5};
cnd.and("audit_status", "in", audit_status);
}
if (identity == 3 && saerchsfsh.equals("1")) {
int audit_status[] = {1, 2};
cnd.and("audit_status", "in", audit_status);
}
if (identity == 3 && saerchsfsh.equals("2")) {
int audit_status[] = {3, 4, 5};
cnd.and("audit_status", "in", audit_status);
}
}
if (Strings.isNotBlank(searchName) && Strings.isNotBlank(searchKeyword)) {
cnd.and(searchName, "like", "%" + searchKeyword + "%");
}
if (Strings.isNotBlank(startTime)) {
cnd.and("booking_time", ">=", startTime);
}
if (Strings.isNotBlank(endTime)) {
cnd.and("booking_time", "<=", endTime);
}
//只查询需要审核的预约报销
Sql sql = Sqls.create("SELECT\n" +
"\tbu.username userName,\n" +
"\tch.username chName,\n" +
"\tfi.username fiName,\n" +
"\tbu.loginname,\n" +
"\tbn.`name` unit,\n" +
"\tb.* \n" +
"FROM\n" +
"\tjf_bxyy b\n" +
"\tLEFT JOIN sys_user bu ON bu.id = b.booking_person_id\n" +
"\tLEFT JOIN sys_user ch ON ch.id = b.chairman_id\n" +
"\tLEFT JOIN sys_user fi ON fi.id = b.finance_id\n" +
"\tLEFT JOIN sys_unit bn ON bn.id = bu.unitid $condition");
cnd.asc("audit_status").desc("booking_time");
sql.setCondition(cnd);
Pagination yybxlist = jfBxyyService.listPage(pageNumber, pageSize, sql);
NutMap map = new NutMap();
map.put("bxShList", yybxlist);
map.put("user", user);
map.put("identity", identity);
return Result.success().addData(map);
}
/**
* 报销审核
*
* @param identity
* @param audit_status
* @param opinion
* @param id
* @return
*/
@At
@Ok("json")
public Object bxSh(Integer identity, Integer audit_status, String opinion, String id) {
try {
//获取当前用户信息
Sys_user user = (Sys_user) ShiroUtil.getPrincipal();
jf_bxyy bxyy = jfBxyyService.fetch(id);
bxyy.setAudit_status(audit_status);
//主席审核
if (identity == 1) {
bxyy.setChairman_id(user.getId());
bxyy.setChairman_opinion(opinion);
bxyy.setChairman_time(DateUtil.getDate());
}
//财务审核
if (identity == 2) {
bxyy.setFinance_id(user.getId());
bxyy.setFinance_opinion(opinion);
bxyy.setFinance_time(DateUtil.getDate());
}
jfBxyyService.updateIgnoreNull(bxyy);
// if (audit_status.equals(3)) {
// if (bxyy.getActivity_type().equals("基层工会活动")) {
// String unionid = sysUserService.fetch(bxyy.getBooking_person_id()).getUnionid();
// jf_yjgh jf_yjgh = jfYjghService.fetch(Cnd.where("unionId", "=", unionid).and("year", "=", new SimpleDateFormat("yyyy").format(new Date())));
//
// jf_yjgh.setUsedQuota(jf_yjgh.getUsedQuota() == null ? 0 : jf_yjgh.getUsedQuota() + (int) Float.parseFloat(bxyy.getRei_money()));
// jfYjghService.updateIgnoreNull(jf_yjgh);
// }
// }
return Result.success().addMsg("审核完毕");
} catch (Exception e) {
log.error(e);
return Result.error().addMsg("审核失败!");
}
}
}
@@ -1,223 +0,0 @@
package io.v.nutz.zhgh.jf.controller.jfbx;
import cn.wizzer.framework.base.Result;
import cn.wizzer.framework.page.Pagination;
import io.v.nutz.sys.models.Sys_user;
import io.v.nutz.web.commons.utils.ShiroUtil;
import org.apache.poi.hssf.usermodel.*;
import org.apache.poi.ss.usermodel.HorizontalAlignment;
import org.apache.poi.ss.usermodel.VerticalAlignment;
import org.apache.shiro.authz.annotation.RequiresAuthentication;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.nutz.dao.Cnd;
import org.nutz.dao.Sqls;
import org.nutz.dao.entity.Record;
import org.nutz.dao.sql.Sql;
import org.nutz.ioc.loader.annotation.Inject;
import org.nutz.ioc.loader.annotation.IocBean;
import org.nutz.lang.Strings;
import org.nutz.lang.util.NutMap;
import org.nutz.log.Log;
import org.nutz.log.Logs;
import org.nutz.mvc.annotation.At;
import org.nutz.mvc.annotation.Ok;
import org.nutz.mvc.annotation.Param;
import javax.servlet.http.HttpServletResponse;
import java.io.OutputStream;
import java.util.List;
/**
* @author 1V
* @date 2020/11/5 14:23
* @description 经费报销预览
*/
@IocBean
@At("/platform/jf/jfbx/bxyl")
@Ok("json:full")
@RequiresAuthentication
public class bxylController {
private static final Log log = Logs.get();
@Inject
private io.v.nutz.zhgh.jf.service.jfBxyyService jfBxyyService;
@At("")
@Ok("beetl:/platform/jf/bxyy/bxyl.html")
@RequiresPermissions("sys.jf.bx.ck")
public void index() {
}
@At
public Object data(String startTime, String endTime, String searchName,
String searchKeyword, int pageNumber, int pageSize) {
try {
Cnd cnd = Cnd.NEW();
Sys_user user = (Sys_user) ShiroUtil.getPrincipal();
if (Strings.isNotBlank(searchName) && Strings.isNotBlank(searchKeyword)) {
cnd.and(searchName, "like", "%" + searchKeyword + "%");
}
if (Strings.isNotBlank(startTime)) {
cnd.and("booking_time", ">=", startTime);
}
if (Strings.isNotBlank(endTime)) {
cnd.and("booking_time", "<=", endTime);
}
cnd.and("audit_status", "=", 3);
//只查询需要审核的预约报销
Sql sql = Sqls.create("SELECT\n" +
"\tbu.username userName,\n" +
"\tch.username chName,\n" +
"\tfi.username fiName,\n" +
"\tbu.loginname,\n" +
"\tbn.`name` unit,\n" +
"\tb.* \n" +
"FROM\n" +
"\tjf_bxyy b\n" +
"\tLEFT JOIN sys_user bu ON bu.id = b.booking_person_id\n" +
"\tLEFT JOIN sys_user ch ON ch.id = b.chairman_id\n" +
"\tLEFT JOIN sys_user fi ON fi.id = b.finance_id\n" +
"\tLEFT JOIN sys_unit bn ON bn.id = bu.unitid $condition");
cnd.asc("audit_status").desc("booking_time");
sql.setCondition(cnd);
Pagination bxylList = jfBxyyService.listPage(pageNumber, pageSize, sql);
NutMap map = new NutMap();
map.put("bxylList", bxylList);
map.put("user", user);
return Result.success().addData(map);
} catch (Exception e) {
log.error(e);
return Result.error().addMsg("查询失败!");
}
}
//导出预约报销表
@At
public void export(@Param("startTime") String startTime, @Param("endTime") String endTime, @Param("searchName") String searchName, String searchKeyword, HttpServletResponse response) {
try {
Cnd cnd = Cnd.NEW();//查询代表条件
cnd.and("audit_status", "=", 3);
if (Strings.isNotBlank(searchName) && Strings.isNotBlank(searchKeyword)) {
cnd.and(searchName, "like", "%" + searchKeyword + "%");
}
if (Strings.isNotBlank(startTime)) {
cnd.and("booking_time", ">=", startTime);
}
if (Strings.isNotBlank(endTime)) {
cnd.and("booking_time", "<=", endTime);
}
//只查询需要审核的预约报销
Sql sqlc = Sqls.create("SELECT\n" +
"\tbu.username userName,\n" +
"\tbu.loginname,\n" +
"\tbn.`name` unit,\n" +
"\tb.* \n" +
"FROM\n" +
"\tjf_bxyy b\n" +
"\tLEFT JOIN sys_user bu ON bu.id = b.booking_person_id\n" +
"\tLEFT JOIN sys_unit bn ON bn.id = bu.unitid $condition");
cnd.desc("booking_time");
sqlc.setCondition(cnd);
List<Record> records = jfBxyyService.list(sqlc);
//创建HSSFWorkbook对象(excel的文档对象)
HSSFWorkbook wb = new HSSFWorkbook();
//建立新的sheet对象(excel的表单)
HSSFSheet sheet = wb.createSheet("经费报销预约名单");
sheet.setDefaultColumnWidth(20);
sheet.setColumnWidth(4, 265 * 36);
//sheet.setColumnWidth(5,265*38);
//在sheet里创建第一行,参数为行索引(excel的行),可以是0~65535之间的任何一个
HSSFRow row1 = sheet.createRow(0);
row1.setHeight((short) 500);
HSSFCellStyle cellStyle = wb.createCellStyle();
cellStyle.setAlignment(HorizontalAlignment.CENTER);
cellStyle.setVerticalAlignment(VerticalAlignment.CENTER);
HSSFFont fontStyle = wb.createFont();
//fontStyle.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
fontStyle.setFontHeightInPoints((short) 12);
cellStyle.setFont(fontStyle);
//创建单元格(excel的单元格,参数为列索引,可以是0~255之间的任何一个
HSSFCell cell1 = row1.createCell(0);
cell1.setCellStyle(cellStyle);
cell1.setCellValue("申请工号");
HSSFCell cell2 = row1.createCell(1);
cell2.setCellStyle(cellStyle);
cell2.setCellValue("申请人");
HSSFCell cell3 = row1.createCell(2);
cell3.setCellStyle(cellStyle);
cell3.setCellValue("联系电话");
HSSFCell cell4 = row1.createCell(3);
cell4.setCellStyle(cellStyle);
cell4.setCellValue("预约时间");
HSSFCell cell5 = row1.createCell(4);
cell5.setCellStyle(cellStyle);
cell5.setCellValue("报销事项");
HSSFCell cell6 = row1.createCell(5);
cell6.setCellStyle(cellStyle);
cell6.setCellValue("报销金额");
HSSFCell cell7 = row1.createCell(6);
cell7.setCellStyle(cellStyle);
cell7.setCellValue("报销卡号");
HSSFCellStyle cellStyle1 = wb.createCellStyle();
cellStyle1.setAlignment(HorizontalAlignment.CENTER);
//在sheet里创建第二行
for (int i = 0; i < records.size(); i++) {
HSSFRow row = sheet.createRow(i + 1);
HSSFCell cella = row.createCell(0);
cella.setCellStyle(cellStyle1);
cella.setCellValue(records.get(i).getString("loginname"));
HSSFCell cellb = row.createCell(1);
cellb.setCellStyle(cellStyle1);
cellb.setCellValue(records.get(i).getString("userName"));
HSSFCell cellc = row.createCell(2);
cellc.setCellStyle(cellStyle1);
cellc.setCellValue(records.get(i).getString("booking_person_phone"));
HSSFCell celld = row.createCell(3);
celld.setCellStyle(cellStyle1);
celld.setCellValue(records.get(i).getString("booking_time"));
HSSFCell celle = row.createCell(4);
celle.setCellStyle(cellStyle1);
celle.setCellValue(records.get(i).getString("rei_matter"));
HSSFCell cellf = row.createCell(5);
cellf.setCellStyle(cellStyle1);
cellf.setCellValue(records.get(i).getString("rei_money"));
HSSFCell cellh = row.createCell(6);
cellh.setCellStyle(cellStyle1);
cellh.setCellValue(records.get(i).getString("rei_card_number"));
}
String formFileName = "经费报销预约名单";
// 针对IE或者以IE为内核的浏览器:
formFileName = java.net.URLEncoder.encode(formFileName, "UTF-8");
// formFileName = new String(formFileName.getBytes("UTF-8"), "ISO-8859-1");
//输出Excel文件
OutputStream output = response.getOutputStream();
response.reset();
response.setHeader("Content-disposition", "attachment; filename=" + formFileName + ".xls");
response.setContentType("application/msexcel;charset=utf-8");
response.setCharacterEncoding("UTF-8");
wb.write(output);
output.close();
} catch (Exception e) {
log.error(e.getMessage(), e);
}
}
}
@@ -1,387 +0,0 @@
package io.v.nutz.zhgh.jf.controller.jfbx;
import cn.wizzer.framework.base.Result;
import cn.wizzer.framework.base.service.BaseService;
import cn.wizzer.framework.page.Pagination;
import io.v.nutz.base.utils.DateUtil;
import io.v.nutz.zhgh.jf.model.jf_bxyy;
import io.v.nutz.zhgh.jf.model.jf_bxyy_fj;
import io.v.nutz.sys.models.Sys_file;
import io.v.nutz.sys.models.Sys_user;
import io.v.nutz.web.commons.utils.DocConverter;
import io.v.nutz.web.commons.utils.ShiroUtil;
import org.apache.shiro.authz.annotation.RequiresAuthentication;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.nutz.boot.starter.ftp.FtpService;
import org.nutz.dao.Chain;
import org.nutz.dao.Cnd;
import org.nutz.dao.Sqls;
import org.nutz.dao.entity.Record;
import org.nutz.dao.sql.Sql;
import org.nutz.ioc.loader.annotation.Inject;
import org.nutz.ioc.loader.annotation.IocBean;
import org.nutz.lang.Strings;
import org.nutz.lang.random.R;
import org.nutz.lang.util.NutMap;
import org.nutz.log.Log;
import org.nutz.log.Logs;
import org.nutz.mvc.annotation.AdaptBy;
import org.nutz.mvc.annotation.At;
import org.nutz.mvc.annotation.Ok;
import org.nutz.mvc.annotation.Param;
import org.nutz.mvc.upload.TempFile;
import org.nutz.mvc.upload.UploadAdaptor;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.*;
import java.util.List;
import java.util.Map;
/**
* @author 1V
* @date 2020/11/5 14:24
* @description 经费报销预约
*/
@IocBean
@At("/platform/jf/jfbx/bxyy")
@Ok("json:full")
@RequiresAuthentication
public class bxyyController {
private static final Log log = Logs.get();
@Inject
public io.v.nutz.zhgh.jf.service.jfBxYyFjService jfBxYyFjService;
@Inject
private io.v.nutz.zhgh.jf.service.jfBxyyService jfBxyyService;
@Inject
private FtpService ftpService;
@Inject
private BaseService baseService;
@At("")
@Ok("beetl:/platform/jf/bxyy/bxyy.html")
@RequiresPermissions("sys.jf.bx.yy")
public void index() {
}
@At
public Object data(int pageNumber, int pageSize, String searchName, String searchKeyword) {
try {
Sql sql = Sqls.create("SELECT\n" +
"\tbu.username userName,\n" +
"\tch.username chName,\n" +
"\tfi.username fiName,\n" +
"\tbu.loginname,\n" +
"\tbn.`name` unit,\n" +
"\tb.* \n" +
"FROM\n" +
"\tjf_bxyy b\n" +
"\tLEFT JOIN sys_user bu ON bu.id = b.booking_person_id\n" +
"\tLEFT JOIN sys_user ch ON ch.id = b.chairman_id\n" +
"\tLEFT JOIN sys_user fi ON fi.id = b.finance_id\n" +
"\tLEFT JOIN sys_unit bn ON bn.id = bu.unitid $condition");
Cnd cnd = Cnd.NEW();
Sys_user user = (Sys_user) ShiroUtil.getPrincipal();
cnd.and("booking_person_id", "=", user.getId());
if (Strings.isNotBlank(searchName) && Strings.isNotBlank(searchKeyword)) {
cnd.and(searchName, "like", "%" + searchKeyword + "%");
}
cnd.desc("booking_time");
sql.setCondition(cnd);
Pagination pagination = jfBxyyService.listPage(pageNumber, pageSize, sql);
NutMap nutMap = new NutMap();
nutMap.put("list", pagination);
nutMap.put("user", user);
return Result.success().addData(nutMap);
} catch (Exception e) {
log.error(e);
return Result.error();
}
}
@At
@AdaptBy(type = UploadAdaptor.class, args = {"ioc:fileUpload"})
public Object add(jf_bxyy jf_bxyy, @Param("files") TempFile[] files) {
try {
//新增预约报销
jf_bxyy.setBooking_time(DateUtil.getDate());
jf_bxyy.setAudit_status(1);
jf_bxyy.setBooking_person_id(ShiroUtil.getPrincipalProperty("id").toString());
jf_bxyy insert = jfBxyyService.insert(jf_bxyy);
for (TempFile file : files) {
String rid = R.UU32();
String suffixName = file.getSubmittedFileName().substring(file.getSubmittedFileName().lastIndexOf(".")).toLowerCase();
String savepath = "jfbxyy";
ftpService.upload(savepath, rid + suffixName, file.getInputStream());
Sys_file sys_file = new Sys_file();
sys_file.setId(R.UU32());
sys_file.setReid(insert.getId());
sys_file.setFilename(file.getSubmittedFileName());
sys_file.setFilepath("/" + savepath + "/" + rid + suffixName);
baseService.insert("sys_file", Chain.from(sys_file));
}
return Result.success();
} catch (Exception e) {
e.printStackTrace();
return Result.error().addMsg("提交失败!");
}
}
@At
@AdaptBy(type = UploadAdaptor.class, args = {"ioc:fileUpload"})
public Object editYyBx(jf_bxyy jf_bxyy, @Param("files") TempFile[] files, String[] delFiles) {
try {
jf_bxyy.setAudit_status(1);
jfBxyyService.updateIgnoreNull(jf_bxyy);
for (TempFile file : files) {
String rid = R.UU32();
String suffixName = file.getSubmittedFileName().substring(file.getSubmittedFileName().lastIndexOf(".")).toLowerCase();
String savepath = "jfbxyy";
ftpService.upload(savepath, rid + suffixName, file.getInputStream());
Sys_file sys_file = new Sys_file();
sys_file.setId(R.UU32());
sys_file.setReid(jf_bxyy.getId());
sys_file.setFilename(file.getSubmittedFileName());
sys_file.setFilepath("/" + savepath + "/" + rid + suffixName);
baseService.insert("sys_file", Chain.from(sys_file));
}
for (String s : delFiles) {
Sys_file file = baseService.dao().fetch(Sys_file.class, Cnd.where("id", "=", s));
ftpService.delete(file.getFilepath());
baseService.dao().delete(Sys_file.class, s);
}
return Result.success();
} catch (Exception e) {
e.printStackTrace();
return Result.error();
}
}
@At
public Object delYyBx(String id) {
try {
List<Record> files = baseService.dao().query("sys_file", Cnd.where("reid", "=", id));
files.forEach(file -> {
ftpService.delete(file.getString("filepath"));
baseService.dao().delete(Sys_file.class, file.getString("id"));
});
jfBxyyService.clear(Cnd.where("id", "=", id));
return Result.success().addMsg("成功删除预约报销申请!");
} catch (Exception e) {
e.printStackTrace();
return Result.error().addMsg("删除失败!");
}
}
/**
* 上传附件
*
* @param map
*/
@At("/uploadFiles")
@AdaptBy(type = UploadAdaptor.class, args = {"ioc:fileUpload"})
@Ok("json:full")
public Object uploadFiles(Map map) {
try {
TempFile tempFile = (TempFile) map.get("file");
String booking_id = map.get("id").toString();//预约报销id
String fileLocalName = ((TempFile) map.get("file")).getMeta().getFileLocalName();//原文件名
String fjid = R.UU32();//附件ID
String wjkzm = fileLocalName.substring(fileLocalName.lastIndexOf(".")); //文件扩展名
String filepath = "upload/yybx/";
savePic(tempFile.getInputStream(), fjid + wjkzm, filepath);
/*Files.write(new File(filepath),tempFile.getInputStream());*/
jfBxYyFjService.insert("jf_bxyy_fj", Chain.make("id", fjid).add("booking_id", booking_id)
.add("name", fileLocalName).add("url", filepath + "/" + fjid + wjkzm).add("time", DateUtil.getDate()));
//数据库的路径 为 FJID+文件名 防止重复
return Result.success();
} catch (Exception e) {
e.printStackTrace();
return Result.error();
}
}
//保存文件
private void savePic(InputStream inputStream, String fileName, String path) {
OutputStream os = null;
try {
//String path = "D:\\testFile\\";
// 2、保存到临时文件
// 1K的数据缓冲
byte[] bs = new byte[1024];
// 读取到的数据长度
int len;
// 输出的文件流保存到本地文件
File tempFile = new File(path);
if (!tempFile.exists()) {
tempFile.mkdirs();
}
os = new FileOutputStream(tempFile.getPath() + File.separator + fileName);
// 开始读取
while ((len = inputStream.read(bs)) != -1) {
os.write(bs, 0, len);
}
} catch (IOException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
} finally {
// 完毕,关闭所有链接
try {
os.close();
inputStream.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
//获取当前选择预约单的附件列表
@At
public Object ViewFjList(String booking_id) {
try {
return Result.success(baseService.dao().query("sys_file", Cnd.where("reid", "=", booking_id)));
} catch (Exception e) {
e.printStackTrace();
return Result.error("文件列表加载失败!");
}
}
/**
* 删除已上传的附件
*/
@At
public Object delFjById(@Param("fjid") String fjid) {
try {
int num = 0;
String[] ids = fjid.split(",");
for (int i = 0; i < ids.length; i++) {
jf_bxyy_fj jfBxyyFj = jfBxYyFjService.fetch(ids[i]);
String url = jfBxyyFj.getUrl(); //附件存放位置
File file = new File("");
String path = file.getCanonicalPath();
File delfile = new File(path + "/" + url);
if (delfile.exists() && delfile.isFile()) {
if (delfile.delete()) {
num++;
}
}
jfBxYyFjService.clear("jf_bxyy_fj", Cnd.where("id", "=", ids[i]));
}
if (num == ids.length) {
return Result.success();
} else {
return Result.error();
}
} catch (Exception e) {
return Result.error();
}
}
//获取当前预约报销的所有附件信息
@At
public Object viewFjInfoById(String booking_id) {
try {
return Result.success(baseService.dao().query("sys_file", Cnd.where("reid", "=", booking_id)));
} catch (Exception e) {
return Result.error("获取附件失败");
}
}
/**
* 将图片以文件流的形式在页面显示
*/
@At
@Ok("void")
public void showPic(String url, HttpServletResponse response) throws Exception {
response.setContentType("image/jpeg");
//获取路径
File directory = new File("");// 参数为空
String courseFile = directory.getCanonicalPath();
// 获取图片
File file = new File(courseFile + "\\" + url);
//创建文件输入流
FileInputStream is = new FileInputStream(file);
// 响应输出流
ServletOutputStream out = response.getOutputStream();
// 创建缓冲区
byte[] buffer = new byte[1024];
int len = 0;
while ((len = is.read(buffer)) != -1) {
out.write(buffer, 0, len);
}
is.close();
out.flush();
out.close();
}
@At
public void preview(HttpServletRequest request, HttpServletResponse response, @Param("filePath") String filePath) throws IOException {
//获取路径
File directory = new File("");// 参数为空
String courseFile = directory.getCanonicalPath();
filePath = courseFile + "\\" + filePath;
DocConverter doc = new DocConverter(filePath);
doc.conver();
String newUrl = doc.getswfPath();
File file = new File(newUrl);
//创建文件输入流
FileInputStream is = new FileInputStream(file);
// 响应输出流
ServletOutputStream out = response.getOutputStream();
// 创建缓冲区
byte[] buffer = new byte[1024];
int len = 0;
while ((len = is.read(buffer)) != -1) {
out.write(buffer, 0, len);
}
new File(newUrl).delete();
is.close();
out.flush();
out.close();
}
//下载附件
@At
public void download(String path, String filename, String fname, HttpServletResponse response) {
//取得文件
try {
//获取路径
File directory = new File("");// 参数为空
String courseFile = directory.getCanonicalPath();
File file = new File(courseFile + "\\" + path);
if (file.exists()) {
response.setHeader("content-disposition", "attachment;filename=" + new String(fname.getBytes("utf-8"), "ISO8859-1"));
FileInputStream fis = new FileInputStream(file);
OutputStream os = response.getOutputStream();
int len = -1;
byte[] b = new byte[1024 * 100];
while ((len = fis.read(b)) != -1) {
os.write(b, 0, len);
}
os.flush();
os.close();
fis.close();
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
@@ -5,12 +5,15 @@ import cn.wizzer.framework.page.Pagination;
import io.v.nutz.base.annontation.ViReturn;
import io.v.nutz.base.utils.DateUtil;
import io.v.nutz.base.utils.PageUtil;
import io.v.nutz.sys.models.Sys_user;
import io.v.nutz.web.commons.utils.ShiroUtil;
import io.v.nutz.zhgh.jf.model.jf_club;
import io.v.nutz.zhgh.jf.model.jf_use;
import io.v.nutz.zhgh.jf.model.jf_yjgh;
import io.v.nutz.zhgh.jf.service.ActivityBxService;
import io.v.nutz.sys.models.Sys_user;
import io.v.nutz.web.commons.utils.ShiroUtil;
import io.v.nutz.zhgh.jf.service.jfClubService;
import io.v.nutz.zhgh.jf.service.jfUseService;
import io.v.nutz.zhgh.jf.service.jfYjghService;
import org.nutz.dao.Cnd;
import org.nutz.dao.Sqls;
import org.nutz.dao.sql.Sql;
@@ -22,6 +25,8 @@ import org.nutz.log.Logs;
import org.nutz.mvc.annotation.At;
import org.nutz.mvc.annotation.Ok;
import java.math.BigDecimal;
/**
* @author zhf
* @date 2020/11/5 14:28
@@ -37,13 +42,13 @@ public class jsTzController {
@Inject
private io.v.nutz.zhgh.jf.service.jfUseService jfUseService;
private jfUseService jfUseService;
@Inject
private io.v.nutz.zhgh.jf.service.jfYjghService jfYjghService;
private jfYjghService jfYjghService;
@Inject
private io.v.nutz.zhgh.jf.service.jfClubService jfClubService;
private jfClubService jfClubService;
@Inject
private ActivityBxService activityBxService;
@@ -52,23 +57,19 @@ public class jsTzController {
@At
public Object data(int pageNumber, int pageSize, Integer year, String pageOrderName, String pageOrderBy, String adjust_id) {
try {
Sql sql = Sqls.create("""
SELECT
ju.*,
re.userId ,
re.activity_number,
su.username,
YEAR(re.applyTime) `year`,
us.unionname
FROM
`jf_use` ju
LEFT JOIN jf_yjgh jf ON ju.adjust_id = jf.id
LEFT JOIN sys_user su ON su.id = ju.adjust_person
LEFT JOIN reimbursement_new re ON re.id = ju.apply_id
LEFT JOIN `user` us ON us.id = re.userId
$condition
""");
Sql sql = Sqls.create("SELECT\n" +
"\tju.*,\n" +
"\tbx.user_id,\n" +
"\tbx.activity_number,\n" +
"\tsu.username,\n" +
"\tbx.`year`,\n" +
"\tus.unionname \n" +
"FROM\n" +
"\t`jf_use` ju\n" +
"\tLEFT JOIN jf_yjgh jf ON ju.adjust_id = jf.id\n" +
"\tLEFT JOIN sys_user su ON su.id = ju.adjust_person\n" +
"\tLEFT JOIN activity_bx bx ON bx.id = ju.apply_id\n" +
"\tLEFT JOIN `user` us ON us.id = bx.user_id $condition");
Cnd cnd = Cnd.NEW();
if (Strings.isNotBlank(pageOrderBy) && Strings.isNotBlank(pageOrderName)) {
cnd.orderBy(pageOrderName, PageUtil.getOrder(pageOrderBy));
@@ -100,6 +101,7 @@ public class jsTzController {
}
@At
public Object delUse(String id, boolean isClub) {
try {
@@ -125,15 +127,15 @@ public class jsTzController {
private void flushMoney(String id, boolean isClub) {
Sql sql = Sqls.create("SELECT IFNULL(SUM(u.adjust_money),0) money from jf_use u WHERE u.adjust_id = @id").setParam("id", id);
Double money = jfUseService.list(sql).get(0).getDouble("money");
String money = jfUseService.list(sql).get(0).getString("money");
if (!isClub) {
jf_yjgh yjgh = jfYjghService.fetch(id);
yjgh.setUsedQuota(money);
yjgh.setUsedQuota(new BigDecimal(money));
jfYjghService.update(yjgh);
} else {
jf_club club = jfClubService.fetch(id);
club.setUsed_quota(money);
club.setUsedQuota(new BigDecimal(money));
jfClubService.update(club);
}
@@ -1,13 +1,13 @@
package io.v.nutz.zhgh.jf.controller.school;
import io.v.nutz.base.annontation.ViReturn;
import io.v.nutz.base.query.PageForm;
import io.v.nutz.base.service.BaseService;
import io.v.nutz.base.utils.DateUtil;
import io.v.nutz.zhgh.jf.model.CostsSet;
import io.v.nutz.zhgh.activityBudget.models.ActivityBudget;
import io.v.nutz.zhgh.jf.model.jf_school;
import io.v.nutz.base.query.PageForm;
import org.apache.shiro.authz.annotation.RequiresAuthentication;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.nutz.dao.Chain;
import org.nutz.dao.Cnd;
import org.nutz.dao.Sqls;
import org.nutz.dao.sql.Sql;
@@ -15,7 +15,10 @@ import org.nutz.ioc.loader.annotation.Inject;
import org.nutz.ioc.loader.annotation.IocBean;
import org.nutz.mvc.annotation.At;
import org.nutz.mvc.annotation.Ok;
import org.nutz.mvc.annotation.Param;
import java.math.BigDecimal;
import java.util.List;
import java.util.Objects;
/**
* TODO
@@ -43,8 +46,9 @@ public class schoolBudgetController {
@At
@ViReturn
@RequiresAuthentication
@RequiresPermissions("sys.jf.school.schoolBudgetList")
public Object pageData(PageForm pageForm, @Param(value = "year",required = false) Integer year) {
public Object pageData(PageForm pageForm, Integer year) {
Cnd cnd = Cnd.NEW();
Sql sql = Sqls.create("""
SELECT * FROM `jf_school` $condition
@@ -55,14 +59,52 @@ public class schoolBudgetController {
}
// 重置本年
@At
@ViReturn
@RequiresPermissions("sys.jf.school.schoolBudgetList")
public Object doChangeYs(Double totalQuota2, String id) {
public Object reset() {
baseService.dao().clear(jf_school.class,Cnd.where("year", "=", DateUtil.getYear()));
return null;
}
@At
@ViReturn
@RequiresPermissions("sys.jf.school.schoolBudgetList")
public Object isSet() {
return baseService.dao().count(jf_school.class, Cnd.where("state", "=", 1).and("year", "=", DateUtil.getYear()));
}
@At
@ViReturn
@RequiresAuthentication
@RequiresPermissions("sys.jf.school.schoolBudgetList")
public Object doChangeYs(String totalQuota, String id) {
jf_school jf_school = baseService.dao().fetch(jf_school.class, id);
jf_school.setTotalQuota(totalQuota2);
jf_school.setTotalQuota(new BigDecimal(totalQuota));
baseService.updateIgnoreNull(jf_school);
baseService.dao().update(CostsSet.class, Chain.make("schoolMoney", totalQuota2), Cnd.where("year", "=", DateUtil.getYear()));
return null;
}
@At
@ViReturn
@RequiresPermissions("sys.jf.school.schoolBudgetList")
public Object issue() {
List<ActivityBudget> budgetList = baseService.dao().query(ActivityBudget.class,
Cnd.where("YEAR(applyDate)", "=", DateUtil.getYear())
.and("auditState", "=", 4)
.and("budgetTypeCode", "=", "ACTIVITY_BUDGET_TYPE_ONE"));
BigDecimal totalBudgetMoney = budgetList.stream()
.map(ActivityBudget::getTotalBudgetMoney) // 提取 money 属性
.filter(Objects::nonNull) // 过滤掉空值
.reduce(BigDecimal.ZERO, BigDecimal::add);
jf_school school = new jf_school();
school.setState(1);
school.setYear(DateUtil.getYear());
school.setTotalQuota(totalBudgetMoney);
baseService.insert(school);
return null;
}
@@ -1,18 +1,27 @@
package io.v.nutz.zhgh.jf.controller.school;
import cn.hutool.core.util.StrUtil;
import cn.wizzer.framework.base.service.BaseService;
import io.v.nutz.base.annontation.ViReturn;
import io.v.nutz.base.query.PageForm;
import io.v.nutz.zhgh.jf.model.jf_school;
import io.v.nutz.zhgh.reimbursement.constants.ReimbursementState;
import io.v.nutz.zhgh.reimbursement.models.ReimbursementNew;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.nutz.dao.Cnd;
import org.nutz.dao.Sqls;
import org.nutz.dao.sql.Sql;
import org.nutz.ioc.loader.annotation.Inject;
import org.nutz.ioc.loader.annotation.IocBean;
import org.nutz.lang.Lang;
import org.nutz.lang.Strings;
import org.nutz.mvc.annotation.At;
import org.nutz.mvc.annotation.Ok;
import org.nutz.mvc.annotation.Param;
import java.math.BigDecimal;
import java.util.List;
import java.util.Map;
import java.util.Objects;
/**
* TODO
@@ -39,9 +48,7 @@ public class schoolBudgetUseController {
@At
@ViReturn
@RequiresPermissions("sys.jf.school.schoolBudgetUseList")
public Object pageData(PageForm page,
@Param(value = "year", required = false) Integer year,
@Param(value = "activity_name", required = false) String activity_name) {
public Object pageData(PageForm page, Integer year, String activity_name) {
Cnd cnd = Cnd.NEW();
Sql sql = Sqls.create("""
SELECT
@@ -62,4 +69,23 @@ public class schoolBudgetUseController {
return baseService.listPageMap(page.getPageNumber(), page.getPageSize(), sql);
}
@At
@ViReturn
@RequiresPermissions("sys.jf.school.schoolBudgetUseList")
public Object findInitData(Integer year, String activity_name) {
jf_school school = baseService.dao().fetch(jf_school.class, Cnd.where("year", "=", year));
if (StrUtil.isEmpty(activity_name)) {
return Map.of("totalMoney", 0, "totalQuota", Lang.isNotEmpty(school) ? school.getTotalQuota() : 0, "usedQuota", Lang.isNotEmpty(school) ? school.getUsedQuota() : 0);
}
Cnd cnd = Cnd.NEW();
cnd.and("State", "=", ReimbursementState.SUCCESSFUL_REIMBURSEMENT);
cnd.where().andLike("activity_name", activity_name);
List<ReimbursementNew> newList = baseService.dao().query(ReimbursementNew.class, cnd);
BigDecimal totalMoney = newList.stream()
.map(ReimbursementNew::getMoney)
.filter(Objects::nonNull) // 避免 null 值导致计算错误
.reduce(BigDecimal.ZERO, BigDecimal::add);
return Map.of("totalMoney", totalMoney, "totalQuota", school.getTotalQuota(), "usedQuota", school.getUsedQuota());
}
}
@@ -1,31 +1,36 @@
package io.v.nutz.zhgh.jf.controller.yjgh;
import cn.afterturn.easypoi.entity.BaseTypeConstants;
import cn.afterturn.easypoi.excel.ExcelExportUtil;
import cn.afterturn.easypoi.excel.entity.ExportParams;
import cn.afterturn.easypoi.excel.entity.enmus.ExcelType;
import cn.afterturn.easypoi.excel.entity.params.ExcelExportEntity;
import cn.wizzer.framework.base.Result;
import cn.wizzer.framework.page.Pagination;
import io.v.nutz.base.utils.ExcelUtil;
import io.v.nutz.base.annontation.ViReturn;
import io.v.nutz.base.utils.PageUtil;
import io.v.nutz.base.utils.Roles;
import io.v.nutz.base.utils.Vi;
import io.v.nutz.web.commons.utils.ShiroUtil;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import io.v.nutz.zhgh.jf.service.jfYjghService;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.shiro.authz.annotation.RequiresAuthentication;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.nutz.dao.Chain;
import org.nutz.dao.Cnd;
import org.nutz.dao.Sqls;
import org.nutz.dao.entity.Record;
import org.nutz.dao.sql.Sql;
import org.nutz.ioc.loader.annotation.Inject;
import org.nutz.ioc.loader.annotation.IocBean;
import org.nutz.lang.Strings;
import org.nutz.lang.util.NutMap;
import org.nutz.log.Log;
import org.nutz.log.Logs;
import org.nutz.mvc.annotation.At;
import org.nutz.mvc.annotation.Ok;
import org.nutz.mvc.annotation.Param;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.OutputStream;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.List;
/**
@@ -36,6 +41,7 @@ import java.util.List;
@IocBean
@At("/platform/jf/yjgh/jfsy")
@Ok("json:full")
@RequiresAuthentication
public class jfsyController {
@@ -43,7 +49,7 @@ public class jfsyController {
@Inject
private io.v.nutz.zhgh.jf.service.jfYjghService jfYjghService;
private jfYjghService jfYjghService;
@At("")
@@ -55,40 +61,35 @@ public class jfsyController {
@At
@RequiresPermissions("sys.jf.gh.tz")
public Object data(int pageNumber, int pageSize,
@Param(value = "year",required = false) Integer year,
@Param(value = "pageOrderName",required = false) String pageOrderName,
@Param(value = "pageOrderBy",required = false) String pageOrderBy,
@Param(value = "unionId",required = false) String unionId) {
public Object data(int pageNumber, int pageSize, Integer year, String pageOrderName, String pageOrderBy, String unionId) {
try {
Sql sql = Sqls.create("""
SELECT
jf.*,
yjgh.id unid,
yjgh.unionname,
yjgh.unioncode
jf.*,
un.unioncode,
it.unitcode unitCode
FROM
`sys_union` yjgh
LEFT JOIN jf_yjgh jf ON jf.unionId = yjgh.id
AND jf.`year` = @year
jf_yjgh jf
LEFT JOIN sys_union un ON un.id = jf.unionid
LEFT JOIN sys_unit it ON it.unitcode = jf.unionid
$condition
""");
Cnd cnd = Cnd.NEW();
if (ShiroUtil.hasRole("sysadmin") || ShiroUtil.hasRole("A06")) {
cnd.andEX("yjgh.id", "=", unionId);
} else if (ShiroUtil.hasRole("H04")) {
cnd.andEX("jf.unionId", "=", unionId);
} else if (ShiroUtil.hasAnyRoles("gh14,gh01")) {
//基层工会管理员
cnd.and("yjgh.id", "in", "(SELECT sur.`unionid` FROM sys_user_role AS sur WHERE sur.`userId`= '" + ShiroUtil.getPrincipalProperty("id") + "' AND sur.`roleId`= '" + Roles.UNION_MANGER + "')");
cnd.and("jf.unionId", "=", Vi.getUnionId());
}
cnd.and("jf.totalQuota", "IS NOT", null);
cnd.and("jf.year", "=", year);
if (Strings.isNotBlank(pageOrderBy) && Strings.isNotBlank(pageOrderName)) {
cnd.orderBy(pageOrderName, PageUtil.getOrder(pageOrderBy));
} else {
cnd.asc("yjgh.unionname");
cnd.asc("un.unioncode");
}
sql.setParam("year", year);
sql.setCondition(cnd);
Pagination listPage = jfYjghService.listPage(pageNumber, pageSize, sql);
Pagination listPage = jfYjghService.listPageMap(pageNumber, pageSize, sql);
return Result.success().addData(listPage);
} catch (Exception e) {
return Result.error();
@@ -111,10 +112,60 @@ public class jfsyController {
// 导出
@At
@Ok("void")
@RequiresPermissions("sys.jf.gh.tz")
public void exportExcel(HttpServletResponse response, Integer year) {
Sql sql = Sqls.create("SELECT jf.*, yjgh.id unid, yjgh.unionname \n" +
Sql sql = Sqls.create("""
SELECT
jf.*,
un.unioncode,
it.unitcode unitCode
FROM
jf_yjgh jf
LEFT JOIN sys_union un ON un.id = jf.unionid
LEFT JOIN sys_unit it ON it.unitcode = jf.unionid
$condition
""");
Cnd cnd = Cnd.NEW();
if (!ShiroUtil.hasRole("sysadmin") || ShiroUtil.hasRole("A06")) {
if (ShiroUtil.hasAnyRoles("gh14,gh01")) {
//基层工会管理员
cnd.and("jf.unionId", "=", Vi.getUnionId());
}
}
cnd.and("jf.totalQuota", "IS NOT", null);
cnd.and("jf.year", "=", year);
cnd.asc("un.unioncode");
sql.setCondition(cnd);
List<NutMap> list = jfYjghService.listMap(sql);
list.forEach(l->{
l.put("shenyu",l.getDouble("totalQuota")-l.getDouble("usedQuota"));
});
try {
List<ExcelExportEntity> exportEntities = new ArrayList<>();
exportEntities.add(new ExcelExportEntity("年度", "year", 10));
exportEntities.add(new ExcelExportEntity("院级工会名称", "unionName", 20));
ExcelExportEntity totalQuota = new ExcelExportEntity("分配总额度(元)", "totalQuota", 20);
totalQuota.setType(BaseTypeConstants.DOUBLE_TYPE);
exportEntities.add(totalQuota);
ExcelExportEntity usedQuota = new ExcelExportEntity("已使用额度(元)", "usedQuota", 20);
usedQuota.setType(BaseTypeConstants.DOUBLE_TYPE);
exportEntities.add(usedQuota);
ExcelExportEntity shenyu = new ExcelExportEntity("剩余额度(元)", "shenyu", 20);
shenyu.setType(BaseTypeConstants.DOUBLE_TYPE);
exportEntities.add(shenyu);
response.setContentType("application/octet-stream");
response.setHeader("Content-Disposition", "attachment;filename=" + new String((year+"年院级工会经费使用情况表.xlsx").getBytes(StandardCharsets.UTF_8), StandardCharsets.ISO_8859_1));
ExportParams exportParams = new ExportParams();
exportParams.setType(ExcelType.XSSF);
Workbook workbook = ExcelExportUtil.exportExcel(exportParams, exportEntities, list);
workbook.write(response.getOutputStream());
}catch (Exception e){
}
/* Sql sql = Sqls.create("SELECT jf.*, yjgh.id unid, yjgh.unionname \n" +
"FROM `sys_union` yjgh\n" +
"LEFT JOIN jf_yjgh jf \n" +
"ON jf.unionId = yjgh.id \n" +
@@ -131,6 +182,7 @@ public class jfsyController {
sql.setCondition(cnd);
List<Record> list = jfYjghService.list(sql);
//excel标题
String[] title = {"年度", "院级工会名称", "分配总额度(元)", "已使用额度(元)", "剩余额度(元)"};
//excel文件名
@@ -139,13 +191,13 @@ public class jfsyController {
String sheetName = year + "年院级工会经费使用情况表";
String[][] content = new String[list.size()][title.length];
for (int i = 0; i < list.size(); i++) {
Double zed = list.get(i).getDouble("totalquota");
// int ysyed = Strings.isBlank(list.get(i).getString("usedquota")) ? 0 : Integer.parseInt(list.get(i).getString("usedquota"));
Float zed = Strings.isBlank(list.get(i).getString("totalQuota")) ? 0 : Float.parseFloat(list.get(i).getString("totalQuota"));
Float ysyed = Strings.isBlank(list.get(i).getString("usedQuota")) ? 0 : Float.parseFloat(list.get(i).getString("usedQuota"));
content[i][0] = list.get(i).getString("year");
content[i][1] = list.get(i).getString("unionname");
content[i][2] = String.valueOf(zed);
content[i][3] = String.valueOf(list.get(i).getDouble("usedquota"));
content[i][4] = String.valueOf(zed - list.get(i).getDouble("usedquota"));
content[i][3] = String.valueOf(ysyed);
content[i][4] = String.format("%.2f", zed - ysyed);
}
HSSFWorkbook wb = ExcelUtil.getHSSFWorkbook(sheetName, title, content, null);
try {
@@ -157,7 +209,27 @@ public class jfsyController {
os.close();
} catch (IOException e) {
e.printStackTrace();
}
}*/
}
@At
@ViReturn
public Object getJfUnion(Integer year) {
Sql sql = Sqls.create("""
SELECT
yj.*,
un.unioncode,
it.unitcode unitCode
FROM
jf_yjgh yj
LEFT JOIN sys_union un ON un.id = yj.unionid
LEFT JOIN sys_unit it ON it.unitcode = yj.unionid
WHERE yj.year=@year
ORDER BY
un.unioncode
""").setParam("year", year);
return jfYjghService.listMap(sql);
}
@@ -3,30 +3,32 @@ package io.v.nutz.zhgh.jf.controller.yjgh;
import cn.wizzer.framework.base.Result;
import io.v.nutz.base.annontation.ViReturn;
import io.v.nutz.base.page.Pagination;
import io.v.nutz.base.service.AsyncService;
import io.v.nutz.base.service.BaseService;
import io.v.nutz.base.utils.DateUtil;
import io.v.nutz.zhgh.jf.model.CostsSet;
import io.v.nutz.sys.models.Sys_union;
import io.v.nutz.sys.models.Sys_unit;
import io.v.nutz.web.commons.utils.ShiroUtil;
import io.v.nutz.zhgh.activityBudget.models.ActivityBudget;
import io.v.nutz.zhgh.jf.model.jf_yjgh;
import io.v.nutz.zhgh.jf.service.CostsSetService;
import io.v.nutz.zhgh.jf.service.jfYjghService;
import io.v.nutz.base.service.AsyncService;
import org.apache.shiro.authz.annotation.RequiresAuthentication;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.nutz.aop.interceptor.ioc.TransAop;
import org.nutz.dao.Chain;
import org.nutz.dao.Cnd;
import org.nutz.dao.Sqls;
import org.nutz.dao.entity.Record;
import org.nutz.dao.sql.Sql;
import org.nutz.ioc.aop.Aop;
import org.nutz.ioc.loader.annotation.Inject;
import org.nutz.ioc.loader.annotation.IocBean;
import org.nutz.lang.Strings;
import org.nutz.mvc.annotation.At;
import org.nutz.mvc.annotation.Ok;
import org.nutz.mvc.annotation.Param;
import javax.validation.Valid;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
/**
* @author zhf
@@ -36,8 +38,10 @@ import java.util.List;
@IocBean
@At("/platform/jf/yjgh/ghys")
@Ok("json:full")
@RequiresAuthentication
public class yjghController {
@Inject
private jfYjghService jfYjghService;
@@ -55,32 +59,13 @@ public class yjghController {
public void index() {
}
// 查询是否已经设置了值 设置值时才会向表中添加工会的记录和现在的年
@At
@ViReturn
@RequiresPermissions("sys.jf.gh.fp")
public Object isSetUnionAvg() {
return jfYjghService.count(Cnd.where("year", "=", DateUtil.getYear()));
}
// 获取最近的一年
@At
@ViReturn
@RequiresPermissions("sys.jf.gh.fp")
public Object lastYear() {
Sql sql = Sqls.create("""
select max(year) year from jf_yjgh where state=1
""");
return jfYjghService.fetch(sql);
}
// 重置本年
@At
@ViReturn
@RequiresPermissions("sys.jf.gh.fp")
public Object reset() {
return jfYjghService.update(Chain.make("state", 0), Cnd.where("year", "=", DateUtil.getYear()).and("state", "=", 1));
jfYjghService.clear(Cnd.where("year", "=", DateUtil.getYear()));
return null;
}
//查询是否已下发
@@ -96,63 +81,42 @@ public class yjghController {
@At
@ViReturn
@RequiresPermissions("sys.jf.gh.fp")
@Aop(TransAop.READ_COMMITTED)
public Object issue() {
Sql sql = Sqls.create("""
SELECT
jf.unionId,
(
SELECT
COUNT( 1 )
FROM
sys_user u
LEFT JOIN sys_unit unit ON u.unitid = unit.id
LEFT JOIN sys_union hu ON hu.id = unit.unionid
WHERE
u.member = '1'
AND hu.id = un.id
) hyzs
FROM
sys_union un
LEFT JOIN jf_yjgh jf ON jf.unionId = un.id
AND jf.`year` = @year
""");
List<Sys_union> unionList = baseService.dao().query(Sys_union.class, Cnd.NEW());
List<ActivityBudget> budgetList = baseService.dao().query(ActivityBudget.class,
Cnd.where("YEAR(applyDate)", "=", DateUtil.getYear())
.and("auditState", "=", 4)
.and("isSchoolBudget", "=", false)
.and("budgetTypeCode", "=", "ACTIVITY_BUDGET_TYPE_TWO"));
sql.setParam("year", DateUtil.getYear());
// 经费设置
CostsSet costsSet = costsSetService.fetch(Cnd.where("year", "=", DateUtil.getYear()));
List<Record> list = jfYjghService.list(sql);
asyncService.exe2(list, record -> {
String unionid = (String) record.get("unionid");
Double union_avg = costsSet.getUnion_avg();
int hyzs = record.getInt("hyzs");
jfYjghService.update(Chain.make("totalquota", union_avg * hyzs).add("state", 1).add("history_member", hyzs).add("history_union_avg", union_avg), Cnd.where("year", "=", DateUtil.getYear()).and("state", "<", 1).and("unionid", "=", unionid));
List<jf_yjgh> yjghList = new ArrayList<>();
unionList.forEach(v -> {
BigDecimal totalBudgetMoney = budgetList.stream()
.filter(budget -> budget.getUnionId().equals(v.getId()))
.map(ActivityBudget::getTotalBudgetMoney) // 提取 money 属性
.filter(Objects::nonNull) // 过滤掉空值
.reduce(BigDecimal.ZERO, BigDecimal::add);
jf_yjgh yjgh = new jf_yjgh();
yjgh.setUnionId(v.getId());
yjgh.setUnionName(v.getUnionname());
yjgh.setYear(DateUtil.getYear());
yjgh.setTotalQuota(totalBudgetMoney);
yjgh.setState(1);
yjghList.add(yjgh);
});
baseService.insert(yjghList);
return Result.success();
}
@At
@ViReturn
@RequiresPermissions("sys.jf.gh.fp")
public Object changeYs(@Param(value = "unionId", required = false) String unionId,
@Param(value = "project", required = false) String project,
@Param(value = "year", required = false) Integer year, Double totalQuota) {
public Object changeYs(@Valid String unionId, Integer year, String totalQuota) {
try {
totalQuota = totalQuota == null ? 0 : totalQuota;
jf_yjgh ghys = jfYjghService.fetch(Cnd.where("unionId", "=", unionId).and("year", "=", year));
if (ghys != null) {
ghys.setTotalQuota(totalQuota);
jfYjghService.updateIgnoreNull(ghys);
} else {
ghys = new jf_yjgh();
ghys.setUnionId(unionId);
ghys.setYear(year);
ghys.setTotalQuota(totalQuota);
jfYjghService.insert(ghys);
}
ghys.setTotalQuota(new BigDecimal(totalQuota));
ghys.setState(1);
jfYjghService.updateIgnoreNull(ghys);
return Result.success();
} catch (Exception e) {
return Result.error();
@@ -163,32 +127,35 @@ public class yjghController {
@At
@ViReturn
@RequiresPermissions("sys.jf.gh.fp")
public Object pageData(@Param(value = "pageNumber", required = false) Integer pageNumber,
@Param(value = "pageSize", required = false) Integer pageSize,
@Param(value = "year", required = false) Integer year,
@Param(value = "union_id", required = false) String union_id) {
public Object pageData(Integer pageNumber, Integer pageSize, Integer year, String union_id) {
Sql sql = Sqls.create(
"""
SELECT
jf.*,
un.id unid,
un.unionname,
un.unioncode
FROM
sys_union un
LEFT JOIN jf_yjgh jf ON jf.unionId = un.id
$condition
"""
SELECT
jf.*,
un.unioncode,
it.unitcode unitCode
FROM
jf_yjgh jf
LEFT JOIN sys_union un ON un.id = jf.unionid
LEFT JOIN sys_unit it ON it.unitcode = jf.unionid
$condition
"""
);
Cnd cnd = Cnd.NEW();
if (Strings.isNotBlank(union_id)) {
cnd.and("jf.unionId", "=", union_id);
}
if (!ShiroUtil.hasRole("sysadmin")) {
/*String unionId = Vi.getUnionId();
if (StrUtil.isNotBlank(unionId)) {
cnd.and("jf.unionId", "=", unionId);
}*/
}
cnd.and("jf.year", "=", year);
cnd.and("jf.state", "=", 1);
cnd.asc("un.unioncode");
sql.setCondition(cnd);
Pagination pagination = baseService.listPage(pageNumber, pageSize, sql);
Pagination pagination = baseService.listPageMap(pageNumber, pageSize, sql);
return pagination;
}
@@ -3,7 +3,6 @@ package io.v.nutz.zhgh.jf.model;
import lombok.Data;
import org.nutz.dao.entity.annotation.*;
import org.nutz.dao.interceptor.annotation.PrevInsert;
import org.nutz.integration.json4excel.annotation.J4EIgnore;
/**
* TODO
@@ -5,11 +5,12 @@ import lombok.Data;
import org.nutz.dao.entity.annotation.*;
import java.io.Serializable;
import java.math.BigDecimal;
/**
* @author: Aaron
* @create: 2020-08-18 15:01
* @description: 协会预算管理
* @description: 社团预算管理
**/
@Table("jf_club")
@Data
@@ -26,7 +27,7 @@ public class jf_club implements Serializable {
@Column
@Comment("协会ID")
@Comment("社团ID")
@ColDefine(type = ColType.VARCHAR, width = 32)
private String club_id;
@@ -36,30 +37,29 @@ public class jf_club implements Serializable {
@ColDefine(type = ColType.INT, width = 4)
private Integer year;
@Column
@Comment("协会活动费")
@ColDefine(type = ColType.INT)
private Integer club_activity_cost;
@Column
@Comment("六必访经费")
@ColDefine(type = ColType.INT)
private Integer lbf_cost;
@Excel(name = "总额度")
@Column
@Comment("总额度")
@ColDefine(type = ColType.FLOAT)
private Double total_quota;
@ColDefine(customType = "decimal(10,2)")
private BigDecimal totalQuota;
@Column
@Comment("状态(>=1代表今年已经设置过,<1代表今年未设置,默认值是0)")
@Default("0")
@ColDefine(type = ColType.INT)
private Integer state;
@Column
@Comment("已使用额度")
@Default("0")
@ColDefine(customType = "decimal(10,2)")
private BigDecimal usedQuota;
@Excel(name = "协会人数")
@Column
@Comment("历史会员人数")
@ColDefine(type = ColType.INT)
private Integer history_member;
@Excel(name = "标准")
@Column
@Comment("历史人均额度")
@ColDefine(type = ColType.FLOAT)
@@ -71,27 +71,10 @@ public class jf_club implements Serializable {
private Integer history_y_giveMoney_member;
@Column
@Excel(name = "历史未拨付人数")
@Comment("历史未拨付人数")
@ColDefine(type = ColType.INT)
private Integer history_w_giveMoney_member;
@Excel(name = "协会名称")
@Column
@Comment("历史协会名称")
@ColDefine(type = ColType.VARCHAR, width = 32)
private String history_clubname;
@Column
@Comment("状态(>=1代表今年已经设置过,<1代表今年未设置,默认值是0)")
@Default("0")
@ColDefine(type = ColType.INT)
private Integer state;
@Column
@Comment("已使用额度")
@ColDefine(type = ColType.FLOAT, width = 10, precision = 2,notNull = true)
private Double used_quota;
}
@@ -5,6 +5,8 @@ import lombok.Data;
import org.nutz.dao.entity.annotation.*;
import org.nutz.dao.interceptor.annotation.PrevInsert;
import java.math.BigDecimal;
/**
* TODO
*
@@ -33,14 +35,16 @@ public class jf_school {
@Excel(name = "总额度")
@Column
@Comment("总额度")
@ColDefine(type = ColType.FLOAT, width = 10, precision = 2)
private Double totalQuota;
@Default("0")
@ColDefine(customType = "decimal(10,2)")
private BigDecimal totalQuota;
@Column
@Comment("已使用额度")
@ColDefine(type = ColType.FLOAT, width = 10, precision = 2, notNull = true)
private Double usedQuota;
@Default("0")
@ColDefine(customType = "decimal(10,2)")
private BigDecimal usedQuota;
@Column
@@ -50,4 +54,5 @@ public class jf_school {
private Integer state;
}
@@ -5,6 +5,7 @@ import lombok.Data;
import org.nutz.dao.entity.annotation.*;
import java.io.Serializable;
import java.math.BigDecimal;
/**
* @author: Aaron
@@ -34,15 +35,15 @@ public class jf_use implements Serializable {
@ColDefine(type = ColType.VARCHAR, width = 255)
private String project;
@Column
@Comment("调整金额")
@ColDefine(type = ColType.FLOAT, width = 10, precision = 2)
private Double adjust_money;
@Default("0")
@ColDefine(customType = "decimal(10,2)")
private BigDecimal adjust_money;
@Column
@Comment("调整事由")
@ColDefine(type = ColType.VARCHAR, width = 500)
@ColDefine(type = ColType.VARCHAR, width = 2000)
private String adjust_reason;
@Column
@@ -69,10 +70,4 @@ public class jf_use implements Serializable {
private String activitie_time;
@Column
@Comment("月份")
@ColDefine(type = ColType.INT, width = 2)
private Integer month;
}
@@ -5,6 +5,7 @@ import lombok.Data;
import org.nutz.dao.entity.annotation.*;
import java.io.Serializable;
import java.math.BigDecimal;
/**
* @author: Aaron
@@ -30,6 +31,11 @@ public class jf_yjgh implements Serializable {
@ColDefine(type = ColType.VARCHAR, width = 32)
private String unionId;
@Column
@Comment("院级工会名称")
@ColDefine(type = ColType.VARCHAR, width = 32)
private String unionName;
@Excel(name = "年度")
@Column
@@ -53,12 +59,14 @@ public class jf_yjgh implements Serializable {
@Excel(name = "总额度")
@Column
@Comment("总额度")
@ColDefine(type = ColType.FLOAT, width = 10, precision = 2)
private Double totalQuota;
@ColDefine(customType = "decimal(10,2)")
@Default("0")
private BigDecimal totalQuota;
@Column
@Comment("已使用额度")
@ColDefine(type = ColType.FLOAT, width = 10, precision = 2, notNull = true)
private Double usedQuota;
@ColDefine(customType = "decimal(10,2)")
@Default("0")
private BigDecimal usedQuota;
@Column
@Comment("状态(>=1代表今年已经设置过,<1代表今年未设置,默认值是0)")
@Default("0")
@@ -72,8 +80,8 @@ public class jf_yjgh implements Serializable {
@Excel(name = "标准")
@Column
@Comment("历史人均额度")
@ColDefine(type = ColType.FLOAT, width = 10, precision = 2)
private Double history_union_avg;
@ColDefine(type = ColType.FLOAT)
private Float history_union_avg;
@Excel(name = "院级工会名称")
@Column
@Comment("历史院级工会名称")
@@ -1,5 +1,6 @@
package io.v.nutz.zhgh.jf.service.impl;
import cn.hutool.core.util.NumberUtil;
import cn.wizzer.framework.base.service.BaseServiceImpl;
import io.v.nutz.zhgh.jf.model.jf_club;
import io.v.nutz.zhgh.jf.model.jf_use;
@@ -31,11 +32,11 @@ public class jfUseServiceImpl extends BaseServiceImpl<jf_use> implements jfUseSe
if (isClub) {
jf_club jf_club = jfClubService.fetch(jf_use.getAdjust_id()); //根据调整经费id查询
jf_club.setUsed_quota(jf_club.getUsed_quota() + jf_use.getAdjust_money());
jf_club.setUsedQuota(NumberUtil.add(jf_club.getUsedQuota(), jf_use.getAdjust_money()));
update(jf_club);
} else {
jf_yjgh jf_yjgh = jfYjghService.fetch(jf_use.getAdjust_id());
jf_yjgh.setUsedQuota(jf_yjgh.getUsedQuota() + jf_use.getAdjust_money());
jf_yjgh.setUsedQuota(NumberUtil.add(jf_yjgh.getUsedQuota(), jf_use.getAdjust_money()));
update(jf_yjgh);
}
@@ -8,6 +8,10 @@ package io.v.nutz.zhgh.reimbursement.constants;
public interface ReimbursementState {
/**
* 待申请人提交
*/
Integer STAY_SUBMIT = 3030;
/**
* 待申请人修改
*/
@@ -23,6 +27,21 @@ public interface ReimbursementState {
*/
Integer SIGNATURE = 3045;
/**
* 待协会审核
*/
Integer CLUB = 3046;
/**
* 协会不通过
*/
Integer CLUB_FAIL = 3047;
/**
* 协会退回
*/
Integer CLUB_GO_BACK = 3048;
/**
* 待分工会审核
*/
@@ -32,47 +51,71 @@ public interface ReimbursementState {
* 分工会审核不通过
*/
Integer UNION_FAIL = 3055;
/**
* 单位书记
*/
Integer UNIT_SECRETARY = 3060;
/**
* 单位书记审核不通过
* 分工会审核退回
*/
Integer UNIT_SECRETARY_FAIL = 3065;
Integer UNION_GO_BACK = 3056;
/**
* 待财务审核
* 工会办公室主管
*/
Integer FINANCE = 3070;
Integer UNION_MANAGE = 3060;
/**
* 财务审核不通过
* 工会办公室主管审核不通过
*/
Integer FINANCE_FAIL = 3075;
Integer UNION_MANAGE_FAIL = 3065;
/**
* 待分管副主席审核
* 工会办公室主管退回
*/
Integer VICE_CHAIRMAN = 3080;
Integer UNION_MANAGE_GO_BACK = 3066;
/**
* 分管副主席审核不通过
* 待工会副主席
*/
Integer VICE_CHAIRMAN_FAIL = 3085;
Integer VICE_CHAIRMAN = 3070;
/**
* 待常务副主席审核
* 工会副主席审核不通过
*/
Integer STANDING_VICE_CHAIRMAN = 3090;
Integer VICE_CHAIRMAN_FAIL = 3075;
/**
* 常务副主席审核不通过
* 工会副主席审核退回
*/
Integer STANDING_VICE_CHAIRMAN_FAIL = 3095;
Integer VICE_CHAIRMAN_GO_BACK = 3076;
/**
* 待校工会主席
*/
Integer STANDING_VICE_CHAIRMAN = 3080;
/**
* 校工会主席退回不通过
*/
Integer STANDING_VICE_CHAIRMAN_FAIL = 3085;
/**
* 校工会主席退回
*/
Integer STANDING_VICE_CHAIRMAN_GO_BACK = 3086;
/**
* 待会计审核
*/
Integer FINANCE = 3090;
/**
* 待会计审核
*/
Integer FINANCE_FAIL = 3095;
/**
* 出会计核不通过
*/
Integer FINANCE_GO_BACK = 3096;
/**
* 报销成功
@@ -1,207 +0,0 @@
package io.v.nutz.zhgh.reimbursement.controller;
import io.v.nutz.base.annontation.ViReturn;
import io.v.nutz.base.utils.DateUtil;
import io.v.nutz.base.utils.MsgApi;
import io.v.nutz.base.utils.Vi;
import io.v.nutz.zhgh.jf.service.ActivityBxService;
import io.v.nutz.base.model.Audit;
import io.v.nutz.base.query.PageForm;
import io.v.nutz.zhgh.reimbursement.constants.ReimbursementState;
import io.v.nutz.zhgh.reimbursement.models.ReimbursementNew;
import io.v.nutz.base.service.ViService;
import io.v.nutz.sys.models.Sys_club_user;
import io.v.nutz.web.commons.utils.ShiroUtil;
import io.v.nutz.web.commons.slog.annotation.SLog;
import io.v.nutz.zhgh.jf.model.*;
import io.v.nutz.zhgh.zgfw.service.CondolenceService;
import org.apache.shiro.authz.annotation.RequiresAuthentication;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.nutz.dao.Chain;
import org.nutz.dao.Cnd;
import org.nutz.dao.Sqls;
import org.nutz.dao.sql.Sql;
import org.nutz.ioc.loader.annotation.Inject;
import org.nutz.ioc.loader.annotation.IocBean;
import org.nutz.lang.Strings;
import org.nutz.mvc.annotation.At;
import org.nutz.mvc.annotation.Ok;
import org.nutz.mvc.annotation.Param;
import org.nutz.trans.Trans;
/**
* @author zhf
* @date 2021/10/15 10:47
* @description
*/
@At("/reimbursement/audit/confirm")
@Ok("json:full")
@IocBean
@RequiresAuthentication
public class AuditConfirmController {
@Inject("ReimbursementNew")
private ViService<ReimbursementNew> reimbursementNewViService;
@Inject
private ActivityBxService activityBxService;
@Inject
private CondolenceService condolenceService;
@Inject
private MsgApi msgApi;
@At("")
@Ok("beetl:/platform/reimbursement/AuditConfirm.html")
@RequiresPermissions("reimbursement.audit.confirm")
public void index() {
}
@At
@ViReturn
@RequiresPermissions("reimbursement.audit.confirm")
public Object pageData(PageForm page,
@Param(value = "isAudit", required = false) Boolean isAudit,
@Param(value = "year", required = false) Integer year,
@Param(value = "unitId", required = false) String unitId,
@Param(value = "unionId", required = false) String unionId,
@Param(value = "reiItemId", required = false) String reiItemId) {
Cnd cnd = Cnd.NEW();
Sql sql = Sqls.create("""
SELECT
rei.*,
be.username be_username,
state.stateName,
state.stateColor
FROM
`reimbursement_new` rei
LEFT JOIN sys_user be ON be.id = rei.be_user
LEFT JOIN audit_state state ON state.stateId = rei.state
$condition
""");
cnd.andEX("YEAR ( rei.applyTime )", "=", year);
cnd.andEX("rei.unitId", "=", unitId);
cnd.andEX("rei.unionId", "=", unionId);
if (Strings.isNotBlank(reiItemId) && reiItemId.equals("ww")) {
cnd.and("rei.reimbursementItemId", "in", "'fyww','zfww'");
} else {
cnd.andEX("rei.reimbursementItemId", "=", reiItemId);
}
if (isAudit != null) {
cnd.and("rei.State", isAudit ? ">" : "=", ReimbursementState.AUDIT_CONFIRM);
}
if (Vi.isNotBlank(page.getSearchName(), page.getSearchKeyword())) {
cnd.where().andLike(page.getSearchName(), page.getSearchKeyword());
}
cnd.desc("rei.applyTime");
sql.setCondition(cnd);
return reimbursementNewViService.listPageMap(page.getPageNumber(), page.getPageSize(), sql);
}
@At
@ViReturn
@RequiresPermissions("reimbursement.audit.confirm")
@SLog(tag = "工会报销", msg = "审核了一条记录", param = true, result = true)
public Object doSubmit(String id, int flag, Audit audit) {
ReimbursementNew reimbursementNew = reimbursementNewViService.fetch(id);
audit.setAuditor(io.v.nutz.web.commons.utils.ShiroUtil.getPrincipalProperty("id").toString());
audit.setLoginname(ShiroUtil.getPrincipalProperty("loginname").toString());
audit = reimbursementNewViService.insert(audit);
String content = flag == 3 ? "您的报销已审核完毕,请前往智慧工会工会报销系统中的我的报销导出" : flag == 2 ? ("您的报销已被退回," + audit.getAuditOpinion() + "请前往智慧工会查看") : ("您的报销已被拒绝," + audit.getAuditOpinion() + "请前往智慧工会查看");
Audit finalAudit = audit;
Trans.exec(() -> {
reimbursementNewViService.update(Chain.make("State", flag == 3 ? ReimbursementState.SUCCESSFUL_REIMBURSEMENT : flag == 2 ? ReimbursementState.MODIFY : ReimbursementState.FINANCE_FAIL).add("accountingAuditId", finalAudit.getId()), Cnd.where("id", "=", id));
if (flag == 3) {
if (reimbursementNew.getJf_source().equals("1")) {
jf_school jfSchool = reimbursementNewViService.dao().fetch(jf_school.class, Cnd.where("year", "=", DateUtil.getYear()).and("state", "=", 1));
SchoolUse schoolUse = new SchoolUse();
schoolUse.setReimbursementId(reimbursementNew.getId());
reimbursementNewViService.insert(schoolUse);
//往预算分配表减钱
jfSchool.setUsedQuota(jfSchool.getUsedQuota() + reimbursementNew.getMoney());
reimbursementNewViService.updateIgnoreNull(jfSchool);
} else if (reimbursementNew.getJf_source().equals("2")) {
jf_yjgh yjgh = reimbursementNewViService.dao().fetch(jf_yjgh.class, Cnd.where("unionId", "=", reimbursementNew.getUnionId()).and("year", "=", DateUtil.getYear()).and("state", "=", 1));
//往经费使用表中添加一条数据
jf_use jf_use = new jf_use();
jf_use.setAdjust_id(yjgh.getId());
jf_use.setProject(reimbursementNew.getReimbursementItemName());
jf_use.setAdjust_money(reimbursementNew.getMoney());
jf_use.setAdjust_reason(reimbursementNew.getCause());
jf_use.setAdjust_time(DateUtil.getDateTime());
jf_use.setAdjust_person(ShiroUtil.getUserId());
jf_use.setApply_id(reimbursementNew.getId());
jf_use.setActivitie_number(reimbursementNew.getActivity_number());
jf_use.setActivitie_time(Strings.isNotBlank(reimbursementNew.getActivity_time()) ? reimbursementNew.getActivity_time() : reimbursementNew.getOccur_time());
reimbursementNewViService.insert(jf_use);
//往预算分配表减钱
yjgh.setUsedQuota((yjgh.getUsedQuota() != null ? yjgh.getUsedQuota() : 0) + reimbursementNew.getMoney());
reimbursementNewViService.updateIgnoreNull(yjgh);
} else {
Sys_club_user clubUser = reimbursementNewViService.dao().fetch(Sys_club_user.class, Cnd.where("userid", "=", reimbursementNew.getUserId()));
jf_club jf_club = reimbursementNewViService.dao().fetch(jf_club.class, Cnd.where("year", "=", DateUtil.getYear()).and("state", "=", 1).and("club_id", "=", clubUser.getClubid()));
//往经费使用表中添加一条数据
jf_use jf_use = new jf_use();
jf_use.setAdjust_id(jf_club.getId());
jf_use.setProject(reimbursementNew.getReimbursementItemName());
jf_use.setAdjust_money(reimbursementNew.getMoney());
jf_use.setAdjust_reason(reimbursementNew.getCause());
jf_use.setAdjust_time(DateUtil.getDateTime());
jf_use.setAdjust_person(ShiroUtil.getUserId());
jf_use.setApply_id(reimbursementNew.getId());
jf_use.setActivitie_number(reimbursementNew.getActivity_number());
jf_use.setActivitie_time(Strings.isNotBlank(reimbursementNew.getActivity_time()) ? reimbursementNew.getActivity_time() : reimbursementNew.getOccur_time());
reimbursementNewViService.insert(jf_use);
//往预算分配表减钱
jf_club.setUsed_quota(jf_club.getUsed_quota() + reimbursementNew.getMoney());
reimbursementNewViService.updateIgnoreNull(jf_club);
}
}
//msgApi.sendWxMsg(content, reimbursementNew.getLoginName());
});
return null;
}
@At
@ViReturn
@RequiresPermissions("reimbursement.audit.confirm")
@SLog(tag = "工会报销", msg = "撤回了一条记录", param = true, result = true)
public Object doRecall(String id) {
Trans.exec(() -> {
ReimbursementNew reimbursementNew = reimbursementNewViService.fetch(id);
reimbursementNew.setState(ReimbursementState.AUDIT_CONFIRM);
reimbursementNew.setAccountingAuditId(null);
reimbursementNewViService.update(reimbursementNew);
if (reimbursementNew.getJf_source().equals("1")) {
jf_school jfSchool = reimbursementNewViService.dao().fetch(jf_school.class, Cnd.where("year", "=", DateUtil.getYear()).and("state", "=", 1));
jfSchool.setUsedQuota((jfSchool.getUsedQuota() != null ? jfSchool.getUsedQuota() : 0) - reimbursementNew.getMoney());
reimbursementNewViService.updateIgnoreNull(jfSchool);
reimbursementNewViService.dao().clear(SchoolUse.class, Cnd.where("reimbursementId", "=", reimbursementNew.getId()));
} else if (reimbursementNew.getJf_source().equals("2")) {
jf_yjgh yjgh = reimbursementNewViService.dao().fetch(jf_yjgh.class, Cnd.where("unionId", "=", reimbursementNew.getUnionId()).and("year", "=", DateUtil.getYear()).and("state", "=", 1));
yjgh.setUsedQuota(yjgh.getUsedQuota() - reimbursementNew.getMoney());
reimbursementNewViService.updateIgnoreNull(yjgh);
reimbursementNewViService.dao().clear(jf_use.class, Cnd.where("apply_id", "=", reimbursementNew.getId()));
} else {
Sys_club_user clubUser = reimbursementNewViService.dao().fetch(Sys_club_user.class, Cnd.where("userid", "=", reimbursementNew.getUserId()));
jf_club jf_club = reimbursementNewViService.dao().fetch(jf_club.class, Cnd.where("year", "=", DateUtil.getYear()).and("state", "=", 1).and("club_id", "=", clubUser.getClubid()));
jf_club.setUsed_quota(jf_club.getUsed_quota() - reimbursementNew.getMoney());
reimbursementNewViService.updateIgnoreNull(jf_club);
reimbursementNewViService.dao().clear(jf_use.class, Cnd.where("apply_id", "=", reimbursementNew.getId()));
}
});
return null;
}
}
@@ -1,160 +0,0 @@
package io.v.nutz.zhgh.reimbursement.controller;
import io.v.nutz.base.annontation.ViReturn;
import io.v.nutz.base.model.Review;
import io.v.nutz.base.service.ReviewService;
import io.v.nutz.base.utils.DateUtil;
import io.v.nutz.base.utils.Vi;
import io.v.nutz.base.dao.CndPlus;
import io.v.nutz.zhgh.jf.model.ActivityBx;
import io.v.nutz.zhgh.jf.service.ActivityBxService;
import io.v.nutz.base.model.Audit;
import io.v.nutz.base.query.PageForm;
import io.v.nutz.base.service.AuditService;
import io.v.nutz.zhgh.reimbursement.constants.ReimbursementState;
import io.v.nutz.zhgh.reimbursement.models.Reimbursement;
import io.v.nutz.base.service.ViService;
import io.v.nutz.sys.services.SysSignatureService;
import io.v.nutz.web.commons.utils.ShiroUtil;
import io.v.nutz.zhgh.zgfw.model.condolence.Condolence;
import io.v.nutz.zhgh.zgfw.service.CondolenceService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.nutz.dao.Cnd;
import org.nutz.dao.Sqls;
import org.nutz.dao.sql.Sql;
import org.nutz.ioc.loader.annotation.Inject;
import org.nutz.ioc.loader.annotation.IocBean;
import org.nutz.mvc.annotation.At;
import org.nutz.mvc.annotation.Ok;
import org.nutz.mvc.annotation.Param;
import java.util.Date;
@At("/platform/reimbursement/dma")
@IocBean
@Ok("json")
public class DmaController {
@Inject("Reimbursement")
private ViService<Reimbursement> reimbursementViService;
@Inject
private ActivityBxService activityBxService;
@Inject
private SysSignatureService sysSignatureService;
@Inject
private AuditService auditService;
@Inject
private ReviewService reviewService;
@Inject
private CondolenceService condolenceService;
@At("")
@Ok("beetl:/platform/reimbursement/dma.html")
@RequiresPermissions("rei.dma")
public void index() {
}
@At
@ViReturn
@RequiresPermissions("rei.dma")
public Object pageData(PageForm page,
@Param(value = "isAudit", required = false) boolean isAudit,
@Param(value = "year", required = false) Integer year,
@Param(value = "unitId", required = false) String unitId,
@Param(value = "unionId", required = false) String unionId,
@Param(value = "reiItemId", required = false) Integer reiItemId) {
Sql sql = Sqls.create("""
SELECT
rei.*,
us.unionname,
us.unioncode,
us.unitcode,
state.stateId,
state.stateColor,
state.stateName,
con_user.username be_username,
bx.activity_name
FROM
`reimbursement` rei
LEFT JOIN `user` us ON us.id = rei.userid
LEFT JOIN audit_state state ON rei.State = state.stateId
LEFT JOIN condolence con ON con.id = rei.reimbursementId
LEFT JOIN activity_bx bx ON rei.reimbursementId = bx.id
LEFT JOIN `user` con_user ON con_user.id=con.be_user
$condition
""");
CndPlus cnd = CndPlus.create();
cnd.and("rei.State", isAudit ? ">" : "=", ReimbursementState.UNION);
Vi.cndPlus(cnd, "rei.reimbursementItemId", "=", reiItemId);
Vi.cndPlus(cnd, "YEAR(rei.applyTime)", "=", year);
Vi.cndPlus(cnd, "us.unitid", "=", unitId);
Vi.cndPlus(cnd, "us.unionid", "=", unionId);
if (!ShiroUtil.hasAnyRoles("sysadmin")) {
cnd.and("us.unionid", "=", Vi.getUnionId());
}
cnd.desc("rei.applyTime");
sql.setCondition(cnd);
return reimbursementViService.listPageMap(page.getPageNumber(), page.getPageSize(), sql);
}
@At
@ViReturn
@RequiresPermissions("rei.dma")
public Object doReview(String id, Boolean flag, double money, Audit audit, Review review, Integer reimbursementItemId) {
double Amount = 2000;
Reimbursement reimbursementId = reimbursementViService.fetch(Cnd.where("reimbursementId", "=", id));
if (reimbursementItemId != 4) {
audit.setLoginname(ShiroUtil.getPrincipalProperty("loginname").toString());
audit.setUsername(ShiroUtil.getPrincipalProperty("username").toString());
audit.setAuditTime(new Date());
audit = auditService.insert(audit);
ActivityBx aid = activityBxService.fetch(id);
aid.setUnion_audit_id(audit.getId());
if (money >= Amount) {
aid.setState_id(flag ? "3060" : "3055");
} else {
aid.setState_id(flag ? "3070" : "3055");
}
activityBxService.updateIgnoreNull(aid);
} else {
review.setLoginname(ShiroUtil.getPrincipalProperty("loginname").toString());
review.setUsername(ShiroUtil.getPrincipalProperty("username").toString());
review.setTime(DateUtil.getDate());
review = reviewService.insert(review);
Condolence condolence = condolenceService.fetch(id);
condolence.setUnion_chairman_review(review.getId());
if (money >= Amount) {
condolence.setState_id(flag ? "3060" : "3055");
} else {
condolence.setState_id(flag ? "3070" : "3055");
}
condolenceService.updateIgnoreNull(condolence);
}
if (money >= Amount) {
reimbursementId.setState(flag ? ReimbursementState.UNIT_SECRETARY : ReimbursementState.UNION_FAIL);
} else {
reimbursementId.setState(flag ? ReimbursementState.FINANCE : ReimbursementState.UNION_FAIL);
}
reimbursementViService.updateIgnoreNull(reimbursementId);
return null;
}
}
@@ -0,0 +1,348 @@
package io.v.nutz.zhgh.reimbursement.controller;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import io.v.nutz.base.annontation.ViReturn;
import io.v.nutz.base.model.Audit;
import io.v.nutz.base.result.Result;
import io.v.nutz.base.utils.DateUtil;
import io.v.nutz.sys.models.Sys_dict;
import io.v.nutz.sys.services.SysDictService;
import io.v.nutz.sys.services.SysLocalProcessService;
import io.v.nutz.web.commons.slog.annotation.SLog;
import io.v.nutz.web.commons.utils.ShiroUtil;
import io.v.nutz.zhgh.activityBudget.models.ActivityBudget;
import io.v.nutz.zhgh.jf.model.*;
import io.v.nutz.zhgh.reimbursement.constants.ReimbursementState;
import io.v.nutz.zhgh.reimbursement.handler.ReimbursementToDoHandler;
import io.v.nutz.zhgh.reimbursement.models.ReimbursementNew;
import io.v.nutz.zhgh.reimbursement.models.ReimbursementPageForm;
import io.v.nutz.zhgh.reimbursement.services.ReimbursementService;
import org.apache.shiro.authz.annotation.RequiresAuthentication;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.nutz.aop.interceptor.ioc.TransAop;
import org.nutz.dao.Chain;
import org.nutz.dao.Cnd;
import org.nutz.dao.Sqls;
import org.nutz.dao.sql.Sql;
import org.nutz.ioc.aop.Aop;
import org.nutz.ioc.loader.annotation.Inject;
import org.nutz.ioc.loader.annotation.IocBean;
import org.nutz.mvc.annotation.At;
import org.nutz.mvc.annotation.Ok;
import org.nutz.mvc.annotation.Param;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
/**
* @author zhf
* @date 2021/6/7 14:23
* @description 校工会会计审核
*/
@At("/platform/reimbursement/financeAudit")
@IocBean
@RequiresAuthentication
@Ok("json")
public class FinanceAuditController {
@Inject
private ReimbursementService reimbursementViService;
@Inject
private SysDictService sysDictService;
@Inject
private SysLocalProcessService localProcessService;
@At("")
@Ok("beetl:/platform/reimbursement/financeAudit.html")
@RequiresPermissions("reimbursement.financeAudit")
public void index() {
}
@At
@ViReturn
@RequiresPermissions("reimbursement.financeAudit")
public Object pageData(ReimbursementPageForm page) {
Sql sql = Sqls.create("""
SELECT
rei.*,
be.username be_username,
state.stateName,
state.stateColor,
cl.`name` clubName
FROM
`reimbursement_new` rei
LEFT JOIN sys_user be ON be.id = rei.be_user
LEFT JOIN audit_state state ON state.stateId = rei.state
LEFT JOIN sys_club cl ON cl.id = rei.clubId
$condition
""");
Cnd cnd = Cnd.NEW();
cnd.andEX("rei.unionId", "=", page.getUnionId());
cnd.andEX("rei.unitId", "=", page.getUnitId());
cnd.andEX("rei.clubId", "=", page.getClubId());
cnd.andEX("rei.jf_source", "=", page.getJf_source());
cnd.andEX("rei.detailsTypeId", "=", page.getDetailsTypeId());
if (page.getIsAudit() != 1) {
cnd.and("rei.State", page.getIsAudit() == 2 ? ">" : "=", ReimbursementState.FINANCE);
} else {
cnd.and("rei.State", ">=", ReimbursementState.FINANCE);
}
if (StrUtil.isAllNotEmpty(page.getSearchName(), page.getSearchKeyword())) {
cnd.where().andLike(page.getSearchName(), page.getSearchKeyword());
}
cnd.andEX("YEAR(rei.applyTime)", "=", page.getYear());
cnd.desc("rei.applyTime");
sql.setCondition(cnd);
return reimbursementViService.listPageMap(page.getPageNumber(), page.getPageSize(), sql);
}
@At
@ViReturn
@Aop(TransAop.READ_COMMITTED)
@SLog(tag = "工会报销", msg = "审核了一条记录", param = true, result = true)
@RequiresPermissions("reimbursement.financeAudit")
public Object doAudit(@Param("id") String id,
@Param("flag") Integer flag,
Audit audit,
String detailsTypeId) {
audit.setLoginname(ShiroUtil.getPlatformLoginname());
audit.setUsername(ShiroUtil.getPlatformUsername());
audit.setAuditTime(new Date());
reimbursementViService.insert(audit);
ReimbursementNew reimbursementNew = reimbursementViService.fetch(id);
ReimbursementToDoHandler.COMPLETE_FINANCE_TASK.exec(reimbursementNew, audit.getAuditOpinion());
Integer auditState;
if (flag == 1) {
auditState = ReimbursementState.FINANCE_FAIL;
ReimbursementToDoHandler.COMPLETE_PROCESS.exec(reimbursementNew, audit.getAuditOpinion());
} else if (flag == 2) {
auditState = ReimbursementState.FINANCE_GO_BACK;
//返回修改
ReimbursementToDoHandler.CREATE_BACK_FINANCE_TASK.exec(reimbursementNew, audit.getAuditOpinion());
} else {
auditState = ReimbursementState.SUCCESSFUL_REIMBURSEMENT;
ReimbursementToDoHandler.COMPLETE_PROCESS.exec(reimbursementNew, audit.getAuditOpinion());
}
Chain chain = Chain.make("financeAuditId", audit.getId())
.add("state", auditState).add("detailsTypeId", detailsTypeId);
reimbursementViService.update(chain, Cnd.where("id", "=", id));
if (flag == 3){
// 更新校工会经费表
if (reimbursementNew.getJf_source().equals("ACTIVITY_BUDGET_TYPE_ONE")) {
jf_school school = reimbursementViService.dao().fetch(jf_school.class, Cnd.where("year", "=", DateUtil.getYear()));
if (ObjectUtil.isEmpty(school)) {
return Result.error("该年份没有设置金额!");
}
school.setUsedQuota(school.getUsedQuota().add(reimbursementNew.getMoney()));
reimbursementViService.updateIgnoreNull(school);
SchoolUse schoolUse = new SchoolUse();
schoolUse.setReimbursementId(reimbursementNew.getId());
reimbursementViService.insert(schoolUse);
} else if (reimbursementNew.getJf_source().equals("ACTIVITY_BUDGET_TYPE_TWO")) {
//如果分工会报销了校工会的余额
ActivityBudget budget = reimbursementViService.dao().fetch(ActivityBudget.class, Cnd.where("id", "=", reimbursementNew.getActivityId()));
if (ObjectUtil.isNotEmpty(budget) && budget.getIsSchoolBudget()){
jf_school school = reimbursementViService.dao().fetch(jf_school.class, Cnd.where("year", "=", DateUtil.getYear()));
if (ObjectUtil.isEmpty(school)) {
return Result.error("该年份没有设置金额!");
}
school.setUsedQuota(school.getUsedQuota().add(reimbursementNew.getMoney()));
reimbursementViService.updateIgnoreNull(school);
SchoolUse schoolUse = new SchoolUse();
schoolUse.setReimbursementId(reimbursementNew.getId());
reimbursementViService.insert(schoolUse);
}else{
// 更新分工会活动经费表
jf_yjgh jfYjgh = reimbursementViService.dao().fetch(jf_yjgh.class, Cnd.where("year", "=", DateUtil.getYear())
.and("unionId", "=", reimbursementNew.getUnionId()));
if (ObjectUtil.isEmpty(jfYjgh)) {
return Result.error("该年份没有设置金额!");
}
if (jfYjgh.getTotalQuota().subtract(jfYjgh.getUsedQuota()).compareTo(reimbursementNew.getMoney()) < 0) {
return Result.error("剩余配额不足!剩余:" + jfYjgh.getTotalQuota().subtract(jfYjgh.getUsedQuota()));
}
BigDecimal decimal = jfYjgh.getUsedQuota().add(reimbursementNew.getMoney());
jfYjgh.setUsedQuota(decimal);
reimbursementViService.updateIgnoreNull(jfYjgh);
jf_use jfUse = new jf_use();
jfUse.setAdjust_id(jfYjgh.getId());
jfUse.setProject(reimbursementNew.getActivity_name());
jfUse.setAdjust_money(reimbursementNew.getMoney());
jfUse.setAdjust_reason(reimbursementNew.getCause());
jfUse.setAdjust_time(DateUtil.getDateTime());
jfUse.setAdjust_person(ShiroUtil.getUserId());
jfUse.setActivitie_number(reimbursementNew.getActivity_number());
jfUse.setActivitie_time(reimbursementNew.getActivity_time());
jfUse.setApply_id(reimbursementNew.getId());
reimbursementViService.insert(jfUse);
}
} else if (reimbursementNew.getJf_source().equals("ACTIVITY_BUDGET_TYPE_THREE")) {
// 更新社团经费表
jf_club jfClub = reimbursementViService.dao().fetch(jf_club.class, Cnd.where("year", "=", DateUtil.getYear())
.and("club_id", "=", reimbursementNew.getClubId()));
if (ObjectUtil.isEmpty(jfClub)) {
return Result.error("该年份没有设置金额!");
}
if (jfClub.getTotalQuota().subtract(jfClub.getUsedQuota()).compareTo(reimbursementNew.getMoney()) < 0) {
return Result.error("剩余配额不足!剩余:" + jfClub.getTotalQuota().subtract(jfClub.getUsedQuota()));
}
jfClub.setUsedQuota(jfClub.getUsedQuota().add(reimbursementNew.getMoney()));
reimbursementViService.updateIgnoreNull(jfClub);
jf_use jfUse = new jf_use();
jfUse.setAdjust_id(jfClub.getId());
jfUse.setProject(reimbursementNew.getActivity_name());
jfUse.setAdjust_money(reimbursementNew.getMoney());
jfUse.setAdjust_reason(reimbursementNew.getCause());
jfUse.setAdjust_time(DateUtil.getDateTime());
jfUse.setAdjust_person(ShiroUtil.getUserId());
jfUse.setActivitie_number(reimbursementNew.getActivity_number());
jfUse.setActivitie_time(reimbursementNew.getActivity_time());
jfUse.setApply_id(reimbursementNew.getId());
reimbursementViService.insert(jfUse);
} else if (reimbursementNew.getJf_source().equals("ACTIVITY_BUDGET_TYPE_FOUR")) {
// 更新其他经费表
/* JfOther jfOther = reimbursementViService.dao().fetch(JfOther.class,
Cnd.where("year", "=", DateUtil.getYear())
.and("clubId","=",fetch.getClubId()));
if (ObjectUtil.isEmpty(jfOther)) {
return Result.error("该年份没有设置金额!");
}
if (jfOther.getTotalQuota().subtract(jfOther.getUsedQuota()).compareTo(fetch.getMoney()) < 0) {
return Result.error("剩余配额不足!剩余:" + jfOther.getTotalQuota().subtract(jfOther.getUsedQuota()));
}
jfOther.setUsedQuota(jfOther.getUsedQuota().add(fetch.getMoney()));
reimbursementViService.updateIgnoreNull(jfOther);
OtherUse otherUse = new OtherUse();
otherUse.setReimbursementId(fetch.getId());
reimbursementViService.insert(otherUse);*/
}
}
return null;
}
@At
@ViReturn
@Aop(TransAop.READ_COMMITTED)
@SLog(tag = "工会报销", msg = "撤回了一条记录", param = true, result = true)
@RequiresPermissions("reimbursement.financeAudit")
public Object doRevoke(@Param("id") String id) {
Chain chain = Chain.make("financeAuditId", null)
.add("detailsTypeId", null)
.add("state", ReimbursementState.FINANCE);
reimbursementViService.update(chain, Cnd.where("id", "=", id));
localProcessService.revokeTask("reimbursement@" + id, "会计审核");
ReimbursementNew fetch = reimbursementViService.fetch(id);
if (fetch.getJf_source().equals("ACTIVITY_BUDGET_TYPE_ONE")) {
jf_school school = reimbursementViService.dao().fetch(jf_school.class, Cnd.where("year", "=", DateUtil.getYear()));
if (ObjectUtil.isEmpty(school)) {
return Result.error("该年份没有设置金额!");
}
school.setUsedQuota(school.getUsedQuota().subtract(fetch.getMoney()));
reimbursementViService.updateIgnoreNull(school);
reimbursementViService.dao().clear(SchoolUse.class, Cnd.where("reimbursementId", "=", id));
} else if (fetch.getJf_source().equals("ACTIVITY_BUDGET_TYPE_TWO")) {
//如果分工会报销了校工会的余额
ActivityBudget budget = reimbursementViService.dao().fetch(ActivityBudget.class, Cnd.where("id", "=", fetch.getActivityId()));
if (ObjectUtil.isNotEmpty(budget) && budget.getIsSchoolBudget()){
jf_school school = reimbursementViService.dao().fetch(jf_school.class, Cnd.where("year", "=", DateUtil.getYear()));
if (ObjectUtil.isEmpty(school)) {
return Result.error("该年份没有设置金额!");
}
school.setUsedQuota(school.getUsedQuota().subtract(fetch.getMoney()));
reimbursementViService.updateIgnoreNull(school);
reimbursementViService.dao().clear(SchoolUse.class, Cnd.where("reimbursementId", "=", id));
}else{
// 更新分工会活动经费表
jf_yjgh jfYjgh= reimbursementViService.dao().fetch(jf_yjgh.class, Cnd.where("year", "=", DateUtil.getYear())
.and("unionId", "=", fetch.getUnionId()));
if (ObjectUtil.isEmpty(jfYjgh)) {
return Result.error("该年份没有设置金额!");
}
jfYjgh.setUsedQuota(jfYjgh.getUsedQuota().subtract(fetch.getMoney()));
reimbursementViService.updateIgnoreNull(jfYjgh);
reimbursementViService.dao().clear(jf_use.class, Cnd.where("apply_id", "=", id));
}
} else if (fetch.getJf_source().equals("ACTIVITY_BUDGET_TYPE_THREE")) {
// 更新社团经费表
jf_club jfClub = reimbursementViService.dao().fetch(jf_club.class, Cnd.where("year", "=", DateUtil.getYear())
.and("club_id", "=", fetch.getClubId()));
if (ObjectUtil.isEmpty(jfClub)) {
return Result.error("该年份没有设置金额!");
}
jfClub.setUsedQuota(jfClub.getUsedQuota().subtract(fetch.getMoney()));
reimbursementViService.updateIgnoreNull(jfClub);
reimbursementViService.dao().clear(jf_use.class, Cnd.where("apply_id", "=", id));
} else if (fetch.getJf_source().equals("ACTIVITY_BUDGET_TYPE_FOUR")) {
// 更新其他经费表
/* JfOther jfOther = reimbursementViService.dao().fetch(JfOther.class, Cnd.where("year", "=", DateUtil.getYear()));
if (ObjectUtil.isEmpty(jfOther)) {
return Result.error("该年份没有设置金额!");
}
jfOther.setUsedQuota(jfOther.getUsedQuota().subtract(fetch.getMoney()));
reimbursementViService.updateIgnoreNull(jfOther);
reimbursementViService.dao().clear(OtherUse.class, Cnd.where("reimbursementId", "=", id));*/
}
return null;
}
@At
@ViReturn
@RequiresPermissions("reimbursement.financeAudit")
public Object getClubsByRole() {
return reimbursementViService.getClubsByRole();
}
@At
@RequiresPermissions("reimbursement.financeAudit")
public Result doSubmitDetailsType(@Param("detailsTypeList") Sys_dict[] detailsTypeList) {
Sys_dict fetch = sysDictService.fetch(Cnd.where("code", "=", "ACTIVITY_BUDGET_DETAILS_TYPE"));
List<Sys_dict> dictList = sysDictService.getSubListByCode("ACTIVITY_BUDGET_DETAILS_TYPE");
if (ObjectUtil.isEmpty(fetch)) {
return Result.error("字典父类不存在!");
}
for (Sys_dict dict : detailsTypeList) {
if (ObjectUtil.isEmpty(dict.getId())) {
sysDictService.save(dict, fetch.getId());
} else {
sysDictService.updateIgnoreNull(dict);
}
}
return Result.success();
}
@At
@ViReturn
@RequiresPermissions("reimbursement.financeAudit")
public Object doDeleteDetailsType(@Param("id") String id) {
Sys_dict dict = sysDictService.fetch(id);
sysDictService.deleteAndChild(dict);
sysDictService.clearCache();
return null;
}
}
@@ -1,141 +0,0 @@
package io.v.nutz.zhgh.reimbursement.controller;
import io.v.nutz.base.annontation.ViReturn;
import io.v.nutz.base.utils.DateUtil;
import io.v.nutz.base.utils.Vi;
import io.v.nutz.base.dao.CndPlus;
import io.v.nutz.zhgh.jf.model.ActivityBx;
import io.v.nutz.zhgh.jf.service.ActivityBxService;
import io.v.nutz.base.model.Audit;
import io.v.nutz.base.query.PageForm;
import io.v.nutz.base.model.Review;
import io.v.nutz.base.service.AuditService;
import io.v.nutz.base.service.ReviewService;
import io.v.nutz.zhgh.reimbursement.constants.ReimbursementState;
import io.v.nutz.zhgh.reimbursement.models.Reimbursement;
import io.v.nutz.base.service.ViService;
import io.v.nutz.sys.services.SysSignatureService;
import io.v.nutz.web.commons.utils.ShiroUtil;
import io.v.nutz.zhgh.zgfw.model.condolence.Condolence;
import io.v.nutz.zhgh.zgfw.service.CondolenceService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.nutz.dao.Cnd;
import org.nutz.dao.Sqls;
import org.nutz.dao.sql.Sql;
import org.nutz.ioc.loader.annotation.Inject;
import org.nutz.ioc.loader.annotation.IocBean;
import org.nutz.mvc.annotation.At;
import org.nutz.mvc.annotation.Ok;
import org.nutz.mvc.annotation.Param;
import java.util.Date;
/**
* @author zhf
* @date 2021/6/7 14:23
* @description 财务审核
*/
@At("/platform/reimbursement/finance")
@IocBean
@Ok("json")
public class FinanceController {
@Inject("Reimbursement")
private ViService<Reimbursement> reimbursementViService;
@Inject
private ActivityBxService activityBxService;
@Inject
private SysSignatureService sysSignatureService;
@Inject
private AuditService auditService;
@Inject
private ReviewService reviewService;
@Inject
private CondolenceService condolenceService;
@At("")
@Ok("beetl:/platform/reimbursement/finance.html")
@RequiresPermissions("reimbursement.finance")
public void index() {
}
@At
@ViReturn
@RequiresPermissions("reimbursement.finance")
public Object pageData(PageForm page,
@Param(value = "isAudit", required = false) boolean isAudit,
@Param(value = "year", required = false) Integer year,
@Param(value = "unitId", required = false) String unitId,
@Param(value = "unionId", required = false) String unionId,
@Param(value = "reiItemId", required = false) Integer reiItemId) {
Sql sql = Sqls.create("""
SELECT
rei.*,
us.unionname,
state.stateColor,
state.stateName,
bx.activity_money,
con.money
FROM
`reimbursement` rei
LEFT JOIN `user` us ON us.id = rei.userid
LEFT JOIN condolence con ON con.id = rei.reimbursementId
LEFT JOIN activity_bx bx ON bx.id = rei.reimbursementId
LEFT JOIN audit_state state ON rei.State = state.stateId $condition
""");
CndPlus cnd = CndPlus.create();
cnd.and("rei.State", isAudit ? ">" : "=", ReimbursementState.FINANCE);
Vi.cndPlus(cnd, "rei.reimbursementItemId", "=", reiItemId);
Vi.cndPlus(cnd, "YEAR(rei.applyTime)", "=", year);
Vi.cndPlus(cnd, "us.unitid", "=", unitId);
Vi.cndPlus(cnd, "us.unionid", "=", unionId);
cnd.desc("rei.applyTime");
sql.setCondition(cnd);
return reimbursementViService.listPageMap(page.getPageNumber(), page.getPageSize(), sql);
}
@At
@ViReturn
@RequiresPermissions("reimbursement.finance")
public Object doReview(String id, Boolean flag, Audit audit, Review review, Integer reimbursementItemId, double money) {
if (reimbursementItemId != 4) {
audit.setLoginname(ShiroUtil.getPrincipalProperty("loginname").toString());
audit.setUsername(ShiroUtil.getPrincipalProperty("username").toString());
audit.setAuditTime(new Date());
audit = auditService.insert(audit);
ActivityBx aid = activityBxService.fetch(id);
aid.setFinance_audit_id(audit.getId());
aid.setState_id(flag ? "3080" : "3075");
aid.setActivity_money(money);
activityBxService.updateIgnoreNull(aid);
} else {
review.setLoginname(ShiroUtil.getPrincipalProperty("loginname").toString());
review.setUsername(ShiroUtil.getPrincipalProperty("username").toString());
review.setTime(DateUtil.getDate());
review = reviewService.insert(review);
Condolence condolence = condolenceService.fetch(id);
condolence.setFinance_review(review.getId());
condolence.setState_id(flag ? "3080" : "3075");
condolence.setMoney(money);
condolenceService.updateIgnoreNull(condolence);
}
Reimbursement reimbursement = reimbursementViService.fetch(Cnd.where("reimbursementId", "=", id));
reimbursement.setState(flag ? ReimbursementState.VICE_CHAIRMAN : ReimbursementState.FINANCE_FAIL);
reimbursementViService.updateIgnoreNull(reimbursement);
return null;
}
}
@@ -1,145 +0,0 @@
package io.v.nutz.zhgh.reimbursement.controller;
import io.v.nutz.base.annontation.ViReturn;
import io.v.nutz.base.utils.DateUtil;
import io.v.nutz.base.utils.Vi;
import io.v.nutz.base.dao.CndPlus;
import io.v.nutz.zhgh.jf.model.ActivityBx;
import io.v.nutz.zhgh.jf.service.ActivityBxService;
import io.v.nutz.base.model.Audit;
import io.v.nutz.base.query.PageForm;
import io.v.nutz.base.model.Review;
import io.v.nutz.base.service.AuditService;
import io.v.nutz.base.service.ReviewService;
import io.v.nutz.zhgh.reimbursement.constants.ReimbursementState;
import io.v.nutz.zhgh.reimbursement.models.Reimbursement;
import io.v.nutz.base.service.ViService;
import io.v.nutz.sys.services.SysSignatureService;
import io.v.nutz.web.commons.utils.ShiroUtil;
import io.v.nutz.zhgh.zgfw.model.condolence.Condolence;
import io.v.nutz.zhgh.zgfw.service.CondolenceService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.nutz.dao.Cnd;
import org.nutz.dao.Sqls;
import org.nutz.dao.sql.Sql;
import org.nutz.dao.util.cri.Static;
import org.nutz.ioc.loader.annotation.Inject;
import org.nutz.ioc.loader.annotation.IocBean;
import org.nutz.mvc.annotation.At;
import org.nutz.mvc.annotation.Ok;
import org.nutz.mvc.annotation.Param;
import java.util.Date;
/**
* @author zhf
* @date 2021/6/7 10:24
* @description 单位书记
*/
@At("/platform/reimbursement/secretary")
@IocBean
@Ok("json")
public class ReiSecretaryController {
@Inject("Reimbursement")
private ViService<Reimbursement> reimbursementViService;
@Inject
private ActivityBxService activityBxService;
@Inject
private SysSignatureService sysSignatureService;
@Inject
private AuditService auditService;
@Inject
private ReviewService reviewService;
@Inject
private CondolenceService condolenceService;
@At("")
@Ok("beetl:/platform/reimbursement/secretary.html")
@RequiresPermissions("reimbursement.secretary")
public void index() {
}
@At
@ViReturn
@RequiresPermissions("reimbursement.secretary")
public Object pageData(PageForm page,
@Param(value = "isAudit", required = false) boolean isAudit,
@Param(value = "year", required = false) Integer year,
@Param(value = "unitId", required = false) String unitId,
@Param(value = "reiItemId", required = false) Integer reiItemId) {
Sql sql = Sqls.create("""
SELECT
rei.*,
us.unionname,
state.stateColor,
state.stateName
FROM
`reimbursement` rei
LEFT JOIN `user` us ON us.id = rei.userid
LEFT JOIN condolence con ON con.id = rei.reimbursementId
LEFT JOIN activity_bx bx ON bx.id = rei.reimbursementId
LEFT JOIN audit_state state ON rei.State = state.stateId $condition
""");
CndPlus cnd = CndPlus.create();
if (isAudit) {
cnd.and(new Static("""
(con.unit_secretary_review IS NOT NULL
OR bx.unit_secretary_audit_id IS NOT NULL)
"""));
} else {
cnd.and("rei.State", "=", ReimbursementState.UNIT_SECRETARY);
}
Vi.cndPlus(cnd, "rei.reimbursementItemId", "=", reiItemId);
Vi.cndPlus(cnd, "YEAR(rei.applyTime)", "=", year);
Vi.cndPlus(cnd, "us.unitid", "=", unitId);
if (!ShiroUtil.hasAnyRoles("sysadmin")) {
cnd.and("us.unionid", "=", Vi.getUnionId());
}
cnd.desc("rei.applyTime");
sql.setCondition(cnd);
return reimbursementViService.listPageMap(page.getPageNumber(), page.getPageSize(), sql);
}
@At
@ViReturn
@RequiresPermissions("reimbursement.secretary")
public Object doReview(String id, Boolean flag, Audit audit, Review review, Integer reimbursementItemId) {
if (reimbursementItemId != 4) {
audit.setLoginname(ShiroUtil.getPrincipalProperty("loginname").toString());
audit.setUsername(ShiroUtil.getPrincipalProperty("username").toString());
audit.setAuditTime(new Date());
audit = auditService.insert(audit);
ActivityBx aid = activityBxService.fetch(id);
aid.setUnit_secretary_audit_id(audit.getId());
aid.setState_id(flag ? "3070" : "3065");
activityBxService.updateIgnoreNull(aid);
} else {
review.setLoginname(ShiroUtil.getPrincipalProperty("loginname").toString());
review.setUsername(ShiroUtil.getPrincipalProperty("username").toString());
review.setTime(DateUtil.getDate());
review = reviewService.insert(review);
Condolence condolence = condolenceService.fetch(id);
condolence.setUnit_secretary_review(review.getId());
condolence.setState_id(flag ? "3070" : "3065");
condolenceService.updateIgnoreNull(condolence);
}
Reimbursement reimbursement = reimbursementViService.fetch(Cnd.where("reimbursementId", "=", id));
reimbursement.setState(flag ? ReimbursementState.FINANCE : ReimbursementState.UNIT_SECRETARY_FAIL);
reimbursementViService.updateIgnoreNull(reimbursement);
return null;
}
}
@@ -1,180 +0,0 @@
package io.v.nutz.zhgh.reimbursement.controller;
import io.v.nutz.base.annontation.ViReturn;
import io.v.nutz.base.utils.Vi;
import io.v.nutz.zhgh.reimbursement.constants.ReimbursementState;
import io.v.nutz.zhgh.reimbursement.services.ReimbursementService;
import io.v.nutz.web.commons.utils.ShiroUtil;
import org.apache.shiro.authz.annotation.RequiresAuthentication;
import org.nutz.dao.Cnd;
import org.nutz.dao.Sqls;
import org.nutz.dao.sql.Sql;
import org.nutz.ioc.loader.annotation.Inject;
import org.nutz.ioc.loader.annotation.IocBean;
import org.nutz.lang.util.NutMap;
import org.nutz.mvc.annotation.At;
import org.nutz.mvc.annotation.Ok;
import java.util.ArrayList;
import java.util.List;
/**
* @author zhf
* @date 2021/6/16 8:55
* @description 报销待办
*/
@IocBean
@Ok("json:full")
@At("/platform/Reimbursement/Agent")
public class ReimbursementAgentController {
private static final String MODIFY = "/activity/reimbursement/list";
private static final String SIGNATURE = "/platform/fw/condolence/be";
private static final String UNION = "/platform/reimbursement/dma";
private static final String UNIT_SECRETARY = "/platform/reimbursement/secretary";
private static final String FINANCE = "/platform/reimbursement/finance";
private static final String VICE_CHAIRMAN = "/platform/reimbursement/ViceChairman";
private static final String STANDING_VICE_CHAIRMAN = "/platform/reimbursement/StandingViceChairman";
@Inject
private Vi vi;
@Inject
private ReimbursementService reimbursementService;
@At
@ViReturn
@RequiresAuthentication
public Object getAgenda() {
final String title = "【职工报销】";
List<NutMap> result = new ArrayList<>();
if (ShiroUtil.hasAnyRoles("sysadmin")) {
result.add(new NutMap().setv("title", title).setv("url", MODIFY).setv("iconClass", vi.getIconByPath(MODIFY)).setv("label", "待经办人修改").setv("number", getModifyCount()));
result.add(new NutMap().setv("title", title).setv("url", SIGNATURE).setv("iconClass", vi.getIconByPath(SIGNATURE)).setv("label", "待慰问人签字").setv("number", getSignatureCount()));
result.add(new NutMap().setv("title", title).setv("url", UNION).setv("iconClass", vi.getIconByPath(UNION)).setv("label", "待分工会审核").setv("number", getUcrCount()));
result.add(new NutMap().setv("title", title).setv("url", UNIT_SECRETARY).setv("iconClass", vi.getIconByPath(UNIT_SECRETARY)).setv("label", "待单位书记审核").setv("number", getUnit_secretaryCount()));
result.add(new NutMap().setv("title", title).setv("url", FINANCE).setv("iconClass", vi.getIconByPath(FINANCE)).setv("label", "待财务审核").setv("number", getFinanceCount()));
result.add(new NutMap().setv("title", title).setv("url", VICE_CHAIRMAN).setv("iconClass", vi.getIconByPath(VICE_CHAIRMAN)).setv("label", "待分管副主席审核").setv("number", getVice_chairmanCount()));
result.add(new NutMap().setv("title", title).setv("url", STANDING_VICE_CHAIRMAN).setv("iconClass", vi.getIconByPath(STANDING_VICE_CHAIRMAN)).setv("label", "待分管副主席审核").setv("number", getStanding_vice_chairmanCount()));
} else {
if (ShiroUtil.hasAnyRoles("gh03")) {
result.add(new NutMap().setv("title", title).setv("url", UNIT_SECRETARY).setv("iconClass", vi.getIconByPath(UNIT_SECRETARY)).setv("label", "待单位书记审核").setv("number", getUnit_secretaryCount()));
}
if (ShiroUtil.hasAnyRoles("SchoolUnionAccountant")) {
result.add(new NutMap().setv("title", title).setv("url", FINANCE).setv("iconClass", vi.getIconByPath(FINANCE)).setv("label", "待财务审核").setv("number", getFinanceCount()));
}
if (ShiroUtil.hasAnyRoles("wyh03")) {
result.add(new NutMap().setv("title", title).setv("url", VICE_CHAIRMAN).setv("iconClass", vi.getIconByPath(VICE_CHAIRMAN)).setv("label", "待分管副主席审核").setv("number", getVice_chairmanCount()));
}
if (ShiroUtil.hasAnyRoles("wyh02")) {
result.add(new NutMap().setv("title", title).setv("url", STANDING_VICE_CHAIRMAN).setv("iconClass", vi.getIconByPath(STANDING_VICE_CHAIRMAN)).setv("label", "待分管副主席审核").setv("number", getStanding_vice_chairmanCount()));
}
}
return result;
}
/**
* 待申请人修改
*
* @return
*/
public Object getModifyCount() {
Cnd cnd = Cnd.NEW();
Sql sql = Sqls.create("""
SELECT COUNT(1) FROM reimbursement $condition
""");
cnd.and("State", "=", ReimbursementState.MODIFY);
if (!ShiroUtil.hasAnyRoles("sysadmin")) {
cnd.and("userId", "=", ShiroUtil.getPrincipalProperty("id"));
}
sql.setCondition(cnd);
return reimbursementService.count(sql);
}
/**
* 待慰问人签字
*
* @return
*/
public Object getSignatureCount() {
Cnd cnd = Cnd.NEW();
Sql sql = Sqls.create("""
SELECT COUNT(1) FROM reimbursement $condition
""");
cnd.and("State", "=", ReimbursementState.SIGNATURE);
if (!ShiroUtil.hasAnyRoles("sysadmin")) {
cnd.and("userId", "=", ShiroUtil.getPrincipalProperty("id"));
}
sql.setCondition(cnd);
return reimbursementService.count(sql);
}
/**
* 待工会主席审核
*
* @return
*/
private Integer getUcrCount() {
Cnd cnd = Cnd.NEW();
Sql sql = Sqls.create("""
SELECT COUNT(1) FROM reimbursement re LEFT JOIN `user` us ON re.userId=us.id $condition
""");
cnd.and("re.State", "=", ReimbursementState.UNION);
if (!ShiroUtil.hasAnyRoles("sysadmin")) {
cnd.and("us.unionid", "=", vi.getUnionId());
}
sql.setCondition(cnd);
return reimbursementService.count(sql);
}
/**
* 待单位书记审核
*
* @return
*/
private Integer getUnit_secretaryCount() {
Cnd cnd = Cnd.NEW();
Sql sql = Sqls.create("""
SELECT COUNT(1) FROM reimbursement re LEFT JOIN `user` us ON re.userId=us.id $condition
""");
cnd.and("re.State", "=", ReimbursementState.UNIT_SECRETARY);
if (!ShiroUtil.hasAnyRoles("sysadmin")) {
cnd.and("us.unionid", "=", vi.getUnionId());
}
sql.setCondition(cnd);
return reimbursementService.count(sql);
}
/**
* 待财务审核
*
* @return
*/
public Object getFinanceCount() {
return reimbursementService.count(Cnd.where("State", "=", ReimbursementState.FINANCE));
}
/**
* 待分管副主席审核
*
* @return
*/
public Object getVice_chairmanCount() {
return reimbursementService.count(Cnd.where("State", "=", ReimbursementState.VICE_CHAIRMAN));
}
/**
* 待常务副主席审核
*
* @return
*/
public Object getStanding_vice_chairmanCount() {
return reimbursementService.count(Cnd.where("State", "=", ReimbursementState.STANDING_VICE_CHAIRMAN));
}
}
@@ -0,0 +1,155 @@
package io.v.nutz.zhgh.reimbursement.controller;
import cn.hutool.core.util.StrUtil;
import io.v.nutz.base.annontation.ViReturn;
import io.v.nutz.base.model.Audit;
import io.v.nutz.base.utils.Roles;
import io.v.nutz.base.utils.Vi;
import io.v.nutz.sys.models.Sys_club;
import io.v.nutz.sys.services.SysClubService;
import io.v.nutz.sys.services.SysLocalProcessService;
import io.v.nutz.web.commons.utils.ShiroUtil;
import io.v.nutz.zhgh.reimbursement.constants.ReimbursementState;
import io.v.nutz.zhgh.reimbursement.handler.ReimbursementToDoHandler;
import io.v.nutz.zhgh.reimbursement.models.ReimbursementNew;
import io.v.nutz.zhgh.reimbursement.models.ReimbursementPageForm;
import io.v.nutz.zhgh.reimbursement.services.ReimbursementService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.nutz.aop.interceptor.ioc.TransAop;
import org.nutz.dao.Chain;
import org.nutz.dao.Cnd;
import org.nutz.dao.Sqls;
import org.nutz.dao.sql.Sql;
import org.nutz.ioc.aop.Aop;
import org.nutz.ioc.loader.annotation.Inject;
import org.nutz.ioc.loader.annotation.IocBean;
import org.nutz.lang.Lang;
import org.nutz.lang.util.NutMap;
import org.nutz.mvc.annotation.At;
import org.nutz.mvc.annotation.Ok;
import org.nutz.mvc.annotation.Param;
import java.util.Date;
import java.util.List;
/**
* @ClassName ReimbursementClubController
* @Description 协会审核
* @Author zhf
* @Date 2025/3/20 上午8:57
*/
@At("/platform/reimbursement/clubAudit")
@IocBean
@Ok("json:full")
public class ReimbursementClubAuditController {
@Inject
private ReimbursementService reimbursementViService;
@At("")
@Ok("beetl:/platform/reimbursement/clubAudit.html")
@RequiresPermissions("reimbursement.clubAudit")
public void index() {
}
@Inject
private SysLocalProcessService localProcessService;
@At
@ViReturn
@RequiresPermissions("reimbursement.clubAudit")
public Object pageData(ReimbursementPageForm page) {
Sql sql = Sqls.create("""
SELECT
rei.*,
be.username be_username,
state.stateName,
state.stateColor,
cl.`name` clubName
FROM
`reimbursement_new` rei
LEFT JOIN sys_user be ON be.id = rei.be_user
LEFT JOIN audit_state state ON state.stateId = rei.state
LEFT JOIN sys_club cl ON cl.id = rei.clubId
$condition
""");
Cnd cnd = Cnd.NEW();
cnd.andEX("rei.jf_source", "in", List.of("ACTIVITY_BUDGET_TYPE_THREE", "ACTIVITY_BUDGET_TYPE_FOUR"));
if (page.getIsAudit() != 1) {
cnd.and("rei.State", page.getIsAudit() == 2 ? ">" : "=", ReimbursementState.CLUB);
} else {
cnd.and("rei.State", ">=", ReimbursementState.CLUB);
}
if (Vi.isNotBlank(page.getSearchName(), page.getSearchKeyword())) {
cnd.where().andLike(page.getSearchName(), page.getSearchKeyword());
}
if (!ShiroUtil.hasAnyRoles("sysadmin,A06")) {
Cnd cnd1 = Cnd.NEW();
Sql sql1 = Sqls.create("""
SELECT
club.id
FROM
sys_club club
LEFT JOIN `sys_user_role` role ON club.id = role.stid
$condition
""");
if (!ShiroUtil.hasRole("sysadmin")) {
cnd1.and("role.roleId", "in", Lang.array(Roles.club01, Roles.club02, Roles.club03, Roles.club04));
cnd1.and("role.userId", "=", ShiroUtil.getUserId());
}
cnd1.and("club.isjs", "=", false);
cnd1.and("club.state", "=", 930);
cnd1.groupBy("club.id");
cnd1.asc("club.`code`");
sql1.setCondition(cnd1);
List<NutMap> nutMapList = reimbursementViService.listMap(sql1);
List<String> ids = nutMapList.stream().map(v -> v.getString("id")).toList();
cnd.and("rei.clubId", "in", ids);
}
cnd.andEX("YEAR(rei.applyTime)", "=", page.getYear());
cnd.desc("rei.applyTime");
sql.setCondition(cnd);
return reimbursementViService.listPageMap(page.getPageNumber(), page.getPageSize(), sql);
}
@At
@ViReturn
@Aop(TransAop.READ_COMMITTED)
@RequiresPermissions("reimbursement.clubAudit")
public Object doAudit(@Param("id") String id, @Param("flag") Integer flag, Audit audit) {
audit.setLoginname(ShiroUtil.getPlatformLoginname());
audit.setUsername(ShiroUtil.getPlatformUsername());
audit.setAuditTime(new Date());
reimbursementViService.insert(audit);
ReimbursementNew reimbursementNew = reimbursementViService.fetch(id);
ReimbursementToDoHandler.COMPLETE_CLUB_TASK.exec(reimbursementNew, audit.getAuditOpinion());
Integer auditState;
if (flag == 1) {
auditState = ReimbursementState.CLUB_FAIL;
//拒绝
ReimbursementToDoHandler.COMPLETE_PROCESS.exec(reimbursementNew, audit.getAuditOpinion());
} else if (flag == 2) {
auditState = ReimbursementState.CLUB_GO_BACK;
//返回修改
ReimbursementToDoHandler.CREATE_BACK_CLUB_TASK.exec(reimbursementNew, audit.getAuditOpinion());
} else {
auditState = ReimbursementState.UNION;
ReimbursementToDoHandler.CREATE_UNION_TASK.exec(reimbursementNew, audit.getAuditOpinion());
}
Chain chain = Chain.make("clubAuditId", audit.getId()).add("state", auditState);
reimbursementViService.update(chain, Cnd.where("id", "=", id));
return null;
}
@At
@ViReturn
@RequiresPermissions("reimbursement.clubAudit")
public Object doRevoke(@Param("id") String id) {
Chain chain = Chain.make("clubAuditId", null).add("state", ReimbursementState.CLUB);
reimbursementViService.update(chain, Cnd.where("id", "=", id));
localProcessService.revokeTask("reimbursement@" + id, "协会会长审核");
return null;
}
}
@@ -1,30 +1,34 @@
package io.v.nutz.zhgh.reimbursement.controller;
import cn.hutool.core.util.ObjectUtil;
import io.v.nutz.base.annontation.ViReturn;
import io.v.nutz.base.query.PageForm;
import io.v.nutz.base.result.Result;
import io.v.nutz.base.service.ViService;
import io.v.nutz.base.utils.DateUtil;
import io.v.nutz.base.utils.PageUtil;
import io.v.nutz.base.utils.Vi;
import io.v.nutz.zhgh.jf.model.ActivityBx;
import io.v.nutz.zhgh.jf.model.jf_use;
import io.v.nutz.zhgh.jf.model.jf_yjgh;
import io.v.nutz.base.query.PageForm;
import io.v.nutz.web.commons.slog.annotation.SLog;
import io.v.nutz.web.commons.utils.ShiroUtil;
import io.v.nutz.zhgh.jf.model.*;
import io.v.nutz.zhgh.reimbursement.constants.ReimbursementState;
import io.v.nutz.zhgh.reimbursement.models.ReimbursementNew;
import io.v.nutz.zhgh.reimbursement.services.ReimbursementService;
import io.v.nutz.base.service.ViService;
import io.v.nutz.web.commons.utils.ShiroUtil;
import io.v.nutz.web.commons.slog.annotation.SLog;
import io.v.nutz.zhgh.zgfw.service.CondolenceService;
import org.apache.shiro.authz.annotation.RequiresAuthentication;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.nutz.aop.interceptor.ioc.TransAop;
import org.nutz.dao.Cnd;
import org.nutz.dao.Sqls;
import org.nutz.dao.sql.Sql;
import org.nutz.dao.util.cri.SqlExpressionGroup;
import org.nutz.ioc.aop.Aop;
import org.nutz.ioc.loader.annotation.Inject;
import org.nutz.ioc.loader.annotation.IocBean;
import org.nutz.lang.Strings;
import org.nutz.mvc.annotation.At;
import org.nutz.mvc.annotation.Ok;
import org.nutz.mvc.annotation.Param;
import java.util.List;
/**
* @author zhf
@@ -34,6 +38,7 @@ import org.nutz.mvc.annotation.Param;
@At("/activity/reimbursement/list")
@Ok("json:full")
@IocBean
@RequiresAuthentication
public class ReimbursementListController {
@Inject
@@ -58,23 +63,20 @@ public class ReimbursementListController {
@At
@ViReturn
@RequiresPermissions("reimbursement.list")
public Object pageData(PageForm page,
@Param(value = "year", required = false) Integer year,
@Param(value = "unitId", required = false) String unitId,
@Param(value = "unionId", required = false) String unionId,
@Param(value = "reiItemId", required = false) String reiItemId,
@Param(value = "person", required = false) String person) {
public Object pageData(Integer year, String unitId, String unionId, String reiItemId, PageForm page, String person) {
Cnd cnd = Cnd.NEW();
Sql sql = Sqls.create("""
SELECT
rei.*,
be.username be_username,
state.stateName,
state.stateColor
state.stateColor,
cl.`name` clubName
FROM
`reimbursement_new` rei
LEFT JOIN sys_user be ON be.id = rei.be_user
LEFT JOIN audit_state state ON state.stateId = rei.state
LEFT JOIN sys_club cl ON cl.id = rei.clubId
$condition
""");
cnd.andEX("YEAR ( rei.applyTime )", "=", year);
@@ -86,14 +88,10 @@ public class ReimbursementListController {
sqlExpressionGroup.orLike("rei.userName", person);
cnd.and(sqlExpressionGroup);
}
if (!ShiroUtil.hasAnyRoles("sysadmin")) {
if (!ShiroUtil.getPrincipalProperty("loginname").equals("superadmin")) {
cnd.and("rei.userId", "=", ShiroUtil.getUserId());
}
if (Strings.isNotBlank(reiItemId) && reiItemId.equals("ww")) {
cnd.and("rei.reimbursementItemId", "in", "'fyww','zfww'");
} else {
cnd.andEX("rei.reimbursementItemId", "=", reiItemId);
}
if (Strings.isNotBlank(page.getPageOrderName()) && Strings.isNotBlank(page.getPageOrderBy())) {
cnd.orderBy(page.getPageOrderName(), PageUtil.getOrder(page.getPageOrderBy()));
} else {
@@ -106,22 +104,59 @@ public class ReimbursementListController {
@At
@ViReturn
@RequiresPermissions("reimbursement.list")
public Object findOne(String id) {
return reimbursementService.findOne(id);
}
@At
@ViReturn
@Aop(TransAop.READ_COMMITTED)
@RequiresPermissions("reimbursement.list")
@SLog(tag = "工会报销", msg = "删除了一条记录", param = true, result = true)
public Object doDelete(String id) {
ReimbursementNew reimbursementNew = reimbursementNewViService.fetch(id);
jf_yjgh yjgh = reimbursementNewViService.dao().fetch(jf_yjgh.class, Cnd.where("unionId", "=", Vi.getUnionId()).and("year", "=", DateUtil.getYear()).and("state", "=", 1));
yjgh.setUsedQuota(yjgh.getUsedQuota() - reimbursementNew.getMoney());
reimbursementNewViService.updateIgnoreNull(yjgh);
reimbursementNewViService.dao().clear(jf_use.class, Cnd.where("apply_id", "=", reimbursementNew.getId()));
ReimbursementNew fetch = reimbursementService.fetch(id);
if (fetch.getState().equals(ReimbursementState.SUCCESSFUL_REIMBURSEMENT)) {
if (fetch.getJf_source().equals("ACTIVITY_BUDGET_TYPE_ONE")) {
jf_school school = reimbursementService.dao().fetch(jf_school.class, Cnd.where("year", "=", DateUtil.getYear()));
if (ObjectUtil.isEmpty(school)) {
return Result.error("该年份没有设置金额!");
}
school.setUsedQuota(school.getUsedQuota().subtract(fetch.getMoney()));
reimbursementService.updateIgnoreNull(school);
reimbursementService.dao().clear(SchoolUse.class, Cnd.where("reimbursementId", "=", id));
} else if (fetch.getJf_source().equals("ACTIVITY_BUDGET_TYPE_TWO")) {
// 更新分工会活动经费表
jf_yjgh jfYjgh=reimbursementService.dao().fetch(jf_yjgh.class, Cnd.where("year", "=", DateUtil.getYear())
.and("unionId", "=", fetch.getUnionId()));;
if (ObjectUtil.isEmpty(jfYjgh)) {
return Result.error("该年份没有设置金额!");
}
jfYjgh.setUsedQuota(jfYjgh.getUsedQuota().subtract(fetch.getMoney()));
reimbursementService.updateIgnoreNull(jfYjgh);
reimbursementService.dao().clear(jf_use.class, Cnd.where("apply_id", "=", id));
} else if (fetch.getJf_source().equals("ACTIVITY_BUDGET_TYPE_THREE")) {
// 更新社团经费表
jf_club jfClub = reimbursementService.dao().fetch(jf_club.class, Cnd.where("year", "=", DateUtil.getYear())
.and("club_id", "=", fetch.getClubId()));
if (ObjectUtil.isEmpty(jfClub)) {
return Result.error("该年份没有设置金额!");
}
jfClub.setUsedQuota(jfClub.getUsedQuota().subtract(fetch.getMoney()));
reimbursementService.updateIgnoreNull(jfClub);
reimbursementService.dao().clear(jf_use.class, Cnd.where("apply_id", "=", id));
} else if (fetch.getJf_source().equals("ACTIVITY_BUDGET_TYPE_FOUR")) {
// 更新其他经费表
/*JfOther jfOther = reimbursementService.dao().fetch(JfOther.class, Cnd.where("year", "=", DateUtil.getYear()));
if (ObjectUtil.isEmpty(jfOther)) {
return Result.error("该年份没有设置金额!");
}
jfOther.setUsedQuota(jfOther.getUsedQuota().subtract(fetch.getMoney()));
reimbursementService.updateIgnoreNull(jfOther);
reimbursementService.dao().clear(OtherUse.class, Cnd.where("reimbursementId", "=", id));*/
}
}
reimbursementNewViService.dao().clear(ReimbursementNew.class, Cnd.where("id", "=", id));
return null;
@@ -4,8 +4,8 @@ import cn.afterturn.easypoi.excel.ExcelExportUtil;
import cn.afterturn.easypoi.excel.entity.ExportParams;
import cn.afterturn.easypoi.excel.entity.enmus.ExcelType;
import cn.afterturn.easypoi.excel.entity.params.ExcelExportEntity;
import cn.hutool.core.convert.Convert;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.artofsolving.jodconverter.DocumentConverter;
import com.artofsolving.jodconverter.openoffice.connection.OpenOfficeConnection;
@@ -19,23 +19,21 @@ import com.google.zxing.client.j2se.MatrixToImageWriter;
import com.google.zxing.common.BitMatrix;
import com.google.zxing.qrcode.QRCodeWriter;
import io.v.nutz.base.annontation.ViReturn;
import io.v.nutz.base.utils.OfficeTemplateUtil;
import io.v.nutz.base.utils.Vi;
import io.v.nutz.base.dao.CndPlus;
import io.v.nutz.base.model.Audit;
import io.v.nutz.base.query.PageForm;
import io.v.nutz.zhgh.reimbursement.services.ReimbursementService;
import io.v.nutz.base.utils.Vi;
import io.v.nutz.base.utils.ViTool;
import io.v.nutz.web.commons.base.Globals;
import io.v.nutz.web.commons.utils.ShiroUtil;
import io.v.nutz.zhgh.zgfw.service.CondolenceService;
import io.v.nutz.sys.models.Sys_dict;
import io.v.nutz.sys.services.SysDictService;
import io.v.nutz.zhgh.reimbursement.constants.ReimbursementState;
import io.v.nutz.zhgh.reimbursement.models.ReimbursementPageForm;
import io.v.nutz.zhgh.reimbursement.services.ReimbursementService;
import org.apache.commons.io.IOUtils;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.shiro.authz.annotation.RequiresAuthentication;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.nutz.dao.Cnd;
import org.nutz.dao.Sqls;
import org.nutz.dao.sql.Sql;
import org.nutz.dao.util.cri.SqlExpressionGroup;
import org.nutz.ioc.loader.annotation.Inject;
import org.nutz.ioc.loader.annotation.IocBean;
import org.nutz.lang.Lang;
@@ -44,11 +42,11 @@ import org.nutz.lang.random.R;
import org.nutz.lang.util.NutMap;
import org.nutz.mvc.annotation.At;
import org.nutz.mvc.annotation.Ok;
import org.nutz.mvc.annotation.Param;
import javax.servlet.http.HttpServletResponse;
import java.awt.image.BufferedImage;
import java.io.*;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Base64;
import java.util.List;
@@ -62,73 +60,57 @@ import java.util.stream.Collectors;
@At("/platform/reimbursement/Summary")
@IocBean
@RequiresAuthentication
@Ok("json")
public class ReimbursementSummaryController {
@Inject
private ReimbursementService reimbursementViService;
@Inject
private CondolenceService condolenceService;
private SysDictService sysDictService;
@Inject
private OfficeTemplateUtil officeTemplateUtil;
@At("")
@Ok("beetl:/platform/reimbursement/Summary.html")
@RequiresPermissions("reimbursement.Summary")
public void index() {
}
@At
@ViReturn
@RequiresPermissions("reimbursement.Summary")
public Object pageData(PageForm page,
@Param(value = "jf_source", required = false) String jf_source,
@Param(value = "reimbursementDate", required = false) String[] reimbursementDate,
@Param(value = "unitId", required = false) String unitId,
@Param(value = "unionId", required = false) String unionId,
@Param(value = "reiItemId", required = false) String reiItemId) {
public Object pageData(ReimbursementPageForm page) {
Sql sql = Sqls.create("""
SELECT
rei.*,
be.username be_username,
state.stateName,
state.stateColor
state.stateColor,
cl.`name` clubName
FROM
`reimbursement_new` rei
LEFT JOIN sys_user be ON be.id = rei.be_user
LEFT JOIN audit_state state ON state.stateId = rei.state
LEFT JOIN sys_club cl ON cl.id = rei.clubId
$condition
""");
CndPlus cnd = CndPlus.create();
Cnd cnd = Cnd.NEW();
Vi.cndPlus(cnd, "rei.jf_source", "=", jf_source);
if (reimbursementDate.length > 0) {
cnd.and("rei.applyTime", ">=", reimbursementDate[0]);
cnd.and("rei.applyTime", "<=", reimbursementDate[1]);
cnd.andEX("rei.jf_source", "=", page.getJf_source());
cnd.andEX("rei.State", "=", ReimbursementState.SUCCESSFUL_REIMBURSEMENT);
if (ObjectUtil.isNotEmpty(page.getReimbursementDate())) {
cnd.and("rei.applyTime", ">=", page.getReimbursementDate().get(0));
cnd.and("rei.applyTime", "<=", page.getReimbursementDate().get(1));
}
Vi.cndPlus(cnd, "rei.unitId", "=", unitId);
Vi.cndPlus(cnd, "rei.unionId", "=", unionId);
cnd.andEX("rei.unitId", "=", page.getUnitId());
cnd.andEX("rei.unionId", "=", page.getUnionId());
cnd.andEX("rei.clubId", "=", page.getClubId());
if (Vi.isNotBlank(page.getSearchName(), page.getSearchKeyword())) {
cnd.where().andLike(page.getSearchName(), page.getSearchKeyword());
}
if (Strings.isNotBlank(reiItemId) && reiItemId.equals("ww")) {
cnd.and("rei.reimbursementItemId", "in", "'fyww','zfww'");
} else {
cnd.andEX("rei.reimbursementItemId", "=", reiItemId);
}
/* Vi.cndPlus(cnd, "rei.State", "=", ReimbursementState.SUCCESSFUL_REIMBURSEMENT);*/
if (!ShiroUtil.hasAnyRoles("sysadmin,A06,gh12,wyh02,wyh03")) {
SqlExpressionGroup group = new SqlExpressionGroup();
if (ShiroUtil.hasAnyRoles("gh01,H04")) {
group.or("rei.unionId", "=", Vi.getUnionId());
} else {
group.or("rei.userId", "=", ShiroUtil.getPrincipalProperty("id"));
}
cnd.and(group);
}
cnd.desc("rei.applyTime");
sql.setCondition(cnd);
return reimbursementViService.listPageMap(page.getPageNumber(), page.getPageSize(), sql);
@@ -142,9 +124,8 @@ public class ReimbursementSummaryController {
@At
@Ok("void")
@RequiresPermissions("reimbursement.Summary")
public void reiExport(String id, HttpServletResponse response, boolean Print) throws Exception {
NutMap record = reimbursementViService.findOne(id);
/* NutMap record = reimbursementViService.findOne(id);
if ("3".equals(record.getString("jf_source"))) {
Sql clubSql = Sqls.create("""
SELECT
@@ -171,9 +152,9 @@ public class ReimbursementSummaryController {
PictureRenderData pictureRenderData = new PictureRenderData(80, 80, ".png", bufferedImage);
record.setv("qrcode", pictureRenderData);
record.setv("applyTime", record.getString("applyTime").substring(0, 10));
record.setv("money_big", Convert.digitToChinese(record.getDouble("money")));
record.setv("money_big", MoneyUtil.toRMBUpper(record.getString("money")));
String wtAct = "□慰问 □活动 □建家 □日常 □劳务 □专家";
String wtAct = "□慰问 □活动 □建家 □日常 □劳务 □专家 □奖励";
if (record.getString("reimbursementItemId").equals("fyww") || record.getString("reimbursementItemId").equals("zfww")) {
wtAct = wtAct.replace("□慰问", "√慰问");
} else if (record.getString("reimbursementItemId").equals("fyhd")) {
@@ -186,6 +167,8 @@ public class ReimbursementSummaryController {
wtAct = wtAct.replace("□劳务", "√劳务");
} else if (record.getString("reimbursementItemId").equals("zfzj")) {
wtAct = wtAct.replace("□专家", "√专家");
} else if (record.getString("reimbursementItemId").equals("zfjl")) {
wtAct = wtAct.replace("□奖励", "√奖励");
}
record.setv("bxxm", wtAct);
@@ -205,13 +188,13 @@ public class ReimbursementSummaryController {
record.setv("accTime", audit.getAuditTime() != null ? DateUtil.formatDate(audit.getAuditTime()) : null);
record.setv("accOpinion", audit.getAuditOpinion());
}
record.setv("schoolName", Globals.schoolName);
Configure config = Configure.newBuilder().build();
String templateUrl;
InputStream inputStream;
if (record.getString("reimbursementItemSort").equals("zf")) {
templateUrl = officeTemplateUtil.getPath("reimbursementMoney");
inputStream = Thread.currentThread().getContextClassLoader().getResourceAsStream("docTemplate/reimbursement/reimbursementMoney.docx");
} else {
templateUrl = officeTemplateUtil.getPath("reimbursement");
inputStream = Thread.currentThread().getContextClassLoader().getResourceAsStream("docTemplate/reimbursement/reimbursement.docx");
}
if (Print) {
String uuid = R.UU32();
@@ -221,7 +204,8 @@ public class ReimbursementSummaryController {
OutputStream outputStream = new FileOutputStream(docx);
XWPFTemplate.compile(templateUrl, config).render(record).writeAndClose(outputStream);
XWPFTemplate.compile(inputStream, config).render(record, outputStream);
inputStream.close();
outputStream.close();
//打开连接
@@ -243,78 +227,66 @@ public class ReimbursementSummaryController {
} else {
String fileName = "";
if (record.getString("reimbursementItemSort").equals("zf")) {
fileName = Globals.schoolName + "支付凭证";
fileName = "南京工业大学支付凭证";
} else {
fileName = Globals.schoolName + "工会凭证报销单";
fileName = "南京工业大学工会凭证报销单";
}
response.addHeader("Content-Type", "application/octet-stream");
response.addHeader("Content-Disposition", "attachment; filename=\"" + new String(fileName.getBytes("UTF-8"), "ISO-8859-1") + "\".docx");
XWPFTemplate.compile(templateUrl, config).render(record).writeAndClose(response.getOutputStream());
}
response.addHeader("Content-Disposition", "attachment; filename=\"" + new String(fileName.getBytes(StandardCharsets.UTF_8), StandardCharsets.ISO_8859_1) + "\".docx");
XWPFTemplate.compile(inputStream, config).render(record, response.getOutputStream());
inputStream.close();
}*/
}
@At()
@Ok("void")
@RequiresPermissions("reimbursement.Summary")
public void doExportUserExcel(HttpServletResponse response,
@Param(value = "reiItemId", required = false) String reiItemId,
@Param(value = "unitId", required = false) String unitId,
@Param(value = "unionId", required = false) String unionId,
@Param(value = "searchKeyword", required = false) String searchKeyword,
@Param(value = "searchName", required = false) String searchName,
@Param(value = "reimbursementDate", required = false) String[] reimbursementDate) {
public void doExportUserExcel(HttpServletResponse response, ReimbursementPageForm page) {
Sql sql = Sqls.create("""
SELECT
rei.*,
be.username be_username,
state.stateName,
state.stateColor
state.stateColor,
cl.`name` clubName
FROM
`reimbursement_new` rei
LEFT JOIN sys_user be ON be.id = rei.be_user
LEFT JOIN audit_state state ON state.stateId = rei.state
$condition
LEFT JOIN sys_club cl ON cl.id = rei.clubId
$condition
""");
CndPlus cnd = CndPlus.create();
Cnd cnd = Cnd.NEW();
Vi.cndPlus(cnd, "rei.reimbursementItemId", "=", reiItemId);
if (reimbursementDate != null && reimbursementDate.length > 0) {
Vi.cndPlus(cnd, "rei.applyTime", ">=", reimbursementDate[0]);
Vi.cndPlus(cnd, "rei.applyTime", "<=", reimbursementDate[1]);
cnd.andEX("rei.jf_source", "=", page.getJf_source());
cnd.andEX("rei.State", "=", ReimbursementState.SUCCESSFUL_REIMBURSEMENT);
if (ObjectUtil.isNotEmpty(page.getReimbursementDate())) {
cnd.and("rei.applyTime", ">=", page.getReimbursementDate().get(0));
cnd.and("rei.applyTime", "<=", page.getReimbursementDate().get(1));
}
Vi.cndPlus(cnd, "rei.unitId", "=", unitId);
Vi.cndPlus(cnd, "rei.unionId", "=", unionId);
if (Vi.isNotBlank(searchName, searchKeyword)) {
cnd.where().andLike(searchName, searchKeyword);
cnd.andEX("rei.unitId", "=", page.getUnitId());
cnd.andEX("rei.unionId", "=", page.getUnionId());
cnd.andEX("rei.clubId", "=", page.getClubId());
if (Vi.isNotBlank(page.getSearchName(), page.getSearchKeyword())) {
cnd.where().andLike(page.getSearchName(), page.getSearchKeyword());
}
cnd.desc("rei.applyTime");
sql.setCondition(cnd);
List<NutMap> mapList = reimbursementViService.listMap(sql);
List<Sys_dict> dictList = sysDictService.getSubListByCode("ACTIVITY_BUDGET_TYPE");
mapList.forEach(v -> {
v.setv("description", Strings.isNotBlank(v.getString("activity_name")) ? ("活动名称:" + v.getString("activity_name")) : ("被慰问人:" + v.getString("be_username")));
if ("3".equals(v.getString("jf_source"))) {
Sql clubSql = Sqls.create("""
SELECT
cu.*,
c.NAME as clubName
FROM
sys_club_user cu
LEFT JOIN sys_club c ON c.id = cu.clubid
$condition
""");
Cnd clubCnd = Cnd.NEW();
clubCnd.and("userid", "=", v.getString("userId"));
clubCnd.and("clubid", "=", v.getString("clubId"));
clubSql.setCondition(clubCnd);
List<NutMap> list = reimbursementViService.listMap(clubSql);
if (Lang.isNotEmpty(list)) {
String name = list.stream().map(o -> o.getString("clubName")).collect(Collectors.joining(","));
v.put("unitName", name);
}
Sys_dict dict = dictList.stream().filter(sys_dict -> sys_dict.getCode().equals(v.getString("jf_source"))).findFirst().orElse(null);
v.put("jf_source_name", dict.getName());
if (List.of("ACTIVITY_BUDGET_TYPE_ONE", "ACTIVITY_BUDGET_TYPE_FOUR").contains(v.getString("jf_source"))) {
v.put("helpUnitName", dict.getName());
}else if (v.getString("jf_source").equals("ACTIVITY_BUDGET_TYPE_TWO")){
v.put("helpUnitName", v.getString("unionName"));
}else if (v.getString("jf_source").equals("ACTIVITY_BUDGET_TYPE_THREE")){
v.put("helpUnitName", v.getString("clubName"));
}
});
List<ExcelExportEntity> exportEntities = new ArrayList<>();
@@ -322,10 +294,13 @@ public class ReimbursementSummaryController {
exportEntities.add(new ExcelExportEntity("姓名", "userName", 20));
exportEntities.add(new ExcelExportEntity("所属工会", "unionName", 20));
exportEntities.add(new ExcelExportEntity("所属单位", "unitName", 20));
exportEntities.add(new ExcelExportEntity("申请时间", "applyTime", 20));
exportEntities.add(new ExcelExportEntity("报销项目", "reimbursementItemName", 20));
exportEntities.add(new ExcelExportEntity("备注", "description", 20));
exportEntities.add(new ExcelExportEntity("活动类型", "jf_source_name", 20));
exportEntities.add(new ExcelExportEntity("活动项目", "activity_name", 20));
exportEntities.add(new ExcelExportEntity("申报单位", "helpUnitName", 20));
exportEntities.add(new ExcelExportEntity("金额(元)", "money", 20));
exportEntities.add(new ExcelExportEntity("申请时间", "applyTime", 20));
exportEntities.add(new ExcelExportEntity("审核状态", "stateName", 20));
try {
ViTool.excelResponse(response, "报销汇总表.xlsx");
@@ -0,0 +1,145 @@
package io.v.nutz.zhgh.reimbursement.controller;
import io.v.nutz.base.annontation.ViReturn;
import io.v.nutz.base.model.Audit;
import io.v.nutz.base.utils.Vi;
import io.v.nutz.sys.models.Sys_club;
import io.v.nutz.sys.services.SysClubService;
import io.v.nutz.sys.services.SysLocalProcessService;
import io.v.nutz.web.commons.utils.ShiroUtil;
import io.v.nutz.zhgh.reimbursement.constants.ReimbursementState;
import io.v.nutz.zhgh.reimbursement.handler.ReimbursementToDoHandler;
import io.v.nutz.zhgh.reimbursement.models.ReimbursementNew;
import io.v.nutz.zhgh.reimbursement.models.ReimbursementPageForm;
import io.v.nutz.zhgh.reimbursement.services.ReimbursementService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.nutz.aop.interceptor.ioc.TransAop;
import org.nutz.dao.Chain;
import org.nutz.dao.Cnd;
import org.nutz.dao.Sqls;
import org.nutz.dao.sql.Sql;
import org.nutz.dao.util.cri.SqlExpressionGroup;
import org.nutz.ioc.aop.Aop;
import org.nutz.ioc.loader.annotation.Inject;
import org.nutz.ioc.loader.annotation.IocBean;
import org.nutz.mvc.annotation.At;
import org.nutz.mvc.annotation.Ok;
import org.nutz.mvc.annotation.Param;
import java.util.Date;
import java.util.List;
/**
* @ClassName ReimbursementUnionController
* @Description TODO
* @Author zhf
* @Date 2025/3/20 下午5:10
*/
@At("/platform/reimbursement/unionAudit")
@IocBean
@Ok("json:full")
public class ReimbursementUnionAuditController {
@Inject
private ReimbursementService reimbursementViService;
@Inject
private SysLocalProcessService localProcessService;
@At("")
@Ok("beetl:/platform/reimbursement/unionAudit.html")
@RequiresPermissions("reimbursement.unionAudit")
public void index() {
}
@At
@ViReturn
@RequiresPermissions("reimbursement.unionAudit")
public Object pageData(ReimbursementPageForm page) {
Sql sql = Sqls.create("""
SELECT
rei.*,
be.username be_username,
state.stateName,
state.stateColor,
cl.`name` clubName
FROM
`reimbursement_new` rei
LEFT JOIN sys_user be ON be.id = rei.be_user
LEFT JOIN audit_state state ON state.stateId = rei.state
LEFT JOIN sys_club cl ON cl.id = rei.clubId
$condition
""");
Cnd cnd = Cnd.NEW();
if (page.getIsAudit() != 1) {
cnd.and("rei.State", page.getIsAudit() == 2 ? ">" : "=", ReimbursementState.UNION);
} else {
cnd.and("rei.State", ">=", ReimbursementState.UNION);
}
if (Vi.isNotBlank(page.getSearchName(), page.getSearchKeyword())) {
cnd.where().andLike(page.getSearchName(), page.getSearchKeyword());
}
SqlExpressionGroup group = new SqlExpressionGroup();
List<Sys_club> clubList = reimbursementViService.dao().query(Sys_club.class, Cnd.where("belongUnionId", "=", Vi.getUnionId()));
List<String> ids = clubList.stream().map(Sys_club::getId).toList();
SqlExpressionGroup group1 = new SqlExpressionGroup();
group1.and("rei.clubId", "in", ids);
group1.and("rei.jf_source", "=", "ACTIVITY_BUDGET_TYPE_THREE");
group.or(group1);
SqlExpressionGroup group2 = new SqlExpressionGroup();
group2.and("rei.unionId", "=", Vi.getUnionId());
group2.and("rei.jf_source", "=", "ACTIVITY_BUDGET_TYPE_TWO");
group.or(group2);
cnd.and(group);
cnd.andEX("YEAR(rei.applyTime)", "=", page.getYear());
cnd.desc("rei.applyTime");
sql.setCondition(cnd);
return reimbursementViService.listPageMap(page.getPageNumber(), page.getPageSize(), sql);
}
@At
@ViReturn
@RequiresPermissions("reimbursement.unionAudit")
public Object doAudit(@Param("id") String id, @Param("flag") Integer flag, Audit audit) {
ReimbursementNew reimbursementNew = reimbursementViService.fetch(id);
audit.setLoginname(ShiroUtil.getPlatformLoginname());
audit.setUsername(ShiroUtil.getPlatformUsername());
audit.setAuditTime(new Date());
reimbursementViService.insert(audit);
ReimbursementToDoHandler.COMPLETE_UNION_TASK.exec(reimbursementNew, audit.getAuditOpinion());
Integer auditState;
if (flag == 1) {
auditState = ReimbursementState.UNION_FAIL;
//拒绝
ReimbursementToDoHandler.COMPLETE_PROCESS.exec(reimbursementNew, audit.getAuditOpinion());
} else if (flag == 2) {
auditState = ReimbursementState.UNION_GO_BACK;
//返回修改
ReimbursementToDoHandler.CREATE_BACK_UNION_TASK.exec(reimbursementNew, audit.getAuditOpinion());
} else {
auditState = ReimbursementState.UNION_MANAGE;
ReimbursementToDoHandler.CREATE_UNION_MANAGE_TASK.exec(reimbursementNew, audit.getAuditOpinion());
}
Chain chain = Chain.make("unionAuditId", audit.getId()).add("state", auditState);
reimbursementViService.update(chain, Cnd.where("id", "=", id));
return null;
}
@At
@ViReturn
@Aop(TransAop.READ_COMMITTED)
@RequiresPermissions("reimbursement.unionAudit")
public Object doRevoke(@Param("id") String id) {
Chain chain = Chain.make("unionAuditId", null).add("state", ReimbursementState.UNION);
reimbursementViService.update(chain, Cnd.where("id", "=", id));
localProcessService.revokeTask("reimbursement@" + id, "分工会主席审核");
return null;
}
}
@@ -0,0 +1,156 @@
package io.v.nutz.zhgh.reimbursement.controller;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import io.v.nutz.base.annontation.ViReturn;
import io.v.nutz.base.model.Audit;
import io.v.nutz.base.result.Result;
import io.v.nutz.base.service.AuditService;
import io.v.nutz.base.utils.DateUtil;
import io.v.nutz.sys.services.SysLocalProcessService;
import io.v.nutz.web.commons.slog.annotation.SLog;
import io.v.nutz.web.commons.utils.ShiroUtil;
import io.v.nutz.zhgh.activityBudget.models.ActivityBudget;
import io.v.nutz.zhgh.jf.model.*;
import io.v.nutz.zhgh.reimbursement.constants.ReimbursementState;
import io.v.nutz.zhgh.reimbursement.handler.ReimbursementToDoHandler;
import io.v.nutz.zhgh.reimbursement.models.ReimbursementNew;
import io.v.nutz.zhgh.reimbursement.models.ReimbursementPageForm;
import io.v.nutz.zhgh.reimbursement.services.ReimbursementService;
import org.apache.shiro.authz.annotation.RequiresAuthentication;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.nutz.aop.interceptor.ioc.TransAop;
import org.nutz.dao.Chain;
import org.nutz.dao.Cnd;
import org.nutz.dao.Sqls;
import org.nutz.dao.sql.Sql;
import org.nutz.ioc.aop.Aop;
import org.nutz.ioc.loader.annotation.Inject;
import org.nutz.ioc.loader.annotation.IocBean;
import org.nutz.mvc.annotation.At;
import org.nutz.mvc.annotation.Ok;
import org.nutz.mvc.annotation.Param;
import java.util.Date;
/**
* @author zhf
* @date 2021/6/7 16:58
* @description 常务副主席审核
*/
@At("/platform/reimbursement/standingViceChairmanAudit")
@IocBean
@RequiresAuthentication
@Ok("json")
public class StandingViceChairmanAuditController {
@Inject
private ReimbursementService reimbursementViService;
@Inject
private AuditService auditService;
@Inject
private SysLocalProcessService localProcessService;
@At("")
@Ok("beetl:/platform/reimbursement/standingViceChairmanAudit.html")
@RequiresPermissions("reimbursement.standingViceChairmanAudit")
public void index() {
}
@At
@ViReturn
@RequiresPermissions("reimbursement.standingViceChairmanAudit")
public Object pageData(ReimbursementPageForm page) {
Sql sql = Sqls.create("""
SELECT
rei.*,
be.username be_username,
state.stateName,
state.stateColor,
cl.`name` clubName
FROM
`reimbursement_new` rei
LEFT JOIN sys_user be ON be.id = rei.be_user
LEFT JOIN audit_state state ON state.stateId = rei.state
LEFT JOIN sys_club cl ON cl.id = rei.clubId
$condition
""");
Cnd cnd = Cnd.NEW();
cnd.andEX("rei.unionId", "=", page.getUnionId());
cnd.andEX("rei.unitId", "=", page.getUnitId());
cnd.andEX("rei.clubId", "=", page.getClubId());
cnd.andEX("rei.jf_source", "=", page.getJf_source());
cnd.andEX("rei.detailsTypeId", "=", page.getDetailsTypeId());
if (page.getIsAudit() != 1) {
cnd.and("rei.State", page.getIsAudit() == 2 ? ">" : "=", ReimbursementState.STANDING_VICE_CHAIRMAN);
} else {
cnd.and("rei.State", ">=", ReimbursementState.STANDING_VICE_CHAIRMAN);
}
if (StrUtil.isAllNotEmpty(page.getSearchName(), page.getSearchKeyword())) {
cnd.where().andLike(page.getSearchName(), page.getSearchKeyword());
}
cnd.andEX("YEAR(rei.applyTime)", "=", page.getYear());
cnd.desc("rei.applyTime");
sql.setCondition(cnd);
return reimbursementViService.listPageMap(page.getPageNumber(), page.getPageSize(), sql);
}
@At
@ViReturn
@Aop(TransAop.READ_COMMITTED)
@SLog(tag = "工会报销", msg = "审核了一条记录", param = true, result = true)
@RequiresPermissions("reimbursement.standingViceChairmanAudit")
public Object doAudit(@Param("id") String id,
@Param("flag") Integer flag,
Audit audit) {
audit.setLoginname(ShiroUtil.getPlatformLoginname());
audit.setUsername(ShiroUtil.getPlatformUsername());
audit.setAuditTime(new Date());
reimbursementViService.insert(audit);
ReimbursementNew reimbursementNew = reimbursementViService.fetch(id);
ReimbursementToDoHandler.COMPLETE_STANDING_VICE_CHAIRMAN_TASK.exec(reimbursementNew, audit.getAuditOpinion());
Integer auditState;
if (flag == 1) {
auditState = ReimbursementState.STANDING_VICE_CHAIRMAN_FAIL;
//拒绝
ReimbursementToDoHandler.COMPLETE_PROCESS.exec(reimbursementNew, audit.getAuditOpinion());
} else if (flag == 2) {
auditState = ReimbursementState.STANDING_VICE_CHAIRMAN_GO_BACK;
//返回修改
ReimbursementToDoHandler.CREATE_BACK_STANDING_VICE_CHAIRMAN_TASK.exec(reimbursementNew, audit.getAuditOpinion());
} else {
auditState = ReimbursementState.FINANCE;
ReimbursementToDoHandler.CREATE_FINANCE_TASK.exec(reimbursementNew, audit.getAuditOpinion());
}
Chain chain = Chain.make("standingViceChairmanAuditId", audit.getId()).add("state", auditState);
reimbursementViService.update(chain, Cnd.where("id", "=", id));
return null;
}
@At
@ViReturn
@Aop(TransAop.READ_COMMITTED)
@SLog(tag = "工会报销", msg = "撤回了一条记录", param = true, result = true)
@RequiresPermissions("reimbursement.standingViceChairmanAudit")
public Object doRevoke(@Param("id") String id) {
Chain chain = Chain.make("standingViceChairmanAuditId", null)
.add("state", ReimbursementState.STANDING_VICE_CHAIRMAN);
reimbursementViService.update(chain, Cnd.where("id", "=", id));
localProcessService.revokeTask("reimbursement@" + id, "工会主席审核");
return null;
}
}
@@ -1,142 +0,0 @@
package io.v.nutz.zhgh.reimbursement.controller;
import io.v.nutz.base.annontation.ViReturn;
import io.v.nutz.base.utils.DateUtil;
import io.v.nutz.base.utils.Vi;
import io.v.nutz.base.dao.CndPlus;
import io.v.nutz.zhgh.jf.model.ActivityBx;
import io.v.nutz.zhgh.jf.service.ActivityBxService;
import io.v.nutz.base.model.Audit;
import io.v.nutz.base.query.PageForm;
import io.v.nutz.base.model.Review;
import io.v.nutz.base.service.AuditService;
import io.v.nutz.base.service.ReviewService;
import io.v.nutz.zhgh.reimbursement.constants.ReimbursementState;
import io.v.nutz.zhgh.reimbursement.models.Reimbursement;
import io.v.nutz.base.service.ViService;
import io.v.nutz.sys.services.SysSignatureService;
import io.v.nutz.web.commons.utils.ShiroUtil;
import io.v.nutz.zhgh.zgfw.model.condolence.Condolence;
import io.v.nutz.zhgh.zgfw.service.CondolenceService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.nutz.dao.Cnd;
import org.nutz.dao.Sqls;
import org.nutz.dao.sql.Sql;
import org.nutz.ioc.loader.annotation.Inject;
import org.nutz.ioc.loader.annotation.IocBean;
import org.nutz.mvc.annotation.At;
import org.nutz.mvc.annotation.Ok;
import org.nutz.mvc.annotation.Param;
import java.util.Date;
/**
* @author zhf
* @date 2021/6/7 16:58
* @description 常务副主席审核
*/
@At("/platform/reimbursement/StandingViceChairman")
@IocBean
@Ok("json")
public class StandingViceChairmanController {
@Inject("Reimbursement")
private ViService<Reimbursement> reimbursementViService;
@Inject
private ActivityBxService activityBxService;
@Inject
private SysSignatureService sysSignatureService;
@Inject
private AuditService auditService;
@Inject
private ReviewService reviewService;
@Inject
private CondolenceService condolenceService;
@At("")
@Ok("beetl:/platform/reimbursement/StandingViceChairman.html")
@RequiresPermissions("reimbursement.StandingViceChairman")
public void index() {
}
@At
@ViReturn
@RequiresPermissions("reimbursement.StandingViceChairman")
public Object pageData(PageForm page,
@Param(value = "isAudit", required = false) boolean isAudit,
@Param(value = "unitId", required = false) String unitId,
@Param(value = "year", required = false) Integer year,
@Param(value = "unionId", required = false) String unionId,
@Param(value = "reiItemId", required = false) Integer reiItemId) {
Sql sql = Sqls.create("""
SELECT
rei.*,
us.unionname,
state.stateColor,
state.stateName
FROM
`reimbursement` rei
LEFT JOIN `user` us ON us.id = rei.userid
LEFT JOIN condolence con ON con.id = rei.reimbursementId
LEFT JOIN activity_bx bx ON bx.id = rei.reimbursementId
LEFT JOIN audit_state state ON rei.State = state.stateId $condition
""");
CndPlus cnd = CndPlus.create();
cnd.and("rei.State", isAudit ? ">" : "=", ReimbursementState.STANDING_VICE_CHAIRMAN);
Vi.cndPlus(cnd, "rei.reimbursementItemId", "=", reiItemId);
Vi.cndPlus(cnd, "YEAR(rei.applyTime)", "=", year);
Vi.cndPlus(cnd, "us.unitid", "=", unitId);
Vi.cndPlus(cnd, "us.unionid", "=", unionId);
if (Vi.isNotBlank(page.getSearchName(), page.getSearchKeyword())) {
cnd.where().andLike(page.getSearchName(), page.getSearchKeyword());
}
cnd.desc("rei.applyTime");
sql.setCondition(cnd);
return reimbursementViService.listPageMap(page.getPageNumber(), page.getPageSize(), sql);
}
@At
@ViReturn
@RequiresPermissions("reimbursement.StandingViceChairman")
public Object doReview(String id, Boolean flag, Audit audit, Review review, Integer reimbursementItemId) {
if (reimbursementItemId != 4) {
audit.setLoginname(ShiroUtil.getPrincipalProperty("loginname").toString());
audit.setUsername(ShiroUtil.getPrincipalProperty("username").toString());
audit.setAuditTime(new Date());
audit = auditService.insert(audit);
ActivityBx aid = activityBxService.fetch(id);
aid.setStanding_vice_chairman_audit_id(audit.getId());
aid.setState_id(flag ? "3100" : "3095");
activityBxService.updateIgnoreNull(aid);
} else {
review.setLoginname(ShiroUtil.getPrincipalProperty("loginname").toString());
review.setUsername(ShiroUtil.getPrincipalProperty("username").toString());
review.setTime(DateUtil.getDate());
review = reviewService.insert(review);
Condolence condolence = condolenceService.fetch(id);
condolence.setExecutive_chairman_review(review.getId());
condolence.setState_id(flag ? "3100" : "3095");
condolenceService.updateIgnoreNull(condolence);
}
Reimbursement reimbursement = reimbursementViService.fetch(Cnd.where("reimbursementId", "=", id));
reimbursement.setState(flag ? ReimbursementState.SUCCESSFUL_REIMBURSEMENT : ReimbursementState.STANDING_VICE_CHAIRMAN_FAIL);
reimbursementViService.updateIgnoreNull(reimbursement);
return null;
}
}
@@ -0,0 +1,130 @@
package io.v.nutz.zhgh.reimbursement.controller;
import io.v.nutz.base.annontation.ViReturn;
import io.v.nutz.base.model.Audit;
import io.v.nutz.base.utils.Vi;
import io.v.nutz.sys.services.SysClubService;
import io.v.nutz.sys.services.SysLocalProcessService;
import io.v.nutz.web.commons.utils.ShiroUtil;
import io.v.nutz.zhgh.reimbursement.constants.ReimbursementState;
import io.v.nutz.zhgh.reimbursement.handler.ReimbursementToDoHandler;
import io.v.nutz.zhgh.reimbursement.models.ReimbursementNew;
import io.v.nutz.zhgh.reimbursement.models.ReimbursementPageForm;
import io.v.nutz.zhgh.reimbursement.services.ReimbursementService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.nutz.aop.interceptor.ioc.TransAop;
import org.nutz.dao.Chain;
import org.nutz.dao.Cnd;
import org.nutz.dao.Sqls;
import org.nutz.dao.sql.Sql;
import org.nutz.ioc.aop.Aop;
import org.nutz.ioc.loader.annotation.Inject;
import org.nutz.ioc.loader.annotation.IocBean;
import org.nutz.mvc.annotation.At;
import org.nutz.mvc.annotation.Ok;
import org.nutz.mvc.annotation.Param;
import java.util.Date;
/**
* @author zhf
* @date 2025/8/30 16:19
* @description 工会办公室主管审核
*/
@At("/platform/reimbursement/unionManageAudit")
@IocBean
@Ok("json:full")
public class UnionManageAuditController {
@Inject
private ReimbursementService reimbursementViService;
@Inject
private SysLocalProcessService localProcessService;
@At("")
@Ok("beetl:/platform/reimbursement/unionManageAudit.html")
@RequiresPermissions("reimbursement.unionManageAudit")
public void index() {
}
@At
@ViReturn
@RequiresPermissions("reimbursement.unionManageAudit")
public Object pageData(ReimbursementPageForm page) {
Sql sql = Sqls.create("""
SELECT
rei.*,
be.username be_username,
state.stateName,
state.stateColor,
cl.`name` clubName
FROM
`reimbursement_new` rei
LEFT JOIN sys_user be ON be.id = rei.be_user
LEFT JOIN audit_state state ON state.stateId = rei.state
LEFT JOIN sys_club cl ON cl.id = rei.clubId
$condition
""");
Cnd cnd = Cnd.NEW();
if (page.getIsAudit() != 1) {
cnd.and("rei.State", page.getIsAudit() == 2 ? ">" : "=", ReimbursementState.UNION_MANAGE);
} else {
cnd.and("rei.State", ">=", ReimbursementState.UNION_MANAGE);
}
cnd.andEX("rei.unionId", "=", page.getUnionId());
cnd.andEX("rei.unitId", "=", page.getUnitId());
cnd.andEX("rei.clubId", "=", page.getClubId());
cnd.andEX("rei.jf_source", "=", page.getJf_source());
if (Vi.isNotBlank(page.getSearchName(), page.getSearchKeyword())) {
cnd.where().andLike(page.getSearchName(), page.getSearchKeyword());
}
cnd.andEX("YEAR(rei.applyTime)", "=", page.getYear());
cnd.desc("rei.applyTime");
sql.setCondition(cnd);
return reimbursementViService.listPageMap(page.getPageNumber(), page.getPageSize(), sql);
}
@At
@ViReturn
@RequiresPermissions("reimbursement.unionManageAudit")
public Object doAudit(@Param("id") String id, @Param("flag") Integer flag, Audit audit) {
ReimbursementNew reimbursementNew = reimbursementViService.fetch(id);
audit.setLoginname(ShiroUtil.getPlatformLoginname());
audit.setUsername(ShiroUtil.getPlatformUsername());
audit.setAuditTime(new Date());
reimbursementViService.insert(audit);
ReimbursementToDoHandler.COMPLETE_UNION_MANAGE_TASK.exec(reimbursementNew, audit.getAuditOpinion());
Integer auditState;
if (flag == 1) {
auditState = ReimbursementState.UNION_MANAGE_FAIL;
//拒绝
ReimbursementToDoHandler.COMPLETE_PROCESS.exec(reimbursementNew, audit.getAuditOpinion());
} else if (flag == 2) {
auditState = ReimbursementState.UNION_MANAGE_GO_BACK;
//返回修改
ReimbursementToDoHandler.CREATE_BACK_UNION_MANAGE_TASK.exec(reimbursementNew, audit.getAuditOpinion());
} else {
auditState = ReimbursementState.VICE_CHAIRMAN;
ReimbursementToDoHandler.CREATE_VICE_CHAIRMAN_TASK.exec(reimbursementNew, audit.getAuditOpinion());
}
Chain chain = Chain.make("unionManageAuditId", audit.getId()).add("state", auditState);
reimbursementViService.update(chain, Cnd.where("id", "=", id));
return null;
}
@At
@ViReturn
@Aop(TransAop.READ_COMMITTED)
@RequiresPermissions("reimbursement.unionManageAudit")
public Object doRevoke(@Param("id") String id) {
Chain chain = Chain.make("unionManageAuditId", null).add("state", ReimbursementState.UNION_MANAGE);
reimbursementViService.update(chain, Cnd.where("id", "=", id));
localProcessService.revokeTask("reimbursement@" + id, "工会办公室主管审核");
return null;
}
}
@@ -0,0 +1,152 @@
package io.v.nutz.zhgh.reimbursement.controller;
import cn.hutool.core.util.StrUtil;
import io.v.nutz.base.annontation.ViReturn;
import io.v.nutz.base.model.Audit;
import io.v.nutz.base.result.Result;
import io.v.nutz.sys.services.SysLocalProcessService;
import io.v.nutz.web.commons.slog.annotation.SLog;
import io.v.nutz.web.commons.utils.ShiroUtil;
import io.v.nutz.zhgh.reimbursement.constants.ReimbursementState;
import io.v.nutz.zhgh.reimbursement.handler.ReimbursementToDoHandler;
import io.v.nutz.zhgh.reimbursement.models.ReimbursementNew;
import io.v.nutz.zhgh.reimbursement.models.ReimbursementPageForm;
import io.v.nutz.zhgh.reimbursement.services.ReimbursementService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.nutz.aop.interceptor.ioc.TransAop;
import org.nutz.dao.Chain;
import org.nutz.dao.Cnd;
import org.nutz.dao.Sqls;
import org.nutz.dao.sql.Sql;
import org.nutz.ioc.aop.Aop;
import org.nutz.ioc.loader.annotation.Inject;
import org.nutz.ioc.loader.annotation.IocBean;
import org.nutz.mvc.annotation.At;
import org.nutz.mvc.annotation.Ok;
import org.nutz.mvc.annotation.Param;
import java.math.BigDecimal;
import java.util.Date;
/**
* @author zhf
* @date 2021/6/7 15:27
* @description 工会副主席
*/
@At("/platform/reimbursement/viceChairmanAudit")
@IocBean
@Ok("json")
public class ViceChairmanAuditController {
@Inject
private ReimbursementService reimbursementViService;
@Inject
private SysLocalProcessService localProcessService;
@At("")
@Ok("beetl:/platform/reimbursement/viceChairmanAudit.html")
@RequiresPermissions("reimbursement.viceChairmanAudit")
public void index() {
}
@At
@ViReturn
@RequiresPermissions("reimbursement.viceChairmanAudit")
public Object pageData(ReimbursementPageForm page) {
Sql sql = Sqls.create("""
SELECT
rei.*,
be.username be_username,
state.stateName,
state.stateColor,
cl.`name` clubName
FROM
`reimbursement_new` rei
LEFT JOIN sys_user be ON be.id = rei.be_user
LEFT JOIN audit_state state ON state.stateId = rei.state
LEFT JOIN sys_club cl ON cl.id = rei.clubId
$condition
""");
Cnd cnd = Cnd.NEW();
cnd.andEX("rei.unionId", "=", page.getUnionId());
cnd.andEX("rei.unitId", "=", page.getUnitId());
cnd.andEX("rei.clubId", "=", page.getClubId());
cnd.andEX("rei.jf_source", "=", page.getJf_source());
if (page.getIsAudit() != 1) {
cnd.and("rei.State", page.getIsAudit() == 2 ? ">" : "=", ReimbursementState.VICE_CHAIRMAN);
} else {
cnd.and("rei.State", ">=", ReimbursementState.VICE_CHAIRMAN);
}
if (StrUtil.isAllNotEmpty(page.getSearchName(), page.getSearchKeyword())) {
cnd.where().andLike(page.getSearchName(), page.getSearchKeyword());
}
cnd.andEX("YEAR(rei.applyTime)", "=", page.getYear());
cnd.desc("rei.applyTime");
sql.setCondition(cnd);
return reimbursementViService.listPageMap(page.getPageNumber(), page.getPageSize(), sql);
}
@At
@ViReturn
@Aop(TransAop.READ_COMMITTED)
@SLog(tag = "工会报销", msg = "审核了一条记录", param = true, result = true)
@RequiresPermissions("reimbursement.viceChairmanAudit")
public Object doAudit(@Param("id") String id, @Param("flag") Integer flag, Audit audit) {
ReimbursementNew reimbursementNew = reimbursementViService.fetch(id);
ReimbursementToDoHandler.COMPLETE_VICE_CHAIRMAN_TASK.exec(reimbursementNew, audit.getAuditOpinion());
Integer auditState;
if (flag == 1) {
auditState = ReimbursementState.VICE_CHAIRMAN_FAIL;
//拒绝
ReimbursementToDoHandler.COMPLETE_PROCESS.exec(reimbursementNew, audit.getAuditOpinion());
} else if (flag == 2) {
auditState = ReimbursementState.VICE_CHAIRMAN_GO_BACK;
//返回修改
ReimbursementToDoHandler.CREATE_BACK_VICE_CHAIRMAN_TASK.exec(reimbursementNew, audit.getAuditOpinion());
} else {
if (reimbursementNew.getMoney().compareTo(BigDecimal.valueOf(50000)) > 0) {
auditState = ReimbursementState.STANDING_VICE_CHAIRMAN;
ReimbursementToDoHandler.CREATE_STANDING_VICE_CHAIRMAN_TASK.exec(reimbursementNew, audit.getAuditOpinion());
}else{
auditState = ReimbursementState.FINANCE;
ReimbursementToDoHandler.CREATE_FINANCE_TASK.exec(reimbursementNew, audit.getAuditOpinion());
}
}
audit.setLoginname(ShiroUtil.getPlatformLoginname());
audit.setUsername(ShiroUtil.getPlatformUsername());
audit.setAuditTime(new Date());
reimbursementViService.insert(audit);
reimbursementViService.update(Chain.make("viceChairmanAuditId", audit.getId())
.add("state", auditState), Cnd.where("id", "=", id));
return null;
}
@At
@Aop(TransAop.READ_COMMITTED)
@SLog(tag = "工会报销", msg = "撤回了一条记录", param = true, result = true)
@RequiresPermissions("reimbursement.viceChairmanAudit")
public Result doRevoke(@Param("id") String id) {
Chain chain = Chain.make("viceChairmanAuditId", null)
.add("state", ReimbursementState.VICE_CHAIRMAN);
reimbursementViService.update(chain, Cnd.where("id", "=", id));
localProcessService.revokeTask("reimbursement@" + id, "工会办公室主管审核");
return Result.success();
}
@At
@ViReturn
@RequiresPermissions("reimbursement.viceChairmanAudit")
public Object getClubsByRole() {
return reimbursementViService.getClubsByRole();
}
}
@@ -1,137 +0,0 @@
package io.v.nutz.zhgh.reimbursement.controller;
import io.v.nutz.base.annontation.ViReturn;
import io.v.nutz.base.utils.DateUtil;
import io.v.nutz.base.utils.Vi;
import io.v.nutz.base.dao.CndPlus;
import io.v.nutz.zhgh.jf.model.ActivityBx;
import io.v.nutz.zhgh.jf.service.ActivityBxService;
import io.v.nutz.base.model.Audit;
import io.v.nutz.base.query.PageForm;
import io.v.nutz.base.model.Review;
import io.v.nutz.base.service.AuditService;
import io.v.nutz.base.service.ReviewService;
import io.v.nutz.zhgh.reimbursement.constants.ReimbursementState;
import io.v.nutz.zhgh.reimbursement.models.Reimbursement;
import io.v.nutz.base.service.ViService;
import io.v.nutz.sys.services.SysSignatureService;
import io.v.nutz.web.commons.utils.ShiroUtil;
import io.v.nutz.zhgh.zgfw.model.condolence.Condolence;
import io.v.nutz.zhgh.zgfw.service.CondolenceService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.nutz.dao.Cnd;
import org.nutz.dao.Sqls;
import org.nutz.dao.sql.Sql;
import org.nutz.ioc.loader.annotation.Inject;
import org.nutz.ioc.loader.annotation.IocBean;
import org.nutz.mvc.annotation.At;
import org.nutz.mvc.annotation.Ok;
import org.nutz.mvc.annotation.Param;
import java.util.Date;
/**
* @author zhf
* @date 2021/6/7 15:27
* @description 分管副主席
*/
@At("/platform/reimbursement/ViceChairman")
@IocBean
@Ok("json")
public class ViceChairmanController {
@Inject("Reimbursement")
private ViService<Reimbursement> reimbursementViService;
@Inject
private ActivityBxService activityBxService;
@Inject
private SysSignatureService sysSignatureService;
@Inject
private AuditService auditService;
@Inject
private ReviewService reviewService;
@Inject
private CondolenceService condolenceService;
@At("")
@Ok("beetl:/platform/reimbursement/ViceChairman.html")
@RequiresPermissions("reimbursement.ViceChairman")
public void index() {
}
@At
@ViReturn
@RequiresPermissions("reimbursement.ViceChairman")
public Object pageData(PageForm page,
@Param(value = "isAudit", required = false) boolean isAudit,
@Param(value = "year", required = false) Integer year,
@Param(value = "unitId", required = false) String unitId,
@Param(value = "unionId", required = false) String unionId,
@Param(value = "reiItemId", required = false) Integer reiItemId) {
Sql sql = Sqls.create("""
SELECT
rei.*,
us.unionname,
state.stateColor,
state.stateName
FROM
`reimbursement` rei
LEFT JOIN `user` us ON us.id = rei.userid
LEFT JOIN condolence con ON con.id = rei.reimbursementId
LEFT JOIN activity_bx bx ON bx.id = rei.reimbursementId
LEFT JOIN audit_state state ON rei.State = state.stateId $condition
""");
CndPlus cnd = CndPlus.create();
cnd.and("rei.State", isAudit ? ">" : "=", ReimbursementState.VICE_CHAIRMAN);
Vi.cndPlus(cnd, "rei.reimbursementItemId", "=", reiItemId);
Vi.cndPlus(cnd, "YEAR(rei.applyTime)", "=", year);
Vi.cndPlus(cnd, "us.unitid", "=", unitId);
Vi.cndPlus(cnd, "us.unionid", "=", unionId);
cnd.desc("rei.applyTime");
sql.setCondition(cnd);
return reimbursementViService.listPageMap(page.getPageNumber(), page.getPageSize(), sql);
}
@At
@ViReturn
@RequiresPermissions("reimbursement.ViceChairman")
public Object doReview(String id, Boolean flag, Audit audit, Review review, Integer reimbursementItemId) {
if (reimbursementItemId != 4) {
audit.setLoginname(ShiroUtil.getPrincipalProperty("loginname").toString());
audit.setUsername(ShiroUtil.getPrincipalProperty("username").toString());
audit.setAuditTime(new Date());
audit = auditService.insert(audit);
ActivityBx aid = activityBxService.fetch(id);
aid.setVice_chairman_audit_id(audit.getId());
aid.setState_id(flag ? "3090" : "3085");
activityBxService.updateIgnoreNull(aid);
} else {
review.setLoginname(ShiroUtil.getPrincipalProperty("loginname").toString());
review.setUsername(ShiroUtil.getPrincipalProperty("username").toString());
review.setTime(DateUtil.getDate());
review = reviewService.insert(review);
Condolence condolence = condolenceService.fetch(id);
condolence.setVice_chairman_review(review.getId());
condolence.setState_id(flag ? "3090" : "3085");
condolenceService.updateIgnoreNull(condolence);
}
Reimbursement reimbursement = reimbursementViService.fetch(Cnd.where("reimbursementId", "=", id));
reimbursement.setState(flag ? ReimbursementState.STANDING_VICE_CHAIRMAN : ReimbursementState.VICE_CHAIRMAN_FAIL);
reimbursementViService.updateIgnoreNull(reimbursement);
return null;
}
}
@@ -1,35 +1,40 @@
package io.v.nutz.zhgh.reimbursement.controller;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import cn.wizzer.framework.base.Result;
import io.v.nutz.base.annontation.Valid;
import io.v.nutz.base.annontation.ViReturn;
import io.v.nutz.base.service.BaseService;
import io.v.nutz.base.utils.DateUtil;
import io.v.nutz.base.utils.MsgApi;
import io.v.nutz.base.utils.Roles;
import io.v.nutz.base.utils.Vi;
import io.v.nutz.sys.models.Sys_club_user;
import io.v.nutz.web.commons.slog.annotation.SLog;
import io.v.nutz.web.commons.utils.ShiroUtil;
import io.v.nutz.zhgh.activityBudget.handler.ActivityBudgetUserApplyToDoHandler;
import io.v.nutz.zhgh.activityBudget.models.ActivityBudget;
import io.v.nutz.zhgh.jf.model.jf_club;
import io.v.nutz.zhgh.jf.model.jf_school;
import io.v.nutz.zhgh.jf.model.jf_yjgh;
import io.v.nutz.zhgh.reimbursement.constants.ReimbursementState;
import io.v.nutz.zhgh.reimbursement.handler.ReimbursementToDoHandler;
import io.v.nutz.zhgh.reimbursement.models.ReimbursementNew;
import io.v.nutz.sys.models.Sys_club_user;
import io.v.nutz.web.commons.utils.ShiroUtil;
import io.v.nutz.web.commons.slog.annotation.SLog;
import io.v.nutz.zhgh.reimbursement.services.ReimbursementService;
import org.apache.shiro.authz.annotation.RequiresAuthentication;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.nutz.dao.Cnd;
import org.nutz.dao.Dao;
import org.nutz.dao.Sqls;
import org.nutz.dao.sql.Sql;
import org.nutz.dao.util.cri.Static;
import org.nutz.ioc.loader.annotation.Inject;
import org.nutz.ioc.loader.annotation.IocBean;
import org.nutz.lang.Lang;
import org.nutz.lang.util.NutMap;
import org.nutz.mvc.annotation.At;
import org.nutz.mvc.annotation.Ok;
import org.nutz.mvc.annotation.Param;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.List;
/**
@@ -42,16 +47,17 @@ import java.util.List;
@At("/platform/reimbursement/applyNew")
@Ok("json:full")
@IocBean
@RequiresAuthentication
public class applyNewController {
@Inject
private BaseService baseService;
@Inject
private ReimbursementService reimbursementService;
@Inject
private Dao dao;
@Inject
private MsgApi msgApi;
@At("")
@Ok("beetl:/platform/reimbursement/applyNew.html")
@@ -59,11 +65,13 @@ public class applyNewController {
public void index() {
}
@At
@ViReturn
@RequiresAuthentication
@RequiresPermissions("reimbursement.applyNew")
@SLog(tag = "工会报销", msg = "新增一条记录", param = true, result = true)
public Object doAdd(@Param("data") ReimbursementNew reimbursementNew) {
public Object doAdd(@Param("data") ReimbursementNew reimbursementNew, Boolean flag) {
//查询发票号码有没有重复的
String billNumber = reimbursementNew.getBillNumber();
if (StrUtil.isNotBlank(billNumber)) {
@@ -81,28 +89,43 @@ public class applyNewController {
reimbursementNew.setUserId(ShiroUtil.getUserId());
reimbursementNew.setUnitId(ShiroUtil.getUnitId());
reimbursementNew.setUnionId(Vi.getUnionId());
reimbursementNew.setState(ReimbursementState.AUDIT_CONFIRM);
if (flag) {
if (List.of("ACTIVITY_BUDGET_TYPE_THREE", "ACTIVITY_BUDGET_TYPE_FOUR").contains(reimbursementNew.getJf_source())) {
reimbursementNew.setState(ReimbursementState.CLUB);
} else if (reimbursementNew.getJf_source().equals("ACTIVITY_BUDGET_TYPE_TWO")) {
reimbursementNew.setState(ReimbursementState.UNION);
} else {
reimbursementNew.setState(ReimbursementState.UNION_MANAGE);
}
} else {
reimbursementNew.setState(ReimbursementState.STAY_SUBMIT);
}
reimbursementNew.setApplyTime(DateUtil.getDateTime());
baseService.insert(reimbursementNew);
Sql sql = Sqls.create("""
SELECT
u.loginname
FROM
sys_user_role role
LEFT JOIN sys_user u ON u.id = role.userId
WHERE
role.roleId = @kj
""").setParam("kj", Roles.XGHKJ);
List<NutMap> list = baseService.listMap(sql);
list.forEach(v -> {
//msgApi.sendWxMsg("%s(%s)提交了一条报销申请待您审核,请前往智慧工会查看!".formatted(reimbursementNew.getUserName(), reimbursementNew.getLoginName()), v.getString("loginname"));
});
if (flag) {
//插入后,发起待办流程
ReimbursementToDoHandler.START_PROCESS.exec(reimbursementNew, null);
if (List.of("ACTIVITY_BUDGET_TYPE_THREE", "ACTIVITY_BUDGET_TYPE_FOUR").contains(reimbursementNew.getJf_source())) {
//发任务给分工会主席审核
ReimbursementToDoHandler.CREATE_CLUB_TASK.exec(reimbursementNew, null);
} else if (reimbursementNew.getJf_source().equals("ACTIVITY_BUDGET_TYPE_TWO")) {
//发任务给分工会主席审核
ReimbursementToDoHandler.CREATE_UNION_TASK.exec(reimbursementNew, null);
} else {
//发任务给工会办公室主管审核
ReimbursementToDoHandler.CREATE_UNION_MANAGE_TASK.exec(reimbursementNew, null);
}
//完成申请人的任务(申请拒绝的情况)
ReimbursementToDoHandler.COMPLETE_APPLY_TASK.exec(reimbursementNew, null);
}
return null;
}
@At
@ViReturn
@RequiresPermissions("reimbursement.applyNew")
@RequiresAuthentication
public Object findOne(String id) {
ReimbursementNew fetch = baseService.dao().fetch(ReimbursementNew.class, id);
return fetch;
@@ -112,7 +135,7 @@ public class applyNewController {
@ViReturn
@RequiresPermissions("reimbursement.applyNew")
@SLog(tag = "工会报销", msg = "编辑一条记录", param = true, result = true)
public Object doEdit(@Param("data") ReimbursementNew reimbursementNew) {
public Object doEdit(@Param("data") ReimbursementNew reimbursementNew, Boolean flag) {
//查询发票号码有没有重复的
String billNumber = reimbursementNew.getBillNumber();
if (StrUtil.isNotBlank(billNumber)) {
@@ -128,72 +151,42 @@ public class applyNewController {
}
}
}
if (reimbursementNew.getState().equals(ReimbursementState.MODIFY)) {
Sql sql = Sqls.create("""
SELECT
u.loginname
FROM
sys_user_role role
LEFT JOIN sys_user u ON u.id = role.userId
WHERE
role.roleId = @kj
""").setParam("kj", Roles.XGHKJ);
List<NutMap> list = baseService.listMap(sql);
list.forEach(v -> {
//msgApi.sendWxMsg("%s(%s)提交了一条报销申请待您审核,请前往智慧工会查看!".formatted(reimbursementNew.getUserName(), reimbursementNew.getLoginName()), v.getString("loginname"));
});
if (flag) {
if (List.of("ACTIVITY_BUDGET_TYPE_THREE", "ACTIVITY_BUDGET_TYPE_FOUR").contains(reimbursementNew.getJf_source())) {
reimbursementNew.setState(ReimbursementState.CLUB);
} else if (reimbursementNew.getJf_source().equals("ACTIVITY_BUDGET_TYPE_TWO")) {
reimbursementNew.setState(ReimbursementState.UNION);
} else {
reimbursementNew.setState(ReimbursementState.UNION_MANAGE);
}
} else {
reimbursementNew.setState(ReimbursementState.STAY_SUBMIT);
}
reimbursementNew.setState(ReimbursementState.AUDIT_CONFIRM);
baseService.updateIgnoreNull(reimbursementNew);
if (flag) {
//插入后,发起待办流程
ReimbursementToDoHandler.START_PROCESS.exec(reimbursementNew, null);
if (List.of("ACTIVITY_BUDGET_TYPE_THREE", "ACTIVITY_BUDGET_TYPE_FOUR").contains(reimbursementNew.getJf_source())) {
//发任务给分工会主席审核
ReimbursementToDoHandler.CREATE_CLUB_TASK.exec(reimbursementNew, null);
} else if (reimbursementNew.getJf_source().equals("ACTIVITY_BUDGET_TYPE_TWO")) {
//发任务给分工会主席审核
ReimbursementToDoHandler.CREATE_UNION_TASK.exec(reimbursementNew, null);
} else {
//发任务给工会办公室主管审核
ReimbursementToDoHandler.CREATE_UNION_MANAGE_TASK.exec(reimbursementNew, null);
}
//完成申请人的任务(申请拒绝的情况)
ReimbursementToDoHandler.COMPLETE_APPLY_TASK.exec(reimbursementNew, null);
}
return null;
}
@At
@RequiresPermissions("reimbursement.applyNew")
public Object getBalance() {
jf_yjgh yjgh = baseService.dao().fetch(jf_yjgh.class, Cnd.where("unionId", "=", Vi.getUnionId()).and("year", "=", DateUtil.getYear()).and("state", "=", 1));
if (yjgh != null) {
double balance = yjgh.getTotalQuota() - (yjgh.getUsedQuota() != null ? yjgh.getUsedQuota() : 0);
BigDecimal bigDecimal = new BigDecimal(balance);
double value = bigDecimal.setScale(2, RoundingMode.HALF_UP).doubleValue();
return Result.success(value);
}
return Result.success(0f);
}
@At
@RequiresPermissions("reimbursement.applyNew")
public Object getSchoolBudget() {
jf_school jfSchool = baseService.dao().fetch(jf_school.class, Cnd.where("year", "=", DateUtil.getYear()).and("state", "=", 1));
if (jfSchool != null) {
double balance = jfSchool.getTotalQuota() - (jfSchool.getUsedQuota() != null ? jfSchool.getUsedQuota() : 0);
BigDecimal bigDecimal = new BigDecimal(balance);
double value = bigDecimal.setScale(2, RoundingMode.HALF_UP).doubleValue();
return Result.success(value);
}
return Result.success(0f);
}
@At
@RequiresPermissions("reimbursement.applyNew")
public Object getClubBudget(@Param(value = "clubId", required = false) String clubId) {
jf_club jf_club = baseService.dao().fetch(jf_club.class, Cnd.where("year", "=", DateUtil.getYear()).and("state", "=", 1).and("club_id", "=", clubId));
if (jf_club != null) {
double balance = jf_club.getTotal_quota() - jf_club.getUsed_quota();
BigDecimal bigDecimal = new BigDecimal(balance);
double value = bigDecimal.setScale(2, RoundingMode.HALF_UP).doubleValue();
return Result.success(value);
}
return Result.success(0f);
}
@At
@ViReturn
@RequiresPermissions("reimbursement.applyNew")
public Object getLastData(@Param(value = "queryString", required = false) String queryString) {
public Object getLastData(String queryString) {
Sql sql = Sqls.create("""
select
bankUserName,
@@ -214,23 +207,81 @@ public class applyNewController {
return list;
}
@At
public Object getBudgetMoneyOrActivity(@Param(value = "jf_source") String jf_source, String clubId, String unionId, String id) {
List<String> budgetIds = baseService.dao().query(ActivityBudget.class, Cnd.where("isRepeatReimbursement", "=", 1)).stream().map(ActivityBudget::getId).toList();
List<ReimbursementNew> reimbursementNewList = baseService.dao().query(ReimbursementNew.class,
Cnd.NEW().andEX("id", "!=", id).and("activityId", "not in", budgetIds).and("activityId", "is not", null));
List<String> ids = reimbursementNewList.stream().map(ReimbursementNew::getActivityId).toList();
Cnd cnd = Cnd.NEW();
cnd.and("budgetTypeCode", "=", jf_source);
cnd.and("auditState", "=", 4);
if (jf_source.equals("ACTIVITY_BUDGET_TYPE_TWO")) {
cnd.and("unionId", "=", StrUtil.isNotBlank(unionId) ? unionId : Vi.getUnionId());
} else if (List.of("ACTIVITY_BUDGET_TYPE_THREE", "ACTIVITY_BUDGET_TYPE_FOUR").contains(jf_source)) {
cnd.and("clubId", "=", clubId);
}
cnd.andEX("id", "not in", ids);
List<ActivityBudget> budgetList = baseService.dao().query(ActivityBudget.class, cnd);
NutMap map = new NutMap();
if (jf_source.equals("ACTIVITY_BUDGET_TYPE_ONE")) {
jf_school school = baseService.dao().fetch(jf_school.class, Cnd.where("year", "=", DateUtil.getYear()));
map.put("budgetMoney", school.getTotalQuota().subtract(school.getUsedQuota()));
} else if (jf_source.equals("ACTIVITY_BUDGET_TYPE_TWO")) {
Cnd twoCnd = Cnd.NEW();
twoCnd.and("year", "=", DateUtil.getYear());
twoCnd.and("unionId", "=", StrUtil.isNotBlank(unionId) ? unionId : Vi.getUnionId());
jf_yjgh yjgh = baseService.dao().fetch(jf_yjgh.class, twoCnd);
map.put("budgetMoney", ObjectUtil.isNotEmpty(yjgh) ? yjgh.getTotalQuota().subtract(yjgh.getUsedQuota()) : 0);
} else if (jf_source.equals("ACTIVITY_BUDGET_TYPE_THREE")) {
jf_club club = baseService.dao().fetch(jf_club.class, Cnd.where("year", "=", DateUtil.getYear())
.and("club_id", "=", clubId));
map.put("budgetMoney", ObjectUtil.isNotEmpty(club) ? club.getTotalQuota().subtract(club.getUsedQuota()) : 0);
} else if (jf_source.equals("ACTIVITY_BUDGET_TYPE_FOUR")) {
/* JfOther other = baseService.dao().fetch(JfOther.class, Cnd.where("year", "=", DateUtil.getYear())
.and("clubId", "=", clubId));
map.put("budgetMoney", ObjectUtil.isNotEmpty(other) ? other.getTotalQuota().subtract(other.getUsedQuota()) : 0);*/
}
map.put("activityList", budgetList);
return Result.success(map);
}
@At
@ViReturn
public Object getClubsByUser() {
Sql sql = Sqls.create("""
SELECT
id as clubid,
name as clubName
FROM
sys_club
$condition
""");
Cnd cnd = Cnd.NEW();
cnd.and(new Static(" id in (select clubid from sys_club_user where userid = '%s')"
.formatted(ShiroUtil.getPrincipalProperty("id"))));
cnd.and("state", "=", 930);
sql.setCondition(cnd);
List list = baseService.listMap(sql);
return list;
}
@At
@RequiresPermissions("reimbursement.applyNew")
public Object validRole(String val) {
if (ShiroUtil.hasAnyRoles("sysadmin")) {
return Result.success();
}
if ("2".equals(val)) {
if (!ShiroUtil.hasAnyRoles("gh01, H04")) {
return Result.error("分工会报销只能由分工会主席操作");
}
} else if ("3".equals(val)) {
int count = baseService.dao().count(Sys_club_user.class, Cnd.where("userid", "=", ShiroUtil.getPrincipalProperty("id"))
.and("sf", "=", 1));
if (count == 0) {
return Result.error("协会/协会报销只能由会长操作");
}
}
return Result.success();
public Result getBxMoneyByActivityId(String activityId, String jf_source) {
return Result.success(reimbursementService.getBxMoneyByActivityId(activityId, jf_source));
}
@At
@RequiresPermissions("reimbursement.applyNew")
public Result bxAddValidate(String activityId, String money, String jf_source, String clubId) {
return reimbursementService.bxAddValidate(activityId, money, jf_source, clubId);
}
}
@@ -0,0 +1,502 @@
package io.v.nutz.zhgh.reimbursement.handler;
import cn.hutool.core.util.StrUtil;
import io.v.nutz.base.utils.Roles;
import io.v.nutz.base.utils.Vi;
import io.v.nutz.base.utils.ViResource;
import io.v.nutz.sys.models.Sys_club;
import io.v.nutz.sys.models.Sys_user;
import io.v.nutz.sys.services.SysLocalProcessService;
import io.v.nutz.sys.services.impl.SysLocalProcessServiceImpl;
import io.v.nutz.web.commons.utils.ShiroUtil;
import io.v.nutz.zhgh.activityBudget.models.ActivityBudget;
import io.v.nutz.zhgh.reimbursement.models.ReimbursementNew;
import org.nutz.dao.Cnd;
import org.nutz.dao.Dao;
import org.nutz.dao.Sqls;
import org.nutz.dao.sql.Sql;
import org.nutz.lang.Lang;
import java.util.ArrayList;
import java.util.List;
/**
* @author zhf
* @date 2025/8/30 14:27
* @description
*/
public enum ReimbursementToDoHandler {
/**
* 流程开始
*/
START_PROCESS() {
@Override
public void exec(ReimbursementNew reimbursementNew, String option) {
Sys_user sysUser = dao.fetch(Sys_user.class, reimbursementNew.getUserId());
localProcessService.startProcess(
"【费用报销管理】" + sysUser.getUsername(),
"reimbursement@" + reimbursementNew.getId(),
"费用报销申请",
sysUser.getId(),
"/activity/reimbursement/list",
"/activity/reimbursement/list"
);
}
},
/**
* 完成申请人的任务(申请拒绝的情况)
*/
COMPLETE_APPLY_TASK() {
@Override
public void exec(ReimbursementNew reimbursementNew, String option) {
localProcessService.completeTask(
"apply_reimbursement_modify",
"reimbursement@" + reimbursementNew.getId(),
ShiroUtil.getUserId(),
""
);
}
},
/**
* 创建协会负责人任务
*/
CREATE_CLUB_TASK() {
@Override
public void exec(ReimbursementNew reimbursementNew, String option) {
List<String> loginNames = this.getLoginNames(Roles.club01, null, reimbursementNew.getClubId());
if (Lang.isEmpty(loginNames)) {
throw new RuntimeException("找不到下一步审核人,请联系管理员设置。");
}
localProcessService.createTask(
"reimbursement@" + reimbursementNew.getId(),
"club_audit",
"协会负责人审核",
ShiroUtil.getUserId(),
loginNames,
"/platform/reimbursement/clubAudit",
"/platform/reimbursement/clubAudit",
"/platform/reimbursement/clubAudit",
"/platform/reimbursement/clubAudit"
);
localProcessService.updateProcessNodeName("reimbursement@" + reimbursementNew.getId(), "协会负责人审核");
}
},
/**
* 协会负责人完成
*/
COMPLETE_CLUB_TASK() {
@Override
public void exec(ReimbursementNew reimbursementNew, String option) {
localProcessService.completeTask(
"club_audit",
"reimbursement@" + reimbursementNew.getId(),
ShiroUtil.getUserId(),
option
);
}
},
/**
* 协会负责人退回,退回给个人节点
*/
CREATE_BACK_CLUB_TASK() {
@Override
public void exec(ReimbursementNew reimbursementNew, String option) {
localProcessService.createTask(
"reimbursement@" + reimbursementNew.getId(),
"club_audit_back",
"协会负责人退回",
ShiroUtil.getUserId(),
List.of(reimbursementNew.getLoginName()),
"/activity/reimbursement/list",
"/activity/reimbursement/list",
"/activity/reimbursement/list",
"/activity/reimbursement/list"
);
localProcessService.updateProcessNodeName("reimbursement@" + reimbursementNew.getId(), "协会负责人退回");
}
},
/**
* 创建分工会任务
*/
CREATE_UNION_TASK() {
@Override
public void exec(ReimbursementNew reimbursementNew, String option) {
List<String> loginNames;
Sys_club club = dao.fetch(Sys_club.class, Cnd.where("id", "=", reimbursementNew.getClubId()));
//如果是协会活动就发协会挂靠的分工会主席
if (reimbursementNew.getJf_source().equals("ACTIVITY_BUDGET_TYPE_THREE")) {
if (StrUtil.isBlank(club.getBelongUnionId())){
throw new RuntimeException("找不到协会所关联的分工会,请联系管理员设置。");
}
loginNames = this.getLoginNames(Roles.GH01, club.getBelongUnionId(), null);
} else {
loginNames = this.getLoginNames(Roles.GH01, Vi.getUnionId(), null);
}
if (Lang.isEmpty(loginNames)) {
throw new RuntimeException("找不到下一步审核人,请联系管理员设置。");
}
localProcessService.createTask(
"reimbursement@" + reimbursementNew.getId(),
"union_audit",
"分工会主席审核",
ShiroUtil.getUserId(),
loginNames,
"/platform/reimbursement/unionAudit",
"/platform/reimbursement/unionAudit",
"/platform/reimbursement/unionAudit",
"/platform/reimbursement/unionAudit"
);
localProcessService.updateProcessNodeName("reimbursement@" + reimbursementNew.getId(), "分工会主席审核");
}
},
/**
* 分工会完成
*/
COMPLETE_UNION_TASK() {
@Override
public void exec(ReimbursementNew reimbursementNew, String option) {
localProcessService.completeTask(
"union_audit",
"reimbursement@" + reimbursementNew.getId(),
ShiroUtil.getUserId(),
option
);
}
},
/**
* 分工会主席退回,退回给个人节点
*/
CREATE_BACK_UNION_TASK() {
@Override
public void exec(ReimbursementNew reimbursementNew, String option) {
localProcessService.createTask(
"reimbursement@" + reimbursementNew.getId(),
"union_back",
"分工会主席退回",
ShiroUtil.getUserId(),
List.of(reimbursementNew.getLoginName()),
"/activity/reimbursement/list",
"/activity/reimbursement/list",
"/activity/reimbursement/list",
"/activity/reimbursement/list"
);
localProcessService.updateProcessNodeName("reimbursement@" + reimbursementNew.getId(), "分工会主席退回");
}
},
/**
* 创建工会办公室主管任务
*/
CREATE_UNION_MANAGE_TASK() {
@Override
public void exec(ReimbursementNew reimbursementNew, String option) {
List<String> loginNames = this.getLoginNames(Roles.XCYWT, null, null);
if (Lang.isEmpty(loginNames)) {
throw new RuntimeException("找不到下一步审核人,请联系管理员设置。");
}
localProcessService.createTask(
"reimbursement@" + reimbursementNew.getId(),
"union_manage_audit",
"工会办公室主管审核",
ShiroUtil.getUserId(),
loginNames,
"/platform/reimbursement/unionManageAudit",
"/platform/reimbursement/unionManageAudit",
"/platform/reimbursement/unionManageAudit",
"/platform/reimbursement/unionManageAudit"
);
localProcessService.updateProcessNodeName("reimbursement@" + reimbursementNew.getId(), "工会办公室主管审核");
}
},
/**
* 工会办公室主管完成
*/
COMPLETE_UNION_MANAGE_TASK() {
@Override
public void exec(ReimbursementNew reimbursementNew, String option) {
localProcessService.completeTask(
"union_manage_audit",
"reimbursement@" + reimbursementNew.getId(),
ShiroUtil.getUserId(),
option
);
}
},
/**
* 工会办公室主管退回,退回给个人节点
*/
CREATE_BACK_UNION_MANAGE_TASK() {
@Override
public void exec(ReimbursementNew reimbursementNew, String option) {
localProcessService.createTask(
"reimbursement@" + reimbursementNew.getId(),
"union_manage_audit_back",
"工会办公室主管退回",
ShiroUtil.getUserId(),
List.of(reimbursementNew.getLoginName()),
"/activity/reimbursement/list",
"/activity/reimbursement/list",
"/activity/reimbursement/list",
"/activity/reimbursement/list"
);
localProcessService.updateProcessNodeName("reimbursement@" + reimbursementNew.getId(), "工会办公室主管退回");
}
},
/**
* 创建工会副主席任务
*/
CREATE_VICE_CHAIRMAN_TASK() {
@Override
public void exec(ReimbursementNew reimbursementNew, String option) {
List<String> loginNames = this.getLoginNames(Roles.WYH01, null, null);
if (Lang.isEmpty(loginNames)) {
throw new RuntimeException("找不到下一步审核人,请联系管理员设置。");
}
localProcessService.createTask(
"reimbursement@" + reimbursementNew.getId(),
"vice_chairman_audit",
"工会副主席审核",
ShiroUtil.getUserId(),
loginNames,
"/platform/reimbursement/viceChairmanAudit",
"/platform/reimbursement/viceChairmanAudit",
"/platform/reimbursement/viceChairmanAudit",
"/platform/reimbursement/viceChairmanAudit"
);
localProcessService.updateProcessNodeName("reimbursement@" + reimbursementNew.getId(), "工会副主席审核");
}
},
/**
* 工会副主席完成
*/
COMPLETE_VICE_CHAIRMAN_TASK() {
@Override
public void exec(ReimbursementNew reimbursementNew, String option) {
localProcessService.completeTask(
"vice_chairman_audit",
"reimbursement@" + reimbursementNew.getId(),
ShiroUtil.getUserId(),
option
);
}
},
/**
* 工会副主席退回,退回给个人节点
*/
CREATE_BACK_VICE_CHAIRMAN_TASK() {
@Override
public void exec(ReimbursementNew reimbursementNew, String option) {
localProcessService.createTask(
"reimbursement@" + reimbursementNew.getId(),
"vice_chairman_audit_back",
"工会副主席退回",
ShiroUtil.getUserId(),
List.of(reimbursementNew.getLoginName()),
"/activity/reimbursement/list",
"/activity/reimbursement/list",
"/activity/reimbursement/list",
"/activity/reimbursement/list"
);
localProcessService.updateProcessNodeName("reimbursement@" + reimbursementNew.getId(), "工会副主席退回");
}
},
/**
* 创建工会主席任务
*/
CREATE_STANDING_VICE_CHAIRMAN_TASK() {
@Override
public void exec(ReimbursementNew reimbursementNew, String option) {
List<String> loginNames = this.getLoginNames(Roles.XGH02, null, null);
if (Lang.isEmpty(loginNames)) {
throw new RuntimeException("找不到下一步审核人,请联系管理员设置。");
}
localProcessService.createTask(
"reimbursement@" + reimbursementNew.getId(),
"standing_vice_chairman_audit",
"工会主席审核",
ShiroUtil.getUserId(),
loginNames,
"/platform/reimbursement/standingViceChairmanAudit",
"/platform/reimbursement/standingViceChairmanAudit",
"/platform/reimbursement/standingViceChairmanAudit",
"/platform/reimbursement/standingViceChairmanAudit"
);
localProcessService.updateProcessNodeName("reimbursement@" + reimbursementNew.getId(), "工会主席审核");
}
},
/**
* 工会主席完成
*/
COMPLETE_STANDING_VICE_CHAIRMAN_TASK() {
@Override
public void exec(ReimbursementNew reimbursementNew, String option) {
localProcessService.completeTask(
"standing_vice_chairman_audit",
"reimbursement@" + reimbursementNew.getId(),
ShiroUtil.getUserId(),
option
);
}
},
/**
* 工会主席退回,退回给个人节点
*/
CREATE_BACK_STANDING_VICE_CHAIRMAN_TASK() {
@Override
public void exec(ReimbursementNew reimbursementNew, String option) {
localProcessService.createTask(
"reimbursement@" + reimbursementNew.getId(),
"standing_vice_chairman_audit_back",
"工会主席退回",
ShiroUtil.getUserId(),
List.of(reimbursementNew.getLoginName()),
"/activity/reimbursement/list",
"/activity/reimbursement/list",
"/activity/reimbursement/list",
"/activity/reimbursement/list"
);
localProcessService.updateProcessNodeName("reimbursement@" + reimbursementNew.getId(), "工会主席退回");
}
},
/**
* 创建会计审核任务
*/
CREATE_FINANCE_TASK() {
@Override
public void exec(ReimbursementNew reimbursementNew, String option) {
List<String> loginNames = this.getLoginNames(Roles.SCHOOL_UNION_ACCOUNTANT, null, null);
if (Lang.isEmpty(loginNames)) {
throw new RuntimeException("找不到下一步审核人,请联系管理员设置。");
}
localProcessService.createTask(
"reimbursement@" + reimbursementNew.getId(),
"finance_audit",
"会计审核",
ShiroUtil.getUserId(),
loginNames,
"/platform/reimbursement/financeAudit",
"/platform/reimbursement/financeAudit",
"/platform/reimbursement/financeAudit",
"/platform/reimbursement/financeAudit"
);
localProcessService.updateProcessNodeName("reimbursement@" + reimbursementNew.getId(), "会计审核");
}
},
/**
* 会计审核完成
*/
COMPLETE_FINANCE_TASK() {
@Override
public void exec(ReimbursementNew reimbursementNew, String option) {
localProcessService.completeTask(
"finance_audit",
"reimbursement@" + reimbursementNew.getId(),
ShiroUtil.getUserId(),
option
);
}
},
/**
* 会计审核退回,退回给个人节点
*/
CREATE_BACK_FINANCE_TASK() {
@Override
public void exec(ReimbursementNew reimbursementNew, String option) {
localProcessService.createTask(
"reimbursement@" + reimbursementNew.getId(),
"finance_audit",
"会计退回",
ShiroUtil.getUserId(),
List.of(reimbursementNew.getLoginName()),
"/activity/reimbursement/list",
"/activity/reimbursement/list",
"/activity/reimbursement/list",
"/activity/reimbursement/list"
);
localProcessService.updateProcessNodeName("reimbursement@" + reimbursementNew.getId(), "会计退回");
}
},
/**
* 流程结束
*/
COMPLETE_PROCESS() {
@Override
public void exec(ReimbursementNew reimbursementNew, String option) {
localProcessService.completeProcess("reimbursement@" + reimbursementNew.getId());
}
},
/**
* 删除
*/
DELETE_PROCESS() {
@Override
public void exec(ReimbursementNew reimbursementNew, String option) {
localProcessService.deleteProcessInstance("reimbursement@" + reimbursementNew.getId());
}
};
public List<String> getLoginNames(String roleCode, String unionId, String clubId) {
Cnd cnd = Cnd.NEW();
cnd.andEX("sur.unionid", "=", unionId);
cnd.andEX("sur.roleId", "=", roleCode);
cnd.andEX("sur.stid", "=", clubId);
cnd.groupBy("sur.userId");
Sql sql = Sqls.create("""
SELECT
u.loginname
FROM
sys_user_role sur
LEFT JOIN sys_user u ON u.id = sur.userid
$condition
""");
sql.setCondition(cnd);
sql.setCallback(Sqls.callback.strs());
dao.execute(sql);
List<String> loginNames = sql.getList(String.class);
return loginNames;
}
;
public abstract void exec(ReimbursementNew reimbursementNew, String option);
public Dao dao = ViResource.dao;
public SysLocalProcessService localProcessService = ViResource.ioc.get(SysLocalProcessServiceImpl.class);
}
@@ -7,6 +7,7 @@ import org.nutz.dao.entity.annotation.*;
import org.nutz.dao.interceptor.annotation.PrevInsert;
import org.nutz.integration.json4excel.annotation.J4EIgnore;
import java.math.BigDecimal;
import java.util.List;
/**
@@ -60,10 +61,15 @@ public class ReimbursementNew {
private String unitId;
@Column
@Comment("协会id")
@Comment("社团id")
@ColDefine(type = ColType.VARCHAR, width = 32)
private String clubId;
@Column
@Comment("社团id")
@ColDefine(type = ColType.VARCHAR, width = 32)
private String newClubId;
@Column
@Comment("工会")
@ColDefine(type = ColType.VARCHAR, width = 30)
@@ -79,6 +85,11 @@ public class ReimbursementNew {
@ColDefine(type = ColType.VARCHAR, width = 32)
private String jf_source;
@Column
@Comment("新报销经费来源")
@ColDefine(type = ColType.VARCHAR, width = 32)
private String new_jf_source;
@Column
@Comment("慰问人电话")
@@ -164,14 +175,39 @@ public class ReimbursementNew {
private List<Sys_file> files;
@Column
@Comment("经办人签字id")
@Comment("经办人签字")
@ColDefine(type = ColType.VARCHAR, width = 100)
private String signUrl;
@Column
@Comment("协会审核id")
@ColDefine(type = ColType.VARCHAR, width = 32)
private String signId;
private String clubAuditId;
@Column
@Comment("分工会审核id")
@ColDefine(type = ColType.VARCHAR, width = 32)
private String unionAuditId;
@Column
@Comment("会计审核id")
@ColDefine(type = ColType.VARCHAR, width = 32)
private String accountingAuditId;
private String financeAuditId;
@Column
@Comment("出纳审核id")
@ColDefine(type = ColType.VARCHAR, width = 32)
private String viceChairmanAuditId;
@Column
@Comment("工会办公室主管审核id")
@ColDefine(type = ColType.VARCHAR, width = 32)
private String unionManageAuditId;
@Column
@Comment("校工会主席审核id")
@ColDefine(type = ColType.VARCHAR, width = 32)
private String standingViceChairmanAuditId;
@Column
@Comment("单据号")
@@ -224,9 +260,8 @@ public class ReimbursementNew {
@Column
@Comment("慰问金额")
@J4EIgnore
@ColDefine(type = ColType.FLOAT, width = 10, precision = 2)
private Double money;
@ColDefine(customType = "decimal(10,2)")
private BigDecimal money;
@Column
@Comment("住院开始时间")
@@ -290,7 +325,7 @@ public class ReimbursementNew {
@Column
@Comment("活动名称")
@ColDefine(type = ColType.VARCHAR, width = 50)
@ColDefine(type = ColType.VARCHAR, width = 100)
private String activity_name;
@Column
@@ -299,7 +334,7 @@ public class ReimbursementNew {
private String activity_number;
@Column
@Comment("活动类型(1.基层工会,2.校工会,3.协会")
@Comment("活动类型(1.基层工会,2.校工会,3.社团")
@ColDefine(type = ColType.INT, width = 2)
private Integer activity_type;
@@ -307,4 +342,19 @@ public class ReimbursementNew {
@Comment("发票号码")
@ColDefine(type = ColType.VARCHAR, width = 300)
private String billNumber;
@Column
@Comment("活动id")
@ColDefine(type = ColType.VARCHAR, width = 32)
private String activityId;
@Column
@Comment("明细类")
@ColDefine(type = ColType.VARCHAR, width = 32)
private String detailsTypeId;
@Column
@Comment("上账明细")
@ColDefine(type = ColType.VARCHAR, width = 32)
private String accountViewId;
}
@@ -0,0 +1,36 @@
package io.v.nutz.zhgh.reimbursement.models;
import io.v.nutz.base.query.PageForm;
import lombok.Data;
import java.util.List;
/**
* @ClassName ReimbursementPageForm
* @Description TODO
* @Author zhf
* @Date 2025/3/20 上午8:59
*/
@Data
public class ReimbursementPageForm extends PageForm {
String unitId;
String unionId;
String clubId;
Integer year;
String jf_source;
String detailsTypeId;
Integer isAudit;
List<String> reimbursementDate;
String accountViewId;
}
@@ -1,16 +1,35 @@
package io.v.nutz.zhgh.reimbursement.services;
import io.v.nutz.zhgh.reimbursement.models.Reimbursement;
import cn.wizzer.framework.base.Result;
import io.v.nutz.base.service.ViService;
import io.v.nutz.zhgh.reimbursement.models.ReimbursementNew;
import org.nutz.lang.util.NutMap;
import java.math.BigDecimal;
import java.util.List;
/**
* @author zhf
* @date 2021/6/3 10:16
* @description
*/
public interface ReimbursementService extends ViService<Reimbursement> {
public interface ReimbursementService extends ViService<ReimbursementNew> {
NutMap findOne(String id);
List<NutMap> getClubsByRole();
Result bxAddValidate(String activityId, String money, String jf_source,String clubId);
/**
* 查询已经报销了的金额
* 1.如果是校工会进来的,就查询这个项目关联的分工会预算总额
* 2.如果是其他,就查这个项目已经报销了的
* @param activityId
* @param jf_source
* @return
*/
BigDecimal getBxMoneyByActivityId(String activityId,String jf_source);
}
@@ -1,25 +1,38 @@
package io.v.nutz.zhgh.reimbursement.services.impl;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import cn.wizzer.framework.base.Result;
import io.v.nutz.base.service.AuditService;
import io.v.nutz.zhgh.reimbursement.models.Reimbursement;
import io.v.nutz.zhgh.reimbursement.services.ReimbursementService;
import io.v.nutz.base.service.impl.ViServiceImpl;
import io.v.nutz.base.utils.DateUtil;
import io.v.nutz.base.utils.Roles;
import io.v.nutz.zhgh.activityBudget.models.ActivityBudget;
import io.v.nutz.zhgh.jf.model.jf_club;
import io.v.nutz.zhgh.reimbursement.constants.ReimbursementState;
import io.v.nutz.zhgh.reimbursement.models.ReimbursementNew;
import io.v.nutz.zhgh.reimbursement.services.ReimbursementService;
import org.nutz.dao.Cnd;
import org.nutz.dao.Dao;
import org.nutz.dao.Sqls;
import org.nutz.dao.sql.Sql;
import org.nutz.ioc.loader.annotation.Inject;
import org.nutz.ioc.loader.annotation.IocBean;
import org.nutz.lang.Lang;
import org.nutz.lang.Strings;
import org.nutz.lang.util.NutMap;
import java.math.BigDecimal;
import java.util.List;
import java.util.Objects;
/**
* @author zhf
* @date 2021/6/3 10:17
* @description
*/
@IocBean(args = {"refer:dao"})
public class ReimbursementServiceImpl extends ViServiceImpl<Reimbursement> implements ReimbursementService {
public class ReimbursementServiceImpl extends ViServiceImpl<ReimbursementNew> implements ReimbursementService {
@Inject
private AuditService auditService;
@@ -37,15 +50,16 @@ public class ReimbursementServiceImpl extends ViServiceImpl<Reimbursement> imple
be.loginname be_loginname,
state.stateName,
state.stateColor,
type.`name` typeName,
type.`code` typeCode,
sign.`data` jbrSignData
cl.`name` clubName,
cl2.`name` nweClubName,
un.unionname AS newUnionName
FROM
`reimbursement_new` rei
LEFT JOIN sys_user be ON be.id = rei.be_user
LEFT JOIN audit_state state ON state.stateId = rei.state
LEFT JOIN sys_signature sign ON sign.id = rei.signId
LEFT JOIN condolence_type type ON type.id=rei.type
LEFT JOIN sys_club cl ON cl.id = rei.clubId
LEFT JOIN sys_club cl2 ON cl2.id = rei.newClubId
LEFT JOIN sys_union un ON un.id = rei.unionId
$condition
""");
Cnd cnd = Cnd.NEW();
@@ -53,11 +67,199 @@ public class ReimbursementServiceImpl extends ViServiceImpl<Reimbursement> imple
sql.setCondition(cnd);
NutMap record = listMap(sql).get(0);
if (Strings.isNotBlank(record.getString("accountingAuditId"))) {
record.setv("accounting", auditService.fetch(record.getString("accountingAuditId")));
if (Strings.isNotBlank(record.getString("clubAuditId"))) {
record.setv("clubAudit", auditService.fetch(record.getString("clubAuditId")));
}
if (Strings.isNotBlank(record.getString("unionAuditId"))) {
record.setv("unionAudit", auditService.fetch(record.getString("unionAuditId")));
}
if (Strings.isNotBlank(record.getString("unionManageAuditId"))) {
record.setv("unionManageAudit", auditService.fetch(record.getString("unionManageAuditId")));
}
if (Strings.isNotBlank(record.getString("financeAuditId"))) {
record.setv("financeAudit", auditService.fetch(record.getString("financeAuditId")));
}
if (Strings.isNotBlank(record.getString("viceChairmanAuditId"))) {
record.setv("viceChairmanAudit", auditService.fetch(record.getString("viceChairmanAuditId")));
}
if (Strings.isNotBlank(record.getString("standingViceChairmanAuditId"))) {
record.setv("standingViceChairmanAudit", auditService.fetch(record.getString("standingViceChairmanAuditId")));
}
return record;
}
@Override
public List<NutMap> getClubsByRole() {
Cnd cnd = Cnd.NEW();
Sql sql = Sqls.create("""
SELECT
club.id as stid,
role.userId,
club.`name`,
club.foundTime,
club.dues_standard,
club.`code`
FROM
sys_club club
LEFT JOIN `sys_user_role` role ON club.id = role.stid
$condition
""");
cnd.and("club.isjs", "=", false);
cnd.and("club.state", "=", 930);
cnd.groupBy("club.id");
cnd.asc("club.`code`");
sql.setCondition(cnd);
return listMap(sql);
}
@Override
public Result bxAddValidate(String activityId, String money, String jf_source, String clubId) {
if (StrUtil.hasEmpty(jf_source, money)) {
return Result.error("请填写【活动类型、金额】");
}
BigDecimal moneyBig = new BigDecimal(money);
if (List.of("ACTIVITY_BUDGET_TYPE_TWO", "ACTIVITY_BUDGET_TYPE_ONE").contains(jf_source)) {
ActivityBudget budget = dao().fetch(ActivityBudget.class, Cnd.where("id", "=", activityId));
if (jf_source.equals("ACTIVITY_BUDGET_TYPE_TWO")) {
//判断是否可以重复报
if (budget.getIsRepeatReimbursement()) {
//1.查询已经报销了的总金额
BigDecimal bXMoney = getBxMoneyByActivityId(activityId, jf_source);
if (budget.getIsSchoolBudget()) {
//如果是分工会进来并且报销的活动是校会预算
// 1. 计算本次加上之前的报销总金额
BigDecimal totalReimbursement = bXMoney.add(moneyBig);
// 2. 判断是否超出预算
if (totalReimbursement.compareTo(budget.getTotalBudgetMoney()) > 0) {
return Result.error("该活动预算金额不足!");
} else {
return Result.success();
}
} else {
//如果是自己的项目就能超20%
//1.算出现在还能报销多少钱
BigDecimal twentyPercent = budget.getTotalBudgetMoney().multiply(new BigDecimal("20")).divide(new BigDecimal("100"), 2, BigDecimal.ROUND_HALF_UP);
BigDecimal totalBudgetMoney = budget.getTotalBudgetMoney().add(twentyPercent);
// 2. 计算本次加上之前的报销总金额
BigDecimal totalReimbursement = bXMoney.add(moneyBig);
// 3. 判断是否超出预算的 20%
if (totalReimbursement.compareTo(totalBudgetMoney) > 0) {
return Result.error("该活动预算金额不足!");
} else {
return Result.success();
}
}
} else {
//分工会进来报销自己的预算
//正常判断这个活动是否超出预算
//算出现在还能报销多少钱
//判断是否超出预算的 20%
BigDecimal twentyPercent = budget.getTotalBudgetMoney().multiply(new BigDecimal("20")).divide(new BigDecimal("100"), 2, BigDecimal.ROUND_HALF_UP);
BigDecimal totalBudgetMoney = budget.getTotalBudgetMoney().add(twentyPercent);
if (moneyBig.compareTo(totalBudgetMoney) > 0) {
return Result.error("该活动预算金额不足!");
} else {
return Result.success();
}
}
} else {
//如果是校工会进来
//如果报销的项目是可以重复报销的
if (budget.getIsRepeatReimbursement()) {
List<ReimbursementNew> newList = dao().query(ReimbursementNew.class, Cnd.where("activityId", "=", activityId)
.and("State", "=", ReimbursementState.SUCCESSFUL_REIMBURSEMENT));
//已报销l的金额
BigDecimal totalMoney = newList.stream()
.map(ReimbursementNew::getMoney)
.filter(Objects::nonNull) // 避免 null 值导致计算错误
.reduce(BigDecimal.ZERO, BigDecimal::add);
if (budget.getIsSchoolBudget()) {
//如果报销的项目是分工会也能报校工会也能报,就要减去所有已分配分工会的钱在算能报销多少钱。
//分配分工会的钱在算能报销多少钱
BigDecimal unionTotalMoney = getBxMoneyByActivityId(activityId, jf_source);
//找出能报销多少钱
BigDecimal totalBudgetMoney = budget.getTotalBudgetMoney().subtract(unionTotalMoney);
//已报销加上现在的钱
BigDecimal totalReimbursement = totalMoney.add(moneyBig);
if (totalReimbursement.compareTo(totalBudgetMoney) > 0) {
return Result.error("该活动预算金额不足!");
} else {
return Result.success();
}
} else {
//正常判断这个活动是否超出预算
//算出现在还能报销多少钱,判断是否超出预算的 20%
//1.算出现在还能报销多少钱
BigDecimal twentyPercent = budget.getTotalBudgetMoney().multiply(new BigDecimal("20")).divide(new BigDecimal("100"), 2, BigDecimal.ROUND_HALF_UP);
BigDecimal totalBudgetMoney = budget.getTotalBudgetMoney().add(twentyPercent);
//2. 计算本次加上之前的报销总金额
BigDecimal totalReimbursement = totalMoney.add(moneyBig);
// 3. 判断是否超出预算的 20%
if (totalReimbursement.compareTo(totalBudgetMoney) > 0) {
return Result.error("该活动预算金额不足!");
} else {
return Result.success();
}
}
} else {
//正常判断这个活动是否超出预算
//算出现在还能报销多少钱,判断是否超出预算的 20%
BigDecimal twentyPercent = budget.getTotalBudgetMoney().multiply(new BigDecimal("20")).divide(new BigDecimal("100"), 2, BigDecimal.ROUND_HALF_UP);
BigDecimal totalBudgetMoney = budget.getTotalBudgetMoney().add(twentyPercent);
if (moneyBig.compareTo(totalBudgetMoney) > 0) {
return Result.error("该活动预算金额不足!");
} else {
return Result.success();
}
}
}
} else if ("ACTIVITY_BUDGET_TYPE_THREE".equals(jf_source)) {
//如果进来的是协会
jf_club jfClub = dao().fetch(jf_club.class, Cnd.where("year", "=", DateUtil.getYear())
.and("club_id", "=", clubId));
if (ObjectUtil.isEmpty(jfClub)) {
return Result.error("该年份没有设置金额!");
}
if (jfClub.getTotalQuota().subtract(jfClub.getUsedQuota()).compareTo(moneyBig) < 0) {
return Result.error("剩余配额不足!剩余:" + jfClub.getTotalQuota().subtract(jfClub.getUsedQuota()));
} else {
return Result.success();
}
} else if ("ACTIVITY_BUDGET_TYPE_FOUR".equals(jf_source)) {
//如果进来的是其他项目
} else {
return Result.error("暂时不能报销!");
}
return Result.error("参数错误");
}
@Override
public BigDecimal getBxMoneyByActivityId(String activityId, String jf_source) {
if ("ACTIVITY_BUDGET_TYPE_ONE".equals(jf_source)) {
ActivityBudget budget = dao().fetch(ActivityBudget.class, Cnd.where("id", "=", activityId));
List<ActivityBudget> budgetList = dao().query(ActivityBudget.class, Cnd.where("schoolBudgetId", "=", budget.getId()));
BigDecimal totalMoney = budgetList.stream()
.map(ActivityBudget::getTotalBudgetMoney)
.filter(Objects::nonNull) // 避免 null 值导致计算错误
.reduce(BigDecimal.ZERO, BigDecimal::add);
return totalMoney;
} else {
List<ReimbursementNew> newList = dao().query(ReimbursementNew.class, Cnd.where("activityId", "=", activityId)
.and("State", "=", ReimbursementState.SUCCESSFUL_REIMBURSEMENT));
BigDecimal totalMoney = newList.stream()
.map(ReimbursementNew::getMoney)
.filter(Objects::nonNull) // 避免 null 值导致计算错误
.reduce(BigDecimal.ZERO, BigDecimal::add);
return totalMoney;
}
}
}