优化
This commit is contained in:
@ -94,6 +94,15 @@ public class AppBgtProjectRecruitApplyController extends BaseController {
|
||||
return AjaxResult.success(iBgtProjectRecruitApplyService.quit(id));
|
||||
}
|
||||
|
||||
@ApiOperation("取消务工者选择")
|
||||
@Log(title = "取消务工者选择", businessType = BusinessType.UPDATE)
|
||||
@RepeatSubmit
|
||||
@PutMapping("/cancel/{id}")
|
||||
public AjaxResult<Boolean> cancel(@NotNull(message = "主键不能为空")
|
||||
@PathVariable("id") Long id) {
|
||||
return AjaxResult.success(iBgtProjectRecruitApplyService.cancel(id));
|
||||
}
|
||||
|
||||
@ApiOperation("App务工者打分")
|
||||
@Log(title = "App务工者打分", businessType = BusinessType.UPDATE)
|
||||
@RepeatSubmit
|
||||
|
@ -9,6 +9,7 @@ import com.ruoyi.common.core.domain.Area;
|
||||
import com.ruoyi.common.core.domain.entity.BgtUser;
|
||||
import com.ruoyi.common.core.domain.entity.SysDictData;
|
||||
import com.ruoyi.common.core.domain.entity.SysUser;
|
||||
import com.ruoyi.common.core.domain.model.AreaNodeRespVO;
|
||||
import com.ruoyi.common.core.domain.model.BgtLoginBody;
|
||||
import com.ruoyi.common.core.domain.model.LoginUser;
|
||||
import com.ruoyi.common.util.DataUtil;
|
||||
@ -138,10 +139,10 @@ public class AppLoginController
|
||||
|
||||
@GetMapping("/tree")
|
||||
@ApiOperation("获得地区树")
|
||||
public AjaxResult<List<Area>> getAreaTree() {
|
||||
public AjaxResult<List<AreaNodeRespVO>> getAreaTree() {
|
||||
Area area = AreaUtils.getArea(Area.ID_CHINA);
|
||||
Assert.notNull(area, "获取不到中国");
|
||||
return AjaxResult.success(area.getChildren());
|
||||
return AjaxResult.success(AreaUtils.toBean(area.getChildren(), AreaNodeRespVO.class));
|
||||
}
|
||||
|
||||
|
||||
|
@ -0,0 +1,24 @@
|
||||
package com.ruoyi.common.core.domain.model;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@ApiModel("地区节点 Response VO")
|
||||
@Data
|
||||
public class AreaNodeRespVO {
|
||||
|
||||
@ApiModelProperty("编号")
|
||||
private Integer id;
|
||||
|
||||
@ApiModelProperty("名字")
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 子节点
|
||||
*/
|
||||
private List<AreaNodeRespVO> children;
|
||||
|
||||
}
|
@ -38,7 +38,9 @@ public enum RecruitApplyStatus
|
||||
return info;
|
||||
}
|
||||
|
||||
//任务详情里面务工者人员状态
|
||||
public static List<String> getTaskStatus(){
|
||||
return Arrays.asList(BGT_PASS.getCode(),WGZ_PASS.getCode(),WORKING.getCode(), OUT_WORK.getCode());
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,5 +1,7 @@
|
||||
package com.ruoyi.common.utils;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.io.resource.ResourceUtil;
|
||||
import cn.hutool.core.lang.Assert;
|
||||
import cn.hutool.core.text.csv.CsvRow;
|
||||
@ -7,11 +9,11 @@ import cn.hutool.core.text.csv.CsvUtil;
|
||||
import com.ruoyi.common.core.domain.Area;
|
||||
import com.ruoyi.common.enums.AreaType;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 区域工具类
|
||||
@ -19,6 +21,7 @@ import java.util.Map;
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class AreaUtils {
|
||||
|
||||
/**
|
||||
@ -32,32 +35,40 @@ public class AreaUtils {
|
||||
*/
|
||||
private static Map<Integer, Area> areas;
|
||||
|
||||
private AreaUtils() {
|
||||
long now = System.currentTimeMillis();
|
||||
areas = new HashMap<>();
|
||||
areas.put(Area.ID_GLOBAL, new Area(Area.ID_GLOBAL, "全球", 0,
|
||||
null, new ArrayList<>()));
|
||||
// 从 csv 中加载数据
|
||||
List<CsvRow> rows = CsvUtil.getReader().read(ResourceUtil.getUtf8Reader("area.csv")).getRows();
|
||||
rows.remove(0); // 删除 header
|
||||
for (CsvRow row : rows) {
|
||||
// 创建 Area 对象
|
||||
Area area = new Area(Integer.valueOf(row.get(0)), row.get(1), Integer.valueOf(row.get(2)),
|
||||
null, new ArrayList<>());
|
||||
// 添加到 areas 中
|
||||
areas.put(area.getId(), area);
|
||||
}
|
||||
private AreaUtils() {
|
||||
long now = System.currentTimeMillis();
|
||||
areas = new HashMap<>();
|
||||
areas.put(Area.ID_GLOBAL, new Area(Area.ID_GLOBAL, "全球", 0, null, new ArrayList<>()));
|
||||
|
||||
// 构建父子关系:因为 Area 中没有 parentId 字段,所以需要重复读取
|
||||
for (CsvRow row : rows) {
|
||||
Area area = areas.get(Integer.valueOf(row.get(0))); // 自己
|
||||
Area parent = areas.get(Integer.valueOf(row.get(3))); // 父
|
||||
Assert.isTrue(area != parent, "{}:父子节点相同", area.getName());
|
||||
area.setParent(parent);
|
||||
parent.getChildren().add(area);
|
||||
}
|
||||
log.info("启动加载 AreaUtils 成功,耗时 ({}) 毫秒", System.currentTimeMillis() - now);
|
||||
}
|
||||
try {
|
||||
List<CsvRow> rows = CsvUtil.getReader().read(ResourceUtil.getUtf8Reader("area.csv")).getRows();
|
||||
if (!rows.isEmpty()) {
|
||||
rows.remove(0); // 删除 header
|
||||
for (CsvRow row : rows) {
|
||||
// 创建 Area 对象
|
||||
Area area = new Area(Integer.valueOf(row.get(0)), row.get(1), Integer.valueOf(row.get(2)),
|
||||
null, new ArrayList<>());
|
||||
// 添加到 areas 中
|
||||
areas.put(area.getId(), area);
|
||||
|
||||
// 构建父子关系
|
||||
int parentId = Integer.valueOf(row.get(3));
|
||||
Area parent = areas.get(parentId);
|
||||
if (parent != null) {
|
||||
Assert.isTrue(area != parent, "{}:父子节点相同", area.getName());
|
||||
area.setParent(parent);
|
||||
parent.getChildren().add(area);
|
||||
} else {
|
||||
log.warn("区域 {} 的父区域 ID {} 无效", area.getName(), parentId);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("加载区域数据时发生错误", e);
|
||||
}
|
||||
|
||||
log.info("启动加载 AreaUtils 成功,耗时 ({}) 毫秒", System.currentTimeMillis() - now);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得指定编号对应的区域
|
||||
@ -152,4 +163,28 @@ public class AreaUtils {
|
||||
|
||||
|
||||
|
||||
public static AreaUtils getInstance() {
|
||||
return INSTANCE;
|
||||
}
|
||||
|
||||
public static <S, T> List<T> toBean(List<S> source, Class<T> targetType) {
|
||||
if (source == null) {
|
||||
return null;
|
||||
}
|
||||
return convertList(source, s -> toBean(s, targetType));
|
||||
}
|
||||
|
||||
public static <T> T toBean(Object source, Class<T> targetClass) {
|
||||
return BeanUtil.toBean(source, targetClass);
|
||||
}
|
||||
|
||||
public static <T, U> List<U> convertList(Collection<T> from, Function<T, U> func) {
|
||||
if (CollUtil.isEmpty(from)) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
return from.stream().map(func).filter(Objects::nonNull).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@ -22,6 +22,7 @@ public class BgtProjectRecruitApplyConsentDTO{
|
||||
|
||||
/** 主键ID */
|
||||
@ApiModelProperty("主键ID")
|
||||
@NotNull(message = "主键ID不能为空")
|
||||
private Long id;
|
||||
|
||||
@ApiModelProperty("进场时间")
|
||||
|
@ -113,6 +113,10 @@ public interface IBgtProjectRecruitApplyService extends IServicePlus<BgtProjectR
|
||||
*/
|
||||
Boolean quit(Long id);
|
||||
|
||||
/**
|
||||
* 取消选择
|
||||
*/
|
||||
Boolean cancel(Long id);
|
||||
/**
|
||||
* 批量退场
|
||||
*/
|
||||
|
@ -383,6 +383,35 @@ public class BgtProjectRecruitApplyServiceImpl extends ServicePlusImpl<BgtProjec
|
||||
return updateById(recruitApply);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean cancel(Long id) {
|
||||
BgtProjectRecruitApply recruitApply = getById(id);
|
||||
BgtProjectRecruit recruit = iBgtProjectRecruitService.getById(recruitApply.getRecruitId());
|
||||
|
||||
//发消息
|
||||
HashMap<String, String> mp = new HashMap<>();
|
||||
mp.put("projectName", recruit.getRecruitName());
|
||||
mp.put("auditor", SecurityUtils.getUsername());
|
||||
Map<String, String> map = bgtMessage(mp, BGT_TYPE_CANSEL, true);
|
||||
WgzMessage wgzMessage = new WgzMessage()
|
||||
.setSenderType(USERTYPE_BGT)
|
||||
.setRecipientType(USERTYPE_WGZ)
|
||||
.setRecipientId(recruitApply.getUserId())
|
||||
.setHeadline(map.get(HEADLINE))
|
||||
.setSubheading(map.get(SUBHEADING))
|
||||
.setTableId(recruitApply.getId())
|
||||
.setTableName(SqlHelper.table(BgtProjectRecruitApply.class).getTableName())
|
||||
.setMessageLargeType(LARGE_OTHER)
|
||||
.setMessageSmallType(SMALL_CANCEL);
|
||||
iWgzMessageService.sendAMessage(wgzMessage);
|
||||
|
||||
recruitApply.setStatus(RecruitApplyStatus.BGT_REFUSE.getCode());
|
||||
if(RecruitApplyStatus.WORKING.getCode().equals(recruitApply.getStatus())){
|
||||
recruitApply.setLeaveTime(LocalDate.now());
|
||||
}
|
||||
return updateById(recruitApply);
|
||||
}
|
||||
|
||||
@Async
|
||||
@Override
|
||||
public void quitBatch(Long taskId) {
|
||||
|
@ -37,6 +37,10 @@ public class BgtMessageConstant {
|
||||
public static final String BGT_LEAVE_EXIT_HEADLINE = "您已从【%s】项目退场!";
|
||||
public static final String BGT_LEAVE_EXIT_SUBHEADING_ONE = "您已被【%s】指定从【%s】项目退场!";
|
||||
public static final String BGT_LEAVE_EXIT_SUBHEADING_TWO = "【%s】项目已完结,自动退场!";
|
||||
//取消选择
|
||||
public static final String BGT_LEAVE_CANSEL_HEADLINE = "您已从【%s】项目离开!";
|
||||
public static final String BGT_LEAVE_CANSEL_SUBHEADING_ONE = "您在【%s】项目中被【%s】拒绝!";
|
||||
|
||||
|
||||
//包工头->务工者 消息类型
|
||||
public static final String BGT_TYPE_SIGN_UP = "1"; //务工者报名
|
||||
@ -44,6 +48,7 @@ public class BgtMessageConstant {
|
||||
public static final String BGT_TYPE_LEAVE = "3"; //请假
|
||||
public static final String BGT_TYPE_MAKE_UP = "4"; //补卡
|
||||
public static final String BGT_TYPE_EXIT = "5"; //退场
|
||||
public static final String BGT_TYPE_CANSEL = "11"; //取消选择
|
||||
|
||||
|
||||
/**
|
||||
@ -146,6 +151,10 @@ public class BgtMessageConstant {
|
||||
map.put(HEADLINE, String.format(BGT_TO_FBG_SETTLEMENT_APPLY_HEADLINE, auditor));
|
||||
map.put(SUBHEADING, String.format(BGT_TO_FBG_SETTLEMENT_APPLY_SUBHEADING, auditor, amount));
|
||||
break;
|
||||
case "11":
|
||||
map.put(HEADLINE, String.format(BGT_LEAVE_CANSEL_HEADLINE, projectName));
|
||||
map.put(SUBHEADING, String.format(BGT_LEAVE_CANSEL_SUBHEADING_ONE, projectName,auditor));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -24,6 +24,7 @@ public class WgzAndBgtMessageConstant {
|
||||
public static final String SMALL_EXIT = "2"; //小类型-退场
|
||||
public static final String SMALL_LEAVE = "3"; //小类型-请假
|
||||
public static final String SMALL_DAILY = "4"; //小类型-日报补卡
|
||||
public static final String SMALL_CANCEL = "5"; //小类型-取消选择
|
||||
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user