Compare commits

...

2 Commits

Author SHA1 Message Date
PQZ
ce7393652a Merge branch 'dev' of http://122.51.230.86:3000/dianliang/lanan-system into dev 2024-10-11 16:55:08 +08:00
PQZ
fb27a36be1 1 2024-10-11 16:55:06 +08:00
11 changed files with 270 additions and 31 deletions

View File

@ -94,6 +94,8 @@ public class BaseConstants {
public static final String ORDER_KKYL = "3";
/**订单店铺名称*/
public static final String ORDER_TENANT_NAME = "蓝安集团";
/**------工单记录常量-----------*/
/**工单*/
public static final String REPAIR_RECORD_TYPE_TICKET = "ticket";
/**工单附属项目*/
@ -101,4 +103,21 @@ public class BaseConstants {
/**维修记录*/
public static final String REPAIR_RECORD_TYPE_RECORD = "record";
/**创建工单*/
public static final String REPAIR_RECORD_TYPE_CJGD = "cjgd";
/**指派施工*/
public static final String REPAIR_RECORD_TYPE_ZPSG = "zpsg";
/**领料*/
public static final String REPAIR_RECORD_TYPE_LL = "ll";
/**退料*/
public static final String REPAIR_RECORD_TYPE_TL = "tl";
/**施工完成(自检)*/
public static final String REPAIR_RECORD_TYPE_SGWCZJ = "sgwczj";
/**总检*/
public static final String REPAIR_RECORD_TYPE_ZJ = "zj";
/**结束工单*/
public static final String REPAIR_RECORD_TYPE_JSGD = "jsgd";
}

View File

@ -41,10 +41,6 @@ public class RepairRecords extends TenantBaseDO {
* 记录描述
*/
private String remark;
/**
* 过程记录中的图片多个拼接
*/
private String image;
/**
* 处理人
*/
@ -52,6 +48,6 @@ public class RepairRecords extends TenantBaseDO {
/**
* 处理人员工表id
*/
private String dealUserId;
private Long dealUserId;
}

View File

@ -17,6 +17,15 @@ import java.util.List;
@Mapper
public interface RepairRecordsMapper extends BaseMapper<RepairRecords> {
/**
* 查询维修记录
* @author lzt
* @param entity 查询条件
* @return List<RepairRecordsRespVO>
* @date 2024年10月9日
*/
List<RepairRecordsRespVO> queryRepairRecords(@Param("entity") RepairRecordsPageReqVO entity);
}

View File

@ -3,6 +3,8 @@ package cn.iocoder.yudao.module.base.service;
import cn.iocoder.yudao.module.base.entity.RepairRecordsItem;
import com.baomidou.mybatisplus.extension.service.IService;
import java.util.List;
/**
* 维修记录 Service 接口
*
@ -20,4 +22,37 @@ public interface RepairRecordsItemService extends IService<RepairRecordsItem> {
**/
void removeByMainId(String mainType, String mainId);
/**
* 通过主表id查询图片
*
* @param mainType ticket工单repairItem工单附属项目record维修记录
* @param mainId 主表id
* @param isOpen 是否开放给用户默认查询全部如不为null则根据条件查询
* @return 记录图片集合
* @author PQZ
* @date 14:30 2024/10/11
**/
List<RepairRecordsItem> getByMainId(String mainType, String mainId, String isOpen);
/**
* 保存维修记录相关的图片
*
* @param recordId 记录id
* @param ticketId 工单id
* @param repairItemId 工单子表id
* @param image 上传附件相对路径多个用分隔
* @author PQZ
* @date 14:09 2024/10/11
**/
void saveItem(String recordId, String ticketId, String repairItemId, String image);
/**
* 设置图片是否开放给用户
*
* @param ids 前端选中图片id多个用分隔
* @param isOpen 0否1是
* @author PQZ
* @date 14:22 2024/10/11
**/
void setRepairOpen(String ids, String isOpen);
}

View File

@ -3,13 +3,8 @@ package cn.iocoder.yudao.module.base.service;
import cn.iocoder.yudao.module.base.entity.RepairRecords;
import cn.iocoder.yudao.module.base.vo.RepairRecordsPageReqVO;
import cn.iocoder.yudao.module.base.vo.RepairRecordsRespVO;
import cn.iocoder.yudao.module.base.vo.RepairRecordsSaveReqVO;
import cn.iocoder.yudao.module.base.vo.RepairWorkerPageReqVO;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import javax.validation.Valid;
import java.util.List;
/**
@ -20,11 +15,25 @@ import java.util.List;
public interface RepairRecordsService extends IService<RepairRecords> {
/**
* 创建维修记录
* 保存维修记录
*
* @param ticketId 工单id
* @param repairItemId 工单子表id
* @param type 工作类型数据字典repair_records_type;后端已初始化常量可直接引用base包中BaseConstants下106-119行
* @param remark 备注
* @param images 图片(相对路径按照分隔)
* @author PQZ
* @date 11:41 2024/10/11
* @param saveReqVO RepairRecordsSaveReqVO实体
* @date 14:51 2024/10/11
**/
void saveRepairRecord(String ticketId, String repairItemId, String type, String remark, String images);
/**
* 根据条件查询维修记录
* @author PQZ
* @date 15:14 2024/10/11
* @param pageReqVO RepairRecordsPageReqVO实体
* @return java.util.List<cn.iocoder.yudao.module.base.vo.RepairRecordsRespVO>
**/
void saveRepairRecord(RepairRecordsSaveReqVO saveReqVO);
List<RepairRecordsRespVO> queryList(RepairRecordsPageReqVO pageReqVO);
}

View File

@ -1,15 +1,20 @@
package cn.iocoder.yudao.module.base.service.impl;
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
import cn.iocoder.yudao.module.base.entity.RepairRecordsItem;
import cn.iocoder.yudao.module.base.mapper.RepairRecordsItemMapper;
import cn.iocoder.yudao.module.base.service.RepairRecordsItemService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
import static cn.iocoder.yudao.common.BaseConstants.*;
@ -36,6 +41,97 @@ public class RepairRecordsItemServiceImpl extends ServiceImpl<RepairRecordsItemM
**/
@Override
public void removeByMainId(String mainType, String mainId) {
//根据不同类型初始化不通过查询条件
LambdaQueryWrapper<RepairRecordsItem> lambdaQueryWrapper = queryType(mainType, mainId);
remove(lambdaQueryWrapper);
}
/**
* 通过主表id查询图片
*
* @param mainType ticket工单repairItem工单附属项目record维修记录
* @param mainId 主表id
* @param isOpen 是否开放给用户默认查询全部如不为null则根据条件查询
* @return 记录图片集合
* @author PQZ
* @date 14:30 2024/10/11
**/
@Override
public List<RepairRecordsItem> getByMainId(String mainType, String mainId, String isOpen) {
//根据不同类型初始化不通过查询条件
LambdaQueryWrapper<RepairRecordsItem> lambdaQueryWrapper = queryType(mainType, mainId);
//默认查询全部如不为null则根据条件查询
if (StringUtils.isNotEmpty(isOpen)) {
lambdaQueryWrapper.eq(RepairRecordsItem::getIsOpen, isOpen);
}
return list(lambdaQueryWrapper);
}
/**
* 保存维修记录相关的图片
*
* @param recordId 记录id
* @param ticketId 工单id
* @param repairItemId 工单子表id
* @param image 上传附件相对路径多个用分隔
* @author PQZ
* @date 14:09 2024/10/11
**/
@Override
public void saveItem(String recordId, String ticketId, String repairItemId, String image) {
//根据记录id删除改记录中原有的图片
removeByMainId(REPAIR_RECORD_TYPE_RECORD, recordId);
//组装维修记录图片集合
List<RepairRecordsItem> saveList = new ArrayList<>();
if (StringUtils.isNotEmpty(image)) {
//字符串转换集合
List<String> imageList = Arrays.stream(image.split(","))
.collect(Collectors.toList());
imageList.forEach(item -> {
RepairRecordsItem saveItem = new RepairRecordsItem();
saveItem.setRecordId(recordId);
saveItem.setTicketId(ticketId);
saveItem.setRepairItemId(repairItemId);
saveItem.setImage(item);
saveList.add(saveItem);
});
saveBatch(saveList);
}
}
/**
* 设置图片是否开放给用户
*
* @param ids 前端选中图片id多个用分隔
* @param isOpen 0否1是
* @author PQZ
* @date 14:22 2024/10/11
**/
@Override
public void setRepairOpen(String ids, String isOpen) {
if (StringUtils.isNotEmpty(ids)) {
//id字符串转换集合
List<String> idList = Arrays.stream(ids.split(","))
.collect(Collectors.toList());
LambdaUpdateWrapper<RepairRecordsItem> lambdaUpdateWrapper = new LambdaUpdateWrapper<>();
//设置更新条件
lambdaUpdateWrapper.in(RepairRecordsItem::getId, idList).set(RepairRecordsItem::getIsOpen, isOpen);
//更新
update(lambdaUpdateWrapper);
}
}
/**
* 封装查询条件
*
* @param mainType ticket工单repairItem工单附属项目record维修记录
* @param mainId 主表id
* @return com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper<cn.iocoder.yudao.module.base.entity.RepairRecordsItem>
* @author PQZ
* @date 14:36 2024/10/11
**/
private LambdaQueryWrapper<RepairRecordsItem> queryType(String mainType, String mainId) {
LambdaQueryWrapper<RepairRecordsItem> lambdaQueryWrapper = new LambdaQueryWrapper<>();
switch (mainType) {
//匹配根据工单表id删除条件
@ -44,15 +140,15 @@ public class RepairRecordsItemServiceImpl extends ServiceImpl<RepairRecordsItemM
break;
//匹配根据工单子表id删除条件
case REPAIR_RECORD_TYPE_REPAIR_ITEM:
lambdaQueryWrapper.eq(RepairRecordsItem::getRepairItemId,mainId);
lambdaQueryWrapper.eq(RepairRecordsItem::getRepairItemId, mainId);
break;
//匹配根据根据记录表id删除条件
case REPAIR_RECORD_TYPE_RECORD:
lambdaQueryWrapper.eq(RepairRecordsItem::getRecordId,mainId);
lambdaQueryWrapper.eq(RepairRecordsItem::getRecordId, mainId);
break;
default:
break;
}
remove(lambdaQueryWrapper);
return lambdaQueryWrapper;
}
}

View File

@ -1,14 +1,24 @@
package cn.iocoder.yudao.module.base.service.impl;
import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils;
import cn.iocoder.yudao.module.base.entity.RepairRecords;
import cn.iocoder.yudao.module.base.entity.RepairRecordsItem;
import cn.iocoder.yudao.module.base.mapper.RepairRecordsMapper;
import cn.iocoder.yudao.module.base.service.RepairRecordsItemService;
import cn.iocoder.yudao.module.base.service.RepairRecordsService;
import cn.iocoder.yudao.module.base.vo.RepairRecordsSaveReqVO;
import cn.iocoder.yudao.module.base.vo.RepairRecordsPageReqVO;
import cn.iocoder.yudao.module.base.vo.RepairRecordsRespVO;
import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;
import javax.annotation.Resource;
import java.util.List;
import java.util.stream.Collectors;
import static cn.iocoder.yudao.common.BaseConstants.REPAIR_RECORD_TYPE_RECORD;
/**
* 维修记录 Service 实现类
@ -21,17 +31,61 @@ public class RepairRecordsServiceImpl extends ServiceImpl<RepairRecordsMapper, R
@Resource
private RepairRecordsMapper repairRecordsMapper;
@Resource
private AdminUserApi userApi;
@Resource
private RepairRecordsItemService itemService;
/**
* 创建维修记录
* 保存维修记录
*
* @param saveReqVO RepairRecordsSaveReqVO实体
* @param ticketId 工单id
* @param repairItemId 工单子表id
* @param type 工作类型数据字典repair_records_type;后端已初始化常量可直接引用base包中BaseConstants下106-119行
* @param remark 备注
* @param images 图片(相对路径按照分隔)
* @author PQZ
* @date 11:41 2024/10/11
* @date 14:51 2024/10/11
**/
@Override
public void saveRepairRecord(RepairRecordsSaveReqVO saveReqVO) {
public void saveRepairRecord(String ticketId, String repairItemId, String type, String remark, String images) {
//获取当前登录用户
Long userId = SecurityFrameworkUtils.getLoginUserId();
AdminUserRespDTO loginUser = userApi.getUser(userId);
//初始化维修记录
RepairRecords repairRecords = new RepairRecords();
repairRecords.setTicketId(ticketId);
repairRecords.setRepairItemId(repairItemId);
repairRecords.setType(type);
repairRecords.setRemark(remark);
repairRecords.setDealUserId(loginUser.getId());
repairRecords.setDealUserName(loginUser.getNickname());
//保存维修记录
save(repairRecords);
//保存附件信息
itemService.saveItem(repairRecords.getId(), ticketId, repairItemId, images);
}
/**
* 根据条件查询维修记录
*
* @param pageReqVO RepairRecordsPageReqVO实体
* @return java.util.List<cn.iocoder.yudao.module.base.vo.RepairRecordsRespVO>
* @author PQZ
* @date 15:14 2024/10/11
**/
@Override
public List<RepairRecordsRespVO> queryList(RepairRecordsPageReqVO pageReqVO) {
//根据条件查询维修记录
List<RepairRecordsRespVO> list = repairRecordsMapper.queryRepairRecords(pageReqVO);
//为每一条维修记录设置查询附件
list.forEach(item -> {
List<RepairRecordsItem> itemList = itemService.getByMainId(REPAIR_RECORD_TYPE_RECORD, item.getId(), pageReqVO.getIsOpen());
item.setItemList(itemList);
//相对路径按照分隔
item.setImages(itemList.stream().map(RepairRecordsItem::getImage).collect(Collectors.joining(",")));
});
return list;
}
}

View File

@ -11,5 +11,7 @@ import lombok.ToString;
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class RepairRecordsPageReqVO extends RepairRecords {
/**是否开放给用户*/
private String isOpen;
}

View File

@ -1,13 +1,20 @@
package cn.iocoder.yudao.module.base.vo;
import cn.iocoder.yudao.module.base.entity.RepairRecords;
import cn.iocoder.yudao.module.base.entity.RepairRecordsItem;
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.util.List;
@Schema(description = "管理后台 - 维修记录 Response VO")
@Data
@ExcelIgnoreUnannotated
public class RepairRecordsRespVO extends RepairRecords {
/**维修记录关联子表*/
private List<RepairRecordsItem> itemList;
/**维修记录关联附件信息*/
private String images;
}

View File

@ -1,20 +1,13 @@
package cn.iocoder.yudao.module.base.vo;
import cn.iocoder.yudao.module.base.entity.RepairRecords;
import cn.iocoder.yudao.module.base.entity.RepairRecordsItem;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.util.List;
@Schema(description = "管理后台 - 维修记录新增/修改 Request VO")
@Data
public class RepairRecordsSaveReqVO extends RepairRecords {
/**维修记录附件表*/
List<RepairRecordsItem> itemList;
/**当前维修记录中需要保存的附件信息*/
String images;
}

View File

@ -9,6 +9,25 @@
文档可见https://www.iocoder.cn/MyBatis/x-plugins/
-->
<select id="queryRepairRecords" resultType="cn.iocoder.yudao.module.base.vo.RepairRecordsRespVO">
SELECT *
FROM dl_repair_records
<where>
deleted = '0'
<if test="entity.ticketId != null and entity.ticketId != ''">
AND ticket_id = #{entity.ticketId}
</if>
<if test="entity.repairItemId != null and entity.repairItemId != ''">
AND repair_item_id = #{entity.repairItemId}
</if>
<if test="entity.dealUserId != null and entity.dealUserId != ''">
AND deal_user_id = #{entity.dealUserId}
</if>
<if test="entity.type != null and entity.type != ''">
AND type = #{entity.type}
</if>
</where>
order by create_time desc
</select>
</mapper>