From 0e344682ec5fa7cd750bf768e29b606748c0a940 Mon Sep 17 00:00:00 2001 From: mashuai Date: Wed, 27 Nov 2024 17:29:15 +0800 Subject: [PATCH] =?UTF-8?q?=E7=A7=9F=E8=B5=81=E9=9C=80=E6=B1=82=E5=A4=A7?= =?UTF-8?q?=E5=8E=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bonus/common/biz/enums/HttpCodeEnum.java | 1 + .../controller/MaLeaseInfoController.java | 125 +++++++ .../bonus/material/lease/domain/MaLease.java | 57 +++ .../material/lease/domain/MaLeaseDto.java | 59 ++++ .../material/lease/domain/MaLeaseInfo.java | 119 +++++++ .../material/lease/domain/vo/MaLeaseVo.java | 58 +++ .../lease/mapper/MaLeaseInfoMapper.java | 94 +++++ .../lease/service/MaLeaseInfoService.java | 73 ++++ .../service/impl/MaLeaseInfoServiceImpl.java | 300 ++++++++++++++++ .../material/lease/MaLeaseInfoMapper.xml | 330 ++++++++++++++++++ 10 files changed, 1216 insertions(+) create mode 100644 bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/lease/controller/MaLeaseInfoController.java create mode 100644 bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/lease/domain/MaLease.java create mode 100644 bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/lease/domain/MaLeaseDto.java create mode 100644 bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/lease/domain/MaLeaseInfo.java create mode 100644 bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/lease/domain/vo/MaLeaseVo.java create mode 100644 bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/lease/mapper/MaLeaseInfoMapper.java create mode 100644 bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/lease/service/MaLeaseInfoService.java create mode 100644 bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/lease/service/impl/MaLeaseInfoServiceImpl.java create mode 100644 bonus-modules/bonus-material-mall/src/main/resources/mapper/material/lease/MaLeaseInfoMapper.xml diff --git a/bonus-common-biz/src/main/java/com/bonus/common/biz/enums/HttpCodeEnum.java b/bonus-common-biz/src/main/java/com/bonus/common/biz/enums/HttpCodeEnum.java index 5ec8f10..f2059d6 100644 --- a/bonus-common-biz/src/main/java/com/bonus/common/biz/enums/HttpCodeEnum.java +++ b/bonus-common-biz/src/main/java/com/bonus/common/biz/enums/HttpCodeEnum.java @@ -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, "无权限操作"), diff --git a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/lease/controller/MaLeaseInfoController.java b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/lease/controller/MaLeaseInfoController.java new file mode 100644 index 0000000..43810ce --- /dev/null +++ b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/lease/controller/MaLeaseInfoController.java @@ -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 list = leaseInfoService.list(dto); + return AjaxResult.success(getDataTable(list)); + } + + /** + * 查询租赁需求列表首页 + * @param maLease + * @return + */ + @ApiOperation(value = "查询租赁需求列表首页") + @PostMapping("/leaseList") + public AjaxResult leaseList(@RequestBody MaLease maLease) { + List 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 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); + } +} diff --git a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/lease/domain/MaLease.java b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/lease/domain/MaLease.java new file mode 100644 index 0000000..99a59dd --- /dev/null +++ b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/lease/domain/MaLease.java @@ -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; + +} diff --git a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/lease/domain/MaLeaseDto.java b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/lease/domain/MaLeaseDto.java new file mode 100644 index 0000000..e87b820 --- /dev/null +++ b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/lease/domain/MaLeaseDto.java @@ -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; + +} diff --git a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/lease/domain/MaLeaseInfo.java b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/lease/domain/MaLeaseInfo.java new file mode 100644 index 0000000..282f16a --- /dev/null +++ b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/lease/domain/MaLeaseInfo.java @@ -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 fileInfoList; +} + diff --git a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/lease/domain/vo/MaLeaseVo.java b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/lease/domain/vo/MaLeaseVo.java new file mode 100644 index 0000000..3b875bf --- /dev/null +++ b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/lease/domain/vo/MaLeaseVo.java @@ -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 typeIds; + + @ApiModelProperty(value = "浏览次数") + private Integer searchNum; +} diff --git a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/lease/mapper/MaLeaseInfoMapper.java b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/lease/mapper/MaLeaseInfoMapper.java new file mode 100644 index 0000000..4284c07 --- /dev/null +++ b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/lease/mapper/MaLeaseInfoMapper.java @@ -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 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 leaseList(MaLease maLease); + + /** + * 查询出租方需求列表 + * @param dto + * @return + */ + List rentList(MaLeaseDto dto); +} diff --git a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/lease/service/MaLeaseInfoService.java b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/lease/service/MaLeaseInfoService.java new file mode 100644 index 0000000..ca0c05b --- /dev/null +++ b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/lease/service/MaLeaseInfoService.java @@ -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 list(MaLeaseDto dto); + + /** + * 删除租赁需求 + * @param maLeaseInfo + * @return + */ + AjaxResult deleteById(MaLeaseInfo maLeaseInfo); + + /** + * 查询租赁需求列表首页 + * @param maLease + * @return + */ + List leaseList(MaLease maLease); + + /** + * 出租方立即接单 + * @param maLeaseInfo + * @return + */ + AjaxResult accept(MaLeaseInfo maLeaseInfo); + + /** + * 查询出租方需求列表 + * @param dto + * @return + */ + List rentList(MaLeaseDto dto); +} diff --git a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/lease/service/impl/MaLeaseInfoServiceImpl.java b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/lease/service/impl/MaLeaseInfoServiceImpl.java new file mode 100644 index 0000000..272561b --- /dev/null +++ b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/lease/service/impl/MaLeaseInfoServiceImpl.java @@ -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 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 list = new ArrayList<>(); + if (maLeaseVo != null) { + //查询文件信息 + BmFileInfo bmFileInfo = new BmFileInfo(); + bmFileInfo.setModelId(Long.valueOf(maLeaseVo.getId())); + bmFileInfo.setTaskType(MaterialConstants.LEASE_FILE_TYPE_CODE); + List 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 list(MaLeaseDto dto) { + //获取当前登录人id + Long userId = SecurityUtils.getUserId(); + dto.setCreateBy(String.valueOf(userId)); + List 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 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 rentList(MaLeaseDto dto) { + dto.setOrderUser(String.valueOf(SecurityUtils.getUserId())); + List 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; + } +} diff --git a/bonus-modules/bonus-material-mall/src/main/resources/mapper/material/lease/MaLeaseInfoMapper.xml b/bonus-modules/bonus-material-mall/src/main/resources/mapper/material/lease/MaLeaseInfoMapper.xml new file mode 100644 index 0000000..dc6fb61 --- /dev/null +++ b/bonus-modules/bonus-material-mall/src/main/resources/mapper/material/lease/MaLeaseInfoMapper.xml @@ -0,0 +1,330 @@ + + + + + insert into ma_lease_info + + lease_name, + lease_code, + type_id, + company_id, + lease_status, + lease_day, + lease_num, + start_time, + publish_user, + end_time, + person, + person_phone, + description, + create_by, + create_time, + + + #{leaseName}, + #{leaseCode}, + #{typeId}, + #{companyId}, + #{leaseStatus}, + #{leaseDay}, + #{leaseNum}, + #{startTime}, + #{publishUser}, + #{endTime}, + #{person}, + #{personPhone}, + #{description}, + #{createBy}, + #{createTime}, + + + + + insert into ma_hot_search(lease_id, lease_num, create_time) + values(#{id}, 1, now()) + + + + update ma_lease_info + + lease_name = #{leaseName}, + type_id = #{typeId}, + company_id = #{companyId}, + lease_day = #{leaseDay}, + lease_status = #{leaseStatus}, + lease_num = #{leaseNum}, + start_time = #{startTime}, + publish_user = #{publishUser}, + end_time = #{endTime}, + person = #{person}, + person_phone = #{personPhone}, + description = #{description}, + update_by = #{updateBy}, + update_time = #{updateTime}, + order_user = #{orderUser}, + order_time = #{orderTime}, + + where id = #{id} + + + + update ma_hot_search + set lease_num = lease_num + 1, + update_time = now() + where lease_id = #{id} + + + + delete from ma_lease_info where id = #{id} + + + + + + + + + + + + + + \ No newline at end of file