|
@@ -26,11 +26,14 @@ import com.zhongzheng.common.utils.ToolsUtils;
|
|
import com.zhongzheng.common.utils.file.FileUtils;
|
|
import com.zhongzheng.common.utils.file.FileUtils;
|
|
import com.zhongzheng.common.utils.file.ImageUtils;
|
|
import com.zhongzheng.common.utils.file.ImageUtils;
|
|
import com.zhongzheng.common.utils.http.HttpUtils;
|
|
import com.zhongzheng.common.utils.http.HttpUtils;
|
|
|
|
+import com.zhongzheng.common.utils.poi.ExcelUtil;
|
|
import com.zhongzheng.modules.alioss.bo.OssRequest;
|
|
import com.zhongzheng.modules.alioss.bo.OssRequest;
|
|
import com.zhongzheng.modules.alioss.service.OssService;
|
|
import com.zhongzheng.modules.alioss.service.OssService;
|
|
import com.zhongzheng.modules.alioss.vo.FileBean;
|
|
import com.zhongzheng.modules.alioss.vo.FileBean;
|
|
import com.zhongzheng.modules.base.bo.ConsoleQueryBo;
|
|
import com.zhongzheng.modules.base.bo.ConsoleQueryBo;
|
|
import com.zhongzheng.modules.base.bo.UserProfileFit;
|
|
import com.zhongzheng.modules.base.bo.UserProfileFit;
|
|
|
|
+import com.zhongzheng.modules.base.domain.UserProfile;
|
|
|
|
+import com.zhongzheng.modules.base.service.IUserProfileService;
|
|
import com.zhongzheng.modules.course.domain.CourseBusiness;
|
|
import com.zhongzheng.modules.course.domain.CourseBusiness;
|
|
import com.zhongzheng.modules.course.domain.CourseEducationType;
|
|
import com.zhongzheng.modules.course.domain.CourseEducationType;
|
|
import com.zhongzheng.modules.course.domain.CourseProjectType;
|
|
import com.zhongzheng.modules.course.domain.CourseProjectType;
|
|
@@ -61,6 +64,7 @@ import com.zhongzheng.modules.goods.service.IGoodsService;
|
|
import com.zhongzheng.modules.goods.vo.GoodsVo;
|
|
import com.zhongzheng.modules.goods.vo.GoodsVo;
|
|
import com.zhongzheng.modules.grade.domain.ClassGradeUser;
|
|
import com.zhongzheng.modules.grade.domain.ClassGradeUser;
|
|
import com.zhongzheng.modules.grade.service.IClassGradeUserService;
|
|
import com.zhongzheng.modules.grade.service.IClassGradeUserService;
|
|
|
|
+import com.zhongzheng.modules.grade.service.IUserPeriodService;
|
|
import com.zhongzheng.modules.grade.vo.ClassGradeVo;
|
|
import com.zhongzheng.modules.grade.vo.ClassGradeVo;
|
|
import com.zhongzheng.modules.inform.bo.InformUserAddBo;
|
|
import com.zhongzheng.modules.inform.bo.InformUserAddBo;
|
|
import com.zhongzheng.modules.inform.service.IInformRemindService;
|
|
import com.zhongzheng.modules.inform.service.IInformRemindService;
|
|
@@ -73,6 +77,7 @@ import com.zhongzheng.modules.system.domain.SysTask;
|
|
import com.zhongzheng.modules.system.domain.SysTenant;
|
|
import com.zhongzheng.modules.system.domain.SysTenant;
|
|
import com.zhongzheng.modules.system.service.ISysTaskService;
|
|
import com.zhongzheng.modules.system.service.ISysTaskService;
|
|
import com.zhongzheng.modules.system.service.ISysTenantService;
|
|
import com.zhongzheng.modules.system.service.ISysTenantService;
|
|
|
|
+import com.zhongzheng.modules.system.vo.SysTaskVo;
|
|
import com.zhongzheng.modules.user.bo.*;
|
|
import com.zhongzheng.modules.user.bo.*;
|
|
import com.zhongzheng.modules.user.domain.User;
|
|
import com.zhongzheng.modules.user.domain.User;
|
|
import com.zhongzheng.modules.user.domain.UserExamGoods;
|
|
import com.zhongzheng.modules.user.domain.UserExamGoods;
|
|
@@ -99,6 +104,9 @@ import java.awt.*;
|
|
import java.awt.image.BufferedImage;
|
|
import java.awt.image.BufferedImage;
|
|
import java.io.*;
|
|
import java.io.*;
|
|
import java.net.URL;
|
|
import java.net.URL;
|
|
|
|
+import java.nio.file.Files;
|
|
|
|
+import java.nio.file.Path;
|
|
|
|
+import java.nio.file.Paths;
|
|
import java.text.ParseException;
|
|
import java.text.ParseException;
|
|
import java.text.SimpleDateFormat;
|
|
import java.text.SimpleDateFormat;
|
|
import java.time.LocalDate;
|
|
import java.time.LocalDate;
|
|
@@ -110,6 +118,7 @@ import java.util.List;
|
|
import java.util.*;
|
|
import java.util.*;
|
|
import java.util.concurrent.TimeUnit;
|
|
import java.util.concurrent.TimeUnit;
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
|
|
+import java.util.stream.Stream;
|
|
import java.util.zip.ZipOutputStream;
|
|
import java.util.zip.ZipOutputStream;
|
|
|
|
|
|
import static java.util.stream.Collectors.toCollection;
|
|
import static java.util.stream.Collectors.toCollection;
|
|
@@ -132,6 +141,8 @@ public class UserSubscribeServiceImpl extends ServiceImpl<UserSubscribeMapper, U
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
private IGoodsService iGoodsService;
|
|
private IGoodsService iGoodsService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private IMajorService iMajorService;
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
private IInformUserService iInformUserService;
|
|
private IInformUserService iInformUserService;
|
|
@@ -148,6 +159,9 @@ public class UserSubscribeServiceImpl extends ServiceImpl<UserSubscribeMapper, U
|
|
@Autowired
|
|
@Autowired
|
|
private IUserService iUserService;
|
|
private IUserService iUserService;
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
+ private IUserProfileService iUserProfileService;
|
|
|
|
+
|
|
@Autowired
|
|
@Autowired
|
|
private IExamApplySiteService iExamApplySiteService;
|
|
private IExamApplySiteService iExamApplySiteService;
|
|
|
|
|
|
@@ -2655,6 +2669,32 @@ public class UserSubscribeServiceImpl extends ServiceImpl<UserSubscribeMapper, U
|
|
}
|
|
}
|
|
Long zeroTime = DateUtils.getTodayZeroTime();
|
|
Long zeroTime = DateUtils.getTodayZeroTime();
|
|
bo.setDataTime(zeroTime);
|
|
bo.setDataTime(zeroTime);
|
|
|
|
+ if (ObjectUtils.isNotNull(bo.getApplyDateTime()) && bo.getApplyDateTime().length() == 6){
|
|
|
|
+ //根据月份筛选
|
|
|
|
+ String dateStr = String.format(bo.getApplyDateTime()); // 指定年月
|
|
|
|
+ LocalDate date = LocalDate.parse(dateStr + "01", DateTimeFormatter.BASIC_ISO_DATE);
|
|
|
|
+ LocalDate dateFirst = date.with(TemporalAdjusters.firstDayOfMonth()); // 指定年月的第一天
|
|
|
|
+ LocalDate dateEnd = date.with(TemporalAdjusters.lastDayOfMonth()); // 指定年月的最后一天
|
|
|
|
+ ZonedDateTime zonedDateTime1 = dateFirst.atStartOfDay(ZoneId.systemDefault());
|
|
|
|
+ Date date1 = Date.from(zonedDateTime1.toInstant());
|
|
|
|
+ ZonedDateTime zonedDateTime = dateEnd.atStartOfDay(ZoneId.systemDefault());
|
|
|
|
+ Date date2 = Date.from(zonedDateTime.toInstant());
|
|
|
|
+ Long startTime = date1.getTime()/1000;
|
|
|
|
+ Long endTime = (date2.getTime()/1000) + 86400;
|
|
|
|
+ bo.setMonthStartTime(startTime);
|
|
|
|
+ bo.setMonthEndTime(endTime);
|
|
|
|
+ }else if (ObjectUtils.isNotNull(bo.getApplyDateTime()) && bo.getApplyDateTime().length() > 6){
|
|
|
|
+ //根据某天筛选
|
|
|
|
+ String dateStr = String.format(bo.getApplyDateTime());
|
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
|
|
|
|
+ try {
|
|
|
|
+ Date parse = sdf.parse(dateStr);
|
|
|
|
+ bo.setMonthStartTime(parse.getTime()/1000);
|
|
|
|
+ bo.setMonthEndTime(parse.getTime()/1000);
|
|
|
|
+ } catch (ParseException e) {
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
List<UserSubVo> userSubVos = baseMapper.getListSubscribe(bo);
|
|
List<UserSubVo> userSubVos = baseMapper.getListSubscribe(bo);
|
|
if (CollectionUtils.isEmpty(userSubVos)){
|
|
if (CollectionUtils.isEmpty(userSubVos)){
|
|
return new ArrayList<>();
|
|
return new ArrayList<>();
|
|
@@ -2690,7 +2730,7 @@ public class UserSubscribeServiceImpl extends ServiceImpl<UserSubscribeMapper, U
|
|
public Boolean subUserExport(SubUserExportBo bo) {
|
|
public Boolean subUserExport(SubUserExportBo bo) {
|
|
//加入任务列表
|
|
//加入任务列表
|
|
SysTask sysTask = new SysTask();
|
|
SysTask sysTask = new SysTask();
|
|
- sysTask.setTaskName(String.format("%s 学员预约下载任务",DateUtils.getTime()));
|
|
|
|
|
|
+ sysTask.setTaskName(String.format("(%s)学员档案下载任务",DateUtils.getTime()));
|
|
//下载数量
|
|
//下载数量
|
|
String tenantId = ServletUtils.getRequest().getHeader("TenantId");
|
|
String tenantId = ServletUtils.getRequest().getHeader("TenantId");
|
|
SysTenant sysTenant = iSysTenantService.getById(Long.valueOf(tenantId));
|
|
SysTenant sysTenant = iSysTenantService.getById(Long.valueOf(tenantId));
|
|
@@ -2723,6 +2763,188 @@ public class UserSubscribeServiceImpl extends ServiceImpl<UserSubscribeMapper, U
|
|
baseMapper.updateByIdNoTenant(subscribe);
|
|
baseMapper.updateByIdNoTenant(subscribe);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
+ public String subRecordUserExport(SubUserExportBo bo) {
|
|
|
|
+ String tenantId = ServletUtils.getRequest().getHeader("TenantId");
|
|
|
|
+ SysTenant sysTenant = iSysTenantService.getById(Long.valueOf(tenantId));
|
|
|
|
+ if (ObjectUtils.isNotNull(sysTenant.getExamRoom()) && sysTenant.getExamRoom() == 1){
|
|
|
|
+ //公用祥粤考场
|
|
|
|
+ List<SysTenant> list = iSysTenantService
|
|
|
|
+ .list(new LambdaQueryWrapper<SysTenant>().eq(SysTenant::getStatus, 1)
|
|
|
|
+ .eq(SysTenant::getExamRoom, 1));
|
|
|
|
+ bo.setTenantIds(list.stream().map(SysTenant::getTenantId).collect(Collectors.toList()));
|
|
|
|
+ }else {
|
|
|
|
+ bo.setTenantIds(Arrays.asList(Long.valueOf(tenantId)));
|
|
|
|
+ }
|
|
|
|
+ List<UserSubscribe> subscribeList = baseMapper.listByTimeNoTenant(bo);
|
|
|
|
+ if (CollectionUtils.isEmpty(subscribeList)){
|
|
|
|
+ throw new CustomException("该场次没有预约的学员!");
|
|
|
|
+ }
|
|
|
|
+ //商品分组
|
|
|
|
+ Map<Long, List<UserSubscribe>> map = subscribeList.stream().collect(Collectors.groupingBy(UserSubscribe::getGoodsId));
|
|
|
|
+ String zhiyuan = System.getProperty("user.dir");
|
|
|
|
+ String destDirPath = zhiyuan+"/zhongzheng-admin/src/main/resources/"
|
|
|
|
+ +String.format("%s预约考试%s",DateUtils.timestampToDateFormat(bo.getApplyTime(),"yyyy-MM-dd"),DateUtils.getNowTime());
|
|
|
|
+ List<UserExamApplyExport> examApplyExports = new ArrayList<>();
|
|
|
|
+ map.forEach((k,v) -> {
|
|
|
|
+ Goods goods = iGoodsService.getGoodsByIdNotTenant(k);
|
|
|
|
+ if (ObjectUtils.isNull(goods) || ObjectUtils.isNull(goods.getMajorId())){
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ Major major = iMajorService.getMajorByIdNoTenant(goods.getMajorId());
|
|
|
|
+ String majorPath = destDirPath+"/"+major.getCategoryName();
|
|
|
|
+ File dirw = new File(majorPath);
|
|
|
|
+ if (!dirw.exists()){
|
|
|
|
+ dirw.mkdirs();
|
|
|
|
+ }
|
|
|
|
+ String photoPath = majorPath+"/"+"广东省祥粤建设职业培训学校";
|
|
|
|
+ File dirw2 = new File(photoPath);
|
|
|
|
+ if (!dirw2.exists()){
|
|
|
|
+ dirw2.mkdirs();
|
|
|
|
+ }
|
|
|
|
+ List<UserSubApplyExport> applyExports = new ArrayList<>();
|
|
|
|
+ //学员头像
|
|
|
|
+ v.forEach(item -> {
|
|
|
|
+ User user = iUserService.getByIdNoTenant(item.getUserId());
|
|
|
|
+ //获取个人近照
|
|
|
|
+ try {
|
|
|
|
+ InputStream inputStream = ossService.getStreamByObject(user.getOneInchPhotos());
|
|
|
|
+ //写入本地文件
|
|
|
|
+ String inchPath = photoPath + "/"+String.format("%s$头像.jpg", EncryptHandler.decrypt(user.getIdCard()));
|
|
|
|
+ FileOutputStream fileOutputStream = new FileOutputStream(inchPath);
|
|
|
|
+ byte[] buffer = new byte[1024];
|
|
|
|
+ int len = 0;
|
|
|
|
+ while ((len = inputStream.read(buffer)) != -1) {
|
|
|
|
+ fileOutputStream.write(buffer, 0, len);
|
|
|
|
+ }
|
|
|
|
+ inputStream.close();
|
|
|
|
+ fileOutputStream.close();
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ }
|
|
|
|
+ //报考资料
|
|
|
|
+ UserProfile profile = iUserProfileService.getByOrderGoodsIdNoTenant(item.getOrderGoodsId());
|
|
|
|
+ if (ObjectUtils.isNull(profile)){
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ UserSubApplyExport applyExport = new UserSubApplyExport();
|
|
|
|
+ applyExport.setUserName(user.getRealname());
|
|
|
|
+ applyExport.setIdCard(EncryptHandler.decrypt(user.getIdCard()));
|
|
|
|
+ applyExport.setPhone(EncryptHandler.decrypt(user.getTelphone()));
|
|
|
|
+
|
|
|
|
+ String keyValue = profile.getKeyValue();
|
|
|
|
+ applyExport.setSex(getUserProfileValue(keyValue,"sex"));
|
|
|
|
+ applyExport.setEducation(getUserProfileValue(keyValue,"education"));
|
|
|
|
+ applyExport.setCompanyName(getUserProfileValue(keyValue,"work_unit"));
|
|
|
|
+ applyExport.setPostName(getUserProfileValue(keyValue,"apply_post"));
|
|
|
|
+ applyExport.setMajorName(getUserProfileValue(keyValue,"major"));
|
|
|
|
+ applyExport.setAge(getUserProfileValue(keyValue,"working_years"));
|
|
|
|
+ applyExport.setGraduateTime(getUserProfileValue(keyValue,"graduation_time"));
|
|
|
|
+ applyExports.add(applyExport);
|
|
|
|
+
|
|
|
|
+ //测试计划
|
|
|
|
+ UserExamApplyExport export = new UserExamApplyExport();
|
|
|
|
+ export.setUserName(user.getRealname());
|
|
|
|
+ export.setIdCard(EncryptHandler.decrypt(user.getIdCard()));
|
|
|
|
+ export.setPhone(EncryptHandler.decrypt(user.getTelphone()));
|
|
|
|
+ export.setPostName(getUserProfileValue(keyValue,"apply_post"));
|
|
|
|
+ export.setApplyName(
|
|
|
|
+ String.format("%s测试%s-%s",DateUtils.timestampToDateFormat(item.getApplySiteExamTime(),"yyyy.MM.dd")
|
|
|
|
+ ,applyTimeTransition(item.getApplySiteStartTime()),applyTimeTransition(item.getApplySiteEndTime())));
|
|
|
|
+ examApplyExports.add(export);
|
|
|
|
+ });
|
|
|
|
+ //打包zip
|
|
|
|
+ String zipPath = majorPath+"/"+"广东省祥粤建设职业培训学校.zip";
|
|
|
|
+ FileUtils.toZip(zipPath,photoPath,true);
|
|
|
|
+ //删除本地资源
|
|
|
|
+ Path pathStr = Paths.get(photoPath);
|
|
|
|
+ try (Stream<Path> walk = Files.walk(pathStr)) {
|
|
|
|
+ walk.sorted(Comparator.reverseOrder())
|
|
|
|
+ .forEach(FileUtils::deleteDirectoryStream);
|
|
|
|
+ }catch (IOException e) {
|
|
|
|
+ log.error("删除本地资源失败:"+ DateUtils.getNowTime());
|
|
|
|
+ }
|
|
|
|
+ //报考资料
|
|
|
|
+ if (CollectionUtils.isNotEmpty(applyExports)){
|
|
|
|
+ ExcelUtil<UserSubApplyExport> util = new ExcelUtil<UserSubApplyExport>(UserSubApplyExport.class);
|
|
|
|
+ String path = majorPath + "/" +String.format("%s报名信息表",major.getCategoryName()) + ".xlsx";
|
|
|
|
+ util.exportEasyExcelStudy(util.exportEasyData(applyExports), path);
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ //测试计划
|
|
|
|
+ if (CollectionUtils.isNotEmpty(examApplyExports)){
|
|
|
|
+ ExcelUtil<UserExamApplyExport> util = new ExcelUtil<UserExamApplyExport>(UserExamApplyExport.class);
|
|
|
|
+ String path = destDirPath + "/测试计划.xlsx";
|
|
|
|
+ util.exportEasyExcelStudy(util.exportEasyData(examApplyExports), path);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //打包zip 上传oss
|
|
|
|
+ String zipPath = zhiyuan+"/zhongzheng-admin/src/main/resources/"
|
|
|
|
+ +String.format("%s预约考试%s.zip",DateUtils.timestampToDateFormat(bo.getApplyTime(),"yyyy-MM-dd"),DateUtils.getNowTime());
|
|
|
|
+ FileUtils.toZip(zipPath,destDirPath,true);
|
|
|
|
+ //上传oss
|
|
|
|
+ OssRequest ossRequest = new OssRequest();
|
|
|
|
+ ossRequest.setGradeId(0L);
|
|
|
|
+ ossRequest.setUserId(0L);
|
|
|
|
+ ossRequest.setImageStatus(7);
|
|
|
|
+ File file1 = new File(zipPath);
|
|
|
|
+ ossRequest.setFile(FileUtils.getMultipartFile(file1));
|
|
|
|
+ try {
|
|
|
|
+ String upload = ossService.upload(ossRequest);
|
|
|
|
+ //删除本地资源
|
|
|
|
+ Path pathStr = Paths.get(destDirPath);
|
|
|
|
+ try (Stream<Path> walk = Files.walk(pathStr)) {
|
|
|
|
+ walk.sorted(Comparator.reverseOrder())
|
|
|
|
+ .forEach(FileUtils::deleteDirectoryStream);
|
|
|
|
+ }catch (IOException e) {
|
|
|
|
+ log.error("删除本地资源失败:"+ DateUtils.getNowTime());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ Path zipStr = Paths.get(zipPath);
|
|
|
|
+ try (Stream<Path> walk = Files.walk(zipStr)) {
|
|
|
|
+ walk.sorted(Comparator.reverseOrder())
|
|
|
|
+ .forEach(FileUtils::deleteDirectoryStream);
|
|
|
|
+ }catch (IOException e) {
|
|
|
|
+ log.error("删除本地资源失败:"+ DateUtils.getNowTime());
|
|
|
|
+ }
|
|
|
|
+ return upload;
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ }
|
|
|
|
+ return "";
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public List<SysTaskVo> subUserExportList() {
|
|
|
|
+ List<SysTask> list = iSysTaskService.list(new LambdaQueryWrapper<SysTask>().eq(SysTask::getStatus, 1));
|
|
|
|
+ if (CollectionUtils.isEmpty(list)){
|
|
|
|
+ return new ArrayList<>();
|
|
|
|
+ }
|
|
|
|
+ return list.stream().map(item -> BeanUtil.toBean(item,SysTaskVo.class)).collect(Collectors.toList());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private String applyTimeTransition(String time){
|
|
|
|
+ List<String> collect = Arrays.stream(time.split(":")).collect(Collectors.toList());
|
|
|
|
+ StringBuffer result = new StringBuffer();
|
|
|
|
+ for (String s : collect) {
|
|
|
|
+ result.append(s);
|
|
|
|
+ }
|
|
|
|
+ return result.toString();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private String getUserProfileValue(String keyValue,String key){
|
|
|
|
+ JSONObject jsonObject = JSONObject.parseObject(keyValue);
|
|
|
|
+ if (ObjectUtils.isNotNull(jsonObject.get(key))){
|
|
|
|
+ Object o = jsonObject.get(key);
|
|
|
|
+ JSONObject jsonObject1 = JSONObject.parseObject(JSONObject.toJSONString(o));
|
|
|
|
+ if (ObjectUtils.isNotNull(jsonObject1.get("value"))){
|
|
|
|
+ return jsonObject1.get("value").toString();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return "";
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
|
|
/**
|
|
/**
|
|
* 学员学时图片修改
|
|
* 学员学时图片修改
|