app
This commit is contained in:
@ -29,6 +29,8 @@ import org.dromara.common.social.utils.SocialUtils;
|
||||
import org.dromara.common.sse.dto.SseMessageDto;
|
||||
import org.dromara.common.sse.utils.SseMessageUtils;
|
||||
import org.dromara.common.tenant.helper.TenantHelper;
|
||||
import org.dromara.sms4j.api.SmsBlend;
|
||||
import org.dromara.sms4j.core.factory.SmsFactory;
|
||||
import org.dromara.system.domain.bo.SysTenantBo;
|
||||
import org.dromara.system.domain.vo.SysClientVo;
|
||||
import org.dromara.system.domain.vo.SysTenantVo;
|
||||
@ -198,7 +200,12 @@ public class AuthController {
|
||||
|
||||
@PostMapping("/app/register")
|
||||
public R<Void> appRegister(@Validated @RequestBody RegisterBody user) {
|
||||
registerService.appRegister(user);
|
||||
if("sms".equals(user.getGrantType())){
|
||||
registerService.appSmsRegister(user);
|
||||
}else {
|
||||
registerService.appRegister(user);
|
||||
}
|
||||
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
|
||||
@ -57,16 +57,23 @@ public class CaptchaController {
|
||||
*/
|
||||
@RateLimiter(key = "#phonenumber", time = 60, count = 1)
|
||||
@GetMapping("/resource/sms/code")
|
||||
public R<Void> smsCode(@NotBlank(message = "{user.phonenumber.not.blank}") String phonenumber) {
|
||||
public R<Void> smsCode(@NotBlank(message = "{user.phonenumber.not.blank}") String phonenumber,String type) {
|
||||
String key = GlobalConstants.CAPTCHA_CODE_KEY + phonenumber;
|
||||
String code = RandomUtil.randomNumbers(4);
|
||||
RedisUtils.setCacheObject(key, code, Duration.ofMinutes(Constants.CAPTCHA_EXPIRATION));
|
||||
// 验证码模板id 自行处理 (查数据库或写死均可)
|
||||
String templateId = "";
|
||||
|
||||
LinkedHashMap<String, String> map = new LinkedHashMap<>(1);
|
||||
map.put("code", code);
|
||||
SmsBlend smsBlend = SmsFactory.getSmsBlend("config1");
|
||||
SmsResponse smsResponse = smsBlend.sendMessage(phonenumber, templateId, map);
|
||||
map.put("1", code);
|
||||
map.put("2", Constants.CAPTCHA_EXPIRATION.toString());
|
||||
String configName;
|
||||
if("login".equals(type)){
|
||||
configName = "config2";
|
||||
}else{
|
||||
configName = "config3";
|
||||
}
|
||||
SmsBlend smsBlend = SmsFactory.getSmsBlend(configName);
|
||||
SmsResponse smsResponse = smsBlend.sendMessage(phonenumber, map);
|
||||
if (!smsResponse.isSuccess()) {
|
||||
log.error("验证码短信发送异常 => {}", smsResponse);
|
||||
return R.fail(smsResponse.getData().toString());
|
||||
|
||||
@ -117,6 +117,42 @@ public class SysRegisterService {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 短信注册
|
||||
*/
|
||||
public void appSmsRegister(RegisterBody registerBody) {
|
||||
String tenantId = registerBody.getTenantId();
|
||||
String username = registerBody.getPhonenumber();
|
||||
String smsCode = registerBody.getSmsCode();
|
||||
|
||||
validateSmsCode(tenantId, username, smsCode);
|
||||
|
||||
// 校验用户类型是否存在
|
||||
String userType = UserType.getUserType(registerBody.getUserType()).getUserType();
|
||||
|
||||
// 验证码开关
|
||||
SysUserBo sysUser = new SysUserBo();
|
||||
sysUser.setUserName(username);
|
||||
sysUser.setNickName(username);
|
||||
sysUser.setPhonenumber(username);
|
||||
sysUser.setUserType(userType);
|
||||
|
||||
boolean exist = TenantHelper.dynamic(tenantId, () -> {
|
||||
return userMapper.exists(new LambdaQueryWrapper<SysUser>()
|
||||
.eq(SysUser::getPhonenumber, sysUser.getPhonenumber()));
|
||||
});
|
||||
if (exist) {
|
||||
throw new UserException("user.register.save.error", username);
|
||||
}
|
||||
boolean regFlag = userService.registerUser(sysUser, tenantId);
|
||||
if (!regFlag) {
|
||||
throw new UserException("user.register.error");
|
||||
}
|
||||
|
||||
recordLogininfor(tenantId, username, Constants.REGISTER, MessageUtils.message("user.register.success"));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 校验验证码
|
||||
*
|
||||
@ -138,6 +174,18 @@ public class SysRegisterService {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验短信验证码
|
||||
*/
|
||||
private boolean validateSmsCode(String tenantId, String phonenumber, String smsCode) {
|
||||
String code = RedisUtils.getCacheObject(GlobalConstants.CAPTCHA_CODE_KEY + phonenumber);
|
||||
if (StringUtils.isBlank(code)) {
|
||||
recordLogininfor(tenantId, phonenumber, Constants.LOGIN_FAIL, MessageUtils.message("user.jcaptcha.expire"));
|
||||
throw new CaptchaExpireException();
|
||||
}
|
||||
return code.equals(smsCode);
|
||||
}
|
||||
|
||||
/**
|
||||
* 记录登录信息
|
||||
*
|
||||
|
||||
@ -180,12 +180,21 @@ sms:
|
||||
signature: 您的短信签名
|
||||
sdk-app-id: 您的sdkAppId
|
||||
config2:
|
||||
# 厂商标识,标定此配置是哪个厂商,详细请看厂商标识介绍部分
|
||||
# 登录
|
||||
supplier: tencent
|
||||
access-key-id: 您的accessKey
|
||||
access-key-secret: 您的accessKeySecret
|
||||
signature: 您的短信签名
|
||||
sdk-app-id: 您的sdkAppId
|
||||
access-key-id: AKIDb3JK5dx4wa0DCxWqvxlKejvysZ3ITVJv
|
||||
access-key-secret: c5LPFsJI8k7GDxTkoeFj4A1ukQr66rPi
|
||||
signature: 重庆远界大数据研究院
|
||||
sdk-app-id: 1401018866
|
||||
template-id: 2491779
|
||||
config3:
|
||||
# 注册
|
||||
supplier: tencent
|
||||
access-key-id: AKIDb3JK5dx4wa0DCxWqvxlKejvysZ3ITVJv
|
||||
access-key-secret: c5LPFsJI8k7GDxTkoeFj4A1ukQr66rPi
|
||||
signature: 重庆远界大数据研究院
|
||||
sdk-app-id: 1401018866
|
||||
template-id: 2491776
|
||||
|
||||
|
||||
--- # 三方授权
|
||||
|
||||
@ -183,12 +183,21 @@ sms:
|
||||
signature: 您的短信签名
|
||||
sdk-app-id: 您的sdkAppId
|
||||
config2:
|
||||
# 厂商标识,标定此配置是哪个厂商,详细请看厂商标识介绍部分
|
||||
# 登录
|
||||
supplier: tencent
|
||||
access-key-id: 您的accessKey
|
||||
access-key-secret: 您的accessKeySecret
|
||||
signature: 您的短信签名
|
||||
sdk-app-id: 您的sdkAppId
|
||||
access-key-id: AKIDb3JK5dx4wa0DCxWqvxlKejvysZ3ITVJv
|
||||
access-key-secret: c5LPFsJI8k7GDxTkoeFj4A1ukQr66rPi
|
||||
signature: 重庆远界大数据研究院
|
||||
sdk-app-id: 1401018866
|
||||
template-id: 2491779
|
||||
config3:
|
||||
# 注册
|
||||
supplier: tencent
|
||||
access-key-id: AKIDb3JK5dx4wa0DCxWqvxlKejvysZ3ITVJv
|
||||
access-key-secret: c5LPFsJI8k7GDxTkoeFj4A1ukQr66rPi
|
||||
signature: 重庆远界大数据研究院
|
||||
sdk-app-id: 1401018866
|
||||
template-id: 2491776
|
||||
|
||||
--- # 三方授权
|
||||
justauth:
|
||||
|
||||
@ -65,7 +65,7 @@ public interface Constants {
|
||||
/**
|
||||
* 验证码有效期(分钟)
|
||||
*/
|
||||
Integer CAPTCHA_EXPIRATION = 2;
|
||||
Integer CAPTCHA_EXPIRATION = 5;
|
||||
|
||||
/**
|
||||
* 顶级父级id
|
||||
|
||||
@ -38,4 +38,5 @@ public class RegisterBody extends LoginBody {
|
||||
|
||||
private Long deptId;
|
||||
|
||||
private String smsCode;
|
||||
}
|
||||
|
||||
@ -156,4 +156,5 @@ public class SubConstructionUserAppController {
|
||||
public R<Long> add(@Validated(AddGroup.class) @RequestBody BusProjectTeamMemberCreateReq req) {
|
||||
return R.ok(busProjectTeamMemberService.insertByBo(req));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -196,4 +196,7 @@ public class SubConstructionUser extends BaseEntity {
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
|
||||
private LocalDate firstDate;
|
||||
|
||||
}
|
||||
|
||||
@ -51,6 +51,7 @@ import org.dromara.project.domain.enums.BusAttendanceClockStatusEnum;
|
||||
import org.dromara.project.domain.enums.BusAttendanceCommuterEnum;
|
||||
import org.dromara.project.domain.enums.BusConstructionUserAttendanceStatusEnum;
|
||||
import org.dromara.project.service.*;
|
||||
import org.dromara.system.domain.bo.SysUserBo;
|
||||
import org.dromara.system.domain.vo.SysOssVo;
|
||||
import org.dromara.system.domain.vo.SysUserVo;
|
||||
import org.dromara.system.service.ISysDictTypeService;
|
||||
@ -1196,6 +1197,11 @@ public class SubConstructionUserServiceImpl extends ServiceImpl<SubConstructionU
|
||||
if (!save) {
|
||||
throw new ServiceException("施工人员信息保存失败");
|
||||
}
|
||||
//修改用户昵称
|
||||
SysUserBo sysUserBo = new SysUserBo();
|
||||
sysUserBo.setUserId(userId);
|
||||
sysUserBo.setNickName(user.getUserName());
|
||||
userService.updateUser(sysUserBo);
|
||||
return user.getId();
|
||||
}
|
||||
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
package org.dromara.project.controller.app;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import org.dromara.common.core.domain.R;
|
||||
@ -8,7 +9,11 @@ import org.dromara.common.mybatis.core.page.PageQuery;
|
||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||
import org.dromara.common.satoken.utils.LoginHelper;
|
||||
import org.dromara.common.web.core.BaseController;
|
||||
import org.dromara.contractor.domain.SubConstructionUser;
|
||||
import org.dromara.contractor.domain.dto.constructionuser.SubConstructionUserQueryReq;
|
||||
import org.dromara.contractor.domain.vo.constructionuser.SubConstructionUserAppVo;
|
||||
import org.dromara.contractor.service.ISubConstructionUserService;
|
||||
import org.dromara.project.domain.BusAttendance;
|
||||
import org.dromara.project.domain.BusProjectPunchrange;
|
||||
import org.dromara.project.domain.dto.attendance.AttendanceCountDto;
|
||||
import org.dromara.project.domain.dto.attendance.AttendanceUserCountDto;
|
||||
@ -26,6 +31,7 @@ import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@ -42,13 +48,15 @@ public class BusAttendanceAppController extends BaseController {
|
||||
@Resource
|
||||
private IBusAttendanceService attendanceService;
|
||||
|
||||
|
||||
@Resource
|
||||
private IBusAttendanceRuleService attendanceRuleService;
|
||||
|
||||
@Resource
|
||||
private IBusProjectPunchrangeService projectPunchrangeService;
|
||||
|
||||
@Resource
|
||||
private ISubConstructionUserService constructionUserService;
|
||||
|
||||
|
||||
/**
|
||||
* 人脸坐标打卡
|
||||
@ -163,8 +171,30 @@ public class BusAttendanceAppController extends BaseController {
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 入职和考勤天数统计
|
||||
*/
|
||||
@GetMapping("/daysCount")
|
||||
public R<DaysCountVo> daysCount() {
|
||||
Long userId = LoginHelper.getUserId();
|
||||
|
||||
DaysCountVo daysCountVo = new DaysCountVo();
|
||||
|
||||
SubConstructionUser bySysUserId = constructionUserService.getBySysUserId(userId);
|
||||
if(bySysUserId == null || bySysUserId.getFirstDate() == null){
|
||||
daysCountVo.setEntryDays(0);
|
||||
}else{
|
||||
daysCountVo.setEntryDays(LocalDate.now().getDayOfYear() - bySysUserId.getFirstDate().getDayOfYear());
|
||||
}
|
||||
List<BusAttendance> list = attendanceService.list(Wrappers.<BusAttendance>lambdaQuery()
|
||||
.eq(BusAttendance::getUserId, userId)
|
||||
.in(BusAttendance::getClockStatus, Arrays.asList("1", "2", "3"))
|
||||
);
|
||||
long count = list.stream().map(BusAttendance::getClockDate).distinct().count();
|
||||
daysCountVo.setAttendanceDays((int)count);
|
||||
|
||||
return R.ok(daysCountVo);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@ -97,4 +97,9 @@ public class BusAttendance extends BaseEntity {
|
||||
* 规定时间
|
||||
*/
|
||||
private LocalTime ruleTime;
|
||||
|
||||
/**
|
||||
* 处理 0-未处理,1-已处理
|
||||
*/
|
||||
private String handle;
|
||||
}
|
||||
|
||||
@ -120,4 +120,9 @@ public class BusAttendanceVo implements Serializable {
|
||||
*/
|
||||
private LocalTime ruleTime;
|
||||
|
||||
/**
|
||||
* 处理 0-未处理,1-已处理
|
||||
*/
|
||||
private String handle;
|
||||
|
||||
}
|
||||
|
||||
@ -0,0 +1,17 @@
|
||||
package org.dromara.project.domain.vo.attendance;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class DaysCountVo {
|
||||
|
||||
/**
|
||||
* 入职天数
|
||||
*/
|
||||
private Integer entryDays;
|
||||
/**
|
||||
* 出勤天数
|
||||
*/
|
||||
private Integer attendanceDays;
|
||||
|
||||
}
|
||||
@ -299,6 +299,7 @@ public class BusAttendanceServiceImpl extends ServiceImpl<BusAttendanceMapper, B
|
||||
attendance.setProjectId(req.getProjectId());
|
||||
attendance.setClockDate(localDate);
|
||||
attendance.setClockTime(now);
|
||||
attendance.setUserName(constructionUser.getUserName());
|
||||
// 记录打卡坐标
|
||||
attendance.setLat(req.getLat());
|
||||
attendance.setLng(req.getLng());
|
||||
|
||||
@ -36,6 +36,7 @@ import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@ -152,6 +153,7 @@ public class BusProjectTeamMemberServiceImpl extends ServiceImpl<BusProjectTeamM
|
||||
throw new ServiceException("新增项目班组下的成员失败,数据库异常", HttpStatus.ERROR);
|
||||
}
|
||||
// 同步修改用户表的team_id字段并添加入场时间
|
||||
|
||||
LambdaUpdateWrapper<SubConstructionUser> constructionUserLuw = Wrappers.lambdaUpdate(SubConstructionUser.class)
|
||||
.eq(SubConstructionUser::getId, constructionUser.getId())
|
||||
.set(SubConstructionUser::getProjectId, req.getProjectId())
|
||||
@ -159,7 +161,9 @@ public class BusProjectTeamMemberServiceImpl extends ServiceImpl<BusProjectTeamM
|
||||
.set(SubConstructionUser::getTeamName, projectTeam.getTeamName())
|
||||
.set(SubConstructionUser::getEntryDate, new Date())
|
||||
.set(SubConstructionUser::getLeaveDate, null)
|
||||
.set(SubConstructionUser::getExitStatus, "0");
|
||||
.set(SubConstructionUser::getExitStatus, "0")
|
||||
.set(constructionUser.getFirstDate()!=null,SubConstructionUser::getFirstDate, LocalDate.now())
|
||||
;
|
||||
constructionUserService.update(constructionUserLuw);
|
||||
|
||||
|
||||
|
||||
@ -359,8 +359,11 @@ public class BusReissueCardServiceImpl extends ServiceImpl<BusReissueCardMapper,
|
||||
if (CollUtil.isNotEmpty(busReissueCards)) {
|
||||
throw new ServiceException("已提交该申请");
|
||||
}
|
||||
|
||||
save(bean);
|
||||
//修改为已处理
|
||||
attendanceService.update(Wrappers.<BusAttendance>lambdaUpdate()
|
||||
.eq(BusAttendance::getId, bean.getAttendanceId())
|
||||
.set(BusAttendance::getHandle, "1"));
|
||||
return bean.getId();
|
||||
}
|
||||
|
||||
|
||||
@ -48,4 +48,10 @@ public class QltQualityInspectionQueryReq implements Serializable {
|
||||
|
||||
private Long createBy;
|
||||
|
||||
/**
|
||||
* 巡检标题
|
||||
*/
|
||||
private String inspectionHeadline;
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -36,9 +36,15 @@ public class QltQualityInspectionVo implements Serializable {
|
||||
*/
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 项目id
|
||||
*/
|
||||
private Long projectId;
|
||||
|
||||
/**
|
||||
* 项目名称
|
||||
*/
|
||||
@Translation(type = TransConstant.PROJECT_ID_TO_NAME, mapper = "projectId")
|
||||
private String projectName;
|
||||
|
||||
/**
|
||||
|
||||
@ -343,6 +343,7 @@ public class QltQualityInspectionServiceImpl extends ServiceImpl<QltQualityInspe
|
||||
lqw.eq(ObjectUtils.isNotEmpty(rectificationId), QltQualityInspection::getRectificationId, rectificationId);
|
||||
lqw.eq(req.getCorrectorId() != null, QltQualityInspection::getCorrectorId, req.getCorrectorId());
|
||||
lqw.eq(req.getCreateBy() != null, QltQualityInspection::getCreateBy, req.getCreateBy());
|
||||
lqw.like(StringUtils.isNotBlank(req.getInspectionHeadline()), QltQualityInspection::getInspectionHeadline, req.getInspectionHeadline());
|
||||
return lqw;
|
||||
}
|
||||
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
package org.dromara.safety.domain.dto.safetyinspection;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
@ -78,6 +79,7 @@ public class HseSafetyInspectionCreateReq implements Serializable {
|
||||
/**
|
||||
* 检查时间
|
||||
*/
|
||||
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd")
|
||||
private Date checkTime;
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user