From 291360d2e63f8274f6f29a6358948e624b0d275d Mon Sep 17 00:00:00 2001 From: Vinjor Date: Thu, 21 Nov 2024 13:50:53 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cn/iocoder/yudao/common/CommonErrorCodeConstants.java | 1 + .../staff/controller/admin/CompanyStaffController.java | 3 +-- .../module/staff/service/impl/ApiAppLoginServiceImpl.java | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/dl-module-base/src/main/java/cn/iocoder/yudao/common/CommonErrorCodeConstants.java b/dl-module-base/src/main/java/cn/iocoder/yudao/common/CommonErrorCodeConstants.java index 44fa0ab3..b65c6846 100644 --- a/dl-module-base/src/main/java/cn/iocoder/yudao/common/CommonErrorCodeConstants.java +++ b/dl-module-base/src/main/java/cn/iocoder/yudao/common/CommonErrorCodeConstants.java @@ -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, "身份有误"); } diff --git a/dl-module-company/src/main/java/cn/iocoder/yudao/module/staff/controller/admin/CompanyStaffController.java b/dl-module-company/src/main/java/cn/iocoder/yudao/module/staff/controller/admin/CompanyStaffController.java index ed96fabc..358c6fcb 100644 --- a/dl-module-company/src/main/java/cn/iocoder/yudao/module/staff/controller/admin/CompanyStaffController.java +++ b/dl-module-company/src/main/java/cn/iocoder/yudao/module/staff/controller/admin/CompanyStaffController.java @@ -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()); } } } diff --git a/dl-module-company/src/main/java/cn/iocoder/yudao/module/staff/service/impl/ApiAppLoginServiceImpl.java b/dl-module-company/src/main/java/cn/iocoder/yudao/module/staff/service/impl/ApiAppLoginServiceImpl.java index ecd2b078..b985b054 100644 --- a/dl-module-company/src/main/java/cn/iocoder/yudao/module/staff/service/impl/ApiAppLoginServiceImpl.java +++ b/dl-module-company/src/main/java/cn/iocoder/yudao/module/staff/service/impl/ApiAppLoginServiceImpl.java @@ -94,7 +94,7 @@ public class ApiAppLoginServiceImpl implements ApiAppLoginService { // 获取登录用户的角色信息 List 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 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; } From 00b51b8b862ad5ef347569ae51465f14bc00818f Mon Sep 17 00:00:00 2001 From: Vinjor Date: Thu, 21 Nov 2024 14:59:17 +0800 Subject: [PATCH 2/2] 1 --- .../impl/DlRepairTicketsServiceImpl.java | 116 ++++++++++-------- .../impl/DlTicketWaresServiceImpl.java | 2 - 2 files changed, 62 insertions(+), 56 deletions(-) diff --git a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/tickets/service/impl/DlRepairTicketsServiceImpl.java b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/tickets/service/impl/DlRepairTicketsServiceImpl.java index 00dc57b3..b7cbfe27 100644 --- a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/tickets/service/impl/DlRepairTicketsServiceImpl.java +++ b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/tickets/service/impl/DlRepairTicketsServiceImpl.java @@ -1582,50 +1582,8 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl list = titemService.list(new LambdaQueryWrapper().eq(DlRepairTitem::getTicketId, ticketId)); - // 计算子表 - if (CollectionUtil.isEmpty(list)) { - throw exception0(500, "没有项目、配件或其他"); - } - List updateItems = list.stream().map(item -> { - DlRepairTitem titem = new DlRepairTitem(); - titem.setId(item.getId()); - // 取出折扣 - BigDecimal discount = item.getItemDiscount() == null ? new BigDecimal("1") : item.getItemDiscount(); - BigDecimal itemPrice = item.getItemPrice() == null ? BigDecimal.ZERO : item.getItemPrice(); - titem.setItemMoney(itemPrice.multiply(BigDecimal.valueOf(item.getItemCount())).multiply(discount)); - return titem; - }).collect(Collectors.toList()); - // 更新 - titemService.updateBatchById(updateItems); - - // 计算主表 - // 查新的子表信息 - List newList = titemService.list(new LambdaQueryWrapper().eq(DlRepairTitem::getTicketId, ticketId)); - DlRepairTickets tickets = new DlRepairTickets(); - // 计算子项总数 - int count = newList.stream().mapToInt(DlRepairTitem::getItemCount).sum(); - tickets.setId(ticketId); - tickets.setCount(count); - // 分类计算各自的总价和最终工单总价 - Map> map = newList.stream().collect(Collectors.groupingBy(DlRepairTitem::getItemType)); - // 01项目,02,配件,03,其他 - tickets.setTotalPrice(BigDecimal.ZERO); - map.forEach((k, v) -> { - BigDecimal reduce = v.stream().map(DlRepairTitem::getItemMoney).reduce(BigDecimal.ZERO, BigDecimal::add); - tickets.setTotalPrice(tickets.getTotalPrice().add(reduce)); - if (k.equals("01")) { - tickets.setProjectPrice(reduce); - } else if (k.equals("02")) { - tickets.setPartPrice(reduce); - } else if (k.equals("03")) { - tickets.setOtherPrice(reduce); - } - }); - - // 工单总价还需要变,把其他新加的费用也需要算上 - // 查主表 + Long time1 = System.currentTimeMillis(); + /*1.查主表 */ DlRepairTickets oldTicket = baseMapper.selectById(ticketId); // 管理费 BigDecimal managerMoney = ObjectUtil.isNotEmpty(oldTicket.getManagerMoney()) ? oldTicket.getManagerMoney() : new BigDecimal("0"); @@ -1635,19 +1593,69 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl list = titemService.list(new LambdaQueryWrapper().eq(DlRepairTitem::getTicketId, ticketId)); + if (CollectionUtil.isEmpty(list)) { + throw exception0(500, "没有项目、配件或其他"); + } + /*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()); + } + } + /*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().eq(RepairOrderInfo::getGoodsId, ticketId)); - RepairOrderInfo newOrderInfo = new RepairOrderInfo(); - newOrderInfo.setId(orderInfo.getId()); // 更新商品原价和实付金额 - newOrderInfo.setGoodsPrice(tickets.getTotalPrice()); - newOrderInfo.setPayMoney(tickets.getTotalPrice()); - repairOrderInfoService.updateById(newOrderInfo); - - return baseMapper.updateById(tickets) > 0; + orderInfo.setGoodsPrice(totalAmount); + orderInfo.setPayMoney(totalAmount); + repairOrderInfoService.updateById(orderInfo); + Long time2 = System.currentTimeMillis(); + System.out.println("时间差:"+(time2-time1)); + return true; } /** diff --git a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/tickets/service/impl/DlTicketWaresServiceImpl.java b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/tickets/service/impl/DlTicketWaresServiceImpl.java index 559c8172..d1acbb02 100644 --- a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/tickets/service/impl/DlTicketWaresServiceImpl.java +++ b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/tickets/service/impl/DlTicketWaresServiceImpl.java @@ -347,13 +347,11 @@ public class DlTicketWaresServiceImpl extends ServiceImpl ids = permissionApi.getUserIdByRoleId(roleInfo.getId());