fix(system): 优化日志记录和部门相关接口
- 在补卡失败时添加错误日志记录 - 新增按工厂 ID 获取部门列表的接口 - 优化部门简单响应 VO,添加机构类型字段 - 调整贷款控制器,使用工厂信息 API 获取部门信息 - 修改日志使用列表查询方式 - 优化用户导出模板中的部门和岗位数据加载
This commit is contained in:
parent
b169fadbf2
commit
72b60dd1ab
@ -108,6 +108,14 @@ public class DeptApiImpl implements DeptApi {
|
||||
return success(BeanUtils.toBean(deptDO, DeptRespDTO.class));
|
||||
}
|
||||
|
||||
@Override
|
||||
@DataPermission(enable = false)
|
||||
public CommonResult<List<DeptRespDTO>> getDeptByFactoryIds(Collection<Long> factoryIds) {
|
||||
|
||||
List<DeptDO> deptDOS = deptService.getDeptListByFactoryIds(factoryIds);
|
||||
return success(BeanUtils.toBean(deptDOS, DeptRespDTO.class));
|
||||
}
|
||||
|
||||
@Override
|
||||
@DataPermission(enable = false)
|
||||
public CommonResult<List<Long>> getChildDeptList(Long deptId) {
|
||||
|
@ -28,4 +28,7 @@ public class DeptSimpleRespVO {
|
||||
|
||||
@Schema(description = "工厂编号")
|
||||
private Long factoryId;
|
||||
|
||||
@Schema(description = "机构类型 | 字典值参考 system_dept_type", example = "0")
|
||||
private String type;
|
||||
}
|
||||
|
@ -4,6 +4,8 @@ import cn.hutool.core.collection.CollUtil;
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import cn.iocoder.yudao.module.smartfactory.api.factoryInfo.FactoryInfoApi;
|
||||
import cn.iocoder.yudao.module.smartfactory.api.factoryInfo.dto.FactoryInfoDTO;
|
||||
import cn.iocoder.yudao.module.smartfactory.api.staff.StaffApi;
|
||||
import cn.iocoder.yudao.module.smartfactory.api.staff.dto.StaffDTO;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.loan.vo.LoanPageReqVO;
|
||||
@ -44,7 +46,7 @@ public class LoanController {
|
||||
private StaffApi staffApi;
|
||||
|
||||
@Resource
|
||||
private DeptService deptService;
|
||||
private FactoryInfoApi factoryInfoApi;
|
||||
|
||||
@GetMapping("/get")
|
||||
@Operation(summary = "获得借支管理")
|
||||
@ -55,6 +57,15 @@ public class LoanController {
|
||||
return success(BeanUtils.toBean(loan, LoanRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/getByStaffId")
|
||||
@Operation(summary = "获得指定员工的借支管理")
|
||||
@Parameter(name = "staffId", description = "员工编号", required = true, example = "1024")
|
||||
@PreAuthorize("@ss.hasPermission('system:loan:query')")
|
||||
public CommonResult<LoanRespVO> getByStaffId(@RequestParam("id") Long id) {
|
||||
LoanDO loan = loanService.getByUserId(id);
|
||||
return success(BeanUtils.toBean(loan, LoanRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/page")
|
||||
@Operation(summary = "获得借支管理分页")
|
||||
@PreAuthorize("@ss.hasPermission('system:loan:query')")
|
||||
@ -70,7 +81,7 @@ public class LoanController {
|
||||
|
||||
// 获取部门信息
|
||||
Set<Long> deptIds = convertSet(result.getList(), LoanRespVO::getDeptId);
|
||||
Map<Long, DeptDO> deptMap = convertMap(deptService.getDeptList(deptIds), DeptDO::getId);
|
||||
Map<Long, FactoryInfoDTO> deptMap = factoryInfoApi.getFactoryMap(deptIds);
|
||||
|
||||
result.getList().forEach(item -> {
|
||||
// 设置借支用户名称
|
||||
|
@ -372,11 +372,14 @@ public class UserController {
|
||||
List<PostDO> postDO = postService.getPostList(null, Collections.singleton(CommonStatusEnum.ENABLE.getStatus()));
|
||||
postDO.sort(Comparator.comparing(PostDO::getSort));
|
||||
|
||||
Map<Integer, List<String>> mapDropDown = new HashMap<>();
|
||||
mapDropDown.put(1, getDeptNameFun(deptDO));
|
||||
mapDropDown.put(2, getPostNameFun(postDO));
|
||||
|
||||
// 输出 Excel
|
||||
ExcelUtils.write(response, "用户数据.xls", "数据", UserRespVO.class,
|
||||
UserConvert.INSTANCE.convertList(list, deptMap, postMap, positionMap),
|
||||
1, getDeptNameFun(deptDO),
|
||||
2, getPostNameFun(postDO));
|
||||
mapDropDown);
|
||||
}
|
||||
|
||||
@GetMapping("/get-import-template")
|
||||
@ -397,11 +400,14 @@ public class UserController {
|
||||
List<PostDO> postDO = postService.getPostList(null, Collections.singleton(CommonStatusEnum.ENABLE.getStatus()));
|
||||
postDO.sort(Comparator.comparing(PostDO::getSort));
|
||||
|
||||
Map<Integer, List<String>> mapDropDown = new HashMap<>();
|
||||
mapDropDown.put(1, getDeptNameFun(deptDO));
|
||||
mapDropDown.put(2, getPostNameFun(postDO));
|
||||
|
||||
// 输出
|
||||
ExcelUtils.write(response, "用户导入模板.xlsx", "用户列表",
|
||||
UserImportExcelVO.class, null,
|
||||
1, getDeptNameFun(deptDO),
|
||||
2, getPostNameFun(postDO));
|
||||
mapDropDown);
|
||||
}
|
||||
|
||||
@PostMapping("/import")
|
||||
|
@ -71,9 +71,11 @@ public class LogFormController {
|
||||
//获取规则信息
|
||||
LogRuleDO logRuleDO = logRuleService.getLogRule(form.getId());
|
||||
|
||||
if (logRuleDO != null) {
|
||||
//设置日志类型
|
||||
logFormRespVO.setType(logRuleDO.getType());
|
||||
}
|
||||
}
|
||||
|
||||
return success(logFormRespVO);
|
||||
}
|
||||
|
@ -45,4 +45,6 @@ public interface LogUseMapper extends BaseMapperX<LogUseDO> {
|
||||
* @return
|
||||
*/
|
||||
List<Long> getFormIdsByDataPermission(Long userId);
|
||||
|
||||
List<Long> selectUseDeptList();
|
||||
}
|
@ -1084,6 +1084,7 @@ public class AttendanceServiceImpl implements AttendanceService {
|
||||
// -- 如果有报错的话 - 那么进行回滚操作 - 并且redis 中的补卡次数也要+1 (redis并不会回滚)
|
||||
String key = "ReplacementCardNum" + "_" + userId + "_" + LocalDateTime.now().format(Constants.YEAR_MONTH_FORMAT);
|
||||
stringRedisTemplate.opsForValue().increment(key, 1);
|
||||
log.error("补卡失败", e);
|
||||
throw exception(ABNORMAL_CARD_REPLENISHMENT);
|
||||
}
|
||||
}
|
||||
@ -1115,6 +1116,7 @@ public class AttendanceServiceImpl implements AttendanceService {
|
||||
// -- 如果有报错的话 - 那么进行回滚操作 - 并且redis 中的补卡次数也要+1 (redis并不会回滚)
|
||||
String key = "ReplacementCardNum" + "_" + userId + "_" + LocalDateTime.now().format(Constants.YEAR_MONTH_FORMAT);
|
||||
stringRedisTemplate.opsForValue().increment(key, punchRecordIds.size());
|
||||
log.error("补卡失败", e);
|
||||
throw exception(ABNORMAL_CARD_REPLENISHMENT);
|
||||
}
|
||||
}
|
||||
|
@ -160,7 +160,7 @@ public interface DeptService {
|
||||
* @param factoryIds
|
||||
* @return
|
||||
*/
|
||||
List<DeptDO> getDeptListByFactoryIds(List<Long> factoryIds);
|
||||
List<DeptDO> getDeptListByFactoryIds(Collection<Long> factoryIds);
|
||||
|
||||
/**
|
||||
* 获取部门列表
|
||||
|
@ -356,7 +356,7 @@ public class DeptServiceImpl implements DeptService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DeptDO> getDeptListByFactoryIds(List<Long> factoryIds) {
|
||||
public List<DeptDO> getDeptListByFactoryIds(Collection<Long> factoryIds) {
|
||||
return deptMapper.selectList(new LambdaQueryWrapper<DeptDO>()
|
||||
.in(DeptDO::getFactoryId, factoryIds));
|
||||
}
|
||||
|
@ -98,11 +98,7 @@ public class LogUseServiceImpl implements LogUseService {
|
||||
@Override
|
||||
public List<Long> getUseDeptList() {
|
||||
|
||||
QueryWrapper<LogUseDO> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.select("DISTINCT use_user_dept");
|
||||
|
||||
List<LogUseDO> logUseDOS = logUseMapper.selectList(queryWrapper);
|
||||
return convertList(logUseDOS, LogUseDO::getUseUserDept);
|
||||
return logUseMapper.selectUseDeptList();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -66,7 +66,7 @@
|
||||
</springProfile>
|
||||
<!-- 其它环境 -->
|
||||
<springProfile name="dev,test,stage,prod,default">
|
||||
<root level="INFO">
|
||||
<root level="DEBUG">
|
||||
<appender-ref ref="STDOUT"/>
|
||||
<appender-ref ref="ASYNC"/>
|
||||
<appender-ref ref="GRPC"/>
|
||||
|
@ -30,4 +30,17 @@
|
||||
deleted = 0
|
||||
and form_id = #{formId}
|
||||
</select>
|
||||
|
||||
<select id="selectUseDeptList" resultType="java.lang.Long">
|
||||
SELECT DISTINCT
|
||||
u.dept_id as deptId
|
||||
FROM
|
||||
work_log_use log,
|
||||
system_users u
|
||||
WHERE
|
||||
u.id = log.use_user_id
|
||||
and u.status = 0
|
||||
and log.deleted = 0
|
||||
and u.deleted = 0
|
||||
</select>
|
||||
</mapper>
|
Loading…
Reference in New Issue
Block a user