feat: licensed的客户取项目的客户
This commit is contained in:
@@ -33,10 +33,6 @@ public class LicenseDO extends BaseDO {
|
||||
*/
|
||||
@TableId
|
||||
private Long id;
|
||||
/**
|
||||
* 客户ID
|
||||
*/
|
||||
private Long customerId;
|
||||
/**
|
||||
* 项目ID
|
||||
*/
|
||||
|
||||
@@ -37,10 +37,6 @@ public class LicenseHistoryDO extends BaseDO {
|
||||
* License ID
|
||||
*/
|
||||
private Long licenseId;
|
||||
/**
|
||||
* 客户ID
|
||||
*/
|
||||
private Long customerId;
|
||||
/**
|
||||
* 项目ID
|
||||
*/
|
||||
|
||||
@@ -1,11 +1,15 @@
|
||||
package org.agt.module.license.dal.mysql.license;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import org.agt.framework.common.pojo.PageResult;
|
||||
import org.agt.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import org.agt.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import org.agt.framework.mybatis.core.query.MPJLambdaWrapperX;
|
||||
import org.agt.module.license.controller.admin.license.vo.LicensePageReqVO;
|
||||
import org.agt.module.license.controller.admin.license.vo.LicenseRespVO;
|
||||
import org.agt.module.license.dal.dataobject.license.LicenseDO;
|
||||
import org.agt.module.license.dal.dataobject.project.ProjectDO;
|
||||
import org.agt.module.license.enums.LicenseStatusEnum;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
@@ -23,7 +27,6 @@ public interface LicenseMapper extends BaseMapperX<LicenseDO> {
|
||||
|
||||
default PageResult<LicenseDO> selectPage(LicensePageReqVO reqVO) {
|
||||
return selectPage(reqVO, new LambdaQueryWrapperX<LicenseDO>()
|
||||
.eqIfPresent(LicenseDO::getCustomerId, reqVO.getCustomerId())
|
||||
.eqIfPresent(LicenseDO::getProjectId, reqVO.getProjectId())
|
||||
.likeIfPresent(LicenseDO::getSerialNo, reqVO.getSerialNo())
|
||||
.betweenIfPresent(LicenseDO::getExpiryDate, reqVO.getExpiryDate())
|
||||
@@ -37,8 +40,12 @@ public interface LicenseMapper extends BaseMapperX<LicenseDO> {
|
||||
.orderByDesc(LicenseDO::getApplicationTime));
|
||||
}
|
||||
|
||||
default List<LicenseDO> selectListByExpiryDate() {
|
||||
return selectList(new LambdaQueryWrapperX<LicenseDO>()
|
||||
default List<LicenseRespVO> selectListByExpiryDate() {
|
||||
|
||||
return selectJoinList(LicenseRespVO.class, new MPJLambdaWrapperX<LicenseDO>()
|
||||
.selectAll(LicenseDO.class)
|
||||
.leftJoin(ProjectDO.class, ProjectDO::getId, LicenseDO::getProjectId)
|
||||
.selectAs(ProjectDO::getCustomerId, LicenseRespVO::getCustomerId)
|
||||
.gt(LicenseDO::getExpiryDate, LocalDateTime.now())
|
||||
.le(LicenseDO::getExpiryDate, LocalDateTime.now().plusDays(7))
|
||||
.eq(LicenseDO::getStatus, LicenseStatusEnum.COMPLETED.getCode())
|
||||
@@ -50,4 +57,6 @@ public interface LicenseMapper extends BaseMapperX<LicenseDO> {
|
||||
}
|
||||
|
||||
LicenseDO getBySnAndProjectAndCustomer(@Param("serialNo") String serialNo, @Param("projectName") String projectName, @Param("customerName") String customerName);
|
||||
|
||||
IPage<LicenseRespVO> queryPage(IPage<?> page, @Param("query") LicensePageReqVO reqVO);
|
||||
}
|
||||
@@ -5,7 +5,9 @@ import cn.hutool.core.io.FileUtil;
|
||||
import cn.hutool.core.io.resource.ResourceUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.core.util.ZipUtil;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import jakarta.annotation.Resource;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.agt.framework.common.pojo.PageResult;
|
||||
@@ -168,8 +170,8 @@ public class LicenseServiceImpl implements LicenseService {
|
||||
Long userId = updateReqVO.getApprover();
|
||||
String templateCode = "license_apply"; // 邮件模版,记得在【邮箱管理】中配置噢
|
||||
Map<String, Object> templateParams = new HashMap<>();
|
||||
CustomerDO customerDO = customerMapper.selectById(updateReqVO.getCustomerId());
|
||||
ProjectDO projectDO = projectMapper.selectById(updateReqVO.getProjectId());
|
||||
CustomerDO customerDO = customerMapper.selectById(projectDO.getCustomerId());
|
||||
templateParams.put("customer", customerDO.getName());
|
||||
templateParams.put("project", projectDO.getName());
|
||||
templateParams.put("sn", updateReqVO.getSerialNo());
|
||||
@@ -469,7 +471,11 @@ public class LicenseServiceImpl implements LicenseService {
|
||||
@Override
|
||||
public LicenseRespVO getLicense(Long id) {
|
||||
LicenseDO licenseDO = licenseMapper.selectById(id);
|
||||
ProjectDO projectDO = projectMapper.selectById(licenseDO.getProjectId());
|
||||
LicenseRespVO licenseRespVO = BeanUtils.toBean(licenseDO, LicenseRespVO.class);
|
||||
if (projectDO != null) {
|
||||
licenseRespVO.setCustomerId(projectDO.getCustomerId());
|
||||
}
|
||||
fillLicenseRespVO(licenseRespVO);
|
||||
return licenseRespVO;
|
||||
}
|
||||
@@ -576,8 +582,9 @@ public class LicenseServiceImpl implements LicenseService {
|
||||
|
||||
@Override
|
||||
public PageResult<LicenseRespVO> getLicensePage(LicensePageReqVO pageReqVO) {
|
||||
PageResult<LicenseDO> pageResult = licenseMapper.selectPage(pageReqVO);
|
||||
PageResult<LicenseRespVO> voPageResult = BeanUtils.toBean(pageResult, LicenseRespVO.class);
|
||||
IPage<LicenseRespVO> page = licenseMapper.queryPage(new Page<>(pageReqVO.getPageNo(), pageReqVO.getPageSize()), pageReqVO);
|
||||
|
||||
PageResult<LicenseRespVO> voPageResult = BeanUtils.toBean(new PageResult<>(page.getRecords(), page.getTotal()), LicenseRespVO.class);
|
||||
for (LicenseRespVO licenseRespVO : voPageResult.getList()) {
|
||||
fillLicenseRespVO(licenseRespVO);
|
||||
}
|
||||
@@ -586,8 +593,7 @@ public class LicenseServiceImpl implements LicenseService {
|
||||
|
||||
@Override
|
||||
public List<LicenseRespVO> getLicenseByExpiryDate() {
|
||||
List<LicenseDO> licenseDOS = licenseMapper.selectListByExpiryDate();
|
||||
return BeanUtils.toBean(licenseDOS, LicenseRespVO.class);
|
||||
return licenseMapper.selectListByExpiryDate();
|
||||
}
|
||||
|
||||
|
||||
@@ -616,6 +622,10 @@ public class LicenseServiceImpl implements LicenseService {
|
||||
List<LicenseRespVO> allLicenses = new ArrayList<>();
|
||||
if (LicenseStatusEnum.COMPLETED.getCode().equals(licenseDO.getStatus())) {
|
||||
LicenseRespVO license = BeanUtils.toBean(licenseDO, LicenseRespVO.class);
|
||||
ProjectDO projectDO = projectMapper.selectById(licenseDO.getProjectId());
|
||||
if (projectDO != null) {
|
||||
license.setCustomerId(projectDO.getCustomerId());
|
||||
}
|
||||
List<LicenseDetailDO> licenseDetailDOS = licenseDetailMapper.selectList(Wrappers.<LicenseDetailDO>lambdaQuery().eq(LicenseDetailDO::getLicenseId, license.getId()));
|
||||
List<LicenseDetailVO> details = BeanUtils.toBean(licenseDetailDOS, LicenseDetailVO.class);
|
||||
fillDetail(details, license);
|
||||
@@ -625,6 +635,10 @@ public class LicenseServiceImpl implements LicenseService {
|
||||
.eq(LicenseHistoryDO::getLicenseId, id).orderByDesc(LicenseHistoryDO::getApplicationTime));
|
||||
List<LicenseRespVO> voList = BeanUtils.toBean(historyDOList, LicenseRespVO.class);
|
||||
for (LicenseRespVO licenseRespVO : voList) {
|
||||
ProjectDO projectDO = projectMapper.selectById(licenseRespVO.getProjectId());
|
||||
if (projectDO != null) {
|
||||
licenseRespVO.setCustomerId(projectDO.getCustomerId());
|
||||
}
|
||||
fillLicenseHistoryRespVO(licenseRespVO);
|
||||
}
|
||||
allLicenses.addAll(voList);
|
||||
@@ -722,6 +736,7 @@ public class LicenseServiceImpl implements LicenseService {
|
||||
projectId = projectDO.getId();
|
||||
projectDO = BeanUtils.toBean(importVO, ProjectDO.class);
|
||||
projectDO.setId(projectId);
|
||||
projectDO.setCustomerId(customerId);
|
||||
projectDO.setBusinessOwner(customerMapper.getUserByName(importVO.getBusinessOwnerName()));
|
||||
projectDO.setTechnicalOwnerA(customerMapper.getUserByName(importVO.getTechnicalOwnerAName()));
|
||||
projectDO.setTechnicalOwnerB(customerMapper.getUserByName(importVO.getTechnicalOwnerBName()));
|
||||
@@ -732,7 +747,6 @@ public class LicenseServiceImpl implements LicenseService {
|
||||
}
|
||||
|
||||
LicenseDO licenseDO = new LicenseDO();
|
||||
licenseDO.setCustomerId(customerId);
|
||||
licenseDO.setProjectId(projectId);
|
||||
licenseDO.setSerialNo(serialNo);
|
||||
licenseDO.setStatus(LicenseStatusEnum.COMPLETED.getCode());
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
crm_license_server l
|
||||
LEFT JOIN crm_project p ON l.project_id = p.id
|
||||
AND p.deleted = 0
|
||||
LEFT JOIN crm_customer c ON l.customer_id = c.id
|
||||
LEFT JOIN crm_customer c ON p.customer_id = c.id
|
||||
AND c.deleted = 0
|
||||
WHERE
|
||||
l.deleted = 0
|
||||
@@ -25,4 +25,74 @@
|
||||
limit 1
|
||||
</select>
|
||||
|
||||
|
||||
<select id="queryPage" resultType="org.agt.module.license.controller.admin.license.vo.LicenseRespVO">
|
||||
SELECT
|
||||
l.id,
|
||||
l.project_id,
|
||||
l.serial_no,
|
||||
l.expiry_date,
|
||||
l.ran_number,
|
||||
l.user_number,
|
||||
l.file_url,
|
||||
l.applicant,
|
||||
l.application_time,
|
||||
l.license_admin,
|
||||
l.approver,
|
||||
l.approve_time,
|
||||
l.`status`,
|
||||
l.remark,
|
||||
l.data_type,
|
||||
l.creator,
|
||||
l.create_time,
|
||||
l.updater,
|
||||
l.update_time,
|
||||
l.deleted,
|
||||
l.tenant_id,
|
||||
p.customer_id
|
||||
FROM
|
||||
crm_license_server l
|
||||
LEFT JOIN crm_project p ON l.project_id = p.id
|
||||
AND p.deleted = 0
|
||||
WHERE
|
||||
l.deleted = 0
|
||||
<if test="query.customerId != null">
|
||||
AND p.customer_id = #{query.customerId}
|
||||
</if>
|
||||
<if test="query.projectId != null">
|
||||
AND l.project_id = #{query.projectId}
|
||||
</if>
|
||||
<if test="query.serialNo != null and query.serialNo != ''">
|
||||
AND l.serial_no LIKE CONCAT('%',#{query.serialNo},'%')
|
||||
</if>
|
||||
<if test="query.expiryDate != null and query.expiryDate.length > 1">
|
||||
AND l.expiry_date BETWEEN #{query.expiryDate[0]} AND #{query.expiryDate[1]}
|
||||
</if>
|
||||
<if test="query.userNumber != null">
|
||||
AND l.user_number = #{query.userNumber}
|
||||
</if>
|
||||
<if test="query.ranNumber != null">
|
||||
AND l.ran_number = #{query.ranNumber}
|
||||
</if>
|
||||
<if test="query.applicant != null">
|
||||
AND l.applicant = #{query.applicant}
|
||||
</if>
|
||||
<if test="query.approver != null">
|
||||
AND l.approver = #{query.approver}
|
||||
</if>
|
||||
<if test="query.status != null">
|
||||
AND l.status = #{query.status}
|
||||
</if>
|
||||
<if test="query.remark != null and query.remark != ''">
|
||||
AND l.remark LIKE CONCAT('%',#{query.remark},'%')
|
||||
</if>
|
||||
<if test="query.applicationTime != null and query.applicationTime.length > 1">
|
||||
AND l.application_time BETWEEN #{query.applicationTime[0]} AND #{query.applicationTime[1]}
|
||||
</if>
|
||||
<if test="query.createTime != null and query.createTime.length > 1">
|
||||
AND l.create_time BETWEEN #{query.createTime[0]} AND #{query.createTime[1]}
|
||||
</if>
|
||||
ORDER BY
|
||||
l.application_time DESC
|
||||
</select>
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user