Merge branch 'dev' of http://122.51.230.86:3000/dianliang/lanan-system into dev
This commit is contained in:
commit
f1e4b9af3e
@ -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";
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@ -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;
|
||||
|
||||
}
|
||||
|
@ -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);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -11,5 +11,7 @@ import lombok.ToString;
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class RepairRecordsPageReqVO extends RepairRecords {
|
||||
/**是否开放给用户*/
|
||||
private String isOpen;
|
||||
|
||||
}
|
||||
|
@ -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;
|
||||
|
||||
}
|
||||
|
@ -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;
|
||||
|
||||
|
||||
}
|
||||
|
@ -126,8 +126,7 @@ public class RepairWaresController {
|
||||
@GetMapping("/getByName")
|
||||
@Operation(summary = "根据名称获取最新的数据")
|
||||
public CommonResult<?> getWaresByName(@RequestParam("name") String name) {
|
||||
List<RepairWares> list = waresService.list(new LambdaQueryWrapper<RepairWares>().eq(RepairWares::getName, name));
|
||||
return success(list.stream().max(Comparator.comparing(RepairWares::getCreateTime)).orElse(null));
|
||||
return success(waresService.getWaresByName(name));
|
||||
}
|
||||
|
||||
|
||||
|
@ -102,5 +102,7 @@ public class RepairWares extends TenantBaseDO {
|
||||
private String status;
|
||||
/**数据来源*/
|
||||
private String dataForm;
|
||||
/** 进价 */
|
||||
private String purPrice;
|
||||
|
||||
}
|
@ -28,4 +28,11 @@ public interface RepairWaresMapper extends BaseMapper<RepairWares> {
|
||||
**/
|
||||
IPage<RepairWaresRespVO> queryListPage(@Param("entity") RepairWaresPageReqVO pageReqVO, Page<RepairWaresRespVO> page);
|
||||
|
||||
/**
|
||||
* 根据名称获取最新的数据
|
||||
*
|
||||
* @author 小李
|
||||
* @date 18:03 2024/9/25
|
||||
**/
|
||||
RepairWaresRespVO getWaresByName(@Param("name") String name);
|
||||
}
|
@ -53,4 +53,11 @@ public interface RepairWaresService extends IService<RepairWares> {
|
||||
**/
|
||||
IPage<RepairWaresRespVO> getWaresPage(RepairWaresPageReqVO pageReqVO, Page<RepairWaresRespVO> page);
|
||||
|
||||
/**
|
||||
* 根据名称获取最新的数据
|
||||
*
|
||||
* @author 小李
|
||||
* @date 18:03 2024/9/25
|
||||
**/
|
||||
RepairWaresRespVO getWaresByName(String name);
|
||||
}
|
@ -89,4 +89,15 @@ public class RepairWaresServiceImpl extends ServiceImpl<RepairWaresMapper, Repai
|
||||
return waresMapper.queryListPage(pageReqVO, page);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据名称获取最新的数据
|
||||
*
|
||||
* @author 小李
|
||||
* @date 18:03 2024/9/25
|
||||
**/
|
||||
@Override
|
||||
public RepairWaresRespVO getWaresByName(String name){
|
||||
return waresMapper.getWaresByName(name);
|
||||
}
|
||||
|
||||
}
|
@ -7,6 +7,8 @@ import cn.iocoder.yudao.common.RepairErrorCodeConstants;
|
||||
import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils;
|
||||
import cn.iocoder.yudao.module.company.entity.Company;
|
||||
import cn.iocoder.yudao.module.company.service.CompanyService;
|
||||
import cn.iocoder.yudao.module.project.entity.RepairWares;
|
||||
import cn.iocoder.yudao.module.project.service.RepairWaresService;
|
||||
import cn.iocoder.yudao.module.stockOperate.entity.DlRepairSo;
|
||||
import cn.iocoder.yudao.module.stockOperate.entity.DlRepairSoi;
|
||||
import cn.iocoder.yudao.module.stockOperate.mapper.DlRepairSoMapper;
|
||||
@ -18,14 +20,18 @@ import cn.iocoder.yudao.module.system.api.dept.DeptApi;
|
||||
import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO;
|
||||
import com.baomidou.dynamic.datasource.annotation.DSTransactional;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
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.stream.Collectors;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
|
||||
@ -48,6 +54,10 @@ public class DlRepairSoServiceImpl extends ServiceImpl<DlRepairSoMapper, DlRepai
|
||||
@Resource
|
||||
private CompanyService companyService;
|
||||
|
||||
@Resource
|
||||
@Lazy
|
||||
private RepairWaresService waresService;
|
||||
|
||||
/**
|
||||
* 采购单/领料单 新增
|
||||
* @author 小李
|
||||
@ -65,7 +75,9 @@ public class DlRepairSoServiceImpl extends ServiceImpl<DlRepairSoMapper, DlRepai
|
||||
if (ObjectUtil.isNotEmpty(dept)){
|
||||
repairSoRespVO.setCorpId(dept.getCorpId());
|
||||
Company company = companyService.getById(dept.getCorpId());
|
||||
repairSoRespVO.setCorpName(company.getCorpName());
|
||||
if (ObjectUtil.isNotEmpty(company)){
|
||||
repairSoRespVO.setCorpName(company.getCorpName());
|
||||
}
|
||||
}
|
||||
|
||||
// 新增主表
|
||||
@ -76,9 +88,31 @@ public class DlRepairSoServiceImpl extends ServiceImpl<DlRepairSoMapper, DlRepai
|
||||
}
|
||||
repairSoRespVO.getGoodsList().forEach(item -> {
|
||||
item.setSoId(repairSoRespVO.getId());
|
||||
item.setSoiType(repairSoRespVO.getSoType());
|
||||
// item.setSoiType(repairSoRespVO.getSoType());
|
||||
});
|
||||
repairSoiService.saveBatch(repairSoRespVO.getGoodsList());
|
||||
|
||||
// 操作配件库存表
|
||||
// 获取所有需要操作的数据
|
||||
List<DlRepairSoi> goodsList = repairSoRespVO.getGoodsList();
|
||||
List<String> ids = goodsList.stream().map(DlRepairSoi::getGoodsId).collect(Collectors.toList());
|
||||
List<RepairWares> repairWares = waresService.listByIds(ids);
|
||||
// 更新库存和进价
|
||||
List<RepairWares> newWares = repairWares.stream().map(item -> {
|
||||
// 取数据
|
||||
DlRepairSoi repairSoi = goodsList.stream().filter(i -> i.getGoodsId().equals(item.getId())).collect(Collectors.toList()).get(0);
|
||||
// 设置新值
|
||||
// 如果是采购入库,数量+,如果是领料出库,数量-
|
||||
// 01, 03 是采购 02 是领料
|
||||
BigDecimal count = new BigDecimal(repairSoi.getGoodsCount());
|
||||
RepairWares wares = new RepairWares();
|
||||
wares.setId(item.getId());
|
||||
wares.setStock("02".equals(repairSoRespVO.getSoType()) ? item.getStock().subtract(count) : item.getStock().add(count));
|
||||
// 更新进价
|
||||
wares.setPurPrice(repairSoi.getGoodsPrice().toString());
|
||||
return wares;
|
||||
}).collect(Collectors.toList());
|
||||
waresService.updateBatchById(newWares);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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>
|
||||
|
@ -30,4 +30,18 @@
|
||||
ORDER BY
|
||||
drw.create_time DESC
|
||||
</select>
|
||||
|
||||
<select id="getWaresByName" resultType="cn.iocoder.yudao.module.project.vo.RepairWaresRespVO">
|
||||
SELECT
|
||||
drw.*,
|
||||
dbt.`name` AS typeName,
|
||||
dbw.`name` AS warehouseName,
|
||||
GROUP_CONCAT( bc.corp_name ) AS corpNames
|
||||
FROM
|
||||
dl_repair_wares drw
|
||||
LEFT JOIN base_company bc ON FIND_IN_SET( bc.id, drw.corp_id ) > 0
|
||||
LEFT JOIN dl_base_type dbt ON drw.type = dbt.id AND dbt.deleted = 0
|
||||
LEFT JOIN dl_base_warehouse dbw ON drw.warehouse = dbw.id AND dbw.deleted = 0
|
||||
where drw.name = #{name} order by drw.create_time desc limit 1
|
||||
</select>
|
||||
</mapper>
|
Loading…
Reference in New Issue
Block a user