Commit 07a49211 by zhuht

[chg]项目管理查询返回值中增加合同数和服务单数;查询支持name模糊搜索;增加分页查询服务单接口;

1 parent a5cc8d5d
......@@ -3,15 +3,18 @@ package vion.controller;
import cn.dev33.satoken.annotation.SaCheckPermission;
import cn.hutool.core.lang.Assert;
import cn.hutool.core.util.IdUtil;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.github.linpeilie.Converter;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
import vion.dto.ServiceOrderDTO;
import vion.dto.StoreDTO;
import vion.model.Dictionary;
import vion.model.ServiceOrder;
import vion.service.IDictionaryService;
import vion.service.IServiceOrderService;
import vion.vo.ServiceOrderVO;
import vion.vo.StoreVO;
import java.util.List;
import java.util.Map;
......@@ -32,6 +35,12 @@ public class ServiceOrderController {
private final IDictionaryService dictionaryService;
private final Converter converter;
@GetMapping("/orders")
@SaCheckPermission(value = "order:list", orRole="admin")
public Page<ServiceOrderVO> getServiceOrderList(ServiceOrderDTO data) {
return serviceOrderService.getServiceOrderList(data);
}
@GetMapping("/order/{id}")
@SaCheckPermission(value = "order:query", orRole = "admin")
public ServiceOrder getOrderById(@PathVariable Long id) {
......
......@@ -12,6 +12,7 @@ import vion.service.IFaultLogService;
import vion.service.ITaskService;
import vion.vo.TaskVO;
import java.util.Date;
import java.util.List;
@RestController
......@@ -44,10 +45,21 @@ public class TaskController {
@GetMapping("/faultLogs")
@SaCheckPermission(value = "task:log:list", orRole = "admin")
public List<FaultLog> getFaultLogById(Integer storeId, Integer taskId) {
return faultLogService.lambdaQuery()
List<FaultLog> faultLogList = faultLogService.lambdaQuery()
.eq(FaultLog::getStoreId, storeId)
.eq(FaultLog::getTaskId, taskId)
.orderByAsc(FaultLog::getCreateTime)
.list();
TaskVO taskVO = taskService.getTaskById(Long.valueOf(taskId));
// 进行中的任务,在最后追加一条当前处理人正在处理的记录,仅做显示用
if (taskVO.getStatus() == 2) {
FaultLog faultLog = new FaultLog();
faultLog.setOperator(taskVO.getActiveUser());
faultLog.setCreateTime(new Date());
faultLogList.add(faultLog);
}
return faultLogList;
}
}
package vion.dto;
import com.baomidou.mybatisplus.annotation.TableField;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Getter;
import lombok.Setter;
......@@ -116,4 +117,14 @@ public class ContractDTO extends BaseDTO {
private MultipartFile[] files;
/**
* 合同质保周期(月)
*/
private Integer warrantyPeriod;
/**
* 项目id
*/
private Long storeId;
}
\ No newline at end of file
......@@ -70,5 +70,6 @@ public class ServiceOrderDTO extends BaseDTO {
/** 完成时间 */
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date finishTime;
/** 项目id */
private Long storeId;
}
......@@ -138,4 +138,10 @@ public class Contract {
*/
@TableField(value = "modify_time", fill = FieldFill.INSERT_UPDATE)
private Date modifyTime;
/**
* 合同质保周期(月)
*/
@TableField(value = "warranty_period")
private Integer warrantyPeriod;
}
\ No newline at end of file
package vion.service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.github.yulichang.base.MPJBaseService;
import vion.dto.ServiceOrderDTO;
import vion.model.ServiceOrder;
import vion.vo.ServiceOrderVO;
/**
* @author HlQ
......@@ -10,4 +13,7 @@ import vion.model.ServiceOrder;
public interface IServiceOrderService extends MPJBaseService<ServiceOrder> {
String sendOrder(Long id);
Page<ServiceOrderVO> getServiceOrderList(ServiceOrderDTO data);
}
......@@ -6,6 +6,9 @@ import cn.hutool.core.io.FileUtil;
import cn.hutool.core.lang.Opt;
import cn.hutool.core.util.ObjUtil;
import cn.hutool.crypto.SecureUtil;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.github.yulichang.base.MPJBaseServiceImpl;
import io.github.linpeilie.Converter;
......@@ -14,8 +17,10 @@ import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import vion.dto.ContractDTO;
import vion.mapper.ContractMapper;
import vion.mapper.RContractStoreMapper;
import vion.model.Contract;
import vion.model.FileInfo;
import vion.model.RContractStore;
import vion.service.IContractPaymentService;
import vion.service.IContractService;
import vion.service.IFileService;
......@@ -27,6 +32,7 @@ import java.io.IOException;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;
/**
* @author HlQ
......@@ -39,13 +45,29 @@ public class ContractServiceImpl extends MPJBaseServiceImpl<ContractMapper, Cont
private final IFileService fileService;
private final IContractPaymentService contractPaymentService;
private final Converter converter;
private final RContractStoreMapper rContractStoreMapper;
@Value("${fileUrl:}")
private String fileUrl;
@Override
public Page<ContractVO> list(ContractDTO dto) {
Page<Contract> contractList = this.lambdaQuery(converter.convert(dto, new Contract()))
Contract contract = converter.convert(dto, new Contract());
String name = contract.getName();
contract.setName(null);
List<Long> ids = null;
if (dto.getStoreId() != null) {
ids = rContractStoreMapper.selectList(Wrappers.lambdaQuery(RContractStore.class)
.select(RContractStore::getContractId)
.eq(RContractStore::getStoreId, dto.getStoreId()))
.stream().map(RContractStore::getContractId).collect(Collectors.toList());
if (ids.isEmpty()) {
ids.add(-1L);
}
}
Page<Contract> contractList = this.lambdaQuery(contract)
.in(CollectionUtils.isNotEmpty(ids), Contract::getId, ids)
.like(StringUtils.isNotBlank(name), Contract::getName, name)
.page(Page.of(dto.getPageNum(), dto.getPageSize()));
List<ContractVO> contractVOList = converter.convert(contractList.getRecords(), ContractVO.class);
return Page.<ContractVO>of(contractList.getCurrent(), contractList.getSize(), contractList.getTotal()).setRecords(contractVOList);
......
......@@ -2,10 +2,15 @@ package vion.service.impl;
import cn.hutool.core.collection.ListUtil;
import cn.hutool.core.lang.Opt;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.github.yulichang.base.MPJBaseServiceImpl;
import io.github.linpeilie.Converter;
import lombok.RequiredArgsConstructor;
import me.chanjar.weixin.mp.bean.template.WxMpTemplateData;
import org.springframework.stereotype.Service;
import vion.dto.ServiceOrderDTO;
import vion.mapper.ServiceOrderMapper;
import vion.model.ServiceOrder;
import vion.model.Task;
......@@ -13,8 +18,10 @@ import vion.service.IServiceOrderService;
import vion.service.ITaskService;
import vion.service.ITaskTempService;
import vion.third.WechatMod;
import vion.vo.ServiceOrderVO;
import java.util.List;
import java.util.stream.Collectors;
/**
* @author HlQ
......@@ -27,6 +34,7 @@ public class ServiceOrderServiceImpl extends MPJBaseServiceImpl<ServiceOrderMapp
private final ITaskService taskService;
private final ITaskTempService taskTempService;
private final WechatMod wechatMod;
private final Converter converter;
@Override
public String sendOrder(Long id) {
......@@ -42,4 +50,22 @@ public class ServiceOrderServiceImpl extends MPJBaseServiceImpl<ServiceOrderMapp
})
.orElse("微信公众号消息推送失败,请检查工单是否绑定微信用户或联系管理员!");
}
@Override
public Page<ServiceOrderVO> getServiceOrderList(ServiceOrderDTO data) {
ServiceOrder serviceOrder = converter.convert(data, new ServiceOrder());
List<Long> taskIds = null;
if (data.getStoreId() != null) {
taskIds = taskService.getBaseMapper().selectList(Wrappers.lambdaQuery(Task.class)
.select(Task::getId).eq(Task::getStoreId, data.getStoreId()))
.stream().map(Task::getId).collect(Collectors.toList());
}
Page<ServiceOrder> serviceOrderPage = this.lambdaQuery(serviceOrder)
.in(CollectionUtils.isNotEmpty(taskIds), ServiceOrder::getTaskId, taskIds)
.page(Page.of(data.getPageNum(), data.getPageSize()));
List<ServiceOrderVO> orderVOList = serviceOrderPage.getRecords().stream().map(order -> converter.convert(order, new ServiceOrderVO())).collect(Collectors.toList());
return Page.<ServiceOrderVO>of(data.getPageNum(), data.getPageSize(), serviceOrderPage.getTotal()).setRecords(orderVOList);
}
}
......@@ -8,6 +8,7 @@ import cn.hutool.core.lang.Opt;
import cn.hutool.core.map.MapUtil;
import cn.hutool.core.util.ArrayUtil;
import cn.hutool.crypto.SecureUtil;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.github.yulichang.base.MPJBaseServiceImpl;
......@@ -19,7 +20,9 @@ import org.springframework.web.multipart.MultipartFile;
import vion.Global;
import vion.dto.StatusDTO;
import vion.dto.StoreDTO;
import vion.mapper.ServiceOrderMapper;
import vion.mapper.StoreMapper;
import vion.mapper.TaskMapper;
import vion.model.*;
import vion.service.*;
import vion.vo.StoreVO;
......@@ -39,13 +42,20 @@ public class StoreServiceImpl extends MPJBaseServiceImpl<StoreMapper, Store> imp
private final IContractService contractService;
private final IFileService fileService;
private final Converter converter;
// 引入 taskService 会循环依赖
private final TaskMapper taskMapper;
private final ServiceOrderMapper serviceOrderMapper;
@Value("${fileUrl:}")
private String fileUrl;
@Override
public Page<StoreVO> getStoreList(StoreDTO data) {
Page<Store> storeList = this.lambdaQuery(converter.convert(data, new Store()))
Store store = converter.convert(data, new Store());
String name = store.getName();
store.setName(null);
Page<Store> storeList = this.lambdaQuery(store)
.like(StringUtils.isNotBlank(name), Store::getName, name)
.between(data.getStartdate() != null && data.getEnddate() != null, Store::getOrderdate, data.getStartdate(), data.getEnddate())
.page(Page.of(data.getPageNum(), data.getPageSize()));
// todo 缓存
......@@ -69,6 +79,20 @@ public class StoreServiceImpl extends MPJBaseServiceImpl<StoreMapper, Store> imp
})
.orElse(MapUtil.empty());
Map<Long, List<Long>> storeTaskIdMap = Opt.ofEmptyAble(storeIdList)
.map(l -> taskMapper.selectList(Wrappers.lambdaQuery(Task.class).in(Task::getStoreId, l))
.stream()
.collect(Collectors.groupingBy(Task::getStoreId, Collectors.mapping(Task::getId, Collectors.toList()))))
.orElse(MapUtil.empty());
List<Long> taskIds = storeTaskIdMap.values().stream()
.flatMap(List::stream)
.collect(Collectors.toList());
Map<Long, List<ServiceOrder>> taskServiceOrderMap = Opt.ofEmptyAble(taskIds)
.map(t -> serviceOrderMapper.selectList(Wrappers.lambdaQuery(ServiceOrder.class).in(ServiceOrder::getTaskId, taskIds))
.stream()
.collect(Collectors.groupingBy(ServiceOrder::getTaskId)))
.orElse(MapUtil.empty());
List<StoreVO> storeVOList = new ArrayList<>();
storeList.getRecords().forEach(item -> {
......@@ -93,6 +117,14 @@ public class StoreServiceImpl extends MPJBaseServiceImpl<StoreMapper, Store> imp
}
});
storeVO.setMaintainStatus(CollUtil.isEmpty(maintainStatusSet) ? "--" : maintainStatusSet.contains(true) ? "在保" : "脱保");
storeVO.setContractCount(contractIds.size());
}
// 补充服务单
if (storeTaskIdMap.containsKey(item.getId())) {
List<ServiceOrder> serviceOrders = storeTaskIdMap.get(item.getId())
.stream().flatMap(taskId -> taskServiceOrderMap.getOrDefault(taskId, ListUtil.empty()).stream())
.collect(Collectors.toList());
storeVO.setServiceOrderCount(serviceOrders.size());
}
storeVOList.add(storeVO);
......
......@@ -7,6 +7,7 @@ import cn.hutool.core.util.StrUtil;
import cn.hutool.crypto.SecureUtil;
import cn.hutool.json.JSONArray;
import cn.hutool.json.JSONObject;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.github.yulichang.base.MPJBaseServiceImpl;
import com.github.yulichang.wrapper.MPJLambdaWrapper;
......@@ -15,8 +16,10 @@ import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import vion.dto.TaskTempDTO;
import vion.mapper.TaskMapper;
import vion.mapper.TaskTempMapper;
import vion.model.FileInfo;
import vion.model.Task;
import vion.model.TaskTemp;
import vion.model.User;
import vion.service.IFileService;
......@@ -42,6 +45,7 @@ public class TaskTempServiceImpl extends MPJBaseServiceImpl<TaskTempMapper, Task
private final DingMod dingMod;
private final WechatMod wechatMod;
private final Converter converter;
private final TaskMapper taskMapper;
@Value("${fileUrl:}")
private String fileUrl;
......@@ -65,7 +69,12 @@ public class TaskTempServiceImpl extends MPJBaseServiceImpl<TaskTempMapper, Task
.eq(FileInfo::getSourceId, TaskTemp::getId)
.eq(FileInfo::getStoreId, 0L))
.eq(TaskTemp::getId, id);
return this.selectJoinOne(TaskTempVO.class, wrapper);
TaskTempVO taskTempVO = this.selectJoinOne(TaskTempVO.class, wrapper);
List<Task> tasks = taskMapper.selectList(Wrappers.lambdaQuery(Task.class).eq(Task::getTaskTempId, id));
if (!tasks.isEmpty()) {
taskTempVO.setTask(tasks.get(0));
}
return taskTempVO;
}
@Override
......
package vion.vo;
import com.baomidou.mybatisplus.annotation.TableField;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Getter;
import lombok.Setter;
......@@ -112,4 +113,9 @@ public class ContractVO {
*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date modifyTime;
/**
* 合同质保周期(月)
*/
private Integer warrantyPeriod;
}
\ No newline at end of file
package vion.vo;
import com.baomidou.mybatisplus.annotation.TableField;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import vion.model.Contract;
import vion.model.ServiceOrder;
import java.util.Date;
import java.util.List;
@Data
public class StoreVO {
......@@ -72,4 +76,15 @@ public class StoreVO {
private Long fileNum;
/** 维保状态(在保、脱保、--) */
private String maintainStatus;
/**
* 门店的合同信息
*/
private Integer contractCount;
/**
* 工单下的服务单
*/
private Integer serviceOrderCount;
}
......@@ -3,6 +3,7 @@ package vion.vo;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import vion.model.FileInfo;
import vion.model.Task;
import java.util.Date;
import java.util.List;
......@@ -30,4 +31,9 @@ public class TaskTempVO {
private Date modifyTime;
private String remark;
private List<FileInfo> fileList;
/**
* 确认后的工单。可能不存在
*/
private Task task;
}
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!