first commit
This commit is contained in:
@@ -0,0 +1,131 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>ruoyi-modules</artifactId>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<version>3.6.1</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>ruoyi-modules-staffService</artifactId>
|
||||
|
||||
<description>
|
||||
ruoyi-modules-staffService职工服务
|
||||
</description>
|
||||
|
||||
<dependencies>
|
||||
|
||||
<!-- SpringCloud Alibaba Nacos -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- SpringCloud Alibaba Nacos Config -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- SpringCloud Alibaba Sentinel -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- SpringBoot Actuator -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-actuator</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- Swagger UI -->
|
||||
<dependency>
|
||||
<groupId>io.springfox</groupId>
|
||||
<artifactId>springfox-swagger-ui</artifactId>
|
||||
<version>${swagger.fox.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Mysql Connector -->
|
||||
<dependency>
|
||||
<groupId>mysql</groupId>
|
||||
<artifactId>mysql-connector-java</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- RuoYi Common DataSource -->
|
||||
<dependency>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<artifactId>ruoyi-common-datasource</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- RuoYi Common Log -->
|
||||
<dependency>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<artifactId>ruoyi-common-log</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- RuoYi Common Swagger -->
|
||||
<dependency>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<artifactId>ruoyi-common-swagger</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- nutz -->
|
||||
<dependency>
|
||||
<groupId>org.nutz</groupId>
|
||||
<artifactId>nutz-spring-boot-starter</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<artifactId>ruoyi-api-staffService</artifactId>
|
||||
<version>3.6.1</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<artifactId>ruoyi-api-member</artifactId>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<finalName>${project.artifactId}</finalName>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>repackage</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<configuration>
|
||||
<source>15</source>
|
||||
<target>15</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
</project>
|
||||
+143
@@ -0,0 +1,143 @@
|
||||
package com.ruoyi.staffService.Inclusive.controller;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.dynamic.datasource.toolkit.DynamicDataSourceContextHolder;
|
||||
import com.ruoyi.common.core.domain.PageForm;
|
||||
import com.ruoyi.common.core.page.Pagination;
|
||||
import com.ruoyi.common.core.web.domain.AjaxResult;
|
||||
import com.ruoyi.common.security.annotation.RequiresPermissions;
|
||||
import com.ruoyi.common.security.utils.SecurityUtils;
|
||||
import com.ruoyi.staffService.Inclusive.service.InclusivePlatformManageService;
|
||||
import com.ruoyi.staffService.api.domain.Inclusive.InclusivePlatform;
|
||||
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.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
|
||||
/**
|
||||
* 普惠平台管理
|
||||
*
|
||||
* @author jug
|
||||
* @date 2023/09/20
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/inclusive/manage")
|
||||
public class InclusivePlatformManageController {
|
||||
|
||||
@Autowired
|
||||
private Dao dao;
|
||||
|
||||
@Autowired
|
||||
private InclusivePlatformManageService inclusivePlatformManageService;
|
||||
|
||||
@RequestMapping("/pageData")
|
||||
@RequiresPermissions("staffService:inclusive:manage")
|
||||
public AjaxResult pageData(@RequestBody PageForm pageForm,
|
||||
@RequestParam(required = false) String title) {
|
||||
Sql sql = Sqls.create("select * from inclusive_platform $condition");
|
||||
Cnd cnd = Cnd.NEW();
|
||||
cnd.and(Cnd.likeEX("title", title));
|
||||
sql.setCondition(cnd);
|
||||
Pagination pagination = inclusivePlatformManageService.listPageMap(pageForm.getPageNumber(), pageForm.getPageSize(), sql);
|
||||
return AjaxResult.success(pagination);
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存
|
||||
*
|
||||
* @param inclusivePlatform
|
||||
* @return {@link AjaxResult}
|
||||
*/
|
||||
@RequestMapping("/save")
|
||||
@RequiresPermissions("staffService:inclusive:manage")
|
||||
public AjaxResult save(@RequestBody InclusivePlatform inclusivePlatform) {
|
||||
inclusivePlatform.setSave(true);
|
||||
if (StrUtil.isNotBlank(inclusivePlatform.getId())) {
|
||||
dao.updateIgnoreNull(inclusivePlatform);
|
||||
} else {
|
||||
dao.insert(inclusivePlatform);
|
||||
}
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 提交
|
||||
*
|
||||
* @param inclusivePlatform
|
||||
* @return {@link AjaxResult}
|
||||
*/
|
||||
@RequestMapping("/submit")
|
||||
@RequiresPermissions("staffService:inclusive:manage")
|
||||
public AjaxResult submit(@RequestBody InclusivePlatform inclusivePlatform) {
|
||||
inclusivePlatform.setSave(false);
|
||||
dao.insert(inclusivePlatform);
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 发布
|
||||
*
|
||||
* @param id
|
||||
* @return {@link AjaxResult}
|
||||
*/
|
||||
@RequestMapping("/publish")
|
||||
@RequiresPermissions("staffService:inclusive:manage")
|
||||
public AjaxResult publish(String id) {
|
||||
dao.update(InclusivePlatform.class, Chain.make("save", 0), Cnd.where("id", "=", id));
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 下架
|
||||
*
|
||||
* @param id
|
||||
* @return {@link AjaxResult}
|
||||
*/
|
||||
@RequestMapping("/offShelf")
|
||||
@RequiresPermissions("staffService:inclusive:manage")
|
||||
public AjaxResult offShelf(String id) {
|
||||
dao.update(InclusivePlatform.class, Chain.make("save", 1), Cnd.where("id", "=", id));
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*
|
||||
* @param id
|
||||
* @return {@link AjaxResult}
|
||||
*/
|
||||
@RequestMapping("/delete")
|
||||
@RequiresPermissions("staffService:inclusive:manage")
|
||||
public AjaxResult delete(String id) {
|
||||
dao.clear(InclusivePlatform.class, Cnd.where("id", "=", id));
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
@RequestMapping("/h5PageData")
|
||||
public AjaxResult h5PageData(@RequestBody PageForm pageForm,
|
||||
@RequestParam(required = false) String title) {
|
||||
Sql sql = Sqls.create("select * from inclusive_platform $condition");
|
||||
Cnd cnd = Cnd.NEW();
|
||||
cnd.and(Cnd.likeEX("title", title));
|
||||
cnd.and("save", "=", 0);
|
||||
|
||||
SqlExpressionGroup group = new SqlExpressionGroup();
|
||||
group.or("sexLimit", "=", 2);
|
||||
group.or("sexLimit", "=", SecurityUtils.getLoginUser().getSysUser().getSex());
|
||||
cnd.and(group);
|
||||
|
||||
sql.setCondition(cnd);
|
||||
Pagination pagination = inclusivePlatformManageService.listPageMap(1, 30, sql);
|
||||
return AjaxResult.success(pagination);
|
||||
}
|
||||
|
||||
}
|
||||
+61
@@ -0,0 +1,61 @@
|
||||
package com.ruoyi.staffService.Inclusive.controller;
|
||||
|
||||
import com.ruoyi.common.core.domain.PageForm;
|
||||
import com.ruoyi.common.core.page.Pagination;
|
||||
import com.ruoyi.common.core.web.domain.AjaxResult;
|
||||
import com.ruoyi.common.security.annotation.RequiresLogin;
|
||||
import com.ruoyi.common.security.annotation.RequiresPermissions;
|
||||
import com.ruoyi.common.security.utils.SecurityUtils;
|
||||
import com.ruoyi.staffService.Inclusive.service.InclusivePlatformManageService;
|
||||
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.lang.util.NutMap;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/inclusive/read")
|
||||
public class InclusivePlatformReadController {
|
||||
|
||||
@Autowired
|
||||
private InclusivePlatformManageService inclusivePlatformManageService;
|
||||
|
||||
@RequestMapping("/pageData")
|
||||
@RequiresPermissions("")
|
||||
public AjaxResult pageData(@RequestBody PageForm pageForm) {
|
||||
Sql sql = Sqls.create("select * from inclusive_platform $condition");
|
||||
Cnd cnd = Cnd.NEW();
|
||||
cnd.and("save", "=", 0);
|
||||
sql.setCondition(cnd);
|
||||
Pagination pagination = inclusivePlatformManageService.listPageMap(pageForm.getPageNumber(), pageForm.getPageSize(), sql);
|
||||
return AjaxResult.success(pagination);
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping("/getMyRights")
|
||||
@RequiresLogin
|
||||
public AjaxResult getMyRights(){
|
||||
// sexLimit: 性别限制(2.全部开放,0.男性,1.女性)
|
||||
String sex = SecurityUtils.getLoginUser().getSysUser().getSex();
|
||||
Sql sql = Sqls.create("select * from inclusive_platform $condition");
|
||||
Cnd cnd = Cnd.NEW();
|
||||
cnd.and("save", "=", 0);
|
||||
SqlExpressionGroup seg = new SqlExpressionGroup();
|
||||
seg.or("sexLimit", "=", 2);
|
||||
// sex: 0=男,1=女,2=未知
|
||||
switch (sex){
|
||||
case "0" -> seg.or("sexLimit", "=", 0);
|
||||
case "1" -> seg.or("sexLimit", "=", 1);
|
||||
}
|
||||
cnd.and(seg);
|
||||
sql.setCondition(cnd);
|
||||
List<NutMap> list = inclusivePlatformManageService.listMap(sql);
|
||||
return AjaxResult.success(list);
|
||||
}
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
package com.ruoyi.staffService.Inclusive.service;
|
||||
|
||||
import com.ruoyi.common.core.service.BaseService;
|
||||
import com.ruoyi.staffService.api.domain.Inclusive.InclusivePlatform;
|
||||
|
||||
public interface InclusivePlatformManageService extends BaseService<InclusivePlatform> {
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
package com.ruoyi.staffService.Inclusive.service.impl;
|
||||
|
||||
import com.ruoyi.common.core.service.BaseServiceImpl;
|
||||
import com.ruoyi.staffService.Inclusive.service.InclusivePlatformManageService;
|
||||
import com.ruoyi.staffService.api.domain.Inclusive.InclusivePlatform;
|
||||
import org.nutz.dao.Dao;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class InclusivePlatformManageServiceImpl extends BaseServiceImpl<InclusivePlatform> implements InclusivePlatformManageService {
|
||||
public InclusivePlatformManageServiceImpl(Dao dao) {
|
||||
super(dao);
|
||||
}
|
||||
}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
package com.ruoyi.staffService;
|
||||
|
||||
import com.ruoyi.common.security.annotation.EnableCustomConfig;
|
||||
import com.ruoyi.common.security.annotation.EnableRyFeignClients;
|
||||
import com.ruoyi.common.swagger.annotation.EnableCustomSwagger2;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
@EnableCustomConfig
|
||||
@EnableCustomSwagger2
|
||||
@EnableRyFeignClients
|
||||
@SpringBootApplication
|
||||
public class RuoYiStaffServiceApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(RuoYiStaffServiceApplication.class, args);
|
||||
}
|
||||
|
||||
}
|
||||
+53
@@ -0,0 +1,53 @@
|
||||
package com.ruoyi.staffService.birthdayWishes.controller;
|
||||
|
||||
import com.ruoyi.common.core.domain.R;
|
||||
import com.ruoyi.common.core.utils.StringUtils;
|
||||
import com.ruoyi.common.core.web.domain.AjaxResult;
|
||||
import com.ruoyi.common.security.annotation.InnerAuth;
|
||||
import com.ruoyi.common.security.annotation.RequiresPermissions;
|
||||
import com.ruoyi.staffService.api.domain.birthdayWishes.BirthdayParamsConfig;
|
||||
import com.ruoyi.system.api.RemoteJobService;
|
||||
import org.nutz.dao.Dao;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* @ClassName BirthdayWishesParamsConfigController
|
||||
* @Author JyuHsin
|
||||
* @Date 2025/4/9 10:34
|
||||
* @Version 1.0
|
||||
* @Description TODO
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/birthdayWishes/paramsConfig")
|
||||
public class BirthdayWishesParamsConfigController {
|
||||
|
||||
@Autowired
|
||||
private Dao dao;
|
||||
|
||||
@Autowired
|
||||
private RemoteJobService remoteJobService;
|
||||
|
||||
@PostMapping("/doHandle")
|
||||
@RequiresPermissions("birthdayWishes:paramsConfig")
|
||||
public AjaxResult doHandle(@RequestBody BirthdayParamsConfig birthdayParamsConfig) {
|
||||
dao.insertOrUpdate(birthdayParamsConfig);
|
||||
if(StringUtils.isNotBlank(birthdayParamsConfig.getSendTime())) {
|
||||
R<Integer> result = remoteJobService.editByCron(birthdayParamsConfig.getSendTime(), birthdayParamsConfig.getStatus());
|
||||
if(result.getCode() != 200) {
|
||||
return AjaxResult.error(result.getMsg());
|
||||
}
|
||||
return AjaxResult.success();
|
||||
}
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
@RequestMapping("/findOne")
|
||||
public AjaxResult findOne() {
|
||||
BirthdayParamsConfig config = dao.fetch(BirthdayParamsConfig.class);
|
||||
return AjaxResult.success(config);
|
||||
}
|
||||
}
|
||||
+70
@@ -0,0 +1,70 @@
|
||||
package com.ruoyi.staffService.birthdayWishes.controller;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.ruoyi.common.core.domain.PageForm;
|
||||
import com.ruoyi.common.core.page.Pagination;
|
||||
import com.ruoyi.common.core.service.BaseService;
|
||||
import com.ruoyi.common.core.web.domain.AjaxResult;
|
||||
import com.ruoyi.common.security.annotation.InnerAuth;
|
||||
import com.ruoyi.common.security.annotation.RequiresPermissions;
|
||||
import com.ruoyi.staffService.api.domain.birthdayWishes.BirthdaySendRecord;
|
||||
import com.ruoyi.staffService.birthdayWishes.service.BirthdayWishesSendRecordService;
|
||||
import org.nutz.dao.Cnd;
|
||||
import org.nutz.dao.Dao;
|
||||
import org.nutz.lang.Lang;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @ClassName BirthdayWishesSendRecordController
|
||||
* @Author JyuHsin
|
||||
* @Date 2025/4/9 10:49
|
||||
* @Version 1.0
|
||||
* @Description TODO
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/birthdayWishes/sendRecord")
|
||||
public class BirthdayWishesSendRecordController {
|
||||
|
||||
@Autowired
|
||||
private BirthdayWishesSendRecordService birthdayWishesSendRecordService;
|
||||
|
||||
@PostMapping("/pageData")
|
||||
@RequiresPermissions("birthdayWishes:sendRecord")
|
||||
public AjaxResult pageData(@RequestBody PageForm pageForm,
|
||||
String startTime,
|
||||
String endTime,
|
||||
String unionId,
|
||||
String unitId) {
|
||||
Cnd cnd = Cnd.NEW();
|
||||
cnd.andEX("sendTime", ">=", startTime);
|
||||
cnd.andEX("sendTime", "<=", endTime);
|
||||
cnd.andEX("receiveUnionId", "=", unionId);
|
||||
cnd.andEX("receiveUnitId", "=", unitId);
|
||||
if (StrUtil.isNotBlank(pageForm.getSearchKeyword())) {
|
||||
cnd.and(Cnd.exps("receiveLoginName", "like", "%" + pageForm.getSearchKeyword() + "%").or("receiveUserName", "like", "%" + pageForm.getSearchKeyword() + "%"));
|
||||
}
|
||||
cnd.desc("sendTime");
|
||||
Pagination pagination = birthdayWishesSendRecordService.listPageMap(pageForm.getPageNumber(), pageForm.getPageSize(), cnd);
|
||||
return AjaxResult.success(pagination);
|
||||
}
|
||||
|
||||
@PostMapping("/onDelete")
|
||||
@RequiresPermissions("birthdayWishes:sendRecord")
|
||||
public AjaxResult onDelete(String id) {
|
||||
birthdayWishesSendRecordService.delete(id);
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
@InnerAuth
|
||||
@RequestMapping("/insertSendRecord")
|
||||
public AjaxResult insertSendRecord(@RequestBody List<BirthdaySendRecord> records) {
|
||||
List<BirthdaySendRecord> list = birthdayWishesSendRecordService.insert(records);
|
||||
return AjaxResult.success(Lang.isNotEmpty(list));
|
||||
}
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
package com.ruoyi.staffService.birthdayWishes.service;
|
||||
|
||||
import com.ruoyi.common.core.service.BaseService;
|
||||
import com.ruoyi.staffService.api.domain.birthdayWishes.BirthdaySendRecord;
|
||||
|
||||
/**
|
||||
* @ClassName BirthdayWishesSendRecordService
|
||||
* @Author JyuHsin
|
||||
* @Date 2025/4/9 10:51
|
||||
* @Version 1.0
|
||||
* @Description TODO
|
||||
*/
|
||||
public interface BirthdayWishesSendRecordService extends BaseService<BirthdaySendRecord> {
|
||||
}
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
package com.ruoyi.staffService.birthdayWishes.service.impl;
|
||||
|
||||
import com.ruoyi.common.core.service.BaseServiceImpl;
|
||||
import com.ruoyi.staffService.api.domain.birthdayWishes.BirthdaySendRecord;
|
||||
import com.ruoyi.staffService.birthdayWishes.service.BirthdayWishesSendRecordService;
|
||||
import org.nutz.dao.Dao;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* @ClassName BirthdayWishesSendRecordServiceImpl
|
||||
* @Author JyuHsin
|
||||
* @Date 2025/4/9 10:52
|
||||
* @Version 1.0
|
||||
* @Description TODO
|
||||
*/
|
||||
@Service
|
||||
public class BirthdayWishesSendRecordServiceImpl extends BaseServiceImpl<BirthdaySendRecord> implements BirthdayWishesSendRecordService {
|
||||
public BirthdayWishesSendRecordServiceImpl(Dao dao) {
|
||||
super(dao);
|
||||
}
|
||||
}
|
||||
+214
@@ -0,0 +1,214 @@
|
||||
package com.ruoyi.staffService.condolence.controller;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.ruoyi.common.core.constant.Roles;
|
||||
import com.ruoyi.common.core.constant.SecurityConstants;
|
||||
import com.ruoyi.common.core.domain.R;
|
||||
import com.ruoyi.common.core.web.domain.AjaxResult;
|
||||
import com.ruoyi.common.security.annotation.RequiresPermissions;
|
||||
import com.ruoyi.common.security.auth.AuthUtil;
|
||||
import com.ruoyi.common.security.utils.SecurityUtils;
|
||||
import com.ruoyi.member.api.constant.MemberApplyState;
|
||||
import com.ruoyi.staffService.api.constant.condolence.CondolenceAuditState;
|
||||
import com.ruoyi.staffService.api.constant.condolence.CondolenceAuditType;
|
||||
import com.ruoyi.staffService.api.constant.difficulty.DifficultyAuditState;
|
||||
import com.ruoyi.staffService.api.domain.condolence.Condolence;
|
||||
import com.ruoyi.staffService.api.domain.condolence.CondolenceAudit;
|
||||
import com.ruoyi.system.api.RemoteSysLocalProcessService;
|
||||
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.Daos;
|
||||
import org.nutz.dao.util.cri.SqlExpressionGroup;
|
||||
import org.nutz.lang.Lang;
|
||||
import org.nutz.lang.util.NutMap;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 职工慰问申请
|
||||
*
|
||||
* @author jug
|
||||
* @date 2023/02/01
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/condolence/apply")
|
||||
public class StaffCondolenceApplyController {
|
||||
|
||||
@Autowired
|
||||
private Dao dao;
|
||||
@Autowired
|
||||
private RemoteSysLocalProcessService localProcessService;
|
||||
|
||||
/**
|
||||
* 做保存
|
||||
*
|
||||
* @param condolence 慰问
|
||||
* @return {@link AjaxResult}
|
||||
*/
|
||||
@PostMapping("/doSave")
|
||||
@RequiresPermissions("condolence:apply")
|
||||
public AjaxResult doSave(@RequestBody Condolence condolence) {
|
||||
// 如果是被退回的流程,那就要完成被退回流程的任务
|
||||
if (condolence.getStateId() != null) {
|
||||
localProcessService.completeReturnTask("CONDOLENCE@" + condolence.getId(), SecurityConstants.INNER);
|
||||
}
|
||||
condolence.setStateId(CondolenceAuditState.NOT_SUBMIT);
|
||||
condolence.setApplyTime(new Date());
|
||||
condolence.setAgentId(SecurityUtils.getUserId());
|
||||
condolence.setAgentUserName(SecurityUtils.getNickName());
|
||||
condolence.setAgentLoginName(SecurityUtils.getUsername());
|
||||
String spouseUserId = condolence.getSpouseUserId();
|
||||
if (StrUtil.isNotBlank(spouseUserId)) {
|
||||
Record user = dao.fetch("`user`", Cnd.where("userId", "=", spouseUserId));
|
||||
condolence.setSpouseLoginName(user.getString("loginName"));
|
||||
condolence.setSpouseUsername(user.getString("userName"));
|
||||
}
|
||||
dao.insertOrUpdate(condolence);
|
||||
|
||||
localProcessService.initCreateInstance(
|
||||
"CONDOLENCE@" + condolence.getId(),
|
||||
condolence.getId(),
|
||||
"[职工慰问]" + condolence.getComfortedPersonUserName(),
|
||||
"/staffService/condolence/applyRecord",
|
||||
null,
|
||||
SecurityConstants.INNER
|
||||
);
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 做提交
|
||||
*
|
||||
* @param condolence 慰问
|
||||
* @return {@link AjaxResult}
|
||||
*/
|
||||
@PostMapping("/doSubmit")
|
||||
@RequiresPermissions("condolence:apply")
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public AjaxResult doSubmit(@RequestBody Condolence condolence) {
|
||||
// 如果是被退回的流程,那就要完成被退回流程的任务
|
||||
if (condolence.getStateId() != null) {
|
||||
localProcessService.completeReturnTask("CONDOLENCE@" + condolence.getId(), SecurityConstants.INNER);
|
||||
}
|
||||
condolence.setStateId(CondolenceAuditState.UNION_GROUP_READY);
|
||||
condolence.setApplyTime(new Date());
|
||||
condolence.setAgentId(SecurityUtils.getUserId());
|
||||
condolence.setAgentUserName(SecurityUtils.getNickName());
|
||||
condolence.setAgentLoginName(SecurityUtils.getUsername());
|
||||
String spouseUserId = condolence.getSpouseUserId();
|
||||
if (StrUtil.isNotBlank(spouseUserId)) {
|
||||
Record user = dao.fetch("`user`", Cnd.where("userId", "=", spouseUserId));
|
||||
condolence.setSpouseLoginName(user.getString("loginName"));
|
||||
condolence.setSpouseUsername(user.getString("userName"));
|
||||
}
|
||||
dao.insertOrUpdate(condolence);
|
||||
|
||||
String processUniqueId = "CONDOLENCE@" + condolence.getId();
|
||||
localProcessService.initCreateInstance(
|
||||
processUniqueId,
|
||||
condolence.getId(),
|
||||
"[职工慰问]" + condolence.getComfortedPersonUserName(),
|
||||
"/staffService/condolence/applyRecord",
|
||||
null,
|
||||
SecurityConstants.INNER
|
||||
);
|
||||
|
||||
// 创建工会小组任务, 获取负责人
|
||||
R<List<String>> assignments = localProcessService.getAssignments(null,
|
||||
condolence.getComfortedPersonUnionGroupId(), Roles.UNION_GROUP_LEADER, SecurityConstants.INNER);
|
||||
List<String> loginNameList = assignments.getData();
|
||||
|
||||
localProcessService.initCreateTask(
|
||||
processUniqueId,
|
||||
String.valueOf(CondolenceAuditState.UNION_GROUP_READY),
|
||||
"工会小组审核",
|
||||
loginNameList,
|
||||
"/staffService/condolence/unionGroupAudit",
|
||||
null,
|
||||
SecurityConstants.INNER
|
||||
);
|
||||
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
@GetMapping("/findOne")
|
||||
public AjaxResult findOne(@RequestParam String id) {
|
||||
return AjaxResult.success(dao.fetch(Condolence.class, id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 得到申请信息 包括审核信息
|
||||
*
|
||||
* @param id id
|
||||
* @return {@link AjaxResult}
|
||||
*/
|
||||
@GetMapping("/getApplyInfo")
|
||||
public AjaxResult getApplyInfo(@RequestParam String id) {
|
||||
Condolence condolence = dao.fetch(Condolence.class, id);
|
||||
// dao.fetchLinks(condolence, null);
|
||||
NutMap condolenceMapData = Lang.obj2nutmap(condolence);
|
||||
List<CondolenceAudit> audits = dao.query(CondolenceAudit.class, Cnd.where("condolenceId", "=", id).asc("auditTime"));
|
||||
condolenceMapData.setv("unionGroupAudits", audits.stream().filter(v -> v.getAuditType() == CondolenceAuditType.UNION_GROUP).collect(Collectors.toList()));
|
||||
condolenceMapData.setv("branchUnionAudits", audits.stream().filter(v -> v.getAuditType() == CondolenceAuditType.BRANCH_UNION).collect(Collectors.toList()));
|
||||
condolenceMapData.setv("schoolUnionAccountingAudits", audits.stream().filter(v -> v.getAuditType() == CondolenceAuditType.SCHOOL_UNION_ACCOUNTING).collect(Collectors.toList()));
|
||||
condolenceMapData.setv("schoolUnionAudits", audits.stream().filter(v -> v.getAuditType() == CondolenceAuditType.SCHOOL_UNION).collect(Collectors.toList()));
|
||||
return AjaxResult.success(condolenceMapData);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询用户
|
||||
*
|
||||
* @param query 查询
|
||||
* @return {@link AjaxResult}
|
||||
*/
|
||||
@GetMapping("/queryUsers")
|
||||
@RequiresPermissions("condolence:apply")
|
||||
public AjaxResult queryUsers(@RequestParam(required = false) String query, @RequestParam(required = false) String userId) {
|
||||
Sql sql = Sqls.create("""
|
||||
select
|
||||
userId as comfortedPersonId,
|
||||
userName as comfortedPersonUserName,
|
||||
loginName as comfortedPersonLoginName,
|
||||
unionId as comfortedPersonUnionId,
|
||||
unionName as comfortedPersonUnionName,
|
||||
unionGroupId as comfortedPersonUnionGroupId,
|
||||
unionGroupName as comfortedPersonUnionGroupName,
|
||||
deptId as comfortedPersonUnitId,
|
||||
deptName as comfortedPersonUnitName,
|
||||
threeDeptName as comfortedPersonThreeUnitName,
|
||||
threeUnitId as comfortedPersonThreeUnitId,
|
||||
sex as comfortedPersonSex,
|
||||
jobTitle as comfortedPersonJobTitle,
|
||||
position as comfortedPersonPosition,
|
||||
TIMESTAMPDIFF(YEAR, birthday, CURDATE()) as comfortedPersonAge
|
||||
from `user`
|
||||
$condition
|
||||
limit 0,10
|
||||
""");
|
||||
Cnd cnd = Cnd.NEW();
|
||||
if (StrUtil.isNotBlank(userId)) {
|
||||
cnd.and("userId", "=", userId);
|
||||
} else if (StrUtil.isNotBlank(query)) {
|
||||
SqlExpressionGroup seg = new SqlExpressionGroup();
|
||||
seg.orLike("loginName", query);
|
||||
seg.orLike("userName", query);
|
||||
cnd.and(seg);
|
||||
}
|
||||
if (!AuthUtil.hasAnyRoles("admin,A06")) {
|
||||
cnd.and("unionId", "=", SecurityUtils.getUnionId());
|
||||
}
|
||||
|
||||
sql.setCondition(cnd);
|
||||
List<NutMap> users = (List<NutMap>) Daos.query(dao, sql.toString(), Sqls.callback.maps());
|
||||
return AjaxResult.success(users);
|
||||
}
|
||||
|
||||
}
|
||||
+131
@@ -0,0 +1,131 @@
|
||||
package com.ruoyi.staffService.condolence.controller;
|
||||
|
||||
import cn.hutool.core.convert.NumberChineseFormatter;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.deepoove.poi.XWPFTemplate;
|
||||
import com.deepoove.poi.config.Configure;
|
||||
import com.deepoove.poi.plugin.table.LoopRowTableRenderPolicy;
|
||||
import com.ruoyi.common.core.constant.SecurityConstants;
|
||||
import com.ruoyi.common.core.web.domain.AjaxResult;
|
||||
import com.ruoyi.common.security.annotation.RequiresPermissions;
|
||||
import com.ruoyi.common.security.utils.SecurityUtils;
|
||||
import com.ruoyi.staffService.api.constant.condolence.CondolencePageForm;
|
||||
import com.ruoyi.staffService.condolence.service.StaffCondolenceApplyRecordService;
|
||||
import com.ruoyi.system.api.RemoteSysLocalProcessService;
|
||||
import com.ruoyi.system.api.domain.SysUnion;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nutz.lang.util.NutMap;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.ServletOutputStream;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.InputStream;
|
||||
import java.net.URLEncoder;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* 慰问申请记录
|
||||
*
|
||||
* @author jug
|
||||
* @date 2023/02/01
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/condolence/applyRecord")
|
||||
@Slf4j
|
||||
public class StaffCondolenceApplyRecordController {
|
||||
|
||||
@Autowired
|
||||
private RemoteSysLocalProcessService localProcessService;
|
||||
@Autowired
|
||||
private StaffCondolenceApplyRecordService staffCondolenceApplyRecordService;
|
||||
|
||||
@PostMapping("/pageData")
|
||||
@RequiresPermissions("condolence:applyRecord")
|
||||
public AjaxResult pageData(@RequestBody CondolencePageForm condolencePageForm) {
|
||||
return AjaxResult.success(staffCondolenceApplyRecordService.pageData(condolencePageForm));
|
||||
}
|
||||
|
||||
/**
|
||||
* 做删除
|
||||
*
|
||||
* @param id id
|
||||
* @return {@link AjaxResult}
|
||||
*/
|
||||
@PostMapping("/doDelete")
|
||||
@RequiresPermissions("condolence:applyRecord")
|
||||
public AjaxResult doDelete(@RequestParam String id) {
|
||||
staffCondolenceApplyRecordService.delete(id);
|
||||
localProcessService.deleteProcessInstance("CONDOLENCE@" + id, SecurityConstants.INNER);
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 导出申请表
|
||||
*
|
||||
* @param id id
|
||||
* @param response 响应
|
||||
*/
|
||||
@PostMapping("/exportApplyForm")
|
||||
@RequiresPermissions("condolence:applyRecord")
|
||||
public void exportApplyForm(@RequestParam String id, HttpServletResponse response) {
|
||||
try (InputStream inputStream = Thread.currentThread().getContextClassLoader().getResourceAsStream("docTemplate/condolence/condolenceApply.docx");
|
||||
ServletOutputStream outputStream = response.getOutputStream()) {
|
||||
response.setContentType("application/octet-stream");
|
||||
response.setHeader("Content-Disposition", "attachment;filename=%s".formatted(URLEncoder.encode("慰问申请表.docx", StandardCharsets.UTF_8)));
|
||||
NutMap renderMap = staffCondolenceApplyRecordService.exportApplyForm(id);
|
||||
Configure config = Configure.builder().build();
|
||||
assert inputStream != null;
|
||||
XWPFTemplate.compile(inputStream, config).render(renderMap, outputStream);
|
||||
} catch (Exception e) {
|
||||
log.error("慰问申请表导出失败{}", e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出慰问金发放表
|
||||
*
|
||||
* @param response 响应
|
||||
*/
|
||||
@PostMapping("/exportMoneyIssue")
|
||||
@RequiresPermissions("condolence:applyRecord")
|
||||
public void exportMoneyIssue(@RequestParam(value = "year",required = false) String year,
|
||||
@RequestParam(value = "type",required = false) String type,
|
||||
@RequestParam(value = "unionId",required = false) String unionId,
|
||||
@RequestParam(value = "unitId",required = false) String unitId,
|
||||
@RequestParam(value = "unionGroupId",required = false) String unionGroupId,
|
||||
@RequestParam(value = "threeUnitId",required = false) String threeUnitId,
|
||||
HttpServletResponse response) {
|
||||
try (InputStream inputStream = Thread.currentThread().getContextClassLoader().getResourceAsStream("docTemplate/condolence/condolenceMoney.docx");
|
||||
ServletOutputStream outputStream = response.getOutputStream()) {
|
||||
assert inputStream != null;
|
||||
response.setContentType("application/octet-stream");
|
||||
response.setHeader("Content-Disposition", "attachment;filename=%s".formatted(URLEncoder.encode("慰问金发放.docx", StandardCharsets.UTF_8)));
|
||||
|
||||
List<NutMap> list = staffCondolenceApplyRecordService.exportMoneyIssue(year,type,unionId,unitId,unionGroupId,threeUnitId);
|
||||
|
||||
double totalMoney = list.stream().mapToDouble(v -> v.getDouble("money", 0)).sum();
|
||||
|
||||
LoopRowTableRenderPolicy hackLoopTableRenderPolicy = new LoopRowTableRenderPolicy();
|
||||
Configure config = Configure.builder()
|
||||
.bind("list", hackLoopTableRenderPolicy)
|
||||
.build();
|
||||
NutMap renderMap = NutMap.NEW();
|
||||
renderMap.setv("list", list);
|
||||
renderMap.setv("unionName", Optional.ofNullable(SecurityUtils.getUnion()).map(SysUnion::getUnionName).orElse(null));
|
||||
renderMap.setv("currentTime", DateUtil.format(new Date(), "yyyy年MM月dd日"));
|
||||
renderMap.setv("totalMoney", totalMoney);
|
||||
renderMap.setv("chinesTotalMoney", NumberChineseFormatter.format(totalMoney, true, true));
|
||||
XWPFTemplate.compile(inputStream, config).render(renderMap, outputStream);
|
||||
} catch (Exception e) {
|
||||
log.error("慰问慰问金发放表导出失败{}", e.getMessage());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
+62
@@ -0,0 +1,62 @@
|
||||
package com.ruoyi.staffService.condolence.controller;
|
||||
|
||||
import com.ruoyi.common.core.web.domain.AjaxResult;
|
||||
import com.ruoyi.common.security.annotation.RequiresPermissions;
|
||||
import com.ruoyi.staffService.api.constant.condolence.CondolencePageForm;
|
||||
import com.ruoyi.staffService.api.domain.condolence.CondolenceAudit;
|
||||
import com.ruoyi.staffService.condolence.service.StaffCondolenceAuditService;
|
||||
import com.ruoyi.staffService.condolence.service.StaffCondolenceBranchUnionAuditService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
/**
|
||||
* 分工会审核
|
||||
*
|
||||
* @author jug
|
||||
* @date 2023/02/01
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/condolence/branchUnionAudit")
|
||||
public class StaffCondolenceBranchUnionAuditController {
|
||||
|
||||
@Autowired
|
||||
private StaffCondolenceAuditService staffCondolenceAuditService;
|
||||
|
||||
@Autowired
|
||||
private StaffCondolenceBranchUnionAuditService staffCondolenceBranchUnionAuditService;
|
||||
|
||||
@PostMapping("/pageData")
|
||||
@RequiresPermissions("condolence:branchUnionAudit")
|
||||
public AjaxResult pageData(@RequestBody(required = false) CondolencePageForm condolencePageForm) {
|
||||
return AjaxResult.success(staffCondolenceAuditService.branchUnionPageData(condolencePageForm));
|
||||
}
|
||||
|
||||
@PostMapping("/doPass")
|
||||
@RequiresPermissions("condolence:branchUnionAudit")
|
||||
public AjaxResult doPass(@RequestBody CondolenceAudit audit) {
|
||||
staffCondolenceBranchUnionAuditService.doPass(audit);
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
@PostMapping("/doReject")
|
||||
@RequiresPermissions("condolence:branchUnionAudit")
|
||||
public AjaxResult doReject(@RequestBody CondolenceAudit audit) {
|
||||
staffCondolenceBranchUnionAuditService.doReject(audit);
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
@PostMapping("/doBackTo")
|
||||
@RequiresPermissions("condolence:branchUnionAudit")
|
||||
public AjaxResult doBackTo(@RequestBody CondolenceAudit audit) {
|
||||
staffCondolenceBranchUnionAuditService.doBackTo(audit);
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
@PostMapping("/doRevoke")
|
||||
@RequiresPermissions("condolence:branchUnionAudit")
|
||||
public AjaxResult doRevoke(@RequestParam String id) {
|
||||
staffCondolenceBranchUnionAuditService.doRevoke(id);
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
}
|
||||
+61
@@ -0,0 +1,61 @@
|
||||
package com.ruoyi.staffService.condolence.controller;
|
||||
|
||||
import com.ruoyi.common.core.web.domain.AjaxResult;
|
||||
import com.ruoyi.common.security.annotation.RequiresPermissions;
|
||||
import com.ruoyi.staffService.api.constant.condolence.CondolencePageForm;
|
||||
import com.ruoyi.staffService.api.domain.condolence.CondolenceAudit;
|
||||
import com.ruoyi.staffService.condolence.service.StaffCondolenceAuditService;
|
||||
import com.ruoyi.staffService.condolence.service.StaffCondolenceSchoolUnionAccountingAuditService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
/**
|
||||
* 校工会会计审核
|
||||
*
|
||||
* @author jug
|
||||
* @date 2023/02/01
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/condolence/schoolUnionAccountingAudit")
|
||||
public class StaffCondolenceSchoolUnionAccountingAuditController {
|
||||
|
||||
@Autowired
|
||||
private StaffCondolenceAuditService staffCondolenceAuditService;
|
||||
|
||||
@Autowired
|
||||
private StaffCondolenceSchoolUnionAccountingAuditService staffCondolenceSchoolUnionAccountingAuditService;
|
||||
|
||||
@PostMapping("/pageData")
|
||||
@RequiresPermissions("condolence:schoolUnionAccountingAudit")
|
||||
public AjaxResult pageData(@RequestBody(required = false) CondolencePageForm condolencePageForm) {
|
||||
return AjaxResult.success(staffCondolenceAuditService.schoolAccountingPageData(condolencePageForm));
|
||||
}
|
||||
|
||||
@PostMapping("/doPass")
|
||||
@RequiresPermissions("condolence:schoolUnionAccountingAudit")
|
||||
public AjaxResult doPass(@RequestBody CondolenceAudit audit) {
|
||||
staffCondolenceSchoolUnionAccountingAuditService.doPass(audit);
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
@PostMapping("/doReject")
|
||||
public AjaxResult doReject(@RequestBody CondolenceAudit audit) {
|
||||
staffCondolenceSchoolUnionAccountingAuditService.doReject(audit);
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
@PostMapping("/doBackTo")
|
||||
@RequiresPermissions("condolence:schoolUnionAccountingAudit")
|
||||
public AjaxResult doBackTo(@RequestBody CondolenceAudit audit) {
|
||||
staffCondolenceSchoolUnionAccountingAuditService.doBackTo(audit);
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
@PostMapping("/doRevoke")
|
||||
@RequiresPermissions("condolence:schoolUnionAccountingAudit")
|
||||
public AjaxResult doRevoke(@RequestParam String id) {
|
||||
staffCondolenceSchoolUnionAccountingAuditService.doRevoke(id);
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
}
|
||||
+62
@@ -0,0 +1,62 @@
|
||||
package com.ruoyi.staffService.condolence.controller;
|
||||
|
||||
import com.ruoyi.common.core.web.domain.AjaxResult;
|
||||
import com.ruoyi.common.security.annotation.RequiresPermissions;
|
||||
import com.ruoyi.staffService.api.constant.condolence.CondolencePageForm;
|
||||
import com.ruoyi.staffService.api.domain.condolence.CondolenceAudit;
|
||||
import com.ruoyi.staffService.condolence.service.StaffCondolenceAuditService;
|
||||
import com.ruoyi.staffService.condolence.service.StaffCondolenceSchoolUnionAuditService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
/**
|
||||
* 校工会审核
|
||||
*
|
||||
* @author jug
|
||||
* @date 2023/02/01
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/condolence/schoolUnionAudit")
|
||||
public class StaffCondolenceSchoolUnionAuditController {
|
||||
|
||||
@Autowired
|
||||
private StaffCondolenceAuditService staffCondolenceAuditService;
|
||||
|
||||
@Autowired
|
||||
private StaffCondolenceSchoolUnionAuditService staffCondolenceSchoolUnionAuditService;
|
||||
|
||||
@PostMapping("/pageData")
|
||||
@RequiresPermissions("condolence:schoolUnionAudit")
|
||||
public AjaxResult pageData(@RequestBody(required = false) CondolencePageForm condolencePageForm) {
|
||||
return AjaxResult.success(staffCondolenceAuditService.schoolUnionPageData(condolencePageForm));
|
||||
}
|
||||
|
||||
@PostMapping("/doPass")
|
||||
@RequiresPermissions("condolence:schoolUnionAudit")
|
||||
public AjaxResult doPass(@RequestBody CondolenceAudit audit) {
|
||||
staffCondolenceSchoolUnionAuditService.doPass(audit);
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
@PostMapping("/doReject")
|
||||
@RequiresPermissions("condolence:schoolUnionAudit")
|
||||
public AjaxResult doReject(@RequestBody CondolenceAudit audit) {
|
||||
staffCondolenceSchoolUnionAuditService.doReject(audit);
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
@PostMapping("/doBackTo")
|
||||
@RequiresPermissions("condolence:schoolUnionAudit")
|
||||
public AjaxResult doBackTo(@RequestBody CondolenceAudit audit) {
|
||||
staffCondolenceSchoolUnionAuditService.doBackTo(audit);
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
@PostMapping("/doRevoke")
|
||||
@RequiresPermissions("condolence:schoolUnionAudit")
|
||||
public AjaxResult doRevoke(@RequestParam String id) {
|
||||
staffCondolenceSchoolUnionAuditService.doRevoke(id);
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
}
|
||||
+33
@@ -0,0 +1,33 @@
|
||||
package com.ruoyi.staffService.condolence.controller;
|
||||
|
||||
import com.ruoyi.common.core.web.domain.AjaxResult;
|
||||
import com.ruoyi.common.security.annotation.RequiresPermissions;
|
||||
import com.ruoyi.staffService.api.constant.condolence.CondolencePageForm;
|
||||
import com.ruoyi.staffService.condolence.service.StaffCondolenceAuditService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* 慰问查询
|
||||
*
|
||||
* @author jug
|
||||
* @date 2023/02/02
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/condolence/statistics/query")
|
||||
@Slf4j
|
||||
public class StaffCondolenceStatisticsQueryController {
|
||||
|
||||
@Autowired
|
||||
private StaffCondolenceAuditService staffCondolenceAuditService;
|
||||
|
||||
@PostMapping("/pageData")
|
||||
@RequiresPermissions("condolence:query")
|
||||
public AjaxResult pageData(@RequestBody(required = false) CondolencePageForm pageForm) {
|
||||
return AjaxResult.success(staffCondolenceAuditService.statisticsQueryPageData(pageForm));
|
||||
}
|
||||
}
|
||||
+51
@@ -0,0 +1,51 @@
|
||||
package com.ruoyi.staffService.condolence.controller;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.ruoyi.common.core.web.domain.AjaxResult;
|
||||
import com.ruoyi.common.security.annotation.RequiresPermissions;
|
||||
import com.ruoyi.staffService.api.constant.condolence.CondolenceAuditState;
|
||||
import com.ruoyi.staffService.api.constant.condolence.CondolencePageForm;
|
||||
import org.nutz.dao.Dao;
|
||||
import org.nutz.dao.Sqls;
|
||||
import org.nutz.dao.sql.Sql;
|
||||
import org.nutz.dao.util.Daos;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/condolence/statistics/typeChart")
|
||||
public class StaffCondolenceStatisticsTypeChartController {
|
||||
|
||||
@Autowired
|
||||
private Dao dao;
|
||||
|
||||
@PostMapping("/typeNum")
|
||||
@RequiresPermissions("condolence:typeChart")
|
||||
public AjaxResult typeNum(@RequestBody CondolencePageForm pageForm) {
|
||||
Sql sql = Sqls.create("""
|
||||
SELECT
|
||||
type.`typeName`,
|
||||
type.`typeCode`,
|
||||
sum( CASE WHEN $conCnd THEN 1 ELSE 0 END ) as `value`
|
||||
FROM
|
||||
condolence_type type
|
||||
LEFT JOIN condolence con ON con.type = type.id
|
||||
GROUP BY
|
||||
type.id
|
||||
""");
|
||||
StringBuffer sbf = new StringBuffer();
|
||||
sbf.append("con.stateId = %d".formatted(CondolenceAuditState.SCHOOL_UNION_PASS));
|
||||
if (StrUtil.isNotBlank(pageForm.getUnionId())) {
|
||||
sbf.append(" AND con.comfortedPersonUnionId = '%s'".formatted(pageForm.getUnionId()));
|
||||
}
|
||||
if (pageForm.getYear() != null) {
|
||||
sbf.append(" AND YEAR(con.applyTime) = %d".formatted(pageForm.getYear()));
|
||||
}
|
||||
sql.setVar("conCnd", sbf);
|
||||
return AjaxResult.success(Daos.query(dao, sql.toString(), Sqls.callback.maps()));
|
||||
}
|
||||
|
||||
}
|
||||
+63
@@ -0,0 +1,63 @@
|
||||
package com.ruoyi.staffService.condolence.controller;
|
||||
|
||||
import com.ruoyi.common.core.web.domain.AjaxResult;
|
||||
import com.ruoyi.common.security.annotation.RequiresPermissions;
|
||||
import com.ruoyi.staffService.api.domain.condolence.CondolenceType;
|
||||
import org.nutz.dao.Cnd;
|
||||
import org.nutz.dao.Dao;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 职工慰问类型
|
||||
*
|
||||
* @author jug
|
||||
* @date 2023/02/01
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/condolence/type")
|
||||
public class StaffCondolenceTypeController {
|
||||
|
||||
@Autowired
|
||||
private Dao dao;
|
||||
|
||||
@PostMapping("/list")
|
||||
public AjaxResult list(@RequestBody(required = false) CondolenceType condolenceType) {
|
||||
Cnd cnd = Cnd.NEW();
|
||||
cnd.asc("typeCode");
|
||||
if (condolenceType != null) {
|
||||
cnd.and(Cnd.likeEX("typeName", condolenceType.getTypeName()));
|
||||
}
|
||||
List<CondolenceType> list = dao.query(CondolenceType.class, cnd);
|
||||
return AjaxResult.success(list);
|
||||
}
|
||||
|
||||
@PostMapping("/doAdd")
|
||||
@RequiresPermissions("condolence:type")
|
||||
public AjaxResult doAdd(@RequestBody CondolenceType condolenceType) {
|
||||
dao.insert(condolenceType);
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
@PostMapping("/doEdit")
|
||||
@RequiresPermissions("condolence:type")
|
||||
public AjaxResult doEdit(@RequestBody CondolenceType condolenceType) {
|
||||
dao.updateIgnoreNull(condolenceType);
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
@PostMapping("/doDelete/{id}")
|
||||
@RequiresPermissions("condolence:type")
|
||||
public AjaxResult doDelete(@PathVariable String id) {
|
||||
dao.clear(CondolenceType.class, Cnd.where("id", "=", id));
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
@GetMapping("/findOne/{id}")
|
||||
public AjaxResult findOne(@PathVariable String id) {
|
||||
CondolenceType condolenceType = dao.fetch(CondolenceType.class, Cnd.where("id", "=", id));
|
||||
return AjaxResult.success(condolenceType);
|
||||
}
|
||||
}
|
||||
+65
@@ -0,0 +1,65 @@
|
||||
package com.ruoyi.staffService.condolence.controller;
|
||||
|
||||
import com.ruoyi.common.core.web.domain.AjaxResult;
|
||||
import com.ruoyi.common.security.annotation.RequiresPermissions;
|
||||
import com.ruoyi.staffService.api.constant.condolence.CondolencePageForm;
|
||||
import com.ruoyi.staffService.api.domain.condolence.CondolenceAudit;
|
||||
import com.ruoyi.staffService.condolence.service.StaffCondolenceAuditService;
|
||||
import com.ruoyi.staffService.condolence.service.StaffCondolenceUnionGroupAuditService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
/**
|
||||
* 工会小组审核
|
||||
*
|
||||
* @author jug
|
||||
* @date 2023/02/01
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/condolence/unionGroupAudit")
|
||||
public class StaffCondolenceUnionGroupAuditController {
|
||||
|
||||
@Autowired
|
||||
private StaffCondolenceAuditService staffCondolenceAuditService;
|
||||
|
||||
@Autowired
|
||||
private StaffCondolenceUnionGroupAuditService staffCondolenceUnionGroupAuditService;
|
||||
|
||||
@PostMapping("/pageData")
|
||||
@RequiresPermissions("condolence:unionGroupAudit")
|
||||
public AjaxResult pageData(@RequestBody(required = false) CondolencePageForm condolencePageForm) {
|
||||
// if (StrUtil.isBlank(SecurityUtils.getUnionGroupId())) {
|
||||
// return AjaxResult.warn("您没有对应的工会小组!");
|
||||
// }
|
||||
return AjaxResult.success(staffCondolenceAuditService.unionGroupPageData(condolencePageForm));
|
||||
}
|
||||
|
||||
@PostMapping("/doPass")
|
||||
@RequiresPermissions("condolence:unionGroupAudit")
|
||||
public AjaxResult doPass(@RequestBody CondolenceAudit audit) {
|
||||
staffCondolenceUnionGroupAuditService.doPass(audit);
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
@PostMapping("/doReject")
|
||||
@RequiresPermissions("condolence:unionGroupAudit")
|
||||
public AjaxResult doReject(@RequestBody CondolenceAudit audit) {
|
||||
staffCondolenceUnionGroupAuditService.doReject(audit);
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
@PostMapping("/doBackTo")
|
||||
@RequiresPermissions("condolence:unionGroupAudit")
|
||||
public AjaxResult doBackTo(@RequestBody CondolenceAudit audit) {
|
||||
staffCondolenceUnionGroupAuditService.doBackTo(audit);
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
@PostMapping("/doRevoke")
|
||||
@RequiresPermissions("condolence:unionGroupAudit")
|
||||
public AjaxResult doRevoke(@RequestParam String id) {
|
||||
staffCondolenceUnionGroupAuditService.doRevoke(id);
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
}
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
package com.ruoyi.staffService.condolence.service;
|
||||
|
||||
import com.ruoyi.common.core.page.Pagination;
|
||||
import com.ruoyi.common.core.service.BaseService;
|
||||
import com.ruoyi.staffService.api.constant.condolence.CondolencePageForm;
|
||||
import com.ruoyi.staffService.api.domain.condolence.Condolence;
|
||||
import org.nutz.lang.util.NutMap;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface StaffCondolenceApplyRecordService extends BaseService<Condolence> {
|
||||
|
||||
Pagination pageData(CondolencePageForm pageForm);
|
||||
|
||||
/**
|
||||
* 导出申请表
|
||||
*
|
||||
* @param id id
|
||||
* @return {@link NutMap}
|
||||
*/
|
||||
NutMap exportApplyForm(String id);
|
||||
|
||||
/**
|
||||
* 导出慰问金发放单
|
||||
*
|
||||
* @return {@link NutMap}
|
||||
*/
|
||||
List<NutMap> exportMoneyIssue(String year,String type,String unionId,String unitId,String unionGroupId,String threeUnitId);
|
||||
}
|
||||
+57
@@ -0,0 +1,57 @@
|
||||
package com.ruoyi.staffService.condolence.service;
|
||||
|
||||
import com.ruoyi.common.core.page.Pagination;
|
||||
import com.ruoyi.common.core.service.BaseService;
|
||||
import com.ruoyi.staffService.api.constant.condolence.CondolencePageForm;
|
||||
import com.ruoyi.staffService.api.domain.condolence.Condolence;
|
||||
|
||||
|
||||
/**
|
||||
* 慰问审核service
|
||||
*
|
||||
* @author jug
|
||||
* @date 2023/02/01
|
||||
*/
|
||||
public interface StaffCondolenceAuditService extends BaseService<Condolence> {
|
||||
|
||||
/**
|
||||
* 工会小组页面数据
|
||||
*
|
||||
* @param pageForm 页面形式
|
||||
* @return {@link Pagination}
|
||||
*/
|
||||
Pagination unionGroupPageData(CondolencePageForm pageForm);
|
||||
|
||||
/**
|
||||
* 分工会页面数据
|
||||
*
|
||||
* @param pageForm 页面形式
|
||||
* @return {@link Pagination}
|
||||
*/
|
||||
Pagination branchUnionPageData(CondolencePageForm pageForm);
|
||||
|
||||
/**
|
||||
* 校工会会计页面数据
|
||||
*
|
||||
* @param pageForm 页面形式
|
||||
* @return {@link Pagination}
|
||||
*/
|
||||
Pagination schoolAccountingPageData(CondolencePageForm pageForm);
|
||||
|
||||
/**
|
||||
* 校工会页面数据
|
||||
*
|
||||
* @param pageForm 页面形式
|
||||
* @return {@link Pagination}
|
||||
*/
|
||||
Pagination schoolUnionPageData(CondolencePageForm pageForm);
|
||||
|
||||
/**
|
||||
* 统计查询页面数据
|
||||
*
|
||||
* @param pageForm 页面形式
|
||||
* @return {@link Pagination}
|
||||
*/
|
||||
Pagination statisticsQueryPageData(CondolencePageForm pageForm);
|
||||
|
||||
}
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
package com.ruoyi.staffService.condolence.service;
|
||||
|
||||
import com.ruoyi.common.core.service.BaseService;
|
||||
import com.ruoyi.staffService.api.domain.condolence.Condolence;
|
||||
import com.ruoyi.staffService.api.domain.condolence.CondolenceAudit;
|
||||
|
||||
public interface StaffCondolenceBranchUnionAuditService extends BaseService<Condolence> {
|
||||
|
||||
/**
|
||||
* 通过
|
||||
*
|
||||
* @param audit 审计
|
||||
*/
|
||||
void doPass(CondolenceAudit audit);
|
||||
|
||||
/**
|
||||
* 拒绝
|
||||
*
|
||||
* @param audit 审计
|
||||
*/
|
||||
void doReject(CondolenceAudit audit);
|
||||
|
||||
/**
|
||||
* 退回
|
||||
*
|
||||
* @param audit 审计
|
||||
*/
|
||||
void doBackTo(CondolenceAudit audit);
|
||||
|
||||
/**
|
||||
* 撤销
|
||||
*
|
||||
* @param id id
|
||||
*/
|
||||
void doRevoke(String id);
|
||||
|
||||
}
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
package com.ruoyi.staffService.condolence.service;
|
||||
|
||||
import com.ruoyi.common.core.service.BaseService;
|
||||
import com.ruoyi.staffService.api.domain.condolence.Condolence;
|
||||
import com.ruoyi.staffService.api.domain.condolence.CondolenceAudit;
|
||||
|
||||
public interface StaffCondolenceSchoolUnionAccountingAuditService extends BaseService<Condolence> {
|
||||
|
||||
/**
|
||||
* 通过
|
||||
*
|
||||
* @param audit 审计
|
||||
*/
|
||||
void doPass(CondolenceAudit audit);
|
||||
|
||||
/**
|
||||
* 拒绝
|
||||
*
|
||||
* @param audit 审计
|
||||
*/
|
||||
void doReject(CondolenceAudit audit);
|
||||
|
||||
/**
|
||||
* 退回
|
||||
*
|
||||
* @param audit 审计
|
||||
*/
|
||||
void doBackTo(CondolenceAudit audit);
|
||||
|
||||
/**
|
||||
* 撤销
|
||||
*
|
||||
* @param id id
|
||||
*/
|
||||
void doRevoke(String id);
|
||||
|
||||
}
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
package com.ruoyi.staffService.condolence.service;
|
||||
|
||||
import com.ruoyi.common.core.service.BaseService;
|
||||
import com.ruoyi.staffService.api.domain.condolence.Condolence;
|
||||
import com.ruoyi.staffService.api.domain.condolence.CondolenceAudit;
|
||||
|
||||
public interface StaffCondolenceSchoolUnionAuditService extends BaseService<Condolence> {
|
||||
|
||||
/**
|
||||
* 通过
|
||||
*
|
||||
* @param audit 审计
|
||||
*/
|
||||
void doPass(CondolenceAudit audit);
|
||||
|
||||
/**
|
||||
* 拒绝
|
||||
*
|
||||
* @param audit 审计
|
||||
*/
|
||||
void doReject(CondolenceAudit audit);
|
||||
|
||||
/**
|
||||
* 退回
|
||||
*
|
||||
* @param audit 审计
|
||||
*/
|
||||
void doBackTo(CondolenceAudit audit);
|
||||
|
||||
/**
|
||||
* 撤销
|
||||
*
|
||||
* @param id id
|
||||
*/
|
||||
void doRevoke(String id);
|
||||
|
||||
}
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
package com.ruoyi.staffService.condolence.service;
|
||||
|
||||
import com.ruoyi.common.core.service.BaseService;
|
||||
import com.ruoyi.staffService.api.domain.condolence.Condolence;
|
||||
import com.ruoyi.staffService.api.domain.condolence.CondolenceAudit;
|
||||
|
||||
public interface StaffCondolenceUnionGroupAuditService extends BaseService<Condolence> {
|
||||
|
||||
/**
|
||||
* 通过
|
||||
*
|
||||
* @param audit 审计
|
||||
*/
|
||||
void doPass(CondolenceAudit audit);
|
||||
|
||||
/**
|
||||
* 拒绝
|
||||
*
|
||||
* @param audit 审计
|
||||
*/
|
||||
void doReject(CondolenceAudit audit);
|
||||
|
||||
/**
|
||||
* 退回
|
||||
*
|
||||
* @param audit 审计
|
||||
*/
|
||||
void doBackTo(CondolenceAudit audit);
|
||||
|
||||
/**
|
||||
* 撤销
|
||||
*
|
||||
* @param id id
|
||||
*/
|
||||
void doRevoke(String id);
|
||||
|
||||
}
|
||||
+130
@@ -0,0 +1,130 @@
|
||||
package com.ruoyi.staffService.condolence.service.impl;
|
||||
|
||||
import com.ruoyi.common.core.constant.AuditConstants;
|
||||
import com.ruoyi.common.core.constant.Roles;
|
||||
import com.ruoyi.common.core.constant.SecurityConstants;
|
||||
import com.ruoyi.common.core.domain.R;
|
||||
import com.ruoyi.common.core.service.BaseServiceImpl;
|
||||
import com.ruoyi.staffService.api.constant.condolence.CondolenceAuditState;
|
||||
import com.ruoyi.staffService.api.constant.condolence.CondolenceAuditType;
|
||||
import com.ruoyi.staffService.api.domain.condolence.Condolence;
|
||||
import com.ruoyi.staffService.api.domain.condolence.CondolenceAudit;
|
||||
import com.ruoyi.staffService.condolence.service.StaffCondolenceBranchUnionAuditService;
|
||||
import com.ruoyi.system.api.RemoteSysLocalProcessService;
|
||||
import org.nutz.dao.Chain;
|
||||
import org.nutz.dao.Cnd;
|
||||
import org.nutz.dao.Dao;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class CondolenceBranchUnionAuditServiceImpl extends BaseServiceImpl<Condolence> implements StaffCondolenceBranchUnionAuditService {
|
||||
|
||||
@Autowired
|
||||
private RemoteSysLocalProcessService localProcessService;
|
||||
|
||||
public CondolenceBranchUnionAuditServiceImpl(Dao dao) {
|
||||
super(dao);
|
||||
}
|
||||
|
||||
private void doAudit(CondolenceAudit audit) {
|
||||
audit.setAuditType(CondolenceAuditType.BRANCH_UNION);
|
||||
dao().insert(audit);
|
||||
String condolenceId = audit.getCondolenceId();
|
||||
// 查询慰问
|
||||
Condolence condolence = dao().fetch(Condolence.class, condolenceId);
|
||||
String taskNodeName = "";
|
||||
Chain chain = Chain.make("branchUnionAuditId", audit.getId());
|
||||
switch (audit.getAuditResult()) {
|
||||
case AuditConstants.PASS -> {
|
||||
chain.add("stateId", CondolenceAuditState.SCHOOL_UNION_ACCOUNTING_READY);
|
||||
taskNodeName = "分工会通过";
|
||||
}
|
||||
case AuditConstants.REJECT -> {
|
||||
chain.add("stateId", CondolenceAuditState.BRANCH_UNION_REJECTED);
|
||||
taskNodeName = "分工会拒绝";
|
||||
}
|
||||
case AuditConstants.BACK -> {
|
||||
chain.add("stateId", CondolenceAuditState.BRANCH_UNION_BACK_MODIFY);
|
||||
taskNodeName = "分工会退回";
|
||||
}
|
||||
}
|
||||
dao().update(Condolence.class, chain, Cnd.where("id", "=", condolenceId));
|
||||
|
||||
String processUniqueId = "CONDOLENCE@" + condolenceId;
|
||||
localProcessService.completeTask(processUniqueId, String.valueOf(CondolenceAuditState.BRANCH_UNION_READY), taskNodeName, SecurityConstants.INNER);
|
||||
|
||||
switch (audit.getAuditResult()) {
|
||||
case AuditConstants.PASS -> {
|
||||
// 通过,下一步流程,校工会财务审核
|
||||
R<List<String>> assignments = localProcessService.getAssignments(null, null, Roles.SCHOOL_ACCOUNTING, SecurityConstants.INNER);
|
||||
List<String> loginNameList = assignments.getData();
|
||||
localProcessService.initCreateTask(
|
||||
processUniqueId,
|
||||
String.valueOf(CondolenceAuditState.SCHOOL_UNION_ACCOUNTING_READY),
|
||||
"校工会会计审核",
|
||||
loginNameList,
|
||||
"/staffService/condolence/schoolUnionAccountingAudit",
|
||||
null,
|
||||
SecurityConstants.INNER
|
||||
);
|
||||
}
|
||||
case AuditConstants.REJECT -> {
|
||||
// 拒绝,流程结束
|
||||
localProcessService.completeProcess(processUniqueId, true, SecurityConstants.INNER);
|
||||
}
|
||||
case AuditConstants.BACK -> {
|
||||
// 退回
|
||||
localProcessService.initCreateTask(
|
||||
processUniqueId,
|
||||
String.valueOf(CondolenceAuditState.BRANCH_UNION_BACK_MODIFY),
|
||||
"分工会退回",
|
||||
List.of(condolence.getAgentLoginName()),
|
||||
"/staffService/condolence/applyRecord",
|
||||
null,
|
||||
SecurityConstants.INNER
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void doPass(CondolenceAudit audit) {
|
||||
audit.setAuditResult(AuditConstants.PASS);
|
||||
this.doAudit(audit);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doReject(CondolenceAudit audit) {
|
||||
audit.setAuditResult(AuditConstants.REJECT);
|
||||
this.doAudit(audit);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doBackTo(CondolenceAudit audit) {
|
||||
audit.setAuditResult(AuditConstants.BACK);
|
||||
this.doAudit(audit);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void doRevoke(String id) {
|
||||
Condolence condolence = fetch(id);
|
||||
String branchUnionAuditId = condolence.getBranchUnionAuditId();
|
||||
dao().clear(CondolenceAudit.class, Cnd.where("id", "=", branchUnionAuditId));
|
||||
Chain chain = Chain.make("branchUnionAuditId", null);
|
||||
chain.add("stateId", CondolenceAuditState.BRANCH_UNION_READY);
|
||||
dao().update(Condolence.class, chain, Cnd.where("id", "=", id));
|
||||
|
||||
localProcessService.revokeTask(
|
||||
"CONDOLENCE@" + id,
|
||||
String.valueOf(CondolenceAuditState.BRANCH_UNION_READY),
|
||||
SecurityConstants.INNER
|
||||
);
|
||||
}
|
||||
}
|
||||
+130
@@ -0,0 +1,130 @@
|
||||
package com.ruoyi.staffService.condolence.service.impl;
|
||||
|
||||
import com.ruoyi.common.core.constant.AuditConstants;
|
||||
import com.ruoyi.common.core.constant.Roles;
|
||||
import com.ruoyi.common.core.constant.SecurityConstants;
|
||||
import com.ruoyi.common.core.domain.R;
|
||||
import com.ruoyi.common.core.service.BaseServiceImpl;
|
||||
import com.ruoyi.staffService.api.constant.condolence.CondolenceAuditState;
|
||||
import com.ruoyi.staffService.api.constant.condolence.CondolenceAuditType;
|
||||
import com.ruoyi.staffService.api.domain.condolence.Condolence;
|
||||
import com.ruoyi.staffService.api.domain.condolence.CondolenceAudit;
|
||||
import com.ruoyi.staffService.condolence.service.StaffCondolenceSchoolUnionAccountingAuditService;
|
||||
import com.ruoyi.system.api.RemoteSysLocalProcessService;
|
||||
import org.nutz.dao.Chain;
|
||||
import org.nutz.dao.Cnd;
|
||||
import org.nutz.dao.Dao;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class CondolenceSchoolUnionAccountingAuditServiceImpl extends BaseServiceImpl<Condolence> implements StaffCondolenceSchoolUnionAccountingAuditService {
|
||||
|
||||
@Autowired
|
||||
private RemoteSysLocalProcessService localProcessService;
|
||||
|
||||
public CondolenceSchoolUnionAccountingAuditServiceImpl(Dao dao) {
|
||||
super(dao);
|
||||
}
|
||||
|
||||
private void doAudit(CondolenceAudit audit) {
|
||||
audit.setAuditType(CondolenceAuditType.SCHOOL_UNION_ACCOUNTING);
|
||||
dao().insert(audit);
|
||||
String condolenceId = audit.getCondolenceId();
|
||||
// 查询慰问
|
||||
Condolence condolence = dao().fetch(Condolence.class, condolenceId);
|
||||
String taskNodeName = "";
|
||||
Chain chain = Chain.make("schoolUnionAccountingAuditId", audit.getId());
|
||||
switch (audit.getAuditResult()) {
|
||||
case AuditConstants.PASS -> {
|
||||
chain.add("stateId", CondolenceAuditState.SCHOOL_UNION_READY);
|
||||
taskNodeName = "校工会会计通过";
|
||||
}
|
||||
case AuditConstants.REJECT -> {
|
||||
chain.add("stateId", CondolenceAuditState.SCHOOL_UNION_ACCOUNTING_REJECTED);
|
||||
taskNodeName = "校工会会计拒绝";
|
||||
}
|
||||
case AuditConstants.BACK -> {
|
||||
chain.add("stateId", CondolenceAuditState.SCHOOL_UNION_ACCOUNTING_BACK_MODIFY);
|
||||
taskNodeName = "校工会会计退回";
|
||||
}
|
||||
}
|
||||
dao().update(Condolence.class, chain, Cnd.where("id", "=", condolenceId));
|
||||
|
||||
String processUniqueId = "CONDOLENCE@" + condolenceId;
|
||||
localProcessService.completeTask(processUniqueId, String.valueOf(CondolenceAuditState.SCHOOL_UNION_ACCOUNTING_READY), taskNodeName, SecurityConstants.INNER);
|
||||
|
||||
switch (audit.getAuditResult()) {
|
||||
case AuditConstants.PASS -> {
|
||||
// 通过,下一步流程,校工会审核
|
||||
R<List<String>> assignments = localProcessService.getAssignments(null, null, Roles.SCHOOL_ADMIN, SecurityConstants.INNER);
|
||||
List<String> loginNameList = assignments.getData();
|
||||
|
||||
localProcessService.initCreateTask(
|
||||
processUniqueId,
|
||||
String.valueOf(CondolenceAuditState.SCHOOL_UNION_READY),
|
||||
"校工会审核",
|
||||
loginNameList,
|
||||
"/staffService/condolence/schoolUnionAudit",
|
||||
null,
|
||||
SecurityConstants.INNER
|
||||
);
|
||||
}
|
||||
case AuditConstants.REJECT -> {
|
||||
// 拒绝
|
||||
localProcessService.completeProcess(processUniqueId, true, SecurityConstants.INNER);
|
||||
}
|
||||
case AuditConstants.BACK -> {
|
||||
// 退回
|
||||
localProcessService.initCreateTask(
|
||||
processUniqueId,
|
||||
String.valueOf(CondolenceAuditState.SCHOOL_UNION_ACCOUNTING_BACK_MODIFY),
|
||||
"校工会会计退回",
|
||||
List.of(condolence.getAgentLoginName()),
|
||||
"/staffService/condolence/applyRecord",
|
||||
null,
|
||||
SecurityConstants.INNER
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void doPass(CondolenceAudit audit) {
|
||||
audit.setAuditResult(AuditConstants.PASS);
|
||||
this.doAudit(audit);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doReject(CondolenceAudit audit) {
|
||||
audit.setAuditResult(AuditConstants.REJECT);
|
||||
this.doAudit(audit);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doBackTo(CondolenceAudit audit) {
|
||||
audit.setAuditResult(AuditConstants.BACK);
|
||||
this.doAudit(audit);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void doRevoke(String id) {
|
||||
Condolence condolence = fetch(id);
|
||||
String schoolUnionAccountingAuditId = condolence.getSchoolUnionAccountingAuditId();
|
||||
dao().clear(CondolenceAudit.class, Cnd.where("id", "=", schoolUnionAccountingAuditId));
|
||||
Chain chain = Chain.make("schoolUnionAccountingAuditId", null);
|
||||
chain.add("stateId", CondolenceAuditState.SCHOOL_UNION_ACCOUNTING_READY);
|
||||
dao().update(Condolence.class, chain, Cnd.where("id", "=", id));
|
||||
|
||||
localProcessService.revokeTask(
|
||||
"CONDOLENCE@" + id,
|
||||
String.valueOf(CondolenceAuditState.SCHOOL_UNION_ACCOUNTING_READY),
|
||||
SecurityConstants.INNER
|
||||
);
|
||||
}
|
||||
}
|
||||
+111
@@ -0,0 +1,111 @@
|
||||
package com.ruoyi.staffService.condolence.service.impl;
|
||||
|
||||
import com.ruoyi.common.core.constant.AuditConstants;
|
||||
import com.ruoyi.common.core.constant.SecurityConstants;
|
||||
import com.ruoyi.common.core.service.BaseServiceImpl;
|
||||
import com.ruoyi.staffService.api.constant.condolence.CondolenceAuditState;
|
||||
import com.ruoyi.staffService.api.constant.condolence.CondolenceAuditType;
|
||||
import com.ruoyi.staffService.api.domain.condolence.Condolence;
|
||||
import com.ruoyi.staffService.api.domain.condolence.CondolenceAudit;
|
||||
import com.ruoyi.staffService.condolence.service.StaffCondolenceSchoolUnionAuditService;
|
||||
import com.ruoyi.system.api.RemoteSysLocalProcessService;
|
||||
import org.nutz.dao.Chain;
|
||||
import org.nutz.dao.Cnd;
|
||||
import org.nutz.dao.Dao;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class CondolenceSchoolUnionAuditServiceImpl extends BaseServiceImpl<Condolence> implements StaffCondolenceSchoolUnionAuditService {
|
||||
|
||||
@Autowired
|
||||
private RemoteSysLocalProcessService localProcessService;
|
||||
|
||||
public CondolenceSchoolUnionAuditServiceImpl(Dao dao) {
|
||||
super(dao);
|
||||
}
|
||||
|
||||
private void doAudit(CondolenceAudit audit) {
|
||||
audit.setAuditType(CondolenceAuditType.SCHOOL_UNION);
|
||||
dao().insert(audit);
|
||||
String condolenceId = audit.getCondolenceId();
|
||||
// 查询慰问
|
||||
Condolence condolence = dao().fetch(Condolence.class, condolenceId);
|
||||
String taskNodeName = "";
|
||||
Chain chain = Chain.make("schoolUnionAccountingAuditId", audit.getId());
|
||||
switch (audit.getAuditResult()) {
|
||||
case AuditConstants.PASS -> {
|
||||
chain.add("stateId", CondolenceAuditState.SCHOOL_UNION_PASS);
|
||||
taskNodeName = "校工会通过";
|
||||
}
|
||||
case AuditConstants.REJECT -> {
|
||||
chain.add("stateId", CondolenceAuditState.SCHOOL_UNION_REJECTED);
|
||||
taskNodeName = "校工会拒绝";
|
||||
}
|
||||
case AuditConstants.BACK -> {
|
||||
chain.add("stateId", CondolenceAuditState.SCHOOL_UNION_BACK_MODIFY);
|
||||
taskNodeName = "校工会退回";
|
||||
}
|
||||
}
|
||||
dao().update(Condolence.class, chain, Cnd.where("id", "=", condolenceId));
|
||||
|
||||
String processUniqueId = "CONDOLENCE@" + condolenceId;
|
||||
localProcessService.completeTask(processUniqueId, String.valueOf(CondolenceAuditState.SCHOOL_UNION_READY), taskNodeName, SecurityConstants.INNER);
|
||||
|
||||
switch (audit.getAuditResult()) {
|
||||
case AuditConstants.PASS, AuditConstants.REJECT -> {
|
||||
localProcessService.completeProcess(processUniqueId, audit.getAuditResult().equals(AuditConstants.REJECT), SecurityConstants.INNER);
|
||||
}
|
||||
case AuditConstants.BACK -> {
|
||||
localProcessService.initCreateTask(
|
||||
processUniqueId,
|
||||
String.valueOf(CondolenceAuditState.SCHOOL_UNION_BACK_MODIFY),
|
||||
"校工会退回",
|
||||
List.of(condolence.getAgentLoginName()),
|
||||
"/staffService/condolence/applyRecord",
|
||||
null,
|
||||
SecurityConstants.INNER
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void doPass(CondolenceAudit audit) {
|
||||
audit.setAuditResult(AuditConstants.PASS);
|
||||
this.doAudit(audit);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doReject(CondolenceAudit audit) {
|
||||
audit.setAuditResult(AuditConstants.REJECT);
|
||||
this.doAudit(audit);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doBackTo(CondolenceAudit audit) {
|
||||
audit.setAuditResult(AuditConstants.BACK);
|
||||
this.doAudit(audit);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void doRevoke(String id) {
|
||||
Condolence condolence = fetch(id);
|
||||
String schoolUnionAuditId = condolence.getSchoolUnionAuditId();
|
||||
dao().clear(CondolenceAudit.class, Cnd.where("id", "=", schoolUnionAuditId));
|
||||
Chain chain = Chain.make("schoolUnionAuditId", null);
|
||||
chain.add("stateId", CondolenceAuditState.SCHOOL_UNION_READY);
|
||||
dao().update(Condolence.class, chain, Cnd.where("id", "=", id));
|
||||
|
||||
localProcessService.revokeTask(
|
||||
"CONDOLENCE@" + id,
|
||||
String.valueOf(CondolenceAuditState.SCHOOL_UNION_READY),
|
||||
SecurityConstants.INNER
|
||||
);
|
||||
}
|
||||
}
|
||||
+131
@@ -0,0 +1,131 @@
|
||||
package com.ruoyi.staffService.condolence.service.impl;
|
||||
|
||||
import com.ruoyi.common.core.constant.AuditConstants;
|
||||
import com.ruoyi.common.core.constant.Roles;
|
||||
import com.ruoyi.common.core.constant.SecurityConstants;
|
||||
import com.ruoyi.common.core.domain.R;
|
||||
import com.ruoyi.common.core.service.BaseServiceImpl;
|
||||
import com.ruoyi.staffService.api.constant.condolence.CondolenceAuditState;
|
||||
import com.ruoyi.staffService.api.constant.condolence.CondolenceAuditType;
|
||||
import com.ruoyi.staffService.api.domain.condolence.Condolence;
|
||||
import com.ruoyi.staffService.api.domain.condolence.CondolenceAudit;
|
||||
import com.ruoyi.staffService.condolence.service.StaffCondolenceUnionGroupAuditService;
|
||||
import com.ruoyi.system.api.RemoteSysLocalProcessService;
|
||||
import org.nutz.dao.Chain;
|
||||
import org.nutz.dao.Cnd;
|
||||
import org.nutz.dao.Dao;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class CondolenceUnionGroupAuditServiceImpl extends BaseServiceImpl<Condolence> implements StaffCondolenceUnionGroupAuditService {
|
||||
|
||||
@Autowired
|
||||
private RemoteSysLocalProcessService localProcessService;
|
||||
|
||||
public CondolenceUnionGroupAuditServiceImpl(Dao dao) {
|
||||
super(dao);
|
||||
}
|
||||
|
||||
private void doAudit(CondolenceAudit audit) {
|
||||
audit.setAuditType(CondolenceAuditType.UNION_GROUP);
|
||||
dao().insert(audit);
|
||||
String condolenceId = audit.getCondolenceId();
|
||||
// 查询慰问
|
||||
Condolence condolence = dao().fetch(Condolence.class, condolenceId);
|
||||
String taskNodeName = "";
|
||||
Chain chain = Chain.make("unionGroupAuditId", audit.getId());
|
||||
switch (audit.getAuditResult()) {
|
||||
case AuditConstants.PASS -> {
|
||||
chain.add("stateId", CondolenceAuditState.BRANCH_UNION_READY);
|
||||
taskNodeName = "工会小组通过";
|
||||
}
|
||||
case AuditConstants.REJECT -> {
|
||||
chain.add("stateId", CondolenceAuditState.UNION_GROUP_REJECTED);
|
||||
taskNodeName = "工会小组不通过";
|
||||
}
|
||||
case AuditConstants.BACK -> {
|
||||
chain.add("stateId", CondolenceAuditState.UNION_GROUP_BACK_MODIFY);
|
||||
taskNodeName = "工会小组退回";
|
||||
}
|
||||
}
|
||||
dao().update(Condolence.class, chain, Cnd.where("id", "=", condolenceId));
|
||||
|
||||
String processUniqueId = "CONDOLENCE@" + condolenceId;
|
||||
localProcessService.completeTask(processUniqueId, String.valueOf(CondolenceAuditState.UNION_GROUP_READY), taskNodeName, SecurityConstants.INNER);
|
||||
|
||||
switch (audit.getAuditResult()) {
|
||||
case AuditConstants.PASS -> {
|
||||
// 通过,下一步流程,分工会审核
|
||||
R<List<String>> assignments = localProcessService.getAssignments(condolence.getComfortedPersonUnionId(),
|
||||
null, Roles.FGH_ADMIN, SecurityConstants.INNER);
|
||||
List<String> loginNameList = assignments.getData();
|
||||
|
||||
localProcessService.initCreateTask(
|
||||
processUniqueId,
|
||||
String.valueOf(CondolenceAuditState.BRANCH_UNION_READY),
|
||||
"分工会审核",
|
||||
loginNameList,
|
||||
"/staffService/condolence/branchUnionAudit",
|
||||
null,
|
||||
SecurityConstants.INNER
|
||||
);
|
||||
}
|
||||
case AuditConstants.REJECT -> {
|
||||
// 拒绝,流程结束
|
||||
localProcessService.completeProcess(processUniqueId, true, SecurityConstants.INNER);
|
||||
}
|
||||
case AuditConstants.BACK -> {
|
||||
// 退回
|
||||
localProcessService.initCreateTask(
|
||||
processUniqueId,
|
||||
String.valueOf(CondolenceAuditState.UNION_GROUP_BACK_MODIFY),
|
||||
"工会小组退回",
|
||||
List.of(condolence.getAgentLoginName()),
|
||||
"/staffService/condolence/applyRecord",
|
||||
null,
|
||||
SecurityConstants.INNER
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void doPass(CondolenceAudit audit) {
|
||||
audit.setAuditResult(AuditConstants.PASS);
|
||||
this.doAudit(audit);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doReject(CondolenceAudit audit) {
|
||||
audit.setAuditResult(AuditConstants.REJECT);
|
||||
this.doAudit(audit);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doBackTo(CondolenceAudit audit) {
|
||||
audit.setAuditResult(AuditConstants.BACK);
|
||||
this.doAudit(audit);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void doRevoke(String id) {
|
||||
Condolence condolence = fetch(id);
|
||||
String unionGroupAuditId = condolence.getUnionGroupAuditId();
|
||||
dao().clear(CondolenceAudit.class, Cnd.where("id", "=", unionGroupAuditId));
|
||||
Chain chain = Chain.make("unionGroupAuditId", null);
|
||||
chain.add("stateId", CondolenceAuditState.UNION_GROUP_READY);
|
||||
dao().update(Condolence.class, chain, Cnd.where("id", "=", id));
|
||||
|
||||
localProcessService.revokeTask(
|
||||
"CONDOLENCE@" + id,
|
||||
String.valueOf(CondolenceAuditState.UNION_GROUP_READY),
|
||||
SecurityConstants.INNER
|
||||
);
|
||||
}
|
||||
}
|
||||
+133
@@ -0,0 +1,133 @@
|
||||
package com.ruoyi.staffService.condolence.service.impl;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.ruoyi.common.core.page.Pagination;
|
||||
import com.ruoyi.common.core.service.BaseServiceImpl;
|
||||
import com.ruoyi.common.security.utils.DictUtils;
|
||||
import com.ruoyi.common.security.utils.SecurityUtils;
|
||||
import com.ruoyi.staffService.api.constant.condolence.CondolenceAuditState;
|
||||
import com.ruoyi.staffService.api.constant.condolence.CondolencePageForm;
|
||||
import com.ruoyi.staffService.api.domain.condolence.Condolence;
|
||||
import com.ruoyi.staffService.condolence.service.StaffCondolenceApplyRecordService;
|
||||
import com.ruoyi.system.api.domain.SysDictData;
|
||||
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.lang.Lang;
|
||||
import org.nutz.lang.util.NutMap;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class StaffCondolenceApplyRecordServiceImpl extends BaseServiceImpl<Condolence> implements StaffCondolenceApplyRecordService {
|
||||
|
||||
public StaffCondolenceApplyRecordServiceImpl(Dao dao) {
|
||||
super(dao);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Pagination pageData(CondolencePageForm pageForm) {
|
||||
Sql sql = Sqls.create("""
|
||||
SELECT
|
||||
c.*,
|
||||
ct.typeName,
|
||||
ct.typeCode,
|
||||
state.stateName,
|
||||
state.stateColor,
|
||||
IF ( ct.way = '慰问金 (A)', TRUE, FALSE ) AS exportMoneyIssue
|
||||
FROM
|
||||
condolence c
|
||||
LEFT JOIN condolence_type ct ON ct.id = c.type
|
||||
LEFT JOIN audit_state state on state.stateId = c.stateId
|
||||
$condition
|
||||
""");
|
||||
Cnd cnd = Cnd.NEW();
|
||||
SqlExpressionGroup seg = new SqlExpressionGroup();
|
||||
seg.or("agentId", "=", SecurityUtils.getUserId());
|
||||
seg.or("comfortedPersonId", "=", SecurityUtils.getUserId());
|
||||
cnd.and(seg);
|
||||
|
||||
cnd.andEX("YEAR(c.applyTime)", "=", pageForm.getYear());
|
||||
cnd.andEX("c.type", "=", pageForm.getType());
|
||||
|
||||
if (StrUtil.isNotBlank(pageForm.getSearchKeyword())) {
|
||||
SqlExpressionGroup seg2 = new SqlExpressionGroup();
|
||||
seg2.orLike("c.comfortedPersonUserName", pageForm.getSearchKeyword());
|
||||
seg2.orLike("c.comfortedPersonLoginName", pageForm.getSearchKeyword());
|
||||
cnd.and(seg2);
|
||||
}
|
||||
|
||||
sql.setCondition(cnd);
|
||||
Pagination pagination = listPageMap(pageForm.getPageNumber(), pageForm.getPageSize(), sql);
|
||||
return pagination;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NutMap exportApplyForm(String id) {
|
||||
Condolence condolence = dao().fetch(Condolence.class, id);
|
||||
dao().fetchLinks(condolence, null);
|
||||
NutMap condolenceMapData = Lang.obj2nutmap(condolence);
|
||||
List<SysDictData> sys_user_sex = DictUtils.getDictCache("sys_user_sex");
|
||||
String comfortedPersonSex = sys_user_sex.stream().filter(v -> v.getDictValue().equals(condolence.getComfortedPersonSex())).findFirst().map(SysDictData::getDictLabel).orElse(null);
|
||||
condolenceMapData.setv("comfortedPersonSex", comfortedPersonSex);
|
||||
Boolean spousePersonTwoEmployees = condolence.getSpouseTwoEmployees();
|
||||
if (spousePersonTwoEmployees) {
|
||||
condolenceMapData.setv("YescomfortedPersonTwoEmployees", "√");
|
||||
} else {
|
||||
condolenceMapData.setv("NotcomfortedPersonTwoEmployees", "√");
|
||||
}
|
||||
condolenceMapData.setv("applyTime", DateUtil.format(condolence.getApplyTime(), "yyyy年MM月dd日"));
|
||||
|
||||
NutMap unionGroupAudit = condolenceMapData.getAs("unionGroupAudit", NutMap.class);
|
||||
if (unionGroupAudit != null) {
|
||||
unionGroupAudit.setv("auditTime", DateUtil.format(unionGroupAudit.getTime("auditTime"), "yyyy年MM月dd日"));
|
||||
condolenceMapData.setv("unionGroupAudit", unionGroupAudit);
|
||||
}
|
||||
|
||||
NutMap branchUnionAudit = condolenceMapData.getAs("branchUnionAudit", NutMap.class);
|
||||
if (branchUnionAudit != null) {
|
||||
branchUnionAudit.setv("auditTime", DateUtil.format(branchUnionAudit.getTime("auditTime"), "yyyy年MM月dd日"));
|
||||
condolenceMapData.setv("branchUnionAudit", branchUnionAudit);
|
||||
}
|
||||
|
||||
NutMap schoolUnionAudit = condolenceMapData.getAs("schoolUnionAudit", NutMap.class);
|
||||
if (schoolUnionAudit != null) {
|
||||
schoolUnionAudit.setv("auditTime", DateUtil.format(schoolUnionAudit.getTime("auditTime"), "yyyy年MM月dd日"));
|
||||
condolenceMapData.setv("schoolUnionAudit", schoolUnionAudit);
|
||||
}
|
||||
|
||||
return condolenceMapData;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<NutMap> exportMoneyIssue(String year,String type,String unionId,String unitId,String unionGroupId,String threeUnitId) {
|
||||
Sql sql = Sqls.create("""
|
||||
SELECT
|
||||
c.comfortedPersonUserName as userName,
|
||||
t.money,
|
||||
c.comfortedPersonUnionName
|
||||
FROM
|
||||
condolence c
|
||||
LEFT JOIN condolence_type t ON t.id = c.type
|
||||
$condition
|
||||
""");
|
||||
Cnd cnd = Cnd.NEW();
|
||||
if (StrUtil.isNotBlank(type)){
|
||||
cnd.and("c.type","=",type);
|
||||
} else {
|
||||
cnd.and("t.way","=","慰问金 (A)");
|
||||
}
|
||||
cnd.andEX("YEAR(c.applyTime)","=",year);
|
||||
cnd.andEX("comfortedPersonUnionId","=",unionId);
|
||||
cnd.andEX("comfortedPersonUnitId","=",unitId);
|
||||
cnd.andEX("comfortedPersonThreeUnitId","=",threeUnitId);
|
||||
cnd.andEX("comfortedPersonUnionGroupId","=",unionGroupId);
|
||||
cnd.and("c.stateId","=",CondolenceAuditState.SCHOOL_UNION_PASS);
|
||||
sql.setCondition(cnd);
|
||||
return listMap(sql);
|
||||
}
|
||||
}
|
||||
+137
@@ -0,0 +1,137 @@
|
||||
package com.ruoyi.staffService.condolence.service.impl;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.ruoyi.common.core.page.Pagination;
|
||||
import com.ruoyi.common.core.service.BaseServiceImpl;
|
||||
import com.ruoyi.common.security.auth.AuthUtil;
|
||||
import com.ruoyi.common.security.utils.SecurityUtils;
|
||||
import com.ruoyi.staffService.api.constant.condolence.CondolencePageForm;
|
||||
import com.ruoyi.staffService.api.domain.condolence.Condolence;
|
||||
import com.ruoyi.staffService.condolence.service.StaffCondolenceAuditService;
|
||||
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.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class StaffCondolenceAuditServiceService extends BaseServiceImpl<Condolence> implements StaffCondolenceAuditService {
|
||||
public StaffCondolenceAuditServiceService(Dao dao) {
|
||||
super(dao);
|
||||
}
|
||||
|
||||
private String selectSql() {
|
||||
return """
|
||||
SELECT
|
||||
c.*,
|
||||
ct.typeName,
|
||||
ct.typeCode,
|
||||
state.stateName,
|
||||
state.stateColor
|
||||
FROM
|
||||
condolence c
|
||||
LEFT JOIN condolence_type ct ON ct.id = c.type
|
||||
LEFT JOIN audit_state state on state.stateId = c.stateId
|
||||
$condition
|
||||
""";
|
||||
}
|
||||
|
||||
void commonCnd(Cnd cnd, CondolencePageForm pageForm) {
|
||||
cnd.andEX("YEAR(c.applyTime)", "=", pageForm.getYear());
|
||||
cnd.andEX("c.type", "=", pageForm.getType());
|
||||
cnd.andEX("c.comfortedPersonUnionId", "=", pageForm.getUnionId());
|
||||
cnd.andEX("c.comfortedPersonUnitId", "=", pageForm.getUnitId());
|
||||
cnd.andEX("c.comfortedPersonThreeUnitId", "=", pageForm.getThreeUnitId());
|
||||
cnd.andEX("c.comfortedPersonUnionGroupId", "=", pageForm.getUnionGroupId());
|
||||
|
||||
if (StrUtil.isNotBlank(pageForm.getSearchKeyword())) {
|
||||
SqlExpressionGroup seg2 = new SqlExpressionGroup();
|
||||
seg2.orLike("c.comfortedPersonUserName", pageForm.getSearchKeyword());
|
||||
seg2.orLike("c.comfortedPersonLoginName", pageForm.getSearchKeyword());
|
||||
cnd.and(seg2);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Pagination unionGroupPageData(CondolencePageForm pageForm) {
|
||||
Sql sql = Sqls.create(selectSql());
|
||||
Cnd cnd = Cnd.NEW();
|
||||
commonCnd(cnd, pageForm);
|
||||
if (!AuthUtil.hasRole("admin")) {
|
||||
cnd.and("c.comfortedPersonUnionGroupId", "in", SecurityUtils.getManageUnionGroupIds());
|
||||
}
|
||||
if (pageForm.getIsAudit() == null) {
|
||||
cnd.and("c.stateId", ">=", 10);
|
||||
} else if (pageForm.getIsAudit()) {
|
||||
cnd.and("c.stateId", ">", 10);
|
||||
} else if (!pageForm.getIsAudit()) {
|
||||
cnd.and("c.stateId", "=", 10);
|
||||
}
|
||||
sql.setCondition(cnd);
|
||||
Pagination pagination = listPageMap(pageForm.getPageNumber(), pageForm.getPageSize(), sql);
|
||||
return pagination;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Pagination branchUnionPageData(CondolencePageForm pageForm) {
|
||||
Sql sql = Sqls.create(selectSql());
|
||||
Cnd cnd = Cnd.NEW();
|
||||
commonCnd(cnd, pageForm);
|
||||
if (!AuthUtil.hasRole("admin")) {
|
||||
cnd.and("c.comfortedPersonUnionId", "=", SecurityUtils.getUnionId());
|
||||
}
|
||||
if (pageForm.getIsAudit() == null) {
|
||||
cnd.and("c.stateId", ">=", 25);
|
||||
} else if (pageForm.getIsAudit()) {
|
||||
cnd.and("c.stateId", ">", 25);
|
||||
} else if (!pageForm.getIsAudit()) {
|
||||
cnd.and("c.stateId", "=", 25);
|
||||
}
|
||||
sql.setCondition(cnd);
|
||||
return listPageMap(pageForm.getPageNumber(), pageForm.getPageSize(), sql);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Pagination schoolAccountingPageData(CondolencePageForm pageForm) {
|
||||
Sql sql = Sqls.create(selectSql());
|
||||
Cnd cnd = Cnd.NEW();
|
||||
commonCnd(cnd, pageForm);
|
||||
if (pageForm.getIsAudit() == null) {
|
||||
cnd.and("c.stateId", ">=", 40);
|
||||
} else if (pageForm.getIsAudit()) {
|
||||
cnd.and("c.stateId", ">", 40);
|
||||
} else if (!pageForm.getIsAudit()) {
|
||||
cnd.and("c.stateId", "=", 40);
|
||||
}
|
||||
sql.setCondition(cnd);
|
||||
return listPageMap(pageForm.getPageNumber(), pageForm.getPageSize(), sql);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Pagination schoolUnionPageData(CondolencePageForm pageForm) {
|
||||
Sql sql = Sqls.create(selectSql());
|
||||
Cnd cnd = Cnd.NEW();
|
||||
commonCnd(cnd, pageForm);
|
||||
if (pageForm.getIsAudit() == null) {
|
||||
cnd.and("c.stateId", ">=", 55);
|
||||
} else if (pageForm.getIsAudit()) {
|
||||
cnd.and("c.stateId", ">", 55);
|
||||
} else if (!pageForm.getIsAudit()) {
|
||||
cnd.and("c.stateId", "=", 55);
|
||||
}
|
||||
sql.setCondition(cnd);
|
||||
return listPageMap(pageForm.getPageNumber(), pageForm.getPageSize(), sql);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Pagination statisticsQueryPageData(CondolencePageForm pageForm) {
|
||||
Sql sql = Sqls.create(selectSql());
|
||||
Cnd cnd = Cnd.NEW();
|
||||
commonCnd(cnd, pageForm);
|
||||
cnd.and("c.stateId", "=", 70);
|
||||
sql.setCondition(cnd);
|
||||
return listPageMap(pageForm.getPageNumber(), pageForm.getPageSize(), sql);
|
||||
}
|
||||
}
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
package com.ruoyi.staffService.config;
|
||||
|
||||
import org.apache.catalina.connector.Connector;
|
||||
import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
/**
|
||||
* @ClassName TomcatConfig
|
||||
* @Description TODO
|
||||
* @Author zhaoxinyu
|
||||
* @Date 2022/12/19 13:46
|
||||
* @Version 1.0
|
||||
*/
|
||||
@Configuration
|
||||
public class TomcatConfig {
|
||||
|
||||
@Bean
|
||||
public TomcatServletWebServerFactory webServerFactory() {
|
||||
TomcatServletWebServerFactory factory = new TomcatServletWebServerFactory();
|
||||
factory.addConnectorCustomizers((Connector connector) -> {
|
||||
connector.setProperty("relaxedPathChars", "\"<>[\\]^`{|}");
|
||||
connector.setProperty("relaxedQueryChars", "\"<>[\\]^`{|}");
|
||||
});
|
||||
return factory;
|
||||
}
|
||||
|
||||
}
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
package com.ruoyi.staffService.constant;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* 数据源
|
||||
*
|
||||
* @author jug
|
||||
* @date 2022/12/30
|
||||
*/
|
||||
@Getter
|
||||
public enum Ds {
|
||||
/**
|
||||
* 主库
|
||||
*/
|
||||
STAFFSERVICE,
|
||||
/**
|
||||
* 系统
|
||||
*/
|
||||
SYSTEM,
|
||||
}
|
||||
+173
@@ -0,0 +1,173 @@
|
||||
package com.ruoyi.staffService.difficulty.controller;
|
||||
|
||||
import com.ruoyi.common.core.constant.Roles;
|
||||
import com.ruoyi.common.core.constant.SecurityConstants;
|
||||
import com.ruoyi.common.core.domain.R;
|
||||
import com.ruoyi.common.core.utils.DateUtils;
|
||||
import com.ruoyi.common.core.web.domain.AjaxResult;
|
||||
import com.ruoyi.common.security.annotation.RequiresPermissions;
|
||||
import com.ruoyi.common.security.utils.SecurityUtils;
|
||||
import com.ruoyi.staffService.api.constant.difficulty.DifficultyAuditState;
|
||||
import com.ruoyi.staffService.api.domain.difficulty.Difficulty;
|
||||
import com.ruoyi.staffService.difficulty.service.DifficultyManageService;
|
||||
import com.ruoyi.system.api.RemoteSysLocalProcessService;
|
||||
import com.ruoyi.system.api.domain.SysUser;
|
||||
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.lang.Strings;
|
||||
import org.nutz.lang.util.NutMap;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author JyuHsin
|
||||
* @Date 2023/2/10
|
||||
* @Description
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/difficulty/apply")
|
||||
public class DifficultyApplyController {
|
||||
|
||||
@Autowired
|
||||
private Dao dao;
|
||||
@Autowired
|
||||
private DifficultyManageService difficultyManageService;
|
||||
@Autowired
|
||||
private RemoteSysLocalProcessService localProcessService;
|
||||
|
||||
@PostMapping("doSave")
|
||||
@RequiresPermissions("staffService:difficulty:difficultyApply")
|
||||
public AjaxResult doSave(@RequestBody Difficulty difficulty) {
|
||||
// 如果是被退回的流程,那就要完成被退回流程的任务
|
||||
if (difficulty.getState() != null) {
|
||||
localProcessService.completeReturnTask("DIFFICULTY@" + difficulty.getId(), SecurityConstants.INNER);
|
||||
}
|
||||
difficulty.setState(DifficultyAuditState.NOT_SUBMIT);
|
||||
difficulty.setApplyUserId(SecurityUtils.getUserId());
|
||||
difficulty.setApplyTime(DateUtils.getDate());
|
||||
dao.insertOrUpdate(difficulty);
|
||||
|
||||
Sql sql = Sqls.create("select userName from `user` where userId = @id").setParam("id", difficulty.getApplyUserId());
|
||||
sql.setCallback(Sqls.callback.str());
|
||||
dao.execute(sql);
|
||||
String userName = sql.getString();
|
||||
String processUniqueId = "DIFFICULTY@" + difficulty.getId();
|
||||
localProcessService.initCreateInstance(
|
||||
processUniqueId,
|
||||
difficulty.getId(),
|
||||
"[困难帮扶]" + userName,
|
||||
"/staffService/difficulty/difficultyApplyList",
|
||||
null,
|
||||
SecurityConstants.INNER
|
||||
);
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
@PostMapping("doSubmit")
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@RequiresPermissions("staffService:difficulty:difficultyApply")
|
||||
public AjaxResult doSubmit(@RequestBody Difficulty difficulty) {
|
||||
// 如果是被退回的流程,那就要完成被退回流程的任务
|
||||
if (difficulty.getState() != null) {
|
||||
localProcessService.completeReturnTask("DIFFICULTY@" + difficulty.getId(), SecurityConstants.INNER);
|
||||
}
|
||||
|
||||
difficulty.setState(DifficultyAuditState.UNION_GROUP_READY);
|
||||
difficulty.setApplyUserId(SecurityUtils.getUserId());
|
||||
difficulty.setApplyTime(DateUtils.getDate());
|
||||
dao.insertOrUpdate(difficulty);
|
||||
|
||||
Sql sql = Sqls.create("select userName from `user` where userId = @id").setParam("id", difficulty.getApplyUserId());
|
||||
sql.setCallback(Sqls.callback.str());
|
||||
dao.execute(sql);
|
||||
String userName = sql.getString();
|
||||
String processUniqueId = "DIFFICULTY@" + difficulty.getId();
|
||||
localProcessService.initCreateInstance(
|
||||
processUniqueId,
|
||||
difficulty.getId(),
|
||||
"[困难帮扶]" + userName,
|
||||
"/staffService/difficulty/difficultyApplyList",
|
||||
null,
|
||||
SecurityConstants.INNER
|
||||
);
|
||||
|
||||
// 创建工会小组任务, 获取负责人
|
||||
R<List<String>> assignments = localProcessService.getAssignments(null,
|
||||
SecurityUtils.getUnionGroupId(), Roles.UNION_GROUP_LEADER, SecurityConstants.INNER);
|
||||
List<String> loginNameList = assignments.getData();
|
||||
|
||||
localProcessService.initCreateTask(
|
||||
processUniqueId,
|
||||
String.valueOf(DifficultyAuditState.UNION_GROUP_READY),
|
||||
"工会小组审核",
|
||||
loginNameList,
|
||||
"/staffService/difficulty/difficultyUnionGroupAudit",
|
||||
null,
|
||||
SecurityConstants.INNER
|
||||
);
|
||||
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
@PostMapping("doEdit")
|
||||
@RequiresPermissions("staffService:difficulty:difficultyApply")
|
||||
public AjaxResult doEdit(@RequestBody Difficulty difficulty) {
|
||||
dao.updateIgnoreNull(difficulty);
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
@GetMapping("getUserData")
|
||||
public AjaxResult getUserData(String userId) {
|
||||
Sql sql = Sqls.create("""
|
||||
select
|
||||
*
|
||||
from
|
||||
`user`
|
||||
where userId = @userId
|
||||
""");
|
||||
sql.setParam("userId", userId);
|
||||
sql.setCallback(Sqls.callback.map());
|
||||
dao.execute(sql);
|
||||
NutMap nutMap = (NutMap) sql.getResult();
|
||||
return AjaxResult.success(nutMap);
|
||||
}
|
||||
|
||||
@GetMapping("querySqr")
|
||||
public AjaxResult querySqr(String key) {
|
||||
Cnd cnd = Cnd.NEW();
|
||||
Sql sql = Sqls.create("""
|
||||
SELECT
|
||||
su.userId as id,
|
||||
su.userId,
|
||||
su.userName,
|
||||
su.birthday,
|
||||
su.loginName,
|
||||
su.mobile,
|
||||
su.sex,
|
||||
su.deptName,
|
||||
su.unionName,
|
||||
su.idcard,
|
||||
su.position,
|
||||
su.jobTitle
|
||||
FROM
|
||||
`user` su
|
||||
$condition
|
||||
""");
|
||||
cnd.and("su.unionId", "=", SecurityUtils.getUnionId());
|
||||
if (Strings.isNotBlank(key)) {
|
||||
SqlExpressionGroup group = new SqlExpressionGroup();
|
||||
group.orLike("su.userName", key);
|
||||
group.orLike("su.loginName", key);
|
||||
cnd.and(group);
|
||||
}
|
||||
sql.setCondition(cnd);
|
||||
List<Object> list = difficultyManageService.listPageMap(1, 10, sql).getList();
|
||||
return AjaxResult.success(list);
|
||||
}
|
||||
}
|
||||
+121
@@ -0,0 +1,121 @@
|
||||
package com.ruoyi.staffService.difficulty.controller;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.ruoyi.common.core.constant.Roles;
|
||||
import com.ruoyi.common.core.constant.SecurityConstants;
|
||||
import com.ruoyi.common.core.domain.PageForm;
|
||||
import com.ruoyi.common.core.page.Pagination;
|
||||
import com.ruoyi.common.core.web.domain.AjaxResult;
|
||||
import com.ruoyi.common.security.annotation.RequiresLogin;
|
||||
import com.ruoyi.common.security.annotation.RequiresPermissions;
|
||||
import com.ruoyi.common.security.auth.AuthUtil;
|
||||
import com.ruoyi.common.security.utils.SecurityUtils;
|
||||
import com.ruoyi.staffService.api.constant.difficulty.DifficultyAuditState;
|
||||
import com.ruoyi.staffService.api.domain.common.Audit;
|
||||
import com.ruoyi.staffService.api.domain.difficulty.Difficulty;
|
||||
import com.ruoyi.staffService.constant.Ds;
|
||||
import com.ruoyi.staffService.difficulty.service.DifficultyManageService;
|
||||
import com.ruoyi.staffService.util.ProModuleDS;
|
||||
import com.ruoyi.system.api.RemoteSysLocalProcessService;
|
||||
import com.ruoyi.system.api.domain.SysUserRole;
|
||||
import org.nutz.dao.Cnd;
|
||||
import org.nutz.dao.Dao;
|
||||
import org.nutz.lang.Lang;
|
||||
import org.nutz.lang.util.NutMap;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
/**
|
||||
* @Author JyuHsin
|
||||
* @Date 2023/2/10
|
||||
* @Description
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/difficulty/applyList")
|
||||
public class DifficultyApplyListController {
|
||||
|
||||
@Autowired
|
||||
private Dao dao;
|
||||
@Autowired
|
||||
private DifficultyManageService difficultyManageService;
|
||||
@Autowired
|
||||
private RemoteSysLocalProcessService localProcessService;
|
||||
|
||||
|
||||
@PostMapping("pageData")
|
||||
@RequiresPermissions("staffService:difficulty:difficultyApplyList")
|
||||
public AjaxResult pageData(@RequestBody PageForm pageForm,
|
||||
@RequestParam(value = "year", required = false) Integer year,
|
||||
@RequestParam(value = "unitId", required = false) String unitId,
|
||||
@RequestParam(value = "unionId", required = false) String unionId) {
|
||||
Cnd cnd = Cnd.NEW();
|
||||
if (!AuthUtil.hasAnyRoles("admin")) {
|
||||
cnd.and(Cnd.exps("sq.applyUserId", "=", SecurityUtils.getUserId()).or("sq.helpUserId", "=", SecurityUtils.getUserId()));
|
||||
}
|
||||
Pagination pagination = difficultyManageService.pageData(cnd, pageForm, year, unitId, unionId);
|
||||
return AjaxResult.success(pagination);
|
||||
}
|
||||
|
||||
@GetMapping("findOne/{id}")
|
||||
public AjaxResult findOne(@PathVariable String id) {
|
||||
NutMap re = difficultyManageService.findOne(id);
|
||||
return AjaxResult.success(re);
|
||||
}
|
||||
|
||||
@PostMapping("doDelete/{id}")
|
||||
@RequiresPermissions("staffService:difficulty:difficultyApplyList")
|
||||
public AjaxResult doDelete(@PathVariable String id) {
|
||||
Difficulty difficulty = dao.fetch(Difficulty.class, id);
|
||||
if (StrUtil.isNotBlank(difficulty.getUnionGroupAuditId())) {
|
||||
dao.delete(Audit.class, difficulty.getUnionGroupAuditId());
|
||||
}
|
||||
if (StrUtil.isNotBlank(difficulty.getUnionAuditId())) {
|
||||
dao.delete(Audit.class, difficulty.getUnionAuditId());
|
||||
}
|
||||
if (StrUtil.isNotBlank(difficulty.getSchoolAuditId())) {
|
||||
dao.delete(Audit.class, difficulty.getSchoolAuditId());
|
||||
}
|
||||
difficultyManageService.delete(id);
|
||||
localProcessService.deleteProcessInstance("DIFFICULTY@" + id, SecurityConstants.INNER);
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
@PostMapping("mobilePageData")
|
||||
@RequiresLogin
|
||||
public AjaxResult mobilePageData(@RequestBody PageForm pageForm,
|
||||
@RequestParam(value = "year", required = false) Integer year,
|
||||
@RequestParam(value = "unitId", required = false) String unitId,
|
||||
@RequestParam(value = "unionId", required = false) String unionId,
|
||||
@RequestParam(value = "isAudit", required = false) Boolean isAudit) {
|
||||
Cnd cnd = Cnd.NEW();
|
||||
if (!AuthUtil.hasAnyRoles("admin")) {
|
||||
if (AuthUtil.hasRole("unionGroupLeader")) {
|
||||
//查询当前登录用户管理的工会小组
|
||||
SysUserRole userRole = ProModuleDS.exec(Ds.SYSTEM, () -> {
|
||||
return dao.fetch(SysUserRole.class, Cnd.where("role_id", "=", Roles.UNION_GROUP_LEADER)
|
||||
.and("user_id", "=", SecurityUtils.getUserId()));
|
||||
});
|
||||
cnd.and("sqr.unionGroupId", "=", userRole.getUnionGroupId());
|
||||
cnd.and("sq.state", isAudit ? ">" : "=", DifficultyAuditState.UNION_GROUP_READY);
|
||||
}
|
||||
if (AuthUtil.hasRole("H04")) {
|
||||
cnd.and("sqr.unionId", "=", SecurityUtils.getUnionId());
|
||||
cnd.and("sq.state", isAudit ? ">" : "=", DifficultyAuditState.UNION_READY);
|
||||
}
|
||||
if (AuthUtil.hasRole("A06")) {
|
||||
cnd.and("sq.state", isAudit ? ">" : "=", DifficultyAuditState.SCHOOL_READY);
|
||||
}
|
||||
} else {
|
||||
if (isAudit) {
|
||||
cnd.and("sq.state", ">", DifficultyAuditState.UNION_GROUP_READY);
|
||||
} else {
|
||||
Integer[] array = Lang.array(DifficultyAuditState.UNION_GROUP_READY, DifficultyAuditState.UNION_READY,
|
||||
DifficultyAuditState.SCHOOL_READY);
|
||||
cnd.and("sq.state", "in", array);
|
||||
}
|
||||
}
|
||||
|
||||
Pagination pagination = difficultyManageService.pageData(cnd, pageForm, year, unitId, unionId);
|
||||
return AjaxResult.success(pagination);
|
||||
}
|
||||
}
|
||||
+123
@@ -0,0 +1,123 @@
|
||||
package com.ruoyi.staffService.difficulty.controller;
|
||||
|
||||
import com.ruoyi.common.core.constant.SecurityConstants;
|
||||
import com.ruoyi.common.core.domain.PageForm;
|
||||
import com.ruoyi.common.core.page.Pagination;
|
||||
import com.ruoyi.common.core.web.domain.AjaxResult;
|
||||
import com.ruoyi.common.security.annotation.RequiresPermissions;
|
||||
import com.ruoyi.common.security.utils.SecurityUtils;
|
||||
import com.ruoyi.staffService.api.constant.difficulty.DifficultyAuditState;
|
||||
import com.ruoyi.staffService.api.domain.common.Audit;
|
||||
import com.ruoyi.staffService.api.domain.difficulty.Difficulty;
|
||||
import com.ruoyi.staffService.difficulty.service.DifficultyManageService;
|
||||
import com.ruoyi.system.api.RemoteSysLocalProcessService;
|
||||
import com.ruoyi.system.api.domain.SysUser;
|
||||
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.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author JyuHsin
|
||||
* @Date 2023/2/10
|
||||
* @Description
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/difficulty/schoolAudit")
|
||||
public class DifficultySchoolAuditController {
|
||||
|
||||
@Autowired
|
||||
private Dao dao;
|
||||
@Autowired
|
||||
private DifficultyManageService difficultyManageService;
|
||||
@Autowired
|
||||
private RemoteSysLocalProcessService localProcessService;
|
||||
|
||||
@PostMapping("pageData")
|
||||
@RequiresPermissions("staffService:difficulty:difficultySchoolAudit")
|
||||
public AjaxResult pageData(@RequestBody PageForm pageForm,
|
||||
@RequestParam(value = "year", required = false) Integer year,
|
||||
@RequestParam(value = "unitId", required = false) String unitId,
|
||||
@RequestParam(value = "unionId", required = false) String unionId,
|
||||
@RequestParam(value = "isAudit", required = false) Boolean isAudit) {
|
||||
Cnd cnd = Cnd.NEW();
|
||||
if (isAudit == null) {
|
||||
cnd.and("sq.state", ">=", 270);
|
||||
} else if (isAudit) {
|
||||
cnd.and("sq.state", ">", 270);
|
||||
} else {
|
||||
cnd.and("sq.state", "=", 270);
|
||||
}
|
||||
Pagination pagination = difficultyManageService.pageData(cnd, pageForm, year, unitId, unionId);
|
||||
return AjaxResult.success(pagination);
|
||||
}
|
||||
|
||||
@PostMapping("rollBack/{id}")
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@RequiresPermissions("staffService:difficulty:difficultySchoolAudit")
|
||||
public AjaxResult rollBack(@PathVariable String id) {
|
||||
difficultyManageService.update(Chain.make("state", DifficultyAuditState.SCHOOL_READY), Cnd.where("id", "=", id));
|
||||
localProcessService.revokeTask("DIFFICULTY@" + id, String.valueOf(DifficultyAuditState.SCHOOL_READY), SecurityConstants.INNER);
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
@PostMapping("doReview")
|
||||
@RequiresPermissions("staffService:difficulty:difficultySchoolAudit")
|
||||
public AjaxResult doReview(@RequestBody Audit audit,
|
||||
@RequestParam(name = "id", required = false) String id,
|
||||
@RequestParam(name = "pass", required = false) Integer pass,
|
||||
@RequestParam(name = "helpMoney", required = false) String helpMoney) {
|
||||
audit.setAuditor(SecurityUtils.getUserId());
|
||||
audit.setLoginName(SecurityUtils.getUsername());
|
||||
audit.setUserName(SecurityUtils.getNickName());
|
||||
audit.setAuditTime(new Date());
|
||||
audit = dao.insert(audit);
|
||||
Difficulty difficulty = dao.fetch(Difficulty.class, id);
|
||||
|
||||
String taskNodeName = "";
|
||||
if (pass == 1) {
|
||||
difficulty.setState(DifficultyAuditState.SCHOOL_REJECTED);
|
||||
taskNodeName = "校工会拒绝";
|
||||
} else if (pass == 2) {
|
||||
difficulty.setState(DifficultyAuditState.SCHOOL_BACK_MODIFY);
|
||||
taskNodeName = "校工会退回";
|
||||
} else {
|
||||
difficulty.setState(DifficultyAuditState.SCHOOL_PASS);
|
||||
taskNodeName = "校工会通过";
|
||||
}
|
||||
difficulty.setSchoolAuditId(audit.getId());
|
||||
difficulty.setHelpMoney(helpMoney);
|
||||
dao.updateIgnoreNull(difficulty);
|
||||
|
||||
String processUniqueId = "DIFFICULTY@" + difficulty.getId();
|
||||
localProcessService.completeTask(processUniqueId, String.valueOf(DifficultyAuditState.SCHOOL_READY), taskNodeName, SecurityConstants.INNER);
|
||||
|
||||
if (pass == 2) {
|
||||
// 退回
|
||||
Sql sql = Sqls.create("select loginName from `user` where userId = @id").setParam("id", difficulty.getApplyUserId());
|
||||
sql.setCallback(Sqls.callback.str());
|
||||
dao.execute(sql);
|
||||
String loginName = sql.getString();
|
||||
localProcessService.initCreateTask(
|
||||
processUniqueId,
|
||||
String.valueOf(DifficultyAuditState.UNION_BACK_MODIFY),
|
||||
"校工会退回",
|
||||
List.of(loginName),
|
||||
"/staffService/difficulty/difficultyApplyList",
|
||||
null,
|
||||
SecurityConstants.INNER
|
||||
);
|
||||
} else {
|
||||
localProcessService.completeProcess(processUniqueId, pass == 1, SecurityConstants.INNER);
|
||||
}
|
||||
|
||||
return AjaxResult.success();
|
||||
}
|
||||
}
|
||||
+324
@@ -0,0 +1,324 @@
|
||||
package com.ruoyi.staffService.difficulty.controller;
|
||||
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import cn.hutool.core.io.IoUtil;
|
||||
import cn.hutool.core.util.ZipUtil;
|
||||
import cn.hutool.http.HttpUtil;
|
||||
import com.deepoove.poi.XWPFTemplate;
|
||||
import com.deepoove.poi.config.Configure;
|
||||
import com.deepoove.poi.plugin.table.LoopRowTableRenderPolicy;
|
||||
import com.ruoyi.common.core.domain.PageForm;
|
||||
import com.ruoyi.common.core.domain.SysFile;
|
||||
import com.ruoyi.common.core.page.Pagination;
|
||||
import com.ruoyi.common.core.utils.DateUtils;
|
||||
import com.ruoyi.common.core.web.domain.AjaxResult;
|
||||
import com.ruoyi.common.security.annotation.RequiresPermissions;
|
||||
import com.ruoyi.common.security.auth.AuthUtil;
|
||||
import com.ruoyi.common.security.utils.SecurityUtils;
|
||||
import com.ruoyi.staffService.api.constant.difficulty.DifficultyAuditState;
|
||||
import com.ruoyi.staffService.constant.Ds;
|
||||
import com.ruoyi.staffService.difficulty.service.DifficultyManageService;
|
||||
import com.ruoyi.staffService.util.ProModuleDS;
|
||||
import com.ruoyi.system.api.RemoteDictService;
|
||||
import com.ruoyi.system.api.domain.SysConfig;
|
||||
import com.ruoyi.system.api.domain.SysDictData;
|
||||
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.json.Json;
|
||||
import org.nutz.lang.Files;
|
||||
import org.nutz.lang.Strings;
|
||||
import org.nutz.lang.util.NutMap;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.ServletOutputStream;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.*;
|
||||
import java.net.URLEncoder;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Path;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @Author JyuHsin
|
||||
* @Date 2023/2/10
|
||||
* @Description
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/difficulty/summaryRead")
|
||||
public class DifficultySummaryReadController {
|
||||
|
||||
@Autowired
|
||||
private Dao dao;
|
||||
|
||||
@Autowired
|
||||
private DifficultyManageService difficultyManageService;
|
||||
|
||||
@Autowired
|
||||
private RemoteDictService dictService;
|
||||
|
||||
@PostMapping("pageData")
|
||||
@RequiresPermissions("staffService:difficulty:summaryRead")
|
||||
public AjaxResult pageData(@RequestBody PageForm pageForm,
|
||||
@RequestParam(value = "year", required = false) Integer year,
|
||||
@RequestParam(value = "unitId", required = false) String unitId,
|
||||
@RequestParam(value = "unionId", required = false) String unionId,
|
||||
@RequestParam(value = "dateRange[]", required = false) String[] dateRange) {
|
||||
Cnd cnd = Cnd.NEW();
|
||||
if (!AuthUtil.hasAnyRoles("admin, A06 , wyh03, wyh02")) {
|
||||
SqlExpressionGroup group2 = new SqlExpressionGroup();
|
||||
if (AuthUtil.hasAnyRoles("gh01, H04")) {
|
||||
group2.or("sqr.unionId", "=", SecurityUtils.getUnionId());
|
||||
}
|
||||
if (AuthUtil.hasRole("H01")) {
|
||||
group2.or("sq.applyUserId", "=", SecurityUtils.getUserId());
|
||||
group2.or("sq.helpUserId", "=", SecurityUtils.getUserId());
|
||||
}
|
||||
cnd.and(group2);
|
||||
}
|
||||
if (dateRange != null && dateRange.length == 2) {
|
||||
cnd.and("sq.applyTime", ">=", dateRange[0]);
|
||||
cnd.and("sq.applyTime", "<=", dateRange[1]);
|
||||
}
|
||||
Pagination pagination = difficultyManageService.pageData(cnd, pageForm, year, unitId, unionId);
|
||||
return AjaxResult.success(pagination);
|
||||
}
|
||||
|
||||
@RequestMapping("doExcel")
|
||||
public void doExcel(@RequestParam(value = "year", required = false) Integer year,
|
||||
@RequestParam(value = "unitId", required = false) String unitId,
|
||||
@RequestParam(value = "unionId", required = false) String unionId,
|
||||
@RequestParam(value = "dateRange[]", required = false) String[] dateRange,
|
||||
HttpServletResponse response) throws IOException {
|
||||
NutMap nutMap = NutMap.NEW();
|
||||
|
||||
Sql sql = Sqls.create("""
|
||||
SELECT
|
||||
su.userName as username,
|
||||
su.loginName as loginname,
|
||||
su.deptName as unitname,
|
||||
su.unionName as unionname,
|
||||
su.sex,
|
||||
bf.jobTitle as zc,
|
||||
bf.position as zw,
|
||||
bf.applyReason as apply_reason
|
||||
FROM
|
||||
zgfw_knbf bf
|
||||
LEFT JOIN `user` su ON su.userId = bf.helpUserId
|
||||
$condition
|
||||
""");
|
||||
Cnd cnd = Cnd.where("bf.state", "=", DifficultyAuditState.SCHOOL_PASS);
|
||||
if (dateRange != null && dateRange.length == 2) {
|
||||
cnd.and("bf.applyTime", ">=", dateRange[0]);
|
||||
cnd.and("bf.applyTime", "<=", dateRange[1]);
|
||||
}
|
||||
if (!AuthUtil.hasAnyRoles("admin, A06, wyh03, wyh02")) {
|
||||
if (AuthUtil.hasAnyRoles("gh01, H04")) {
|
||||
cnd.andEX("su.unionId", "=", SecurityUtils.getUnionId());
|
||||
nutMap.setv("union", "院级工会主席");
|
||||
|
||||
} else if (AuthUtil.hasAnyRoles("unionGroupLeader")) {
|
||||
cnd.andEX("su.unionGroupId", "=", SecurityUtils.getUnionGroupId());
|
||||
nutMap.setv("union", "工会小组组长");
|
||||
}
|
||||
nutMap.setv("union", "校工会");
|
||||
}
|
||||
cnd.andEX("su.unionId", "=", unionId);
|
||||
cnd.andEX("su.deptId", "=", unitId);
|
||||
cnd.asc("su.unionCode");
|
||||
cnd.asc("bf.applyTime");
|
||||
|
||||
sql.setCondition(cnd);
|
||||
|
||||
List<SysDictData> userSex = dictService.dictType("sys_user_sex").getData();
|
||||
Map<String, String> sexMap = userSex.stream().collect(Collectors.toMap(SysDictData::getDictValue, SysDictData::getDictLabel));
|
||||
|
||||
List<NutMap> map = difficultyManageService.listMap(sql);
|
||||
AtomicInteger listIndex = new AtomicInteger(1);
|
||||
|
||||
map.forEach(v -> {
|
||||
v.put("index", listIndex.get());
|
||||
v.put("sex", sexMap.get(v.getString("sex")));
|
||||
listIndex.getAndIncrement();
|
||||
});
|
||||
nutMap.setv("exportDate", DateUtils.getDate());
|
||||
nutMap.setv("knbf", map);
|
||||
|
||||
LoopRowTableRenderPolicy policy = new LoopRowTableRenderPolicy();
|
||||
Configure config = Configure.builder().bind("knbf", policy).build();
|
||||
|
||||
String fileName = "院级工会教职工困难补助申报汇总表";
|
||||
|
||||
String disposition = "attachment;filename=" + URLEncoder.encode(fileName + ".docx", StandardCharsets.UTF_8);
|
||||
response.setCharacterEncoding("utf-8");
|
||||
response.setContentType("application/octet-stream");
|
||||
response.setHeader("Content-Disposition", disposition);
|
||||
|
||||
InputStream inputStream = Thread.currentThread().getContextClassLoader().getResourceAsStream("docTemplate/difficulty/knbf_summary.docx");
|
||||
assert inputStream != null;
|
||||
XWPFTemplate.compile(inputStream, config).render(nutMap, response.getOutputStream());
|
||||
inputStream.close();
|
||||
}
|
||||
|
||||
@RequestMapping("export")
|
||||
public void export(String id, HttpServletResponse response) throws IOException {
|
||||
|
||||
SysConfig configKey = ProModuleDS.exec(Ds.SYSTEM, () -> {
|
||||
return dao.fetch(SysConfig.class, Cnd.where("config_key", "=", "sys.schoolName"));
|
||||
});
|
||||
|
||||
String fileName = configKey.getConfigValue() + "工会审批表";
|
||||
String disposition = "attachment;filename=" + URLEncoder.encode(fileName + ".docx", StandardCharsets.UTF_8);
|
||||
response.setCharacterEncoding("utf-8");
|
||||
response.setContentType("application/octet-stream");
|
||||
response.setHeader("Content-Disposition", disposition);
|
||||
|
||||
commonExport(id, configKey.getConfigValue(), response.getOutputStream());
|
||||
}
|
||||
|
||||
public void commonExport(String id, String schoolName, OutputStream outputStream) throws IOException {
|
||||
|
||||
NutMap nutMap = difficultyManageService.findOne(id);
|
||||
|
||||
List<SysDictData> userSex = dictService.dictType("sys_user_sex").getData();
|
||||
Map<String, String> sexMap = userSex.stream().collect(Collectors.toMap(SysDictData::getDictValue, SysDictData::getDictLabel));
|
||||
|
||||
nutMap.put("sex", sexMap.get(nutMap.getString("sex")));
|
||||
nutMap.put("helpSex", sexMap.get(nutMap.getString("helpSex")));
|
||||
|
||||
if (nutMap.getInt("helpType") == 1) {
|
||||
nutMap.put("bzlx_name", "日常补助慰问");
|
||||
} else if (nutMap.getInt("helpType") == 2) {
|
||||
nutMap.put("bzlx_name", "“元旦、春节”困难补助慰问");
|
||||
}
|
||||
|
||||
if (Strings.isNotBlank(nutMap.getString("helpMoney"))) {
|
||||
nutMap.put("helpMoney", Convert.digitToChinese(nutMap.getFloat("helpMoney")));
|
||||
}
|
||||
nutMap.put("schoolName", schoolName);
|
||||
|
||||
InputStream inputStream = null;
|
||||
|
||||
if ("1".equals(nutMap.getString("difficultType"))) {
|
||||
inputStream = Thread.currentThread().getContextClassLoader().getResourceAsStream("docTemplate/difficulty/sick.docx");
|
||||
} else if ("3".equals(nutMap.getString("difficultType"))) {
|
||||
inputStream = Thread.currentThread().getContextClassLoader().getResourceAsStream("docTemplate/difficulty/die.docx");
|
||||
} else {
|
||||
inputStream = Thread.currentThread().getContextClassLoader().getResourceAsStream("docTemplate/difficulty/subsidy.docx");
|
||||
}
|
||||
|
||||
LoopRowTableRenderPolicy policy = new LoopRowTableRenderPolicy();
|
||||
Configure config = Configure.builder().build();
|
||||
|
||||
assert inputStream != null;
|
||||
XWPFTemplate.compile(inputStream, config).render(nutMap, outputStream);
|
||||
inputStream.close();
|
||||
}
|
||||
|
||||
@RequestMapping("doExport")
|
||||
public void doExport(String id, HttpServletResponse response) throws IOException {
|
||||
|
||||
SysConfig configKey = ProModuleDS.exec(Ds.SYSTEM, () -> {
|
||||
return dao.fetch(SysConfig.class, Cnd.where("config_key", "=", "sys.schoolName"));
|
||||
});
|
||||
|
||||
NutMap nutMap = difficultyManageService.findOne(id);
|
||||
|
||||
nutMap.put("subsidy_amount_big", Convert.digitToChinese(nutMap.getFloat("helpMoney")));
|
||||
|
||||
int price = nutMap.getInt("helpMoney");
|
||||
int money_int = price;
|
||||
int money_decimal = money_int - price;
|
||||
nutMap.put("one", money_int >= 1000000 ? (money_int / 1000000) % 10 : null);
|
||||
nutMap.put("two", money_int >= 100000 ? (money_int / 100000) % 10 : null);
|
||||
nutMap.put("three", money_int >= 10000 ? (money_int / 10000) % 10 : null);
|
||||
nutMap.put("four", money_int >= 1000 ? (money_int / 1000) % 10 : null);
|
||||
nutMap.put("five", money_int >= 100 ? (money_int / 100) % 10 : null);
|
||||
nutMap.put("six", money_int >= 10 ? (money_int / 10) % 10 : null);
|
||||
nutMap.put("seven", money_int >= 10 ? money_int % 10 : null);
|
||||
nutMap.put("eight", (int) (money_decimal * 10));
|
||||
nutMap.put("nine", (int) (money_decimal % 0.1 * 100));
|
||||
|
||||
if (nutMap.getInt("helpType") == 1) {
|
||||
nutMap.put("bzlx_name", "日常补助慰问");
|
||||
} else if (nutMap.getInt("helpType") == 2) {
|
||||
nutMap.put("bzlx_name", "“元旦、春节”困难补助慰问");
|
||||
}
|
||||
|
||||
nutMap.put("schoolName", configKey.getConfigValue());
|
||||
|
||||
Configure config = Configure.builder().build();
|
||||
String fileName = configKey.getConfigValue() + "困难帮扶报销表";
|
||||
InputStream inputStream = Thread.currentThread().getContextClassLoader().getResourceAsStream("docTemplate/difficulty/reimbursement.docx");
|
||||
|
||||
String disposition = "attachment;filename=" + URLEncoder.encode(fileName + ".docx", StandardCharsets.UTF_8);
|
||||
response.setCharacterEncoding("utf-8");
|
||||
response.setContentType("application/octet-stream");
|
||||
response.setHeader("Content-Disposition", disposition);
|
||||
|
||||
XWPFTemplate.compile(inputStream, config).render(nutMap, response.getOutputStream());
|
||||
inputStream.close();
|
||||
}
|
||||
|
||||
@RequestMapping("downloadAnnex")
|
||||
public void downloadAnnex(@RequestBody String id, HttpServletResponse response) throws IOException {
|
||||
|
||||
ServletOutputStream outputStream = response.getOutputStream();
|
||||
response.setContentType("application/octet-stream");
|
||||
response.setHeader("Content-Disposition", "attachment;filename=%s".formatted(URLEncoder.encode("困难帮扶附件汇总.zip", StandardCharsets.UTF_8)));
|
||||
|
||||
/**
|
||||
* 创建临时文件夹
|
||||
*/
|
||||
Path difficultyBatchExportTempDir = java.nio.file.Files.createTempDirectory("difficultyBatchExportTempDir");
|
||||
|
||||
String fileName = "";
|
||||
|
||||
NutMap nutMap = difficultyManageService.findOne(id);
|
||||
if (Strings.isNotBlank(nutMap.getString("helpUnionName"))) {
|
||||
fileName += nutMap.getString("helpUnionName") + "-";
|
||||
}
|
||||
fileName += nutMap.getString("helpUserName");
|
||||
|
||||
File f = Files.createDirIfNoExists(difficultyBatchExportTempDir + "/" + fileName);
|
||||
|
||||
List<SysFile> files = null;
|
||||
|
||||
if (nutMap.getString("files") != null) {
|
||||
files = Json.fromJsonAsList(SysFile.class, nutMap.getString("files"));
|
||||
}
|
||||
|
||||
if (files != null) {
|
||||
for (SysFile file : files) {
|
||||
|
||||
InputStream inputStream = HttpUtil.createGet(file.getLink()).execute().bodyStream();
|
||||
File file1 = new File(f.getPath() + "/" + file.getName());
|
||||
FileOutputStream fileOutputStream = new FileOutputStream(file1);
|
||||
byte[] bytes = new byte[1024];
|
||||
int fileLength = 0;
|
||||
while ((fileLength = inputStream.read(bytes)) != -1) {
|
||||
fileOutputStream.write(bytes, 0, fileLength);
|
||||
}
|
||||
inputStream.close();
|
||||
fileOutputStream.close();
|
||||
}
|
||||
}
|
||||
|
||||
File zipFile = ZipUtil.zip(difficultyBatchExportTempDir.toString());
|
||||
|
||||
FileInputStream zipFileInputStream = new FileInputStream(zipFile);
|
||||
IoUtil.copy(zipFileInputStream, outputStream);
|
||||
zipFileInputStream.close();
|
||||
outputStream.close();
|
||||
|
||||
FileUtil.del(difficultyBatchExportTempDir);
|
||||
|
||||
}
|
||||
}
|
||||
+144
@@ -0,0 +1,144 @@
|
||||
package com.ruoyi.staffService.difficulty.controller;
|
||||
|
||||
import com.ruoyi.common.core.constant.Roles;
|
||||
import com.ruoyi.common.core.constant.SecurityConstants;
|
||||
import com.ruoyi.common.core.domain.PageForm;
|
||||
import com.ruoyi.common.core.domain.R;
|
||||
import com.ruoyi.common.core.page.Pagination;
|
||||
import com.ruoyi.common.core.web.domain.AjaxResult;
|
||||
import com.ruoyi.common.security.annotation.RequiresPermissions;
|
||||
import com.ruoyi.common.security.auth.AuthUtil;
|
||||
import com.ruoyi.common.security.utils.SecurityUtils;
|
||||
import com.ruoyi.staffService.api.constant.condolence.CondolenceAuditState;
|
||||
import com.ruoyi.staffService.api.constant.difficulty.DifficultyAuditState;
|
||||
import com.ruoyi.staffService.api.domain.common.Audit;
|
||||
import com.ruoyi.staffService.api.domain.difficulty.Difficulty;
|
||||
import com.ruoyi.staffService.difficulty.service.DifficultyManageService;
|
||||
import com.ruoyi.system.api.RemoteSysLocalProcessService;
|
||||
import com.ruoyi.system.api.domain.SysUser;
|
||||
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.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author JyuHsin
|
||||
* @Date 2023/2/10
|
||||
* @Description
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/difficulty/unionAudit")
|
||||
public class DifficultyUnionAuditController {
|
||||
|
||||
@Autowired
|
||||
private Dao dao;
|
||||
@Autowired
|
||||
private DifficultyManageService difficultyManageService;
|
||||
@Autowired
|
||||
private RemoteSysLocalProcessService localProcessService;
|
||||
|
||||
@PostMapping("pageData")
|
||||
@RequiresPermissions("staffService:difficulty:difficultyUnionAudit")
|
||||
public AjaxResult pageData(@RequestBody PageForm pageForm,
|
||||
@RequestParam(value = "year", required = false) Integer year,
|
||||
@RequestParam(value = "unitId", required = false) String unitId,
|
||||
@RequestParam(value = "unionId", required = false) String unionId,
|
||||
@RequestParam(value = "isAudit", required = false) Boolean isAudit) {
|
||||
Cnd cnd = Cnd.NEW();
|
||||
if (!AuthUtil.hasRole("admin")) {
|
||||
cnd.and("sqr.unionId", "=", SecurityUtils.getUnionId());
|
||||
}
|
||||
if (isAudit == null) {
|
||||
cnd.and("sq.state", ">=", 240);
|
||||
} else if (isAudit) {
|
||||
cnd.and("sq.state", ">", 240);
|
||||
} else {
|
||||
cnd.and("sq.state", "=", 240);
|
||||
}
|
||||
Pagination pagination = difficultyManageService.pageData(cnd, pageForm, year, unitId, unionId);
|
||||
return AjaxResult.success(pagination);
|
||||
}
|
||||
|
||||
@PostMapping("rollBack/{id}")
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@RequiresPermissions("staffService:difficulty:difficultyUnionAudit")
|
||||
public AjaxResult rollBack(@PathVariable String id) {
|
||||
difficultyManageService.update(Chain.make("state", DifficultyAuditState.UNION_READY), Cnd.where("id", "=", id));
|
||||
localProcessService.revokeTask("DIFFICULTY@" + id, String.valueOf(DifficultyAuditState.UNION_READY), SecurityConstants.INNER);
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
@PostMapping("doReview")
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@RequiresPermissions("staffService:difficulty:difficultyUnionAudit")
|
||||
public AjaxResult doReview(@RequestBody Audit audit,
|
||||
@RequestParam(name = "id", required = false) String id,
|
||||
@RequestParam(name = "pass", required = false) Integer pass) {
|
||||
audit.setAuditor(SecurityUtils.getUserId());
|
||||
audit.setLoginName(SecurityUtils.getUsername());
|
||||
audit.setUserName(SecurityUtils.getNickName());
|
||||
audit.setAuditTime(new Date());
|
||||
audit = dao.insert(audit);
|
||||
Difficulty difficulty = dao.fetch(Difficulty.class, id);
|
||||
|
||||
String taskNodeName = "";
|
||||
if (pass == 1) {
|
||||
difficulty.setState(DifficultyAuditState.UNION_REJECTED);
|
||||
taskNodeName = "分工会拒绝";
|
||||
} else if (pass == 2) {
|
||||
difficulty.setState(DifficultyAuditState.UNION_BACK_MODIFY);
|
||||
taskNodeName = "分工会退回";
|
||||
} else {
|
||||
difficulty.setState(DifficultyAuditState.SCHOOL_READY);
|
||||
taskNodeName = "分工会通过";
|
||||
}
|
||||
difficulty.setUnionAuditId(audit.getId());
|
||||
dao.updateIgnoreNull(difficulty);
|
||||
|
||||
String processUniqueId = "DIFFICULTY@" + difficulty.getId();
|
||||
localProcessService.completeTask(processUniqueId, String.valueOf(DifficultyAuditState.UNION_READY), taskNodeName, SecurityConstants.INNER);
|
||||
|
||||
if (pass == 1) {
|
||||
// 拒绝
|
||||
localProcessService.completeProcess(processUniqueId, true, SecurityConstants.INNER);
|
||||
} else if (pass == 2) {
|
||||
// 退回
|
||||
Sql sql = Sqls.create("select loginName from `user` where userId = @id").setParam("id", difficulty.getApplyUserId());
|
||||
sql.setCallback(Sqls.callback.str());
|
||||
dao.execute(sql);
|
||||
String loginName = sql.getString();
|
||||
localProcessService.initCreateTask(
|
||||
processUniqueId,
|
||||
String.valueOf(DifficultyAuditState.UNION_BACK_MODIFY),
|
||||
"分工会退回",
|
||||
List.of(loginName),
|
||||
"/staffService/difficulty/difficultyApplyList",
|
||||
null,
|
||||
SecurityConstants.INNER
|
||||
);
|
||||
} else {
|
||||
// 通过,下一步流程,分工会审核
|
||||
R<List<String>> assignments = localProcessService.getAssignments(null, null, Roles.SCHOOL_ADMIN, SecurityConstants.INNER);
|
||||
List<String> loginNameList = assignments.getData();
|
||||
// 通过,创建后续任务
|
||||
localProcessService.initCreateTask(
|
||||
processUniqueId,
|
||||
String.valueOf(DifficultyAuditState.SCHOOL_READY),
|
||||
"校工会审核",
|
||||
loginNameList,
|
||||
"/staffService/difficulty/difficultySchoolAudit",
|
||||
null,
|
||||
SecurityConstants.INNER
|
||||
);
|
||||
}
|
||||
|
||||
return AjaxResult.success();
|
||||
}
|
||||
}
|
||||
+152
@@ -0,0 +1,152 @@
|
||||
package com.ruoyi.staffService.difficulty.controller;
|
||||
|
||||
import com.ruoyi.common.core.constant.Roles;
|
||||
import com.ruoyi.common.core.constant.SecurityConstants;
|
||||
import com.ruoyi.common.core.domain.PageForm;
|
||||
import com.ruoyi.common.core.domain.R;
|
||||
import com.ruoyi.common.core.page.Pagination;
|
||||
import com.ruoyi.common.core.web.domain.AjaxResult;
|
||||
import com.ruoyi.common.security.annotation.RequiresPermissions;
|
||||
import com.ruoyi.common.security.auth.AuthUtil;
|
||||
import com.ruoyi.common.security.utils.SecurityUtils;
|
||||
import com.ruoyi.staffService.api.constant.difficulty.DifficultyAuditState;
|
||||
import com.ruoyi.staffService.api.domain.common.Audit;
|
||||
import com.ruoyi.staffService.api.domain.difficulty.Difficulty;
|
||||
import com.ruoyi.staffService.constant.Ds;
|
||||
import com.ruoyi.staffService.difficulty.service.DifficultyManageService;
|
||||
import com.ruoyi.staffService.util.ProModuleDS;
|
||||
import com.ruoyi.system.api.RemoteSysLocalProcessService;
|
||||
import com.ruoyi.system.api.domain.SysUser;
|
||||
import com.ruoyi.system.api.domain.SysUserRole;
|
||||
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.lang.util.NutMap;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author JyuHsin
|
||||
* @Date 2023/2/10
|
||||
* @Description
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/difficulty/unionGroupAudit")
|
||||
public class DifficultyUnionGroupAuditController {
|
||||
|
||||
@Autowired
|
||||
private Dao dao;
|
||||
@Autowired
|
||||
private DifficultyManageService difficultyManageService;
|
||||
@Autowired
|
||||
private RemoteSysLocalProcessService localProcessService;
|
||||
|
||||
@PostMapping("pageData")
|
||||
@RequiresPermissions("staffService:difficulty:difficultyUnionGroupAudit")
|
||||
public AjaxResult pageData(@RequestBody PageForm pageForm,
|
||||
@RequestParam(value = "year", required = false) Integer year,
|
||||
@RequestParam(value = "unitId", required = false) String unitId,
|
||||
@RequestParam(value = "unionId", required = false) String unionId,
|
||||
@RequestParam(value = "isAudit", required = false) Boolean isAudit) {
|
||||
Cnd cnd = Cnd.NEW();
|
||||
if (!AuthUtil.hasRole("admin")) {
|
||||
//查询当前登录用户管理的工会小组
|
||||
SysUserRole userRole = ProModuleDS.exec(Ds.SYSTEM, () -> {
|
||||
return dao.fetch(SysUserRole.class, Cnd.where("role_id", "=", Roles.UNION_GROUP_LEADER)
|
||||
.and("user_id", "=", SecurityUtils.getUserId()));
|
||||
});
|
||||
cnd.and("sqr.unionGroupId", "=", userRole.getUnionGroupId());
|
||||
}
|
||||
if (isAudit == null) {
|
||||
cnd.and("sq.state", ">=", 210);
|
||||
} else if (isAudit) {
|
||||
cnd.and("sq.state", ">", 210);
|
||||
} else {
|
||||
cnd.and("sq.state", "=", 210);
|
||||
}
|
||||
Pagination pagination = difficultyManageService.pageData(cnd, pageForm, year, unitId, unionId);
|
||||
return AjaxResult.success(pagination);
|
||||
}
|
||||
|
||||
@PostMapping("rollBack/{id}")
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@RequiresPermissions("staffService:difficulty:difficultyUnionGroupAudit")
|
||||
public AjaxResult rollBack(@PathVariable String id) {
|
||||
difficultyManageService.update(Chain.make("state", DifficultyAuditState.UNION_GROUP_READY), Cnd.where("id", "=", id));
|
||||
localProcessService.revokeTask("DIFFICULTY@" + id, String.valueOf(DifficultyAuditState.UNION_GROUP_READY), SecurityConstants.INNER);
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
@PostMapping("doReview")
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@RequiresPermissions("staffService:difficulty:difficultyUnionGroupAudit")
|
||||
public AjaxResult doReview(@RequestBody Audit audit,
|
||||
@RequestParam(name = "id", required = false) String id,
|
||||
@RequestParam(name = "pass", required = false) Integer pass) {
|
||||
audit.setAuditor(SecurityUtils.getUserId());
|
||||
audit.setLoginName(SecurityUtils.getUsername());
|
||||
audit.setUserName(SecurityUtils.getNickName());
|
||||
audit.setAuditTime(new Date());
|
||||
audit = dao.insert(audit);
|
||||
Difficulty difficulty = dao.fetch(Difficulty.class, id);
|
||||
|
||||
String taskNodeName = "";
|
||||
if (pass == 1) {
|
||||
difficulty.setState(DifficultyAuditState.UNION_GROUP_REJECTED);
|
||||
taskNodeName = "工会小组不通过";
|
||||
} else if (pass == 2) {
|
||||
difficulty.setState(DifficultyAuditState.UNION_GROUP_BACK_MODIFY);
|
||||
taskNodeName = "工会小组退回";
|
||||
} else {
|
||||
difficulty.setState(DifficultyAuditState.UNION_READY);
|
||||
taskNodeName = "工会小组通过";
|
||||
}
|
||||
difficulty.setUnionGroupAuditId(audit.getId());
|
||||
dao.updateIgnoreNull(difficulty);
|
||||
|
||||
String processUniqueId = "DIFFICULTY@" + difficulty.getId();
|
||||
localProcessService.completeTask(processUniqueId, String.valueOf(DifficultyAuditState.UNION_GROUP_READY), taskNodeName, SecurityConstants.INNER);
|
||||
|
||||
Sql sql = Sqls.create("select loginName,userName,unionId from `user` where userId = @id").setParam("id", difficulty.getApplyUserId());
|
||||
sql.setCallback(Sqls.callback.map());
|
||||
dao.execute(sql);
|
||||
NutMap map = (NutMap) sql.getResult();
|
||||
if (pass == 1) {
|
||||
// 不通过,流程结束
|
||||
localProcessService.completeProcess(processUniqueId, true, SecurityConstants.INNER);
|
||||
} else if (pass == 2) {
|
||||
// 退回
|
||||
localProcessService.initCreateTask(
|
||||
processUniqueId,
|
||||
String.valueOf(DifficultyAuditState.UNION_GROUP_BACK_MODIFY),
|
||||
"工会小组退回",
|
||||
List.of(map.getString("loginName")),
|
||||
"/staffService/difficulty/difficultyApplyList",
|
||||
null,
|
||||
SecurityConstants.INNER
|
||||
);
|
||||
} else {
|
||||
// 通过,下一步流程,分工会审核
|
||||
R<List<String>> assignments = localProcessService.getAssignments(map.getString("unionId"), null, Roles.FGH_ADMIN, SecurityConstants.INNER);
|
||||
List<String> loginNameList = assignments.getData();
|
||||
// 通过,创建后续任务
|
||||
localProcessService.initCreateTask(
|
||||
processUniqueId,
|
||||
String.valueOf(DifficultyAuditState.UNION_READY),
|
||||
"分工会审核",
|
||||
loginNameList,
|
||||
"/staffService/difficulty/difficultyUnionAudit",
|
||||
null,
|
||||
SecurityConstants.INNER
|
||||
);
|
||||
}
|
||||
|
||||
return AjaxResult.success();
|
||||
}
|
||||
}
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
package com.ruoyi.staffService.difficulty.service;
|
||||
|
||||
import com.ruoyi.common.core.domain.PageForm;
|
||||
import com.ruoyi.common.core.page.Pagination;
|
||||
import com.ruoyi.common.core.service.BaseService;
|
||||
import com.ruoyi.staffService.api.domain.difficulty.Difficulty;
|
||||
import org.nutz.dao.Cnd;
|
||||
import org.nutz.lang.util.NutMap;
|
||||
|
||||
/**
|
||||
* @Author JyuHsin
|
||||
* @Date 2023/2/10
|
||||
* @Description
|
||||
*/
|
||||
public interface DifficultyManageService extends BaseService<Difficulty> {
|
||||
|
||||
NutMap findOne(String id);
|
||||
|
||||
Pagination pageData(Cnd cnd, PageForm page, Integer year, String unitId, String unionId);
|
||||
}
|
||||
+116
@@ -0,0 +1,116 @@
|
||||
package com.ruoyi.staffService.difficulty.service.impl;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.ruoyi.common.core.domain.PageForm;
|
||||
import com.ruoyi.common.core.page.Pagination;
|
||||
import com.ruoyi.common.core.service.BaseServiceImpl;
|
||||
import com.ruoyi.staffService.api.domain.common.Audit;
|
||||
import com.ruoyi.staffService.api.domain.difficulty.Difficulty;
|
||||
import com.ruoyi.staffService.difficulty.service.DifficultyManageService;
|
||||
import org.nutz.dao.Cnd;
|
||||
import org.nutz.dao.Dao;
|
||||
import org.nutz.dao.Sqls;
|
||||
import org.nutz.dao.sql.Sql;
|
||||
import org.nutz.lang.Lang;
|
||||
import org.nutz.lang.Strings;
|
||||
import org.nutz.lang.util.NutMap;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* @Author JyuHsin
|
||||
* @Date 2023/2/10
|
||||
* @Description
|
||||
*/
|
||||
@Service
|
||||
public class DifficultyManageServiceImpl extends BaseServiceImpl<Difficulty> implements DifficultyManageService {
|
||||
|
||||
public DifficultyManageServiceImpl(Dao dao) {
|
||||
super(dao);
|
||||
}
|
||||
|
||||
@Override
|
||||
public NutMap findOne(String id) {
|
||||
Sql sql = Sqls.create("""
|
||||
SELECT
|
||||
sq.*,
|
||||
sqr.loginName applyLoginName,
|
||||
sqr.userName applyUserName,
|
||||
sbzr.userName helpUserName,
|
||||
sbzr.loginName helpLoginName,
|
||||
sbzr.sex helpSex,
|
||||
if(sq.birthday is not null, sq.birthday, sbzr.birthday) helpBirthday,
|
||||
sbzr.deptName helpDeptName,
|
||||
sbzr.unionName helpUnionName,
|
||||
sbzr.userState,
|
||||
state.stateColor,
|
||||
state.stateName
|
||||
FROM
|
||||
zgfw_knbf sq
|
||||
LEFT JOIN `user` sqr ON sq.applyUserId = sqr.userId
|
||||
LEFT JOIN `user` sbzr ON sq.helpUserId = sbzr.userId
|
||||
LEFT JOIN audit_state state ON state.stateId = sq.state
|
||||
WHERE sq.id = @id
|
||||
""");
|
||||
sql.setParam("id", id);
|
||||
sql.setCallback(Sqls.callback.map());
|
||||
this.dao().execute(sql);
|
||||
NutMap nutMap = sql.getObject(NutMap.class);
|
||||
|
||||
if (Strings.isNotBlank(nutMap.getString("unionGroupAuditId"))) {
|
||||
Audit unionGroupAudit = dao().fetch(Audit.class, nutMap.getString("unionGroupAuditId"));
|
||||
NutMap map = Lang.obj2nutmap(unionGroupAudit);
|
||||
map.setv("auditTime", DateUtil.formatChineseDate(unionGroupAudit.getAuditTime(),false,false));
|
||||
nutMap.put("unionGroupAudit", map);
|
||||
}
|
||||
if (Strings.isNotBlank(nutMap.getString("unionAuditId"))) {
|
||||
Audit unionAudit = dao().fetch(Audit.class, nutMap.getString("unionAuditId"));
|
||||
NutMap map = Lang.obj2nutmap(unionAudit);
|
||||
map.setv("auditTime", DateUtil.formatChineseDate(unionAudit.getAuditTime(),false,false));
|
||||
nutMap.put("unionAudit", map);
|
||||
}
|
||||
if (Strings.isNotBlank(nutMap.getString("schoolAuditId"))) {
|
||||
Audit schoolAudit = dao().fetch(Audit.class, nutMap.getString("schoolAuditId"));
|
||||
NutMap map = Lang.obj2nutmap(schoolAudit);
|
||||
map.setv("auditTime", DateUtil.formatChineseDate(schoolAudit.getAuditTime(),false,false));
|
||||
nutMap.put("schoolAudit", map);
|
||||
}
|
||||
return nutMap;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Pagination pageData(Cnd cnd, PageForm page, Integer year, String unitId, String unionId) {
|
||||
Sql sql = Sqls.create("""
|
||||
SELECT
|
||||
sq.*,
|
||||
sqr.userName applyUserName,
|
||||
sqr.loginName applyLoginName,
|
||||
sqr.deptName applyDeptName,
|
||||
sqr.unionName applyUnionName,
|
||||
sqr.unionGroupName applyUnionGroupName,
|
||||
sbzr.userName helpUserName,
|
||||
sbzr.loginName helpLoginName,
|
||||
sbzr.deptName helpDeptName,
|
||||
sbzr.unionName helpUnionName,
|
||||
sbzr.unionId helpUnionId,
|
||||
state.stateColor,
|
||||
state.stateName stateName
|
||||
FROM
|
||||
`zgfw_knbf` sq
|
||||
LEFT JOIN `user` sqr ON sq.applyUserId = sqr.userId
|
||||
LEFT JOIN `user` sbzr ON sq.helpUserId = sbzr.userId
|
||||
LEFT JOIN audit_state state ON sq.state = state.stateId
|
||||
$condition
|
||||
""");
|
||||
|
||||
if (Strings.isNotBlank(page.getSearchKeyword())) {
|
||||
cnd.where().andLike(page.getSearchName(), page.getSearchKeyword());
|
||||
}
|
||||
cnd.andEX("YEAR(sq.applyTime)", "=", year);
|
||||
cnd.andEX("sqr.deptId", "=", unitId);
|
||||
cnd.andEX("sqr.unionId", "=", unionId);
|
||||
cnd.asc("sq.state");
|
||||
cnd.desc("sq.applyTime");
|
||||
sql.setCondition(cnd);
|
||||
return listPageMap(page.getPageNumber(), page.getPageSize(), sql);
|
||||
}
|
||||
}
|
||||
+204
@@ -0,0 +1,204 @@
|
||||
package com.ruoyi.staffService.manuscript.controller;
|
||||
|
||||
import com.ruoyi.common.core.constant.Roles;
|
||||
import com.ruoyi.common.core.constant.SecurityConstants;
|
||||
import com.ruoyi.common.core.domain.R;
|
||||
import com.ruoyi.common.core.utils.DateUtils;
|
||||
import com.ruoyi.common.core.web.domain.AjaxResult;
|
||||
import com.ruoyi.common.security.annotation.RequiresPermissions;
|
||||
import com.ruoyi.common.security.utils.SecurityUtils;
|
||||
import com.ruoyi.staffService.api.domain.manuscript.Manuscript;
|
||||
import com.ruoyi.staffService.constant.Ds;
|
||||
import com.ruoyi.staffService.manuscript.service.ManuscriptManageService;
|
||||
import com.ruoyi.staffService.util.ProModuleDS;
|
||||
import com.ruoyi.system.api.RemoteSysLocalProcessService;
|
||||
import com.ruoyi.system.api.domain.SysUser;
|
||||
import com.ruoyi.system.api.domain.SysUserRole;
|
||||
import com.ruoyi.system.api.domain.club.Sys_club;
|
||||
import org.nutz.dao.Cnd;
|
||||
import org.nutz.dao.Dao;
|
||||
import org.nutz.dao.Sqls;
|
||||
import org.nutz.dao.sql.Sql;
|
||||
import org.nutz.lang.util.NutMap;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @Author JyuHsin
|
||||
* @Date 2023/2/8
|
||||
* @Description
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/manuscript/manuscriptApply")
|
||||
public class ManuscriptApplyController {
|
||||
|
||||
@Autowired
|
||||
private Dao dao;
|
||||
@Autowired
|
||||
private ManuscriptManageService manuscriptManageService;
|
||||
@Autowired
|
||||
private RemoteSysLocalProcessService localProcessService;
|
||||
|
||||
@RequestMapping("getClubByUserId")
|
||||
public AjaxResult getClubByUserId() {
|
||||
//获取当前登录用户负责的社团
|
||||
String stid = ProModuleDS.exec(Ds.SYSTEM, () -> {
|
||||
List<SysUserRole> userRoleList = dao.query(SysUserRole.class, Cnd.where("userId", "=", SecurityUtils.getUserId()).and("roleId", "=", Roles.CLUB_FZR));
|
||||
return userRoleList != null && userRoleList.size() > 0 ? userRoleList.get(0).getStid() : "";
|
||||
});
|
||||
return AjaxResult.success(stid);
|
||||
}
|
||||
|
||||
@PostMapping("doAdd")
|
||||
@RequiresPermissions("staffService:manuscript:manuscriptApply")
|
||||
public AjaxResult doAdd(@RequestBody Manuscript manuscript,
|
||||
@RequestParam(name = "flag", required = false) Boolean flag) {
|
||||
if (manuscript.getStateId() != 0) {
|
||||
// 如果是被退回的流程,那就要完成被退回流程的任务
|
||||
localProcessService.completeReturnTask("MANUSCRIPT@" + manuscript.getId(), SecurityConstants.INNER);
|
||||
}
|
||||
|
||||
manuscript.setUserId(SecurityUtils.getUserId());
|
||||
manuscript.setApplyTime(DateUtils.getDate());
|
||||
if (manuscript.getType() == 2) {
|
||||
manuscript.setStateId(flag ? 2510 : 2500);
|
||||
} else {
|
||||
manuscript.setStateId(flag ? 2550 : 2500);
|
||||
}
|
||||
Manuscript insert = manuscriptManageService.insert(manuscript);
|
||||
|
||||
String processUniqueId = "MANUSCRIPT@" + insert.getId();
|
||||
Sql sql = Sqls.create("select userName from `user` where userId = @id").setParam("id", manuscript.getUserId());
|
||||
sql.setCallback(Sqls.callback.str());
|
||||
dao.execute(sql);
|
||||
String userName = sql.getString();
|
||||
localProcessService.initCreateInstance(
|
||||
processUniqueId,
|
||||
insert.getId(),
|
||||
"[新闻投稿]" + userName,
|
||||
"/staffService/manuscript/manuscriptMine",
|
||||
null,
|
||||
SecurityConstants.INNER
|
||||
);
|
||||
|
||||
if (flag) {
|
||||
if (manuscript.getType() == 2) {
|
||||
// 类型是分工会,创建分工会审核任务
|
||||
R<List<String>> assignments = localProcessService.getAssignments(SecurityUtils.getUnionId(), null, Roles.FGH_ADMIN, SecurityConstants.INNER);
|
||||
List<String> loginNameList = assignments.getData();
|
||||
localProcessService.initCreateTask(
|
||||
processUniqueId,
|
||||
"2510",
|
||||
"分工会审核",
|
||||
loginNameList,
|
||||
"/staffService/manuscript/manuscriptUnionAudit",
|
||||
null,
|
||||
SecurityConstants.INNER
|
||||
);
|
||||
} else {
|
||||
// 协会和校工会,创建校工会任务
|
||||
R<List<String>> assignments = localProcessService.getAssignments(null, null, Roles.SCHOOL_ADMIN, SecurityConstants.INNER);
|
||||
List<String> loginNameList = assignments.getData();
|
||||
localProcessService.initCreateTask(
|
||||
processUniqueId,
|
||||
"2550",
|
||||
"校工会审核",
|
||||
loginNameList,
|
||||
"/staffService/manuscript/manuscriptSchoolAudit",
|
||||
null,
|
||||
SecurityConstants.INNER
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return AjaxResult.success(insert);
|
||||
}
|
||||
|
||||
@PostMapping("doEdit")
|
||||
@RequiresPermissions("staffService:manuscript:manuscriptApply")
|
||||
public AjaxResult doEdit(@RequestBody Manuscript manuscript,
|
||||
@RequestParam(name = "flag", required = false) Boolean flag) {
|
||||
if (manuscript.getStateId() != 0) {
|
||||
// 如果是被退回的流程,那就要完成被退回流程的任务
|
||||
localProcessService.completeReturnTask("MANUSCRIPT@" + manuscript.getId(), SecurityConstants.INNER);
|
||||
}
|
||||
|
||||
if (manuscript.getType() == 2 || manuscript.getType() == 1) {
|
||||
manuscript.setStateId(flag ? 2510 : 2500);
|
||||
} else {
|
||||
manuscript.setStateId(flag ? 2550 : 2500);
|
||||
}
|
||||
|
||||
int i = manuscriptManageService.updateIgnoreNull(manuscript);
|
||||
|
||||
String processUniqueId = "MANUSCRIPT@" + manuscript.getId();
|
||||
|
||||
Sql sql = Sqls.create("select userName from `user` where userId = @id").setParam("id", manuscript.getUserId());
|
||||
sql.setCallback(Sqls.callback.str());
|
||||
dao.execute(sql);
|
||||
String userName = sql.getString();
|
||||
localProcessService.initCreateInstance(
|
||||
processUniqueId,
|
||||
manuscript.getId(),
|
||||
"[新闻投稿]" + userName,
|
||||
"/staffService/manuscript/manuscriptMine",
|
||||
null,
|
||||
SecurityConstants.INNER
|
||||
);
|
||||
|
||||
if (flag) {
|
||||
if (manuscript.getType() == 2) {
|
||||
// 类型是分工会,创建分工会审核任务
|
||||
R<List<String>> assignments = localProcessService.getAssignments(SecurityUtils.getUnionId(), null, Roles.FGH_ADMIN, SecurityConstants.INNER);
|
||||
List<String> loginNameList = assignments.getData();
|
||||
localProcessService.initCreateTask(
|
||||
processUniqueId,
|
||||
"2510",
|
||||
"分工会审核",
|
||||
loginNameList,
|
||||
"/staffService/manuscript/manuscriptUnionAudit",
|
||||
null,
|
||||
SecurityConstants.INNER
|
||||
);
|
||||
} else {
|
||||
// 协会和校工会,创建校工会任务
|
||||
R<List<String>> assignments = localProcessService.getAssignments(null, null, Roles.SCHOOL_ADMIN, SecurityConstants.INNER);
|
||||
List<String> loginNameList = assignments.getData();
|
||||
localProcessService.initCreateTask(
|
||||
processUniqueId,
|
||||
"2550",
|
||||
"校工会审核",
|
||||
loginNameList,
|
||||
"/staffService/manuscript/manuscriptSchoolAudit",
|
||||
null,
|
||||
SecurityConstants.INNER
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return AjaxResult.success(i);
|
||||
}
|
||||
|
||||
@GetMapping("getRoleByUserId")
|
||||
public AjaxResult getRoleByUserId() {
|
||||
List<String> result = ProModuleDS.exec(Ds.SYSTEM, () -> {
|
||||
Sql sql = Sqls.create("""
|
||||
SELECT sy.`role_key` FROM `sys_user_role` suy LEFT JOIN sys_role sy ON sy.role_id = suy.role_id WHERE suy.user_id = @userId
|
||||
""").setParam("userId", SecurityUtils.getUserId());
|
||||
List<NutMap> list = manuscriptManageService.listMap(sql);
|
||||
return list.stream().map(v -> v.getString("role_key")).collect(Collectors.toList());
|
||||
});
|
||||
return AjaxResult.success(result);
|
||||
}
|
||||
|
||||
@GetMapping("getClubs")
|
||||
public AjaxResult getClubs() {
|
||||
List<Sys_club> result = ProModuleDS.exec(Ds.SYSTEM, () -> {
|
||||
return dao.query(Sys_club.class, Cnd.orderBy().asc("code"));
|
||||
});
|
||||
return AjaxResult.success(result);
|
||||
}
|
||||
}
|
||||
+112
@@ -0,0 +1,112 @@
|
||||
package com.ruoyi.staffService.manuscript.controller;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.ruoyi.common.core.constant.SecurityConstants;
|
||||
import com.ruoyi.common.core.domain.PageForm;
|
||||
import com.ruoyi.common.core.page.Pagination;
|
||||
import com.ruoyi.common.core.web.domain.AjaxResult;
|
||||
import com.ruoyi.common.security.annotation.RequiresPermissions;
|
||||
import com.ruoyi.common.security.auth.AuthUtil;
|
||||
import com.ruoyi.common.security.utils.SecurityUtils;
|
||||
import com.ruoyi.staffService.manuscript.service.ManuscriptCommonService;
|
||||
import com.ruoyi.staffService.manuscript.service.ManuscriptManageService;
|
||||
import com.ruoyi.system.api.RemoteSysLocalProcessService;
|
||||
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.lang.Strings;
|
||||
import org.nutz.lang.util.NutMap;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
/**
|
||||
* @Author JyuHsin
|
||||
* @Date 2023/2/8
|
||||
* @Description
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/manuscript/manuscriptMine")
|
||||
public class ManuscriptMineController {
|
||||
|
||||
@Autowired
|
||||
private Dao dao;
|
||||
@Autowired
|
||||
private ManuscriptManageService manuscriptManageService;
|
||||
@Autowired
|
||||
private ManuscriptCommonService manuscriptCommonService;
|
||||
@Autowired
|
||||
private RemoteSysLocalProcessService localProcessService;
|
||||
|
||||
@PostMapping("pageData")
|
||||
@RequiresPermissions("staffService:manuscript:manuscriptMine")
|
||||
public AjaxResult pageData(@RequestBody PageForm pageForm,
|
||||
@RequestParam(name = "year", required = false) String year,
|
||||
@RequestParam(name = "manuscriptName", required = false) String manuscriptName,
|
||||
@RequestParam(name = "manuscriptCode", required = false) String manuscriptCode) {
|
||||
Cnd cnd = Cnd.NEW();
|
||||
Sql sql = Sqls.create("""
|
||||
SELECT
|
||||
man.*,
|
||||
ty.manuscriptTypeName,
|
||||
us.userName as username,
|
||||
us.loginName as loginname,
|
||||
us.deptName as unitname,
|
||||
us.deptCode as unitcode,
|
||||
us.unionName as unionname,
|
||||
us.unionCode as unioncode,
|
||||
state.stateName,
|
||||
state.stateColor
|
||||
FROM
|
||||
`manuscript` man
|
||||
LEFT JOIN manuscript_type ty ON man.manuscriptCode = ty.manuscriptTypeCode
|
||||
LEFT JOIN `user` us ON us.userId = man.userId
|
||||
LEFT JOIN audit_state state ON state.stateId = man.stateId
|
||||
$condition
|
||||
""");
|
||||
if (Strings.isNotBlank(pageForm.getSearchName()) && Strings.isNotBlank(pageForm.getSearchKeyword())) {
|
||||
cnd.where().andLike(pageForm.getSearchName(), pageForm.getSearchKeyword());
|
||||
}
|
||||
if (StrUtil.isNotBlank(manuscriptName)) {
|
||||
cnd.where().andLike("man.manuscriptName", manuscriptName);
|
||||
}
|
||||
cnd.andEX("man.manuscriptCode", "=", manuscriptCode);
|
||||
cnd.andEX("YEAR(man.applyTime)", "=", year);
|
||||
if (!AuthUtil.hasRole("admin")) {
|
||||
cnd.and("man.userId", "=", SecurityUtils.getUserId());
|
||||
}
|
||||
cnd.desc("man.applyTime");
|
||||
sql.setCondition(cnd);
|
||||
|
||||
Pagination pagination = manuscriptManageService.listPageMap(pageForm.getPageNumber(), pageForm.getPageSize(), sql);
|
||||
return AjaxResult.success(pagination);
|
||||
}
|
||||
|
||||
@PostMapping("doDelete/{id}")
|
||||
@RequiresPermissions("staffService:manuscript:manuscriptMine")
|
||||
public AjaxResult doDelete(@PathVariable String id) {
|
||||
manuscriptManageService.delete(id);
|
||||
localProcessService.deleteProcessInstance("MANUSCRIPT@" + id, SecurityConstants.INNER);
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
@PostMapping("doSubmit")
|
||||
@RequiresPermissions("staffService:manuscript:manuscriptMine")
|
||||
public AjaxResult doSubmit(String id, Integer type) {
|
||||
int stateId;
|
||||
if (type == 2) {
|
||||
stateId = 2510;
|
||||
} else {
|
||||
stateId = 2550;
|
||||
}
|
||||
manuscriptManageService.update(Chain.make("stateId", stateId), Cnd.where("id", "=", id));
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
@GetMapping("findOne/{id}")
|
||||
public AjaxResult findOne(@PathVariable String id) {
|
||||
NutMap nutMap = manuscriptCommonService.findOne(id);
|
||||
return AjaxResult.success(nutMap);
|
||||
}
|
||||
}
|
||||
+156
@@ -0,0 +1,156 @@
|
||||
package com.ruoyi.staffService.manuscript.controller;
|
||||
|
||||
import com.ruoyi.common.core.constant.SecurityConstants;
|
||||
import com.ruoyi.common.core.domain.PageForm;
|
||||
import com.ruoyi.common.core.page.Pagination;
|
||||
import com.ruoyi.common.core.web.domain.AjaxResult;
|
||||
import com.ruoyi.common.security.annotation.RequiresPermissions;
|
||||
import com.ruoyi.common.security.utils.SecurityUtils;
|
||||
import com.ruoyi.staffService.api.domain.common.Audit;
|
||||
import com.ruoyi.staffService.api.domain.manuscript.Manuscript;
|
||||
import com.ruoyi.staffService.manuscript.service.ManuscriptManageService;
|
||||
import com.ruoyi.system.api.RemoteSysLocalProcessService;
|
||||
import com.ruoyi.system.api.domain.SysUser;
|
||||
import org.nutz.dao.Cnd;
|
||||
import org.nutz.dao.Dao;
|
||||
import org.nutz.dao.Sqls;
|
||||
import org.nutz.dao.sql.Sql;
|
||||
import org.nutz.lang.Strings;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author JyuHsin
|
||||
* @Date 2023/2/8
|
||||
* @Description
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/manuscript/manuscriptSchoolAudit")
|
||||
public class ManuscriptSchoolAuditController {
|
||||
|
||||
@Autowired
|
||||
private Dao dao;
|
||||
@Autowired
|
||||
private ManuscriptManageService manuscriptManageService;
|
||||
@Autowired
|
||||
private RemoteSysLocalProcessService localProcessService;
|
||||
|
||||
|
||||
@PostMapping("pageData")
|
||||
@RequiresPermissions("staffService:manuscript:manuscriptSchoolAudit")
|
||||
public AjaxResult pageData(@RequestBody PageForm pageForm,
|
||||
@RequestParam(name = "year", required = false) String year,
|
||||
@RequestParam(name = "isAudit", required = false) Boolean isAudit,
|
||||
@RequestParam(name = "unitId", required = false) String unitId,
|
||||
@RequestParam(name = "unionId", required = false) String unionId,
|
||||
@RequestParam(name = "manuscriptName", required = false) String manuscriptName,
|
||||
@RequestParam(name = "manuscriptCode", required = false) String manuscriptCode,
|
||||
@RequestParam(name = "isManuscriptType", required = false) String isManuscriptType) {
|
||||
Cnd cnd = Cnd.NEW();
|
||||
Sql sql = Sqls.create("""
|
||||
SELECT
|
||||
man.*,
|
||||
ty.manuscriptTypeName,
|
||||
us.userName as username,
|
||||
us.loginName as loginname,
|
||||
us.deptName as unitname,
|
||||
us.deptCode as unitcode,
|
||||
us.unionName as unionname,
|
||||
us.unionCode as unioncode,
|
||||
state.stateName,
|
||||
state.stateColor
|
||||
FROM
|
||||
`manuscript` man
|
||||
LEFT JOIN manuscript_type ty ON man.manuscriptCode = ty.manuscriptTypeCode
|
||||
LEFT JOIN `user` us ON us.userId = man.userId
|
||||
LEFT JOIN audit_state state ON state.stateId = man.stateId
|
||||
$condition
|
||||
""");
|
||||
if (Strings.isNotBlank(pageForm.getSearchName()) && Strings.isNotBlank(pageForm.getSearchKeyword())) {
|
||||
cnd.where().andLike(pageForm.getSearchName(), pageForm.getSearchKeyword());
|
||||
}
|
||||
if (Strings.isNotBlank(manuscriptName)) {
|
||||
cnd.where().andLike("man.manuscriptName", manuscriptName);
|
||||
}
|
||||
if (Strings.isNotBlank(manuscriptCode)) {
|
||||
cnd.and("man.manuscriptCode", "=", manuscriptCode);
|
||||
}
|
||||
if (isAudit == null) {
|
||||
cnd.and("man.stateId", ">=", 2550);
|
||||
} else if (isAudit) {
|
||||
cnd.and("man.stateId", ">", 2550);
|
||||
} else {
|
||||
cnd.and("man.stateId", "=", 2550);
|
||||
}
|
||||
if (Strings.isNotBlank(isManuscriptType) && "3".equals(isManuscriptType)) {
|
||||
cnd.and("man.type", "=", 3);
|
||||
}
|
||||
cnd.andEX("YEAR(man.applyTime)", "=", year);
|
||||
cnd.andEX("us.deptId", "=", unitId);
|
||||
cnd.andEX("us.unionId", "=", unionId);
|
||||
cnd.desc("man.applyTime");
|
||||
sql.setCondition(cnd);
|
||||
|
||||
Pagination pagination = manuscriptManageService.listPageMap(pageForm.getPageNumber(), pageForm.getPageSize(), sql);
|
||||
return AjaxResult.success(pagination);
|
||||
}
|
||||
|
||||
@PostMapping("doReview")
|
||||
@RequiresPermissions("staffService:manuscript:manuscriptSchoolAudit")
|
||||
public AjaxResult doReview(@RequestBody Audit audit,
|
||||
@RequestParam(name = "id", required = false) String id,
|
||||
@RequestParam(name = "pass", required = false) Integer pass) {
|
||||
audit.setLoginName(SecurityUtils.getUsername());
|
||||
audit.setUserName(SecurityUtils.getNickName());
|
||||
audit.setAuditTime(new Date());
|
||||
audit = dao.insert(audit);
|
||||
Manuscript manuscript = dao.fetch(Manuscript.class, id);
|
||||
List<String> schoolUnionAudit = manuscript.getSchool_union_audit() == null ? new ArrayList<>() : manuscript.getSchool_union_audit();
|
||||
schoolUnionAudit.add(audit.getId());
|
||||
manuscript.setSchool_union_audit(schoolUnionAudit);
|
||||
|
||||
String taskNodeName = "";
|
||||
if (pass == 1) {
|
||||
manuscript.setStateId(2560);
|
||||
taskNodeName = "校工会退回";
|
||||
} else if (pass == 2) {
|
||||
manuscript.setStateId(2555);
|
||||
taskNodeName = "校工会拒绝";
|
||||
} else {
|
||||
manuscript.setStateId(2570);
|
||||
taskNodeName = "校工会通过";
|
||||
}
|
||||
dao.updateIgnoreNull(manuscript);
|
||||
|
||||
String processUniqueId = "MANUSCRIPT@" + manuscript.getId();
|
||||
localProcessService.completeTask(processUniqueId, "2550", taskNodeName, SecurityConstants.INNER);
|
||||
|
||||
switch (pass) {
|
||||
case 1 -> {
|
||||
// 退回
|
||||
Sql sql = Sqls.create("select loginName from `user` where userId = @id").setParam("id", manuscript.getUserId());
|
||||
sql.setCallback(Sqls.callback.str());
|
||||
dao.execute(sql);
|
||||
String loginName = sql.getString();
|
||||
localProcessService.initCreateTask(
|
||||
processUniqueId,
|
||||
"2560",
|
||||
"校工会退回",
|
||||
List.of(loginName),
|
||||
"/staffService/manuscript/manuscriptMine",
|
||||
null,
|
||||
SecurityConstants.INNER
|
||||
);
|
||||
}
|
||||
case 2, 3 -> {
|
||||
localProcessService.completeProcess(processUniqueId, pass == 2, SecurityConstants.INNER);
|
||||
}
|
||||
}
|
||||
|
||||
return AjaxResult.success();
|
||||
}
|
||||
}
|
||||
+107
@@ -0,0 +1,107 @@
|
||||
package com.ruoyi.staffService.manuscript.controller;
|
||||
|
||||
import com.ruoyi.common.core.web.domain.AjaxResult;
|
||||
import com.ruoyi.common.security.annotation.RequiresPermissions;
|
||||
import com.ruoyi.staffService.constant.Ds;
|
||||
import com.ruoyi.staffService.manuscript.service.ManuscriptManageService;
|
||||
import com.ruoyi.staffService.util.ProModuleDS;
|
||||
import com.ruoyi.system.api.domain.SysUnion;
|
||||
import com.ruoyi.system.api.domain.club.Sys_club;
|
||||
import org.nutz.dao.Cnd;
|
||||
import org.nutz.dao.Dao;
|
||||
import org.nutz.dao.Sqls;
|
||||
import org.nutz.dao.sql.Sql;
|
||||
import org.nutz.lang.Lang;
|
||||
import org.nutz.lang.util.NutMap;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @Author JyuHsin
|
||||
* @Date 2023/2/8
|
||||
* @Description
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/manuscript/manuscriptStatistics")
|
||||
public class ManuscriptStatisticsController {
|
||||
|
||||
@Autowired
|
||||
private Dao dao;
|
||||
|
||||
@Autowired
|
||||
private ManuscriptManageService manuscriptManageService;
|
||||
|
||||
@GetMapping("unionTableNum")
|
||||
@RequiresPermissions("staffService:manuscript:manuscriptStatistics")
|
||||
public AjaxResult unionTableNum(Integer year) {
|
||||
|
||||
Sql sql = Sqls.create("""
|
||||
select count(*) as count, unionId from manuscript
|
||||
$condition
|
||||
""");
|
||||
Cnd cnd = Cnd.NEW();
|
||||
cnd.and("stateId", "=", 2570);
|
||||
cnd.and("unionId", "is not", null);
|
||||
cnd.andEX("YEAR(applyTime)", "=", year);
|
||||
cnd.groupBy("unionId");
|
||||
sql.setCondition(cnd);
|
||||
|
||||
List<NutMap> list = manuscriptManageService.listMap(sql);
|
||||
Map<String, String> unionCountMap = list.stream().collect(Collectors.toMap(o -> o.getString("unionId"), o -> o.getString("count")));
|
||||
|
||||
List<SysUnion> unionList = ProModuleDS.exec(Ds.SYSTEM, () -> {
|
||||
return dao.query(SysUnion.class, Cnd.orderBy().asc("unionCode"));
|
||||
});
|
||||
|
||||
List<NutMap> result = new ArrayList<>();
|
||||
|
||||
unionList.forEach(item -> {
|
||||
NutMap map = Lang.obj2nutmap(item);
|
||||
map.put("unionName", item.getUnionName() + "(" + item.getUnionCode() + ')');
|
||||
map.put("manuscriptNum", unionCountMap.get(item.getId()) != null ? unionCountMap.get(item.getId()) : 0);
|
||||
result.add(map);
|
||||
});
|
||||
|
||||
return AjaxResult.success(result);
|
||||
}
|
||||
|
||||
@GetMapping("clubTableNum")
|
||||
@RequiresPermissions("staffService:manuscript:manuscriptStatistics")
|
||||
public AjaxResult clubTableNum(Integer year) {
|
||||
Sql sql = Sqls.create("""
|
||||
select count(*) as count, clubId from manuscript
|
||||
$condition
|
||||
""");
|
||||
Cnd cnd = Cnd.NEW();
|
||||
cnd.and("stateId", "=", 2570);
|
||||
cnd.and("clubId", "is not", null);
|
||||
cnd.andEX("YEAR(applyTime)", "=", year);
|
||||
cnd.groupBy("clubId");
|
||||
sql.setCondition(cnd);
|
||||
|
||||
List<NutMap> list = manuscriptManageService.listMap(sql);
|
||||
Map<String, String> clubCountMap = list.stream().collect(Collectors.toMap(o -> o.getString("clubId"), o -> o.getString("count")));
|
||||
|
||||
List<Sys_club> unionList = ProModuleDS.exec(Ds.SYSTEM, () -> {
|
||||
return dao.query(Sys_club.class, Cnd.orderBy().asc("code"));
|
||||
});
|
||||
|
||||
List<NutMap> result = new ArrayList<>();
|
||||
|
||||
unionList.forEach(item -> {
|
||||
NutMap map = Lang.obj2nutmap(item);
|
||||
map.put("clubname", item.getName() + "(" + item.getCode() + ')');
|
||||
map.put("manuscriptNum", clubCountMap.get(item.getId()) != null ? clubCountMap.get(item.getId()) : 0);
|
||||
result.add(map);
|
||||
});
|
||||
|
||||
return AjaxResult.success(result);
|
||||
}
|
||||
}
|
||||
+68
@@ -0,0 +1,68 @@
|
||||
package com.ruoyi.staffService.manuscript.controller;
|
||||
|
||||
import com.ruoyi.common.core.domain.PageForm;
|
||||
import com.ruoyi.common.core.page.Pagination;
|
||||
import com.ruoyi.common.core.web.domain.AjaxResult;
|
||||
import com.ruoyi.common.security.annotation.RequiresPermissions;
|
||||
import com.ruoyi.staffService.api.domain.manuscript.ManuscriptType;
|
||||
import com.ruoyi.staffService.manuscript.service.ManuscriptTypeService;
|
||||
import org.nutz.dao.Cnd;
|
||||
import org.nutz.dao.Dao;
|
||||
import org.nutz.lang.Strings;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
/**
|
||||
* @Author JyuHsin
|
||||
* @Date 2023/2/8
|
||||
* @Description
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/manuscript/manuscriptType")
|
||||
public class ManuscriptTypeController {
|
||||
|
||||
@Autowired
|
||||
private Dao dao;
|
||||
|
||||
@Autowired
|
||||
private ManuscriptTypeService manuscriptTypeService;
|
||||
|
||||
@PostMapping("pageData")
|
||||
@RequiresPermissions("staffService:manuscript:manuscriptType")
|
||||
public AjaxResult pageData(@RequestBody PageForm pageForm) {
|
||||
Cnd cnd = Cnd.NEW();
|
||||
if (Strings.isNotBlank(pageForm.getSearchName()) && Strings.isNotBlank(pageForm.getSearchKeyword())) {
|
||||
cnd.where().andLike(pageForm.getSearchName(), pageForm.getSearchKeyword());
|
||||
}
|
||||
cnd.asc("manuscriptTypeCode");
|
||||
|
||||
Pagination pagination = manuscriptTypeService.listPage(pageForm.getPageNumber(), pageForm.getPageSize(), cnd);
|
||||
return AjaxResult.success(pagination);
|
||||
}
|
||||
|
||||
@PostMapping("doAdd")
|
||||
@RequiresPermissions("staffService:manuscript:manuscriptType")
|
||||
public AjaxResult doAdd(@RequestBody ManuscriptType manuscriptType) {
|
||||
return AjaxResult.success(manuscriptTypeService.insert(manuscriptType));
|
||||
}
|
||||
|
||||
@PostMapping("doEdit")
|
||||
@RequiresPermissions("staffService:manuscript:manuscriptType")
|
||||
public AjaxResult doEdit(@RequestBody ManuscriptType manuscriptType) {
|
||||
return AjaxResult.success(manuscriptTypeService.updateIgnoreNull(manuscriptType));
|
||||
}
|
||||
|
||||
@PostMapping("doDelete/{id}")
|
||||
@RequiresPermissions("staffService:manuscript:manuscriptType")
|
||||
public AjaxResult doDelete(@PathVariable String id) {
|
||||
return AjaxResult.success(manuscriptTypeService.delete(id));
|
||||
}
|
||||
|
||||
@RequestMapping("getManuscriptType")
|
||||
public AjaxResult getManuscriptType() {
|
||||
Cnd cnd = Cnd.NEW();
|
||||
cnd.asc("manuscriptTypeCode");
|
||||
return AjaxResult.success(manuscriptTypeService.query(cnd));
|
||||
}
|
||||
|
||||
}
|
||||
+181
@@ -0,0 +1,181 @@
|
||||
package com.ruoyi.staffService.manuscript.controller;
|
||||
|
||||
import com.ruoyi.common.core.constant.Roles;
|
||||
import com.ruoyi.common.core.constant.SecurityConstants;
|
||||
import com.ruoyi.common.core.domain.PageForm;
|
||||
import com.ruoyi.common.core.domain.R;
|
||||
import com.ruoyi.common.core.page.Pagination;
|
||||
import com.ruoyi.common.core.web.domain.AjaxResult;
|
||||
import com.ruoyi.common.security.annotation.RequiresPermissions;
|
||||
import com.ruoyi.common.security.auth.AuthUtil;
|
||||
import com.ruoyi.common.security.utils.SecurityUtils;
|
||||
import com.ruoyi.staffService.api.constant.difficulty.DifficultyAuditState;
|
||||
import com.ruoyi.staffService.api.domain.common.Audit;
|
||||
import com.ruoyi.staffService.api.domain.manuscript.Manuscript;
|
||||
import com.ruoyi.staffService.manuscript.service.ManuscriptManageService;
|
||||
import com.ruoyi.system.api.RemoteSysLocalProcessService;
|
||||
import com.ruoyi.system.api.domain.SysUser;
|
||||
import org.nutz.dao.Cnd;
|
||||
import org.nutz.dao.Dao;
|
||||
import org.nutz.dao.Sqls;
|
||||
import org.nutz.dao.sql.Sql;
|
||||
import org.nutz.lang.Strings;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author JyuHsin
|
||||
* @Date 2023/2/8
|
||||
* @Description
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/manuscript/manuscriptUnionAudit")
|
||||
public class ManuscriptUnionAuditController {
|
||||
|
||||
@Autowired
|
||||
private Dao dao;
|
||||
@Autowired
|
||||
private ManuscriptManageService manuscriptManageService;
|
||||
@Autowired
|
||||
private RemoteSysLocalProcessService localProcessService;
|
||||
|
||||
@PostMapping("pageData")
|
||||
@RequiresPermissions("staffService:manuscript:manuscriptUnionAudit")
|
||||
public AjaxResult pageData(@RequestBody PageForm pageForm,
|
||||
@RequestParam(name = "year", required = false) String year,
|
||||
@RequestParam(name = "isAudit", required = false) Boolean isAudit,
|
||||
@RequestParam(name = "unitId", required = false) String unitId,
|
||||
@RequestParam(name = "unionId", required = false) String unionId,
|
||||
@RequestParam(name = "manuscriptName", required = false) String manuscriptName,
|
||||
@RequestParam(name = "manuscriptCode", required = false) String manuscriptCode) {
|
||||
Cnd cnd = Cnd.NEW();
|
||||
Sql sql = Sqls.create("""
|
||||
SELECT
|
||||
man.*,
|
||||
ty.manuscriptTypeName,
|
||||
us.userName as username,
|
||||
us.loginName as loginname,
|
||||
us.deptName as unitname,
|
||||
us.deptCode as unitcode,
|
||||
us.unionName as unionname,
|
||||
us.unionCode as unioncode,
|
||||
state.stateName,
|
||||
state.stateColor
|
||||
FROM
|
||||
`manuscript` man
|
||||
LEFT JOIN manuscript_type ty ON man.manuscriptCode = ty.manuscriptTypeCode
|
||||
LEFT JOIN `user` us ON us.userId = man.userId
|
||||
LEFT JOIN audit_state state ON state.stateId = man.stateId
|
||||
$condition
|
||||
""");
|
||||
if (Strings.isNotBlank(pageForm.getSearchName()) && Strings.isNotBlank(pageForm.getSearchKeyword())) {
|
||||
cnd.where().andLike(pageForm.getSearchName(), pageForm.getSearchKeyword());
|
||||
}
|
||||
if (!AuthUtil.hasRole("admin")) {
|
||||
cnd.and("man.unionId", "=", SecurityUtils.getUnionId());
|
||||
}
|
||||
if (Strings.isNotBlank(manuscriptName)) {
|
||||
cnd.where().andLike("man.manuscriptName", manuscriptName);
|
||||
}
|
||||
if (Strings.isNotBlank(manuscriptCode)) {
|
||||
cnd.and("man.manuscriptCode", "=", manuscriptCode);
|
||||
}
|
||||
if (isAudit == null) {
|
||||
cnd.and("man.stateId", ">=", 2510);
|
||||
} else if (isAudit) {
|
||||
cnd.and("man.stateId", ">", 2510);
|
||||
} else {
|
||||
cnd.and("man.stateId", "=", 2510);
|
||||
}
|
||||
/*if (isAudit != null) {
|
||||
if (isAudit) {
|
||||
cnd.andEX("man.stateId", ">", "2510");
|
||||
cnd.andEX("man.stateId", "!=", "2560");
|
||||
} else {
|
||||
cnd.andEX("man.stateId", "in", "2510,2560");
|
||||
}
|
||||
}*/
|
||||
cnd.andEX("YEAR(man.applyTime)", "=", year);
|
||||
cnd.andEX("us.deptId", "=", unitId);
|
||||
cnd.andEX("us.unionId", "=", unionId);
|
||||
cnd.desc("man.applyTime");
|
||||
sql.setCondition(cnd);
|
||||
|
||||
Pagination pagination = manuscriptManageService.listPageMap(pageForm.getPageNumber(), pageForm.getPageSize(), sql);
|
||||
return AjaxResult.success(pagination);
|
||||
}
|
||||
|
||||
@PostMapping("doReview")
|
||||
@RequiresPermissions("staffService:manuscript:manuscriptUnionAudit")
|
||||
public AjaxResult doReview(@RequestBody Audit audit,
|
||||
@RequestParam(name = "id", required = false) String id,
|
||||
@RequestParam(name = "pass", required = false) Integer pass) {
|
||||
audit.setLoginName(SecurityUtils.getUsername());
|
||||
audit.setUserName(SecurityUtils.getNickName());
|
||||
audit.setAuditTime(new Date());
|
||||
audit = dao.insert(audit);
|
||||
Manuscript manuscript = dao.fetch(Manuscript.class, id);
|
||||
List<String> unionAudit = manuscript.getUnion_audit() == null ? new ArrayList<>() : manuscript.getUnion_audit();
|
||||
unionAudit.add(audit.getId());
|
||||
manuscript.setUnion_audit(unionAudit);
|
||||
|
||||
String taskNodeName = "";
|
||||
if (pass == 1) {
|
||||
manuscript.setStateId(2520);
|
||||
taskNodeName = "分工会退回";
|
||||
} else if (pass == 2) {
|
||||
manuscript.setStateId(2515);
|
||||
taskNodeName = "分工会拒绝";
|
||||
} else {
|
||||
manuscript.setStateId(2550);
|
||||
taskNodeName = "分工会通过";
|
||||
}
|
||||
dao.updateIgnoreNull(manuscript);
|
||||
|
||||
String processUniqueId = "MANUSCRIPT@" + manuscript.getId();
|
||||
localProcessService.completeTask(processUniqueId, "2510", taskNodeName, SecurityConstants.INNER);
|
||||
switch (pass) {
|
||||
case 1 -> {
|
||||
// 退回
|
||||
Sql sql = Sqls.create("select loginName from `user` where userId = @id").setParam("id", manuscript.getUserId());
|
||||
sql.setCallback(Sqls.callback.str());
|
||||
dao.execute(sql);
|
||||
String loginName = sql.getString();
|
||||
localProcessService.initCreateTask(
|
||||
processUniqueId,
|
||||
"2520",
|
||||
"分工会退回",
|
||||
List.of(loginName),
|
||||
"/staffService/manuscript/manuscriptMine",
|
||||
null,
|
||||
SecurityConstants.INNER
|
||||
);
|
||||
}
|
||||
case 2 -> {
|
||||
// 拒绝
|
||||
localProcessService.completeProcess(processUniqueId, true, SecurityConstants.INNER);
|
||||
}
|
||||
case 3 -> {
|
||||
// 通过,下一步流程,分工会审核
|
||||
R<List<String>> assignments = localProcessService.getAssignments(null, null, Roles.SCHOOL_ADMIN, SecurityConstants.INNER);
|
||||
List<String> loginNameList = assignments.getData();
|
||||
// 通过,创建后续任务
|
||||
localProcessService.initCreateTask(
|
||||
processUniqueId,
|
||||
"2550",
|
||||
"校工会审核",
|
||||
loginNameList,
|
||||
"/staffService/manuscript/manuscriptSchoolAudit",
|
||||
null,
|
||||
SecurityConstants.INNER
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return AjaxResult.success();
|
||||
}
|
||||
}
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
package com.ruoyi.staffService.manuscript.service;
|
||||
|
||||
import com.ruoyi.common.core.service.BaseService;
|
||||
import org.nutz.lang.util.NutMap;
|
||||
|
||||
/**
|
||||
* @Author JyuHsin
|
||||
* @Date 2023/2/8
|
||||
* @Description
|
||||
*/
|
||||
public interface ManuscriptCommonService extends BaseService {
|
||||
|
||||
/**
|
||||
* 根据id查找
|
||||
*
|
||||
* @param id:
|
||||
* @return org.nutz.lang.util.NutMap
|
||||
* @author JyuHsin
|
||||
* @date 2023/2/8
|
||||
*/
|
||||
NutMap findOne(String id);
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
package com.ruoyi.staffService.manuscript.service;
|
||||
|
||||
import com.ruoyi.common.core.service.BaseService;
|
||||
import com.ruoyi.staffService.api.domain.manuscript.Manuscript;
|
||||
|
||||
/**
|
||||
* @Author JyuHsin
|
||||
* @Date 2023/2/8
|
||||
* @Description
|
||||
*/
|
||||
public interface ManuscriptManageService extends BaseService<Manuscript> {
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
package com.ruoyi.staffService.manuscript.service;
|
||||
|
||||
import com.ruoyi.common.core.service.BaseService;
|
||||
import com.ruoyi.staffService.api.domain.manuscript.ManuscriptType;
|
||||
|
||||
/**
|
||||
* @Author JyuHsin
|
||||
* @Date 2023/2/8
|
||||
* @Description
|
||||
*/
|
||||
public interface ManuscriptTypeService extends BaseService<ManuscriptType> {
|
||||
}
|
||||
+69
@@ -0,0 +1,69 @@
|
||||
package com.ruoyi.staffService.manuscript.service.impl;
|
||||
|
||||
import com.ruoyi.common.core.service.BaseServiceImpl;
|
||||
import com.ruoyi.staffService.api.domain.common.Audit;
|
||||
import com.ruoyi.staffService.manuscript.service.ManuscriptCommonService;
|
||||
import org.nutz.dao.Cnd;
|
||||
import org.nutz.dao.Dao;
|
||||
import org.nutz.dao.Sqls;
|
||||
import org.nutz.dao.sql.Sql;
|
||||
import org.nutz.json.Json;
|
||||
import org.nutz.lang.Strings;
|
||||
import org.nutz.lang.util.NutMap;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* @Author JyuHsin
|
||||
* @Date 2023/2/8
|
||||
* @Description
|
||||
*/
|
||||
@Service
|
||||
public class ManuscriptCommonServiceImpl extends BaseServiceImpl implements ManuscriptCommonService {
|
||||
|
||||
public ManuscriptCommonServiceImpl(Dao dao) {
|
||||
super(dao);
|
||||
}
|
||||
|
||||
@Override
|
||||
public NutMap findOne(String id) {
|
||||
Sql sql = Sqls.create("""
|
||||
SELECT
|
||||
man.*,
|
||||
ty.manuscriptTypeName,
|
||||
us.userName as username,
|
||||
us.loginName as loginname,
|
||||
us.deptName as unitname,
|
||||
us.deptCode as unitcode,
|
||||
us.unionName as unionname,
|
||||
us.unionCode as unioncode,
|
||||
state.stateName
|
||||
FROM
|
||||
`manuscript` man
|
||||
LEFT JOIN manuscript_type ty ON man.manuscriptCode = ty.manuscriptTypeCode
|
||||
LEFT JOIN `user` us ON us.userId = man.userId
|
||||
LEFT JOIN audit_state state ON state.stateId = man.stateId
|
||||
WHERE man.id=@id
|
||||
""").setParam("id", id);
|
||||
|
||||
sql.setCallback(Sqls.callback.map());
|
||||
this.dao().execute(sql);
|
||||
NutMap nutMap = sql.getObject(NutMap.class);
|
||||
|
||||
if (Strings.isNotBlank(nutMap.getString("union_audit"))) {
|
||||
String[] unionAudits = Json.fromJsonAsArray(String.class, nutMap.getString("union_audit"));
|
||||
nutMap.setv("unionAudit", getAudit(unionAudits));
|
||||
}
|
||||
if (Strings.isNotBlank(nutMap.getString("school_union_audit"))) {
|
||||
String[] schoolUnionAudits = Json.fromJsonAsArray(String.class, nutMap.getString("school_union_audit"));
|
||||
nutMap.setv("schoolAudit", getAudit(schoolUnionAudits));
|
||||
}
|
||||
return nutMap;
|
||||
}
|
||||
|
||||
private Object getAudit(String[] unionAudits) {
|
||||
Cnd cnd = Cnd.NEW();
|
||||
cnd.where().andIn("id", unionAudits);
|
||||
cnd.asc("auditTime");
|
||||
return dao().query(Audit.class, cnd);
|
||||
}
|
||||
}
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
package com.ruoyi.staffService.manuscript.service.impl;
|
||||
|
||||
import com.ruoyi.common.core.service.BaseServiceImpl;
|
||||
import com.ruoyi.staffService.api.domain.manuscript.Manuscript;
|
||||
import com.ruoyi.staffService.manuscript.service.ManuscriptManageService;
|
||||
import org.nutz.dao.Dao;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* @Author JyuHsin
|
||||
* @Date 2023/2/8
|
||||
* @Description
|
||||
*/
|
||||
@Service
|
||||
public class ManuscriptManageServiceImpl extends BaseServiceImpl<Manuscript> implements ManuscriptManageService {
|
||||
|
||||
public ManuscriptManageServiceImpl(Dao dao) {
|
||||
super(dao);
|
||||
}
|
||||
}
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
package com.ruoyi.staffService.manuscript.service.impl;
|
||||
|
||||
import com.ruoyi.common.core.service.BaseServiceImpl;
|
||||
import com.ruoyi.staffService.api.domain.manuscript.ManuscriptType;
|
||||
import com.ruoyi.staffService.manuscript.service.ManuscriptTypeService;
|
||||
import org.nutz.dao.Dao;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* @Author JyuHsin
|
||||
* @Date 2023/2/8
|
||||
* @Description
|
||||
*/
|
||||
@Service
|
||||
public class ManuscriptTypeServiceImpl extends BaseServiceImpl<ManuscriptType> implements ManuscriptTypeService {
|
||||
|
||||
public ManuscriptTypeServiceImpl(Dao dao) {
|
||||
super(dao);
|
||||
}
|
||||
}
|
||||
+59
@@ -0,0 +1,59 @@
|
||||
package com.ruoyi.staffService.util;
|
||||
|
||||
import com.baomidou.dynamic.datasource.toolkit.DynamicDataSourceContextHolder;
|
||||
import com.ruoyi.staffService.constant.Ds;
|
||||
import lombok.Getter;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
|
||||
/**
|
||||
* 数据源执行
|
||||
*
|
||||
* @author jug
|
||||
* @date 2022/12/30
|
||||
*/
|
||||
@Getter
|
||||
public class ProModuleDS {
|
||||
|
||||
/**
|
||||
* 执行某个数据源下的业务代码 有返回值 不需要就返回null
|
||||
*
|
||||
* @param ds
|
||||
* @param supplier
|
||||
* @param <T>
|
||||
* @return
|
||||
*/
|
||||
public static <T> T exec(Ds ds, Supplier<T> supplier) {
|
||||
DynamicDataSourceContextHolder.clear();
|
||||
switch (ds) {
|
||||
case STAFFSERVICE -> DynamicDataSourceContextHolder.push("master");
|
||||
case SYSTEM -> DynamicDataSourceContextHolder.push("system");
|
||||
}
|
||||
T t;
|
||||
try {
|
||||
t = supplier.get();
|
||||
DynamicDataSourceContextHolder.clear();
|
||||
return t;
|
||||
} catch (Exception e) {
|
||||
DynamicDataSourceContextHolder.clear();
|
||||
throw new RuntimeException(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public static void execVoid(Ds ds, Runnable runnable) {
|
||||
DynamicDataSourceContextHolder.clear();
|
||||
switch (ds) {
|
||||
case STAFFSERVICE -> DynamicDataSourceContextHolder.push("master");
|
||||
case SYSTEM -> DynamicDataSourceContextHolder.push("system");
|
||||
}
|
||||
try {
|
||||
runnable.run();
|
||||
DynamicDataSourceContextHolder.clear();
|
||||
} catch (Exception e) {
|
||||
DynamicDataSourceContextHolder.clear();
|
||||
throw new RuntimeException(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+299
@@ -0,0 +1,299 @@
|
||||
package com.ruoyi.staffService.welfare.controller;
|
||||
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.NumberUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.ruoyi.common.core.domain.PageForm;
|
||||
import com.ruoyi.common.core.domain.R;
|
||||
import com.ruoyi.common.core.exception.ServiceException;
|
||||
import com.ruoyi.common.core.page.Pagination;
|
||||
import com.ruoyi.common.core.web.domain.AjaxResult;
|
||||
import com.ruoyi.common.security.auth.AuthUtil;
|
||||
import com.ruoyi.common.security.utils.SecurityUtils;
|
||||
import com.ruoyi.staffService.api.domain.welfare.WelfareList;
|
||||
import com.ruoyi.staffService.api.domain.welfare.WelfareMemberChangeRecord;
|
||||
import com.ruoyi.staffService.api.domain.welfare.WelfareProject;
|
||||
import com.ruoyi.staffService.api.domain.welfare.WelfareUnit;
|
||||
import com.ruoyi.staffService.constant.Ds;
|
||||
import com.ruoyi.staffService.util.ProModuleDS;
|
||||
import com.ruoyi.staffService.welfare.service.StaffWelfareMemberService;
|
||||
import com.ruoyi.staffService.welfare.service.StaffWelfareProjectMangeService;
|
||||
import com.ruoyi.system.api.RemoteConfigService;
|
||||
import com.ruoyi.system.api.domain.SysDept;
|
||||
import com.ruoyi.system.api.domain.SysUnion;
|
||||
import com.ruoyi.system.api.domain.SysUser;
|
||||
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.Daos;
|
||||
import org.nutz.dao.util.cri.SqlExpressionGroup;
|
||||
import org.nutz.lang.util.NutMap;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/welfare/common")
|
||||
public class StaffWelfareCommonController {
|
||||
|
||||
@Autowired
|
||||
private Dao dao;
|
||||
|
||||
@Autowired
|
||||
private RemoteConfigService remoteConfigService;
|
||||
|
||||
@Autowired
|
||||
private StaffWelfareMemberService welfareMemberService;
|
||||
|
||||
@Autowired
|
||||
private StaffWelfareProjectMangeService welfareProjectMangeService;
|
||||
|
||||
/**
|
||||
* 福利单位
|
||||
*
|
||||
* @return {@link AjaxResult}
|
||||
*/
|
||||
@GetMapping("/welfareUnit")
|
||||
public AjaxResult welfareUnit() {
|
||||
R<String> welfareUnitModeR = remoteConfigService.selectConfigByKey("WelfareUnitMode");
|
||||
if (welfareUnitModeR.getCode() == R.SUCCESS) {
|
||||
List<WelfareUnit> list = dao.query(WelfareUnit.class, Cnd.where("welfareUnitMode", "=", welfareUnitModeR.getMsg()));
|
||||
return AjaxResult.success(list);
|
||||
} else {
|
||||
throw new ServiceException(welfareUnitModeR.getMsg());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 福利单位的组成单位
|
||||
*
|
||||
* @param welfareUnitId 福利部门id
|
||||
* @return {@link AjaxResult}
|
||||
*/
|
||||
@GetMapping("/componentUnit")
|
||||
public AjaxResult getComponentUnit(String welfareUnitId) {
|
||||
Cnd cnd = Cnd.NEW();
|
||||
// cnd.and(WelfareUnitMode.getMode().getField(), "=", welfareUnitId);
|
||||
cnd.and("welfareUnitId", "=", welfareUnitId);
|
||||
cnd.desc("deptCode");
|
||||
cnd.and("unitLevel", "=", 2);
|
||||
List<SysDept> list = ProModuleDS.exec(Ds.SYSTEM, () -> dao.query(SysDept.class, cnd));
|
||||
return AjaxResult.success(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 不是福利用户
|
||||
*
|
||||
* @param pageForm 页面形式
|
||||
* @param unionId 工会id
|
||||
* @return {@link AjaxResult}
|
||||
*/
|
||||
@PostMapping("/notWelfareMemberUserPageData")
|
||||
public AjaxResult notWelfareMemberUserPageData(@RequestBody PageForm pageForm, @RequestParam(required = false) String unionId, @RequestParam(required = false) Boolean task) {
|
||||
Sql sql = Sqls.create("""
|
||||
select
|
||||
DISTINCT(u.userId) as userId,
|
||||
u.userName,
|
||||
u.loginName,
|
||||
u.sex,
|
||||
u.mobile,
|
||||
u.deptName,
|
||||
u.unionName,
|
||||
u.unionGroupName
|
||||
from
|
||||
`user` u
|
||||
left join welfare_member_change_record wmcr on wmcr.userId = u.userId
|
||||
$condition
|
||||
""");
|
||||
Cnd cnd = Cnd.NEW();
|
||||
cnd.and("u.welfareMember", "=", 0);
|
||||
if (StrUtil.isNotBlank(pageForm.getSearchKeyword())) {
|
||||
SqlExpressionGroup seg = new SqlExpressionGroup();
|
||||
seg.orLike("u.userName", pageForm.getSearchKeyword());
|
||||
seg.orLike("u.loginName", pageForm.getSearchKeyword());
|
||||
cnd.and(seg);
|
||||
}
|
||||
if (task) {
|
||||
cnd.and("wmcr.taskId", "is", null);
|
||||
}
|
||||
|
||||
cnd.asc("u.loginName");
|
||||
sql.setCondition(cnd);
|
||||
Pagination pagination = welfareMemberService.listPageMap(pageForm.getPageNumber(), pageForm.getPageSize(), sql);
|
||||
return AjaxResult.success(pagination);
|
||||
}
|
||||
|
||||
/**
|
||||
* 福利项目
|
||||
*
|
||||
* @param year 年
|
||||
* @return {@link AjaxResult}
|
||||
*/
|
||||
@GetMapping("/welfareProjects")
|
||||
public AjaxResult welfareProjects(@RequestParam(required = false) Integer year) {
|
||||
Cnd cnd = Cnd.NEW();
|
||||
cnd.andEX("year", "=", year);
|
||||
cnd.desc("provideTimeStart");
|
||||
List<WelfareProject> list = welfareProjectMangeService.query(cnd);
|
||||
return AjaxResult.success(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 成员信息
|
||||
*
|
||||
* @param id id
|
||||
* @return {@link AjaxResult}
|
||||
*/
|
||||
@RequestMapping("/memberInfo/{id}")
|
||||
public AjaxResult memberInfo(@PathVariable Long id) {
|
||||
if (!AuthUtil.hasAnyRole("admin,A06,H04,unionGroupLeader") && !SecurityUtils.getUserId().equals(id)) {
|
||||
return AjaxResult.warn("没有权限");
|
||||
}
|
||||
Sql sql = Sqls.create("select * from user where userId = @id");
|
||||
sql.setParam("id", id);
|
||||
NutMap userMap = (NutMap) Daos.query(dao, sql.toString(), Sqls.callback.map());
|
||||
return AjaxResult.success(userMap);
|
||||
}
|
||||
|
||||
/**
|
||||
* 找到单条变更申请信息
|
||||
*
|
||||
* @param recordId 记录
|
||||
* @param userId 用户id
|
||||
* @return {@link AjaxResult}
|
||||
*/
|
||||
@GetMapping("/selectOneChangeRecords")
|
||||
public AjaxResult selectOneChangeRecords(@RequestParam(required = false) String recordId, @RequestParam(required = false) String userId) {
|
||||
if (StrUtil.isAllBlank(recordId, userId)) {
|
||||
return AjaxResult.warn("非法参数");
|
||||
}
|
||||
Cnd cnd = Cnd.NEW();
|
||||
cnd.andEX("id", "=", recordId);
|
||||
cnd.andEX("userId", "=", userId);
|
||||
WelfareMemberChangeRecord record = dao.fetch(WelfareMemberChangeRecord.class, cnd);
|
||||
dao.fetchLinks(record, null);
|
||||
ProModuleDS.exec(Ds.SYSTEM, () -> {
|
||||
record.setOriginUnit(dao.fetch(SysDept.class, record.getOriginUnitId()));
|
||||
record.setOriginUnion(dao.fetch(SysUnion.class, record.getOriginUnionId()));
|
||||
record.setCurrentUnit(dao.fetch(SysDept.class, record.getCurrentUnitId()));
|
||||
record.setCurrentUnion(dao.fetch(SysUnion.class, record.getOriginUnionId()));
|
||||
return null;
|
||||
});
|
||||
return AjaxResult.success(record);
|
||||
}
|
||||
|
||||
/**
|
||||
* 找到多条变更申请信息
|
||||
*
|
||||
* @param userId 用户id
|
||||
* @return {@link AjaxResult}
|
||||
*/
|
||||
@GetMapping("/selectChangeRecords")
|
||||
public AjaxResult selectChangeRecords(@RequestParam String userId) {
|
||||
NutMap userMap = ProModuleDS.exec(Ds.SYSTEM, () -> {
|
||||
Sql sql = Sqls.create("select userName,loginName from `user` where userId = @userId");
|
||||
sql.setParam("userId", userId);
|
||||
return welfareMemberService.fetch(sql);
|
||||
});
|
||||
List<WelfareMemberChangeRecord> records = dao.query(WelfareMemberChangeRecord.class, Cnd.where("userId", "=", userId).desc("applyTime"));
|
||||
for (WelfareMemberChangeRecord record : records) {
|
||||
dao.fetchLinks(record, null);
|
||||
ProModuleDS.exec(Ds.SYSTEM, () -> {
|
||||
record.setOriginThreeUnit(dao.fetch(SysDept.class, record.getOriginThreeUnitId()));
|
||||
record.setOriginUnit(dao.fetch(SysDept.class, record.getOriginUnitId()));
|
||||
record.setOriginUnion(dao.fetch(SysUnion.class, record.getOriginUnionId()));
|
||||
record.setCurrentThreeUnit(dao.fetch(SysDept.class, record.getCurrentThreeUnitId()));
|
||||
record.setCurrentUnit(dao.fetch(SysDept.class, record.getCurrentUnitId()));
|
||||
record.setCurrentUnion(dao.fetch(SysUnion.class, record.getOriginUnionId()));
|
||||
return null;
|
||||
});
|
||||
record.setLoginName(userMap.getString("loginName"));
|
||||
record.setUserName(userMap.getString("userName"));
|
||||
}
|
||||
return AjaxResult.success(records);
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户信息
|
||||
*
|
||||
* @param id id
|
||||
* @return {@link AjaxResult}
|
||||
*/
|
||||
@RequestMapping("/userInfo/{id}")
|
||||
public AjaxResult userInfo(@PathVariable Long id) {
|
||||
if (!AuthUtil.hasAnyRole("admin,A06,H04,unionGroupLeader") && !SecurityUtils.getUserId().equals(id)) {
|
||||
return AjaxResult.warn("没有权限");
|
||||
}
|
||||
SysUser userR = ProModuleDS.exec(Ds.SYSTEM, () -> {
|
||||
SysUser user = dao.fetch(SysUser.class, Cnd.where("userId", "=", id));
|
||||
user.setPassword(null);
|
||||
return user;
|
||||
});
|
||||
return AjaxResult.success(userR);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新成员
|
||||
*
|
||||
* @param user 用户
|
||||
* @return {@link AjaxResult}
|
||||
*/
|
||||
@PostMapping("/updateMember")
|
||||
public AjaxResult updateMember(@RequestBody SysUser user) {
|
||||
if (!AuthUtil.hasAnyRole("admin,A06,H04,unionGroupLeader") && !SecurityUtils.getUserId().equals(user.getUserId())) {
|
||||
return AjaxResult.warn("没有权限");
|
||||
}
|
||||
ProModuleDS.exec(Ds.SYSTEM, () -> dao.updateIgnoreNull(user));
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 补充成员
|
||||
*
|
||||
* @param user 用户
|
||||
* @return {@link AjaxResult}
|
||||
*/
|
||||
@PostMapping("/supplementMember")
|
||||
public AjaxResult supplementMember(@RequestBody SysUser user) {
|
||||
Integer count = ProModuleDS.exec(Ds.SYSTEM, () -> dao.count(SysUser.class, Cnd.where("userName", "=", user.getUserName())));
|
||||
if (count > 0) {
|
||||
return AjaxResult.warn("用户名已存在");
|
||||
}
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 查询当前进行中的福利项目,如果传递userId;查询当前人不在的福利项目
|
||||
*
|
||||
* @param userId
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/listAfootWelfare")
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public AjaxResult listAfootWelfare(@RequestParam(required = false, value = "userId") Long userId) {
|
||||
//找出这个人的福利项目
|
||||
List<WelfareList> welfareListList = dao.query(WelfareList.class, Cnd.where("userId", "=", Convert.convert(String.class, userId)));
|
||||
// 遍历出welfareId
|
||||
Set<String> welfareIdSet = welfareListList.stream().map(WelfareList::getProjectId).collect(Collectors.toSet());
|
||||
// 查询出 当前人员 不在进行中福利项目 的福利项目
|
||||
List<WelfareProject> list = dao.query(WelfareProject.class, Cnd.where("choiceTimeStart", "<=", DateUtil.now())
|
||||
.and("choiceTimeEnd", ">=", DateUtil.now()).and("id", "not in", welfareIdSet));
|
||||
return AjaxResult.success(list);
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping("/insertWelfareList")
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public AjaxResult insertWelfareList(@RequestBody List<WelfareList> welfareList){
|
||||
dao.insert(welfareList);
|
||||
return AjaxResult.success();
|
||||
}
|
||||
}
|
||||
+485
@@ -0,0 +1,485 @@
|
||||
package com.ruoyi.staffService.welfare.controller;
|
||||
|
||||
import cn.afterturn.easypoi.excel.ExcelExportUtil;
|
||||
import cn.afterturn.easypoi.excel.entity.ExportParams;
|
||||
import cn.afterturn.easypoi.excel.entity.params.ExcelExportEntity;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.dynamic.datasource.annotation.DSTransactional;
|
||||
import com.baomidou.dynamic.datasource.toolkit.DynamicDataSourceContextHolder;
|
||||
import com.google.common.base.Joiner;
|
||||
import com.ruoyi.common.core.utils.sql.SqlUtil;
|
||||
import com.ruoyi.common.core.web.domain.AjaxResult;
|
||||
import com.ruoyi.common.security.annotation.RequiresPermissions;
|
||||
import com.ruoyi.common.security.auth.AuthUtil;
|
||||
import com.ruoyi.common.security.utils.DictUtils;
|
||||
import com.ruoyi.common.security.utils.SecurityUtils;
|
||||
import com.ruoyi.member.api.constant.MemberChangeOrigin;
|
||||
import com.ruoyi.member.api.constant.MemberMode;
|
||||
import com.ruoyi.member.api.constant.UserChangeType;
|
||||
import com.ruoyi.staffService.api.constant.welfare.WelfareMemberApplyState;
|
||||
import com.ruoyi.staffService.api.constant.welfare.WelfareMemberChangeApplyState;
|
||||
import com.ruoyi.staffService.api.constant.welfare.WelfareMemberMode;
|
||||
import com.ruoyi.staffService.api.constant.welfare.WelfareMemberPageForm;
|
||||
import com.ruoyi.staffService.api.domain.common.Audit;
|
||||
import com.ruoyi.staffService.api.domain.welfare.WelfareMemberChangeRecord;
|
||||
import com.ruoyi.staffService.api.domain.welfare.WelfareMemberCheckUnionTask;
|
||||
import com.ruoyi.staffService.constant.Ds;
|
||||
import com.ruoyi.staffService.util.ProModuleDS;
|
||||
import com.ruoyi.staffService.welfare.handle.WelfareMemberChangeAuditHandle;
|
||||
import com.ruoyi.staffService.welfare.service.StaffWelfareMemberService;
|
||||
import com.ruoyi.system.api.domain.SysDictData;
|
||||
import com.ruoyi.system.api.domain.SysUser;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.poi.ss.usermodel.Workbook;
|
||||
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.lang.util.NutMap;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.ServletOutputStream;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.net.URLEncoder;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 工会小组审核
|
||||
*
|
||||
* @author jug
|
||||
* @date 2023/05/30
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/welfare/memberBranchUnionCheckTask")
|
||||
@Slf4j
|
||||
public class StaffWelfareMemberBranchUnionCheckTaskController {
|
||||
|
||||
@Autowired
|
||||
private StaffWelfareMemberService welfareMemberService;
|
||||
|
||||
@Autowired
|
||||
private Dao dao;
|
||||
|
||||
@PostMapping("/pageData")
|
||||
@RequiresPermissions("staffService:welfare:branchUnionTask")
|
||||
public AjaxResult pageData(@RequestBody WelfareMemberPageForm pageForm, @RequestParam(required = false) Integer member, @RequestParam(required = false) Boolean changed, @RequestParam(required = false) Integer welfareMember, @RequestParam(required = false) Integer changeType) {
|
||||
Sql sql = Sqls.create("""
|
||||
SELECT
|
||||
u.*,
|
||||
his.id as hisId,
|
||||
his.changeType,
|
||||
his.changeTime,
|
||||
IF
|
||||
( his.id IS NULL, FALSE, TRUE ) hasHis,
|
||||
TRUE AS flag,
|
||||
mcr_state.stateId mcrStateId,
|
||||
mcr_state.stateName mcrStateName,
|
||||
mcr_state.stateColor mcrStateColor,
|
||||
IF(mcr.stateId = @changeUnitAuditing,TRUE,FALSE) changeUnitAuditing,
|
||||
IF(mcr.stateId = @changeUnitError,TRUE,FALSE) changeUnitError
|
||||
FROM
|
||||
`user` u
|
||||
LEFT JOIN user_history_latest his ON his.user_name = u.loginName
|
||||
LEFT JOIN (select * from welfare_member_change_record where (userId,applyTime) in (SELECT userId, MAX( applyTime ) FROM welfare_member_change_record GROUP BY userId)) mcr ON mcr.userId = u.userId
|
||||
LEFT JOIN audit_state mcr_state ON mcr_state.stateId = mcr.stateId
|
||||
$condition
|
||||
""").setParam("changeUnitAuditing", WelfareMemberChangeApplyState.SCHOOL_UNION).setParam("changeUnitError", WelfareMemberChangeApplyState.SCHOOL_UNION_FAIL);
|
||||
//查询出是在审核中还是审核拒绝了
|
||||
|
||||
// LEFT JOIN welfare_member_change_record_latest mcr ON mcr.userId = u.userId
|
||||
|
||||
sql.setVar("states", Joiner.on(",").join(List.of(WelfareMemberApplyState.SCHOOL_UNION_FAIL)));
|
||||
|
||||
Cnd cnd = Cnd.NEW();
|
||||
cnd.andEX("u.personType", "=", pageForm.getPersonType());
|
||||
cnd.andEX("u.userState", "=", pageForm.getUserState());
|
||||
cnd.andEX("u.sex", "=", pageForm.getSex());
|
||||
cnd.andEX("u.unionId", "=", pageForm.getUnionId());
|
||||
cnd.andEX("u.deptId", "=", pageForm.getUnitId());
|
||||
cnd.andEX("u.unionGroupId", "=", pageForm.getUnionGroupId());
|
||||
cnd.andEX("u.threeUnitId", "=", pageForm.getThreeUnitId());
|
||||
|
||||
if (!AuthUtil.hasAnyRoles("admin,A06")) {
|
||||
if (AuthUtil.hasRole("H04")) {
|
||||
cnd.and("u.unionId", "=", SecurityUtils.getUnionId());
|
||||
} else if (AuthUtil.hasRole("unionGroupLeader")) {
|
||||
cnd.and("u.unionId", "=", SecurityUtils.getUnionId());
|
||||
SqlExpressionGroup seg = new SqlExpressionGroup();
|
||||
seg.or("u.unionGroupId", "in", SecurityUtils.getManageUnionGroupIds());
|
||||
seg.or("u.unionGroupId", "is", null);
|
||||
cnd.and(seg);
|
||||
}
|
||||
}
|
||||
|
||||
if (changed != null) {
|
||||
if (changed) {
|
||||
cnd.and(new Static("his.user_name is not null"));
|
||||
} else {
|
||||
cnd.and(new Static("his.user_name is null"));
|
||||
}
|
||||
}
|
||||
|
||||
if (welfareMember != 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);
|
||||
}
|
||||
}
|
||||
|
||||
cnd.andEX("his.changeType", "=", changeType);
|
||||
|
||||
if (StrUtil.isNotBlank(pageForm.getSearchKeyword())) {
|
||||
SqlExpressionGroup seg = new SqlExpressionGroup();
|
||||
seg.orLike("u.userName", pageForm.getSearchKeyword());
|
||||
seg.orLike("u.loginName", pageForm.getSearchKeyword());
|
||||
cnd.and(seg);
|
||||
}
|
||||
cnd.groupBy("u.userId");
|
||||
|
||||
if (StrUtil.isAllNotBlank(pageForm.getPageOrderName(), pageForm.getPageOrderBy())) {
|
||||
cnd.orderBy(pageForm.getPageOrderName(), SqlUtil.getOrderBy(pageForm.getPageOrderBy()));
|
||||
} else {
|
||||
cnd.asc("u.loginName");
|
||||
cnd.desc("his.changeTime");
|
||||
cnd.asc("u.userState");
|
||||
}
|
||||
|
||||
sql.setCondition(cnd);
|
||||
return AjaxResult.success(welfareMemberService.listPageMap(pageForm.getPageNumber(), pageForm.getPageSize(), sql));
|
||||
}
|
||||
|
||||
/**
|
||||
* 提交核对任务至校工会
|
||||
*
|
||||
* @param taskId 任务id
|
||||
* @param unionGroupId 工会小组id
|
||||
* @return {@link AjaxResult}
|
||||
*/
|
||||
@PostMapping("/submitCheck")
|
||||
@RequiresPermissions("staffService:welfare:branchUnionTask")
|
||||
public AjaxResult submitCheck(@RequestParam String taskId, @RequestParam(required = false) String unionGroupId) {
|
||||
Cnd cnd = Cnd.where("taskId", "=", taskId);
|
||||
cnd.and("unionGroupId", "=", unionGroupId);
|
||||
dao.update(WelfareMemberCheckUnionTask.class, Chain.make("isFinish", true), cnd);
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 提交变更人员
|
||||
*
|
||||
* @param record 记录
|
||||
* @return {@link AjaxResult}
|
||||
*/
|
||||
@PostMapping("/doSubmitChangeUser")
|
||||
@RequiresPermissions("staffService:welfare:branchUnionTask")
|
||||
public AjaxResult doSubmitChangeUser(@RequestBody WelfareMemberChangeRecord record) {
|
||||
record.setApplyOrigin(MemberChangeOrigin.UNION_GROUP.getCode());
|
||||
record = WelfareMemberChangeAuditHandle.CREATE.next(record, null);
|
||||
|
||||
Audit audit = new Audit();
|
||||
audit.setAuditPass(true);
|
||||
audit.setAuditOpinion(record.getRemark());
|
||||
WelfareMemberChangeAuditHandle.UNION.next(record, audit);
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 分工会核对任务状态
|
||||
*
|
||||
* @param taskId 任务id
|
||||
* @param unionGroupId 工会小组id
|
||||
* @return {@link AjaxResult}
|
||||
*/
|
||||
@GetMapping("/getUnionTaskStatus")
|
||||
@RequiresPermissions("staffService:welfare:branchUnionTask")
|
||||
public AjaxResult getUnionTaskStatus(@RequestParam String taskId, @RequestParam(required = false) String unionGroupId) {
|
||||
Cnd cnd = Cnd.where("taskId", "=", taskId);
|
||||
cnd.and("unionGroupId", "=", unionGroupId);
|
||||
WelfareMemberCheckUnionTask unionTask = dao.fetch(WelfareMemberCheckUnionTask.class, cnd);
|
||||
boolean status = unionTask != null && unionTask.getIsFinish();
|
||||
return AjaxResult.success(status);
|
||||
}
|
||||
|
||||
/**
|
||||
* 重新核对
|
||||
*
|
||||
* @param taskId 任务id
|
||||
* @return {@link AjaxResult}
|
||||
*/
|
||||
@PostMapping("/checkAgain")
|
||||
@RequiresPermissions("staffService:welfare:branchUnionTask")
|
||||
public AjaxResult checkAgain(@RequestParam String taskId, @RequestParam(required = false) String unionGroupId) {
|
||||
Cnd cnd = Cnd.where("taskId", "=", taskId);
|
||||
cnd.andEX("unionGroupId", "=", unionGroupId);
|
||||
dao.update(WelfareMemberCheckUnionTask.class, Chain.make("isFinish", false), cnd);
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
@PostMapping("/getChangeNumber")
|
||||
@RequiresPermissions("staffService:welfare:branchUnionTask")
|
||||
public AjaxResult getChangeNumber(@RequestBody WelfareMemberPageForm pageForm, @RequestParam(required = false) Integer member, @RequestParam(required = false) Boolean changed, @RequestParam(required = false) Integer welfareMember, @RequestParam(required = false) Integer changeType) {
|
||||
|
||||
Sql sql = Sqls.create("""
|
||||
SELECT
|
||||
(
|
||||
SELECT
|
||||
COUNT( DISTINCT u.userId )
|
||||
FROM
|
||||
`user` u
|
||||
LEFT JOIN user_history_latest his ON his.user_name = u.loginname
|
||||
LEFT JOIN welfare_member_apply_record_latest wmar ON wmar.userId = u.userId
|
||||
LEFT JOIN member_change_record_latest mcr ON mcr.userId = u.userId
|
||||
LEFT JOIN audit_state state ON wmar.stateId = state.stateId
|
||||
LEFT JOIN audit_state mcr_state ON mcr_state.stateId = mcr.stateId
|
||||
$condition
|
||||
) `all`,
|
||||
(
|
||||
SELECT
|
||||
COUNT( DISTINCT u.userId )
|
||||
FROM
|
||||
`user` u
|
||||
LEFT JOIN user_history_latest his ON his.user_name = u.loginname
|
||||
LEFT JOIN welfare_member_apply_record_latest wmar ON wmar.userId = u.userId
|
||||
LEFT JOIN member_change_record_latest mcr ON mcr.userId = u.userId
|
||||
LEFT JOIN audit_state state ON wmar.stateId = state.stateId
|
||||
LEFT JOIN audit_state mcr_state ON mcr_state.stateId = mcr.stateId
|
||||
$condition
|
||||
AND his.user_name IS NOT NULL
|
||||
) have,
|
||||
(
|
||||
SELECT
|
||||
COUNT( DISTINCT u.userId )
|
||||
FROM
|
||||
`user` u
|
||||
LEFT JOIN user_history_latest his ON his.user_name = u.loginname
|
||||
LEFT JOIN welfare_member_apply_record_latest wmar ON wmar.userId = u.userId
|
||||
LEFT JOIN member_change_record_latest mcr ON mcr.userId = u.userId
|
||||
LEFT JOIN audit_state state ON wmar.stateId = state.stateId
|
||||
LEFT JOIN audit_state mcr_state ON mcr_state.stateId = mcr.stateId
|
||||
$condition
|
||||
AND his.user_name IS NULL
|
||||
) `no`
|
||||
""");
|
||||
|
||||
Cnd cnd = Cnd.NEW();
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
cnd.andEX("u.personType", "=", pageForm.getPersonType());
|
||||
cnd.andEX("u.userState", "=", pageForm.getUserState());
|
||||
cnd.andEX("u.sex", "=", pageForm.getSex());
|
||||
cnd.andEX("u.unionId", "=", pageForm.getUnionId());
|
||||
cnd.andEX("u.deptId", "=", pageForm.getUnitId());
|
||||
cnd.andEX("u.unionGroupId", "=", pageForm.getUnionGroupId());
|
||||
cnd.andEX("u.threeUnitId", "=", pageForm.getThreeUnitId());
|
||||
|
||||
if (!AuthUtil.hasAnyRoles("admin,A06")) {
|
||||
if (AuthUtil.hasRole("H04")) {
|
||||
cnd.and("u.unionId", "=", SecurityUtils.getUnionId());
|
||||
} else if (AuthUtil.hasRole("unionGroupLeader")) {
|
||||
cnd.and("u.unionId", "=", SecurityUtils.getUnionId());
|
||||
SqlExpressionGroup seg = new SqlExpressionGroup();
|
||||
seg.or("u.unionGroupId", "in", SecurityUtils.getManageUnionGroupIds());
|
||||
seg.or("u.unionGroupId", "is", null);
|
||||
cnd.and(seg);
|
||||
}
|
||||
}
|
||||
|
||||
cnd.andEX("his.changeType", "=", changeType);
|
||||
sql.setCondition(cnd);
|
||||
NutMap nutMap = welfareMemberService.fetch(sql);
|
||||
return AjaxResult.success(nutMap);
|
||||
}
|
||||
|
||||
/**
|
||||
* 加入福利成员
|
||||
* 关联到核对任务 需要审核
|
||||
*
|
||||
* @param userIds 用户id
|
||||
* @param taskId 任务id
|
||||
* @return {@link AjaxResult}
|
||||
*/
|
||||
@PostMapping("/joinWelfareMember")
|
||||
@RequiresPermissions("staffService:welfare:branchUnionTask")
|
||||
@Transactional
|
||||
public AjaxResult joinWelfareMember(@RequestBody List<Long> userIds, @RequestParam String taskId) {
|
||||
if (AuthUtil.hasAnyRoles("admin,A06")) {
|
||||
welfareMemberService.joinWelfareMember(userIds);
|
||||
return AjaxResult.success();
|
||||
}
|
||||
List<WelfareMemberChangeRecord> maps = new ArrayList<>();
|
||||
Audit audit = new Audit();
|
||||
audit.setAuditPass(true);
|
||||
audit.setAuditTime(new Date());
|
||||
audit.setAuditOpinion("新增福利会员");
|
||||
dao.insert(audit);
|
||||
|
||||
Sql sql = Sqls.create("select userId,deptId,unionId,threeUnitId from `user` where userId in (@userIds)").setParam("userIds", userIds);
|
||||
List<NutMap> userList = (List<NutMap>) welfareMemberService.listMap(sql);
|
||||
|
||||
|
||||
for (Long userId : userIds) {
|
||||
Optional<NutMap> userOptional = userList.stream().filter(v -> v.getLong("userId") == userId).findFirst();
|
||||
|
||||
WelfareMemberChangeRecord changeRecord = new WelfareMemberChangeRecord();
|
||||
changeRecord.setType(UserChangeType.NEW.getCode());
|
||||
changeRecord.setApplyOrigin(MemberChangeOrigin.UNION_GROUP.getCode());
|
||||
changeRecord.setStateId(WelfareMemberChangeApplyState.SCHOOL_UNION);
|
||||
changeRecord.setUpdateWelfareMember(true);
|
||||
changeRecord.setUserId(userId);
|
||||
changeRecord.setApplyTime(new Date());
|
||||
changeRecord.setOriginUnitId(userOptional.map(v -> v.getLong("deptId")).orElse(null));
|
||||
changeRecord.setOriginUnionId(userOptional.map(v -> v.getString("unionId")).orElse(null));
|
||||
changeRecord.setOriginThreeUnitId(userOptional.map(v -> v.getLong("threeUnitId")).orElse(null));
|
||||
changeRecord.setUnionAuditId(audit.getId());
|
||||
changeRecord.setTaskId(taskId);
|
||||
maps.add(changeRecord);
|
||||
}
|
||||
dao.insert(maps);
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 会员新增、编辑
|
||||
*
|
||||
* @param user 用户
|
||||
* @return {@link AjaxResult}
|
||||
*/
|
||||
@PostMapping("/updateWelfareMember")
|
||||
@RequiresPermissions("staffService:welfare:branchUnionTask")
|
||||
@DSTransactional
|
||||
public AjaxResult updateWelfareMember(@RequestBody SysUser user,
|
||||
@RequestParam String taskId,
|
||||
@RequestParam String unionId,
|
||||
@RequestParam Long threeUnitId
|
||||
) {
|
||||
|
||||
user.setMember(user.getMember() == null ? 0 : user.getMember());
|
||||
user.setMember(user.getWelfareMember() == null ? 0 : user.getWelfareMember());
|
||||
|
||||
if (user.getUserId() == null) {
|
||||
ProModuleDS.execVoid(Ds.SYSTEM, () -> dao.insert(user));
|
||||
} else {
|
||||
ProModuleDS.execVoid(Ds.SYSTEM, () -> dao.updateIgnoreNull(user));
|
||||
}
|
||||
|
||||
Audit audit = new Audit();
|
||||
audit.setAuditPass(true);
|
||||
audit.setAuditTime(new Date());
|
||||
audit.setAuditOpinion("新增福利会员");
|
||||
dao.insert(audit);
|
||||
|
||||
WelfareMemberChangeRecord changeRecord = new WelfareMemberChangeRecord();
|
||||
changeRecord.setType(UserChangeType.NEW.getCode());
|
||||
changeRecord.setApplyOrigin(MemberChangeOrigin.UNION_GROUP.getCode());
|
||||
changeRecord.setStateId(WelfareMemberChangeApplyState.SCHOOL_UNION);
|
||||
changeRecord.setUpdateWelfareMember(true);
|
||||
changeRecord.setUserId(user.getUserId());
|
||||
changeRecord.setApplyTime(new Date());
|
||||
changeRecord.setOriginUnitId(user.getDeptId());
|
||||
changeRecord.setOriginUnionId(unionId);
|
||||
changeRecord.setOriginThreeUnitId(threeUnitId);
|
||||
changeRecord.setUnionAuditId(audit.getId());
|
||||
changeRecord.setTaskId(taskId);
|
||||
DynamicDataSourceContextHolder.push("master");
|
||||
dao.insert(changeRecord);
|
||||
DynamicDataSourceContextHolder.clear();
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 导出福利会员
|
||||
*
|
||||
* @param response 响应
|
||||
*/
|
||||
@RequestMapping("/doWelfareMemberExport")
|
||||
@RequiresPermissions("staffService:welfare:branchUnionTask")
|
||||
public void doWelfareMemberExport(HttpServletResponse response,
|
||||
@RequestParam(required = false) String unionId,
|
||||
@RequestParam(required = false) String unitId,
|
||||
@RequestParam(required = false) String unionGroupId,
|
||||
@RequestParam(required = false) String threeUnitId) {
|
||||
try (ServletOutputStream outputStream = response.getOutputStream()) {
|
||||
response.setContentType("application/octet-stream");
|
||||
response.setHeader("Content-Disposition", "attachment;filename=%s".formatted(URLEncoder.encode("福利会员.xlsx", StandardCharsets.UTF_8)));
|
||||
|
||||
Sql sql = Sqls.create("select loginName,userName,userState,unionName,deptName,threeDeptName,unionGroupName from `user` $condition");
|
||||
Cnd cnd = Cnd.NEW();
|
||||
cnd.andEX("unionId", "=", unionId);
|
||||
cnd.andEX("unitId", "=", unitId);
|
||||
cnd.andEX("unionGroupId", "=", unionGroupId);
|
||||
cnd.andEX("threeUnitId", "=", threeUnitId);
|
||||
cnd.and("welfareMember", "=", WelfareMemberMode.NORMAL.getCode());
|
||||
sql.setCondition(cnd);
|
||||
List<NutMap> dataList = welfareMemberService.listMap(sql);
|
||||
List<SysDictData> userStateDicts = DictUtils.getDictCache("user_state");
|
||||
|
||||
for (NutMap map : dataList) {
|
||||
map.put("userStateName", userStateDicts.stream().filter(v -> v.getDictValue().equals(map.getString("userState"))).findFirst().map(v -> v.getDictLabel()).orElse(null));
|
||||
}
|
||||
|
||||
List<ExcelExportEntity> excelExportEntities = new ArrayList<>();
|
||||
excelExportEntities.add(new ExcelExportEntity("工号", "loginName", 20));
|
||||
excelExportEntities.add(new ExcelExportEntity("姓名", "userName", 20));
|
||||
excelExportEntities.add(new ExcelExportEntity("在职状态", "userStateName", 20));
|
||||
excelExportEntities.add(new ExcelExportEntity("所属工会", "unionName", 20));
|
||||
excelExportEntities.add(new ExcelExportEntity("所属单位", "deptName", 20));
|
||||
excelExportEntities.add(new ExcelExportEntity("三级单位", "threeDeptName", 20));
|
||||
excelExportEntities.add(new ExcelExportEntity("工会小组", "unionGroupName", 20));
|
||||
|
||||
ExportParams exportParams = new ExportParams();
|
||||
Workbook workbook = ExcelExportUtil.exportExcel(exportParams, excelExportEntities, dataList);
|
||||
workbook.write(outputStream);
|
||||
} catch (Exception e) {
|
||||
log.error("福利工会小组审核导出福利会员失败{}", e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@PostMapping("/doMemberChange")
|
||||
@RequiresPermissions("staffService:welfare:branchUnionTask")
|
||||
public AjaxResult doMemberChange(@RequestBody WelfareMemberChangeRecord record) {
|
||||
if (Objects.equals(record.getType(), UserChangeType.NEW.getCode())) {
|
||||
return AjaxResult.warn("您已经入职!");
|
||||
}
|
||||
if (Objects.equals(record.getType(), UserChangeType.UNIT_CHANGE.getCode())) {
|
||||
if (record.getCurrentUnitId().equals(record.getOriginUnitId())) {
|
||||
return AjaxResult.warn("请选择不同的单位!");
|
||||
}
|
||||
}
|
||||
welfareMemberService.doMemberChange(record, false);
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
+112
@@ -0,0 +1,112 @@
|
||||
package com.ruoyi.staffService.welfare.controller;
|
||||
|
||||
import cn.hutool.core.lang.Assert;
|
||||
import com.baomidou.dynamic.datasource.annotation.DSTransactional;
|
||||
import com.ruoyi.common.core.domain.PageForm;
|
||||
import com.ruoyi.common.core.web.domain.AjaxResult;
|
||||
import com.ruoyi.common.security.annotation.RequiresPermissions;
|
||||
import com.ruoyi.staffService.api.domain.welfare.WelfareMemberChangeRecord;
|
||||
import com.ruoyi.staffService.api.domain.welfare.WelfareMemberCheckTask;
|
||||
import com.ruoyi.staffService.api.domain.welfare.WelfareMemberCheckUnionTask;
|
||||
import com.ruoyi.staffService.constant.Ds;
|
||||
import com.ruoyi.staffService.util.ProModuleDS;
|
||||
import com.ruoyi.staffService.welfare.service.StaffWelfareMemberService;
|
||||
import com.ruoyi.system.api.domain.SysUnionGroup;
|
||||
import org.nutz.dao.Cnd;
|
||||
import org.nutz.dao.Dao;
|
||||
import org.nutz.dao.Sqls;
|
||||
import org.nutz.dao.sql.Sql;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.Calendar;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/welfare/memberCheckTask")
|
||||
public class StaffWelfareMemberCheckTaskController {
|
||||
|
||||
@Autowired
|
||||
private StaffWelfareMemberService welfareMemberService;
|
||||
|
||||
@Autowired
|
||||
private Dao dao;
|
||||
|
||||
@PostMapping("/pageData")
|
||||
@RequiresPermissions("staffService:welfare:taskManage")
|
||||
public AjaxResult pageData(@RequestBody PageForm pageForm, @RequestParam(required = false) Integer year) {
|
||||
Sql sql = Sqls.create("""
|
||||
select * from welfare_member_check_task $condition
|
||||
""");
|
||||
Cnd cnd = Cnd.NEW();
|
||||
cnd.andEX("year", "=", year);
|
||||
sql.setCondition(cnd);
|
||||
return AjaxResult.success(welfareMemberService.listPageMap(pageForm.getPageNumber(), pageForm.getPageSize(), sql));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 做添加
|
||||
*
|
||||
* @param task 任务
|
||||
* @return {@link AjaxResult}
|
||||
*/
|
||||
@PostMapping("/doAdd")
|
||||
@DSTransactional
|
||||
@RequiresPermissions("staffService:welfare:taskManage")
|
||||
public AjaxResult doAdd(@RequestBody WelfareMemberCheckTask task) {
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.setTime(task.getStartTime());
|
||||
List<SysUnionGroup> sysUnionGroups = ProModuleDS.exec(Ds.SYSTEM, () -> {
|
||||
List<SysUnionGroup> unionGroups = dao.query(SysUnionGroup.class, null);
|
||||
return dao.fetchLinks(unionGroups, null);
|
||||
});
|
||||
|
||||
task.setYear(calendar.get(Calendar.YEAR));
|
||||
dao.insert(task);
|
||||
List<WelfareMemberCheckUnionTask> unionTasks = sysUnionGroups.stream().map(v -> {
|
||||
WelfareMemberCheckUnionTask unionTask = new WelfareMemberCheckUnionTask();
|
||||
unionTask.setTaskId(task.getId());
|
||||
unionTask.setUnionId(v.getId());
|
||||
unionTask.setUnionGroupId(v.getId());
|
||||
unionTask.setUnionId(v.getUnionId());
|
||||
unionTask.setUnionName(v.getSysUnion().getUnionName());
|
||||
unionTask.setUnionCode(v.getSysUnion().getUnionCode());
|
||||
unionTask.setIsFinish(false);
|
||||
return unionTask;
|
||||
}).collect(Collectors.toList());
|
||||
dao.insert(unionTasks);
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
@PostMapping("/doEdit")
|
||||
@RequiresPermissions("staffService:welfare:taskManage")
|
||||
public AjaxResult doEdit(@RequestBody WelfareMemberCheckTask task) {
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.setTime(task.getStartTime());
|
||||
task.setYear(calendar.get(Calendar.YEAR));
|
||||
dao.updateIgnoreNull(task);
|
||||
return null;
|
||||
}
|
||||
|
||||
@PostMapping("/doDelete")
|
||||
@RequiresPermissions("staffService:welfare:taskManage")
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public AjaxResult doDelete(@RequestParam String id) {
|
||||
Assert.notBlank(id);
|
||||
dao.clear(WelfareMemberCheckTask.class, Cnd.where("id", "=", id));
|
||||
dao.clear(WelfareMemberCheckUnionTask.class, Cnd.where("taskId", "=", id));
|
||||
dao.clear(WelfareMemberChangeRecord.class, Cnd.where("taskId", "=", id));
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
@PostMapping("/getAllTask")
|
||||
public AjaxResult getAllTask(@RequestParam(required = false) Integer year) {
|
||||
Cnd cnd = Cnd.NEW();
|
||||
cnd.andEX("year", "=", year);
|
||||
return AjaxResult.success(dao.query(WelfareMemberCheckTask.class, cnd));
|
||||
}
|
||||
|
||||
}
|
||||
+113
@@ -0,0 +1,113 @@
|
||||
package com.ruoyi.staffService.welfare.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 com.ruoyi.common.core.domain.R;
|
||||
import com.ruoyi.common.core.web.domain.AjaxResult;
|
||||
import com.ruoyi.staffService.api.constant.welfare.WelfareMemberListPageForm;
|
||||
import com.ruoyi.staffService.api.domain.welfare.WelfareProject;
|
||||
import com.ruoyi.staffService.welfare.service.StaffWelfareMemberListGrantSummaryService;
|
||||
import com.ruoyi.staffService.welfare.service.StaffWelfareMemberListService;
|
||||
import com.ruoyi.staffService.welfare.service.StaffWelfareProjectMangeService;
|
||||
import com.ruoyi.system.api.RemoteConfigService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.poi.ss.usermodel.Workbook;
|
||||
import org.nutz.lang.util.NutMap;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.ServletOutputStream;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.net.URLEncoder;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 发放名单汇总
|
||||
*
|
||||
* @author jug
|
||||
* @date 2023/02/10
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/welfare/list/grantSummary")
|
||||
@Slf4j
|
||||
public class StaffWelfareMemberListGrantSummaryController {
|
||||
|
||||
@Autowired
|
||||
private StaffWelfareProjectMangeService projectMangeService;
|
||||
|
||||
@Autowired
|
||||
private StaffWelfareMemberListGrantSummaryService grantSummaryService;
|
||||
|
||||
@Autowired
|
||||
private RemoteConfigService remoteConfigService;
|
||||
|
||||
@Autowired
|
||||
private StaffWelfareMemberListService welfareMemberListService;
|
||||
|
||||
/**
|
||||
* 页面数据
|
||||
*
|
||||
* @param projectId 项目id
|
||||
* @return {@link AjaxResult}
|
||||
*/
|
||||
@PostMapping("/pageData")
|
||||
public AjaxResult pageData(@RequestParam String projectId) {
|
||||
return AjaxResult.success(grantSummaryService.pageData(projectId));
|
||||
}
|
||||
|
||||
@PostMapping("/userPageData")
|
||||
public AjaxResult userPageData(@RequestBody WelfareMemberListPageForm pageForm) {
|
||||
return AjaxResult.success(welfareMemberListService.pageData(pageForm));
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出
|
||||
*
|
||||
* @param projectId 项目id
|
||||
* @param response 响应
|
||||
*/
|
||||
@PostMapping("/exportWelfareListSummary")
|
||||
public void exportWelfareListSummary(@RequestParam String projectId, HttpServletResponse response) {
|
||||
try (ServletOutputStream outputStream = response.getOutputStream()) {
|
||||
NutMap nutMap = grantSummaryService.pageData(projectId);
|
||||
List<NutMap> tableList = nutMap.getList("tableList", NutMap.class);
|
||||
List<NutMap> tableColumn = nutMap.getList("tableColumn", NutMap.class);
|
||||
|
||||
List<ExcelExportEntity> exportEntityList = new ArrayList<>();
|
||||
|
||||
R<String> welfareUnitModeR = remoteConfigService.selectConfigByKey("WelfareUnitMode");
|
||||
if (welfareUnitModeR.getCode() == R.SUCCESS) {
|
||||
String welfareMode = welfareUnitModeR.getMsg();
|
||||
if (welfareMode.equals("UNION")) {
|
||||
exportEntityList.add(new ExcelExportEntity("分工会", "welfareUnitName", 30));
|
||||
} else {
|
||||
exportEntityList.add(new ExcelExportEntity("福利单位", "welfareUnitName", 30));
|
||||
}
|
||||
}
|
||||
tableColumn.forEach(v -> {
|
||||
exportEntityList.add(new ExcelExportEntity(v.getString("label"), v.getString("prop"), 20));
|
||||
});
|
||||
exportEntityList.add(new ExcelExportEntity("合计", "totalNum"));
|
||||
|
||||
WelfareProject project = projectMangeService.fetch(projectId);
|
||||
String fileName = project.getName().concat("发放表");
|
||||
|
||||
ExportParams exportParams = new ExportParams();
|
||||
exportParams.setType(ExcelType.XSSF);
|
||||
exportParams.setTitle(project.getName());
|
||||
Workbook workbook = ExcelExportUtil.exportExcel(exportParams, exportEntityList, tableList);
|
||||
response.setContentType("application/octet-stream");
|
||||
response.setHeader("Content-Disposition", "attachment;filename=%s".formatted(URLEncoder.encode(fileName + ".xlsx", StandardCharsets.UTF_8)));
|
||||
workbook.write(outputStream);
|
||||
workbook.close();
|
||||
} catch (Exception e) {
|
||||
log.error("导出签字表失败{}", e.getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
+290
@@ -0,0 +1,290 @@
|
||||
package com.ruoyi.staffService.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.io.FileUtil;
|
||||
import cn.hutool.core.lang.Assert;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.deepoove.poi.XWPFTemplate;
|
||||
import com.deepoove.poi.config.Configure;
|
||||
import com.deepoove.poi.plugin.table.LoopRowTableRenderPolicy;
|
||||
import com.ruoyi.common.core.constant.Constants;
|
||||
import com.ruoyi.common.core.page.Pagination;
|
||||
import com.ruoyi.common.core.web.domain.AjaxResult;
|
||||
import com.ruoyi.common.security.annotation.RequiresPermissions;
|
||||
import com.ruoyi.staffService.api.constant.welfare.WelfareMemberListPageForm;
|
||||
import com.ruoyi.staffService.api.domain.welfare.WelfareMemberSupermarket;
|
||||
import com.ruoyi.staffService.api.domain.welfare.WelfareProjectSubject;
|
||||
import com.ruoyi.staffService.api.domain.welfare.WelfareProjectSubjectOption;
|
||||
import com.ruoyi.staffService.api.domain.welfare.WelfareUserSelection;
|
||||
import com.ruoyi.staffService.welfare.service.StaffWelfareMemberListService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.poi.ss.usermodel.Workbook;
|
||||
import org.nutz.dao.Chain;
|
||||
import org.nutz.dao.Cnd;
|
||||
import org.nutz.dao.Dao;
|
||||
import org.nutz.lang.util.NutMap;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.ServletOutputStream;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.InputStream;
|
||||
import java.net.URLDecoder;
|
||||
import java.net.URLEncoder;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 福利名单管理
|
||||
*
|
||||
* @author jug
|
||||
* @date 2023/02/09
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/welfare/memberList")
|
||||
@Slf4j
|
||||
public class StaffWelfareMemberListManageController {
|
||||
|
||||
@Autowired
|
||||
private StaffWelfareMemberListService welfareMemberListService;
|
||||
|
||||
/**
|
||||
* 页面数据
|
||||
*
|
||||
* @param pageForm 页面形式
|
||||
* @return {@link AjaxResult}
|
||||
*/
|
||||
@PostMapping("/pageData")
|
||||
@RequiresPermissions("staffService:welfare:list:memberList")
|
||||
public AjaxResult pageData(@RequestBody WelfareMemberListPageForm pageForm) {
|
||||
if(StrUtil.isNotBlank(pageForm.getProjectId())){
|
||||
Pagination pagination = welfareMemberListService.pageData(pageForm);
|
||||
return AjaxResult.success(pagination);
|
||||
}
|
||||
return AjaxResult.success(new Pagination());
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送消息至未填写地址人员
|
||||
*
|
||||
* @param projectId 项目id
|
||||
* @return {@link AjaxResult}
|
||||
*/
|
||||
@PostMapping("/sendMsgToNotWriteAddressUsers")
|
||||
@RequiresPermissions("staffService:welfare:list:memberList")
|
||||
public AjaxResult sendMsgToNotWriteAddressUsers(@RequestParam String projectId) {
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 领取
|
||||
*
|
||||
* @param userIds 用户id
|
||||
* @param projectId 项目id
|
||||
* @return {@link AjaxResult}
|
||||
*/
|
||||
@PostMapping("/doReceive")
|
||||
@RequiresPermissions("staffService:welfare:list:memberList")
|
||||
public AjaxResult doReceive(@RequestBody List<Long> userIds, @RequestParam String projectId) {
|
||||
Chain chain = Chain.make("isReceive", true);
|
||||
welfareMemberListService.update(chain, Cnd.where("projectId", "=", projectId).and("userId", "in", userIds));
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 一键领取
|
||||
*
|
||||
* @param projectId
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/doOneKeyReceive")
|
||||
@RequiresPermissions("staffService:welfare:list:memberList")
|
||||
public AjaxResult doOneKeyReceive(@RequestParam String projectId) {
|
||||
Assert.notBlank(projectId);
|
||||
welfareMemberListService.update(Chain.make("isReceive", true), Cnd.where("projectId", "=", projectId));
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
@GetMapping("/welfareOptions")
|
||||
@RequiresPermissions("staffService:welfare:list:memberList")
|
||||
public AjaxResult welfareOptions(String projectId) {
|
||||
List<WelfareProjectSubject> subjects = welfareMemberListService.dao().query(WelfareProjectSubject.class, Cnd.where("projectId", "=", projectId));
|
||||
List<String> subjectIds = subjects.stream().map(v -> v.getId()).collect(Collectors.toList());
|
||||
return AjaxResult.success(welfareMemberListService.dao().query(WelfareProjectSubjectOption.class, Cnd.where("subjectId", "in", subjectIds).asc("optionSort")));
|
||||
}
|
||||
|
||||
@PostMapping("/doEditWelfareData")
|
||||
@RequiresPermissions("staffService:welfare:list:memberList")
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Object doEditWelfareData(@RequestParam(value = "optionIds[]", required = false) String[] optionIds, String projectId, String userId, String receiveAddress) throws Exception{
|
||||
String StrReceiveAddress = URLDecoder.decode(receiveAddress, Constants.UTF8);
|
||||
Dao dao = welfareMemberListService.dao();
|
||||
List<WelfareProjectSubjectOption> subjectOptions = dao.query(WelfareProjectSubjectOption.class, Cnd.where("id", "in", optionIds));
|
||||
Map<String, String> subjectMap = subjectOptions.stream().collect(Collectors.toMap(v -> v.getId(), v -> v.getSubjectId()));
|
||||
|
||||
WelfareUserSelection userSelection = dao.fetch(WelfareUserSelection.class, Cnd.where("welfareId", "=", projectId).and("selectUserId", "=", userId));
|
||||
String userSign = Optional.ofNullable(userSelection).map(v -> v.getUserSign()).orElse(null);
|
||||
|
||||
dao.clear(WelfareUserSelection.class, Cnd.where("welfareId", "=", projectId).and("selectUserId", "=", userId));
|
||||
List<WelfareUserSelection> userSelections = Arrays.stream(optionIds).map(v -> {
|
||||
WelfareUserSelection selection = new WelfareUserSelection();
|
||||
selection.setSelectTime(new Date());
|
||||
selection.setWelfareId(projectId);
|
||||
selection.setSelectUserId(userId);
|
||||
selection.setSelectOptionId(v);
|
||||
selection.setReceiveAddress(StrReceiveAddress);
|
||||
selection.setSubjectId(subjectMap.get(v));
|
||||
selection.setIsReceive(false);
|
||||
selection.setUserSign(userSign);
|
||||
return selection;
|
||||
}).collect(Collectors.toList());
|
||||
dao.insert(userSelections);
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 导出签字表
|
||||
*
|
||||
* @param userTypes 用户类型
|
||||
* @param projectId 项目id
|
||||
* @return {@link AjaxResult}
|
||||
*/
|
||||
@PostMapping("/exportSign")
|
||||
@RequiresPermissions("staffService:welfare:list:memberList")
|
||||
public void exportSign(@RequestBody List<String> userTypes, @RequestParam String projectId, HttpServletResponse response) {
|
||||
try (InputStream inputStream = Thread.currentThread().getContextClassLoader().getResourceAsStream("docTemplate/welfare/sign.docx"); ServletOutputStream outputStream = response.getOutputStream()) {
|
||||
NutMap renderMap = welfareMemberListService.exportSign(userTypes, projectId);
|
||||
response.setContentType("application/octet-stream");
|
||||
response.setHeader("Content-Disposition", "attachment;filename=%s".formatted(URLEncoder.encode(renderMap.getString("projectName") + "发放名单.docx", StandardCharsets.UTF_8)));
|
||||
LoopRowTableRenderPolicy policy = new LoopRowTableRenderPolicy();
|
||||
Configure config = Configure.builder().bind("users", policy).build();
|
||||
assert inputStream != null;
|
||||
XWPFTemplate.compile(inputStream, config).render(renderMap, outputStream);
|
||||
} catch (Exception e) {
|
||||
log.error("导出签字表失败{}", e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出福利名单
|
||||
*
|
||||
* @param projectId 项目id
|
||||
* @param response 响应
|
||||
*/
|
||||
@PostMapping("/exportUserList")
|
||||
@RequiresPermissions("staffService:welfare:list:memberList")
|
||||
public void exportUserList(@RequestParam String projectId, HttpServletResponse response) {
|
||||
try (ServletOutputStream outputStream = response.getOutputStream()) {
|
||||
List<NutMap> list = welfareMemberListService.exportUserList(projectId);
|
||||
ExportParams exportParams = new ExportParams();
|
||||
exportParams.setType(ExcelType.XSSF);
|
||||
|
||||
List<ExcelExportEntity> entityList = new ArrayList<>();
|
||||
entityList.add(new ExcelExportEntity("工号", "loginName", 20));
|
||||
entityList.add(new ExcelExportEntity("姓名", "userName", 20));
|
||||
entityList.add(new ExcelExportEntity("人员类型", "personType", 20));
|
||||
entityList.add(new ExcelExportEntity("在职状态", "userState", 20));
|
||||
entityList.add(new ExcelExportEntity("所属工会", "unionName", 20));
|
||||
entityList.add(new ExcelExportEntity("所属单位", "deptName", 20));
|
||||
entityList.add(new ExcelExportEntity("所属校区", "campus", 20));
|
||||
|
||||
Workbook workbook = ExcelExportUtil.exportExcel(exportParams, entityList, list);
|
||||
response.setContentType("application/octet-stream");
|
||||
response.setHeader("Content-Disposition", "attachment;filename=%s".formatted(URLEncoder.encode("福利名单.xlsx", StandardCharsets.UTF_8)));
|
||||
workbook.write(outputStream);
|
||||
workbook.close();
|
||||
} catch (Exception e) {
|
||||
log.error("导出福利名单{}", e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除福利名单
|
||||
*
|
||||
* @param listId id列表
|
||||
* @return {@link AjaxResult}
|
||||
*/
|
||||
@PostMapping("/doDelete")
|
||||
@RequiresPermissions("staffService:welfare:list:memberList")
|
||||
public AjaxResult doDelete(@RequestParam String listId) {
|
||||
welfareMemberListService.doDelete(listId);
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 导入超市卡信息
|
||||
*
|
||||
* @param file 文件
|
||||
* @param welfareId 福利id
|
||||
* @return {@link AjaxResult}
|
||||
*/
|
||||
@RequestMapping("/importSuperMarketCard")
|
||||
@RequiresPermissions("staffService:welfare:list:memberList")
|
||||
@Transactional
|
||||
public AjaxResult importSuperMarketCard(@RequestParam MultipartFile file, @RequestParam("welfareId") String welfareId) {
|
||||
String originalFilename = file.getOriginalFilename();
|
||||
String extName = FileUtil.extName(originalFilename);
|
||||
assert extName != null;
|
||||
if (!extName.equalsIgnoreCase("xls") && !extName.equalsIgnoreCase("xlsx")) {
|
||||
return AjaxResult.warn("请上传xls/xlsx文件");
|
||||
}
|
||||
try {
|
||||
List<WelfareMemberSupermarket> cardList = ExcelImportUtil.importExcel(file.getInputStream(), WelfareMemberSupermarket.class, new ImportParams());
|
||||
boolean isBlankData = cardList.stream().anyMatch(v -> StrUtil.isBlank(v.getCardNo()) || StrUtil.isBlank(v.getCardPassWord()));
|
||||
if (isBlankData) {
|
||||
return AjaxResult.warn("请检查是否有为空的卡号、密码行!");
|
||||
}
|
||||
|
||||
welfareMemberListService.dao().clear(WelfareMemberSupermarket.class, Cnd.where("welfareId", "=", welfareId));
|
||||
List<String> userIds = welfareMemberListService.userIds(welfareId);
|
||||
if (cardList.size() < userIds.size()) {
|
||||
return AjaxResult.warn("当前福利会员共有" + userIds.size() + "人,您导入的卡号不够分配,请重新导入 !");
|
||||
}
|
||||
for (int i = 0; i < cardList.size(); i++) {
|
||||
if (i >= userIds.size()) {
|
||||
break;
|
||||
}
|
||||
cardList.get(i).setUserId(userIds.get(i));
|
||||
cardList.get(i).setWelfareId(welfareId);
|
||||
}
|
||||
List<WelfareMemberSupermarket> filterSuperMarkerList = cardList.stream().filter(v -> StrUtil.isNotBlank(v.getUserId())).collect(Collectors.toList());
|
||||
welfareMemberListService.dao().insert(filterSuperMarkerList);
|
||||
return AjaxResult.success();
|
||||
} catch (Exception e) {
|
||||
return AjaxResult.warn("福利商超卡导入失败" + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出超市卡模板
|
||||
*
|
||||
* @return {@link AjaxResult}
|
||||
*/
|
||||
@RequestMapping("/exportSuperMarketCardTemplate")
|
||||
@RequiresPermissions("staffService:welfare:list:memberList")
|
||||
public void exportSuperMarketCardTemplate(HttpServletResponse response) {
|
||||
try (ServletOutputStream outputStream = response.getOutputStream()) {
|
||||
List<WelfareMemberSupermarket> dataList = new ArrayList<>();
|
||||
dataList.add(new WelfareMemberSupermarket().setCardNo("test001").setCardPassWord("123456"));
|
||||
ExportParams exportParams = new ExportParams();
|
||||
exportParams.setType(ExcelType.XSSF);
|
||||
Workbook workbook = ExcelExportUtil.exportExcel(exportParams, WelfareMemberSupermarket.class, dataList);
|
||||
response.setContentType("application/octet-stream");
|
||||
response.setHeader("Content-Disposition", "attachment;filename=%s".formatted(URLEncoder.encode("模板信息.xlsx", StandardCharsets.UTF_8)));
|
||||
workbook.write(outputStream);
|
||||
workbook.close();
|
||||
} catch (Exception e) {
|
||||
log.error("福利商超卡模板信息导出失败{}", e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+197
@@ -0,0 +1,197 @@
|
||||
package com.ruoyi.staffService.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 com.baomidou.dynamic.datasource.toolkit.DynamicDataSourceContextHolder;
|
||||
import com.ruoyi.common.core.page.Pagination;
|
||||
import com.ruoyi.common.core.web.domain.AjaxResult;
|
||||
import com.ruoyi.common.security.annotation.Logical;
|
||||
import com.ruoyi.common.security.annotation.RequiresPermissions;
|
||||
import com.ruoyi.member.api.constant.*;
|
||||
import com.ruoyi.member.api.domain.MemberChangeRecord;
|
||||
import com.ruoyi.staffService.api.constant.welfare.WelfareMemberPageForm;
|
||||
import com.ruoyi.staffService.api.domain.common.Audit;
|
||||
import com.ruoyi.staffService.constant.Ds;
|
||||
import com.ruoyi.staffService.util.ProModuleDS;
|
||||
import com.ruoyi.staffService.welfare.service.StaffWelfareMemberService;
|
||||
import com.ruoyi.system.api.domain.SysDept;
|
||||
import com.ruoyi.system.api.domain.SysUser;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.poi.ss.usermodel.Workbook;
|
||||
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.Daos;
|
||||
import org.nutz.lang.util.NutMap;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.ServletOutputStream;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.net.URLEncoder;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
||||
/**
|
||||
* 福利会员台账
|
||||
*
|
||||
* @author jug
|
||||
* @date 2023/02/09
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/welfare/memberManage")
|
||||
@Slf4j
|
||||
public class StaffWelfareMemberManageController {
|
||||
|
||||
@Autowired
|
||||
private StaffWelfareMemberService welfareMemberService;
|
||||
|
||||
@Autowired
|
||||
private Dao dao;
|
||||
|
||||
/**
|
||||
* 页面数据
|
||||
*
|
||||
* @param pageForm 页面形式
|
||||
* @return {@link AjaxResult}
|
||||
*/
|
||||
@PostMapping("/pageData")
|
||||
@RequiresPermissions("staffService:welfare:memberManage")
|
||||
public AjaxResult pageData(@RequestBody WelfareMemberPageForm pageForm) {
|
||||
Pagination pagination = welfareMemberService.pageData(pageForm);
|
||||
return AjaxResult.success(pagination);
|
||||
}
|
||||
|
||||
/**
|
||||
* 加入福利成员
|
||||
*
|
||||
* @param userIds 用户id
|
||||
* @return {@link AjaxResult}
|
||||
*/
|
||||
@PostMapping("/joinWelfareMember")
|
||||
@RequiresPermissions(value = {"staffService:welfare:memberManage", "staffService:welfare:memberSeniorManage"}, logical = Logical.OR)
|
||||
public AjaxResult joinWelfareMember(@RequestBody List<Long> userIds) {
|
||||
welfareMemberService.joinWelfareMember(userIds);
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 取消福利成员
|
||||
*
|
||||
* @param userIds 用户id
|
||||
* @return {@link AjaxResult}
|
||||
*/
|
||||
@PostMapping("/kickWelfareMember")
|
||||
@RequiresPermissions("staffService:welfare:memberManage")
|
||||
public AjaxResult kickWelfareMember(@RequestBody List<Long> userIds) {
|
||||
welfareMemberService.kickWelfareMember(userIds);
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 会员编辑
|
||||
*
|
||||
* @param user 用户
|
||||
* @return {@link AjaxResult}
|
||||
*/
|
||||
@PostMapping("/updateWelfareMember")
|
||||
@RequiresPermissions("staffService:welfare:memberManage")
|
||||
public AjaxResult updateWelfareMember(@RequestBody SysUser user) {
|
||||
welfareMemberService.addNewWelfareMember(user);
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量修改校区
|
||||
*
|
||||
* @param sysUsers 系统用户
|
||||
* @return {@link AjaxResult}
|
||||
*/
|
||||
@PostMapping("/batchModifyCampus")
|
||||
@RequiresPermissions("staffService:welfare:memberManage")
|
||||
public AjaxResult batchModifyCampus(@RequestBody List<SysUser> sysUsers) {
|
||||
DynamicDataSourceContextHolder.push("system");
|
||||
welfareMemberService.dao().update(sysUsers, "campus");
|
||||
DynamicDataSourceContextHolder.clear();
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 下载模板
|
||||
*
|
||||
* @param response 响应
|
||||
* @return {@link AjaxResult}
|
||||
*/
|
||||
@PostMapping("/downLoadTemplate")
|
||||
@RequiresPermissions("staffService:welfare:memberManage")
|
||||
public void downLoadTemplate(HttpServletResponse response) {
|
||||
try (ServletOutputStream outputStream = response.getOutputStream()) {
|
||||
ExportParams exportParams = new ExportParams();
|
||||
exportParams.setType(ExcelType.XSSF);
|
||||
|
||||
List<ExcelExportEntity> entityList = new ArrayList<>();
|
||||
entityList.add(new ExcelExportEntity("工号", "loginName", 20));
|
||||
entityList.add(new ExcelExportEntity("姓名", "userName", 20));
|
||||
entityList.add(new ExcelExportEntity("福利发放单位", "welfareUnitName", 20));
|
||||
// entityList.add(new ExcelExportEntity("福利缴费类型", "welfarePayType", 20));
|
||||
|
||||
List<NutMap> list = new ArrayList<>();
|
||||
list.add(NutMap.NEW().addv("loginName", "123").addv("userName", "张三").addv("welfareUnitName", "图书馆"));
|
||||
|
||||
Workbook workbook = ExcelExportUtil.exportExcel(exportParams, entityList, list);
|
||||
response.setContentType("application/octet-stream");
|
||||
response.setHeader("Content-Disposition", "attachment;filename=%s".formatted(URLEncoder.encode("模板.xlsx", StandardCharsets.UTF_8)));
|
||||
workbook.write(outputStream);
|
||||
workbook.close();
|
||||
} catch (Exception e) {
|
||||
log.error("下载模板失败{}", e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@PostMapping("/importWelfareList")
|
||||
@RequiresPermissions("staffService:welfare:memberManage")
|
||||
public AjaxResult importWelfareList(@RequestParam MultipartFile file, boolean isfg) {
|
||||
try {
|
||||
List<WelfareMemberTemp> list = ExcelImportUtil.importExcel(file.getInputStream(), WelfareMemberTemp.class, new ImportParams());
|
||||
List<String> loginNames = list.stream().map(WelfareMemberTemp::getLoginName).filter(StrUtil::isNotBlank).collect(Collectors.toList());
|
||||
if (isfg) {
|
||||
ProModuleDS.execVoid(Ds.SYSTEM, () -> dao.execute(Sqls.create("update sys_user set welfareMember=0")));
|
||||
}
|
||||
Sql sql = Sqls.create("select userId from `user` where loginName in (@loginNames)");
|
||||
sql.setParam("loginNames", loginNames);
|
||||
String[] userIds = (String[]) Daos.query(dao, sql.toString(), Sqls.callback.strs());
|
||||
welfareMemberService.joinWelfareMember(Arrays.stream(userIds).map(Long::valueOf).collect(Collectors.toList()));
|
||||
return AjaxResult.success();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return AjaxResult.warn(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 同步会员名单
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/syncMember")
|
||||
@RequiresPermissions("staffService:welfare:memberManage")
|
||||
public AjaxResult syncMember(){
|
||||
welfareMemberService.syncMember();
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
+219
@@ -0,0 +1,219 @@
|
||||
package com.ruoyi.staffService.welfare.controller;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.dynamic.datasource.toolkit.DynamicDataSourceContextHolder;
|
||||
import com.ruoyi.common.core.domain.PageForm;
|
||||
import com.ruoyi.common.core.utils.sql.SqlUtil;
|
||||
import com.ruoyi.common.core.web.domain.AjaxResult;
|
||||
import com.ruoyi.common.security.annotation.RequiresPermissions;
|
||||
import com.ruoyi.staffService.api.constant.welfare.WelfareMemberChangeApplyState;
|
||||
import com.ruoyi.staffService.api.domain.common.Audit;
|
||||
import com.ruoyi.staffService.api.domain.welfare.WelfareMemberChangeRecord;
|
||||
import com.ruoyi.staffService.constant.Ds;
|
||||
import com.ruoyi.staffService.util.ProModuleDS;
|
||||
import com.ruoyi.staffService.welfare.handle.WelfareMemberChangeAuditHandle;
|
||||
import com.ruoyi.staffService.welfare.service.StaffWelfareMemberService;
|
||||
import com.ruoyi.system.api.domain.SysDept;
|
||||
import org.nutz.dao.Cnd;
|
||||
import org.nutz.dao.Dao;
|
||||
import org.nutz.dao.Sqls;
|
||||
import org.nutz.dao.sql.Sql;
|
||||
import org.nutz.lang.Lang;
|
||||
import org.nutz.lang.util.NutMap;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/welfare/memberSchoolUnionCheckTask")
|
||||
public class StaffWelfareMemberSchoolUnionCheckTaskController {
|
||||
|
||||
@Autowired
|
||||
private StaffWelfareMemberService welfareMemberService;
|
||||
|
||||
@Autowired
|
||||
private Dao dao;
|
||||
|
||||
@PostMapping("/pageData")
|
||||
@RequiresPermissions("staffService:welfare:schoolUnionTask")
|
||||
public AjaxResult pageData(@RequestBody PageForm pageForm,
|
||||
@RequestParam String taskId,
|
||||
@RequestParam(required = false) String unionId,
|
||||
@RequestParam(required = false) String unitId) {
|
||||
Sql sql = Sqls.create("""
|
||||
SELECT
|
||||
mcut.unionId,
|
||||
mcut.unionName,
|
||||
mcut.unionCode,
|
||||
mcut.isFinish,
|
||||
IF(mcut.isFinish is true,'是','否') as isFinishText,
|
||||
sum( CASE WHEN u.welfareMember = 1 THEN 1 ELSE 0 END ) AS memberNum,
|
||||
(SELECT count( 1 ) FROM welfare_member_change_record mcr WHERE mcr.originUnionId = mcut.unionId AND mcr.taskId = mcut.taskId AND mcr.stateId = @stateId) as notCheckNum,
|
||||
(SELECT COUNT( 1 ) FROM welfare_member_check_union_task WHERE unionid = gh.id and taskId = @taskId ) unionGroupNum,
|
||||
(SELECT COUNT( 1 ) FROM welfare_member_check_union_task WHERE isFinish = 1 AND unionid = gh.id and taskId = @taskId ) hasCheckUnionGroupNum,
|
||||
(SELECT COUNT( 1 ) FROM welfare_member_check_union_task WHERE isFinish = 0 AND unionid = gh.id and taskId = @taskId ) notCheckUnionGroupNum
|
||||
|
||||
FROM
|
||||
welfare_member_check_union_task mcut
|
||||
LEFT JOIN `user` u ON u.unionId = mcut.unionId
|
||||
LEFT JOIN (select distinct unionId as id from welfare_member_check_union_task where taskId = @taskId) gh on gh.id = mcut.unionId
|
||||
$condition
|
||||
""");
|
||||
sql.setParam("stateId", WelfareMemberChangeApplyState.SCHOOL_UNION);
|
||||
sql.setParam("taskId", taskId);
|
||||
Cnd cnd = Cnd.NEW();
|
||||
cnd.andEX("mcut.unionId", "=", unionId);
|
||||
cnd.and("mcut.taskId", "=", taskId);
|
||||
cnd.groupBy("mcut.unionId");
|
||||
if (StrUtil.isAllNotBlank(pageForm.getPageOrderName(), pageForm.getPageOrderBy())) {
|
||||
cnd.orderBy(pageForm.getPageOrderName(), SqlUtil.getOrderBy(pageForm.getPageOrderBy()));
|
||||
} else {
|
||||
cnd.asc("mcut.unionCode");
|
||||
}
|
||||
sql.setCondition(cnd);
|
||||
return AjaxResult.success(welfareMemberService.listMap(sql));
|
||||
}
|
||||
|
||||
/**
|
||||
* 小组核对情况
|
||||
*
|
||||
* @param taskId 任务id
|
||||
* @param unionId 工会id
|
||||
* @return {@link AjaxResult}
|
||||
*/
|
||||
@RequestMapping("/unionGroupCheckDesc")
|
||||
@RequiresPermissions("staffService:welfare:schoolUnionTask")
|
||||
public AjaxResult pageData(@RequestParam String taskId, @RequestParam String unionId) {
|
||||
// Sql sql = Sqls.create("""
|
||||
// SELECT
|
||||
// sug.id,
|
||||
// sug.groupName,
|
||||
// sug.groupCode,
|
||||
// mcut.isFinish,
|
||||
// u.user_name as loginName,
|
||||
// u.nick_name as userName,
|
||||
// u.mobile\s
|
||||
// FROM
|
||||
// welfare_member_check_union_task mcut
|
||||
// LEFT JOIN sys_union_group sug ON mcut.unionGroupId = sug.id
|
||||
// LEFT JOIN sys_user_role sur ON sur.unionGroupId = sug.id\s
|
||||
// AND sur.role_id = 112
|
||||
// LEFT JOIN sys_user u ON u.user_id = sur.user_id
|
||||
// WHERE mcut.unionId = @unionId AND mcut.taskId = @taskId
|
||||
// ORDER BY mcut.isFinish ASC,sug.groupCode ASC
|
||||
// """);
|
||||
// sql.setParam("unionId", unionId);
|
||||
// sql.setParam("taskId", taskId);
|
||||
// List list = welfareMemberService.listMap(sql);
|
||||
// return AjaxResult.success(list);
|
||||
Sql unionGroupCheckDescSql = Sqls.create("""
|
||||
SELECT
|
||||
mcut.unionGroupId,
|
||||
mcut.isFinish
|
||||
FROM
|
||||
welfare_member_check_union_task mcut
|
||||
WHERE mcut.unionId = @unionId AND mcut.taskId = @taskId
|
||||
ORDER BY mcut.isFinish ASC
|
||||
""");
|
||||
unionGroupCheckDescSql.setParam("unionId", unionId);
|
||||
unionGroupCheckDescSql.setParam("taskId", taskId);
|
||||
List<NutMap> unionGroupCheckDescList = welfareMemberService.listMap(unionGroupCheckDescSql);
|
||||
List<String> unionGroupIds = unionGroupCheckDescList.stream().map(v -> v.getString("unionGroupId")).collect(Collectors.toList());
|
||||
|
||||
List<NutMap> unionGroupLeaderInfos = ProModuleDS.exec(Ds.SYSTEM, () -> {
|
||||
Sql sql = Sqls.create("""
|
||||
SELECT
|
||||
sug.id,
|
||||
sug.groupName,
|
||||
sug.groupCode,
|
||||
GROUP_CONCAT(u.user_name,'(',u.nick_name,'}') as userName,
|
||||
GROUP_CONCAT(u.mobile) as mobile
|
||||
FROM
|
||||
sys_user_role sur
|
||||
LEFT JOIN sys_union_group sug ON sug.id = sur.unionGroupId
|
||||
LEFT JOIN sys_user u ON u.user_id = sur.user_id
|
||||
WHERE
|
||||
sur.role_id = 112
|
||||
AND sur.unionGroupId in (@unionGroupIds)
|
||||
GROUP BY
|
||||
sur.unionGroupId
|
||||
""");
|
||||
sql.setParam("unionGroupIds", unionGroupIds);
|
||||
return (List<NutMap>) welfareMemberService.listMap(sql);
|
||||
});
|
||||
|
||||
Map<String, NutMap> unionGroupLeaderInfoMap = unionGroupLeaderInfos.stream().collect(Collectors.toMap(v -> v.getString("id"), v -> v));
|
||||
|
||||
for (NutMap g : unionGroupCheckDescList) {
|
||||
NutMap unionGroupInfo = unionGroupLeaderInfoMap.get(g.getString("unionGroupId"));
|
||||
if (Lang.isNotEmpty(unionGroupInfo)) {
|
||||
g.putAll(unionGroupInfo);
|
||||
}
|
||||
}
|
||||
|
||||
return AjaxResult.success(unionGroupCheckDescList.stream().sorted(Comparator.comparing(v -> v.getString("groupCode"))).collect(Collectors.toList()));
|
||||
}
|
||||
|
||||
@PostMapping("/getNotCheckUsers")
|
||||
@RequiresPermissions("staffService:welfare:schoolUnionTask")
|
||||
public AjaxResult getNotCheckUsers(@RequestParam String taskId, @RequestParam String unionId) {
|
||||
Sql sql = Sqls.create("""
|
||||
SELECT
|
||||
mcr.id,
|
||||
mcr.type,
|
||||
mcr.userId,
|
||||
mcr.originUnitId,
|
||||
mcr.currentUnitId,
|
||||
mcr.originThreeUnitId,
|
||||
mcr.currentThreeUnitId,
|
||||
u.username AS userName,
|
||||
u.loginname AS loginName,
|
||||
u.welfareMember,
|
||||
his.changeType,
|
||||
his.changeTime,
|
||||
state.stateId,
|
||||
state.stateName
|
||||
FROM
|
||||
welfare_member_change_record mcr
|
||||
LEFT JOIN `user` u ON u.userId = mcr.userId
|
||||
LEFT JOIN audit_state state ON mcr.stateId = state.stateId
|
||||
LEFT JOIN user_history_latest his ON his.user_name = u.loginName
|
||||
WHERE
|
||||
mcr.taskId = @taskId
|
||||
AND mcr.originUnionId = @unionId
|
||||
AND mcr.stateId = @stateId
|
||||
""");
|
||||
sql.setParam("taskId", taskId);
|
||||
sql.setParam("unionId", unionId);
|
||||
sql.setParam("stateId", WelfareMemberChangeApplyState.SCHOOL_UNION);
|
||||
List<NutMap> userList = welfareMemberService.listMap(sql);
|
||||
|
||||
DynamicDataSourceContextHolder.push("system");
|
||||
List<SysDept> units = dao.query(SysDept.class, Cnd.NEW());
|
||||
DynamicDataSourceContextHolder.clear();
|
||||
|
||||
for (NutMap user : userList) {
|
||||
user.put("originUnitName", units.stream().filter(v -> v.getDeptId() == user.getLong("originUnitId")).findFirst().map(v -> v.getDeptName()).orElse("无单位"));
|
||||
user.put("currentUnitName", units.stream().filter(v -> v.getDeptId() == user.getLong("currentUnitId")).findFirst().map(v -> v.getDeptName()).orElse("无单位"));
|
||||
user.put("originThreeUnitName", units.stream().filter(v -> v.getDeptId() == user.getLong("originThreeUnitId")).findFirst().map(v -> v.getDeptName()).orElse("无单位"));
|
||||
user.put("currentThreeUnitName", units.stream().filter(v -> v.getDeptId() == user.getLong("currentThreeUnitId")).findFirst().map(v -> v.getDeptName()).orElse("无单位"));
|
||||
}
|
||||
|
||||
return AjaxResult.success(userList);
|
||||
}
|
||||
|
||||
@PostMapping("/doAudit")
|
||||
@RequiresPermissions("staffService:welfare:schoolUnionTask")
|
||||
public AjaxResult doAudit(@RequestBody WelfareMemberChangeRecord record, @RequestParam(required = false) String auditOpinion, @RequestParam boolean flag) {
|
||||
Audit audit = new Audit();
|
||||
audit.setAuditOpinion(auditOpinion);
|
||||
audit.setAuditPass(flag);
|
||||
WelfareMemberChangeAuditHandle.SCHOOL.next(dao.fetch(WelfareMemberChangeRecord.class, record.getId()), audit);
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
}
|
||||
+453
@@ -0,0 +1,453 @@
|
||||
package com.ruoyi.staffService.welfare.controller;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.dynamic.datasource.annotation.DSTransactional;
|
||||
import com.baomidou.dynamic.datasource.toolkit.DynamicDataSourceContextHolder;
|
||||
import com.google.common.base.Joiner;
|
||||
import com.ruoyi.common.core.utils.sql.SqlUtil;
|
||||
import com.ruoyi.common.core.web.domain.AjaxResult;
|
||||
import com.ruoyi.common.security.annotation.RequiresPermissions;
|
||||
import com.ruoyi.common.security.auth.AuthUtil;
|
||||
import com.ruoyi.common.security.utils.SecurityUtils;
|
||||
import com.ruoyi.member.api.constant.*;
|
||||
import com.ruoyi.member.api.domain.Audit;
|
||||
import com.ruoyi.member.api.domain.MemberChangeRecord;
|
||||
import com.ruoyi.staffService.api.constant.welfare.WelfareMemberApplyState;
|
||||
import com.ruoyi.staffService.api.constant.welfare.WelfareMemberMode;
|
||||
import com.ruoyi.staffService.api.constant.welfare.WelfareMemberPageForm;
|
||||
import com.ruoyi.staffService.api.domain.welfare.WelfareMemberChangeRecord;
|
||||
import com.ruoyi.staffService.api.domain.welfare.WelfareMemberCheckTask;
|
||||
import com.ruoyi.staffService.constant.Ds;
|
||||
import com.ruoyi.staffService.util.ProModuleDS;
|
||||
import com.ruoyi.staffService.welfare.service.StaffWelfareMemberService;
|
||||
import com.ruoyi.system.api.domain.SysDept;
|
||||
import com.ruoyi.system.api.domain.SysUser;
|
||||
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.lang.Lang;
|
||||
import org.nutz.lang.util.NutMap;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
|
||||
/**
|
||||
* 福利会员高级管理
|
||||
*
|
||||
* @author jug
|
||||
* @date 2023/02/09
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/welfare/memberSeniorManage")
|
||||
public class StaffWelfareMemberSeniorManageController {
|
||||
|
||||
@Autowired
|
||||
private StaffWelfareMemberService welfareMemberService;
|
||||
|
||||
@Autowired
|
||||
private Dao dao;
|
||||
|
||||
/**
|
||||
* 页面数据
|
||||
*
|
||||
* @param pageForm 页面形式
|
||||
* @return {@link AjaxResult}
|
||||
*/
|
||||
@PostMapping("/pageData")
|
||||
@RequiresPermissions("staffService:welfare:memberSeniorManage")
|
||||
public AjaxResult pageData(@RequestBody WelfareMemberPageForm pageForm,
|
||||
@RequestParam(required = false) Integer member,
|
||||
@RequestParam(required = false) Boolean changed,
|
||||
@RequestParam(required = false) Integer welfareMember,
|
||||
@RequestParam(required = false) Integer changeType) {
|
||||
Sql sql = Sqls.create("""
|
||||
SELECT
|
||||
u.*,
|
||||
his.changeType,
|
||||
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,
|
||||
mcr_state.stateId mcrStateId,
|
||||
mcr_state.stateName mcrStateName,
|
||||
mcr_state.stateColor mcrStateColor
|
||||
FROM
|
||||
`user` u
|
||||
|
||||
LEFT JOIN user_history_latest his ON his.user_name = u.loginName
|
||||
LEFT JOIN welfare_member_apply_record_latest wmar ON wmar.userId = u.userId
|
||||
LEFT JOIN member_change_record_latest mcr ON mcr.userId = u.userId
|
||||
LEFT JOIN audit_state state ON wmar.stateId = state.stateId
|
||||
LEFT JOIN audit_state mcr_state ON mcr_state.stateId = mcr.stateId
|
||||
$condition
|
||||
""");
|
||||
|
||||
sql.setVar("states", Joiner.on(",").join(List.of(WelfareMemberApplyState.SCHOOL_UNION_FAIL)));
|
||||
|
||||
Cnd cnd = Cnd.NEW();
|
||||
|
||||
if (!AuthUtil.hasAnyRoles("admin,A06")) {
|
||||
if (AuthUtil.hasRole("H04")) {
|
||||
cnd.and("u.unionId", "=", SecurityUtils.getUnionId());
|
||||
} else if (AuthUtil.hasRole("unionGroupLeader")) {
|
||||
cnd.and("u.unionId", "=", SecurityUtils.getUnionId());
|
||||
SqlExpressionGroup seg = new SqlExpressionGroup();
|
||||
seg.or("u.unionGroupId", "in", SecurityUtils.getManageUnionGroupIds());
|
||||
seg.or("u.unionGroupId", "is", null);
|
||||
cnd.and(seg);
|
||||
}
|
||||
}
|
||||
|
||||
cnd.andEX("u.unionId", "=", pageForm.getUnionId());
|
||||
cnd.andEX("u.deptId", "=", pageForm.getUnitId());
|
||||
cnd.andEX("u.unionGroupId", "=", pageForm.getUnionGroupId());
|
||||
cnd.andEX("u.threeUnitId", "=", pageForm.getThreeUnitId());
|
||||
cnd.andEX("u.sex", "=", pageForm.getSex());
|
||||
cnd.andEX("u.personType", "=", pageForm.getPersonType());
|
||||
cnd.andEX("u.userState", "=", pageForm.getUserState());
|
||||
cnd.andEX("u.campus", "=", pageForm.getCampus());
|
||||
cnd.groupBy("u.userId");
|
||||
|
||||
if (welfareMember != null) {
|
||||
if (welfareMember == WelfareMemberMode.NORMAL.getCode()) {
|
||||
cnd.and("u.welfareMember", "=", WelfareMemberMode.NORMAL.getCode());
|
||||
} else if (welfareMember == WelfareMemberMode.NONE.getCode()) {
|
||||
SqlExpressionGroup group = new SqlExpressionGroup();
|
||||
group.or("u.welfareMember", "=", null).or("u.welfareMember", "=", WelfareMemberMode.NONE.getCode());
|
||||
cnd.and(group);
|
||||
}
|
||||
}
|
||||
|
||||
if (member != null) {
|
||||
if (member == MemberMode.NORMAL.getCode()) {
|
||||
cnd.and("u.member", "=", MemberMode.NORMAL.getCode());
|
||||
} else if (member == MemberMode.NONE.getCode()) {
|
||||
SqlExpressionGroup group = new SqlExpressionGroup();
|
||||
group.or("u.member", "is", null);
|
||||
group.or("u.member", "!=", MemberMode.NORMAL.getCode());
|
||||
cnd.and(group);
|
||||
}
|
||||
}
|
||||
|
||||
if (changed != null) {
|
||||
if (changed) {
|
||||
cnd.and(new Static("his.user_name is not null"));
|
||||
} else {
|
||||
cnd.and(new Static("his.user_name is null"));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (StrUtil.isNotBlank(pageForm.getSearchKeyword())) {
|
||||
SqlExpressionGroup seg = new SqlExpressionGroup();
|
||||
seg.orLike("u.userName", pageForm.getSearchKeyword());
|
||||
seg.orLike("u.loginName", pageForm.getSearchKeyword());
|
||||
cnd.and(seg);
|
||||
}
|
||||
|
||||
if (StrUtil.isAllNotBlank(pageForm.getPageOrderName(), pageForm.getPageOrderBy())) {
|
||||
cnd.orderBy(pageForm.getPageOrderName(), SqlUtil.getOrderBy(pageForm.getPageOrderBy()));
|
||||
} else {
|
||||
cnd.asc("u.loginName");
|
||||
cnd.desc("his.changeTime");
|
||||
cnd.asc("u.userState");
|
||||
}
|
||||
|
||||
if (Lang.isNotEmpty(pageForm.getChangeDateRange()) && pageForm.getChangeDateRange().length == 2) {
|
||||
String changeDateBefore = pageForm.getChangeDateRange()[0];
|
||||
String changeDateEnd = pageForm.getChangeDateRange()[1];
|
||||
cnd.and(new SqlExpressionGroup().andBetween("his.changeTime", changeDateBefore, changeDateEnd));
|
||||
}
|
||||
|
||||
cnd.andEX("his.changeType", "=", changeType);
|
||||
|
||||
sql.setCondition(cnd);
|
||||
return AjaxResult.success(welfareMemberService.listPageMap(pageForm.getPageNumber(), pageForm.getPageSize(), sql));
|
||||
}
|
||||
|
||||
/**
|
||||
* 加入福利成员
|
||||
*
|
||||
* @param userIds 用户id
|
||||
* @return {@link AjaxResult}
|
||||
*/
|
||||
@PostMapping("/joinWelfareMember")
|
||||
@RequiresPermissions("staffService:welfare:memberSeniorManage")
|
||||
public AjaxResult joinWelfareMember(@RequestBody List<Long> userIds) {
|
||||
welfareMemberService.joinWelfareMember(userIds);
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 会员编辑
|
||||
*
|
||||
* @param user 用户
|
||||
* @return {@link AjaxResult}
|
||||
*/
|
||||
@PostMapping("/updateWelfareMember")
|
||||
@RequiresPermissions("staffService:welfare:memberSeniorManage")
|
||||
public AjaxResult updateWelfareMember(@RequestBody SysUser user) {
|
||||
welfareMemberService.addNewWelfareMember(user);
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 取消福利成员
|
||||
*
|
||||
* @param userIds 用户id
|
||||
* @return {@link AjaxResult}
|
||||
*/
|
||||
@PostMapping("/kickWelfareMember")
|
||||
@RequiresPermissions("staffService:welfare:memberSeniorManage")
|
||||
public AjaxResult kickWelfareMember(@RequestBody List<Long> userIds) {
|
||||
welfareMemberService.kickWelfareMember(userIds);
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量修改校区
|
||||
*
|
||||
* @param sysUsers 系统用户
|
||||
* @return {@link AjaxResult}
|
||||
*/
|
||||
@PostMapping("/batchModifyCampus")
|
||||
@RequiresPermissions("staffService:welfare:memberSeniorManage")
|
||||
public AjaxResult batchModifyCampus(@RequestBody List<SysUser> sysUsers) {
|
||||
DynamicDataSourceContextHolder.push("system");
|
||||
welfareMemberService.dao().update(sysUsers, "campus");
|
||||
DynamicDataSourceContextHolder.clear();
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 历史用户
|
||||
*
|
||||
* @param loginName 登录名
|
||||
* @return {@link AjaxResult}
|
||||
*/
|
||||
@GetMapping("/historyUsers")
|
||||
@RequiresPermissions("staffService:welfare:memberSeniorManage")
|
||||
public AjaxResult historyUsers(@RequestParam String loginName) {
|
||||
List<NutMap> list = welfareMemberService.historyUsers(loginName);
|
||||
return AjaxResult.success(list);
|
||||
}
|
||||
|
||||
@PostMapping("/getChangeNumber")
|
||||
@RequiresPermissions("staffService:welfare:memberSeniorManage")
|
||||
public AjaxResult getChangeNumber(@RequestBody WelfareMemberPageForm pageForm,
|
||||
@RequestParam(required = false) Integer member,
|
||||
@RequestParam(required = false) Boolean changed,
|
||||
@RequestParam(required = false) Integer welfareMember,
|
||||
@RequestParam(required = false) Integer changeType) {
|
||||
|
||||
// Sql sql = Sqls.create("""
|
||||
// SELECT
|
||||
// (
|
||||
// SELECT
|
||||
// COUNT( distinct u.userId )
|
||||
// FROM
|
||||
// `user` u
|
||||
// LEFT JOIN user_history_latest his ON his.user_name = u.loginname
|
||||
// LEFT JOIN welfare_member_apply_record_latest wmar ON wmar.userId = u.userId
|
||||
// LEFT JOIN member_change_record_latest mcr ON mcr.userId = u.userId
|
||||
// LEFT JOIN audit_state state ON wmar.stateId = state.stateId
|
||||
// LEFT JOIN audit_state mcr_state ON mcr_state.stateId = mcr.stateId
|
||||
// $condition
|
||||
// ) `all`,
|
||||
// (
|
||||
// SELECT
|
||||
// COUNT( distinct u.userId )
|
||||
// FROM
|
||||
// `user` u
|
||||
// LEFT JOIN user_history_latest his ON his.user_name = u.loginname
|
||||
// LEFT JOIN welfare_member_apply_record_latest wmar ON wmar.userId = u.userId
|
||||
// LEFT JOIN member_change_record_latest mcr ON mcr.userId = u.userId
|
||||
// LEFT JOIN audit_state state ON wmar.stateId = state.stateId
|
||||
// LEFT JOIN audit_state mcr_state ON mcr_state.stateId = mcr.stateId
|
||||
// $condition
|
||||
// AND his.user_name IS NOT NULL
|
||||
// ) have,
|
||||
// (
|
||||
// SELECT
|
||||
// COUNT( distinct u.userId )
|
||||
// FROM
|
||||
// `user` u
|
||||
// LEFT JOIN user_history_latest his ON his.user_name = u.loginname
|
||||
// LEFT JOIN welfare_member_apply_record_latest wmar ON wmar.userId = u.userId
|
||||
// LEFT JOIN member_change_record_latest mcr ON mcr.userId = u.userId
|
||||
// LEFT JOIN audit_state state ON wmar.stateId = state.stateId
|
||||
// LEFT JOIN audit_state mcr_state ON mcr_state.stateId = mcr.stateId
|
||||
// $condition
|
||||
// AND his.user_name IS NULL
|
||||
// ) `no`
|
||||
// """);
|
||||
|
||||
Sql sql = Sqls.create("""
|
||||
SELECT
|
||||
COUNT(DISTINCT u.userId) AS `all`,
|
||||
COUNT(DISTINCT CASE WHEN his.user_name IS NOT NULL THEN u.userId END) AS have,
|
||||
COUNT(DISTINCT CASE WHEN his.user_name IS NULL THEN u.userId END) AS `no`
|
||||
FROM
|
||||
`user` u
|
||||
LEFT JOIN user_history_latest his ON his.user_name = u.loginname
|
||||
LEFT JOIN welfare_member_apply_record_latest wmar ON wmar.userId = u.userId
|
||||
LEFT JOIN member_change_record_latest mcr ON mcr.userId = u.userId
|
||||
LEFT JOIN audit_state state ON wmar.stateId = state.stateId
|
||||
LEFT JOIN audit_state mcr_state ON mcr_state.stateId = mcr.stateId
|
||||
$condition
|
||||
""");
|
||||
|
||||
sql.setVar("states", Joiner.on(",").join(List.of(WelfareMemberApplyState.SCHOOL_UNION_FAIL)));
|
||||
|
||||
Cnd cnd = Cnd.NEW();
|
||||
if (!AuthUtil.hasAnyRoles("admin,A06")) {
|
||||
if (AuthUtil.hasRole("H04")) {
|
||||
cnd.and("u.unionId", "=", SecurityUtils.getUnionId());
|
||||
} else if (AuthUtil.hasRole("unionGroupLeader")) {
|
||||
cnd.and("u.unionId", "=", SecurityUtils.getUnionId());
|
||||
SqlExpressionGroup seg = new SqlExpressionGroup();
|
||||
seg.or("u.unionGroupId", "in", SecurityUtils.getManageUnionGroupIds());
|
||||
seg.or("u.unionGroupId", "is", null);
|
||||
cnd.and(seg);
|
||||
}
|
||||
}
|
||||
|
||||
cnd.andEX("u.unionId", "=", pageForm.getUnionId());
|
||||
cnd.andEX("u.deptId", "=", pageForm.getUnitId());
|
||||
cnd.andEX("u.unionGroupId", "=", pageForm.getUnionGroupId());
|
||||
cnd.andEX("u.threeUnitId", "=", pageForm.getThreeUnitId());
|
||||
cnd.andEX("u.sex", "=", pageForm.getSex());
|
||||
cnd.andEX("u.personType", "=", pageForm.getPersonType());
|
||||
cnd.andEX("u.userState", "=", pageForm.getUserState());
|
||||
cnd.andEX("u.campus", "=", pageForm.getCampus());
|
||||
|
||||
if (welfareMember != null) {
|
||||
if (welfareMember == WelfareMemberMode.NORMAL.getCode()) {
|
||||
cnd.and("u.welfareMember", "=", WelfareMemberMode.NORMAL.getCode());
|
||||
} else if (welfareMember == WelfareMemberMode.NONE.getCode()) {
|
||||
SqlExpressionGroup group = new SqlExpressionGroup();
|
||||
group.or("u.welfareMember", "=", null).or("u.welfareMember", "=", WelfareMemberMode.NONE.getCode());
|
||||
cnd.and(group);
|
||||
}
|
||||
}
|
||||
|
||||
if (member != null) {
|
||||
if (member == MemberMode.NORMAL.getCode()) {
|
||||
cnd.and("u.member", "=", MemberMode.NORMAL.getCode());
|
||||
} else if (member == MemberMode.NONE.getCode()) {
|
||||
SqlExpressionGroup group = new SqlExpressionGroup();
|
||||
group.or("u.member", "is", null);
|
||||
group.or("u.member", "!=", MemberMode.NORMAL.getCode());
|
||||
cnd.and(group);
|
||||
}
|
||||
}
|
||||
|
||||
// if (changed != null) {
|
||||
// if (changed) {
|
||||
// cnd.and(new Static("his.user_name is not null"));
|
||||
// } else {
|
||||
// cnd.and(new Static("his.user_name is null"));
|
||||
// }
|
||||
// }
|
||||
|
||||
if (StrUtil.isNotBlank(pageForm.getSearchKeyword())) {
|
||||
SqlExpressionGroup seg = new SqlExpressionGroup();
|
||||
seg.orLike("u.userName", pageForm.getSearchKeyword());
|
||||
seg.orLike("u.loginName", pageForm.getSearchKeyword());
|
||||
cnd.and(seg);
|
||||
}
|
||||
|
||||
if (Lang.isNotEmpty(pageForm.getChangeDateRange()) && pageForm.getChangeDateRange().length == 2) {
|
||||
String changeDateBefore = pageForm.getChangeDateRange()[0];
|
||||
String changeDateEnd = pageForm.getChangeDateRange()[1];
|
||||
cnd.and(new SqlExpressionGroup().andBetween("his.changeTime", changeDateBefore, changeDateEnd));
|
||||
}
|
||||
|
||||
cnd.andEX("his.changeType", "=", changeType);
|
||||
|
||||
sql.setCondition(cnd);
|
||||
NutMap nutMap = welfareMemberService.fetch(sql);
|
||||
return AjaxResult.success(nutMap);
|
||||
}
|
||||
|
||||
|
||||
@PostMapping("/doMemberChange")
|
||||
@RequiresPermissions("staffService:welfare:memberSeniorManage")
|
||||
public AjaxResult doMemberChange(@RequestBody WelfareMemberChangeRecord record) {
|
||||
if (Objects.equals(record.getType(), UserChangeType.NEW.getCode())) {
|
||||
return AjaxResult.warn("您已经入职!");
|
||||
}
|
||||
if (Objects.equals(record.getType(), UserChangeType.UNIT_CHANGE.getCode())) {
|
||||
if (record.getCurrentUnitId().equals(record.getOriginUnitId())) {
|
||||
return AjaxResult.warn("请选择不同的单位!");
|
||||
}
|
||||
}
|
||||
welfareMemberService.doMemberChange(record, true);
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
|
||||
@PostMapping("/doBatchEdit")
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@RequiresPermissions("staffService:welfare:memberManage")
|
||||
public AjaxResult doBatchEdit(@RequestBody List<NutMap> batch) {
|
||||
batch.forEach(v -> {
|
||||
ProModuleDS.execVoid(Ds.SYSTEM, () -> welfareMemberService.execute(Sqls.create("update sys_user set campus=@campusId where userId=@userId")
|
||||
.setParam("campusId", v.getString("campusId")).setParam("userId", v.getLong("userId"))));
|
||||
});
|
||||
return AjaxResult.success();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@PostMapping("/doUnitMove")
|
||||
@DSTransactional
|
||||
@RequiresPermissions("staffService:welfare:memberManage")
|
||||
public AjaxResult doUnitMove(@RequestBody List<Long> userId,String threeUnitId, String unitId){
|
||||
|
||||
SysDept dept = ProModuleDS.exec(Ds.SYSTEM, () -> dao.fetch(SysDept.class, Cnd.where("deptId","=",unitId)));
|
||||
|
||||
Chain updateUnitChain = Chain.make("deptId", dept.getDeptId())
|
||||
.add("threeUnitId", threeUnitId);
|
||||
ProModuleDS.exec(Ds.SYSTEM,()->dao.update(SysUser.class,updateUnitChain, Cnd.where("userId", "in", userId)));
|
||||
|
||||
|
||||
for (Long uid : userId) {
|
||||
MemberChangeRecord record = new MemberChangeRecord();
|
||||
record.setRecordMode(MemberChangeRecordMode.MEMBER.getCode());
|
||||
record.setType(UserChangeType.UNIT_CHANGE.getCode());
|
||||
record.setUserId(uid);
|
||||
record.setApplyTime(new Date());
|
||||
record.setApplyOrigin(MemberChangeOrigin.SCHOOL.getCode());
|
||||
record.setRecordMode(MemberChangeRecordMode.MEMBER.getCode());
|
||||
record.setStateId(MemberChangeApplyState.SUCCESS);
|
||||
|
||||
Audit audit = new Audit();
|
||||
audit.setAuditPass(true);
|
||||
audit.setAuditOpinion(MemberChangeOrigin.SCHOOL.getDescription());
|
||||
String id = dao.insert(audit).getId();
|
||||
|
||||
record.setSchoolAuditId(id);
|
||||
ProModuleDS.exec(Ds.SYSTEM,()->dao.insert(record));
|
||||
}
|
||||
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
+85
@@ -0,0 +1,85 @@
|
||||
package com.ruoyi.staffService.welfare.controller;
|
||||
|
||||
import com.ruoyi.common.core.domain.PageForm;
|
||||
import com.ruoyi.common.core.page.Pagination;
|
||||
import com.ruoyi.common.core.web.domain.AjaxResult;
|
||||
import com.ruoyi.common.security.annotation.RequiresPermissions;
|
||||
import com.ruoyi.staffService.api.domain.welfare.WelfareProject;
|
||||
import com.ruoyi.staffService.welfare.service.StaffWelfareMemberListService;
|
||||
import com.ruoyi.staffService.welfare.service.StaffWelfareProjectMangeService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
/**
|
||||
* 福利项目管理
|
||||
*
|
||||
* @author jug
|
||||
* @date 2023/02/08
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/welfare/projectManage")
|
||||
public class StaffWelfareProjectManageController {
|
||||
|
||||
@Autowired
|
||||
private StaffWelfareProjectMangeService projectMangeService;
|
||||
|
||||
@Autowired
|
||||
private StaffWelfareMemberListService welfareMemberListService;
|
||||
|
||||
@PostMapping("/save")
|
||||
@RequiresPermissions("staffService:welfare:projectManage")
|
||||
public AjaxResult save(@RequestBody WelfareProject project) {
|
||||
projectMangeService.save(project);
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
@PostMapping("/pageData")
|
||||
@RequiresPermissions("staffService:welfare:projectManage")
|
||||
public AjaxResult pageData(@RequestBody PageForm pageForm,
|
||||
@RequestParam(required = false) String name,
|
||||
@RequestParam(required = false) Integer year) {
|
||||
Pagination pagination = projectMangeService.pageData(pageForm, name, year);
|
||||
return AjaxResult.success(pagination);
|
||||
}
|
||||
|
||||
@GetMapping("/findOne")
|
||||
@RequiresPermissions("staffService:welfare:projectManage")
|
||||
public AjaxResult findOne(@RequestParam String id) {
|
||||
return AjaxResult.success(projectMangeService.projectInfo(id));
|
||||
}
|
||||
|
||||
@PostMapping("/delete")
|
||||
@RequiresPermissions("staffService:welfare:projectManage")
|
||||
public AjaxResult delete(@RequestParam String id) {
|
||||
projectMangeService.deleteProject(id);
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成福利名单
|
||||
*
|
||||
* @param id id
|
||||
* @return {@link AjaxResult}
|
||||
*/
|
||||
@PostMapping("/createList")
|
||||
@RequiresPermissions("staffService:welfare:projectManage")
|
||||
public AjaxResult createList(@RequestParam String id) {
|
||||
welfareMemberListService.createList(id);
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新福利名单
|
||||
*
|
||||
* @param id id
|
||||
* @return {@link AjaxResult}
|
||||
*/
|
||||
@PostMapping("/updateList")
|
||||
@RequiresPermissions("staffService:welfare:projectManage")
|
||||
public AjaxResult updateList(@RequestParam String id) {
|
||||
welfareMemberListService.updateList(id);
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
+623
@@ -0,0 +1,623 @@
|
||||
package com.ruoyi.staffService.welfare.controller;
|
||||
|
||||
import cn.afterturn.easypoi.entity.BaseTypeConstants;
|
||||
import cn.afterturn.easypoi.excel.ExcelExportUtil;
|
||||
import cn.afterturn.easypoi.excel.entity.ExportParams;
|
||||
import cn.afterturn.easypoi.excel.entity.enmus.ExcelType;
|
||||
import cn.afterturn.easypoi.excel.entity.params.ExcelExportEntity;
|
||||
import cn.afterturn.easypoi.excel.export.ExcelExportService;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.core.util.ZipUtil;
|
||||
import com.ruoyi.common.core.web.domain.AjaxResult;
|
||||
import com.ruoyi.common.security.auth.AuthUtil;
|
||||
import com.ruoyi.common.security.utils.SecurityUtils;
|
||||
import com.ruoyi.staffService.api.domain.welfare.WelfareProject;
|
||||
import com.ruoyi.staffService.api.domain.welfare.WelfareProjectSubject;
|
||||
import com.ruoyi.staffService.api.domain.welfare.WelfareProjectSubjectOption;
|
||||
import com.ruoyi.staffService.welfare.service.StaffWelfareSingleService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.commons.lang3.time.DateFormatUtils;
|
||||
import org.apache.poi.ss.usermodel.Workbook;
|
||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||
import org.nutz.dao.Cnd;
|
||||
import org.nutz.dao.Dao;
|
||||
import org.nutz.dao.Sqls;
|
||||
import org.nutz.dao.sql.Sql;
|
||||
import org.nutz.json.Json;
|
||||
import org.nutz.lang.Lang;
|
||||
import org.nutz.lang.random.R;
|
||||
import org.nutz.lang.util.NutMap;
|
||||
import org.nutz.mvc.annotation.Ok;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.ServletOutputStream;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.xml.bind.DatatypeConverter;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.net.URLEncoder;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 意向选择 邮寄到家类的统计
|
||||
*
|
||||
* @author jug
|
||||
* @date 2023/02/10
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/welfare/statistics/single")
|
||||
@Slf4j
|
||||
public class StaffWelfareSingleController {
|
||||
|
||||
@Autowired
|
||||
private Dao dao;
|
||||
|
||||
@Autowired
|
||||
private StaffWelfareSingleService welfareSingleService;
|
||||
|
||||
/**
|
||||
* 页面数据
|
||||
*
|
||||
* @param projectId 项目id
|
||||
* @param unionId 分工会
|
||||
* @return {@link AjaxResult}
|
||||
*/
|
||||
@PostMapping("/pageData")
|
||||
public AjaxResult pageData(@RequestParam(required = false) String projectId,
|
||||
@RequestParam(required = false) String unionId,
|
||||
@RequestParam(required = false) String unionGroupId) {
|
||||
return AjaxResult.success(welfareSingleService.pageData(projectId, unionId, unionGroupId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 按分工会导出选择情况
|
||||
*
|
||||
* @param projectId
|
||||
* @param unionId
|
||||
* @param response
|
||||
*/
|
||||
@PostMapping("/exportByUnion")
|
||||
public void exportByUnion(@RequestParam String projectId,
|
||||
@RequestParam(required = false) String unionId,
|
||||
HttpServletResponse response) {
|
||||
try (ServletOutputStream outputStream = response.getOutputStream()) {
|
||||
String title = "统计名单";
|
||||
NutMap dataMap = welfareSingleService.pageData(projectId, unionId, null);
|
||||
List<NutMap> labelList = dataMap.getAsList("tableColumn", NutMap.class);
|
||||
List<NutMap> list = dataMap.getAsList("tableList", NutMap.class);
|
||||
|
||||
List<ExcelExportEntity> entityList = new ArrayList<>();
|
||||
for (NutMap label : labelList) {
|
||||
entityList.add(new ExcelExportEntity(label.getString("label"), label.getString("prop"), 30));
|
||||
}
|
||||
ExportParams exportParams = new ExportParams();
|
||||
exportParams.setType(ExcelType.XSSF);
|
||||
Workbook workbook = ExcelExportUtil.exportExcel(exportParams, entityList, list);
|
||||
response.setContentType("application/octet-stream");
|
||||
response.setHeader("Content-Disposition", "attachment;filename=%s".formatted(URLEncoder.encode(title + "汇总表.xlsx", StandardCharsets.UTF_8)));
|
||||
workbook.write(outputStream);
|
||||
workbook.close();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
log.error("导出汇总表失败{}", e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 每个分工会领取人员
|
||||
*
|
||||
* @param projectId
|
||||
* @param welfareUnitCode
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/receivePageData")
|
||||
public AjaxResult receivePageData(@RequestParam String projectId,
|
||||
@RequestParam String welfareUnitCode,
|
||||
@RequestParam(required = false) String unionGroupId,
|
||||
@RequestParam(required = false) Integer pageNumber,
|
||||
@RequestParam(required = false) Integer pageSize) {
|
||||
return AjaxResult.success(welfareSingleService.receivePageData(projectId, welfareUnitCode, unionGroupId, pageNumber, pageSize, true));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 导出名单
|
||||
*
|
||||
* @param projectId
|
||||
* @param unionId
|
||||
* @param unionGroupId
|
||||
* @param isSelect
|
||||
* @param response
|
||||
*/
|
||||
@PostMapping("/exportSelectSituation")
|
||||
public void exportSelectSituation(@RequestParam String projectId,
|
||||
@RequestParam() String unionId,
|
||||
@RequestParam(required = false) String unionGroupId,
|
||||
@RequestParam boolean isSelect,
|
||||
HttpServletResponse response) {
|
||||
|
||||
try (ServletOutputStream outputStream = response.getOutputStream()) {
|
||||
|
||||
Sql sql = Sqls.create("""
|
||||
SELECT
|
||||
wl.loginName,
|
||||
wl.userName,
|
||||
wl.unionName,
|
||||
wl.unionGroupName,
|
||||
wl.unitName,
|
||||
wl.mobile,
|
||||
GROUP_CONCAT( wpso.optionName, '(×', wpus.selectNum, ')' ) as selectOptionNames,
|
||||
GROUP_CONCAT( wpso.optionName, ' (' , wpus.receiveAddress , ')' ) AS selectReceiveAddresss,
|
||||
wpus.userSign
|
||||
FROM
|
||||
welfare_list wl
|
||||
LEFT JOIN welfare_project_user_selection wpus ON wpus.selectUserId = wl.userId AND wpus.welfareId = @projectId
|
||||
LEFT JOIN welfare_project_subject_option wpso ON wpso.id = wpus.selectOptionId
|
||||
$condition
|
||||
""");
|
||||
sql.setParam("projectId", projectId);
|
||||
Cnd cnd = Cnd.NEW();
|
||||
cnd.andEX("wl.projectId", "=", projectId);
|
||||
cnd.andEX("wl.unionId", "=", unionId);
|
||||
if (isSelect) {
|
||||
cnd.and("wpus.selectOptionId", "is not", null);
|
||||
} else {
|
||||
cnd.and("wpus.selectOptionId", "is", null);
|
||||
}
|
||||
cnd.groupBy("wl.userId");
|
||||
cnd.desc("wl.unitName");
|
||||
cnd.desc("wl.unionGroupName");
|
||||
sql.setCondition(cnd);
|
||||
List<NutMap> list = welfareSingleService.listMap(sql);
|
||||
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
list.get(i).put("index", i + 1);
|
||||
if (StrUtil.isNotBlank(list.get(i).getString("userSign"))) {
|
||||
String str = list.get(i).getString("userSign").substring(list.get(i).getString("userSign").indexOf(",") + 1);
|
||||
byte[] bytes = DatatypeConverter.parseBase64Binary(str);
|
||||
list.get(i).put("userSign", bytes);
|
||||
}
|
||||
}
|
||||
|
||||
List<ExcelExportEntity> entityList = new ArrayList<>();
|
||||
entityList.add(new ExcelExportEntity("序号", "index", 20));
|
||||
entityList.add(new ExcelExportEntity("姓名", "userName", 20));
|
||||
entityList.add(new ExcelExportEntity("工号", "loginName", 20));
|
||||
entityList.add(new ExcelExportEntity("单位", "unitName", 20));
|
||||
entityList.add(new ExcelExportEntity("分工会", "unionName", 20));
|
||||
entityList.add(new ExcelExportEntity("工会小组", "unionGroupName", 20));
|
||||
entityList.add(new ExcelExportEntity("联系方式", "mobile", 20));
|
||||
entityList.add(new ExcelExportEntity("选择情况", "selectOptionNames", 20));
|
||||
|
||||
WelfareProject project = dao.fetch(WelfareProject.class, projectId);
|
||||
if (project.getProvideMode().equals("2")){
|
||||
ExcelExportEntity addressExcelExportEntity = new ExcelExportEntity();
|
||||
addressExcelExportEntity.setName("收货地址");
|
||||
addressExcelExportEntity.setKey("selectReceiveAddresss");
|
||||
addressExcelExportEntity.setWidth(100);
|
||||
entityList.add(addressExcelExportEntity);
|
||||
}
|
||||
if (project.getSignMode().equals("2")) {
|
||||
ExcelExportEntity signExcelExportEntity = new ExcelExportEntity();
|
||||
signExcelExportEntity.setName("签字");
|
||||
signExcelExportEntity.setKey("userSign");
|
||||
signExcelExportEntity.setWidth(20);
|
||||
signExcelExportEntity.setType(BaseTypeConstants.IMAGE_TYPE);
|
||||
signExcelExportEntity.setExportImageType(2);
|
||||
entityList.add(signExcelExportEntity);
|
||||
}
|
||||
|
||||
ExportParams exportParams = new ExportParams();
|
||||
exportParams.setType(ExcelType.XSSF);
|
||||
Workbook workbook = ExcelExportUtil.exportExcel(exportParams, entityList, list);
|
||||
response.setContentType("application/octet-stream");
|
||||
response.setHeader("Content-Disposition", "attachment;filename=%s".formatted(URLEncoder.encode((isSelect ? "已选名单" : "未选名单") + "汇总表.xlsx", StandardCharsets.UTF_8)));
|
||||
workbook.write(outputStream);
|
||||
workbook.close();
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
log.error("导出已选名单失败{}", e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 查看选择情况
|
||||
*
|
||||
* @param projectId
|
||||
* @param unionId
|
||||
* @param unionGroupId
|
||||
* @param isSelect
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/selectSituation")
|
||||
public AjaxResult selectSituation(@RequestParam String projectId,
|
||||
@RequestParam(required = false) String unionId,
|
||||
@RequestParam(required = false) String unionGroupId,
|
||||
@RequestParam boolean isSelect) {
|
||||
// 弹框选择情况按用户聚合;充值会员卡(类型 3)在套餐名称后拼接下单时确认的手机号。
|
||||
Sql sql = Sqls.create("""
|
||||
SELECT
|
||||
wl.loginName,
|
||||
wl.userName,
|
||||
wl.unionName,
|
||||
wl.unionGroupName,
|
||||
wl.unitName,
|
||||
wl.mobile,
|
||||
GROUP_CONCAT(DISTINCT CONCAT(
|
||||
wpso.optionName,
|
||||
IF(wpso.optionType = '3' AND wpus.mobile IS NOT NULL AND wpus.mobile != '', CONCAT('-', wpus.mobile), ''),
|
||||
IF(wp.multiSelect, CONCAT(' (×', CAST(wpus.selectNum AS CHAR), ')'), '')
|
||||
)) AS selectOptionNames,
|
||||
GROUP_CONCAT( wpso.optionName, ' (' , wpus.receiveAddress , ')' ) AS selectReceiveAddresss,
|
||||
wpus.userSign
|
||||
FROM
|
||||
welfare_list wl
|
||||
LEFT JOIN welfare_project_user_selection wpus ON wpus.selectUserId = wl.userId AND wpus.welfareId = @projectId
|
||||
LEFT JOIN welfare_project_subject_option wpso ON wpso.id = wpus.selectOptionId
|
||||
LEFT JOIN welfare_project wp on wp.id = wl.projectId
|
||||
$condition
|
||||
""");
|
||||
sql.setParam("projectId", projectId);
|
||||
Cnd cnd = Cnd.NEW();
|
||||
cnd.andEX("wl.projectId", "=", projectId);
|
||||
cnd.andEX("wl.unionId", "=", unionId);
|
||||
if (isSelect) {
|
||||
cnd.and("wpus.selectOptionId", "is not", null);
|
||||
} else {
|
||||
cnd.and("wpus.selectOptionId", "is", null);
|
||||
}
|
||||
cnd.groupBy("wl.userId");
|
||||
cnd.desc("wl.unitName");
|
||||
cnd.desc("wl.unionGroupName");
|
||||
sql.setCondition(cnd);
|
||||
List list = welfareSingleService.listMap(sql);
|
||||
return AjaxResult.success(list);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 按商品导出
|
||||
*
|
||||
* @param projectId
|
||||
* @param response
|
||||
* @throws Exception
|
||||
*/
|
||||
@PostMapping("/shopExport")
|
||||
public void shopExport(@RequestParam String projectId, HttpServletResponse response) throws Exception {
|
||||
//找出所有领福利的人
|
||||
Sql sql = Sqls.create("""
|
||||
SELECT
|
||||
u.loginName,
|
||||
u.userName,
|
||||
u.deptName,
|
||||
u.unionName,
|
||||
u.mobile,
|
||||
wpus.receiveAddress,
|
||||
wpso.optionName,
|
||||
wpus.courierNumber
|
||||
FROM
|
||||
welfare_project_user_selection wpus
|
||||
LEFT JOIN `user` u ON u.userId = wpus.selectUserId
|
||||
LEFT JOIN welfare_project_subject_option wpso ON wpso.id = wpus.selectOptionId
|
||||
WHERE
|
||||
wpus.welfareId = @welfareId
|
||||
ORDER BY
|
||||
u.unionCode ASC
|
||||
""").setParam("welfareId", projectId);
|
||||
List<NutMap> list = welfareSingleService.listMap(sql);
|
||||
String fileName = "名单汇总文件夹";
|
||||
|
||||
response.reset();
|
||||
response.setContentType("application/x-msdownload;charset=utf-8");
|
||||
|
||||
String tmpPath = "tmp/" + DateFormatUtils.format(new Date(), "yyyyMMddHHmmss", Locale.CHINA) + "/";
|
||||
File tmpDir = new File(tmpPath);
|
||||
tmpDir.mkdirs();
|
||||
|
||||
List<NutMap> labelList = welfareSingleService.receivePageDataColumns(projectId);
|
||||
List<ExcelExportEntity> entityList = new ArrayList<>();
|
||||
labelList.forEach(v -> {
|
||||
entityList.add(new ExcelExportEntity(v.getString("label"), v.getString("prop"), v.getInt("width", 20)));
|
||||
});
|
||||
|
||||
//找出有哪几种福利商品
|
||||
WelfareProjectSubject welfareProjectSubject = dao.fetch(WelfareProjectSubject.class, Cnd.where("projectId", "=", projectId));
|
||||
List<WelfareProjectSubjectOption> welfareProjectSubjectOptionList = dao.query(WelfareProjectSubjectOption.class, Cnd.where("subjectId", "=", welfareProjectSubject.getId()));
|
||||
|
||||
welfareProjectSubjectOptionList.forEach(v -> {
|
||||
List<NutMap> userList = list.stream().filter(u -> u.getString("optionName").equals(v.getOptionName())).collect(Collectors.toList());
|
||||
FileOutputStream outputStream = null;
|
||||
try {
|
||||
|
||||
ExportParams exportParams = new ExportParams();
|
||||
exportParams.setType(ExcelType.XSSF);
|
||||
|
||||
outputStream = new FileOutputStream(tmpPath + v.getOptionName() + ".xlsx");
|
||||
Workbook workbook = ExcelExportUtil.exportExcel(exportParams, entityList, userList);
|
||||
workbook.write(outputStream);
|
||||
workbook.close();
|
||||
outputStream.close();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
});
|
||||
String aimsDir = "zipTmp/" + R.UU32();
|
||||
String aimsName = fileName + ".zip";
|
||||
|
||||
File zip = ZipUtil.zip(tmpDir.getPath());
|
||||
|
||||
response.setHeader("content-disposition", "attachment;filename="
|
||||
+ URLEncoder.encode(zip.getName(), StandardCharsets.UTF_8));
|
||||
|
||||
FileInputStream fileInputStream = new FileInputStream(zip);
|
||||
IOUtils.copy(fileInputStream, response.getOutputStream());
|
||||
fileInputStream.close();
|
||||
}
|
||||
|
||||
/**
|
||||
* 按套餐导出
|
||||
*
|
||||
* @param projectId
|
||||
* @param response
|
||||
*/
|
||||
@PostMapping("/exportByOption")
|
||||
public void exportByOption(String projectId, HttpServletResponse response) {
|
||||
try (ServletOutputStream outputStream = response.getOutputStream()) {
|
||||
|
||||
WelfareProject project = dao.fetch(WelfareProject.class, projectId);
|
||||
|
||||
//查询套餐数据
|
||||
List<NutMap> optionList = welfareSingleService.getOptionByProjectId(projectId);
|
||||
|
||||
//选择数据
|
||||
List<NutMap> userSelections = welfareSingleService.getUserSelectionByProjectId(projectId);
|
||||
|
||||
List<ExcelExportEntity> entityList = new ArrayList<>();
|
||||
entityList.add(new ExcelExportEntity("序号", "index", 20));
|
||||
entityList.add(new ExcelExportEntity("工号", "loginName", 20));
|
||||
entityList.add(new ExcelExportEntity("姓名", "userName", 20));
|
||||
|
||||
|
||||
if (project.getProvideMode().equals("6")) {
|
||||
entityList.add(new ExcelExportEntity("手机号", "userMobile", 20));
|
||||
entityList.add(new ExcelExportEntity("备用号码", "backUpMobile", 20));
|
||||
entityList.add(new ExcelExportEntity("派送时间", "deliveryTime", 20));
|
||||
for (NutMap optionMap : optionList) {
|
||||
entityList.add(new ExcelExportEntity(optionMap.getString("optionName"), optionMap.getString("id"), 20));
|
||||
}
|
||||
} else {
|
||||
entityList.add(new ExcelExportEntity("手机号", "mobile", 20));
|
||||
// if (Lang.isNotEmpty(optionList)) {
|
||||
// for (NutMap q : optionList) {
|
||||
// entityList.add(new ExcelExportEntity(q.getString("optionName"), q.getString("id"), 30));
|
||||
// }
|
||||
// }
|
||||
}
|
||||
entityList.add(new ExcelExportEntity("所属分工会", "unionName", 20));
|
||||
entityList.add(new ExcelExportEntity("所属工会小组", "unionGroupName", 20));
|
||||
|
||||
entityList.add(new ExcelExportEntity("所选套餐", "optionName", 20));
|
||||
entityList.add(new ExcelExportEntity("收货地址", "receiveAddress", 100));
|
||||
|
||||
// if (project.getProvideMode().equals("2")) {
|
||||
// entityList.add(new ExcelExportEntity("收货地址", "selectReceiveAddresss", 100));
|
||||
// }
|
||||
entityList.add(new ExcelExportEntity("选择日期", "selectTime", 20));
|
||||
entityList.add(new ExcelExportEntity("派送时间", "deliveryTime", 20));
|
||||
|
||||
|
||||
Sql sql = Sqls.create("""
|
||||
SELECT
|
||||
wl.loginName,
|
||||
wl.userName,
|
||||
u.mobile,
|
||||
wpus.mobile userMobile,
|
||||
wpus.backUpMobile,
|
||||
wpus.deliveryTime,
|
||||
wpso.isPost,
|
||||
wpus.receiveAddress,
|
||||
wpus.selectOptionId,
|
||||
wpso.optionName,
|
||||
date_format( wpus.selectTime, '%Y-%m-%d' ) selectTime,
|
||||
wl.unionName,
|
||||
wl.unionGroupName
|
||||
FROM
|
||||
welfare_list wl
|
||||
LEFT JOIN welfare_project_user_selection wpus ON wpus.selectUserId = wl.userId
|
||||
AND wpus.welfareId = wl.projectId
|
||||
LEFT JOIN welfare_project_subject_option wpso ON wpso.id = wpus.selectOptionId
|
||||
LEFT JOIN user u on u.userId = wl.userId
|
||||
$condition
|
||||
""");
|
||||
Cnd cnd = Cnd.NEW();
|
||||
cnd.and("wl.projectId", "=", projectId);
|
||||
// cnd.groupBy("wl.userId");
|
||||
cnd.desc("wpus.selectTime");
|
||||
cnd.desc("wl.unionName");
|
||||
cnd.desc("wl.unitName");
|
||||
cnd.desc("wl.unionGroupName");
|
||||
cnd.asc("wl.userId");
|
||||
cnd.desc("wpus.selectOptionId");
|
||||
|
||||
if (!AuthUtil.hasAnyRole("admin,A06")) {
|
||||
if (AuthUtil.hasRole("H04")) {
|
||||
cnd.and("wl.unionId", "=", SecurityUtils.getUnionId());
|
||||
}
|
||||
}
|
||||
|
||||
sql.setCondition(cnd);
|
||||
|
||||
List<NutMap> list = welfareSingleService.listMap(sql);
|
||||
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
// String userSelectsStr = list.get(i).getString("userSelects");
|
||||
// List<NutMap> userSelects = Json.fromJsonAsList(NutMap.class, userSelectsStr);
|
||||
// for (NutMap userSelect : userSelects) {
|
||||
// list.get(i).put(userSelect.getString("selectOptionId"), userSelect.getInt("selectNum") == 1 ? '√' : ("×" + userSelect.getInt("selectNum")));
|
||||
// }
|
||||
list.get(i).put("index", i + 1);
|
||||
}
|
||||
|
||||
ExportParams exportParams = new ExportParams();
|
||||
exportParams.setType(ExcelType.XSSF);
|
||||
exportParams.setTitle(project.getName() + "汇总表");
|
||||
Workbook workbook = ExcelExportUtil.exportExcel(exportParams, entityList, list);
|
||||
response.setContentType("application/octet-stream");
|
||||
response.setHeader("Content-Disposition", "attachment;filename=%s".formatted(URLEncoder.encode(project.getName() + "汇总表.xlsx", StandardCharsets.UTF_8)));
|
||||
workbook.write(outputStream);
|
||||
workbook.close();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
log.error(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@PostMapping("/exportOptionSheet")
|
||||
@Ok("void")
|
||||
public void exportOptionSheet(String projectId, HttpServletResponse response) {
|
||||
try (ServletOutputStream outputStream = response.getOutputStream()) {
|
||||
WelfareProject project = dao.fetch(WelfareProject.class, projectId);
|
||||
//查询套餐数据
|
||||
List<NutMap> optionList = welfareSingleService.getOptionByProjectId(projectId);
|
||||
|
||||
//选择数据
|
||||
Sql sql = Sqls.create("""
|
||||
SELECT
|
||||
wl.loginName,
|
||||
wl.userName,
|
||||
wl.unionName,
|
||||
wl.unionGroupName,
|
||||
u.mobile,
|
||||
wpus.mobile userMobile,
|
||||
wpus.backUpMobile,
|
||||
wpus.deliveryTime,
|
||||
wpus.selectOptionId,
|
||||
wpus.selectTime,
|
||||
wpus.userSign,
|
||||
wpus.selectNum,
|
||||
wpus.receiveAddress,
|
||||
wpus.account,
|
||||
wpus.password
|
||||
FROM
|
||||
`welfare_project_user_selection` wpus
|
||||
LEFT JOIN welfare_list wl ON wl.userId = wpus.selectUserId
|
||||
AND wl.projectId = @projectId
|
||||
LEFT JOIN user u ON u.userId = wl.userId
|
||||
WHERE
|
||||
wpus.welfareId = @projectId
|
||||
ORDER BY
|
||||
wl.unionName ASC,
|
||||
wl.unionGroupName ASC,
|
||||
wl.unitName ASC,
|
||||
wl.userName ASC
|
||||
""");
|
||||
// GROUP BY
|
||||
// wpus.selectUserId,
|
||||
// wpus.selectOptionId
|
||||
sql.setParam("projectId",projectId);
|
||||
List<NutMap> selectionList = welfareSingleService.listMap(sql);
|
||||
|
||||
Workbook workbook = new XSSFWorkbook();
|
||||
for (NutMap optionMap : optionList) {
|
||||
|
||||
List<ExcelExportEntity> entityList = new ArrayList<>();
|
||||
entityList.add(new ExcelExportEntity("序号", "index", 20));
|
||||
entityList.add(new ExcelExportEntity("工号", "loginName", 20));
|
||||
entityList.add(new ExcelExportEntity("姓名", "userName", 20));
|
||||
entityList.add(new ExcelExportEntity("手机号", "mobile", 20));
|
||||
// 充值会员卡工作表额外展示用户下单时确认的充值号码。
|
||||
if ("3".equals(optionMap.getString("optionType"))) {
|
||||
entityList.add(new ExcelExportEntity("充值手机号", "userMobile", 20));
|
||||
}
|
||||
entityList.add(new ExcelExportEntity("所属分工会", "unionName", 20));
|
||||
entityList.add(new ExcelExportEntity("所属工会小组", "unionGroupName", 20));
|
||||
if (optionMap.getInt("isPost")==1) {
|
||||
entityList.add(new ExcelExportEntity("收货地址", "receiveAddress", 100));
|
||||
}
|
||||
if (optionMap.getInt("isDeliveryTime")==1) {
|
||||
entityList.add(new ExcelExportEntity("配送时间", "deliveryTime", 25));
|
||||
}
|
||||
entityList.add(new ExcelExportEntity("选择日期", "selectTime", 25));
|
||||
// 蛋糕卡需要将导入的领取账号和密码追加在工作表最后,其他套餐保持原有表头不变。
|
||||
if ("蛋糕卡".equals(optionMap.getString("optionName"))) {
|
||||
entityList.add(new ExcelExportEntity("账号", "account", 25));
|
||||
entityList.add(new ExcelExportEntity("密码", "password", 25));
|
||||
}
|
||||
|
||||
ExcelExportService service = new ExcelExportService();
|
||||
ExportParams exportParams = new ExportParams();
|
||||
exportParams.setType(ExcelType.XSSF);
|
||||
exportParams.setTitle(optionMap.getString("optionName"));
|
||||
exportParams.setSheetName(optionMap.getString("optionName"));
|
||||
List<NutMap> list = selectionList.stream().filter(selection -> StrUtil.isNotBlank(selection.getString("selectOptionId")) && selection.getString("selectOptionId").equals(optionMap.getString("id"))).collect(Collectors.toList());
|
||||
list.forEach(item -> item.put("index", list.indexOf(item) + 1));
|
||||
service.createSheetForMap(workbook, exportParams, entityList, list);
|
||||
}
|
||||
|
||||
response.setContentType("application/octet-stream");
|
||||
response.setHeader("Content-Disposition", "attachment;filename=%s".formatted(URLEncoder.encode(project.getName() + "套餐选择统计表.xlsx", StandardCharsets.UTF_8)));
|
||||
workbook.write(outputStream);
|
||||
workbook.close();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
log.error(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 下载套餐账号密码导入模板。
|
||||
*
|
||||
* @param projectId 福利项目ID,模板人员限定在该项目内
|
||||
* @param optionId 套餐选项ID,模板仅带出选择该套餐的人员
|
||||
* @param response HTTP 下载响应,返回内容为 XSSF 格式的 Excel 文件
|
||||
* @throws Exception 模板生成或文件输出失败时抛出异常
|
||||
*/
|
||||
@PostMapping("/downloadAccountPasswordTemplate")
|
||||
@Ok("void")
|
||||
public void downloadAccountPasswordTemplate(@RequestParam String projectId,
|
||||
@RequestParam String optionId,
|
||||
HttpServletResponse response) throws Exception {
|
||||
try (Workbook workbook = welfareSingleService.buildAccountPasswordTemplate(projectId, optionId);
|
||||
ServletOutputStream outputStream = response.getOutputStream()) {
|
||||
response.setContentType("application/octet-stream");
|
||||
response.setHeader("Content-Disposition", "attachment;filename=%s".formatted(
|
||||
URLEncoder.encode("套餐账号密码导入模板.xlsx", StandardCharsets.UTF_8)));
|
||||
workbook.write(outputStream);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 导入套餐账号密码。
|
||||
*
|
||||
* @param projectId 福利项目ID
|
||||
* @param optionId 套餐选项ID,账号密码只更新该套餐的选择记录
|
||||
* @param file 包含工号、姓名、账号、密码四列的 xls/xlsx 文件
|
||||
* @return AjaxResult;成功时 msg 说明导入人数,校验失败时返回对应提示
|
||||
*/
|
||||
@PostMapping("/importAccountPassword")
|
||||
public AjaxResult importAccountPassword(@RequestParam String projectId,
|
||||
@RequestParam String optionId,
|
||||
@RequestParam("file") MultipartFile file) {
|
||||
if (StrUtil.hasBlank(projectId, optionId) || file == null || file.isEmpty()) {
|
||||
return AjaxResult.warn("福利项目、套餐和导入文件不能为空");
|
||||
}
|
||||
String originalFilename = file.getOriginalFilename();
|
||||
String lowerFilename = StrUtil.blankToDefault(originalFilename, "").toLowerCase(Locale.ROOT);
|
||||
if (!lowerFilename.endsWith(".xls") && !lowerFilename.endsWith(".xlsx")) {
|
||||
return AjaxResult.warn("请上传xls/xlsx文件");
|
||||
}
|
||||
int importedCount = welfareSingleService.importAccountPassword(projectId, optionId, file);
|
||||
return AjaxResult.success("成功导入" + importedCount + "人账号密码");
|
||||
}
|
||||
|
||||
}
|
||||
+92
@@ -0,0 +1,92 @@
|
||||
package com.ruoyi.staffService.welfare.controller;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.ruoyi.common.core.domain.PageForm;
|
||||
import com.ruoyi.common.core.page.Pagination;
|
||||
import com.ruoyi.common.core.web.domain.AjaxResult;
|
||||
import com.ruoyi.staffService.api.constant.welfare.WelfareUnitMode;
|
||||
import com.ruoyi.staffService.api.domain.welfare.WelfareUnit;
|
||||
import com.ruoyi.staffService.constant.Ds;
|
||||
import com.ruoyi.staffService.util.ProModuleDS;
|
||||
import com.ruoyi.staffService.welfare.service.StaffWelfareUnitManageService;
|
||||
import com.ruoyi.system.api.domain.SysDept;
|
||||
import org.nutz.dao.Cnd;
|
||||
import org.nutz.dao.Dao;
|
||||
import org.nutz.dao.util.cri.SqlExpressionGroup;
|
||||
import org.nutz.lang.util.NutMap;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 福利单位管理
|
||||
*
|
||||
* @author jug
|
||||
* @date 2023/02/20
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/welfare/unitManage")
|
||||
public class StaffWelfareUnitManageController {
|
||||
|
||||
@Autowired
|
||||
private StaffWelfareUnitManageService unitManageService;
|
||||
|
||||
@Autowired
|
||||
private Dao dao;
|
||||
|
||||
@GetMapping("/tree")
|
||||
public AjaxResult tree() {
|
||||
List<NutMap> list = unitManageService.treeData();
|
||||
return AjaxResult.success(list);
|
||||
}
|
||||
|
||||
@PostMapping("/pageData")
|
||||
public AjaxResult pageData(@RequestBody PageForm pageForm, @RequestParam(required = false) String welfareUnitName) {
|
||||
Pagination pagination = unitManageService.pageData(pageForm, welfareUnitName);
|
||||
return AjaxResult.success(pagination);
|
||||
}
|
||||
|
||||
@PostMapping("/update")
|
||||
public AjaxResult update(@RequestBody WelfareUnit welfareUnit) {
|
||||
unitManageService.updateIgnoreNull(welfareUnit);
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
@PostMapping("/add")
|
||||
public AjaxResult add(@RequestBody WelfareUnit welfareUnit) {
|
||||
String modeName = WelfareUnitMode.getMode().name();
|
||||
welfareUnit.setWelfareUnitMode(modeName);
|
||||
unitManageService.insert(welfareUnit);
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
@PostMapping("/remove")
|
||||
public AjaxResult remove(@RequestParam String id) {
|
||||
unitManageService.delete(id);
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
@GetMapping("/getTransferData")
|
||||
public AjaxResult getTransferData(@RequestParam String welfareUnitId) {
|
||||
Cnd cnd = Cnd.NEW();
|
||||
cnd.and("unitLevel", "=", 2);
|
||||
SqlExpressionGroup seg = new SqlExpressionGroup();
|
||||
seg.or("welfareUnitId", "is", null);
|
||||
seg.or("welfareUnitId", "=", "");
|
||||
seg.or("welfareUnitId", "=", welfareUnitId);
|
||||
cnd.and(seg);
|
||||
List<SysDept> data = ProModuleDS.exec(Ds.SYSTEM, () -> dao.query(SysDept.class, cnd));
|
||||
List<SysDept> value = data.stream().filter(v -> StrUtil.isNotBlank(v.getWelfareUnitId()) && v.getWelfareUnitId().equals(welfareUnitId) && v.getUnitLevel() != null && v.getUnitLevel() == 2).collect(Collectors.toList());
|
||||
return AjaxResult.success(Map.of("data", data, "value", value));
|
||||
}
|
||||
|
||||
@PostMapping("/setComponentUnit")
|
||||
public AjaxResult setComponentUnit(@RequestBody Long[] deptIds, @RequestParam String welfareUnitId) {
|
||||
unitManageService.setComponentUnit(deptIds, welfareUnitId);
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
}
|
||||
+131
@@ -0,0 +1,131 @@
|
||||
package com.ruoyi.staffService.welfare.controller;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.ruoyi.common.core.domain.PageForm;
|
||||
import com.ruoyi.common.core.page.Pagination;
|
||||
import com.ruoyi.common.core.web.domain.AjaxResult;
|
||||
import com.ruoyi.common.security.annotation.RequiresPermissions;
|
||||
import com.ruoyi.common.security.auth.AuthUtil;
|
||||
import com.ruoyi.common.security.utils.SecurityUtils;
|
||||
import com.ruoyi.staffService.api.constant.welfare.WelfareMemberPageForm;
|
||||
import com.ruoyi.staffService.api.domain.welfare.WelfareUserSelection;
|
||||
import com.ruoyi.staffService.welfare.param.WelfareUserSelectionDeleteParam;
|
||||
import com.ruoyi.staffService.welfare.service.StaffWelfareSingleService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
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.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* 福利选择详情
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/welfare/statistics/selectDetail")
|
||||
@Slf4j
|
||||
public class WelfareSelectDetailController {
|
||||
|
||||
@Resource
|
||||
private StaffWelfareSingleService welfareSingleService;
|
||||
|
||||
/**
|
||||
* 页面数据
|
||||
*
|
||||
* @param pageForm
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/pageData")
|
||||
@RequiresPermissions("staffService:welfare:statistics:selectDetail")
|
||||
public AjaxResult pageData(@RequestBody WelfareMemberPageForm pageForm,
|
||||
@RequestParam(required = false) String projectId,
|
||||
@RequestParam(required = false) Boolean isSelect) {
|
||||
// 选择情况按用户聚合;充值会员卡(类型 3)在套餐名称后拼接下单时确认的手机号。
|
||||
Sql sql = Sqls.create("""
|
||||
SELECT
|
||||
wl.userId,
|
||||
wl.loginName,
|
||||
wl.userName,
|
||||
wl.sex,
|
||||
wl.userState,
|
||||
wl.personType,
|
||||
wl.unionName,
|
||||
wl.unionGroupName,
|
||||
wl.unitName,
|
||||
wl.threeUnitName,
|
||||
wl.mobile,
|
||||
GROUP_CONCAT(DISTINCT CONCAT(
|
||||
wpso.optionName,
|
||||
IF(wpso.optionType = '3' AND wpus.mobile IS NOT NULL AND wpus.mobile != '', CONCAT('-', wpus.mobile), ''),
|
||||
IF(wp.multiSelect, CONCAT(' (×', CAST(wpus.selectNum AS CHAR), ')'), '')
|
||||
)) AS selectOptionNames,
|
||||
GROUP_CONCAT( wpso.optionName, ' (' , wpus.receiveAddress , ')' ) AS selectReceiveAddresss,
|
||||
wpus.userSign,
|
||||
wpus.mobile userMobile,
|
||||
wpus.backUpMobile,
|
||||
wpus.deliveryTime
|
||||
FROM
|
||||
welfare_list wl
|
||||
LEFT JOIN welfare_project_user_selection wpus ON wpus.selectUserId = wl.userId AND wpus.welfareId = @projectId
|
||||
LEFT JOIN welfare_project_subject_option wpso ON wpso.id = wpus.selectOptionId
|
||||
LEFT JOIN welfare_project wp on wp.id = wl.projectId
|
||||
$condition
|
||||
""");
|
||||
sql.setParam("projectId",projectId);
|
||||
Cnd cnd = Cnd.NEW();
|
||||
cnd.and("wl.projectId", "=", projectId);
|
||||
if (isSelect != null) {
|
||||
if (isSelect) {
|
||||
cnd.and("wpus.selectOptionId", "is not", null);
|
||||
} else {
|
||||
cnd.and("wpus.selectOptionId", "is", null);
|
||||
}
|
||||
}
|
||||
|
||||
if (StrUtil.isNotBlank(pageForm.getSearchKeyword())) {
|
||||
SqlExpressionGroup seg = new SqlExpressionGroup();
|
||||
seg.orLike("wl.loginName", pageForm.getSearchKeyword());
|
||||
seg.orLike("wl.userName", pageForm.getSearchKeyword());
|
||||
cnd.and(seg);
|
||||
}
|
||||
|
||||
|
||||
cnd.groupBy("wl.userId");
|
||||
if (!AuthUtil.hasAnyRole("admin,A06")) {
|
||||
if (AuthUtil.hasRole("H04")) {
|
||||
cnd.and("wl.unionId", "=", SecurityUtils.getUnionId());
|
||||
} else if (AuthUtil.hasRole("unionGroupLeader")) {
|
||||
cnd.and("wl.unionId", "=", SecurityUtils.getUnionId());
|
||||
SqlExpressionGroup seg = new SqlExpressionGroup();
|
||||
seg.or("wl.unionGroupId", "in", SecurityUtils.getManageUnionGroupIds());
|
||||
cnd.and(seg);
|
||||
}
|
||||
}
|
||||
|
||||
cnd.andEX("wl.unionId", "=", pageForm.getUnionId());
|
||||
cnd.andEX("wl.unionGroupId", "=", pageForm.getUnionGroupId());
|
||||
cnd.andEX("wl.threeUnitId", "=", pageForm.getThreeUnitId());
|
||||
cnd.andEX("wl.unitId", "=", pageForm.getUnitId());
|
||||
|
||||
sql.setCondition(cnd);
|
||||
Pagination pagination = welfareSingleService.listPageMap(pageForm.getPageNumber(), pageForm.getPageSize(), sql);
|
||||
return AjaxResult.success(pagination);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除用户选择的数据
|
||||
* @param param
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/clearSelection")
|
||||
@RequiresPermissions("staffService:welfare:statistics:selectDetail")
|
||||
public AjaxResult clearSelection(@RequestBody @Validated WelfareUserSelectionDeleteParam param){
|
||||
welfareSingleService.dao().clear(WelfareUserSelection.class,Cnd.where(WelfareUserSelection::getWelfareId,"=",param.getWelfareId())
|
||||
.and(WelfareUserSelection::getSelectUserId,"in",param.getUserIds()));
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
}
|
||||
+93
@@ -0,0 +1,93 @@
|
||||
package com.ruoyi.staffService.welfare.controller.jd;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.ruoyi.common.core.web.domain.AjaxResult;
|
||||
import com.ruoyi.common.security.utils.SecurityUtils;
|
||||
import com.ruoyi.staffService.api.constant.welfare.JD.SignatureUtil;
|
||||
import com.ruoyi.staffService.api.constant.welfare.JD.WelfareJDAutoLoginParam;
|
||||
import com.ruoyi.staffService.api.constant.welfare.JD.WelfareJDAutoLoginParamUtil;
|
||||
import com.ruoyi.staffService.api.constant.welfare.JD.WelfareJDConstant;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nutz.dao.Dao;
|
||||
import org.nutz.dao.Sqls;
|
||||
import org.nutz.dao.sql.Sql;
|
||||
import org.nutz.dao.util.Daos;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.TreeMap;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* 福利jd自动登录
|
||||
*
|
||||
* @author jug
|
||||
* @date 2023/06/14
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/welfare/jd/autoLogin")
|
||||
@Slf4j
|
||||
public class StaffWelfareJdAutoLoginController {
|
||||
|
||||
@Autowired
|
||||
private Dao dao;
|
||||
|
||||
@RequestMapping("/getAutoLoginUrl")
|
||||
public AjaxResult getAutoLoginUrl() {
|
||||
String domain = "jxi-fuli-m.jd.com";
|
||||
String returnUrl = "https://" + domain + "/newIndex?activityCode=" + WelfareJDConstant.accessKey; // "&thirdAppPath="用于指向性返回的客户端路径(仅限于小程序环境),默认返回index页
|
||||
// String userId = "17621374553"; //需替换为自身系统中的用户唯一标识,长度不能超过50,例如手机号、邮箱、工号、账号等
|
||||
Sql sql = Sqls.create("select mobile from user where userId = @userId").setParam("userId", SecurityUtils.getUserId());
|
||||
String mobile = (String)Daos.query(dao, sql.toString(), Sqls.callback.str());
|
||||
if (StrUtil.isBlank(mobile)) {
|
||||
return AjaxResult.error("请联系校工会完善自己的手机号!");
|
||||
}
|
||||
String extend = "{}"; //扩展字段使用方式详见接口文档
|
||||
String version = "V1.0";
|
||||
String logindomain = "jxi-fuli-login.jd.com";
|
||||
String autoLoginUrl = "https://" + logindomain + "/autoLogin?appTarget=5&loginCode=" + WelfareJDConstant.accessKey;
|
||||
try {
|
||||
WelfareJDAutoLoginParam autoLoginParam = WelfareJDAutoLoginParamUtil.getAutoLoginParam(WelfareJDConstant.rsaSignPrivateKey, WelfareJDConstant.rsaEncryptPublicKey, WelfareJDConstant.accessKey, returnUrl, mobile, extend, version);
|
||||
String url = generateUrl(autoLoginParam, autoLoginUrl);
|
||||
return AjaxResult.success().put("data", url);
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage());
|
||||
return AjaxResult.error("系统错误");
|
||||
}
|
||||
}
|
||||
|
||||
private static String generateUrl(Object o, String title) throws IllegalAccessException {
|
||||
if (o instanceof String) {
|
||||
return title + ":" + o.toString();
|
||||
}
|
||||
TreeMap paramMap = SignatureUtil.objectToMap(o);
|
||||
StringBuilder sb = new StringBuilder();
|
||||
Iterator iterator1 = paramMap.entrySet().iterator();
|
||||
|
||||
while (iterator1.hasNext()) {
|
||||
Map.Entry result1 = (Map.Entry) iterator1.next();
|
||||
if (result1.getValue() != null && ((String) result1.getValue()).trim().length() > 0) {
|
||||
sb.append(result1.getKey() + "=" + replaceBlank(((String) result1.getValue()).trim()) + "&");
|
||||
}
|
||||
}
|
||||
String url = title + "&" + sb.toString();
|
||||
url = url.replaceAll("\\+", "%2B");
|
||||
return url;
|
||||
}
|
||||
|
||||
public static String replaceBlank(String str) {
|
||||
String dest = "";
|
||||
if (str != null) {
|
||||
Pattern p = Pattern.compile("\\s*|\t|\r|");
|
||||
Matcher m = p.matcher(str);
|
||||
dest = m.replaceAll("");
|
||||
}
|
||||
return dest;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
+106
@@ -0,0 +1,106 @@
|
||||
package com.ruoyi.staffService.welfare.controller.mobile;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.ruoyi.common.core.domain.PageForm;
|
||||
import com.ruoyi.common.core.page.Pagination;
|
||||
import com.ruoyi.common.core.web.domain.AjaxResult;
|
||||
import com.ruoyi.common.security.annotation.Logical;
|
||||
import com.ruoyi.common.security.annotation.RequiresRoles;
|
||||
import com.ruoyi.common.security.utils.SecurityUtils;
|
||||
import com.ruoyi.staffService.api.constant.welfare.WelfareProvideMode;
|
||||
import com.ruoyi.staffService.api.domain.welfare.WelfareMemberSupermarket;
|
||||
import com.ruoyi.staffService.api.domain.welfare.WelfareProject;
|
||||
import com.ruoyi.staffService.api.domain.welfare.WelfareProjectSubject;
|
||||
import com.ruoyi.staffService.welfare.service.StaffWelfareMemberListService;
|
||||
import com.ruoyi.staffService.welfare.service.StaffWelfareProjectMangeService;
|
||||
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.lang.util.NutMap;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @ClassName MStaWelfareController
|
||||
* @Description TODO
|
||||
* @Author zhf
|
||||
* @Date 2023/3/5 10:30
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/mobile/welfare/list")
|
||||
public class MStaWelfareController {
|
||||
|
||||
|
||||
@Autowired
|
||||
private StaffWelfareMemberListService welfareMemberListService;
|
||||
|
||||
@Autowired
|
||||
private StaffWelfareProjectMangeService welfareProjectMangeService;
|
||||
|
||||
|
||||
@PostMapping("/pageData")
|
||||
@RequiresRoles(value = {"admin", "H01", "common"}, logical = Logical.OR)
|
||||
public AjaxResult pageData(@RequestBody PageForm pageForm, @RequestParam String tabName) {
|
||||
|
||||
Sql sql = Sqls.create("""
|
||||
SELECT *,
|
||||
( SELECT count( 1 ) > 0 FROM welfare_project_user_selection WHERE welfareId = welfare_project.id AND selectUserId = @selectUserId ) AS isSelect,
|
||||
( SELECT count( 1 ) > 0 FROM welfare_list WHERE projectId = welfare_project.id AND userId = @selectUserId AND isReceive IS TRUE ) AS isReceive
|
||||
FROM
|
||||
welfare_project
|
||||
$condition
|
||||
""");
|
||||
|
||||
sql = Sqls.create("""
|
||||
SELECT
|
||||
wp.*
|
||||
FROM
|
||||
welfare_list wl
|
||||
RIGHT JOIN welfare_project wp ON wp.id = wl.projectId
|
||||
$condition
|
||||
""");
|
||||
|
||||
Cnd cnd = Cnd.NEW();
|
||||
cnd.and("wl.userId", "=", SecurityUtils.getUserId());
|
||||
|
||||
if (tabName.equals("ing")) {
|
||||
cnd.and(Cnd.exps("wp.choiceTimeStart", "<", DateUtil.now()).and("wp.choiceTimeEnd", ">", DateUtil.now()));
|
||||
} else if (tabName.equals("end")) {
|
||||
cnd.and("wp.choiceTimeEnd", "<", DateUtil.now());
|
||||
}
|
||||
cnd.groupBy("wp.id");
|
||||
sql.setCondition(cnd);
|
||||
Pagination pagination = welfareMemberListService.listPageMap(pageForm.getPageNumber(), pageForm.getPageSize(), sql);
|
||||
List<NutMap> list = pagination.getList();
|
||||
pagination.setList(list);
|
||||
return AjaxResult.success(pagination);
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("/findOne")
|
||||
@RequiresRoles(value = {"admin", "H01"}, logical = Logical.OR)
|
||||
public AjaxResult findOne(String projectId) {
|
||||
WelfareProject welfareProject = welfareProjectMangeService.projectInfo(projectId);
|
||||
|
||||
return AjaxResult.success(welfareProject);
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否为商超卡福利
|
||||
*
|
||||
* @param projectId 项目id
|
||||
* @return {@link AjaxResult}
|
||||
*/
|
||||
@GetMapping("/isSuperMarketCard")
|
||||
@RequiresRoles(value = {"admin", "H01", "common"}, logical = Logical.OR)
|
||||
public AjaxResult isSuperMarketCard(@RequestParam String projectId) {
|
||||
WelfareMemberSupermarket memberSupermarket = welfareMemberListService.dao().fetch(WelfareMemberSupermarket.class, Cnd.where("welfareId", "=", projectId).and("userId", "=", SecurityUtils.getUserId()));
|
||||
return AjaxResult.success(memberSupermarket);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
+328
@@ -0,0 +1,328 @@
|
||||
package com.ruoyi.staffService.welfare.controller.mobile;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.ruoyi.common.core.web.domain.AjaxResult;
|
||||
import com.ruoyi.common.security.annotation.Logical;
|
||||
import com.ruoyi.common.security.annotation.RequiresLogin;
|
||||
import com.ruoyi.common.security.annotation.RequiresRoles;
|
||||
import com.ruoyi.common.security.utils.SecurityUtils;
|
||||
import com.ruoyi.staffService.api.constant.welfare.WelfareProvideMode;
|
||||
import com.ruoyi.staffService.api.domain.welfare.WelfareList;
|
||||
import com.ruoyi.staffService.api.domain.welfare.WelfareMemberAddress;
|
||||
import com.ruoyi.staffService.api.domain.welfare.WelfareProjectSubject;
|
||||
import com.ruoyi.staffService.api.domain.welfare.WelfareUserSelection;
|
||||
import com.ruoyi.staffService.welfare.service.StaffWelfareMemberListService;
|
||||
import com.ruoyi.staffService.welfare.service.StaffWelfareMemberService;
|
||||
import com.ruoyi.staffService.welfare.service.StaffWelfareProjectMangeService;
|
||||
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.lang.util.NutMap;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @ClassName MStaWelfareMineController
|
||||
* @Description TODO
|
||||
* @Author zhf
|
||||
* @Date 2023/3/5 10:08
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/mobile/welfare/mine")
|
||||
public class MStaWelfareMineController {
|
||||
|
||||
|
||||
@Autowired
|
||||
private StaffWelfareMemberService welfareMemberService;
|
||||
|
||||
@Autowired
|
||||
private StaffWelfareMemberListService welfareMemberListService;
|
||||
|
||||
@Autowired
|
||||
private StaffWelfareProjectMangeService welfareProjectMangeService;
|
||||
|
||||
@Resource
|
||||
private Dao dao;
|
||||
|
||||
|
||||
/**
|
||||
* @return com.ruoyi.common.core.web.domain.AjaxResult
|
||||
* @author zhf
|
||||
* @description 地址列表
|
||||
*/
|
||||
@GetMapping("/selectUserAddress")
|
||||
public AjaxResult selectUserAddress() {
|
||||
Sql sql = Sqls.create("""
|
||||
SELECT
|
||||
id,
|
||||
userName AS `name`,
|
||||
tel,
|
||||
addressDetail AS address,
|
||||
isDefault,
|
||||
province,
|
||||
city,
|
||||
county
|
||||
FROM
|
||||
`welfare_member_address`
|
||||
WHERE userId = @userId
|
||||
""");
|
||||
sql.setParam("userId", SecurityUtils.getUserId());
|
||||
return AjaxResult.success(welfareMemberService.listMap(sql));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param projectId
|
||||
* @return com.ruoyi.common.core.web.domain.AjaxResult
|
||||
* @author zhf
|
||||
* @description 是否选择
|
||||
*/
|
||||
@GetMapping("/isChoice")
|
||||
public AjaxResult isChoice(String projectId) {
|
||||
int count = welfareMemberListService.dao().count(WelfareUserSelection.class, Cnd.where("welfareId", "=", projectId).and("selectUserId", "=", SecurityUtils.getUserId()));
|
||||
return AjaxResult.success(count > 0);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param projectId
|
||||
* @return com.ruoyi.common.core.web.domain.AjaxResult
|
||||
* @author zhf
|
||||
* @description 用户选择数据
|
||||
*/
|
||||
@GetMapping("/getUserSelection")
|
||||
public AjaxResult getUserSelection(String projectId) {
|
||||
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,
|
||||
wpus.mobile,
|
||||
wpus.backUpMobile,
|
||||
wpus.deliveryTime,
|
||||
wpus.selectNum
|
||||
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", SecurityUtils.getUserId());
|
||||
return AjaxResult.success(welfareMemberService.listMap(sql));
|
||||
}
|
||||
|
||||
|
||||
@PostMapping("/confirmSelect")
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public AjaxResult doChoice(@RequestBody WelfareUserSelection[] welfareUserSelections, @RequestParam String projectId) {
|
||||
//删除上次选择的
|
||||
dao.clear(WelfareUserSelection.class, Cnd.where("welfareId", "=", projectId).and("selectUserId", "=", SecurityUtils.getUserIdStr()));
|
||||
for (WelfareUserSelection welfareUserSelection : welfareUserSelections) {
|
||||
welfareUserSelection.setSelectUserId(SecurityUtils.getUserIdStr());
|
||||
welfareUserSelection.setSelectTime(new Date());
|
||||
}
|
||||
dao.insert(welfareUserSelections);
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param welfareMemberAddress
|
||||
* @return com.ruoyi.common.core.web.domain.AjaxResult
|
||||
* @author zhf
|
||||
* @description 保存地址
|
||||
*/
|
||||
@PostMapping("/doSaveUserAddress")
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public AjaxResult doSaveUserAddress(@RequestBody WelfareMemberAddress welfareMemberAddress) {
|
||||
if (welfareMemberAddress.getIsDefault()) {
|
||||
welfareMemberListService.dao().update(WelfareMemberAddress.class, Chain.make("isDefault", false), Cnd.where("userId", "=", SecurityUtils.getUserId()));
|
||||
}
|
||||
welfareMemberAddress.setUserId(SecurityUtils.getUserId().toString());
|
||||
welfareMemberListService.dao().insertOrUpdate(welfareMemberAddress);
|
||||
return AjaxResult.success("保存成功!");
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param id
|
||||
* @return com.ruoyi.common.core.web.domain.AjaxResult
|
||||
* @author zhf
|
||||
* @description 单个地址信息
|
||||
*/
|
||||
@GetMapping("/findOneUserAddress")
|
||||
public AjaxResult findOneUserAddress(String id) {
|
||||
Sql sql = Sqls.create("""
|
||||
SELECT
|
||||
*,
|
||||
userName AS `name`
|
||||
FROM
|
||||
`welfare_member_address`
|
||||
WHERE id = @id
|
||||
""");
|
||||
sql.setParam("id", id);
|
||||
return AjaxResult.success(welfareMemberListService.fetch(sql));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param id
|
||||
* @return java.lang.Object
|
||||
* @author zhf
|
||||
* @description 删除地址
|
||||
*/
|
||||
@DeleteMapping("/deleteAddress")
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public AjaxResult deleteAddress(String id) {
|
||||
welfareMemberListService.dao().clear(WelfareMemberAddress.class, Cnd.where("id", "=", id));
|
||||
return AjaxResult.success("删除成功!");
|
||||
|
||||
}
|
||||
|
||||
@PostMapping("/getMyWelfare")
|
||||
@RequiresRoles(value = {"admin", "H01", "common"}, logical = Logical.OR)
|
||||
public AjaxResult getMyWelfare(@RequestParam(required = false) String tabName) {
|
||||
Sql sql = Sqls.create("""
|
||||
SELECT
|
||||
wp.*,
|
||||
(select count(1) > 0 from welfare_project_user_selection where welfareId = wp.id and selectUserId = @userId) AS isChoice,
|
||||
(select count(1) > 0 from welfare_project_user_selection where welfareId = wp.id and selectUserId = @userId AND isReceive IS TRUE) AS isReceive
|
||||
FROM
|
||||
welfare_project wp
|
||||
$condition
|
||||
""");
|
||||
sql.setParam("userId", SecurityUtils.getUserId());
|
||||
Cnd cnd = Cnd.NEW();
|
||||
if (StrUtil.isNotBlank(tabName)) {
|
||||
if (tabName.equals("ing")) {
|
||||
cnd.and(Cnd.exps("wp.provideTimeStart", "<", DateUtil.now()).and("wp.provideTimeEnd", ">", DateUtil.now()))
|
||||
.or(Cnd.exps("wp.choiceTimeStart", "<", DateUtil.now()).and("wp.choiceTimeEnd", ">", DateUtil.now()));
|
||||
} else if (tabName.equals("end")) {
|
||||
cnd.and("wp.provideTimeEnd", "<", DateUtil.now());
|
||||
}
|
||||
}
|
||||
sql.setCondition(cnd);
|
||||
List<NutMap> list = welfareMemberListService.listMap(sql);
|
||||
list.forEach(v -> {
|
||||
v.put("isReceive", v.getInt("isReceive") == 1);
|
||||
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
|
||||
)
|
||||
""");
|
||||
sqlo.setParam("userid", SecurityUtils.getUserId());
|
||||
sqlo.setParam("welfareId", v.getString("id"));
|
||||
List<NutMap> optionNameList = welfareMemberListService.listMap(sqlo);
|
||||
v.setv("optionName", optionNameList.stream().map(x -> x.getString("optionName")).collect(Collectors.joining("、")));
|
||||
|
||||
|
||||
if (v.getString("provideMode").equals(WelfareProvideMode.WELFARE_UNIT.getCode())) {
|
||||
v.put("isReceive", true);
|
||||
}
|
||||
|
||||
if (v.getString("provideMode").equals(WelfareProvideMode.PERSON_CHOICE.getCode())) {
|
||||
WelfareProjectSubject subject = welfareMemberListService.dao().fetch(WelfareProjectSubject.class, Cnd.where("projectId", "=", v.getString("id")));
|
||||
v.put("gift", subject.getSubjectName());
|
||||
}
|
||||
if (v.getString("provideMode").equals(WelfareProvideMode.PERSONAL.getCode())) {
|
||||
Sql courierNumberSql = Sqls.create("select courierNumber from welfare_project_user_selection where welfareId = @welfareId and selectUserId = @userid");
|
||||
courierNumberSql.setParam("welfareId", v.getString("id"));
|
||||
courierNumberSql.setParam("userid", SecurityUtils.getUserId());
|
||||
NutMap courierNumberMap = welfareMemberListService.fetch(courierNumberSql);
|
||||
if (courierNumberMap == null) {
|
||||
v.setv("courierNumber", "暂无");
|
||||
} else {
|
||||
v.setv("courierNumber", courierNumberMap.getString("courierNumber", "暂无"));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
|
||||
return AjaxResult.success(list);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 查询我的福利
|
||||
*
|
||||
* @param year 年度
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/listMyWelfareList")
|
||||
@RequiresLogin
|
||||
public AjaxResult listMyWelfareList(@RequestParam(required = false) Integer year) {
|
||||
Sql sql = Sqls.create("""
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
`welfare_project`
|
||||
WHERE
|
||||
id IN (SELECT welfareId FROM welfare_project_user_selection WHERE selectUserId = @selectUserId)
|
||||
AND year = @year
|
||||
order by choiceTimeStart DESC
|
||||
""");
|
||||
sql.setParam("selectUserId", SecurityUtils.getUserId());
|
||||
sql.setParam("year", year);
|
||||
List<NutMap> list = welfareMemberService.listMap(sql);
|
||||
|
||||
for (NutMap row : list) {
|
||||
// 查询选择的套餐
|
||||
Sql sqlOption = Sqls.create("""
|
||||
SELECT
|
||||
t1.*,
|
||||
t2.optionName,
|
||||
t2.imgUrl,
|
||||
t2.price
|
||||
FROM
|
||||
welfare_project_user_selection t1
|
||||
left join welfare_project_subject_option t2 on t2.id = t1.selectOptionId
|
||||
WHERE
|
||||
t1.selectUserId = @selectUserId
|
||||
AND welfareId = @welfareId
|
||||
""");
|
||||
sqlOption.setParam("selectUserId", SecurityUtils.getUserId());
|
||||
sqlOption.setParam("welfareId", row.getString("id"));
|
||||
List<NutMap> optionList = welfareMemberService.listMap(sqlOption);
|
||||
row.put("optionList", optionList);
|
||||
if (!optionList.isEmpty()){
|
||||
row.put("userSelectTime", optionList.get(0).getString("selectTime"));
|
||||
}
|
||||
}
|
||||
return AjaxResult.success(list);
|
||||
}
|
||||
|
||||
|
||||
@PostMapping("/doReceive")
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@RequiresRoles(value = {"admin", "H01", "common"}, logical = Logical.OR)
|
||||
public AjaxResult doReceive(@RequestParam String projectId, @RequestBody HashMap<String, Object> map) {
|
||||
Object userSign = map.get("userSign");
|
||||
Dao dao = welfareMemberListService.dao();
|
||||
|
||||
Chain chain = Chain.make("isReceive", true).add("userSign", userSign);
|
||||
Cnd cnd = Cnd.where("welfareId", "=", projectId).and("selectUserId", "=", SecurityUtils.getUserId());
|
||||
dao.update(WelfareUserSelection.class, chain, cnd);
|
||||
|
||||
dao.update(WelfareList.class, Chain.make("isReceive", true), Cnd.where("projectId", "=", projectId).and("userId", "=", SecurityUtils.getUserId()));
|
||||
return AjaxResult.success();
|
||||
}
|
||||
}
|
||||
+90
@@ -0,0 +1,90 @@
|
||||
package com.ruoyi.staffService.welfare.handle;
|
||||
|
||||
import cn.hutool.core.util.EnumUtil;
|
||||
import com.baomidou.dynamic.datasource.annotation.DSTransactional;
|
||||
import com.ruoyi.common.core.utils.SpringUtils;
|
||||
import com.ruoyi.common.security.utils.SecurityUtils;
|
||||
import com.ruoyi.member.api.constant.MemberChangeOrigin;
|
||||
import com.ruoyi.staffService.api.constant.welfare.WelfareMemberChangeApplyState;
|
||||
import com.ruoyi.staffService.api.domain.common.Audit;
|
||||
import com.ruoyi.staffService.api.domain.welfare.WelfareMemberChangeRecord;
|
||||
import lombok.Getter;
|
||||
import org.nutz.dao.Dao;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 会员变更审核Handle
|
||||
*
|
||||
* @author: 1V
|
||||
* @date: 2021/1/27
|
||||
* @since 1.0
|
||||
*/
|
||||
@Getter
|
||||
public enum WelfareMemberChangeAuditHandle {
|
||||
/**
|
||||
* 创建
|
||||
*/
|
||||
CREATE(null) {
|
||||
@Override
|
||||
public WelfareMemberChangeRecord next(WelfareMemberChangeRecord record, Audit audit) {
|
||||
record.setApplyTime(new Date());
|
||||
if (record.getApplyOrigin() == MemberChangeOrigin.PERSONAL.getCode()) {
|
||||
record.setUserId(SecurityUtils.getUserId());
|
||||
record.setOriginUnitId(SecurityUtils.getDeptId());
|
||||
record.setOriginUnionId(SecurityUtils.getUnionId());
|
||||
record.setStateId(WelfareMemberChangeApplyState.UNION);
|
||||
} else if (record.getApplyOrigin() == MemberChangeOrigin.UNION.getCode()) {
|
||||
record.setStateId(WelfareMemberChangeApplyState.SCHOOL_UNION);
|
||||
} else if (record.getApplyOrigin() == MemberChangeOrigin.SCHOOL.getCode()) {
|
||||
record.setStateId(WelfareMemberChangeApplyState.SUCCESS);
|
||||
}
|
||||
return dao.insert(record);
|
||||
}
|
||||
},
|
||||
/**
|
||||
* 院级工会审核
|
||||
*/
|
||||
UNION(WelfareMemberChangeApplyState.UNION) {
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public WelfareMemberChangeRecord next(WelfareMemberChangeRecord record, Audit audit) {
|
||||
record.setStateId(audit.getAuditPass() ? WelfareMemberChangeApplyState.SCHOOL_UNION : WelfareMemberChangeApplyState.UNION_FAIL);
|
||||
record.setUnionAuditId(dao.insert(audit).getId());
|
||||
dao.update(record);
|
||||
return record;
|
||||
}
|
||||
},
|
||||
/**
|
||||
* 校工会审核
|
||||
*/
|
||||
SCHOOL(WelfareMemberChangeApplyState.SCHOOL_UNION) {
|
||||
@Override
|
||||
@DSTransactional
|
||||
public WelfareMemberChangeRecord next(WelfareMemberChangeRecord record, Audit audit) {
|
||||
record.setStateId(audit.getAuditPass() ? WelfareMemberChangeApplyState.SUCCESS : WelfareMemberChangeApplyState.SCHOOL_UNION_FAIL);
|
||||
record.setSchoolAuditId(dao.insert(audit).getId());
|
||||
|
||||
if (record.getStateId() == WelfareMemberChangeApplyState.SUCCESS) {
|
||||
WelfareMemberChangeHandle handle = EnumUtil.getBy(WelfareMemberChangeHandle.class, v -> v.getChangeType() == record.getType());
|
||||
handle.change(record);
|
||||
}
|
||||
|
||||
dao.update(record);
|
||||
|
||||
return record;
|
||||
}
|
||||
};
|
||||
|
||||
private Integer state;
|
||||
|
||||
WelfareMemberChangeAuditHandle(Integer state) {
|
||||
this.state = state;
|
||||
}
|
||||
|
||||
public Dao dao = SpringUtils.getBean(Dao.class);
|
||||
|
||||
public abstract WelfareMemberChangeRecord next(WelfareMemberChangeRecord record, Audit audit);
|
||||
|
||||
}
|
||||
+167
@@ -0,0 +1,167 @@
|
||||
package com.ruoyi.staffService.welfare.handle;
|
||||
|
||||
import com.ruoyi.common.core.utils.SpringUtils;
|
||||
import com.ruoyi.member.api.constant.UserChangeType;
|
||||
import com.ruoyi.staffService.api.domain.welfare.WelfareMemberChangeRecord;
|
||||
import com.ruoyi.staffService.constant.Ds;
|
||||
import com.ruoyi.staffService.util.ProModuleDS;
|
||||
import com.ruoyi.system.api.domain.SysUser;
|
||||
import lombok.Getter;
|
||||
import org.nutz.dao.Chain;
|
||||
import org.nutz.dao.Cnd;
|
||||
import org.nutz.dao.Dao;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
/**
|
||||
* 福利会员变更Handle
|
||||
*
|
||||
* @author: 1V
|
||||
* @date: 2021/1/27
|
||||
* @see UserChangeType
|
||||
* @since 1.0
|
||||
*/
|
||||
@Getter
|
||||
public enum WelfareMemberChangeHandle {
|
||||
|
||||
//单位异动
|
||||
UNIT_CHANGE(UserChangeType.UNIT_CHANGE.getCode()) {
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void change(WelfareMemberChangeRecord record) {
|
||||
archive(record.getUserId(), UserChangeType.UNIT_CHANGE);
|
||||
Chain chain = Chain.make("deptId", record.getCurrentUnitId());
|
||||
ProModuleDS.exec(Ds.SYSTEM, () -> dao.update(SysUser.class, chain, Cnd.where("userId", "=", record.getUserId())));
|
||||
}
|
||||
},
|
||||
//新入职
|
||||
NEW(UserChangeType.NEW.getCode()) {
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void change(WelfareMemberChangeRecord record) {
|
||||
WelfareUserMode.addMemberRole(record.getUserId(), record.getApplyOrigin());
|
||||
updateWelfareMember(record);
|
||||
updateMember(record);
|
||||
}
|
||||
},
|
||||
|
||||
//离职
|
||||
RESIGN(UserChangeType.RESIGN.getCode()) {
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void change(WelfareMemberChangeRecord record) {
|
||||
archive(record.getUserId(), UserChangeType.RESIGN);
|
||||
WelfareUserMode.removeMemberRole(record.getUserId());
|
||||
updateWelfareMember(record);
|
||||
updateMember(record);
|
||||
}
|
||||
},
|
||||
|
||||
//去世
|
||||
DIE(UserChangeType.DIE.getCode()) {
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void change(WelfareMemberChangeRecord record) {
|
||||
archive(record.getUserId(), UserChangeType.DIE);
|
||||
WelfareUserMode.removeMemberRole(record.getUserId());
|
||||
updateWelfareMember(record);
|
||||
updateMember(record);
|
||||
}
|
||||
},
|
||||
|
||||
//退休
|
||||
RETIREMENT(UserChangeType.RETIREMENT.getCode()) {
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void change(WelfareMemberChangeRecord record) {
|
||||
archive(record.getUserId(), UserChangeType.RETIREMENT);
|
||||
WelfareUserMode.removeMemberRole(record.getUserId());
|
||||
updateWelfareMember(record);
|
||||
updateMember(record);
|
||||
}
|
||||
},
|
||||
|
||||
//开除
|
||||
EXPELLED(UserChangeType.EXPELLED.getCode()) {
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void change(WelfareMemberChangeRecord record) {
|
||||
archive(record.getUserId(), UserChangeType.EXPELLED);
|
||||
WelfareUserMode.removeMemberRole(record.getUserId());
|
||||
updateWelfareMember(record);
|
||||
updateMember(record);
|
||||
}
|
||||
},
|
||||
|
||||
//恢复
|
||||
RESTORE(UserChangeType.RESTORE.getCode()) {
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void change(WelfareMemberChangeRecord record) {
|
||||
WelfareUserMode.addMemberRole(record.getUserId(), record.getApplyOrigin());
|
||||
updateWelfareMember(record);
|
||||
updateMember(record);
|
||||
}
|
||||
},
|
||||
|
||||
//退会
|
||||
WITHDRAWAL(UserChangeType.WITHDRAWAL.getCode()) {
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void change(WelfareMemberChangeRecord record) {
|
||||
WelfareUserMode.removeMemberRole(record.getUserId());
|
||||
updateWelfareMember(record);
|
||||
updateMember(record);
|
||||
}
|
||||
};
|
||||
|
||||
public static Dao dao = SpringUtils.getBean(Dao.class);
|
||||
|
||||
/**
|
||||
* 变更类型
|
||||
*/
|
||||
private final String changeType;
|
||||
|
||||
WelfareMemberChangeHandle(String changeType) {
|
||||
this.changeType = changeType;
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新福利会员
|
||||
*
|
||||
* @param record 变更记录
|
||||
*/
|
||||
public static void updateWelfareMember(WelfareMemberChangeRecord record) {
|
||||
Chain chain = Chain.make("welfareMember", record.getUpdateWelfareMember());
|
||||
ProModuleDS.exec(Ds.SYSTEM, () -> dao.update(SysUser.class, chain, Cnd.where("userId", "=", record.getUserId())));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 更新会员状态
|
||||
*
|
||||
* @param record 变更记录
|
||||
*/
|
||||
public static void updateMember(WelfareMemberChangeRecord record) {
|
||||
Chain chain = Chain.make("member", record.getUpdateWelfareMember());
|
||||
ProModuleDS.exec(Ds.SYSTEM, () -> dao.update(SysUser.class, chain, Cnd.where("userId", "=", record.getUserId())));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 存档
|
||||
*
|
||||
* @param userId
|
||||
* @param changeType
|
||||
*/
|
||||
private static void archive(Long userId, UserChangeType changeType) {
|
||||
// Sys_user user = sysUserService.fetch(userId);
|
||||
// UserHistory history = new UserHistory();
|
||||
// BeanUtils.copyProperties(user, history);
|
||||
// history.setChangeTime(new Date());
|
||||
// history.setChangeType(changeType.getCode());
|
||||
// sysUserService.insert(history);
|
||||
}
|
||||
|
||||
public abstract void change(WelfareMemberChangeRecord record);
|
||||
|
||||
}
|
||||
+113
@@ -0,0 +1,113 @@
|
||||
package com.ruoyi.staffService.welfare.handle;
|
||||
|
||||
|
||||
import com.ruoyi.common.core.utils.SpringUtils;
|
||||
import com.ruoyi.member.api.domain.MemberApplyRecord;
|
||||
import com.ruoyi.member.api.domain.MemberChangeRecord;
|
||||
import com.ruoyi.staffService.api.constant.welfare.WelfareMemberMode;
|
||||
import com.ruoyi.staffService.constant.Ds;
|
||||
import com.ruoyi.staffService.util.ProModuleDS;
|
||||
import com.ruoyi.system.api.domain.SysUser;
|
||||
import org.nutz.dao.Chain;
|
||||
import org.nutz.dao.Cnd;
|
||||
import org.nutz.dao.Dao;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* Todo
|
||||
*
|
||||
* @author: 1V
|
||||
* @date: 2021/2/3
|
||||
* @since 1.0
|
||||
*/
|
||||
public interface WelfareUserMode {
|
||||
|
||||
Dao dao = SpringUtils.getBean(Dao.class);
|
||||
|
||||
|
||||
/**
|
||||
* 初始化用户并持久化
|
||||
*
|
||||
* @param user
|
||||
* @param <E>
|
||||
* @return
|
||||
*/
|
||||
static <E extends SysUser> E initUserPush(E user) {
|
||||
// SysUserService sysUserService = ioc.getByType(SysUserService.class);
|
||||
// return sysUserService.insert(initUser(user));
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 初始化用户
|
||||
*
|
||||
* @param user
|
||||
* @param <E>
|
||||
* @return
|
||||
*/
|
||||
static <E extends SysUser> E initUser(E user) {
|
||||
// String salt = R.UU32();
|
||||
// user.setId(R.UU32());
|
||||
// user.setSalt(salt);
|
||||
// user.setPassword("dd3s@#2022");
|
||||
// user.setPassword(new Sha256Hash(user.getPassword(), ByteSource.Util.bytes(salt), 1024).toHex());
|
||||
// user.setLoginPjax(true);
|
||||
// user.setMenuTheme("left");
|
||||
|
||||
return user;
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加普通用户的角色
|
||||
*
|
||||
* @param userid
|
||||
*/
|
||||
static void addPublicRole(String userid) {
|
||||
// SysUserService sysUserService = ioc.getByType(SysUserService.class);
|
||||
// addRoleAndFlush(userid, Roles.PUBLIC);
|
||||
// sysUserService.deleteCache(userid);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除一个用户
|
||||
*
|
||||
* @param userid
|
||||
*/
|
||||
static void removeUser(Long userid) {
|
||||
ProModuleDS.exec(Ds.SYSTEM, () -> {
|
||||
removeMemberRole(userid);
|
||||
dao.delete(SysUser.class, userid);
|
||||
dao.clear(MemberApplyRecord.class, Cnd.where("userId", "=", userid));
|
||||
dao.clear(MemberChangeRecord.class, Cnd.where("userId", "=", userid));
|
||||
return null;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加会员角色
|
||||
*
|
||||
* @param userid
|
||||
*/
|
||||
static void addMemberRole(Long userid, Integer changeOriginCode) {
|
||||
ProModuleDS.exec(Ds.SYSTEM, () -> {
|
||||
Chain chain = Chain.make("welfareMember", WelfareMemberMode.NORMAL.getCode()).add("welfareMemberJoinTime", new Date());
|
||||
dao.update(SysUser.class, chain, Cnd.where("userId", "=", userid));
|
||||
return null;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除会员角色
|
||||
*
|
||||
* @param userid
|
||||
*/
|
||||
static void removeMemberRole(Long userid) {
|
||||
ProModuleDS.exec(Ds.SYSTEM, () -> {
|
||||
dao.update(SysUser.class, Chain.make("welfareMember", WelfareMemberMode.NONE.getCode()), Cnd.where("userId", "=", userid));
|
||||
return null;
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
package com.ruoyi.staffService.welfare.param;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class WelfareUserSelectionDeleteParam {
|
||||
|
||||
@NotBlank(message = "福利id不能为空")
|
||||
private String welfareId;
|
||||
@NotEmpty(message = "选择记录不能为空")
|
||||
private List<String> userIds;
|
||||
|
||||
}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
package com.ruoyi.staffService.welfare.service;
|
||||
|
||||
import com.ruoyi.common.core.page.Pagination;
|
||||
import com.ruoyi.common.core.service.BaseService;
|
||||
import com.ruoyi.staffService.api.constant.welfare.WelfareMemberPageForm;
|
||||
import org.nutz.lang.util.NutMap;
|
||||
|
||||
public interface StaffWelfareMemberListGrantSummaryService extends BaseService {
|
||||
|
||||
/**
|
||||
* 页面数据
|
||||
*
|
||||
* @param projectId 项目id
|
||||
* @return {@link Pagination}
|
||||
*/
|
||||
NutMap pageData(String projectId);
|
||||
|
||||
/**
|
||||
* 用户页面数据
|
||||
*
|
||||
* @param pageForm 页面形式
|
||||
* @return {@link Pagination}
|
||||
*/
|
||||
Pagination userPageData(WelfareMemberPageForm pageForm);
|
||||
}
|
||||
+80
@@ -0,0 +1,80 @@
|
||||
package com.ruoyi.staffService.welfare.service;
|
||||
|
||||
import com.ruoyi.common.core.page.Pagination;
|
||||
import com.ruoyi.common.core.service.BaseService;
|
||||
import com.ruoyi.staffService.api.constant.welfare.WelfareMemberListPageForm;
|
||||
import com.ruoyi.staffService.api.domain.welfare.WelfareList;
|
||||
import org.nutz.lang.util.NutMap;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 福利名单service
|
||||
*
|
||||
* @author jug
|
||||
* @date 2023/02/09
|
||||
*/
|
||||
public interface StaffWelfareMemberListService extends BaseService<WelfareList> {
|
||||
|
||||
/**
|
||||
* 生成名单
|
||||
*
|
||||
* @param projectId
|
||||
*/
|
||||
void createList(String projectId);
|
||||
|
||||
/**
|
||||
* 更新名单
|
||||
*
|
||||
* @param projectId 项目id
|
||||
*/
|
||||
void updateList(String projectId);
|
||||
|
||||
/**
|
||||
* 加入福利名单
|
||||
*
|
||||
* @param projectId
|
||||
* @param userIds
|
||||
*/
|
||||
void joinWelfareList(String projectId, List<String> userIds);
|
||||
|
||||
/**
|
||||
* 页面数据
|
||||
*
|
||||
* @param pageForm 页面形式
|
||||
* @return {@link Pagination}
|
||||
*/
|
||||
Pagination pageData(WelfareMemberListPageForm pageForm);
|
||||
|
||||
/**
|
||||
* 导出签字表数据
|
||||
*
|
||||
* @param userTypes 用户类型
|
||||
* @param projectId 项目id
|
||||
* @return {@link NutMap}
|
||||
*/
|
||||
NutMap exportSign(List<String> userTypes, String projectId);
|
||||
|
||||
/**
|
||||
* 导出福利名单
|
||||
*
|
||||
* @param projectId 项目id
|
||||
* @return {@link List}<{@link NutMap}>
|
||||
*/
|
||||
List<NutMap> exportUserList(String projectId);
|
||||
|
||||
/**
|
||||
* 删除福利名单
|
||||
*
|
||||
* @param listId id列表
|
||||
*/
|
||||
void doDelete(String listId);
|
||||
|
||||
/**
|
||||
* 福利用户id集合
|
||||
*
|
||||
* @param projectId 项目id
|
||||
* @return {@link List}<{@link String}>
|
||||
*/
|
||||
List<String> userIds(String projectId);
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
package com.ruoyi.staffService.welfare.service;
|
||||
|
||||
import com.ruoyi.common.core.service.BaseService;
|
||||
|
||||
public interface StaffWelfareMemberSchoolUnionCheckTaskService extends BaseService {
|
||||
|
||||
|
||||
}
|
||||
+54
@@ -0,0 +1,54 @@
|
||||
package com.ruoyi.staffService.welfare.service;
|
||||
|
||||
import com.ruoyi.common.core.page.Pagination;
|
||||
import com.ruoyi.common.core.service.BaseService;
|
||||
import com.ruoyi.staffService.api.constant.welfare.WelfareMemberPageForm;
|
||||
import com.ruoyi.staffService.api.domain.welfare.WelfareMemberChangeRecord;
|
||||
import com.ruoyi.system.api.domain.SysUser;
|
||||
import org.nutz.lang.util.NutMap;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface StaffWelfareMemberService extends BaseService {
|
||||
|
||||
/**
|
||||
* 页面数据
|
||||
*
|
||||
* @param pageForm 页面形式
|
||||
* @return {@link Pagination}
|
||||
*/
|
||||
Pagination pageData(WelfareMemberPageForm pageForm);
|
||||
|
||||
/**
|
||||
* 加入福利会员
|
||||
*
|
||||
* @param userIds 用户id
|
||||
*/
|
||||
void joinWelfareMember(List<Long> userIds);
|
||||
|
||||
/**
|
||||
* 取消福利会员
|
||||
*
|
||||
* @param userIds 用户id
|
||||
*/
|
||||
void kickWelfareMember(List<Long> userIds);
|
||||
|
||||
/**
|
||||
* 历史用户
|
||||
*
|
||||
* @param loginName 登录名
|
||||
* @return {@link List}<{@link NutMap}>
|
||||
*/
|
||||
List<NutMap> historyUsers(String loginName);
|
||||
|
||||
/**
|
||||
* 成员改变
|
||||
*
|
||||
* @param memberChangeRecord 成员变更记录
|
||||
*/
|
||||
void doMemberChange(WelfareMemberChangeRecord memberChangeRecord,boolean isChange);
|
||||
|
||||
void addNewWelfareMember(SysUser sysUser);
|
||||
|
||||
void syncMember();
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
package com.ruoyi.staffService.welfare.service;
|
||||
|
||||
import com.ruoyi.common.core.domain.PageForm;
|
||||
import com.ruoyi.common.core.page.Pagination;
|
||||
import com.ruoyi.common.core.service.BaseService;
|
||||
import com.ruoyi.staffService.api.domain.welfare.WelfareProject;
|
||||
|
||||
public interface StaffWelfareProjectMangeService extends BaseService<WelfareProject> {
|
||||
|
||||
Pagination pageData(PageForm pageForm, String name, Integer year);
|
||||
|
||||
void save(WelfareProject project);
|
||||
|
||||
WelfareProject projectInfo(String projectId);
|
||||
|
||||
void deleteProject(String projectId);
|
||||
}
|
||||
+71
@@ -0,0 +1,71 @@
|
||||
package com.ruoyi.staffService.welfare.service;
|
||||
|
||||
import com.ruoyi.common.core.service.BaseService;
|
||||
import org.apache.poi.ss.usermodel.Workbook;
|
||||
import org.nutz.lang.util.NutMap;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.OutputStream;
|
||||
import java.util.List;
|
||||
|
||||
public interface StaffWelfareSingleService extends BaseService {
|
||||
/**
|
||||
* 获取某个福利下的题目 这个福利必然是弹性福利
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
List<NutMap> getOptionByProjectId(String projectId);
|
||||
|
||||
/**
|
||||
* 某个福利下以后选择的数据
|
||||
*
|
||||
* @param projectId
|
||||
* @return
|
||||
*/
|
||||
List<NutMap> getUserSelectionByProjectId(String projectId);
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*
|
||||
* @param projectId 福利id
|
||||
* @return
|
||||
*/
|
||||
NutMap pageData(String projectId, String unionId, String unionGroupId);
|
||||
|
||||
/**
|
||||
* 领取详情
|
||||
*
|
||||
* @param projectId 福利id
|
||||
* @return
|
||||
*/
|
||||
Object receivePageData(String projectId, String welfareUnitCode, String unionGroupId, Integer pageNumber, Integer pageSize, boolean isFy);
|
||||
|
||||
/**
|
||||
* 导出发放详细表
|
||||
*
|
||||
* @param projectId
|
||||
* @return
|
||||
*/
|
||||
List<NutMap> receivePageDataColumns(String projectId);
|
||||
|
||||
/**
|
||||
* 生成指定福利套餐的账号密码导入模板。
|
||||
*
|
||||
* @param projectId 福利项目ID
|
||||
* @param optionId 套餐选项ID,必须属于当前福利项目
|
||||
* @return XSSF 格式的账号密码导入模板,包含该套餐已选人员的工号和姓名
|
||||
*/
|
||||
Workbook buildAccountPasswordTemplate(String projectId, String optionId);
|
||||
|
||||
/**
|
||||
* 导入指定福利套餐的账号和密码。
|
||||
*
|
||||
* @param projectId 福利项目ID
|
||||
* @param optionId 套餐选项ID,账号密码仅更新到该套餐的选择记录
|
||||
* @param file 包含工号、姓名、账号、密码四列的 xls/xlsx 文件
|
||||
* @return 成功导入的人员数量,同一人员的重复选择记录只计一人
|
||||
*/
|
||||
int importAccountPassword(String projectId, String optionId, MultipartFile file);
|
||||
|
||||
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
package com.ruoyi.staffService.welfare.service;
|
||||
|
||||
import com.ruoyi.common.core.domain.PageForm;
|
||||
import com.ruoyi.common.core.page.Pagination;
|
||||
import com.ruoyi.common.core.service.BaseService;
|
||||
import com.ruoyi.staffService.api.domain.welfare.WelfareUnit;
|
||||
import org.nutz.lang.util.NutMap;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface StaffWelfareUnitManageService extends BaseService<WelfareUnit> {
|
||||
|
||||
List<NutMap> treeData();
|
||||
|
||||
Pagination pageData(PageForm pageForm, String welfareUnitName);
|
||||
|
||||
void setComponentUnit(Long[] deptIds, String welfareUnitId);
|
||||
}
|
||||
+69
@@ -0,0 +1,69 @@
|
||||
package com.ruoyi.staffService.welfare.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import com.ruoyi.common.core.page.Pagination;
|
||||
import com.ruoyi.common.core.service.BaseServiceImpl;
|
||||
import com.ruoyi.common.security.utils.DictUtils;
|
||||
import com.ruoyi.staffService.api.constant.welfare.WelfareMemberPageForm;
|
||||
import com.ruoyi.staffService.api.constant.welfare.WelfareUnitMode;
|
||||
import com.ruoyi.staffService.welfare.service.StaffWelfareMemberListGrantSummaryService;
|
||||
import com.ruoyi.system.api.domain.SysDictData;
|
||||
import org.nutz.dao.Cnd;
|
||||
import org.nutz.dao.Dao;
|
||||
import org.nutz.dao.Sqls;
|
||||
import org.nutz.dao.sql.Sql;
|
||||
import org.nutz.lang.util.NutMap;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
public class StaffWelfareMemberListGrantSummaryServiceImpl extends BaseServiceImpl implements StaffWelfareMemberListGrantSummaryService {
|
||||
|
||||
public StaffWelfareMemberListGrantSummaryServiceImpl(Dao dao) {
|
||||
super(dao);
|
||||
}
|
||||
|
||||
@Override
|
||||
public NutMap pageData(String projectId) {
|
||||
//获取所有人员类型
|
||||
List<SysDictData> user_typed_dicts = DictUtils.getDictCache("user_type");
|
||||
assert user_typed_dicts != null;
|
||||
List<NutMap> labelList = user_typed_dicts.stream().map(v -> NutMap.NEW().addv("prop", v.getDictLabel()).addv("label", v.getDictLabel())).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.userId = list.userId
|
||||
$condition
|
||||
""");
|
||||
StringBuffer temp_sql_str = new StringBuffer();
|
||||
user_typed_dicts.forEach(v -> {
|
||||
temp_sql_str.append("COUNT( CASE WHEN ( su.personType = '%s' ) THEN 1 ELSE NULL END ) AS '%s',".formatted(v.getDictValue(), v.getDictLabel()));
|
||||
});
|
||||
|
||||
|
||||
String totalUserType = CollUtil.join(user_typed_dicts.stream().map(v -> v.getDictValue()).collect(Collectors.toList()), ",", "'", "'");
|
||||
|
||||
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);
|
||||
|
||||
Cnd cnd = Cnd.NEW();
|
||||
cnd.and("unit.welfareUnitMode", "=", WelfareUnitMode.getMode().name());
|
||||
cnd.and("list.projectId", "=", projectId);
|
||||
cnd.groupBy("unit.welfareUnitId");
|
||||
sql.setCondition(cnd);
|
||||
labelList.add(NutMap.NEW().addv("prop", "totalNum").addv("label", "合计"));
|
||||
return NutMap.NEW().addv("tableList", listMap(sql)).addv("tableColumn", labelList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Pagination userPageData(WelfareMemberPageForm pageForm) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
+430
@@ -0,0 +1,430 @@
|
||||
package com.ruoyi.staffService.welfare.service.impl;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.ruoyi.common.core.page.Pagination;
|
||||
import com.ruoyi.common.core.service.BaseServiceImpl;
|
||||
import com.ruoyi.common.core.utils.sql.SqlUtil;
|
||||
import com.ruoyi.common.security.auth.AuthUtil;
|
||||
import com.ruoyi.common.security.utils.DictUtils;
|
||||
import com.ruoyi.common.security.utils.SecurityUtils;
|
||||
import com.ruoyi.staffService.api.constant.welfare.WelfareMemberListPageForm;
|
||||
import com.ruoyi.staffService.api.domain.welfare.WelfareList;
|
||||
import com.ruoyi.staffService.api.domain.welfare.WelfareProject;
|
||||
import com.ruoyi.staffService.api.domain.welfare.WelfareUserSelection;
|
||||
import com.ruoyi.staffService.welfare.service.StaffWelfareMemberListService;
|
||||
import com.ruoyi.staffService.welfare.service.StaffWelfareProjectMangeService;
|
||||
import com.ruoyi.system.api.domain.SysDictData;
|
||||
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.Daos;
|
||||
import org.nutz.dao.util.cri.SqlExpressionGroup;
|
||||
import org.nutz.lang.util.NutMap;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
public class StaffWelfareMemberListServiceImpl extends BaseServiceImpl<WelfareList> implements StaffWelfareMemberListService {
|
||||
|
||||
public StaffWelfareMemberListServiceImpl(Dao dao) {
|
||||
super(dao);
|
||||
}
|
||||
|
||||
@Autowired
|
||||
private StaffWelfareProjectMangeService projectMangeService;
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void createList(String projectId) {
|
||||
//删除原来的福利名单
|
||||
dao().clear(WelfareList.class, Cnd.where("projectId", "=", projectId));
|
||||
WelfareProject project = projectMangeService.projectInfo(projectId);
|
||||
|
||||
//查询最新的福利会员
|
||||
Sql sql = Sqls.create("""
|
||||
SELECT
|
||||
userId,
|
||||
loginName,
|
||||
userName,
|
||||
sex,
|
||||
personType,
|
||||
userState,
|
||||
mobile,
|
||||
unionId,
|
||||
unionName,
|
||||
deptId as unitId,
|
||||
deptName as unitName,
|
||||
threeUnitId,
|
||||
threeDeptName as threeUnitName,
|
||||
unionGroupId,
|
||||
unionGroupName
|
||||
FROM
|
||||
`user`
|
||||
$condition
|
||||
""");
|
||||
Cnd cnd = Cnd.NEW();
|
||||
cnd.and("welfareMember", "=", 1);
|
||||
sql.setCondition(cnd);
|
||||
|
||||
List<WelfareList> welfareLists = listEntity(sql, WelfareList.class);
|
||||
for (WelfareList welfareList : welfareLists) {
|
||||
welfareList.setProjectId(projectId);
|
||||
// 授予积分
|
||||
if (project.getGrantPoints() != null && project.getGrantPoints() > 0) {
|
||||
welfareList.setPointsBalance(project.getGrantPoints());
|
||||
}
|
||||
}
|
||||
dao().insert(welfareLists);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void updateList(String projectId) {
|
||||
// //目前的福利名单
|
||||
// List<WelfareList> lists = dao().query(WelfareList.class, Cnd.where("projectId", "=", projectId));
|
||||
// List<String> userIds = lists.stream().map(v -> v.getUserId()).collect(Collectors.toList());
|
||||
//
|
||||
//
|
||||
// //查询最新的福利会员并且不在当前福利名单中的
|
||||
// Sql sql = Sqls.create("""
|
||||
// SELECT
|
||||
// userId,
|
||||
// loginName,
|
||||
// userName,
|
||||
// sex,
|
||||
// personType,
|
||||
// userState,
|
||||
// mobile,
|
||||
// unionId,
|
||||
// unionName,
|
||||
// deptId as unitId,
|
||||
// deptName as unitName,
|
||||
// threeUnitId,
|
||||
// threeDeptName as threeUnitName,
|
||||
// unionGroupId,
|
||||
// unionGroupName
|
||||
// FROM
|
||||
// `user`
|
||||
// $condition
|
||||
// """);
|
||||
// Cnd cnd = Cnd.NEW();
|
||||
// cnd.and("welfareMember", "=", 1);
|
||||
// cnd.andEX("userId", "not in", userIds);
|
||||
// sql.setCondition(cnd);
|
||||
// List<WelfareList> welfareLists = listEntity(sql, WelfareList.class);
|
||||
// for (WelfareList welfareList : welfareLists) {
|
||||
// welfareList.setProjectId(projectId);
|
||||
// }
|
||||
// //加入到福利名单
|
||||
// dao().insert(welfareLists);
|
||||
//
|
||||
// //再对本次福利名单进行比较修改 比如单位变动了
|
||||
// Sql updateSql = Sqls.create("""
|
||||
// SELECT
|
||||
// userId,
|
||||
// loginName,
|
||||
// userName,
|
||||
// sex,
|
||||
// personType,
|
||||
// userState,
|
||||
// mobile,
|
||||
// unionId,
|
||||
// unionName,
|
||||
// deptId as unitId,
|
||||
// deptName as unitName,
|
||||
// threeUnitId,
|
||||
// threeDeptName as threeUnitName,
|
||||
// unionGroupId,
|
||||
// unionGroupName
|
||||
// FROM
|
||||
// `user`
|
||||
// $condition
|
||||
// """);
|
||||
// Cnd updateCnd = Cnd.NEW();
|
||||
// updateCnd.andEX("userId", "in", userIds);
|
||||
// sql.setCondition(updateCnd);
|
||||
// List<WelfareList> updateWelfareLists = listEntity(sql, WelfareList.class);
|
||||
// Map<String, WelfareList> welfareListMap = updateWelfareLists.stream().collect(Collectors.toMap(v -> v.getUserId(), v -> v));
|
||||
//
|
||||
// for (WelfareList list : lists) {
|
||||
//
|
||||
// list.setSex()
|
||||
//
|
||||
// }
|
||||
//
|
||||
//
|
||||
// //删除掉在名单里但不是福利会员的用户 不管他有没有选择套餐
|
||||
// dao().clear(WelfareList.class, Cnd.where("projectId", "=", projectId).and("userId", "not in", Sqls.create("select userId from `user` where welfareMember != 1")));
|
||||
// //再删除掉选择的数据
|
||||
// dao().clear(WelfareUserSelection.class, Cnd.where("welfareId", "=", projectId).and("selectUserId", "not in", Sqls.create("select userId from `user` where welfareMember != 1")));
|
||||
|
||||
//删除原来的福利名单
|
||||
dao().clear(WelfareList.class, Cnd.where("projectId", "=", projectId));
|
||||
WelfareProject project = projectMangeService.projectInfo(projectId);
|
||||
|
||||
//查询最新的福利会员
|
||||
Sql sql = Sqls.create("""
|
||||
SELECT
|
||||
userId,
|
||||
loginName,
|
||||
userName,
|
||||
sex,
|
||||
personType,
|
||||
userState,
|
||||
mobile,
|
||||
unionId,
|
||||
unionName,
|
||||
deptId as unitId,
|
||||
deptName as unitName,
|
||||
threeUnitId,
|
||||
threeDeptName as threeUnitName,
|
||||
unionGroupId,
|
||||
unionGroupName
|
||||
FROM
|
||||
`user`
|
||||
$condition
|
||||
""");
|
||||
Cnd cnd = Cnd.NEW();
|
||||
cnd.and("welfareMember", "=", 1);
|
||||
sql.setCondition(cnd);
|
||||
|
||||
List<WelfareList> welfareLists = listEntity(sql, WelfareList.class);
|
||||
for (WelfareList welfareList : welfareLists) {
|
||||
welfareList.setProjectId(projectId);
|
||||
if (StrUtil.isNotBlank(welfareList.getMobile())) {
|
||||
welfareList.setMobile(welfareList.getMobile().trim());
|
||||
}
|
||||
if (StrUtil.isNotBlank(welfareList.getMobile()) && welfareList.getMobile().length() > 11) {
|
||||
welfareList.setMobile(null);
|
||||
}
|
||||
// 授予积分
|
||||
if (project.getGrantPoints() != null && project.getGrantPoints() > 0) {
|
||||
welfareList.setPointsBalance(project.getGrantPoints());
|
||||
}
|
||||
}
|
||||
dao().insert(welfareLists);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void joinWelfareList(String projectId, List<String> userIds) {
|
||||
Sql sql = Sqls.create("""
|
||||
SELECT
|
||||
userId,
|
||||
loginName,
|
||||
userName,
|
||||
personType,
|
||||
userState,
|
||||
mobile,
|
||||
unionId,
|
||||
unionName,
|
||||
deptId as unitId,
|
||||
deptName as unitName,
|
||||
threeUnitId,
|
||||
threeDeptName as threeUnitName,
|
||||
unionGroupId,
|
||||
unionGroupName
|
||||
FROM
|
||||
`user`
|
||||
$condition
|
||||
""");
|
||||
Cnd cnd = Cnd.NEW();
|
||||
cnd.and("userId", "in", userIds);
|
||||
sql.setCondition(cnd);
|
||||
List<NutMap> list = listMap(sql);
|
||||
|
||||
|
||||
joinWelfareList(listMap(sql), projectId);
|
||||
}
|
||||
|
||||
private void joinWelfareList(List<NutMap> users, String projectId) {
|
||||
// String field = WelfareUnitMode.getMode().getField();
|
||||
// List<WelfareList> lists = new ArrayList<>();
|
||||
// for (NutMap user : users) {
|
||||
// WelfareList list = new WelfareList();
|
||||
// list.setProjectId(projectId);
|
||||
// list.setUserId(user.getString("userId"));
|
||||
// lists.add(list);
|
||||
// }
|
||||
// dao().insert(lists);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Pagination pageData(WelfareMemberListPageForm pageForm) {
|
||||
Cnd cnd = Cnd.NEW();
|
||||
if (!AuthUtil.hasAnyRoles("admin,A06")) {
|
||||
if (AuthUtil.hasRole("H04")) {
|
||||
cnd.and("unionId", "=", SecurityUtils.getUnionId());
|
||||
} else if (AuthUtil.hasRole("unionGroupLeader")) {
|
||||
cnd.and("unionId", "=", SecurityUtils.getUnionId());
|
||||
SqlExpressionGroup seg = new SqlExpressionGroup();
|
||||
seg.or("unionGroupId", "in", SecurityUtils.getManageUnionGroupIds());
|
||||
seg.or("unionGroupId", "is", null);
|
||||
cnd.and(seg);
|
||||
}
|
||||
}
|
||||
|
||||
if (StrUtil.isNotBlank(pageForm.getSearchKeyword())) {
|
||||
SqlExpressionGroup seg = new SqlExpressionGroup();
|
||||
seg.orLike("loginName", pageForm.getSearchKeyword());
|
||||
seg.orLike("userName", pageForm.getSearchKeyword());
|
||||
cnd.and(seg);
|
||||
}
|
||||
|
||||
cnd.andEX("projectId", "=", pageForm.getProjectId());
|
||||
cnd.andEX("unionId", "=", pageForm.getUnionId());
|
||||
cnd.andEX("unitId", "=", pageForm.getUnitId());
|
||||
cnd.andEX("unionGroupId", "=", pageForm.getUnionGroupId());
|
||||
cnd.andEX("threeUnitId", "=", pageForm.getThreeUnitId());
|
||||
cnd.andEX("sex", "=", pageForm.getSex());
|
||||
cnd.andEX("personType", "=", pageForm.getPersonType());
|
||||
cnd.andEX("userState", "=", pageForm.getUserState());
|
||||
|
||||
if (StrUtil.isAllNotBlank(pageForm.getPageOrderName(), pageForm.getPageOrderBy())) {
|
||||
cnd.orderBy(pageForm.getPageOrderName(), SqlUtil.getOrderBy(pageForm.getPageOrderBy()));
|
||||
} else {
|
||||
cnd.asc("loginName");
|
||||
}
|
||||
|
||||
Pagination pagination = listPageMap(pageForm.getPageNumber(), pageForm.getPageSize(), cnd);
|
||||
return pagination;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NutMap exportSign(List<String> userTypes, String projectId) {
|
||||
WelfareProject project = projectMangeService.fetch(projectId);
|
||||
|
||||
Sql sql = Sqls.create("""
|
||||
SELECT
|
||||
vwl.*,
|
||||
wpus.userSign
|
||||
FROM
|
||||
view_welfare_list vwl
|
||||
LEFT JOIN welfare_project_user_selection wpus ON wpus.selectUserId = vwl.userId
|
||||
$condition
|
||||
""");
|
||||
Cnd cnd = Cnd.NEW();
|
||||
cnd.and("vwl.projectId", "=", projectId);
|
||||
cnd.and("vwl.deptId", "IS NOT", null);
|
||||
cnd.and("vwl.realWelfareUnitId", "IS NOT", null);
|
||||
cnd.andEX("vwl.personType", "in", userTypes);
|
||||
cnd.groupBy("vwl.userId");
|
||||
cnd.asc("vwl.realWelfareUnitCode");
|
||||
if (!AuthUtil.hasAnyRoles("admin,A06")) {
|
||||
cnd.and("vwl.unionId", "=", SecurityUtils.getUnionId());
|
||||
}
|
||||
sql.setCondition(cnd);
|
||||
List<NutMap> welfareList = projectMangeService.listMap(sql);
|
||||
|
||||
NutMap v = NutMap.NEW();
|
||||
|
||||
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("deptCode"))).collect(Collectors.groupingBy(x -> x.getString("deptName")));
|
||||
List units = new ArrayList();
|
||||
unitCollect.forEach((unitName, unitUsers) -> {
|
||||
unitUsers.forEach(user -> {
|
||||
try {
|
||||
// user.setv("userSign", Strings.isNotBlank(user.getString("userSign")) ? Vi.getImg(user.getString("userSign")) : null);
|
||||
user.setv("userSign", null);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
});
|
||||
|
||||
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.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);
|
||||
v.setv("projectName", project.getName());
|
||||
return v;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<NutMap> exportUserList(String projectId) {
|
||||
Sql sql = Sqls.create("""
|
||||
SELECT
|
||||
loginName,
|
||||
userName,
|
||||
personType,
|
||||
userState,
|
||||
unionName,
|
||||
deptName,
|
||||
campus
|
||||
FROM
|
||||
view_welfare_list
|
||||
$condition
|
||||
""");
|
||||
Cnd cnd = Cnd.NEW();
|
||||
cnd.and("projectId", "=", projectId);
|
||||
|
||||
if (!AuthUtil.hasAnyRoles("admin,A06")) {
|
||||
cnd.and("unionId", "=", SecurityUtils.getUnionId());
|
||||
}
|
||||
cnd.asc("unionCode");
|
||||
cnd.asc("deptCode");
|
||||
sql.setCondition(cnd);
|
||||
|
||||
List<NutMap> list = listMap(sql);
|
||||
|
||||
List<SysDictData> user_types = DictUtils.getDictCache("user_type");
|
||||
List<SysDictData> user_states = DictUtils.getDictCache("user_state");
|
||||
List<SysDictData> campus = DictUtils.getDictCache("campus");
|
||||
|
||||
for (NutMap nutMap : list) {
|
||||
nutMap.setv("personType", user_types.stream().filter(v -> v.getDictValue().equals(nutMap.getString("personType"))).findFirst().map(v -> v.getDictLabel()).orElse(null));
|
||||
nutMap.setv("userState", user_states.stream().filter(v -> v.getDictValue().equals(nutMap.getString("userState"))).findFirst().map(v -> v.getDictLabel()).orElse(null));
|
||||
nutMap.setv("campus", campus.stream().filter(v -> v.getDictValue().equals(nutMap.getString("campus"))).findFirst().map(v -> v.getDictLabel()).orElse(null));
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void doDelete(String listId) {
|
||||
WelfareList welfareList = dao().fetch(WelfareList.class, listId);
|
||||
String projectId = welfareList.getProjectId();
|
||||
String userId = welfareList.getUserId();
|
||||
dao().clear(WelfareUserSelection.class, Cnd.where("welfareId", "=", projectId).and("selectUserId", "=", userId));
|
||||
dao().delete(welfareList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> userIds(String projectId) {
|
||||
Sql sql = Sqls.create("select userId from welfare_list where projectId = @projectId");
|
||||
sql.setParam("projectId", projectId);
|
||||
List<String> userIds = (List<String>) Daos.query(dao(), sql.toString(), Sqls.callback.strList());
|
||||
return userIds;
|
||||
}
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
package com.ruoyi.staffService.welfare.service.impl;
|
||||
|
||||
import com.ruoyi.common.core.service.BaseServiceImpl;
|
||||
import com.ruoyi.staffService.welfare.service.StaffWelfareMemberSchoolUnionCheckTaskService;
|
||||
import org.nutz.dao.Dao;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class StaffWelfareMemberSchoolUnionCheckTaskServiceImpl extends BaseServiceImpl implements StaffWelfareMemberSchoolUnionCheckTaskService {
|
||||
|
||||
public StaffWelfareMemberSchoolUnionCheckTaskServiceImpl(Dao dao) {
|
||||
super(dao);
|
||||
}
|
||||
|
||||
}
|
||||
+180
@@ -0,0 +1,180 @@
|
||||
package com.ruoyi.staffService.welfare.service.impl;
|
||||
|
||||
import cn.hutool.core.util.EnumUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.dynamic.datasource.annotation.DSTransactional;
|
||||
import com.baomidou.dynamic.datasource.toolkit.DynamicDataSourceContextHolder;
|
||||
import com.ruoyi.common.core.constant.Roles;
|
||||
import com.ruoyi.common.core.page.Pagination;
|
||||
import com.ruoyi.common.core.service.BaseServiceImpl;
|
||||
import com.ruoyi.common.core.utils.sql.SqlUtil;
|
||||
import com.ruoyi.common.security.auth.AuthUtil;
|
||||
import com.ruoyi.common.security.utils.SecurityUtils;
|
||||
import com.ruoyi.member.api.constant.MemberChangeApplyState;
|
||||
import com.ruoyi.member.api.constant.MemberChangeOrigin;
|
||||
import com.ruoyi.member.api.constant.UserChangeType;
|
||||
import com.ruoyi.member.api.constant.UserMode;
|
||||
import com.ruoyi.member.api.domain.Audit;
|
||||
import com.ruoyi.staffService.api.constant.welfare.WelfareMemberMode;
|
||||
import com.ruoyi.staffService.api.constant.welfare.WelfareMemberPageForm;
|
||||
import com.ruoyi.staffService.api.domain.welfare.WelfareMemberApplyRecord;
|
||||
import com.ruoyi.staffService.api.domain.welfare.WelfareMemberChangeRecord;
|
||||
import com.ruoyi.staffService.constant.Ds;
|
||||
import com.ruoyi.staffService.util.ProModuleDS;
|
||||
import com.ruoyi.staffService.welfare.handle.WelfareMemberChangeHandle;
|
||||
import com.ruoyi.staffService.welfare.service.StaffWelfareMemberService;
|
||||
import com.ruoyi.system.api.domain.SysUser;
|
||||
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.lang.util.NutMap;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
public class StaffWelfareMemberServiceImpl extends BaseServiceImpl implements StaffWelfareMemberService {
|
||||
|
||||
public StaffWelfareMemberServiceImpl(Dao dao) {
|
||||
super(dao);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Pagination pageData(WelfareMemberPageForm pageForm) {
|
||||
Sql sql = Sqls.create("SELECT * from welfare_member $condition");
|
||||
Cnd cnd = Cnd.NEW();
|
||||
if (!AuthUtil.hasAnyRoles("admin,A06")) {
|
||||
if (AuthUtil.hasRole("H04")) {
|
||||
cnd.and("unionId", "=", SecurityUtils.getUnionId());
|
||||
} else if (AuthUtil.hasRole("unionGroupLeader")) {
|
||||
cnd.and("unionId", "=", SecurityUtils.getUnionId());
|
||||
cnd.and("unionGroupId", "in", SecurityUtils.getManageUnionGroupIds());
|
||||
}
|
||||
}
|
||||
|
||||
if (StrUtil.isNotBlank(pageForm.getSearchKeyword())) {
|
||||
SqlExpressionGroup seg = new SqlExpressionGroup();
|
||||
seg.orLike("userName", pageForm.getSearchKeyword());
|
||||
seg.orLike("loginName", pageForm.getSearchKeyword());
|
||||
cnd.and(seg);
|
||||
}
|
||||
cnd.andEX("unionId", "=", pageForm.getUnionId());
|
||||
cnd.andEX("deptId", "=", pageForm.getUnitId());
|
||||
cnd.andEX("unionGroupId", "=", pageForm.getUnionGroupId());
|
||||
cnd.andEX("threeUnitId", "=", pageForm.getThreeUnitId());
|
||||
cnd.andEX("campus", "=", pageForm.getCampus());
|
||||
cnd.andEX("sex", "=", pageForm.getSex());
|
||||
cnd.andEX("personType", "=", pageForm.getPersonType());
|
||||
cnd.andEX("userState", "=", pageForm.getUserState());
|
||||
|
||||
if (StrUtil.isAllNotBlank(pageForm.getPageOrderName(), pageForm.getPageOrderBy())) {
|
||||
cnd.orderBy(pageForm.getPageOrderName(), SqlUtil.getOrderBy(pageForm.getPageOrderBy()));
|
||||
} else {
|
||||
cnd.asc("loginName");
|
||||
}
|
||||
|
||||
sql.setCondition(cnd);
|
||||
return listPageMap(pageForm.getPageNumber(), pageForm.getPageSize(), sql);
|
||||
}
|
||||
|
||||
@Override
|
||||
@DSTransactional
|
||||
public void joinWelfareMember(List<Long> userIds) {
|
||||
Chain chain = Chain.make("welfareMember", WelfareMemberMode.NORMAL.getCode());
|
||||
chain.add("welfareMemberJoinTime", new Date());
|
||||
ProModuleDS.execVoid(Ds.SYSTEM, () -> dao().update(SysUser.class, chain, Cnd.where("userId", "in", userIds)));
|
||||
}
|
||||
|
||||
@Override
|
||||
@DSTransactional
|
||||
public void kickWelfareMember(List<Long> userIds) {
|
||||
dao().clear(WelfareMemberApplyRecord.class, Cnd.where("userId", "in", userIds));
|
||||
DynamicDataSourceContextHolder.push("system");
|
||||
Chain chain = Chain.make("welfareMember", WelfareMemberMode.NONE.getCode());
|
||||
chain.add("welfareMemberJoinTime", null);
|
||||
dao().update(SysUser.class, chain, Cnd.where("userId", "in", userIds));
|
||||
DynamicDataSourceContextHolder.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<NutMap> historyUsers(String loginName) {
|
||||
return ProModuleDS.exec(Ds.SYSTEM, () -> {
|
||||
Sql sql = Sqls.create("""
|
||||
SELECT
|
||||
u.changeTime,
|
||||
u.changeType,
|
||||
date_format( u.changeTime, '%Y-%m-%d' ) changeDate,
|
||||
u.user_id as userId,
|
||||
u.user_name as loginName,
|
||||
u.nick_name as userName,
|
||||
u.sex,
|
||||
u.personType,
|
||||
u.userState,
|
||||
u.welfareMember,
|
||||
dept.dept_name as deptName,
|
||||
dept.dept_code as deptCode,
|
||||
gh.unionName,
|
||||
gh.unionCode
|
||||
FROM
|
||||
`user_history` u
|
||||
left join sys_dept dept on dept.dept_id = u.dept_id
|
||||
left join sys_union gh on gh.id = dept.union_id
|
||||
WHERE
|
||||
u.user_name = @loginName
|
||||
ORDER BY
|
||||
u.changeTime DESC
|
||||
""");
|
||||
sql.setParam("loginName", loginName);
|
||||
return listMap(sql);
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
@DSTransactional
|
||||
public void doMemberChange(WelfareMemberChangeRecord record, boolean isChange) {
|
||||
if (!Objects.equals(record.getType(), UserChangeType.UNIT_CHANGE.getCode())) {
|
||||
record.setCurrentUnitId(null);
|
||||
record.setCurrentUnionId(null);
|
||||
}
|
||||
|
||||
Audit audit = new Audit();
|
||||
audit.setAuditPass(true);
|
||||
dao().insert(audit);
|
||||
|
||||
record.setApplyTime(new Date());
|
||||
record.setApplyOrigin(MemberChangeOrigin.SCHOOL.getCode());
|
||||
record.setStateId(MemberChangeApplyState.SUCCESS);
|
||||
record.setSchoolAuditId(audit.getId());
|
||||
if (isChange) {
|
||||
WelfareMemberChangeHandle handle = EnumUtil.getBy(WelfareMemberChangeHandle.class, v -> Objects.equals(v.getChangeType(), record.getType()));
|
||||
handle.change(record);
|
||||
}
|
||||
|
||||
dao().insert(record);
|
||||
}
|
||||
|
||||
@Override
|
||||
@DSTransactional
|
||||
public void addNewWelfareMember(SysUser sysUser) {
|
||||
if (sysUser.getUserId() == null) {
|
||||
ProModuleDS.execVoid(Ds.SYSTEM, () -> dao().insert(sysUser));
|
||||
joinWelfareMember(List.of(sysUser.getUserId()));
|
||||
} else {
|
||||
ProModuleDS.execVoid(Ds.SYSTEM, () -> dao().updateIgnoreNull(sysUser));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void syncMember() {
|
||||
ProModuleDS.execVoid(Ds.SYSTEM,()->{
|
||||
dao().update(SysUser.class,Chain.make("welfareMember",1),Cnd.where("member","=",1));
|
||||
dao().update(SysUser.class,Chain.make("welfareMember",0),Cnd.where("member","=",0));
|
||||
});
|
||||
}
|
||||
}
|
||||
+164
@@ -0,0 +1,164 @@
|
||||
package com.ruoyi.staffService.welfare.service.impl;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.ruoyi.common.core.domain.PageForm;
|
||||
import com.ruoyi.common.core.page.Pagination;
|
||||
import com.ruoyi.common.core.service.BaseServiceImpl;
|
||||
import com.ruoyi.common.security.utils.SecurityUtils;
|
||||
import com.ruoyi.staffService.api.domain.common.MatchConditionStructure;
|
||||
import com.ruoyi.staffService.api.domain.welfare.*;
|
||||
import com.ruoyi.staffService.welfare.service.StaffWelfareProjectMangeService;
|
||||
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.aop.interceptor.ioc.TransAop;
|
||||
import org.nutz.ioc.aop.Aop;
|
||||
import org.nutz.lang.Lang;
|
||||
import org.nutz.lang.Strings;
|
||||
import org.nutz.lang.random.R;
|
||||
import org.nutz.lang.util.NutMap;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
public class StaffWelfareProjectMangeServiceImpl extends BaseServiceImpl<WelfareProject> implements StaffWelfareProjectMangeService {
|
||||
|
||||
public StaffWelfareProjectMangeServiceImpl(Dao dao) {
|
||||
super(dao);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Pagination pageData(PageForm pageForm, String name, Integer year) {
|
||||
// 福利项目列表按创建时间倒序展示,确保最新创建的项目优先显示。
|
||||
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
|
||||
ORDER BY project.create_time DESC
|
||||
""");
|
||||
Cnd cnd = Cnd.NEW();
|
||||
cnd.andEX("year", "=", year);
|
||||
|
||||
if (StrUtil.isNotBlank(name)) {
|
||||
SqlExpressionGroup seg = Cnd.cri().where().andLike("name", name);
|
||||
cnd.and(seg);
|
||||
}
|
||||
sql.setCondition(cnd);
|
||||
return listPageMap(pageForm.getPageNumber(), pageForm.getPageSize(), sql);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Aop(TransAop.READ_COMMITTED)
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void save(WelfareProject project) {
|
||||
if (StrUtil.isBlank(project.getId())) {
|
||||
dao().insertWith(project, "welfareProjectSubjects");
|
||||
if (Lang.isNotEmpty(project.getWelfareProjectSubjects())) {
|
||||
project.getWelfareProjectSubjects().forEach(v -> {
|
||||
dao().insertLinks(v, "options");
|
||||
});
|
||||
}
|
||||
} 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("optionType", o.getOptionType());
|
||||
// optionChain.add("defaultOption", o.isDefaultOption());
|
||||
// optionChain.add("systemAutoSelect", o.isSystemAutoSelect());
|
||||
optionChain.add("optionSort", o.getOptionSort());
|
||||
optionChain.add("imgUrl", o.getImgUrl());
|
||||
optionChain.add("qrCodeUrl", o.getQrCodeUrl());
|
||||
optionChain.add("description", o.getDescription());
|
||||
optionChain.add("isPost", o.getIsPost());
|
||||
optionChain.add("isDeliveryTime", o.getIsDeliveryTime());
|
||||
optionChain.add("selectMunicipality",o.getSelectMunicipality());
|
||||
optionChain.add("selectProvince", o.getSelectProvince());
|
||||
optionChain.add("price", o.getPrice());
|
||||
|
||||
dao().insert(WelfareProjectSubjectOption.class, optionChain);
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public WelfareProject projectInfo(String 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", SecurityUtils.getUserId());
|
||||
sqlo.setParam("welfareId", project.getId());
|
||||
List<NutMap> optionNameList = 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"));
|
||||
}
|
||||
|
||||
// WelfareUserSelection userSelection = dao().fetch(WelfareUserSelection.class, Cnd.where("welfareId", "=", project.getId()).and("selectUserId", "=", SecurityUtils.getUserId()));
|
||||
// if (null != userSelection) {
|
||||
// project.setUserSign(userSelection.getUserSign());
|
||||
// }
|
||||
|
||||
if (Strings.isNotBlank(project.getConditionStructureId())) {
|
||||
// MatchConditionStructure conditionStructure = fetchLinks(dao().fetch(MatchConditionStructure.class, project.getConditionStructureId()), "conditions");
|
||||
// project.setConditionStructure(conditionStructure);
|
||||
}
|
||||
return project;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void deleteProject(String projectId) {
|
||||
WelfareProject project = fetch(projectId);
|
||||
if (Strings.isNotBlank(project.getConditionStructureId())) {
|
||||
dao().clear("match_condition", Cnd.where("structureId", "=", project.getConditionStructureId()));
|
||||
dao().delete(MatchConditionStructure.class, project.getConditionStructureId());
|
||||
}
|
||||
delete(projectId);
|
||||
dao().clear(WelfareList.class, Cnd.where("projectId", "=", projectId));
|
||||
}
|
||||
}
|
||||
+402
@@ -0,0 +1,402 @@
|
||||
package com.ruoyi.staffService.welfare.service.impl;
|
||||
|
||||
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.hutool.core.util.StrUtil;
|
||||
import com.ruoyi.common.core.exception.ServiceException;
|
||||
import com.ruoyi.common.core.service.BaseServiceImpl;
|
||||
import com.ruoyi.common.security.auth.AuthUtil;
|
||||
import com.ruoyi.common.security.utils.SecurityUtils;
|
||||
import com.ruoyi.staffService.api.constant.welfare.WelfareProvideMode;
|
||||
import com.ruoyi.staffService.api.constant.welfare.WelfareSelectionAccountImport;
|
||||
import com.ruoyi.staffService.api.constant.welfare.WelfareUnitMode;
|
||||
import com.ruoyi.staffService.api.domain.welfare.WelfareProject;
|
||||
import com.ruoyi.staffService.api.domain.welfare.WelfareProjectSubject;
|
||||
import com.ruoyi.staffService.api.domain.welfare.WelfareProjectSubjectOption;
|
||||
import com.ruoyi.staffService.api.domain.welfare.WelfareUserSelection;
|
||||
import com.ruoyi.staffService.constant.Ds;
|
||||
import com.ruoyi.staffService.util.ProModuleDS;
|
||||
import com.ruoyi.staffService.welfare.service.StaffWelfareSingleService;
|
||||
import com.ruoyi.system.api.RemoteUnionService;
|
||||
import com.ruoyi.system.api.domain.SysDept;
|
||||
import com.ruoyi.system.api.domain.SysUnion;
|
||||
import com.ruoyi.system.api.domain.SysUnionGroup;
|
||||
import org.apache.poi.hssf.util.HSSFColor;
|
||||
import org.apache.poi.ss.usermodel.*;
|
||||
import org.apache.poi.ss.util.CellRangeAddress;
|
||||
import org.apache.poi.xssf.usermodel.*;
|
||||
import org.nutz.dao.Cnd;
|
||||
import org.nutz.dao.Chain;
|
||||
import org.nutz.dao.Dao;
|
||||
import org.nutz.dao.Sqls;
|
||||
import org.nutz.dao.sql.Sql;
|
||||
import org.nutz.aop.interceptor.ioc.TransAop;
|
||||
import org.nutz.ioc.aop.Aop;
|
||||
import org.nutz.lang.Strings;
|
||||
import org.nutz.lang.util.NutMap;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.imageio.ImageIO;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
public class StaffWelfareSingleServiceImpl extends BaseServiceImpl implements StaffWelfareSingleService {
|
||||
|
||||
public StaffWelfareSingleServiceImpl(Dao dao) {
|
||||
super(dao);
|
||||
}
|
||||
|
||||
@Override
|
||||
public NutMap pageData(String projectId, String unionId, String unionGroupId) {
|
||||
//查询套餐数据
|
||||
List<NutMap> optionList = this.getOptionByProjectId(projectId);
|
||||
|
||||
//选择数据
|
||||
List<NutMap> userSelections = this.getUserSelectionByProjectId(projectId);
|
||||
|
||||
//查询每个分工会下的福利会员
|
||||
Sql sql = Sqls.create("""
|
||||
SELECT
|
||||
wl.unionId,
|
||||
wl.unionName,
|
||||
count( wl.userId ) welfareMemberCount
|
||||
FROM
|
||||
`welfare_list` wl
|
||||
$condition
|
||||
""");
|
||||
Cnd cnd = Cnd.NEW();
|
||||
cnd.and("wl.projectId","=",projectId);
|
||||
cnd.andEX("wl.unionId","=",unionId);
|
||||
cnd.groupBy("wl.unionId");
|
||||
|
||||
if (!AuthUtil.hasAnyRole("admin,A06")) {
|
||||
if(AuthUtil.hasRole("H04")){
|
||||
cnd.and("wl.unionId","=",SecurityUtils.getUnionId());
|
||||
}
|
||||
}
|
||||
|
||||
sql.setCondition(cnd);
|
||||
|
||||
List<NutMap> list = listMap(sql);
|
||||
|
||||
for (NutMap unionMap : list) {
|
||||
String unionIdX = unionMap.getString("unionId", "");
|
||||
for (NutMap optionMap : optionList) {
|
||||
//该分工会该套餐选项的人数
|
||||
long count = userSelections.stream().filter(us -> us.getString("unionId", "").equals(unionIdX) && us.getString("selectOptionId").equals(optionMap.getString("id"))).count();
|
||||
unionMap.put(optionMap.getString("optionName"), count);
|
||||
}
|
||||
unionMap.put("selectedCount", userSelections.stream().filter(us -> us.getString("unionId", "").equals(unionIdX)).map(us -> us.getString("loginName")).distinct().count());
|
||||
unionMap.put("unSelectedCount", unionMap.getInt("welfareMemberCount", 0) - unionMap.getInt("selectedCount", 0));
|
||||
}
|
||||
|
||||
//表格列数据
|
||||
List<NutMap> labelList = new ArrayList<>();
|
||||
labelList.add(NutMap.NEW().addv("label", "分工会").addv("prop", "unionName"));
|
||||
labelList.add(NutMap.NEW().addv("label", "本次福利会员人数").addv("prop", "welfareMemberCount"));
|
||||
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", "selectedCount"));
|
||||
labelList.add(NutMap.NEW().addv("label", "未选人数").addv("prop", "unSelectedCount"));
|
||||
|
||||
return NutMap.NEW().addv("tableList", list).addv("tableColumn", labelList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<NutMap> getOptionByProjectId(String projectId) {
|
||||
Sql sql = Sqls.create("""
|
||||
SELECT
|
||||
wpso.id,
|
||||
wpso.optionName,
|
||||
wpso.optionType,
|
||||
wpso.isPost,
|
||||
wpso.isDeliveryTime
|
||||
FROM
|
||||
welfare_project_subject_option wpso
|
||||
LEFT JOIN welfare_project_subject wps ON wps.id = wpso.subjectId
|
||||
WHERE
|
||||
wps.projectId = @projectId
|
||||
ORDER BY wpso.optionSort ASC
|
||||
""");
|
||||
sql.setParam("projectId", projectId);
|
||||
return listMap(sql);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<NutMap> getUserSelectionByProjectId(String projectId) {
|
||||
Sql sql = Sqls.create("""
|
||||
SELECT
|
||||
wl.loginName,
|
||||
wl.userName,
|
||||
u.mobile,
|
||||
wpus.mobile userMobile,
|
||||
wpus.backUpMobile,
|
||||
wpus.deliveryTime,
|
||||
wpus.selectOptionId,
|
||||
wpus.selectTime,
|
||||
wpus.userSign,
|
||||
wpus.selectNum,
|
||||
wpus.receiveAddress,
|
||||
wpus.welfareId,
|
||||
wpus.selectUserId,
|
||||
wl.unionId,
|
||||
wl.unitId,
|
||||
wl.threeUnitId,
|
||||
wl.unionGroupId
|
||||
FROM
|
||||
`welfare_project_user_selection` wpus
|
||||
LEFT JOIN welfare_list wl ON wl.userId = wpus.selectUserId AND wl.projectId = @projectId
|
||||
LEFT JOIN user u on u.userId = wl.userId
|
||||
WHERE
|
||||
wpus.welfareId = @projectId
|
||||
GROUP BY wpus.selectUserId,wpus.selectOptionId
|
||||
""").setParam("projectId", projectId);
|
||||
return listMap(sql);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object receivePageData(String projectId, String welfareUnitCode, String unionGroupId, Integer pageNumber, Integer pageSize, boolean isFy) {
|
||||
Sql sql = Sqls.create("""
|
||||
SELECT
|
||||
u.loginName,
|
||||
u.userName,
|
||||
u.deptName,
|
||||
u.unionName,
|
||||
u.mobile,
|
||||
u.threeDeptName,
|
||||
wpus.receiveAddress,
|
||||
(
|
||||
SELECT
|
||||
GROUP_CONCAT( wpso.optionName )
|
||||
FROM
|
||||
welfare_project_user_selection wpus
|
||||
LEFT JOIN welfare_project_subject_option wpso ON wpso.id = wpus.selectOptionId
|
||||
WHERE
|
||||
wpus.welfareId = @welfareId
|
||||
AND wpus.selectUserId = u.userId
|
||||
) optionName,
|
||||
wpus.courierNumber
|
||||
FROM
|
||||
welfare_project_user_selection wpus
|
||||
LEFT JOIN `user` u ON u.userId = wpus.selectUserId
|
||||
LEFT JOIN welfare_project_subject_option wpso ON wpso.id = wpus.selectOptionId
|
||||
$condition
|
||||
""").setParam("welfareId", projectId);
|
||||
Cnd cnd = Cnd.NEW();
|
||||
cnd.andEX("u.unionGroupId", "=", unionGroupId);
|
||||
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);
|
||||
sql.setCondition(cnd);
|
||||
if (isFy) {
|
||||
return listPageMap(pageNumber, pageSize, sql);
|
||||
} else {
|
||||
return listMap(sql);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<NutMap> receivePageDataColumns(String projectId) {
|
||||
List<NutMap> labelList = new ArrayList<>();
|
||||
labelList.add(NutMap.NEW().addv("label", "工号").addv("prop", "loginName"));
|
||||
labelList.add(NutMap.NEW().addv("label", "姓名").addv("prop", "userName"));
|
||||
labelList.add(NutMap.NEW().addv("label", "单位").addv("prop", "deptName"));
|
||||
labelList.add(NutMap.NEW().addv("label", "工会").addv("prop", "unionName"));
|
||||
labelList.add(NutMap.NEW().addv("label", "所选福利").addv("prop", "optionName"));
|
||||
|
||||
WelfareProject project = dao().fetch(WelfareProject.class, Cnd.where("id", "=", projectId));
|
||||
if (project.getProvideMode().equals(WelfareProvideMode.PERSONAL.getCode())) {
|
||||
labelList.add(NutMap.NEW().addv("label", "收货信息").addv("prop", "receiveAddress").addv("width", 50));
|
||||
labelList.add(NutMap.NEW().addv("label", "快递单号").addv("prop", "courierNumber").addv("width", 50));
|
||||
}
|
||||
|
||||
return labelList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Workbook buildAccountPasswordTemplate(String projectId, String optionId) {
|
||||
validateProjectOption(projectId, optionId);
|
||||
|
||||
// 模板只带出当前套餐的已选人员,账号和密码由经办人在下载后填写。
|
||||
List<NutMap> selectedUsers = getSelectedUsers(projectId, optionId);
|
||||
List<WelfareSelectionAccountImport> templateData = selectedUsers.stream()
|
||||
.map(user -> new WelfareSelectionAccountImport()
|
||||
.setLoginName(user.getString("loginName"))
|
||||
.setUserName(user.getString("userName")))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
ExportParams exportParams = new ExportParams();
|
||||
exportParams.setType(ExcelType.XSSF);
|
||||
exportParams.setSheetName("账号密码导入");
|
||||
return ExcelExportUtil.exportExcel(exportParams, WelfareSelectionAccountImport.class, templateData);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Aop(TransAop.READ_COMMITTED)
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public int importAccountPassword(String projectId, String optionId, MultipartFile file) {
|
||||
validateProjectOption(projectId, optionId);
|
||||
List<WelfareSelectionAccountImport> importData;
|
||||
try {
|
||||
importData = ExcelImportUtil.importExcel(file.getInputStream(), WelfareSelectionAccountImport.class, new ImportParams());
|
||||
} catch (Exception e) {
|
||||
throw new ServiceException("账号密码表格解析失败,请检查文件内容和格式");
|
||||
}
|
||||
if (importData == null || importData.isEmpty()) {
|
||||
throw new ServiceException("导入文件中没有可处理的数据");
|
||||
}
|
||||
|
||||
List<NutMap> selectedUsers = getSelectedUsers(projectId, optionId);
|
||||
Map<String, NutMap> selectedUserMap = selectedUsers.stream().collect(Collectors.toMap(
|
||||
user -> user.getString("loginName"),
|
||||
user -> user,
|
||||
(first, second) -> first
|
||||
));
|
||||
Set<String> importedLoginNames = new HashSet<>();
|
||||
|
||||
// 更新前完成整批校验,避免部分人员成功、部分人员失败造成数据不一致。
|
||||
for (int i = 0; i < importData.size(); i++) {
|
||||
WelfareSelectionAccountImport item = importData.get(i);
|
||||
int rowNumber = i + 2;
|
||||
String loginName = StrUtil.trim(item.getLoginName());
|
||||
String userName = StrUtil.trim(item.getUserName());
|
||||
String account = StrUtil.trim(item.getAccount());
|
||||
String password = StrUtil.trim(item.getPassword());
|
||||
if (StrUtil.hasBlank(loginName, userName, account, password)) {
|
||||
throw new ServiceException("第" + rowNumber + "行的工号、姓名、账号或密码不能为空");
|
||||
}
|
||||
if (!importedLoginNames.add(loginName)) {
|
||||
throw new ServiceException("第" + rowNumber + "行工号重复:" + loginName);
|
||||
}
|
||||
NutMap selectedUser = selectedUserMap.get(loginName);
|
||||
if (selectedUser == null) {
|
||||
throw new ServiceException("第" + rowNumber + "行工号不是当前套餐的已选人员:" + loginName);
|
||||
}
|
||||
if (!userName.equals(StrUtil.trim(selectedUser.getString("userName")))) {
|
||||
throw new ServiceException("第" + rowNumber + "行工号与姓名不匹配:" + loginName);
|
||||
}
|
||||
item.setLoginName(loginName).setUserName(userName).setAccount(account).setPassword(password);
|
||||
}
|
||||
|
||||
for (WelfareSelectionAccountImport item : importData) {
|
||||
NutMap selectedUser = selectedUserMap.get(item.getLoginName());
|
||||
Chain updateChain = Chain.make("account", item.getAccount()).add("password", item.getPassword());
|
||||
int updated = dao().update(WelfareUserSelection.class, updateChain,
|
||||
Cnd.where("welfareId", "=", projectId)
|
||||
.and("selectOptionId", "=", optionId)
|
||||
.and("selectUserId", "=", selectedUser.getString("userId")));
|
||||
if (updated == 0) {
|
||||
throw new ServiceException("工号对应的套餐选择记录不存在:" + item.getLoginName());
|
||||
}
|
||||
}
|
||||
return importData.size();
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验套餐属于当前福利项目,且账号密码仅能用于蛋糕卡套餐,避免跨项目或非蛋糕卡套餐写入领取凭证。
|
||||
*/
|
||||
private void validateProjectOption(String projectId, String optionId) {
|
||||
if (StrUtil.hasBlank(projectId, optionId)) {
|
||||
throw new ServiceException("福利项目和套餐不能为空");
|
||||
}
|
||||
WelfareProjectSubjectOption option = dao().fetch(WelfareProjectSubjectOption.class, optionId);
|
||||
WelfareProjectSubject subject = option == null ? null : dao().fetch(WelfareProjectSubject.class, option.getSubjectId());
|
||||
if (subject == null || !projectId.equals(subject.getProjectId())) {
|
||||
throw new ServiceException("所选套餐不属于当前福利项目");
|
||||
}
|
||||
if (!"蛋糕卡".equals(option.getOptionName())) {
|
||||
throw new ServiceException("只有蛋糕卡套餐可以导入账号密码");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询当前项目、当前套餐的已选人员,每名人员只返回一条,用于模板生成和导入校验。
|
||||
*/
|
||||
private List<NutMap> getSelectedUsers(String projectId, String optionId) {
|
||||
Sql sql = Sqls.create("""
|
||||
SELECT DISTINCT
|
||||
wl.userId,
|
||||
wl.loginName,
|
||||
wl.userName
|
||||
FROM welfare_project_user_selection wpus
|
||||
INNER JOIN welfare_list wl ON wl.userId = wpus.selectUserId
|
||||
AND wl.projectId = wpus.welfareId
|
||||
WHERE wpus.welfareId = @projectId
|
||||
AND wpus.selectOptionId = @optionId
|
||||
ORDER BY wl.loginName ASC
|
||||
""");
|
||||
sql.setParam("projectId", projectId);
|
||||
sql.setParam("optionId", optionId);
|
||||
return listMap(sql);
|
||||
}
|
||||
|
||||
|
||||
private CellStyle buildCellStyle(Workbook workbook, String type) {
|
||||
CellStyle style = workbook.createCellStyle();
|
||||
// 字体样式
|
||||
Font font = workbook.createFont();
|
||||
if ("headerStyles".equals(type)) {
|
||||
font.setFontHeightInPoints((short) 16);
|
||||
font.setBold(true);
|
||||
}
|
||||
if ("titleStyles".equals(type)) {
|
||||
font.setFontHeightInPoints((short) 12);
|
||||
font.setBold(true);
|
||||
}
|
||||
if ("valueStyles".equals(type)) {
|
||||
font.setFontHeightInPoints((short) 11);
|
||||
}
|
||||
if (!"headerStyles".equals(type)) {
|
||||
// 设置底边框
|
||||
style.setBorderBottom(BorderStyle.THIN);
|
||||
// 设置左边框
|
||||
style.setBorderLeft(BorderStyle.THIN);
|
||||
// 设置右边框;
|
||||
style.setBorderRight(BorderStyle.THIN);
|
||||
// 设置顶边框;
|
||||
style.setBorderTop(BorderStyle.THIN);
|
||||
}
|
||||
font.setFontName("Courier New");
|
||||
style.setFont(font);
|
||||
|
||||
// 设置底边颜色
|
||||
style.setBottomBorderColor(HSSFColor.HSSFColorPredefined.BLACK.getIndex());
|
||||
// 设置左边框颜色;
|
||||
style.setLeftBorderColor(HSSFColor.HSSFColorPredefined.BLACK.getIndex());
|
||||
// 设置右边框颜色;
|
||||
style.setRightBorderColor(HSSFColor.HSSFColorPredefined.BLACK.getIndex());
|
||||
// 设置顶边框颜色;
|
||||
style.setTopBorderColor(HSSFColor.HSSFColorPredefined.BLACK.getIndex());
|
||||
// 设置自动换行;
|
||||
style.setWrapText(true);
|
||||
// 设置水平对齐的样式为居中对齐;
|
||||
style.setAlignment(HorizontalAlignment.CENTER);
|
||||
// 设置垂直对齐的样式为居中对齐;
|
||||
style.setVerticalAlignment(VerticalAlignment.CENTER);
|
||||
return style;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
+71
@@ -0,0 +1,71 @@
|
||||
package com.ruoyi.staffService.welfare.service.impl;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.dynamic.datasource.annotation.DSTransactional;
|
||||
import com.ruoyi.common.core.domain.PageForm;
|
||||
import com.ruoyi.common.core.page.Pagination;
|
||||
import com.ruoyi.common.core.service.BaseServiceImpl;
|
||||
import com.ruoyi.staffService.api.constant.welfare.WelfareUnitMode;
|
||||
import com.ruoyi.staffService.api.domain.welfare.WelfareUnit;
|
||||
import com.ruoyi.staffService.constant.Ds;
|
||||
import com.ruoyi.staffService.util.ProModuleDS;
|
||||
import com.ruoyi.staffService.welfare.service.StaffWelfareUnitManageService;
|
||||
import com.ruoyi.system.api.domain.SysDept;
|
||||
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.lang.Lang;
|
||||
import org.nutz.lang.util.NutMap;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class StaffWelfareUnitManageServiceImpl extends BaseServiceImpl<WelfareUnit> implements StaffWelfareUnitManageService {
|
||||
|
||||
public StaffWelfareUnitManageServiceImpl(Dao dao) {
|
||||
super(dao);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<NutMap> treeData() {
|
||||
NutMap nutMap = NutMap.NEW();
|
||||
nutMap.setv("welfareUnitName", "福利单位");
|
||||
Cnd cnd = Cnd.NEW();
|
||||
cnd.asc("welfareUnitCode");
|
||||
cnd.and("welfareUnitMode", "=", WelfareUnitMode.getMode().name());
|
||||
List<WelfareUnit> list = query(cnd);
|
||||
nutMap.setv("children", list);
|
||||
return List.of(nutMap);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Pagination pageData(PageForm pageForm, String welfareUnitName) {
|
||||
Sql sql = Sqls.create("""
|
||||
select
|
||||
unit.*
|
||||
from
|
||||
welfare_unit unit
|
||||
$condition
|
||||
""");
|
||||
Cnd cnd = Cnd.NEW();
|
||||
if (StrUtil.isNotBlank(welfareUnitName)) {
|
||||
cnd.and(Cnd.likeEX("welfareUnitName", welfareUnitName));
|
||||
}
|
||||
sql.setCondition(cnd);
|
||||
return listPageMap(pageForm.getPageNumber(), pageForm.getPageSize(), sql);
|
||||
}
|
||||
|
||||
@Override
|
||||
@DSTransactional
|
||||
public void setComponentUnit(Long[] deptIds, String welfareUnitId) {
|
||||
ProModuleDS.execVoid(Ds.SYSTEM, () -> {
|
||||
dao().update(SysDept.class, Chain.make("welfareUnitId", null), Cnd.where("welfareUnitId", "=", welfareUnitId));
|
||||
if (Lang.isNotEmpty(deptIds)) {
|
||||
dao().update(SysDept.class, Chain.make("welfareUnitId", welfareUnitId), Cnd.where("deptId", "in", deptIds));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
# Tomcat
|
||||
server:
|
||||
port: 9212
|
||||
|
||||
# Spring
|
||||
spring:
|
||||
application:
|
||||
# 应用名称
|
||||
name: ruoyi-staffService
|
||||
profiles:
|
||||
# 环境配置
|
||||
active: prod
|
||||
cloud:
|
||||
nacos:
|
||||
discovery:
|
||||
# 服务注册地址
|
||||
server-addr: 127.0.0.1:8848
|
||||
config:
|
||||
# 配置中心地址
|
||||
server-addr: 127.0.0.1:8848
|
||||
# 配置文件格式
|
||||
file-extension: yml
|
||||
# 共享配置
|
||||
shared-configs:
|
||||
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
|
||||
jackson:
|
||||
default-property-inclusion: always
|
||||
date-format: yyyy-MM-dd HH:mm:ss
|
||||
|
||||
|
||||
nutz:
|
||||
dao:
|
||||
runtime:
|
||||
#是否自动建表 默认true
|
||||
create: true
|
||||
#是否自动变更 建议不要打开 会出问题
|
||||
migration: true
|
||||
# 是否添加列 默认true
|
||||
add-column: true
|
||||
# 是否删除列 默认true
|
||||
delete-column: false
|
||||
# 是否删表重建,注意此功能会删除全部表及数据,一般应用于demo或测试 默认false
|
||||
foce-create: false
|
||||
# 是否检查索引 默认true
|
||||
check-index: true
|
||||
# 相关实体所在包
|
||||
basepackage:
|
||||
- com.ruoyi.staffService.api.domain
|
||||
sql-manager:
|
||||
#自定义sql管理模式 file和xml
|
||||
mode: file
|
||||
# 自定义sql文件路径
|
||||
paths:
|
||||
- sqls
|
||||
json:
|
||||
enabled: false
|
||||
auto-unicode: true
|
||||
quote-name: true
|
||||
ignore-null: false
|
||||
null-as-emtry: true
|
||||
mode: FULL
|
||||
|
||||
logging:
|
||||
file:
|
||||
name: logs/${spring.application.name}/info.log
|
||||
BIN
Binary file not shown.
BIN
Binary file not shown.
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
Binary file not shown.
BIN
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,74 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<configuration scan="true" scanPeriod="60 seconds" debug="false">
|
||||
<!-- 日志存放路径 -->
|
||||
<property name="log.path" value="logs/ruoyi-staffService" />
|
||||
<!-- 日志输出格式 -->
|
||||
<property name="log.pattern" value="%d{HH:mm:ss.SSS} [%thread] %-5level %logger{20} - [%method,%line] - %msg%n" />
|
||||
|
||||
<!-- 控制台输出 -->
|
||||
<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<encoder>
|
||||
<pattern>${log.pattern}</pattern>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<!-- 系统日志输出 -->
|
||||
<appender name="file_info" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<file>${log.path}/info.log</file>
|
||||
<!-- 循环政策:基于时间创建日志文件 -->
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||
<!-- 日志文件名格式 -->
|
||||
<fileNamePattern>${log.path}/info.%d{yyyy-MM-dd}.log</fileNamePattern>
|
||||
<!-- 日志最大的历史 60天 -->
|
||||
<maxHistory>60</maxHistory>
|
||||
</rollingPolicy>
|
||||
<encoder>
|
||||
<pattern>${log.pattern}</pattern>
|
||||
</encoder>
|
||||
<filter class="ch.qos.logback.classic.filter.LevelFilter">
|
||||
<!-- 过滤的级别 -->
|
||||
<level>INFO</level>
|
||||
<!-- 匹配时的操作:接收(记录) -->
|
||||
<onMatch>ACCEPT</onMatch>
|
||||
<!-- 不匹配时的操作:拒绝(不记录) -->
|
||||
<onMismatch>DENY</onMismatch>
|
||||
</filter>
|
||||
</appender>
|
||||
|
||||
<appender name="file_error" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<file>${log.path}/error.log</file>
|
||||
<!-- 循环政策:基于时间创建日志文件 -->
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||
<!-- 日志文件名格式 -->
|
||||
<fileNamePattern>${log.path}/error.%d{yyyy-MM-dd}.log</fileNamePattern>
|
||||
<!-- 日志最大的历史 60天 -->
|
||||
<maxHistory>60</maxHistory>
|
||||
</rollingPolicy>
|
||||
<encoder>
|
||||
<pattern>${log.pattern}</pattern>
|
||||
</encoder>
|
||||
<filter class="ch.qos.logback.classic.filter.LevelFilter">
|
||||
<!-- 过滤的级别 -->
|
||||
<level>ERROR</level>
|
||||
<!-- 匹配时的操作:接收(记录) -->
|
||||
<onMatch>ACCEPT</onMatch>
|
||||
<!-- 不匹配时的操作:拒绝(不记录) -->
|
||||
<onMismatch>DENY</onMismatch>
|
||||
</filter>
|
||||
</appender>
|
||||
|
||||
<!-- 系统模块日志级别控制 -->
|
||||
<logger name="com.ruoyi" level="info" />
|
||||
<!-- Spring日志级别控制 -->
|
||||
<logger name="org.springframework" level="warn" />
|
||||
|
||||
<root level="info">
|
||||
<appender-ref ref="console" />
|
||||
</root>
|
||||
|
||||
<!--系统操作日志-->
|
||||
<root level="info">
|
||||
<appender-ref ref="file_info" />
|
||||
<appender-ref ref="file_error" />
|
||||
</root>
|
||||
</configuration>
|
||||
Reference in New Issue
Block a user