commit
This commit is contained in:
@@ -14,6 +14,7 @@ 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.ioc.aop.Aop;
|
||||
@@ -28,6 +29,7 @@ import org.nutz.mvc.annotation.Param;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
|
||||
/**
|
||||
* @ClassName WelfareChooseController
|
||||
@@ -40,12 +42,15 @@ import java.util.List;
|
||||
@At("/platform/welfare/userChoose")
|
||||
public class WelfareUserChooseController {
|
||||
|
||||
@Inject
|
||||
private Dao dao;
|
||||
@Inject
|
||||
private SimpleService simpleService;
|
||||
|
||||
@Inject
|
||||
private WelfareProjectService welfareProjectService;
|
||||
|
||||
private final ReentrantLock lock = new ReentrantLock(true);
|
||||
|
||||
@At("")
|
||||
@Ok("beetl:/platform/welfare/userChoose.html")
|
||||
@RequiresPermissions("welfare.user.choose")
|
||||
@@ -56,7 +61,6 @@ public class WelfareUserChooseController {
|
||||
@ViReturn
|
||||
@RequiresPermissions("welfare.user.choose")
|
||||
public Object pageData(PageForm pageForm, Integer year) {
|
||||
|
||||
Sql sql = Sqls.create("""
|
||||
SELECT
|
||||
wp.*,
|
||||
@@ -96,29 +100,44 @@ public class WelfareUserChooseController {
|
||||
@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()));
|
||||
try {
|
||||
lock.lock();
|
||||
// 查询有没有这个人
|
||||
int count = dao.count(WelfareList.class, Cnd.where("userId", "=", ShiroUtil.getUserId()).and("projectId", "=", projectId));
|
||||
if (count <= 0) {
|
||||
return Result.error("您不在此次选择名单中,如有疑问请及时联系校工会");
|
||||
}
|
||||
|
||||
//删除上次选择的
|
||||
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;
|
||||
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 Result.success();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return Result.error();
|
||||
} finally {
|
||||
lock.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -129,23 +148,37 @@ public class WelfareUserChooseController {
|
||||
@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()));
|
||||
try {
|
||||
lock.lock();
|
||||
// 查询有没有这个人
|
||||
int count = dao.count(WelfareList.class, Cnd.where("userId", "=", ShiroUtil.getUserId()).and("projectId", "=", projectId));
|
||||
if (count <= 0) {
|
||||
return Result.error("您不在此次选择名单中,如有疑问请及时联系校工会");
|
||||
}
|
||||
|
||||
for (WelfareUserSelection welfareUserSelection : welfareUserSelections) {
|
||||
welfareUserSelection.setSelectUserId(ShiroUtil.getUserId());
|
||||
welfareUserSelection.setSelectTime(new Date());
|
||||
//删除上次选择的
|
||||
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("选择成功");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return Result.error();
|
||||
} finally {
|
||||
lock.unlock();
|
||||
}
|
||||
|
||||
simpleService.dao().insert(welfareUserSelections);
|
||||
|
||||
simpleService.dao().update(WelfareList.class,
|
||||
Chain.make("isReceive", true),
|
||||
Cnd.where("projectId", "=", projectId)
|
||||
.and("userId", "=", ShiroUtil.getUserId()));
|
||||
return Result.success("选择成功");
|
||||
}
|
||||
|
||||
|
||||
|
||||
+4
-2
@@ -799,10 +799,11 @@ public class WelfareSingleController {
|
||||
wl.userState,
|
||||
wl.personType,
|
||||
gh.unionname,
|
||||
dw.name as unitname,
|
||||
dw.name as unitname,
|
||||
IF(LOCATE('undefined',wpus.receiveAddress)>0,NULL,wpus.receiveAddress) as receiveAddress,
|
||||
wpus.selectNum,
|
||||
wpso.optionName
|
||||
wpso.optionName,
|
||||
wpus.selectSpecs
|
||||
FROM
|
||||
welfare_project_user_selection wpus
|
||||
left join user u on u.id = wpus.selectUserId
|
||||
@@ -855,6 +856,7 @@ public class WelfareSingleController {
|
||||
exportEntities.add(new ExcelExportEntity("所在分工会", "unionname", 30));
|
||||
exportEntities.add(new ExcelExportEntity("所在单位", "unitname", 50));
|
||||
exportEntities.add(new ExcelExportEntity("选择份数", "selectNum", 10));
|
||||
exportEntities.add(new ExcelExportEntity("规格参数", "selectSpecs", 20));
|
||||
// if (Globals.MyConfig.getBoolean("isThreeUnit")) {
|
||||
// exportEntities.add(new ExcelExportEntity("所在部门", "threeUnitName", 50));
|
||||
// }
|
||||
|
||||
@@ -22,15 +22,21 @@ public class WelfareExportEntityTc {
|
||||
@Excel(name = "姓名", width = 20d)
|
||||
private String userName;
|
||||
|
||||
@Excel(name = "所属工会", width = 20d)
|
||||
@Excel(name = "所属工会", width = 30d)
|
||||
private String unionName;
|
||||
|
||||
// @Excel(name = "所属单位", width = 60d)
|
||||
// private String unitName;
|
||||
@Excel(name = "工会小组", width = 30d)
|
||||
private String unionGroupName;
|
||||
|
||||
@Excel(name = "所属单位", width = 30d)
|
||||
private String unitName;
|
||||
|
||||
@Excel(name = "已选福利", width = 80d)
|
||||
private String optionName;
|
||||
|
||||
@Excel(name = "规格参数", width = 50d)
|
||||
private String selectSpecs;
|
||||
|
||||
@Excel(name = "收货人", width = 15d)
|
||||
private String recipient;
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ import cn.afterturn.easypoi.excel.entity.params.ExcelExportEntity;
|
||||
import cn.afterturn.easypoi.excel.export.ExcelExportService;
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.json.JSONObject;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import io.v.nutz.base.dao.CndPlus;
|
||||
import io.v.nutz.base.service.impl.ViServiceImpl;
|
||||
@@ -464,13 +465,15 @@ public class WelfareSingleServiceImpl extends ViServiceImpl<WelfareProject> impl
|
||||
u.loginname AS loginName,
|
||||
u.username AS userName,
|
||||
vwl.unionname,
|
||||
vwl.unionname as unionName,
|
||||
vwl.unitname,
|
||||
vwl.unionname AS unionName,
|
||||
vwl.unitname AS unitName,
|
||||
vwl.unionGroupName,
|
||||
u.idcard AS idCard,
|
||||
u.mobile,
|
||||
IF(LOCATE('undefined',wpus.receiveAddress)>0,NULL,wpus.receiveAddress) as receiveAddress,
|
||||
wpus.userSign,
|
||||
GROUP_CONCAT(DISTINCT wpso.optionName, IF(wpus.selectSpecs is not null, (CONCAT('—规格:', wpus.selectSpecs)), ''), '(',wpus.selectNum,'份)') optionName,
|
||||
GROUP_CONCAT(DISTINCT wpso.optionName, '(',wpus.selectNum,'份)') optionName,
|
||||
wpus.selectSpecs,
|
||||
wpus.courierNumber
|
||||
FROM
|
||||
welfare_project_user_selection wpus
|
||||
@@ -645,14 +648,33 @@ public class WelfareSingleServiceImpl extends ViServiceImpl<WelfareProject> impl
|
||||
@Override
|
||||
public void exportReceiveDetail(String projectId, String welfareUnitId, List<NutMap> allUser, List<NutMap> userChooseList, OutputStream outputStream) throws Exception {
|
||||
Sql optionSql = Sqls.create("""
|
||||
SELECT w2.id, w2.optionName
|
||||
FROM `welfare_project_subject` w1
|
||||
JOIN `welfare_project_subject_option` w2 ON w1.id = w2.subjectId
|
||||
WHERE w1.projectId = @projectId;
|
||||
SELECT
|
||||
w2.id,
|
||||
w2.optionName,
|
||||
jt.fullOptionName AS fullOptionName
|
||||
FROM
|
||||
`welfare_project_subject` w1
|
||||
JOIN
|
||||
`welfare_project_subject_option` w2 ON w1.id = w2.subjectId
|
||||
LEFT JOIN
|
||||
JSON_TABLE(
|
||||
w2.specs,
|
||||
'$[*]' COLUMNS (
|
||||
fullOptionName VARCHAR(255) PATH '$.value'
|
||||
)
|
||||
) AS jt ON 1=1
|
||||
WHERE
|
||||
w1.projectId = @projectId
|
||||
""");
|
||||
optionSql.setParam("projectId", projectId);
|
||||
List<NutMap> options = (List<NutMap>) Daos.query(dao(), optionSql.toString(), Sqls.callback.maps());
|
||||
|
||||
// for (NutMap option : options) {
|
||||
// if (StrUtil.isNotBlank(option.getString("fullOptionName"))) {
|
||||
// option
|
||||
// }
|
||||
// }
|
||||
|
||||
// Sql sql = Sqls.create("""
|
||||
// SELECT
|
||||
// vwl.loginname,
|
||||
@@ -680,7 +702,8 @@ public class WelfareSingleServiceImpl extends ViServiceImpl<WelfareProject> impl
|
||||
dw.`name` as unitname,
|
||||
wpus.userSign,
|
||||
wpus.selectOptionId,
|
||||
wpus.selectNum
|
||||
wpus.selectNum,
|
||||
wpus.selectSpecs
|
||||
FROM
|
||||
welfare_list vwl
|
||||
LEFT JOIN special_staff staff ON staff.userId = vwl.userId
|
||||
@@ -726,7 +749,10 @@ public class WelfareSingleServiceImpl extends ViServiceImpl<WelfareProject> impl
|
||||
exportEntities.add(excelExportEntity1);
|
||||
|
||||
for (NutMap option : options) {
|
||||
exportEntities.add(new ExcelExportEntity(option.getString("optionName"), option.getString("id"), 10));
|
||||
exportEntities.add(new ExcelExportEntity(option.getString("optionName")
|
||||
+ (StrUtil.isNotBlank(option.getString("fullOptionName")) ? ("-" + option.getString("fullOptionName")) : "")
|
||||
, option.getString("id") + (StrUtil.isNotBlank(option.getString("fullOptionName")) ? ("-" + option.getString("fullOptionName")) : "")
|
||||
, 40));
|
||||
}
|
||||
ExcelExportEntity excelExportEntity = new ExcelExportEntity();
|
||||
excelExportEntity.setName("签字");
|
||||
@@ -749,12 +775,29 @@ public class WelfareSingleServiceImpl extends ViServiceImpl<WelfareProject> impl
|
||||
|
||||
data.put("qzBytes", userMap.get("qzBytes"));
|
||||
for (NutMap option : options) {
|
||||
if (StrUtil.isNotBlank(userMap.getString("selectOptionId"))) {
|
||||
NutMap selectOption = list.stream().filter(x -> x.getString("loginname").equals(v) && x.getString("selectOptionId").equals(option.getString("id"))).findFirst().orElse(null);
|
||||
if (Lang.isNotEmpty(selectOption)) {
|
||||
data.put(option.getString("id"), selectOption.getInt("selectNum"));
|
||||
} else {
|
||||
data.put(option.getString("id"), 0);
|
||||
if (StrUtil.isNotBlank(userMap.getString("selectSpecs"))) {
|
||||
if (StrUtil.isNotBlank(userMap.getString("selectOptionId"))) {
|
||||
String opId = (option.getString("id") + (StrUtil.isNotBlank(option.getString("fullOptionName")) ? ("-" + option.getString("fullOptionName")) : ""));
|
||||
String userSpecs = userMap.getString("selectOptionId") + "-" + userMap.getString("selectSpecs");
|
||||
if (opId.equals(userSpecs)) {
|
||||
data.put(opId, userMap.getInt("selectNum"));
|
||||
} else {
|
||||
data.put(opId, 0);
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
if (StrUtil.isNotBlank(userMap.getString("selectOptionId"))) {
|
||||
NutMap selectOption = list.stream()
|
||||
.filter(x -> x.getString("loginname").equals(v)
|
||||
&& x.getString("selectOptionId").equals(option.getString("id")))
|
||||
.findFirst().orElse(null);
|
||||
if (Lang.isNotEmpty(selectOption)) {
|
||||
data.put(option.getString("id"), selectOption.getInt("selectNum"));
|
||||
} else {
|
||||
data.put(option.getString("id"), 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -767,9 +810,18 @@ public class WelfareSingleServiceImpl extends ViServiceImpl<WelfareProject> impl
|
||||
NutMap totalMap = NutMap.NEW();
|
||||
totalMap.put("no", "合计");
|
||||
for (NutMap option : options) {
|
||||
List<NutMap> selectOptionList = list.stream().filter(x -> StrUtil.isNotBlank(x.getString("selectOptionId")) && x.getString("selectOptionId").equals(option.getString("id"))).collect(Collectors.toList());
|
||||
String opId = (option.getString("id") + (StrUtil.isNotBlank(option.getString("fullOptionName")) ? ("-" + option.getString("fullOptionName")) : ""));
|
||||
List<NutMap> selectOptionList = list.stream()
|
||||
.filter(x -> {
|
||||
String userSpecs = "";
|
||||
if (StrUtil.isNotBlank(x.getString("selectOptionId"))) {
|
||||
userSpecs = x.getString("selectOptionId")
|
||||
+ (StrUtil.isNotBlank(x.getString("selectSpecs")) ? ( "-" + x.getString("selectSpecs")) : "");
|
||||
}
|
||||
return StrUtil.isNotBlank(userSpecs) && userSpecs.equals(opId);
|
||||
}).toList();
|
||||
int selectNum = selectOptionList.stream().mapToInt(s -> s.getInt("selectNum")).sum();
|
||||
totalMap.put(option.getString("id"), selectNum);
|
||||
totalMap.put(opId, selectNum);
|
||||
}
|
||||
dataList.add(totalMap);
|
||||
/*ExportParams exportParams = new ExportParams();
|
||||
|
||||
Reference in New Issue
Block a user