This commit is contained in:
PQZ 2024-08-14 16:25:33 +08:00
commit 9ac4b2f05d
73 changed files with 1350 additions and 292 deletions

View File

@ -39,4 +39,12 @@ public class BaseConstants {
public static final String LABEL_TYPE = "default";
/** 唯一推广码生成长度 */
public static final Integer UNIQUE_CODE_LEN = 6;
/**企业功能标识*/
public static final String FUNC_COMPANY = "company";
/**批量操作数据量*/
public static final Integer BATCH_SIZE = 100;
/**资质临期通知模板*/
public static final String QUALS_INTERIM_PERIOD = "quals_interim_period";
/**资质过期通知模板*/
public static final String QUALS_EXPIRED = "quals_expired";
}

View File

@ -7,5 +7,6 @@ public interface CommonErrorCodeConstants extends ErrorCodeConstants {
/** 企业管理-员工管理 */
ErrorCode UNIQUE_CODE_CREATE_REPEAT = new ErrorCode(2_002_000_000, "唯一推广码生成失败");
ErrorCode STAFF_CHANGE_CREATE_REPEAT = new ErrorCode(2_002_000_001, "交出或接收员工已有交接记录");
ErrorCode STAFF_CHANGE_CREATE_REPEAT = new ErrorCode(2_002_000_001, "该员工工作已交接");
ErrorCode STAFF_NOT_CHANGE = new ErrorCode(2_002_000_003, "该员工还有工作未交接,不可删除");
}

View File

@ -17,5 +17,8 @@ public class DictBaseConstants {
public static final String DICT_SIGN_TYPE = "cus_sign_type";
/**性别*/
public static final String DICT_SYS_USER_SEX = "system_user_sex";
/**学历*/
public static final String COMPANY_STAFF_EDU = "company_staff_edu";
/**企业资质临期判定时间*/
public static final String COMPANY_QUALS_EXPIRED = "company_quals_expired";
}

View File

@ -2,12 +2,15 @@ package cn.iocoder.yudao.module.company.mapper;
import cn.iocoder.yudao.module.company.entity.Company;
import cn.iocoder.yudao.module.company.vo.CompanyReqVO;
import cn.iocoder.yudao.module.company.vo.CompanyRespVO;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* 企业信息表每个租户的下属企业信息;(dl_company)表数据库访问层
* @author : http://www.chiner.pro
@ -16,4 +19,11 @@ import org.apache.ibatis.annotations.Param;
@Mapper
public interface CompanyMapper extends BaseMapper<Company>{
IPage<Company> selectListPage(@Param("map") CompanyReqVO companyReqVO, Page<Company> page);
/**
* 获取所有企业及对应的管理信息
* @author 小李
* @date 10:15 2024/8/14
**/
List<CompanyRespVO> getCompanyAndManager();
}

View File

@ -2,8 +2,11 @@ package cn.iocoder.yudao.module.company.service;
import cn.iocoder.yudao.module.company.entity.CompanyQuals;
import cn.iocoder.yudao.module.company.vo.CompanyQualsRespVO;
import cn.iocoder.yudao.module.company.vo.CompanyRespVO;
import com.baomidou.mybatisplus.extension.service.IService;
import java.util.List;
/**
* 企业资质信息表
* @author : http://www.chiner.pro
@ -34,4 +37,11 @@ public interface CompanyQualsService extends IService<CompanyQuals> {
* @param id 企业资质id
**/
void removeDataObj(String id);
/**
* 企业资质临期提醒
* @author 小李
* @date 8:54 2024/8/14
**/
void noticeCompanyQualsExpired(List<CompanyRespVO> companyRespVOS);
}

View File

@ -7,6 +7,8 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import java.util.List;
/**
* 企业信息表每个租户的下属企业信息;(dl_company)表服务接口
* @author : http://www.chiner.pro
@ -44,4 +46,11 @@ public interface CompanyService extends IService<Company> {
* @param id 企业id
**/
void removeDataObj(String id);
/**
* 获取所有企业及对应的管理信息
* @author 小李
* @date 10:15 2024/8/14
**/
List<CompanyRespVO> getCompanyAndManager();
}

View File

@ -1,19 +1,43 @@
package cn.iocoder.yudao.module.company.service.impl;
import cn.hutool.core.util.ObjectUtil;
import cn.iocoder.yudao.common.BaseConstants;
import cn.iocoder.yudao.common.DictBaseConstants;
import cn.iocoder.yudao.module.company.entity.CompanyQuals;
import cn.iocoder.yudao.module.company.mapper.CompanyQualsMapper;
import cn.iocoder.yudao.module.company.service.CompanyQualsService;
import cn.iocoder.yudao.module.company.vo.CompanyQualsRespVO;
import cn.iocoder.yudao.module.company.vo.CompanyRespVO;
import cn.iocoder.yudao.module.system.api.dict.DictDataApi;
import cn.iocoder.yudao.module.system.api.dict.dto.DictDataRespDTO;
import cn.iocoder.yudao.module.system.api.notify.NotifyMessageSendApi;
import cn.iocoder.yudao.module.system.api.notify.dto.NotifySendSingleToUserReqDTO;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.time.LocalDate;
import java.time.ZoneId;
import java.time.temporal.ChronoUnit;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@Service
public class CompanyQualsServiceImpl extends ServiceImpl<CompanyQualsMapper, CompanyQuals> implements CompanyQualsService {
@Resource
private CompanyQualsMapper companyQualsMapper;
@Resource
private DictDataApi dataApi;
@Resource
private NotifyMessageSendApi sendApi;
/**
* 新增企业资质信息
*
@ -49,4 +73,73 @@ public class CompanyQualsServiceImpl extends ServiceImpl<CompanyQualsMapper, Com
public void removeDataObj(String id) {
this.removeById(id);
}
/**
* 企业资质临期提醒
*
* @author 小李
* @date 8:54 2024/8/14
**/
@Override
public void noticeCompanyQualsExpired(List<CompanyRespVO> companyRespVOS) {
// 构建分页条件
LambdaQueryWrapper<CompanyQuals> queryWrapper = new LambdaQueryWrapper<>();
Page<CompanyQuals> page = new Page<>(0, BaseConstants.BATCH_SIZE);
// 获取临期判定时间
List<DictDataRespDTO> dictDataList = dataApi.getDictDataList(DictBaseConstants.COMPANY_QUALS_EXPIRED);
Long ruleDay = null;
if (ObjectUtil.isNotEmpty(dictDataList)) {
ruleDay = Long.valueOf(dictDataList.get(0).getValue());
}
while (ObjectUtil.isNotEmpty(ruleDay)) {
// 查询一页数据
Page<CompanyQuals> qualsPage = baseMapper.selectPage(page, queryWrapper);
// 分类出临期和过期的数据
// 这里重新赋值是因为不重新赋值用不了我也不知道为什么看到这里的人知道的话可以给我讲讲
Long finalRuleDay = ruleDay;
qualsPage.getRecords().forEach(item -> {
LocalDate currentDate = LocalDate.now();
LocalDate endDate = item.getEndDate().toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
// 计算离当前时间还有多少天
Long day = ChronoUnit.DAYS.between(currentDate, endDate);
// day 小于0是过期了 小于等于finalRuleDay是临期了 其他就正常的
if (day < 0) {
sendMessage(item, BaseConstants.QUALS_EXPIRED, companyRespVOS, day);
} else if (day <= finalRuleDay) {
sendMessage(item, BaseConstants.QUALS_INTERIM_PERIOD, companyRespVOS, day);
}
});
}
}
/**
* 发送站内信
*
* @param data 要发送的数据
* @param templateCode 发送用什么模板
* @param companyRespVOS 企业和其管理员数据集
* @param day 资质的到期时间到今天还有多少天
* @author 小李
* @date 9:58 2024/8/14
**/
private void sendMessage(CompanyQuals data, String templateCode, List<CompanyRespVO> companyRespVOS, Long day) {
// 获取记录的企业管理员的id
List<CompanyRespVO> collect = companyRespVOS.stream().filter(company -> company.getId() == data.getCorpId()).collect(Collectors.toList());
if (ObjectUtil.isNotEmpty(collect)) {
Long userId = collect.get(0).getUserDTO().getId();
// 准备发送参数
Map<String, Object> templateParams = new HashMap<>();
// 什么资质
templateParams.put("qualsName", data.getQualsName());
// 还有多少天过期或已过期多少天可能是负数绝对值一下
templateParams.put("day", Math.abs(day));
// 发送
sendApi.sendSingleMessageToAdmin(new NotifySendSingleToUserReqDTO()
.setUserId(userId)
.setTemplateCode(templateCode).setTemplateParams(templateParams));
}
}
}

View File

@ -31,6 +31,7 @@ import java.util.HashSet;
import java.util.List;
import java.util.Set;
import static cn.iocoder.yudao.framework.common.config.CommonStr.USER_TYPE_STAFF;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet;
@ -85,6 +86,8 @@ public class CompanyServiceImpl extends ServiceImpl<CompanyMapper, Company> impl
//上级部门为本租户顶级部门
DeptRespDTO parentDept = deptApi.getDeptByParentId(0L);
deptRespDTO.setParentId(parentDept.getId());
//所属企业ID为新增的企业ID
deptRespDTO.setCorpId(companyRespVO.getId());
Long deptId = deptApi.saveDept(deptRespDTO);
/*3.新增企业管理员用户信息并配置角色*/
UserDTO userDTO = new UserDTO();
@ -93,6 +96,7 @@ public class CompanyServiceImpl extends ServiceImpl<CompanyMapper, Company> impl
userDTO.setDeptId(deptId);
userDTO.setPassword(companyRespVO.getPassword());
userDTO.setMobile(companyRespVO.getMobilePhone());
userDTO.setUserType(USER_TYPE_STAFF);
Long userId = adminUserApi.createUser(userDTO);
Set<String> roleCodes = new HashSet<>(Arrays.asList(companyRespVO.getServiceCodes().split(StrUtil.COMMA)));
permissionApi.assignUserRole(userId, roleCodes);
@ -157,4 +161,13 @@ public class CompanyServiceImpl extends ServiceImpl<CompanyMapper, Company> impl
}
}
/**
* 获取所有企业及对应的管理信息
* @author 小李
* @date 10:15 2024/8/14
**/
@Override
public List<CompanyRespVO> getCompanyAndManager(){
return baseMapper.getCompanyAndManager();
}
}

View File

@ -1,6 +1,7 @@
package cn.iocoder.yudao.module.company.vo;
import cn.iocoder.yudao.module.company.entity.Company;
import cn.iocoder.yudao.module.system.api.user.dto.UserDTO;
import lombok.Data;
import java.util.List;
@ -20,4 +21,9 @@ public class CompanyRespVO extends Company {
* 登录账户密码
*/
List<String> serviceCodeArray;
/**
* 企业对应的管理员
**/
private UserDTO userDTO;
}

View File

@ -0,0 +1,55 @@
package cn.iocoder.yudao.module.custom.controller.admin;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.module.custom.entity.BasePromotion;
import cn.iocoder.yudao.module.custom.service.BasePromotionService;
import cn.iocoder.yudao.module.custom.vo.BasePromotionReqVO;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
/**
* 推广记录表 控制层
*
* @author 小李
* @date 16:42 2024/8/13
**/
@Tag(name = "管理后台 - 推广记录")
@Validated
@RestController
@RequestMapping("/base/promotion")
public class BasePromotionController {
@Resource
private BasePromotionService promotionService;
/**
* 分页查询推广记录
*
* @param pageReqVO 查询条件对象
* @param pageNo 页码
* @param pageSize 条数
* @author 小李
* @date 16:50 2024/8/13
**/
@GetMapping("/page")
@Operation(summary = "分页查询推广记录")
@PreAuthorize("@ss.hasPermission('base:promotion:query')")
public CommonResult<IPage<?>> getBasePromotionPage(BasePromotionReqVO pageReqVO,
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) {
Page<BasePromotion> page = new Page<>(pageNo, pageSize);
return success(promotionService.queryListPage(pageReqVO, page));
}
}

View File

@ -0,0 +1,49 @@
package cn.iocoder.yudao.module.custom.entity;
import cn.iocoder.yudao.framework.tenant.core.db.TenantBaseDO;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springframework.format.annotation.DateTimeFormat;
import java.util.Date;
/**
* 推广记录表实体
* @author 小李
* @date 16:31 2024/8/13
**/
@TableName(value ="base_promotion")
@Data
@EqualsAndHashCode(callSuper = true)
public class BasePromotion extends TenantBaseDO {
/** 主键标识 */
@TableId(type = IdType.ASSIGN_ID)
private String id;
/** 推广用户idsystem_users表的id */
private Long oldUserId;
/** 推广用户姓名 */
private String oldUserName;
/** 推广渠道 */
private String promotionChannel;
/** 被推广用户idsystem_users表的id */
private Long newUserId;
/** 被推广用户姓名 */
private String newUserName;
/** 被推广用户注册时间 */
@JsonFormat(pattern="yyyy-MM-dd",timezone="GMT+8")
@DateTimeFormat(pattern="yyyy-MM-dd")
private Date registerTime;
/** 被推广用户注册时填写的推广码 */
private String uniqueCode;
}

View File

@ -0,0 +1,28 @@
package cn.iocoder.yudao.module.custom.mapper;
import cn.iocoder.yudao.module.custom.entity.BasePromotion;
import cn.iocoder.yudao.module.custom.vo.BasePromotionReqVO;
import cn.iocoder.yudao.module.custom.vo.BasePromotionRespVO;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
/**
* 推广记录表 Mapper
* @author 小李
* @date 16:38 2024/8/13
**/
@Mapper
public interface BasePromotionMapper extends BaseMapper<BasePromotion> {
/**
* 分页查询推广记录
*
* @param pageReqVO 查询条件对象
* @author 小李
* @date 16:50 2024/8/13
**/
IPage<BasePromotionRespVO> queryListPage(@Param("map") BasePromotionReqVO pageReqVO, Page<BasePromotion> page);
}

View File

@ -0,0 +1,33 @@
package cn.iocoder.yudao.module.custom.service;
import cn.iocoder.yudao.module.custom.entity.BasePromotion;
import cn.iocoder.yudao.module.custom.vo.BasePromotionReqVO;
import cn.iocoder.yudao.module.custom.vo.BasePromotionRespVO;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
/**
* 推广记录表 接口服务
* @author 小李
* @date 16:40 2024/8/13
**/
public interface BasePromotionService extends IService<BasePromotion> {
/**
* 推广记录表 分布查询
* @author 小李
* @date 12:24 2024/8/14
* @param pageReqVO 查询对象
* @param page 分页规则
**/
IPage<BasePromotionRespVO> queryListPage(BasePromotionReqVO pageReqVO, Page<BasePromotion> page);
/**
* 新增推广记录
* @author 小李
* @date 12:26 2024/8/14
* @param promotionRespVO 新增对象
**/
Boolean createPromotion(BasePromotionRespVO promotionRespVO);
}

View File

@ -0,0 +1,46 @@
package cn.iocoder.yudao.module.custom.service.impl;
import cn.hutool.core.bean.BeanUtil;
import cn.iocoder.yudao.module.custom.entity.BasePromotion;
import cn.iocoder.yudao.module.custom.mapper.BasePromotionMapper;
import cn.iocoder.yudao.module.custom.service.BasePromotionService;
import cn.iocoder.yudao.module.custom.vo.BasePromotionReqVO;
import cn.iocoder.yudao.module.custom.vo.BasePromotionRespVO;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
/**
* 推广记录表 接口实现类
* @author 小李
* @date 16:41 2024/8/13
**/
@Service
public class BasePromotionServiceImpl extends ServiceImpl<BasePromotionMapper, BasePromotion> implements BasePromotionService {
/**
* 分页查询推广记录
*
* @param pageReqVO 查询条件对象
* @author 小李
* @date 16:50 2024/8/13
**/
@Override
public IPage<BasePromotionRespVO> queryListPage(BasePromotionReqVO pageReqVO, Page<BasePromotion> page) {
return baseMapper.queryListPage(pageReqVO, page);
}
/**
* 新增推广记录
* @author 小李
* @date 12:26 2024/8/14
* @param promotionRespVO 新增对象
**/
@Override
public Boolean createPromotion(BasePromotionRespVO promotionRespVO){
BasePromotion basePromotion = new BasePromotion();
BeanUtil.copyProperties(promotionRespVO, basePromotion);
return baseMapper.insert(basePromotion) > 0;
}
}

View File

@ -43,6 +43,7 @@ import java.util.*;
import static cn.iocoder.yudao.common.BaseConstants.*;
import static cn.iocoder.yudao.common.DictBaseConstants.DICT_CUS_TYPE;
import static cn.iocoder.yudao.framework.common.config.CommonStr.USER_TYPE_CUS;
/**
* 客户管理 Service 实现类
@ -119,6 +120,7 @@ public class CustomerMainServiceImpl extends ServiceImpl<CustomerMainMapper, Cus
//默认密码
user.setPassword(PASSWORD_DEFAULT);
user.setMobile(saveReqVO.getPhoneNumber());
user.setUserType(USER_TYPE_CUS);
//该用户未注册情况下如果是政企客户需要在部门表中创建部门并给用户绑定
if (CUS_TYPE_CORP.equals(main.getTypeCode())) {
//查询当前登录用户所属租户的政企客户部门id父级部门

View File

@ -0,0 +1,26 @@
package cn.iocoder.yudao.module.custom.vo;
import cn.iocoder.yudao.module.custom.entity.BasePromotion;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import java.util.Date;
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
/**
* 推广记录表查询VO
* @author 小李
* @date 16:36 2024/8/13
**/
@Data
public class BasePromotionReqVO extends BasePromotion {
@Schema(description = "被推广人注册日期查询范围")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private Date[] registerTimeArray;
/** 推广人类型 */
private String userType;
}

View File

@ -0,0 +1,20 @@
package cn.iocoder.yudao.module.custom.vo;
import cn.iocoder.yudao.module.custom.entity.BasePromotion;
import cn.iocoder.yudao.module.system.api.user.dto.UserDTO;
import lombok.Data;
/**
* 推广记录表响应或提交VO
* @author 小李
* @date 16:37 2024/8/13
**/
@Data
public class BasePromotionRespVO extends BasePromotion {
/** 推广人 */
private UserDTO oldUser;
/** 被推广人 */
private UserDTO newUser;
}

View File

@ -0,0 +1,38 @@
package cn.iocoder.yudao.scheduled;
import cn.iocoder.yudao.framework.quartz.core.handler.JobHandler;
import cn.iocoder.yudao.framework.tenant.core.job.TenantJob;
import cn.iocoder.yudao.module.company.service.CompanyQualsService;
import cn.iocoder.yudao.module.company.service.CompanyService;
import cn.iocoder.yudao.module.company.vo.CompanyRespVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.util.List;
/**
* 定时提醒企业管理员资质过期
* @author 小李
* @date 16:02 2024/8/13
**/
@Component
@TenantJob
@Slf4j
public class NoticeCompanyQualsExpiredJob implements JobHandler {
@Resource
private CompanyQualsService qualsService;
@Resource
private CompanyService companyService;
@Override
public String execute(String param) throws Exception {
// 获取所有企业和其管理员
List<CompanyRespVO> companyAndManager = companyService.getCompanyAndManager();
// 提醒管理员资质过期
qualsService.noticeCompanyQualsExpired(companyAndManager);
return null;
}
}

View File

@ -6,29 +6,42 @@
SELECT
bc.*
FROM
base_company bc
base_company bc
WHERE deleted = '0'
<if test="map.registDateArray.length>0">
AND (bc.regist_date BETWEEN #{map.registDateArray[0]} AND #{map.registDateArray[1]})
</if>
<if test="map.corpName!='' and map.corpName!=null">
AND (bc.corp_name LIKE CONCAT('%',#{map.corpName},'%'))
AND (bc.corp_name LIKE CONCAT('%',#{map.corpName},'%'))
</if>
<if test="map.orgCard!='' and map.orgCard!=null">
AND (bc.org_card LIKE CONCAT('%',#{map.orgCard},'%'))
AND (bc.org_card LIKE CONCAT('%',#{map.orgCard},'%'))
</if>
<if test="map.legalName!='' and map.legalName!=null">
AND (bc.legal_name LIKE CONCAT('%',#{map.legalName},'%'))
AND (bc.legal_name LIKE CONCAT('%',#{map.legalName},'%'))
</if>
<if test="map.legalCard!='' and map.legalCard!=null">
AND (bc.legal_card LIKE CONCAT('%',#{map.legalCard},'%'))
AND (bc.legal_card LIKE CONCAT('%',#{map.legalCard},'%'))
</if>
<if test="map.contactName!='' and map.contactName!=null">
AND (bc.contact_name LIKE CONCAT('%',#{map.contactName},'%'))
AND (bc.contact_name LIKE CONCAT('%',#{map.contactName},'%'))
</if>
<if test="map.mobilePhone!='' and map.mobilePhone!=null">
AND (bc.mobile_phone LIKE CONCAT('%',#{map.mobilePhone},'%'))
AND (bc.mobile_phone LIKE CONCAT('%',#{map.mobilePhone},'%'))
</if>
ORDER BY bc.create_time DESC
</select>
<resultMap id="QueryResultMap" type="cn.iocoder.yudao.module.company.vo.CompanyRespVO">
<id property="id" column="c_id" jdbcType="VARCHAR"/>
<association property="userDTO" javaType="cn.iocoder.yudao.module.system.api.user.dto.UserDTO">
<id property="id" column="u_id" jdbcType="BIGINT" />
</association>
</resultMap>
<select id="getCompanyAndManager" resultMap="QueryResultMap">
select c.id as c_id,
u.id as u_id
from base_company c
inner join system_users u on c.login_account = u.username
</select>
</mapper>

View File

@ -0,0 +1,59 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.iocoder.yudao.module.custom.mapper.BasePromotionMapper">
<resultMap id="BaseResultMap" type="cn.iocoder.yudao.module.custom.vo.BasePromotionRespVO">
<id property="id" column="bp_id" jdbcType="VARCHAR"/>
<result property="oldUserName" column="bp_old_user_name" jdbcType="VARCHAR"/>
<result property="promotionChannel" column="bp_promotion_channel" jdbcType="VARCHAR"/>
<result property="newUserName" column="bp_new_user_name" jdbcType="VARCHAR"/>
<result property="registerTime" column="bp_register_time" jdbcType="TIMESTAMP"/>
<result property="uniqueCode" column="bp_unique_code" jdbcType="VARCHAR"/>
<association property="oldUser" javaType="cn.iocoder.yudao.module.system.api.user.dto.UserDTO">
<result property="mobile" column="os_mobile"/>
<result property="userType" column="os_user_type"/>
</association>
<association property="newUser" javaType="cn.iocoder.yudao.module.system.api.user.dto.UserDTO">
<result property="mobile" column="ns_mobile"/>
</association>
</resultMap>
<select id="queryListPage" resultMap="BaseResultMap">
select bp.id as bp_id,
bp.promotion_channel as bp_promotion_channel,
bp.register_time as bp_register_time,
bp.unique_code as bp_unique_code,
bp.old_user_name as bp_old_user_name,
bp.new_user_name as bp_new_user_name,
os.mobile as os_mobile,
os.user_type as os_user_type,
ns.mobile as ns_mobile
from base_promotion bp
INNER JOIN system_users os on bp.old_user_id = os.id
INNER JOIN system_users ns on bp.new_user_id = ns.id
where bp.deleted = '0'
<if test="map.oldUserName != null and map.oldUserName != ''">
and (bp.old_user_name like concat('%', #{map.oldUserName}, '%'))
</if>
<if test="map.uniqueCode != null and map.uniqueCode != ''">
and (bp.unique_code like concat('%', #{map.uniqueCode}, '%'))
</if>
<if test="map.newUserName != null and map.newUserName != ''">
and (bp.new_user_name like concat('%', #{map.newUserName}, '%'))
</if>
<if test="map.promotionChannel != null and map.promotionChannel != ''">
and (bp.promotion_channel = #{map.promotionChannel})
</if>
<if test="map.registerTimeArray != null and map.registerTimeArray.length > 0">
and (bp.register_time between #{map.registerTimeArray[0]} and #{map.registerTimeArray[1]})
</if>
<if test="map.userType != null and map.userType != ''">
and (os.user_type = #{map.userType})
</if>
order by bp.create_time desc
</select>
</mapper>

View File

@ -0,0 +1,19 @@
package cn.iocoder.yudao.common;
import cn.iocoder.yudao.framework.common.exception.ErrorCode;
/**
* company 错误码枚举类
*
* company 系统使用 1-099-000-000
*/
public interface ErrorCodeConstants {
// ========== 员工管理 1-099-000-000 ==========
// ========== 资产管理模块 1-099-001-000 ==========
ErrorCode PROPERTY_NO_DEPT = new ErrorCode(1_099_001_000, "当前登录用户没有所属部门");
ErrorCode PROPERTY_NO_CORP = new ErrorCode(1_099_001_000, "请选择企业");
}

View File

@ -5,7 +5,7 @@ import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
import cn.iocoder.yudao.module.property.entity.PropertyDealDO;
import cn.iocoder.yudao.module.property.entity.PropertyDeal;
import cn.iocoder.yudao.module.property.service.PropertyDealService;
import cn.iocoder.yudao.module.property.vo.PropertyDealReqVO;
import cn.iocoder.yudao.module.property.vo.PropertyDealRespVO;
@ -63,7 +63,7 @@ public class PropertyDealController {
@Parameter(name = "id", description = "编号", required = true, example = "1024")
@PreAuthorize("@ss.hasPermission('company:property-deal:query')")
public CommonResult<PropertyDealRespVO> getPropertyDeal(@RequestParam("id") String id) {
PropertyDealDO propertyDeal = propertyDealService.getPropertyDeal(id);
PropertyDeal propertyDeal = propertyDealService.getPropertyDeal(id);
return success(BeanUtils.toBean(propertyDeal, PropertyDealRespVO.class));
}

View File

@ -5,7 +5,7 @@ import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
import cn.iocoder.yudao.module.property.entity.PropertyDealItemDO;
import cn.iocoder.yudao.module.property.entity.PropertyDealItem;
import cn.iocoder.yudao.module.property.service.PropertyDealItemService;
import cn.iocoder.yudao.module.property.vo.PropertyDealItemReqVO;
import cn.iocoder.yudao.module.property.vo.PropertyDealItemRespVO;
@ -63,7 +63,7 @@ public class PropertyDealItemController {
@Parameter(name = "id", description = "编号", required = true, example = "1024")
@PreAuthorize("@ss.hasPermission('company:property-deal-item:query')")
public CommonResult<PropertyDealItemRespVO> getPropertyDealItem(@RequestParam("id") String id) {
PropertyDealItemDO propertyDealItem = propertyDealItemService.getPropertyDealItem(id);
PropertyDealItem propertyDealItem = propertyDealItemService.getPropertyDealItem(id);
return success(BeanUtils.toBean(propertyDealItem, PropertyDealItemRespVO.class));
}

View File

@ -5,11 +5,14 @@ import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
import cn.iocoder.yudao.module.property.entity.PropertyPosDO;
import cn.iocoder.yudao.module.property.entity.PropertyPos;
import cn.iocoder.yudao.module.property.service.PropertyPosService;
import cn.iocoder.yudao.module.property.vo.PropertyPosReqVO;
import cn.iocoder.yudao.module.property.vo.PropertyPosRespVO;
import cn.iocoder.yudao.module.staff.entity.CompanyStaff;
import cn.iocoder.yudao.module.staff.vo.CompanyStaffReqVO;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
@ -63,28 +66,18 @@ public class PropertyPosController {
@Parameter(name = "id", description = "编号", required = true, example = "1024")
@PreAuthorize("@ss.hasPermission('company:property-pos:query')")
public CommonResult<PropertyPosRespVO> getPropertyPos(@RequestParam("id") String id) {
PropertyPosDO propertyPos = propertyPosService.getPropertyPos(id);
PropertyPos propertyPos = propertyPosService.getPropertyPos(id);
return success(BeanUtils.toBean(propertyPos, PropertyPosRespVO.class));
}
@GetMapping("/page")
@Operation(summary = "获得企业管理-资产存放位置分页")
@PreAuthorize("@ss.hasPermission('company:property-pos:query')")
public CommonResult<IPage<PropertyPosRespVO>> getPropertyPosPage(PropertyPosReqVO pageReqVO) {
IPage<PropertyPosRespVO> pageResult = propertyPosService.getPropertyPosPage(pageReqVO);
return success(pageResult);
}
@GetMapping("/export-excel")
@Operation(summary = "导出企业管理-资产存放位置 Excel")
@PreAuthorize("@ss.hasPermission('company:property-pos:export')")
@ApiAccessLog(operateType = EXPORT)
public void exportPropertyPosExcel(PropertyPosReqVO pageReqVO,
HttpServletResponse response) throws IOException {
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
List<PropertyPosRespVO> list = propertyPosService.getPropertyPosPage(pageReqVO).getRecords();
// 导出 Excel
ExcelUtils.write(response, "企业管理-资产存放位置.xls", "数据", PropertyPosRespVO.class,list);
public CommonResult<IPage<?>> getPropertyPosPage(PropertyPosReqVO pageReqVO,
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) {
Page<PropertyPos> page = new Page<>(pageNo, pageSize);
return success(propertyPosService.getPropertyPosPage( page,pageReqVO));
}
}

View File

@ -22,7 +22,7 @@ import java.time.LocalDate;
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class PropertyDealDO extends BaseDO {
public class PropertyDeal extends BaseDO {
/**
* 主键标识

View File

@ -20,7 +20,7 @@ import lombok.*;
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class PropertyDealItemDO extends BaseDO {
public class PropertyDealItem extends BaseDO {
/**
* 主键标识

View File

@ -22,7 +22,7 @@ import java.math.BigDecimal;
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class PropertyPosDO extends TenantBaseDO {
public class PropertyPos extends TenantBaseDO {
/**
* 主键标识
@ -50,9 +50,7 @@ public class PropertyPosDO extends TenantBaseDO {
*/
private BigDecimal area;
/**
* 存放类型
*
* 枚举 {@link TODO company_deposit_type 对应的类}
* 存放类型-数据字典 company_deposit_type
*/
private String depositType;

View File

@ -1,6 +1,6 @@
package cn.iocoder.yudao.module.property.mapper;
import cn.iocoder.yudao.module.property.entity.PropertyDealItemDO;
import cn.iocoder.yudao.module.property.entity.PropertyDealItem;
import cn.iocoder.yudao.module.property.vo.PropertyDealItemReqVO;
import cn.iocoder.yudao.module.property.vo.PropertyDealItemRespVO;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
@ -13,7 +13,7 @@ import org.apache.ibatis.annotations.Mapper;
* @author 后台管理员
*/
@Mapper
public interface PropertyDealItemMapper extends BaseMapper<PropertyDealItemDO> {
public interface PropertyDealItemMapper extends BaseMapper<PropertyDealItem> {
default IPage<PropertyDealItemRespVO> selectPage(PropertyDealItemReqVO reqVO) {
return null;

View File

@ -1,7 +1,7 @@
package cn.iocoder.yudao.module.property.mapper;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.property.entity.PropertyDealDO;
import cn.iocoder.yudao.module.property.entity.PropertyDeal;
import cn.iocoder.yudao.module.property.vo.PropertyDealReqVO;
import cn.iocoder.yudao.module.property.vo.PropertyDealRespVO;
import com.baomidou.mybatisplus.core.metadata.IPage;
@ -13,7 +13,7 @@ import org.apache.ibatis.annotations.Mapper;
* @author 后台管理员
*/
@Mapper
public interface PropertyDealMapper extends BaseMapperX<PropertyDealDO> {
public interface PropertyDealMapper extends BaseMapperX<PropertyDeal> {
default IPage<PropertyDealRespVO> selectPage(PropertyDealReqVO reqVO) {
return null;

View File

@ -1,11 +1,16 @@
package cn.iocoder.yudao.module.property.mapper;
import cn.iocoder.yudao.module.property.entity.PropertyPosDO;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.property.entity.PropertyPos;
import cn.iocoder.yudao.module.property.vo.PropertyPosReqVO;
import cn.iocoder.yudao.module.property.vo.PropertyPosRespVO;
import cn.iocoder.yudao.module.staff.entity.CompanyStaff;
import cn.iocoder.yudao.module.staff.vo.CompanyStaffReqVO;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
/**
* 企业管理-资产存放位置 Mapper
@ -13,10 +18,16 @@ import org.apache.ibatis.annotations.Mapper;
* @author vinjor-m
*/
@Mapper
public interface PropertyPosMapper extends BaseMapper<PropertyPosDO> {
public interface PropertyPosMapper extends BaseMapper<PropertyPos> {
default IPage<PropertyPosRespVO> selectPage(PropertyPosReqVO reqVO) {
return null;
}
/**
* 分页查询
* @author vinjor-M
* @date 11:43 2024/8/14
* @param propertyPosReqVO 查询条件
* @param page 分页对象
* @return com.baomidou.mybatisplus.core.metadata.IPage<cn.iocoder.yudao.module.property.vo.PropertyPosRespVO>
**/
IPage<PropertyPosRespVO> selectListPage(Page<PropertyPos> page,@Param("map") PropertyPosReqVO propertyPosReqVO);
}

View File

@ -1,6 +1,6 @@
package cn.iocoder.yudao.module.property.service;
import cn.iocoder.yudao.module.property.entity.PropertyDealItemDO;
import cn.iocoder.yudao.module.property.entity.PropertyDealItem;
import cn.iocoder.yudao.module.property.vo.PropertyDealItemReqVO;
import cn.iocoder.yudao.module.property.vo.PropertyDealItemRespVO;
import com.baomidou.mybatisplus.core.metadata.IPage;
@ -12,7 +12,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
*
* @author 后台管理员
*/
public interface PropertyDealItemService extends IService<PropertyDealItemDO> {
public interface PropertyDealItemService extends IService<PropertyDealItem> {
/**
* 创建企业管理-资产处置子
@ -42,7 +42,7 @@ public interface PropertyDealItemService extends IService<PropertyDealItemDO> {
* @param id 编号
* @return 企业管理-资产处置子
*/
PropertyDealItemDO getPropertyDealItem(String id);
PropertyDealItem getPropertyDealItem(String id);
/**
* 获得企业管理-资产处置子分页

View File

@ -1,6 +1,6 @@
package cn.iocoder.yudao.module.property.service;
import cn.iocoder.yudao.module.property.entity.PropertyDealDO;
import cn.iocoder.yudao.module.property.entity.PropertyDeal;
import cn.iocoder.yudao.module.property.vo.PropertyDealReqVO;
import cn.iocoder.yudao.module.property.vo.PropertyDealRespVO;
import com.baomidou.mybatisplus.core.metadata.IPage;
@ -11,7 +11,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
*
* @author 后台管理员
*/
public interface PropertyDealService extends IService<PropertyDealDO> {
public interface PropertyDealService extends IService<PropertyDeal> {
/**
* 创建企业管理-资产处置单/变动单
@ -41,7 +41,7 @@ public interface PropertyDealService extends IService<PropertyDealDO> {
* @param id 编号
* @return 企业管理-资产处置单/变动单
*/
PropertyDealDO getPropertyDeal(String id);
PropertyDeal getPropertyDeal(String id);
/**
* 获得企业管理-资产处置单/变动单分页

View File

@ -1,9 +1,11 @@
package cn.iocoder.yudao.module.property.service;
import cn.iocoder.yudao.module.property.entity.PropertyPosDO;
import cn.iocoder.yudao.module.property.entity.PropertyPos;
import cn.iocoder.yudao.module.property.vo.PropertyPosReqVO;
import cn.iocoder.yudao.module.property.vo.PropertyPosRespVO;
import cn.iocoder.yudao.module.staff.entity.CompanyStaff;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
/**
@ -11,7 +13,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
*
* @author vinjor-m
*/
public interface PropertyPosService extends IService<PropertyPosDO> {
public interface PropertyPosService extends IService<PropertyPos> {
/**
* 创建企业管理-资产存放位置
@ -41,7 +43,7 @@ public interface PropertyPosService extends IService<PropertyPosDO> {
* @param id 编号
* @return 企业管理-资产存放位置
*/
PropertyPosDO getPropertyPos(String id);
PropertyPos getPropertyPos(String id);
/**
* 获得企业管理-资产存放位置分页
@ -49,6 +51,6 @@ public interface PropertyPosService extends IService<PropertyPosDO> {
* @param pageReqVO 分页查询
* @return 企业管理-资产存放位置分页
*/
IPage<PropertyPosRespVO> getPropertyPosPage(PropertyPosReqVO pageReqVO);
IPage<PropertyPosRespVO> getPropertyPosPage(Page<PropertyPos> page,PropertyPosReqVO pageReqVO);
}

View File

@ -1,7 +1,7 @@
package cn.iocoder.yudao.module.property.service.impl;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.module.property.entity.PropertyDealItemDO;
import cn.iocoder.yudao.module.property.entity.PropertyDealItem;
import cn.iocoder.yudao.module.property.mapper.PropertyDealItemMapper;
import cn.iocoder.yudao.module.property.service.PropertyDealItemService;
import cn.iocoder.yudao.module.property.vo.PropertyDealItemReqVO;
@ -18,12 +18,12 @@ import org.springframework.validation.annotation.Validated;
*/
@Service
@Validated
public class PropertyDealItemServiceImpl extends ServiceImpl<PropertyDealItemMapper, PropertyDealItemDO> implements PropertyDealItemService {
public class PropertyDealItemServiceImpl extends ServiceImpl<PropertyDealItemMapper, PropertyDealItem> implements PropertyDealItemService {
@Override
public String createPropertyDealItem(PropertyDealItemReqVO createReqVO) {
// 插入
PropertyDealItemDO propertyDealItem = BeanUtils.toBean(createReqVO, PropertyDealItemDO.class);
PropertyDealItem propertyDealItem = BeanUtils.toBean(createReqVO, PropertyDealItem.class);
baseMapper.insert(propertyDealItem);
// 返回
return propertyDealItem.getId();
@ -32,7 +32,7 @@ public class PropertyDealItemServiceImpl extends ServiceImpl<PropertyDealItemMap
@Override
public void updatePropertyDealItem(PropertyDealItemReqVO updateReqVO) {
// 更新
PropertyDealItemDO updateObj = BeanUtils.toBean(updateReqVO, PropertyDealItemDO.class);
PropertyDealItem updateObj = BeanUtils.toBean(updateReqVO, PropertyDealItem.class);
baseMapper.updateById(updateObj);
}
@ -44,7 +44,7 @@ public class PropertyDealItemServiceImpl extends ServiceImpl<PropertyDealItemMap
@Override
public PropertyDealItemDO getPropertyDealItem(String id) {
public PropertyDealItem getPropertyDealItem(String id) {
return baseMapper.selectById(id);
}

View File

@ -1,7 +1,7 @@
package cn.iocoder.yudao.module.property.service.impl;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.module.property.entity.PropertyDealDO;
import cn.iocoder.yudao.module.property.entity.PropertyDeal;
import cn.iocoder.yudao.module.property.mapper.PropertyDealMapper;
import cn.iocoder.yudao.module.property.service.PropertyDealService;
import cn.iocoder.yudao.module.property.vo.PropertyDealReqVO;
@ -19,12 +19,12 @@ import org.springframework.validation.annotation.Validated;
*/
@Service
@Validated
public class PropertyDealServiceImpl extends ServiceImpl<PropertyDealMapper,PropertyDealDO> implements PropertyDealService {
public class PropertyDealServiceImpl extends ServiceImpl<PropertyDealMapper, PropertyDeal> implements PropertyDealService {
@Override
public String createPropertyDeal(PropertyDealReqVO createReqVO) {
// 插入
PropertyDealDO propertyDeal = BeanUtils.toBean(createReqVO, PropertyDealDO.class);
PropertyDeal propertyDeal = BeanUtils.toBean(createReqVO, PropertyDeal.class);
baseMapper.insert(propertyDeal);
// 返回
return propertyDeal.getId();
@ -33,7 +33,7 @@ public class PropertyDealServiceImpl extends ServiceImpl<PropertyDealMapper,Prop
@Override
public void updatePropertyDeal(PropertyDealReqVO updateReqVO) {
// 更新
PropertyDealDO updateObj = BeanUtils.toBean(updateReqVO, PropertyDealDO.class);
PropertyDeal updateObj = BeanUtils.toBean(updateReqVO, PropertyDeal.class);
baseMapper.updateById(updateObj);
}
@ -45,7 +45,7 @@ public class PropertyDealServiceImpl extends ServiceImpl<PropertyDealMapper,Prop
@Override
public PropertyDealDO getPropertyDeal(String id) {
public PropertyDeal getPropertyDeal(String id) {
return baseMapper.selectById(id);
}

View File

@ -1,16 +1,28 @@
package cn.iocoder.yudao.module.property.service.impl;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.module.property.entity.PropertyPosDO;
import cn.iocoder.yudao.framework.security.core.LoginUser;
import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils;
import cn.iocoder.yudao.module.property.entity.PropertyPos;
import cn.iocoder.yudao.module.property.mapper.PropertyPosMapper;
import cn.iocoder.yudao.module.property.service.PropertyPosService;
import cn.iocoder.yudao.module.property.vo.PropertyPosReqVO;
import cn.iocoder.yudao.module.property.vo.PropertyPosRespVO;
import cn.iocoder.yudao.module.system.api.dept.DeptApi;
import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;
import javax.annotation.Resource;
import static cn.iocoder.yudao.common.ErrorCodeConstants.PROPERTY_NO_CORP;
import static cn.iocoder.yudao.common.ErrorCodeConstants.PROPERTY_NO_DEPT;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
/**
* 企业管理-资产存放位置 Service 实现类
*
@ -18,12 +30,32 @@ import org.springframework.validation.annotation.Validated;
*/
@Service
@Validated
public class PropertyPosServiceImpl extends ServiceImpl<PropertyPosMapper, PropertyPosDO> implements PropertyPosService {
public class PropertyPosServiceImpl extends ServiceImpl<PropertyPosMapper, PropertyPos> implements PropertyPosService {
@Resource
private DeptApi deptApi;
@Resource
private PropertyPosMapper propertyPosMapper;
@Override
public String createPropertyPos(PropertyPosReqVO createReqVO) {
// 插入
PropertyPosDO propertyPos = BeanUtils.toBean(createReqVO, PropertyPosDO.class);
/* 1.设置当前登录用户所属部门Id、企业Id */
LoginUser loginUser = SecurityFrameworkUtils.getLoginUser();
if(StringUtils.isEmpty(loginUser.getInfo().get("deptId"))){
//当前登录用户没有部门不能新增
throw exception(PROPERTY_NO_DEPT);
}
Long deptId = Long.valueOf(loginUser.getInfo().get("deptId"));
createReqVO.setDeptId(deptId);
DeptRespDTO deptRespDTO = deptApi.getDept(deptId);
if(StringUtils.isEmpty(deptRespDTO.getCorpId()) && StringUtils.isEmpty(createReqVO.getCorpId())){
//当前登录用户非企业人员且没有手动选择所属企业的话不能添加
throw exception(PROPERTY_NO_CORP);
}
if(StringUtils.isEmpty(createReqVO.getCorpId())){
createReqVO.setCorpId(deptRespDTO.getCorpId());
}
/* 2.插入数据并反回Id*/
PropertyPos propertyPos = BeanUtils.toBean(createReqVO, PropertyPos.class);
baseMapper.insert(propertyPos);
// 返回
return propertyPos.getId();
@ -32,7 +64,7 @@ public class PropertyPosServiceImpl extends ServiceImpl<PropertyPosMapper, Prope
@Override
public void updatePropertyPos(PropertyPosReqVO updateReqVO) {
// 更新
PropertyPosDO updateObj = BeanUtils.toBean(updateReqVO, PropertyPosDO.class);
PropertyPos updateObj = BeanUtils.toBean(updateReqVO, PropertyPos.class);
baseMapper.updateById(updateObj);
}
@ -45,13 +77,13 @@ public class PropertyPosServiceImpl extends ServiceImpl<PropertyPosMapper, Prope
@Override
public PropertyPosDO getPropertyPos(String id) {
public PropertyPos getPropertyPos(String id) {
return baseMapper.selectById(id);
}
@Override
public IPage<PropertyPosRespVO> getPropertyPosPage(PropertyPosReqVO pageReqVO) {
return baseMapper.selectPage(pageReqVO);
public IPage<PropertyPosRespVO> getPropertyPosPage(Page<PropertyPos> page, PropertyPosReqVO pageReqVO) {
return propertyPosMapper.selectListPage(page,pageReqVO);
}
}

View File

@ -1,6 +1,6 @@
package cn.iocoder.yudao.module.property.vo;
import cn.iocoder.yudao.module.property.entity.PropertyDealItemDO;
import cn.iocoder.yudao.module.property.entity.PropertyDealItem;
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
import com.alibaba.excel.annotation.ExcelProperty;
import io.swagger.v3.oas.annotations.media.Schema;
@ -11,7 +11,7 @@ import java.time.LocalDateTime;
@Schema(description = "管理后台 - 企业管理-资产处置子 Response VO")
@Data
@ExcelIgnoreUnannotated
public class PropertyDealItemRespVO extends PropertyDealItemDO {
public class PropertyDealItemRespVO extends PropertyDealItem {
@Schema(description = "创建时间")
@ExcelProperty("创建时间")

View File

@ -1,6 +1,6 @@
package cn.iocoder.yudao.module.property.vo;
import cn.iocoder.yudao.module.property.entity.PropertyDealDO;
import cn.iocoder.yudao.module.property.entity.PropertyDeal;
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
import com.alibaba.excel.annotation.ExcelProperty;
import io.swagger.v3.oas.annotations.media.Schema;
@ -11,7 +11,7 @@ import java.time.LocalDateTime;
@Schema(description = "管理后台 - 企业管理-资产处置单/变动单 Response VO")
@Data
@ExcelIgnoreUnannotated
public class PropertyDealRespVO extends PropertyDealDO {
public class PropertyDealRespVO extends PropertyDeal {
@Schema(description = "创建时间")
@ExcelProperty("创建时间")

View File

@ -1,46 +1,17 @@
package cn.iocoder.yudao.module.property.vo;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import cn.iocoder.yudao.module.property.entity.PropertyPos;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import org.springframework.format.annotation.DateTimeFormat;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY;
@Schema(description = "管理后台 - 企业管理-资产存放位置分页 Request VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class PropertyPosReqVO extends PageParam {
public class PropertyPosReqVO extends PropertyPos {
@Schema(description = "主键标识", requiredMode = Schema.RequiredMode.REQUIRED, example = "18095")
private String id;
@Schema(description = "企业idbase_company表中的id", example = "5018")
private String corpId;
@Schema(description = "部门idsystem_dept表中的id用来做数据权限控制", example = "25943")
private Long deptId;
@Schema(description = "存放地名称", example = "王五")
private String posName;
@Schema(description = "存放地地址")
private String address;
@Schema(description = "面积")
private BigDecimal area;
@Schema(description = "存放类型", example = "2")
private String depositType;
@Schema(description = "创建时间")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY)
private LocalDateTime createTime;
}

View File

@ -1,20 +1,17 @@
package cn.iocoder.yudao.module.property.vo;
import cn.iocoder.yudao.module.property.entity.PropertyPosDO;
import cn.iocoder.yudao.module.property.entity.PropertyPos;
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
import com.alibaba.excel.annotation.ExcelProperty;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.time.LocalDateTime;
@Schema(description = "管理后台 - 企业管理-资产存放位置 Response VO")
@Data
@ExcelIgnoreUnannotated
public class PropertyPosRespVO extends PropertyPosDO {
@Schema(description = "创建时间")
@ExcelProperty("创建时间")
private LocalDateTime createTime;
public class PropertyPosRespVO extends PropertyPos {
/**
* 企业名称
*/
String corpName;
}

View File

@ -1,10 +1,12 @@
package cn.iocoder.yudao.module.staff.controller.admin;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.module.staff.entity.CompanyStaff;
import cn.iocoder.yudao.module.staff.entity.CompanyStaffChange;
import cn.iocoder.yudao.module.staff.service.CompanyStaffChangeService;
import cn.iocoder.yudao.module.staff.vo.CompanyStaffChangeReqVO;
import cn.iocoder.yudao.module.staff.vo.CompanyStaffChangeRespVO;
import cn.iocoder.yudao.module.staff.vo.CompanyStaffRespVO;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.security.access.prepost.PreAuthorize;
@ -12,7 +14,6 @@ import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.List;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
@ -30,6 +31,12 @@ public class CompanyStaffChangeController {
@Resource
private CompanyStaffChangeService staffChangeService;
/**
* 创建交接信息
* @author 小李
* @date 14:30 2024/8/12
* @param staffChangeRespVO 交接双方
**/
@PostMapping("/create")
@Operation(summary = "创建企业管理-员工交接表信息")
@PreAuthorize("@ss.hasPermission('company:staff:change')")
@ -39,15 +46,19 @@ public class CompanyStaffChangeController {
}
/**
* 查询交接双方信息
* @author 小李
* @date 18:26 2024/8/8
* @param id 接收方员工ID
**/
@GetMapping("/changeItem")
* @date 18:56 2024/8/12
* @param staffChangeReqVO 查询条件对象
* @param pageNo 页码
* @param pageSize 条数
**/
@GetMapping("/page")
@Operation(summary = "查询企业管理-员工交接表信息及交接双方")
@PreAuthorize("@ss.hasPermission('company:staff:query')")
public CommonResult<CompanyStaffChangeRespVO> getChangeStaff(@RequestParam("id") String id){
return success(staffChangeService.getChangeStaff(id));
@PreAuthorize("@ss.hasPermission('company:staffChange:query')")
public CommonResult<IPage<?>> getStaffChangePage(CompanyStaffChangeReqVO staffChangeReqVO,
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize){
Page<CompanyStaffChange> page = new Page<>(pageNo, pageSize);
return success(staffChangeService.getStaffChangePage(staffChangeReqVO, page));
}
}

View File

@ -2,14 +2,12 @@ package cn.iocoder.yudao.module.staff.controller.admin;
import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
import cn.iocoder.yudao.module.label.entity.Label;
import cn.iocoder.yudao.module.staff.entity.CompanyStaff;
import cn.iocoder.yudao.module.staff.service.CompanyStaffService;
import cn.iocoder.yudao.module.staff.vo.CompanyStaffReqVO;
import cn.iocoder.yudao.module.staff.vo.CompanyStaffRespVO;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.v3.oas.annotations.Operation;
@ -31,9 +29,10 @@ import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
/**
* 企业管理-员工信息表 控制层
*
* @author 小李
* @date 17:14 2024/8/6
**/
**/
@RestController
@RequestMapping("/company/staff")
@Tag(name = "管理后台 - 企业管理 - 员工管理")
@ -45,28 +44,30 @@ public class CompanyStaffController {
/**
* 分页查询
*
* @param pageReqVO 查询条件对象
* @param pageNo 页码
* @param pageSize 条数
* @author 小李
* @date 17:19 2024/8/6
* @param pageReqVO 查询条件对象
* @param pageNo 页码
* @param pageSize 条数
**/
**/
@GetMapping("/page")
@Operation(summary = "获得企业管理-员工信息表信息分页")
@PreAuthorize("@ss.hasPermission('company:staff:query')")
public CommonResult<IPage<?>> getCompanyStaffPage(CompanyStaffReqVO pageReqVO,
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) {
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) {
Page<CompanyStaff> page = new Page<>(pageNo, pageSize);
return success(staffService.queryListPage(pageReqVO, page));
}
/**
* 新增员工
*
* @param staffRespVO 员工对象
* @author 小李
* @date 17:20 2024/8/6
* @param staffRespVO 员工对象
**/
**/
@PostMapping("/create")
@Operation(summary = "创建企业管理-员工信息表信息")
@PreAuthorize("@ss.hasPermission('company:staff:create')")
@ -77,10 +78,11 @@ public class CompanyStaffController {
/**
* 修改员工
*
* @param staffRespVO 员工对象
* @author 小李
* @date 17:24 2024/8/6
* @param staffRespVO 员工对象
**/
**/
@PutMapping("/update")
@Operation(summary = "更新企业管理-员工信息表信息")
@PreAuthorize("@ss.hasPermission('company:staff:update')")
@ -91,10 +93,11 @@ public class CompanyStaffController {
/**
* 删除员工
*
* @param id 员工id
* @author 小李
* @date 17:28 2024/8/6
* @param id 员工id
**/
**/
@DeleteMapping("/delete")
@Operation(summary = "删除企业管理-员工信息表信息")
@Parameter(name = "id", description = "编号", required = true)
@ -106,10 +109,11 @@ public class CompanyStaffController {
/**
* 查询员工
*
* @param id
* @author 小李
* @date 17:59 2024/8/6
* @param id
**/
**/
@GetMapping("/get")
@Operation(summary = "获得企业管理-员工信息表信息")
@Parameter(name = "id", description = "编号", required = true, example = "1024")
@ -121,44 +125,79 @@ public class CompanyStaffController {
/**
* 导出员工信息表
*
* @param pageReqVO 查询条件--暂时导出所有
* @param response 响应体
* @author 小李
* @date 18:01 2024/8/6
* @param pageReqVO 查询条件--暂时导出所有
* @param response 响应体
**/
**/
@GetMapping("/export-excel")
@Operation(summary = "导出企业管理-员工信息表 Excel")
@PreAuthorize("@ss.hasPermission('company:staff:export')")
@ApiAccessLog(operateType = EXPORT)
public void exportCompanyStaffExcel(CompanyStaffReqVO pageReqVO,
HttpServletResponse response) throws IOException {
HttpServletResponse response) throws IOException {
List<CompanyStaff> list = staffService.list();
// 导出 Excel
Map<Integer, Integer> columnWidthMap = new HashMap<>();
// 第一列的索引是0宽度设置为20个字符宽
columnWidthMap.put(9, 20);
columnWidthMap.put(10, 20);
ExcelUtils.write(response, "企业信息表.xls", "数据", CompanyStaff.class, list,columnWidthMap);
ExcelUtils.write(response, "企业信息表.xls", "数据", CompanyStaff.class, list, columnWidthMap);
}
/**
* 获取当前功能的标签
*
* @author 小李
* @date 14:59 2024/8/7
**/
**/
@GetMapping("/labels")
public CommonResult<List<Label>> getLabels(){
@Operation(summary = "获取当前功能的标签")
@PreAuthorize("@ss.hasPermission('company:staff:query')")
public CommonResult<List<Label>> getLabels() {
return success(staffService.getLabels());
}
/**
* 获取当前登录用户部门下所有员工信息
*
* @author 小李
* @date 15:54 2024/8/8
**/
**/
@GetMapping("/list")
public CommonResult<List<CompanyStaff>> getStaffList(){
@Operation(summary = "获取当前登录用户部门下所有员工信息")
@PreAuthorize("@ss.hasPermission('company:staff:query')")
public CommonResult<List<CompanyStaff>> getStaffList() {
return success(staffService.getStaffList());
}
/**
* 验证工号是否重复
*
* @param workNo 输入的工号
* @author 小李
* @date 14:03 2024/8/9
**/
@GetMapping("/checkWorkNo")
@Operation(summary = "验证工号是否重复")
@PreAuthorize("@ss.hasPermission('company:staff:query')")
public CommonResult<Boolean> checkWorkNo(@RequestParam("workNo") String workNo) {
return success(staffService.checkWorkNo(workNo));
}
/**
* 重置员工登录密码
*
* @param staffRespVO 员工对象
* @author 小李
* @date 16:21 2024/8/9
**/
@PostMapping("/resetPassword")
@Operation(summary = "重置员工登录密码")
@PreAuthorize("@ss.hasPermission('company:staff:resetPassword')")
public CommonResult resetPassword(@RequestBody CompanyStaffRespVO staffRespVO) {
staffService.resetPassword(staffRespVO);
return CommonResult.ok();
}
}

View File

@ -1,6 +1,8 @@
package cn.iocoder.yudao.module.staff.entity;
import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat;
import cn.iocoder.yudao.framework.excel.core.convert.DictConvert;
import cn.iocoder.yudao.framework.tenant.core.db.TenantBaseDO;
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
import com.alibaba.excel.annotation.ExcelProperty;
@ -15,6 +17,8 @@ import org.springframework.format.annotation.DateTimeFormat;
import java.math.BigDecimal;
import java.util.Date;
import static cn.iocoder.yudao.common.DictBaseConstants.*;
/**
* 企业管理-员工信息实体
* @author 小李
@ -51,7 +55,8 @@ public class CompanyStaff extends TenantBaseDO {
private String tel;
/** 性别 */
@ExcelProperty("性别")
@ExcelProperty(value = "性别", converter = DictConvert.class)
@DictFormat(DICT_SYS_USER_SEX)
private String sex;
/** 家庭住址 */
@ -65,7 +70,7 @@ public class CompanyStaff extends TenantBaseDO {
private Date workDate;
/** 工龄 */
@ExcelProperty("工龄")
@ExcelProperty("工龄(年)")
private BigDecimal workYear;
/** 入职日期 */
@ -75,11 +80,12 @@ public class CompanyStaff extends TenantBaseDO {
private Date joinedDate;
/** 司龄 */
@ExcelProperty("司龄")
@ExcelProperty("司龄(年)")
private BigDecimal joinedYear;
/** 学历 */
@ExcelProperty("学历")
@ExcelProperty(value = "学历", converter = DictConvert.class)
@DictFormat(COMPANY_STAFF_EDU)
private String education;
/** 个人简介 */

View File

@ -32,8 +32,8 @@ public class CompanyStaffChange extends TenantBaseDO {
private Long newUserId;
/** 交接时间 */
@JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern="yyyy-MM-dd",timezone="GMT+8")
@DateTimeFormat(pattern="yyyy-MM-dd")
private Date changeTime;
/** 附件urlsinfra_file表中的url多个英文逗号拼接 */

View File

@ -1,8 +1,13 @@
package cn.iocoder.yudao.module.staff.mapper;
import cn.iocoder.yudao.module.staff.entity.CompanyStaffChange;
import cn.iocoder.yudao.module.staff.vo.CompanyStaffChangeReqVO;
import cn.iocoder.yudao.module.staff.vo.CompanyStaffChangeRespVO;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
/**
* 企业管理-员工交接记录
@ -11,4 +16,7 @@ import org.apache.ibatis.annotations.Mapper;
**/
@Mapper
public interface CompanyStaffChangeMapper extends BaseMapper<CompanyStaffChange> {
IPage<CompanyStaffChangeRespVO> getStaffChangePage(@Param("map") CompanyStaffChangeReqVO staffChangeReqVO, Page<CompanyStaffChange> page);
}

View File

@ -1,11 +1,12 @@
package cn.iocoder.yudao.module.staff.service;
import cn.iocoder.yudao.module.staff.entity.CompanyStaffChange;
import cn.iocoder.yudao.module.staff.vo.CompanyStaffChangeReqVO;
import cn.iocoder.yudao.module.staff.vo.CompanyStaffChangeRespVO;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import java.util.List;
/**
* 企业管理-员工交接记录 接口
* @author 小李
@ -22,10 +23,17 @@ public interface CompanyStaffChangeService extends IService<CompanyStaffChange>
void createChangeStaff(CompanyStaffChangeRespVO staffChangeRespVO);
/**
* 查询交接双方信息
* @author 小李
* @date 18:26 2024/8/8
* @param id 接收方员工ID
* @date 19:00 2024/8/12
* @param staffChangeReqVO 分页对象
**/
IPage<CompanyStaffChangeRespVO> getStaffChangePage(CompanyStaffChangeReqVO staffChangeReqVO, Page<CompanyStaffChange> page);
/**
* 判断交出方工作是否已交接
* @author 小李
* @date 18:02 2024/8/12
* @param userId 交出方ID
**/
CompanyStaffChangeRespVO getChangeStaff(String id);
Boolean checkChangeStatus(Long userId);
}

View File

@ -71,4 +71,27 @@ public interface CompanyStaffService extends IService<CompanyStaff> {
* @date 15:54 2024/8/8
**/
List<CompanyStaff> getStaffList();
/**
* 重置员工登录密码
* @author 小李
* @date 16:21 2024/8/9
* @param staffRespVO 员工对象
**/
void resetPassword(CompanyStaffRespVO staffRespVO);
/**
* 验证工号是否重复
* @author 小李
* @date 14:03 2024/8/9
* @param workNo 输入的工号
**/
Boolean checkWorkNo(String workNo);
/**
* 更新员工的工龄和司龄
* @author 小李
* @date 11:41 2024/8/13
**/
void updateStaffWorkAndJoinedYears();
}

View File

@ -11,11 +11,10 @@ import com.baomidou.mybatisplus.extension.service.IService;
public interface UniqueCodeService extends IService<UniqueCode> {
/**
* 新增唯一推广码
* 生成唯一推广码
* @author 小李
* @date 9:59 2024/8/8
* @param uniqueCode
*
* @return*/
int insertUniqueCode(String uniqueCode);
* @return 可使用推广码
**/
String createUniqueCode();
}

View File

@ -1,6 +1,5 @@
package cn.iocoder.yudao.module.staff.service.impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.iocoder.yudao.common.CommonErrorCodeConstants;
import cn.iocoder.yudao.module.staff.entity.CompanyStaff;
@ -8,13 +7,20 @@ import cn.iocoder.yudao.module.staff.entity.CompanyStaffChange;
import cn.iocoder.yudao.module.staff.mapper.CompanyStaffChangeMapper;
import cn.iocoder.yudao.module.staff.service.CompanyStaffChangeService;
import cn.iocoder.yudao.module.staff.service.CompanyStaffService;
import cn.iocoder.yudao.module.staff.vo.CompanyStaffChangeReqVO;
import cn.iocoder.yudao.module.staff.vo.CompanyStaffChangeRespVO;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.dynamic.datasource.annotation.DSTransactional;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
import java.util.stream.Collectors;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
/**
@ -36,14 +42,12 @@ public class CompanyStaffChangeServiceImpl extends ServiceImpl<CompanyStaffChang
* @author 小李
* @date 16:15 2024/8/8
**/
@Override
@DSTransactional
public void createChangeStaff(CompanyStaffChangeRespVO staffChangeRespVO) {
// 检查是否已有相同的交接记录或交出方已经交出或接收方已接收其他工作
CompanyStaffChange staffChange = baseMapper.selectOne(new QueryWrapper<CompanyStaffChange>().and(itme -> {
itme.eq("old_user_id", staffChangeRespVO.getOldUserId())
.eq("new_user_id", staffChangeRespVO.getNewUserId());
}).or().eq("old_user_id", staffChangeRespVO.getOldUserId())
.or().eq("new_user_id", staffChangeRespVO.getNewUserId()));
if (ObjectUtil.isNotEmpty(staffChange)) {
// 确定交出方目前有没有工作可以交接
Boolean flag = checkChangeStatus(staffChangeRespVO.getOldUserId());
if (flag) {
throw exception(CommonErrorCodeConstants.STAFF_CHANGE_CREATE_REPEAT);
}
baseMapper.insert(staffChangeRespVO);
@ -51,33 +55,67 @@ public class CompanyStaffChangeServiceImpl extends ServiceImpl<CompanyStaffChang
}
/**
* 查询交接双方信息
* 交接记分页查询
*
* @param id 接收方员工ID
* @param staffChangeReqVO 分页对象
* @author 小李
* @date 18:26 2024/8/8
* @date 19:00 2024/8/12
**/
@Override
public CompanyStaffChangeRespVO getChangeStaff(String id) {
/** 构造返回对象 */
CompanyStaffChangeRespVO result = null;
// 1 根据当前ID获取员工记录
CompanyStaff staff = staffService.getOne(new QueryWrapper<CompanyStaff>().eq("id", id));
// 2 根据获取的员工信息中的userId获取交接记录
CompanyStaffChange staffChange = baseMapper.selectOne(new QueryWrapper<CompanyStaffChange>()
.eq("new_user_id", staff.getUserId())
.or()
.eq("old_user_id", staff.getUserId())
);
if (ObjectUtil.isNotEmpty(staffChange)) {
result = new CompanyStaffChangeRespVO();
BeanUtil.copyProperties(staffChange, result);
// 3 根据交接记录中新老员工的userId查新老员工信息
CompanyStaff oldStaff = staffService.getOne(new QueryWrapper<CompanyStaff>().eq("user_id", staffChange.getOldUserId()));
CompanyStaff newStaff = staffService.getOne(new QueryWrapper<CompanyStaff>().eq("user_id", staffChange.getNewUserId()));
result.setNewStaff(newStaff);
result.setOldStaff(oldStaff);
public IPage<CompanyStaffChangeRespVO> getStaffChangePage(CompanyStaffChangeReqVO staffChangeReqVO, Page<CompanyStaffChange> page) {
// 如果用户选择了按交接类型搜索交出接收那一定要保证员工姓名工号电话有一个不为空才行不然没有参照
if (ObjectUtil.isNotEmpty(staffChangeReqVO.getChangeType()) &&
(ObjectUtil.isNotEmpty(staffChangeReqVO.getName()) ||
ObjectUtil.isNotEmpty(staffChangeReqVO.getWorkNo()) ||
ObjectUtil.isNotEmpty(staffChangeReqVO.getTel())
)
) {
// 根据不为空的那个条件去查员工的userId
List<CompanyStaff> list = null;
if (ObjectUtil.isNotEmpty(staffChangeReqVO.getName())) {
list = staffService.list(new LambdaQueryWrapper<CompanyStaff>()
.like(CompanyStaff::getName, staffChangeReqVO.getName())
);
} else if (ObjectUtil.isNotEmpty(staffChangeReqVO.getWorkNo())) {
list = staffService.list(new LambdaQueryWrapper<CompanyStaff>()
.like(CompanyStaff::getWorkNo, staffChangeReqVO.getWorkNo())
);
} else if (ObjectUtil.isNotEmpty(staffChangeReqVO.getTel())) {
list = staffService.list(new LambdaQueryWrapper<CompanyStaff>()
.like(CompanyStaff::getTel, staffChangeReqVO.getTel())
);
}
// 如果查到了结果才处理没查到不管
if (ObjectUtil.isNotEmpty(list)) {
List<Long> userIds = list.stream().map(item -> item.getUserId()).collect(Collectors.toList());
if (staffChangeReqVO.getChangeType().equals("0")) {
staffChangeReqVO.setOldUserIds(userIds);
} else {
staffChangeReqVO.setNewUserIds(userIds);
}
}
}
return result;
return baseMapper.getStaffChangePage(staffChangeReqVO, page);
}
/**
* 判断交出方工作是否已交接
*
* @param userId 交出方ID
* @author 小李
* @date 18:02 2024/8/12
**/
@Override
public Boolean checkChangeStatus(Long userId) {
// 获取该员工的最新一条记录
CompanyStaffChange staffChange = baseMapper.selectOne(new LambdaQueryWrapper<CompanyStaffChange>()
.eq(CompanyStaffChange::getOldUserId, userId)
.or()
.eq(CompanyStaffChange::getNewUserId, userId)
.orderByDesc(CompanyStaffChange::getCreateTime)
.last("limit 1")
);
// 如果为空或者最后一次相关记录他是交出方那就返回true代表他交接了工作没有工作可以交
return ObjectUtil.isNotEmpty(staffChange) && staffChange.getOldUserId().equals(userId);
}
}

View File

@ -2,28 +2,24 @@ package cn.iocoder.yudao.module.staff.service.impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.RandomUtil;
import cn.iocoder.yudao.common.BaseConstants;
import cn.iocoder.yudao.common.CommonErrorCodeConstants;
import cn.iocoder.yudao.framework.common.util.io.FileUtils;
import cn.iocoder.yudao.framework.datapermission.core.rule.DataPermissionRule;
import cn.iocoder.yudao.framework.datapermission.core.rule.dept.DeptDataPermissionRule;
import cn.iocoder.yudao.framework.security.core.LoginUser;
import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils;
import cn.iocoder.yudao.module.company.entity.Company;
import cn.iocoder.yudao.module.company.service.CompanyService;
import cn.iocoder.yudao.module.infra.api.file.FileApi;
import cn.iocoder.yudao.module.staff.entity.UniqueCode;
import cn.iocoder.yudao.module.staff.service.UniqueCodeService;
import cn.iocoder.yudao.module.label.entity.BusiLabel;
import cn.iocoder.yudao.module.label.entity.Label;
import cn.iocoder.yudao.module.label.service.BusiLabelService;
import cn.iocoder.yudao.module.label.service.LabelService;
import cn.iocoder.yudao.module.staff.entity.CompanyStaff;
import cn.iocoder.yudao.module.staff.mapper.CompanyStaffMapper;
import cn.iocoder.yudao.module.staff.service.CompanyStaffChangeService;
import cn.iocoder.yudao.module.staff.service.CompanyStaffService;
import cn.iocoder.yudao.module.staff.service.UniqueCodeService;
import cn.iocoder.yudao.module.staff.vo.CompanyStaffReqVO;
import cn.iocoder.yudao.module.staff.vo.CompanyStaffRespVO;
import cn.iocoder.yudao.module.system.api.dept.DeptApi;
import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO;
import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
import cn.iocoder.yudao.module.system.api.user.dto.UserDTO;
@ -36,10 +32,14 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.Period;
import java.time.ZoneId;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import static cn.iocoder.yudao.framework.common.config.CommonStr.USER_TYPE_STAFF;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
/**
@ -60,16 +60,17 @@ public class CompanyStaffServiceImpl extends ServiceImpl<CompanyStaffMapper, Com
@Resource
private LabelService labelService;
@Resource
private CompanyService companyService;
@Resource
private BusiLabelService busiLabelService;
@Resource
private UniqueCodeService uniqueCodeService;
@Resource
private DataPermissionRule dataPermissionRule;
private DeptApi deptApi;
@Resource
private CompanyStaffChangeService staffChangeService;
/**
* 获得企业管理-员工信息表分页
@ -94,24 +95,25 @@ public class CompanyStaffServiceImpl extends ServiceImpl<CompanyStaffMapper, Com
@Override
@DSTransactional
public void saveStaff(CompanyStaffRespVO staffRespVO) {
/** 获取当前登录用户的信息 */
LoginUser loginUser = SecurityFrameworkUtils.getLoginUser();
AdminUserRespDTO user = adminUserApi.getUser(loginUser.getId());
// 获取当前登录用户的详细信息
AdminUserRespDTO loginUser = getLoginUser();
/** 创建UserDTO用于给sys_user插入数据 */
/* 创建UserDTO用于给sys_user插入数据 */
UserDTO userDTO = new UserDTO();
userDTO.setUsername(staffRespVO.getLoginAccount());
userDTO.setPassword(staffRespVO.getPassword());
userDTO.setNickname(staffRespVO.getName());
userDTO.setDeptId(user.getDeptId());
userDTO.setDeptId(loginUser.getDeptId());
userDTO.setMobile(staffRespVO.getTel());
userDTO.setSex(staffRespVO.getSex());
userDTO.setUserType(USER_TYPE_STAFF);
// 获取sys_users中刚插入记录ID给准备添加的员工
Long userId = adminUserApi.createUser(userDTO);
staffRespVO.setUserId(userId);
// 设置新增员工部门
staffRespVO.setDeptId(user.getDeptId());
staffRespVO.setDeptId(loginUser.getDeptId());
/** 插入标签库 */
/* 插入标签库 */
if (ObjectUtil.isNotEmpty(staffRespVO.getLabelsArray())) {
// 1 获取标签库中的存在的数据
List<Label> labels = getLabelsByLabelName(staffRespVO.getLabelsArray());
@ -127,31 +129,20 @@ public class CompanyStaffServiceImpl extends ServiceImpl<CompanyStaffMapper, Com
}
}
/** 插入员工库 */
/* 插入员工库 */
// 1 获取当前登录用户的企业信息给添加的员工
Company company = companyService.getOne(new QueryWrapper<Company>().eq("mobile_phone", user.getMobile()));
staffRespVO.setCorpId(company.getId());
DeptRespDTO loginDept = getLoginDept(loginUser.getDeptId());
staffRespVO.setCorpId(loginDept.getCorpId());
// 2 生成唯一推广码
int count = 0;
// 3 生成时判断是否重复重复就重新生成最多生成6次
while (true) {
// 重复生成和长度一样的次数还是重复就抛异常
if (count == BaseConstants.UNIQUE_CODE_LEN) {
throw exception(CommonErrorCodeConstants.UNIQUE_CODE_CREATE_REPEAT);
}
String code = RandomUtil.randomStringUpper(BaseConstants.UNIQUE_CODE_LEN);
// 直接新增唯一推码 新增成功就是可以用反之就是重复
int flag = uniqueCodeService.insertUniqueCode(code);
if (flag != 0) {
staffRespVO.setUniqueCode(code);
break;
}
count++;
String uniqueCode = uniqueCodeService.createUniqueCode();
if (!ObjectUtil.isNotEmpty(uniqueCode)) {
throw exception(CommonErrorCodeConstants.UNIQUE_CODE_CREATE_REPEAT);
}
staffRespVO.setUniqueCode(uniqueCode);
// 3 保存员工信息到数据库
this.save(staffRespVO);
/** 插入标签到业务标签表 */
/* 插入标签到业务标签表 */
if (ObjectUtil.isNotEmpty(staffRespVO.getLabelsArray())) {
// 1 获取所有标签信息
List<Label> labels = getLabelsByLabelName(staffRespVO.getLabelsArray());
@ -171,9 +162,9 @@ public class CompanyStaffServiceImpl extends ServiceImpl<CompanyStaffMapper, Com
@Override
@DSTransactional
public void updateStaff(CompanyStaffRespVO staffRespVO) {
/** 修改标签 */
/* 修改标签 */
if (ObjectUtil.isNotEmpty(staffRespVO.getLabelsArray())) {
/** 检查是否需要新增标签 */
/* 检查是否需要新增标签 */
// 1 获取标签
List<Label> labels = getLabelsByLabelName(staffRespVO.getLabelsArray());
List<String> oldLabelNames = labels.stream().map(item -> item.getLabelName()).collect(Collectors.toList());
@ -185,7 +176,7 @@ public class CompanyStaffServiceImpl extends ServiceImpl<CompanyStaffMapper, Com
labelService.saveBatch(newLabels);
}
/** 检查是否需要更新业务标签 */
/* 检查是否需要更新业务标签 */
// 1 获取业务标签表中旧数据
List<BusiLabel> busiLabels = getBusiLabelsByMainId(staffRespVO.getId());
// 2 检查是否需要更新数据, 如果有就更新
@ -207,7 +198,7 @@ public class CompanyStaffServiceImpl extends ServiceImpl<CompanyStaffMapper, Com
}
}
/** 修改员工表 */
/* 修改员工表 */
baseMapper.updateById(staffRespVO);
}
@ -221,19 +212,22 @@ public class CompanyStaffServiceImpl extends ServiceImpl<CompanyStaffMapper, Com
@Override
@DSTransactional
public void deleteStaff(String id) {
/** 获取删除记录详细信息 */
/* 获取删除记录详细信息 */
CompanyStaff staff = baseMapper.selectById(id);
/** 删除sys_users记录 */
/* 验证是否已交接工作 */
Boolean flag = staffChangeService.checkChangeStatus(staff.getUserId());
if (!flag) {
throw exception(CommonErrorCodeConstants.STAFF_NOT_CHANGE);
}
/* 删除sys_users记录 */
adminUserApi.deleteUser(staff.getUserId());
/** 删除业务标签表记录 */
busiLabelService.remove(new QueryWrapper<BusiLabel>().eq("main_id", staff.getId()));
/* 删除业务标签表记录 */
busiLabelService.remove(new LambdaQueryWrapper<BusiLabel>().eq(BusiLabel::getMainId, staff.getId()));
/** 删除唯一推广码表记录 */
uniqueCodeService.remove(new QueryWrapper<UniqueCode>().eq("unique_code", staff.getUniqueCode()));
/** 删除员工表记录 */
/* 删除员工表记录 */
baseMapper.deleteById(id);
}
@ -251,7 +245,7 @@ public class CompanyStaffServiceImpl extends ServiceImpl<CompanyStaffMapper, Com
// 构建员工响应对象
CompanyStaffRespVO staffRespVO = BeanUtil.toBean(staff, CompanyStaffRespVO.class);
// 查询业务标签表中属于员工的标签
List<BusiLabel> busiLabels = busiLabelService.list(new QueryWrapper<BusiLabel>().eq("main_id", staff.getId()));
List<BusiLabel> busiLabels = busiLabelService.list(new LambdaQueryWrapper<BusiLabel>().eq(BusiLabel::getMainId, staff.getId()));
// 取出标签名给员工响应对象
if (ObjectUtil.isNotEmpty(busiLabels)) {
List<String> labelsArray = busiLabels.stream().map(item -> item.getLabelName()).collect(Collectors.toList());
@ -268,7 +262,10 @@ public class CompanyStaffServiceImpl extends ServiceImpl<CompanyStaffMapper, Com
**/
@Override
public List<Label> getLabels() {
return labelService.list(new QueryWrapper<Label>().eq("system_code", BaseConstants.COMPANY_STAFF));
return labelService.list(new LambdaQueryWrapper<Label>().and(item -> {
item.eq(Label::getSystemCode, BaseConstants.COMPANY_STAFF)
.eq(Label::getType, BaseConstants.FUNC_COMPANY);
}));
}
/**
@ -292,7 +289,7 @@ public class CompanyStaffServiceImpl extends ServiceImpl<CompanyStaffMapper, Com
* @date 11:48 2024/8/8
**/
private List<BusiLabel> getBusiLabelsByMainId(String mainId) {
return busiLabelService.list(new QueryWrapper<BusiLabel>().eq("main_id", mainId));
return busiLabelService.list(new LambdaQueryWrapper<BusiLabel>().eq(BusiLabel::getMainId, mainId));
}
/**
@ -306,8 +303,8 @@ public class CompanyStaffServiceImpl extends ServiceImpl<CompanyStaffMapper, Com
return names.stream().map(item -> {
Label label = new Label();
label.setLabelName(item);
label.setType(BaseConstants.COMPANY_SING_STAFF);
label.setLabelDesc(BaseConstants.COMPANY_SING_STAFF);
label.setType(BaseConstants.FUNC_COMPANY);
label.setLabelDesc(item);
label.setLabelType(BaseConstants.LABEL_TYPE);
label.setSystemCode(BaseConstants.COMPANY_STAFF);
return label;
@ -338,17 +335,104 @@ public class CompanyStaffServiceImpl extends ServiceImpl<CompanyStaffMapper, Com
/**
* 获取当前登录用户部门下所有员工信息
*
* @author 小李
* @date 15:54 2024/8/8
**/
@Override
public List<CompanyStaff> getStaffList(){
// 获取当前登录用户的信息取出部门
LoginUser loginUser = SecurityFrameworkUtils.getLoginUser();
Long id = loginUser.getId();
AdminUserRespDTO user = adminUserApi.getUser(id);
Long deptId = user.getDeptId();
// 获取所有该部门下的员工信息
return baseMapper.selectList(new QueryWrapper<CompanyStaff>().eq("dept_id", deptId));
public List<CompanyStaff> getStaffList() {
return baseMapper.selectList(new QueryWrapper<>());
}
/**
* 重置员工登录密码
*
* @param staffRespVO 员工对象
* @author 小李
* @date 16:21 2024/8/9
**/
public void resetPassword(CompanyStaffRespVO staffRespVO) {
// 修改员工密码
adminUserApi.resetPassword(staffRespVO.getUserId(), staffRespVO.getPassword());
}
/**
* 验证工号是否重复
*
* @param workNo 输入的工号
* @author 小李
* @date 14:03 2024/8/9
**/
public Boolean checkWorkNo(String workNo) {
return staffMapper.selectCount(new LambdaQueryWrapper<CompanyStaff>().and(item -> {
item.eq(CompanyStaff::getWorkNo, workNo);
})) == 0;
}
/**
* 获取当前登录用户的详细信息
*
* @author 小李
* @date 17:27 2024/8/9
**/
private AdminUserRespDTO getLoginUser() {
Long userId = SecurityFrameworkUtils.getLoginUserId();
return adminUserApi.getUser(userId);
}
/**
* 获取当前登录用户的部门详细信息
*
* @param deptId 部门ID
* @author 小李
* @date 17:28 2024/8/9
**/
private DeptRespDTO getLoginDept(Long deptId) {
return deptApi.getDept(deptId);
}
/**
* 更新员工的工龄和司龄
*
* @author 小李
* @date 11:41 2024/8/13
**/
@Override
@DSTransactional
public void updateStaffWorkAndJoinedYears() {
LambdaQueryWrapper<CompanyStaff> queryWrapper = new LambdaQueryWrapper<>();
Page<CompanyStaff> page = new Page<>(0, BaseConstants.BATCH_SIZE);
while (true) {
// 查询一页的数据
Page<CompanyStaff> companyStaffPage = baseMapper.selectPage(page, queryWrapper);
// 对每一页数据进行操作更新
List<CompanyStaff> result = companyStaffPage.getRecords().stream().map(item -> {
// 获取当前时间工作时间入职时间
LocalDate currentDate = LocalDate.now();
LocalDate workDate = item.getWorkDate().toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
LocalDate joinedDate = item.getJoinedDate().toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
// 计算工龄
BigDecimal workYear = new BigDecimal(Period.between(workDate, currentDate).getYears());
item.setWorkYear(workYear);
// 计算司龄
BigDecimal joinedYear = new BigDecimal(Period.between(joinedDate, currentDate).getYears());
item.setJoinedYear(joinedYear);
return item;
}).collect(Collectors.toList());
// 批量更新
updateBatchById(result);
// 没有下一页了就退出
if (companyStaffPage.getRecords().isEmpty()){
break;
}
// 取一页
queryWrapper.gt(CompanyStaff::getId, page.getRecords().get(page.getRecords().size() - 1).getId());
}
}
}

View File

@ -1,5 +1,7 @@
package cn.iocoder.yudao.module.staff.service.impl;
import cn.hutool.core.util.RandomUtil;
import cn.iocoder.yudao.common.BaseConstants;
import cn.iocoder.yudao.module.staff.entity.UniqueCode;
import cn.iocoder.yudao.module.staff.mapper.UniqueCodeMapper;
import cn.iocoder.yudao.module.staff.service.UniqueCodeService;
@ -15,16 +17,23 @@ import org.springframework.stereotype.Service;
public class UniqueCodeServiceImpl extends ServiceImpl<UniqueCodeMapper, UniqueCode> implements UniqueCodeService {
/**
* 检查唯一推广码是否存在于数据库
* 生成唯一推广码
* @author 小李
* @date 9:59 2024/8/8
* @param uniqueCode
*
* @return*/
* @return 可使用推广码
**/
@Override
public int insertUniqueCode(String uniqueCode){
UniqueCode code = new UniqueCode();
code.setUniqueCode(uniqueCode);
return baseMapper.insert(code);
public String createUniqueCode(){
int count = 0;
while (true){
if (count >= BaseConstants.UNIQUE_CODE_LEN) return null;
String result = RandomUtil.randomStringUpper(BaseConstants.UNIQUE_CODE_LEN);
UniqueCode uniqueCode = new UniqueCode();
uniqueCode.setUniqueCode(result);
if (baseMapper.insert(uniqueCode) > 0){
return result;
}
count++;
}
}
}

View File

@ -1,7 +1,14 @@
package cn.iocoder.yudao.module.staff.vo;
import cn.iocoder.yudao.module.staff.entity.CompanyStaffChange;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import java.util.Date;
import java.util.List;
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
/**
* 企业管理-员工交接记录VO
@ -10,4 +17,26 @@ import lombok.Data;
**/
@Data
public class CompanyStaffChangeReqVO extends CompanyStaffChange {
/** 搜索用员工姓名 */
private String name;
/** 搜索用员工工号 */
private String workNo;
/** 搜索用员工电话 */
private String tel;
@Schema(description = "工作交接查询范围")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private Date[] changeTimeArray;
/** 搜索用交接类型 */
private String changeType;
/** 搜索用oldUserIds */
private List<Long> oldUserIds;
/** 搜索用newUserIds */
private List<Long> newUserIds;
}

View File

@ -0,0 +1,30 @@
package cn.iocoder.yudao.scheduled;
import cn.iocoder.yudao.framework.quartz.core.handler.JobHandler;
import cn.iocoder.yudao.framework.tenant.core.job.TenantJob;
import cn.iocoder.yudao.module.staff.service.CompanyStaffService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
/**
* 定时更新员工的工龄和司龄
* @author 小李
* @date 14:00 2024/8/13
**/
@Component
@TenantJob
@Slf4j
public class UpdateCompanyStaffWorkAndJoinedYearsJob implements JobHandler {
@Resource
private CompanyStaffService staffService;
@Override
public String execute(String param) throws Exception {
// 执行更新
staffService.updateStaffWorkAndJoinedYears();
return null;
}
}

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.iocoder.yudao.module.property.dal.mysql.property.PropertyPosMapper">
<mapper namespace="cn.iocoder.yudao.module.property.mapper.PropertyPosMapper">
<!--
一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
@ -8,5 +8,28 @@
代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
文档可见https://www.iocoder.cn/MyBatis/x-plugins/
-->
<sql id="Base_SQL">
cpp.id,cpp.corp_id,cpp.dept_id,cpp.pos_name,cpp.address,
cpp.area,cpp.deposit_type,cpp.tenant_id,cpp.deleted,
cpp.creator,cpp.create_time,cpp.updater,cpp.update_time
</sql>
<select id="selectListPage" resultType="cn.iocoder.yudao.module.property.vo.PropertyPosRespVO">
select
<include refid="Base_SQL" />,bc.corp_name
FROM company_property_pos cpp
LEFT JOIN base_company bc ON cpp.corp_id = bc.id
<where>
cpp.deleted = 0
<if test="map.posName != null and map.posName != ''">
AND cpp.pos_name like CONCAT('%', #{map.posName}, '%')
</if>
<if test="map.address != null and map.address != ''">
AND cpp.address like CONCAT('%', #{map.address}, '%')
</if>
<if test="map.depositType != null and map.depositType != ''">
AND cpp.deposit_type like CONCAT('%', #{map.depositType}, '%')
</if>
</where>
ORDER BY cpp.create_time DESC
</select>
</mapper>

View File

@ -3,4 +3,116 @@
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.iocoder.yudao.module.staff.mapper.CompanyStaffChangeMapper">
<resultMap id="BaseResultMap" type="cn.iocoder.yudao.module.staff.vo.CompanyStaffChangeRespVO">
<id property="id" column="csc_id" jdbcType="VARCHAR"/>
<result property="oldUserId" column="csc_old_user_id" jdbcType="BIGINT"/>
<result property="newUserId" column="csc_new_user_id" jdbcType="BIGINT"/>
<result property="changeTime" column="csc_change_time" jdbcType="TIMESTAMP"/>
<result property="fileUrls" column="csc_file_urls" jdbcType="VARCHAR"/>
<result property="remark" column="csc_remark" jdbcType="VARCHAR"/>
<association property="oldStaff" javaType="cn.iocoder.yudao.module.staff.entity.CompanyStaff">
<id property="id" column="cs_old_id" jdbcType="VARCHAR"/>
<result property="workNo" column="cs_old_work_no" jdbcType="VARCHAR"/>
<result property="name" column="cs_old_name" jdbcType="VARCHAR"/>
<result property="tel" column="cs_old_tel" jdbcType="VARCHAR"/>
<result property="sex" column="cs_old_sex" jdbcType="VARCHAR"/>
<result property="address" column="cs_old_address" jdbcType="VARCHAR"/>
<result property="workDate" column="cs_old_work_date" jdbcType="DATE"/>
<result property="workYear" column="cs_old_work_year" jdbcType="DECIMAL"/>
<result property="joinedDate" column="cs_old_joined_date" jdbcType="DATE"/>
<result property="joinedYear" column="cs_old_joined_year" jdbcType="DECIMAL"/>
<result property="education" column="cs_old_education" jdbcType="VARCHAR"/>
<result property="content" column="cs_old_content" jdbcType="VARCHAR"/>
<result property="uniqueCode" column="cs_old_unique_code" jdbcType="VARCHAR"/>
<result property="fileUrls" column="cs_old_file_urls" jdbcType="VARCHAR"/>
</association>
<association property="newStaff" javaType="cn.iocoder.yudao.module.staff.entity.CompanyStaff">
<id property="id" column="cs_new_id" jdbcType="VARCHAR"/>
<result property="workNo" column="cs_new_work_no" jdbcType="VARCHAR"/>
<result property="name" column="cs_new_name" jdbcType="VARCHAR"/>
<result property="tel" column="cs_new_tel" jdbcType="VARCHAR"/>
<result property="sex" column="cs_new_sex" jdbcType="VARCHAR"/>
<result property="address" column="cs_new_address" jdbcType="VARCHAR"/>
<result property="workDate" column="cs_new_work_date" jdbcType="DATE"/>
<result property="workYear" column="cs_new_work_year" jdbcType="DECIMAL"/>
<result property="joinedDate" column="cs_new_joined_date" jdbcType="DATE"/>
<result property="joinedYear" column="cs_new_joined_year" jdbcType="DECIMAL"/>
<result property="education" column="cs_new_education" jdbcType="VARCHAR"/>
<result property="content" column="cs_new_content" jdbcType="VARCHAR"/>
<result property="uniqueCode" column="cs_new_unique_code" jdbcType="VARCHAR"/>
<result property="fileUrls" column="cs_new_file_urls" jdbcType="VARCHAR"/>
</association>
</resultMap>
<select id="getStaffChangePage" resultMap="BaseResultMap">
SELECT
csc.id as csc_id,
csc.old_user_id as csc_old_user_id,
csc.new_user_id as csc_new_user_id,
csc.change_time as csc_change_time,
csc.file_urls as csc_file_urls,
csc.remark as csc_remark,
cs_old.id as cs_old_id,
cs_old.work_no as cs_old_work_no,
cs_old.name as cs_old_name,
cs_old.tel as cs_old_tel,
cs_old.sex as cs_old_sex,
cs_old.address as cs_old_address,
cs_old.work_date as cs_old_work_date,
cs_old.work_year as cs_old_work_year,
cs_old.joined_date as cs_old_joined_date,
cs_old.joined_year as cs_old_joined_year,
cs_old.education as cs_old_education,
cs_old.content as cs_old_content,
cs_old.unique_code as cs_old_unique_code,
cs_old.file_urls as cs_old_file_urls,
cs_new.id as cs_new_id,
cs_new.work_no as cs_new_work_no,
cs_new.name as cs_new_name,
cs_new.tel as cs_new_tel,
cs_new.sex as cs_new_sex,
cs_new.address as cs_new_address,
cs_new.work_date as cs_new_work_date,
cs_new.work_year as cs_new_work_year,
cs_new.joined_date as cs_new_joined_date,
cs_new.joined_year as cs_new_joined_year,
cs_new.education as cs_new_education,
cs_new.content as cs_new_content,
cs_new.unique_code as cs_new_unique_code,
cs_new.file_urls as cs_new_file_urls
FROM company_staff_change csc
INNER JOIN company_staff cs_old ON csc.old_user_id = cs_old.user_id
INNER JOIN company_staff cs_new ON csc.new_user_id = cs_new.user_id
where csc.deleted = '0'
<if test="map.name != null and map.name != ''">
and (cs_old.name like concat('%', #{map.name}, '%') or cs_new.name like concat('%', #{map.name}, '%'))
</if>
<if test="map.workNo != null and map.workNo != ''">
and (cs_old.work_no like concat('%', #{map.workNo}, '%') or cs_new.work_no like concat('%', #{map.workNo},
'%'))
</if>
<if test="map.tel != null and map.tel != ''">
and (cs_old.tel like concat('%', #{map.tel}, '%') or cs_new.tel like concat('%', #{map.tel}, '%'))
</if>
<if test="map.changeTimeArray != null and map.changeTimeArray.length > 0">
and (csc.change_time between #{map.changeTimeArray[0]} and #{map.changeTimeArray[1]})
</if>
<if test="map.oldUserIds != null and map.oldUserIds.size > 0">
and csc.old_user_id in
<foreach collection="map.oldUserIds" item="userId" open="(" separator="," close=")">
#{userId}
</foreach>
</if>
<if test="map.newUserIds != null and map.newUserIds.size > 0">
and csc.new_user_id in
<foreach collection="map.newUserIds" item="userId" open="(" separator="," close=")">
#{userId}
</foreach>
</if>
order by csc.create_time desc
</select>
</mapper>

View File

@ -31,19 +31,35 @@
</resultMap>
<sql id="Base_SQL">
select
id,corp_id,user_id,
dept_id,work_no,name,
tel,sex,address,
work_date,work_year,joined_date,
joined_year,education,content,
unique_code,file_urls,tenant_id,
deleted,creator,create_time,
updater,update_time
from company_staff cs where deleted = '0'
select id,
corp_id,
user_id,
dept_id,
work_no,
name,
tel,
sex,
address,
work_date,
work_year,
joined_date,
joined_year,
education,
content,
unique_code,
file_urls,
tenant_id,
deleted,
creator,
create_time,
updater,
update_time
from company_staff cs
where deleted = '0'
</sql>
<select id="selectListPage" resultMap="BaseResultMap">
<include refid="Base_SQL" />
<include refid="Base_SQL"/>
<if test="map.name != null and map.name != ''">
and cs.name like concat('%', #{map.name}, '%')
</if>
@ -77,5 +93,6 @@
<if test="map.joinedDateArray.length > 0">
and cs.joined_date between #{map.joinedDateArray[0]} and #{map.joinedDateArray[1]}
</if>
order by create_time desc
</select>
</mapper>

View File

@ -10,4 +10,8 @@ public interface CommonStr {
Long TENANT_ID=1L;
/** 默认超级管理员id --1 */
Long SUPER_ADMIN_ID=1L;
/** 用户类型-员工 --1 */
String USER_TYPE_STAFF="01";
/** 用户类型-客户 --1 */
String USER_TYPE_CUS="02";
}

View File

@ -8,7 +8,7 @@ import java.lang.annotation.Target;
/**
* 多租户 Job 注解
*/
@Target({ElementType.METHOD})
@Target({ElementType.TYPE, ElementType.METHOD})
@Retention(RetentionPolicy.RUNTIME)
public @interface TenantJob {
}

View File

@ -15,6 +15,10 @@ public class DeptRespDTO {
* 部门编号
*/
private Long id;
/**
* 所属企业ID
*/
private String corpId;
/**
* 部门名称
*/

View File

@ -112,4 +112,13 @@ public interface AdminUserApi {
*/
void validateUserList(Collection<Long> ids);
/**
* 重置密码
* @author 小李
* @date 16:39 2024/8/9
* @param id 用户ID
* @param password 新密码
**/
void resetPassword(Long id, String password);
}

View File

@ -21,6 +21,11 @@ public class AdminUserRespDTO {
* 用户昵称
*/
private String nickname;
/**
* 用户类型
*/
private String userType;
/**
* 帐号状态
*

View File

@ -16,6 +16,10 @@ public class UserDTO {
* 用户昵称
*/
private String nickname;
/**
* 用户类型
*/
private String userType;
/**
* 备注
*/
@ -34,4 +38,9 @@ public class UserDTO {
*/
private String password;
/**
* 用户性别
**/
private String sex;
}

View File

@ -126,4 +126,16 @@ public class AdminUserApiImpl implements AdminUserApi {
userService.validateUserList(ids);
}
/**
* 重置密码
* @author 小李
* @date 16:39 2024/8/9
* @param id 用户ID
* @param password 新密码
**/
@Override
public void resetPassword(Long id, String password){
userService.updateUserPassword(id, password);
}
}

View File

@ -24,7 +24,7 @@ public class AuthLoginReqVO {
@Schema(description = "账号", requiredMode = Schema.RequiredMode.REQUIRED, example = "yudaoyuanma")
@NotEmpty(message = "登录账号不能为空")
@Length(min = 4, max = 16, message = "账号长度为 4-16 位")
@Pattern(regexp = "^[A-Za-z0-9]+$", message = "账号格式为数字以及字母")
// @Pattern(regexp = "^[A-Za-z0-9]+$", message = "账号格式为数字以及字母")
private String username;
@Schema(description = "密码", requiredMode = Schema.RequiredMode.REQUIRED, example = "buzhidao")

View File

@ -12,6 +12,9 @@ public class DeptRespVO {
@Schema(description = "部门编号", example = "1024")
private Long id;
@Schema(description = "所属企业ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋道")
private String corpId;
@Schema(description = "部门名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋道")
private String name;

View File

@ -17,6 +17,9 @@ public class DeptSaveReqVO {
@Schema(description = "部门编号", example = "1024")
private Long id;
@Schema(description = "所属企业 ID", example = "1024")
private String corpId;
@Schema(description = "部门名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋道")
@NotBlank(message = "部门名称不能为空")
@Size(max = 30, message = "部门名称长度不能超过 30 个字符")

View File

@ -28,6 +28,9 @@ public class UserRespVO{
@ExcelProperty("用户昵称")
private String nickname;
@Schema(description = "用户类型", example = "芋艿")
private String userType;
@Schema(description = "备注", example = "我是一个用户")
private String remark;

View File

@ -33,6 +33,10 @@ public class UserSaveReqVO {
@DiffLogField(name = "用户昵称")
private String nickname;
@Schema(description = "用户类型", example = "芋艿")
@DiffLogField(name = "用户类型")
private String userType;
@Schema(description = "备注", example = "我是一个用户")
@DiffLogField(name = "备注")
private String remark;

View File

@ -28,6 +28,10 @@ public class DeptDO extends TenantBaseDO {
*/
@TableId
private Long id;
/**
* 所属企业ID可能为null
*/
private String corpId;
/**
* 部门名称
*/

View File

@ -43,6 +43,10 @@ public class AdminUserDO extends TenantBaseDO {
* 因为目前使用 {@link BCryptPasswordEncoder} 加密器所以无需自己处理 salt
*/
private String password;
/**
* 用户类型数据字典system_user_type01 员工 | 02 客户
*/
private String userType;
/**
* 用户昵称
*/

View File

@ -13,6 +13,7 @@ import cn.iocoder.yudao.module.system.dal.mysql.dept.DeptMapper;
import cn.iocoder.yudao.module.system.dal.redis.RedisKeyConstants;
import com.google.common.annotations.VisibleForTesting;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;
@ -49,7 +50,13 @@ public class DeptServiceImpl implements DeptService {
createReqVO.setAncestors(validateParentDept(null, createReqVO.getParentId()));
// 校验部门名的唯一性
validateDeptNameUnique(null, createReqVO.getParentId(), createReqVO.getName());
if(StringUtils.isEmpty(createReqVO.getCorpId()) && !DeptDO.PARENT_ID_ROOT.equals(createReqVO.getParentId())){
//没有传企业ID且不是最顶级部门自动取上一节点的企业ID如果有的话
DeptDO parentDept = this.getDept(createReqVO.getParentId());
if(StringUtils.isNotEmpty(parentDept.getCorpId())){
createReqVO.setCorpId(parentDept.getCorpId());
}
}
// 插入部门
DeptDO dept = BeanUtils.toBean(createReqVO, DeptDO.class);
deptMapper.insert(dept);

View File

@ -32,6 +32,7 @@ import com.mzt.logapi.context.LogRecordContext;
import com.mzt.logapi.service.impl.DiffParseFunction;
import com.mzt.logapi.starter.annotation.LogRecord;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.context.annotation.Lazy;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.stereotype.Service;
@ -42,6 +43,7 @@ import java.io.InputStream;
import java.time.LocalDateTime;
import java.util.*;
import static cn.iocoder.yudao.framework.common.config.CommonStr.USER_TYPE_STAFF;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList;
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet;
@ -101,6 +103,10 @@ public class AdminUserServiceImpl implements AdminUserService {
AdminUserDO user = BeanUtils.toBean(createReqVO, AdminUserDO.class);
user.setStatus(CommonStatusEnum.ENABLE.getStatus()); // 默认开启
user.setPassword(encodePassword(createReqVO.getPassword())); // 加密密码
if(StringUtils.isEmpty(user.getUserType())){
//没传用户类型默认员工
user.setUserType(USER_TYPE_STAFF);
}
userMapper.insert(user);
// 2.2 插入关联岗位
if (CollectionUtil.isNotEmpty(user.getPostIds())) {

View File

@ -2,12 +2,12 @@ server:
port: 48080
--- #################### 数据库相关配置 ####################
# exclude中少的内容 - org.springframework.boot.autoconfigure.quartz.QuartzAutoConfiguration # 默认 local 环境,不开启 Quartz 的自动配置
spring:
# 数据源配置项
autoconfigure:
exclude:
- com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure # 排除 Druid 的自动配置,使用 dynamic-datasource-spring-boot-starter 配置多数据源
- org.springframework.boot.autoconfigure.quartz.QuartzAutoConfiguration # 默认 local 环境,不开启 Quartz 的自动配置
- de.codecentric.boot.admin.server.config.AdminServerAutoConfiguration # 禁用 Spring Boot Admin 的 Server 的自动配置
- de.codecentric.boot.admin.server.ui.config.AdminServerUiAutoConfiguration # 禁用 Spring Boot Admin 的 Server UI 的自动配置
- de.codecentric.boot.admin.client.config.SpringBootAdminClientAutoConfiguration # 禁用 Spring Boot Admin 的 Client 的自动配置