init
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
package io.v.nutz.zhgh.welfare.constant;
|
||||
|
||||
/**
|
||||
* 福利会员申请状态
|
||||
*
|
||||
* @author: 1V
|
||||
* @date: 2021/2/28
|
||||
* @since 1.0
|
||||
*/
|
||||
public interface WelfareMemberApplyState {
|
||||
|
||||
/**
|
||||
* 待校工会审核
|
||||
*/
|
||||
int SCHOOL_UNION = 1000;
|
||||
|
||||
/**
|
||||
* 校工会审核不通过
|
||||
*/
|
||||
int SCHOOL_UNION_FAIL = 1050;
|
||||
|
||||
/**
|
||||
* 正式会员
|
||||
*/
|
||||
int NORMAL_MEMBER = 1100;
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
package io.v.nutz.zhgh.welfare.controller;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import io.v.nutz.base.annontation.ViReturn;
|
||||
import io.v.nutz.base.service.SimpleService;
|
||||
import io.v.nutz.web.commons.utils.ShiroUtil;
|
||||
import io.v.nutz.zhgh.welfare.model.WelfareMemberAddress;
|
||||
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.mvc.annotation.At;
|
||||
import org.nutz.mvc.annotation.Ok;
|
||||
|
||||
/**
|
||||
* @ClassName WelfareAddressManageController
|
||||
* @Description 福利地址管理
|
||||
* @Author zhf
|
||||
* @Date 2024/4/30 9:49
|
||||
*/
|
||||
@IocBean
|
||||
@Ok("json:full")
|
||||
@At("/platform/welfare/addressManage")
|
||||
public class WelfareAddressManageController {
|
||||
@Inject
|
||||
private SimpleService simpleService;
|
||||
|
||||
@At("")
|
||||
@Ok("beetl:/platform/welfare/addressManage.html")
|
||||
@RequiresPermissions("welfare.addressManage")
|
||||
public void index() {
|
||||
}
|
||||
|
||||
/**
|
||||
* 地址列表
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@At
|
||||
@ViReturn
|
||||
@RequiresPermissions("welfare.addressManage")
|
||||
public Object selectUserAddress(String userId) {
|
||||
Sql sql = Sqls.create("""
|
||||
SELECT
|
||||
id,
|
||||
userName ,
|
||||
tel,
|
||||
addressDetail,
|
||||
isDefault,
|
||||
province,
|
||||
city,
|
||||
county
|
||||
FROM
|
||||
`welfare_member_address`
|
||||
WHERE userId = @userId
|
||||
ORDER BY
|
||||
isDefault DESC
|
||||
""");
|
||||
sql.setParam("userId", StrUtil.isNotBlank(userId) ? userId : ShiroUtil.getPrincipalProperty("id"));
|
||||
return simpleService.listMap(sql);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 修改默认地址
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@At
|
||||
@ViReturn
|
||||
@RequiresPermissions("welfare.addressManage")
|
||||
public Object doDefault(String id) {
|
||||
simpleService.dao().update(WelfareMemberAddress.class, Chain.make("isDefault", false), Cnd.where("userId", "=", ShiroUtil.getUserId()));
|
||||
simpleService.dao().update(WelfareMemberAddress.class, Chain.make("isDefault", true), Cnd.where("id", "=", id));
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
package io.v.nutz.zhgh.welfare.controller;
|
||||
|
||||
import io.v.nutz.base.annontation.ViReturn;
|
||||
import io.v.nutz.base.utils.Vi;
|
||||
import io.v.nutz.zhgh.member.constant.MemberChangeApplyState;
|
||||
import io.v.nutz.zhgh.member.constant.MemberChangeRecordMode;
|
||||
import io.v.nutz.web.commons.utils.ShiroUtil;
|
||||
import io.v.nutz.zhgh.welfare.constant.WelfareMemberApplyState;
|
||||
import io.v.nutz.zhgh.welfare.service.WelfareMemberService;
|
||||
import org.nutz.dao.Sqls;
|
||||
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: 1V
|
||||
* @date: 2021/2/21
|
||||
* @since 1.0
|
||||
*/
|
||||
@At("/platform/welfare/agenda")
|
||||
@Ok("json:full")
|
||||
@IocBean
|
||||
public class WelfareAgendaController {
|
||||
@Inject
|
||||
private WelfareMemberService service;
|
||||
|
||||
@Inject
|
||||
private Vi vi;
|
||||
|
||||
@At
|
||||
@ViReturn
|
||||
public Object getAgenda() {
|
||||
List<NutMap> list = new ArrayList<>();
|
||||
if (!ShiroUtil.hasAnyRoles("flwyh01,sysadmin")) {
|
||||
return list;
|
||||
}
|
||||
|
||||
int welfareMemberAuditNumber = service.count(Sqls.create("SELECT count(1) from welfare_member_apply_record WHERE stateId = @state").setParam("state", WelfareMemberApplyState.SCHOOL_UNION));
|
||||
list.add(new NutMap().addv("iconClass", vi.getIconByPath("/platform/welfare/member/audit/school")).addv("label", "福利会员审核").addv("number", welfareMemberAuditNumber).addv("url", "/platform/welfare/member/audit/school"));
|
||||
|
||||
int welfareMemberChangeAuditNumber = service.count(Sqls.create("SELECT count(1) from member_change_record WHERE recordMode = @mode and stateId = @state").setParam("mode", MemberChangeRecordMode.WELFARE_MEMBER.getCode()).setParam("state", MemberChangeApplyState.SCHOOL_UNION));
|
||||
list.add(new NutMap().addv("iconClass", vi.getIconByPath("/platform/welfare/member/change/audit")).addv("label", "福利会员变更审核").addv("number", welfareMemberChangeAuditNumber).addv("url", "/platform/welfare/member/change/audit"));
|
||||
|
||||
return list;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,682 @@
|
||||
package io.v.nutz.zhgh.welfare.controller;
|
||||
|
||||
import cn.afterturn.easypoi.excel.ExcelExportUtil;
|
||||
import cn.afterturn.easypoi.excel.annotation.Excel;
|
||||
import cn.afterturn.easypoi.excel.entity.ExportParams;
|
||||
import cn.afterturn.easypoi.excel.entity.params.ExcelExportEntity;
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.codec.Base64;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.wizzer.framework.base.Result;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.deepoove.poi.XWPFTemplate;
|
||||
import com.deepoove.poi.config.Configure;
|
||||
import com.deepoove.poi.policy.HackLoopTableRenderPolicy;
|
||||
import io.v.nutz.base.annontation.ViReturn;
|
||||
import io.v.nutz.base.utils.ExpressSelectUtil;
|
||||
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.zhgh.member.service.MemberService;
|
||||
import io.v.nutz.sys.models.Sys_dict;
|
||||
import io.v.nutz.sys.services.SysDictService;
|
||||
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.welfare.feature.WelfareFeature;
|
||||
import io.v.nutz.zhgh.welfare.mode.WelfareMemberMode;
|
||||
import io.v.nutz.zhgh.welfare.mode.WelfareProvideMode;
|
||||
import io.v.nutz.zhgh.welfare.mode.WelfareUnitMode;
|
||||
import io.v.nutz.zhgh.welfare.model.WelfareCourierNumber;
|
||||
import io.v.nutz.zhgh.welfare.model.WelfareProject;
|
||||
import io.v.nutz.zhgh.welfare.model.WelfareProjectSubject;
|
||||
import io.v.nutz.zhgh.welfare.model.WelfareUserSelection;
|
||||
import io.v.nutz.zhgh.welfare.service.WelfareProjectService;
|
||||
import lombok.Data;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.poi.ss.usermodel.Workbook;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.apache.shiro.authz.annotation.RequiresRoles;
|
||||
import org.nutz.dao.Chain;
|
||||
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.json.Json;
|
||||
import org.nutz.lang.Lang;
|
||||
import org.nutz.lang.Strings;
|
||||
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.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 福利公用
|
||||
*
|
||||
* @author: 1V
|
||||
* @date: 2021/2/6
|
||||
* @since 1.0
|
||||
*/
|
||||
|
||||
@IocBean
|
||||
@Ok("json:full")
|
||||
@At("/platform/welfare/common")
|
||||
public class WelfareCommonController {
|
||||
|
||||
@Inject
|
||||
private MemberService memberService;
|
||||
|
||||
@Inject
|
||||
private WelfareProjectService projectService;
|
||||
|
||||
@Inject
|
||||
private OfficeTemplateUtil officeTemplateUtil;
|
||||
|
||||
@Inject
|
||||
private Dao dao;
|
||||
|
||||
@Inject
|
||||
private ExpressSelectUtil expressSelectUtil;
|
||||
|
||||
/**
|
||||
* 查询单个福利信息
|
||||
*
|
||||
* @param projectId
|
||||
* @return
|
||||
*/
|
||||
@At
|
||||
@ViReturn
|
||||
@RequiresPermissions("welfare.mine")
|
||||
public Object findOne(String projectId) {
|
||||
return projectService.projectInfo(projectId);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return 福利单位
|
||||
*/
|
||||
@At
|
||||
@ViReturn
|
||||
public Object welfareUnit(boolean isPermission) {
|
||||
Sql sql = Sqls.create("SELECT * from welfare_unit $condition");
|
||||
Cnd cnd = Cnd.NEW();
|
||||
cnd.and("welfareUnitMode", "=", WelfareUnitMode.getMode().name().toLowerCase());
|
||||
if (isPermission) {
|
||||
if (WelfareUnitMode.getMode().name().equals(WelfareUnitMode.UNION.name())) {
|
||||
cnd.and("welfareUnitId", "=", Vi.getUnionId());
|
||||
} else {
|
||||
cnd.and("welfareUnitId", "=", Vi.getUnit().getId());
|
||||
}
|
||||
}
|
||||
sql.setCondition(cnd);
|
||||
return memberService.listMap(sql);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return 福利单位的组成单位
|
||||
*/
|
||||
@At
|
||||
@ViReturn
|
||||
public Object componentUnit(String unitId) {
|
||||
Sql sql = Sqls.create("SELECT * from sys_unit $condition");
|
||||
CndPlus cndPlus = CndPlus.create();
|
||||
if (WelfareFeature.judgmentAuthority()) {
|
||||
cndPlus.andEx(WelfareUnitMode.getMode().getField(), "=", unitId);
|
||||
} else {
|
||||
String field = WelfareUnitMode.getMode().getField();
|
||||
Map<String, Object> bean = BeanUtil.beanToMap(Vi.getUnit());
|
||||
cndPlus.andEx(field, "=", bean.get(field));
|
||||
}
|
||||
cndPlus.and("unitlevel", "=", 2);
|
||||
cndPlus.asc("unitcode");
|
||||
sql.setCondition(cndPlus);
|
||||
return memberService.listMap(sql);
|
||||
}
|
||||
|
||||
/**
|
||||
* 将用户设置为福利会员
|
||||
*
|
||||
* @param userIds
|
||||
* @return
|
||||
*/
|
||||
@At
|
||||
@ViReturn
|
||||
public Object joinWelfareMember(String[] userIds) {
|
||||
WelfareMemberMode.joinWelfareMember(Arrays.stream(userIds).collect(Collectors.toList()));
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 将用户从福利会员中剔除
|
||||
*
|
||||
* @param userIds
|
||||
* @return
|
||||
*/
|
||||
@At
|
||||
@ViReturn
|
||||
public Object kickWelfareMember(String[] userIds) {
|
||||
WelfareMemberMode.kickWelfareMember(Arrays.stream(userIds).collect(Collectors.toList()));
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取项目
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@At
|
||||
@ViReturn
|
||||
public Object welfareProjects() {
|
||||
List<NutMap> options = new ArrayList<>();
|
||||
|
||||
List<WelfareProject> projects = projectService.query();
|
||||
|
||||
List<Integer> years = projects.stream().map(WelfareProject::getYear).distinct().sorted(Comparator.reverseOrder()).collect(Collectors.toList());
|
||||
for (Integer year : years) {
|
||||
NutMap map = NutMap.NEW().addv("value", year).addv("label", year);
|
||||
List<WelfareProject> projectList = projects.stream().filter(v -> v.getYear().equals(year)).sorted(Comparator.comparing(WelfareProject::getProvideTimeStart).reversed()).collect(Collectors.toList());
|
||||
map.addv("children", projectList.stream().map(v -> NutMap.NEW().addv("value", v.getId()).addv("label", v.getName()).addv("v", v)).collect(Collectors.toList()));
|
||||
options.add(map);
|
||||
}
|
||||
|
||||
return options;
|
||||
}
|
||||
|
||||
@Inject
|
||||
private SysDictService sysDictService;
|
||||
|
||||
/**
|
||||
* 导出福利名单
|
||||
*
|
||||
* @param projectId 项目id
|
||||
*/
|
||||
@At
|
||||
@Ok("void")
|
||||
public void exportWelfareList(String projectId, String personType, HttpServletResponse response) throws IOException {
|
||||
|
||||
WelfareProject project = projectService.fetch(projectId);
|
||||
WelfareProjectSubject welfareProjectSubject = projectService.dao().fetch(WelfareProjectSubject.class, Cnd.where("projectId", "=", project.getId()));
|
||||
|
||||
|
||||
Sql sql = Sqls.create("""
|
||||
SELECT
|
||||
vwl.*,
|
||||
wpus.userSign,
|
||||
wpus.selectOptionId
|
||||
FROM
|
||||
view_welfare_list vwl
|
||||
LEFT JOIN welfare_project_user_selection wpus ON wpus.selectUserId = vwl.id
|
||||
$condition
|
||||
""");
|
||||
CndPlus cnd = CndPlus.create();
|
||||
cnd.and("vwl.projectId", "=", projectId);
|
||||
cnd.and("vwl.unitid", "IS NOT", null);
|
||||
cnd.and("vwl.realWelfareUnitId", "IS NOT", null);
|
||||
/* if (StrUtil.isNotBlank(personType)) {
|
||||
cnd.and("vwl.personType", "in", Json.fromJsonAsArray(String.class, personType));
|
||||
}*/
|
||||
cnd.groupBy("vwl.id");
|
||||
cnd.asc("vwl.realWelfareUnitCode");
|
||||
WelfareFeature.Condition.judgmentAuthority(cnd);
|
||||
sql.setCondition(cnd);
|
||||
List<NutMap> welfareList = projectService.listMap(sql);
|
||||
|
||||
Map v = new HashMap();
|
||||
|
||||
List list = new ArrayList();
|
||||
|
||||
Map<String, List<NutMap>> collect = welfareList.stream().collect(Collectors.groupingBy(x -> x.getString("realWelfareUnitName")));
|
||||
|
||||
collect.forEach((welfareUnitName, welfareUnitUsers) -> {
|
||||
|
||||
Map map = new HashMap<>();
|
||||
|
||||
map.put("projectName", project.getName());
|
||||
|
||||
map.put("welfareUnitName", welfareUnitName);
|
||||
map.put("peopleNumber", welfareUnitUsers.size());
|
||||
|
||||
Map<String, List<NutMap>> unitCollect = welfareUnitUsers.stream().sorted(Comparator.comparing(x -> x.getString("unitcode"))).collect(Collectors.groupingBy(x -> x.getString("unitname")));
|
||||
|
||||
List units = new ArrayList();
|
||||
unitCollect.forEach((unitName, unitUsers) -> {
|
||||
|
||||
Map m = new HashMap<>();
|
||||
m.put("projectName", project.getName());
|
||||
m.put("welfareUnitName", welfareUnitName);
|
||||
|
||||
m.put("unitName", unitName);
|
||||
m.put("peopleNumber", unitUsers.size());
|
||||
m.put("users", unitUsers);
|
||||
m.put("name", project.getFlexible() ? welfareProjectSubject.getSubjectName() : project.getGift());
|
||||
m.put("provideTime", DateUtil.format(project.getProvideTimeStart(), "yyyy-MM-dd"));
|
||||
|
||||
AtomicInteger i = new AtomicInteger();
|
||||
unitUsers.forEach(unitUser -> {
|
||||
i.getAndIncrement();
|
||||
unitUser.setv("index", i.get());
|
||||
});
|
||||
|
||||
units.add(m);
|
||||
});
|
||||
|
||||
map.put("units", units);
|
||||
|
||||
list.add(map);
|
||||
});
|
||||
|
||||
v.put("list", list);
|
||||
|
||||
|
||||
String fileName = project.getName() + "发放名单";
|
||||
response.addHeader("Content-Type", "application/octet-stream");
|
||||
response.addHeader("Content-Disposition", "attachment; filename=\"" + new String(fileName.getBytes("UTF-8"), "ISO-8859-1") + "\".docx");
|
||||
|
||||
HackLoopTableRenderPolicy policy = new HackLoopTableRenderPolicy();
|
||||
Configure config = Configure.newBuilder().bind("users", policy).build();
|
||||
|
||||
XWPFTemplate.compile(officeTemplateUtil.getPath("WelfareList"), config).render(v).writeAndClose(response.getOutputStream());
|
||||
}
|
||||
|
||||
@At
|
||||
@Ok("void")
|
||||
public void exportWelfareListSummary(String projectId, HttpServletResponse response) throws IOException {
|
||||
try {
|
||||
//获取所有人员类型
|
||||
Sys_dict dict = sysDictService.fetch(Cnd.where("code", "=", "UserType"));
|
||||
List<Sys_dict> userTypeDictList = dict == null ? new ArrayList<>() : sysDictService.query(Cnd.where("parentId", "=", Strings.sNull(dict.getId())).and("disabled", "=", false).asc("location"));
|
||||
List<String> userTypeList = userTypeDictList.stream().map(Sys_dict::getCode).collect(Collectors.toList());
|
||||
|
||||
List<String> typeList = new ArrayList<>();
|
||||
typeList.add("事业编制");
|
||||
typeList.add("非事业编制");
|
||||
typeList.add("劳务派遣");
|
||||
typeList.add("其它");
|
||||
typeList.add("合计");
|
||||
List<String> userTypeListLabel = userTypeList.stream().filter(v -> !typeList.contains(v)).collect(Collectors.toList());
|
||||
|
||||
Sql sql = Sqls.create("""
|
||||
SELECT
|
||||
unit.*,
|
||||
sum( 1 ) number,
|
||||
$temp_sql
|
||||
FROM
|
||||
welfare_unit unit
|
||||
LEFT JOIN welfare_list list ON unit.welfareUnitId = list.welfareUnitId
|
||||
LEFT JOIN `user` su ON su.id = list.userId
|
||||
$condition
|
||||
""");
|
||||
StringBuffer temp_sql_str = new StringBuffer();
|
||||
|
||||
userTypeList.forEach(v -> {
|
||||
temp_sql_str.append("COUNT( CASE WHEN ( su.personType = '%s' ) THEN 1 ELSE NULL END ) AS '%s',".formatted(v, v));
|
||||
});
|
||||
|
||||
String totalUserType = CollUtil.join(userTypeList, ",", "'", "'");
|
||||
String totalUserType2 = CollUtil.join(userTypeListLabel, ",", "'", "'");
|
||||
temp_sql_str.append("COUNT( CASE WHEN ( su.personType in (%s) ) THEN 1 ELSE NULL END ) AS '其它',".formatted(totalUserType2));
|
||||
temp_sql_str.append("COUNT( CASE WHEN ( su.personType in (%s) ) THEN 1 ELSE NULL END ) AS totalNum".formatted(totalUserType));
|
||||
sql.setVar("temp_sql", temp_sql_str);
|
||||
|
||||
CndPlus cnd = CndPlus.create();
|
||||
cnd.and("unit.welfareUnitMode", "=", WelfareUnitMode.getMode().name());
|
||||
cnd.and("list.projectId", "=", projectId);
|
||||
cnd.groupBy("unit.welfareUnitId");
|
||||
cnd.asc("unit.welfareUnitCode");
|
||||
sql.setCondition(cnd);
|
||||
|
||||
List<NutMap> list = projectService.listMap(sql);
|
||||
|
||||
List<ExcelExportEntity> exportEntityList = new ArrayList<ExcelExportEntity>();
|
||||
exportEntityList.add(new ExcelExportEntity("分工会", "welfareUnitName", 30));
|
||||
List<Sys_dict> dicts = userTypeDictList.stream().filter(v -> typeList.contains(v.getName())).collect(Collectors.toList());
|
||||
dicts.forEach(v -> {
|
||||
exportEntityList.add(new ExcelExportEntity(v.getName(), v.getName()));
|
||||
});
|
||||
exportEntityList.add(new ExcelExportEntity("其它", "其它"));
|
||||
exportEntityList.add(new ExcelExportEntity("合计", "totalNum"));
|
||||
|
||||
WelfareProject project = projectService.fetch(projectId);
|
||||
String fileName = project.getName().concat("发放表");
|
||||
|
||||
response.setContentType("application/octet-stream");
|
||||
response.setHeader("Content-Disposition", "attachment;filename=" + new String((fileName + ".xls").getBytes("utf-8"), "ISO8859-1"));
|
||||
Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams(project.getName(), null), exportEntityList, list);
|
||||
workbook.write(response.getOutputStream());
|
||||
workbook.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Data
|
||||
public static class ExportEntityWelfareList {
|
||||
@Excel(name = "编码", width = 20d)
|
||||
private String welfareUnitCode;
|
||||
|
||||
@Excel(name = "分工会", width = 40d)
|
||||
private String welfareUnitName;
|
||||
|
||||
@Excel(name = "教职工", width = 20d)
|
||||
private String faculty;
|
||||
|
||||
@Excel(name = "未起薪人员", width = 20d)
|
||||
private String wqxNum;
|
||||
|
||||
@Excel(name = "校级劳务派遣人员", width = 20d)
|
||||
private String schoolLaborNum;
|
||||
|
||||
@Excel(name = "单位劳务派遣人员", width = 20d)
|
||||
private String unitLaborNum;
|
||||
|
||||
@Excel(name = "劳动服务公司", width = 20d)
|
||||
private String compLaborNum;
|
||||
|
||||
@Excel(name = "后勤聘用人员", width = 20d)
|
||||
private String logisticsNum;
|
||||
|
||||
@Excel(name = "单位自聘人员", width = 20d)
|
||||
private String unitSelfNum;
|
||||
|
||||
@Excel(name = "离退休人员", width = 20d)
|
||||
private String retireNum;
|
||||
|
||||
@Excel(name = "合计", width = 20d)
|
||||
private String totalNum;
|
||||
|
||||
}
|
||||
|
||||
@Data
|
||||
public static class ExportEntityUser {
|
||||
|
||||
@Excel(name = "工号", width = 20d)
|
||||
private String loginname;
|
||||
|
||||
@Excel(name = "姓名", width = 20d)
|
||||
private String username;
|
||||
|
||||
|
||||
@Excel(name = "身份证号", width = 20d)
|
||||
private String idcard;
|
||||
|
||||
/* @Excel(name = "人员类型", width = 20d)
|
||||
private String personType;
|
||||
|
||||
@Excel(name = "在职状态", width = 20d)
|
||||
private String userState;
|
||||
|
||||
@Excel(name = "所属工会", width = 20d)
|
||||
private String unionName;*/
|
||||
|
||||
@Excel(name = "所属单位", width = 20d)
|
||||
private String unitName;
|
||||
|
||||
// @Excel(name = "实名签字", width = 20d)
|
||||
private String userSign;
|
||||
|
||||
@Excel(name = "实名签字", width = 20d, type = 2, imageType = 2)
|
||||
private byte[] qzBytes;
|
||||
|
||||
@Excel(name = "生日蛋糕卷编号", width = 20d)
|
||||
private String bh;
|
||||
|
||||
/* @Excel(name = "所属校区", width = 20d)
|
||||
private String campusName;*/
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@At
|
||||
@Ok("void")
|
||||
public void doExportWelfare(String projectId, String unionId, HttpServletResponse response) throws IOException {
|
||||
CndPlus cnd = CndPlus.create();
|
||||
Sql sql = Sqls.create("""
|
||||
SELECT
|
||||
loginname,
|
||||
idcard,
|
||||
username,
|
||||
personType,
|
||||
userState,
|
||||
unionname,
|
||||
unitname,
|
||||
campusName,
|
||||
wpus.userSign
|
||||
FROM
|
||||
view_welfare_list vwl
|
||||
LEFT JOIN welfare_project_user_selection wpus ON wpus.selectUserId = vwl.id AND wpus.welfareId=vwl.projectId
|
||||
$condition
|
||||
""");
|
||||
cnd.and("vwl.projectId", "=", projectId);
|
||||
cnd.and("wpus.userSign", "is not", null);
|
||||
cnd.and("wpus.userSign", "!=", "");
|
||||
|
||||
ExportParams exportParams = new ExportParams();
|
||||
|
||||
if (!ShiroUtil.hasAnyRoles("sysadmin,SchoolUnionAdmin,SchoolUnionMemberAdmin,SchoolUnionWelfareAdmin")) {
|
||||
cnd.and("vwl.unionid", "=", Vi.getUnionId());
|
||||
exportParams.setTitle(Vi.getUnion().getUnionname() + "名单");
|
||||
}
|
||||
cnd.asc("vwl.unionname");
|
||||
cnd.asc("vwl.unitname");
|
||||
|
||||
sql.setCondition(cnd);
|
||||
List<ExportEntityUser> exportEntityUsers = projectService.listEntity(sql, ExportEntityUser.class);
|
||||
exportEntityUsers.forEach(v -> {
|
||||
if (Strings.isNotBlank(v.getIdcard())) {
|
||||
String idcard = v.getIdcard().substring(0, v.getIdcard().length() - 4);
|
||||
v.setIdcard(idcard + "****");
|
||||
}
|
||||
if (StrUtil.isNotBlank(v.getUserSign())) {
|
||||
try {
|
||||
Path tempPath = Files.createTempFile("福利", ".png");
|
||||
Base64.decodeToFile(v.getUserSign().substring(v.getUserSign().indexOf(",") + 1), tempPath.toFile());
|
||||
FileInputStream inputStream = new FileInputStream(tempPath.toFile());
|
||||
byte[] qzBytes = IOUtils.toByteArray(inputStream);
|
||||
v.setQzBytes(qzBytes);
|
||||
inputStream.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
response.setContentType("application/octet-stream");
|
||||
response.setHeader("Content-Disposition", "attachment;filename=" + new String(("福利名单.xls").getBytes("utf-8"), "ISO8859-1"));
|
||||
Workbook workbook = ExcelExportUtil.exportExcel(exportParams, ExportEntityUser.class, exportEntityUsers);
|
||||
workbook.write(response.getOutputStream());
|
||||
workbook.close();
|
||||
}
|
||||
|
||||
|
||||
@At
|
||||
@ViReturn
|
||||
public Object getPersonTypeListGroupByWelfare() {
|
||||
Sql sql = Sqls.create("""
|
||||
select personType from sys_user where welfareMember = 1 GROUP BY personType
|
||||
""");
|
||||
return memberService.listMap(sql);
|
||||
}
|
||||
|
||||
@At
|
||||
@Ok("void")
|
||||
public void exportReceive(String projectId,
|
||||
String welfareUnit,
|
||||
@Param("welfareTwoUnit") String[] welfareTwoUnit,
|
||||
@Param("personTypes") String[] personTypes,
|
||||
@Param("userStates") String[] userStates,
|
||||
HttpServletResponse response) {
|
||||
WelfareProject welfareProject = projectService.fetch(projectId);
|
||||
CndPlus cnd = CndPlus.create();
|
||||
Sql sql = Sqls.create("""
|
||||
SELECT
|
||||
id,
|
||||
loginname,
|
||||
username,
|
||||
personType,
|
||||
userState,
|
||||
unionname,
|
||||
unitname,
|
||||
campusName,
|
||||
@gift_name AS gift_name
|
||||
FROM
|
||||
view_welfare_list $condition
|
||||
""");
|
||||
sql.setParam("gift_name", welfareProject.getGift());
|
||||
cnd.and("projectId", "=", projectId);
|
||||
cnd.andEX("unionid", "=", welfareUnit);
|
||||
cnd.andEX("unitid", "in", welfareTwoUnit);
|
||||
cnd.andEX("personType", "in", personTypes);
|
||||
cnd.andEX("userState", "in", userStates);
|
||||
|
||||
if (!ShiroUtil.hasAnyRoles("sysadmin,SchoolUnionAdmin,SchoolUnionMemberAdmin,SchoolUnionWelfareAdmin,H04,gh12") && Globals.MyConfig.getBoolean("isThreeUnit")) {
|
||||
cnd.and("list.unionGroupId", "in", ShiroUtil.getUnionGroupIds());
|
||||
}
|
||||
cnd.asc("unionname");
|
||||
cnd.asc("unitname");
|
||||
|
||||
sql.setCondition(cnd);
|
||||
List<NutMap> list = projectService.listMap(sql);
|
||||
|
||||
Sql sql_gift = Sqls.create("""
|
||||
select wpus.selectUserId,wpus.id,wpso.optionName,wpus.receiveAddress from welfare_project_user_selection wpus
|
||||
left join welfare_project_subject_option wpso on wpso.id = wpus.selectOptionId
|
||||
where wpus.welfareId=@projectId
|
||||
""");
|
||||
sql_gift.setParam("projectId", projectId);
|
||||
List<NutMap> gift_list = projectService.listMap(sql_gift);
|
||||
|
||||
list.forEach(v -> {
|
||||
List<NutMap> fl = gift_list.stream().filter(gl -> gl.getString("selectUserId").equals(v.getString("id"))).collect(Collectors.toList());
|
||||
if (Lang.isNotEmpty(fl)) {
|
||||
v.put("gist_list", fl.stream().map(x -> x.getString("optionName")).collect(Collectors.joining("、")));
|
||||
v.put("receiveAddress", fl.stream().findFirst().get().getString("receiveAddress"));
|
||||
} else {
|
||||
v.put("gist_list", "");
|
||||
v.put("receiveAddress", "");
|
||||
}
|
||||
});
|
||||
List<ExcelExportEntity> entityList = new ArrayList<>();
|
||||
entityList.add(new ExcelExportEntity("工号", "loginname", 20));
|
||||
entityList.add(new ExcelExportEntity("姓名", "username", 20));
|
||||
entityList.add(new ExcelExportEntity("在职状态", "userState", 20));
|
||||
entityList.add(new ExcelExportEntity("人员类型", "personType", 20));
|
||||
entityList.add(new ExcelExportEntity("所属工会", "unionname", 50));
|
||||
entityList.add(new ExcelExportEntity("所属单位", "unitname", 50));
|
||||
|
||||
if (welfareProject.getFlexible()) {
|
||||
entityList.add(new ExcelExportEntity("所选福利", "gist_list", 60));
|
||||
} else {
|
||||
entityList.add(new ExcelExportEntity("所选福利", "gift_name", 20));
|
||||
}
|
||||
|
||||
if (welfareProject.getProvideMode().equals(WelfareProvideMode.PERSONAL.getCode())) {
|
||||
entityList.add(new ExcelExportEntity("配送地址", "receiveAddress", 60));
|
||||
}
|
||||
|
||||
try {
|
||||
ViTool.excelResponse(response, "会员福利领取情况.xls");
|
||||
Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams(), entityList, list);
|
||||
workbook.write(response.getOutputStream());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 查看快递物流信息
|
||||
*
|
||||
* @param welfareId 福利id
|
||||
* @param userId 用户id
|
||||
* @return {@link Object}
|
||||
*/
|
||||
@At
|
||||
@ViReturn
|
||||
public Object courierNumberInfo(String welfareId, String userId) {
|
||||
//查询的时候去触发福利最新信息
|
||||
List<WelfareCourierNumber> welfareCourierNumberList = dao.query(WelfareCourierNumber.class, Cnd.where("welfareId", "=", welfareId).and("selectUserId", "=", userId));
|
||||
for (WelfareCourierNumber courierNumber : welfareCourierNumberList) {
|
||||
//如果有上次查询的时间
|
||||
|
||||
if (Lang.isNotEmpty(courierNumber.getSelectExpressDate()) && DateUtil.offsetHour(courierNumber.getSelectExpressDate(), 2).getTime() > new Date().getTime()) {
|
||||
//还在有效期内
|
||||
continue;
|
||||
}
|
||||
|
||||
if (Lang.isNotEmpty(courierNumber.getLogisticsTrace()) && List.of("AGENT_SIGN", "SIGN").contains(courierNumber.getLogisticsTrace().getLogisticsStatus())) {
|
||||
//签收了
|
||||
continue;
|
||||
}
|
||||
|
||||
if (Lang.isEmpty(courierNumber.getCourierNumber())) {
|
||||
//没快递单号
|
||||
continue;
|
||||
}
|
||||
|
||||
WelfareUserSelection userSelection = dao.fetch(WelfareUserSelection.class, Cnd.where("welfareId", "=", welfareId).and("selectUserId", "=", userId));
|
||||
|
||||
//需要去查询最新的物流信息
|
||||
String receiveAddress = userSelection.getReceiveAddress();
|
||||
String mobile = receiveAddress.substring(receiveAddress.length() - 11);
|
||||
|
||||
JSONObject jsonObject = expressSelectUtil.getExpressInfo(courierNumber.getCourierNumber(), mobile);
|
||||
WelfareUserSelection.LogisticsTrace logisticsTrace = new WelfareUserSelection.LogisticsTrace();
|
||||
logisticsTrace.setTheLastTime(jsonObject.getDate("theLastTime"));
|
||||
logisticsTrace.setTheLastMessage(jsonObject.getString("theLastMessage"));
|
||||
logisticsTrace.setLogisticsStatusDesc(jsonObject.getString("logisticsStatusDesc"));
|
||||
logisticsTrace.setLogisticsStatus(jsonObject.getString("logisticsStatus"));
|
||||
List<NutMap> logisticsTraceDetailList = Json.fromJsonAsList(NutMap.class, jsonObject.getString("logisticsTraceDetailList"));
|
||||
logisticsTrace.setLogisticsTraceDetailList(logisticsTraceDetailList);
|
||||
|
||||
dao.update(WelfareCourierNumber.class,
|
||||
Chain.make("logisticsTrace", logisticsTrace)
|
||||
.add("selectExpressDate", new Date()),
|
||||
Cnd.where("id", "=", courierNumber.getId()));
|
||||
}
|
||||
|
||||
Sql sql = Sqls.create("""
|
||||
SELECT
|
||||
wpso.optionName,
|
||||
wpso.imgUrl,
|
||||
wcn.courierNumber,
|
||||
wcn.logisticsTrace
|
||||
FROM
|
||||
welfare_courier_number wcn
|
||||
LEFT JOIN welfare_project_subject_option wpso ON wpso.id = wcn.selectOptionId
|
||||
WHERE
|
||||
wcn.welfareId = @welfareId
|
||||
AND wcn.selectUserId = @userId
|
||||
ORDER BY wpso.optionSort
|
||||
""");
|
||||
sql.setParam("welfareId", welfareId);
|
||||
sql.setParam("userId", userId);
|
||||
List<NutMap> list = projectService.listMap(sql);
|
||||
|
||||
for (NutMap nutMap : list) {
|
||||
nutMap.put("logisticsTrace", nutMap.getAs("logisticsTrace", WelfareUserSelection.LogisticsTrace.class));
|
||||
}
|
||||
List<NutMap> mapList = sql.getList(NutMap.class);
|
||||
|
||||
Map<String, List<NutMap>> listMap = mapList.stream().collect(Collectors.groupingBy(v -> v.getString("optionName")));
|
||||
return listMap;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
+93
@@ -0,0 +1,93 @@
|
||||
package io.v.nutz.zhgh.welfare.controller;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import io.v.nutz.base.annontation.ViReturn;
|
||||
import io.v.nutz.base.query.PageForm;
|
||||
import io.v.nutz.base.service.SimpleService;
|
||||
import io.v.nutz.zhgh.welfare.model.WelfareProjectSubject;
|
||||
import io.v.nutz.zhgh.welfare.model.WelfareProjectSubjectOption;
|
||||
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.ioc.loader.annotation.Inject;
|
||||
import org.nutz.ioc.loader.annotation.IocBean;
|
||||
import org.nutz.mvc.annotation.At;
|
||||
import org.nutz.mvc.annotation.Ok;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @ClassName WelfareEvaluateStatisticsController
|
||||
* @Description 评价统计
|
||||
* @Author zhf
|
||||
* @Date 2024/5/7 20:02
|
||||
*/
|
||||
@IocBean
|
||||
@Ok("json:full")
|
||||
@At("/platform/welfare/evaluate/statistics")
|
||||
public class WelfareEvaluateStatisticsController {
|
||||
|
||||
@Inject
|
||||
private SimpleService simpleService;
|
||||
|
||||
@Inject
|
||||
private Dao dao;
|
||||
|
||||
@At("")
|
||||
@Ok("beetl:/platform/welfare/evaluateStatistics.html")
|
||||
@RequiresPermissions("welfare.evaluate.statistics")
|
||||
public void index() {
|
||||
}
|
||||
|
||||
@At
|
||||
@ViReturn
|
||||
@RequiresPermissions("welfare.evaluate.statistics")
|
||||
public Object pageData(PageForm pageForm, String projectId, String unionId, String unitId, String personType, String userState, Integer evaluateScore, String optionId) {
|
||||
Sql sql = Sqls.create("""
|
||||
SELECT
|
||||
we.evaluateText,
|
||||
we.evaluateScore,
|
||||
we.userName,
|
||||
we.loginName,
|
||||
u.unionname,
|
||||
u.unitname,
|
||||
u.userState,
|
||||
u.personType
|
||||
FROM
|
||||
`welfare_evaluate` we
|
||||
LEFT JOIN `user` u ON u.id = we.userId
|
||||
$condition
|
||||
""");
|
||||
Cnd cnd = Cnd.NEW();
|
||||
if (StrUtil.isNotBlank(pageForm.getSearchName()) && StrUtil.isNotBlank(pageForm.getSearchKeyword())) {
|
||||
cnd.and(Cnd.likeEX(pageForm.getSearchName(), pageForm.getSearchKeyword()));
|
||||
}
|
||||
if (StrUtil.isNotBlank(pageForm.getPageOrderName()) && StrUtil.isNotBlank(pageForm.getPageOrderBy())) {
|
||||
cnd.orderBy(pageForm.getPageOrderName(), pageForm.getPageOrderBy().equals("ascending") ? "asc" : "desc");
|
||||
} else {
|
||||
cnd.desc("we.evaluateScore");
|
||||
}
|
||||
cnd.and("we.projectId", "=", projectId);
|
||||
cnd.andEX("u.unionid", "=", unionId);
|
||||
cnd.andEX("u.unitid", "=", unitId);
|
||||
cnd.andEX("u.personType", "=", personType);
|
||||
cnd.andEX("u.userState", "=", userState);
|
||||
cnd.andEX("we.evaluateScore", "=", evaluateScore);
|
||||
cnd.andEX("optionId", "=", optionId);
|
||||
sql.setCondition(cnd);
|
||||
return simpleService.listPageMap(pageForm.getPageNumber(), pageForm.getPageSize(), sql);
|
||||
}
|
||||
|
||||
@At
|
||||
@ViReturn
|
||||
@RequiresPermissions("welfare.evaluate.statistics")
|
||||
public Object welfareOptions(String projectId) {
|
||||
List<WelfareProjectSubject> subjects = dao.query(WelfareProjectSubject.class, Cnd.where("projectId", "=", projectId));
|
||||
List<String> subjectIds = subjects.stream().map(v -> v.getId()).collect(Collectors.toList());
|
||||
return dao.query(WelfareProjectSubjectOption.class, Cnd.where("subjectId", "in", subjectIds).asc("optionSort"));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,661 @@
|
||||
package io.v.nutz.zhgh.welfare.controller;
|
||||
|
||||
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.TemplateExportParams;
|
||||
import cn.afterturn.easypoi.excel.entity.enmus.ExcelType;
|
||||
import cn.afterturn.easypoi.excel.entity.params.ExcelExportEntity;
|
||||
import cn.afterturn.easypoi.excel.export.ExcelExportService;
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import cn.hutool.core.lang.Assert;
|
||||
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.dao.CndPlus;
|
||||
import io.v.nutz.base.query.PageForm;
|
||||
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.welfare.feature.WelfareFeature;
|
||||
import io.v.nutz.zhgh.welfare.mode.CourierNumberExcelMode;
|
||||
import io.v.nutz.zhgh.welfare.model.*;
|
||||
import io.v.nutz.zhgh.welfare.service.WelfareListService;
|
||||
import io.v.nutz.zhgh.welfare.service.WelfareProjectService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.poi.ss.usermodel.Workbook;
|
||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||
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.Dao;
|
||||
import org.nutz.dao.Sqls;
|
||||
import org.nutz.dao.entity.Record;
|
||||
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.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 org.nutz.trans.Trans;
|
||||
|
||||
import javax.servlet.ServletOutputStream;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 福利名单
|
||||
*
|
||||
* @author: 1V
|
||||
* @date: 2021/3/1
|
||||
* @since 1.0
|
||||
*/
|
||||
@IocBean
|
||||
@Slf4j
|
||||
@Ok("json")
|
||||
@At("/platform/welfare/list/mange")
|
||||
public class WelfareListController {
|
||||
|
||||
@Inject
|
||||
private WelfareListService welfareListService;
|
||||
|
||||
@Inject
|
||||
private WelfareProjectService projectService;
|
||||
|
||||
@Inject
|
||||
private Dao dao;
|
||||
|
||||
@At("")
|
||||
@Ok("beetl:/platform/welfare/list/ListMange.html")
|
||||
@RequiresPermissions("welfare.list.mange")
|
||||
public void index() {
|
||||
}
|
||||
|
||||
@At
|
||||
@ViReturn
|
||||
@RequiresPermissions("welfare.list.mange")
|
||||
public Object pageData(PageForm pageForm,
|
||||
WelfareFeature.Condition.PageParam pageParam,
|
||||
@Param(value = "projectId", required = false) String projectId,
|
||||
@Param(value = "optionId", required = false) String optionId,
|
||||
@Param(value = "month", required = false) String month,
|
||||
@Param(value = "courierNumber", required = false) String courierNumber
|
||||
) {
|
||||
Sql sql = Sqls.create("""
|
||||
SELECT
|
||||
CASE
|
||||
|
||||
WHEN
|
||||
wus.selectUserId IS NOT NULL THEN
|
||||
1 ELSE 0
|
||||
END AS isChoose,
|
||||
wl.id,
|
||||
wl.username,
|
||||
wl.loginname,
|
||||
wl.personType,
|
||||
wl.userState,
|
||||
wl.unionname,
|
||||
wl.unitname,
|
||||
wl.listId,
|
||||
wus.userSign,
|
||||
wus.courierNumber,
|
||||
wus.receiveAddress,
|
||||
GROUP_CONCAT( DISTINCT wuso.optionName, '(', wus.selectNum, '份)' ) AS gist_list
|
||||
FROM
|
||||
view_welfare_list wl
|
||||
LEFT JOIN welfare_project_user_selection wus ON wus.welfareId = wl.projectId
|
||||
AND wus.selectUserId = wl.id
|
||||
LEFT JOIN welfare_project_subject_option wuso ON wus.selectOptionId = wuso.id
|
||||
LEFT JOIN welfare_courier_number wcn on wcn.selectUserId = wl.id
|
||||
LEFT JOIN welfare_project wp ON wp.id = wus.welfareId
|
||||
$condition
|
||||
""");
|
||||
CndPlus cnd = CndPlus.create();
|
||||
cnd.and(pageForm);
|
||||
cnd.and("wl.projectId", "=", projectId);
|
||||
cnd.andEX("wus.selectOptionId", "=", optionId);
|
||||
cnd.andEX("wl.unionid", "=", pageParam.getWelfareUnit());
|
||||
cnd.andEX("wl.unitid", "=", pageParam.getUnit());
|
||||
|
||||
if (Lang.isNotEmpty(pageParam.getPersonTypes())) {
|
||||
String personTypes = pageParam.getPersonTypes();
|
||||
String[] personTypeArray = Json.fromJsonAsArray(String.class, personTypes);
|
||||
cnd.andEX("wl.personType", "in", personTypeArray);
|
||||
}
|
||||
|
||||
if (Lang.isNotEmpty(pageParam.getUserStates())) {
|
||||
String userStates = pageParam.getUserStates();
|
||||
String[] userStateArray = Json.fromJsonAsArray(String.class, userStates);
|
||||
cnd.andEX("wl.userState", "in", userStateArray);
|
||||
}
|
||||
|
||||
cnd.andEX("wl.sex", "in", pageParam.getSex());
|
||||
|
||||
cnd.andEX("wcn.courierNumber", "=", courierNumber);
|
||||
|
||||
cnd.groupBy("wl.id");
|
||||
cnd.asc("wl.unitCode");
|
||||
cnd.asc("wl.loginname");
|
||||
|
||||
if (!ShiroUtil.hasAnyRoles("sysadmin")) {
|
||||
cnd.and("wl.unionid", "=", Vi.getUnionId());
|
||||
}
|
||||
|
||||
sql.setCondition(cnd);
|
||||
return welfareListService.list(pageForm, sql);
|
||||
}
|
||||
|
||||
@At
|
||||
@ViReturn
|
||||
@RequiresPermissions("welfare.list.mange")
|
||||
public Object joinWelfareList(String[] userIds, String projectId) {
|
||||
welfareListService.joinWelfareList(projectId, Arrays.asList(userIds));
|
||||
return null;
|
||||
}
|
||||
|
||||
@At
|
||||
@ViReturn
|
||||
@RequiresPermissions("welfare.list.mange")
|
||||
public Object delete(String[] id) {
|
||||
Record record = welfareListService.dao().fetch("view_welfare_list", Cnd.where("listId", "in", id));
|
||||
String projectId = record.getString("projectId");
|
||||
String userId = record.getString("id");
|
||||
Trans.exec(() -> {
|
||||
welfareListService.delete(id);
|
||||
welfareListService.dao().clear(WelfareUserSelection.class, Cnd.where("welfareId", "=", projectId).and("selectUserId", "=", userId));
|
||||
});
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@At
|
||||
@ViReturn
|
||||
@RequiresPermissions("welfare.list.mange")
|
||||
public Object editWelfareUnit(String listId, String welfareUnitId) {
|
||||
welfareListService.update(Chain.make("welfareUnitId", welfareUnitId), Cnd.where("id", "=", listId));
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@At
|
||||
@ViReturn
|
||||
@RequiresPermissions("welfare.list.mange")
|
||||
public Object doWholeReceive(String id, String choices) {
|
||||
List<String> choiceList = Json.fromJsonAsList(String.class, choices);
|
||||
if (Lang.isNotEmpty(choiceList)) {
|
||||
welfareListService.update(Chain.make("isReceive", true), Cnd.where("projectId", "=", id).and("userId", "in", choiceList));
|
||||
}
|
||||
/* choiceList.forEach(v -> {
|
||||
welfareListService.update(Chain.make("isReceive", true), Cnd.where("projectId", "=", id).and("userId", "=", v));
|
||||
});*/
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 一键领取
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@At
|
||||
@ViReturn
|
||||
@RequiresPermissions("welfare.list.mange")
|
||||
public Object doOneKeyReceive(String id) {
|
||||
try {
|
||||
Assert.notBlank(id);
|
||||
welfareListService.update(Chain.make("isReceive", true), Cnd.where("projectId", "=", id));
|
||||
return Result.success();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return Result.error(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@At
|
||||
@ViReturn
|
||||
@RequiresPermissions("welfare.list.mange")
|
||||
public Object welfareOptions(String projectId) {
|
||||
Dao dao = welfareListService.dao();
|
||||
List<WelfareProjectSubject> subjects = dao.query(WelfareProjectSubject.class, Cnd.where("projectId", "=", projectId));
|
||||
List<String> subjectIds = subjects.stream().map(v -> v.getId()).collect(Collectors.toList());
|
||||
return welfareListService.dao().query(WelfareProjectSubjectOption.class, Cnd.where("subjectId", "in", subjectIds).asc("optionSort"));
|
||||
}
|
||||
|
||||
@At
|
||||
@ViReturn
|
||||
@Aop(TransAop.READ_COMMITTED)
|
||||
@RequiresPermissions("welfare.list.mange")
|
||||
public Object doEditWelfareData(@Param("editWelfareData") String editWelfareData,
|
||||
@Param("welfareOptions") String welfareOptions) {
|
||||
NutMap editData = Json.fromJson(NutMap.class, editWelfareData);
|
||||
List<NutMap> optionList = Json.fromJsonAsList(NutMap.class, welfareOptions);
|
||||
Dao dao = welfareListService.dao();
|
||||
WelfareUserSelection oldSelection = dao.fetch(WelfareUserSelection.class, Cnd.where("welfareId", "=", editData.getString("projectId"))
|
||||
.and("selectUserId", "=", editData.getString("userId")));
|
||||
String sign = "";
|
||||
if (ObjectUtil.isNotEmpty(oldSelection)) {
|
||||
sign = oldSelection.getUserSign();
|
||||
}
|
||||
|
||||
dao.clear(WelfareUserSelection.class,
|
||||
Cnd.where("welfareId", "=", editData.getString("projectId"))
|
||||
.and("selectUserId", "=", editData.getString("userId")));
|
||||
String finalSign = sign;
|
||||
List<WelfareUserSelection> userSelections = optionList.stream().map(v -> {
|
||||
WelfareUserSelection selection = new WelfareUserSelection();
|
||||
selection.setSelectTime(new Date());
|
||||
selection.setWelfareId(editData.getString("projectId"));
|
||||
selection.setSelectUserId(editData.getString("userId"));
|
||||
selection.setSelectOptionId(v.getString("id"));
|
||||
selection.setReceiveAddress(editData.getString("receiveAddress"));
|
||||
selection.setSubjectId(v.getString("subjectId"));
|
||||
selection.setSelectNum(v.getInt("selectNum"));
|
||||
selection.setUserSign(finalSign);
|
||||
return selection;
|
||||
}).collect(Collectors.toList());
|
||||
|
||||
List<WelfareUserSelection> userSelections1 = userSelections.stream().filter(v -> v.getSelectNum() > 0).collect(Collectors.toList());
|
||||
dao.insert(userSelections1);
|
||||
dao.update(WelfareList.class,
|
||||
Chain.make("isReceive", true),
|
||||
Cnd.where("projectId", "=", editData.getString("projectId"))
|
||||
.and("userId", "=", editData.getString("userId")));
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@At
|
||||
@Ok("void")
|
||||
@RequiresPermissions("welfare.list.mange")
|
||||
public void downLoadExpressTemplate(HttpServletResponse response) {
|
||||
try {
|
||||
String fileName = "导入模板";
|
||||
response.setContentType("application/octet-stream");
|
||||
response.setHeader("Content-Disposition", "attachment;filename=" + new String((fileName + ".xlsx").getBytes(StandardCharsets.UTF_8), "ISO8859-1"));
|
||||
ExportParams exportParams = new ExportParams();
|
||||
exportParams.setType(ExcelType.XSSF);
|
||||
Workbook workbook = ExcelExportUtil.exportExcel(exportParams, CourierNumberExcelMode.class, Collections.emptyList());
|
||||
workbook.write(response.getOutputStream());
|
||||
|
||||
// new ExcelExportService().createSheetForMap();
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出各套餐选择数据
|
||||
*
|
||||
* @param projectId
|
||||
*/
|
||||
@At
|
||||
@Ok("void")
|
||||
@RequiresPermissions("welfare.list.mange")
|
||||
public void exportSelectData(String projectId, HttpServletResponse response) {
|
||||
WelfareProject welfareProject = dao.fetch(WelfareProject.class, Cnd.where("id", "=", projectId));
|
||||
String projectName = welfareProject.getName();
|
||||
Cnd cnd = Cnd.NEW();
|
||||
Sql sql = Sqls.create("""
|
||||
SELECT
|
||||
u.loginname,
|
||||
u.username,
|
||||
u.mobile,
|
||||
vwl.unionname,
|
||||
vwl.unitname,
|
||||
IF(LOCATE('undefined',wpus.receiveAddress)>0,NULL,wpus.receiveAddress) as receiveAddress,
|
||||
wpus.selectNum,
|
||||
wpso.optionName
|
||||
FROM
|
||||
welfare_project_user_selection wpus
|
||||
left join `user` u on u.id = wpus.selectUserId
|
||||
left join welfare_project_subject_option wpso on wpso.id = wpus.selectOptionId
|
||||
left join view_welfare_list vwl on vwl.id = wpus.selectUserId
|
||||
$condition
|
||||
""");
|
||||
cnd.and("wpus.welfareId", "=", projectId);
|
||||
|
||||
if (!ShiroUtil.hasAnyRoles("sysadmin,SchoolUnionWelfareAdmin")) {
|
||||
cnd.and("u.unionId", "=", Vi.getUnionId());
|
||||
}
|
||||
|
||||
if (Globals.MyConfig.getBoolean("isThreeUnit")) {
|
||||
cnd.and("u.unionGroupId", "is not", null);
|
||||
}
|
||||
cnd.groupBy("wpus.selectUserId", "wpus.selectOptionId");
|
||||
cnd.asc("u.unitcode");
|
||||
sql.setCondition(cnd);
|
||||
List<NutMap> list = projectService.listMap(sql);
|
||||
Map<String, List<NutMap>> optionGroupData = list.stream().collect(Collectors.groupingBy(v -> v.getString("optionName")));
|
||||
|
||||
List<ExcelExportEntity> exportEntities = new ArrayList<>();
|
||||
exportEntities.add(new ExcelExportEntity("工号", "loginname", 20));
|
||||
exportEntities.add(new ExcelExportEntity("姓名", "username", 20));
|
||||
exportEntities.add(new ExcelExportEntity("电话号码", "mobile", 20));
|
||||
exportEntities.add(new ExcelExportEntity("所在分工会", "unionname", 30));
|
||||
exportEntities.add(new ExcelExportEntity("所在单位", "unitname", 50));
|
||||
exportEntities.add(new ExcelExportEntity("选择份数", "selectNum", 20));
|
||||
if (Globals.MyConfig.getBoolean("isThreeUnit")) {
|
||||
exportEntities.add(new ExcelExportEntity("所在部门", "threeUnitName", 50));
|
||||
}
|
||||
exportEntities.add(new ExcelExportEntity("收货地址", "receiveAddress", 100));
|
||||
Workbook workbook = new XSSFWorkbook();
|
||||
optionGroupData.forEach((k, v) -> {
|
||||
ExcelExportService service = new ExcelExportService();
|
||||
ExportParams exportParams = new ExportParams();
|
||||
exportParams.setType(ExcelType.XSSF);
|
||||
exportParams.setTitle(projectName + k + "选择情况");
|
||||
exportParams.setSheetName(k);
|
||||
service.createSheetForMap(workbook, exportParams, exportEntities, v);
|
||||
});
|
||||
try (ServletOutputStream outputStream = response.getOutputStream()) {
|
||||
ViTool.excelResponse(response, projectName + ".xlsx");
|
||||
workbook.write(outputStream);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 导入快递单号
|
||||
*
|
||||
* @param file excel文件
|
||||
*/
|
||||
@At
|
||||
@Ok("json")
|
||||
@Aop(TransAop.READ_COMMITTED)
|
||||
@RequiresPermissions("welfare.list.mange")
|
||||
@AdaptBy(type = UploadAdaptor.class, args = {"ioc:fileUpload"})
|
||||
public Object importCourierNumber(@Param("file") TempFile file,
|
||||
@Param("projectId") String projectId,
|
||||
@Param("optionId") String optionId
|
||||
) {
|
||||
if (Lang.isEmpty(file)) {
|
||||
return Result.error("上传的文件不能为空");
|
||||
}
|
||||
String extName = FileUtil.extName(file.getFile());
|
||||
if (!List.of("xls", "xlsx").contains(extName.toLowerCase())) {
|
||||
return Result.error("请上传xls,xlsx文件");
|
||||
}
|
||||
|
||||
List<CourierNumberExcelMode> excelList;
|
||||
|
||||
try {
|
||||
ImportParams importParams = new ImportParams();
|
||||
excelList = ExcelImportUtil.importExcel(file.getFile(), CourierNumberExcelMode.class, importParams);
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage());
|
||||
return Result.error("读取不到数据,请检查excel文件格式");
|
||||
}
|
||||
|
||||
if (Lang.isEmpty(excelList)) {
|
||||
return Result.error("读取不到数据,请检查excel文件格式");
|
||||
}
|
||||
|
||||
try {
|
||||
if (excelList.stream().anyMatch(v -> StrUtil.isBlank(v.getLoginName()))) {
|
||||
return Result.error("工号和快递单号不能为空");
|
||||
}
|
||||
|
||||
List<CourierNumberExcelMode> filterExcelList = excelList.stream().collect(Collectors.collectingAndThen(
|
||||
Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(CourierNumberExcelMode::getLoginName))),
|
||||
ArrayList::new
|
||||
));
|
||||
|
||||
|
||||
List<String> loginNameList = filterExcelList.stream().map(v -> v.getLoginName().replaceAll("\n", "").replaceAll("\t", "").trim()).collect(Collectors.toList());
|
||||
Sql loginNameSql = Sqls.create("select id,loginname from sys_user where loginname in (@loginNameList)");
|
||||
loginNameSql.setParam("loginNameList", loginNameList);
|
||||
List<NutMap> loginNameMaps = welfareListService.listMap(loginNameSql);
|
||||
|
||||
List<String> userIds = loginNameMaps.stream().map(v -> v.getString("id")).collect(Collectors.toList());
|
||||
|
||||
|
||||
//根据福利和选项删除本次导入的快递单号
|
||||
welfareListService.dao().clear(WelfareCourierNumber.class,
|
||||
Cnd.where("welfareId", "=", projectId)
|
||||
.and("selectUserId", "in", userIds)
|
||||
.and("selectOptionId", "=", optionId));
|
||||
|
||||
List<WelfareCourierNumber> welfareCourierNumbers = new ArrayList<>();
|
||||
|
||||
|
||||
for (NutMap map : loginNameMaps) {
|
||||
String id = map.getString("id");
|
||||
String loginname = map.getString("loginname");
|
||||
CourierNumberExcelMode courierNumberExcelMode = filterExcelList.stream().filter(u -> u.getLoginName().replaceAll("\n", "").equals(loginname)).findFirst().orElse(null);
|
||||
|
||||
|
||||
List<String> courierNumberList = new ArrayList<>();
|
||||
if (StrUtil.isNotBlank(courierNumberExcelMode.getOneCourierNumber())) {
|
||||
courierNumberList.add(courierNumberExcelMode.getOneCourierNumber());
|
||||
}
|
||||
if (StrUtil.isNotBlank(courierNumberExcelMode.getTwoCourierNumber())) {
|
||||
courierNumberList.add(courierNumberExcelMode.getTwoCourierNumber());
|
||||
}
|
||||
if (StrUtil.isNotBlank(courierNumberExcelMode.getThreeCourierNumber())) {
|
||||
courierNumberList.add(courierNumberExcelMode.getThreeCourierNumber());
|
||||
}
|
||||
if (StrUtil.isNotBlank(courierNumberExcelMode.getFourCourierNumber())) {
|
||||
courierNumberList.add(courierNumberExcelMode.getFourCourierNumber());
|
||||
}
|
||||
|
||||
for (String number : courierNumberList) {
|
||||
WelfareCourierNumber courierNumber = new WelfareCourierNumber();
|
||||
courierNumber.setCourierNumber(number);
|
||||
courierNumber.setSelectUserId(id);
|
||||
courierNumber.setWelfareId(projectId);
|
||||
courierNumber.setSelectOptionId(optionId);
|
||||
welfareCourierNumbers.add(courierNumber);
|
||||
}
|
||||
}
|
||||
welfareListService.insert(welfareCourierNumbers);
|
||||
|
||||
return Result.success("导入成功");
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage());
|
||||
e.printStackTrace();
|
||||
return Result.error("导入快递单号失败");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@At
|
||||
@Ok("void")
|
||||
@RequiresPermissions("welfare.list.mange")
|
||||
public void doExcelByOptionId(@Param(value = "projectId", required = false) String projectId,
|
||||
@Param(value = "optionId", required = false) String optionId,
|
||||
HttpServletResponse response) {
|
||||
WelfareProject project = welfareListService.dao().fetch(WelfareProject.class, projectId);
|
||||
WelfareProjectSubjectOption subjectOption = welfareListService.dao().fetch(WelfareProjectSubjectOption.class, optionId);
|
||||
|
||||
Sql sql = Sqls.create("""
|
||||
SELECT
|
||||
u.id,
|
||||
u.loginname,
|
||||
u.username,
|
||||
wl.personType,
|
||||
un.unionname,
|
||||
it.`name` unitname,
|
||||
wpus.selectNum
|
||||
FROM
|
||||
welfare_project_user_selection wpus
|
||||
LEFT JOIN `welfare_list` wl ON wpus.selectUserId = wl.userId and wpus.welfareId = wl.projectId
|
||||
LEFT JOIN `sys_user` u ON u.id = wl.userId
|
||||
LEFT JOIN sys_union un ON un.id = wl.welfareUnitId
|
||||
LEFT JOIN sys_unit it ON it.id = wl.welfareSecondLevelUnitId
|
||||
WHERE
|
||||
wpus.welfareId = @welfareId
|
||||
AND wpus.selectOptionId = @selectOptionId and wpus.selectNum!=0
|
||||
|
||||
""").setParam("welfareId", projectId).setParam("selectOptionId", optionId);
|
||||
|
||||
// GROUP BY wpus.selectUserId,wpus.selectOptionId ORDER BY un.unioncode
|
||||
|
||||
List<NutMap> mapList = welfareListService.listMap(sql);
|
||||
|
||||
List<String> userId = mapList.stream().map(m -> m.getString("id")).collect(Collectors.toList());
|
||||
|
||||
List<WelfareCourierNumber> courierNumberList = welfareListService.dao().query(WelfareCourierNumber.class,
|
||||
Cnd.where("selectUserId", "in", userId)
|
||||
.and("welfareId", "=", projectId)
|
||||
.and("selectOptionId", "=", optionId));
|
||||
|
||||
List<String> nameList = List.of("one", "two", "three", "four");
|
||||
for (NutMap map : mapList) {
|
||||
List<WelfareCourierNumber> userCourierNumbers = courierNumberList.stream()
|
||||
.filter(c -> c.getSelectUserId().equals(map.getString("id"))).collect(Collectors.toList());
|
||||
for (int i = 0; i < userCourierNumbers.size(); i++) {
|
||||
map.setv(nameList.get(i) + "CourierNumber", userCourierNumbers.get(i).getCourierNumber());
|
||||
}
|
||||
}
|
||||
|
||||
List<ExcelExportEntity> exportEntities = new ArrayList<>();
|
||||
exportEntities.add(new ExcelExportEntity("工号", "loginname", 20));
|
||||
exportEntities.add(new ExcelExportEntity("姓名", "username", 20));
|
||||
exportEntities.add(new ExcelExportEntity("人员类别", "personType", 20));
|
||||
exportEntities.add(new ExcelExportEntity("所在分工会", "unionname", 20));
|
||||
exportEntities.add(new ExcelExportEntity("所在部门", "unitname", 20));
|
||||
exportEntities.add(new ExcelExportEntity("份数", "selectNum", 20));
|
||||
for (int i = 0; i < nameList.size(); i++) {
|
||||
exportEntities.add(new ExcelExportEntity("快递单号" + (i + 1), nameList.get(i) + "CourierNumber", 20));
|
||||
}
|
||||
|
||||
List<String> unitList = List.of("在职教职工", "劳务派遣", "空状态");
|
||||
|
||||
Workbook workbook = new XSSFWorkbook();
|
||||
for (String un : unitList) {
|
||||
List<NutMap> v = new ArrayList<>();
|
||||
if (un.equals("在职教职工")) {
|
||||
v = mapList.stream().filter(m -> StrUtil.isNotBlank(m.getString("personType")) &&
|
||||
(!m.getString("personType").equals("劳务人才派遣") && !m.getString("personType").equals("其他类"))
|
||||
).collect(Collectors.toList());
|
||||
}
|
||||
if (un.equals("劳务派遣")) {
|
||||
v = mapList.stream().filter(m -> StrUtil.isNotBlank(m.getString("personType")) &&
|
||||
(m.getString("personType").equals("劳务人才派遣") || m.getString("personType").equals("其他类"))).collect(Collectors.toList());
|
||||
}
|
||||
if (un.equals("空状态")) {
|
||||
v = mapList.stream().filter(m -> StrUtil.isBlank(m.getString("personType"))).collect(Collectors.toList());
|
||||
}
|
||||
ExcelExportService service = new ExcelExportService();
|
||||
ExportParams exportParams = new ExportParams();
|
||||
exportParams.setType(ExcelType.XSSF);
|
||||
exportParams.setTitle(project.getName() + subjectOption.getOptionName() + "发放名单(" + un + ")");
|
||||
exportParams.setSheetName(un);
|
||||
service.createSheetForMap(workbook, exportParams, exportEntities, v);
|
||||
}
|
||||
|
||||
try (ServletOutputStream outputStream = response.getOutputStream()) {
|
||||
ViTool.excelResponse(response, project.getName() + subjectOption.getOptionName() + ".xlsx");
|
||||
workbook.write(outputStream);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@At
|
||||
@Ok("void")
|
||||
@RequiresPermissions("welfare.list.mange")
|
||||
public void doExportReimbursement(@Param(value = "projectId", required = false) String projectId,
|
||||
@Param(value = "optionId", required = false) String optionId,
|
||||
@Param(value = "personType", required = false) String personType,
|
||||
HttpServletResponse response) {
|
||||
WelfareProject project = welfareListService.dao().fetch(WelfareProject.class, projectId);
|
||||
String subjectOptionName = "";
|
||||
if (StrUtil.isNotBlank(optionId)) {
|
||||
WelfareProjectSubjectOption subjectOption = welfareListService.dao().fetch(WelfareProjectSubjectOption.class, optionId);
|
||||
subjectOptionName = subjectOption.getOptionName();
|
||||
}
|
||||
|
||||
|
||||
Sql sql = Sqls.create("""
|
||||
SELECT
|
||||
u.id,
|
||||
u.loginname,
|
||||
u.username,
|
||||
wl.personType,
|
||||
un.unionname,
|
||||
it.`name` unitname,
|
||||
wpus.selectNum,
|
||||
GROUP_CONCAT(wcn.courierNumber) as courierNumber
|
||||
FROM
|
||||
welfare_project_user_selection wpus
|
||||
LEFT JOIN `welfare_list` wl ON wpus.selectUserId = wl.userId and wpus.welfareId = wl.projectId
|
||||
LEFT JOIN `sys_user` u ON u.id = wl.userId
|
||||
LEFT JOIN sys_union un ON un.id = wl.welfareUnitId
|
||||
LEFT JOIN sys_unit it ON it.id = wl.welfareSecondLevelUnitId
|
||||
LEFT JOIN welfare_courier_number wcn ON wcn.welfareId = wpus.welfareId\s
|
||||
AND wcn.selectUserId = wpus.selectUserId
|
||||
$condition
|
||||
""");
|
||||
Cnd cnd = Cnd.NEW();
|
||||
cnd.groupBy("wpus.id");
|
||||
if(StrUtil.isBlank(optionId)) {
|
||||
cnd.groupBy("u.id");
|
||||
}
|
||||
cnd.and("wpus.welfareId", "=", projectId);
|
||||
cnd.andEX("wpus.selectOptionId", "=", optionId);
|
||||
cnd.and("wpus.selectNum", "!=", 0);
|
||||
if (Objects.equals("在职人员", personType)) {
|
||||
cnd.and("wl.personType", "is not", null);
|
||||
cnd.and("wl.personType", "!=", "");
|
||||
cnd.and("wl.personType", "!=", "劳务人才派遣");
|
||||
cnd.and("wl.personType", "!=", "其他类");
|
||||
} else if (Objects.equals("劳务派遣人员", personType)) {
|
||||
cnd.and("wl.personType", "in", List.of("劳务人才派遣", "其他类"));
|
||||
} else if (Objects.equals("空状态", personType)) {
|
||||
SqlExpressionGroup seg = new SqlExpressionGroup();
|
||||
seg.or("wl.personType", "=", "");
|
||||
seg.orIsNull("wl.personType");
|
||||
cnd.and(seg);
|
||||
}
|
||||
cnd.asc("wl.welfareUnitId");
|
||||
cnd.asc("wl.welfareSecondLevelUnitId");
|
||||
sql.setCondition(cnd);
|
||||
List<NutMap> mapList = welfareListService.listMap(sql);
|
||||
|
||||
if(StrUtil.isBlank(optionId)){
|
||||
for (NutMap map : mapList) {
|
||||
map.put("selectNum",null);
|
||||
}
|
||||
}
|
||||
|
||||
HashMap<String, Object> data = new HashMap<>();
|
||||
data.put("data", mapList);
|
||||
data.put("projectName", project.getName());
|
||||
data.put("optionName", subjectOptionName);
|
||||
data.put("personType", personType);
|
||||
|
||||
try {
|
||||
ViTool.excelResponse(response, subjectOptionName + "(" + personType + ")" + "发放名单.xlsx");
|
||||
TemplateExportParams templateExportParams = new TemplateExportParams();
|
||||
//开启横向遍历
|
||||
templateExportParams.setColForEach(true);
|
||||
templateExportParams.setTemplateUrl("E:\\env\\福利发放名单.xlsx");
|
||||
Workbook workbook = ExcelExportUtil.exportExcel(templateExportParams, data);
|
||||
workbook.write(response.getOutputStream());
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,100 @@
|
||||
package io.v.nutz.zhgh.welfare.controller;
|
||||
|
||||
import io.v.nutz.base.annontation.ViReturn;
|
||||
import io.v.nutz.base.query.PageForm;
|
||||
import io.v.nutz.sys.services.SysDictService;
|
||||
import io.v.nutz.zhgh.welfare.service.WelfareListService;
|
||||
import io.v.nutz.zhgh.welfare.service.WelfareListSummaryService;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.nutz.dao.Dao;
|
||||
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;
|
||||
|
||||
/**
|
||||
* 发放名单汇总
|
||||
*
|
||||
* @author: 1V
|
||||
* @date: 2021/3/3
|
||||
* @since 1.0
|
||||
*/
|
||||
@IocBean
|
||||
@Ok("json")
|
||||
@At("/platform/welfare/list/summary")
|
||||
public class WelfareListSummaryController {
|
||||
|
||||
@At("")
|
||||
@Ok("beetl:/platform/welfare/list/ListSummary.html")
|
||||
@RequiresPermissions("welfare.list.summary")
|
||||
public void index() {
|
||||
}
|
||||
|
||||
@Inject
|
||||
private WelfareListService welfareListService;
|
||||
|
||||
@Inject
|
||||
private SysDictService sysDictService;
|
||||
|
||||
@Inject
|
||||
private Dao dao;
|
||||
|
||||
@Inject
|
||||
private WelfareListSummaryService welfareListSummaryService;
|
||||
|
||||
@At
|
||||
@ViReturn
|
||||
@RequiresPermissions("welfare.list.summary")
|
||||
public Object pageData(PageForm pageForm, String projectId, String unionId) {
|
||||
return welfareListSummaryService.togetherPageData(pageForm, projectId);
|
||||
|
||||
|
||||
// WelfareProject welfareProject = dao.fetch(WelfareProject.class, Cnd.where("id", "=", projectId));
|
||||
// ArrayList<Integer> togetherProvideMode = Lang.list(WelfareProvideMode.WELFARE_UNIT.getCode(), WelfareProvideMode.TOGETHER.getCode());
|
||||
// if (togetherProvideMode.contains(welfareProject.getProvideMode())) {
|
||||
// return welfareListSummaryService.togetherPageData(pageForm, projectId);
|
||||
// } else {
|
||||
// return welfareListSummaryService.singlePageData(pageForm, projectId, unionId);
|
||||
// }
|
||||
|
||||
|
||||
// //获取所有人员类型
|
||||
// Sys_dict dict = sysDictService.fetch(Cnd.where("code", "=", "UserType"));
|
||||
// List<Sys_dict> userTypeDictList = dict == null ? new ArrayList<>() : sysDictService.query(Cnd.where("parentId", "=", Strings.sNull(dict.getId())).and("disabled", "=", false).asc("location"));
|
||||
// List<String> userTypeList = userTypeDictList.stream().map(Sys_dict::getCode).collect(Collectors.toList());
|
||||
// List<NutMap> labelList = userTypeDictList.stream().map(v -> NutMap.NEW().addv("prop", v.getCode()).addv("label", v.getName())).collect(Collectors.toList());
|
||||
// Sql sql = Sqls.create("""
|
||||
// SELECT
|
||||
// unit.*,
|
||||
// sum( 1 ) number,
|
||||
// $temp_sql
|
||||
// FROM
|
||||
// welfare_unit unit
|
||||
// LEFT JOIN welfare_list list ON unit.welfareUnitId = list.welfareUnitId
|
||||
// LEFT JOIN `user` su ON su.id = list.userId
|
||||
// $condition
|
||||
// """);
|
||||
// StringBuffer temp_sql_str = new StringBuffer();
|
||||
// userTypeList.forEach(v -> {
|
||||
// temp_sql_str.append("COUNT( CASE WHEN ( su.personType = '%s' ) THEN 1 ELSE NULL END ) AS '%s',".formatted(v, v));
|
||||
// });
|
||||
//
|
||||
// String totalUserType = CollUtil.join(userTypeList, ",", "'", "'");
|
||||
//
|
||||
// temp_sql_str.append("COUNT( CASE WHEN ( su.personType in (%s) ) THEN 1 ELSE NULL END ) AS totalNum".formatted(totalUserType));
|
||||
// sql.setVar("temp_sql", temp_sql_str);
|
||||
//
|
||||
// CndPlus cnd = CndPlus.create();
|
||||
// cnd.and("unit.welfareUnitMode", "=", WelfareUnitMode.getMode().name());
|
||||
// pageForm.defaultSortAsc("unit.welfareUnitCode");
|
||||
// cnd.and(pageForm);
|
||||
// cnd.and("list.projectId", "=", projectId);
|
||||
// cnd.groupBy("unit.welfareUnitId");
|
||||
// sql.setCondition(cnd);
|
||||
//
|
||||
// labelList.add(NutMap.NEW().addv("prop", "totalNum").addv("label", "合计"));
|
||||
// return Map.of("tableList", welfareListService.listMap(sql), "tableColumn", labelList);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
+368
@@ -0,0 +1,368 @@
|
||||
package io.v.nutz.zhgh.welfare.controller;
|
||||
|
||||
import com.google.common.base.Joiner;
|
||||
import io.v.nutz.base.annontation.ViReturn;
|
||||
import io.v.nutz.base.utils.Vi;
|
||||
import io.v.nutz.base.dao.CndPlus;
|
||||
import io.v.nutz.zhgh.data.constant.UserChangeType;
|
||||
import io.v.nutz.zhgh.data.service.HistoryUserService;
|
||||
import io.v.nutz.base.lang.Lang;
|
||||
import io.v.nutz.zhgh.member.MemberMode;
|
||||
import io.v.nutz.zhgh.member.constant.MemberChangeApplyState;
|
||||
import io.v.nutz.zhgh.member.constant.MemberChangeOrigin;
|
||||
import io.v.nutz.zhgh.member.constant.MemberChangeRecordMode;
|
||||
import io.v.nutz.zhgh.member.handle.MemberChangeAuditHandle;
|
||||
import io.v.nutz.zhgh.member.model.MemberChangeRecord;
|
||||
import io.v.nutz.base.model.Audit;
|
||||
import io.v.nutz.base.query.PageForm;
|
||||
import io.v.nutz.sys.models.User;
|
||||
import io.v.nutz.web.commons.utils.ShiroUtil;
|
||||
import io.v.nutz.zhgh.welfare.constant.WelfareMemberApplyState;
|
||||
import io.v.nutz.zhgh.welfare.feature.WelfareFeature;
|
||||
import io.v.nutz.zhgh.welfare.handle.WelfareMemberApplyAuditHandle;
|
||||
import io.v.nutz.zhgh.welfare.mode.WelfareMemberMode;
|
||||
import io.v.nutz.zhgh.welfare.model.WelfareMemberApplyRecord;
|
||||
import io.v.nutz.zhgh.welfare.service.WelfareMemberService;
|
||||
import org.apache.shiro.authz.annotation.Logical;
|
||||
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.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.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 福利会员调整
|
||||
*
|
||||
* @author: 1V
|
||||
* @date: 2021/2/28
|
||||
* @since 1.0
|
||||
*/
|
||||
@IocBean
|
||||
@Ok("json")
|
||||
@At("/platform/welfare/member/adjustment")
|
||||
public class WelfareMemberAdjustmentController {
|
||||
|
||||
@At("")
|
||||
@Ok("beetl:/platform/welfare/member/Adjustment.html")
|
||||
@RequiresPermissions("welfare.member.adjustment")
|
||||
public void index() {
|
||||
}
|
||||
|
||||
@Inject
|
||||
private WelfareMemberService welfareMemberService;
|
||||
|
||||
@At
|
||||
@ViReturn
|
||||
@RequiresPermissions("welfare.member.adjustment")
|
||||
public Object pageData(@Param(value = "changeDateBefore", required = false) String changeDateBefore,
|
||||
@Param(value = "changeDateEnd", required = false) String changeDateEnd,
|
||||
PageForm pageForm,
|
||||
WelfareFeature.Condition.PageParam pageParam,
|
||||
@Param(value = "changeDate", required = false) String changeDate,
|
||||
@Param(value = "changeType", required = false) String changeType,
|
||||
@Param(value = "welfareMember", required = false) Integer welfareMember,
|
||||
@Param(value = "member", required = false) Integer member,
|
||||
@Param(value = "changed", required = false) Integer changed) {
|
||||
Sql sql = Sqls.create("""
|
||||
SELECT
|
||||
u.*,
|
||||
his.id hisId,
|
||||
his.changeType,
|
||||
his.changeTypes,
|
||||
his.changeTime,
|
||||
IF
|
||||
( his.id IS NULL, FALSE, TRUE ) hasHis,
|
||||
TRUE AS flag,
|
||||
IF(state.stateId in ($states) OR state.stateId IS NULL ,TRUE,FALSE) apply,
|
||||
state.stateId,
|
||||
state.stateName,
|
||||
state.stateColor,
|
||||
IF(mcr.stateId = @changeUnitAuditing,TRUE,FALSE) changeUnitAuditing,
|
||||
IF(mcr.stateId = @changeUnitError,TRUE,FALSE) changeUnitError,
|
||||
mcr_state.stateId mcrStateId,
|
||||
mcr_state.stateName mcrStateName,
|
||||
mcr_state.stateColor mcrStateColor
|
||||
FROM
|
||||
`user` u
|
||||
|
||||
LEFT JOIN user_history_latest his ON his.loginname = u.loginname
|
||||
|
||||
LEFT JOIN welfare_member_apply_record_latest wmar ON wmar.userId = u.id
|
||||
|
||||
LEFT JOIN member_change_record_latest mcr on mcr.userId = u.id
|
||||
|
||||
LEFT JOIN audit_state state ON wmar.stateId = state.stateId
|
||||
|
||||
LEFT JOIN audit_state mcr_state ON mcr_state.stateId = mcr.stateId
|
||||
$condition
|
||||
""")
|
||||
.setParam("recordMode", MemberChangeRecordMode.WELFARE_MEMBER.getCode())
|
||||
.setParam("changeUnitAuditing", MemberChangeApplyState.SCHOOL_UNION)
|
||||
.setParam("changeUnitError", MemberChangeApplyState.SCHOOL_UNION_FAIL);
|
||||
|
||||
sql.setVar("states", Joiner.on(",").join(List.of(WelfareMemberApplyState.SCHOOL_UNION_FAIL)));
|
||||
|
||||
pageForm.defaultSortDesc("wmar.applyTime");
|
||||
|
||||
CndPlus cnd = CndPlus.create();
|
||||
cnd.andEX("u.unionGroupId", "=", pageParam.getUnionGroupId());
|
||||
|
||||
|
||||
if (!ShiroUtil.hasAnyRoles("sysadmin,SchoolUnionAdmin,SchoolUnionMemberAdmin,SchoolUnionWelfareAdmin")) {
|
||||
if (ShiroUtil.hasAnyRoles("H04,gh12")) {
|
||||
cnd.and("u.unionId", "=", Vi.getUnionId());
|
||||
} else if (ShiroUtil.hasRole("ghxzzz")) {
|
||||
SqlExpressionGroup seg = new SqlExpressionGroup();
|
||||
seg.or("u.unionGroupId", "in", io.v.nutz.web.commons.utils.ShiroUtil.getUnionGroupIds());
|
||||
seg.or("u.unionGroupId", "is", null);
|
||||
cnd.and(seg);
|
||||
cnd.and("u.unionid", "=", Vi.getUnionId());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (member != null && member != 1) {
|
||||
if (2 == member) {
|
||||
cnd.and("u.member", "=", MemberMode.NORMAL.getCode());
|
||||
} else if (3 == member) {
|
||||
SqlExpressionGroup group = new SqlExpressionGroup();
|
||||
group.or("u.member", "is", null);
|
||||
group.or("u.member", "!=", MemberMode.NORMAL.getCode());
|
||||
cnd.and(group);
|
||||
}
|
||||
}
|
||||
|
||||
if (changed != 0) {
|
||||
if (changed == 1) {
|
||||
cnd.and(new Static("his.loginname is not null"));
|
||||
} else {
|
||||
cnd.and(new Static("his.loginname is null"));
|
||||
}
|
||||
}
|
||||
|
||||
if (welfareMember == 1) {
|
||||
cnd.and("u.welfareMember", "=", WelfareMemberMode.NORMAL.getCode());
|
||||
} else if (welfareMember == 2) {
|
||||
SqlExpressionGroup group = new SqlExpressionGroup();
|
||||
group.or("u.welfareMember", "=", null).or("u.welfareMember", "=", WelfareMemberMode.NONE.getCode());
|
||||
cnd.and(group);
|
||||
}
|
||||
|
||||
WelfareFeature.Condition.judgmentAuthority(cnd, "u");
|
||||
|
||||
cnd.and(pageForm);
|
||||
cnd.desc("u.threeUnitId");
|
||||
cnd.asc("u.loginname");
|
||||
|
||||
pageParam.participate(cnd, "u");
|
||||
|
||||
if (Lang.notNull(changeDateBefore, changeDateEnd)) {
|
||||
cnd.and(new Static(String.format("Date(his.changeTime) >= '%s' and Date(his.changeTime) <= '%s'", changeDateBefore, changeDateEnd)));
|
||||
}
|
||||
cnd.andEx("his.changeType", "=", changeType);
|
||||
|
||||
sql.setCondition(cnd);
|
||||
return welfareMemberService.list(pageForm, sql);
|
||||
}
|
||||
|
||||
@At
|
||||
@ViReturn
|
||||
@RequiresPermissions(value = {"welfare.member.adjustment", "welfare.member.check.union"}, logical = Logical.OR)
|
||||
public Object getChangeNumber(PageForm pageForm,
|
||||
WelfareFeature.Condition.PageParam pageParam,
|
||||
@Param(value = "changeDateBefore", required = false) String changeDateBefore,
|
||||
@Param(value = "changeDateEnd", required = false) String changeDateEnd,
|
||||
@Param(value = "changeType", required = false) String changeType,
|
||||
@Param(value = "welfareMember", required = false) Integer welfareMember,
|
||||
@Param(value = "member", required = false) Integer member, Integer changed,
|
||||
@Param(value = "userStates", required = false) String[] userStates,
|
||||
@Param(value = "personTypes", required = false) String[] personTypes,
|
||||
@Param(value = "changeTypes", required = false) Integer[] changeTypes,
|
||||
@Param(value = "changeOrigin", required = false) Integer[] changeOrigins
|
||||
) {
|
||||
Sql sql = Sqls.create("""
|
||||
SELECT
|
||||
COUNT(1) AS `all`,
|
||||
COUNT(his.loginname) AS have,
|
||||
COUNT(CASE WHEN his.loginname IS NULL THEN 1 END) AS `no`
|
||||
FROM `user` u
|
||||
LEFT JOIN user_history_latest his ON his.loginname = u.loginname
|
||||
LEFT JOIN welfare_member_apply_record_latest wmar ON wmar.userId = u.id
|
||||
LEFT JOIN member_change_record_latest mcr ON mcr.userId = u.id
|
||||
LEFT JOIN audit_state state ON wmar.stateId = state.stateId
|
||||
LEFT JOIN audit_state mcr_state ON mcr_state.stateId = mcr.stateId
|
||||
$condition
|
||||
""");
|
||||
|
||||
CndPlus cnd = CndPlus.create();
|
||||
|
||||
cnd.and("1", "=", 1);
|
||||
|
||||
if (member != null && member != 1) {
|
||||
if (2 == member) {
|
||||
cnd.and("u.member", "=", MemberMode.NORMAL.getCode());
|
||||
} else if (3 == member) {
|
||||
SqlExpressionGroup group = new SqlExpressionGroup();
|
||||
group.or("u.member", "is", null);
|
||||
group.or("u.member", "!=", MemberMode.NORMAL.getCode());
|
||||
cnd.and(group);
|
||||
}
|
||||
}
|
||||
cnd.andEX("u.unionGroupId", "=", pageParam.getUnionGroupId());
|
||||
if (!ShiroUtil.hasAnyRoles("sysadmin,SchoolUnionAdmin,SchoolUnionMemberAdmin,SchoolUnionWelfareAdmin")) {
|
||||
if (ShiroUtil.hasAnyRoles("H04,gh12")) {
|
||||
cnd.and("u.unionId", "=", Vi.getUnionId());
|
||||
} else if (ShiroUtil.hasRole("ghxzzz")) {
|
||||
SqlExpressionGroup seg = new SqlExpressionGroup();
|
||||
seg.or("u.unionGroupId", "in", io.v.nutz.web.commons.utils.ShiroUtil.getUnionGroupIds());
|
||||
seg.or("u.unionGroupId", "is", null);
|
||||
cnd.and(seg);
|
||||
cnd.and("u.unionid", "=", Vi.getUnionId());
|
||||
}
|
||||
|
||||
}
|
||||
if (welfareMember == 1) {
|
||||
cnd.and("u.welfareMember", "=", WelfareMemberMode.NORMAL.getCode());
|
||||
} else if (welfareMember == 2) {
|
||||
SqlExpressionGroup group = new SqlExpressionGroup();
|
||||
group.or("u.welfareMember", "=", null).or("u.welfareMember", "=", WelfareMemberMode.NONE.getCode());
|
||||
cnd.and(group);
|
||||
}
|
||||
|
||||
WelfareFeature.Condition.judgmentAuthority(cnd, "u");
|
||||
cnd.and(pageForm);
|
||||
pageParam.participate(cnd, "u");
|
||||
if (Lang.notNull(changeDateBefore, changeDateEnd)) {
|
||||
cnd.and(new Static(String.format("Date(his.changeTime) >= '%s' and Date(his.changeTime) <= '%s'", changeDateBefore, changeDateEnd)));
|
||||
}
|
||||
|
||||
// cnd.andEx("his.changeType", "=", changeType);
|
||||
|
||||
if (org.nutz.lang.Lang.isNotEmpty(changeTypes)) {
|
||||
SqlExpressionGroup seg = new SqlExpressionGroup();
|
||||
for (Integer type : changeTypes) {
|
||||
seg.or(new Static("JSON_CONTAINS(his.changeTypes, CAST(%d AS JSON), '$')".formatted(type)));
|
||||
}
|
||||
cnd.and(seg);
|
||||
}
|
||||
|
||||
if (org.nutz.lang.Lang.isNotEmpty(userStates)) {
|
||||
SqlExpressionGroup seg = new SqlExpressionGroup();
|
||||
for (String state : userStates) {
|
||||
seg.orEquals("u.userState", state);
|
||||
}
|
||||
cnd.and(seg);
|
||||
}
|
||||
|
||||
if (org.nutz.lang.Lang.isNotEmpty(personTypes)) {
|
||||
SqlExpressionGroup seg = new SqlExpressionGroup();
|
||||
for (String personType : personTypes) {
|
||||
seg.orEquals("u.personType", personType);
|
||||
}
|
||||
cnd.and(seg);
|
||||
}
|
||||
|
||||
if (org.nutz.lang.Lang.isNotEmpty(changeOrigins)) {
|
||||
SqlExpressionGroup seg = new SqlExpressionGroup();
|
||||
for (Integer c : changeOrigins) {
|
||||
seg.orEquals("u.changeOrigin", c);
|
||||
}
|
||||
cnd.and(seg);
|
||||
}
|
||||
|
||||
sql.setCondition(cnd);
|
||||
|
||||
return welfareMemberService.fetch(sql);
|
||||
}
|
||||
|
||||
@Inject
|
||||
private HistoryUserService historyUserService;
|
||||
|
||||
@At
|
||||
@ViReturn
|
||||
@RequiresPermissions("welfare.member.adjustment")
|
||||
public Object historyUsers(String loginname) {
|
||||
return historyUserService.historyUsers(loginname);
|
||||
}
|
||||
|
||||
/**
|
||||
* 将用户设置为福利会员
|
||||
*
|
||||
* @param userIds
|
||||
* @return
|
||||
*/
|
||||
@At
|
||||
@ViReturn
|
||||
@RequiresPermissions("welfare.member.adjustment")
|
||||
public Object joinWelfareMember(String[] userIds) {
|
||||
if (io.v.nutz.web.commons.utils.ShiroUtil.hasAnyRoles("sysadmin,SchoolUnionAdmin,SchoolUnionMemberAdmin,SchoolUnionWelfareAdmin")) {
|
||||
WelfareMemberMode.joinWelfareMember(Arrays.stream(userIds).collect(Collectors.toList()));
|
||||
return null;
|
||||
}
|
||||
List<MemberChangeRecord> maps = new ArrayList<>();
|
||||
Audit audit = new Audit();
|
||||
audit.setAuditor(io.v.nutz.web.commons.utils.ShiroUtil.getUserId());
|
||||
audit.setAuditPass(true);
|
||||
audit.setAuditTime(new Date());
|
||||
audit.setAuditOpinion("新增福利会员");
|
||||
audit.setUsername(io.v.nutz.web.commons.utils.ShiroUtil.getPrincipalProperty("username").toString());
|
||||
audit.setLoginname(io.v.nutz.web.commons.utils.ShiroUtil.getPrincipalProperty("loginname").toString());
|
||||
historyUserService.insert(audit);
|
||||
for (String userId : userIds) {
|
||||
User user = historyUserService.dao().fetch(User.class, Cnd.where("id", "=", userId));
|
||||
MemberChangeRecord changeRecord = new MemberChangeRecord();
|
||||
changeRecord.setType(UserChangeType.NEW.getCode());
|
||||
changeRecord.setApplyOrigin(io.v.nutz.web.commons.utils.ShiroUtil.hasAnyRoles("H04,gh12") ? MemberChangeOrigin.UNION.getCode() : MemberChangeOrigin.UNION_GROUP.getCode());
|
||||
changeRecord.setStateId(MemberChangeApplyState.SCHOOL_UNION);
|
||||
changeRecord.setUpdateWelfareMember(true);
|
||||
changeRecord.setUserId(userId);
|
||||
changeRecord.setApplyTime(new Date());
|
||||
changeRecord.setOriginUnitId(user.getUnitid());
|
||||
changeRecord.setOriginUnionId(user.getUnionid());
|
||||
changeRecord.setOriginThreeUnitId(user.getThreeUnitId());
|
||||
changeRecord.setUnionAuditId(audit.getId());
|
||||
changeRecord.setRecordMode(MemberChangeRecordMode.WELFARE_MEMBER.getCode());
|
||||
changeRecord.setTaskId(null);
|
||||
maps.add(changeRecord);
|
||||
}
|
||||
historyUserService.insert(maps);
|
||||
WelfareMemberApplyAuditHandle.CREATE.next(Arrays.stream(userIds).map(v -> new WelfareMemberApplyRecord().setUserId(v)).collect(Collectors.toList()), null);
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 变更申请
|
||||
*
|
||||
* @param record
|
||||
* @return
|
||||
*/
|
||||
@At
|
||||
@ViReturn
|
||||
@RequiresPermissions("welfare.member.adjustment")
|
||||
public Object change(MemberChangeRecord record) {
|
||||
record.setRecordMode(MemberChangeRecordMode.WELFARE_MEMBER.getCode());
|
||||
if (WelfareFeature.judgmentAuthority()) {
|
||||
record.setApplyOrigin(MemberChangeOrigin.SCHOOL.getCode());
|
||||
record = MemberChangeAuditHandle.CREATE.next(record, null);
|
||||
MemberChangeAuditHandle.SCHOOL.next(record, new Audit().setAuditPass(true));
|
||||
} else {
|
||||
record.setApplyOrigin(MemberChangeOrigin.UNION.getCode());
|
||||
record = MemberChangeAuditHandle.CREATE.next(record, null);
|
||||
MemberChangeAuditHandle.UNION.next(record, new Audit().setAuditPass(true));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
+89
@@ -0,0 +1,89 @@
|
||||
package io.v.nutz.zhgh.welfare.controller;
|
||||
|
||||
import io.v.nutz.base.annontation.ViReturn;
|
||||
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.base.service.ViService;
|
||||
import io.v.nutz.zhgh.welfare.constant.WelfareMemberApplyState;
|
||||
import io.v.nutz.zhgh.welfare.feature.WelfareFeature;
|
||||
import io.v.nutz.zhgh.welfare.handle.WelfareMemberApplyAuditHandle;
|
||||
import io.v.nutz.zhgh.welfare.model.WelfareMemberApplyRecord;
|
||||
import io.v.nutz.zhgh.welfare.service.WelfareMemberService;
|
||||
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 java.util.List;
|
||||
|
||||
/**
|
||||
* 校工会福利会员审核
|
||||
*
|
||||
* @author: 1V
|
||||
* @date: 2021/2/28
|
||||
* @since 1.0
|
||||
*/
|
||||
@IocBean
|
||||
@Ok("json")
|
||||
@At("/platform/welfare/member/audit/school")
|
||||
public class WelfareMemberAuditSchoolController {
|
||||
|
||||
@At("")
|
||||
@Ok("beetl:/platform/welfare/member/AuditSchool.html")
|
||||
@RequiresPermissions("welfare.member.audit.school")
|
||||
public void index() {
|
||||
}
|
||||
|
||||
@Inject
|
||||
private WelfareMemberService welfareMemberService;
|
||||
|
||||
@Inject("WelfareMemberApplyRecord")
|
||||
private ViService<WelfareMemberApplyRecord> welfareMemberApplyRecordViService;
|
||||
|
||||
@At
|
||||
@ViReturn
|
||||
@RequiresPermissions("welfare.member.audit.school")
|
||||
public Object pageData(PageForm pageForm, WelfareFeature.Condition.PageParam pageParam) {
|
||||
Sql sql = Sqls.create("""
|
||||
SELECT
|
||||
u.*,
|
||||
wmar.id applyId,
|
||||
state.stateName,
|
||||
state.stateColor
|
||||
FROM
|
||||
welfare_member_apply_record wmar
|
||||
LEFT JOIN `user` u ON wmar.userId = u.id
|
||||
LEFT JOIN audit_state state ON wmar.stateId = state.stateId
|
||||
$condition
|
||||
""");
|
||||
|
||||
|
||||
pageForm.defaultSortDesc("wmar.applyTime");
|
||||
|
||||
CndPlus cnd = CndPlus.create();
|
||||
|
||||
cnd.and("wmar.stateId", "=", WelfareMemberApplyState.SCHOOL_UNION);
|
||||
|
||||
cnd.and(pageForm);
|
||||
|
||||
pageParam.participate(cnd, "u");
|
||||
sql.setCondition(cnd);
|
||||
return welfareMemberService.list(pageForm, sql);
|
||||
}
|
||||
|
||||
|
||||
@At
|
||||
@ViReturn
|
||||
@RequiresPermissions("welfare.member.audit.school")
|
||||
public Object audit(String[] applyIds, boolean flag) {
|
||||
List<WelfareMemberApplyRecord> records = welfareMemberApplyRecordViService.query(Cnd.where("id", "in", applyIds));
|
||||
Audit audit = new Audit().setAuditPass(flag);
|
||||
WelfareMemberApplyAuditHandle.AUDIT_SCHOOL.next(records, audit);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
+141
@@ -0,0 +1,141 @@
|
||||
package io.v.nutz.zhgh.welfare.controller;
|
||||
|
||||
import io.v.nutz.base.annontation.ViRequired;
|
||||
import io.v.nutz.base.annontation.ViReturn;
|
||||
import io.v.nutz.base.utils.Vi;
|
||||
import io.v.nutz.base.dao.CndPlus;
|
||||
import io.v.nutz.base.lang.Enum;
|
||||
import io.v.nutz.zhgh.member.constant.MemberChangeApplyState;
|
||||
import io.v.nutz.zhgh.member.constant.MemberChangeRecordMode;
|
||||
import io.v.nutz.zhgh.member.handle.MemberChangeAuditHandle;
|
||||
import io.v.nutz.zhgh.member.model.MemberChangeRecord;
|
||||
import io.v.nutz.base.model.Audit;
|
||||
import io.v.nutz.base.query.PageForm;
|
||||
import io.v.nutz.base.service.ViService;
|
||||
import io.v.nutz.zhgh.welfare.mode.WelfareUnitMode;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
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;
|
||||
|
||||
/**
|
||||
* 福利会员变更申请审核
|
||||
*
|
||||
* @author: 1V
|
||||
* @date: 2021/1/26
|
||||
* @since 1.0
|
||||
*/
|
||||
|
||||
@At("/platform/welfare/member/change/audit")
|
||||
@Ok("json:full")
|
||||
@IocBean
|
||||
public class WelfareMemberChangeApplyAuditController {
|
||||
|
||||
|
||||
@At("")
|
||||
@Ok("beetl:/platform/welfare/member/change/audit/School.html")
|
||||
@RequiresPermissions("welfare.member.change.audit.school")
|
||||
public void index() {
|
||||
}
|
||||
|
||||
@Inject("MemberChangeRecord")
|
||||
private ViService<MemberChangeRecord> recordViService;
|
||||
|
||||
@Inject
|
||||
private Vi vi;
|
||||
|
||||
/**
|
||||
* @param pageForm 分页查询对象
|
||||
* @param source 来源 2 校工会
|
||||
* @return
|
||||
*/
|
||||
@At
|
||||
@ViReturn
|
||||
@RequiresPermissions("welfare.member.change.audit.school")
|
||||
public Object pageData(PageForm pageForm,
|
||||
@Param(value = "unionId", required = false) String unionId,
|
||||
@Param(value = "source", required = false) Integer source,
|
||||
@Param(value = "date", required = false) String[] date,
|
||||
@Param(value = "type", required = false) Integer type, Boolean audit,
|
||||
@Param(value = "welfareUnit", required = false) String welfareUnit) {
|
||||
Sql sql = Sqls.create("""
|
||||
SELECT
|
||||
mcr.*,
|
||||
LEFT ( mcr.applyTime, 10 ) applyDate,
|
||||
u.username,
|
||||
u.loginname,
|
||||
u.unitname,
|
||||
u.unitcode,
|
||||
u.unionname,
|
||||
u.unioncode,
|
||||
wun.welfareUnitId realWelfareUnitId,
|
||||
wun.welfareUnitCode realWelfareUnitCode,
|
||||
wun.welfareUnitName realWelfareUnitName,
|
||||
u.mobile,
|
||||
state.stateName,
|
||||
state.stateColor,
|
||||
originUnit.unitcode originUnitCode,
|
||||
originUnit.`name` originUnitName,
|
||||
originUnion.unioncode originUnionCode,
|
||||
originUnion.unionname originUnionName,
|
||||
currentUnit.unitcode currentUnitCode,
|
||||
currentUnit.`name` currentUnitName,
|
||||
currentUnion.unioncode currentUnionCode,
|
||||
currentUnion.unionname currentUnionName,
|
||||
IF(mcr.stateId = @auditState,TRUE,FALSE) audit
|
||||
FROM
|
||||
member_change_record mcr
|
||||
LEFT JOIN `user` u ON mcr.userId = u.id
|
||||
LEFT JOIN welfare_unit wun ON u.$field = wun.welfareUnitId
|
||||
LEFT JOIN audit_state state ON mcr.stateId = state.stateId
|
||||
LEFT JOIN sys_unit originUnit ON mcr.originUnitId = originUnit.id
|
||||
LEFT JOIN sys_union originUnion ON mcr.originUnionId = originUnion.id
|
||||
LEFT JOIN sys_unit currentUnit ON mcr.currentUnitId = currentUnit.id
|
||||
LEFT JOIN sys_union currentUnion ON mcr.currentUnionId = currentUnion.id
|
||||
$condition
|
||||
""").setVar("field", WelfareUnitMode.getMode().getField());
|
||||
CndPlus cnd = CndPlus.create();
|
||||
pageForm.defaultSortAsc("mcr.stateId");
|
||||
cnd.and(pageForm);
|
||||
|
||||
cnd.and("mcr.recordMode", "=", MemberChangeRecordMode.WELFARE_MEMBER.getCode());
|
||||
|
||||
if (date != null && date.length == 2) {
|
||||
cnd.and("date(mcr.applyTime)", ">=", date[0]);
|
||||
cnd.and("date(mcr.applyTime)", "<=", date[1]);
|
||||
}
|
||||
|
||||
if (audit) {
|
||||
cnd.and("mcr.stateId", "=", source == 1 ? MemberChangeApplyState.UNION : MemberChangeApplyState.SCHOOL_UNION);
|
||||
}
|
||||
|
||||
cnd.andEx("u.unionid", "=", unionId);
|
||||
cnd.andEx("mcr.type", "=", type);
|
||||
cnd.andEx("wun.welfareUnitId", "=", welfareUnit);
|
||||
|
||||
|
||||
cnd.and("mcr.stateId", ">=", MemberChangeApplyState.SCHOOL_UNION);
|
||||
sql.setParam("auditState", MemberChangeApplyState.SCHOOL_UNION);
|
||||
|
||||
|
||||
sql.setCondition(cnd);
|
||||
|
||||
return recordViService.list(pageForm, sql);
|
||||
}
|
||||
|
||||
|
||||
@At
|
||||
@ViReturn
|
||||
@RequiresPermissions("welfare.member.change.audit.school")
|
||||
public Object doAudit(@ViRequired String recordId, Audit audit) {
|
||||
MemberChangeRecord record = recordViService.fetch(recordId);
|
||||
MemberChangeAuditHandle applyHandle = Enum.instance(MemberChangeAuditHandle.class, record.getStateId());
|
||||
applyHandle.next(record, audit);
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,379 @@
|
||||
package io.v.nutz.zhgh.welfare.controller;
|
||||
|
||||
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.util.StrUtil;
|
||||
import io.v.nutz.base.annontation.ViReturn;
|
||||
import io.v.nutz.base.dao.CndPlus;
|
||||
import io.v.nutz.base.query.PageForm;
|
||||
import io.v.nutz.base.result.Result;
|
||||
import io.v.nutz.base.service.AsyncService;
|
||||
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_unit;
|
||||
import io.v.nutz.sys.models.Sys_user;
|
||||
import io.v.nutz.sys.models.Sys_user_role;
|
||||
import io.v.nutz.sys.models.User;
|
||||
import io.v.nutz.sys.services.SysUserService;
|
||||
import io.v.nutz.web.commons.utils.ShiroUtil;
|
||||
import io.v.nutz.zhgh.member.MemberMode;
|
||||
import io.v.nutz.zhgh.member.WelfareMemberMode;
|
||||
import io.v.nutz.zhgh.member.model.MemberCheckTask;
|
||||
import io.v.nutz.zhgh.welfare.feature.WelfareFeature;
|
||||
import io.v.nutz.zhgh.welfare.model.template.WelfareMemberTemp;
|
||||
import io.v.nutz.zhgh.welfare.service.WelfareMemberService;
|
||||
import org.apache.poi.ss.usermodel.Workbook;
|
||||
import org.apache.shiro.authz.annotation.Logical;
|
||||
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.Condition;
|
||||
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.lang.Strings;
|
||||
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 org.springframework.util.CollectionUtils;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 福利会员管理
|
||||
*
|
||||
* @author: 1V
|
||||
* @date: 2021/2/3
|
||||
* @since 1.0
|
||||
*/
|
||||
@IocBean
|
||||
@Ok("json")
|
||||
@At("/platform/welfare/member/mange")
|
||||
public class WelfareMemberMangeController {
|
||||
|
||||
@At("")
|
||||
@Ok("beetl:/platform/welfare/member/MemberMange.html")
|
||||
@RequiresPermissions("welfare.member.mange")
|
||||
public void index() {
|
||||
}
|
||||
|
||||
@Inject
|
||||
private WelfareMemberService welfareMemberService;
|
||||
|
||||
@Inject
|
||||
private SysUserService sysUserService;
|
||||
|
||||
@At
|
||||
@ViReturn
|
||||
@RequiresPermissions("welfare.member.mange")
|
||||
public Object pageData(PageForm pageForm, WelfareFeature.Condition.PageParam pageParam) {
|
||||
|
||||
Sql sql = Sqls.create("SELECT * from welfare_member $condition");
|
||||
pageForm.defaultSortAsc("unitid");
|
||||
CndPlus cnd = CndPlus.create();
|
||||
if (StrUtil.isNotBlank(pageParam.getUnionGroupId())) {
|
||||
List<Sys_unit> units = welfareMemberService.dao().query(Sys_unit.class, Cnd.where("unionGroupId", "=", pageParam.getUnionGroupId()));
|
||||
List<String> ids = units.stream().map(Sys_unit::getId).collect(Collectors.toList());
|
||||
cnd.and("threeUnitId", "in", ids);
|
||||
}
|
||||
pageParam.participate(cnd);
|
||||
cnd.and(pageForm);
|
||||
cnd.asc("loginname");
|
||||
sql.setCondition(cnd);
|
||||
return welfareMemberService.list(pageForm, sql);
|
||||
}
|
||||
|
||||
@Inject
|
||||
private AsyncService asyncService;
|
||||
|
||||
/**
|
||||
* 批量修改校区
|
||||
*
|
||||
* @param users
|
||||
* @return
|
||||
*/
|
||||
@At
|
||||
@ViReturn
|
||||
@RequiresPermissions("welfare.member.mange")
|
||||
public Object batchEdit(NutMap[] users) {
|
||||
welfareMemberService.transactional(() -> {
|
||||
asyncService.exe2(Arrays.asList(users), user -> {
|
||||
welfareMemberService.update(Chain.make("dqid", user.getString("campusId")), Cnd.where("id", "=", user.getString("id")));
|
||||
});
|
||||
});
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@At
|
||||
@ViReturn
|
||||
@RequiresPermissions("welfare.member.mange")
|
||||
@AdaptBy(type = UploadAdaptor.class, args = {"ioc:fileUpload"})
|
||||
@Aop(TransAop.READ_COMMITTED)
|
||||
public Object importMember(TempFile file, boolean isfg) {
|
||||
List<WelfareMemberTemp> welfare = ExcelImportUtil.importExcel(file.getFile(), WelfareMemberTemp.class, new ImportParams());
|
||||
if (isfg) {
|
||||
sysUserService.dao().execute(Sqls.create("update sys_user set welfareMember=0"));
|
||||
}
|
||||
|
||||
if (Lang.isNotEmpty(welfare)) {
|
||||
List<String> loginNameList = welfare.stream().map(WelfareMemberTemp::getLoginName).collect(Collectors.toList());
|
||||
sysUserService.update(Chain.make("welfareMember", 1), Cnd.where("loginname", "in", loginNameList));
|
||||
}
|
||||
|
||||
sysUserService.dao().clear(Sys_user_role.class, Cnd.where("roleid", "=", Roles.WELFARE_MEMBER));
|
||||
Sql sql = Sqls.queryString("select id from sys_user where welfareMember = 1");
|
||||
sysUserService.dao().execute(sql);
|
||||
List<String> ids = sql.getList(String.class);
|
||||
List<Sys_user_role> userRoles = ids.stream().map(v -> {
|
||||
Sys_user_role sys_user_role = new Sys_user_role();
|
||||
sys_user_role.setUserId(v);
|
||||
sys_user_role.setRoleId(Roles.WELFARE_MEMBER);
|
||||
return sys_user_role;
|
||||
}).collect(Collectors.toList());
|
||||
sysUserService.dao().insert(userRoles);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
@At
|
||||
@ViReturn
|
||||
@RequiresPermissions(value = {"welfare.member.check.union", "welfare.member.mange"}, logical = Logical.OR)
|
||||
public Object userPageData(PageForm pageForm,
|
||||
String taskId,
|
||||
@Param(value = "unitId", required = false) String unitId,
|
||||
@Param(value = "unionId", required = false) String unionId,
|
||||
@Param(value = "member", required = false) Boolean member,
|
||||
@Param(value = "sqlCnd", required = false) String sqlCnd) {
|
||||
Sql sql = Sqls.create("""
|
||||
SELECT
|
||||
u.*
|
||||
FROM
|
||||
`user` u
|
||||
LEFT JOIN member_change_record c ON u.id = c.userId
|
||||
$condition
|
||||
""");
|
||||
CndPlus cnd = CndPlus.create();
|
||||
pageForm.defaultSortAsc("u.unitid");
|
||||
cnd.and(pageForm);
|
||||
|
||||
cnd.andEx("u.unitid", "=", unionId);
|
||||
cnd.and("u.unitid", "is not", null);
|
||||
cnd.andEx("u.unionid", "=", unionId);
|
||||
cnd.and("u.unionid", "is not", null);
|
||||
if (StrUtil.isNotBlank(taskId)){
|
||||
MemberCheckTask checkTask = sysUserService.dao().fetch(MemberCheckTask.class, taskId);
|
||||
if (checkTask.getWelfareCheckFilterMode() == 2) {
|
||||
cnd.and(new Static("u.id not in (select userId from welfare_member_check_user where taskId='%s')".formatted(taskId)));
|
||||
}
|
||||
}
|
||||
|
||||
if (member != null && member) {
|
||||
cnd.and("u.member", "=", MemberMode.NORMAL.getCode());
|
||||
}
|
||||
if (!ShiroUtil.hasAnyRoles("sysadmin,SchoolUnionAdmin,SchoolUnionMemberAdmin,SchoolUnionWelfareAdmin")) {
|
||||
cnd.and("u.unionid", "=", Vi.getUnionId());
|
||||
}
|
||||
|
||||
if (StrUtil.isNotBlank(sqlCnd)) {
|
||||
String originalString = new String(Base64.getDecoder().decode(sqlCnd), StandardCharsets.UTF_8);
|
||||
Condition wrap = Cnd.wrap(originalString);
|
||||
cnd.and(new Static(wrap.toString()));
|
||||
}
|
||||
|
||||
cnd.groupBy("u.loginname");
|
||||
cnd.asc("u.loginname");
|
||||
sql.setCondition(cnd);
|
||||
|
||||
return welfareMemberService.list(pageForm, sql);
|
||||
}
|
||||
|
||||
|
||||
@At
|
||||
@ViReturn
|
||||
@RequiresPermissions("welfare.member.mange")
|
||||
@Aop(TransAop.READ_COMMITTED)
|
||||
public Object addMember(PageForm pageForm,
|
||||
@Param(value = "welfareUnit", required = false) String welfareUnit,
|
||||
@Param(value = "unit", required = false) String unit,
|
||||
@Param(value = "unionGroupId", required = false) String unionGroupId,
|
||||
@Param(value = "threeUnitId", required = false) String threeUnitId,
|
||||
@Param(value = "sex", required = false) String sex,
|
||||
@Param(value = "personType", required = false) String personType,
|
||||
@Param(value = "userState", required = false) String userState,
|
||||
@Param(value = "isAppendMember", required = false) Boolean isAppendMember) {
|
||||
Cnd cnd = Cnd.NEW();
|
||||
if (Strings.isNotBlank(pageForm.getSearchName()) && Strings.isNotBlank(pageForm.getSearchKeyword())) {
|
||||
cnd.where().andLike(pageForm.getSearchName(), pageForm.getSearchKeyword());
|
||||
}
|
||||
cnd.andEX("unionid", "=", welfareUnit);
|
||||
cnd.andEX("unitid", "=", unit);
|
||||
cnd.andEX("unionGroupId", "=", unionGroupId);
|
||||
cnd.andEX("threeUnitId", "=", threeUnitId);
|
||||
cnd.andEX("sex", "=", sex);
|
||||
cnd.andEX("personType", "=", personType);
|
||||
cnd.andEX("userState", "=", userState);
|
||||
cnd.andEX("welfareMember", "=", WelfareMemberMode.NORMAL.getCode());
|
||||
|
||||
List<User> users = welfareMemberService.dao().query(User.class, cnd);
|
||||
|
||||
List<String> ids = users.stream().map(User::getId).collect(Collectors.toList());
|
||||
|
||||
//如果清空更新
|
||||
if (!isAppendMember) {
|
||||
welfareMemberService.update(Chain.make("member", MemberMode.NONE.getCode()), Cnd.where("member", "=", MemberMode.NORMAL.getCode()));
|
||||
welfareMemberService.dao().clear(Sys_user_role.class, Cnd.where("roleId", "=", Roles.MEMBER));
|
||||
}
|
||||
welfareMemberService.update(Chain.make("member", MemberMode.NORMAL.getCode()), Cnd.where("welfareMember", "=", WelfareMemberMode.NORMAL.getCode()).and("id", "in", ids));
|
||||
|
||||
//找出福利会员里不是会员的
|
||||
List<Sys_user> sysUserList = welfareMemberService.query(Cnd.where("member", "!=", MemberMode.NORMAL.getCode()).and("id", "in", ids));
|
||||
//添加角色
|
||||
|
||||
List<Sys_user_role> sysUserRoles = sysUserList.stream().map(v -> {
|
||||
Sys_user_role userRole = new Sys_user_role();
|
||||
userRole.setRoleId(Roles.MEMBER);
|
||||
userRole.setUserId(v.getId());
|
||||
sysUserService.deleteCache(v.getId());
|
||||
return userRole;
|
||||
}).collect(Collectors.toList());
|
||||
sysUserService.dao().insert(sysUserRoles);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@At
|
||||
@AdaptBy(type = UploadAdaptor.class, args = {"ioc:fileUpload"})
|
||||
@RequiresPermissions("welfare.member.mange")
|
||||
public Object doImportCheckMember(TempFile file, String unionId) {
|
||||
List<WelfareMemberTemp> memberImportList = ExcelImportUtil.importExcel(file.getFile(), WelfareMemberTemp.class, new ImportParams());
|
||||
|
||||
Cnd cnd = Cnd.NEW();
|
||||
if (!ShiroUtil.hasAnyRoles("sysadmin,SchoolUnionAdmin,SchoolUnionMemberAdmin,SchoolUnionWelfareAdmin")) {
|
||||
cnd.and("unionid", "=", Vi.getUnionId());
|
||||
}
|
||||
cnd.andEX("unionid", "=", unionId);
|
||||
List<User> users = sysUserService.dao().query(User.class, cnd);
|
||||
Map<String, User> userMap = users.stream().collect(Collectors.toMap(User::getLoginname, v -> v));
|
||||
|
||||
List<WelfareMemberTemp> errorInfos = new ArrayList<>();
|
||||
|
||||
//找出系统里是福利会员但名单里不存在的人
|
||||
|
||||
List<User> welfareMember = users.stream().filter(u -> Lang.isNotEmpty(u.getWelfareMember()) && u.getWelfareMember() == 1).collect(Collectors.toList());
|
||||
welfareMember.forEach(wm -> {
|
||||
WelfareMemberTemp memberTemp = new WelfareMemberTemp();
|
||||
WelfareMemberTemp anElse = memberImportList.stream().filter(mil -> StrUtil.isNotBlank(mil.getLoginName()) && mil.getLoginName().equals(wm.getLoginname())).findFirst().orElse(null);
|
||||
|
||||
if (Lang.isEmpty(anElse)) {
|
||||
memberTemp.setLoginName(wm.getLoginname());
|
||||
memberTemp.setUserName(wm.getUsername());
|
||||
memberTemp.setRemarks("请检查此人员当前名单里不存在,但系统里是会员");
|
||||
errorInfos.add(memberTemp);
|
||||
}
|
||||
});
|
||||
|
||||
//循环名单人员
|
||||
List<User> welfareNotMember = users.stream().filter(u -> u.getWelfareMember() == null || u.getWelfareMember() != 1).collect(Collectors.toList());
|
||||
memberImportList.forEach(v -> {
|
||||
User user = userMap.get(v.getLoginName());
|
||||
if (Lang.isEmpty(user)) {
|
||||
v.setRemarks("请检查此人员的工号是否正确,系统查不到此人");
|
||||
errorInfos.add(v);
|
||||
} else {
|
||||
//找出在名单里,但系统里不是会员的
|
||||
User orElse = welfareNotMember.stream().filter(wnm -> wnm.getLoginname().equals(v.getLoginName())).findFirst().orElse(null);
|
||||
if (Lang.isNotEmpty(orElse)) {
|
||||
v.setRemarks("请检查此人员存在于名单内,但系统里不是会员");
|
||||
errorInfos.add(v);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
|
||||
if (!CollectionUtils.isEmpty(errorInfos)) {
|
||||
NutMap nutMap = NutMap.NEW();
|
||||
nutMap.setv("totalCount", memberImportList.size());
|
||||
nutMap.setv("errorList", errorInfos.stream().map(v -> {
|
||||
return NutMap.NEW().addv("工号", v.getLoginName()).addv("姓名", v.getUserName()).addv("错误原因", v.getRemarks());
|
||||
}).collect(Collectors.toList()));
|
||||
return Result.success(nutMap);
|
||||
}
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
|
||||
@At
|
||||
@Ok("void")
|
||||
@RequiresPermissions("welfare.member.mange")
|
||||
public void downloadTemplate(HttpServletResponse response) {
|
||||
ExportParams exportParams = new ExportParams();
|
||||
exportParams.setType(ExcelType.XSSF);
|
||||
List<WelfareMemberTemp> exampleList = new ArrayList<>();
|
||||
WelfareMemberTemp temp = new WelfareMemberTemp();
|
||||
temp.setLoginName("superadmin");
|
||||
temp.setUserName("超级管理员");
|
||||
exampleList.add(temp);
|
||||
|
||||
Workbook workbook = ExcelExportUtil.exportExcel(exportParams, WelfareMemberTemp.class, exampleList);
|
||||
try {
|
||||
ViTool.excelResponse(response, "福利会员导入模版.xlsx");
|
||||
workbook.write(response.getOutputStream());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@At
|
||||
@Ok("void")
|
||||
@RequiresPermissions("welfare.member.mange")
|
||||
public void exportList(HttpServletResponse response) {
|
||||
Sql sql = Sqls.create("SELECT loginname,username,sex,personType,userState,unionname,unitname,CASE member WHEN 1 THEN '是' ELSE '否' END as member from welfare_member $condition");
|
||||
Cnd cnd = Cnd.NEW();
|
||||
if (!ShiroUtil.hasAnyRoles("sysadmin,SchoolUnionWelfareAdmin")) {
|
||||
cnd.andEX("unionid", "=", Vi.getUnionId());
|
||||
}
|
||||
sql.setCondition(cnd);
|
||||
List<NutMap> list = welfareMemberService.listMap(sql);
|
||||
|
||||
List<ExcelExportEntity> exportEntities = new ArrayList<>();
|
||||
exportEntities.add(new ExcelExportEntity("工号", "loginname", 20));
|
||||
exportEntities.add(new ExcelExportEntity("姓名", "username", 20));
|
||||
exportEntities.add(new ExcelExportEntity("性别", "sex", 20));
|
||||
exportEntities.add(new ExcelExportEntity("人员类型", "personType", 20));
|
||||
exportEntities.add(new ExcelExportEntity("在职状态", "userState", 20));
|
||||
exportEntities.add(new ExcelExportEntity("分工会", "unionname", 20));
|
||||
exportEntities.add(new ExcelExportEntity("单位", "unitname", 50));
|
||||
exportEntities.add(new ExcelExportEntity("是否会员", "member", 50));
|
||||
|
||||
try {
|
||||
ViTool.excelResponse(response, "福利会员台账.xls");
|
||||
Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams(), exportEntities, list);
|
||||
workbook.write(response.getOutputStream());
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,217 @@
|
||||
package io.v.nutz.zhgh.welfare.controller;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.wizzer.framework.base.Result;
|
||||
import cn.wizzer.framework.page.Pagination;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import io.v.nutz.base.annontation.ViReturn;
|
||||
import io.v.nutz.base.query.PageForm;
|
||||
import io.v.nutz.base.utils.ExpressSelectUtil;
|
||||
import io.v.nutz.web.commons.slog.annotation.SLog;
|
||||
import io.v.nutz.web.commons.utils.ShiroUtil;
|
||||
import io.v.nutz.zhgh.welfare.model.WelfareEvaluate;
|
||||
import io.v.nutz.zhgh.welfare.model.WelfareUserSelection;
|
||||
import io.v.nutz.zhgh.welfare.service.WelfareListService;
|
||||
import io.v.nutz.zhgh.welfare.service.WelfareProjectService;
|
||||
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.integration.jedis.RedisService;
|
||||
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.util.NutMap;
|
||||
import org.nutz.mvc.annotation.At;
|
||||
import org.nutz.mvc.annotation.Ok;
|
||||
import org.nutz.mvc.annotation.Param;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@IocBean
|
||||
@Ok("json")
|
||||
@At("/platform/welfare/mine")
|
||||
public class WelfareMineController {
|
||||
|
||||
@Inject
|
||||
private WelfareListService welfareListService;
|
||||
|
||||
@Inject
|
||||
private WelfareProjectService welfareProjectService;
|
||||
@Inject
|
||||
private RedisService redisService;
|
||||
@Inject
|
||||
private ExpressSelectUtil expressSelectUtil;
|
||||
|
||||
|
||||
@At("")
|
||||
@Ok("beetl:/platform/welfare/mine.html")
|
||||
@RequiresPermissions("welfare.mine")
|
||||
public void index() {
|
||||
}
|
||||
|
||||
@At
|
||||
@ViReturn
|
||||
@RequiresPermissions("welfare.mine")
|
||||
public Object pageData(PageForm pageForm,
|
||||
@Param(value = "year", required = false) Integer year) {
|
||||
|
||||
Sql sql = Sqls.create("""
|
||||
SELECT
|
||||
wp.*,
|
||||
wp.id as projectId,
|
||||
CASE
|
||||
WHEN wus.selectUserId IS NOT NULL THEN 1
|
||||
ELSE 0
|
||||
END AS isChoose,
|
||||
GROUP_CONCAT(DISTINCT wuso.optionName,wus.selectNum) AS gist_list,
|
||||
wus.receiveAddress,
|
||||
wcn.courierNumber,
|
||||
wl.userId
|
||||
FROM
|
||||
welfare_project wp
|
||||
LEFT JOIN welfare_project_user_selection wus ON wp.id = wus.welfareId AND wus.selectUserId = @selectUserId
|
||||
LEFT JOIN welfare_courier_number wcn ON wp.id = wcn.welfareId AND wcn.selectUserId = @selectUserId
|
||||
LEFT JOIN welfare_list wl ON wp.id = wl.projectId AND wl.userId = @selectUserId
|
||||
LEFT JOIN welfare_project_subject_option wuso ON wus.selectOptionId = wuso.id
|
||||
$condition
|
||||
""");
|
||||
sql.setParam("selectUserId", ShiroUtil.getUserId());
|
||||
Cnd cnd = Cnd.NEW();
|
||||
cnd.and("wp.isDisabled", "=", 0);
|
||||
// cnd.andEX("YEAR(wp.choiceTimeStart)", "=", year);
|
||||
cnd.and("wp.id","in",Sqls.create("(select projectId from view_welfare_list where id = @userId)").setParam("userId",ShiroUtil.getUserId()));
|
||||
cnd.groupBy("wp.id");
|
||||
cnd.desc("wp.choiceTimeStart");
|
||||
sql.setCondition(cnd);
|
||||
Pagination pagination = welfareListService.list(pageForm, sql);
|
||||
|
||||
List<NutMap> list = pagination.getList();
|
||||
for (NutMap nutMap : list) {
|
||||
String gistList = nutMap.getString("gist_list");
|
||||
if (StrUtil.isNotBlank(gistList)) {
|
||||
String[] giftArray = gistList.split(",");
|
||||
List<NutMap> gifts = Arrays.stream(giftArray).map(gift -> {
|
||||
String num = gift.substring(gift.length() - 1);
|
||||
String name = gift.substring(0, gift.length() - 1);
|
||||
return NutMap.NEW().addv("name", name).addv("num", num);
|
||||
}).collect(Collectors.toList());
|
||||
nutMap.put("gifts", gifts);
|
||||
} else {
|
||||
nutMap.put("gifts", new ArrayList<>());
|
||||
}
|
||||
}
|
||||
return pagination;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取我选择的福利
|
||||
*
|
||||
* @param projectId
|
||||
* @return
|
||||
*/
|
||||
@At
|
||||
@ViReturn
|
||||
@RequiresPermissions("welfare.mine")
|
||||
public Object getUserSelection(String projectId, String userId) {
|
||||
Sql sql = Sqls.create("""
|
||||
SELECT
|
||||
wpus.id AS selectId,
|
||||
wpus.subjectId,
|
||||
wpus.selectOptionId,
|
||||
wpus.receiveAddress,
|
||||
wpso.optionName,
|
||||
wpus.selectNum,
|
||||
wpus.userSign,
|
||||
wpus.courierNumber,
|
||||
wpus.selectTime,
|
||||
wpso.imgUrl,
|
||||
wpso.simpleDesc,
|
||||
wpso.simpleDesc,
|
||||
wpso.supplier,
|
||||
(select COUNT(1) FROM welfare_evaluate we WHERE we.projectId=@projectId AND we.optionId=wpso.id) isPj
|
||||
FROM
|
||||
`welfare_project_user_selection` wpus
|
||||
LEFT JOIN welfare_project_subject_option wpso ON wpso.id = wpus.selectOptionId
|
||||
WHERE
|
||||
welfareId = @projectId
|
||||
AND selectUserId = @userId
|
||||
""");
|
||||
sql.setParam("projectId", projectId);
|
||||
sql.setParam("userId", StrUtil.isNotBlank(userId) ? userId : ShiroUtil.getPrincipalProperty("id"));
|
||||
return welfareProjectService.listMap(sql);
|
||||
}
|
||||
|
||||
|
||||
@At
|
||||
@ViReturn
|
||||
@SLog(type = "welfare", tag = "我的福利", msg = "福利评价")
|
||||
@RequiresPermissions("welfare.mine")
|
||||
public Object doEvaluate(WelfareEvaluate welfareEvaluate) {
|
||||
|
||||
welfareEvaluate.setUserId(ShiroUtil.getUserId());
|
||||
welfareEvaluate.setUserName(ShiroUtil.getPlatformUsername());
|
||||
welfareEvaluate.setLoginName(ShiroUtil.getPlatformLoginname());
|
||||
welfareEvaluate.setApplyDate(new Date());
|
||||
welfareProjectService.insert(welfareEvaluate);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@At
|
||||
@ViReturn
|
||||
@RequiresPermissions("welfare.mine")
|
||||
public Object finOneWelfareEvaluate(String projectId, String optionId) {
|
||||
WelfareEvaluate welfareEvaluate = welfareProjectService.dao().fetch(WelfareEvaluate.class,
|
||||
Cnd.where("userId", "=", ShiroUtil.getUserId())
|
||||
.and("projectId", "=", projectId).and("optionId", "=", optionId));
|
||||
return welfareEvaluate;
|
||||
}
|
||||
|
||||
@At
|
||||
@RequiresPermissions("welfare.mine")
|
||||
@ViReturn
|
||||
public Object getExpressInfo(String courierNumber) {
|
||||
WelfareUserSelection userSelection = welfareListService.dao().fetch(WelfareUserSelection.class, Cnd.where("courierNumber", "=", courierNumber));
|
||||
|
||||
//如果有上次查询的时间
|
||||
if (Lang.isNotEmpty(userSelection.getSelectExpressDate())) {
|
||||
String logisticsStatus = userSelection.getLogisticsTrace().getLogisticsStatus();
|
||||
if (List.of("AGENT_SIGN", "SIGN").contains(logisticsStatus)) {
|
||||
return userSelection.getLogisticsTrace();
|
||||
}
|
||||
long oldSelectExpressDate = DateUtil.offsetHour(userSelection.getSelectExpressDate(), 1).getTime();
|
||||
//如果上次查询的时间两小时后大于现在时间,就返回旧的信息
|
||||
if (oldSelectExpressDate > new Date().getTime()) {
|
||||
return Result.success(userSelection.getLogisticsTrace());
|
||||
}
|
||||
}
|
||||
String receiveAddress = userSelection.getReceiveAddress();
|
||||
String mobile = receiveAddress.substring(receiveAddress.length() - 11);
|
||||
|
||||
JSONObject jsonObject = expressSelectUtil.getExpressInfo(courierNumber, mobile);
|
||||
WelfareUserSelection.LogisticsTrace logisticsTrace = new WelfareUserSelection.LogisticsTrace();
|
||||
logisticsTrace.setTheLastTime(jsonObject.getDate("theLastTime"));
|
||||
logisticsTrace.setTheLastMessage(jsonObject.getString("theLastMessage"));
|
||||
logisticsTrace.setLogisticsStatusDesc(jsonObject.getString("logisticsStatusDesc"));
|
||||
logisticsTrace.setLogisticsStatus(jsonObject.getString("logisticsStatus"));
|
||||
List<NutMap> logisticsTraceDetailList = Json.fromJsonAsList(NutMap.class, jsonObject.getString("logisticsTraceDetailList"));
|
||||
logisticsTrace.setLogisticsTraceDetailList(logisticsTraceDetailList);
|
||||
|
||||
welfareListService.dao().update(WelfareUserSelection.class,
|
||||
Chain.make("logisticsTrace", logisticsTrace).add("selectExpressDate", new Date()),
|
||||
Cnd.where("courierNumber", "=", courierNumber));
|
||||
return jsonObject;
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,337 @@
|
||||
package io.v.nutz.zhgh.welfare.controller;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import io.v.nutz.base.annontation.ViReturn;
|
||||
import io.v.nutz.base.utils.MsgApi;
|
||||
import io.v.nutz.base.utils.Vi;
|
||||
import io.v.nutz.base.dao.CndPlus;
|
||||
import io.v.nutz.base.query.PageForm;
|
||||
import io.v.nutz.sys.models.Sys_home_activity;
|
||||
import io.v.nutz.task.services.TaskPlatformService;
|
||||
import io.v.nutz.zhgh.data.model.MatchConditionStructure;
|
||||
import io.v.nutz.zhgh.data.service.MatchConditionStructureService;
|
||||
import io.v.nutz.zhgh.mobileHome.service.MobileHomeService;
|
||||
import io.v.nutz.sys.models.Sys_task;
|
||||
import io.v.nutz.sys.services.SysTaskService;
|
||||
import io.v.nutz.zhgh.welfare.model.WelfareProject;
|
||||
import io.v.nutz.zhgh.welfare.model.WelfareProjectSubject;
|
||||
import io.v.nutz.zhgh.welfare.model.WelfareProjectSubjectOption;
|
||||
import io.v.nutz.zhgh.welfare.model.WelfareUserSelection;
|
||||
import io.v.nutz.zhgh.welfare.service.WelfareListService;
|
||||
import io.v.nutz.zhgh.welfare.service.WelfareProjectService;
|
||||
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.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.json.Json;
|
||||
import org.nutz.lang.Lang;
|
||||
import org.nutz.lang.Strings;
|
||||
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 org.nutz.trans.Trans;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 福利项目管理
|
||||
*
|
||||
* @author: 1V
|
||||
* @date: 2021/2/3
|
||||
* @since 1.0
|
||||
*/
|
||||
@IocBean
|
||||
@Ok("json")
|
||||
@At("/platform/welfare/project/mange")
|
||||
public class WelfareProjectMangeController {
|
||||
private final String JOB_CLASS = "io.v.nutz.task.job.welfare.welfareJob"; //调用类
|
||||
|
||||
|
||||
@At("")
|
||||
@Ok("beetl:/platform/welfare/project/ProjectMange.html")
|
||||
@RequiresPermissions("welfare.project.mange")
|
||||
public void index() {
|
||||
}
|
||||
|
||||
@Inject
|
||||
private WelfareProjectService projectService;
|
||||
|
||||
@Inject
|
||||
private WelfareListService listService;
|
||||
|
||||
@Inject
|
||||
private TaskPlatformService taskPlatformService;
|
||||
|
||||
@Inject
|
||||
private SysTaskService sysTaskService;
|
||||
|
||||
@Inject
|
||||
private Vi vi;
|
||||
|
||||
@Inject
|
||||
private Dao dao;
|
||||
|
||||
@Inject
|
||||
private MobileHomeService mobileHomeService;
|
||||
|
||||
@Inject
|
||||
private MsgApi msgApi;
|
||||
|
||||
@At
|
||||
@ViReturn
|
||||
@RequiresPermissions("welfare.project.mange")
|
||||
public Object pageData(PageForm pageForm,
|
||||
@Param(value = "year", required = false) Integer year,
|
||||
@Param(value = "name", required = false) String name) {
|
||||
|
||||
Sql sql = Sqls.create("SELECT project.*,IF((SELECT count(1) FROM welfare_list WHERE projectId = project.id)>0,TRUE,FALSE) created FROM `welfare_project` project $condition");
|
||||
CndPlus cnd = CndPlus.create();
|
||||
pageForm.defaultSortDesc("opAt");
|
||||
|
||||
cnd.andEx("year", "=", year);
|
||||
if (Strings.isNotBlank(name)) {
|
||||
cnd.and(Cnd.likeEX("name", name));
|
||||
}
|
||||
|
||||
cnd.and(pageForm);
|
||||
sql.setCondition(cnd);
|
||||
|
||||
return projectService.list(pageForm, sql);
|
||||
}
|
||||
|
||||
@Inject
|
||||
private MatchConditionStructureService matchConditionStructureService;
|
||||
|
||||
@At
|
||||
@ViReturn
|
||||
@RequiresPermissions("welfare.project.mange")
|
||||
public Object save(WelfareProject project) {
|
||||
|
||||
|
||||
Trans.exec(() -> {
|
||||
project.setYear(DateUtil.thisYear());
|
||||
if (project.getConditionStructure() != null) {
|
||||
project.setConditionStructureId(matchConditionStructureService.save(project.getConditionStructure()).getId());
|
||||
}
|
||||
if (StrUtil.isBlank(project.getId())) {
|
||||
WelfareProject insertProject = dao.insertWith(project, "welfareProjectSubjects");
|
||||
|
||||
|
||||
if (Lang.isNotEmpty(insertProject.getWelfareProjectSubjects())) {
|
||||
insertProject.getWelfareProjectSubjects().forEach(v -> {
|
||||
dao.insertLinks(v, "options");
|
||||
});
|
||||
}
|
||||
long provideTimeEnd = project.getProvideTimeEnd().getTime();
|
||||
long time = new Date().getTime();
|
||||
if (project.getFlexible()) {
|
||||
//找出福利里面有没有设置 没选系统自动分配
|
||||
// List<WelfareProjectSubject> welfareProjectSubjects = project.getWelfareProjectSubjects();
|
||||
// List<WelfareProjectSubjectOption> options = welfareProjectSubjects.get(0).getOptions();
|
||||
// List<WelfareProjectSubjectOption> isDefaultOption = options.stream().filter(op -> op.getIsDefaultOption()).collect(Collectors.toList());
|
||||
//
|
||||
// if (provideTimeEnd > time && project.getFlexible() && Lang.isNotEmpty(isDefaultOption)) {
|
||||
// //添加任务
|
||||
// Sys_task sys_task = new Sys_task();
|
||||
// sys_task.setName(project.getName() + "活动结束自动分配");
|
||||
// sys_task.setNote(project.getName());
|
||||
// sys_task.setJobClass(JOB_CLASS);
|
||||
//
|
||||
// sys_task.setCron(vi.getCron(project.getProvideTimeEnd()));
|
||||
// sys_task.setData(Json.toJson(new HashMap<String, Object>() {{
|
||||
// put("welfareId", project.getId());
|
||||
// }}));
|
||||
// sys_task.setDisabled(false);
|
||||
// sys_task = sysTaskService.insert(sys_task);
|
||||
// taskPlatformService.add(sys_task.getId(), sys_task.getId(), sys_task.getJobClass(), sys_task.getCron(), sys_task.getNote(), sys_task.getData());
|
||||
// project.setTaskId(sys_task.getId());
|
||||
// projectService.updateIgnoreNull(project);
|
||||
// }
|
||||
}
|
||||
} else {
|
||||
dao.clear(WelfareProjectSubjectOption.class, Cnd.NEW().and(new Static("subjectId in (select id from welfare_project_subject where projectId = '%s')".formatted(project.getId()))));
|
||||
dao.clear(WelfareProjectSubject.class, Cnd.where("projectId", "=", project.getId()));
|
||||
|
||||
dao.update(project);
|
||||
|
||||
List<WelfareProjectSubject> newSubject = project.getWelfareProjectSubjects();
|
||||
if (Lang.isNotEmpty(newSubject)) {
|
||||
newSubject.forEach(v -> {
|
||||
if (v.getId() == null) {
|
||||
v.setId(R.UU32());
|
||||
v.setProjectId(project.getId());
|
||||
}
|
||||
|
||||
Chain chain = Chain.make("id", v.getId());
|
||||
chain.add("projectId", v.getProjectId());
|
||||
chain.add("subjectName", v.getSubjectName());
|
||||
chain.add("subjectType", v.getSubjectType());
|
||||
dao.insert(WelfareProjectSubject.class, chain);
|
||||
|
||||
List<WelfareProjectSubjectOption> options = v.getOptions();
|
||||
options.forEach(o -> {
|
||||
if (o.getId() == null) {
|
||||
o.setId(R.UU32());
|
||||
o.setSubjectId(v.getId());
|
||||
}
|
||||
Chain optionChain = Chain.make("id", o.getId());
|
||||
optionChain.add("subjectId", o.getSubjectId());
|
||||
optionChain.add("optionName", o.getOptionName());
|
||||
optionChain.add("optionNameId", o.getOptionNameId());
|
||||
optionChain.add("optionType", o.getOptionType());
|
||||
optionChain.add("isDefaultOption", o.getIsDefaultOption());
|
||||
optionChain.add("isSystemDefault", o.getIsSystemDefault());
|
||||
optionChain.add("optionSort", o.getOptionSort());
|
||||
optionChain.add("imgUrl", o.getImgUrl());
|
||||
optionChain.add("description", o.getDescription());
|
||||
optionChain.add("shoppingId", o.getShoppingId());
|
||||
optionChain.add("shoppingName", o.getShoppingName());
|
||||
optionChain.add("supplier", o.getSupplier());
|
||||
optionChain.add("simpleDesc", o.getSimpleDesc());
|
||||
dao.insert(WelfareProjectSubjectOption.class, optionChain);
|
||||
});
|
||||
});
|
||||
}
|
||||
long provideTimeEnd = project.getProvideTimeEnd().getTime();
|
||||
long time = new Date().getTime();
|
||||
if (project.getFlexible()) {
|
||||
//找出福利里面有没有设置 没选系统自动分配
|
||||
// List<WelfareProjectSubject> welfareProjectSubjects = project.getWelfareProjectSubjects();
|
||||
// List<WelfareProjectSubjectOption> options = welfareProjectSubjects.get(0).getOptions();
|
||||
// List<WelfareProjectSubjectOption> isDefaultOption = options.stream().filter(op -> op.getIsDefaultOption()).collect(Collectors.toList());
|
||||
//
|
||||
// //先删除任务条件id不等于空代表有定时任务
|
||||
// if (Strings.isNotBlank(project.getTaskId())) {
|
||||
// taskPlatformService.delete(project.getTaskId(), project.getTaskId());
|
||||
// sysTaskService.delete(project.getTaskId());
|
||||
// }
|
||||
// //判断是否添加 条件是时间要大于现在时间&&是福利套餐&&福利选项里面设置了没选系统自动分配
|
||||
// if (provideTimeEnd > time && project.getFlexible() && Lang.isNotEmpty(isDefaultOption)) {
|
||||
// //添加任务
|
||||
// Sys_task sys_task = new Sys_task();
|
||||
// sys_task.setName(project.getName() + "活动结束自动分配");
|
||||
// sys_task.setNote(project.getName());
|
||||
// sys_task.setJobClass(JOB_CLASS);
|
||||
//
|
||||
// sys_task.setCron(vi.getCron(project.getChoiceTimeEnd()));
|
||||
// sys_task.setData(Json.toJson(new HashMap<String, Object>() {{
|
||||
// put("welfareId", project.getId());
|
||||
// }}));
|
||||
// sys_task.setDisabled(false);
|
||||
// sys_task = sysTaskService.insert(sys_task);
|
||||
// taskPlatformService.add(sys_task.getId(), sys_task.getId(), sys_task.getJobClass(), sys_task.getCron(), sys_task.getNote(), sys_task.getData());
|
||||
// project.setTaskId(sys_task.getId());
|
||||
// } else {
|
||||
// project.setTaskId(null);
|
||||
// }
|
||||
}
|
||||
dao.update(project);
|
||||
|
||||
}
|
||||
Sys_home_activity sysHomeActivity = project.covertToSysHomeActivity();
|
||||
dao.insertOrUpdate(sysHomeActivity);
|
||||
});
|
||||
return null;
|
||||
}
|
||||
|
||||
@At
|
||||
@ViReturn
|
||||
@Aop(TransAop.READ_COMMITTED)
|
||||
@RequiresPermissions("welfare.project.mange")
|
||||
public Object delete(String id) {
|
||||
WelfareProject project = projectService.fetch(id);
|
||||
WelfareProjectSubject welfareProjectSubject = projectService.dao().fetch(WelfareProjectSubject.class, Cnd.where("projectId", "=", id));
|
||||
if (Strings.isNotBlank(project.getConditionStructureId())) {
|
||||
projectService.dao().clear("match_condition", Cnd.where("structureId", "=", project.getConditionStructureId()));
|
||||
projectService.dao().delete(MatchConditionStructure.class, project.getConditionStructureId());
|
||||
}
|
||||
projectService.dao().clear(WelfareProjectSubject.class, Cnd.where("projectId", "=", id));
|
||||
if(ObjectUtil.isNotEmpty(welfareProjectSubject)){
|
||||
projectService.dao().clear(WelfareProjectSubjectOption.class, Cnd.where("subjectId", "=", welfareProjectSubject.getId()));
|
||||
}
|
||||
projectService.dao().clear(WelfareUserSelection.class, Cnd.where("welfareId", "=", id));
|
||||
projectService.delete(id);
|
||||
mobileHomeService.delete(id);
|
||||
listService.clear(Cnd.where("projectId", "=", id));
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成名单
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@At
|
||||
@ViReturn
|
||||
@RequiresPermissions("welfare.project.mange")
|
||||
public Object createList(String id, boolean created) {
|
||||
listService.createList(id, created);
|
||||
return null;
|
||||
}
|
||||
|
||||
@At
|
||||
@ViReturn
|
||||
@RequiresPermissions("welfare.project.mange")
|
||||
public Object findOne(String id) {
|
||||
return projectService.projectInfo(id);
|
||||
}
|
||||
|
||||
|
||||
@At
|
||||
@ViReturn
|
||||
@RequiresPermissions("welfare.list.mange")
|
||||
public Object sendMsgToNotWelfareUsers(String projectId, String sendMsgValue) {
|
||||
Sql sql = Sqls.create("""
|
||||
SELECT
|
||||
u.loginname as userId
|
||||
FROM
|
||||
welfare_list wl
|
||||
left join sys_user u on u.id = wl.userId
|
||||
WHERE
|
||||
wl.projectId = @projectId
|
||||
AND wl.userId NOT IN (
|
||||
SELECT DISTINCT
|
||||
( selectUserId )
|
||||
FROM
|
||||
welfare_project_user_selection
|
||||
WHERE
|
||||
welfareId = @projectId
|
||||
)
|
||||
""");
|
||||
sql.setParam("projectId", projectId);
|
||||
List<NutMap> userList = listService.listMap(sql);
|
||||
msgApi.sendMsg(sendMsgValue, "福利选择链接", "", "https://zhgh.jiangnan.edu.cn/mobile/welfare/list/receive?projectId=4fa233704ddb41bc8e34e966efeda0a4", "4", userList);
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 福利状态
|
||||
*
|
||||
* @param id
|
||||
* @param val
|
||||
*/
|
||||
@At
|
||||
@ViReturn
|
||||
@RequiresPermissions("welfare.list.mange")
|
||||
public Object projectStatusChange(String id, boolean val) {
|
||||
dao.update(WelfareProject.class, Chain.make("isDisabled", !val), Cnd.where("id", "=", id));
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
package io.v.nutz.zhgh.welfare.controller;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import io.v.nutz.base.annontation.ViReturn;
|
||||
import io.v.nutz.base.service.BaseService;
|
||||
import io.v.nutz.zhgh.member.constant.MemberChangeRecordMode;
|
||||
import io.v.nutz.zhgh.member.model.MemberCheckSelfTask;
|
||||
import io.v.nutz.zhgh.member.model.MemberCheckTask;
|
||||
import io.v.nutz.web.commons.utils.ShiroUtil;
|
||||
import org.nutz.dao.Cnd;
|
||||
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 java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @ClassName WelfareSelfAgentController
|
||||
* @Description TODO
|
||||
* @Author zhf
|
||||
* @Date 2023/8/1 8:58
|
||||
*/
|
||||
@At("/platform/welfareSelf/agenda")
|
||||
@Ok("json:full")
|
||||
@IocBean
|
||||
public class WelfareSelfAgentController {
|
||||
@Inject
|
||||
private BaseService baseService;
|
||||
|
||||
|
||||
@At
|
||||
@ViReturn
|
||||
public Object getAgenda() {
|
||||
|
||||
List<MemberCheckTask> checkTasks = baseService.dao().query(MemberCheckTask.class, Cnd.where("startTime", "<", DateUtil.date())
|
||||
.and("endTime", ">", DateUtil.date())
|
||||
.and("createTaskMode", "=", 2)
|
||||
.and("year", "=", DateUtil.thisYear())
|
||||
.and("taskMode", "=", MemberChangeRecordMode.WELFARE_MEMBER.getCode()));
|
||||
|
||||
final String title = "【福利系统】";
|
||||
List<NutMap> list = new ArrayList<>();
|
||||
if (Lang.isNotEmpty(checkTasks)) {
|
||||
checkTasks.forEach(v -> {
|
||||
int count = baseService.dao().count(MemberCheckSelfTask.class, Cnd.where("taskId", "=", v.getId())
|
||||
.and("userId", "=", ShiroUtil.getUserId()).and("isFinish", "=", false));
|
||||
list.add(new NutMap().addv("title", title)
|
||||
.addv("iconClass", "")
|
||||
.addv("name", "核对个人信息").addv("count", count)
|
||||
.addv("mobileHref", "/mobile/member/edit?taskId=" + v.getId()));
|
||||
});
|
||||
}
|
||||
return list;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,152 @@
|
||||
package io.v.nutz.zhgh.welfare.controller;
|
||||
|
||||
import cn.wizzer.framework.base.Result;
|
||||
import cn.wizzer.framework.page.Pagination;
|
||||
import io.v.nutz.base.annontation.ViReturn;
|
||||
import io.v.nutz.base.query.PageForm;
|
||||
import io.v.nutz.base.service.SimpleService;
|
||||
import io.v.nutz.web.commons.slog.annotation.SLog;
|
||||
import io.v.nutz.web.commons.utils.ShiroUtil;
|
||||
import io.v.nutz.zhgh.welfare.model.WelfareList;
|
||||
import io.v.nutz.zhgh.welfare.model.WelfareUserSelection;
|
||||
import io.v.nutz.zhgh.welfare.service.WelfareProjectService;
|
||||
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.json.Json;
|
||||
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.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @ClassName WelfareChooseController
|
||||
* @Description TODO
|
||||
* @Author zhf
|
||||
* @Date 2024/1/17 9:42
|
||||
*/
|
||||
@IocBean
|
||||
@Ok("json:full")
|
||||
@At("/platform/welfare/userChoose")
|
||||
public class WelfareUserChooseController {
|
||||
|
||||
@Inject
|
||||
private SimpleService simpleService;
|
||||
|
||||
@Inject
|
||||
private WelfareProjectService welfareProjectService;
|
||||
|
||||
@At("")
|
||||
@Ok("beetl:/platform/welfare/userChoose.html")
|
||||
@RequiresPermissions("welfare.user.choose")
|
||||
public void index() {
|
||||
}
|
||||
|
||||
@At
|
||||
@ViReturn
|
||||
@RequiresPermissions("welfare.user.choose")
|
||||
public Object pageData(PageForm pageForm, Integer year) {
|
||||
|
||||
Sql sql = Sqls.create("""
|
||||
SELECT
|
||||
wp.*,
|
||||
CASE
|
||||
WHEN wus.selectUserId IS NOT NULL THEN 1
|
||||
ELSE 0
|
||||
END AS isChoose,
|
||||
wus.selectTime,
|
||||
GROUP_CONCAT(DISTINCT wuso.optionName ,'(',wus.selectNum,'份)') AS gist_list,
|
||||
wus.receiveAddress
|
||||
FROM
|
||||
welfare_project wp
|
||||
LEFT JOIN welfare_project_user_selection wus ON wp.id = wus.welfareId AND wus.selectUserId = @selectUserId
|
||||
LEFT JOIN welfare_list wl ON wp.id = wl.projectId AND wl.userId = @selectUserId
|
||||
LEFT JOIN welfare_project_subject_option wuso ON wus.selectOptionId = wuso.id
|
||||
$condition
|
||||
""");
|
||||
sql.setParam("selectUserId", ShiroUtil.getUserId());
|
||||
|
||||
Cnd cnd = Cnd.NEW();
|
||||
cnd.and("wp.provideMode", "in", "2,3");
|
||||
cnd.andEX("YEAR(wp.choiceTimeStart)", "in", year);
|
||||
cnd.and("wp.isDisabled", "=", 0);
|
||||
cnd.and("wp.id","!=","fe1d51dafc104a1482cc946d05312e78");
|
||||
cnd.groupBy("wp.id");
|
||||
cnd.desc("YEAR(wp.choiceTimeStart)");
|
||||
sql.setCondition(cnd);
|
||||
Pagination pagination = simpleService.listPageMap(pageForm.getPageNumber(), pageForm.getPageSize(), sql);
|
||||
return pagination;
|
||||
|
||||
}
|
||||
|
||||
|
||||
@At
|
||||
@ViReturn
|
||||
@Aop(TransAop.READ_COMMITTED)
|
||||
@SLog(type = "welfare", tag = "pc电脑选福利", msg = "福利")
|
||||
@RequiresPermissions("welfare.user.choose")
|
||||
public Object doChoose(String chooseIds, String projectId, String subjectId, String receiveAddress) {
|
||||
//删除上次选择的
|
||||
simpleService.dao().clear(WelfareUserSelection.class, Cnd.where("welfareId", "=", projectId)
|
||||
.and("selectUserId", "=", ShiroUtil.getUserId()));
|
||||
|
||||
|
||||
List<WelfareUserSelection> insertList = new ArrayList<>();
|
||||
List<String> ids = Json.fromJsonAsList(String.class, chooseIds);
|
||||
ids.forEach(s -> {
|
||||
WelfareUserSelection selection = new WelfareUserSelection();
|
||||
selection.setWelfareId(projectId);
|
||||
selection.setSubjectId(subjectId);
|
||||
selection.setSelectUserId(ShiroUtil.getUserId());
|
||||
selection.setSelectTime(new Date());
|
||||
selection.setSelectOptionId(s);
|
||||
selection.setReceiveAddress(receiveAddress);
|
||||
insertList.add(selection);
|
||||
});
|
||||
simpleService.dao().insert(insertList);
|
||||
simpleService.dao().update(WelfareList.class,
|
||||
Chain.make("isReceive", true),
|
||||
Cnd.where("projectId", "=", projectId)
|
||||
.and("userId", "=", ShiroUtil.getUserId()));
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@At
|
||||
@ViReturn
|
||||
@Aop(TransAop.READ_COMMITTED)
|
||||
@SLog(type = "welfare", tag = "选择福利", msg = "福利")
|
||||
@RequiresPermissions("welfare.user.choose")
|
||||
public Result confirmSelect(@Param("welfareUserSelections") WelfareUserSelection[] welfareUserSelections,
|
||||
String projectId) {
|
||||
//删除上次选择的
|
||||
simpleService.dao().clear(WelfareUserSelection.class,
|
||||
Cnd.where("welfareId", "=", projectId)
|
||||
.and("selectUserId", "=", ShiroUtil.getUserId()));
|
||||
|
||||
for (WelfareUserSelection welfareUserSelection : welfareUserSelections) {
|
||||
welfareUserSelection.setSelectUserId(ShiroUtil.getUserId());
|
||||
welfareUserSelection.setSelectTime(new Date());
|
||||
}
|
||||
|
||||
simpleService.dao().insert(welfareUserSelections);
|
||||
|
||||
simpleService.dao().update(WelfareList.class,
|
||||
Chain.make("isReceive", true),
|
||||
Cnd.where("projectId", "=", projectId)
|
||||
.and("userId", "=", ShiroUtil.getUserId()));
|
||||
return Result.success("选择成功");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
+217
@@ -0,0 +1,217 @@
|
||||
package io.v.nutz.zhgh.welfare.controller.check;
|
||||
|
||||
import cn.afterturn.easypoi.excel.ExcelExportUtil;
|
||||
import cn.afterturn.easypoi.excel.entity.ExportParams;
|
||||
import cn.afterturn.easypoi.excel.entity.params.ExcelExportEntity;
|
||||
import io.v.nutz.base.annontation.ViReturn;
|
||||
import io.v.nutz.base.utils.Vi;
|
||||
import io.v.nutz.zhgh.member.service.MemberCheckPersonalService;
|
||||
import io.v.nutz.base.query.PageForm;
|
||||
import io.v.nutz.web.commons.utils.ShiroUtil;
|
||||
import io.v.nutz.base.utils.ViTool;
|
||||
import org.apache.poi.ss.usermodel.Workbook;
|
||||
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.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.mvc.annotation.At;
|
||||
import org.nutz.mvc.annotation.Ok;
|
||||
import org.nutz.mvc.annotation.Param;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @ClassName WelfareCheckPersonalController
|
||||
* @Author zzr
|
||||
* @Date 2023/6/14 14:19
|
||||
*/
|
||||
|
||||
@At("/platform/welfare/check/personal")
|
||||
@Ok("json:full")
|
||||
@IocBean
|
||||
public class WelfareCheckPersonalController {
|
||||
|
||||
@Inject
|
||||
private Dao dao;
|
||||
@Inject
|
||||
private MemberCheckPersonalService memberCheckPersonalService;
|
||||
|
||||
@At("")
|
||||
@Ok("beetl:/platform/welfare/member/check/personal.html")
|
||||
@RequiresPermissions("welfare.check.personal")
|
||||
public void index() {
|
||||
}
|
||||
|
||||
|
||||
@At
|
||||
@ViReturn
|
||||
public Object pageData(PageForm pageForm,
|
||||
@Param(value = "taskId", required = false) String taskId,
|
||||
@Param(value = "mobile", required = false) String mobile,
|
||||
@Param(value = "unionId", required = false) String unionId,
|
||||
@Param(value = "unitId", required = false) String unitId,
|
||||
@Param(value = "showFinish", required = false) Integer showFinish,
|
||||
@Param(value = "year", required = false) Integer year) {
|
||||
Sql sql = Sqls.create("""
|
||||
select
|
||||
mcst.id,
|
||||
mcst.taskId,
|
||||
mcst.userId,
|
||||
mcst.isFinish,
|
||||
mct.taskName,
|
||||
su.loginname,
|
||||
su.username,
|
||||
su.sex,
|
||||
su.birthday,
|
||||
su.unionname,
|
||||
su.unitname,
|
||||
su.personType,
|
||||
su.mobile
|
||||
from `member_check_self_task` mcst
|
||||
left join `member_check_task` mct on mct.id=mcst.taskId
|
||||
left join `user` su on su.id = mcst.userId
|
||||
$condition
|
||||
""");
|
||||
Cnd cnd = Cnd.NEW();
|
||||
if (!ShiroUtil.hasRole("sysadmin")) {
|
||||
cnd.and("su.unionid", "=", Vi.getUnionId());
|
||||
}
|
||||
cnd.and("mcst.taskId", "=", taskId);
|
||||
cnd.andEX("su.unionid", "=", unionId);
|
||||
cnd.andEX("su.unitid", "=", unitId);
|
||||
cnd.andEX("mct.`year`", "=", year);
|
||||
cnd.and(Cnd.likeEX("su.mobile", mobile));
|
||||
cnd.and(Cnd.likeEX("su." + pageForm.getSearchName(), pageForm.getSearchKeyword().trim()));
|
||||
switch (showFinish) {
|
||||
case -1 -> cnd.and("mcst.isFinish", "=", "0");
|
||||
case 1 -> cnd.and("mcst.isFinish", "=", "1");
|
||||
}
|
||||
cnd.desc("mcst.isFinish");
|
||||
cnd.asc("su.id");
|
||||
sql.setCondition(cnd);
|
||||
return memberCheckPersonalService.list(pageForm, sql);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取核对情况总人数
|
||||
*
|
||||
* @param unionId
|
||||
* @param unitId
|
||||
* @param taskId
|
||||
* @param year
|
||||
* @return
|
||||
*/
|
||||
@At
|
||||
@ViReturn
|
||||
public Object getFinishNum(PageForm pageForm,
|
||||
@Param(value = "unionId", required = false) String unionId,
|
||||
@Param(value = "unitId", required = false) String unitId,
|
||||
@Param(value = "mobile", required = false) String mobile,
|
||||
@Param(value = "taskId", required = false) String taskId,
|
||||
@Param(value = "year", required = false) Integer year) {
|
||||
Sql sql = Sqls.create("""
|
||||
SELECT
|
||||
count(mcst.id) allFinish,
|
||||
(sum( CASE WHEN mcst.isFinish = 1 THEN 1 ELSE 0 END )) doFinish,
|
||||
(sum( CASE WHEN mcst.isFinish != 1 THEN 1 ELSE 0 END )) noFinish
|
||||
FROM
|
||||
`member_check_self_task` mcst
|
||||
left join `member_check_task` mct on mct.id=mcst.taskId
|
||||
left join `user` u on u.id = mcst.userId
|
||||
$condition
|
||||
""");
|
||||
Cnd cnd = Cnd.NEW();
|
||||
if (!ShiroUtil.hasRole("sysadmin")) {
|
||||
cnd.and("u.unionid", "=", Vi.getUnionId());
|
||||
}
|
||||
cnd.andEX("mcst.taskId", "=", taskId);
|
||||
cnd.andEX("u.unionid", "=", unionId);
|
||||
cnd.andEX("u.unitid", "=", unitId);
|
||||
cnd.and(Cnd.likeEX("u.mobile", mobile));
|
||||
cnd.andEX("mct.`year`", "=", year);
|
||||
cnd.and(Cnd.likeEX("u." + pageForm.getSearchName(), pageForm.getSearchKeyword().trim()));
|
||||
sql.setCondition(cnd);
|
||||
return memberCheckPersonalService.fetch(sql);
|
||||
}
|
||||
|
||||
|
||||
@At("/exportExcel")
|
||||
@Ok("void")
|
||||
public void exportExcel(HttpServletResponse response,
|
||||
@Param(value = "unionId", required = false) String unionId,
|
||||
@Param(value = "unitId", required = false) String unitId,
|
||||
@Param(value = "searchKeyword", required = false) String searchKeyword,
|
||||
@Param(value = "showFinish", required = false) Integer showFinish,
|
||||
@Param(value = "year", required = false) Integer year,
|
||||
@Param(value = "taskId", required = false) String taskId,
|
||||
@Param(value = "taskName", required = false) String taskName,
|
||||
@Param(value = "mobile", required = false) String mobile) {
|
||||
Sql sql = Sqls.create("""
|
||||
select
|
||||
mcst.id,
|
||||
mcst.taskId,
|
||||
mcst.userId,
|
||||
mcst.isFinish,
|
||||
mct.taskName,
|
||||
su.loginname,
|
||||
su.username,
|
||||
su.sex,
|
||||
su.birthday,
|
||||
su.unionname,
|
||||
su.unitname,
|
||||
su.personType,
|
||||
su.mobile
|
||||
from `member_check_self_task` mcst
|
||||
left join `member_check_task` mct on mct.id=mcst.taskId
|
||||
left join `user` su on su.id = mcst.userId
|
||||
$condition
|
||||
""");
|
||||
Cnd cnd = Cnd.NEW();
|
||||
switch (showFinish) {
|
||||
case -1 -> cnd.and("mcst.isFinish", "=", "0");
|
||||
case 1 -> cnd.and("mcst.isFinish", "=", "1");
|
||||
}
|
||||
cnd.andEX("mct.`year`", "=", year);
|
||||
if (Strings.isNotBlank(unionId)) {
|
||||
cnd.and("su.unionid", "=", unionId);
|
||||
}
|
||||
cnd.andEX("mcst.taskId", "=", taskId);
|
||||
cnd.andEX("su.unitid", "=", unitId);
|
||||
cnd.and(Cnd.likeEX("su.mobile", mobile));
|
||||
cnd.andEX("su.username", "like", searchKeyword).orEX("su.loginname", "like", searchKeyword);
|
||||
cnd.desc("mcst.isFinish");
|
||||
cnd.asc("su.id");
|
||||
sql.setCondition(cnd);
|
||||
|
||||
List<NutMap> personalList = memberCheckPersonalService.listMap(sql);
|
||||
personalList.forEach(v -> {
|
||||
v.setv("year", year);
|
||||
v.setv("isfinish", Boolean.parseBoolean(v.getString("isFinish")) ? "已核对" : "未核对");
|
||||
});
|
||||
List<ExcelExportEntity> exportEntities = new ArrayList<>();
|
||||
exportEntities.add(new ExcelExportEntity("年度", "year", 20));
|
||||
exportEntities.add(new ExcelExportEntity("工号", "loginname", 20));
|
||||
exportEntities.add(new ExcelExportEntity("姓名", "username", 20));
|
||||
exportEntities.add(new ExcelExportEntity("性别", "sex", 20));
|
||||
exportEntities.add(new ExcelExportEntity("联系电话", "mobile", 20));
|
||||
exportEntities.add(new ExcelExportEntity("人员类型", "personType", 20));
|
||||
exportEntities.add(new ExcelExportEntity("所属工会", "unionname", 20));
|
||||
exportEntities.add(new ExcelExportEntity("所在单位", "unitname", 20));
|
||||
exportEntities.add(new ExcelExportEntity("核对情况", "isfinish", 20));
|
||||
|
||||
try {
|
||||
ViTool.excelResponse(response, taskName + "任务个人核对信息名单.xls");
|
||||
Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams(), exportEntities, personalList);
|
||||
workbook.write(response.getOutputStream());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
+240
@@ -0,0 +1,240 @@
|
||||
package io.v.nutz.zhgh.welfare.controller.check;
|
||||
|
||||
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.query.PageForm;
|
||||
import io.v.nutz.base.service.SimpleService;
|
||||
import io.v.nutz.base.utils.Roles;
|
||||
import io.v.nutz.base.utils.ViTool;
|
||||
import io.v.nutz.zhgh.data.constant.UserChangeType;
|
||||
import io.v.nutz.zhgh.member.constant.MemberChangeApplyState;
|
||||
import io.v.nutz.zhgh.member.constant.MemberChangeRecordMode;
|
||||
import io.v.nutz.zhgh.member.model.MemberChangeRecord;
|
||||
import org.apache.poi.ss.usermodel.Workbook;
|
||||
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.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 org.nutz.mvc.annotation.Param;
|
||||
|
||||
import javax.servlet.ServletOutputStream;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @FileName io.v.nutz.member.controller.check.MemberCheckUnionController
|
||||
* @Description: 校工会核对
|
||||
* @Author zxc
|
||||
* @Date 2022/10/21:10:31
|
||||
* @Version V1.0
|
||||
**/
|
||||
@At("/platform/welfareMember/check/school")
|
||||
@Ok("json:full")
|
||||
@IocBean
|
||||
public class WelfareMemberCheckSchoolController {
|
||||
|
||||
@Inject
|
||||
private Dao dao;
|
||||
|
||||
@Inject
|
||||
private SimpleService simpleService;
|
||||
|
||||
@At("")
|
||||
@Ok("beetl:/platform/welfare/member/check/school.html")
|
||||
@RequiresPermissions("welfare.member.check.school")
|
||||
public void union() {
|
||||
}
|
||||
|
||||
@At
|
||||
@ViReturn
|
||||
@RequiresPermissions("welfare.member.check.school")
|
||||
public Object pageData(PageForm pageForm,
|
||||
@Param(value = "taskId", required = false) String taskId,
|
||||
@Param(value = "unionId", required = false) String unionId,
|
||||
@Param(value = "unitId", required = false) String unitId) {
|
||||
Sql sql = Sqls.create("""
|
||||
SELECT
|
||||
gh.id,
|
||||
gh.unioncode,
|
||||
gh.unionname,
|
||||
mcut.isFinish,
|
||||
IF(mcut.isFinish is true,'是','否') as isFinishText,
|
||||
( SELECT COUNT( 1 ) FROM `user` WHERE welfareMember = 1 AND unionid=gh.id) memberNum,
|
||||
(SELECT COUNT( 1 ) FROM member_check_union_task WHERE unionid = gh.id and taskId=mcut.taskId ) unionGroupNum,
|
||||
(SELECT COUNT( 1 ) FROM member_check_union_task WHERE isFinish = false AND unionid = gh.id and taskId=mcut.taskId ) fouUnionGroupNum,
|
||||
(SELECT COUNT( 1 ) FROM member_check_union_task WHERE isFinish = true AND unionid = gh.id and taskId=mcut.taskId ) shiUnionGroupNum
|
||||
FROM
|
||||
member_check_union_task mcut
|
||||
LEFT JOIN sys_union gh ON gh.id = mcut.unionId
|
||||
$condition
|
||||
""");
|
||||
Cnd cnd = Cnd.NEW();
|
||||
cnd.andEX("gh.id", "=", unionId);
|
||||
cnd.and("mcut.taskId", "=", taskId);
|
||||
cnd.and("gh.id", "is not", null);
|
||||
cnd.groupBy("gh.id");
|
||||
cnd.asc("gh.unioncode");
|
||||
sql.setCondition(cnd);
|
||||
List<NutMap> map = simpleService.listMap(sql);
|
||||
List<MemberChangeRecord> changeRecords = simpleService.dao().query(MemberChangeRecord.class,
|
||||
Cnd.where("stateId", "=", MemberChangeApplyState.SCHOOL_UNION)
|
||||
.and("taskId", "=", taskId));
|
||||
map.forEach(v -> {
|
||||
//该工会有多少个人需要审核
|
||||
//找出原工会和现工会不等于空的
|
||||
/* //找出的值为单位变更
|
||||
int size = changeRecords.stream().filter(c ->
|
||||
StrUtil.isNotEmpty(c.getCurrentUnionId()) &&
|
||||
StrUtil.isNotEmpty(c.getOriginUnionId()) &&
|
||||
c.getCurrentUnionId().equals(v.getString("id"))).collect(Collectors.toList()).size();*/
|
||||
//找出除了单位变更的其他会员
|
||||
int size2 = changeRecords.stream().filter(c ->
|
||||
StrUtil.isNotEmpty(c.getOriginUnionId()) &&
|
||||
|
||||
c.getOriginUnionId().equals(v.getString("id"))).collect(Collectors.toList()).size();
|
||||
v.setv("notCheckNum", size2);
|
||||
});
|
||||
return map;
|
||||
}
|
||||
|
||||
@At
|
||||
@ViReturn
|
||||
@RequiresPermissions("welfare.member.check.school")
|
||||
public Object getNotCheckUsers(@Param(value = "taskId", required = false) String taskId,
|
||||
@Param(value = "unionId", required = false) String unionId,
|
||||
@Param(value = "isView", required = false) Boolean isView) {
|
||||
Sql sql = Sqls.create("""
|
||||
SELECT
|
||||
u.welfareMember AS member,
|
||||
mcr.id,
|
||||
u.username AS userName,
|
||||
u.loginname AS loginName,
|
||||
u.unitname,
|
||||
u.threeUnitName,
|
||||
u.userState,
|
||||
u.personType,
|
||||
it.`name` newUnitName,
|
||||
threeit.`name` newThreeUnitName,
|
||||
mcr.type changeType,
|
||||
mcr.applyTime changeTime,
|
||||
state.stateId,
|
||||
state.stateName,
|
||||
his.id hisId,
|
||||
his.changeType,
|
||||
his.changeTypes
|
||||
FROM
|
||||
member_change_record mcr
|
||||
LEFT JOIN `user` u ON u.id = mcr.userId
|
||||
LEFT JOIN audit_state state ON mcr.stateId = state.stateId
|
||||
LEFT JOIN user_history_latest his ON his.loginname = u.loginname
|
||||
LEFT JOIN sys_unit it ON it.id=mcr.currentUnitId
|
||||
LEFT JOIN sys_unit threeit ON threeit.id=mcr.currentThreeUnitId
|
||||
$condition
|
||||
""");
|
||||
Cnd cnd = Cnd.NEW();
|
||||
cnd.and("mcr.taskId", "=", taskId);
|
||||
if (!isView) {
|
||||
cnd.and("mcr.stateId", "=", MemberChangeApplyState.SCHOOL_UNION);
|
||||
} else {
|
||||
cnd.and("mcr.stateId", "in", List.of(MemberChangeApplyState.SCHOOL_UNION_FAIL, MemberChangeApplyState.SUCCESS));
|
||||
}
|
||||
cnd.and("mcr.originUnionId", "=", unionId);
|
||||
sql.setCondition(cnd);
|
||||
return simpleService.listMap(sql);
|
||||
}
|
||||
|
||||
@At
|
||||
@ViReturn
|
||||
@RequiresPermissions("welfare.member.check.school")
|
||||
public Object unionGroupData(@Param(value = "unionId", required = false) String unionId,
|
||||
@Param(value = "taskId", required = false) String taskId) {
|
||||
Cnd cnd = Cnd.NEW();
|
||||
Sql sql = Sqls.create("""
|
||||
SELECT
|
||||
sug.* ,
|
||||
mcut.isFinish,
|
||||
u.username,
|
||||
u.loginname,
|
||||
u.mobile
|
||||
FROM
|
||||
member_check_union_task mcut
|
||||
LEFT JOIN sys_union_group sug ON mcut.groupUnionId = sug.id
|
||||
LEFT JOIN sys_user_role sur ON sur.unionGroupId = sug.id
|
||||
AND roleId = @roleId
|
||||
LEFT JOIN sys_user u ON u.id = sur.userId
|
||||
$condition
|
||||
""").setParam("roleId", Roles.ghxzzz);
|
||||
cnd.andEX("mcut.unionid", "=", unionId);
|
||||
cnd.andEX("mcut.taskId", "=", taskId);
|
||||
cnd.asc("mcut.isFinish");
|
||||
cnd.asc("sug.groupCode");
|
||||
sql.setCondition(cnd);
|
||||
return simpleService.listMap(sql);
|
||||
}
|
||||
|
||||
@At
|
||||
@Ok("void")
|
||||
@RequiresPermissions("welfare.member.check.school")
|
||||
public void exportChangeUser(@Param(value = "taskId", required = false) String taskId, HttpServletResponse response) {
|
||||
Sql sql = Sqls.create("""
|
||||
SELECT
|
||||
u.username,
|
||||
u.loginname,
|
||||
u.sex,
|
||||
u.mobile,
|
||||
u.idcard,
|
||||
u.unitname,
|
||||
u.unionname,
|
||||
mcr.type
|
||||
FROM
|
||||
member_change_record mcr
|
||||
LEFT JOIN `user` u ON u.id = mcr.userId\s
|
||||
WHERE
|
||||
taskId = @taskId
|
||||
AND mcr.recordMode = @mode
|
||||
""");
|
||||
sql.setParam("taskId", taskId);
|
||||
sql.setParam("mode", MemberChangeRecordMode.WELFARE_MEMBER.getCode());
|
||||
List<NutMap> dataList = (List<NutMap>) simpleService.listMap(sql);
|
||||
|
||||
for (NutMap map : dataList) {
|
||||
map.put("typeName", Arrays.stream(UserChangeType.class.getEnumConstants()).filter(v -> v.getCode() == map.getInt("type")).findAny().map(v -> v.getDescription()).orElse(null));
|
||||
}
|
||||
|
||||
|
||||
List<ExcelExportEntity> exportEntities = new ArrayList<>();
|
||||
exportEntities.add(new ExcelExportEntity("姓名", "username", 20));
|
||||
exportEntities.add(new ExcelExportEntity("工号", "loginname", 20));
|
||||
exportEntities.add(new ExcelExportEntity("性别", "sex", 20));
|
||||
exportEntities.add(new ExcelExportEntity("联系方式", "mobile", 20));
|
||||
exportEntities.add(new ExcelExportEntity("身份证号", "idcard", 20));
|
||||
exportEntities.add(new ExcelExportEntity("所在单位", "unitname", 20));
|
||||
exportEntities.add(new ExcelExportEntity("所在分工会", "unionname", 20));
|
||||
exportEntities.add(new ExcelExportEntity("变更类型", "typeName", 20));
|
||||
|
||||
try (ServletOutputStream outputStream = response.getOutputStream()) {
|
||||
ViTool.excelResponse(response, "人员名单.xlsx");
|
||||
ExportParams exportParams = new ExportParams();
|
||||
exportParams.setType(ExcelType.XSSF);
|
||||
Workbook workbook = ExcelExportUtil.exportExcel(exportParams, exportEntities, dataList);
|
||||
workbook.write(outputStream);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
+204
@@ -0,0 +1,204 @@
|
||||
package io.v.nutz.zhgh.welfare.controller.check;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.lang.Assert;
|
||||
import io.v.nutz.base.annontation.ViReturn;
|
||||
import io.v.nutz.base.query.PageForm;
|
||||
import io.v.nutz.base.service.SimpleService;
|
||||
import io.v.nutz.sys.models.Sys_union;
|
||||
import io.v.nutz.sys.models.Sys_user;
|
||||
import io.v.nutz.zhgh.member.constant.MemberChangeRecordMode;
|
||||
import io.v.nutz.zhgh.member.model.MemberChangeRecord;
|
||||
import io.v.nutz.zhgh.member.model.MemberCheckSelfTask;
|
||||
import io.v.nutz.zhgh.member.model.MemberCheckTask;
|
||||
import io.v.nutz.zhgh.member.model.MemberCheckUnionTask;
|
||||
import io.v.nutz.zhgh.welfare.model.WelfareMemberCheckUser;
|
||||
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.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 org.nutz.mvc.annotation.Param;
|
||||
import org.nutz.trans.Trans;
|
||||
|
||||
import java.util.Calendar;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @FileName io.v.nutz.member.controller.check.MemberCheckTaskController
|
||||
* @Description: TODO
|
||||
* @Author zxc
|
||||
* @Date 2022/10/21:10:33
|
||||
* @Version V1.0
|
||||
**/
|
||||
@At("/platform/welfareMember/check/task")
|
||||
@Ok("json:full")
|
||||
@IocBean
|
||||
public class WelfareMemberCheckTaskController {
|
||||
|
||||
@Inject
|
||||
private Dao dao;
|
||||
|
||||
@Inject
|
||||
private SimpleService simpleService;
|
||||
|
||||
@At("")
|
||||
@Ok("beetl:/platform/welfare/member/check/task.html")
|
||||
@RequiresPermissions("welfare.member.check.task")
|
||||
public void union() {
|
||||
}
|
||||
|
||||
@At
|
||||
@ViReturn
|
||||
@RequiresPermissions("welfare.member.check.task")
|
||||
public Object pageData(PageForm pageForm, @Param(value = "year", required = false) Integer year) {
|
||||
Sql sql = Sqls.create("""
|
||||
select * from member_check_task $condition
|
||||
""");
|
||||
Cnd cnd = Cnd.NEW();
|
||||
cnd.and("taskMode", "=", MemberChangeRecordMode.WELFARE_MEMBER.getCode());
|
||||
cnd.andEX("year", "=", year);
|
||||
sql.setCondition(cnd);
|
||||
return simpleService.list(pageForm, sql);
|
||||
}
|
||||
|
||||
@At
|
||||
@ViReturn
|
||||
@RequiresPermissions("welfare.member.check.task")
|
||||
public Object doAdd(MemberCheckTask task) {
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.setTime(task.getStartTime());
|
||||
List<Sys_union> sysUnions = dao.query(Sys_union.class, null);
|
||||
|
||||
Trans.exec(() -> {
|
||||
task.setYear(calendar.get(Calendar.YEAR));
|
||||
task.setTaskMode(MemberChangeRecordMode.WELFARE_MEMBER.getCode());
|
||||
dao.insert(task);
|
||||
if (task.getCreateTaskMode() == 1) {
|
||||
List<MemberCheckUnionTask> unionTasks = sysUnions.stream().map(v -> {
|
||||
MemberCheckUnionTask unionTask = new MemberCheckUnionTask();
|
||||
unionTask.setTaskId(task.getId());
|
||||
unionTask.setUnionId(v.getId());
|
||||
unionTask.setIsFinish(false);
|
||||
return unionTask;
|
||||
}).collect(Collectors.toList());
|
||||
dao.insert(unionTasks);
|
||||
|
||||
|
||||
if (task.getWelfareCheckFilterMode() == 2) {
|
||||
Sql sql = Sqls.create("""
|
||||
SELECT
|
||||
id,
|
||||
unionid,
|
||||
unitid,
|
||||
schoolTime,
|
||||
birthday,
|
||||
userState,
|
||||
personType
|
||||
FROM
|
||||
`user`
|
||||
WHERE
|
||||
YEAR ( schoolTime ) = @year
|
||||
AND DATE_FORMAT( birthday, '%m-%d' ) > DATE_FORMAT(schoolTime,'%m-%d')
|
||||
""").setParam("year", DateUtil.thisYear());
|
||||
List<NutMap> userList = simpleService.listMap(sql);
|
||||
List<Object> insertUserList = userList.stream().map(u -> {
|
||||
WelfareMemberCheckUser checkUser = new WelfareMemberCheckUser();
|
||||
checkUser.setUserId(u.getString("id"));
|
||||
checkUser.setUnitId(u.getString("unitid"));
|
||||
checkUser.setUnionId(u.getString("unionid"));
|
||||
checkUser.setUserState(u.getString("userState"));
|
||||
checkUser.setPersonType(u.getString("personType"));
|
||||
checkUser.setTaskId(task.getId());
|
||||
return checkUser;
|
||||
}).collect(Collectors.toList());
|
||||
dao.insert(insertUserList);
|
||||
}
|
||||
|
||||
} else {
|
||||
List<Sys_user> sysUsers = dao.query(Sys_user.class, Cnd.where("welfareMember", "=", 1));
|
||||
List<MemberCheckSelfTask> selfTasks = sysUsers.stream().map(v -> {
|
||||
MemberCheckSelfTask selfTask = new MemberCheckSelfTask();
|
||||
selfTask.setTaskId(task.getId());
|
||||
selfTask.setUserId(v.getId());
|
||||
selfTask.setIsFinish(false);
|
||||
return selfTask;
|
||||
}).collect(Collectors.toList());
|
||||
dao.insert(selfTasks);
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@At
|
||||
@ViReturn
|
||||
@RequiresPermissions("welfare.member.check.task")
|
||||
public Object doEdit(MemberCheckTask task) {
|
||||
if (task.getCreateTaskMode() == 2) {
|
||||
List<MemberCheckSelfTask> checkSelfTasks = dao.query(MemberCheckSelfTask.class, Cnd.where("taskId", "=", task.getId()));
|
||||
List<String> userIdList = checkSelfTasks.stream().map(MemberCheckSelfTask::getUserId).collect(Collectors.toList());
|
||||
List<Sys_user> sysUsers = dao.query(Sys_user.class, Cnd.where("member", "=", 1).and("id", "not in", userIdList));
|
||||
List<MemberCheckSelfTask> selfTasks = sysUsers.stream().map(v -> {
|
||||
MemberCheckSelfTask selfTask = new MemberCheckSelfTask();
|
||||
selfTask.setTaskId(task.getId());
|
||||
selfTask.setUserId(v.getId());
|
||||
selfTask.setIsFinish(false);
|
||||
return selfTask;
|
||||
}).collect(Collectors.toList());
|
||||
dao.insert(selfTasks);
|
||||
}
|
||||
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.setTime(task.getStartTime());
|
||||
task.setTaskMode(MemberChangeRecordMode.WELFARE_MEMBER.getCode());
|
||||
task.setYear(calendar.get(Calendar.YEAR));
|
||||
dao.updateIgnoreNull(task);
|
||||
return null;
|
||||
}
|
||||
|
||||
@At
|
||||
@ViReturn
|
||||
@RequiresPermissions("welfare.member.check.task")
|
||||
public Object doDelete(@Param("id") String id) {
|
||||
Assert.notBlank(id);
|
||||
Trans.exec(() -> {
|
||||
dao.clear(MemberCheckTask.class, Cnd.where("id", "=", id));
|
||||
dao.clear(MemberCheckUnionTask.class, Cnd.where("taskId", "=", id));
|
||||
dao.clear(MemberChangeRecord.class, Cnd.where("taskId", "=", id));
|
||||
dao.clear(MemberCheckSelfTask.class, Cnd.where("taskId", "=", id));
|
||||
});
|
||||
return null;
|
||||
}
|
||||
|
||||
@At
|
||||
@ViReturn
|
||||
public Object getAllTask(Integer year) {
|
||||
Cnd cnd = Cnd.NEW();
|
||||
cnd.andEX("year", "=", year);
|
||||
cnd.and("taskMode", "=", MemberChangeRecordMode.WELFARE_MEMBER.getCode());
|
||||
cnd.and("createTaskMode", "=", 1);
|
||||
cnd.desc("startTime");
|
||||
return dao.query(MemberCheckTask.class, cnd);
|
||||
}
|
||||
|
||||
@At
|
||||
@ViReturn
|
||||
public Object getTaskModePersonal(@Param(value = "year", required = false) Integer year) {
|
||||
Cnd cnd = Cnd.NEW();
|
||||
cnd.andEX("year", "=", year);
|
||||
cnd.andEX("createTaskMode", "=", 2);
|
||||
cnd.and("taskMode", "=", MemberChangeRecordMode.WELFARE_MEMBER.getCode());
|
||||
return dao.query(MemberCheckTask.class, cnd);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
+428
@@ -0,0 +1,428 @@
|
||||
package io.v.nutz.zhgh.welfare.controller.check;
|
||||
|
||||
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 cn.wizzer.framework.base.Result;
|
||||
import com.google.common.base.Joiner;
|
||||
import io.v.nutz.base.annontation.ViReturn;
|
||||
import io.v.nutz.base.service.SimpleService;
|
||||
import io.v.nutz.base.utils.Vi;
|
||||
import io.v.nutz.base.dao.CndPlus;
|
||||
import io.v.nutz.sys.models.Sys_config;
|
||||
import io.v.nutz.zhgh.data.constant.UserChangeType;
|
||||
import io.v.nutz.zhgh.member.constant.MemberChangeApplyState;
|
||||
import io.v.nutz.zhgh.member.constant.MemberChangeOrigin;
|
||||
import io.v.nutz.zhgh.member.constant.MemberChangeRecordMode;
|
||||
import io.v.nutz.zhgh.member.handle.MemberChangeAuditHandle;
|
||||
import io.v.nutz.zhgh.member.model.MemberChangeRecord;
|
||||
import io.v.nutz.zhgh.member.model.MemberCheckTask;
|
||||
import io.v.nutz.zhgh.member.model.MemberCheckUnionTask;
|
||||
import io.v.nutz.base.model.Audit;
|
||||
import io.v.nutz.base.query.PageForm;
|
||||
import io.v.nutz.sys.models.User;
|
||||
import io.v.nutz.web.commons.utils.ShiroUtil;
|
||||
import io.v.nutz.base.utils.ViTool;
|
||||
import io.v.nutz.zhgh.welfare.constant.WelfareMemberApplyState;
|
||||
import io.v.nutz.zhgh.welfare.feature.WelfareFeature;
|
||||
import io.v.nutz.zhgh.welfare.handle.WelfareMemberApplyAuditHandle;
|
||||
import io.v.nutz.zhgh.welfare.mode.WelfareMemberMode;
|
||||
import io.v.nutz.zhgh.welfare.model.WelfareMemberApplyRecord;
|
||||
import io.v.nutz.zhgh.welfare.model.WelfareMemberCheckUser;
|
||||
import org.apache.poi.ss.usermodel.Workbook;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.nutz.dao.Chain;
|
||||
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.SqlExpressionGroup;
|
||||
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 javax.servlet.http.HttpServletResponse;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @FileName io.v.nutz.member.controller.check.MemberCheckUnionController
|
||||
* @Description: 院级工会核对
|
||||
* @Author zxc
|
||||
* @Date 2022/10/21:10:31
|
||||
* @Version V1.0
|
||||
**/
|
||||
@At("/platform/welfareMember/check/union")
|
||||
@Ok("json:full")
|
||||
@IocBean
|
||||
public class WelfareMemberCheckUnionController {
|
||||
|
||||
@Inject
|
||||
private Dao dao;
|
||||
|
||||
@Inject
|
||||
private SimpleService simpleService;
|
||||
|
||||
@At("")
|
||||
@Ok("beetl:/platform/welfare/member/check/union.html")
|
||||
@RequiresPermissions("welfare.member.check.union")
|
||||
public void union() {
|
||||
}
|
||||
|
||||
@At
|
||||
@ViReturn
|
||||
@RequiresPermissions("welfare.member.check.union")
|
||||
public Object pageData(PageForm pageForm,
|
||||
WelfareFeature.Condition.PageParam pageParam,
|
||||
@Param(value = "taskId", required = false) String taskId,
|
||||
@Param(value = "unionId", required = false) String unionId,
|
||||
@Param(value = "unitId", required = false) String unitId,
|
||||
@Param(value = "changed", required = false) Integer changed,
|
||||
@Param(value = "changeType", required = false) String changeType,
|
||||
@Param(value = "isMember", required = false) Integer isMember,
|
||||
@Param(value = "welfareMember", required = false) Integer welfareMember,
|
||||
@Param(value = "userStates", required = false) String[] userStates,
|
||||
@Param(value = "personTypes", required = false) String[] personTypes,
|
||||
@Param(value = "changeTypes", required = false) Integer[] changeTypes,
|
||||
@Param(value = "changeOrigin", required = false) Integer[] changeOrigins
|
||||
) {
|
||||
CndPlus cnd = CndPlus.create();
|
||||
|
||||
Sql sql = Sqls.create("""
|
||||
SELECT
|
||||
u.*,
|
||||
his.id hisId,
|
||||
his.changeType,
|
||||
his.changeTypes,
|
||||
his.changeTime,
|
||||
IF
|
||||
( his.id IS NULL, FALSE, TRUE ) hasHis,
|
||||
TRUE AS flag,
|
||||
IF(state.stateId in ($states) OR state.stateId IS NULL ,TRUE,FALSE) apply,
|
||||
state.stateId,
|
||||
state.stateName,
|
||||
state.stateColor,
|
||||
IF(mcr.stateId = @changeUnitAuditing,TRUE,FALSE) changeUnitAuditing,
|
||||
IF(mcr.stateId = @changeUnitError,TRUE,FALSE) changeUnitError,
|
||||
mcr_state.stateId mcrStateId,
|
||||
mcr_state.stateName mcrStateName,
|
||||
mcr_state.stateColor mcrStateColor
|
||||
FROM
|
||||
`user` u
|
||||
LEFT JOIN user_history_latest his ON his.loginname = u.loginname
|
||||
LEFT JOIN welfare_member_apply_record_latest wmar ON wmar.userId = u.id
|
||||
LEFT JOIN member_change_record_latest mcr on mcr.userId = u.id
|
||||
LEFT JOIN audit_state state ON wmar.stateId = state.stateId
|
||||
LEFT JOIN audit_state mcr_state ON mcr_state.stateId = mcr.stateId
|
||||
$condition
|
||||
""")
|
||||
.setParam("recordMode", MemberChangeRecordMode.WELFARE_MEMBER.getCode())
|
||||
.setParam("changeUnitAuditing", MemberChangeApplyState.SCHOOL_UNION)
|
||||
.setParam("changeUnitError", MemberChangeApplyState.SCHOOL_UNION_FAIL);
|
||||
|
||||
sql.setVar("states", Joiner.on(",").join(List.of(WelfareMemberApplyState.SCHOOL_UNION_FAIL)));
|
||||
|
||||
MemberCheckTask checkTask = dao.fetch(MemberCheckTask.class, taskId);
|
||||
if (checkTask.getWelfareCheckFilterMode()==2){
|
||||
List<WelfareMemberCheckUser> checkUserList = dao.query(WelfareMemberCheckUser.class, Cnd.where("taskId", "=", taskId));
|
||||
List<String> userIds = checkUserList.stream().map(v -> v.getUserId()).collect(Collectors.toList());
|
||||
if (welfareMember==1){
|
||||
cnd.and("u.id", "in", userIds);
|
||||
}else if (welfareMember==2){
|
||||
cnd.and("u.id", "not in", userIds);
|
||||
}
|
||||
}else{
|
||||
if (welfareMember == 1) {
|
||||
cnd.and("u.welfareMember", "=", WelfareMemberMode.NORMAL.getCode());
|
||||
} else if (welfareMember == 2) {
|
||||
SqlExpressionGroup group = new SqlExpressionGroup();
|
||||
group.or("u.welfareMember", "=", null).or("u.welfareMember", "=", WelfareMemberMode.NONE.getCode());
|
||||
cnd.and(group);
|
||||
}
|
||||
}
|
||||
|
||||
pageForm.defaultSortDesc("wmar.applyTime");
|
||||
|
||||
|
||||
cnd.andEX("u.unionGroupId", "=", pageParam.getUnionGroupId());
|
||||
cnd.andEX("his.changeType", "=", changeType);
|
||||
|
||||
if (!ShiroUtil.hasAnyRoles("sysadmin,SchoolUnionAdmin,SchoolUnionMemberAdmin,SchoolUnionWelfareAdmin")) {
|
||||
if (ShiroUtil.hasAnyRoles("H04,gh12")) {
|
||||
cnd.and("u.unionId", "=", Vi.getUnionId());
|
||||
} else if (ShiroUtil.hasRole("ghxzzz")) {
|
||||
SqlExpressionGroup seg = new SqlExpressionGroup();
|
||||
seg.or("u.unionGroupId", "in", io.v.nutz.web.commons.utils.ShiroUtil.getUnionGroupIds());
|
||||
seg.or("u.unionGroupId", "is", null);
|
||||
cnd.and(seg);
|
||||
cnd.and("u.unionid", "=", Vi.getUnionId());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// cnd.and("mcr.recordMode", "=", MemberChangeRecordMode.WELFARE_MEMBER.getCode());
|
||||
if (changed != 0) {
|
||||
if (changed == 1) {
|
||||
cnd.and(new Static("his.loginname is not null"));
|
||||
} else {
|
||||
cnd.and(new Static("his.loginname is null"));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
WelfareFeature.Condition.judgmentAuthority(cnd, "u");
|
||||
pageParam.participate(cnd, "u");
|
||||
|
||||
cnd.and(pageForm);
|
||||
cnd.desc("his.changeTime");
|
||||
cnd.asc("u.userState");
|
||||
cnd.asc("u.unitid");
|
||||
cnd.asc("u.loginname");
|
||||
|
||||
if (org.nutz.lang.Lang.isNotEmpty(changeTypes)) {
|
||||
SqlExpressionGroup seg = new SqlExpressionGroup();
|
||||
for (Integer type : changeTypes) {
|
||||
seg.or(new Static("JSON_CONTAINS(his.changeTypes, CAST(%d AS JSON), '$')".formatted(type)));
|
||||
}
|
||||
cnd.and(seg);
|
||||
}
|
||||
|
||||
if (Lang.isNotEmpty(userStates)) {
|
||||
SqlExpressionGroup seg = new SqlExpressionGroup();
|
||||
for (String state : userStates) {
|
||||
seg.orEquals("u.userState", state);
|
||||
}
|
||||
cnd.and(seg);
|
||||
}
|
||||
|
||||
if (Lang.isNotEmpty(personTypes)) {
|
||||
SqlExpressionGroup seg = new SqlExpressionGroup();
|
||||
for (String personType : personTypes) {
|
||||
seg.orEquals("u.personType", personType);
|
||||
}
|
||||
cnd.and(seg);
|
||||
}
|
||||
|
||||
if (Lang.isNotEmpty(changeOrigins)) {
|
||||
SqlExpressionGroup seg = new SqlExpressionGroup();
|
||||
for (Integer c : changeOrigins) {
|
||||
seg.orEquals("u.changeOrigin", c);
|
||||
}
|
||||
cnd.and(seg);
|
||||
}
|
||||
|
||||
sql.setCondition(cnd);
|
||||
return simpleService.list(pageForm, sql);
|
||||
}
|
||||
|
||||
|
||||
@At
|
||||
@ViReturn
|
||||
@RequiresPermissions("welfare.member.check.union")
|
||||
public Object submitCheck(@Param(value = "taskId", required = false) String taskId,
|
||||
@Param(value = "welfareUnit", required = false) String welfareUnit) {
|
||||
// if (ShiroUtil.lacksRole("H04")) {
|
||||
// return Result.error("请使用分工会管理员来提交核对");
|
||||
// }
|
||||
Cnd cnd = Cnd.NEW();
|
||||
|
||||
cnd.andEX("unionId", "=", welfareUnit);
|
||||
cnd.and("taskId", "=", taskId);
|
||||
dao.update(MemberCheckUnionTask.class, Chain.make("isFinish", true), cnd);
|
||||
return null;
|
||||
}
|
||||
|
||||
@At
|
||||
@ViReturn
|
||||
@RequiresPermissions("welfare.member.check.union")
|
||||
public Object doSubmitChangeUser(MemberChangeRecord memberChangeRecord) {
|
||||
if (Objects.equals(memberChangeRecord.getType(), UserChangeType.NEW.getCode())) {
|
||||
return Result.error("您已经入职,可以选择恢复功能入会!");
|
||||
}
|
||||
if (Objects.equals(memberChangeRecord.getType(), UserChangeType.UNIT_CHANGE.getCode())) {
|
||||
boolean unionGroupEnable = Optional.ofNullable(dao.fetch(Sys_config.class, Cnd.where("configKey", "=", "isThreeUnit"))).map(v -> v.getConfigValue()).orElse("false").equals("true");
|
||||
|
||||
if (unionGroupEnable && memberChangeRecord.getCurrentThreeUnitId().equals(memberChangeRecord.getOriginThreeUnitId())) {
|
||||
return Result.error("请选择不同的单位!");
|
||||
} else if (!unionGroupEnable && memberChangeRecord.getCurrentUnitId().equals(memberChangeRecord.getOriginUnitId())) {
|
||||
return Result.error("请选择不同的单位!");
|
||||
}
|
||||
}
|
||||
if (!Objects.equals(memberChangeRecord.getType(), UserChangeType.UNIT_CHANGE.getCode())) {
|
||||
memberChangeRecord.setCurrentUnitId(null);
|
||||
memberChangeRecord.setCurrentUnionId(null);
|
||||
}
|
||||
|
||||
Sql userSql = Sqls.fetchString("select userState from sys_user where id = @userId");
|
||||
userSql.setParam("userId", memberChangeRecord.getUserId());
|
||||
dao.execute(userSql);
|
||||
String userState = StrUtil.blankToDefault(userSql.getString(), "");
|
||||
|
||||
if (memberChangeRecord.getType() == UserChangeType.WORK.getCode()) {
|
||||
if (userState.equals(UserChangeType.WORK.getDescription())) {
|
||||
return Result.error("该用户当前的状态已经是" + UserChangeType.WORK.getDescription() + ",您无需变更!");
|
||||
}
|
||||
}
|
||||
if (memberChangeRecord.getType() == UserChangeType.RESIGN.getCode()) {
|
||||
if (userState.equals(UserChangeType.RESIGN.getDescription())) {
|
||||
return Result.error("该用户当前的状态已经是" + UserChangeType.RESIGN.getDescription() + ",您无需变更!");
|
||||
}
|
||||
}
|
||||
if (memberChangeRecord.getType() == UserChangeType.RETIREMENT.getCode()) {
|
||||
if (userState.equals(UserChangeType.RETIREMENT.getDescription())) {
|
||||
return Result.error("该用户当前的状态已经是" + UserChangeType.RETIREMENT.getDescription() + ",您无需变更!");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
memberChangeRecord.setRecordMode(MemberChangeRecordMode.WELFARE_MEMBER.getCode());
|
||||
memberChangeRecord.setApplyOrigin(MemberChangeOrigin.UNION.getCode());
|
||||
memberChangeRecord = MemberChangeAuditHandle.CREATE.next(memberChangeRecord, null);
|
||||
|
||||
Audit audit = new Audit();
|
||||
audit.setAuditPass(true);
|
||||
audit.setAuditOpinion(memberChangeRecord.getRemark());
|
||||
|
||||
MemberChangeAuditHandle.UNION.next(memberChangeRecord, audit);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@At
|
||||
@ViReturn
|
||||
@RequiresPermissions("welfare.member.check.union")
|
||||
public Object getUnionTaskStatus(@Param(value = "taskId", required = false) String taskId,
|
||||
@Param(value = "welfareUnit", required = false) String welfareUnit) {
|
||||
Cnd cnd = Cnd.NEW();
|
||||
cnd.andEX("unionId", "=", welfareUnit);
|
||||
cnd.and("taskId", "=", taskId);
|
||||
MemberCheckUnionTask unionTask = dao.fetch(MemberCheckUnionTask.class, cnd);
|
||||
return unionTask != null && unionTask.getIsFinish();
|
||||
}
|
||||
|
||||
@At
|
||||
@ViReturn
|
||||
@RequiresPermissions("welfare.member.check.union")
|
||||
public Object checkAgain(@Param(value = "taskId", required = false) String taskId,
|
||||
@Param(value = "welfareUnit", required = false) String welfareUnit) {
|
||||
Cnd cnd = Cnd.NEW();
|
||||
|
||||
cnd.andEX("unionId", "=", welfareUnit);
|
||||
cnd.and("taskId", "=", taskId);
|
||||
dao.update(MemberCheckUnionTask.class, Chain.make("isFinish", false), cnd);
|
||||
return null;
|
||||
}
|
||||
|
||||
@At
|
||||
@ViReturn
|
||||
@RequiresPermissions("welfare.member.check.union")
|
||||
public Object doWelfareMember(String[] userIds, String taskId,
|
||||
@Param(value = "threeUnitId", required = false) String threeUnitId,
|
||||
@Param(value = "unitId", required = false) String unitId) {
|
||||
/* if (ShiroUtil.hasAnyRoles("sysadmin,SchoolUnionAdmin,SchoolUnionMemberAdmin,SchoolUnionWelfareAdmin")) {
|
||||
WelfareMemberMode.joinWelfareMember(Arrays.stream(userIds).collect(Collectors.toList()));
|
||||
return null;
|
||||
}*/
|
||||
List<MemberChangeRecord> maps = new ArrayList<>();
|
||||
Audit audit = new Audit();
|
||||
audit.setAuditor(ShiroUtil.getUserId());
|
||||
audit.setAuditPass(true);
|
||||
audit.setAuditTime(new Date());
|
||||
audit.setAuditOpinion(UserChangeType.NEW_WELFARE_LIST.getDescription());
|
||||
audit.setUsername(ShiroUtil.getPrincipalProperty("username").toString());
|
||||
audit.setLoginname(ShiroUtil.getPrincipalProperty("loginname").toString());
|
||||
dao.insert(audit);
|
||||
List<User> userList = dao.query(User.class, Cnd.where("id", "in", userIds));
|
||||
List<WelfareMemberCheckUser> checkUserArrayList = new ArrayList<>();
|
||||
for (String userId : userIds) {
|
||||
|
||||
User user = userList.stream().filter(u -> u.getId().equals(userId)).findFirst().orElse(null);
|
||||
MemberChangeRecord changeRecord = new MemberChangeRecord();
|
||||
changeRecord.setType(UserChangeType.NEW_WELFARE_LIST.getCode());
|
||||
changeRecord.setRemark(UserChangeType.NEW_WELFARE_LIST.getDescription());
|
||||
changeRecord.setApplyOrigin(MemberChangeOrigin.UNION.getCode());
|
||||
changeRecord.setStateId(MemberChangeApplyState.SCHOOL_UNION);
|
||||
changeRecord.setUpdateWelfareMember(true);
|
||||
changeRecord.setUserId(userId);
|
||||
changeRecord.setApplyTime(new Date());
|
||||
changeRecord.setOriginUnitId(user.getUnitid());
|
||||
changeRecord.setOriginUnionId(user.getUnionid());
|
||||
changeRecord.setOriginThreeUnitId(user.getThreeUnitId());
|
||||
changeRecord.setCurrentUnionId(user.getUnionid());
|
||||
changeRecord.setCurrentUnitId(unitId);
|
||||
changeRecord.setCurrentThreeUnitId(threeUnitId);
|
||||
changeRecord.setUnionAuditId(audit.getId());
|
||||
changeRecord.setRecordMode(MemberChangeRecordMode.WELFARE_MEMBER.getCode());
|
||||
changeRecord.setTaskId(taskId);
|
||||
// maps.add(changeRecord);
|
||||
changeRecord.setRecordMode(MemberChangeRecordMode.WELFARE_MEMBER.getCode());
|
||||
changeRecord.setApplyOrigin(MemberChangeOrigin.UNION.getCode());
|
||||
changeRecord = MemberChangeAuditHandle.CREATE.next(changeRecord, null);
|
||||
MemberChangeAuditHandle.UNION.next(changeRecord, audit);
|
||||
|
||||
WelfareMemberCheckUser checkUser = new WelfareMemberCheckUser();
|
||||
checkUser.setUserId(userId);
|
||||
checkUser.setTaskId(taskId);
|
||||
checkUser.setUnitId(user.getUnitid());
|
||||
checkUser.setUnionId(user.getUnionid());
|
||||
checkUser.setUserState(user.getUserState());
|
||||
checkUser.setPersonType(user.getPersonType());
|
||||
checkUserArrayList.add(checkUser);
|
||||
|
||||
}
|
||||
// dao.insert(maps);
|
||||
dao.insert(checkUserArrayList);
|
||||
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@At
|
||||
@Ok("void")
|
||||
@RequiresPermissions("welfare.member.check.union")
|
||||
public void doWelfareMemberExport(@Param(value = "welfareUnit", required = false) String welfareUnit,
|
||||
@Param(value = "unit", required = false) String unit,
|
||||
@Param(value = "unionGroupId", required = false) String unionGroupId,
|
||||
@Param(value = "threeUnitId", required = false) String threeUnitId, HttpServletResponse response) {
|
||||
|
||||
Sql sql = Sqls.create("""
|
||||
select * from `user` $condition
|
||||
""");
|
||||
Cnd cnd = Cnd.NEW();
|
||||
cnd.andEX("welfareMember", "=", 1);
|
||||
cnd.andEX("unionId", "=", welfareUnit);
|
||||
cnd.andEX("unitId", "=", unit);
|
||||
cnd.asc("loginname");
|
||||
sql.setCondition(cnd);
|
||||
List<NutMap> map = simpleService.listMap(sql);
|
||||
|
||||
List<ExcelExportEntity> excelExportEntities = new ArrayList<ExcelExportEntity>();
|
||||
|
||||
excelExportEntities.add(new ExcelExportEntity("工号", "loginname", 20));
|
||||
excelExportEntities.add(new ExcelExportEntity("姓名", "username", 20));
|
||||
excelExportEntities.add(new ExcelExportEntity("在职状态", "userState", 20));
|
||||
excelExportEntities.add(new ExcelExportEntity("所属工会", "unionname", 20));
|
||||
excelExportEntities.add(new ExcelExportEntity("所属单位", "unitname", 50));
|
||||
|
||||
try {
|
||||
ViTool.excelResponse(response, "福利名单.xlsx");
|
||||
ExportParams exportParams = new ExportParams();
|
||||
exportParams.setType(ExcelType.XSSF);
|
||||
Workbook workbook = ExcelExportUtil.exportExcel(exportParams, excelExportEntities, map);
|
||||
workbook.write(response.getOutputStream());
|
||||
} catch (Exception e) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
+877
@@ -0,0 +1,877 @@
|
||||
package io.v.nutz.zhgh.welfare.controller.statistics;
|
||||
|
||||
import cn.afterturn.easypoi.excel.ExcelExportUtil;
|
||||
import cn.afterturn.easypoi.excel.annotation.Excel;
|
||||
import cn.afterturn.easypoi.excel.entity.ExportParams;
|
||||
import cn.afterturn.easypoi.excel.entity.TemplateExportParams;
|
||||
import cn.afterturn.easypoi.excel.entity.enmus.ExcelType;
|
||||
import cn.afterturn.easypoi.excel.entity.params.ExcelExportEntity;
|
||||
import cn.afterturn.easypoi.excel.export.ExcelExportService;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import io.v.nutz.base.annontation.ViReturn;
|
||||
import io.v.nutz.base.utils.MsgApi;
|
||||
import io.v.nutz.base.utils.OfficeTemplateUtil;
|
||||
import io.v.nutz.base.utils.Vi;
|
||||
import io.v.nutz.base.utils.ViTool;
|
||||
import io.v.nutz.sys.models.SysUnionGroup;
|
||||
import io.v.nutz.sys.models.Sys_union;
|
||||
import io.v.nutz.sys.models.Sys_unit;
|
||||
import io.v.nutz.web.commons.base.Globals;
|
||||
import io.v.nutz.web.commons.utils.ShiroUtil;
|
||||
import io.v.nutz.zhgh.welfare.mode.WelfareUnitMode;
|
||||
import io.v.nutz.zhgh.welfare.model.*;
|
||||
import io.v.nutz.zhgh.welfare.service.WelfareSingleService;
|
||||
import lombok.Data;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
||||
import org.apache.poi.ss.usermodel.Workbook;
|
||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||
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.Dao;
|
||||
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.lang.util.NutMap;
|
||||
import org.nutz.mvc.annotation.At;
|
||||
import org.nutz.mvc.annotation.Ok;
|
||||
import org.nutz.mvc.annotation.Param;
|
||||
|
||||
import javax.servlet.ServletOutputStream;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipOutputStream;
|
||||
|
||||
/**
|
||||
* @author zxy
|
||||
* @Description 意向选择 邮寄到家类的统计
|
||||
* @createTime 2022年01月25日 13:51:00
|
||||
*/
|
||||
@IocBean
|
||||
@At("/platform/welfare/project/statistics/single")
|
||||
@Slf4j
|
||||
public class WelfareSingleController {
|
||||
|
||||
@Inject
|
||||
private WelfareSingleService welfareSingleService;
|
||||
|
||||
@Inject
|
||||
private MsgApi msgApi;
|
||||
|
||||
@Inject
|
||||
private Dao dao;
|
||||
@Inject
|
||||
private OfficeTemplateUtil officeTemplateUtil;
|
||||
|
||||
@At("")
|
||||
@Ok("beetl:/platform/welfare/statistics/single.html")
|
||||
@RequiresPermissions("welfare.project.statistics.single")
|
||||
public void index() {
|
||||
}
|
||||
|
||||
/**
|
||||
* 表格数据
|
||||
*
|
||||
* @param projectId
|
||||
* @return
|
||||
*/
|
||||
@At
|
||||
@ViReturn
|
||||
@Ok("json")
|
||||
@RequiresPermissions("welfare.project.statistics.single")
|
||||
public Object pageData(@Param(value = "projectId", required = false) String projectId,
|
||||
@Param(value = "month", required = false) String month,
|
||||
@Param(value = "welfareUnitCode", required = false) String welfareUnitCode,
|
||||
@Param(value = "unionGroupId", required = false) String unionGroupId,
|
||||
@Param(value = "personType", required = false) String personType
|
||||
) {
|
||||
return welfareSingleService.pageData(projectId, month, welfareUnitCode, unionGroupId, personType);
|
||||
}
|
||||
|
||||
/**
|
||||
* 福利数据
|
||||
*
|
||||
* @param year
|
||||
* @return
|
||||
*/
|
||||
@At
|
||||
@ViReturn
|
||||
@Ok("json")
|
||||
@RequiresPermissions("welfare.project.statistics.single")
|
||||
public Object welfareProjectList(Integer year) {
|
||||
return welfareSingleService.welfareProjectList(year);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param projectId
|
||||
* @param welfareUnitCode
|
||||
* @author zhf
|
||||
* @description 按单位导出
|
||||
*/
|
||||
@At
|
||||
@Ok("void")
|
||||
@RequiresPermissions("welfare.project.statistics.single")
|
||||
public void exportByUnit(String projectId, @Param(value = "welfareUnitCode", required = false) String welfareUnitCode, HttpServletResponse response) {
|
||||
String title = "统计名单";
|
||||
NutMap dataMap = welfareSingleService.exportByUnit(projectId, welfareUnitCode);
|
||||
List<ExcelExportEntity> entityList = new ArrayList<>();
|
||||
List<NutMap> labelList = dataMap.getAsList("tableColumn", NutMap.class);
|
||||
List<NutMap> list = dataMap.getAsList("tableList", NutMap.class);
|
||||
|
||||
NutMap map = NutMap.NEW().setv("name", "合计");
|
||||
labelList.forEach(o -> {
|
||||
List<Integer> numList = list.stream().map(v -> v.getInt(o.getString("prop"))).collect(Collectors.toList());
|
||||
int sum = numList.stream().mapToInt(Integer::intValue).sum();
|
||||
map.setv(o.getString("prop"), sum);
|
||||
});
|
||||
list.add(map);
|
||||
|
||||
labelList.add(0, NutMap.NEW().addv("label", "单位").addv("prop", "name"));
|
||||
labelList.add(1, NutMap.NEW().addv("label", "单位编码").addv("prop", "unitcode"));
|
||||
labelList.forEach(v -> {
|
||||
entityList.add(new ExcelExportEntity(v.getString("label"), v.getString("prop"), 40));
|
||||
});
|
||||
|
||||
try {
|
||||
ViTool.excelResponse(response, "汇总表.xls");
|
||||
Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams(title, ""), entityList, list);
|
||||
workbook.write(response.getOutputStream());
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* /**
|
||||
*
|
||||
* @param projectId
|
||||
* @param welfareUnitCode
|
||||
* @author zhf
|
||||
* @description 按工会小组导出
|
||||
*/
|
||||
@At
|
||||
@Ok("void")
|
||||
@RequiresPermissions("welfare.project.statistics.single")
|
||||
public void exportByUnionGroup(String projectId, @Param(value = "welfareUnitCode", required = false) String welfareUnitCode, HttpServletResponse response) {
|
||||
String title = "统计名单";
|
||||
NutMap dataMap = welfareSingleService.exportByUnionGroup(projectId, welfareUnitCode);
|
||||
List<ExcelExportEntity> entityList = new ArrayList<>();
|
||||
List<NutMap> labelList = dataMap.getAsList("tableColumn", NutMap.class);
|
||||
List<NutMap> list = dataMap.getAsList("tableList", NutMap.class);
|
||||
|
||||
NutMap map = NutMap.NEW().setv("name", "合计");
|
||||
labelList.forEach(o -> {
|
||||
List<Integer> numList = list.stream().map(v -> v.getInt(o.getString("prop"))).collect(Collectors.toList());
|
||||
int sum = numList.stream().mapToInt(Integer::intValue).sum();
|
||||
map.setv(o.getString("prop"), sum);
|
||||
});
|
||||
list.add(map);
|
||||
|
||||
labelList.add(0, NutMap.NEW().addv("label", "工会小组").addv("prop", "groupName"));
|
||||
labelList.add(1, NutMap.NEW().addv("label", "工会小组编码").addv("prop", "groupCode"));
|
||||
labelList.forEach(v -> {
|
||||
entityList.add(new ExcelExportEntity(v.getString("label"), v.getString("prop"), 40));
|
||||
});
|
||||
|
||||
try {
|
||||
ViTool.excelResponse(response, "汇总表.xls");
|
||||
Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams(title, ""), entityList, list);
|
||||
workbook.write(response.getOutputStream());
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 按基层工会导出
|
||||
*
|
||||
* @param projectId
|
||||
* @param welfareUnitCode
|
||||
*/
|
||||
@At
|
||||
@Ok("void")
|
||||
@RequiresPermissions("welfare.project.statistics.single")
|
||||
public void exportByUnion(String projectId,
|
||||
@Param(value = "welfareUnitCode", required = false) String welfareUnitCode,
|
||||
@Param(value = "month", required = false) String month,
|
||||
@Param(value = "unionGroupId", required = false) String unionGroupId,
|
||||
@Param(value = "isThreeUnit", required = false) Boolean isThreeUnit,
|
||||
@Param(value = "personType", required = false) String personType,
|
||||
HttpServletResponse response) {
|
||||
WelfareProject project = dao.fetch(WelfareProject.class, projectId);
|
||||
WelfareProjectSubject subject = dao.fetch(WelfareProjectSubject.class, Cnd.where("projectId", "=", projectId));
|
||||
List<WelfareProjectSubjectOption> subjectOptions = dao.query(WelfareProjectSubjectOption.class, Cnd.where("subjectId", "=", subject.getId()).asc("optionSort"));
|
||||
|
||||
List<WelfareList> welfareLists = dao.query(WelfareList.class, Cnd.where("projectId", "=", projectId));
|
||||
|
||||
HashMap<String, Object> data = new HashMap<>();
|
||||
data.put("projectName", project.getName());
|
||||
data.put("personType", personType);
|
||||
|
||||
List<NutMap> titles = subjectOptions.stream().map(o -> {
|
||||
NutMap nutMap = NutMap.NEW();
|
||||
nutMap.put("optionName", o.getOptionName());
|
||||
nutMap.put("val", "t." + o.getOptionName());
|
||||
return nutMap;
|
||||
}).collect(Collectors.toList());
|
||||
data.put("titles", titles);
|
||||
|
||||
List<HashMap<String, Object>> datas = new ArrayList<>();
|
||||
|
||||
Sql sql = Sqls.create("""
|
||||
SELECT
|
||||
t1.selectOptionId,
|
||||
t1.selectNum,
|
||||
t2.welfareUnitId,
|
||||
t3.unionname,
|
||||
t2.personType
|
||||
FROM
|
||||
`welfare_project_user_selection` t1
|
||||
LEFT JOIN welfare_list t2 ON t2.userId = t1.selectUserId
|
||||
AND t2.projectId = t1.welfareId
|
||||
LEFT JOIN sys_union t3 ON t3.id = t2.welfareUnitId
|
||||
$condition
|
||||
""");
|
||||
Cnd cnd = Cnd.NEW();
|
||||
cnd.and("t1.welfareId", "=", projectId);
|
||||
cnd.groupBy("t1.id");
|
||||
if (Objects.equals("在职人员", personType)) {
|
||||
cnd.and("t2.personType", "is not", null);
|
||||
cnd.and("t2.personType", "!=", "");
|
||||
cnd.and("t2.personType", "!=", "劳务人才派遣");
|
||||
cnd.and("t2.personType", "!=", "其他类");
|
||||
} else if (Objects.equals("劳务派遣人员", personType)) {
|
||||
cnd.and("t2.personType", "in", List.of("劳务人才派遣", "其他类"));
|
||||
} else if (Objects.equals("空状态", personType)) {
|
||||
SqlExpressionGroup seg = new SqlExpressionGroup();
|
||||
seg.or("t2.personType", "=", "");
|
||||
seg.orIsNull("t2.personType");
|
||||
cnd.and(seg);
|
||||
}
|
||||
sql.setCondition(cnd);
|
||||
List<NutMap> list = welfareSingleService.listMap(sql);
|
||||
|
||||
Map<String, List<NutMap>> welfareUnitGroups = list.stream().collect(Collectors.groupingBy(v -> v.getString("unionname")));
|
||||
|
||||
welfareUnitGroups.forEach((welfareUnitName, welfareUnitList) -> {
|
||||
NutMap welfareUnitMap = NutMap.NEW();
|
||||
welfareUnitMap.addv("name", welfareUnitName);
|
||||
for (int i = 0; i < subjectOptions.size(); i++) {
|
||||
int finalI = i;
|
||||
int sum = welfareUnitList.stream().filter(v -> v.getString("selectOptionId").equals(subjectOptions.get(finalI).getId())).mapToInt(x -> x.getInt("selectNum")).sum();
|
||||
welfareUnitMap.put(subjectOptions.get(finalI).getOptionName(), sum);
|
||||
}
|
||||
welfareUnitMap.addv("total", welfareUnitList.stream().mapToInt(x -> x.getInt("selectNum")).sum());
|
||||
|
||||
String welfareUnitId = welfareUnitList.stream().findFirst().map(v -> v.getString("welfareUnitId")).orElse(null);
|
||||
|
||||
long welfareMemberCount = welfareLists.size();
|
||||
|
||||
if (Objects.equals("在职人员", personType)) {
|
||||
welfareMemberCount = welfareLists.stream().filter(v -> Objects.equals(v.getWelfareUnitId(), welfareUnitId)
|
||||
&& !Objects.equals(v.getPersonType(), "劳务人才派遣") && !Objects.equals(v.getPersonType(), "其他类")).count();
|
||||
} else if (Objects.equals("劳务派遣人员", personType)) {
|
||||
welfareMemberCount = welfareLists.stream().filter(v -> Objects.equals(v.getWelfareUnitId(), welfareUnitId)
|
||||
&& (Objects.equals(v.getPersonType(), "劳务人才派遣") || Objects.equals(v.getPersonType(), "其他类"))).count();
|
||||
} else if (Objects.equals("空状态", personType)) {
|
||||
welfareMemberCount = welfareLists.stream().filter(v -> Objects.equals(v.getWelfareUnitId(), welfareUnitId)
|
||||
&& StrUtil.isBlank(v.getPersonType())).count();
|
||||
}else if(Objects.equals("全部",personType)){
|
||||
welfareMemberCount = welfareLists.stream().filter(v -> Objects.equals(v.getWelfareUnitId(), welfareUnitId)).count();
|
||||
}
|
||||
welfareUnitMap.addv("welfareMemberCount", welfareMemberCount);
|
||||
datas.add(welfareUnitMap);
|
||||
});
|
||||
data.put("data", datas);
|
||||
|
||||
|
||||
try {
|
||||
ViTool.excelResponse(response, personType + "发放清单.xlsx");
|
||||
TemplateExportParams templateExportParams = new TemplateExportParams();
|
||||
//开启横向遍历
|
||||
templateExportParams.setColForEach(true);
|
||||
templateExportParams.setTemplateUrl("E:\\env\\福利导出模板.xlsx");
|
||||
Workbook workbook = ExcelExportUtil.exportExcel(templateExportParams, data);
|
||||
workbook.write(response.getOutputStream());
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
|
||||
// String title = "统计名单";
|
||||
// if (StrUtil.isNotBlank(welfareUnitCode)) {
|
||||
// switch (WelfareUnitMode.getMode().name()) {
|
||||
// case "UNION" -> {
|
||||
// Sys_union sysUnion = dao.fetch(Sys_union.class, Cnd.where("unioncode", "=", welfareUnitCode));
|
||||
// title = (Lang.isNotEmpty(sysUnion) ? sysUnion.getUnionname() : "") + "统计名单";
|
||||
// }
|
||||
// case "UNIT" -> {
|
||||
// Sys_unit sysUnit = dao.fetch(Sys_unit.class, Cnd.where("unitcode", "=", welfareUnitCode));
|
||||
// title = (Lang.isNotEmpty(sysUnit) ? sysUnit.getName() : "") + "统计名单";
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// }
|
||||
|
||||
// NutMap dataMap = welfareSingleService.pageData(projectId, month, welfareUnitCode, unionGroupId,personType);
|
||||
// List<ExcelExportEntity> entityList = new ArrayList<>();
|
||||
// List<NutMap> labelList = dataMap.getAsList("tableColumn", NutMap.class);
|
||||
// List<NutMap> list = dataMap.getAsList("tableList", NutMap.class);
|
||||
|
||||
// NutMap map = NutMap.NEW().setv("welfareUnitName", "合计");
|
||||
// labelList.forEach(o -> {
|
||||
// List<Integer> numList = list.stream().map(v -> v.getInt(o.getString("prop"))).collect(Collectors.toList());
|
||||
// int sum = numList.stream().mapToInt(Integer::intValue).sum();
|
||||
// map.setv(o.getString("prop"), sum);
|
||||
// });
|
||||
// list.add(map);
|
||||
//
|
||||
// labelList.add(0, NutMap.NEW().addv("label", "福利单位").addv("prop", "welfareUnitName"));
|
||||
// labelList.add(1, NutMap.NEW().addv("label", "福利单位编码").addv("prop", "welfareUnitCode"));
|
||||
// labelList.forEach(v -> {
|
||||
// entityList.add(new ExcelExportEntity(v.getString("label"), v.getString("prop"), 20));
|
||||
// });
|
||||
//
|
||||
//
|
||||
// try {
|
||||
// ViTool.excelResponse(response, "汇总表.xls");
|
||||
// Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams(title, ""), entityList, list);
|
||||
// workbook.write(response.getOutputStream());
|
||||
// } catch (IOException e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 每个分工会领取人员
|
||||
*
|
||||
* @param projectId
|
||||
* @param welfareUnitCode
|
||||
* @return
|
||||
*/
|
||||
@At
|
||||
@ViReturn
|
||||
@Ok("json:full")
|
||||
@RequiresPermissions("welfare.project.statistics.single")
|
||||
public Object receivePageData(@Param(value = "projectId", required = false) String projectId,
|
||||
@Param(value = "welfareUnitCode", required = false) String welfareUnitCode,
|
||||
@Param(value = "month", required = false) String month,
|
||||
@Param(value = "unionGroupId", required = false) String unionGroupId,
|
||||
@Param(value = "pageNumber", required = false) Integer pageNumber,
|
||||
@Param(value = "pageSize", required = false) Integer pageSize) {
|
||||
Sql sql = Sqls.create("""
|
||||
SELECT
|
||||
u.loginname AS loginName,
|
||||
u.username AS userName,
|
||||
u.unitname AS unitName,
|
||||
u.threeUnitName AS threeUnitName,
|
||||
u.unionname AS unionName,
|
||||
u.idcard AS idCard,
|
||||
u.mobile,
|
||||
IF(LOCATE('undefined',wpus.receiveAddress)>0,NULL,wpus.receiveAddress) as receiveAddress,
|
||||
GROUP_CONCAT(DISTINCT wpso.optionName ,'(',wpus.selectNum,'份)') optionName,
|
||||
wpus.courierNumber
|
||||
FROM
|
||||
welfare_project_user_selection wpus
|
||||
LEFT JOIN `user` u ON u.id = wpus.selectUserId
|
||||
LEFT JOIN welfare_project_subject_option wpso ON wpso.id = wpus.selectOptionId
|
||||
$condition
|
||||
$monthCnd
|
||||
$notGroupIdCnd
|
||||
""").setParam("welfareId", projectId);
|
||||
Cnd cnd = Cnd.NEW();
|
||||
if (Globals.MyConfig.getBoolean("isThreeUnit")) {
|
||||
sql.setVar("notGroupIdCnd", "and u.unionGroupId is not null");
|
||||
}
|
||||
cnd.andEX("u.unionGroupId", "=", unionGroupId);
|
||||
if (Strings.isNotBlank(month)) {
|
||||
cnd.andEX("SUBSTR(u.birthday,6,2)", "=", month.substring(5, 7));
|
||||
}
|
||||
cnd.groupBy("u.loginname");
|
||||
switch (WelfareUnitMode.getMode().name()) {
|
||||
case "UNION" -> {
|
||||
cnd.andEX("u.unioncode", "=", welfareUnitCode);
|
||||
cnd.asc("u.unioncode");
|
||||
}
|
||||
case "UNIT" -> {
|
||||
cnd.andEX("u.unitcode", "=", welfareUnitCode);
|
||||
cnd.asc("u.unitcode");
|
||||
}
|
||||
}
|
||||
cnd.and("wpus.welfareId", "=", projectId);
|
||||
cnd.desc("u.loginname");
|
||||
cnd.desc("u.threeUnitName");
|
||||
cnd.desc("wpus.selectOptionId");
|
||||
sql.setCondition(cnd);
|
||||
return welfareSingleService.listPageMap(pageNumber, pageSize, sql);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 导出已选名单
|
||||
*
|
||||
* @param projectId
|
||||
* @param welfareUnitCode 空->导出全部
|
||||
*/
|
||||
@At
|
||||
@Ok("void")
|
||||
@RequiresPermissions("welfare.project.statistics.single")
|
||||
public void exportReceiveDetail(@Param(value = "projectId", required = false) String projectId,
|
||||
@Param(value = "welfareUnitCode", required = false) String welfareUnitCode, boolean flag, HttpServletResponse response) {
|
||||
welfareSingleService.exportReceiveDetailList(projectId, welfareUnitCode, flag, response);
|
||||
}
|
||||
|
||||
@At
|
||||
@Ok("void")
|
||||
@RequiresPermissions("welfare.project.statistics.single")
|
||||
public void allShopExport(@Param(value = "projectId", required = false) String projectId,
|
||||
@Param(value = "month", required = false) String month, HttpServletResponse response) throws Exception {
|
||||
WelfareProject project = welfareSingleService.dao().fetch(WelfareProject.class, projectId);
|
||||
response.setContentType("application/octet-stream");
|
||||
response.setHeader("content-disposition", "attachment;filename="
|
||||
+ URLEncoder.encode(project.getName() + "按商品导出.zip", "UTF-8"));
|
||||
|
||||
List<Sys_union> unions = welfareSingleService.dao().query(Sys_union.class, Cnd.NEW().asc("unioncode"));
|
||||
|
||||
|
||||
try {
|
||||
ZipOutputStream zipOutputStream = new ZipOutputStream(new BufferedOutputStream(response.getOutputStream()));
|
||||
|
||||
for (Sys_union union : unions) {
|
||||
String name = union.getUnionname().replaceAll("/", "、") + project.getName();
|
||||
if (Strings.isNotBlank(month)) {
|
||||
name = union.getUnionname().replaceAll("/", "、") + month + "生日蛋糕券";
|
||||
}
|
||||
String fileName = name + "签收表.xlsx";
|
||||
zipOutputStream.putNextEntry(new ZipEntry(fileName));
|
||||
welfareSingleService.oneShopExport(projectId, month, union.getId(), zipOutputStream);
|
||||
zipOutputStream.closeEntry();
|
||||
response.flushBuffer();
|
||||
}
|
||||
|
||||
zipOutputStream.flush();
|
||||
zipOutputStream.close();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 按商品导出
|
||||
*
|
||||
* @param projectId
|
||||
* @param response
|
||||
* @throws Exception
|
||||
*/
|
||||
@At
|
||||
@Ok("void")
|
||||
@RequiresPermissions("welfare.project.statistics.single")
|
||||
public void shopExport(@Param(value = "projectId", required = false) String projectId,
|
||||
@Param(value = "month", required = false) String month,
|
||||
@Param(value = "welfareUnitId", required = false) String welfareUnitId, HttpServletResponse response) throws Exception {
|
||||
|
||||
WelfareProject welfareProject = welfareSingleService.dao().fetch(WelfareProject.class, projectId);
|
||||
Sys_union sysUnion = dao.fetch(Sys_union.class, Cnd.where("id", "=", welfareUnitId));
|
||||
String name = sysUnion.getUnionname().replaceAll("/", "、") + welfareProject.getName();
|
||||
if (Strings.isNotBlank(month)) {
|
||||
name = sysUnion.getUnionname().replaceAll("/", "、") + month + "生日蛋糕券";
|
||||
}
|
||||
try {
|
||||
welfareSingleService.oneShopExport(projectId, month, welfareUnitId, response.getOutputStream());
|
||||
ViTool.excelResponse(response, name + "签收表.xlsx");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@At
|
||||
@ViReturn
|
||||
@RequiresPermissions("welfare.project.statistics.single")
|
||||
public Object sendMsg(String projectId) {
|
||||
List<NutMap> list = welfareSingleService.unclaimedData(projectId, "", "");
|
||||
|
||||
List<String> mobileList = new ArrayList<>();
|
||||
List<NutMap> contents = new ArrayList<>();
|
||||
list.forEach(v -> {
|
||||
mobileList.add(v.getString("mobile"));
|
||||
contents.add(NutMap.NEW().addv("username", v.getString("userName")));
|
||||
contents.add(NutMap.NEW().addv("msgContent", ""));
|
||||
});
|
||||
// msgApi.sendMsg(null, null, null, null);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 某个项目某一分工会未领取人员
|
||||
*
|
||||
* @param projectId
|
||||
* @param welfareUnitCode
|
||||
* @return
|
||||
*/
|
||||
@At
|
||||
@ViReturn
|
||||
@Ok("json")
|
||||
@RequiresPermissions("welfare.project.statistics.single")
|
||||
public Object unclaimedData(@Param(value = "projectId", required = false) String projectId,
|
||||
@Param(value = "welfareUnitCode", required = false) String welfareUnitCode,
|
||||
@Param(value = "month", required = false) String month,
|
||||
@Param(value = "unionGroupId", required = false) String unionGroupId,
|
||||
@Param(value = "pageNumber", required = false) Integer pageNumber,
|
||||
@Param(value = "pageSize", required = false) Integer pageSize) {
|
||||
Sql sql = Sqls.create("""
|
||||
SELECT
|
||||
id,
|
||||
loginname loginName,
|
||||
username userName,
|
||||
unitname unitName,
|
||||
unionname unionName,
|
||||
idcard idCard,
|
||||
mobile
|
||||
FROM
|
||||
view_welfare_list
|
||||
WHERE
|
||||
projectId = @projectId
|
||||
AND id NOT IN
|
||||
(
|
||||
SELECT selectUserId FROM welfare_project_user_selection WHERE welfareId = @projectId AND selectUserId IS NOT NULL
|
||||
)
|
||||
$modeCnd
|
||||
$monthCnd
|
||||
$unionGroupIdCnd
|
||||
$notGroupIdCnd
|
||||
ORDER BY loginname
|
||||
""");
|
||||
if (Strings.isNotBlank(welfareUnitCode)) {
|
||||
if ("UNION".equals(WelfareUnitMode.getMode().name())) {
|
||||
sql.setVar("modeCnd", "AND unioncode = '%s'".formatted(welfareUnitCode));
|
||||
} else if ("UNIT".equals(WelfareUnitMode.getMode().name())) {
|
||||
sql.setVar("modeCnd", "AND unitcode = '%s'".formatted(welfareUnitCode));
|
||||
}
|
||||
}
|
||||
if (Strings.isNotBlank(month)) {
|
||||
sql.setVar("monthCnd", "and SUBSTR(birthday,6,2) = '%s'".formatted(month.substring(5, 7)));
|
||||
}
|
||||
if (Strings.isNotBlank(unionGroupId)) {
|
||||
sql.setVar("unionGroupIdCnd", "and unionGroupId = '%s'".formatted(unionGroupId));
|
||||
}
|
||||
if (Globals.MyConfig.getBoolean("isThreeUnit")) {
|
||||
sql.setVar("notGroupIdCnd", "and unionGroupId is not null");
|
||||
}
|
||||
sql.setParam("projectId", projectId);
|
||||
return welfareSingleService.listPageMap(pageNumber, pageSize, sql);
|
||||
}
|
||||
|
||||
@At
|
||||
@ViReturn
|
||||
@Ok("json")
|
||||
@RequiresPermissions("welfare.project.statistics.single")
|
||||
public Object unionGroupPageData(String projectId, String month, String unionId, String unionGroupId) {
|
||||
//找出这个工会下的工会小组
|
||||
List<SysUnionGroup> unionGroups = welfareSingleService.dao().query(SysUnionGroup.class, Cnd.where("unionId", "=", unionId).andEX("id", "=", unionGroupId).asc("groupCode"));
|
||||
List<NutMap> unionGroupMap = unionGroups.stream().map(v -> {
|
||||
NutMap nutMap = new NutMap();
|
||||
nutMap.setv("id", v.getId());
|
||||
nutMap.setv("unionId", v.getUnionId());
|
||||
nutMap.setv("GroupName", v.getGroupName());
|
||||
return nutMap;
|
||||
}).collect(Collectors.toList());
|
||||
|
||||
//找出这个福利所有的人
|
||||
Cnd cndFlUser = Cnd.NEW();
|
||||
Sql sqlFlUser = Sqls.create("""
|
||||
SELECT
|
||||
unionGroupId
|
||||
FROM
|
||||
`view_welfare_list`
|
||||
$condition
|
||||
""");
|
||||
cndFlUser.andEX("projectId", "=", projectId);
|
||||
if (Strings.isNotBlank(month)) {
|
||||
cndFlUser.andEX("SUBSTR(birthday,6,2)", "=", month.substring(5, 7));
|
||||
}
|
||||
cndFlUser.and("unionGroupId", "is not", null);
|
||||
cndFlUser.andEX("unionId", "=", unionId);
|
||||
sqlFlUser.setCondition(cndFlUser);
|
||||
List<NutMap> flUserList = welfareSingleService.listMap(sqlFlUser);
|
||||
|
||||
|
||||
//这个福利已选择了的福利会员
|
||||
Sql sqlYxzUser = Sqls.create("""
|
||||
SELECT
|
||||
wpus.selectOptionId,
|
||||
wpus.welfareId,
|
||||
wpus.selectUserId,
|
||||
u.unionid AS unionId,
|
||||
u.unioncode AS unionCode,
|
||||
u.unitcode AS unitCode,
|
||||
u.unionGroupId
|
||||
FROM
|
||||
`welfare_project_user_selection` wpus
|
||||
LEFT JOIN `user` u ON u.id = wpus.selectUserId
|
||||
$condition
|
||||
""");
|
||||
Cnd cndYxz = Cnd.NEW();
|
||||
cndYxz.and("u.unionGroupId", "is not", null);
|
||||
cndYxz.andEX("wpus.welfareId", "=", projectId);
|
||||
if (Strings.isNotBlank(month)) {
|
||||
cndYxz.andEX("SUBSTR(u.birthday,6,2)", "=", month.substring(5, 7));
|
||||
}
|
||||
cndFlUser.andEX("u.unionId", "=", unionId);
|
||||
sqlYxzUser.setCondition(cndYxz);
|
||||
List<NutMap> yxzUserList = welfareSingleService.listMap(sqlYxzUser);
|
||||
|
||||
|
||||
//这个福利的选项
|
||||
List<NutMap> optionList = welfareSingleService.getOptionByProjectId(projectId);
|
||||
|
||||
//找出每个小组的人数
|
||||
for (NutMap un : unionGroupMap) {
|
||||
|
||||
//这个小组全部的福利会员
|
||||
long teacherSum = flUserList.stream().filter(v -> v.getString("unionGroupId").equals(un.getString("id"))).collect(Collectors.toList()).size();
|
||||
un.setv("teacherSum", teacherSum);
|
||||
//这个小组已选择人数
|
||||
long yxzSum = yxzUserList.stream().filter(y -> y.getString("unionGroupId").equals(un.getString("id"))).collect(Collectors.toList()).size();
|
||||
un.setv("totalCount", yxzSum);
|
||||
//这个小组未选人数
|
||||
un.setv("unselectedTeacherSum", un.getInt("teacherSum") - un.getInt("totalCount"));
|
||||
|
||||
//每个选项有多少人选
|
||||
optionList.forEach(o -> {
|
||||
long optionCount = yxzUserList.stream().filter(y -> StrUtil.isNotBlank(y.getString("selectOptionId"))
|
||||
&& y.getString("selectOptionId").equals(o.getString("id"))
|
||||
&& y.getString("unionGroupId").equals(un.getString("id"))).collect(Collectors.toList()).size();
|
||||
un.setv(o.getString("optionName"), optionCount);
|
||||
|
||||
});
|
||||
}
|
||||
//表格列数据
|
||||
List<NutMap> labelList = new ArrayList<>();
|
||||
labelList.add(NutMap.NEW().addv("label", "小组名称").addv("prop", "GroupName"));
|
||||
labelList.add(NutMap.NEW().addv("label", "福利会员").addv("prop", "teacherSum"));
|
||||
optionList.forEach(v -> {
|
||||
labelList.add(NutMap.NEW().addv("label", v.getString("optionName")).addv("prop", v.getString("optionName")));
|
||||
});
|
||||
labelList.add(NutMap.NEW().addv("label", "参加人数").addv("prop", "totalCount"));
|
||||
labelList.add(NutMap.NEW().addv("label", "未选人数").addv("prop", "unselectedTeacherSum"));
|
||||
|
||||
return NutMap.NEW().addv("tableList", unionGroupMap).addv("tableColumn", labelList);
|
||||
}
|
||||
|
||||
|
||||
@At
|
||||
@Ok("void")
|
||||
@RequiresPermissions("welfare.project.statistics.single")
|
||||
public void allExportReceiveDetailByUnionIdWord(@Param(value = "month", required = false) String month, String projectId, HttpServletResponse response) throws Exception {
|
||||
WelfareProject welfareProject = welfareSingleService.dao().fetch(WelfareProject.class, projectId);
|
||||
|
||||
response.setContentType("application/octet-stream");
|
||||
response.setHeader("content-disposition", "attachment;filename="
|
||||
+ URLEncoder.encode(welfareProject.getName() + "签收表.zip", "UTF-8"));
|
||||
|
||||
|
||||
//获取这个福利项目下的所有数据
|
||||
List<NutMap> allUser = welfareSingleService.getUserByProjectId(projectId, month, null);
|
||||
List<NutMap> userChoose = welfareSingleService.getUserChooseByProjectId(projectId, month, null);
|
||||
List<Sys_union> unions = dao.query(Sys_union.class, Cnd.NEW());
|
||||
try {
|
||||
ZipOutputStream zipOutputStream = new ZipOutputStream(new BufferedOutputStream(response.getOutputStream()));
|
||||
|
||||
for (Sys_union union : unions) {
|
||||
String fileName = union.getUnioncode() + union.getUnionname().replaceAll("/", "、") + welfareProject.getName() + "签收表.xlsx";
|
||||
zipOutputStream.putNextEntry(new ZipEntry(fileName));
|
||||
welfareSingleService.exportReceiveDetail(projectId, union.getId(), allUser, userChoose, zipOutputStream);
|
||||
zipOutputStream.closeEntry();
|
||||
response.flushBuffer();
|
||||
}
|
||||
zipOutputStream.flush();
|
||||
zipOutputStream.close();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@At
|
||||
@Ok("void")
|
||||
@RequiresPermissions("welfare.project.statistics.single")
|
||||
public void exportReceiveDetailByUnionIdWord(@Param(value = "projectId", required = false) String projectId,
|
||||
@Param(value = "month", required = false) String month,
|
||||
@Param(value = "welfareUnitId", required = false) String welfareUnitId,
|
||||
@Param(value = "unionGroupId", required = false) String unionGroupId, HttpServletResponse response) {
|
||||
WelfareProject welfareProject = welfareSingleService.dao().fetch(WelfareProject.class, projectId);
|
||||
Sys_union sysUnion = dao.fetch(Sys_union.class, Cnd.where("id", "=", welfareUnitId));
|
||||
try {
|
||||
response.setContentType("application/octet-stream");
|
||||
response.setHeader("content-disposition", "attachment;filename="
|
||||
+ URLEncoder.encode(welfareProject.getName() + "签收表.xlsx", "UTF-8"));
|
||||
//获取这个福利项目下的所有数据
|
||||
List<NutMap> allUser = welfareSingleService.getUserByProjectId(projectId, month, unionGroupId);
|
||||
List<NutMap> userChoose = welfareSingleService.getUserChooseByProjectId(projectId, month, unionGroupId);
|
||||
welfareSingleService.exportReceiveDetail(projectId, welfareUnitId, new ArrayList<>(), new ArrayList<>(), response.getOutputStream());
|
||||
ViTool.excelResponse(response, sysUnion.getUnioncode() + sysUnion.getUnionname() + welfareProject.getName() + "签收表.xlsx");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@At
|
||||
@ViReturn
|
||||
@Ok("json:full")
|
||||
@RequiresPermissions("welfare.project.statistics.single")
|
||||
public Object getNoSelectUsers(String projectId) {
|
||||
List<NutMap> userList = welfareSingleService.unclaimedData(projectId, null, null);
|
||||
return userList;
|
||||
}
|
||||
|
||||
@At
|
||||
@ViReturn
|
||||
@Aop(TransAop.READ_COMMITTED)
|
||||
@Ok("json:full")
|
||||
@RequiresPermissions("welfare.project.statistics.single")
|
||||
public Object doSelectByAdmin(String projectId, @Param("welfareOptions") String welfareOptions) {
|
||||
List<NutMap> userList = welfareSingleService.unclaimedData(projectId, null, null);
|
||||
List<String> userIds = userList.stream().map(v -> v.getString("id")).collect(Collectors.toList());
|
||||
|
||||
List<NutMap> optionList = Json.fromJsonAsList(NutMap.class, welfareOptions);
|
||||
userIds.forEach(id -> {
|
||||
List<WelfareUserSelection> userSelections = optionList.stream().filter(v -> v.getInt("selectNum") > 0).map(v -> {
|
||||
WelfareUserSelection selection = new WelfareUserSelection();
|
||||
selection.setSelectTime(new Date());
|
||||
selection.setWelfareId(projectId);
|
||||
selection.setSelectUserId(id);
|
||||
selection.setSelectOptionId(v.getString("id"));
|
||||
selection.setReceiveAddress(null);
|
||||
selection.setSubjectId(v.getString("subjectId"));
|
||||
selection.setSelectNum(v.getInt("selectNum"));
|
||||
return selection;
|
||||
}).collect(Collectors.toList());
|
||||
dao.insert(userSelections);
|
||||
});
|
||||
welfareSingleService.dao().update(WelfareList.class,
|
||||
Chain.make("isReceive", true),
|
||||
Cnd.where("projectId", "=", projectId)
|
||||
.and("userId", "in", userIds));
|
||||
return null;
|
||||
}
|
||||
|
||||
@At
|
||||
@ViReturn
|
||||
@Ok("void")
|
||||
@RequiresPermissions("welfare.project.statistics.single")
|
||||
public void welfareProjectGroupExport(String projectId,
|
||||
@Param(value = "welfareUnitCode", required = false) String welfareUnitCode, HttpServletResponse response) {
|
||||
WelfareProject welfareProject = dao.fetch(WelfareProject.class, Cnd.where("id", "=", projectId));
|
||||
String projectName = welfareProject.getName();
|
||||
Cnd cnd = Cnd.NEW();
|
||||
Sql sql = Sqls.create("""
|
||||
SELECT
|
||||
u.loginname,
|
||||
u.username,
|
||||
u.mobile,
|
||||
wl.userState,
|
||||
wl.personType,
|
||||
gh.unionname,
|
||||
dw.name as unitname,
|
||||
IF(LOCATE('undefined',wpus.receiveAddress)>0,NULL,wpus.receiveAddress) as receiveAddress,
|
||||
wpus.selectNum,
|
||||
wpso.optionName
|
||||
FROM
|
||||
welfare_project_user_selection wpus
|
||||
left join user u on u.id = wpus.selectUserId
|
||||
left join welfare_project_subject_option wpso on wpso.id = wpus.selectOptionId
|
||||
left join welfare_list wl on wl.userId = wpus.selectUserId AND wpus.welfareId = wl.projectId
|
||||
left join sys_union gh on gh.id = wl.welfareUnitId
|
||||
left join sys_unit dw on dw.id = wl.welfareSecondLevelUnitId
|
||||
$condition
|
||||
""");
|
||||
cnd.and("wpus.welfareId", "=", projectId);
|
||||
|
||||
if (!ShiroUtil.hasAnyRoles("sysadmin,SchoolUnionWelfareAdmin")) {
|
||||
cnd.and("u.unionId", "=", Vi.getUnionId());
|
||||
}
|
||||
cnd.and("wpus.selectNum", "!=", 0);
|
||||
cnd.andEX("u.unioncode", "=", welfareUnitCode);
|
||||
//下次活动必须打开
|
||||
//cnd.groupBy("wpus.selectUserId", "wpus.selectOptionId");
|
||||
sql.setCondition(cnd);
|
||||
List<NutMap> list = welfareSingleService.listMap(sql);
|
||||
Map<String, List<NutMap>> optionGroupData = list.stream().collect(Collectors.groupingBy(v -> v.getString("optionName")));
|
||||
|
||||
List<ExcelExportEntity> exportEntities = new ArrayList<>();
|
||||
exportEntities.add(new ExcelExportEntity("工号", "loginname", 20));
|
||||
exportEntities.add(new ExcelExportEntity("姓名", "username", 20));
|
||||
exportEntities.add(new ExcelExportEntity("电话号码", "mobile", 20));
|
||||
exportEntities.add(new ExcelExportEntity("在职状态", "userState", 20));
|
||||
exportEntities.add(new ExcelExportEntity("人员类型", "personType", 20));
|
||||
exportEntities.add(new ExcelExportEntity("所在分工会", "unionname", 30));
|
||||
exportEntities.add(new ExcelExportEntity("所在单位", "unitname", 50));
|
||||
exportEntities.add(new ExcelExportEntity("选择份数", "selectNum", 20));
|
||||
// if (Globals.MyConfig.getBoolean("isThreeUnit")) {
|
||||
// exportEntities.add(new ExcelExportEntity("所在部门", "threeUnitName", 50));
|
||||
// }
|
||||
exportEntities.add(new ExcelExportEntity("收货地址", "receiveAddress", 100));
|
||||
|
||||
Workbook workbook = new XSSFWorkbook();
|
||||
optionGroupData.forEach((k, v) -> {
|
||||
ExcelExportService service = new ExcelExportService();
|
||||
ExportParams exportParams = new ExportParams();
|
||||
exportParams.setType(ExcelType.XSSF);
|
||||
exportParams.setTitle(projectName + k + "选择情况");
|
||||
exportParams.setSheetName(k);
|
||||
service.createSheetForMap(workbook, exportParams, exportEntities, v);
|
||||
});
|
||||
|
||||
|
||||
try (ServletOutputStream outputStream = response.getOutputStream()) {
|
||||
ViTool.excelResponse(response, projectName + ".xlsx");
|
||||
workbook.write(outputStream);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Data
|
||||
public static class qlbExportEntityUser {
|
||||
@Excel(name = "姓名", width = 20d)
|
||||
private String userName;
|
||||
|
||||
private String userSign;
|
||||
|
||||
@Excel(name = "实名签字", width = 20d, type = 2, imageType = 2)
|
||||
private byte[] qzBytes;
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
+252
@@ -0,0 +1,252 @@
|
||||
package io.v.nutz.zhgh.welfare.controller.voucher;
|
||||
|
||||
import io.v.nutz.base.annontation.ViReturn;
|
||||
import io.v.nutz.base.dao.CndPlus;
|
||||
import io.v.nutz.base.query.PageForm;
|
||||
import io.v.nutz.zhgh.welfare.mode.WelfareVoucherOrigin;
|
||||
import io.v.nutz.zhgh.welfare.mode.WelfareVoucherStatus;
|
||||
import io.v.nutz.zhgh.welfare.service.WelfareVoucherService;
|
||||
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.Static;
|
||||
import org.nutz.ioc.loader.annotation.Inject;
|
||||
import org.nutz.ioc.loader.annotation.IocBean;
|
||||
import org.nutz.mvc.adaptor.JsonAdaptor;
|
||||
import org.nutz.mvc.annotation.*;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 礼品券
|
||||
*
|
||||
* @author: 1V
|
||||
* @date: 2021/3/15
|
||||
* @since 1.0
|
||||
*/
|
||||
@IocBean
|
||||
@Ok("json:full")
|
||||
@At("/platform/welfare/voucher")
|
||||
public class WelfareVoucherController {
|
||||
|
||||
@Inject
|
||||
private WelfareVoucherService welfareVoucherService;
|
||||
|
||||
|
||||
/**
|
||||
* 发放礼品
|
||||
*
|
||||
* @param voucherId 券id
|
||||
* @param userid 发放人id
|
||||
* @return null
|
||||
*/
|
||||
@At
|
||||
@POST
|
||||
@ViReturn
|
||||
@AdaptBy(type = JsonAdaptor.class)
|
||||
public Object grantGift(@Param("voucherId") String voucherId, @Param("userid") String userid) {
|
||||
return welfareVoucherService.grantGift(voucherId, userid);
|
||||
}
|
||||
|
||||
/**
|
||||
* 自己点已领取
|
||||
*
|
||||
* @param voucherId 券id
|
||||
* @return null
|
||||
*/
|
||||
@At
|
||||
@POST
|
||||
@ViReturn
|
||||
@AdaptBy(type = JsonAdaptor.class)
|
||||
public Object selfReceived(@Param("voucherId") String voucherId) {
|
||||
welfareVoucherService.update(Chain.make("status", WelfareVoucherStatus.USED.getCode())
|
||||
.add("useTime", System.currentTimeMillis()), Cnd.where("id", "=", voucherId));
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 观测这个礼品券是否已经被使用
|
||||
*
|
||||
* @param voucherId 券id
|
||||
* @return 礼品券是否已经被使用
|
||||
*/
|
||||
@At
|
||||
@GET
|
||||
public boolean voucherReceived(String voucherId) {
|
||||
return welfareVoucherService.count(Cnd.where("id", "=", voucherId).and("status", "=", WelfareVoucherStatus.USED.getCode())) > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取礼品券详细信息
|
||||
*
|
||||
* @param voucherId 券id
|
||||
* @return 礼品券详细信息
|
||||
*/
|
||||
@At
|
||||
@GET
|
||||
@ViReturn
|
||||
public Object voucherInfo(String voucherId) {
|
||||
return welfareVoucherService.voucherInfo(voucherId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取转赠的礼品券详细信息
|
||||
*
|
||||
* @param voucherId 券id
|
||||
* @return 礼品券详细信息
|
||||
*/
|
||||
@At
|
||||
@GET
|
||||
@ViReturn
|
||||
public Object donateVoucherInfo(String voucherId) {
|
||||
return welfareVoucherService.donateVoucherInfo(voucherId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 转赠领取
|
||||
*
|
||||
* @param voucherId 券id
|
||||
* @param userid 被转赠人id
|
||||
* @return 领取结果
|
||||
*/
|
||||
@At
|
||||
@POST
|
||||
@ViReturn
|
||||
@AdaptBy(type = JsonAdaptor.class)
|
||||
public Object donateReceive(@Param("voucherId") String voucherId, @Param("userid") String userid) {
|
||||
return welfareVoucherService.donateReceive(voucherId, userid).map();
|
||||
}
|
||||
|
||||
/**
|
||||
* 将礼品券的状态改为已赠但是未领
|
||||
*
|
||||
* @param voucherId 券Id
|
||||
* @return null
|
||||
*/
|
||||
@At
|
||||
@POST
|
||||
@ViReturn
|
||||
@AdaptBy(type = JsonAdaptor.class)
|
||||
public Object voucherDonating(@Param("voucherId") String voucherId) {
|
||||
welfareVoucherService.voucherDonating(voucherId);
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 领取礼品券
|
||||
*
|
||||
* @param projectId 福利项目id
|
||||
* @param userid 用户id
|
||||
* @return null
|
||||
*/
|
||||
@At
|
||||
@ViReturn
|
||||
@POST
|
||||
@AdaptBy(type = JsonAdaptor.class)
|
||||
public Object grantVoucher(@Param("projectId") String projectId, @Param("userid") String userid) {
|
||||
return welfareVoucherService.grantVoucher(projectId, userid);
|
||||
}
|
||||
|
||||
/**
|
||||
* 该用户未领取的礼品券
|
||||
*
|
||||
* @param userid 用户id
|
||||
* @return 列表
|
||||
*/
|
||||
@At
|
||||
@ViReturn
|
||||
public Object unclaimedVoucher(String userid) {
|
||||
return welfareVoucherService.unclaimedVoucher(userid);
|
||||
}
|
||||
|
||||
/**
|
||||
* 礼品券列表
|
||||
*
|
||||
* @param pageForm 分页对象
|
||||
* @param userid 用户id
|
||||
* @param status {1:待使用 2:已使用 3:已过期}
|
||||
* @return 分页列表
|
||||
*/
|
||||
@At
|
||||
@ViReturn
|
||||
public Object pageData(PageForm pageForm, String userid, Integer status) {
|
||||
|
||||
Sql sql = Sqls.create("""
|
||||
SELECT
|
||||
voucher.id,
|
||||
voucher.projectId,
|
||||
project.`name`,
|
||||
project.festival,
|
||||
project.provideAddress,
|
||||
project.gift,
|
||||
project.flexibleGifts,
|
||||
project.provideTimeStart,
|
||||
project.provideTimeEnd,
|
||||
voucher.grantTime,
|
||||
voucher.useTime,
|
||||
voucher.origin,
|
||||
voucher.status,
|
||||
donateUser.username donateUser
|
||||
FROM
|
||||
welfare_voucher voucher
|
||||
LEFT JOIN welfare_project project ON voucher.projectId = project.id
|
||||
LEFT JOIN sys_user donateUser ON voucher.donateUserId = donateUser.id
|
||||
$condition
|
||||
""");
|
||||
|
||||
pageForm.defaultSortDesc("voucher.grantTime");
|
||||
|
||||
CndPlus cnd = CndPlus.create();
|
||||
cnd.and("voucher.userId", "=", userid);
|
||||
|
||||
if (status == 1) {
|
||||
cnd.and("voucher.status", "=", WelfareVoucherStatus.NORMAL.getCode())
|
||||
.and(new Static("project.provideTimeEnd >= now()"));
|
||||
} else if (status == 2) {
|
||||
cnd.and("voucher.status", "in", List.of(WelfareVoucherStatus.USED.getCode(), WelfareVoucherStatus.DONATING.getCode(), WelfareVoucherStatus.DONATE.getCode(), WelfareVoucherStatus.INVALID.getCode()));
|
||||
} else if (status == 3) {
|
||||
cnd.and("voucher.status", "=", WelfareVoucherStatus.NORMAL.getCode())
|
||||
.and(new Static("project.provideTimeEnd < now()"));
|
||||
} else {
|
||||
cnd.and(new Static("1 != 1"));
|
||||
}
|
||||
|
||||
sql.setCondition(cnd);
|
||||
|
||||
return welfareVoucherService.list(pageForm, sql);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return 状态词典
|
||||
*/
|
||||
@At
|
||||
@ViReturn
|
||||
public Object statusDict() {
|
||||
Map result = new HashMap();
|
||||
WelfareVoucherStatus[] values = WelfareVoucherStatus.values();
|
||||
for (WelfareVoucherStatus value : values) {
|
||||
result.put(value.getCode(), value.getDescription());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return 来源词典
|
||||
*/
|
||||
@At
|
||||
@ViReturn
|
||||
public Object originDict() {
|
||||
Map result = new HashMap();
|
||||
WelfareVoucherOrigin[] values = WelfareVoucherOrigin.values();
|
||||
for (WelfareVoucherOrigin value : values) {
|
||||
result.put(value.getCode(), value.getDescription());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,119 @@
|
||||
package io.v.nutz.zhgh.welfare.feature;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import io.v.nutz.base.utils.Vi;
|
||||
import io.v.nutz.base.dao.CndPlus;
|
||||
import io.v.nutz.web.commons.utils.ShiroUtil;
|
||||
import io.v.nutz.zhgh.welfare.mode.WelfareUnitMode;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
import org.nutz.dao.Cnd;
|
||||
import org.nutz.json.Json;
|
||||
import org.nutz.lang.Lang;
|
||||
import org.nutz.lang.Strings;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 小工具
|
||||
*
|
||||
* @author: 1V
|
||||
* @date: 2021/2/28
|
||||
* @since 1.0
|
||||
*/
|
||||
public interface WelfareFeature {
|
||||
|
||||
/**
|
||||
* 判断是否可以查看全部
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
static boolean judgmentAuthority() {
|
||||
return ShiroUtil.hasAnyRoles("sysadmin,SchoolUnionWelfareAdmin,SchoolUnionAdmin,SchoolUnionMemberAdmin");
|
||||
}
|
||||
|
||||
interface Condition {
|
||||
private static String getPrefix(String prefix) {
|
||||
return Strings.isBlank(prefix) ? "" : prefix + ".";
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断是否可以查看全部
|
||||
* 分工会只看自己工会的
|
||||
*
|
||||
* @param cnd
|
||||
* @return
|
||||
*/
|
||||
static void judgmentAuthority(Cnd cnd) {
|
||||
judgmentAuthority(cnd, "");
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断是否可以查看全部
|
||||
* 分工会只看自己工会的
|
||||
*
|
||||
* @param cnd
|
||||
* @param prefix
|
||||
* @return
|
||||
*/
|
||||
static void judgmentAuthority(Cnd cnd, String prefix) {
|
||||
if (!WelfareFeature.judgmentAuthority()) {
|
||||
String field = WelfareUnitMode.getMode().getField();
|
||||
Map<String, Object> bean = BeanUtil.beanToMap(Vi.getUnit());
|
||||
cnd.and(Condition.getPrefix(prefix) + field, "=", bean.get(field));
|
||||
}
|
||||
}
|
||||
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
class PageParam {
|
||||
String unit;
|
||||
String welfareUnit;
|
||||
String campus;
|
||||
String personType;
|
||||
String userState;
|
||||
String sex;
|
||||
String unionGroupId;
|
||||
String threeUnitId;
|
||||
|
||||
String units;
|
||||
String personTypes;
|
||||
String userStates;
|
||||
|
||||
|
||||
public void participate(CndPlus cnd) {
|
||||
participate(cnd, "");
|
||||
}
|
||||
|
||||
public void participate(CndPlus cnd, String prefix) {
|
||||
// if (Strings.isNotBlank())
|
||||
// cnd.andEX(Condition.getPrefix(prefix) + "unitid", "=", getUnit());
|
||||
cnd.andEX(Condition.getPrefix(prefix) + WelfareUnitMode.getMode().getField(), "=", getWelfareUnit());
|
||||
cnd.andEX(Condition.getPrefix(prefix) + "campusId", "=", getCampus());
|
||||
// cnd.andEX(Condition.getPrefix(prefix) + "personType", "=", getPersonType());
|
||||
// cnd.andEX(Condition.getPrefix(prefix) + "userState", "=", getUserState());
|
||||
cnd.andEX(Condition.getPrefix(prefix) + "sex", "=", getSex());
|
||||
cnd.andEX(Condition.getPrefix(prefix) + "threeUnitId", "=", getThreeUnitId());
|
||||
|
||||
if(Lang.isNotEmpty(getUnits())){
|
||||
String units = getUnits();
|
||||
String[] unitArray = Json.fromJsonAsArray(String.class, units);
|
||||
cnd.andEX(Condition.getPrefix(prefix) + "unitid", "in", unitArray);
|
||||
}
|
||||
|
||||
if(Lang.isNotEmpty(getPersonTypes())) {
|
||||
String personTypes = getPersonTypes();
|
||||
String[] personTypeArray = Json.fromJsonAsArray(String.class, personTypes);
|
||||
cnd.andEX(Condition.getPrefix(prefix) + "personType", "in", personTypeArray);
|
||||
}
|
||||
|
||||
if(Lang.isNotEmpty(getUserStates())) {
|
||||
String userStates = getUserStates();
|
||||
String[] userStateArray = Json.fromJsonAsArray(String.class, userStates);
|
||||
cnd.andEX(Condition.getPrefix(prefix) + "userState", "in", userStateArray);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,116 @@
|
||||
package io.v.nutz.zhgh.welfare.handle;
|
||||
|
||||
import io.v.nutz.base.model.Audit;
|
||||
import io.v.nutz.base.service.AuditService;
|
||||
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_user_role;
|
||||
import io.v.nutz.sys.services.SysUserService;
|
||||
import io.v.nutz.zhgh.member.constant.MemberApplyState;
|
||||
import io.v.nutz.zhgh.welfare.constant.WelfareMemberApplyState;
|
||||
import io.v.nutz.zhgh.welfare.feature.WelfareFeature;
|
||||
import io.v.nutz.zhgh.welfare.mode.WelfareMemberMode;
|
||||
import io.v.nutz.zhgh.welfare.model.WelfareMemberApplyRecord;
|
||||
import io.v.nutz.zhgh.welfare.service.WelfareMemberService;
|
||||
import lombok.Getter;
|
||||
import org.nutz.dao.Chain;
|
||||
import org.nutz.dao.Cnd;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 福利会员申请审核
|
||||
*
|
||||
* @author: 1V
|
||||
* @date: 2021/2/28
|
||||
* @since 1.0
|
||||
*/
|
||||
@Getter
|
||||
public enum WelfareMemberApplyAuditHandle {
|
||||
|
||||
/**
|
||||
* 创建
|
||||
*/
|
||||
CREATE(null) {
|
||||
@Override
|
||||
public void next(WelfareMemberApplyRecord record, Audit audit) {
|
||||
next(List.of(record), audit);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void next(List<WelfareMemberApplyRecord> records, Audit audit) {
|
||||
// WelfareMemberMode.joinWelfareMember(records.stream().map(v -> v.getUserId()).collect(Collectors.toList()));
|
||||
if (WelfareFeature.judgmentAuthority()) {
|
||||
WelfareMemberMode.joinWelfareMember(records.stream().map(v -> v.getUserId()).collect(Collectors.toList()));
|
||||
} else {
|
||||
Date now = new Date();
|
||||
for (WelfareMemberApplyRecord record : records) {
|
||||
record.setApplyTime(now);
|
||||
record.setStateId(WelfareMemberApplyState.SCHOOL_UNION);
|
||||
}
|
||||
service.dao().insert(records);
|
||||
}
|
||||
}
|
||||
},
|
||||
/**
|
||||
* 校工会审核
|
||||
*/
|
||||
AUDIT_SCHOOL(MemberApplyState.SCHOOL_UNION) {
|
||||
@Override
|
||||
public void next(WelfareMemberApplyRecord record, Audit audit) {
|
||||
next(List.of(record), audit);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void next(List<WelfareMemberApplyRecord> records, Audit audit) {
|
||||
service.transactional(() -> {
|
||||
|
||||
String auditId = auditService.insert(audit).getId();
|
||||
|
||||
for (WelfareMemberApplyRecord record : records) {
|
||||
record.setStateId(audit.getAuditPass() ? WelfareMemberApplyState.NORMAL_MEMBER : WelfareMemberApplyState.SCHOOL_UNION_FAIL);
|
||||
record.setSchoolAuditId(auditId);
|
||||
|
||||
sysUserService.deleteCache(record.getUserId());
|
||||
}
|
||||
|
||||
service.update(records);
|
||||
|
||||
if (audit.getAuditPass()) {
|
||||
List<String> userIds = records.stream().map(WelfareMemberApplyRecord::getUserId).collect(Collectors.toList());
|
||||
service.update(Chain.make("welfareMember", WelfareMemberMode.NORMAL.getCode()).add("welfareMemberJoinTime", new Date()), Cnd.where("id", "in", userIds));
|
||||
service.dao().clear(Sys_user_role.class, Cnd.where("id", "in", userIds).and("roleId", "=", Roles.WELFARE_MEMBER));
|
||||
|
||||
List<Sys_user_role> roles = new ArrayList<>();
|
||||
userIds.forEach(u -> {
|
||||
Sys_user_role userRole = new Sys_user_role();
|
||||
userRole.setUserId(u);
|
||||
userRole.setRoleId(Roles.WELFARE_MEMBER);
|
||||
roles.add(userRole);
|
||||
});
|
||||
getService().insert(roles);
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
private Integer state;
|
||||
|
||||
WelfareMemberApplyAuditHandle(Integer state) {
|
||||
this.state = state;
|
||||
}
|
||||
|
||||
public Vi vi = ViResource.ioc.get(Vi.class);
|
||||
public AuditService auditService = ViResource.ioc.getByType(AuditService.class);
|
||||
public WelfareMemberService service = ViResource.ioc.getByType(WelfareMemberService.class);
|
||||
public SysUserService sysUserService = ViResource.ioc.getByType(SysUserService.class);
|
||||
|
||||
public abstract void next(WelfareMemberApplyRecord record, Audit audit);
|
||||
|
||||
public abstract void next(List<WelfareMemberApplyRecord> records, Audit audit);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package io.v.nutz.zhgh.welfare.mode;
|
||||
|
||||
import cn.afterturn.easypoi.excel.annotation.Excel;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class CourierNumberExcelMode {
|
||||
|
||||
@Excel(name = "工号", width = 20)
|
||||
private String loginName;
|
||||
|
||||
@Excel(name = "姓名", width = 20)
|
||||
private String userName;
|
||||
|
||||
@Excel(name = "快递单号1", width = 30)
|
||||
private String oneCourierNumber;
|
||||
|
||||
@Excel(name = "快递单号2", width = 30)
|
||||
private String twoCourierNumber;
|
||||
|
||||
@Excel(name = "快递单号3", width = 30)
|
||||
private String threeCourierNumber;
|
||||
|
||||
@Excel(name = "快递单号4", width = 30)
|
||||
private String fourCourierNumber;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
package io.v.nutz.zhgh.welfare.mode;
|
||||
|
||||
import io.v.nutz.base.utils.Roles;
|
||||
import io.v.nutz.base.utils.ViResource;
|
||||
import io.v.nutz.sys.models.Sys_user_role;
|
||||
import io.v.nutz.zhgh.welfare.model.WelfareMemberApplyRecord;
|
||||
import io.v.nutz.zhgh.welfare.service.WelfareMemberService;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import org.nutz.dao.Chain;
|
||||
import org.nutz.dao.Cnd;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 福利会员状态
|
||||
*
|
||||
* @author: 1V
|
||||
* @date: 2021/1/25
|
||||
* @since 1.0
|
||||
*/
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum WelfareMemberMode {
|
||||
|
||||
NONE(0, "非会员"), NORMAL(1, "正式会员"), POTENTIAL(2, "潜在会员");
|
||||
|
||||
private int code;
|
||||
private String description;
|
||||
|
||||
private static WelfareMemberService getService() {
|
||||
return ViResource.ioc.getByType(WelfareMemberService.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* 将用户设为福利会员
|
||||
*
|
||||
* @param userId
|
||||
*/
|
||||
public static void joinWelfareMember(String userId) {
|
||||
joinWelfareMember(List.of(userId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 将用户设为福利会员(多个)
|
||||
*
|
||||
* @param userIds
|
||||
*/
|
||||
public static void joinWelfareMember(List<String> userIds) {
|
||||
getService().update(Chain.make("welfareMember", NORMAL.getCode()).add("welfareMemberJoinTime", new Date()), Cnd.where("id", "in", userIds));
|
||||
|
||||
List<Sys_user_role> roles = new ArrayList<>();
|
||||
userIds.forEach(u -> {
|
||||
Sys_user_role userRole = new Sys_user_role();
|
||||
userRole.setUserId(u);
|
||||
userRole.setRoleId(Roles.WELFARE_MEMBER);
|
||||
roles.add(userRole);
|
||||
});
|
||||
getService().insert(roles);
|
||||
}
|
||||
|
||||
/**
|
||||
* 取消福利会员的身份
|
||||
*
|
||||
* @param userId
|
||||
*/
|
||||
public static void kickWelfareMember(String userId) {
|
||||
kickWelfareMember(List.of(userId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 取消福利会员的身份(多个)
|
||||
*
|
||||
* @param userIds
|
||||
*/
|
||||
public static void kickWelfareMember(List<String> userIds) {
|
||||
getService().dao().clear(WelfareMemberApplyRecord.class, Cnd.where("userId", "in", userIds));
|
||||
getService().dao().clear(Sys_user_role.class, Cnd.where("userId", "in", userIds).and("roleId", "=", Roles.WELFARE_MEMBER));
|
||||
getService().update(Chain.make("welfareMember", NONE.getCode()).add("welfareMemberJoinTime", null), Cnd.where("id", "in", userIds));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package io.v.nutz.zhgh.welfare.mode;
|
||||
|
||||
import io.v.nutz.base.annontation.SelectEnum;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* 福利通知推送形式
|
||||
*
|
||||
* @author: 1V
|
||||
* @date: 2021/2/26
|
||||
* @since 1.0
|
||||
*/
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
@SelectEnum
|
||||
public enum WelfareNoticePushMode {
|
||||
ENTERPRISE_WECHAT(1, "企业微信");
|
||||
// , APPLET(2, "小程序");
|
||||
|
||||
private Integer code;
|
||||
private String description;
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package io.v.nutz.zhgh.welfare.mode;
|
||||
|
||||
import io.v.nutz.base.annontation.SelectEnum;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* 福利发放形式
|
||||
*
|
||||
* @author: 1V
|
||||
* @date: 2021/2/26
|
||||
* @since 1.0
|
||||
*/
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
@SelectEnum
|
||||
public enum WelfareProvideMode {
|
||||
WELFARE_UNIT(1, "分工会/福利单位"),
|
||||
PERSON_CHOICE(2, "意向选择"),
|
||||
PERSONAL(3, "邮寄到家");
|
||||
// TOGETHER(4, "集中发放");
|
||||
|
||||
private Integer code;
|
||||
private String description;
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package io.v.nutz.zhgh.welfare.mode;
|
||||
|
||||
import io.v.nutz.base.annontation.SelectEnum;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* 福利签收形式
|
||||
*
|
||||
* @author: 1V
|
||||
* @date: 2021/2/26
|
||||
* @since 1.0
|
||||
*/
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
@SelectEnum
|
||||
public enum WelfareSignMode {
|
||||
PAPER(1, "纸质签字"), QRCODE_SIGNATURE(2, "电子签字"), QRCODE(3, "二维码"), NO_SIGNATURE(4, "不签字");
|
||||
|
||||
private Integer code;
|
||||
private String description;
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
package io.v.nutz.zhgh.welfare.mode;
|
||||
|
||||
import io.v.nutz.base.lang.Enum;
|
||||
import io.v.nutz.sys.services.SysUnitService;
|
||||
import io.v.nutz.base.utils.ViResource;
|
||||
import io.v.nutz.web.commons.base.Globals;
|
||||
import io.v.nutz.zhgh.welfare.model.view.WelfareUnit;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import org.nutz.dao.Sqls;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Todo
|
||||
*
|
||||
* @author: 1V
|
||||
* @date: 2021/2/4
|
||||
* @since 1.0
|
||||
*/
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum WelfareUnitMode {
|
||||
UNIT("welfareUnitId"), UNION("unionid");
|
||||
|
||||
private String field;
|
||||
|
||||
/**
|
||||
* 获取当前系统参数设置的mode
|
||||
*
|
||||
* @return mode
|
||||
*/
|
||||
public static WelfareUnitMode getMode() {
|
||||
return Enum.instance(WelfareUnitMode.class, Globals.MyConfig.getString("WelfareUnitMode"));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取福利单位
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static List<WelfareUnit> getWelfareUnits() {
|
||||
SysUnitService service = ViResource.ioc.getByType(SysUnitService.class);
|
||||
return service.listEntity(Sqls.create("SELECT * from welfare_unit WHERE welfareUnitMode = @mode ORDER BY welfareUnitCode").setParam("mode", getMode()), WelfareUnit.class);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package io.v.nutz.zhgh.welfare.mode;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* 礼品卷来源
|
||||
*
|
||||
* @author: 1V
|
||||
* @date: 2021/3/16
|
||||
* @since 1.0
|
||||
*/
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum WelfareVoucherOrigin {
|
||||
|
||||
/**
|
||||
* 正常领取
|
||||
*/
|
||||
RECEIVE(1, "正常领取"),
|
||||
/**
|
||||
* 转赠
|
||||
*/
|
||||
DONATE(2, "转赠");
|
||||
|
||||
/**
|
||||
* 代码
|
||||
*/
|
||||
private final int code;
|
||||
/**
|
||||
* 描述
|
||||
*/
|
||||
private final String description;
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
package io.v.nutz.zhgh.welfare.mode;
|
||||
|
||||
import io.v.nutz.base.annontation.SelectEnum;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* 礼品卷状态
|
||||
*
|
||||
* @author: 1V
|
||||
* @date: 2021/3/16
|
||||
* @since 1.0
|
||||
*/
|
||||
@Getter
|
||||
@SelectEnum
|
||||
@AllArgsConstructor
|
||||
public enum WelfareVoucherStatus {
|
||||
|
||||
/**
|
||||
* 待使用
|
||||
*/
|
||||
NORMAL(1, "待使用"),
|
||||
/**
|
||||
* 已使用
|
||||
*/
|
||||
USED(2, "已使用"),
|
||||
/**
|
||||
* 已转赠待领取
|
||||
*/
|
||||
DONATING(3, "转赠待领取"),
|
||||
/**
|
||||
* 已转赠
|
||||
*/
|
||||
DONATE(4, "已转赠"),
|
||||
/**
|
||||
* 作废
|
||||
*/
|
||||
INVALID(10, "作废");
|
||||
|
||||
/**
|
||||
* 编码
|
||||
*/
|
||||
private final int code;
|
||||
/**
|
||||
* 描述
|
||||
*/
|
||||
private final String description;
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
package io.v.nutz.zhgh.welfare.mode.voucher;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 发放礼品结果
|
||||
*
|
||||
* @author: 1V
|
||||
* @date: 2021/3/17
|
||||
* @since 1.0
|
||||
*/
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum WelfareGiftGrantResult {
|
||||
|
||||
/**
|
||||
* 发放成功
|
||||
*/
|
||||
SUCCESS(true, "发放成功"),
|
||||
/**
|
||||
* 已使用
|
||||
*/
|
||||
GRANTED(false, "礼品券已使用"),
|
||||
/**
|
||||
* 为找到
|
||||
*/
|
||||
NotFound(false, "不存在的礼品券"),
|
||||
/**
|
||||
* 超时
|
||||
*/
|
||||
TIMEOUT(false, "不在发放时间范围内"),
|
||||
/**
|
||||
* 系统错误
|
||||
*/
|
||||
FAIL(false, "系统错误");
|
||||
|
||||
|
||||
/**
|
||||
* 是否成功
|
||||
*/
|
||||
private final boolean success;
|
||||
/**
|
||||
* 结果描述
|
||||
*/
|
||||
private final String description;
|
||||
|
||||
public Map<String, Object> map() {
|
||||
return Map.of("success", this.success, "description", this.description);
|
||||
}
|
||||
|
||||
}
|
||||
+53
@@ -0,0 +1,53 @@
|
||||
package io.v.nutz.zhgh.welfare.mode.voucher;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 礼品券转赠领取结果
|
||||
*
|
||||
* @author: 1V
|
||||
* @date: 2021/3/17
|
||||
* @since 1.0
|
||||
*/
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum WelfareVoucherDonateReceiveResult {
|
||||
|
||||
/**
|
||||
* 领取成功
|
||||
*/
|
||||
SUCCESS(true, "领取成功"),
|
||||
/**
|
||||
* 已被领取
|
||||
*/
|
||||
DONATED(false, "该礼品券已被领取"),
|
||||
/**
|
||||
* 系统错误
|
||||
*/
|
||||
FAIL(false, "系统错误"),
|
||||
/**
|
||||
* 作废
|
||||
*/
|
||||
INVALID(false, "该礼品券已作废"),
|
||||
/**
|
||||
* 超时
|
||||
*/
|
||||
TIMEOUT(false, "该礼品券领取时间已过");
|
||||
|
||||
/**
|
||||
* 是否成功
|
||||
*/
|
||||
private final boolean success;
|
||||
/**
|
||||
* 结果描述
|
||||
*/
|
||||
private final String description;
|
||||
|
||||
public Map<String, Object> map() {
|
||||
return Map.of("success", this.success, "description", this.description);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
package io.v.nutz.zhgh.welfare.model;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
import org.nutz.dao.entity.annotation.*;
|
||||
import org.nutz.dao.interceptor.annotation.PrevInsert;
|
||||
import org.nutz.lang.util.NutMap;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @ClassName WelfareCourierNumber
|
||||
* @Description TODO
|
||||
* @Author zhf
|
||||
* @Date 2024/6/27 9:46
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
@Table
|
||||
@Comment("福利用户快递单号")
|
||||
public class WelfareCourierNumber {
|
||||
|
||||
|
||||
@Name
|
||||
@Comment("ID")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 32)
|
||||
@PrevInsert(uu32 = true)
|
||||
private String id;
|
||||
|
||||
@Column
|
||||
@Comment("所属福利")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 32)
|
||||
private String welfareId;
|
||||
|
||||
@Column
|
||||
@Comment("选择项")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 32)
|
||||
private String selectOptionId;
|
||||
|
||||
@Column
|
||||
@Comment("选择用户")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 32)
|
||||
private String selectUserId;
|
||||
|
||||
@Column
|
||||
@Comment("快递单号")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 50)
|
||||
private String courierNumber;
|
||||
|
||||
@Column
|
||||
@Comment("物流信息")
|
||||
@ColDefine(type = ColType.MYSQL_JSON)
|
||||
private WelfareUserSelection.LogisticsTrace logisticsTrace;
|
||||
|
||||
@Column
|
||||
@Comment("上次查询物流信息的时间")
|
||||
@ColDefine(type = ColType.DATETIME)
|
||||
private Date selectExpressDate;
|
||||
|
||||
@Data
|
||||
public static class LogisticsTrace {
|
||||
//运单号物流流转当前最新变更时间
|
||||
private Date theLastTime;
|
||||
//运单号物流流转当前最新描述
|
||||
private String theLastMessage;
|
||||
//运单号当前物流状态文字描述
|
||||
private String logisticsStatusDesc;
|
||||
//物流流转状态(WAIT_ACCEPT:)
|
||||
private String logisticsStatus;
|
||||
//物流流转明细
|
||||
private List<NutMap> logisticsTraceDetailList;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
package io.v.nutz.zhgh.welfare.model;
|
||||
|
||||
import io.v.nutz.base.model.BaseModel;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.nutz.dao.entity.annotation.*;
|
||||
import org.nutz.dao.interceptor.annotation.PrevInsert;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @ClassName WelfareEvaluate
|
||||
* @Description 福利评价
|
||||
* @Author zhf
|
||||
* @Date 2024/5/7 18:47
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Table
|
||||
public class WelfareEvaluate extends BaseModel implements Serializable {
|
||||
|
||||
@Name
|
||||
@Column
|
||||
@Comment("ID")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 32)
|
||||
@PrevInsert(uu32 = true)
|
||||
private String id;
|
||||
|
||||
@Column
|
||||
@Comment("福利项目ID")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 32)
|
||||
private String projectId;
|
||||
|
||||
@Column
|
||||
@Comment("套餐ID")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 32)
|
||||
private String optionId;
|
||||
|
||||
@Column
|
||||
@Comment("用户ID")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 32)
|
||||
private String userId;
|
||||
|
||||
@Column
|
||||
@Comment("姓名")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 32)
|
||||
private String userName;
|
||||
|
||||
@Column
|
||||
@Comment("工号")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 32)
|
||||
private String loginName;
|
||||
|
||||
@Column
|
||||
@Comment("评分")
|
||||
@ColDefine(type = ColType.DOUBLE,width = 2,precision = 1)
|
||||
private Double evaluateScore;
|
||||
|
||||
@Column
|
||||
@Comment("评价内容")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 100)
|
||||
private String evaluateText;
|
||||
|
||||
@Column
|
||||
@Comment("评价时间")
|
||||
@ColDefine(type = ColType.DATETIME)
|
||||
private Date applyDate;
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
package io.v.nutz.zhgh.welfare.model;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
import org.nutz.dao.entity.annotation.*;
|
||||
import org.nutz.dao.interceptor.annotation.PrevInsert;
|
||||
|
||||
/**
|
||||
* 福利名单
|
||||
*
|
||||
* @author: 1V
|
||||
* @date: 2021/2/1
|
||||
* @since 1.0
|
||||
*/
|
||||
@Table("welfare_list")
|
||||
@TableIndexes({
|
||||
@Index(name = "INDEX_WELFARE_LIST_USER_ID", fields = {"userId"}, unique = false),
|
||||
@Index(name = "INDEX_WELFARE_LIST_WELFARE_UNIT_ID", fields = {"welfareUnitId"}, unique = false),
|
||||
})
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class WelfareList {
|
||||
@Name
|
||||
@Column
|
||||
@Comment("ID")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 32)
|
||||
@PrevInsert(uu32 = true)
|
||||
private String id;
|
||||
|
||||
@Column
|
||||
@Comment("福利项目ID")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 32)
|
||||
private String projectId;
|
||||
|
||||
@Column
|
||||
@Comment("用户ID")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 32)
|
||||
private String userId;
|
||||
|
||||
@Column
|
||||
@Comment("福利单位ID")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 32)
|
||||
private String welfareUnitId;
|
||||
|
||||
@Column
|
||||
@Comment("福利二级单位ID")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 32)
|
||||
private String welfareSecondLevelUnitId;
|
||||
|
||||
@Column
|
||||
@Comment("是否签收")
|
||||
@ColDefine(type = ColType.BOOLEAN)
|
||||
private Boolean isReceive;
|
||||
|
||||
@Column
|
||||
@Comment("是否下次福利自动选择当前提货券")
|
||||
@ColDefine(type = ColType.BOOLEAN)
|
||||
private Boolean isAutoSelect;
|
||||
|
||||
@Column
|
||||
@Comment("人员类型")
|
||||
@ColDefine(type = ColType.VARCHAR)
|
||||
private String personType;
|
||||
|
||||
@Column
|
||||
@Comment("在职状态")
|
||||
@ColDefine(type = ColType.VARCHAR)
|
||||
private String userState;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
package io.v.nutz.zhgh.welfare.model;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
import org.nutz.dao.entity.annotation.*;
|
||||
import org.nutz.dao.interceptor.annotation.PrevInsert;
|
||||
|
||||
/**
|
||||
* @author zxy
|
||||
* @Description 福利会员地址信息
|
||||
* @createTime 2022年01月14日 09:49:00
|
||||
*/
|
||||
@Table("welfare_member_address")
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class WelfareMemberAddress {
|
||||
|
||||
@Name
|
||||
@Comment("ID")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 32)
|
||||
@PrevInsert(uu32 = true)
|
||||
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 = 11)
|
||||
private String tel;
|
||||
|
||||
@Column
|
||||
@Comment("省份")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 10)
|
||||
private String province;
|
||||
|
||||
@Column
|
||||
@Comment("城市")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 10)
|
||||
private String city;
|
||||
|
||||
@Column
|
||||
@Comment("区县")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 10)
|
||||
private String county;
|
||||
|
||||
@Column
|
||||
@Comment("详细地址")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 100)
|
||||
private String addressDetail;
|
||||
|
||||
@Column
|
||||
@Comment("地区编码")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 10)
|
||||
private String areaCode;
|
||||
|
||||
@Column
|
||||
@Comment("是否为默认地址")
|
||||
@ColDefine(type = ColType.BOOLEAN)
|
||||
private boolean isDefault;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
package io.v.nutz.zhgh.welfare.model;
|
||||
|
||||
import io.v.nutz.base.model.Audit;
|
||||
import io.v.nutz.base.model.AuditState;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
import org.nutz.dao.entity.annotation.*;
|
||||
import org.nutz.dao.interceptor.annotation.PrevInsert;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 福利会员申请记录
|
||||
*
|
||||
* @author: 1V
|
||||
* @date: 2021/2/28
|
||||
* @since 1.0
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
@Table("welfare_member_apply_record")
|
||||
public class WelfareMemberApplyRecord {
|
||||
@Column
|
||||
@Name
|
||||
@Comment("ID")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 32)
|
||||
@PrevInsert(uu32 = true)
|
||||
private String id;
|
||||
|
||||
@Column
|
||||
@Comment("用户id")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 32)
|
||||
private String userId;
|
||||
|
||||
@Column
|
||||
@Comment("状态id")
|
||||
@ColDefine(type = ColType.INT, width = 8)
|
||||
private Integer stateId;
|
||||
|
||||
@Column
|
||||
@Comment("申请时间")
|
||||
private Date applyTime;
|
||||
|
||||
@Column
|
||||
@Comment("校工会审核记录id")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 32)
|
||||
public String schoolAuditId;
|
||||
|
||||
@One(field = "schoolAuditId")
|
||||
public Audit schoolAudit;
|
||||
|
||||
@One(field = "stateId")
|
||||
private AuditState auditState;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
package io.v.nutz.zhgh.welfare.model;
|
||||
|
||||
import cn.wizzer.framework.base.model.BaseModel;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
import org.nutz.dao.entity.annotation.*;
|
||||
import org.nutz.dao.interceptor.annotation.PrevInsert;
|
||||
|
||||
/**
|
||||
* @ClassName WelfareMemberCheckUser
|
||||
* @Description 福利会员核对人员表
|
||||
* @Author zhf
|
||||
* @Date 2024/10/21 10:55
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
@Table
|
||||
public class WelfareMemberCheckUser extends BaseModel {
|
||||
|
||||
@Column
|
||||
@Name
|
||||
@Comment("ID")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 32)
|
||||
@PrevInsert(uu32 = true)
|
||||
private String id;
|
||||
|
||||
@Column
|
||||
@Comment("用户id")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 32)
|
||||
private String userId;
|
||||
|
||||
@Column
|
||||
@Comment("单位id")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 32)
|
||||
private String unitId;
|
||||
|
||||
@Column
|
||||
@Comment("工会id")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 32)
|
||||
private String unionId;
|
||||
|
||||
@Column
|
||||
@Comment("任务id")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 32)
|
||||
private String taskId;
|
||||
|
||||
@Column
|
||||
@Comment("在职状态")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 10)
|
||||
private String userState;
|
||||
|
||||
@Column
|
||||
@Comment("人员类型")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 20)
|
||||
private String personType;
|
||||
|
||||
@Column
|
||||
@Comment("是否删除")
|
||||
@Default("0")
|
||||
@ColDefine(type = ColType.BOOLEAN)
|
||||
private Boolean isDelete;
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package io.v.nutz.zhgh.welfare.model;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
import org.nutz.dao.entity.annotation.*;
|
||||
|
||||
/**
|
||||
* 福利会员名单
|
||||
* 年度 + 用户id + 福利单位
|
||||
*
|
||||
* @author: 1V
|
||||
* @date: 2021/2/24
|
||||
* @since 1.0
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
@Table("welfare_member_record")
|
||||
public class WelfareMemberRecord {
|
||||
@Column
|
||||
@Comment("年度")
|
||||
@ColDefine(type = ColType.INT, width = 4)
|
||||
private Integer year;
|
||||
|
||||
@Column
|
||||
@Comment("用户Id")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 32)
|
||||
private String userId;
|
||||
|
||||
@Column
|
||||
@Comment("单位Id")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 32)
|
||||
private String unitId;
|
||||
}
|
||||
@@ -0,0 +1,236 @@
|
||||
package io.v.nutz.zhgh.welfare.model;
|
||||
|
||||
import cn.wizzer.framework.base.model.BaseModel;
|
||||
import io.v.nutz.sys.models.Sys_home_activity;
|
||||
import io.v.nutz.sys.services.SysHomeConvert;
|
||||
import io.v.nutz.zhgh.data.model.MatchConditionStructure;
|
||||
import io.v.nutz.zhgh.welfare.mode.WelfareNoticePushMode;
|
||||
import io.v.nutz.zhgh.welfare.mode.WelfareProvideMode;
|
||||
import io.v.nutz.zhgh.welfare.mode.WelfareSignMode;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
import org.nutz.dao.entity.annotation.*;
|
||||
import org.nutz.dao.interceptor.annotation.PrevInsert;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 福利项目
|
||||
*
|
||||
* @author: 1V
|
||||
* @date: 2021/2/26
|
||||
* @since 1.0
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
@Table("welfare_project")
|
||||
@Comment("福利项目")
|
||||
public class WelfareProject extends BaseModel implements Serializable, SysHomeConvert {
|
||||
@Column
|
||||
@Name
|
||||
@Comment("ID")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 32)
|
||||
@PrevInsert(uu32 = true)
|
||||
private String id;
|
||||
|
||||
@Column
|
||||
@Comment("年度")
|
||||
@ColDefine(type = ColType.INT, width = 4)
|
||||
private Integer year;
|
||||
|
||||
@Column
|
||||
@Comment("任务id")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 32)
|
||||
private String taskId;
|
||||
|
||||
@Column
|
||||
@Comment("项目名称")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 100)
|
||||
private String name;
|
||||
|
||||
@Column
|
||||
@Comment("节日")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 50)
|
||||
private String festival;
|
||||
|
||||
@Column
|
||||
@Comment("发放开始时间")
|
||||
@ColDefine(type = ColType.DATETIME)
|
||||
private Date provideTimeStart;
|
||||
|
||||
@Column
|
||||
@Comment("发放结束时间")
|
||||
@ColDefine(type = ColType.DATETIME)
|
||||
private Date provideTimeEnd;
|
||||
|
||||
@Column
|
||||
@Comment("选择开始时间")
|
||||
@ColDefine(type = ColType.DATETIME)
|
||||
private Date choiceTimeStart;
|
||||
|
||||
@Column
|
||||
@Comment("选择结束时间")
|
||||
@ColDefine(type = ColType.DATETIME)
|
||||
private Date choiceTimeEnd;
|
||||
|
||||
@Column
|
||||
@Comment("逾期补发结束时间")
|
||||
@ColDefine(type = ColType.DATETIME)
|
||||
private Date overdueChoiceTimeEnd;
|
||||
|
||||
@Column
|
||||
@Comment("发放地址")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 200)
|
||||
private String provideAddress;
|
||||
|
||||
@Column
|
||||
@Comment("发放地址坐标")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 50)
|
||||
private String provideCoordinate;
|
||||
|
||||
/**
|
||||
* @see WelfareProvideMode
|
||||
*/
|
||||
@Column
|
||||
@Comment("发放形式")
|
||||
@ColDefine(type = ColType.INT, width = 1)
|
||||
private Integer provideMode;
|
||||
|
||||
/**
|
||||
* @see WelfareSignMode
|
||||
*/
|
||||
@Column
|
||||
@Comment("签收形式")
|
||||
@ColDefine(type = ColType.INT, width = 1)
|
||||
private Integer signMode;
|
||||
|
||||
/**
|
||||
* @see WelfareNoticePushMode
|
||||
*/
|
||||
@Column
|
||||
@Comment("通知推送形式")
|
||||
@ColDefine(type = ColType.INT, width = 1)
|
||||
private Integer noticePushMode;
|
||||
|
||||
@Column
|
||||
@Comment("是否弹性福利")
|
||||
@ColDefine(type = ColType.BOOLEAN)
|
||||
private Boolean flexible;
|
||||
|
||||
@Column
|
||||
@Comment("是否推送移动端首页")
|
||||
@ColDefine(type = ColType.INT)
|
||||
private Integer isPushHome;
|
||||
|
||||
@Column
|
||||
@Comment("是否福利套餐")
|
||||
@ColDefine(type = ColType.BOOLEAN)
|
||||
private Boolean isRoutine;
|
||||
|
||||
@Column
|
||||
@Comment("选择模式(checkBox多选 radio单选)")
|
||||
@ColDefine(type = ColType.VARCHAR)
|
||||
private String isCheckBox;
|
||||
|
||||
@Column
|
||||
@Comment("最多选几个")
|
||||
@ColDefine(type = ColType.INT)
|
||||
private Integer multiSelectNum;
|
||||
|
||||
@Column
|
||||
@Comment("是否支持单个多选")
|
||||
@ColDefine(type = ColType.BOOLEAN)
|
||||
private Boolean singleOptionSupportMultipleSelection;
|
||||
|
||||
|
||||
@Column
|
||||
@Comment("主福利礼品")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 100)
|
||||
private String gift;
|
||||
|
||||
@Column
|
||||
@Comment("弹性礼品")
|
||||
@ColDefine(type = ColType.MYSQL_JSON)
|
||||
private List<Gift> flexibleGifts;
|
||||
|
||||
@Column
|
||||
@Comment("福利所属分工会")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 32)
|
||||
private String welfareUnionId;
|
||||
|
||||
@Column
|
||||
@Comment("选择套餐Id")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 32)
|
||||
private String schoolWelfareId;
|
||||
|
||||
|
||||
/**
|
||||
* 弹性礼品
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public static class Gift {
|
||||
/**
|
||||
* 礼品名称
|
||||
*/
|
||||
private String name;
|
||||
/**
|
||||
* 是否默认
|
||||
*/
|
||||
private Boolean isDefault;
|
||||
}
|
||||
|
||||
@Column
|
||||
@Comment("条件")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 32)
|
||||
private String conditionStructureId;
|
||||
|
||||
@One(field = "conditionStructureId")
|
||||
private MatchConditionStructure conditionStructure;
|
||||
|
||||
@Many(field = "projectId")
|
||||
private List<WelfareProjectSubject> welfareProjectSubjects;
|
||||
|
||||
@Column
|
||||
@Comment("题目ID")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 32)
|
||||
private String subjectId;
|
||||
|
||||
@Column
|
||||
@Comment("封面")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 200)
|
||||
private String cover;
|
||||
|
||||
@Column
|
||||
@Comment("是否全年生日蛋糕卷")
|
||||
@Default("0")
|
||||
@ColDefine(type = ColType.BOOLEAN)
|
||||
private Boolean isYearBirthday;
|
||||
|
||||
@Column
|
||||
@Comment("是否禁用")
|
||||
@Default("0")
|
||||
@ColDefine(type = ColType.BOOLEAN)
|
||||
private Boolean isDisabled;
|
||||
|
||||
@Override
|
||||
public Sys_home_activity covertToSysHomeActivity() {
|
||||
Sys_home_activity sysHomeActivity = new Sys_home_activity();
|
||||
sysHomeActivity.setId(this.getId());
|
||||
sysHomeActivity.setName(this.getName());
|
||||
sysHomeActivity.setCover(this.getCover());
|
||||
sysHomeActivity.setUrl("/platform/welfare/userChoose");
|
||||
sysHomeActivity.setH5Url("/mobile/welfare/list/index");
|
||||
sysHomeActivity.setStartDate(this.getChoiceTimeStart());
|
||||
sysHomeActivity.setEndDate(this.getChoiceTimeEnd());
|
||||
sysHomeActivity.setAllowUserSql("select userId from welfare_list where projectId = '" + this.getId() + "' and userId = @userId");
|
||||
sysHomeActivity.setEnable(this.getIsDisabled() == null || !this.getIsDisabled());
|
||||
sysHomeActivity.setClassPath(this.getClass().getPackageName() + this.getClass().getName());
|
||||
return sysHomeActivity;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
package io.v.nutz.zhgh.welfare.model;
|
||||
|
||||
import io.v.nutz.base.model.ViBaseModel;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
import org.nutz.dao.entity.annotation.*;
|
||||
import org.nutz.dao.interceptor.annotation.PrevInsert;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author zxy
|
||||
* @Description 福利项目题目
|
||||
* @createTime 2022年01月12日 16:58:00
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
@Table("welfare_project_subject")
|
||||
@Comment("福利选项标题")
|
||||
public class WelfareProjectSubject extends ViBaseModel {
|
||||
|
||||
@Name
|
||||
@Comment("ID")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 32)
|
||||
@PrevInsert(uu32 = true)
|
||||
private String id;
|
||||
|
||||
@Column
|
||||
@Comment("所属福利")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 32)
|
||||
private String projectId;
|
||||
|
||||
@Column
|
||||
@Comment("题目名称")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 50)
|
||||
private String subjectName;
|
||||
|
||||
@Column
|
||||
@Comment("题目类型")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 10)
|
||||
private String subjectType;
|
||||
|
||||
@Column
|
||||
@Comment("本题总共最多选几项")
|
||||
@ColDefine(type = ColType.INT)
|
||||
private String subjectMaxSelectNum;
|
||||
|
||||
@Many(field = "subjectId")
|
||||
private List<WelfareProjectSubjectOption> options;
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
package io.v.nutz.zhgh.welfare.model;
|
||||
|
||||
import io.v.nutz.base.model.BaseModel;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
import org.nutz.dao.entity.annotation.*;
|
||||
import org.nutz.dao.interceptor.annotation.PrevInsert;
|
||||
|
||||
/**
|
||||
* @author zxy
|
||||
* @Description TODO
|
||||
* @createTime 2022年01月12日 17:03:00
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
@Table("welfare_project_subject_option")
|
||||
@Comment("福利选项")
|
||||
public class WelfareProjectSubjectOption extends BaseModel {
|
||||
|
||||
@Name
|
||||
@Comment("ID")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 32)
|
||||
@PrevInsert(uu32 = true)
|
||||
private String id;
|
||||
|
||||
@Column
|
||||
@Comment("所属题目")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 32)
|
||||
private String subjectId;
|
||||
|
||||
@Column
|
||||
@Comment("选项类型")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 50)
|
||||
private String optionType;
|
||||
|
||||
@Column
|
||||
@Comment("选项名称")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 50)
|
||||
private String optionName;
|
||||
|
||||
@Column
|
||||
@Comment("选项名称Id")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 50)
|
||||
private String optionNameId;
|
||||
|
||||
@Column
|
||||
@Comment("选项排序")
|
||||
@ColDefine(type = ColType.INT)
|
||||
private Integer optionSort;
|
||||
|
||||
@Column
|
||||
@Comment("没选系统自动选")
|
||||
@ColDefine(type = ColType.BOOLEAN)
|
||||
private Boolean isDefaultOption;
|
||||
|
||||
@Column
|
||||
@Comment("默认选项")
|
||||
@ColDefine(type = ColType.BOOLEAN)
|
||||
private Boolean isSystemDefault;
|
||||
|
||||
@Column
|
||||
@Comment("图片地址")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 100)
|
||||
private String imgUrl;
|
||||
|
||||
@Column
|
||||
@Comment("供应商id")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 100)
|
||||
private String shoppingId;
|
||||
|
||||
@Column
|
||||
@Comment("供应商名称")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 100)
|
||||
private String shoppingName;
|
||||
|
||||
@Column
|
||||
@Comment("说明描述")
|
||||
@ColDefine(type = ColType.TEXT)
|
||||
private String description;
|
||||
|
||||
@Column
|
||||
@Comment("供货商")
|
||||
@ColDefine(type = ColType.VARCHAR,width = 100)
|
||||
private String supplier;
|
||||
|
||||
@Column
|
||||
@Comment("简短备注")
|
||||
@ColDefine(type = ColType.VARCHAR,width = 100)
|
||||
private String simpleDesc;
|
||||
}
|
||||
@@ -0,0 +1,103 @@
|
||||
package io.v.nutz.zhgh.welfare.model;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
import org.nutz.dao.entity.annotation.*;
|
||||
import org.nutz.dao.interceptor.annotation.PrevInsert;
|
||||
import org.nutz.lang.util.NutMap;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author zxy
|
||||
* @Description TODO
|
||||
* @createTime 2022年01月12日 17:07:00
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
@Table("welfare_project_user_selection")
|
||||
@Comment("福利用户选择记录")
|
||||
public class WelfareUserSelection {
|
||||
|
||||
@Name
|
||||
@Comment("ID")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 32)
|
||||
@PrevInsert(uu32 = true)
|
||||
private String id;
|
||||
|
||||
@Column
|
||||
@Comment("所属福利")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 32)
|
||||
private String welfareId;
|
||||
|
||||
@Column
|
||||
@Comment("所属题目")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 32)
|
||||
private String subjectId;
|
||||
|
||||
@Column
|
||||
@Comment("选择项")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 32)
|
||||
private String selectOptionId;
|
||||
|
||||
@Column
|
||||
@Comment("选择用户")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 32)
|
||||
private String selectUserId;
|
||||
|
||||
@Column
|
||||
@Comment("选择时间")
|
||||
@ColDefine(type = ColType.DATETIME)
|
||||
private Date selectTime;
|
||||
|
||||
@Column
|
||||
@Comment("收货地址")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 100)
|
||||
private String receiveAddress;
|
||||
|
||||
@Column
|
||||
@Comment("用户签字")
|
||||
@ColDefine(type = ColType.TEXT)
|
||||
private String userSign;
|
||||
|
||||
@Column
|
||||
@Comment("快递单号")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 50)
|
||||
private String courierNumber;
|
||||
|
||||
@Column
|
||||
@Comment("是否签收")
|
||||
@ColDefine(type = ColType.BOOLEAN)
|
||||
private Boolean isReceive;
|
||||
|
||||
@Column
|
||||
@Comment("选择数量")
|
||||
@ColDefine(type = ColType.INT)
|
||||
private Integer selectNum;
|
||||
|
||||
@Column
|
||||
@Comment("物流信息")
|
||||
@ColDefine(type = ColType.MYSQL_JSON)
|
||||
private LogisticsTrace logisticsTrace;
|
||||
|
||||
@Column
|
||||
@Comment("上次查询物流信息的时间")
|
||||
@ColDefine(type = ColType.DATETIME)
|
||||
private Date selectExpressDate;
|
||||
|
||||
@Data
|
||||
public static class LogisticsTrace {
|
||||
//运单号物流流转当前最新变更时间
|
||||
private Date theLastTime;
|
||||
//运单号物流流转当前最新描述
|
||||
private String theLastMessage;
|
||||
//运单号当前物流状态文字描述
|
||||
private String logisticsStatusDesc;
|
||||
//物流流转状态(WAIT_ACCEPT:)
|
||||
private String logisticsStatus;
|
||||
//物流流转明细
|
||||
private List<NutMap> logisticsTraceDetailList;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
package io.v.nutz.zhgh.welfare.model;
|
||||
|
||||
import io.v.nutz.zhgh.welfare.mode.WelfareVoucherOrigin;
|
||||
import io.v.nutz.zhgh.welfare.mode.WelfareVoucherStatus;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
import org.nutz.dao.entity.annotation.*;
|
||||
import org.nutz.dao.interceptor.annotation.PrevInsert;
|
||||
|
||||
/**
|
||||
* 礼品券
|
||||
*
|
||||
* @author: 1V
|
||||
* @date: 2021/3/15
|
||||
* @since 1.0
|
||||
*/
|
||||
@Table("welfare_voucher")
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class WelfareVoucher {
|
||||
@Name
|
||||
@Column
|
||||
@Comment("ID")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 32)
|
||||
@PrevInsert(uu32 = true)
|
||||
private String id;
|
||||
|
||||
@Column
|
||||
@Comment("福利项目ID")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 32)
|
||||
private String projectId;
|
||||
|
||||
@Column
|
||||
@Comment("用户ID")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 32)
|
||||
private String userId;
|
||||
|
||||
@Column
|
||||
@Comment("礼品发放员")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 32)
|
||||
private String issuedBy;
|
||||
|
||||
@Column
|
||||
@Comment("领券时间")
|
||||
private Long grantTime;
|
||||
|
||||
@Column
|
||||
@Comment("使用时间")
|
||||
private Long useTime;
|
||||
|
||||
/**
|
||||
* @see WelfareVoucherOrigin
|
||||
*/
|
||||
@Column
|
||||
@Comment("来源")
|
||||
private Integer origin;
|
||||
|
||||
/**
|
||||
* @see WelfareVoucherStatus
|
||||
*/
|
||||
@Column
|
||||
@Comment("状态")
|
||||
private Integer status;
|
||||
|
||||
@Column
|
||||
@Comment("赠予人id")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 32)
|
||||
private String donateUserId;
|
||||
|
||||
/**
|
||||
* 采用乐观锁
|
||||
*/
|
||||
@Column(value = "version")
|
||||
private int version;
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package io.v.nutz.zhgh.welfare.model.template;
|
||||
|
||||
import cn.afterturn.easypoi.excel.annotation.Excel;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* @ClassName ExportEntityTc
|
||||
* @Description 导出套餐模版
|
||||
* @Author zhf
|
||||
* @Date 2024/5/8 15:58
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class WelfareExportEntityTc {
|
||||
@Excel(name = "工号", width = 20d)
|
||||
private String loginName;
|
||||
|
||||
@Excel(name = "姓名", width = 20d)
|
||||
private String userName;
|
||||
|
||||
@Excel(name = "所属工会", width = 20d)
|
||||
private String unionName;
|
||||
|
||||
// @Excel(name = "所属单位", width = 60d)
|
||||
// private String unitName;
|
||||
|
||||
@Excel(name = "已选福利", width = 80d)
|
||||
private String optionName;
|
||||
|
||||
@Excel(name = "收货信息", width = 100d)
|
||||
private String receiveAddress;
|
||||
|
||||
@Excel(name = "快递单号", width = 40d)
|
||||
private String courierNumber;
|
||||
|
||||
@Excel(name = "实名签字", width = 20d, type = 2 , imageType = 2)
|
||||
private byte[] qzBytes;
|
||||
|
||||
private String userSign;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package io.v.nutz.zhgh.welfare.model.template;
|
||||
|
||||
import cn.afterturn.easypoi.excel.annotation.Excel;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 福利会员导入模板
|
||||
*
|
||||
* @author: 1V
|
||||
* @date: 2021/2/24
|
||||
* @since 1.0
|
||||
*/
|
||||
@Data
|
||||
public class WelfareMemberTemp {
|
||||
@Excel(name = "工号")
|
||||
private String loginName;
|
||||
|
||||
@Excel(name = "姓名")
|
||||
private String userName;
|
||||
|
||||
private String remarks;
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package io.v.nutz.zhgh.welfare.model.view;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* 福利单位视图
|
||||
*
|
||||
* @author: 1V
|
||||
* @date: 2021/2/24
|
||||
* @since 1.0
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class WelfareUnit {
|
||||
private String welfareUnitId;
|
||||
private String welfareUnitName;
|
||||
private String welfareUnitCode;
|
||||
private String welfareUnitMode;
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package io.v.nutz.zhgh.welfare.service;
|
||||
|
||||
import io.v.nutz.base.service.ViService;
|
||||
import io.v.nutz.zhgh.welfare.model.WelfareList;
|
||||
import org.nutz.lang.util.NutMap;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Todo
|
||||
*
|
||||
* @author: 1V
|
||||
* @date: 2021/1/25
|
||||
* @since 1.0
|
||||
*/
|
||||
public interface WelfareListService extends ViService<WelfareList> {
|
||||
/**
|
||||
* 生成名单
|
||||
*
|
||||
* @param projectId
|
||||
*/
|
||||
void createList(String projectId, boolean created);
|
||||
|
||||
/**
|
||||
* 加入福利名单
|
||||
*
|
||||
* @param projectId
|
||||
* @param userIds
|
||||
*/
|
||||
void joinWelfareList(String projectId, List<String> userIds);
|
||||
|
||||
List<NutMap> getToNotWelfareUsers(String projectId);
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package io.v.nutz.zhgh.welfare.service;
|
||||
|
||||
import io.v.nutz.base.query.PageForm;
|
||||
import io.v.nutz.base.service.ViService;
|
||||
import org.nutz.lang.util.NutMap;
|
||||
|
||||
/**
|
||||
* 发放名单汇总
|
||||
*/
|
||||
public interface WelfareListSummaryService extends ViService {
|
||||
|
||||
/**
|
||||
* 分工会/福利单位,集中发放
|
||||
*
|
||||
* @param pageForm
|
||||
* @param projectId
|
||||
* @return
|
||||
*/
|
||||
NutMap togetherPageData(PageForm pageForm, String projectId);
|
||||
|
||||
|
||||
/**
|
||||
* 个人
|
||||
*
|
||||
* @param pageForm
|
||||
* @param projectId
|
||||
* @param unionId
|
||||
* @return
|
||||
*/
|
||||
NutMap singlePageData(PageForm pageForm, String projectId, String unionId);
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package io.v.nutz.zhgh.welfare.service;
|
||||
|
||||
import io.v.nutz.base.service.ViService;
|
||||
import io.v.nutz.zhgh.welfare.model.WelfareMemberRecord;
|
||||
|
||||
/**
|
||||
* Todo
|
||||
*
|
||||
* @author: 1V
|
||||
* @date: 2021/1/25
|
||||
* @since 1.0
|
||||
*/
|
||||
public interface WelfareMemberRecordService extends ViService<WelfareMemberRecord> {
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package io.v.nutz.zhgh.welfare.service;
|
||||
|
||||
import io.v.nutz.base.service.ViService;
|
||||
import io.v.nutz.sys.models.Sys_user;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Todo
|
||||
*
|
||||
* @author: 1V
|
||||
* @date: 2021/1/25
|
||||
* @since 1.0
|
||||
*/
|
||||
public interface WelfareMemberService extends ViService<Sys_user> {
|
||||
|
||||
void doWelfareMemberSetMember(List<String> userIdList);
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package io.v.nutz.zhgh.welfare.service;
|
||||
|
||||
import io.v.nutz.base.service.ViService;
|
||||
import io.v.nutz.zhgh.welfare.model.WelfareProject;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Todo
|
||||
*
|
||||
* @author: 1V
|
||||
* @date: 2021/1/25
|
||||
* @since 1.0
|
||||
*/
|
||||
public interface WelfareProjectService extends ViService<WelfareProject> {
|
||||
|
||||
/**
|
||||
* 获取项目的信息
|
||||
*
|
||||
* @param projectId
|
||||
* @return
|
||||
*/
|
||||
WelfareProject projectInfo(String projectId);
|
||||
|
||||
List<WelfareProject> getIngWelfareProject();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,115 @@
|
||||
package io.v.nutz.zhgh.welfare.service;
|
||||
|
||||
import io.v.nutz.base.service.ViService;
|
||||
import io.v.nutz.zhgh.welfare.model.WelfareProject;
|
||||
import org.nutz.lang.util.NutMap;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.OutputStream;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author zxy
|
||||
* @Description 意向选择 邮寄到家类的统计
|
||||
* @createTime 2022年01月25日 13:58:00
|
||||
*/
|
||||
public interface WelfareSingleService extends ViService<WelfareProject> {
|
||||
|
||||
/**
|
||||
* 某年的福利信息 (弹性)
|
||||
*
|
||||
* @param year
|
||||
* @return
|
||||
*/
|
||||
List<NutMap> welfareProjectList(Integer year);
|
||||
|
||||
/**
|
||||
* 分工会信息
|
||||
*
|
||||
* @param unionId 分工会id
|
||||
* @param projectId 福利id
|
||||
* @return 每个分工会信息 及 该福利项目下分工会的福利会员人数
|
||||
*/
|
||||
List<NutMap> getUnionData(String unionId, String projectId);
|
||||
|
||||
/**
|
||||
* 获取某个福利下的题目 这个福利必然是弹性福利
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
List<NutMap> getOptionByProjectId(String projectId);
|
||||
|
||||
/**
|
||||
* 某个福利下以后选择的数据
|
||||
*
|
||||
* @param projectId
|
||||
* @return
|
||||
*/
|
||||
List<NutMap> getUserSelectionByProjectId(String projectId, String month);
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*
|
||||
* @param projectId 福利id
|
||||
* @return
|
||||
*/
|
||||
NutMap pageData(String projectId, String month, String welfareUnitCode, String unionGroupId,String personType);
|
||||
|
||||
|
||||
NutMap exportByUnit(String projectId, String welfareUnitCode);
|
||||
|
||||
NutMap exportByUnionGroup(String projectId, String welfareUnitCode);
|
||||
|
||||
|
||||
/**
|
||||
* 领取详情
|
||||
*
|
||||
* @param projectId 福利id
|
||||
* @return
|
||||
*/
|
||||
List<NutMap> receivePageData(String projectId, String welfareUnitCode, String month);
|
||||
|
||||
/**
|
||||
* 导出发放详细表
|
||||
*
|
||||
* @param projectId
|
||||
* @return
|
||||
*/
|
||||
List<NutMap> receivePageDataColumns(String projectId);
|
||||
|
||||
/**
|
||||
* 未领取人员信息
|
||||
*
|
||||
* @param projectId
|
||||
* @param welfareUnitCode
|
||||
* @return
|
||||
*/
|
||||
List<NutMap> unclaimedData(String projectId, String welfareUnitCode, String month);
|
||||
|
||||
void exportReceiveDetail(String projectId, String welfareUnitId, List<NutMap> allUser, List<NutMap> userChoose, OutputStream outputStream) throws Exception;
|
||||
|
||||
|
||||
void oneShopExport(String projectId, String month, String welfareUnitId, OutputStream outputStream) throws Exception;
|
||||
|
||||
|
||||
/**
|
||||
* @param projectId
|
||||
* @param welfareUnitCode
|
||||
* @param flag
|
||||
* @param response
|
||||
* @author zhf
|
||||
* @description 导出已选为选名单
|
||||
*/
|
||||
void exportReceiveDetailList(String projectId, String welfareUnitCode, Boolean flag, HttpServletResponse response);
|
||||
|
||||
/**
|
||||
* 获取这个项目所有的福利会员
|
||||
*
|
||||
* @param projectId
|
||||
* @param month
|
||||
* @return
|
||||
*/
|
||||
List<NutMap> getUserByProjectId(String projectId, String month, String unionGroupId);
|
||||
|
||||
List<NutMap> getUserChooseByProjectId(String projectId, String month, String unionGroupId);
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
package io.v.nutz.zhgh.welfare.service;
|
||||
|
||||
import io.v.nutz.base.service.ViService;
|
||||
import io.v.nutz.zhgh.welfare.mode.voucher.WelfareVoucherDonateReceiveResult;
|
||||
import io.v.nutz.zhgh.welfare.model.WelfareVoucher;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Todo
|
||||
*
|
||||
* @author: 1V
|
||||
* @date: 2021/1/25
|
||||
* @since 1.0
|
||||
*/
|
||||
public interface WelfareVoucherService extends ViService<WelfareVoucher> {
|
||||
|
||||
/**
|
||||
* 发放礼品
|
||||
*
|
||||
* @param voucherId 券id
|
||||
* @param userid 发放人id
|
||||
* @return 持券人信息
|
||||
*/
|
||||
Map<String, Object> grantGift(String voucherId, String userid);
|
||||
|
||||
/**
|
||||
* 获取礼品券详细信息
|
||||
*
|
||||
* @param voucherId 券id
|
||||
* @return 礼品券详细信息
|
||||
*/
|
||||
Map<String, Object> voucherInfo(String voucherId);
|
||||
|
||||
/**
|
||||
* 转赠领取
|
||||
*
|
||||
* @param voucherId 券id
|
||||
* @param userid 被转赠人id
|
||||
* @return 领取结果
|
||||
*/
|
||||
WelfareVoucherDonateReceiveResult donateReceive(String voucherId, String userid);
|
||||
|
||||
/**
|
||||
* 获取礼品券详细信息
|
||||
*
|
||||
* @param voucherId 券id
|
||||
* @return 礼品券详细信息
|
||||
*/
|
||||
Map<String, Object> donateVoucherInfo(String voucherId);
|
||||
|
||||
/**
|
||||
* 将礼品券的状态改为已赠但是未领
|
||||
*
|
||||
* @param voucherId 券id
|
||||
*/
|
||||
void voucherDonating(String voucherId);
|
||||
|
||||
/**
|
||||
* 领取礼品券
|
||||
*
|
||||
* @param projectId 项目
|
||||
* @param userid 用户
|
||||
* @return
|
||||
*/
|
||||
WelfareVoucher grantVoucher(String projectId, String userid);
|
||||
|
||||
/**
|
||||
* 该用户待领取的礼品券
|
||||
*
|
||||
* @param userid
|
||||
* @return
|
||||
*/
|
||||
List unclaimedVoucher(String userid);
|
||||
}
|
||||
@@ -0,0 +1,166 @@
|
||||
package io.v.nutz.zhgh.welfare.service.impl;
|
||||
|
||||
import io.v.nutz.base.dao.CndPlus;
|
||||
import io.v.nutz.base.service.impl.ViServiceImpl;
|
||||
import io.v.nutz.sys.models.Sys_user;
|
||||
import io.v.nutz.zhgh.welfare.model.WelfareList;
|
||||
import io.v.nutz.zhgh.welfare.model.WelfareMemberCheckUser;
|
||||
import io.v.nutz.zhgh.welfare.model.WelfareProject;
|
||||
import io.v.nutz.zhgh.welfare.model.WelfareUserSelection;
|
||||
import io.v.nutz.zhgh.welfare.service.WelfareListService;
|
||||
import io.v.nutz.zhgh.welfare.service.WelfareProjectService;
|
||||
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.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.plugins.wkcache.annotation.CacheDefaults;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
||||
/**
|
||||
* @author 1V
|
||||
*/
|
||||
@IocBean(args = {"refer:dao"})
|
||||
@CacheDefaults(cacheName = "welfare_list")
|
||||
public class WelfareListServiceImpl extends ViServiceImpl<WelfareList> implements WelfareListService {
|
||||
public WelfareListServiceImpl(Dao dao) {
|
||||
super(dao);
|
||||
}
|
||||
|
||||
@Inject
|
||||
private WelfareProjectService projectService;
|
||||
|
||||
@Override
|
||||
@Aop(TransAop.READ_COMMITTED)
|
||||
public void createList(String projectId, boolean created) {
|
||||
WelfareProject project = projectService.projectInfo(projectId);
|
||||
|
||||
CndPlus cnd = CndPlus.create();
|
||||
|
||||
//如果是更新
|
||||
if (created) {
|
||||
Cnd cndMemberUser = Cnd.NEW();
|
||||
|
||||
List<String> userIds;
|
||||
|
||||
if (project.getIsYearBirthday() != null && project.getIsYearBirthday()) {
|
||||
//如果是补发生日福利
|
||||
List<WelfareMemberCheckUser> checkUserList = dao().query(WelfareMemberCheckUser.class,
|
||||
Cnd.where("taskId", "=", project.getTaskId())
|
||||
.and("isDelete", "=", 0));
|
||||
List<String> welfareMemberUserIds = checkUserList.stream().map(v -> v.getUserId()).collect(Collectors.toList());
|
||||
|
||||
//删除在福利名单内,并且符合上面条件的人
|
||||
dao().clear(WelfareUserSelection.class, Cnd.where("welfareId", "=", projectId).and("selectUserId", "not in", welfareMemberUserIds));
|
||||
dao().clear(WelfareList.class, Cnd.where("projectId", "=", projectId).and("userId", "not in", welfareMemberUserIds));
|
||||
|
||||
cnd.andEX("userId", "not in", welfareMemberUserIds);
|
||||
|
||||
|
||||
} else {
|
||||
|
||||
cndMemberUser.and(Cnd.exps("welfareMember", "=", 0).or("welfareMember", "is", null));
|
||||
|
||||
//从user找出不是福利会员的人,并且不符合发放范围的人
|
||||
List<Sys_user> welfareMember = dao().query(Sys_user.class, cndMemberUser);
|
||||
List<String> ids = welfareMember.stream().map(Sys_user::getId).collect(Collectors.toList());
|
||||
List<WelfareList> lists = query(Cnd.where("projectId", "=", projectId).and("userId", "in", ids));
|
||||
userIds = lists.stream().map(WelfareList::getUserId).collect(Collectors.toList());
|
||||
|
||||
|
||||
List<WelfareList> welfareLists = query(Cnd.where("projectId", "=", projectId));
|
||||
List<String> users = welfareLists.stream().map(WelfareList::getUserId).collect(Collectors.toList());
|
||||
cnd.andEX("id", "not in", users);
|
||||
|
||||
|
||||
//删除在福利名单内,并且符合上面条件的人
|
||||
dao().clear(WelfareUserSelection.class, Cnd.where("welfareId", "=", projectId).and("selectUserId", "in", userIds));
|
||||
dao().clear(WelfareList.class, Cnd.where("projectId", "=", projectId).and("userId", "in", userIds));
|
||||
}
|
||||
|
||||
|
||||
} else {
|
||||
clear(Cnd.where("projectId", "=", projectId));
|
||||
dao().clear(WelfareUserSelection.class, Cnd.where("welfareId", "=", projectId));
|
||||
}
|
||||
|
||||
|
||||
if (project.getIsYearBirthday()) {
|
||||
List<WelfareMemberCheckUser> checkUserList = dao().query(WelfareMemberCheckUser.class,
|
||||
Cnd.where("taskId", "=", project.getTaskId()).and("isDelete", "=", 0));
|
||||
List<NutMap> checkUserMap = checkUserList.stream()
|
||||
.map(user -> new NutMap().addv("id", user.getUserId())
|
||||
.addv("unionid", user.getUnionId())
|
||||
.addv("unitid", user.getUnitId())
|
||||
.addv("userState", user.getUserState())
|
||||
.addv("personType", user.getPersonType()))
|
||||
.collect(Collectors.toList());
|
||||
joinWelfareList(checkUserMap, projectId);
|
||||
} else {
|
||||
if (project.getConditionStructure() != null) {
|
||||
project.getConditionStructure().join(cnd);
|
||||
}
|
||||
Sql sql = Sqls.create("SELECT * from `welfare_member` $condition");
|
||||
sql.setCondition(cnd);
|
||||
joinWelfareList(listMap(sql), projectId);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<NutMap> getToNotWelfareUsers(String projectId) {
|
||||
Sql sql = Sqls.create("""
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
view_welfare_list
|
||||
WHERE
|
||||
projectId = @projectId
|
||||
AND id NOT IN (
|
||||
SELECT
|
||||
selectUserId
|
||||
FROM
|
||||
welfare_project_user_selection
|
||||
WHERE
|
||||
welfareId = projectId)
|
||||
""").setParam("projectId", projectId);
|
||||
return listMap(sql);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Aop(TransAop.READ_COMMITTED)
|
||||
public void joinWelfareList(String projectId, List<String> userIds) {
|
||||
Sql sql = Sqls.create("SELECT * from `user` $condition");
|
||||
CndPlus cnd = CndPlus.create();
|
||||
cnd.and("id", "in", userIds);
|
||||
sql.setCondition(cnd);
|
||||
// joinWelfareList(listMap(sql), projectId);
|
||||
}
|
||||
|
||||
private void joinWelfareList(List<NutMap> users, String projectId) {
|
||||
List<WelfareList> lists = new ArrayList<>();
|
||||
for (NutMap user : users) {
|
||||
WelfareList list = new WelfareList();
|
||||
list.setProjectId(projectId);
|
||||
list.setUserId(user.getString("id"));
|
||||
list.setWelfareUnitId(user.getString("unionid"));
|
||||
list.setWelfareSecondLevelUnitId(user.getString("unitid"));
|
||||
list.setUserState(user.getString("userState"));
|
||||
list.setPersonType(user.getString("personType"));
|
||||
lists.add(list);
|
||||
}
|
||||
dao().insert(lists);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,134 @@
|
||||
package io.v.nutz.zhgh.welfare.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import io.v.nutz.base.dao.CndPlus;
|
||||
import io.v.nutz.base.query.PageForm;
|
||||
import io.v.nutz.base.service.impl.ViServiceImpl;
|
||||
import io.v.nutz.sys.models.Sys_dict;
|
||||
import io.v.nutz.zhgh.welfare.mode.WelfareUnitMode;
|
||||
import io.v.nutz.zhgh.welfare.service.WelfareListSummaryService;
|
||||
import io.v.nutz.zhgh.welfare.service.WelfareSingleService;
|
||||
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.Strings;
|
||||
import org.nutz.lang.util.NutMap;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@IocBean(args = {"refer:dao"})
|
||||
public class WelfareListSummaryServiceImpl extends ViServiceImpl implements WelfareListSummaryService {
|
||||
|
||||
@Inject
|
||||
private WelfareSingleService welfareSingleService;
|
||||
|
||||
public WelfareListSummaryServiceImpl(Dao dao) {
|
||||
super(dao);
|
||||
}
|
||||
|
||||
@Override
|
||||
public NutMap togetherPageData(PageForm pageForm, String projectId) {
|
||||
//获取所有人员类型
|
||||
Sys_dict dict = dao().fetch(Sys_dict.class, Cnd.where("code", "=", "UserType"));
|
||||
List<Sys_dict> userTypeDictList = dict == null ? new ArrayList<>() : dao().query(Sys_dict.class, Cnd.where("parentId", "=", Strings.sNull(dict.getId())).and("disabled", "=", false).asc("location"));
|
||||
List<String> userTypeList = userTypeDictList.stream().map(Sys_dict::getCode).collect(Collectors.toList());
|
||||
List<NutMap> labelList = userTypeDictList.stream().map(v -> NutMap.NEW().addv("prop", v.getCode()).addv("label", v.getName())).collect(Collectors.toList());
|
||||
|
||||
List<String> typeList = new ArrayList<>();
|
||||
typeList.add("事业编制");
|
||||
typeList.add("非事业编制");
|
||||
typeList.add("劳务派遣");
|
||||
typeList.add("其它");
|
||||
typeList.add("合计");
|
||||
List<NutMap> userTypeList2 = labelList.stream().filter(v -> !typeList.contains(v.getString("label"))).collect(Collectors.toList());
|
||||
List<String> userTypeListLabel = userTypeList2.stream().map(v -> v.getString("label")).collect(Collectors.toList());
|
||||
Sql sql = Sqls.create("""
|
||||
SELECT
|
||||
unit.*,
|
||||
sum( 1 ) number,
|
||||
$temp_sql
|
||||
FROM
|
||||
welfare_unit unit
|
||||
LEFT JOIN welfare_list list ON unit.welfareUnitId = list.welfareUnitId
|
||||
LEFT JOIN `user` su ON su.id = list.userId
|
||||
$condition
|
||||
""");
|
||||
StringBuffer temp_sql_str = new StringBuffer();
|
||||
userTypeList.forEach(v -> {
|
||||
temp_sql_str.append("COUNT( CASE WHEN ( su.personType = '%s' ) THEN 1 ELSE NULL END ) AS '%s',".formatted(v, v));
|
||||
});
|
||||
|
||||
String totalUserType = CollUtil.join(userTypeList, ",", "'", "'");
|
||||
String totalUserType2 = CollUtil.join(userTypeListLabel, ",", "'", "'");
|
||||
temp_sql_str.append("COUNT( CASE WHEN ( su.personType in (%s) ) THEN 1 ELSE NULL END ) AS '其它',".formatted(totalUserType2));
|
||||
temp_sql_str.append("COUNT( CASE WHEN ( su.personType in (%s) ) THEN 1 ELSE NULL END ) AS totalNum".formatted(totalUserType));
|
||||
sql.setVar("temp_sql", temp_sql_str);
|
||||
|
||||
CndPlus cnd = CndPlus.create();
|
||||
cnd.and("unit.welfareUnitMode", "=", WelfareUnitMode.getMode().name());
|
||||
pageForm.defaultSortAsc("unit.welfareUnitCode");
|
||||
cnd.and(pageForm);
|
||||
cnd.and("list.projectId", "=", projectId);
|
||||
cnd.groupBy("unit.welfareUnitId");
|
||||
sql.setCondition(cnd);
|
||||
labelList.add(NutMap.NEW().addv("prop", "其它").addv("label", "其它"));
|
||||
labelList.add(NutMap.NEW().addv("prop", "totalNum").addv("label", "合计"));
|
||||
|
||||
return NutMap.WRAP(Map.of("tableList", listMap(sql), "tableColumn", labelList.stream().filter(v -> typeList.contains(v.getString("label"))).collect(Collectors.toList())));
|
||||
}
|
||||
|
||||
@Override
|
||||
public NutMap singlePageData(PageForm pageForm, String projectId, String unionId) {
|
||||
Sql welfareUnitSql = Sqls.create("""
|
||||
SELECT
|
||||
unit.*,
|
||||
( SELECT count( 1 ) FROM view_welfare_list WHERE unioncode = unit.welfareUnitCode AND projectId = @projectId ) AS teacherSum\s
|
||||
FROM
|
||||
welfare_unit unit
|
||||
$condition
|
||||
""");
|
||||
CndPlus cnd = CndPlus.create();
|
||||
cnd.and("unit.welfareUnitMode", "=", WelfareUnitMode.getMode().name());
|
||||
pageForm.defaultSortAsc("unit.welfareUnitCode");
|
||||
cnd.and(pageForm);
|
||||
cnd.groupBy("unit.welfareUnitId");
|
||||
welfareUnitSql.setCondition(cnd);
|
||||
welfareUnitSql.setParam("projectId", projectId);
|
||||
List<NutMap> welfareUnitList = listMap(welfareUnitSql);
|
||||
|
||||
//选项数据
|
||||
List<NutMap> optionList = welfareSingleService.getOptionByProjectId(projectId);
|
||||
//选择数据
|
||||
List<NutMap> userSelectionList = welfareSingleService.getUserSelectionByProjectId(projectId, null);
|
||||
for (NutMap wUnit : welfareUnitList) {
|
||||
//该分工会选择数据
|
||||
List<NutMap> thisUnionSelectionList = userSelectionList.stream().filter(x -> x.getString("unionCode").equals(wUnit.getString("welfareUnitCode")) && x.getString("welfareId").equals(projectId)).collect(Collectors.toList());
|
||||
optionList.forEach(o -> {
|
||||
//每一项选择的人数
|
||||
long count = thisUnionSelectionList.stream().filter(z -> z.getString("selectOptionId").equals(o.getString("id"))).count();
|
||||
wUnit.put(o.getString("optionName"), count);
|
||||
});
|
||||
//已选人数
|
||||
wUnit.put("totalCount", thisUnionSelectionList.size());
|
||||
//未选人数
|
||||
wUnit.put("unselectedTeacherSum", wUnit.getInt("teacherSum") - wUnit.getInt("totalCount"));
|
||||
}
|
||||
//表格列数据
|
||||
List<NutMap> labelList = new ArrayList<>();
|
||||
labelList.add(NutMap.NEW().addv("label", "本次福利会员人数").addv("prop", "teacherSum"));
|
||||
optionList.forEach(v -> {
|
||||
labelList.add(NutMap.NEW().addv("label", v.getString("optionName")).addv("prop", v.getString("optionName")));
|
||||
});
|
||||
labelList.add(NutMap.NEW().addv("label", "参加人数").addv("prop", "totalCount"));
|
||||
labelList.add(NutMap.NEW().addv("label", "未选人数").addv("prop", "unselectedTeacherSum"));
|
||||
|
||||
return NutMap.NEW().addv("tableList", welfareUnitList).addv("tableColumn", labelList);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package io.v.nutz.zhgh.welfare.service.impl;
|
||||
|
||||
import io.v.nutz.base.service.impl.ViServiceImpl;
|
||||
import io.v.nutz.zhgh.welfare.model.WelfareMemberRecord;
|
||||
import io.v.nutz.zhgh.welfare.service.WelfareMemberRecordService;
|
||||
import org.nutz.dao.Dao;
|
||||
import org.nutz.ioc.loader.annotation.IocBean;
|
||||
import org.nutz.plugins.wkcache.annotation.CacheDefaults;
|
||||
|
||||
|
||||
/**
|
||||
* @author 1V
|
||||
*/
|
||||
@IocBean(args = {"refer:dao"})
|
||||
@CacheDefaults(cacheName = "member")
|
||||
public class WelfareMemberRecordServiceImpl extends ViServiceImpl<WelfareMemberRecord> implements WelfareMemberRecordService {
|
||||
public WelfareMemberRecordServiceImpl(Dao dao) {
|
||||
super(dao);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
package io.v.nutz.zhgh.welfare.service.impl;
|
||||
|
||||
import io.v.nutz.base.utils.Roles;
|
||||
import io.v.nutz.base.service.impl.ViServiceImpl;
|
||||
import io.v.nutz.sys.models.Sys_user;
|
||||
import io.v.nutz.sys.models.Sys_user_role;
|
||||
import io.v.nutz.sys.services.SysRoleService;
|
||||
import io.v.nutz.sys.services.SysUserService;
|
||||
import io.v.nutz.zhgh.welfare.service.WelfareMemberService;
|
||||
import org.nutz.aop.interceptor.ioc.TransAop;
|
||||
import org.nutz.dao.Chain;
|
||||
import org.nutz.dao.Cnd;
|
||||
import org.nutz.dao.Dao;
|
||||
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.plugins.wkcache.annotation.CacheDefaults;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
||||
/**
|
||||
* @author 1V
|
||||
*/
|
||||
@IocBean(args = {"refer:dao"})
|
||||
@CacheDefaults(cacheName = "welfare_member")
|
||||
public class WelfareMemberServiceImpl extends ViServiceImpl<Sys_user> implements WelfareMemberService {
|
||||
public WelfareMemberServiceImpl(Dao dao) {
|
||||
super(dao);
|
||||
}
|
||||
|
||||
@Inject
|
||||
private SysUserService sysUserService;
|
||||
|
||||
@Inject
|
||||
private SysRoleService sysRoleService;
|
||||
|
||||
@Override
|
||||
@Aop(TransAop.READ_COMMITTED)
|
||||
public void doWelfareMemberSetMember(List<String> userIdList) {
|
||||
Dao dao = sysUserService.dao();
|
||||
dao.update(Sys_user.class, Chain.make("member",1), Cnd.where("id","in",userIdList));
|
||||
//查询有会员角色的福利会员
|
||||
List<String> hasMemberRoleWelfareList = dao.query(Sys_user_role.class, Cnd.where("roleId", "=", Roles.MEMBER)
|
||||
.and("userId","in",userIdList)).stream().map(Sys_user_role::getUserId).collect(Collectors.toList());
|
||||
//查出福利会员中是会员但没有会员角色的人
|
||||
List<String> hasNotMemberRoleWelfareUserList = sysUserService.query(Cnd.where("member", "=", 1)
|
||||
.and("id", "NOT IN", hasMemberRoleWelfareList)).stream()
|
||||
.filter(userIdList::contains).map(Sys_user::getId).collect(Collectors.toList());
|
||||
List<Sys_user_role> userRoleList = new ArrayList<>();
|
||||
if (Lang.isNotEmpty(hasNotMemberRoleWelfareUserList)) {
|
||||
hasNotMemberRoleWelfareUserList.forEach(v -> {
|
||||
Sys_user_role userRole = new Sys_user_role();
|
||||
userRole.setRoleId(Roles.MEMBER);
|
||||
userRole.setUserId(v);
|
||||
userRoleList.add(userRole);
|
||||
});
|
||||
sysUserService.dao().insert(userRoleList);
|
||||
sysUserService.clearCache();
|
||||
sysRoleService.clearCache();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
package io.v.nutz.zhgh.welfare.service.impl;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import io.v.nutz.base.service.BaseService;
|
||||
import io.v.nutz.zhgh.data.model.MatchConditionStructure;
|
||||
import io.v.nutz.base.service.impl.ViServiceImpl;
|
||||
import io.v.nutz.web.commons.utils.ShiroUtil;
|
||||
import io.v.nutz.zhgh.welfare.model.WelfareProject;
|
||||
import io.v.nutz.zhgh.welfare.model.WelfareProjectSubject;
|
||||
import io.v.nutz.zhgh.welfare.service.WelfareProjectService;
|
||||
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 org.nutz.plugins.wkcache.annotation.CacheDefaults;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
||||
/**
|
||||
* @author 1V
|
||||
*/
|
||||
@IocBean(args = {"refer:dao"})
|
||||
@CacheDefaults(cacheName = "welfare_project")
|
||||
public class WelfareProjectServiceImpl extends ViServiceImpl<WelfareProject> implements WelfareProjectService {
|
||||
public WelfareProjectServiceImpl(Dao dao) {
|
||||
super(dao);
|
||||
}
|
||||
|
||||
@Inject
|
||||
private BaseService baseService;
|
||||
|
||||
@Override
|
||||
public WelfareProject projectInfo(String projectId) {
|
||||
// WelfareProject project = fetchLinks(projectId);
|
||||
WelfareProject project = fetchLinks(dao().fetch(WelfareProject.class, Cnd.where("id", "=", projectId)), "welfareProjectSubjects");
|
||||
List<WelfareProjectSubject> welfareProjectSubjects = project.getWelfareProjectSubjects();
|
||||
Sql sqlo = Sqls.create("""
|
||||
SELECT
|
||||
optionName
|
||||
FROM
|
||||
welfare_project_subject_option
|
||||
WHERE
|
||||
id IN ( SELECT selectOptionId FROM welfare_project_user_selection WHERE selectUserId = @userid AND welfareId = @welfareId )
|
||||
ORDER BY
|
||||
optionSort ASC
|
||||
""");
|
||||
sqlo.setParam("userid", ShiroUtil.getPrincipalProperty("id"));
|
||||
sqlo.setParam("welfareId", project.getId());
|
||||
List<NutMap> optionNameList = baseService.listMap(sqlo);
|
||||
if (Lang.isNotEmpty(optionNameList)) {
|
||||
project.setGift(optionNameList.stream().map(x -> x.getString("optionName")).collect(Collectors.joining("、")));
|
||||
}
|
||||
if (Lang.isNotEmpty(welfareProjectSubjects)) {
|
||||
fetchLinks(welfareProjectSubjects, "options", Cnd.NEW().asc("optionSort"));
|
||||
}
|
||||
if (Strings.isNotBlank(project.getConditionStructureId())) {
|
||||
MatchConditionStructure conditionStructure = fetchLinks(dao().fetch(MatchConditionStructure.class, project.getConditionStructureId()), "conditions");
|
||||
project.setConditionStructure(conditionStructure);
|
||||
}
|
||||
return project;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<WelfareProject> getIngWelfareProject() {
|
||||
return dao().query(WelfareProject.class, Cnd.where("choiceTimeStart", "<=", DateUtil.date())
|
||||
.and("choiceTimeEnd", ">=", DateUtil.date()));
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,265 @@
|
||||
package io.v.nutz.zhgh.welfare.service.impl;
|
||||
|
||||
import io.v.nutz.base.service.impl.ViServiceImpl;
|
||||
import io.v.nutz.zhgh.welfare.mode.WelfareProvideMode;
|
||||
import io.v.nutz.zhgh.welfare.mode.WelfareSignMode;
|
||||
import io.v.nutz.zhgh.welfare.mode.WelfareVoucherOrigin;
|
||||
import io.v.nutz.zhgh.welfare.mode.WelfareVoucherStatus;
|
||||
import io.v.nutz.zhgh.welfare.mode.voucher.WelfareGiftGrantResult;
|
||||
import io.v.nutz.zhgh.welfare.mode.voucher.WelfareVoucherDonateReceiveResult;
|
||||
import io.v.nutz.zhgh.welfare.model.WelfareProject;
|
||||
import io.v.nutz.zhgh.welfare.model.WelfareVoucher;
|
||||
import io.v.nutz.zhgh.welfare.service.WelfareProjectService;
|
||||
import io.v.nutz.zhgh.welfare.service.WelfareVoucherService;
|
||||
import org.nutz.aop.interceptor.ioc.TransAop;
|
||||
import org.nutz.dao.Chain;
|
||||
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.util.NutMap;
|
||||
import org.nutz.plugins.wkcache.annotation.CacheDefaults;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
/**
|
||||
* @author 1V
|
||||
*/
|
||||
@IocBean(args = {"refer:dao"})
|
||||
@CacheDefaults(cacheName = "welfare_voucher")
|
||||
public class WelfareVoucherServiceImpl extends ViServiceImpl<WelfareVoucher> implements WelfareVoucherService {
|
||||
public WelfareVoucherServiceImpl(Dao dao) {
|
||||
super(dao);
|
||||
}
|
||||
|
||||
@Inject
|
||||
private WelfareProjectService projectService;
|
||||
|
||||
@Override
|
||||
@Aop(TransAop.READ_COMMITTED)
|
||||
public Map<String, Object> grantGift(String voucherId, String userid) {
|
||||
|
||||
WelfareVoucher voucher = fetch(voucherId);
|
||||
|
||||
if (voucher == null) {
|
||||
return Map.of("result", WelfareGiftGrantResult.NotFound.map());
|
||||
}
|
||||
|
||||
WelfareProject project = projectService.fetch(voucher.getProjectId());
|
||||
|
||||
Date now = new Date();
|
||||
if (!(project.getProvideTimeStart().compareTo(now) < 0 && project.getProvideTimeEnd().compareTo(now) > 0)) {
|
||||
return Map.of("result", WelfareGiftGrantResult.TIMEOUT.map());
|
||||
}
|
||||
|
||||
Chain chain = Chain.make("status", WelfareVoucherStatus.USED.getCode())
|
||||
.add("useTime", System.currentTimeMillis())
|
||||
.add("issuedBy", userid);
|
||||
boolean success = update(chain, Cnd.where("id", "=", voucherId).and("status", "=", WelfareVoucherStatus.NORMAL.getCode())) > 0;
|
||||
|
||||
if (success) {
|
||||
Sql sql = Sqls.create("""
|
||||
SELECT
|
||||
`user`.username,
|
||||
`user`.loginname,
|
||||
`user`.unitname,
|
||||
`user`.unionname
|
||||
FROM
|
||||
welfare_voucher voucher
|
||||
LEFT JOIN `user` ON voucher.userId = `user`.id
|
||||
WHERE
|
||||
voucher.id = @id
|
||||
""").setParam("id", voucherId);
|
||||
|
||||
return Map.of("user", fetch(sql), "result", WelfareGiftGrantResult.SUCCESS.map());
|
||||
}
|
||||
|
||||
return Map.of("result", WelfareGiftGrantResult.GRANTED.map());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> voucherInfo(String voucherId) {
|
||||
Sql sql = Sqls.create("""
|
||||
SELECT
|
||||
voucher.id,
|
||||
voucher.`status`,
|
||||
project.`id` projectId,
|
||||
project.`name`,
|
||||
project.festival,
|
||||
project.provideAddress,
|
||||
project.gift,
|
||||
project.flexibleGifts,
|
||||
project.provideTimeStart,
|
||||
project.provideTimeEnd,
|
||||
`user`.username,
|
||||
`user`.loginname,
|
||||
`user`.unitname,
|
||||
`user`.unionname
|
||||
FROM
|
||||
welfare_voucher voucher
|
||||
LEFT JOIN welfare_project project ON voucher.projectId = project.id
|
||||
LEFT JOIN `user` ON voucher.userId = `user`.id
|
||||
WHERE
|
||||
voucher.id = @id
|
||||
""").setParam("id", voucherId);
|
||||
|
||||
NutMap result = fetch(sql);
|
||||
|
||||
result.setv("canget", result.getInt("status") == WelfareVoucherStatus.NORMAL.getCode());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Aop(TransAop.READ_COMMITTED)
|
||||
public WelfareVoucherDonateReceiveResult donateReceive(String voucherId, String userid) {
|
||||
WelfareVoucher voucher = fetch(voucherId);
|
||||
|
||||
WelfareVoucherDonateReceiveResult receiveResult = donateReceiveResult(voucher);
|
||||
if (receiveResult != null) {
|
||||
return receiveResult;
|
||||
}
|
||||
|
||||
int update = update(Chain.make("status", WelfareVoucherStatus.DONATE.getCode()),
|
||||
Cnd.where("id", "=", voucherId).and("status", "=", WelfareVoucherStatus.DONATING.getCode()));
|
||||
if (update < 1) {
|
||||
return WelfareVoucherDonateReceiveResult.FAIL;
|
||||
}
|
||||
|
||||
WelfareVoucher welfareVoucher = new WelfareVoucher()
|
||||
.setOrigin(WelfareVoucherOrigin.DONATE.getCode())
|
||||
.setProjectId(voucher.getProjectId())
|
||||
.setUserId(userid)
|
||||
.setDonateUserId(voucher.getUserId())
|
||||
.setGrantTime(System.currentTimeMillis())
|
||||
.setStatus(WelfareVoucherStatus.NORMAL.getCode());
|
||||
|
||||
insert(welfareVoucher);
|
||||
|
||||
return WelfareVoucherDonateReceiveResult.SUCCESS;
|
||||
}
|
||||
|
||||
private WelfareVoucherDonateReceiveResult donateReceiveResult(WelfareVoucher voucher) {
|
||||
if (voucher == null) {
|
||||
return WelfareVoucherDonateReceiveResult.FAIL;
|
||||
}
|
||||
|
||||
WelfareProject project = projectService.fetch(voucher.getProjectId());
|
||||
|
||||
if (voucher.getStatus() == WelfareVoucherStatus.DONATE.getCode()) {
|
||||
return WelfareVoucherDonateReceiveResult.DONATED;
|
||||
}
|
||||
|
||||
if (voucher.getStatus() == WelfareVoucherStatus.INVALID.getCode()) {
|
||||
return WelfareVoucherDonateReceiveResult.INVALID;
|
||||
}
|
||||
|
||||
if (project.getProvideTimeStart().compareTo(new Date()) <= 0) {
|
||||
return WelfareVoucherDonateReceiveResult.TIMEOUT;
|
||||
}
|
||||
|
||||
if (voucher.getStatus() != WelfareVoucherStatus.DONATING.getCode()) {
|
||||
return WelfareVoucherDonateReceiveResult.FAIL;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Map<String, Object> donateVoucherInfo(String voucherId) {
|
||||
|
||||
Sql sql = Sqls.create("""
|
||||
SELECT
|
||||
voucher.id,
|
||||
voucher.`status`,
|
||||
project.`id` projectId,
|
||||
project.`name`,
|
||||
project.festival,
|
||||
project.provideAddress,
|
||||
project.gift,
|
||||
project.flexibleGifts,
|
||||
project.provideTimeStart,
|
||||
project.provideTimeEnd,
|
||||
`user`.username donors
|
||||
FROM
|
||||
welfare_voucher voucher
|
||||
LEFT JOIN welfare_project project ON voucher.projectId = project.id
|
||||
LEFT JOIN sys_user `user` ON voucher.userId = `user`.id
|
||||
WHERE
|
||||
voucher.id = @id
|
||||
""").setParam("id", voucherId);
|
||||
|
||||
NutMap result = fetch(sql);
|
||||
|
||||
WelfareVoucherDonateReceiveResult receiveResult = donateReceiveResult(fetch(voucherId));
|
||||
result.put("result", receiveResult == null ? null : receiveResult.map());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Aop(TransAop.READ_COMMITTED)
|
||||
public void voucherDonating(String voucherId) {
|
||||
update(Chain.make("status", WelfareVoucherStatus.DONATING.getCode()), Cnd.where("id", "=", voucherId));
|
||||
}
|
||||
|
||||
@Override
|
||||
@Aop(TransAop.READ_COMMITTED)
|
||||
public WelfareVoucher grantVoucher(String projectId, String userid) {
|
||||
return insert(new WelfareVoucher()
|
||||
.setOrigin(WelfareVoucherOrigin.RECEIVE.getCode())
|
||||
.setProjectId(projectId)
|
||||
.setUserId(userid)
|
||||
.setGrantTime(System.currentTimeMillis())
|
||||
.setStatus(WelfareVoucherStatus.NORMAL.getCode())
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List unclaimedVoucher(String userid) {
|
||||
Sql sql = Sqls.create("""
|
||||
SELECT
|
||||
project.`id` projectId,
|
||||
project.`name`,
|
||||
project.festival,
|
||||
project.provideAddress,
|
||||
project.gift,
|
||||
project.flexibleGifts,
|
||||
project.provideTimeStart,
|
||||
project.provideTimeEnd
|
||||
FROM
|
||||
welfare_project project
|
||||
LEFT JOIN welfare_list list ON project.id = list.projectId
|
||||
LEFT JOIN welfare_voucher voucher ON (voucher.projectId = project.id AND voucher.userId = list.userId)
|
||||
$condition
|
||||
""");
|
||||
|
||||
Cnd cnd = Cnd.where("project.provideMode", "=", WelfareProvideMode.PERSONAL.getCode())
|
||||
.and("project.signMode", "in", List.of(WelfareSignMode.QRCODE.getCode(), WelfareSignMode.QRCODE_SIGNATURE.getCode()))
|
||||
.and("list.userId", "=", userid)
|
||||
.and(new Static("now() < project.provideTimeStart"))
|
||||
.and("voucher.id", "is", null);
|
||||
|
||||
cnd.desc("project.provideTimeStart");
|
||||
|
||||
sql.setCondition(cnd);
|
||||
|
||||
return listMap(sql);
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws InterruptedException {
|
||||
Date date = new Date();
|
||||
Thread.sleep(3000);
|
||||
Date date1 = new Date();
|
||||
System.err.println(date1.compareTo(date));
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user