init
This commit is contained in:
@@ -0,0 +1,88 @@
|
||||
package io.v.nutz.zhgh.insurance.controller;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import io.v.nutz.base.annontation.ViReturn;
|
||||
import io.v.nutz.base.page.Pagination;
|
||||
import io.v.nutz.base.service.BaseService;
|
||||
import io.v.nutz.zhgh.insurance.model.Insurance;
|
||||
import io.v.nutz.base.query.PageForm;
|
||||
import io.v.nutz.web.commons.utils.ShiroUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.shiro.authz.annotation.RequiresAuthentication;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.nutz.dao.Cnd;
|
||||
import org.nutz.dao.Dao;
|
||||
import org.nutz.dao.Sqls;
|
||||
import org.nutz.dao.sql.Sql;
|
||||
import org.nutz.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.POST;
|
||||
import org.nutz.mvc.annotation.Param;
|
||||
|
||||
/**
|
||||
* @Author JyuHsin
|
||||
* @Date 2023/5/12
|
||||
* @Description
|
||||
*/
|
||||
@IocBean
|
||||
@At("/platform/insurance/manage")
|
||||
@Slf4j
|
||||
@Ok("json:full")
|
||||
public class InsuranceController {
|
||||
|
||||
@Inject
|
||||
private Dao dao;
|
||||
|
||||
@Inject
|
||||
private BaseService baseService;
|
||||
|
||||
@At("")
|
||||
@RequiresPermissions("insurance.manage")
|
||||
@Ok("beetl:/platform/insurance/manage.html")
|
||||
public void index() {
|
||||
}
|
||||
|
||||
@At
|
||||
@ViReturn
|
||||
@RequiresAuthentication
|
||||
@RequiresPermissions("insurance.manage")
|
||||
public Object pageData(PageForm page, @Param(value = "year",required = false) Integer year,
|
||||
@Param(value = "name",required = false) String name) {
|
||||
Sql sql = Sqls.create("""
|
||||
SELECT
|
||||
ins.*,
|
||||
u.username
|
||||
FROM
|
||||
insurance ins
|
||||
LEFT JOIN `user` u on u.id = ins.userId
|
||||
$condition
|
||||
""");
|
||||
Cnd cnd = Cnd.NEW();
|
||||
cnd.andEX("year(startTime)", "=", year);
|
||||
cnd.and(Cnd.likeEX("name", name));
|
||||
sql.setCondition(cnd);
|
||||
Pagination pagination = baseService.listPageMap(page.getPageNumber(), page.getPageSize(), sql);
|
||||
return pagination;
|
||||
}
|
||||
|
||||
@At
|
||||
@ViReturn
|
||||
@POST
|
||||
@RequiresPermissions("insurance.manage")
|
||||
public Object doHandle(Insurance insurance) {
|
||||
insurance.setUserId(ShiroUtil.getPlatformUid());
|
||||
insurance.setCreateTime(DateUtil.now());
|
||||
dao.insertOrUpdate(insurance);
|
||||
return null;
|
||||
}
|
||||
|
||||
@At
|
||||
@ViReturn
|
||||
@RequiresPermissions("insurance.manage")
|
||||
public Object doDelete(String id) {
|
||||
dao.clear(Insurance.class, Cnd.where("id", "=", id));
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,168 @@
|
||||
package io.v.nutz.zhgh.insurance.controller;
|
||||
|
||||
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.page.Pagination;
|
||||
import io.v.nutz.base.service.BaseService;
|
||||
import io.v.nutz.base.utils.PageUtil;
|
||||
import io.v.nutz.zhgh.insurance.model.Insurance;
|
||||
import io.v.nutz.zhgh.insurance.model.InsuranceUser;
|
||||
import io.v.nutz.base.query.PageForm;
|
||||
import io.v.nutz.base.utils.ViTool;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.poi.ss.usermodel.Workbook;
|
||||
import org.apache.shiro.authz.annotation.RequiresAuthentication;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.nutz.dao.Cnd;
|
||||
import org.nutz.dao.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;
|
||||
|
||||
/**
|
||||
* @Author JyuHsin
|
||||
* @Date 2023/5/12
|
||||
* @Description
|
||||
*/
|
||||
@IocBean
|
||||
@At("/platform/insurance/summary")
|
||||
@Slf4j
|
||||
@Ok("json:full")
|
||||
public class InsuranceSummaryController {
|
||||
|
||||
@Inject
|
||||
private Dao dao;
|
||||
|
||||
@Inject
|
||||
private BaseService baseService;
|
||||
|
||||
@At("")
|
||||
@RequiresPermissions("insurance.summary")
|
||||
@Ok("beetl:/platform/insurance/summary.html")
|
||||
public void index() {
|
||||
}
|
||||
|
||||
@At
|
||||
@ViReturn
|
||||
@RequiresAuthentication
|
||||
@RequiresPermissions("insurance.summary")
|
||||
public Object pageData(PageForm page,
|
||||
@Param(value = "year",required = false) Integer year,
|
||||
@Param(value = "name",required = false) String name) {
|
||||
Sql sql = Sqls.create("""
|
||||
SELECT
|
||||
ins.*,
|
||||
u.username,
|
||||
(select count(*) from insurance_user iu where iu.insuranceId = ins.id) as chooseCount
|
||||
FROM
|
||||
insurance ins
|
||||
LEFT JOIN `user` u on u.id = ins.userId
|
||||
$condition
|
||||
""");
|
||||
Cnd cnd = Cnd.NEW();
|
||||
cnd.andEX("year(startTime)", "=", year);
|
||||
cnd.and(Cnd.likeEX("name", name));
|
||||
sql.setCondition(cnd);
|
||||
Pagination pagination = baseService.listPageMap(page.getPageNumber(), page.getPageSize(), sql);
|
||||
return pagination;
|
||||
}
|
||||
|
||||
@At
|
||||
@ViReturn
|
||||
@RequiresAuthentication
|
||||
@RequiresPermissions("insurance.summary")
|
||||
public Object userPageData(PageForm page, @Param(value = "unionId",required = false) String unionId,
|
||||
@Param(value = "unitId",required = false) String unitId,
|
||||
@Param(value = "insuranceId",required = false) String insuranceId) {
|
||||
Sql sql = Sqls.create("""
|
||||
SELECT
|
||||
iu.id,
|
||||
u.username,
|
||||
u.loginname,
|
||||
u.mobile,
|
||||
u.sex,
|
||||
u.unionname,
|
||||
u.unitname
|
||||
FROM
|
||||
insurance_user iu
|
||||
LEFT JOIN `user` u ON iu.userId = u.id
|
||||
$condition
|
||||
""");
|
||||
Cnd cnd = Cnd.NEW();
|
||||
cnd.and("iu.insuranceId", "=", insuranceId);
|
||||
cnd.andEX("u.unitid", "=", unitId);
|
||||
cnd.andEX("u.unionid", "=", unionId);
|
||||
if (Strings.isNotBlank(page.getSearchKeyword()) && Strings.isNotBlank(page.getSearchName())) {
|
||||
cnd.and(Cnd.likeEX(page.getSearchName(), page.getSearchKeyword()));
|
||||
}
|
||||
if (StrUtil.isAllNotBlank(page.getPageOrderName(), page.getPageOrderBy())) {
|
||||
cnd.orderBy(page.getPageOrderName(), PageUtil.getOrder(page.getPageOrderBy()));
|
||||
}
|
||||
sql.setCondition(cnd);
|
||||
return baseService.listPageMap(page.getPageNumber(), page.getPageSize(), sql);
|
||||
}
|
||||
|
||||
@At
|
||||
@ViReturn
|
||||
@RequiresPermissions("insurance.summary")
|
||||
public Object doDeleteUser(String id) {
|
||||
dao.clear(InsuranceUser.class, Cnd.where("id", "=", id));
|
||||
return null;
|
||||
}
|
||||
|
||||
@At
|
||||
@RequiresPermissions("insurance.summary")
|
||||
public void doExport(String id, HttpServletResponse response) {
|
||||
Insurance insurance = dao.fetch(Insurance.class, id);
|
||||
Sql sql = Sqls.create("""
|
||||
SELECT
|
||||
iu.id,
|
||||
u.username,
|
||||
u.loginname,
|
||||
u.mobile,
|
||||
u.sex,
|
||||
u.unionname,
|
||||
u.unitname
|
||||
FROM
|
||||
insurance_user iu
|
||||
LEFT JOIN `user` u ON iu.userId = u.id
|
||||
$condition
|
||||
""");
|
||||
Cnd cnd = Cnd.NEW();
|
||||
cnd.and("iu.insuranceId", "=", id);
|
||||
sql.setCondition(cnd);
|
||||
List<NutMap> list = baseService.listMap(sql);
|
||||
|
||||
List<ExcelExportEntity> entityList = new ArrayList<>();
|
||||
entityList.add(new ExcelExportEntity("姓名", "username", 20));
|
||||
entityList.add(new ExcelExportEntity("工号", "loginname", 20));
|
||||
entityList.add(new ExcelExportEntity("性别", "sex", 20));
|
||||
entityList.add(new ExcelExportEntity("联系方式", "mobile", 20));
|
||||
entityList.add(new ExcelExportEntity("所属单位", "unitname", 30));
|
||||
entityList.add(new ExcelExportEntity("所属工会", "unionname", 30));
|
||||
|
||||
try {
|
||||
ExportParams exportParams = new ExportParams();
|
||||
exportParams.setType(ExcelType.XSSF);
|
||||
ViTool.excelResponse(response, insurance.getName() + "选择人员明细.xlsx");
|
||||
Workbook workbook = ExcelExportUtil.exportExcel(exportParams, entityList, list);
|
||||
workbook.write(response.getOutputStream());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
package io.v.nutz.zhgh.insurance.controller.mobile;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import io.v.nutz.base.annontation.ViReturn;
|
||||
import io.v.nutz.base.page.Pagination;
|
||||
import io.v.nutz.base.service.BaseService;
|
||||
import io.v.nutz.zhgh.insurance.model.InsuranceUser;
|
||||
import io.v.nutz.base.query.PageForm;
|
||||
import io.v.nutz.web.commons.utils.ShiroUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.shiro.authz.annotation.RequiresAuthentication;
|
||||
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;
|
||||
|
||||
/**
|
||||
* @Author JyuHsin
|
||||
* @Date 2023/5/15
|
||||
* @Description
|
||||
*/
|
||||
@IocBean
|
||||
@At("/mobile/insurance/manage")
|
||||
@Slf4j
|
||||
@Ok("json:full")
|
||||
public class MInsuranceController {
|
||||
|
||||
@Inject
|
||||
private Dao dao;
|
||||
|
||||
@Inject
|
||||
private BaseService baseService;
|
||||
|
||||
@At("")
|
||||
@Ok("beetl:/mobile/insurance/insuranceRegister.html")
|
||||
public void index() {
|
||||
}
|
||||
|
||||
@At
|
||||
@ViReturn
|
||||
@RequiresAuthentication
|
||||
public Object pageData(PageForm page, Integer activityStatus) {
|
||||
Sql sql = Sqls.create("""
|
||||
SELECT
|
||||
ins.*,
|
||||
u.username,
|
||||
(select count(*) from insurance_user iu where insuranceId = ins.id and userId = @userId) as count
|
||||
FROM
|
||||
insurance ins
|
||||
LEFT JOIN `user` u on u.id = ins.userId
|
||||
$condition
|
||||
""").setParam("userId", ShiroUtil.getPlatformUid());
|
||||
Cnd cnd = Cnd.NEW();
|
||||
String dateTime = io.v.nutz.base.utils.DateUtil.getDateTime();
|
||||
if (activityStatus != null) {
|
||||
switch (activityStatus) {
|
||||
case 1 -> cnd.and("endTime", ">", dateTime).and("startTime", "<", dateTime);
|
||||
case 2 -> cnd.and("endTime", "<", dateTime);
|
||||
}
|
||||
}
|
||||
sql.setCondition(cnd);
|
||||
Pagination pagination = baseService.listPageMap(page.getPageNumber(), page.getPageSize(), sql);
|
||||
return pagination;
|
||||
}
|
||||
|
||||
@At
|
||||
@ViReturn
|
||||
public Object needChoose(String id) {
|
||||
InsuranceUser insuranceUser = new InsuranceUser();
|
||||
insuranceUser.setInsuranceId(id);
|
||||
insuranceUser.setUserId(ShiroUtil.getPlatformUid());
|
||||
insuranceUser.setChooseTime(DateUtil.now());
|
||||
dao.insert(insuranceUser);
|
||||
return null;
|
||||
}
|
||||
|
||||
@At
|
||||
@ViReturn
|
||||
public Object cancelChoose(String id) {
|
||||
dao.clear(InsuranceUser.class, Cnd.where("insuranceId", "=", id)
|
||||
.and("userId", "=", ShiroUtil.getPlatformUid()));
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
package io.v.nutz.zhgh.insurance.model;
|
||||
|
||||
import io.v.nutz.sys.models.Sys_file;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
import org.nutz.dao.entity.annotation.*;
|
||||
import org.nutz.dao.interceptor.annotation.PrevInsert;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author JyuHsin
|
||||
* @Date 2023/5/12
|
||||
* @Description
|
||||
*/
|
||||
@Data
|
||||
@Table("insurance")
|
||||
@Accessors(chain = true)
|
||||
public class Insurance {
|
||||
|
||||
@Name
|
||||
@PrevInsert(uu32 = true)
|
||||
private String id;
|
||||
|
||||
@Column
|
||||
@ColDefine(type = ColType.VARCHAR, width = 50)
|
||||
@Comment("保险名称")
|
||||
private String name;
|
||||
|
||||
@Column
|
||||
@ColDefine(type = ColType.VARCHAR, width = 20)
|
||||
@Comment("登记开始时间")
|
||||
private String startTime;
|
||||
|
||||
@Column
|
||||
@ColDefine(type = ColType.VARCHAR, width = 20)
|
||||
@Comment("登记结束时间")
|
||||
private String endTime;
|
||||
|
||||
@Column
|
||||
@ColDefine(type = ColType.INT)
|
||||
@Comment("人员范围")
|
||||
private Integer groupId;
|
||||
|
||||
@Column
|
||||
@ColDefine(type = ColType.VARCHAR, width = 30)
|
||||
@Comment("人员范围名称")
|
||||
private String activityGroupName;
|
||||
|
||||
@Column
|
||||
@ColDefine(type = ColType.VARCHAR, width = 100)
|
||||
@Comment("险种介绍链接")
|
||||
private String href;
|
||||
|
||||
@Column
|
||||
@ColDefine(customType = "longtext")
|
||||
@Comment("详细信息")
|
||||
private String moreInfo;
|
||||
|
||||
@Column
|
||||
@ColDefine(type = ColType.MYSQL_JSON)
|
||||
@Comment("支付二维码")
|
||||
private List<Sys_file> payCode;
|
||||
|
||||
@Column
|
||||
@ColDefine(type = ColType.VARCHAR, width = 32)
|
||||
@Comment("创建人")
|
||||
private String userId;
|
||||
|
||||
@Column
|
||||
@ColDefine(type = ColType.VARCHAR, width = 20)
|
||||
@Comment("创建时间")
|
||||
private String createTime;
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package io.v.nutz.zhgh.insurance.model;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
import org.nutz.dao.entity.annotation.*;
|
||||
import org.nutz.dao.interceptor.annotation.PrevInsert;
|
||||
|
||||
/**
|
||||
* @Author JyuHsin
|
||||
* @Date 2023/5/12
|
||||
* @Description
|
||||
*/
|
||||
@Data
|
||||
@Table("insurance_user")
|
||||
@Accessors(chain = true)
|
||||
public class InsuranceUser {
|
||||
|
||||
@Name
|
||||
@PrevInsert(uu32 = true)
|
||||
private String id;
|
||||
|
||||
@Column
|
||||
@ColDefine(type = ColType.VARCHAR, width = 32)
|
||||
@Comment("保险id")
|
||||
private String insuranceId;
|
||||
|
||||
@Column
|
||||
@ColDefine(type = ColType.VARCHAR, width = 32)
|
||||
@Comment("选择人id")
|
||||
private String userId;
|
||||
|
||||
@Column
|
||||
@ColDefine(type = ColType.VARCHAR, width = 20)
|
||||
@Comment("选择时间")
|
||||
private String chooseTime;
|
||||
}
|
||||
Reference in New Issue
Block a user