Merge branch 'master' into repair

# Conflicts:
#	dl-module-repair/src/main/java/cn/iocoder/yudao/module/tickets/service/impl/DlRepairTicketsServiceImpl.java
This commit is contained in:
Vinjor 2024-11-21 15:00:50 +08:00
commit 92b4b7e7d1
5 changed files with 104 additions and 95 deletions

View File

@ -11,6 +11,7 @@ public interface CommonErrorCodeConstants extends ErrorCodeConstants {
ErrorCode STAFF_NOT_CHANGE = new ErrorCode(2_002_000_003, "该员工还有工作未交接,不可删除");
ErrorCode LOGIN_ACCOUNT_EXIST = new ErrorCode(2_002_000_004, "登录账号已存在");
ErrorCode LOGIN_ACCOUNT_NOT_EXIST = new ErrorCode(2_002_000_005, "登录账号不存在");
ErrorCode LOGIN_ACCOUNT_NOT_AUTH = new ErrorCode(2_002_000_010, "登录账号没有权限");
ErrorCode SYSTEM_ERROR = new ErrorCode(2_002_000_005, "系统错误");
ErrorCode MISTAKEN_IDENTITY = new ErrorCode(2_002_000_006, "身份有误");
}

View File

@ -2,7 +2,6 @@ package cn.iocoder.yudao.module.staff.controller.admin;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import cn.iocoder.yudao.common.CommonErrorCodeConstants;
import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
@ -324,7 +323,7 @@ public class CompanyStaffController {
rtnMap.put("loginResult",loginService.loginApp(authLoginReqVO,loginBody.getTenantId()));
return success(rtnMap);
}catch (Exception e){
return error(CommonErrorCodeConstants.LOGIN_ACCOUNT_NOT_EXIST);
return error(2_002_000_005,e.getMessage());
}
}
}

View File

@ -94,7 +94,7 @@ public class ApiAppLoginServiceImpl implements ApiAppLoginService {
// 获取登录用户的角色信息
List<Long> roleIdsByUserId = permissionApi.getRoleIdsByUserId(user.getId());
if (ObjectUtil.isEmpty(roleIdsByUserId) || roleIdsByUserId.size() == 0) {
throw new Exception(CommonErrorCodeConstants.LOGIN_ACCOUNT_NOT_EXIST.getMsg());
throw new Exception(CommonErrorCodeConstants.LOGIN_ACCOUNT_NOT_AUTH.getMsg());
}
List<RoleReqDTO> roleList = roleApi.getRoleList();
//所拥有的角色code集和
@ -126,11 +126,11 @@ public class ApiAppLoginServiceImpl implements ApiAppLoginService {
} else {
//错误的业务系统标识
throw new Exception(CommonErrorCodeConstants.LOGIN_ACCOUNT_NOT_EXIST.getMsg());
throw new Exception(CommonErrorCodeConstants.LOGIN_ACCOUNT_NOT_AUTH.getMsg());
}
// 角色是否可以登录
if (!flag) {
throw new Exception(CommonErrorCodeConstants.LOGIN_ACCOUNT_NOT_EXIST.getMsg());
throw new Exception(CommonErrorCodeConstants.LOGIN_ACCOUNT_NOT_AUTH.getMsg());
}
return user;
}

View File

@ -341,13 +341,13 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl<DlRepairTicketsMappe
/**
* 获得一个工单的详细信息
*
* @param id 工单ID
* @param id 工单ID
* @param ifApp 是否是APP发起的查询
* @author 小李
* @date 16:05 2024/9/21
**/
@Override
public DlRepairTicketsRespVO getTicketsById(String id, Boolean ifApp) {
public DlRepairTicketsRespVO getTicketsById(String id,Boolean ifApp) {
// 查工单主表
DlRepairTickets dlRepairTickets = baseMapper.selectById(id);
DlRepairTicketsRespVO result = BeanUtil.toBean(dlRepairTickets, DlRepairTicketsRespVO.class);
@ -374,44 +374,44 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl<DlRepairTicketsMappe
}
result.setProjects(projects);
if (ifApp) {
if(ifApp){
//app的逻辑
List<AppWaresGroupVO> waresGroupList = new ArrayList<>();
//查这个工单的配件
List<DlRepairTitemReqVO> waresList = repairTitemMapper.selectByTicketId(id);
if (CollectionUtil.isNotEmpty(waresList)) {
//先过滤出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)) {
AppWaresGroupVO waresGroupVO = new AppWaresGroupVO();
waresGroupVO.setWares(nullList);
waresGroupVO.setGroupName("未知分组");
waresGroupVO.setNums(nullList.size());
waresGroupVO.setTotalAmount(nullList.stream().peek(item -> {
if (null == item.getItemMoney()) {
waresGroupVO.setTotalAmount(nullList.stream().peek(item->{
if(null==item.getItemMoney()){
item.setItemMoney(new BigDecimal(0));
}
}).map(DlRepairTitem::getItemMoney).reduce(BigDecimal.ZERO, BigDecimal::add));
}).map(DlRepairTitem::getItemMoney).reduce(BigDecimal.ZERO,BigDecimal::add));
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));
for (String key : groupListMap.keySet()) {
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()){
AppWaresGroupVO waresGroupVO = new AppWaresGroupVO();
waresGroupVO.setWares(groupListMap.get(key));
waresGroupVO.setGroupName(groupListMap.get(key).get(0).getItemTypeName());
waresGroupVO.setGroupId(key);
waresGroupVO.setNums(groupListMap.get(key).size());
waresGroupVO.setTotalAmount(groupListMap.get(key).stream().peek(item -> {
if (null == item.getItemMoney()) {
waresGroupVO.setTotalAmount(groupListMap.get(key).stream().peek(item->{
if(null==item.getItemMoney()){
item.setItemMoney(new BigDecimal(0));
}
}).map(DlRepairTitem::getItemMoney).reduce(BigDecimal.ZERO, BigDecimal::add));
}).map(DlRepairTitem::getItemMoney).reduce(BigDecimal.ZERO,BigDecimal::add));
waresGroupList.add(waresGroupVO);
}
}
result.setWaresGroupList(waresGroupList);
} else {
}else{
// 取配件----原有逻辑-电脑端
List<DlRepairTitemReqVO> wares = items.stream().filter(item -> item.getItemType().equals("02")).collect(Collectors.toList());
if (CollectionUtil.isNotEmpty(wares)) {
@ -1453,47 +1453,47 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl<DlRepairTicketsMappe
* @date 11:30 2024/10/24
**/
@Override
public Map<String, Long> getBossNum(String selectType, String startDate, String endDate) {
public Map<String, Long> getBossNum(String selectType,String startDate,String endDate) {
Map<String, Long> rtnMap = new HashMap<>();
//维修中---当前这一时刻
long workingNum = 0;
//在厂数--当前这一时刻
long inCompanyNum = 0;
//进场数
long newOrderNum = 0;
long newOrderNum=0;
//已完成
long overNum = 0;
long overNum=0;
//已交车
long giveCusNum = 0;
long giveCusNum=0;
List<DlRepairTickets> repairTickets = this.list();
if (!repairTickets.isEmpty()) {
workingNum = repairTickets.stream().filter(item -> TicketsStatusEnum.WORKING.getCode().equals(item.getTicketsStatus())).count();
inCompanyNum = repairTickets.stream().filter(item -> TicketsStatusEnum.NO_PAY.getCode().equals(item.getTicketsStatus())).count();
LocalDateTime currentTime = LocalDateTime.now();
if ("today".equals(selectType)) {
if("today".equals(selectType)){
String nowDayStr = DateUtil.formatDate(new Date());
//查当日进厂数已完成已交车
newOrderNum = repairTickets.stream().filter(item -> item.getCreateTime().toLocalDate().equals(currentTime.toLocalDate())).count();
//查当日已完成的总检完成的
overNum = repairTicketsMapper.selectCountByParams(nowDayStr, RecordTypeEnum.ZJ.getCode(), null, null);
overNum = repairTicketsMapper.selectCountByParams(nowDayStr,RecordTypeEnum.ZJ.getCode(),null,null);
//查当日已交车的已结算的
giveCusNum = repairTicketsMapper.selectCountByParams(nowDayStr, RecordTypeEnum.JS.getCode(), null, null);
} else if ("all".equals(selectType)) {
giveCusNum = repairTicketsMapper.selectCountByParams(nowDayStr,RecordTypeEnum.JS.getCode(),null,null);
}else if("all".equals(selectType)){
//查累计进厂数已完成已交车
newOrderNum = repairTickets.size();
//查累计已完成的总检完成的
overNum = repairTicketsMapper.selectCountByParams(null, RecordTypeEnum.ZJ.getCode(), null, null);
overNum = repairTicketsMapper.selectCountByParams(null,RecordTypeEnum.ZJ.getCode(),null,null);
//查累计已交车的已结算的
giveCusNum = repairTicketsMapper.selectCountByParams(null, RecordTypeEnum.JS.getCode(), null, null);
} else {
giveCusNum = repairTicketsMapper.selectCountByParams(null,RecordTypeEnum.JS.getCode(),null,null);
}else {
//查某个时间范围内进厂数已完成已交车
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 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"));
newOrderNum = repairTickets.stream().filter(item -> item.getCreateTime().isAfter(startTime) && item.getCreateTime().isBefore(endTime)).count();
//查某区间范围内已完成的总检完成的
overNum = repairTicketsMapper.selectCountByParams(null, RecordTypeEnum.ZJ.getCode(), startDate + " 00:00:00", endDate + " 23:59:59");
overNum = repairTicketsMapper.selectCountByParams(null,RecordTypeEnum.ZJ.getCode(), startDate+" 00:00:00", endDate+" 23:59:59");
//查某区间范围内已交车的已结算的
giveCusNum = repairTicketsMapper.selectCountByParams(null, RecordTypeEnum.JS.getCode(), startDate + " 00:00:00", endDate + " 23:59:59");
giveCusNum = repairTicketsMapper.selectCountByParams(null,RecordTypeEnum.JS.getCode(), startDate+" 00:00:00", endDate+" 23:59:59");
}
}
rtnMap.put("workingNum", workingNum);
@ -1565,7 +1565,7 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl<DlRepairTicketsMappe
throw exception0(500, "工单中有项目或配件没有设置价格,请服务顾问填写项目价格,仓库填写配件价格");
}
// 如果有为0的那就提示让操作人选择
if (item.getItemPrice().equals(new BigDecimal("0.00"))) {
if (item.getItemPrice().equals(new BigDecimal("0.00"))){
return false;
}
}
@ -1582,69 +1582,80 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl<DlRepairTicketsMappe
@Override
@DSTransactional
public boolean computeTicket(String ticketId) {
// 取主表
DlRepairTickets tickets = baseMapper.selectById(ticketId);
// 取子表
List<DlRepairTitem> titems = titemService.list(new LambdaQueryWrapper<DlRepairTitem>().eq(DlRepairTitem::getTicketId, ticketId));
if (CollectionUtil.isEmpty(titems)) {
Long time1 = System.currentTimeMillis();
/*1.查主表 */
DlRepairTickets oldTicket = baseMapper.selectById(ticketId);
// 管理费
BigDecimal managerMoney = ObjectUtil.isNotEmpty(oldTicket.getManagerMoney()) ? oldTicket.getManagerMoney() : new BigDecimal("0");
// 救援费
BigDecimal rescueMoney = ObjectUtil.isNotEmpty(oldTicket.getRescueMoney()) ? oldTicket.getRescueMoney() : new BigDecimal("0");
// 三包费
BigDecimal threePackMoney = ObjectUtil.isNotEmpty(oldTicket.getThreePackMoney()) ? oldTicket.getThreePackMoney() : new BigDecimal("0");
// 定损费
BigDecimal confirmFaultMoney = ObjectUtil.isNotEmpty(oldTicket.getConfirmFaultMoney()) ? oldTicket.getConfirmFaultMoney() : new BigDecimal("0");
/*2.查子表 */
List<DlRepairTitem> list = titemService.list(new LambdaQueryWrapper<DlRepairTitem>().eq(DlRepairTitem::getTicketId, ticketId));
if (CollectionUtil.isEmpty(list)) {
throw exception0(500, "没有项目、配件或其他");
}
// 计算子表
Map<String, BigDecimal> titemsMap = titems.stream().collect(Collectors.toMap(
DlRepairTitem::getId,
item -> {
BigDecimal discount = item.getItemDiscount() == null ? BigDecimal.ONE : item.getItemDiscount();
BigDecimal itemPrice = item.getItemPrice() == null ? BigDecimal.ZERO : item.getItemPrice();
return itemPrice.multiply(BigDecimal.valueOf(item.getItemCount())).multiply(discount);
}
));
titems.forEach(item -> {
item.setItemMoney(titemsMap.get(item.getId()));
});
titemService.updateBatchById(titems);
// 计算主表
// 总数量
tickets.setCount(titems.stream().mapToInt(DlRepairTitem::getItemCount).sum());
// 各类总价
Map<String, BigDecimal> typePrice = titems.stream()
.collect(Collectors.groupingBy(DlRepairTitem::getItemType,
Collectors.mapping(DlRepairTitem::getItemMoney,
Collectors.reducing(BigDecimal.ZERO, BigDecimal::add))));
BigDecimal itemTotalPrice = new BigDecimal("0");
for (Map.Entry<String, BigDecimal> entry : typePrice.entrySet()) {
itemTotalPrice = itemTotalPrice.add(entry.getValue());
switch (entry.getKey()){
case "01":
tickets.setProjectPrice(entry.getValue());
break;
case "02":
tickets.setPartPrice(entry.getValue());
break;
case "03":
tickets.setOtherPrice(entry.getValue());
break;
/*3.遍历数据--遍历这一次,处理所有需要处理的*/
//商品总数
Integer goodsCount=0;
//工单总价
BigDecimal totalAmount = BigDecimal.ZERO.add(managerMoney).add(rescueMoney).add(threePackMoney).add(confirmFaultMoney);
//项目总价
BigDecimal proAmount = BigDecimal.ZERO;
//配件总价
BigDecimal waresAmount = BigDecimal.ZERO;
//其他总价
BigDecimal otherAmount = BigDecimal.ZERO;
for(DlRepairTitem item:list){
//空字段设置默认值
if(null==item.getItemDiscount()){
item.setItemDiscount(new BigDecimal(1));
}
if(null==item.getItemPrice()){
item.setItemPrice(BigDecimal.ZERO);
}
if(null==item.getItemCount()){
item.setItemCount(1);
}
//总价
item.setItemMoney(item.getItemPrice().multiply(BigDecimal.valueOf(item.getItemCount())).multiply(item.getItemDiscount()));
//商品数量
goodsCount+=item.getItemCount();
//工单总价
totalAmount = totalAmount.add(item.getItemMoney());
if("01".equals(item.getItemType())){
//项目
proAmount = proAmount.add(item.getItemMoney());
}else if("02".equals(item.getItemType())){
//配件
waresAmount = waresAmount.add(item.getItemMoney());
}else if("03".equals(item.getItemType())){
//其他
otherAmount = otherAmount.add(item.getItemMoney());
}
}
// 其他费用
// 管理费
BigDecimal managerMoney = ObjectUtil.isNotEmpty(tickets.getManagerMoney()) ? tickets.getManagerMoney() : new BigDecimal("0");
// 救援费
BigDecimal rescueMoney = ObjectUtil.isNotEmpty(tickets.getRescueMoney()) ? tickets.getRescueMoney() : new BigDecimal("0");
// 三包费
BigDecimal threePackMoney = ObjectUtil.isNotEmpty(tickets.getThreePackMoney()) ? tickets.getThreePackMoney() : new BigDecimal("0");
// 定损费
BigDecimal confirmFaultMoney = ObjectUtil.isNotEmpty(tickets.getConfirmFaultMoney()) ? tickets.getConfirmFaultMoney() : new BigDecimal("0");
tickets.setTotalPrice(itemTotalPrice.add(managerMoney).add(rescueMoney).add(threePackMoney).add(confirmFaultMoney));
// 更新订单
/*4.设置指定字段值*/
oldTicket.setCount(goodsCount);
oldTicket.setTotalPrice(totalAmount);
oldTicket.setProjectPrice(proAmount);
oldTicket.setPartPrice(waresAmount);
oldTicket.setOtherPrice(otherAmount);
/*5.更新数据*/
//暂不更新只要计算不出问题就行
// titemService.updateBatchById(list);
baseMapper.updateById(oldTicket);
// 因为订单是在工单创建的时候就新增了后面加的配件之类的金额没有同步到订单这里同步一下
RepairOrderInfo orderInfo = repairOrderInfoService.getOne(new LambdaQueryWrapper<RepairOrderInfo>().eq(RepairOrderInfo::getGoodsId, ticketId));
orderInfo.setGoodsPrice(tickets.getTotalPrice());
orderInfo.setPayMoney(tickets.getTotalPrice());
// 更新商品原价和实付金额
orderInfo.setGoodsPrice(totalAmount);
orderInfo.setPayMoney(totalAmount);
repairOrderInfoService.updateById(orderInfo);
return baseMapper.updateById(tickets) > 0;
Long time2 = System.currentTimeMillis();
System.out.println("时间差:"+(time2-time1));
return true;
}
/**
@ -1826,12 +1837,12 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl<DlRepairTicketsMappe
/**
* 根据工单ID查客户和车辆信息
*
* @param id id
* @author 小李
* @date 19:07 2024/11/18
* @param id id
**/
@Override
public CustomerAndCarVO getCusAndCarById(String id) {
public CustomerAndCarVO getCusAndCarById(String id){
// 查工单
DlRepairTickets tickets = baseMapper.selectById(id);
// 查用户

View File

@ -347,13 +347,11 @@ public class DlTicketWaresServiceImpl extends ServiceImpl<DlTicketWaresMapper, D
}).collect(Collectors.toList());
repairTitemService.saveBatch(newTitems);
}
// 更新维修工单主表
boolean flag = repairTicketsService.computeTicket(ticketWares.getTicketId());
if (!flag) {
throw exception0(500, "重新计算工单错误");
}
// 发送通过的消息给仓库
RoleReqDTO roleInfo = roleApi.getRoleInfo(RepairRoleEnum.WAREHOUSE.getCode());
List<Long> ids = permissionApi.getUserIdByRoleId(roleInfo.getId());