Merge remote-tracking branch 'origin/dev' into dev

This commit is contained in:
许允枞 2024-10-24 18:06:22 +08:00
commit ec5b1a29c1
31 changed files with 903 additions and 184 deletions

View File

@ -5,6 +5,8 @@ import javax.servlet.http.HttpServletResponse;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.util.ExcelUtil;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
@ -39,7 +41,12 @@ public class WarnMessageController extends BaseController
return success(list);
}
@GetMapping("/pageList")
public CommonResult pageList(WarnMessage warnMessage,Integer pageNo,Integer pageSize) throws Exception {
Page page =new Page(pageNo,pageSize);
IPage<WarnMessage> list = warnMessageService.pageList(page,warnMessage);
return success(list);
}
@PostMapping("/export")
public void export(HttpServletResponse response, WarnMessage warnMessage) throws Exception {
List<WarnMessage> list = warnMessageService.selectWarnMessageList(warnMessage);

View File

@ -4,7 +4,11 @@ import java.util.List;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import cn.iocoder.yudao.module.inspection.entity.WarnMessage;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
/**
* warnMsgMapper接口
@ -31,4 +35,6 @@ public interface WarnMessageMapper extends BaseMapper<WarnMessage>
*/
public List<WarnMessage> selectWarnMessageList(WarnMessage warnMessage);
IPage<WarnMessage> pageList(Page page,@Param("warnMessage") WarnMessage warnMessage);
}

View File

@ -2,6 +2,8 @@ package cn.iocoder.yudao.module.inspection.service;
import java.util.List;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import cn.iocoder.yudao.module.inspection.entity.WarnMessage;
@ -28,6 +30,7 @@ public interface IWarnMessageService extends IService<WarnMessage>
* @return warnMsg集合
*/
public List<WarnMessage> selectWarnMessageList(WarnMessage warnMessage) throws Exception;
IPage<WarnMessage> pageList(Page page,WarnMessage warnMessage) throws Exception;
/**
* 新增warnMsg

View File

@ -195,7 +195,7 @@ public class InspectionInfoServiceImpl extends ServiceImpl<InspectionInfoMapper,
customerInfo.setCustomerName(user.getNickname());
customerInfo.setSex("0");
customerInfo.setUserAge(user.getUserAge());
customerInfoService.save(customerInfo);
customerInfoService.insertPartnerCustomerInfo(customerInfo);
}
//追加订单明细记录
orderInfoDetailService.save(new OrderInfoDetail(orderInfo.getId(),"线下订单创建",new Date(),0L,"1"));

View File

@ -3,6 +3,8 @@ package cn.iocoder.yudao.module.inspection.service.impl;
import java.util.Arrays;
import java.util.List;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import cn.iocoder.yudao.util.DateUtils;
import cn.iocoder.yudao.module.inspection.service.AppInspectionPartnerService;
@ -53,6 +55,15 @@ public class WarnMessageServiceImpl extends ServiceImpl<WarnMessageMapper,WarnMe
return warnMessages;
}
@Override
public IPage<WarnMessage> pageList(Page page, WarnMessage warnMessage) throws Exception {
ShopMallPartners partners = partnerService.shopInfo();
warnMessage.setPartnerId(partners.getPartnerId());
warnMessage.setIsRead("0");
IPage<WarnMessage> warnMessages = baseMapper.pageList(page,warnMessage);
return warnMessages;
}
/**
* 新增warnMsg
*

View File

@ -1,6 +1,14 @@
package cn.iocoder.yudao.module.partner.service.impl;
import cn.hutool.core.collection.CollectionUtil;
import cn.iocoder.yudao.module.custom.entity.CarMain;
import cn.iocoder.yudao.module.custom.entity.CustomerCar;
import cn.iocoder.yudao.module.custom.entity.CustomerMain;
import cn.iocoder.yudao.module.custom.entity.UserCar;
import cn.iocoder.yudao.module.custom.service.CarMainService;
import cn.iocoder.yudao.module.custom.service.CustomerCarService;
import cn.iocoder.yudao.module.custom.service.CustomerMainService;
import cn.iocoder.yudao.module.custom.vo.CustomerMainSaveReqVO;
import cn.iocoder.yudao.module.inspection.service.AppInspectionPartnerService;
import cn.iocoder.yudao.module.partner.entity.PartnerCustomerInfo;
import cn.iocoder.yudao.module.partner.mapper.PartnerCustomerInfoMapper;
@ -27,10 +35,12 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.util.*;
import static cn.iocoder.yudao.common.BaseConstants.SIGN_CREATE;
/**
* 客户信息Service业务层处理
@ -55,6 +65,12 @@ public class PartnerCustomerInfoServiceImpl extends ServiceImpl<PartnerCustomerI
private PartnerCustomerInfoMapper customerInfoMapper;
@Autowired
private PartnerCustomerInfoMapper partnerCustomerInfoMapper;
@Resource
private CustomerMainService customerMainService;
@Autowired
private CarMainService carMainService;
@Resource
private CustomerCarService customerCarService;
/**
* 查询客户信息列表
@ -112,83 +128,179 @@ public class PartnerCustomerInfoServiceImpl extends ServiceImpl<PartnerCustomerI
@Override
@Transactional(rollbackFor = Exception.class)
public int insertPartnerCustomerInfo(PartnerCustomerInfo partnerCustomerInfo) throws Exception {
// 获取当前商户信息
ShopMallPartners partners = partnerService.shopInfo();
LambdaQueryWrapper<PartnerCustomerInfo> queryWrapper =new LambdaQueryWrapper<>();
queryWrapper.eq(PartnerCustomerInfo::getPartnerId,partners.getPartnerId()).eq(PartnerCustomerInfo::getCustomerPhone,partnerCustomerInfo.getCustomerPhone());
// 检查客户是否已存在
LambdaQueryWrapper<PartnerCustomerInfo> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(PartnerCustomerInfo::getPartnerId, partners.getPartnerId())
.eq(PartnerCustomerInfo::getCustomerPhone, partnerCustomerInfo.getCustomerPhone());
PartnerCustomerInfo customerInfo = this.getOne(queryWrapper);
if (ObjectUtils.isNotEmpty(customerInfo)){
if (ObjectUtils.isNotEmpty(customerInfo)) {
throw new Exception("客户已存在");
}
// 查找或创建用户
AdminUserDO user = userService.selectUserByPhone(partnerCustomerInfo.getCustomerPhone());
if (ObjectUtils.isEmpty(user)){
if (ObjectUtils.isEmpty(user)) {
RoleDO role = roleService.queryRole("jcyh");
UserSaveReqVO userSaveReqVO = new UserSaveReqVO();
user = new AdminUserDO();
BeanUtils.copyProperties(partnerCustomerInfo,user);
userSaveReqVO.setUsername(partnerCustomerInfo.getCustomerPhone());
userSaveReqVO.setNickname(partnerCustomerInfo.getCustomerName());
userSaveReqVO.setPassword("123456");
Long uid = userService.createUser(userSaveReqVO);
user.setId(uid);
Set<Long> ids = new HashSet<>();
ids.add(role.getId());
permissionService.assignUserRole(uid,ids);
if (role != null) {
UserSaveReqVO userSaveReqVO = new UserSaveReqVO();
user = new AdminUserDO();
BeanUtils.copyProperties(partnerCustomerInfo, user);
userSaveReqVO.setUsername(partnerCustomerInfo.getCustomerPhone());
userSaveReqVO.setNickname(partnerCustomerInfo.getCustomerName());
userSaveReqVO.setPassword("123456");
Long uid = userService.createUser(userSaveReqVO);
user.setId(uid);
Set<Long> ids = new HashSet<>();
ids.add(role.getId());
permissionService.assignUserRole(uid, ids);
} else {
throw new RuntimeException("无法找到角色 'jcyh'");
}
}
if (!StringUtils.isEmpty(partnerCustomerInfo.getCustomerPhone())&&!StringUtils.isEmpty(partnerCustomerInfo.getRoleCode())){
// 角色分配
if (!StringUtils.isEmpty(partnerCustomerInfo.getRoleCode())) {
RoleDO sysRole = roleService.queryRole(partnerCustomerInfo.getRoleCode());
Set<Long> ids = new HashSet<>();
ids.add(sysRole.getId());
permissionService.assignUserRole(user.getId(),ids);
permissionService.assignUserRole(user.getId(), ids);
}
// 车辆信息处理
List<ShopUserCar> userCarList = partnerCustomerInfo.getUserCarList();
if (CollectionUtil.isNotEmpty(userCarList)){
List<CarMain> saveCarList = new ArrayList<>();
List<CustomerCar> saveCustomerCarList = new ArrayList<>();
List<ShopUserCar> saveUserCarList = new ArrayList<>();
UserCar userCar1 = new UserCar();
if (CollectionUtil.isNotEmpty(userCarList)) {
for (ShopUserCar shopUserCar : userCarList) {
LambdaQueryWrapper<ShopUserCar> queryWrapper1 =new LambdaQueryWrapper<>();
queryWrapper1.eq(ShopUserCar::getUserId,user.getId()).eq(ShopUserCar::getCarNo,shopUserCar.getCarNo());
ShopUserCar one = userCarService.getOne(queryWrapper1);
if (ObjectUtils.isNotEmpty(one)){
//保养日期
if (null!=shopUserCar.getMaintenanceDate()){
one.setMaintenanceDate(shopUserCar.getMaintenanceDate());
}
if (null!=shopUserCar.getMaintenanceMileage()){
one.setMaintenanceMileage(shopUserCar.getMaintenanceMileage());
}
if (null!=shopUserCar.getInspectionDate()){
one.setInspectionDate(shopUserCar.getInspectionDate());
}
// 生成车辆ID
String carId = UUID.randomUUID().toString().replace("-", "");
CarMain carMain = new CarMain();
carMain.setId(carId);
carMain.setUserId(user.getId());
carMain.setLicenseNumber(shopUserCar.getCarNo());
carMain.setEngineNumber(userCar1.getEngineNumber());
carMain.setVin(userCar1.getVin());
carMain.setCarModel(shopUserCar.getCarModel());
// 设置其它车辆信息
carMain.setMaintenanceDate(convertToLocalDateTime(shopUserCar.getMaintenanceDate()));
carMain.setMaintenanceMileage(convertToBigDecimal(shopUserCar.getMaintenanceMileage()));
carMain.setInspectionDate(convertToLocalDateTime(shopUserCar.getInspectionDate()));
carMain.setInsuranceDate(convertToLocalDateTime(shopUserCar.getInsuranceDate()));
carMain.setNextMaintenanceDate(convertToLocalDateTime(shopUserCar.getNextMaintenanceDate()));
carMain.setNextMaintenanceMileage(convertToBigDecimal(shopUserCar.getNextMaintenanceMileage()));
carMain.setNextInspectionDate(convertToLocalDateTime(shopUserCar.getNextInspectionDate()));
carMain.setInsuranceExpiryDate(convertToLocalDateTime(shopUserCar.getInsuranceExpiryDate()));
carMain.setCarBrand(shopUserCar.getCarBrand());
carMain.setCarNature(shopUserCar.getCarNature());
carMain.setCarCategory(userCar1.getCarCategory());
carMain.setCarRegisterDate(convertToLocalDateTime(shopUserCar.getCarRegisterDate()));
carMain.setCarLicenseImg(shopUserCar.getCarLicenseImg());
carMain.setCheckDate(convertToLocalDateTime(shopUserCar.getCheckDate()));
carMain.setNextCheckDate(convertToLocalDateTime(shopUserCar.getNextCheckDate()));
if (null!=shopUserCar.getInsuranceDate()){
one.setInsuranceDate(shopUserCar.getInsuranceDate());
}
if (null!=shopUserCar.getNextMaintenanceDate()){
one.setNextMaintenanceDate(shopUserCar.getNextMaintenanceDate());
}
if (null!=shopUserCar.getNextMaintenanceMileage()){
one.setNextMaintenanceMileage(shopUserCar.getNextMaintenanceMileage());
}
if (null!=shopUserCar.getNextInspectionDate()){
one.setNextInspectionDate(shopUserCar.getNextInspectionDate());
}
if (null!=shopUserCar.getInsuranceExpiryDate()){
one.setInsuranceExpiryDate(shopUserCar.getInsuranceExpiryDate());
}
userCarService.updateById(one);
}else {
shopUserCar.setUserId(user.getId());
userCarService.save(shopUserCar);
}
// 保存车辆信息
saveCarList.add(carMain);
// 客户与车辆的关联关系
CustomerCar customerCar = new CustomerCar();
customerCar.setId(UUID.randomUUID().toString().replace("-", ""));
customerCar.setCusId(user.getId().toString());
customerCar.setCarId(carId);
customerCar.setIsOwner(userCar1.getIsOwner()); // 是否为车主
saveCustomerCarList.add(customerCar);
// 保存用户车辆信息
ShopUserCar userCar = new ShopUserCar();
userCar.setUserId(user.getId());
userCar.setCarNo(shopUserCar.getCarNo());
userCar.setCarModel(shopUserCar.getCarModel());
userCar.setMaintenanceDate(shopUserCar.getMaintenanceDate());
userCar.setMaintenanceMileage(shopUserCar.getMaintenanceMileage());
userCar.setInspectionDate(shopUserCar.getInspectionDate());
userCar.setInsuranceDate(shopUserCar.getInsuranceDate());
userCar.setNextMaintenanceDate(shopUserCar.getNextMaintenanceDate());
userCar.setNextMaintenanceMileage(shopUserCar.getNextMaintenanceMileage());
userCar.setNextInspectionDate(shopUserCar.getNextInspectionDate());
userCar.setInsuranceExpiryDate(shopUserCar.getInsuranceExpiryDate());
saveUserCarList.add(userCar);
}
}
// 验证手机号
if (!StringUtils.isMobile(partnerCustomerInfo.getCustomerPhone())) {
throw new Exception("手机号不符合规范");
}
// 创建客户信息
CustomerMain customerMain = new CustomerMain();
customerMain.setId(UUID.randomUUID().toString().replace("-", ""));
customerMain.setUserId(user.getId());
customerMain.setCusName(partnerCustomerInfo.getCustomerName());
customerMain.setPhoneNumber(partnerCustomerInfo.getCustomerPhone());
customerMain.setSex(partnerCustomerInfo.getSex());
customerMain.setIsHangAccount("0");
customerMain.setTypeCode("01");
// 设置客户初始来源
customerMain.setDataFrom("01");
// 设置注册方式
customerMain.setInviterType("01");
// 保存客户信息
customerMainService.saveOrUpdate(customerMain);
// 保存车辆信息和客户与车辆关联关系
carMainService.saveOrUpdateBatch(saveCarList);
customerCarService.saveBatch(saveCustomerCarList);
// 保存用户车辆信息
for (ShopUserCar userCar : saveUserCarList) {
// 检查是否已存在
LambdaQueryWrapper<ShopUserCar> queryWrapper1 = new LambdaQueryWrapper<>();
queryWrapper1.eq(ShopUserCar::getUserId, userCar.getUserId()).eq(ShopUserCar::getCarNo, userCar.getCarNo());
ShopUserCar existingUserCar = userCarService.getOne(queryWrapper1);
if (existingUserCar != null) {
// 更新用户车辆信息
userCarService.updateById(userCar);
} else {
// 保存新用户车辆信息
userCarService.save(userCar);
}
}
// 填充 partnerCustomerInfo
partnerCustomerInfo.setPartnerId(partners.getPartnerId());
partnerCustomerInfo.setUserId(user.getId());
// 插入 partner_customer_info
return baseMapper.insertPartnerCustomerInfo(partnerCustomerInfo);
}
/* Date转换为LocalDateTime */
private LocalDateTime convertToLocalDateTime(Date date) {
if (date != null) {
return LocalDateTime.ofInstant(date.toInstant(), ZoneId.systemDefault());
}
return null;
}
/* Long转换为BigDecimal */
private BigDecimal convertToBigDecimal(Long value) {
if (value != null) {
return BigDecimal.valueOf(value);
}
return null;
}
/**
* 修改客户信息
*

View File

@ -607,4 +607,19 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils
}
return sb.toString();
}
/**
* 手机号格式验证
* @author lzt
* @param customerPhone 手机号
* @return 验证结果
* @date 2024年10月22日
*/
public static boolean isMobile(String customerPhone) {
if (customerPhone == null || customerPhone.length() != 11) {
return false;
}
String regex = "^1[358]\\d{9}$";
return customerPhone.matches(regex);
}
}

View File

@ -209,8 +209,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</if>
</select>
<select id="pageWorkOrder" resultType="cn.iocoder.yudao.module.inspection.entity.InspectionInfo">
select ins.*,oi.goods_title,su.nickname as buyName,su.mobile as buyPhone,oi.sku_name,oi.pay_money as realPayMoney
,oi.pay_type,oi.order_status as orderStatus,oi.goods_id,oi.sku_id,oi.pay_time,oi.goods_price,ins.create_time
select distinct ins.*,oi.goods_title,su.nickname as buyName,su.mobile as buyPhone,oi.sku_name,oi.pay_money as realPayMoney
,oi.pay_type,oi.order_status as orderStatus,oi.goods_id,oi.sku_id,oi.pay_time,oi.goods_price
from inspection_info ins
left join order_info oi on oi.id = ins.inspection_order_id
left join system_users su on su.id = ins.user_id

View File

@ -20,7 +20,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
select * from warn_message
where id = #{id}
</select>
<select id="pageList" resultType="cn.iocoder.yudao.module.inspection.entity.WarnMessage">
select * from warn_message
<where>
and warn_time <![CDATA[<=]]> NOW()
<if test="warnMessage.title != null and warnMessage.title != ''"> and title = #{warnMessage.title}</if>
<if test="warnMessage.partnerId != null "> and partner_id = #{warnMessage.partnerId}</if>
<if test="warnMessage.isRead != null and warnMessage.isRead != ''"> and is_read = #{warnMessage.isRead}</if>
</where>
order by create_time desc
</select>
</mapper>

View File

@ -4,7 +4,7 @@ import lombok.AllArgsConstructor;
import lombok.Getter;
/**
* 工单操作记录-工作类型枚举
* 工单操作记录-工作类型枚举(repair_records_type)
*
* @author vinjor-m
*/
@ -39,6 +39,10 @@ public enum RecordTypeEnum {
* 结束工单
*/
JSGD("jsgd","结束工单"),
/**
* 通知客户取车
*/
TZQC("tzqc","通知客户取车"),
/**
* 开始施工
*/

View File

@ -11,4 +11,9 @@ public class RepairCons {
public static final String TICKETS_WAITING = "waiting";
/**工单-所有*/
public static final String TICKETS_ALL = "all";
/**数据字典常量-repair_records_type-*/
public static final String DICT_REPAIR_RECORDS_TYPE = "repair_records_type";
/**数据字典常量-repair_type-*/
public static final String DICT_REPAIR_TYPE = "repair_type";
}

View File

@ -0,0 +1,61 @@
package cn.iocoder.yudao.common;
import lombok.AllArgsConstructor;
import lombok.Getter;
/**
* 维修工单子表配件/项目状态枚举
*
* @author vinjor-m
*/
@AllArgsConstructor
@Getter
public enum TicketsItemStatusEnum {
/**
* 待派工
*/
WAITING_WORK("01","待派工"),
/**
* 施工中
*/
WORKING("02","施工中"),
/**
* 已完成
*/
DONE("03","已完成"),
/**
* 未领料
*/
WAITING_RECEIVE("04","未领料"),
/**
* 已领料
*/
RECEIVED("05","已领料");
/**
* code
*/
private String code;
/**
* 名称
*/
private String name;
/**
* 根据code返回对应的枚举
* @author vinjor-M
* @date 14:23 2024/10/16
* @param code 枚举code
* @return cn.iocoder.yudao.common.SystemEnum
**/
public static TicketsItemStatusEnum getEnumByCode(String code) {
for (TicketsItemStatusEnum roleEnum : TicketsItemStatusEnum.values()) {
if (roleEnum.getCode().equalsIgnoreCase(code)) {
// 找到对应的枚举
return roleEnum;
}
}
throw new IllegalArgumentException("无效的枚举code" + code);
}
}

View File

@ -4,7 +4,7 @@ import lombok.AllArgsConstructor;
import lombok.Getter;
/**
* 维修工单状态枚举
* 维修工单状态枚举(repair_tickets_status)
*
* @author vinjor-m
*/
@ -23,6 +23,10 @@ public enum TicketsStatusEnum {
* 未结账
*/
NO_PAY("01","未结账"),
/**
* 待通知客户取车
*/
WAITING_NOTICE("07","待通知客户取车"),
/**
* 挂单/记账
*/

View File

@ -19,7 +19,7 @@ public interface RepairRecordsService extends IService<RepairRecords> {
* 保存维修记录
*
* @param ticketId 工单id
* @param repairItemId 工单子表id
// * @param repairItemId 工单子表id
* @param type 工作类型数据字典repair_records_type;后端对应 RecordTypeEnum 枚举
* @param remark 备注
* @param images 图片(相对路径按照,分隔)

View File

@ -71,4 +71,13 @@ public interface RepairWaresService extends IService<RepairWares> {
* @return java.util.List<java.util.Map<java.lang.String,java.lang.String>>
**/
List<Map<String,String>> getAllTypeList();
/**
* 通过id查询集合
* @author PQZ
* @date 14:56 2024/10/24
* @param idList waresId集合
* @return java.util.List<cn.iocoder.yudao.module.project.entity.RepairWares>
**/
List<RepairWares> listByIds(List<String> idList);
}

View File

@ -114,4 +114,17 @@ public class RepairWaresServiceImpl extends ServiceImpl<RepairWaresMapper, Repai
return waresMapper.selectAllType();
}
/**
* 通过id查询集合
*
* @param idList waresId集合
* @return java.util.List<cn.iocoder.yudao.module.project.entity.RepairWares>
* @author PQZ
* @date 14:56 2024/10/24
**/
@Override
public List<RepairWares> listByIds(List<String> idList) {
return baseMapper.selectBatchIds(idList);
}
}

View File

@ -112,6 +112,13 @@ public class DlRepairSo extends TenantBaseDO {
/** 关联的配件申请单的id(dl_ticket_wares表的ID) */
private String twId;
/** 关联主表id */
private String mainId;
/** 关联主表名称 */
private String mainTable;
/**
* 车牌号
*/

View File

@ -31,7 +31,7 @@ public class DlRepairSoi extends TenantBaseDO {
private String id;
/**
* 采购单/领料单ID(dl_repair_so表的ID)
* 采购单/领料单ID/入库单(dl_repair_so表的ID)
*/
private String soId;
@ -69,6 +69,14 @@ public class DlRepairSoi extends TenantBaseDO {
* 备注
*/
private String remark;
/**
* 入库数量
*/
private Integer inCount;
/**
* 原始id
*/
private String rawId;
/**
* 配件信息

View File

@ -1,6 +1,5 @@
package cn.iocoder.yudao.module.stockOperate.service;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.module.stockOperate.entity.DlRepairSo;
import cn.iocoder.yudao.module.stockOperate.vo.DlRepairSoReqVO;
import cn.iocoder.yudao.module.stockOperate.vo.DlRepairSoRespVO;
@ -10,16 +9,18 @@ import com.baomidou.mybatisplus.extension.service.IService;
/**
* 针对表dl_repair_so(采购单领料单)的数据库操作Service
*
* @author 小李
* @date 9:09 2024/9/13
**/
**/
public interface DlRepairSoService extends IService<DlRepairSo> {
/**
* 采购单/领料单 新增
*
* @param repairSoRespVO 采购单对象
* @author 小李
* @date 10:49 2024/9/14
* @param repairSoRespVO 采购单对象
**/
void createRepairSo(DlRepairSoRespVO repairSoRespVO);
@ -35,36 +36,45 @@ public interface DlRepairSoService extends IService<DlRepairSo> {
/**
* 采购单/领料单 作废
*
* @param repairSoReqVO 作废对象
* @author 小李
* @date 11:12 2024/9/18
* @param repairSoReqVO 作废对象
**/
void voidRepairSo(DlRepairSoReqVO repairSoReqVO);
/**
* 采购单/领料单 查看
*
* @param id 主键
* @author 小李
* @date 9:34 2024/9/22
* @param id 主键
**/
DlRepairSoRespVO getRepairSoById(String id);
/**
* 员工确认领料
*
* @param id 单据ID 领料单主表
* @author 小李
* @date 11:58 2024/10/21
* @param id 单据ID 领料单主表
**/
void confirmGet(String id);
/**
* 员工确认退料
*
* @param id 退料单主表ID
* @author 小李
* @date 19:41 2024/10/21
* @param id 退料单主表ID
**/
void confirmBack(String id);
/**
* 采购入库
*
* @param reqVO 接参实体中需传入采购单id子表中商品id子表中入库数量inCount
* @author PQZ
* @date 14:32 2024/10/24
**/
void inWare(DlRepairSoReqVO reqVO);
}

View File

@ -11,35 +11,46 @@ import java.util.List;
/**
* 针对表dl_repair_soi(采购单领料单子表)的数据库操作Service
*
* @author 小李
* @date 9:09 2024/9/13
**/
**/
public interface DlRepairSoiService extends IService<DlRepairSoi> {
/**
* 采购单领料单子表 分页
*
* @param repairSoiReqVO 查询对象
* @author 小李
* @date 10:44 2024/9/18
* @param repairSoiReqVO 查询对象
**/
IPage<DlRepairSoi> getRepairSoiPage(DlRepairSoiReqVO repairSoiReqVO, Page<DlRepairSoi> page);
/**
* 采购单领料单子表详细 按ID查
*
* @param ids ids
* @author 小李
* @date 11:24 2024/9/22
* @param ids ids
**/
List<DlRepairSoiQueryRespVO> getRepairSoiByIds(List<String> ids);
/**
* 按主表ID查
*
* @param soId 主表ID
* @author 小李
* @date 11:22 2024/10/21
* @param soId 主表ID
**/
List<DlRepairSoiQueryRespVO> getRepairSoiBySoId(String soId);
/**
* 根据关联配件id查询关联配件
*
* @param ids 配件id集合
* @return java.util.List<cn.iocoder.yudao.module.stockOperate.entity.DlRepairSoi>
* @author PQZ
* @date 14:39 2024/10/24
**/
List<DlRepairSoi> listByIds(List<String> ids);
}

View File

@ -20,6 +20,8 @@ import cn.iocoder.yudao.module.stockOperate.vo.DlRepairSoReqVO;
import cn.iocoder.yudao.module.stockOperate.vo.DlRepairSoRespVO;
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.user.AdminUserApi;
import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
import cn.iocoder.yudao.module.tickets.entity.DlRepairTickets;
import cn.iocoder.yudao.module.tickets.entity.DlRepairTitem;
import cn.iocoder.yudao.module.tickets.entity.DlTicketWares;
@ -39,9 +41,7 @@ import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
@ -89,6 +89,8 @@ public class DlRepairSoServiceImpl extends ServiceImpl<DlRepairSoMapper, DlRepai
@Resource
@Lazy
private RepairWorkerService repairWorkerService;
@Resource
private AdminUserApi userApi;
/**
* 采购单/领料单 新增
@ -100,6 +102,7 @@ public class DlRepairSoServiceImpl extends ServiceImpl<DlRepairSoMapper, DlRepai
@DSTransactional
@Override
public void createRepairSo(DlRepairSoRespVO repairSoRespVO) {
repairSoRespVO.setSoTime(new Date());
// 取当前登录用户的门店信息
Long deptId = SecurityFrameworkUtils.getLoginUserDeptId();
repairSoRespVO.setDeptId(deptId);
@ -178,7 +181,7 @@ public class DlRepairSoServiceImpl extends ServiceImpl<DlRepairSoMapper, DlRepai
Long loginUserId = SecurityFrameworkUtils.getLoginUserId();
// 如果主表记录的领退料人与操作人一致即是员工点击的作废即需要通知仓库
boolean flag = so.getUserId().equals(loginUserId);
if (flag){
if (flag) {
repairWorkerService.sentMessage(Long.valueOf(so.getCreator()), (so.getSoType().equals("02") ? "领料单:" : "退料单:") + so.getSoNo() + "已被" + so.getUserName() + "作废");
}
}
@ -198,17 +201,17 @@ public class DlRepairSoServiceImpl extends ServiceImpl<DlRepairSoMapper, DlRepai
// 查子表
List<DlRepairSoi> list = repairSoiService.list(new LambdaQueryWrapper<DlRepairSoi>().eq(DlRepairSoi::getSoId, result.getId()));
if(!list.isEmpty()){
if (!list.isEmpty()) {
//所有有配件的分类
List<Map<String,String>> typeMapList = waresService.getAllTypeList();
Map<String,String> typeMap = new HashMap<>();
for(Map<String,String> map:typeMapList){
typeMap.put(map.get("id"),map.get("name"));
List<Map<String, String>> typeMapList = waresService.getAllTypeList();
Map<String, String> typeMap = new HashMap<>();
for (Map<String, String> map : typeMapList) {
typeMap.put(map.get("id"), map.get("name"));
}
//关联查配件信息
List<RepairWares> repairWaresList = waresService.listByIds(list.stream().map(DlRepairSoi::getGoodsId).collect(Collectors.toList()));
Map<String,RepairWares> waresMap = repairWaresList.stream().collect(Collectors.toMap(RepairWares::getId, Function.identity()));
list.forEach(item->{
Map<String, RepairWares> waresMap = repairWaresList.stream().collect(Collectors.toMap(RepairWares::getId, Function.identity()));
list.forEach(item -> {
item.setWares(waresMap.get(item.getGoodsId()));
item.setTypeName(typeMap.get(item.getWares().getType()));
});
@ -369,7 +372,7 @@ public class DlRepairSoServiceImpl extends ServiceImpl<DlRepairSoMapper, DlRepai
if (CollectionUtil.isEmpty(updateTitems)) {
titemService.updateBatchById(updateTitems);
}
}
// 更新维修工单
DlRepairTickets tickets = ticketsService.getOne(new LambdaQueryWrapper<DlRepairTickets>().eq(DlRepairTickets::getId, ticketWares.getTicketId()));
@ -394,6 +397,83 @@ public class DlRepairSoServiceImpl extends ServiceImpl<DlRepairSoMapper, DlRepai
// 通知仓库
repairWorkerService.sentMessage(Long.valueOf(newSo.getCreator()), newSo.getUserName() + "已确认退料单:" + newSo.getSoNo());
}
/**
* 采购入库
*
* @param reqVO 接参实体中需传入采购单id单据编号soNo备注remark,入库总价totalPrice子表中商品id子表中入库数量inCount
* @author PQZ
* @date 14:32 2024/10/24
**/
@Override
@DSTransactional
public void inWare(DlRepairSoReqVO reqVO) {
/*1、基础数据准备*/
//获取当前登录用户
Long userId = SecurityFrameworkUtils.getLoginUserId();
AdminUserRespDTO user = userApi.getUser(userId);
//采购单
DlRepairSo dlRepairSo = getById(reqVO.getId());
//需要保存的入库单
DlRepairSo inSo = new DlRepairSo();
//过滤掉入库数量为null或0的情况(此为无效数据)
List<DlRepairSoi> filterWare = reqVO.getSoiList().stream().filter(item -> item.getInCount() != null && item.getInCount() > 0).collect(Collectors.toList());
//即将入库采购品
List<DlRepairSoi> pmsWaresList = repairSoiService.listByIds(filterWare.stream().map(DlRepairSoi::getId).collect(Collectors.toList()));
//初始化本次入库采购品
List<DlRepairSoi> inWaresList = new ArrayList<>();
//原始配件库相关配件
List<RepairWares> waresList = waresService.listByIds(pmsWaresList.stream().map(DlRepairSoi::getWareId).collect(Collectors.toList()));
/*2、采购单转入库单*/
//入库单关联采购单
inSo.setMainId(dlRepairSo.getId());
inSo.setMainTable("dl_repair_so");
//05表示入库单
inSo.setSoType("05");
//入库单号
inSo.setSoNo(reqVO.getSoNo());
//入库人
inSo.setUserId(userId);
inSo.setUserName(user.getNickname());
//入库时间
inSo.setSoTime(new Date());
//入库商品总价
inSo.setTotalPrice(reqVO.getTotalPrice());
save(inSo);
/*3、入库配件处理*/
Map<String, DlRepairSoi> filterWareMap = filterWare.stream().collect(Collectors.toMap(DlRepairSoi::getId, soi -> soi));
pmsWaresList.forEach(item -> {
DlRepairSoi filterSoi = filterWareMap.get(item.getId());
DlRepairSoi inWares = item;
//采购单id
inWares.setSoId(inSo.getId());
//采购品原始id
inWares.setRawId(item.getId());
//入库数量
inWares.setInCount(filterSoi.getInCount());
inWares.setId(null);
//采购品中入库数量字段累加
item.setInCount(item.getInCount() == null?0:item.getInCount()+filterSoi.getInCount());
inWaresList.add(inWares);
});
//更新采购品
repairSoiService.updateBatchById(pmsWaresList);
//新增入库采购品
repairSoiService.saveBatch(inWaresList);
/*4、原始配件库处理*/
Map<String, DlRepairSoi> wareMap = filterWare.stream().collect(Collectors.toMap(DlRepairSoi::getWareId, soi -> soi));
waresList.forEach(item -> {
DlRepairSoi filterSoi = wareMap.get(item.getId());
item.setStock((item.getStock()==null?new BigDecimal(0):item.getStock()).add(new BigDecimal(filterSoi.getInCount())));
});
waresService.updateBatchById(waresList);
}
}

View File

@ -107,6 +107,19 @@ public class DlRepairSoiServiceImpl extends ServiceImpl<DlRepairSoiMapper, DlRep
});
return result;
}
/**
* 根据关联配件id查询关联配件
*
* @param ids 配件id集合
* @return java.util.List<cn.iocoder.yudao.module.stockOperate.entity.DlRepairSoi>
* @author PQZ
* @date 14:39 2024/10/24
**/
@Override
public List<DlRepairSoi> listByIds(List<String> ids) {
return baseMapper.selectBatchIds(ids);
}
}

View File

@ -1,11 +1,13 @@
package cn.iocoder.yudao.module.stockOperate.vo;
import cn.iocoder.yudao.module.stockOperate.entity.DlRepairSo;
import cn.iocoder.yudao.module.stockOperate.entity.DlRepairSoi;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import java.util.Date;
import java.util.List;
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
@ -20,4 +22,7 @@ public class DlRepairSoReqVO extends DlRepairSo {
@Schema(description = "时间区间")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private Date[] searchTimeArray;
/**关联商品*/
List<DlRepairSoi> soiList;
}

View File

@ -8,6 +8,7 @@ import cn.iocoder.yudao.module.tickets.service.DlRepairTicketsService;
import cn.iocoder.yudao.module.tickets.vo.CustomerAndCarVO;
import cn.iocoder.yudao.module.tickets.vo.DlRepairTicketsReqVO;
import cn.iocoder.yudao.module.tickets.vo.DlRepairTicketsRespVO;
import cn.iocoder.yudao.module.tickets.vo.NoticeCusVO;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.v3.oas.annotations.Operation;
import org.apache.commons.lang3.StringUtils;
@ -34,7 +35,6 @@ public class DlRepairTicketsController {
private DlRepairTicketsService dlRepairTicketsService;
/**
* 维修工单表 新增
*
@ -140,7 +140,7 @@ public class DlRepairTicketsController {
@GetMapping("/print/{id}")
@Operation(summary = "维修工单打印")
public void printDocument(HttpServletResponse response, @PathVariable String id) {
dlRepairTicketsService.print(response,id);
dlRepairTicketsService.print(response, id);
}
/**
@ -160,19 +160,19 @@ public class DlRepairTicketsController {
/**
* 分类查询工单分页
*
* @param repairTicketsReqVO 查询对象
* @param pageNo 页码
* @param pageSize 条数
* @author 小李
* @date 16:26 2024/10/12
* @param repairTicketsReqVO 查询对象
* @param pageNo 页码
* @param pageSize 条数
**/
**/
@GetMapping("/pageType")
@Operation(summary = "分类查询工单分页")
public CommonResult<?> getPageType(DlRepairTicketsReqVO repairTicketsReqVO,
@RequestParam(value = "pageNo", defaultValue = "1")Integer pageNo,
@RequestParam(value = "pageSize", defaultValue = "10")Integer pageSize){
@RequestParam(value = "pageNo", defaultValue = "1") Integer pageNo,
@RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) {
Page<DlRepairTickets> page = new Page<>(pageNo, pageSize);
if(StringUtils.isEmpty(repairTicketsReqVO.getSelectType())){
if (StringUtils.isEmpty(repairTicketsReqVO.getSelectType())) {
//查询类型为空默认查待处理的
repairTicketsReqVO.setSelectType(RepairCons.TICKETS_WAITING);
}
@ -187,20 +187,20 @@ public class DlRepairTicketsController {
**/
@GetMapping("/userRole")
@Operation(summary = "判断登录用户的角色,针对维修工单中的四个角色")
public CommonResult<?> getUserRole(){
public CommonResult<?> getUserRole() {
return success(dlRepairTicketsService.getUserRole());
}
/**
* 接单
*
* @param id 工单ID
* @author 小李
* @date 11:48 2024/10/14
* @param id 工单ID
**/
**/
@GetMapping("/take")
@Operation(summary = "接单")
public CommonResult<?> updateTake(@RequestParam("id") String id){
public CommonResult<?> updateTake(@RequestParam("id") String id) {
dlRepairTicketsService.updateTake(id);
return CommonResult.ok();
}
@ -208,13 +208,13 @@ public class DlRepairTicketsController {
/**
* 指派员工通知施工
*
* @param reqVO 请求对象
* @author 小李
* @date 15:34 2024/10/14
* @param reqVO 请求对象
**/
**/
@PostMapping("/notify")
@Operation(summary = "指派员工,通知施工")
public CommonResult<?> updateRepair(@RequestBody DlRepairTicketsReqVO reqVO){
public CommonResult<?> updateRepair(@RequestBody DlRepairTicketsReqVO reqVO) {
dlRepairTicketsService.updateRepair(reqVO);
return CommonResult.ok();
}
@ -222,13 +222,13 @@ public class DlRepairTicketsController {
/**
* 更新工单状态
*
* @param respVO 请求对象
* @author 小李
* @date 15:46 2024/10/18
* @param respVO 请求对象
**/
**/
@PostMapping("/updateStatus")
@Operation(summary = "更新工单状态")
public CommonResult<?> updateStatus(@RequestBody DlRepairTicketsRespVO respVO){
public CommonResult<?> updateStatus(@RequestBody DlRepairTicketsRespVO respVO) {
dlRepairTicketsService.updateStatus(respVO);
return CommonResult.ok();
}
@ -236,14 +236,14 @@ public class DlRepairTicketsController {
/**
* 配件客户是否可见
*
* @param id 工单ID
* @param show 是否可见
* @author 小李
* @date 21:52 2024/10/18
* @param id 工单ID
* @param show 是否可见
**/
**/
@GetMapping("/show")
@Operation(summary = "配件客户是否可见")
public CommonResult<?> updateShow(@RequestParam("id") String id, @RequestParam("show") String show){
public CommonResult<?> updateShow(@RequestParam("id") String id, @RequestParam("show") String show) {
dlRepairTicketsService.updateShow(id, show);
return CommonResult.ok();
}
@ -252,19 +252,73 @@ public class DlRepairTicketsController {
* 查待总检或待出厂检验的工单
* 维修服务顾问和总检用的
*
* @param repairTicketsReqVO 请求对象
* @param pageNo 页码
* @param pageSize 条数
* @author 小李
* @date 11:40 2024/10/23
* @param repairTicketsReqVO 请求对象
* @param pageNo 页码
* @param pageSize 条数
**/
**/
@GetMapping("/pageByRole")
@Operation(summary = "查待总检或待出厂检验的工单")
public CommonResult<?> getPageByRole(DlRepairTicketsReqVO repairTicketsReqVO,
@RequestParam(value = "pageNo", defaultValue = "1")Integer pageNo,
@RequestParam(value = "pageSize", defaultValue = "10")Integer pageSize){
@RequestParam(value = "pageNo", defaultValue = "1") Integer pageNo,
@RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) {
Page<DlRepairTickets> page = new Page<>(pageNo, pageSize);
return success(dlRepairTicketsService.getPageByRole(repairTicketsReqVO, page));
}
/**
* 维修总检完成总检
*
* @author 小李
* @date 16:48 2024/10/23
* @param respVO 请求对象
**/
@PostMapping("/inspection")
@Operation(summary = "维修总检完成总检")
public CommonResult<?> inspection(@RequestBody DlRepairTicketsRespVO respVO) {
dlRepairTicketsService.inspection(respVO);
return CommonResult.ok();
}
/**
* 服务顾问上传出厂检验日志
*
* @author 小李
* @date 17:47 2024/10/23
* @param respVO 请求对象
**/
@PostMapping("/confirm")
@Operation(summary = "服务顾问上传出厂检验日志")
public CommonResult<?> confirm(@RequestBody DlRepairTicketsRespVO respVO) {
dlRepairTicketsService.confirm(respVO);
return CommonResult.ok();
}
/**
* 从总检的角度差维修中已完成的工单数量
* @author vinjor-M
* @date 11:29 2024/10/24
* @return cn.iocoder.yudao.framework.common.pojo.CommonResult<?>
**/
@GetMapping("/getBossNum")
@Operation(summary = "从总检的角度差维修中、已完成的工单数量")
public CommonResult<?> getBossNum() {
return success(dlRepairTicketsService.getBossNum());
}
/**
* 服务顾问通知客户取车
*
* @author 小李
* @date 22:40 2024/10/23
* @param noticeCusVO 请求对象
**/
@PostMapping("/noticeCus")
@Operation(summary = "服务顾问通知客户取车")
public CommonResult<?> noticeCus(@RequestBody NoticeCusVO noticeCusVO) {
dlRepairTicketsService.noticeCus(noticeCusVO);
return CommonResult.ok();
}
}

View File

@ -4,11 +4,13 @@ import cn.iocoder.yudao.module.tickets.entity.DlRepairTickets;
import cn.iocoder.yudao.module.tickets.vo.CustomerAndCarVO;
import cn.iocoder.yudao.module.tickets.vo.DlRepairTicketsReqVO;
import cn.iocoder.yudao.module.tickets.vo.DlRepairTicketsRespVO;
import cn.iocoder.yudao.module.tickets.vo.NoticeCusVO;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import javax.servlet.http.HttpServletResponse;
import java.util.Map;
/**
* 针对表dl_repair_tickets(维修工单表)的数据库操作Service
@ -145,4 +147,39 @@ public interface DlRepairTicketsService extends IService<DlRepairTickets> {
* @param repairTicketsReqVO 请求对象
**/
IPage<DlRepairTickets> getPageByRole(DlRepairTicketsReqVO repairTicketsReqVO, Page<DlRepairTickets> page);
/**
* 维修总检完成总检
*
* @author 小李
* @date 16:48 2024/10/23
* @param respVO 请求对象
**/
void inspection(DlRepairTicketsRespVO respVO);
/**
* 服务顾问上传出厂检验日志
*
* @author 小李
* @date 17:47 2024/10/23
* @param respVO 请求对象
**/
void confirm(DlRepairTicketsRespVO respVO);
/**
* 从总检的角度差维修中已完成的工单数量
* @author vinjor-M
* @date 11:30 2024/10/24
* @return java.util.Map<java.lang.String,java.lang.Integer>
**/
Map<String,Integer> getBossNum();
/**
* 服务顾问通知客户取车
*
* @author 小李
* @date 22:40 2024/10/23
* @param noticeCusVO 请求对象
**/
void noticeCus(NoticeCusVO noticeCusVO);
}

View File

@ -43,10 +43,8 @@ import cn.iocoder.yudao.module.tickets.mapper.DlRepairTicketsMapper;
import cn.iocoder.yudao.module.tickets.service.DlRepairTicketsService;
import cn.iocoder.yudao.module.tickets.service.DlRepairTitemService;
import cn.iocoder.yudao.module.tickets.tools.WordUtil;
import cn.iocoder.yudao.module.tickets.vo.CustomerAndCarVO;
import cn.iocoder.yudao.module.tickets.vo.DlRepairTicketsReqVO;
import cn.iocoder.yudao.module.tickets.vo.DlRepairTicketsRespVO;
import cn.iocoder.yudao.module.tickets.vo.DlRepairTitemReqVO;
import cn.iocoder.yudao.module.tickets.vo.*;
import cn.iocoder.yudao.util.SendSmsUtil;
import com.baomidou.dynamic.datasource.annotation.DSTransactional;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
@ -55,7 +53,6 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.deepoove.poi.XWPFTemplate;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
@ -68,6 +65,8 @@ import java.util.*;
import java.util.stream.Collectors;
import static cn.iocoder.yudao.common.BaseConstants.ORDER_TENANT_NAME;
import static cn.iocoder.yudao.common.RepairCons.DICT_REPAIR_RECORDS_TYPE;
import static cn.iocoder.yudao.common.RepairCons.DICT_REPAIR_TYPE;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception0;
@ -188,6 +187,13 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl<DlRepairTicketsMappe
// 新增子表
itemList.forEach(item -> {
item.setTicketId(ticketsRespVO.getId());
if("01".equals(item.getItemType())){
//维修项目,初始状态待派工
item.setItemStatus(TicketsItemStatusEnum.WAITING_WORK.getCode());
}else if("02".equals(item.getItemType())){
//维修配件初始状态待领料
item.setItemStatus(TicketsItemStatusEnum.WAITING_RECEIVE.getCode());
}
});
titemService.saveBatch(itemList);
@ -300,7 +306,10 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl<DlRepairTicketsMappe
RepairRecordsPageReqVO entity = new RepairRecordsPageReqVO();
entity.setTicketId(id);
List<RepairRecordsRespVO> records = repairRecordsService.queryList(entity);
result.setRecords(records);
// 操作记录类型
List<DictDataRespDTO> recordTypeList = dictDataApi.getDictDataList(DICT_REPAIR_RECORDS_TYPE);
Map<String,String> typeMap = recordTypeList.stream().collect(Collectors.toMap(DictDataRespDTO::getValue,DictDataRespDTO::getLabel));
result.setRecords(records.stream().peek(item->item.setType(typeMap.get(item.getType()))).collect(Collectors.toList()));
return result;
}
@ -424,10 +433,16 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl<DlRepairTicketsMappe
@Override
public IPage<DlRepairTickets> getPageType(DlRepairTicketsReqVO repairTicketsReqVO, Page<DlRepairTickets> page) {
String userRoleCode = getUserRole();
if (userRoleCode.equals(RepairRoleEnum.ADMIN.getCode()) || userRoleCode.equals(RepairRoleEnum.INSPECTION.getCode())) {
//维修管理员和总检看所有数据
} else if (userRoleCode.equals(RepairRoleEnum.ADVISOR.getCode())) {
//服务顾问看自己的
if (userRoleCode.equals(RepairRoleEnum.ADMIN.getCode())) {
//维修管理员看所有数据
} else if(userRoleCode.equals(RepairRoleEnum.INSPECTION.getCode())){
//总检
if (RepairCons.TICKETS_WAITING.equals(repairTicketsReqVO.getSelectType())) {
//查待处理的查需要自己处理的否则就是查所有
repairTicketsReqVO.setUserIds(Collections.singletonList(SecurityFrameworkUtils.getLoginUserId()));
}
}else if (userRoleCode.equals(RepairRoleEnum.ADVISOR.getCode())) {
//服务顾问
repairTicketsReqVO.setAdviserId(String.valueOf(SecurityFrameworkUtils.getLoginUserId()));
} else if (userRoleCode.equals(RepairRoleEnum.REPAIR_STAFF.getCode())) {
//维修工进一步判断是否是班组长
@ -448,8 +463,10 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl<DlRepairTicketsMappe
return null;
}
if (RepairCons.TICKETS_WAITING.equals(repairTicketsReqVO.getSelectType())) {
//查待处理
return baseMapper.getPageType(repairTicketsReqVO, page);
} else {
//查所有
return baseMapper.getPageTypeAll(repairTicketsReqVO, page);
}
}
@ -550,7 +567,7 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl<DlRepairTicketsMappe
}
/**
* 更新工单状态
* 更新工单状态(针对开始施工施工中记录施工完成)
*
* @param respVO 请求对象
* @author 小李
@ -560,9 +577,9 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl<DlRepairTicketsMappe
@DSTransactional
public void updateStatus(DlRepairTicketsRespVO respVO) {
// 如果是开始施工但项目还在施工中就不能施工
if (respVO.getRecordType().equals("kssg")){
if (RecordTypeEnum.KSSG.getCode().equals(respVO.getRecordType())){
DlRepairTitem titem = titemService.getById(respVO.getItem().getId());
if (titem.getItemStatus().equals("02")){
if (TicketsItemStatusEnum.WORKING.getCode().equals(titem.getItemStatus())){
throw exception0(500, "选择的项目在施工中,不能重新开始施工");
}
}
@ -572,9 +589,10 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl<DlRepairTicketsMappe
LambdaUpdateWrapper<DlRepairTickets> wrapper = new LambdaUpdateWrapper<>();
wrapper.eq(DlRepairTickets::getId, respVO.getId());
wrapper.set(DlRepairTickets::getTicketsWorkStatus, respVO.getTicketsWorkStatus());
if (ObjectUtil.isNotEmpty(respVO.getIsFinish())) {
wrapper.set(DlRepairTickets::getIsFinish, respVO.getIsFinish());
}
// 这里注掉不能让员工更新工单的状态为完成后面还有总检服务顾问
// if (ObjectUtil.isNotEmpty(respVO.getIsFinish())) {
// wrapper.set(DlRepairTickets::getIsFinish, respVO.getIsFinish());
// }
baseMapper.update(wrapper);
}
if (null != respVO.getItem() && StringUtils.isNotEmpty(respVO.getItem().getItemStatus())) {
@ -603,8 +621,13 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl<DlRepairTicketsMappe
String message = createMessage(tickets.getNowRepairName(), tickets.getTicketNo(), titem.getItemName(), respVO.getRecordType(), respVO.getFinishType(), respVO.getNextName());
// 通知服务顾问
// 如果员工完成了订单
if (respVO.getRecordType().equals("sgwczj") && respVO.getFinishType().equals("03")) {
repairWorkerService.sentMessage(Long.valueOf(tickets.getAdviserId()), "您有新的工单可以交车");
if (RecordTypeEnum.SGWCZJ.getCode().equals(respVO.getRecordType())&& "03".equals(respVO.getFinishType())) {
repairWorkerService.sentMessage(Long.valueOf(tickets.getAdviserId()), "您有新的工单可以出厂检验");
// 需要把工单的当前操作人移交服务顾问
baseMapper.update(new LambdaUpdateWrapper<DlRepairTickets>()
.setSql("now_repair_id = adviser_id")
.setSql("now_repair_name = adviser_name")
.eq(DlRepairTickets::getId, respVO.getId()));
} else {
repairWorkerService.sentMessage(Long.valueOf(tickets.getAdviserId()), message);
}
@ -616,12 +639,13 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl<DlRepairTicketsMappe
List<Long> ids = permissionApi.getUserIdByRoleId(roleInfo.getId());
if (CollectionUtil.isEmpty(ids)) return;
// 如果是移交给总检就需要通知总检并让其总检
if (respVO.getRecordType().equals("sgwczj") && respVO.getFinishType().equals("02")) {
if (RecordTypeEnum.SGWCZJ.getCode().equals(respVO.getRecordType()) && "02".equals(respVO.getFinishType())) {
// 工单移交给总检(理论上讲只有一个总检就算有多个这里面也只给一个)
AdminUserRespDTO user = adminUserApi.getUser(ids.get(0));
baseMapper.update(new LambdaUpdateWrapper<DlRepairTickets>()
.set(DlRepairTickets::getNowRepairId, user.getId())
.set(DlRepairTickets::getNowRepairName, user.getNickname())
.set(DlRepairTickets::getTicketsWorkStatus, "05")
.eq(DlRepairTickets::getId, respVO.getId()));
repairWorkerService.sentMessage(user.getId(), "您有新的工单需要总检");
} else {
@ -642,7 +666,7 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl<DlRepairTicketsMappe
return result + "上传了工单:" + no + "" + projectName + "项目的维修记录";
// 施工完成
case "sgwczj":
if (ObjectUtil.isNotEmpty(finishType)){
if (ObjectUtil.isNotEmpty(finishType)) {
result = result + "完成了工单:" + no + "" + projectName + "项目";
switch (finishType) {
// 完成并移交下一班组
@ -657,7 +681,7 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl<DlRepairTicketsMappe
default:
return "异常消息";
}
}else {
} else {
return result + "部分完成了工单:" + no + "" + projectName + "项目";
}
default:
@ -685,24 +709,147 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl<DlRepairTicketsMappe
* 查待总检或待出厂检验的工单
* 维修服务顾问和总检用的
*
* @param repairTicketsReqVO 请求对象
* @author 小李
* @date 11:40 2024/10/23
* @param repairTicketsReqVO 请求对象
**/
@Override
public IPage<DlRepairTickets> getPageByRole(DlRepairTicketsReqVO repairTicketsReqVO, Page<DlRepairTickets> page){
public IPage<DlRepairTickets> getPageByRole(DlRepairTicketsReqVO repairTicketsReqVO, Page<DlRepairTickets> page) {
String userRoleCode = getUserRole();
// 当前操作人的id
Long loginUserId = SecurityFrameworkUtils.getLoginUserId();
//设置查询类型---待总检或待出厂检验的工单
repairTicketsReqVO.setSelectType("special");
// 维修服务顾问
if (userRoleCode.equals(RepairRoleEnum.ADVISOR.getCode())){
}else if (userRoleCode.equals(RepairRoleEnum.INSPECTION.getCode())){
if (userRoleCode.equals(RepairRoleEnum.ADVISOR.getCode())) {
repairTicketsReqVO.setNowRepairId(loginUserId);
repairTicketsReqVO.setIsFinish("1");
} else if (userRoleCode.equals(RepairRoleEnum.INSPECTION.getCode())) {
// 总检
}else {
repairTicketsReqVO.setNowRepairId(loginUserId);
repairTicketsReqVO.setIsFinish("0");
} else {
return null;
}
// 还是用分类查询不过需要重新构造查询条件 todo
// 还是用分类查询不过需要重新构造查询条件
return baseMapper.getPageType(repairTicketsReqVO, page);
}
/**
* 维修总检完成总检
*
* @param respVO 请求对象
* @author 小李
* @date 16:48 2024/10/23
**/
@Override
@DSTransactional
public void inspection(DlRepairTicketsRespVO respVO) {
// 新增日志
repairRecordsService.saveRepairRecord(respVO.getId(), null, RecordTypeEnum.ZJ.getCode(), respVO.getRemark(), respVO.getImage());
// 更新工单
baseMapper.update(new LambdaUpdateWrapper<DlRepairTickets>()
.set(DlRepairTickets::getIsFinish, "1")
.setSql("now_repair_id = adviser_id")
.setSql("now_repair_name = adviser_name")
.eq(DlRepairTickets::getId, respVO.getId())
);
// 通知服务顾问
DlRepairTickets tickets = baseMapper.selectById(respVO.getId());
repairWorkerService.sentMessage(Long.valueOf(tickets.getAdviserId()), "您有新的工单可以出厂检验");
}
/**
* 服务顾问上传出厂检验日志
*
* @param respVO 请求对象
* @author 小李
* @date 17:47 2024/10/23
**/
@Override
public void confirm(DlRepairTicketsRespVO respVO) {
// 更新工单状态
baseMapper.update(new LambdaUpdateWrapper<DlRepairTickets>()
.set(DlRepairTickets::getTicketsWorkStatus, TicketsWorkStatusEnum.END.getCode())
.set(DlRepairTickets::getTicketsStatus, TicketsStatusEnum.WAITING_NOTICE.getCode())
.eq(DlRepairTickets::getId, respVO.getId())
);
// 记录日志
repairRecordsService.saveRepairRecord(respVO.getId(), null, RecordTypeEnum.JSGD.getCode(), respVO.getRemark(), respVO.getImage());
}
/**
* 从总检的角度差维修中已完成的工单数量
*
* @return java.util.Map<java.lang.String, java.lang.Integer>
* @author vinjor-M
* @date 11:30 2024/10/24
**/
@Override
public Map<String, Integer> getBossNum() {
Map<String,Integer> rtnMap = new HashMap<>();
int workingNum = 0;
int doneNum = 0;
List<DlRepairTickets> repairTickets = this.list();
if(!repairTickets.isEmpty()){
Map<String,List<DlRepairTickets>> ifFinishMap = repairTickets.stream().collect(Collectors.groupingBy(DlRepairTickets::getIsFinish));
if(ifFinishMap.containsKey("0")){
workingNum = ifFinishMap.get("0").size();
}
if(ifFinishMap.containsKey("1")){
doneNum = ifFinishMap.get("1").size();
}
}
rtnMap.put("workingNum",workingNum);
rtnMap.put("doneNum",doneNum);
return rtnMap;
}
/**
* 服务顾问通知客户取车
*
* @param noticeCusVO 请求对象
* @author 小李
* @date 22:40 2024/10/23
**/
@Override
@DSTransactional
public void noticeCus(NoticeCusVO noticeCusVO) {
// 获取客户信息
DlRepairTickets tickets = baseMapper.selectById(noticeCusVO.getId());
// 更新工单状态为待结算待取车
baseMapper.update(new LambdaUpdateWrapper<DlRepairTickets>()
.set(DlRepairTickets::getTicketsStatus, TicketsStatusEnum.NO_PAY.getCode())
.eq(DlRepairTickets::getId, noticeCusVO.getId())
);
CustomerMain cus = customerService.getById(tickets.getUserId());
// 维修项目
List<DictDataRespDTO> repairType = dictDataApi.getDictDataList(DICT_REPAIR_TYPE);
// 默认是维修
String type = "维修";
DictDataRespDTO dictDataRespDTO = repairType.stream()
.filter(item -> item.getValue().equals(tickets.getRepairType()))
.findFirst()
.orElse(null);
if (dictDataRespDTO != null){
type = dictDataRespDTO.getLabel();
}
// 构建消息
String message = String.format(
"尊敬的客户您好:您的爱车%s已%s完毕请您前来取车。若有问题可以联系%s联系电话%s"
, tickets.getCarNo(), type, noticeCusVO.getName(), noticeCusVO.getMobile()
);
// todo 小程序通知客户
if(null!=cus && StringUtils.isNotEmpty(cus.getPhoneNumber())){
// 短信通知客户
SendSmsUtil.sendMsgCommon(new String[]{message}, cus.getPhoneNumber(), "1400852709", "蓝安汽车小程序", "2143603");
}
// 记录日志
String recordStr = noticeCusVO.getName()
+ "通知客户取车:"+message;
repairRecordsService.saveRepairRecord(noticeCusVO.getId(), null, RecordTypeEnum.TZQC.getCode(), recordStr, null);
}
}

View File

@ -4,6 +4,7 @@ import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.iocoder.yudao.common.RepairRoleEnum;
import cn.iocoder.yudao.common.SoStatusEnum;
import cn.iocoder.yudao.common.TicketsItemStatusEnum;
import cn.iocoder.yudao.framework.security.core.LoginUser;
import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils;
import cn.iocoder.yudao.module.base.entity.RepairWorker;
@ -40,6 +41,7 @@ import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception0;
@ -224,18 +226,55 @@ public class DlTicketWaresServiceImpl extends ServiceImpl<DlTicketWaresMapper, D
@DSTransactional
public void auditTicketWares(DlTicketWaresRespVO respVO) {
// 设置单据状态
baseMapper.update(new LambdaUpdateWrapper<DlTicketWares>()
.set(DlTicketWares::getStatus, respVO.getStatus())
.eq(DlTicketWares::getId, respVO.getId())
);
//配件申请单id
String mainId = respVO.getId();
//单据类型现在只有配件申请单 01
String type = respVO.getType();
//单据状态 02 通过 05驳回
String status = respVO.getStatus();
//配件信息
List<DlRepairTitem> repairItemList = respVO.getWares();
DlTicketWares updateObj = this.getById(mainId);
String ticketMainId = updateObj.getTicketId();
updateObj.setStatus(status);
this.updateById(updateObj);
// 如果是通过并且是领料就还需要把配件信息加入到工单中
if (ObjectUtil.isNotEmpty(respVO.getStatus()) && respVO.getStatus().equals("02") && respVO.getType().equals("01")) {
if (ObjectUtil.isNotEmpty(status) && status.equals("02") && type.equals("01")) {
// 更新维修工单
if(null== repairItemList || repairItemList.isEmpty()){
repairItemList = new ArrayList<>();
//配件没传去库里面查需要的配件
LambdaQueryWrapper<DlTwItem> queryWrapper= new LambdaQueryWrapper<DlTwItem>()
.eq(DlTwItem::getTwId,mainId);
List<DlTwItem> applyList = twItemService.list(queryWrapper);
if(!applyList.isEmpty()){
//查配件库
List<RepairWares> waresList = repairWaresService.listByIds(applyList.stream().map(DlTwItem::getWaresId).collect(Collectors.toList()));
Map<String,RepairWares> waresMap =waresList.stream().collect(Collectors.toMap(RepairWares::getId, Function.identity()));
//组装工单子表数据
for (DlTwItem item:applyList){
DlRepairTitem repairTitem = new DlRepairTitem();
repairTitem.setTicketId(ticketMainId);
repairTitem.setItemCount(item.getWaresCount());
repairTitem.setItemName(item.getWaresName());
repairTitem.setItemUnit(waresMap.get(item.getWaresId()).getUnit());
repairTitem.setItemPrice(new BigDecimal(waresMap.get(item.getWaresId()).getPrice()));
//默认不打折为1
repairTitem.setItemDiscount(new BigDecimal(1));
repairTitem.setItemMoney(new BigDecimal(repairTitem.getItemCount()).multiply(repairTitem.getItemPrice()));
//类型是配件
repairTitem.setItemType("02");
repairTitem.setPartId(item.getWaresId());
repairTitem.setItemStatus(TicketsItemStatusEnum.WAITING_RECEIVE.getCode());
repairItemList.add(repairTitem);
}
}
}
// 计算配件的总价
BigDecimal reduce = respVO.getWares().stream().map(DlRepairTitem::getItemMoney).reduce(BigDecimal.ZERO, BigDecimal::add);
BigDecimal reduce = repairItemList.stream().map(DlRepairTitem::getItemMoney).reduce(BigDecimal.ZERO, BigDecimal::add);
repairTicketsService.update(new LambdaUpdateWrapper<DlRepairTickets>()
// 工单子项总数量增加上配件的数量
.setSql("count = count + " + respVO.getWares().size())
.setSql("count = count + " + repairItemList.size())
// 工单配件总价
.setSql("part_price = part_price + " + reduce)
// 工单总价
@ -246,18 +285,18 @@ public class DlTicketWaresServiceImpl extends ServiceImpl<DlTicketWaresMapper, D
.setSql("profit = profit + " + reduce)
// 领料状态
.set(DlRepairTickets::getPartStatus, "02")
.eq(DlRepairTickets::getId, respVO.getTicketId())
.eq(DlRepairTickets::getId, ticketMainId)
);
// 更新维修工单子表
respVO.getWares().forEach(item -> {
repairItemList.forEach(item -> {
// 主表id
item.setTicketId(respVO.getTicketId());
item.setTicketId(ticketMainId);
// 类型为配件
item.setItemType("02");
// 状态为未领料
item.setItemStatus("08");
item.setItemStatus(TicketsItemStatusEnum.WAITING_RECEIVE.getCode());
});
repairTitemService.saveBatch(respVO.getWares());
repairTitemService.saveBatch(repairItemList);
// 发送通过的消息给仓库
RoleReqDTO roleInfo = roleApi.getRoleInfo(RepairRoleEnum.WAREHOUSE.getCode());

View File

@ -0,0 +1,30 @@
package cn.iocoder.yudao.module.tickets.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import java.util.Date;
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
@Data
public class NoticeCusVO {
/** 维修工单ID */
private String id;
/** 取车时间 */
@Schema(pattern = "时间区间")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private Date[] time;
/** 联系人 */
private String name;
/** 联系电话 */
private String mobile;
/** 备注 */
private String remark;
}

View File

@ -182,9 +182,10 @@
</select>
<select id="getPageType" resultMap="APPBaseResultMap">
-- 查待处理数据 --
select drt.*
from dl_repair_tickets drt
where drt.deleted = '0'
where (drt.deleted = '0') AND drt.tickets_status IN ('04','05','01')
<if test="map.ticketNo != null and map.ticketNo != ''">
and (
drt.ticket_no like concat('%', #{map.ticketNo}, '%')
@ -199,33 +200,36 @@
)
</if>
<if test="map.searchTimeArray != null and map.searchTimeArray.length > 0">
and drt.create_time between #{map.searchTimeArray[0]} and #{map.searchTimeArray[1]}
and (drt.create_time between #{map.searchTimeArray[0]} and #{map.searchTimeArray[1]})
</if>
<if test="map.adviserId != null and map.adviserId != ''">
and drt.adviser_id = #{map.adviserId}
</if>
<if test="map.isFinish != null and map.isFinish != ''">
and drt.is_finish = #{map.isFinish}
</if>
<if test="map.userIds != null and map.userIds.size > 0 ">
and (drt.tickets_status = '05')
<choose>
<when test="map.isFinish == '0'">
and (drt.now_repair_id in
<choose>
<when test="map.selectType=='special'">
-- 小李用的逻辑 --
<if test="map.isFinish != null and map.isFinish != ''">
AND ( drt.is_finish = #{map.isFinish})
</if>
<if test="map.nowRepairId != null and map.nowRepairId != ''">
AND ( drt.now_repair_id = #{map.nowRepairId})
</if>
</when>
<otherwise>
-- 正常查询用的逻辑 --
<if test="map.adviserId != null and map.adviserId != ''">
-- 查服务顾问 待处理的 工单未完成并且服务顾问是自己的 工单已完成且当前处理人是自己的--
AND ( drt.is_finish = '0' AND drt.adviser_id = #{map.adviserId} )
OR (drt.is_finish = '1' AND drt.now_repair_id = #{map.adviserId})
</if>
<if test="map.userIds != null and map.userIds.size > 0">
-- 查维修工、总检待处理的 --
AND (drt.is_finish = '0')
AND (drt.now_repair_id in
<foreach collection="map.userIds" item="item" index="index" open="(" separator="," close=")">
#{item}
</foreach>
)
</when>
<when test="map.isFinish == '1'">
and (
<foreach item="item" collection="map.userIds" index="index" open="" separator="or" close="">
find_in_set(#{item}, drti.repair_ids) > 0
</foreach>
)
</when>
</choose>
</if>
</if>
</otherwise>
</choose>
order by drt.create_time desc
</select>
@ -276,9 +280,11 @@
and drt.create_time between #{map.searchTimeArray[0]} and #{map.searchTimeArray[1]}
</if>
<if test="map.adviserId != null and map.adviserId != ''">
-- 服务顾问查所有的就是服务顾问是自己的 --
and drt.adviser_id = #{map.adviserId}
</if>
<if test="map.userIds != null and map.userIds.size > 0">
-- 维修工或维修厂长查所有的就是维修人是自己的或者是自己班组内的 --
and (
<foreach item="item" collection="map.userIds" index="index" open="" separator="or" close="">
find_in_set(#{item}, drt.now_repair_id) > 0

File diff suppressed because one or more lines are too long

View File

@ -19,12 +19,14 @@ import cn.iocoder.yudao.module.system.controller.admin.user.LoginBody;
import cn.iocoder.yudao.module.system.convert.auth.AuthConvert;
import cn.iocoder.yudao.module.system.dal.dataobject.permission.MenuDO;
import cn.iocoder.yudao.module.system.dal.dataobject.permission.RoleDO;
import cn.iocoder.yudao.module.system.dal.dataobject.service.ServicePackageDO;
import cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO;
import cn.iocoder.yudao.module.system.enums.logger.LoginLogTypeEnum;
import cn.iocoder.yudao.module.system.service.auth.AdminAuthService;
import cn.iocoder.yudao.module.system.service.permission.MenuService;
import cn.iocoder.yudao.module.system.service.permission.PermissionService;
import cn.iocoder.yudao.module.system.service.permission.RoleService;
import cn.iocoder.yudao.module.system.service.service.ServicePackageService;
import cn.iocoder.yudao.module.system.service.social.SocialClientService;
import cn.iocoder.yudao.module.system.service.user.AdminUserService;
import io.swagger.v3.oas.annotations.Operation;
@ -32,6 +34,7 @@ import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Parameters;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
@ -39,6 +42,7 @@ import javax.annotation.Resource;
import javax.annotation.security.PermitAll;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Set;
@ -75,6 +79,8 @@ public class AuthController {
private PermissionApi permissionApi;
@Resource
private RoleApi roleApi;
@Resource
private ServicePackageService servicePackageService;
@PostMapping("/login")
@ -185,7 +191,7 @@ public class AuthController {
@GetMapping("/get-permission-info")
@Operation(summary = "获取登录用户的权限信息")
public CommonResult<AuthPermissionInfoRespVO> getPermissionInfo() {
public CommonResult<AuthPermissionInfoRespVO> getPermissionInfo(String routeCode) {
// 1.1 获得用户信息
AdminUserDO user = userService.getUser(getLoginUserId());
if (user == null) {
@ -202,6 +208,12 @@ public class AuthController {
// 1.3 获得菜单列表
Set<Long> menuIds = permissionService.getRoleMenuListByRoleId(convertSet(roles, RoleDO::getId));
//过滤出来当前服务的菜单
if (StringUtils.isNotEmpty(routeCode)){
ServicePackageDO servicePackage = servicePackageService.getServicePackage(routeCode);
Set<Long> servicePackageMenuIds = servicePackage.getMenuIds();
menuIds= menuIds.stream().filter(servicePackageMenuIds::contains).collect(Collectors.toSet());
}
List<MenuDO> menuList = menuService.getMenuList(menuIds);
menuList = menuService.filterDisableMenus(menuList);