Compare commits

...

2 Commits

Author SHA1 Message Date
xiao-fajia
2b821383ff Merge branch 'master' of http://122.51.230.86:3000/dianliang/lanan-system 2024-09-23 18:21:58 +08:00
xiao-fajia
18cf45c52d 更新代码 2024-09-23 18:21:48 +08:00
12 changed files with 252 additions and 94 deletions

View File

@ -42,7 +42,7 @@
<if test="map.type != null and map.type != ''">
and dbt.type = #{map.type}
</if>
<if test="map.tenantId != null and map.tenantId != ''">
<if test="map.corpId != null and map.corpId != ''">
and dbt.corp_id = #{map.corpId}
</if>
</select>

View File

@ -0,0 +1,74 @@
package cn.iocoder.yudao.module.app.order.admin;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.module.project.entity.RepairOrderInfo;
import cn.iocoder.yudao.module.project.service.RepairOrderInfoService;
import cn.iocoder.yudao.module.project.vo.RepairOrderInfoRespVO;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.v3.oas.annotations.Operation;
import org.springframework.context.annotation.Lazy;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
/**
* 维修订单API
*
* @author 小李
* @date 17:20 2024/9/23
**/
@RestController
@RequestMapping("/api/repair/order")
public class RepairOrderAPI {
@Resource
@Lazy
private RepairOrderInfoService repairOrderInfoService;
/**
* 订单分页查询
*
* @author 小李
* @date 17:35 2024/9/23
* @param respVO 查询对象
* @param pageNo 页码
* @param pageSize 条数
**/
@GetMapping("/page")
@Operation(summary = "订单分页查询")
public CommonResult<?> getOrderPageByStatus(RepairOrderInfoRespVO respVO,
@RequestParam(value = "pageNo", defaultValue = "1")Integer pageNo,
@RequestParam(value = "pageSize", defaultValue = "10")Integer pageSize){
Page<RepairOrderInfo> page = new Page<>(pageNo, pageSize);
return success(repairOrderInfoService.getOrderPageByStatus(respVO, page));
}
/**
* 查询订单详情(包括工单)
*
* @author 小李
* @date 17:43 2024/9/23
* @param id 订单ID
**/
@GetMapping("/get")
@Operation(summary = "查询订单详情")
public CommonResult<?> getOrderById(@RequestParam(value = "id") String id){
return success(repairOrderInfoService.getOrderById(id));
}
/**
* 评价订单
*
* @author 小李
* @date 17:50 2024/9/23
* @param respVO 请求对象
**/
@PostMapping("/appraise")
@Operation(summary = "评价订单")
public CommonResult<?> appraiseOrder(@RequestBody RepairOrderInfoRespVO respVO){
repairOrderInfoService.appraiseOrder(respVO);
return CommonResult.ok();
}
}

View File

@ -1,13 +1,12 @@
package cn.iocoder.yudao.module.app.tickets.admin;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.module.tickets.entity.DlRepairTickets;
import cn.iocoder.yudao.module.tickets.service.DlRepairTicketsService;
import cn.iocoder.yudao.module.tickets.vo.DlRepairTicketsReqVO;
import cn.iocoder.yudao.module.tickets.vo.DlRepairTicketsRespVO;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.v3.oas.annotations.Operation;
import org.springframework.web.bind.annotation.*;
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;
@ -28,38 +27,6 @@ public class TicketsAPI {
@Resource
private DlRepairTicketsService dlRepairTicketsService;
/**
* 维修工单表 评价
*
* @author 小李
* @date 10:54 2024/9/23
* @param repairTicketsRespVO 对象
**/
@PostMapping("/appraise")
@Operation(summary = "维修工单表 评价")
public CommonResult<?> setAppraise(@RequestBody DlRepairTicketsRespVO repairTicketsRespVO){
dlRepairTicketsService.setAppraise(repairTicketsRespVO);
return CommonResult.ok();
}
/**
* 维修工单表 按用户的id查
*
* @author 小李
* @date 11:37 2024/9/23
* @param repairTicketsReqVO 查询对象
* @param pageNo 页码
* @param pageSize 条数
**/
@GetMapping("/page")
@Operation(summary = "维修工单表 按用户的id查")
public CommonResult<?> getTicketsPageById(DlRepairTicketsReqVO repairTicketsReqVO,
@RequestParam(value = "pageNo", defaultValue = "1")Integer pageNo,
@RequestParam(value = "pageSize", defaultValue = "10")Integer pageSize){
Page<DlRepairTickets> page = new Page<>(pageNo, pageSize);
return success(dlRepairTicketsService.getTicketsPage(repairTicketsReqVO, page));
}
/**
* 维修工单表 查看一个工单的详细信息
*

View File

@ -29,4 +29,12 @@ public interface RepairOrderInfoMapper extends BaseMapper<RepairOrderInfo> {
IPage<RepairOrderInfoRespVO> queryListPage(@Param("entity") RepairOrderInfoPageReqVO entity, Page<RepairOrderInfoRespVO> page);
/**
* 订单分页查询
*
* @author 小李
* @date 17:35 2024/9/23
* @param respVO 查询对象
**/
IPage<RepairOrderInfoRespVO> getOrderPageByStatus(@Param("map") RepairOrderInfoRespVO respVO, Page<RepairOrderInfo> page);
}

View File

@ -60,5 +60,30 @@ public interface RepairOrderInfoService extends IService<RepairOrderInfo> {
**/
IPage<RepairOrderInfoRespVO> queryListPage(RepairOrderInfoPageReqVO pageReqVO, Page<RepairOrderInfoRespVO> page);
/**
* 订单分页查询
*
* @author 小李
* @date 17:35 2024/9/23
* @param respVO 查询对象
**/
IPage<RepairOrderInfoRespVO> getOrderPageByStatus(RepairOrderInfoRespVO respVO, Page<RepairOrderInfo> page);
/**
* 查询订单详情(包括工单)
*
* @author 小李
* @date 17:43 2024/9/23
* @param id 订单ID
**/
RepairOrderInfoRespVO getOrderById(String id);
/**
* 评价订单
*
* @author 小李
* @date 17:50 2024/9/23
* @param respVO 请求对象
**/
void appraiseOrder(RepairOrderInfoRespVO respVO);
}

View File

@ -1,5 +1,6 @@
package cn.iocoder.yudao.module.project.service.impl;
import cn.hutool.core.util.ObjectUtil;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.module.project.entity.RepairOrderInfo;
@ -8,13 +9,18 @@ import cn.iocoder.yudao.module.project.service.RepairOrderInfoService;
import cn.iocoder.yudao.module.project.vo.RepairOrderInfoPageReqVO;
import cn.iocoder.yudao.module.project.vo.RepairOrderInfoRespVO;
import cn.iocoder.yudao.module.project.vo.RepairOrderInfoSaveReqVO;
import cn.iocoder.yudao.module.tickets.entity.DlRepairTickets;
import cn.iocoder.yudao.module.tickets.service.DlRepairTicketsService;
import cn.iocoder.yudao.module.tickets.vo.DlRepairTicketsRespVO;
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.context.annotation.Lazy;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;
import javax.annotation.Resource;
import java.time.LocalDateTime;
/**
* 维修模块 订单 Service 实现类
@ -28,6 +34,9 @@ public class RepairOrderInfoServiceImpl extends ServiceImpl<RepairOrderInfoMappe
@Resource
private RepairOrderInfoMapper repairOrderInfoMapper;
@Resource
@Lazy
private DlRepairTicketsService ticketsService;
/**
* 保存订单信息
@ -74,4 +83,52 @@ public class RepairOrderInfoServiceImpl extends ServiceImpl<RepairOrderInfoMappe
return repairOrderInfoMapper.queryListPage(pageReqVO, page);
}
/**
* 订单分页查询
*
* @author 小李
* @date 17:35 2024/9/23
* @param respVO 查询对象
**/
@Override
public IPage<RepairOrderInfoRespVO> getOrderPageByStatus(RepairOrderInfoRespVO respVO, Page<RepairOrderInfo> page){
return baseMapper.getOrderPageByStatus(respVO, page);
}
/**
* 查询订单详情(包括工单)
*
* @author 小李
* @date 17:43 2024/9/23
* @param id 订单ID
**/
@Override
public RepairOrderInfoRespVO getOrderById(String id){
// 查订单信息
RepairOrderInfo repairOrderInfo = baseMapper.selectById(id);
return BeanUtils.toBean(repairOrderInfo, RepairOrderInfoRespVO.class);
}
/**
* 评价订单
*
* @author 小李
* @date 17:50 2024/9/23
* @param respVO 请求对象
**/
@Override
public void appraiseOrder(RepairOrderInfoRespVO respVO){
// 没有评价内容就给默认评价内容
if (ObjectUtil.isEmpty(respVO.getCommentDesc())){
respVO.setCommentDesc("没有填写文本");
}
// 没有评分就给默认评分
if (ObjectUtil.isEmpty(respVO.getCommentStar())){
respVO.setCommentStar(5);
}
respVO.setCommentTime(LocalDateTime.now());
baseMapper.updateById(respVO);
}
}

View File

@ -1,6 +1,7 @@
package cn.iocoder.yudao.module.project.vo;
import cn.iocoder.yudao.module.project.entity.RepairOrderInfo;
import cn.iocoder.yudao.module.tickets.vo.DlRepairTicketsRespVO;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import java.util.*;
@ -14,5 +15,10 @@ import com.alibaba.excel.annotation.*;
@ExcelIgnoreUnannotated
public class RepairOrderInfoRespVO extends RepairOrderInfo {
/** 订单状态(工单的状态) */
private String status;
/** 工单信息(包含子表) */
private DlRepairTicketsRespVO tickets;
}

View File

@ -175,13 +175,4 @@ public class DlRepairTickets extends TenantBaseDO {
/** 工单进行状态 */
private String ticketsWorkStatus;
/** 评价 */
private String appraise;
/** 是否已评价 */
private String isAppraise;
/** 评分 */
private Integer appraiseScope;
}

View File

@ -59,13 +59,4 @@ public interface DlRepairTicketsService extends IService<DlRepairTickets> {
* @param repairTicketsRespVO 工单
**/
void setTicketsPaid(DlRepairTicketsRespVO repairTicketsRespVO);
/**
* 维修工单表 评价
*
* @author 小李
* @date 10:54 2024/9/23
* @param repairTicketsRespVO 对象
**/
void setAppraise(DlRepairTicketsRespVO repairTicketsRespVO);
}

View File

@ -5,14 +5,22 @@ import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.iocoder.yudao.common.RepairErrorCodeConstants;
import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils;
import cn.iocoder.yudao.module.custom.service.CustomerMainService;
import cn.iocoder.yudao.module.custom.vo.CustomerMainRespVO;
import cn.iocoder.yudao.module.other.entity.DlRepairOther;
import cn.iocoder.yudao.module.other.service.DlRepairOtherService;
import cn.iocoder.yudao.module.project.entity.RepairOrderInfo;
import cn.iocoder.yudao.module.project.entity.RepairProject;
import cn.iocoder.yudao.module.project.entity.RepairWares;
import cn.iocoder.yudao.module.project.service.RepairOrderInfoService;
import cn.iocoder.yudao.module.project.service.RepairProjectService;
import cn.iocoder.yudao.module.project.service.RepairWaresService;
import cn.iocoder.yudao.module.project.vo.RepairOrderInfoSaveReqVO;
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.dict.DictDataApi;
import cn.iocoder.yudao.module.system.api.dict.dto.DictDataRespDTO;
import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
import cn.iocoder.yudao.module.tickets.entity.DlRepairTickets;
import cn.iocoder.yudao.module.tickets.entity.DlRepairTitem;
import cn.iocoder.yudao.module.tickets.mapper.DlRepairTicketsMapper;
@ -26,12 +34,14 @@ 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.context.annotation.Lazy;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.List;
import java.util.Optional;
import java.util.Set;
import java.util.stream.Collectors;
@ -62,6 +72,16 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl<DlRepairTicketsMappe
@Resource
private DlRepairOtherService otherService;
@Resource
private DictDataApi dictDataApi;
@Resource
private CustomerMainService customerMainService;
@Resource
@Lazy
private RepairOrderInfoService repairOrderInfoService;
/**
* 维修工单表 新增
*
@ -104,6 +124,33 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl<DlRepairTicketsMappe
item.setTicketId(ticketsRespVO.getId());
});
titemService.saveBatch(itemList);
// 创建订单
RepairOrderInfoSaveReqVO repairOrderInfo = new RepairOrderInfoSaveReqVO();
// 订单号采用时间戳+工单ID和hash值取余后取3位
repairOrderInfo.setOrderNo(System.currentTimeMillis() + Math.abs(ticketsRespVO.getId().hashCode() % 1000) + "");
repairOrderInfo.setGoodsId(ticketsRespVO.getId());
DictDataRespDTO repairType = dictDataApi.getDictData("repair_type", ticketsRespVO.getRepairType());
if (ObjectUtil.isNotEmpty(repairType)) {
repairOrderInfo.setGoodsTitle(repairType.getLabel());
} else {
repairOrderInfo.setGoodsTitle("维修费用");
}
repairOrderInfo.setGoodsType("2");
CustomerMainRespVO customerById = customerMainService.getCustomerById(ticketsRespVO.getUserId());
if (ObjectUtil.isNotEmpty(customerById)) {
repairOrderInfo.setUserId(Integer.parseInt(customerById.getUserId() + ""));
} else {
repairOrderInfo.setUserId(0);
}
repairOrderInfo.setCusId(customerById.getId());
repairOrderInfo.setCusName(customerById.getCusName());
repairOrderInfo.setCusPhone(customerById.getPhoneNumber());
repairOrderInfo.setGoodsPrice(ticketsRespVO.getTotalPrice());
repairOrderInfo.setOrderTime(ticketsRespVO.getCreateTime());
repairOrderInfo.setOrderStatus("0");
repairOrderInfo.setDeptId(Integer.parseInt(deptId + ""));
repairOrderInfoService.saveOrderInfo(repairOrderInfo);
}
/**
@ -121,12 +168,12 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl<DlRepairTicketsMappe
/**
* 获得一个工单的详细信息
*
* @param id 工单ID
* @author 小李
* @date 16:05 2024/9/21
* @param id 工单ID
**/
@Override
public DlRepairTicketsRespVO getTicketsById(String id){
public DlRepairTicketsRespVO getTicketsById(String id) {
// 查工单主表
DlRepairTickets dlRepairTickets = baseMapper.selectById(id);
DlRepairTicketsRespVO result = BeanUtil.toBean(dlRepairTickets, DlRepairTicketsRespVO.class);
@ -135,7 +182,7 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl<DlRepairTicketsMappe
List<DlRepairTitemReqVO> items = itemList.stream().map(item -> BeanUtil.toBean(item, DlRepairTitemReqVO.class)).collect(Collectors.toList());
// 取项目
List<DlRepairTitemReqVO> projects = items.stream().filter(item -> item.getItemType().equals("01")).collect(Collectors.toList());
if (CollectionUtil.isNotEmpty(projects)){
if (CollectionUtil.isNotEmpty(projects)) {
Set<String> ids = projects.stream().map(DlRepairTitemReqVO::getProjectId).collect(Collectors.toSet());
List<RepairProject> repairProjects = projectService.listByIds(ids);
items.forEach(item -> repairProjects.stream().filter(i -> i.getId().equals(item.getProjectId())).findFirst().ifPresent(item::setProject));
@ -143,14 +190,14 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl<DlRepairTicketsMappe
// 取配件
List<DlRepairTitemReqVO> wares = items.stream().filter(item -> item.getItemType().equals("02")).collect(Collectors.toList());
if (CollectionUtil.isNotEmpty(wares)){
if (CollectionUtil.isNotEmpty(wares)) {
Set<String> ids = wares.stream().map(DlRepairTitemReqVO::getPartId).collect(Collectors.toSet());
List<RepairWares> repairWares = waresService.listByIds(ids);
items.forEach(item -> repairWares.stream().filter(i -> i.getId().equals(item.getPartId())).findFirst().ifPresent(item::setWare));
}
// 取附加
List<DlRepairTitemReqVO> others = items.stream().filter(item -> item.getItemType().equals("03")).collect(Collectors.toList());
if (CollectionUtil.isNotEmpty(others)){
if (CollectionUtil.isNotEmpty(others)) {
Set<String> ids = others.stream().map(DlRepairTitemReqVO::getOtherId).collect(Collectors.toSet());
List<DlRepairOther> dlRepairOthers = otherService.listByIds(ids);
items.forEach(item -> dlRepairOthers.stream().filter(i -> i.getId().equals(item.getOtherId())).findFirst().ifPresent(item::setOther));
@ -162,45 +209,24 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl<DlRepairTicketsMappe
/**
* 维修工单表 作废
*
* @param repairTicketsReqVO 工单对象
* @author 小李
* @date 19:46 2024/9/22
* @param repairTicketsReqVO 工单对象
**/
@Override
public void setTicketsVoid(DlRepairTicketsReqVO repairTicketsReqVO){
public void setTicketsVoid(DlRepairTicketsReqVO repairTicketsReqVO) {
baseMapper.updateById(repairTicketsReqVO);
}
/**
* 维修工单表 结算
*
* @param repairTicketsRespVO 工单
* @author 小李
* @date 8:50 2024/9/23
* @param repairTicketsRespVO 工单
**/
@Override
public void setTicketsPaid(DlRepairTicketsRespVO repairTicketsRespVO){
baseMapper.updateById(repairTicketsRespVO);
}
/**
* 维修工单表 评价
*
* @author 小李
* @date 10:54 2024/9/23
* @param repairTicketsRespVO 对象
**/
@Override
public void setAppraise(DlRepairTicketsRespVO repairTicketsRespVO){
// 如果用户什么评价也没输入给个默认评价
if (ObjectUtil.isEmpty(repairTicketsRespVO.getAppraise())){
repairTicketsRespVO.setIsAppraise("未输入评价内容");
}
// 如果用户没选择评分给个默认评分理论讲前端直接给以防万一
if (ObjectUtil.isEmpty(repairTicketsRespVO.getAppraiseScope())){
repairTicketsRespVO.setAppraiseScope(5);
}
repairTicketsRespVO.setIsAppraise("1");
public void setTicketsPaid(DlRepairTicketsRespVO repairTicketsRespVO) {
baseMapper.updateById(repairTicketsRespVO);
}
}

View File

@ -33,4 +33,24 @@
</if>
</where>
</select>
<select id="getOrderPageByStatus" resultType="cn.iocoder.yudao.module.project.vo.RepairOrderInfoRespVO">
select roi.*,drt.tickets_work_status as status from repair_order_info roi left join dl_repair_tickets drt on
roi.goods_id = drt.id
where roi.deleted = '0'
<if test="map.userId != null and map.userId != ''">
and roi.user_id = #{map.userId}
</if>
<if test="map.status != null and map.status != ''">
<choose>
<when test="map.status != '00'">
drt.tickets_work_status = #{map.status}
</when>
<when test="map.status == '00'">
roi.comment_time is null
</when>
</choose>
</if>
order by roi.create_time desc
</select>
</mapper>

View File

@ -42,8 +42,6 @@
<result property="profit" column="profit" />
<result property="partStatus" column="part_status" />
<result property="ticketsWorkStatus" column="tickets_work_status" />
<result property="appraise" column="appraise" />
<result property="appraiseScope" column="appraise_scope" />
</resultMap>
<sql id="Base_SQL">
@ -83,9 +81,7 @@
cost,
profit,
part_status,
tickets_work_status,
appraise,
appraise_scope
tickets_work_status
from dl_repair_tickets drt
where drt.deleted = '0'
</sql>
@ -123,9 +119,6 @@
<if test="map.userId != null and map.userId != ''">
and drt.user_id = #{map.userId}
</if>
<if test="map.isAppraise != null and map.isAppraise != ''">
and drt.is_appraise = #{map.isAppraise}
</if>
<if test="map.ticketsWorkStatus != null and map.ticketsWorkStatus != ''">
and drt.tickets_work_status = #{map.ticketsWorkStatus}
</if>