工程在用量及app验证码登录

This commit is contained in:
mashuai 2025-07-10 16:12:40 +08:00
parent 87a3ada02a
commit 72acd4affa
7 changed files with 212 additions and 28 deletions

View File

@ -248,4 +248,25 @@ public class BackApplyInfo {
* 库管id集合
*/
private List<Long> userIds;
@ApiModelProperty(value = "租赁数量")
private Double outNum;
/**
* 在用数量
*/
@ApiModelProperty(value = "在用数量")
private Double usNum;
/**
* 在用总价值
*/
@ApiModelProperty(value = "在用总价值")
private Double usPrice;
/**
* 投入总价值
*/
@ApiModelProperty(value = "投入总价值")
private Double totalPrice;
}

View File

@ -124,6 +124,13 @@ public class TokenController {
@PostMapping("sendCode")
public R<?> sendCode(@RequestBody LoginBody form) {
if (StringUtils.isBlank(form.getPhone())) {
return R.fail("手机号码不能为空");
}
// app登录不校验图形验证码
if (StringUtils.isBlank(form.getUuid()) && StringUtils.isBlank(form.getCode())) {
return remoteUserService.sendCode(form.getPhone());
}
String uuid = form.getUuid();
String captcha = "";
Object object = redisService.getCacheObject(CacheConstants.CAPTCHA_CODE_KEY + uuid);

View File

@ -226,4 +226,11 @@ public interface BackReceiveMapper {
Integer getCheckDetails(BackApplyInfo record);
int updateMtNum(BackApplyInfo record);
/**
* 根据工程及设备类型查询工程在用量
* @param backApplyInfo
* @return
*/
BackApplyInfo getProAndTypeNum(BackApplyInfo backApplyInfo);
}

View File

@ -86,30 +86,72 @@ public class BackReceiveServiceImpl implements BackReceiveService {
@Override
public List<BackApplyInfo> receiveView(BackApplyInfo record) {
// 获取当前用户ID和角色
Long userId = SecurityUtils.getUserId();
List<BackApplyInfo> list = new ArrayList<>();
List<Long> longs = new ArrayList<>();
List<BackApplyInfo> backApplyInfoList = backReceiveMapper.receiveView(record);
// 定义需要匹配的角色集合
List<String> allowedRoles = Arrays.asList("admin", "em01", "em02", "jjbz", "dm01", "dm07");
// 获取当前用户的角色集合
Set<String> userRoles = SecurityUtils.getLoginUser().getRoles();
if (userRoles != null && allowedRoles.stream().anyMatch(userRoles::contains)) {
return backApplyInfoList;
// 查询所有申请信息
List<BackApplyInfo> allApplyInfos = backReceiveMapper.receiveView(record);
if (CollectionUtils.isEmpty(allApplyInfos)) {
return Collections.emptyList();
}
if (CollectionUtils.isNotEmpty(backApplyInfoList)) {
for (BackApplyInfo backApplyInfo : backApplyInfoList) {
if (StringUtils.isNotBlank(backApplyInfo.getUserId())) {
List<String> strings = Arrays.asList(backApplyInfo.getUserId().split(","));
//转换为long类型
longs = strings.stream().map(Long::parseLong).collect(Collectors.toList());
}
if (longs.contains(userId)) {
list.add(backApplyInfo);
}
// 检查用户是否具有特殊角色
boolean hasSpecialRole = hasSpecialRole(userRoles);
// 处理数据并设置在用量
List<BackApplyInfo> resultList = new ArrayList<>();
for (BackApplyInfo applyInfo : allApplyInfos) {
// 设置在用量
setUsageNumber(applyInfo);
// 根据角色决定是否添加到结果集
if (hasSpecialRole || isUserInvolved(applyInfo, userId)) {
resultList.add(applyInfo);
}
}
return list;
return resultList;
}
/**
* 检查用户是否具有特殊角色
* @param userRoles
* @return
*/
private boolean hasSpecialRole(Set<String> userRoles) {
if (userRoles == null) {
return false;
}
List<String> allowedRoles = Arrays.asList("admin", "em01", "em02", "jjbz", "dm01", "dm07");
return allowedRoles.stream().anyMatch(userRoles::contains);
}
/**
* 设置申请信息的在用量
* @param applyInfo
*/
private void setUsageNumber(BackApplyInfo applyInfo) {
BackApplyInfo info = backReceiveMapper.getProAndTypeNum(applyInfo);
applyInfo.setUsNum(info != null ? info.getUsNum() : 0.0);
}
/**
* 检查用户是否参与了该申请
* @param applyInfo
* @param userId
* @return
*/
private boolean isUserInvolved(BackApplyInfo applyInfo, Long userId) {
if (StringUtils.isBlank(applyInfo.getUserId())) {
return false;
}
List<Long> involvedUserIds = Arrays.stream(applyInfo.getUserId().split(","))
.map(Long::parseLong)
.collect(Collectors.toList());
return involvedUserIds.contains(userId);
}
public List<BackApplyInfo> receiveView2(BackApplyInfo record) {

View File

@ -674,14 +674,19 @@ public class TmTaskServiceImpl implements TmTaskService {
List<TmTask> list = tmTaskMapper.getLeaseOutListByUser(task);
if (CollectionUtils.isNotEmpty(list)) {
for (TmTask tmTask : list) {
// 首先排除任务状态为待出库或者出库完成的状态
if (tmTask.getTaskStatus() == 33 || tmTask.getTaskStatus() == 35) {
// 首先排除任务状态为出库完成的状态
if (tmTask.getTaskStatus() == 35) {
continue;
}
if (tmTask.getPreCountNum().equals(tmTask.getAlNum())) {
// 全部出库返回个人任务状态为出库完成不修改整条任务状态
tmTask.setTaskStatus(35);
tmTask.setTaskName("完成");
task.setId(tmTask.getId());
List<TmTask> leaseApplyDetailsList = tmTaskMapper.getLeaseDetailByParentId(task);
if (CollectionUtils.isNotEmpty(leaseApplyDetailsList)) {
// 如果leaseApplyDetailsList中的status状态全部为2已完成则修改整条任务状态为出库完成
if (leaseApplyDetailsList.stream().allMatch(item -> item.getStatus() == 2)) {
// 全部出库返回个人任务状态为出库完成不修改整条任务状态
tmTask.setTaskStatus(35);
tmTask.setTaskName("完成");
}
}
}
}

View File

@ -734,13 +734,17 @@
mt.company_id as companyId,
CONCAT('NSJJ',mt.`code`,mt.model_code) as `code`,
mtk.userId as userId,
aa.badId as badId
aa.badId as badId,
bpl.lot_id as lotId,
bpl.lot_name as lotName
FROM
back_apply_details bad
LEFT JOIN back_apply_info bai on bai.id=bad.parent_id
LEFT JOIN tm_task_agreement tta on tta.task_id=bai.task_id
LEFT JOIN ma_type mt on mt.type_id=bad.type_id
LEFT JOIN ma_type mt2 ON mt2.type_id=mt.parent_id
LEFT JOIN bm_agreement_info bagi on bagi.agreement_id=tta.agreement_id
LEFT JOIN bm_project_lot bpl on bpl.lot_id = bagi.project_id
LEFT JOIN (
SELECT
GROUP_CONCAT(id) as badId,
@ -1198,5 +1202,101 @@
select sum(back_num) from back_check_details where parent_id = #{parentId} and type_id = #{typeId} and (is_finished is null or is_finished != 1)
</select>
<select id="getProAndTypeNum" resultType="com.bonus.sgzb.base.api.domain.BackApplyInfo">
SELECT
subquery1.unitName as unitName,
subquery1.proName as lotName,
subquery1.unitId as unitId,
subquery1.type_id as typeId,
subquery1.proId as lotId,
subquery1.typeName,
subquery1.typeModelName as typeCode,
CASE WHEN subquery1.manage_type = '0' then '编码' else '数量' end as manageType,
IFNULL(subquery1.outNum, 0) as outNum,
IFNULL(subquery2.backNum, 0) as backNum,
CASE
WHEN IFNULL(subquery1.outNum, 0) - IFNULL(subquery2.backNum, 0) > 0
THEN IFNULL(subquery1.outNum, 0) - IFNULL(subquery2.backNum, 0)
ELSE 0
END as usNum,
CASE
WHEN IFNULL(subquery1.outNum, 0) - IFNULL(subquery2.backNum, 0) > 0 THEN
IFNULL(subquery1.rent_price, 0) *
(IFNULL(subquery1.outNum, 0) - IFNULL(subquery2.backNum, 0))
ELSE
0
END as usPrice,
IFNULL(subquery1.outNum, 0) * IFNULL(subquery1.rent_price, 0) as totalPrice
FROM (SELECT bai.agreement_id,
mt.type_id,
mt.rent_price,
mt.manage_type,
bai.agreement_code AS agreementCode,
bui.unit_name AS unitName,
bui.unit_id AS unitId,
bpl.lot_name AS proName,
bpl.lot_id AS proId,
mt2.type_name AS typeName,
mt.type_name AS typeModelName,
mt.unit_name AS unit,
SUM(IFNULL(lod.out_num, 0)) AS outNum
FROM lease_out_details lod
LEFT JOIN lease_apply_info lai ON lai.id = lod.parent_id
LEFT JOIN tm_task_agreement tta ON tta.task_id = lai.task_id
LEFT JOIN bm_agreement_info bai ON bai.agreement_id = tta.agreement_id
LEFT JOIN bm_project_lot bpl ON bpl.lot_id = bai.project_id
LEFT JOIN bm_unit_info bui ON bui.unit_id = bai.unit_id
LEFT JOIN ma_type mt ON mt.type_id = lod.type_id
LEFT JOIN ma_type mt2 ON mt2.type_id = mt.parent_id
LEFT JOIN ma_machine mm ON mm.ma_id = lod.ma_id
LEFT JOIN sys_user su ON su.user_id = lai.lease_person
where 1=1
<if test="lotId != null">
and bpl.lot_id = #{lotId}
</if>
<if test="typeName != null and typeName != ''">
and mt2.type_name like concat('%',#{typeName},'%')
</if>
<if test="typeCode != null and typeCode != ''">
and mt.type_name like concat('%',#{typeCode},'%')
</if>
GROUP BY bai.agreement_id,
mt.type_id) AS subquery1
LEFT JOIN (SELECT bai.agreement_id,
mt.type_id,
mt.rent_price,
bai.agreement_code AS agreementCode,
bui.unit_name AS unitName,
bpl.lot_name AS proName,
mt2.type_name AS typeName,
mt.type_name AS typeModelName,
mt.unit_name AS unit,
SUM(IFNULL(bcd.back_num, 0)) backNum
FROM back_check_details bcd
LEFT JOIN back_apply_info baif ON baif.id = bcd.parent_id
LEFT JOIN tm_task_agreement tta ON tta.task_id = baif.task_id
LEFT JOIN bm_agreement_info bai ON bai.agreement_id = tta.agreement_id
LEFT JOIN bm_project_lot bpl ON bpl.lot_id = bai.project_id
LEFT JOIN bm_unit_info bui ON bui.unit_id = bai.unit_id
LEFT JOIN ma_type mt ON mt.type_id = bcd.type_id
LEFT JOIN ma_type mt2 ON mt2.type_id = mt.parent_id
LEFT JOIN ma_machine mm ON mm.ma_id = bcd.ma_id
LEFT JOIN sys_user su ON su.user_id = baif.back_person
where 1=1
<if test="lotId != null">
and bpl.lot_id = #{lotId}
</if>
<if test="typeName != null and typeName != ''">
and mt2.type_name like concat('%',#{typeName},'%')
</if>
<if test="typeCode != null and typeCode != ''">
and mt.type_name like concat('%',#{typeCode},'%')
</if>
GROUP BY bai.agreement_id,
mt.type_id) AS subquery2 ON subquery1.type_id = subquery2.type_id
AND subquery1.agreement_id = subquery2.agreement_id
</select>
</mapper>

View File

@ -148,8 +148,10 @@ public class SysSmsServiceImpl implements ISysSmsService {
}
// 发送短信
try {
String content = URL + "&mobile=" + phone + "&content=【智慧仓储】您正在进行短信验证,验证码:" + code + "请在5分钟内完成验证。";
String body = HttpRequest.post(content).execute(false).body();
/*String content = URL + "&mobile=" + phone + "&content=【智慧仓储】您正在进行短信验证,验证码:" + code + "请在5分钟内完成验证。";
String body = HttpRequest.post(content).execute(false).body();*/
msg = "您正在进行短信验证,验证码:" + code + "请在5分钟内完成验证。";
String body = SmsUtils.smsToken(phone, msg, "");
System.out.println("发送短信:" + phone + ",验证码:" + code + ",返回结果:" + body);
if (body == null || !body.contains(GlobalConstants.STRING_OK)) {
return AjaxResult.error("发送失败");