From 77036c32f5e49c482f4a569ff361e7587613e54a Mon Sep 17 00:00:00 2001 From: Vinjor Date: Wed, 23 Oct 2024 14:32:38 +0800 Subject: [PATCH 1/4] 1 --- .../stockOperate/entity/DlRepairSo.java | 7 ++- .../stockOperate/entity/DlRepairSoi.java | 13 +++++ .../service/impl/DlRepairSoServiceImpl.java | 23 +++++++-- .../mapper/stockOperate/DlRepairSoMapper.xml | 47 ++++++++++--------- 4 files changed, 63 insertions(+), 27 deletions(-) diff --git a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/stockOperate/entity/DlRepairSo.java b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/stockOperate/entity/DlRepairSo.java index 3931e90b..9e185191 100644 --- a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/stockOperate/entity/DlRepairSo.java +++ b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/stockOperate/entity/DlRepairSo.java @@ -10,7 +10,6 @@ import lombok.Data; import lombok.EqualsAndHashCode; import org.springframework.format.annotation.DateTimeFormat; -import java.io.Serializable; import java.math.BigDecimal; import java.util.Date; @@ -112,4 +111,10 @@ public class DlRepairSo extends TenantBaseDO { /** 关联的配件申请单的id(dl_ticket_wares表的ID) */ private String twId; + + /** + * 车牌号 + */ + @TableField(exist = false) + private String licenseNumber; } \ No newline at end of file diff --git a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/stockOperate/entity/DlRepairSoi.java b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/stockOperate/entity/DlRepairSoi.java index 02309b59..dc8eebdc 100644 --- a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/stockOperate/entity/DlRepairSoi.java +++ b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/stockOperate/entity/DlRepairSoi.java @@ -1,7 +1,9 @@ package cn.iocoder.yudao.module.stockOperate.entity; import cn.iocoder.yudao.framework.tenant.core.db.TenantBaseDO; +import cn.iocoder.yudao.module.project.entity.RepairWares; import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; import lombok.Data; @@ -67,4 +69,15 @@ public class DlRepairSoi extends TenantBaseDO { * 备注 */ private String remark; + + /** + * 配件信息 + */ + @TableField(exist = false) + private RepairWares wares; + /** + * 配件类型名称 + */ + @TableField(exist = false) + private String typeName; } \ No newline at end of file diff --git a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/stockOperate/service/impl/DlRepairSoServiceImpl.java b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/stockOperate/service/impl/DlRepairSoServiceImpl.java index 1f1dd665..1b09bf62 100644 --- a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/stockOperate/service/impl/DlRepairSoServiceImpl.java +++ b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/stockOperate/service/impl/DlRepairSoServiceImpl.java @@ -38,11 +38,11 @@ import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Service; import javax.annotation.Resource; - import java.math.BigDecimal; -import java.util.Iterator; +import java.util.HashMap; import java.util.List; -import java.util.Objects; +import java.util.Map; +import java.util.function.Function; import java.util.stream.Collectors; import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; @@ -197,6 +197,21 @@ public class DlRepairSoServiceImpl extends ServiceImpl list = repairSoiService.list(new LambdaQueryWrapper().eq(DlRepairSoi::getSoId, result.getId())); + if(!list.isEmpty()){ + //所有有配件的分类 + List> typeMapList = waresService.getAllTypeList(); + Map typeMap = new HashMap<>(); + for(Map map:typeMapList){ + typeMap.put(map.get("id"),map.get("name")); + } + //关联查配件信息 + List repairWaresList = waresService.listByIds(list.stream().map(DlRepairSoi::getGoodsId).collect(Collectors.toList())); + Map waresMap = repairWaresList.stream().collect(Collectors.toMap(RepairWares::getId, Function.identity())); + list.forEach(item->{ + item.setWares(waresMap.get(item.getGoodsId())); + item.setTypeName(typeMap.get(item.getWares().getType())); + }); + } result.setGoodsList(list); return result; } @@ -338,7 +353,7 @@ public class DlRepairSoServiceImpl extends ServiceImpl i.getGoodsId().equals(item.getPartId())).findFirst().ifPresent(i -> { titem.setItemCount(item.getItemCount() - i.getGoodsCount()); - titem.setItemMoney(new BigDecimal(titem.getItemCount()).multiply(item.getItemPrice()).multiply(item.getItemDiscount())); + titem.setItemMoney(new BigDecimal(item.getItemCount()).multiply(item.getItemPrice()).multiply(item.getItemDiscount())); }); return titem; }).collect(Collectors.toList()); diff --git a/dl-module-repair/src/main/resources/mapper/stockOperate/DlRepairSoMapper.xml b/dl-module-repair/src/main/resources/mapper/stockOperate/DlRepairSoMapper.xml index beb00091..06abc89b 100644 --- a/dl-module-repair/src/main/resources/mapper/stockOperate/DlRepairSoMapper.xml +++ b/dl-module-repair/src/main/resources/mapper/stockOperate/DlRepairSoMapper.xml @@ -25,40 +25,43 @@ + - select id, - so_type, - purchase_type, - so_no, - supplier_id, - supplier_name, - user_id, - user_name, - so_time, - item_count, - total_price, - so_status, - remark, - corp_id, - corp_name, - dept_id, - create_time, - update_time, - updater, - tw_id + select so.id, + so.so_type, + so.purchase_type, + so.so_no, + so.supplier_id, + so.supplier_name, + so.user_id, + so.user_name, + so.so_time, + so.item_count, + so.total_price, + so.so_status, + so.remark, + so.corp_id, + so.corp_name, + so.dept_id, + so.create_time, + so.update_time, + so.updater, + so.tw_id, + dtw.license_number from dl_repair_so so + LEFT JOIN dl_ticket_wares dtw ON so.tw_id = dtw.id where so.deleted = '0' - where deleted = 0 and dept_id = #{deptId} + where deleted = 0 diff --git a/dl-module-jx/src/main/resources/mapper/jx/DriveSchoolSwiperMapper.xml b/dl-module-jx/src/main/resources/mapper/jx/DriveSchoolSwiperMapper.xml index 50e7f386..e5c35404 100644 --- a/dl-module-jx/src/main/resources/mapper/jx/DriveSchoolSwiperMapper.xml +++ b/dl-module-jx/src/main/resources/mapper/jx/DriveSchoolSwiperMapper.xml @@ -128,6 +128,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" AND list_order = #{driveSchoolSwiper.listOrder} + ORDER BY list_order ASC diff --git a/sql/增量DB.sql b/sql/增量DB.sql new file mode 100644 index 00000000..6c0fb9af --- /dev/null +++ b/sql/增量DB.sql @@ -0,0 +1,3 @@ +--增加封面图字段用来回显首页 +ALTER TABLE `system_service_package` +ADD COLUMN `cover_img` varchar(255) NULL COMMENT '服务icon' AFTER `menu_ids`; diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/service/ServicePackageController.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/service/ServicePackageController.java index dbd15b11..b8d6c2a5 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/service/ServicePackageController.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/service/ServicePackageController.java @@ -88,5 +88,9 @@ public class ServicePackageController { List list = servicePackageService.getServicePackageListByStatus(CommonStatusEnum.ENABLE.getStatus()); return success(BeanUtils.toBean(list, ServicePackageSimpleRespVO.class)); } - -} \ No newline at end of file + @GetMapping({"/getPackageListByTenantId"}) + public CommonResult> getPackageListByTenantId() { + List list = servicePackageService.getPackageListByTenantId(); + return success(list); + } +} diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/service/vo/ServicePackageRespVO.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/service/vo/ServicePackageRespVO.java index 973a3345..56260992 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/service/vo/ServicePackageRespVO.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/service/vo/ServicePackageRespVO.java @@ -19,6 +19,7 @@ public class ServicePackageRespVO { @Schema(description = "套餐名", requiredMode = Schema.RequiredMode.REQUIRED, example = "赵六") @ExcelProperty("套餐名") private String name; + private String coverImg; @Schema(description = "套餐状态(0正常 1停用)", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") @ExcelProperty("租户状态(0正常 1停用)") @@ -36,4 +37,4 @@ public class ServicePackageRespVO { @ExcelProperty("创建时间") private LocalDateTime createTime; -} \ No newline at end of file +} diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/service/vo/ServicePackageSaveReqVO.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/service/vo/ServicePackageSaveReqVO.java index ca9c3acf..fa132dd5 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/service/vo/ServicePackageSaveReqVO.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/service/vo/ServicePackageSaveReqVO.java @@ -15,6 +15,7 @@ public class ServicePackageSaveReqVO { @Schema(description = "套餐名", requiredMode = Schema.RequiredMode.REQUIRED, example = "赵六") @NotEmpty(message = "套餐名不能为空") private String name; + private String coverImg; @Schema(description = "套餐状态(0正常 1停用)", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") @NotNull(message = "套餐状态(0正常 1停用)不能为空") @@ -27,4 +28,4 @@ public class ServicePackageSaveReqVO { @NotEmpty(message = "关联的菜单编号不能为空") private Set menuIds; -} \ No newline at end of file +} diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/service/vo/ServicePackageSimpleRespVO.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/service/vo/ServicePackageSimpleRespVO.java index 0bf2d82b..1f22a1ec 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/service/vo/ServicePackageSimpleRespVO.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/service/vo/ServicePackageSimpleRespVO.java @@ -17,4 +17,5 @@ public class ServicePackageSimpleRespVO { @NotNull(message = "套餐名不能为空") private String name; + } diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/dataobject/service/ServicePackageDO.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/dataobject/service/ServicePackageDO.java index 7787592c..55e46527 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/dataobject/service/ServicePackageDO.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/dataobject/service/ServicePackageDO.java @@ -40,10 +40,11 @@ public class ServicePackageDO extends BaseDO { * 备注 */ private String remark; + private String coverImg; /** * 关联的菜单编号 */ @TableField(typeHandler = JacksonTypeHandler.class) private Set menuIds; -} \ No newline at end of file +} diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/service/ServicePackageMapper.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/service/ServicePackageMapper.java index daa1d1a3..a52428e3 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/service/ServicePackageMapper.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/service/ServicePackageMapper.java @@ -29,4 +29,7 @@ public interface ServicePackageMapper extends BaseMapperX { default List selectListByStatus(Integer status) { return selectList(ServicePackageDO::getStatus, status); } -} \ No newline at end of file + + + List getPackageListByTenantId(); +} diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/service/ServicePackageService.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/service/ServicePackageService.java index 5edda829..cd1fb307 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/service/ServicePackageService.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/service/ServicePackageService.java @@ -78,4 +78,14 @@ public interface ServicePackageService { * @param ids ids **/ List getServicePackageByIds(List ids); -} \ No newline at end of file + + /** + * 查租户服务 + * + * @author zcy + * @date 10:37 2024/9/24 + **/ + List getPackageListByTenantId(); + + +} diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/service/ServicePackageServiceImpl.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/service/ServicePackageServiceImpl.java index 2a2085a0..40cf2ed4 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/service/ServicePackageServiceImpl.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/service/ServicePackageServiceImpl.java @@ -4,6 +4,8 @@ import cn.iocoder.yudao.framework.common.config.CommonStr; import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; import cn.iocoder.yudao.framework.datapermission.core.rule.DataPermissionRule; import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; +import cn.iocoder.yudao.framework.security.core.LoginUser; +import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils; import cn.iocoder.yudao.framework.tenant.core.util.TenantUtils; import cn.iocoder.yudao.module.system.api.service.dto.ServicePackageDto; import cn.iocoder.yudao.module.system.controller.admin.permission.vo.role.RoleSaveReqVO; @@ -14,6 +16,7 @@ import cn.iocoder.yudao.module.system.enums.permission.RoleTypeEnum; import cn.iocoder.yudao.module.system.service.permission.PermissionService; import cn.iocoder.yudao.module.system.service.permission.RoleService; import cn.iocoder.yudao.module.system.service.tenant.TenantService; +import com.alibaba.fastjson.JSONArray; import org.springframework.stereotype.Service; import javax.annotation.Resource; import org.springframework.validation.annotation.Validated; @@ -155,4 +158,19 @@ public class ServicePackageServiceImpl implements ServicePackageService { public List getServicePackageByIds(List ids){ return servicePackageMapper.selectList(new LambdaQueryWrapperX().in(ServicePackageDO::getId, ids)); } -} \ No newline at end of file + + @Override + public List getPackageListByTenantId() { + //获取当前登录用户 + LoginUser loginUser = SecurityFrameworkUtils.getLoginUser(); + Long tenantId = loginUser.getTenantId(); + TenantDO tenant = tenantService.getTenant(tenantId); + Set packageId = tenant.getPackageId(); + List ids =new ArrayList<>(); + for (String s : packageId) { + ids.add(s); + } + return this.getServicePackageByIds(ids); + + } +} From a9889e5985d7db23ae2b48492c9034969c2c96ac Mon Sep 17 00:00:00 2001 From: PQZ Date: Wed, 23 Oct 2024 17:59:24 +0800 Subject: [PATCH 3/4] 1 --- .../module/tickets/service/impl/DlTicketWaresServiceImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 feb54588..12ebf43c 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 @@ -34,7 +34,6 @@ import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Service; @@ -326,6 +325,7 @@ public class DlTicketWaresServiceImpl extends ServiceImpl Date: Wed, 23 Oct 2024 18:30:38 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E6=95=91=E6=8F=B4=E5=A4=A7=E5=B1=8F?= =?UTF-8?q?=E6=95=91=E6=8F=B4=E8=AE=A2=E5=8D=95=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin/RescueBigScreeController.java | 26 ++++++ .../rescue/mapper/RescueOrderInfoMapper.java | 2 +- .../service/IRescueOrderInfoService.java | 8 ++ .../impl/RescueOrderInfoServiceImpl.java | 91 +++++++++++++++++++ 4 files changed, 126 insertions(+), 1 deletion(-) create mode 100644 dl-module-rescue/src/main/java/cn/iocoder/yudao/module/rescue/controller/admin/RescueBigScreeController.java diff --git a/dl-module-rescue/src/main/java/cn/iocoder/yudao/module/rescue/controller/admin/RescueBigScreeController.java b/dl-module-rescue/src/main/java/cn/iocoder/yudao/module/rescue/controller/admin/RescueBigScreeController.java new file mode 100644 index 00000000..bf1d101e --- /dev/null +++ b/dl-module-rescue/src/main/java/cn/iocoder/yudao/module/rescue/controller/admin/RescueBigScreeController.java @@ -0,0 +1,26 @@ +package cn.iocoder.yudao.module.rescue.controller.admin; + +import cn.iocoder.yudao.framework.common.pojo.CommonResult; +import cn.iocoder.yudao.module.rescue.service.IRescueOrderInfoService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@RequestMapping("/rescue/bigScree") +public class RescueBigScreeController { + @Autowired + private IRescueOrderInfoService rescueOrderInfoService; + + /** + * + * @param type count 数量 money 金额 + * @param timeType day 日 month 月 year 年 + * @return + */ + @GetMapping("/getRescueOrderCount") + public CommonResult getRescueOrderCount(String type, String timeType){ + return CommonResult.success(rescueOrderInfoService.getRescueOrderCount(type,timeType)); + } +} diff --git a/dl-module-rescue/src/main/java/cn/iocoder/yudao/module/rescue/mapper/RescueOrderInfoMapper.java b/dl-module-rescue/src/main/java/cn/iocoder/yudao/module/rescue/mapper/RescueOrderInfoMapper.java index 50f38dd0..3fd66f9f 100644 --- a/dl-module-rescue/src/main/java/cn/iocoder/yudao/module/rescue/mapper/RescueOrderInfoMapper.java +++ b/dl-module-rescue/src/main/java/cn/iocoder/yudao/module/rescue/mapper/RescueOrderInfoMapper.java @@ -7,6 +7,7 @@ import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; import java.util.List; +import java.util.Map; /** * 救援订单Mapper接口 @@ -33,5 +34,4 @@ public interface RescueOrderInfoMapper extends BaseMapper */ public List selectRescueOrderInfoList(RescueOrderInfo rescueOrderInfo); Double avgPartnerScore(@Param("driverId") Long driverId); - } diff --git a/dl-module-rescue/src/main/java/cn/iocoder/yudao/module/rescue/service/IRescueOrderInfoService.java b/dl-module-rescue/src/main/java/cn/iocoder/yudao/module/rescue/service/IRescueOrderInfoService.java index 51ab1446..3709aba8 100644 --- a/dl-module-rescue/src/main/java/cn/iocoder/yudao/module/rescue/service/IRescueOrderInfoService.java +++ b/dl-module-rescue/src/main/java/cn/iocoder/yudao/module/rescue/service/IRescueOrderInfoService.java @@ -69,4 +69,12 @@ public interface IRescueOrderInfoService extends IService RescueOrderInfo getOrderByOrderNo(String orderNo); Map payNotify( JSONObject jsonObject); public void reviewOrder(String rescueId, Integer starLevel, String reviewStr) throws Exception; + + /** + * + * @param type count 数量 money 金额 + * @param timeType day 日 month 月 year 年 + * @return + */ + List> getRescueOrderCount(String type, String timeType); } diff --git a/dl-module-rescue/src/main/java/cn/iocoder/yudao/module/rescue/service/impl/RescueOrderInfoServiceImpl.java b/dl-module-rescue/src/main/java/cn/iocoder/yudao/module/rescue/service/impl/RescueOrderInfoServiceImpl.java index 1d042229..80bf1cd8 100644 --- a/dl-module-rescue/src/main/java/cn/iocoder/yudao/module/rescue/service/impl/RescueOrderInfoServiceImpl.java +++ b/dl-module-rescue/src/main/java/cn/iocoder/yudao/module/rescue/service/impl/RescueOrderInfoServiceImpl.java @@ -1,6 +1,9 @@ package cn.iocoder.yudao.module.rescue.service.impl; import cn.hutool.core.collection.CollectionUtil; +import cn.hutool.core.date.DateField; +import cn.hutool.core.date.DateTime; +import cn.hutool.core.date.DateUtil; import cn.hutool.core.util.ObjectUtil; import cn.hutool.json.JSONUtil; import cn.iocoder.yudao.module.rescue.domain.*; @@ -22,6 +25,7 @@ import org.springframework.stereotype.Service; import javax.annotation.Resource; import java.nio.charset.StandardCharsets; +import java.time.LocalDate; import java.util.*; import java.util.concurrent.locks.ReentrantLock; import java.util.stream.Collectors; @@ -313,4 +317,91 @@ public class RescueOrderInfoServiceImpl extends ServiceImpl> getRescueOrderCount(String type, String timeType) { + List> res = new ArrayList<>(); + DateTime startTime = DateUtil.date(); + DateTime endTime = new DateTime(); + List dateList = new ArrayList<>(); + switch (timeType) { + case "day": + startTime = DateUtil.beginOfDay(startTime); + endTime = DateUtil.endOfDay(endTime); + dateList = DateUtil.rangeToList(startTime, endTime, DateField.HOUR_OF_DAY); + break; + case "month": + startTime = DateUtil.beginOfMonth(startTime); + endTime = DateUtil.endOfMonth(endTime); + dateList = DateUtil.rangeToList(startTime, endTime, DateField.DAY_OF_MONTH); + break; + case "year": + startTime = DateUtil.beginOfYear(startTime); + endTime = DateUtil.endOfYear(endTime); + dateList = DateUtil.rangeToList(startTime, endTime, DateField.MONTH); + break; + } + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.between(RescueOrderInfo::getCreateTime, startTime, endTime); + queryWrapper.eq(RescueOrderInfo::getOrderStatus, "3"); + List list = this.list(queryWrapper); + for (DateTime dateTime : dateList) { + String name = ""; + switch (timeType) { + case "day": + name = dateTime.toString("HH:mm"); + break; + case "month": + name = dateTime.toString("MM-dd"); + break; + case "year": + name = dateTime.toString("YYYY-MM"); + break; + } + Map map = new HashMap<>(); + DateTime endTime1 = getEndTime(timeType, dateTime); + List rescueOrderInfos = filterOrdersByDate(list, dateTime, endTime1); + map.put("name", name); + if ("count".equals(type)) { + long count = rescueOrderInfos.stream().count(); + map.put("value", count); + }else if ("money".equals(type)) { + // 使用 stream() 计算总金额,并防止空指针异常 + long money = rescueOrderInfos.stream() + .filter(Objects::nonNull) // 过滤掉 null 对象 + .filter(order -> Objects.nonNull(order.getPayMoney())) // 过滤掉 payMoney 为 null 的对象 + .mapToLong(RescueOrderInfo::getPayMoney) // 获取支付金额 + .sum(); // 计算总和 + //将分转为元 + map.put("value", (double)money / 100); + } + res.add(map); + } + return res; + } + + public DateTime getEndTime(String timeType, DateTime startTime){ + switch (timeType) { + case "day": + return DateUtil.endOfHour(startTime); + case "month": + return DateUtil.endOfDay(startTime); + case "year": + return DateUtil.endOfMonth(startTime); + } + return null; + } + + public List filterOrdersByDate(List orders, Date startDate, Date endDate) { + return orders.stream() + .filter(order -> order.getOrderTime() != null && + !order.getOrderTime().before(startDate) && + !order.getOrderTime().after(endDate)) + .collect(Collectors.toList()); + } }