租赁需求大厅

This commit is contained in:
mashuai 2024-11-27 17:29:15 +08:00
parent f52fae9613
commit 0e344682ec
10 changed files with 1216 additions and 0 deletions

View File

@ -13,6 +13,7 @@ public enum HttpCodeEnum {
//失败
FAIL(400, "操作失败,请联系管理员"),
// 登录
LEASE_ORDER_RECEIVED_NOT_DELETE(1002, "已接单状态,不可删除"),
NEED_LOGIN(401, "需要登录后操作"),
TO_PARAM_NULL(1007, "参数为空"),
NO_OPERATOR_AUTH(403, "无权限操作"),

View File

@ -0,0 +1,125 @@
package com.bonus.material.lease.controller;
import cn.hutool.core.convert.Convert;
import com.bonus.common.biz.config.ListPagingUtil;
import com.bonus.common.core.web.controller.BaseController;
import com.bonus.common.core.web.domain.AjaxResult;
import com.bonus.material.lease.domain.MaLease;
import com.bonus.material.lease.domain.MaLeaseDto;
import com.bonus.material.lease.domain.MaLeaseInfo;
import com.bonus.material.lease.domain.vo.MaLeaseVo;
import com.bonus.material.lease.service.MaLeaseInfoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.List;
/**
* @Author ma_sh
* @create 2024/11/26 10:40
*/
@Api(value = "租赁需求大厅控制层")
@RestController
@RequestMapping("/ma-lease")
public class MaLeaseInfoController extends BaseController {
@Resource
private MaLeaseInfoService leaseInfoService;
/**
* 查询租赁需求列表(后台)
* @param dto
* @return
*/
@ApiOperation(value = "查询租赁需求列表")
@GetMapping("/list")
public AjaxResult list(MaLeaseDto dto) {
startPage();
List<MaLeaseVo> list = leaseInfoService.list(dto);
return AjaxResult.success(getDataTable(list));
}
/**
* 查询租赁需求列表首页
* @param maLease
* @return
*/
@ApiOperation(value = "查询租赁需求列表首页")
@PostMapping("/leaseList")
public AjaxResult leaseList(@RequestBody MaLease maLease) {
List<MaLeaseVo> list = leaseInfoService.leaseList(maLease);
Integer pageIndex = Convert.toInt(maLease.getPageNum(), 1);
Integer pageSize = Convert.toInt(maLease.getPageSize(), 10);
return AjaxResult.success(ListPagingUtil.paging(pageIndex, pageSize, list));
}
/**
* 查询出租方需求列表
* @param dto
* @return
*/
@ApiOperation(value = "查询出租方需求列表")
@GetMapping("/rentList")
public AjaxResult rentList(MaLeaseDto dto) {
startPage();
List<MaLeaseVo> list = leaseInfoService.rentList(dto);
return AjaxResult.success(getDataTable(list));
}
/**
* 发布租赁需求
* @param maLeaseInfo
* @return
*/
@ApiOperation(value = "发布租赁需求")
@PostMapping("/add")
public AjaxResult add(@RequestBody MaLeaseInfo maLeaseInfo) {
return leaseInfoService.add(maLeaseInfo);
}
/**
* 查询单个租赁需求详情
* @param maLeaseInfo
* @return
*/
@ApiOperation(value = "查询单个租赁需求详情")
@GetMapping("/getById")
public AjaxResult getById(MaLeaseInfo maLeaseInfo) {
return leaseInfoService.getById(maLeaseInfo);
}
/**
* 修改租赁需求
* @param maLeaseInfo
* @return
*/
@ApiOperation(value = "修改租赁需求")
@PostMapping("/edit")
public AjaxResult edit(@RequestBody MaLeaseInfo maLeaseInfo) {
return leaseInfoService.edit(maLeaseInfo);
}
/**
* 出租方立即接单
* @param maLeaseInfo
* @return
*/
@ApiOperation(value = "出租方立即接单")
@PostMapping("/accept")
public AjaxResult accept(@RequestBody MaLeaseInfo maLeaseInfo) {
return leaseInfoService.accept(maLeaseInfo);
}
/**
* 删除租赁需求
* @param maLeaseInfo
* @return
*/
@ApiOperation(value = "删除租赁需求")
@PostMapping("/deleteById")
public AjaxResult deleteById(@RequestBody MaLeaseInfo maLeaseInfo) {
return leaseInfoService.deleteById(maLeaseInfo);
}
}

View File

@ -0,0 +1,57 @@
package com.bonus.material.lease.domain;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* @Author ma_sh
* @create 2024/11/27 16:02
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
public class MaLease {
private Integer pageNum;
private Integer pageSize;
@ApiModelProperty("类型id")
private String typeId;
@ApiModelProperty("层级")
private String level;
@ApiModelProperty("企业id")
private String companyId;
/**
* 预估租期
*/
@ApiModelProperty("预估租期")
private Integer leaseDay;
/**
* 预估租赁装备数量
*/
@ApiModelProperty("预估数量")
private Integer leaseNum;
/**
* 需求发布时间
*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private String startTime;
/**
* 需求截止日期(年月日)
*/
@JsonFormat(pattern = "yyyy-MM-dd")
private String endTime;
@ApiModelProperty("关键字")
private String keyWord;
}

View File

@ -0,0 +1,59 @@
package com.bonus.material.lease.domain;
import com.bonus.common.core.web.domain.BaseEntity;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* @Author ma_sh
* @create 2024/11/26 17:15
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
public class MaLeaseDto extends BaseEntity {
/**
* 需求名称
*/
private String leaseName;
/**
* 需求编号
*/
private String leaseCode;
/**
* 需求状态
*/
private Integer leaseStatus;
/**
* 需求发布开始时间
*/
@JsonFormat(pattern = "yyyy-MM-dd")
private String publishStartTime;
/**
* 需求发布结束时间
*/
@JsonFormat(pattern = "yyyy-MM-dd")
private String publishEndTime;
/**
* 需求截止开始时间
*/
@JsonFormat(pattern = "yyyy-MM-dd")
private String finishStartTime;
/**
* 需求截止结束时间
*/
@JsonFormat(pattern = "yyyy-MM-dd")
private String finishEndTime;
private String orderUser;
}

View File

@ -0,0 +1,119 @@
package com.bonus.material.lease.domain;
import com.bonus.common.biz.domain.BmFileInfo;
import com.bonus.common.core.annotation.Excel;
import com.bonus.common.core.web.domain.BaseEntity;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.Date;
import java.io.Serializable;
import java.util.List;
/**
* 租赁信息表(MaLeaseInfo)实体类
*
* @author makejava
* @since 2024-11-26 10:48:29
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
public class MaLeaseInfo extends BaseEntity implements Serializable {
private static final long serialVersionUID = -66749132523394415L;
/**
* 是否提交决定不同状态
*/
private Boolean isSubmit;
/**
* 主键ID
*/
private Integer id;
/**
* 需求名称
*/
private String leaseName;
/**
* 需求编号
*/
private String leaseCode;
/**
* 类型id
*/
private Integer typeId;
/**
* 所属公司租赁公司
*/
private Integer companyId;
/**
* 需求状态
*/
private Integer leaseStatus;
/**
* 预估租期
*/
private Integer leaseDay;
/**
* 预估租赁装备数量
*/
private Integer leaseNum;
/**
* 需求发布时间
*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date startTime;
/**
* 需求发布人
*/
private String publishUser;
/**
* 需求截止日期(年月日)
*/
@JsonFormat(pattern = "yyyy-MM-dd")
private Date endTime;
/**
* 联系人
*/
private String person;
/**
* 联系电话
*/
private String personPhone;
/**
* 需求描述
*/
private String description;
/**
* 接单人
*/
private String orderUser;
/**
* 接单时间
*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date orderTime;
@ApiModelProperty(value = "文件信息")
private List<BmFileInfo> fileInfoList;
}

View File

@ -0,0 +1,58 @@
package com.bonus.material.lease.domain.vo;
import com.bonus.material.lease.domain.MaLeaseInfo;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.List;
/**
* @Author ma_sh
* @create 2024/11/26 11:03
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
public class MaLeaseVo extends MaLeaseInfo {
@ApiModelProperty(value = "公司名称")
private String companyName;
@ApiModelProperty(value = "公司经营地址")
private String operateAddress;
@ApiModelProperty(value = "类型名称")
private String typeName;
@ApiModelProperty(value = "所属三级类目合集")
private String groupName;
@ApiModelProperty(value = "租赁需求状态名称")
private String leaseStatusName;
@ApiModelProperty(value = "装备一级类目Id")
private String firstId;
@ApiModelProperty(value = "装备一级类目名称")
private String firstName;
@ApiModelProperty(value = "装备二级类目Id")
private String secondId;
@ApiModelProperty(value = "装备二级类目名称")
private String secondName;
@ApiModelProperty(value = "装备三级类目Id")
private String thirdId;
@ApiModelProperty(value = "装备三级类目名称")
private String thirdName;
@ApiModelProperty(value = "装备类目id集合")
private List<String> typeIds;
@ApiModelProperty(value = "浏览次数")
private Integer searchNum;
}

View File

@ -0,0 +1,94 @@
package com.bonus.material.lease.mapper;
import com.bonus.material.lease.domain.MaLease;
import com.bonus.material.lease.domain.MaLeaseDto;
import com.bonus.material.lease.domain.MaLeaseInfo;
import com.bonus.material.lease.domain.vo.MaLeaseVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.Date;
import java.util.List;
/**
* @Author ma_sh
* @create 2024/11/26 10:49
*/
@Mapper
public interface MaLeaseInfoMapper {
/**
* 根据设备名称查询设备信息
* @param maLeaseInfo
* @return
*/
MaLeaseVo selectByName(MaLeaseInfo maLeaseInfo);
/**
* 添加设备信息
* @param maLeaseInfo
* @return
*/
int insert(MaLeaseInfo maLeaseInfo);
/**
* 根据月份查询任务数量
* @param nowDate
* @return
*/
String selectTaskNumByMonth(@Param("date") Date nowDate);
/**
* 更新设备信息
* @param maLeaseInfo
* @return
*/
int updateDevInfo(MaLeaseInfo maLeaseInfo);
/**
* 查询租赁需求列表
* @param dto
* @return
*/
List<MaLeaseVo> list(MaLeaseDto dto);
/**
* 根据租赁需求id查询搜索次数
* @param id
* @return
*/
int getHotSearchCountByLeaseId(Integer id);
/**
* 添加搜索次数
* @param id
*/
void insertHotSearch(Integer id);
/**
* 更新搜索次数
* @param id
*/
void updateHotSearchByLeaseId(Integer id);
/**
* 根据id删除设备信息
* @param maLeaseInfo
* @return
*/
int deleteById(MaLeaseInfo maLeaseInfo);
/**
* 查询租赁需求列表首页
* @param maLease
* @return
*/
List<MaLeaseVo> leaseList(MaLease maLease);
/**
* 查询出租方需求列表
* @param dto
* @return
*/
List<MaLeaseVo> rentList(MaLeaseDto dto);
}

View File

@ -0,0 +1,73 @@
package com.bonus.material.lease.service;
import com.bonus.common.core.web.domain.AjaxResult;
import com.bonus.material.lease.domain.MaLease;
import com.bonus.material.lease.domain.MaLeaseDto;
import com.bonus.material.lease.domain.MaLeaseInfo;
import com.bonus.material.lease.domain.vo.MaLeaseVo;
import java.util.List;
/**
* 赁需求大厅service层
* @Author ma_sh
* @create 2024/11/26 10:41
*/
public interface MaLeaseInfoService {
/**
* 发布租赁需求
* @param maLeaseInfo
* @return
*/
AjaxResult add(MaLeaseInfo maLeaseInfo);
/**
* 修改租赁需求
* @param maLeaseInfo
* @return
*/
AjaxResult edit(MaLeaseInfo maLeaseInfo);
/**
* 查询单个租赁需求详情
* @param maLeaseInfo
* @return
*/
AjaxResult getById(MaLeaseInfo maLeaseInfo);
/**
* 查询租赁需求列表
* @param dto
* @return
*/
List<MaLeaseVo> list(MaLeaseDto dto);
/**
* 删除租赁需求
* @param maLeaseInfo
* @return
*/
AjaxResult deleteById(MaLeaseInfo maLeaseInfo);
/**
* 查询租赁需求列表首页
* @param maLease
* @return
*/
List<MaLeaseVo> leaseList(MaLease maLease);
/**
* 出租方立即接单
* @param maLeaseInfo
* @return
*/
AjaxResult accept(MaLeaseInfo maLeaseInfo);
/**
* 查询出租方需求列表
* @param dto
* @return
*/
List<MaLeaseVo> rentList(MaLeaseDto dto);
}

View File

@ -0,0 +1,300 @@
package com.bonus.material.lease.service.impl;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.PhoneUtil;
import com.bonus.common.biz.constant.MaterialConstants;
import com.bonus.common.biz.domain.BmFileInfo;
import com.bonus.common.biz.enums.HttpCodeEnum;
import com.bonus.common.biz.enums.LeaseInfoEnum;
import com.bonus.common.core.utils.DateUtils;
import com.bonus.common.core.utils.StringUtils;
import com.bonus.common.core.web.domain.AjaxResult;
import com.bonus.common.security.utils.SecurityUtils;
import com.bonus.material.device.mapper.BmFileInfoMapper;
import com.bonus.material.lease.domain.MaLease;
import com.bonus.material.lease.domain.MaLeaseDto;
import com.bonus.material.lease.domain.MaLeaseInfo;
import com.bonus.material.lease.domain.vo.MaLeaseVo;
import com.bonus.material.lease.mapper.MaLeaseInfoMapper;
import com.bonus.material.lease.service.MaLeaseInfoService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
/**
* 租赁需求大厅实现层
* @Author ma_sh
* @create 2024/11/26 10:42
*/
@Service
@Slf4j
public class MaLeaseInfoServiceImpl implements MaLeaseInfoService {
@Resource
private MaLeaseInfoMapper leaseInfoMapper;
@Resource
private BmFileInfoMapper bmFileInfoMapper;
/**
* 发布租赁需求
* @param maLeaseInfo
* @return
*/
@Override
@Transactional(rollbackFor = Exception.class)
public AjaxResult add(MaLeaseInfo maLeaseInfo) {
//1.判断手机号是否合法
if (StringUtils.isNotBlank(maLeaseInfo.getPersonPhone()) && !PhoneUtil.isMobile(maLeaseInfo.getPersonPhone())) {
return AjaxResult.error(HttpCodeEnum.INVALID_PHONE_FORMAT.getCode(), HttpCodeEnum.INVALID_PHONE_FORMAT.getMsg());
}
// 2. 生成需求编号及其他字段
populateLeaseInfoFields(maLeaseInfo);
// 3. 插入租赁需求
int result = leaseInfoMapper.insert(maLeaseInfo);
if (result <= 0 || maLeaseInfo.getId() == null) {
return AjaxResult.error(HttpCodeEnum.FAIL.getCode(), HttpCodeEnum.FAIL.getMsg());
}
// 4. 插入文件信息
insertFileInfo(maLeaseInfo);
// 5. 返回成功结果
return AjaxResult.success(HttpCodeEnum.SUCCESS.getMsg());
}
/**
* 修改租赁需求
* @param maLeaseInfo
* @return
*/
@Override
public AjaxResult edit(MaLeaseInfo maLeaseInfo) {
if (maLeaseInfo.getId() == null) {
return AjaxResult.error(HttpCodeEnum.TO_PARAM_NULL.getCode(), HttpCodeEnum.TO_PARAM_NULL.getMsg());
}
//判断手机号是否合法
if (StringUtils.isNotBlank(maLeaseInfo.getPersonPhone()) && !PhoneUtil.isMobile(maLeaseInfo.getPersonPhone())) {
return AjaxResult.error(HttpCodeEnum.INVALID_PHONE_FORMAT.getCode(), HttpCodeEnum.INVALID_PHONE_FORMAT.getMsg());
}
//根据id修改租赁需求信息
Long userId = SecurityUtils.getUserId();
maLeaseInfo.setUpdateBy(String.valueOf(userId));
maLeaseInfo.setUpdateTime(DateUtils.getNowDate());
maLeaseInfo.setLeaseStatus(LeaseInfoEnum.LEASE_PENDING_ORDER.getStatus());
maLeaseInfo.setStartTime(DateUtils.getNowDate());
maLeaseInfo.setPublishUser(String.valueOf(userId));
int result = leaseInfoMapper.updateDevInfo(maLeaseInfo);
//首先根据id查询文件信息是否存在
BmFileInfo bmFileInfo = new BmFileInfo();
bmFileInfo.setModelId(Long.valueOf(maLeaseInfo.getId()));
bmFileInfo.setTaskType(MaterialConstants.LEASE_FILE_TYPE_CODE);
List<BmFileInfo> bmFileInfoList = bmFileInfoMapper.selectBmFileInfoList(bmFileInfo);
if (bmFileInfoList.size() > 0) {
bmFileInfoMapper.deleteBmFileInfoByIds(bmFileInfoList.stream().map(BmFileInfo::getId).toArray(Long[]::new));
}
//插入文件信息
insertFileInfo(maLeaseInfo);
return result > 0 ? AjaxResult.success(HttpCodeEnum.SUCCESS.getMsg()) : AjaxResult.error(HttpCodeEnum.FAIL.getCode(), HttpCodeEnum.FAIL.getMsg());
}
/**
* 查询单个租赁需求详情
* @param maLeaseInfo
* @return
*/
@Override
public AjaxResult getById(MaLeaseInfo maLeaseInfo) {
if (maLeaseInfo.getId() == null) {
return AjaxResult.error(HttpCodeEnum.TO_PARAM_NULL.getCode(), HttpCodeEnum.TO_PARAM_NULL.getMsg());
}
MaLeaseVo maLeaseVo = leaseInfoMapper.selectByName(maLeaseInfo);
ArrayList<String> list = new ArrayList<>();
if (maLeaseVo != null) {
//查询文件信息
BmFileInfo bmFileInfo = new BmFileInfo();
bmFileInfo.setModelId(Long.valueOf(maLeaseVo.getId()));
bmFileInfo.setTaskType(MaterialConstants.LEASE_FILE_TYPE_CODE);
List<BmFileInfo> fileList = bmFileInfoMapper.selectBmFileInfoList(bmFileInfo);
if (CollectionUtil.isNotEmpty(fileList)) {
maLeaseVo.setFileInfoList(fileList);
}
list.add(maLeaseVo.getFirstId());
list.add(maLeaseVo.getSecondId());
list.add(maLeaseVo.getThirdId());
list.add(String.valueOf(maLeaseVo.getTypeId()));
maLeaseVo.setTypeIds(list);
//更新搜索量
try {
//只针对于待接单状态租赁需求更新浏览量
if (maLeaseVo.getLeaseStatus() != null && maLeaseVo.getLeaseStatus().equals(LeaseInfoEnum.LEASE_PENDING_ORDER.getStatus())) {
updateHotSearch(maLeaseInfo.getId());
}
} catch (Exception e) {
log.error("更新租赁需求浏览量失败,不影响主业务流程");
}
}
return AjaxResult.success(maLeaseVo);
}
/**
* 更新浏览量
* @param id
*/
private void updateHotSearch(Integer id) {
int count = leaseInfoMapper.getHotSearchCountByLeaseId(id);
if (count == 0) {
leaseInfoMapper.insertHotSearch(id);
} else {
leaseInfoMapper.updateHotSearchByLeaseId(id);
}
}
/**
* 查询租赁需求列表
* @param dto
* @return
*/
@Override
public List<MaLeaseVo> list(MaLeaseDto dto) {
//获取当前登录人id
Long userId = SecurityUtils.getUserId();
dto.setCreateBy(String.valueOf(userId));
List<MaLeaseVo> list = leaseInfoMapper.list(dto);
//查询列表中数据如果需求截止日期超过当前则修改状态为已过期
for (MaLeaseVo maLeaseVo : list) {
Date endTime = maLeaseVo.getEndTime();
if (maLeaseVo.getLeaseStatus().equals(LeaseInfoEnum.LEASE_PENDING_ORDER.getStatus())
&& endTime != null && endTime.before(new Date())) {
//根据id修改状态为已过期
MaLeaseInfo maLeaseInfo = new MaLeaseInfo();
maLeaseInfo.setId(maLeaseVo.getId());
maLeaseInfo.setLeaseStatus(LeaseInfoEnum.LEASE_PAST_DUE.getStatus());
maLeaseInfo.setUpdateTime(DateUtils.getNowDate());
int result = leaseInfoMapper.updateDevInfo(maLeaseInfo);
if (result > 0) {
maLeaseVo.setLeaseStatusName(LeaseInfoEnum.LEASE_PAST_DUE.getStatusName());
}
}
}
return list;
}
/**
* 删除租赁需求
* @param maLeaseInfo
* @return
*/
@Override
public AjaxResult deleteById(MaLeaseInfo maLeaseInfo) {
if (maLeaseInfo.getId() == null) {
return AjaxResult.error(HttpCodeEnum.TO_PARAM_NULL.getCode(), HttpCodeEnum.TO_PARAM_NULL.getMsg());
}
//根据id查询租赁需求详情已接单状态不可删除
MaLeaseVo maLeaseVo = leaseInfoMapper.selectByName(maLeaseInfo);
if (maLeaseVo != null && maLeaseVo.getLeaseStatus().equals(LeaseInfoEnum.LEASE_ORDER_RECEIVED.getStatus())) {
return AjaxResult.error(HttpCodeEnum.LEASE_ORDER_RECEIVED_NOT_DELETE.getCode(), HttpCodeEnum.LEASE_ORDER_RECEIVED_NOT_DELETE.getMsg());
}
int result = leaseInfoMapper.deleteById(maLeaseInfo);
return result > 0 ? AjaxResult.success(HttpCodeEnum.SUCCESS.getMsg()) : AjaxResult.error(HttpCodeEnum.FAIL.getCode(), HttpCodeEnum.FAIL.getMsg());
}
/**
* 查询租赁需求列表首页
* @param maLease
* @return
*/
@Override
public List<MaLeaseVo> leaseList(MaLease maLease) {
return leaseInfoMapper.leaseList(maLease);
}
/**
* 出租方立即接单
* @param maLeaseInfo
* @return
*/
@Override
public AjaxResult accept(MaLeaseInfo maLeaseInfo) {
if (maLeaseInfo.getId() == null) {
return AjaxResult.error(HttpCodeEnum.TO_PARAM_NULL.getCode(), HttpCodeEnum.TO_PARAM_NULL.getMsg());
}
Long userId = SecurityUtils.getUserId();
maLeaseInfo.setOrderUser(String.valueOf(userId));
maLeaseInfo.setOrderTime(DateUtils.getNowDate());
maLeaseInfo.setLeaseStatus(LeaseInfoEnum.LEASE_ORDER_RECEIVED.getStatus());
int result = leaseInfoMapper.updateDevInfo(maLeaseInfo);
return result > 0 ? AjaxResult.success(HttpCodeEnum.SUCCESS.getMsg()) : AjaxResult.error(HttpCodeEnum.FAIL.getCode(), HttpCodeEnum.FAIL.getMsg());
}
/**
* 查询出租方需求列表
* @param dto
* @return
*/
@Override
public List<MaLeaseVo> rentList(MaLeaseDto dto) {
dto.setOrderUser(String.valueOf(SecurityUtils.getUserId()));
List<MaLeaseVo> list = leaseInfoMapper.rentList(dto);
return null;
}
/**
* 设置租赁需求的必要字段
* @param maLeaseInfo
*/
private void populateLeaseInfoFields(MaLeaseInfo maLeaseInfo) {
String code = getString();
Long userId = SecurityUtils.getUserId();
maLeaseInfo.setLeaseCode(code);
maLeaseInfo.setCreateBy(String.valueOf(userId));
maLeaseInfo.setCreateTime(DateUtils.getNowDate());
maLeaseInfo.setLeaseStatus(LeaseInfoEnum.LEASE_PENDING_ORDER.getStatus());
maLeaseInfo.setStartTime(DateUtils.getNowDate());
maLeaseInfo.setPublishUser(String.valueOf(userId));
}
/**
* 插入文件信息
* @param maLeaseInfo
*/
private void insertFileInfo(MaLeaseInfo maLeaseInfo) {
if (CollectionUtil.isNotEmpty(maLeaseInfo.getFileInfoList())) {
Long userId = SecurityUtils.getUserId();
Integer id = maLeaseInfo.getId();
for (BmFileInfo bmFileInfo : maLeaseInfo.getFileInfoList()) {
bmFileInfo.setModelId(Long.valueOf(id));
bmFileInfo.setTaskType(MaterialConstants.LEASE_FILE_TYPE_CODE);
bmFileInfo.setCreateBy(String.valueOf(userId));
bmFileInfoMapper.insertBmFileInfo(bmFileInfo);
}
}
}
/**
* 生成需求编号
* @return
*/
private String getString() {
//根据前台传过来的数据生成需求编号
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMdd");
Date nowDate = DateUtils.getNowDate();
String format = dateFormat.format(nowDate);
String taskNum = leaseInfoMapper.selectTaskNumByMonth(nowDate);
if (StringUtils.isNotBlank(taskNum)) {
// 将字符串转换为整数
int num = Integer.parseInt(taskNum);
// 执行加一操作
num++;
// 将结果转换回字符串格式并确保结果是4位数不足4位则在前面补0
taskNum = String.format("%04d", num);
} else {
taskNum = "0001";
}
return format + "-" + taskNum;
}
}

View File

@ -0,0 +1,330 @@
<?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="com.bonus.material.lease.mapper.MaLeaseInfoMapper">
<insert id="insert" useGeneratedKeys="true" keyProperty="id">
insert into ma_lease_info
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="leaseName != null and leaseName != ''">lease_name,</if>
<if test="leaseCode != null and leaseCode != ''">lease_code,</if>
<if test="typeId != null">type_id,</if>
<if test="companyId != null">company_id,</if>
<if test="leaseStatus != null">lease_status,</if>
<if test="leaseDay != null">lease_day,</if>
<if test="leaseNum != null">lease_num,</if>
<if test="startTime != null">start_time,</if>
<if test="publishUser != null">publish_user,</if>
<if test="endTime != null">end_time,</if>
<if test="person != null">person,</if>
<if test="personPhone != null">person_phone,</if>
<if test="description != null and description != ''">description,</if>
<if test="createBy != null">create_by,</if>
<if test="createTime != null">create_time,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="leaseName != null and leaseName != ''">#{leaseName},</if>
<if test="leaseCode != null and leaseCode != ''">#{leaseCode},</if>
<if test="typeId != null">#{typeId},</if>
<if test="companyId != null">#{companyId},</if>
<if test="leaseStatus != null">#{leaseStatus},</if>
<if test="leaseDay != null ">#{leaseDay},</if>
<if test="leaseNum != null ">#{leaseNum},</if>
<if test="startTime != null">#{startTime},</if>
<if test="publishUser != null">#{publishUser},</if>
<if test="endTime != null">#{endTime},</if>
<if test="person != null">#{person},</if>
<if test="personPhone != null">#{personPhone},</if>
<if test="description != null and description != ''">#{description},</if>
<if test="createBy != null">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
</trim>
</insert>
<insert id="insertHotSearch">
insert into ma_hot_search(lease_id, lease_num, create_time)
values(#{id}, 1, now())
</insert>
<update id="updateDevInfo">
update ma_lease_info
<trim prefix="SET" suffixOverrides=",">
<if test="leaseName != null and leaseName != ''">lease_name = #{leaseName},</if>
<if test="typeId != null">type_id = #{typeId},</if>
<if test="companyId != null">company_id = #{companyId},</if>
<if test="leaseDay != null ">lease_day = #{leaseDay},</if>
<if test="leaseStatus != null ">lease_status = #{leaseStatus},</if>
<if test="leaseNum != null ">lease_num = #{leaseNum},</if>
<if test="startTime != null">start_time = #{startTime},</if>
<if test="publishUser != null and publishUser != ''">publish_user = #{publishUser},</if>
<if test="endTime != null">end_time = #{endTime},</if>
<if test="person != null">person = #{person},</if>
<if test="personPhone != null">person_phone = #{personPhone},</if>
<if test="description != null and description != ''">description = #{description},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="orderUser != null and orderUser != ''">order_user = #{orderUser},</if>
<if test="orderTime != null">order_time = #{orderTime},</if>
</trim>
where id = #{id}
</update>
<update id="updateHotSearchByLeaseId">
update ma_hot_search
set lease_num = lease_num + 1,
update_time = now()
where lease_id = #{id}
</update>
<delete id="deleteById">
delete from ma_lease_info where id = #{id}
</delete>
<select id="selectByName" resultType="com.bonus.material.lease.domain.vo.MaLeaseVo">
SELECT
m.id as id,
m.lease_name as leaseName,
m.lease_code as leaseCode,
m.type_id as typeId,
mt4.type_name as typeName,
m.company_id as companyId,
c.company_name as companyName,
c.operate_address as operateAddress,
m.lease_status as leaseStatus,
m.lease_day as leaseDay,
m.lease_num as leaseNum,
m.start_time as startTime,
m.end_time as endTime,
m.person as person,
m.person_phone as personPhone,
m.description as description,
h.lease_num as searchNum,
mt3.type_id as thirdId,
mt3.type_name as thirdName,
mt2.type_id as secondId,
mt2.type_name as secondName,
mt1.type_id as firstId,
mt1.type_name as firstName
FROM
ma_lease_info m
LEFT JOIN bm_company_info c ON m.company_id = c.company_id
LEFT JOIN ma_hot_search h ON h.lease_id = m.id
LEFT JOIN ma_type mt4 ON mt4.type_id = m.type_id and mt4.del_flag = '0'
LEFT JOIN ma_type mt3 ON mt3.type_id = mt4.parent_id and mt3.del_flag = '0'
LEFT JOIN ma_type mt2 ON mt2.type_id = mt3.parent_id and mt2.del_flag = '0'
LEFT JOIN ma_type mt1 ON mt1.type_id = mt2.parent_id and mt1.del_flag = '0'
WHERE 1 = 1
<if test="id != null">
and m.id = #{id}
</if>
<if test="leaseCode != null and leaseCode != ''">
and m.lease_code = #{leaseCode}
</if>
<if test="leaseName != null and leaseName != ''">
and m.lease_name = #{leaseName}
</if>
</select>
<select id="selectTaskNumByMonth" resultType="java.lang.String">
SELECT SUBSTRING(lease_code, - 4) as code
FROM ma_lease_info
WHERE DATE_FORMAT(create_time, '%y%m') = DATE_FORMAT(#{date}, '%y%m')
ORDER BY create_time DESC LIMIT 1
</select>
<select id="list" resultType="com.bonus.material.lease.domain.vo.MaLeaseVo">
SELECT
m.id as id,
m.lease_name as leaseName,
m.lease_code as leaseCode,
m.type_id as typeId,
mt4.type_name as typeName,
m.company_id as companyId,
c.company_name as companyName,
c.operate_address as operateAddress,
m.lease_status as leaseStatus,
m.lease_day as leaseDay,
m.lease_num as leaseNum,
m.start_time as startTime,
m.end_time as endTime,
m.person as person,
m.person_phone as personPhone,
m.description as description,
mt3.type_id as thirdId,
mt3.type_name as thirdName,
mt2.type_id as secondId,
mt2.type_name as secondName,
mt1.type_id as firstId,
mt1.type_name as firstName,
GROUP_CONCAT(CONCAT(mt1.type_name, '/', mt2.type_name, '/', mt3.type_name)) AS groupName,
CASE
WHEN lease_status = 0 THEN '待接单'
WHEN lease_status = 1 THEN '已接单'
WHEN lease_status = 2 THEN '已到期'
ELSE '未知'
END
AS leaseStatusName,
su.nick_name as publishUser
FROM
ma_lease_info m
LEFT JOIN bm_company_info c ON m.company_id = c.company_id
LEFT JOIN sys_user su ON m.publish_user = su.user_id
LEFT JOIN ma_type mt4 ON mt4.type_id = m.type_id and mt4.del_flag = '0'
LEFT JOIN ma_type mt3 ON mt3.type_id = mt4.parent_id and mt3.del_flag = '0'
LEFT JOIN ma_type mt2 ON mt2.type_id = mt3.parent_id and mt2.del_flag = '0'
LEFT JOIN ma_type mt1 ON mt1.type_id = mt2.parent_id and mt1.del_flag = '0'
WHERE 1 = 1 and m.create_by = #{createBy}
<if test="leaseCode != null and leaseCode != ''">
and m.lease_code like concat('%',#{leaseCode},'%')
</if>
<if test="leaseName != null and leaseName != ''">
and m.lease_name like concat('%',#{leaseName},'%')
</if>
<if test="leaseStatus != null">
and m.lease_status = #{leaseStatus}
</if>
<if test="publishStartTime != null and publishEndTime != ''">
and DATE_FORMAT(m.start_time,'%Y-%m-%d') between #{publishStartTime} and #{publishEndTime}
</if>
<if test="finishStartTime != null and finishEndTime != ''">
and DATE_FORMAT(m.end_time,'%Y-%m-%d') between #{finishStartTime} and #{finishEndTime}
</if>
GROUP BY m.lease_code
</select>
<select id="getHotSearchCountByLeaseId" resultType="java.lang.Integer">
select count(1) from ma_hot_search
where lease_id = #{leaseId}
</select>
<select id="leaseList" resultType="com.bonus.material.lease.domain.vo.MaLeaseVo">
SELECT
m.id as id,
m.lease_name as leaseName,
m.lease_code as leaseCode,
m.type_id as typeId,
mt4.type_name as typeName,
m.company_id as companyId,
c.company_name as companyName,
c.operate_address as operateAddress,
m.lease_status as leaseStatus,
m.lease_day as leaseDay,
m.lease_num as leaseNum,
m.start_time as startTime,
m.end_time as endTime,
m.person as person,
m.person_phone as personPhone,
m.description as description,
mt3.type_id as thirdId,
mt3.type_name as thirdName,
mt2.type_id as secondId,
mt2.type_name as secondName,
mt1.type_id as firstId,
mt1.type_name as firstName,
GROUP_CONCAT(CONCAT(mt1.type_name, '/', mt2.type_name, '/', mt3.type_name)) AS groupName
FROM
ma_lease_info m
LEFT JOIN bm_company_info c ON m.company_id = c.company_id
LEFT JOIN sys_user su ON m.publish_user = su.user_id
LEFT JOIN ma_type mt4 ON mt4.type_id = m.type_id and mt4.del_flag = '0'
LEFT JOIN ma_type mt3 ON mt3.type_id = mt4.parent_id and mt3.del_flag = '0'
LEFT JOIN ma_type mt2 ON mt2.type_id = mt3.parent_id and mt2.del_flag = '0'
LEFT JOIN ma_type mt1 ON mt1.type_id = mt2.parent_id and mt1.del_flag = '0'
WHERE m.lease_status = '0'
<if test="typeId != null">
<choose>
<when test="level != null and level == 4">
and d.type_id = #{typeId}
</when>
<when test="level != null and level == 3">
and mt3.type_id = #{typeId}
</when>
<when test="level != null and level == 2">
and mt2.type_id = #{typeId}
</when>
<when test="level != null and level == 1">
and mt1.type_id = #{typeId}
</when>
</choose>
</if>
<if test="companyId != null and companyId != ''"> and m.company_id = #{companyId}</if>
<if test="keyWord != null and keyWord != ''">
and (
locate(#{keyWord},mt1.type_name) > 0
or locate(#{keyWord},mt2.type_name) > 0
or locate(#{keyWord},mt3.type_name) > 0
or locate(#{keyWord},mt4.type_name) > 0
or locate(#{keyWord},c.company_name) > 0
or locate(#{keyWord},m.lease_name) > 0
)
</if>
GROUP BY m.lease_code
ORDER BY
m.lease_status
<if test="startTime != '' and startTime == 'ASC'">
,m.start_time
</if>
<if test="startTime != '' and startTime == 'DESC'">
,m.start_time DESC
</if>
<if test="leaseDay != null and leaseDay == 'ASC'">
,m.lease_day
</if>
<if test="leaseDay != null and leaseDay == 'DESC'">
,m.lease_day DESC
</if>
<if test="endTime != '' and endTime == 'ASC'">
,m.end_time
</if>
<if test="endTime != '' and endTime == 'DESC'">
,m.end_time DESC
</if>
<if test="leaseNum != null and leaseNum == 'ASC'">
,m.lease_num
</if>
<if test="leaseNum != null and leaseNum == 'DESC'">
,m.lease_num DESC
</if>
</select>
<select id="rentList" resultType="com.bonus.material.lease.domain.vo.MaLeaseVo">
SELECT
m.id as id,
m.lease_name as leaseName,
m.lease_code as leaseCode,
m.type_id as typeId,
m.company_id as companyId,
c.company_name as companyName,
c.operate_address as operateAddress,
m.lease_status as leaseStatus,
m.lease_day as leaseDay,
m.lease_num as leaseNum,
m.start_time as startTime,
m.end_time as endTime,
m.person as person,
m.person_phone as personPhone,
m.description as description,
su.nick_name as publishUser,
su1.nick_name as orderUser,
m.order_time as orderTime
FROM
ma_lease_info m
LEFT JOIN bm_company_info c ON m.company_id = c.company_id
LEFT JOIN sys_user su ON m.publish_user = su.user_id
LEFT JOIN sys_user su1 ON m.order_user = su1.user_id
WHERE 1 = 1 and m.order_user = #{orderUser} and m.lease_status = '1'
<if test="leaseCode != null and leaseCode != ''">
and m.lease_code like concat('%',#{leaseCode},'%')
</if>
<if test="leaseName != null and leaseName != ''">
and m.lease_name like concat('%',#{leaseName},'%')
</if>
<if test="publishStartTime != null and publishEndTime != ''">
and DATE_FORMAT(m.start_time,'%Y-%m-%d') between #{publishStartTime} and #{publishEndTime}
</if>
<if test="finishStartTime != null and finishEndTime != ''">
and DATE_FORMAT(m.end_time,'%Y-%m-%d') between #{finishStartTime} and #{finishEndTime}
</if>
GROUP BY m.lease_code
</select>
</mapper>