This commit is contained in:
xiaofajia 2024-10-23 21:21:13 +08:00
commit 82cbaaa890
21 changed files with 241 additions and 77 deletions

View File

@ -267,44 +267,13 @@ public class DriveSchoolInfoServiceImpl implements IDriveSchoolInfoService
*/
@Override
public DriveSchoolInfoVO getSchoolInfoByDeptId(Long deptId) {
// 记录deptId
System.out.println("Dept ID: " + deptId);
// 获取教练id
Long jlId = 0L;
// 根据当前用户的手机号获取教练信息
Long userId = SecurityFrameworkUtils.getLoginUserId();
AdminUserRespDTO sysUser = userApi.getUser(userId);
String phonenumber = sysUser.getMobile();
System.out.println("当前用户手机号: " + phonenumber);
// 获取教练信息
DriveSchoolCoach driveSchoolCoach = driveSchoolCoachMapper.selectByPhonenumber(phonenumber);
if (driveSchoolCoach != null) {
jlId = driveSchoolCoach.getId();
System.out.println("教练ID: " + jlId);
} else {
System.err.println("未找到手机号为 " + phonenumber + " 的教练信息");
// 可以选择抛出异常或返回默认值
}
// 获取驾校信息
DriveSchoolInfoVO schoolInfoByDeptId = driveSchoolInfoMapper.getSchoolInfoByDeptId(deptId);
if (schoolInfoByDeptId != null) {
schoolInfoByDeptId.setJlId(jlId);
} else {
System.err.println("未找到部门 ID 为 " + deptId + " 的驾校信息");
throw new RuntimeException("未找到指定部门的驾校信息");
}
return schoolInfoByDeptId;
}
@Override
public List<PayVo> findSelfSchoolData() {
@ -319,15 +288,6 @@ public class DriveSchoolInfoServiceImpl implements IDriveSchoolInfoService
return payVoList;
}
/*@Override
public DriveSchoolInfo selectDriveSchoolInfoAppletById(Long id) {
DriveSchoolInfo driveSchoolInfo = driveSchoolInfoMapper.selectDriveSchoolInfoById(id);
double lat = driveSchoolInfo1.getLat().doubleValue();
double lgt = driveSchoolInfo1.getLgt().doubleValue();
double distance = calculateDistance(driveSchoolInfo.getLat().doubleValue(), driveSchoolInfo.getLgt().doubleValue(), lat, lgt);
driveSchoolInfo1.setDistance(distance/1000);
return null;
}*/
/**
* 计算两个经纬度之间的距离

View File

@ -152,7 +152,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="getSchoolInfoByDeptId" parameterType="Long" resultMap="DriveSchoolInfoVOResult">
<include refid="selectDriveSchoolInfoVo"/>
where deleted = 0 and dept_id = #{deptId}
where deleted = 0
</select>

View File

@ -128,6 +128,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
AND list_order = #{driveSchoolSwiper.listOrder}
</if>
</if>
</where>
ORDER BY list_order ASC
</select>

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
@ -198,6 +198,21 @@ public class DlRepairSoServiceImpl extends ServiceImpl<DlRepairSoMapper, DlRepai
// 查子表
List<DlRepairSoi> list = repairSoiService.list(new LambdaQueryWrapper<DlRepairSoi>().eq(DlRepairSoi::getSoId, result.getId()));
if(!list.isEmpty()){
//所有有配件的分类
List<Map<String,String>> typeMapList = waresService.getAllTypeList();
Map<String,String> typeMap = new HashMap<>();
for(Map<String,String> map:typeMapList){
typeMap.put(map.get("id"),map.get("name"));
}
//关联查配件信息
List<RepairWares> repairWaresList = waresService.listByIds(list.stream().map(DlRepairSoi::getGoodsId).collect(Collectors.toList()));
Map<String,RepairWares> waresMap = repairWaresList.stream().collect(Collectors.toMap(RepairWares::getId, Function.identity()));
list.forEach(item->{
item.setWares(waresMap.get(item.getGoodsId()));
item.setTypeName(typeMap.get(item.getWares().getType()));
});
}
result.setGoodsList(list);
return result;
}

View File

@ -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<DlTicketWaresMapper, D
@Override
@DSTransactional
public void passTicketWares(DlTicketWaresRespVO respVO) {
respVO.getRepairSo().setSoTime(new Date());
// 把单据类型先取出来02是领料04是退料
String type = respVO.getRepairSo().getSoType();
// 查工单子表中的配件信息

View File

@ -25,40 +25,43 @@
<result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
<result property="updater" column="updater" jdbcType="VARCHAR"/>
<result property="twId" column="tw_id" />
<result property="licenseNumber" column="license_number" />
</resultMap>
<sql id="Base_SQL">
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'
</sql>
<select id="getRepairSoPage" resultMap="BaseResultMap">
<include refid="Base_SQL"/>
<if test="map.soType != null and map.soType">
and so_type = #{map.soType}
and so.so_type = #{map.soType}
</if>
<if test="map.purchaseType != null and map.purchaseType != ''">
and purchase_type = #{map.purchaseType}
and so.purchase_type = #{map.purchaseType}
</if>
<if test="map.soStatus != null and map.soStatus != ''">
and so.so_status = #{map.soStatus}

View File

@ -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));
}
}

View File

@ -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<RescueOrderInfo>
*/
public List<RescueOrderInfo> selectRescueOrderInfoList(RescueOrderInfo rescueOrderInfo);
Double avgPartnerScore(@Param("driverId") Long driverId);
}

View File

@ -69,4 +69,12 @@ public interface IRescueOrderInfoService extends IService<RescueOrderInfo>
RescueOrderInfo getOrderByOrderNo(String orderNo);
Map<String, String> 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<Map<String, Object>> getRescueOrderCount(String type, String timeType);
}

View File

@ -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<RescueOrderInfoMappe
driverInfoService.updateById(driverInfo);
}
}
/**
* @param type count 数量 money 金额
* @param timeType day month year
* @return
*/
@Override
public List<Map<String, Object>> getRescueOrderCount(String type, String timeType) {
List<Map<String, Object>> res = new ArrayList<>();
DateTime startTime = DateUtil.date();
DateTime endTime = new DateTime();
List<DateTime> 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<RescueOrderInfo> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.between(RescueOrderInfo::getCreateTime, startTime, endTime);
queryWrapper.eq(RescueOrderInfo::getOrderStatus, "3");
List<RescueOrderInfo> 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<String, Object> map = new HashMap<>();
DateTime endTime1 = getEndTime(timeType, dateTime);
List<RescueOrderInfo> 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<RescueOrderInfo> filterOrdersByDate(List<RescueOrderInfo> orders, Date startDate, Date endDate) {
return orders.stream()
.filter(order -> order.getOrderTime() != null &&
!order.getOrderTime().before(startDate) &&
!order.getOrderTime().after(endDate))
.collect(Collectors.toList());
}
}

3
sql/增量DB.sql Normal file
View File

@ -0,0 +1,3 @@
--
ALTER TABLE `system_service_package`
ADD COLUMN `cover_img` varchar(255) NULL COMMENT '服务icon' AFTER `menu_ids`;

View File

@ -88,5 +88,9 @@ public class ServicePackageController {
List<ServicePackageDO> list = servicePackageService.getServicePackageListByStatus(CommonStatusEnum.ENABLE.getStatus());
return success(BeanUtils.toBean(list, ServicePackageSimpleRespVO.class));
}
}
@GetMapping({"/getPackageListByTenantId"})
public CommonResult<List<ServicePackageDO>> getPackageListByTenantId() {
List<ServicePackageDO> list = servicePackageService.getPackageListByTenantId();
return success(list);
}
}

View File

@ -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;
}
}

View File

@ -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<Long> menuIds;
}
}

View File

@ -17,4 +17,5 @@ public class ServicePackageSimpleRespVO {
@NotNull(message = "套餐名不能为空")
private String name;
}

View File

@ -40,10 +40,11 @@ public class ServicePackageDO extends BaseDO {
* 备注
*/
private String remark;
private String coverImg;
/**
* 关联的菜单编号
*/
@TableField(typeHandler = JacksonTypeHandler.class)
private Set<Long> menuIds;
}
}

View File

@ -29,4 +29,7 @@ public interface ServicePackageMapper extends BaseMapperX<ServicePackageDO> {
default List<ServicePackageDO> selectListByStatus(Integer status) {
return selectList(ServicePackageDO::getStatus, status);
}
}
List<ServicePackageDO> getPackageListByTenantId();
}

View File

@ -78,4 +78,14 @@ public interface ServicePackageService {
* @param ids ids
**/
List<ServicePackageDO> getServicePackageByIds(List<String> ids);
}
/**
* 查租户服务
*
* @author zcy
* @date 10:37 2024/9/24
**/
List<ServicePackageDO> getPackageListByTenantId();
}

View File

@ -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<ServicePackageDO> getServicePackageByIds(List<String> ids){
return servicePackageMapper.selectList(new LambdaQueryWrapperX<ServicePackageDO>().in(ServicePackageDO::getId, ids));
}
}
@Override
public List<ServicePackageDO> getPackageListByTenantId() {
//获取当前登录用户
LoginUser loginUser = SecurityFrameworkUtils.getLoginUser();
Long tenantId = loginUser.getTenantId();
TenantDO tenant = tenantService.getTenant(tenantId);
Set<String> packageId = tenant.getPackageId();
List<String> ids =new ArrayList<>();
for (String s : packageId) {
ids.add(s);
}
return this.getServicePackageByIds(ids);
}
}