更新0815
This commit is contained in:
parent
15e54c5984
commit
d85b0d8028
@ -31,6 +31,7 @@ import cn.iocoder.yudao.module.tickets.service.DlRepairTicketsService;
|
|||||||
import cn.iocoder.yudao.module.tickets.service.DlRepairTitemService;
|
import cn.iocoder.yudao.module.tickets.service.DlRepairTitemService;
|
||||||
import cn.iocoder.yudao.module.tickets.service.DlTicketWaresService;
|
import cn.iocoder.yudao.module.tickets.service.DlTicketWaresService;
|
||||||
import cn.iocoder.yudao.module.tickets.service.DlTwItemService;
|
import cn.iocoder.yudao.module.tickets.service.DlTwItemService;
|
||||||
|
import cn.iocoder.yudao.module.tickets.utils.TicketsOperateUtil;
|
||||||
import cn.iocoder.yudao.module.tickets.vo.AppWaresGroupVO;
|
import cn.iocoder.yudao.module.tickets.vo.AppWaresGroupVO;
|
||||||
import com.baomidou.dynamic.datasource.annotation.DSTransactional;
|
import com.baomidou.dynamic.datasource.annotation.DSTransactional;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
@ -44,6 +45,7 @@ import org.springframework.stereotype.Service;
|
|||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
|
import java.math.RoundingMode;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
@ -53,7 +55,6 @@ import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionU
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 针对表【dl_repair_so(采购单领料单)】的数据库操作Service实现
|
* 针对表【dl_repair_so(采购单领料单)】的数据库操作Service实现
|
||||||
*
|
|
||||||
* @author 小李
|
* @author 小李
|
||||||
* @date 9:11 2024/9/13
|
* @date 9:11 2024/9/13
|
||||||
**/
|
**/
|
||||||
@ -108,9 +109,11 @@ public class DlRepairSoServiceImpl extends ServiceImpl<DlRepairSoMapper, DlRepai
|
|||||||
@Lazy
|
@Lazy
|
||||||
private RepairRecordsService recordsService;
|
private RepairRecordsService recordsService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private TicketsOperateUtil operateUtil;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 采购单/领料单 新增
|
* 采购单/领料单 新增
|
||||||
*
|
|
||||||
* @param repairSoRespVO 采购单对象
|
* @param repairSoRespVO 采购单对象
|
||||||
* @author 小李
|
* @author 小李
|
||||||
* @date 10:49 2024/9/14
|
* @date 10:49 2024/9/14
|
||||||
@ -171,7 +174,6 @@ public class DlRepairSoServiceImpl extends ServiceImpl<DlRepairSoMapper, DlRepai
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 采购单/领料单新增分页
|
* 采购单/领料单新增分页
|
||||||
*
|
|
||||||
* @param repairSoReqVO 查询对象
|
* @param repairSoReqVO 查询对象
|
||||||
* @author 小李
|
* @author 小李
|
||||||
* @date 18:14 2024/9/14
|
* @date 18:14 2024/9/14
|
||||||
@ -183,7 +185,6 @@ public class DlRepairSoServiceImpl extends ServiceImpl<DlRepairSoMapper, DlRepai
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 采购单/领料单 作废
|
* 采购单/领料单 作废
|
||||||
*
|
|
||||||
* @param repairSoReqVO 作废对象
|
* @param repairSoReqVO 作废对象
|
||||||
* @author 小李
|
* @author 小李
|
||||||
* @date 11:12 2024/9/18
|
* @date 11:12 2024/9/18
|
||||||
@ -217,7 +218,7 @@ public class DlRepairSoServiceImpl extends ServiceImpl<DlRepairSoMapper, DlRepai
|
|||||||
// 如果主表记录的领退料人与操作人一致,即是员工点击的作废,即需要通知仓库
|
// 如果主表记录的领退料人与操作人一致,即是员工点击的作废,即需要通知仓库
|
||||||
boolean flag = so.getUserId().equals(loginUserId);
|
boolean flag = so.getUserId().equals(loginUserId);
|
||||||
if (flag) {
|
if (flag) {
|
||||||
repairWorkerService.sentMessage(SystemEnum.REPAIR.getCode(),Long.valueOf(so.getCreator()), (so.getSoType().equals("02") ? "领料单:" : "退料单:") + so.getSoNo() + "已被" + so.getUserName() + "作废");
|
repairWorkerService.sentMessage(SystemEnum.REPAIR.getCode(), Long.valueOf(so.getCreator()), (so.getSoType().equals("02") ? "领料单:" : "退料单:") + so.getSoNo() + "已被" + so.getUserName() + "作废");
|
||||||
// 需要更新库存和申请表数据
|
// 需要更新库存和申请表数据
|
||||||
// 查单据子表
|
// 查单据子表
|
||||||
List<DlRepairSoi> sois = repairSoiService.list(new LambdaQueryWrapper<DlRepairSoi>().in(DlRepairSoi::getSoId, so.getId()));
|
List<DlRepairSoi> sois = repairSoiService.list(new LambdaQueryWrapper<DlRepairSoi>().in(DlRepairSoi::getSoId, so.getId()));
|
||||||
@ -272,7 +273,6 @@ public class DlRepairSoServiceImpl extends ServiceImpl<DlRepairSoMapper, DlRepai
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 采购单/领料单 查看
|
* 采购单/领料单 查看
|
||||||
*
|
|
||||||
* @param id 主键
|
* @param id 主键
|
||||||
* @author 小李
|
* @author 小李
|
||||||
* @date 9:34 2024/9/22
|
* @date 9:34 2024/9/22
|
||||||
@ -306,7 +306,6 @@ public class DlRepairSoServiceImpl extends ServiceImpl<DlRepairSoMapper, DlRepai
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 员工确认领料
|
* 员工确认领料
|
||||||
*
|
|
||||||
* @param id 单据ID 领料单主表
|
* @param id 单据ID 领料单主表
|
||||||
* @author 小李
|
* @author 小李
|
||||||
* @date 11:58 2024/10/21
|
* @date 11:58 2024/10/21
|
||||||
@ -341,11 +340,11 @@ public class DlRepairSoServiceImpl extends ServiceImpl<DlRepairSoMapper, DlRepai
|
|||||||
}).collect(Collectors.toList());
|
}).collect(Collectors.toList());
|
||||||
|
|
||||||
/* 这里添加新逻辑,员工确认领料时,把领的配件添加进工单子表---start */
|
/* 这里添加新逻辑,员工确认领料时,把领的配件添加进工单子表---start */
|
||||||
this.dealWareItem(true,so.getTwId(),sois,repairWares);
|
this.dealWareItem(true, so.getTwId(), sois, repairWares);
|
||||||
/* 这里添加新逻辑,员工确认领料时,把领的配件添加进工单子表---end */
|
/* 这里添加新逻辑,员工确认领料时,把领的配件添加进工单子表---end */
|
||||||
|
|
||||||
// 通知仓库
|
// 通知仓库
|
||||||
repairWorkerService.sentMessage(SystemEnum.REPAIR.getCode(),Long.valueOf(so.getCreator()), so.getUserName() + "已确认领料单:" + so.getSoNo());
|
repairWorkerService.sentMessage(SystemEnum.REPAIR.getCode(), Long.valueOf(so.getCreator()), so.getUserName() + "已确认领料单:" + so.getSoNo());
|
||||||
|
|
||||||
// 记录日志
|
// 记录日志
|
||||||
// 查配件申请表
|
// 查配件申请表
|
||||||
@ -376,7 +375,6 @@ public class DlRepairSoServiceImpl extends ServiceImpl<DlRepairSoMapper, DlRepai
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 员工确认退料
|
* 员工确认退料
|
||||||
*
|
|
||||||
* @param id 退料单主表ID
|
* @param id 退料单主表ID
|
||||||
* @author 小李
|
* @author 小李
|
||||||
* @date 19:41 2024/10/21
|
* @date 19:41 2024/10/21
|
||||||
@ -397,7 +395,7 @@ public class DlRepairSoServiceImpl extends ServiceImpl<DlRepairSoMapper, DlRepai
|
|||||||
// 查主表
|
// 查主表
|
||||||
DlRepairSo newSo = baseMapper.selectById(id);
|
DlRepairSo newSo = baseMapper.selectById(id);
|
||||||
// 通知仓库
|
// 通知仓库
|
||||||
repairWorkerService.sentMessage(SystemEnum.REPAIR.getCode(),Long.valueOf(newSo.getCreator()), newSo.getUserName() + "已确认退料单:" + newSo.getSoNo());
|
repairWorkerService.sentMessage(SystemEnum.REPAIR.getCode(), Long.valueOf(newSo.getCreator()), newSo.getUserName() + "已确认退料单:" + newSo.getSoNo());
|
||||||
// 记录日志
|
// 记录日志
|
||||||
// 查子表信息
|
// 查子表信息
|
||||||
List<DlRepairSoi> sois = repairSoiService.list(new LambdaQueryWrapper<DlRepairSoi>().eq(DlRepairSoi::getSoId, id));
|
List<DlRepairSoi> sois = repairSoiService.list(new LambdaQueryWrapper<DlRepairSoi>().eq(DlRepairSoi::getSoId, id));
|
||||||
@ -414,7 +412,7 @@ public class DlRepairSoServiceImpl extends ServiceImpl<DlRepairSoMapper, DlRepai
|
|||||||
StringBuilder remark = new StringBuilder("确认退料: ");
|
StringBuilder remark = new StringBuilder("确认退料: ");
|
||||||
|
|
||||||
/* 这里添加新逻辑,员工确认退料时,把退的配件从工单子表中删除---start */
|
/* 这里添加新逻辑,员工确认退料时,把退的配件从工单子表中删除---start */
|
||||||
this.dealWareItem(false,newSo.getTwId(),sois,repairWares);
|
this.dealWareItem(false, newSo.getTwId(), sois, repairWares);
|
||||||
/* 这里添加新逻辑,员工确认退料时,把退的配件从工单子表中删除---end */
|
/* 这里添加新逻辑,员工确认退料时,把退的配件从工单子表中删除---end */
|
||||||
|
|
||||||
// 构建备注
|
// 构建备注
|
||||||
@ -441,19 +439,19 @@ public class DlRepairSoServiceImpl extends ServiceImpl<DlRepairSoMapper, DlRepai
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 领料、退料计算工单子表的通用方法
|
* 领料、退料计算工单子表的通用方法
|
||||||
|
* @param ifGet 是否是领料
|
||||||
|
* @param applyId 配件申请单id
|
||||||
|
* @param sois 领料单、退料单配件明细
|
||||||
|
* @param repairWares 配件库的明细
|
||||||
* @author vinjor-M
|
* @author vinjor-M
|
||||||
* @date 14:31 2024/12/4
|
* @date 14:31 2024/12/4
|
||||||
* @param ifGet 是否是领料
|
**/
|
||||||
* @param applyId 配件申请单id
|
private void dealWareItem(Boolean ifGet, String applyId, List<DlRepairSoi> sois, List<RepairWares> repairWares) {
|
||||||
* @param sois 领料单、退料单配件明细
|
|
||||||
* @param repairWares 配件库的明细
|
|
||||||
**/
|
|
||||||
private void dealWareItem(Boolean ifGet,String applyId,List<DlRepairSoi> sois,List<RepairWares> repairWares){
|
|
||||||
//配件申请单
|
//配件申请单
|
||||||
DlTicketWares dlTicketWares = ticketWaresService.getById(applyId);
|
DlTicketWares dlTicketWares = ticketWaresService.getById(applyId);
|
||||||
//工单现有的配件
|
//工单现有的配件
|
||||||
List<DlRepairTitem> titems = titemService.list(new LambdaQueryWrapper<DlRepairTitem>().and(i -> {
|
List<DlRepairTitem> titems = titemService.list(new LambdaQueryWrapper<DlRepairTitem>().and(i -> {
|
||||||
i.eq(DlRepairTitem::getTicketId,dlTicketWares.getTicketId())
|
i.eq(DlRepairTitem::getTicketId, dlTicketWares.getTicketId())
|
||||||
.eq(DlRepairTitem::getItemType, "02");
|
.eq(DlRepairTitem::getItemType, "02");
|
||||||
}));
|
}));
|
||||||
//更新或插入的数据集合
|
//更新或插入的数据集合
|
||||||
@ -461,37 +459,64 @@ public class DlRepairSoServiceImpl extends ServiceImpl<DlRepairSoMapper, DlRepai
|
|||||||
//删除的数据id集合
|
//删除的数据id集合
|
||||||
List<String> delIdList = new ArrayList<>();
|
List<String> delIdList = new ArrayList<>();
|
||||||
//工单现有配件转MAP
|
//工单现有配件转MAP
|
||||||
Map<String,DlRepairTitem> itemMap = titems.stream().collect(Collectors.toMap(DlRepairTitem::getPartId,Function.identity()));
|
Map<String, DlRepairTitem> itemMap = titems.stream().collect(Collectors.toMap(DlRepairTitem::getPartId, Function.identity()));
|
||||||
//配件库的数据集合转MAP
|
//配件库的数据集合转MAP
|
||||||
Map<String,RepairWares> repairWaresMap = repairWares.stream().collect(Collectors.toMap(RepairWares::getId,Function.identity()));
|
Map<String, RepairWares> repairWaresMap = repairWares.stream().collect(Collectors.toMap(RepairWares::getId, Function.identity()));
|
||||||
//遍历本次领料/退料的所有配件
|
//遍历本次领料/退料的所有配件
|
||||||
for (DlRepairSoi repairSoi:sois){
|
for (DlRepairSoi repairSoi : sois) {
|
||||||
if(itemMap.containsKey(repairSoi.getGoodsId())){
|
if (itemMap.containsKey(repairSoi.getGoodsId())) {
|
||||||
//工单中有这个配件
|
//工单中有这个配件
|
||||||
if(ifGet){
|
if (ifGet) {
|
||||||
//领料
|
//领料
|
||||||
//工单现有配件中就有这个领取的配件,需要更新这个配件的数量、价格
|
//工单现有配件中就有这个领取的配件,需要更新这个配件的数量、价格
|
||||||
DlRepairTitem item = itemMap.get(repairSoi.getGoodsId());
|
DlRepairTitem item = itemMap.get(repairSoi.getGoodsId());
|
||||||
item.setItemCount(item.getItemCount() + repairSoi.getGoodsCount());
|
item.setItemCount(item.getItemCount() + repairSoi.getGoodsCount());
|
||||||
item.setItemMoney(item.getItemPrice().multiply(BigDecimal.valueOf(item.getItemCount())).multiply(item.getItemDiscount()));
|
item.setItemMoney(item.getItemPrice().multiply(BigDecimal.valueOf(item.getItemCount())).multiply(item.getItemDiscount()));
|
||||||
item.setItemStatus(TicketsItemStatusEnum.RECEIVED.getCode());
|
item.setItemStatus(TicketsItemStatusEnum.RECEIVED.getCode());
|
||||||
|
|
||||||
|
|
||||||
|
// 获取配件的售价和进价
|
||||||
|
BigDecimal salePrice = repairWaresMap.get(repairSoi.getGoodsId()).getPrice(); // 售价
|
||||||
|
BigDecimal purchasePrice = repairWaresMap.get(repairSoi.getGoodsId()).getPurPrice(); // 进价
|
||||||
|
|
||||||
|
//计算利润
|
||||||
|
BigDecimal profit = operateUtil.calcProfit(salePrice, purchasePrice, item.getItemCount());
|
||||||
|
// 计算毛利率
|
||||||
|
BigDecimal profitRate = operateUtil.calcProfitRate(salePrice, purchasePrice, item.getItemCount());
|
||||||
|
|
||||||
|
item.setItemProfit(profit);
|
||||||
|
item.setItemProfitRate(profitRate);
|
||||||
|
|
||||||
saveOrUpdateList.add(item);
|
saveOrUpdateList.add(item);
|
||||||
}else{
|
} else {
|
||||||
//退料
|
//退料
|
||||||
//工单现有配件中就有这个领取的配件,需要更新这个配件的数量、价格
|
//工单现有配件中就有这个领取的配件,需要更新这个配件的数量、价格
|
||||||
DlRepairTitem item = itemMap.get(repairSoi.getGoodsId());
|
DlRepairTitem item = itemMap.get(repairSoi.getGoodsId());
|
||||||
if(item.getItemCount()>repairSoi.getGoodsCount()){
|
if (item.getItemCount() > repairSoi.getGoodsCount()) {
|
||||||
//现有数量大于要退的数量,扣掉
|
//现有数量大于要退的数量,扣掉
|
||||||
item.setItemCount(item.getItemCount() - repairSoi.getGoodsCount());
|
item.setItemCount(item.getItemCount() - repairSoi.getGoodsCount());
|
||||||
item.setItemMoney(item.getItemPrice().multiply(BigDecimal.valueOf(item.getItemCount())).multiply(item.getItemDiscount()));
|
item.setItemMoney(item.getItemPrice().multiply(BigDecimal.valueOf(item.getItemCount())).multiply(item.getItemDiscount()));
|
||||||
item.setItemStatus(TicketsItemStatusEnum.RECEIVED.getCode());
|
item.setItemStatus(TicketsItemStatusEnum.RECEIVED.getCode());
|
||||||
|
|
||||||
|
// 重新计算利润和利润率
|
||||||
|
BigDecimal salePrice = repairWaresMap.get(repairSoi.getGoodsId()).getPrice(); // 售价
|
||||||
|
BigDecimal purchasePrice = repairWaresMap.get(repairSoi.getGoodsId()).getPurPrice(); // 进价
|
||||||
|
|
||||||
|
//计算利润
|
||||||
|
BigDecimal profit = operateUtil.calcProfit(salePrice, purchasePrice, item.getItemCount());
|
||||||
|
// 计算毛利率
|
||||||
|
BigDecimal profitRate = operateUtil.calcProfitRate(salePrice, purchasePrice, item.getItemCount());
|
||||||
|
|
||||||
|
item.setItemProfit(profit);
|
||||||
|
item.setItemProfitRate(profitRate);
|
||||||
|
|
||||||
saveOrUpdateList.add(item);
|
saveOrUpdateList.add(item);
|
||||||
}else{
|
} else {
|
||||||
//现有数量小于或等于要退的数量,直接将这个配件删掉
|
//现有数量小于或等于要退的数量,直接将这个配件删掉
|
||||||
delIdList.add(item.getId());
|
delIdList.add(item.getId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}else{
|
} else {
|
||||||
//工单中没有这个配件
|
//工单中没有这个配件
|
||||||
if (ifGet) {
|
if (ifGet) {
|
||||||
//领料,需要把这个配件添加到工单子表中
|
//领料,需要把这个配件添加到工单子表中
|
||||||
@ -515,25 +540,37 @@ public class DlRepairSoServiceImpl extends ServiceImpl<DlRepairSoMapper, DlRepai
|
|||||||
titem.setSaleName(dlTicketWares.getAdviserName());
|
titem.setSaleName(dlTicketWares.getAdviserName());
|
||||||
titem.setPartId(repairSoi.getGoodsId());
|
titem.setPartId(repairSoi.getGoodsId());
|
||||||
titem.setItemStatus(TicketsItemStatusEnum.RECEIVED.getCode());
|
titem.setItemStatus(TicketsItemStatusEnum.RECEIVED.getCode());
|
||||||
|
|
||||||
|
// 获取售价和进价
|
||||||
|
BigDecimal salePrice = waresItem.getPrice(); // 售价
|
||||||
|
BigDecimal purchasePrice = waresItem.getPurPrice(); // 进价
|
||||||
|
|
||||||
|
//计算利润
|
||||||
|
BigDecimal profit = operateUtil.calcProfit(salePrice, purchasePrice, titem.getItemCount());
|
||||||
|
// 计算毛利率
|
||||||
|
BigDecimal profitRate = operateUtil.calcProfitRate(salePrice, purchasePrice, titem.getItemCount());
|
||||||
|
|
||||||
|
titem.setItemProfitRate(profitRate);
|
||||||
|
titem.setItemProfit(profit);
|
||||||
saveOrUpdateList.add(titem);
|
saveOrUpdateList.add(titem);
|
||||||
}else{
|
} else {
|
||||||
//退料,不可能出现,没领料就退料的情况,不用处理
|
//退料,不可能出现,没领料就退料的情况,不用处理
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(!saveOrUpdateList.isEmpty()){
|
if (!saveOrUpdateList.isEmpty()) {
|
||||||
titemService.saveOrUpdateBatch(saveOrUpdateList);
|
titemService.saveOrUpdateBatch(saveOrUpdateList);
|
||||||
}
|
}
|
||||||
if(!delIdList.isEmpty()){
|
if (!delIdList.isEmpty()) {
|
||||||
titemService.removeBatchByIds(delIdList);
|
titemService.removeBatchByIds(delIdList);
|
||||||
}
|
}
|
||||||
//重新计算工单的价格和订单的价格
|
//重新计算工单的价格和订单的价格
|
||||||
ticketsService.computeTicket(dlTicketWares.getTicketId());
|
ticketsService.computeTicket(dlTicketWares.getTicketId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 采购入库
|
* 采购入库
|
||||||
*
|
|
||||||
* @param reqVO (接参实体中需传入:采购单id,单据编号soNo,备注remark,入库总价totalPrice,子表中商品id,子表中入库数量inCount)
|
* @param reqVO (接参实体中需传入:采购单id,单据编号soNo,备注remark,入库总价totalPrice,子表中商品id,子表中入库数量inCount)
|
||||||
* @author PQZ
|
* @author PQZ
|
||||||
* @date 14:32 2024/10/24
|
* @date 14:32 2024/10/24
|
||||||
@ -649,7 +686,6 @@ public class DlRepairSoServiceImpl extends ServiceImpl<DlRepairSoMapper, DlRepai
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 领料单、退料单APP查看
|
* 领料单、退料单APP查看
|
||||||
*
|
|
||||||
* @param id 单据id
|
* @param id 单据id
|
||||||
* @return cn.iocoder.yudao.framework.common.pojo.CommonResult<?>
|
* @return cn.iocoder.yudao.framework.common.pojo.CommonResult<?>
|
||||||
* @author vinjor-M
|
* @author vinjor-M
|
||||||
|
|||||||
@ -61,6 +61,16 @@ public class DlRepairTitem extends TenantBaseDO {
|
|||||||
*/
|
*/
|
||||||
private BigDecimal itemMoney;
|
private BigDecimal itemMoney;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 利润
|
||||||
|
*/
|
||||||
|
private BigDecimal itemProfit;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 毛利率
|
||||||
|
*/
|
||||||
|
private BigDecimal itemProfitRate;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 维修人员ID(system_users表的ID)
|
* 维修人员ID(system_users表的ID)
|
||||||
*/
|
*/
|
||||||
@ -115,4 +125,4 @@ public class DlRepairTitem extends TenantBaseDO {
|
|||||||
* 备注
|
* 备注
|
||||||
*/
|
*/
|
||||||
private String remark;
|
private String remark;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -86,6 +86,7 @@ import javax.servlet.http.HttpServletResponse;
|
|||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
|
import java.math.RoundingMode;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.time.ZoneId;
|
import java.time.ZoneId;
|
||||||
import java.time.format.DateTimeFormatter;
|
import java.time.format.DateTimeFormatter;
|
||||||
@ -100,7 +101,6 @@ import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionU
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 针对表【dl_repair_tickets(维修工单表)】的数据库操作Service实现
|
* 针对表【dl_repair_tickets(维修工单表)】的数据库操作Service实现
|
||||||
*
|
|
||||||
* @author 小李
|
* @author 小李
|
||||||
* @date 18:19 2024/9/13
|
* @date 18:19 2024/9/13
|
||||||
**/
|
**/
|
||||||
@ -202,7 +202,6 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl<DlRepairTicketsMappe
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 维修工单表 新增
|
* 维修工单表 新增
|
||||||
*
|
|
||||||
* @param ticketsRespVO 新增对象
|
* @param ticketsRespVO 新增对象
|
||||||
* @author 小李
|
* @author 小李
|
||||||
* @date 11:33 2024/9/20
|
* @date 11:33 2024/9/20
|
||||||
@ -244,39 +243,39 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl<DlRepairTicketsMappe
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* 更新车辆的字段最近保养日期、最近保养公里数等等 start */
|
/* 更新车辆的字段最近保养日期、最近保养公里数等等 start */
|
||||||
if(null!=ticketsRespVO.getMaintenanceDate() || null!= ticketsRespVO.getMaintenanceMileage()){
|
if (null != ticketsRespVO.getMaintenanceDate() || null != ticketsRespVO.getMaintenanceMileage()) {
|
||||||
CarMain carMain = carMainService.getById(ticketsRespVO.getCarId());
|
CarMain carMain = carMainService.getById(ticketsRespVO.getCarId());
|
||||||
if(null!=carMain.getCarRegisterDate()){
|
if (null != carMain.getCarRegisterDate()) {
|
||||||
carMain.setCarYear(operateUtil.computeCarYear(Date.from(carMain.getCarRegisterDate().atZone(ZoneId.systemDefault()).toInstant())));
|
carMain.setCarYear(operateUtil.computeCarYear(Date.from(carMain.getCarRegisterDate().atZone(ZoneId.systemDefault()).toInstant())));
|
||||||
}
|
}
|
||||||
//保养日期
|
//保养日期
|
||||||
if(null!=ticketsRespVO.getMaintenanceDate()){
|
if (null != ticketsRespVO.getMaintenanceDate()) {
|
||||||
carMain.setMaintenanceDate(ticketsRespVO.getMaintenanceDate().toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime());
|
carMain.setMaintenanceDate(ticketsRespVO.getMaintenanceDate().toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime());
|
||||||
}
|
}
|
||||||
//保养里程
|
//保养里程
|
||||||
if(null!=ticketsRespVO.getMaintenanceMileage()) {
|
if (null != ticketsRespVO.getMaintenanceMileage()) {
|
||||||
carMain.setMaintenanceMileage(ticketsRespVO.getMaintenanceMileage());
|
carMain.setMaintenanceMileage(ticketsRespVO.getMaintenanceMileage());
|
||||||
}
|
}
|
||||||
//下次年检日期
|
//下次年检日期
|
||||||
if(null!=ticketsRespVO.getNextInspectionDate()) {
|
if (null != ticketsRespVO.getNextInspectionDate()) {
|
||||||
carMain.setNextInspectionDate(ticketsRespVO.getNextInspectionDate().toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime());
|
carMain.setNextInspectionDate(ticketsRespVO.getNextInspectionDate().toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime());
|
||||||
}
|
}
|
||||||
//保险到期日期
|
//保险到期日期
|
||||||
if(null!=ticketsRespVO.getInsuranceExpiryDate()) {
|
if (null != ticketsRespVO.getInsuranceExpiryDate()) {
|
||||||
carMain.setInsuranceExpiryDate(ticketsRespVO.getInsuranceExpiryDate().toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime());
|
carMain.setInsuranceExpiryDate(ticketsRespVO.getInsuranceExpiryDate().toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime());
|
||||||
}
|
}
|
||||||
//保险公司名称
|
//保险公司名称
|
||||||
if(null!=ticketsRespVO.getInsuranceName()) {
|
if (null != ticketsRespVO.getInsuranceName()) {
|
||||||
carMain.setInsuranceName(ticketsRespVO.getInsuranceName());
|
carMain.setInsuranceName(ticketsRespVO.getInsuranceName());
|
||||||
}
|
}
|
||||||
//承保险种,多个英文逗号隔开
|
//承保险种,多个英文逗号隔开
|
||||||
if(null!=ticketsRespVO.getInsuranceType()) {
|
if (null != ticketsRespVO.getInsuranceType()) {
|
||||||
carMain.setInsuranceType(ticketsRespVO.getInsuranceType());
|
carMain.setInsuranceType(ticketsRespVO.getInsuranceType());
|
||||||
}
|
}
|
||||||
if(null!=ticketsRespVO.getJiaoqiang()) {
|
if (null != ticketsRespVO.getJiaoqiang()) {
|
||||||
carMain.setJiaoqiang(ticketsRespVO.getJiaoqiang());
|
carMain.setJiaoqiang(ticketsRespVO.getJiaoqiang());
|
||||||
}
|
}
|
||||||
if(null!=ticketsRespVO.getShangye()) {
|
if (null != ticketsRespVO.getShangye()) {
|
||||||
carMain.setShangye(ticketsRespVO.getShangye());
|
carMain.setShangye(ticketsRespVO.getShangye());
|
||||||
}
|
}
|
||||||
carMainService.updateById(carMain);
|
carMainService.updateById(carMain);
|
||||||
@ -284,7 +283,7 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl<DlRepairTicketsMappe
|
|||||||
/* 更新车辆的最近保养日期、最近保养公里数 end */
|
/* 更新车辆的最近保养日期、最近保养公里数 end */
|
||||||
|
|
||||||
/* 更新客户来源 */
|
/* 更新客户来源 */
|
||||||
if(StringUtils.isNotEmpty(ticketsRespVO.getCusFrom())){
|
if (StringUtils.isNotEmpty(ticketsRespVO.getCusFrom())) {
|
||||||
CustomerMain customerMain = customerMainService.getById(ticketsRespVO.getUserId());
|
CustomerMain customerMain = customerMainService.getById(ticketsRespVO.getUserId());
|
||||||
customerMain.setDataFrom(ticketsRespVO.getCusFrom());
|
customerMain.setDataFrom(ticketsRespVO.getCusFrom());
|
||||||
customerMainService.updateById(customerMain);
|
customerMainService.updateById(customerMain);
|
||||||
@ -376,13 +375,12 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl<DlRepairTicketsMappe
|
|||||||
// 通知客户
|
// 通知客户
|
||||||
// 构建消息
|
// 构建消息
|
||||||
String message = String.format("您的爱车%s已开始%s", ticketsRespVO.getCarNo(), repairOrderInfo.getGoodsTitle());
|
String message = String.format("您的爱车%s已开始%s", ticketsRespVO.getCarNo(), repairOrderInfo.getGoodsTitle());
|
||||||
repairWorkerService.sentMessageToCus(SystemEnum.REPAIR.getCode(),ticketsRespVO.getId(), message, true);
|
repairWorkerService.sentMessageToCus(SystemEnum.REPAIR.getCode(), ticketsRespVO.getId(), message, true);
|
||||||
return ticketsRespVO;
|
return ticketsRespVO;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 维修工单表 分页
|
* 维修工单表 分页
|
||||||
*
|
|
||||||
* @param repairTicketsReqVO 查询对象
|
* @param repairTicketsReqVO 查询对象
|
||||||
* @author 小李
|
* @author 小李
|
||||||
* @date 20:51 2024/9/20
|
* @date 20:51 2024/9/20
|
||||||
@ -394,28 +392,27 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl<DlRepairTicketsMappe
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 获得一个工单的详细信息
|
* 获得一个工单的详细信息
|
||||||
*
|
* @param id 工单ID
|
||||||
* @param id 工单ID
|
|
||||||
* @param ifApp 是否是APP发起的查询
|
* @param ifApp 是否是APP发起的查询
|
||||||
* @author 小李
|
* @author 小李
|
||||||
* @date 16:05 2024/9/21
|
* @date 16:05 2024/9/21
|
||||||
**/
|
**/
|
||||||
@Override
|
@Override
|
||||||
public DlRepairTicketsRespVO getTicketsById(String id,Boolean ifApp) {
|
public DlRepairTicketsRespVO getTicketsById(String id, Boolean ifApp) {
|
||||||
// 查工单主表
|
// 查工单主表
|
||||||
DlRepairTickets dlRepairTickets = baseMapper.selectById(id);
|
DlRepairTickets dlRepairTickets = baseMapper.selectById(id);
|
||||||
//翻译维修类型
|
//翻译维修类型
|
||||||
List<DictDataRespDTO> repairTypeList = dictDataApi.getDictDataList(DICT_REPAIR_TYPE);
|
List<DictDataRespDTO> repairTypeList = dictDataApi.getDictDataList(DICT_REPAIR_TYPE);
|
||||||
Map<String,String> repairTypeMap = repairTypeList.stream().collect(Collectors.toMap(DictDataRespDTO::getValue,DictDataRespDTO::getLabel));
|
Map<String, String> repairTypeMap = repairTypeList.stream().collect(Collectors.toMap(DictDataRespDTO::getValue, DictDataRespDTO::getLabel));
|
||||||
DlRepairTicketsRespVO result = BeanUtil.toBean(dlRepairTickets, DlRepairTicketsRespVO.class);
|
DlRepairTicketsRespVO result = BeanUtil.toBean(dlRepairTickets, DlRepairTicketsRespVO.class);
|
||||||
result.setRepairTypeText(repairTypeMap.getOrDefault(dlRepairTickets.getRepairType(),""));
|
result.setRepairTypeText(repairTypeMap.getOrDefault(dlRepairTickets.getRepairType(), ""));
|
||||||
//查是否存在总检完成的记录,取出他的时间
|
//查是否存在总检完成的记录,取出他的时间
|
||||||
LambdaQueryWrapper<RepairRecords> queryWrapper = new LambdaQueryWrapper<RepairRecords>()
|
LambdaQueryWrapper<RepairRecords> queryWrapper = new LambdaQueryWrapper<RepairRecords>()
|
||||||
.eq(RepairRecords::getTicketId,id)
|
.eq(RepairRecords::getTicketId, id)
|
||||||
.eq(RepairRecords::getType,RecordTypeEnum.ZJ.getCode())
|
.eq(RepairRecords::getType, RecordTypeEnum.ZJ.getCode())
|
||||||
.orderByDesc(BaseDO::getCreateTime);
|
.orderByDesc(BaseDO::getCreateTime);
|
||||||
List<RepairRecords> repairRecords = repairRecordsService.list(queryWrapper);
|
List<RepairRecords> repairRecords = repairRecordsService.list(queryWrapper);
|
||||||
if(!repairRecords.isEmpty()){
|
if (!repairRecords.isEmpty()) {
|
||||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
||||||
String formattedString = repairRecords.get(0).getCreateTime().format(formatter);
|
String formattedString = repairRecords.get(0).getCreateTime().format(formatter);
|
||||||
result.setRealOverDate(formattedString);
|
result.setRealOverDate(formattedString);
|
||||||
@ -427,13 +424,13 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl<DlRepairTicketsMappe
|
|||||||
if (ObjectUtil.isNotEmpty(dlRepairTickets.getCarId())) {
|
if (ObjectUtil.isNotEmpty(dlRepairTickets.getCarId())) {
|
||||||
CarMainRespVO carInfo = carMainService.queryCarById(dlRepairTickets.getCarId());
|
CarMainRespVO carInfo = carMainService.queryCarById(dlRepairTickets.getCarId());
|
||||||
//计算车龄
|
//计算车龄
|
||||||
if(null!=carInfo.getCarRegisterDate()){
|
if (null != carInfo.getCarRegisterDate()) {
|
||||||
Double carYear = operateUtil.computeCarYear(Date.from(carInfo.getCarRegisterDate().atZone(ZoneId.systemDefault()).toInstant()));
|
Double carYear = operateUtil.computeCarYear(Date.from(carInfo.getCarRegisterDate().atZone(ZoneId.systemDefault()).toInstant()));
|
||||||
//更新回去
|
//更新回去
|
||||||
CarMain carMain = new CarMain();
|
CarMain carMain = new CarMain();
|
||||||
carMain.setId(dlRepairTickets.getCarId());
|
carMain.setId(dlRepairTickets.getCarId());
|
||||||
carMain.setCarYear(carYear);
|
carMain.setCarYear(carYear);
|
||||||
if(null==carInfo.getCarYear() ||!carInfo.getCarYear().equals(carYear)){
|
if (null == carInfo.getCarYear() || !carInfo.getCarYear().equals(carYear)) {
|
||||||
carMainService.updateById(carMain);
|
carMainService.updateById(carMain);
|
||||||
}
|
}
|
||||||
carInfo.setCarYear(carYear);
|
carInfo.setCarYear(carYear);
|
||||||
@ -443,10 +440,10 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl<DlRepairTicketsMappe
|
|||||||
|
|
||||||
//查用户信息
|
//查用户信息
|
||||||
CustomerMain customerInfo = customerService.getById(dlRepairTickets.getUserId());
|
CustomerMain customerInfo = customerService.getById(dlRepairTickets.getUserId());
|
||||||
if(StringUtils.isNotEmpty(customerInfo.getDataFrom())){
|
if (StringUtils.isNotEmpty(customerInfo.getDataFrom())) {
|
||||||
//翻译客户来源
|
//翻译客户来源
|
||||||
List<DictDataRespDTO> dataFromList = dictDataApi.getDictDataList(DICT_CUS_DATA_FROM);
|
List<DictDataRespDTO> dataFromList = dictDataApi.getDictDataList(DICT_CUS_DATA_FROM);
|
||||||
Map<String,String> dataFromMap = dataFromList.stream().collect(Collectors.toMap(DictDataRespDTO::getValue,DictDataRespDTO::getLabel));
|
Map<String, String> dataFromMap = dataFromList.stream().collect(Collectors.toMap(DictDataRespDTO::getValue, DictDataRespDTO::getLabel));
|
||||||
customerInfo.setDataFromText(dataFromMap.get(customerInfo.getDataFrom()));
|
customerInfo.setDataFromText(dataFromMap.get(customerInfo.getDataFrom()));
|
||||||
}
|
}
|
||||||
result.setCustomerInfo(customerInfo);
|
result.setCustomerInfo(customerInfo);
|
||||||
@ -464,15 +461,15 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl<DlRepairTicketsMappe
|
|||||||
items.forEach(item -> repairProjects.stream().filter(i -> i.getId().equals(item.getProjectId())).findFirst().ifPresent(item::setProject));
|
items.forEach(item -> repairProjects.stream().filter(i -> i.getId().equals(item.getProjectId())).findFirst().ifPresent(item::setProject));
|
||||||
}
|
}
|
||||||
result.setProjects(projects);
|
result.setProjects(projects);
|
||||||
if(ifApp){
|
if (ifApp) {
|
||||||
//app新增逻辑
|
//app新增逻辑
|
||||||
if (CollectionUtil.isNotEmpty(projects)) {
|
if (CollectionUtil.isNotEmpty(projects)) {
|
||||||
List<AppWaresGroupVO> projectList = new ArrayList<>();
|
List<AppWaresGroupVO> projectList = new ArrayList<>();
|
||||||
//查所有服务分类(项目分类)
|
//查所有服务分类(项目分类)
|
||||||
List<BaseType> baseTypeList = baseTypeService.list();
|
List<BaseType> baseTypeList = baseTypeService.list();
|
||||||
Map<String,String> baseTypeMap = baseTypeList.stream().collect(Collectors.toMap(BaseType::getId,BaseType::getName));
|
Map<String, String> baseTypeMap = baseTypeList.stream().collect(Collectors.toMap(BaseType::getId, BaseType::getName));
|
||||||
//先过滤出itenTypeId为null或空为单独一个组
|
//先过滤出itenTypeId为null或空为单独一个组
|
||||||
List<DlRepairTitemReqVO> nullList = projects.stream().filter(item->StringUtils.isEmpty(item.getItemTypeId())).collect(Collectors.toList());
|
List<DlRepairTitemReqVO> nullList = projects.stream().filter(item -> StringUtils.isEmpty(item.getItemTypeId())).collect(Collectors.toList());
|
||||||
if (CollectionUtil.isNotEmpty(nullList)) {
|
if (CollectionUtil.isNotEmpty(nullList)) {
|
||||||
AppWaresGroupVO waresGroupVO = new AppWaresGroupVO();
|
AppWaresGroupVO waresGroupVO = new AppWaresGroupVO();
|
||||||
waresGroupVO.setWares(nullList);
|
waresGroupVO.setWares(nullList);
|
||||||
@ -484,8 +481,8 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl<DlRepairTicketsMappe
|
|||||||
projectList.add(waresGroupVO);
|
projectList.add(waresGroupVO);
|
||||||
}
|
}
|
||||||
//过滤出有分类的进行分组
|
//过滤出有分类的进行分组
|
||||||
Map<String,List<DlRepairTitemReqVO>> groupListMap = projects.stream().filter(item->StringUtils.isNotEmpty(item.getItemTypeId())).collect(Collectors.groupingBy(DlRepairTitem::getItemTypeId));
|
Map<String, List<DlRepairTitemReqVO>> groupListMap = projects.stream().filter(item -> StringUtils.isNotEmpty(item.getItemTypeId())).collect(Collectors.groupingBy(DlRepairTitem::getItemTypeId));
|
||||||
for (String key:groupListMap.keySet()){
|
for (String key : groupListMap.keySet()) {
|
||||||
AppWaresGroupVO waresGroupVO = new AppWaresGroupVO();
|
AppWaresGroupVO waresGroupVO = new AppWaresGroupVO();
|
||||||
waresGroupVO.setWares(groupListMap.get(key));
|
waresGroupVO.setWares(groupListMap.get(key));
|
||||||
waresGroupVO.setGroupName(baseTypeMap.get(key));
|
waresGroupVO.setGroupName(baseTypeMap.get(key));
|
||||||
@ -501,44 +498,44 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl<DlRepairTicketsMappe
|
|||||||
}
|
}
|
||||||
|
|
||||||
//处理配件
|
//处理配件
|
||||||
if(ifApp){
|
if (ifApp) {
|
||||||
//app的逻辑
|
//app的逻辑
|
||||||
List<AppWaresGroupVO> waresGroupList = new ArrayList<>();
|
List<AppWaresGroupVO> waresGroupList = new ArrayList<>();
|
||||||
//查这个工单的配件
|
//查这个工单的配件
|
||||||
List<DlRepairTitemReqVO> waresList = repairTitemMapper.selectByTicketId(id);
|
List<DlRepairTitemReqVO> waresList = repairTitemMapper.selectByTicketId(id);
|
||||||
if (CollectionUtil.isNotEmpty(waresList)) {
|
if (CollectionUtil.isNotEmpty(waresList)) {
|
||||||
//先过滤出itenTypeId为null或空,或者itemTypeName为null或空的,为单独一个组
|
//先过滤出itenTypeId为null或空,或者itemTypeName为null或空的,为单独一个组
|
||||||
List<DlRepairTitemReqVO> nullList = waresList.stream().filter(item->StringUtils.isEmpty(item.getItemTypeId()) || StringUtils.isEmpty(item.getItemTypeName())).collect(Collectors.toList());
|
List<DlRepairTitemReqVO> nullList = waresList.stream().filter(item -> StringUtils.isEmpty(item.getItemTypeId()) || StringUtils.isEmpty(item.getItemTypeName())).collect(Collectors.toList());
|
||||||
if (CollectionUtil.isNotEmpty(nullList)) {
|
if (CollectionUtil.isNotEmpty(nullList)) {
|
||||||
AppWaresGroupVO waresGroupVO = new AppWaresGroupVO();
|
AppWaresGroupVO waresGroupVO = new AppWaresGroupVO();
|
||||||
waresGroupVO.setWares(nullList);
|
waresGroupVO.setWares(nullList);
|
||||||
waresGroupVO.setGroupName("未知分组");
|
waresGroupVO.setGroupName("未知分组");
|
||||||
waresGroupVO.setNums(nullList.size());
|
waresGroupVO.setNums(nullList.size());
|
||||||
waresGroupVO.setTotalAmount(nullList.stream().peek(item->{
|
waresGroupVO.setTotalAmount(nullList.stream().peek(item -> {
|
||||||
if(null==item.getItemMoney()){
|
if (null == item.getItemMoney()) {
|
||||||
item.setItemMoney(new BigDecimal(0));
|
item.setItemMoney(new BigDecimal(0));
|
||||||
}
|
}
|
||||||
}).map(DlRepairTitem::getItemMoney).reduce(BigDecimal.ZERO,BigDecimal::add));
|
}).map(DlRepairTitem::getItemMoney).reduce(BigDecimal.ZERO, BigDecimal::add));
|
||||||
waresGroupList.add(waresGroupVO);
|
waresGroupList.add(waresGroupVO);
|
||||||
}
|
}
|
||||||
//过滤出有分类的进行分组
|
//过滤出有分类的进行分组
|
||||||
Map<String,List<DlRepairTitemReqVO>> groupListMap = waresList.stream().filter(item->StringUtils.isNotEmpty(item.getItemTypeId()) && StringUtils.isNotEmpty(item.getItemTypeName())).collect(Collectors.groupingBy(DlRepairTitem::getItemTypeId));
|
Map<String, List<DlRepairTitemReqVO>> groupListMap = waresList.stream().filter(item -> StringUtils.isNotEmpty(item.getItemTypeId()) && StringUtils.isNotEmpty(item.getItemTypeName())).collect(Collectors.groupingBy(DlRepairTitem::getItemTypeId));
|
||||||
for (String key:groupListMap.keySet()){
|
for (String key : groupListMap.keySet()) {
|
||||||
AppWaresGroupVO waresGroupVO = new AppWaresGroupVO();
|
AppWaresGroupVO waresGroupVO = new AppWaresGroupVO();
|
||||||
waresGroupVO.setWares(groupListMap.get(key));
|
waresGroupVO.setWares(groupListMap.get(key));
|
||||||
waresGroupVO.setGroupName(groupListMap.get(key).get(0).getItemTypeName());
|
waresGroupVO.setGroupName(groupListMap.get(key).get(0).getItemTypeName());
|
||||||
waresGroupVO.setGroupId(key);
|
waresGroupVO.setGroupId(key);
|
||||||
waresGroupVO.setNums(groupListMap.get(key).size());
|
waresGroupVO.setNums(groupListMap.get(key).size());
|
||||||
waresGroupVO.setTotalAmount(groupListMap.get(key).stream().peek(item->{
|
waresGroupVO.setTotalAmount(groupListMap.get(key).stream().peek(item -> {
|
||||||
if(null==item.getItemMoney()){
|
if (null == item.getItemMoney()) {
|
||||||
item.setItemMoney(new BigDecimal(0));
|
item.setItemMoney(new BigDecimal(0));
|
||||||
}
|
}
|
||||||
}).map(DlRepairTitem::getItemMoney).reduce(BigDecimal.ZERO,BigDecimal::add));
|
}).map(DlRepairTitem::getItemMoney).reduce(BigDecimal.ZERO, BigDecimal::add));
|
||||||
waresGroupList.add(waresGroupVO);
|
waresGroupList.add(waresGroupVO);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
result.setWaresGroupList(waresGroupList);
|
result.setWaresGroupList(waresGroupList);
|
||||||
}else{
|
} else {
|
||||||
// 取配件----原有逻辑-电脑端
|
// 取配件----原有逻辑-电脑端
|
||||||
List<DlRepairTitemReqVO> wares = items.stream().filter(item -> item.getItemType().equals("02")).collect(Collectors.toList());
|
List<DlRepairTitemReqVO> wares = items.stream().filter(item -> item.getItemType().equals("02")).collect(Collectors.toList());
|
||||||
if (CollectionUtil.isNotEmpty(wares)) {
|
if (CollectionUtil.isNotEmpty(wares)) {
|
||||||
@ -570,13 +567,45 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl<DlRepairTicketsMappe
|
|||||||
List<DictDataRespDTO> recordTypeList = dictDataApi.getDictDataList(DICT_REPAIR_RECORDS_TYPE);
|
List<DictDataRespDTO> recordTypeList = dictDataApi.getDictDataList(DICT_REPAIR_RECORDS_TYPE);
|
||||||
Map<String, String> typeMap = recordTypeList.stream().collect(Collectors.toMap(DictDataRespDTO::getValue, DictDataRespDTO::getLabel));
|
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()));
|
result.setRecords(records.stream().peek(item -> item.setType(typeMap.get(item.getType()))).collect(Collectors.toList()));
|
||||||
|
|
||||||
|
//配件总利润
|
||||||
|
BigDecimal waresProfit = BigDecimal.ZERO;
|
||||||
|
if (CollectionUtil.isNotEmpty(items)) {
|
||||||
|
for (DlRepairTitemReqVO item : items) {
|
||||||
|
if ("02".equals(item.getItemType())) {
|
||||||
|
// 获取配件利润 加到总利润中
|
||||||
|
BigDecimal itemProfit = item.getItemProfit() != null ? item.getItemProfit() : BigDecimal.ZERO;
|
||||||
|
waresProfit = waresProfit.add(itemProfit);
|
||||||
|
System.out.println("配件利润:" + itemProfit);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//计算含工时项目毛利率
|
||||||
|
//配件总利润除以工单总价
|
||||||
|
BigDecimal profitRate = new BigDecimal(0);
|
||||||
|
if (ObjectUtil.isNotEmpty(dlRepairTickets.getTotalPrice())) {
|
||||||
|
if (dlRepairTickets.getTotalPrice().compareTo(BigDecimal.ZERO) != 0) {
|
||||||
|
profitRate = waresProfit.divide(dlRepairTickets.getTotalPrice(), 2, RoundingMode.HALF_UP);
|
||||||
|
}
|
||||||
|
result.setProfitRate(profitRate);
|
||||||
|
}
|
||||||
|
//计算不含工时项目毛利率
|
||||||
|
if (ObjectUtil.isNotEmpty(dlRepairTickets.getPartPrice())) {
|
||||||
|
BigDecimal profitRateNo = new BigDecimal(0);
|
||||||
|
if (dlRepairTickets.getPartPrice().compareTo(BigDecimal.ZERO) != 0) {
|
||||||
|
profitRateNo = waresProfit.divide(dlRepairTickets.getPartPrice(), 2, RoundingMode.HALF_UP);
|
||||||
|
}
|
||||||
|
result.setProfitRateNo(profitRateNo);
|
||||||
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 维修工单表 作废
|
* 维修工单表 作废
|
||||||
* 传对象是因为需要有作废备注
|
* 传对象是因为需要有作废备注
|
||||||
*
|
|
||||||
* @param repairTicketsReqVO 工单对象
|
* @param repairTicketsReqVO 工单对象
|
||||||
* @author 小李
|
* @author 小李
|
||||||
* @date 19:46 2024/9/22
|
* @date 19:46 2024/9/22
|
||||||
@ -600,7 +629,6 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl<DlRepairTicketsMappe
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 维修工单表 结算
|
* 维修工单表 结算
|
||||||
*
|
|
||||||
* @param repairTicketsRespVO 工单
|
* @param repairTicketsRespVO 工单
|
||||||
* @author 小李
|
* @author 小李
|
||||||
* @date 8:50 2024/9/23
|
* @date 8:50 2024/9/23
|
||||||
@ -619,13 +647,13 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl<DlRepairTicketsMappe
|
|||||||
|
|
||||||
// 更新工单
|
// 更新工单
|
||||||
// 在这里把工单的状态更新为已完成---需要判断,如果是线上支付,需要在支付回调更新----有点问题
|
// 在这里把工单的状态更新为已完成---需要判断,如果是线上支付,需要在支付回调更新----有点问题
|
||||||
if (repairTicketsRespVO.getPayType().equals("01")){
|
if (repairTicketsRespVO.getPayType().equals("01")) {
|
||||||
// 线上支付需要在回调中去更新状态工单状态和订单状态
|
// 线上支付需要在回调中去更新状态工单状态和订单状态
|
||||||
|
|
||||||
}else {
|
} else {
|
||||||
// 线下支付和签单、挂账等其他支付方式才是直接结束工单和订单
|
// 线下支付和签单、挂账等其他支付方式才是直接结束工单和订单
|
||||||
DlRepairTickets repairTickets = this.getById(repairTicketsRespVO.getId());
|
DlRepairTickets repairTickets = this.getById(repairTicketsRespVO.getId());
|
||||||
if("1".equals(repairTickets.getIsHandover())){
|
if ("1".equals(repairTickets.getIsHandover())) {
|
||||||
//已交车,已结算。那么工单状态改为 已完成
|
//已交车,已结算。那么工单状态改为 已完成
|
||||||
repairTicketsRespVO.setTicketsStatus(TicketsStatusEnum.OVER.getCode());
|
repairTicketsRespVO.setTicketsStatus(TicketsStatusEnum.OVER.getCode());
|
||||||
//工单结束
|
//工单结束
|
||||||
@ -648,7 +676,6 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl<DlRepairTicketsMappe
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 客户信息和车辆信息 新增、修改
|
* 客户信息和车辆信息 新增、修改
|
||||||
*
|
|
||||||
* @param customerAndCarVO 用户信息和车辆信息
|
* @param customerAndCarVO 用户信息和车辆信息
|
||||||
* @author 小李
|
* @author 小李
|
||||||
* @date 9:25 2024/10/8
|
* @date 9:25 2024/10/8
|
||||||
@ -672,7 +699,7 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl<DlRepairTicketsMappe
|
|||||||
userDTO.setId(byMobile.getId());
|
userDTO.setId(byMobile.getId());
|
||||||
}
|
}
|
||||||
customerAndCarVO.getUserInfo().setUserId(userDTO.getId());
|
customerAndCarVO.getUserInfo().setUserId(userDTO.getId());
|
||||||
}else {
|
} else {
|
||||||
customerAndCarVO.getUserInfo().setUserId(userByMobile.getId());
|
customerAndCarVO.getUserInfo().setUserId(userByMobile.getId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -734,7 +761,6 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl<DlRepairTicketsMappe
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 打印工单
|
* 打印工单
|
||||||
*
|
|
||||||
* @param response HttpServletResponse
|
* @param response HttpServletResponse
|
||||||
* @param id String
|
* @param id String
|
||||||
* @author PQZ
|
* @author PQZ
|
||||||
@ -1032,29 +1058,29 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl<DlRepairTicketsMappe
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 翻译字典
|
* 翻译字典
|
||||||
* @author vinjor-M
|
|
||||||
* @date 16:25 2025/1/9
|
|
||||||
* @param dlRepairTicketsIPage TODO
|
* @param dlRepairTicketsIPage TODO
|
||||||
* @return com.baomidou.mybatisplus.core.metadata.IPage<cn.iocoder.yudao.module.tickets.entity.DlRepairTickets>
|
* @return com.baomidou.mybatisplus.core.metadata.IPage<cn.iocoder.yudao.module.tickets.entity.DlRepairTickets>
|
||||||
**/
|
* @author vinjor-M
|
||||||
private IPage<DlRepairTickets> dealDictText(IPage<DlRepairTickets> dlRepairTicketsIPage){
|
* @date 16:25 2025/1/9
|
||||||
|
**/
|
||||||
|
private IPage<DlRepairTickets> dealDictText(IPage<DlRepairTickets> dlRepairTicketsIPage) {
|
||||||
//维修类型
|
//维修类型
|
||||||
List<DictDataRespDTO> repairTypeList = dictDataApi.getDictDataList(DICT_REPAIR_TYPE);
|
List<DictDataRespDTO> repairTypeList = dictDataApi.getDictDataList(DICT_REPAIR_TYPE);
|
||||||
Map<String,String> repairTypeMap = repairTypeList.stream().collect(Collectors.toMap(DictDataRespDTO::getValue,DictDataRespDTO::getLabel));
|
Map<String, String> repairTypeMap = repairTypeList.stream().collect(Collectors.toMap(DictDataRespDTO::getValue, DictDataRespDTO::getLabel));
|
||||||
//支付方式
|
//支付方式
|
||||||
List<DictDataRespDTO> payTypeList = dictDataApi.getDictDataList(DICT_REPAIR_PAY_TYPE);
|
List<DictDataRespDTO> payTypeList = dictDataApi.getDictDataList(DICT_REPAIR_PAY_TYPE);
|
||||||
|
|
||||||
dlRepairTicketsIPage.getRecords().forEach(item->{
|
dlRepairTicketsIPage.getRecords().forEach(item -> {
|
||||||
if(StringUtils.isNotEmpty(item.getRepairType())){
|
if (StringUtils.isNotEmpty(item.getRepairType())) {
|
||||||
item.setRepairTypeText(repairTypeMap.get(item.getRepairType()));
|
item.setRepairTypeText(repairTypeMap.get(item.getRepairType()));
|
||||||
}
|
}
|
||||||
if(StringUtils.isNotEmpty(item.getPayType())){
|
if (StringUtils.isNotEmpty(item.getPayType())) {
|
||||||
payTypeList.forEach(payType->{
|
payTypeList.forEach(payType -> {
|
||||||
if(item.getPayType().contains(payType.getValue())){
|
if (item.getPayType().contains(payType.getValue())) {
|
||||||
if(StringUtils.isEmpty(item.getPayTypeText())){
|
if (StringUtils.isEmpty(item.getPayTypeText())) {
|
||||||
item.setPayTypeText(payType.getLabel());
|
item.setPayTypeText(payType.getLabel());
|
||||||
}else{
|
} else {
|
||||||
item.setPayTypeText(item.getPayTypeText()+","+payType.getLabel());
|
item.setPayTypeText(item.getPayTypeText() + "," + payType.getLabel());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -1065,7 +1091,6 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl<DlRepairTicketsMappe
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 分类查询工单分页
|
* 分类查询工单分页
|
||||||
*
|
|
||||||
* @param repairTicketsReqVO 查询对象
|
* @param repairTicketsReqVO 查询对象
|
||||||
* @author 小李
|
* @author 小李
|
||||||
* @date 16:26 2024/10/12
|
* @date 16:26 2024/10/12
|
||||||
@ -1073,7 +1098,7 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl<DlRepairTicketsMappe
|
|||||||
@Override
|
@Override
|
||||||
public IPage<DlRepairTickets> getPageType(DlRepairTicketsReqVO repairTicketsReqVO, Page<DlRepairTickets> page) {
|
public IPage<DlRepairTickets> getPageType(DlRepairTicketsReqVO repairTicketsReqVO, Page<DlRepairTickets> page) {
|
||||||
String userRoleCode = getUserRole();
|
String userRoleCode = getUserRole();
|
||||||
if(null!=repairTicketsReqVO.getIdList() && repairTicketsReqVO.getIdList().size()>0){
|
if (null != repairTicketsReqVO.getIdList() && repairTicketsReqVO.getIdList().size() > 0) {
|
||||||
//根据id集和查询
|
//根据id集和查询
|
||||||
DlRepairTicketsReqVO queryObj = new DlRepairTicketsReqVO();
|
DlRepairTicketsReqVO queryObj = new DlRepairTicketsReqVO();
|
||||||
queryObj.setIdList(repairTicketsReqVO.getIdList());
|
queryObj.setIdList(repairTicketsReqVO.getIdList());
|
||||||
@ -1127,54 +1152,54 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl<DlRepairTicketsMappe
|
|||||||
return dealDictText(baseMapper.getPageType(repairTicketsReqVO, page));
|
return dealDictText(baseMapper.getPageType(repairTicketsReqVO, page));
|
||||||
} else {
|
} else {
|
||||||
//查所有,
|
//查所有,
|
||||||
if(("jinchang".equals(repairTicketsReqVO.getTicketsStatus()) ||
|
if (("jinchang".equals(repairTicketsReqVO.getTicketsStatus()) ||
|
||||||
"yijungong".equals(repairTicketsReqVO.getTicketsStatus()) ||
|
"yijungong".equals(repairTicketsReqVO.getTicketsStatus()) ||
|
||||||
"yijiaoche".equals(repairTicketsReqVO.getTicketsStatus())) && StringUtils.isNotEmpty(repairTicketsReqVO.getStartDate())){
|
"yijiaoche".equals(repairTicketsReqVO.getTicketsStatus())) && StringUtils.isNotEmpty(repairTicketsReqVO.getStartDate())) {
|
||||||
//如果是查询进场、已竣工、已交车三个状态,同时选了时间范围的,需要单独处理
|
//如果是查询进场、已竣工、已交车三个状态,同时选了时间范围的,需要单独处理
|
||||||
String startDate = repairTicketsReqVO.getStartDate()+" 00:00:00";
|
String startDate = repairTicketsReqVO.getStartDate() + " 00:00:00";
|
||||||
String endDate = repairTicketsReqVO.getEndDate()+" 23:59:59";
|
String endDate = repairTicketsReqVO.getEndDate() + " 23:59:59";
|
||||||
List<String> idList = new ArrayList<>();
|
List<String> idList = new ArrayList<>();
|
||||||
if("yijungong".equals(repairTicketsReqVO.getTicketsStatus())){
|
if ("yijungong".equals(repairTicketsReqVO.getTicketsStatus())) {
|
||||||
//已竣工
|
//已竣工
|
||||||
idList = repairTicketsMapper.selectTicketIdByParams(null,RecordTypeEnum.ZJ.getCode(),startDate,endDate);
|
idList = repairTicketsMapper.selectTicketIdByParams(null, RecordTypeEnum.ZJ.getCode(), startDate, endDate);
|
||||||
}else if("yijiaoche".equals(repairTicketsReqVO.getTicketsStatus())){
|
} else if ("yijiaoche".equals(repairTicketsReqVO.getTicketsStatus())) {
|
||||||
//已交车
|
//已交车
|
||||||
idList = repairTicketsMapper.selectTicketIdByParams(null,RecordTypeEnum.JC.getCode(),startDate,endDate);
|
idList = repairTicketsMapper.selectTicketIdByParams(null, RecordTypeEnum.JC.getCode(), startDate, endDate);
|
||||||
}else {
|
} else {
|
||||||
//进厂
|
//进厂
|
||||||
repairTicketsReqVO.setStartDate(startDate);
|
repairTicketsReqVO.setStartDate(startDate);
|
||||||
repairTicketsReqVO.setEndDate(endDate);
|
repairTicketsReqVO.setEndDate(endDate);
|
||||||
}
|
}
|
||||||
if(null!=idList && !idList.isEmpty()){
|
if (null != idList && !idList.isEmpty()) {
|
||||||
repairTicketsReqVO.setIdList(idList);
|
repairTicketsReqVO.setIdList(idList);
|
||||||
//时间查询条件置空
|
//时间查询条件置空
|
||||||
repairTicketsReqVO.setStartDate(null);
|
repairTicketsReqVO.setStartDate(null);
|
||||||
repairTicketsReqVO.setEndDate(null);
|
repairTicketsReqVO.setEndDate(null);
|
||||||
}
|
}
|
||||||
}else {
|
} else {
|
||||||
//否则查询时间不生效,按维修状态查
|
//否则查询时间不生效,按维修状态查
|
||||||
List<String> statusList = new ArrayList<>();
|
List<String> statusList = new ArrayList<>();
|
||||||
if("weixiuzhong".equals(repairTicketsReqVO.getTicketsStatus())){
|
if ("weixiuzhong".equals(repairTicketsReqVO.getTicketsStatus())) {
|
||||||
//维修中
|
//维修中
|
||||||
statusList.add(TicketsStatusEnum.WORKING.getCode());
|
statusList.add(TicketsStatusEnum.WORKING.getCode());
|
||||||
}else if("weijiesuan".equals(repairTicketsReqVO.getTicketsStatus())){
|
} else if ("weijiesuan".equals(repairTicketsReqVO.getTicketsStatus())) {
|
||||||
//未结算
|
//未结算
|
||||||
statusList = Arrays.asList("04","05","07","01");
|
statusList = Arrays.asList("04", "05", "07", "01");
|
||||||
}else if("zaichang".equals(repairTicketsReqVO.getTicketsStatus())){
|
} else if ("zaichang".equals(repairTicketsReqVO.getTicketsStatus())) {
|
||||||
//在厂,就是没交车的,且不能是已作废和已完成的
|
//在厂,就是没交车的,且不能是已作废和已完成的
|
||||||
repairTicketsReqVO.setIsHandover("0");
|
repairTicketsReqVO.setIsHandover("0");
|
||||||
statusList = Arrays.asList("04","05","07","01","06","02");
|
statusList = Arrays.asList("04", "05", "07", "01", "06", "02");
|
||||||
}else if("jinchang".equals(repairTicketsReqVO.getTicketsStatus())){
|
} else if ("jinchang".equals(repairTicketsReqVO.getTicketsStatus())) {
|
||||||
//进厂
|
//进厂
|
||||||
statusList.add(TicketsStatusEnum.NO_WORK.getCode());
|
statusList.add(TicketsStatusEnum.NO_WORK.getCode());
|
||||||
}else if("yijungong".equals(repairTicketsReqVO.getTicketsStatus())){
|
} else if ("yijungong".equals(repairTicketsReqVO.getTicketsStatus())) {
|
||||||
//已竣工
|
//已竣工
|
||||||
statusList = Arrays.asList("07","01","06","02","08");
|
statusList = Arrays.asList("07", "01", "06", "02", "08");
|
||||||
}else if("yijiaoche".equals(repairTicketsReqVO.getTicketsStatus())){
|
} else if ("yijiaoche".equals(repairTicketsReqVO.getTicketsStatus())) {
|
||||||
//已交车
|
//已交车
|
||||||
repairTicketsReqVO.setIsHandover("1");
|
repairTicketsReqVO.setIsHandover("1");
|
||||||
}
|
}
|
||||||
if(!statusList.isEmpty()){
|
if (!statusList.isEmpty()) {
|
||||||
repairTicketsReqVO.setStatusList(statusList);
|
repairTicketsReqVO.setStatusList(statusList);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1184,7 +1209,6 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl<DlRepairTicketsMappe
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 判断登录用户的角色,针对维修工单中的四个角色
|
* 判断登录用户的角色,针对维修工单中的四个角色
|
||||||
*
|
|
||||||
* @author 小李
|
* @author 小李
|
||||||
* @date 9:28 2024/10/14
|
* @date 9:28 2024/10/14
|
||||||
**/
|
**/
|
||||||
@ -1229,7 +1253,6 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl<DlRepairTicketsMappe
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 接单
|
* 接单
|
||||||
*
|
|
||||||
* @param id 工单ID
|
* @param id 工单ID
|
||||||
* @author 小李
|
* @author 小李
|
||||||
* @date 11:48 2024/10/14
|
* @date 11:48 2024/10/14
|
||||||
@ -1257,7 +1280,7 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl<DlRepairTicketsMappe
|
|||||||
List<DictDataRespDTO> dataList = dictDataApi.getDictDataList("repair_work_type");
|
List<DictDataRespDTO> dataList = dictDataApi.getDictDataList("repair_work_type");
|
||||||
DictDataRespDTO dictDataRespDTO = dataList.stream().filter(item -> item.getValue().equals(worker.getWorkType())).findFirst().orElse(null);
|
DictDataRespDTO dictDataRespDTO = dataList.stream().filter(item -> item.getValue().equals(worker.getWorkType())).findFirst().orElse(null);
|
||||||
String message = String.format("您的爱车%s已由%s %s接单了", tickets.getCarNo(), (dictDataRespDTO != null ? dictDataRespDTO.getLabel() : "维修工"), worker.getUserName());
|
String message = String.format("您的爱车%s已由%s %s接单了", tickets.getCarNo(), (dictDataRespDTO != null ? dictDataRespDTO.getLabel() : "维修工"), worker.getUserName());
|
||||||
repairWorkerService.sentMessageToCus(SystemEnum.REPAIR.getCode(),id, message, false);
|
repairWorkerService.sentMessageToCus(SystemEnum.REPAIR.getCode(), id, message, false);
|
||||||
|
|
||||||
// 更新工单主表时间
|
// 更新工单主表时间
|
||||||
refreshUpdateTime(id);
|
refreshUpdateTime(id);
|
||||||
@ -1265,7 +1288,6 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl<DlRepairTicketsMappe
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 指派员工,通知施工
|
* 指派员工,通知施工
|
||||||
*
|
|
||||||
* @param reqVO 请求对象
|
* @param reqVO 请求对象
|
||||||
* @author 小李
|
* @author 小李
|
||||||
* @date 15:34 2024/10/14
|
* @date 15:34 2024/10/14
|
||||||
@ -1285,7 +1307,7 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl<DlRepairTicketsMappe
|
|||||||
if (update != 1) {
|
if (update != 1) {
|
||||||
throw exception0(500, "工单已开始");
|
throw exception0(500, "工单已开始");
|
||||||
}
|
}
|
||||||
repairWorkerService.sentMessage(SystemEnum.REPAIR.getCode(),reqVO.getNowRepairId(), "您有新的工单要处理");
|
repairWorkerService.sentMessage(SystemEnum.REPAIR.getCode(), reqVO.getNowRepairId(), "您有新的工单要处理");
|
||||||
|
|
||||||
// 获取当前操作人的身份----小李新加的逻辑
|
// 获取当前操作人的身份----小李新加的逻辑
|
||||||
String userRole = getUserRole();
|
String userRole = getUserRole();
|
||||||
@ -1312,7 +1334,6 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl<DlRepairTicketsMappe
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 指派施工,施工项目中不包含选中人员处理
|
* 指派施工,施工项目中不包含选中人员处理
|
||||||
*
|
|
||||||
* @param ticketId 工单id
|
* @param ticketId 工单id
|
||||||
* @param nowRepairId 当前处理人id
|
* @param nowRepairId 当前处理人id
|
||||||
* @param nowRepairName 当前处理人名称
|
* @param nowRepairName 当前处理人名称
|
||||||
@ -1361,7 +1382,6 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl<DlRepairTicketsMappe
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 更新工单状态(针对开始施工、施工中记录、施工完成)
|
* 更新工单状态(针对开始施工、施工中记录、施工完成)
|
||||||
*
|
|
||||||
* @param respVO 请求对象
|
* @param respVO 请求对象
|
||||||
* @author 小李
|
* @author 小李
|
||||||
* @date 15:46 2024/10/18
|
* @date 15:46 2024/10/18
|
||||||
@ -1415,7 +1435,7 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl<DlRepairTicketsMappe
|
|||||||
// 通知服务顾问
|
// 通知服务顾问
|
||||||
// 如果员工完成了订单
|
// 如果员工完成了订单
|
||||||
if (RecordTypeEnum.SGWCZJ.getCode().equals(respVO.getRecordType()) && "03".equals(respVO.getFinishType())) {
|
if (RecordTypeEnum.SGWCZJ.getCode().equals(respVO.getRecordType()) && "03".equals(respVO.getFinishType())) {
|
||||||
repairWorkerService.sentMessage(SystemEnum.REPAIR.getCode(),Long.valueOf(tickets.getAdviserId()), "您有新的工单可以出厂检验");
|
repairWorkerService.sentMessage(SystemEnum.REPAIR.getCode(), Long.valueOf(tickets.getAdviserId()), "您有新的工单可以出厂检验");
|
||||||
// 需要把工单的当前操作人移交服务顾问
|
// 需要把工单的当前操作人移交服务顾问
|
||||||
baseMapper.update(new LambdaUpdateWrapper<DlRepairTickets>()
|
baseMapper.update(new LambdaUpdateWrapper<DlRepairTickets>()
|
||||||
.setSql("now_repair_id = adviser_id")
|
.setSql("now_repair_id = adviser_id")
|
||||||
@ -1428,7 +1448,7 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl<DlRepairTicketsMappe
|
|||||||
throw exception0(500, "系统异常");
|
throw exception0(500, "系统异常");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
repairWorkerService.sentMessage(SystemEnum.REPAIR.getCode(),Long.valueOf(tickets.getAdviserId()), message);
|
repairWorkerService.sentMessage(SystemEnum.REPAIR.getCode(), Long.valueOf(tickets.getAdviserId()), message);
|
||||||
}
|
}
|
||||||
// 通知总检
|
// 通知总检
|
||||||
// 总检查角色包含总检的员工
|
// 总检查角色包含总检的员工
|
||||||
@ -1446,10 +1466,10 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl<DlRepairTicketsMappe
|
|||||||
.set(DlRepairTickets::getNowRepairName, user.getNickname())
|
.set(DlRepairTickets::getNowRepairName, user.getNickname())
|
||||||
.set(DlRepairTickets::getTicketsWorkStatus, "05")
|
.set(DlRepairTickets::getTicketsWorkStatus, "05")
|
||||||
.eq(DlRepairTickets::getId, respVO.getId()));
|
.eq(DlRepairTickets::getId, respVO.getId()));
|
||||||
repairWorkerService.sentMessage(SystemEnum.REPAIR.getCode(),user.getId(), "您有新的工单需要总检");
|
repairWorkerService.sentMessage(SystemEnum.REPAIR.getCode(), user.getId(), "您有新的工单需要总检");
|
||||||
} else {
|
} else {
|
||||||
ids.forEach(id -> {
|
ids.forEach(id -> {
|
||||||
repairWorkerService.sentMessage(SystemEnum.REPAIR.getCode(),id, message);
|
repairWorkerService.sentMessage(SystemEnum.REPAIR.getCode(), id, message);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1466,7 +1486,7 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl<DlRepairTicketsMappe
|
|||||||
worker.getUserName(),
|
worker.getUserName(),
|
||||||
(respVO.getRecordType().equals(RecordTypeEnum.KSSG.getCode()) ? "开始施工" : "施工完成")
|
(respVO.getRecordType().equals(RecordTypeEnum.KSSG.getCode()) ? "开始施工" : "施工完成")
|
||||||
);
|
);
|
||||||
repairWorkerService.sentMessageToCus(SystemEnum.REPAIR.getCode(),tickets.getId(), newMessage, false);
|
repairWorkerService.sentMessageToCus(SystemEnum.REPAIR.getCode(), tickets.getId(), newMessage, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 更新工单主表时间
|
// 更新工单主表时间
|
||||||
@ -1509,7 +1529,6 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl<DlRepairTicketsMappe
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 配件客户是否可见
|
* 配件客户是否可见
|
||||||
*
|
|
||||||
* @param id 工单ID
|
* @param id 工单ID
|
||||||
* @param show 是否可见 1可见, 0不可见
|
* @param show 是否可见 1可见, 0不可见
|
||||||
* @author 小李
|
* @author 小李
|
||||||
@ -1528,7 +1547,6 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl<DlRepairTicketsMappe
|
|||||||
/**
|
/**
|
||||||
* 查待总检或待出厂检验的工单
|
* 查待总检或待出厂检验的工单
|
||||||
* 维修服务顾问和总检用的
|
* 维修服务顾问和总检用的
|
||||||
*
|
|
||||||
* @param repairTicketsReqVO 请求对象
|
* @param repairTicketsReqVO 请求对象
|
||||||
* @author 小李
|
* @author 小李
|
||||||
* @date 11:40 2024/10/23
|
* @date 11:40 2024/10/23
|
||||||
@ -1563,7 +1581,6 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl<DlRepairTicketsMappe
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 维修总检完成总检
|
* 维修总检完成总检
|
||||||
*
|
|
||||||
* @param respVO 请求对象
|
* @param respVO 请求对象
|
||||||
* @author 小李
|
* @author 小李
|
||||||
* @date 16:48 2024/10/23
|
* @date 16:48 2024/10/23
|
||||||
@ -1589,13 +1606,13 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl<DlRepairTicketsMappe
|
|||||||
|
|
||||||
// 通知服务顾问
|
// 通知服务顾问
|
||||||
DlRepairTickets tickets = baseMapper.selectById(respVO.getId());
|
DlRepairTickets tickets = baseMapper.selectById(respVO.getId());
|
||||||
repairWorkerService.sentMessage(SystemEnum.REPAIR.getCode(),Long.valueOf(tickets.getAdviserId()), "您有新的工单可以出厂检验");
|
repairWorkerService.sentMessage(SystemEnum.REPAIR.getCode(), Long.valueOf(tickets.getAdviserId()), "您有新的工单可以出厂检验");
|
||||||
|
|
||||||
// 通知客户
|
// 通知客户
|
||||||
// 构建消息
|
// 构建消息
|
||||||
DictDataRespDTO repairType = dictDataApi.getDictData("repair_type", tickets.getRepairType());
|
DictDataRespDTO repairType = dictDataApi.getDictData("repair_type", tickets.getRepairType());
|
||||||
String message = String.format("您的爱车%s已%s完成", tickets.getCarNo(), (repairType != null ? repairType.getLabel() : "维修保养"));
|
String message = String.format("您的爱车%s已%s完成", tickets.getCarNo(), (repairType != null ? repairType.getLabel() : "维修保养"));
|
||||||
repairWorkerService.sentMessageToCus(SystemEnum.REPAIR.getCode(),tickets.getId(), message, true);
|
repairWorkerService.sentMessageToCus(SystemEnum.REPAIR.getCode(), tickets.getId(), message, true);
|
||||||
|
|
||||||
// 更新工单主表状态
|
// 更新工单主表状态
|
||||||
refreshUpdateTime(respVO.getId());
|
refreshUpdateTime(respVO.getId());
|
||||||
@ -1603,7 +1620,6 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl<DlRepairTicketsMappe
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 用于同步一个工单的所有配件申请表的数据到维修工单,主要针对已领取数量小于申请数量的情况
|
* 用于同步一个工单的所有配件申请表的数据到维修工单,主要针对已领取数量小于申请数量的情况
|
||||||
*
|
|
||||||
* @param id 维修工单ID
|
* @param id 维修工单ID
|
||||||
* @author 小李
|
* @author 小李
|
||||||
* @date 9:52 2024/10/26
|
* @date 9:52 2024/10/26
|
||||||
@ -1674,7 +1690,6 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl<DlRepairTicketsMappe
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 服务顾问上传出厂检验日志
|
* 服务顾问上传出厂检验日志
|
||||||
*
|
|
||||||
* @param respVO 请求对象
|
* @param respVO 请求对象
|
||||||
* @author 小李
|
* @author 小李
|
||||||
* @date 17:47 2024/10/23
|
* @date 17:47 2024/10/23
|
||||||
@ -1697,13 +1712,12 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl<DlRepairTicketsMappe
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 从总检的角度差维修中、已完成的工单数量
|
* 从总检的角度差维修中、已完成的工单数量
|
||||||
*
|
|
||||||
* @return java.util.Map<java.lang.String, java.lang.Integer>
|
* @return java.util.Map<java.lang.String, java.lang.Integer>
|
||||||
* @author vinjor-M
|
* @author vinjor-M
|
||||||
* @date 11:30 2024/10/24
|
* @date 11:30 2024/10/24
|
||||||
**/
|
**/
|
||||||
@Override
|
@Override
|
||||||
public Map<String, Object> getBossNum(String selectType,String startDate,String endDate) {
|
public Map<String, Object> getBossNum(String selectType, String startDate, String endDate) {
|
||||||
Map<String, Object> rtnMap = new HashMap<>();
|
Map<String, Object> rtnMap = new HashMap<>();
|
||||||
//维修中---当前这一时刻
|
//维修中---当前这一时刻
|
||||||
long workingNum = 0;
|
long workingNum = 0;
|
||||||
@ -1712,16 +1726,16 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl<DlRepairTicketsMappe
|
|||||||
long inCompanyNum = 0;
|
long inCompanyNum = 0;
|
||||||
List<String> inCompanyIdList = new ArrayList<>();
|
List<String> inCompanyIdList = new ArrayList<>();
|
||||||
//进场数
|
//进场数
|
||||||
long newOrderNum=0;
|
long newOrderNum = 0;
|
||||||
List<String> newOrderIdList = new ArrayList<>();
|
List<String> newOrderIdList = new ArrayList<>();
|
||||||
//已完成
|
//已完成
|
||||||
long overNum=0;
|
long overNum = 0;
|
||||||
List<String> overIdList = new ArrayList<>();
|
List<String> overIdList = new ArrayList<>();
|
||||||
//已交车
|
//已交车
|
||||||
long giveCusNum=0;
|
long giveCusNum = 0;
|
||||||
List<String> giveCusIdList = new ArrayList<>();
|
List<String> giveCusIdList = new ArrayList<>();
|
||||||
//未结算
|
//未结算
|
||||||
long noPayNum=0;
|
long noPayNum = 0;
|
||||||
List<String> noPayIdList = new ArrayList<>();
|
List<String> noPayIdList = new ArrayList<>();
|
||||||
List<DlRepairTickets> repairTickets = this.list();
|
List<DlRepairTickets> repairTickets = this.list();
|
||||||
if (!repairTickets.isEmpty()) {
|
if (!repairTickets.isEmpty()) {
|
||||||
@ -1729,46 +1743,46 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl<DlRepairTicketsMappe
|
|||||||
workingIdList = repairTickets.stream().filter(item -> TicketsStatusEnum.WORKING.getCode().equals(item.getTicketsStatus())).map(DlRepairTickets::getId).collect(Collectors.toList());
|
workingIdList = repairTickets.stream().filter(item -> TicketsStatusEnum.WORKING.getCode().equals(item.getTicketsStatus())).map(DlRepairTickets::getId).collect(Collectors.toList());
|
||||||
workingNum = workingIdList.size();
|
workingNum = workingIdList.size();
|
||||||
//只要没交车都算在厂
|
//只要没交车都算在厂
|
||||||
inCompanyIdList = repairTickets.stream().filter(item -> "0".equals(item.getIsHandover())).filter(item->!"03".equals(item.getTicketsStatus())).map(DlRepairTickets::getId).collect(Collectors.toList());
|
inCompanyIdList = repairTickets.stream().filter(item -> "0".equals(item.getIsHandover())).filter(item -> !"03".equals(item.getTicketsStatus())).map(DlRepairTickets::getId).collect(Collectors.toList());
|
||||||
inCompanyNum = inCompanyIdList.size();
|
inCompanyNum = inCompanyIdList.size();
|
||||||
//只要没结算,都是未结算
|
//只要没结算,都是未结算
|
||||||
List<String> noPayCodeList = Arrays.asList("04","05","07","01");
|
List<String> noPayCodeList = Arrays.asList("04", "05", "07", "01");
|
||||||
noPayIdList = repairTickets.stream().filter(item -> noPayCodeList.contains(item.getTicketsStatus())).map(DlRepairTickets::getId).collect(Collectors.toList());
|
noPayIdList = repairTickets.stream().filter(item -> noPayCodeList.contains(item.getTicketsStatus())).map(DlRepairTickets::getId).collect(Collectors.toList());
|
||||||
noPayNum = noPayIdList.size();
|
noPayNum = noPayIdList.size();
|
||||||
LocalDateTime currentTime = LocalDateTime.now();
|
LocalDateTime currentTime = LocalDateTime.now();
|
||||||
if("today".equals(selectType)){
|
if ("today".equals(selectType)) {
|
||||||
String nowDayStr = DateUtil.formatDate(new Date());
|
String nowDayStr = DateUtil.formatDate(new Date());
|
||||||
//查当日进厂数、已完成、已交车
|
//查当日进厂数、已完成、已交车
|
||||||
newOrderIdList = repairTickets.stream().filter(item -> item.getCreateTime().toLocalDate().equals(currentTime.toLocalDate())).map(DlRepairTickets::getId).collect(Collectors.toList());
|
newOrderIdList = repairTickets.stream().filter(item -> item.getCreateTime().toLocalDate().equals(currentTime.toLocalDate())).map(DlRepairTickets::getId).collect(Collectors.toList());
|
||||||
newOrderNum = newOrderIdList.size();
|
newOrderNum = newOrderIdList.size();
|
||||||
//查当日已完成的(总检完成的)
|
//查当日已完成的(总检完成的)
|
||||||
overIdList = repairTicketsMapper.selectTicketIdByParams(nowDayStr,RecordTypeEnum.ZJ.getCode(),null,null);
|
overIdList = repairTicketsMapper.selectTicketIdByParams(nowDayStr, RecordTypeEnum.ZJ.getCode(), null, null);
|
||||||
overNum = overIdList.size();
|
overNum = overIdList.size();
|
||||||
//查当日已交车的
|
//查当日已交车的
|
||||||
giveCusIdList = repairTicketsMapper.selectTicketIdByParams(nowDayStr,RecordTypeEnum.JC.getCode(),null,null);
|
giveCusIdList = repairTicketsMapper.selectTicketIdByParams(nowDayStr, RecordTypeEnum.JC.getCode(), null, null);
|
||||||
giveCusNum = giveCusIdList.size();
|
giveCusNum = giveCusIdList.size();
|
||||||
}else if("all".equals(selectType)){
|
} else if ("all".equals(selectType)) {
|
||||||
//查累计进厂数、已完成、已交车
|
//查累计进厂数、已完成、已交车
|
||||||
newOrderIdList = repairTickets.stream().map(DlRepairTickets::getId).collect(Collectors.toList());
|
newOrderIdList = repairTickets.stream().map(DlRepairTickets::getId).collect(Collectors.toList());
|
||||||
newOrderNum = repairTickets.size();
|
newOrderNum = repairTickets.size();
|
||||||
//查累计已完成的(总检完成的)
|
//查累计已完成的(总检完成的)
|
||||||
List<String> overCodeList = Arrays.asList("07","01","06","02","08");
|
List<String> overCodeList = Arrays.asList("07", "01", "06", "02", "08");
|
||||||
overIdList = repairTickets.stream().filter(item -> overCodeList.contains(item.getTicketsStatus())).map(DlRepairTickets::getId).collect(Collectors.toList());
|
overIdList = repairTickets.stream().filter(item -> overCodeList.contains(item.getTicketsStatus())).map(DlRepairTickets::getId).collect(Collectors.toList());
|
||||||
overNum = overIdList.size();
|
overNum = overIdList.size();
|
||||||
//查累计已交车的
|
//查累计已交车的
|
||||||
giveCusIdList = repairTickets.stream().filter(item -> "1".equals(item.getIsHandover())).map(DlRepairTickets::getId).collect(Collectors.toList());
|
giveCusIdList = repairTickets.stream().filter(item -> "1".equals(item.getIsHandover())).map(DlRepairTickets::getId).collect(Collectors.toList());
|
||||||
giveCusNum = giveCusIdList.size();
|
giveCusNum = giveCusIdList.size();
|
||||||
}else {
|
} else {
|
||||||
//查某个时间范围内进厂数、已完成、已交车
|
//查某个时间范围内进厂数、已完成、已交车
|
||||||
LocalDateTime startTime = LocalDateTime.parse(startDate+" 00:00:00", DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
|
LocalDateTime startTime = LocalDateTime.parse(startDate + " 00:00:00", DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
|
||||||
LocalDateTime endTime = LocalDateTime.parse(endDate+" 23:59:59", DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
|
LocalDateTime endTime = LocalDateTime.parse(endDate + " 23:59:59", DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
|
||||||
newOrderIdList = repairTickets.stream().filter(item -> item.getCreateTime().isAfter(startTime) && item.getCreateTime().isBefore(endTime)).map(DlRepairTickets::getId).collect(Collectors.toList());
|
newOrderIdList = repairTickets.stream().filter(item -> item.getCreateTime().isAfter(startTime) && item.getCreateTime().isBefore(endTime)).map(DlRepairTickets::getId).collect(Collectors.toList());
|
||||||
newOrderNum = newOrderIdList.size();
|
newOrderNum = newOrderIdList.size();
|
||||||
//查某区间范围内已完成的(总检完成的)
|
//查某区间范围内已完成的(总检完成的)
|
||||||
overIdList = repairTicketsMapper.selectTicketIdByParams(null,RecordTypeEnum.ZJ.getCode(), startDate+" 00:00:00", endDate+" 23:59:59");
|
overIdList = repairTicketsMapper.selectTicketIdByParams(null, RecordTypeEnum.ZJ.getCode(), startDate + " 00:00:00", endDate + " 23:59:59");
|
||||||
overNum = overIdList.size();
|
overNum = overIdList.size();
|
||||||
//查某区间范围内已交车的
|
//查某区间范围内已交车的
|
||||||
giveCusIdList = repairTicketsMapper.selectTicketIdByParams(null,RecordTypeEnum.JC.getCode(), startDate+" 00:00:00", endDate+" 23:59:59");
|
giveCusIdList = repairTicketsMapper.selectTicketIdByParams(null, RecordTypeEnum.JC.getCode(), startDate + " 00:00:00", endDate + " 23:59:59");
|
||||||
giveCusNum = giveCusIdList.size();
|
giveCusNum = giveCusIdList.size();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1789,7 +1803,6 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl<DlRepairTicketsMappe
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 服务顾问通知客户取车
|
* 服务顾问通知客户取车
|
||||||
*
|
|
||||||
* @param noticeCusVO 请求对象
|
* @param noticeCusVO 请求对象
|
||||||
* @author 小李
|
* @author 小李
|
||||||
* @date 22:40 2024/10/23
|
* @date 22:40 2024/10/23
|
||||||
@ -1805,7 +1818,7 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl<DlRepairTicketsMappe
|
|||||||
.eq(DlRepairTickets::getId, noticeCusVO.getId())
|
.eq(DlRepairTickets::getId, noticeCusVO.getId())
|
||||||
);
|
);
|
||||||
// 这里如果是拨打电话通知的,就不走下面的逻辑了,判断条件是看name是不是就是客户的名字
|
// 这里如果是拨打电话通知的,就不走下面的逻辑了,判断条件是看name是不是就是客户的名字
|
||||||
if (noticeCusVO.getName().equals(tickets.getUserName())){
|
if (noticeCusVO.getName().equals(tickets.getUserName())) {
|
||||||
repairRecordsService.saveRepairRecord(noticeCusVO.getId(), null, RecordTypeEnum.TZQC.getCode(), tickets.getAdviserName() + "电话通知客户取车", null);
|
repairRecordsService.saveRepairRecord(noticeCusVO.getId(), null, RecordTypeEnum.TZQC.getCode(), tickets.getAdviserName() + "电话通知客户取车", null);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -1843,7 +1856,6 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl<DlRepairTicketsMappe
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 判断是否工单子表的任何一个类目没有价格或价格为0
|
* 判断是否工单子表的任何一个类目没有价格或价格为0
|
||||||
*
|
|
||||||
* @param id 工单ID
|
* @param id 工单ID
|
||||||
* @author 小李
|
* @author 小李
|
||||||
* @date 15:00 2024/11/16
|
* @date 15:00 2024/11/16
|
||||||
@ -1857,7 +1869,7 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl<DlRepairTicketsMappe
|
|||||||
throw exception0(500, "工单中有项目或配件没有设置价格,请服务顾问填写项目价格,仓库填写配件价格");
|
throw exception0(500, "工单中有项目或配件没有设置价格,请服务顾问填写项目价格,仓库填写配件价格");
|
||||||
}
|
}
|
||||||
// 如果有为0的,那就提示,让操作人选择
|
// 如果有为0的,那就提示,让操作人选择
|
||||||
if (item.getItemPrice().equals(new BigDecimal("0.00"))){
|
if (item.getItemPrice().equals(new BigDecimal("0.00"))) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1866,7 +1878,6 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl<DlRepairTicketsMappe
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 重新计算工单的一些数值,子表也要重新计算
|
* 重新计算工单的一些数值,子表也要重新计算
|
||||||
*
|
|
||||||
* @param ticketId 工单ID
|
* @param ticketId 工单ID
|
||||||
* @author 小李
|
* @author 小李
|
||||||
* @date 15:47 2024/10/24
|
* @date 15:47 2024/10/24
|
||||||
@ -1892,7 +1903,7 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl<DlRepairTicketsMappe
|
|||||||
}
|
}
|
||||||
/*3.遍历数据--遍历这一次,处理所有需要处理的*/
|
/*3.遍历数据--遍历这一次,处理所有需要处理的*/
|
||||||
//商品总数
|
//商品总数
|
||||||
Integer goodsCount=0;
|
Integer goodsCount = 0;
|
||||||
//工单总价
|
//工单总价
|
||||||
BigDecimal totalAmount = BigDecimal.ZERO.add(managerMoney).add(rescueMoney).add(threePackMoney).add(confirmFaultMoney);
|
BigDecimal totalAmount = BigDecimal.ZERO.add(managerMoney).add(rescueMoney).add(threePackMoney).add(confirmFaultMoney);
|
||||||
//项目总价
|
//项目总价
|
||||||
@ -1901,30 +1912,30 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl<DlRepairTicketsMappe
|
|||||||
BigDecimal waresAmount = BigDecimal.ZERO;
|
BigDecimal waresAmount = BigDecimal.ZERO;
|
||||||
//其他总价
|
//其他总价
|
||||||
BigDecimal otherAmount = BigDecimal.ZERO;
|
BigDecimal otherAmount = BigDecimal.ZERO;
|
||||||
for(DlRepairTitem item:list){
|
for (DlRepairTitem item : list) {
|
||||||
//空字段设置默认值
|
//空字段设置默认值
|
||||||
if(null==item.getItemDiscount()){
|
if (null == item.getItemDiscount()) {
|
||||||
item.setItemDiscount(new BigDecimal(1));
|
item.setItemDiscount(new BigDecimal(1));
|
||||||
}
|
}
|
||||||
if(null==item.getItemPrice()){
|
if (null == item.getItemPrice()) {
|
||||||
item.setItemPrice(BigDecimal.ZERO);
|
item.setItemPrice(BigDecimal.ZERO);
|
||||||
}
|
}
|
||||||
if(null==item.getItemCount()){
|
if (null == item.getItemCount()) {
|
||||||
item.setItemCount(1);
|
item.setItemCount(1);
|
||||||
}
|
}
|
||||||
//总价
|
//总价
|
||||||
item.setItemMoney(item.getItemPrice().multiply(BigDecimal.valueOf(item.getItemCount())).multiply(item.getItemDiscount()));
|
item.setItemMoney(item.getItemPrice().multiply(BigDecimal.valueOf(item.getItemCount())).multiply(item.getItemDiscount()));
|
||||||
//商品数量
|
//商品数量
|
||||||
goodsCount+=item.getItemCount();
|
goodsCount += item.getItemCount();
|
||||||
//工单总价
|
//工单总价
|
||||||
totalAmount = totalAmount.add(item.getItemMoney());
|
totalAmount = totalAmount.add(item.getItemMoney());
|
||||||
if("01".equals(item.getItemType())){
|
if ("01".equals(item.getItemType())) {
|
||||||
//项目
|
//项目
|
||||||
proAmount = proAmount.add(item.getItemMoney());
|
proAmount = proAmount.add(item.getItemMoney());
|
||||||
}else if("02".equals(item.getItemType())){
|
} else if ("02".equals(item.getItemType())) {
|
||||||
//配件
|
//配件
|
||||||
waresAmount = waresAmount.add(item.getItemMoney());
|
waresAmount = waresAmount.add(item.getItemMoney());
|
||||||
}else if("03".equals(item.getItemType())){
|
} else if ("03".equals(item.getItemType())) {
|
||||||
//其他
|
//其他
|
||||||
otherAmount = otherAmount.add(item.getItemMoney());
|
otherAmount = otherAmount.add(item.getItemMoney());
|
||||||
}
|
}
|
||||||
@ -1946,7 +1957,7 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl<DlRepairTicketsMappe
|
|||||||
orderInfo.setPayMoney(totalAmount);
|
orderInfo.setPayMoney(totalAmount);
|
||||||
repairOrderInfoService.updateById(orderInfo);
|
repairOrderInfoService.updateById(orderInfo);
|
||||||
Long time2 = System.currentTimeMillis();
|
Long time2 = System.currentTimeMillis();
|
||||||
System.out.println("时间差:"+(time2-time1));
|
System.out.println("时间差:" + (time2 - time1));
|
||||||
|
|
||||||
// 更新主表时间
|
// 更新主表时间
|
||||||
refreshUpdateTime(ticketId);
|
refreshUpdateTime(ticketId);
|
||||||
@ -1955,7 +1966,6 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl<DlRepairTicketsMappe
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 新增工单子项
|
* 新增工单子项
|
||||||
*
|
|
||||||
* @param respVO 主要有两个参数,主表ID,itemList(这个需要前端处理成子表的对象能接收的数据)
|
* @param respVO 主要有两个参数,主表ID,itemList(这个需要前端处理成子表的对象能接收的数据)
|
||||||
* @author 小李
|
* @author 小李
|
||||||
* @date 19:59 2024/10/24
|
* @date 19:59 2024/10/24
|
||||||
@ -1986,7 +1996,6 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl<DlRepairTicketsMappe
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 超时自动总检
|
* 超时自动总检
|
||||||
*
|
|
||||||
* @author 小李
|
* @author 小李
|
||||||
* @date 16:35 2024/10/26
|
* @date 16:35 2024/10/26
|
||||||
**/
|
**/
|
||||||
@ -2038,7 +2047,7 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl<DlRepairTicketsMappe
|
|||||||
if (!flag) {
|
if (!flag) {
|
||||||
// 通知总检,让其手动操作
|
// 通知总检,让其手动操作
|
||||||
ids.forEach(id -> {
|
ids.forEach(id -> {
|
||||||
repairWorkerService.sentMessage(SystemEnum.REPAIR.getCode(),id, "待总检车牌为:" + item.getCarNo() + "工单已经超时,但无法自动总检,请手动处理");
|
repairWorkerService.sentMessage(SystemEnum.REPAIR.getCode(), id, "待总检车牌为:" + item.getCarNo() + "工单已经超时,但无法自动总检,请手动处理");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return flag;
|
return flag;
|
||||||
@ -2058,9 +2067,9 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl<DlRepairTicketsMappe
|
|||||||
baseMapper.updateById(updateTickets);
|
baseMapper.updateById(updateTickets);
|
||||||
// 通知总检和服务顾问
|
// 通知总检和服务顾问
|
||||||
result.forEach(item -> {
|
result.forEach(item -> {
|
||||||
repairWorkerService.sentMessage(SystemEnum.REPAIR.getCode(),Long.valueOf(item.getAdviserId()), "您有新的工单可以出厂检验");
|
repairWorkerService.sentMessage(SystemEnum.REPAIR.getCode(), Long.valueOf(item.getAdviserId()), "您有新的工单可以出厂检验");
|
||||||
ids.forEach(id -> {
|
ids.forEach(id -> {
|
||||||
repairWorkerService.sentMessage(SystemEnum.REPAIR.getCode(),id, "车牌为:" + item.getCarNo() + "工单已由系统自动总检并移交服务顾问");
|
repairWorkerService.sentMessage(SystemEnum.REPAIR.getCode(), id, "车牌为:" + item.getCarNo() + "工单已由系统自动总检并移交服务顾问");
|
||||||
});
|
});
|
||||||
// 记录日志
|
// 记录日志
|
||||||
repairRecordsService.saveRepairRecord(item.getId(), null, RecordTypeEnum.ZJ.getCode(), "该工单由系统自动总检完成", null);
|
repairRecordsService.saveRepairRecord(item.getId(), null, RecordTypeEnum.ZJ.getCode(), "该工单由系统自动总检完成", null);
|
||||||
@ -2069,7 +2078,6 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl<DlRepairTicketsMappe
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改工单主表,只是主表
|
* 修改工单主表,只是主表
|
||||||
*
|
|
||||||
* @param respVO 请求对象
|
* @param respVO 请求对象
|
||||||
* @author 小李
|
* @author 小李
|
||||||
* @date 10:25 2024/10/30
|
* @date 10:25 2024/10/30
|
||||||
@ -2089,7 +2097,6 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl<DlRepairTicketsMappe
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除工单
|
* 删除工单
|
||||||
*
|
|
||||||
* @param id 工单ID
|
* @param id 工单ID
|
||||||
* @author 小李
|
* @author 小李
|
||||||
* @date 20:05 2024/11/1
|
* @date 20:05 2024/11/1
|
||||||
@ -2109,18 +2116,16 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl<DlRepairTicketsMappe
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 服务顾问交车
|
* 服务顾问交车
|
||||||
*
|
|
||||||
* @param respVO
|
|
||||||
* @author vinjor-M
|
* @author vinjor-M
|
||||||
* @date 16:51 2024/11/13
|
* @date 16:51 2024/11/13
|
||||||
**/
|
**/
|
||||||
@Override
|
@Override
|
||||||
public void overOrder(DlRepairTicketsRespVO respVO) {
|
public void overOrder(DlRepairTicketsRespVO respVO) {
|
||||||
DlRepairTickets repairTickets = this.getById(respVO.getId());
|
DlRepairTickets repairTickets = this.getById(respVO.getId());
|
||||||
if(TicketsStatusEnum.NO_PAY.getCode().equals(repairTickets.getTicketsStatus())){
|
if (TicketsStatusEnum.NO_PAY.getCode().equals(repairTickets.getTicketsStatus())) {
|
||||||
//没结账呢还
|
//没结账呢还
|
||||||
repairTickets.setIsHandover("1");
|
repairTickets.setIsHandover("1");
|
||||||
}else{
|
} else {
|
||||||
//结完账了
|
//结完账了
|
||||||
repairTickets.setIsHandover("1");
|
repairTickets.setIsHandover("1");
|
||||||
repairTickets.setTicketsStatus(TicketsStatusEnum.OVER.getCode());
|
repairTickets.setTicketsStatus(TicketsStatusEnum.OVER.getCode());
|
||||||
@ -2136,13 +2141,12 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl<DlRepairTicketsMappe
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据工单ID查客户和车辆信息
|
* 根据工单ID查客户和车辆信息
|
||||||
*
|
* @param id id
|
||||||
* @author 小李
|
* @author 小李
|
||||||
* @date 19:07 2024/11/18
|
* @date 19:07 2024/11/18
|
||||||
* @param id id
|
|
||||||
**/
|
**/
|
||||||
@Override
|
@Override
|
||||||
public CustomerAndCarVO getCusAndCarById(String id){
|
public CustomerAndCarVO getCusAndCarById(String id) {
|
||||||
// 查工单
|
// 查工单
|
||||||
DlRepairTickets tickets = baseMapper.selectById(id);
|
DlRepairTickets tickets = baseMapper.selectById(id);
|
||||||
// 查用户
|
// 查用户
|
||||||
@ -2158,14 +2162,13 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl<DlRepairTicketsMappe
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 用于刷新工单的更新时间
|
* 用于刷新工单的更新时间
|
||||||
*
|
* @param id 工单ID
|
||||||
* @author 小李
|
* @author 小李
|
||||||
* @date 10:31 2024/11/27
|
* @date 10:31 2024/11/27
|
||||||
* @param id 工单ID
|
|
||||||
**/
|
**/
|
||||||
@Override
|
@Override
|
||||||
public void refreshUpdateTime(String id){
|
public void refreshUpdateTime(String id) {
|
||||||
if (ObjectUtil.isNotEmpty(id)){
|
if (ObjectUtil.isNotEmpty(id)) {
|
||||||
baseMapper.update(new LambdaUpdateWrapper<DlRepairTickets>()
|
baseMapper.update(new LambdaUpdateWrapper<DlRepairTickets>()
|
||||||
.set(DlRepairTickets::getUpdateTime, LocalDateTime.now())
|
.set(DlRepairTickets::getUpdateTime, LocalDateTime.now())
|
||||||
.eq(DlRepairTickets::getId, id)
|
.eq(DlRepairTickets::getId, id)
|
||||||
|
|||||||
@ -3,26 +3,85 @@ package cn.iocoder.yudao.module.tickets.utils;
|
|||||||
import cn.hutool.core.date.DateUtil;
|
import cn.hutool.core.date.DateUtil;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.math.RoundingMode;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 工单操作常用util
|
* 工单操作常用util
|
||||||
* @author vinjor-M
|
* @author vinjor-M
|
||||||
* @date 16:15 2024/10/18
|
* @date 16:15 2024/10/18
|
||||||
**/
|
**/
|
||||||
@Component
|
@Component
|
||||||
public class TicketsOperateUtil {
|
public class TicketsOperateUtil {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 计算车龄
|
* 计算车龄
|
||||||
|
* @param registerDate 车辆注册日期
|
||||||
|
* @return java.lang.Double
|
||||||
* @author vinjor-M
|
* @author vinjor-M
|
||||||
* @date 14:47 2025/1/9
|
* @date 14:47 2025/1/9
|
||||||
* @param registerDate 车辆注册日期
|
|
||||||
* @return java.lang.Double
|
|
||||||
**/
|
**/
|
||||||
public Double computeCarYear(Date registerDate){
|
public Double computeCarYear(Date registerDate) {
|
||||||
long betweenMonth = DateUtil.betweenMonth(registerDate, new Date(), true);
|
long betweenMonth = DateUtil.betweenMonth(registerDate, new Date(), true);
|
||||||
String carYear = String.format("%.2f", (double) betweenMonth / 12);
|
String carYear = String.format("%.2f", (double) betweenMonth / 12);
|
||||||
return Double.parseDouble(carYear);
|
return Double.parseDouble(carYear);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 计算利润
|
||||||
|
* @param salePrice 单个售价(不含折扣)
|
||||||
|
* @param purchasePrice 单个进价(采购价格)
|
||||||
|
* @param count 数量
|
||||||
|
* @return 利润金额
|
||||||
|
*/
|
||||||
|
public BigDecimal calcProfit(BigDecimal salePrice, BigDecimal purchasePrice, int count) {
|
||||||
|
if (salePrice == null || purchasePrice == null) {
|
||||||
|
return BigDecimal.ZERO;
|
||||||
|
}
|
||||||
|
BigDecimal c = BigDecimal.valueOf(count);
|
||||||
|
return salePrice.multiply(c).subtract(purchasePrice.multiply(c));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 计算利润率
|
||||||
|
* @param salePrice 单个售价(不含折扣)
|
||||||
|
* @param purchasePrice 单个进价(采购价格)
|
||||||
|
* @param count 数量
|
||||||
|
* @return 利润率(0-1之间的小数,保留2位)
|
||||||
|
*/
|
||||||
|
public BigDecimal calcProfitRate(BigDecimal salePrice, BigDecimal purchasePrice, int count) {
|
||||||
|
if (salePrice == null || purchasePrice == null || count <= 0) {
|
||||||
|
return BigDecimal.ZERO;
|
||||||
|
}
|
||||||
|
|
||||||
|
BigDecimal c = BigDecimal.valueOf(count);
|
||||||
|
BigDecimal saleTotal = salePrice.multiply(c);
|
||||||
|
if (saleTotal.compareTo(BigDecimal.ZERO) == 0) {
|
||||||
|
return BigDecimal.ZERO;
|
||||||
|
}
|
||||||
|
|
||||||
|
BigDecimal profit = saleTotal.subtract(purchasePrice.multiply(c));
|
||||||
|
return profit.divide(saleTotal, 2, RoundingMode.HALF_UP);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 计算利润
|
||||||
|
* @param salePrice 单个售价(不含折扣)
|
||||||
|
* @param purchasePrice 单个进价(采购价格)
|
||||||
|
* @return 利润金额
|
||||||
|
*/
|
||||||
|
public BigDecimal calcProfit(BigDecimal salePrice, BigDecimal purchasePrice) {
|
||||||
|
return calcProfit(salePrice, purchasePrice, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 计算利润率
|
||||||
|
* @param salePrice 售价(不含折扣)
|
||||||
|
* @param purchasePrice 进价(采购价格)
|
||||||
|
* @return 利润率(0-1之间的小数,保留2位)
|
||||||
|
*/
|
||||||
|
public BigDecimal calcProfitRate(BigDecimal salePrice, BigDecimal purchasePrice) {
|
||||||
|
return calcProfitRate(salePrice, purchasePrice, 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -8,6 +8,7 @@ import cn.iocoder.yudao.module.tickets.entity.DlRepairTickets;
|
|||||||
import cn.iocoder.yudao.module.tickets.entity.DlRepairTitem;
|
import cn.iocoder.yudao.module.tickets.entity.DlRepairTitem;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -75,4 +76,10 @@ public class DlRepairTicketsRespVO extends DlRepairTickets {
|
|||||||
|
|
||||||
/** 客户来源 */
|
/** 客户来源 */
|
||||||
private String cusFrom;
|
private String cusFrom;
|
||||||
|
|
||||||
|
/** 含工时项目毛利率*/
|
||||||
|
private BigDecimal profitRate;
|
||||||
|
|
||||||
|
/** 不含工时项目毛利率*/
|
||||||
|
private BigDecimal profitRateNo;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user