Commit 3f54bac9 by 杨浩

对账权限控制;

日期格式化;
parent d4a9d030
package cn.iocoder.foodnexus.framework.common.util.json.databind;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.deser.std.StdDeserializer;
import java.io.IOException;
import java.time.Instant;
import java.time.LocalDate;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.time.format.DateTimeParseException;
/**
* @author : yanghao
* create at: 2025/11/4 10:29
* @description:
*/
public class FlexibleLocalDateDeserializer extends StdDeserializer<LocalDate> {
// 定义日期字符串格式(与前端保持一致)
private static final DateTimeFormatter DATE_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd");
// 时区(默认北京时间)
private static final ZoneId ZONE_ID = ZoneId.of("GMT+8");
public FlexibleLocalDateDeserializer() {
super(LocalDate.class);
}
@Override
public LocalDate deserialize(JsonParser p, DeserializationContext ctxt) throws IOException {
String value = p.getValueAsString();
if (value == null || value.trim().isEmpty()) {
return null; // 允许空值
}
// 尝试解析时间戳(Long类型)
try {
long timestamp = Long.parseLong(value.trim());
// 时间戳转LocalDate(先转Instant,再转指定时区的LocalDate)
return Instant.ofEpochMilli(timestamp)
.atZone(ZONE_ID)
.toLocalDate();
} catch (NumberFormatException e) {
// 时间戳解析失败,尝试解析日期字符串
try {
return LocalDate.parse(value.trim(), DATE_FORMATTER);
} catch (DateTimeParseException ex) {
// 两种格式都失败,抛出异常(包含具体错误信息)
throw new IOException("无法解析LocalDate:" + value + ",支持格式:时间戳(毫秒)或 yyyy-MM-dd", ex);
}
}
}
}
package cn.iocoder.foodnexus.framework.common.util.json.databind;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.deser.std.StdDeserializer;
import java.io.IOException;
import java.time.Instant;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;
import java.time.format.DateTimeParseException;
/**
* @author : yanghao
* create at: 2025/11/4 10:22
* @description:
*/
public class FlexibleLocalDateTimeDeserializer extends StdDeserializer<LocalDateTime> {
private static final DateTimeFormatter DATETIME_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
private static final ZoneId DEFAULT_ZONE = ZoneId.of("GMT+8");
public FlexibleLocalDateTimeDeserializer() {
super(LocalDateTime.class);
}
@Override
public LocalDateTime deserialize(JsonParser p, DeserializationContext ctxt) throws IOException {
String value = p.getValueAsString();
if (value == null || value.trim().isEmpty()) {
return null;
}
value = value.trim();
// 1. 尝试解析时间戳(毫秒级)
try {
long timestamp = Long.parseLong(value);
return Instant.ofEpochMilli(timestamp).atZone(DEFAULT_ZONE).toLocalDateTime();
} catch (NumberFormatException e) {
// 2. 尝试解析 ISO 8601 格式(带 Z 或时区偏移)
try {
ZonedDateTime zonedDateTime = ZonedDateTime.parse(value);
return zonedDateTime.withZoneSameInstant(DEFAULT_ZONE).toLocalDateTime();
} catch (DateTimeParseException ex) {
// 3. 尝试解析 yyyy-MM-dd HH:mm:ss 字符串格式
try {
return LocalDateTime.parse(value, DATETIME_FORMATTER);
} catch (DateTimeParseException exc) {
throw new IOException(
"无法解析LocalDateTime:" + value +
",支持格式:时间戳(毫秒)、yyyy-MM-dd HH:mm:ss、ISO 8601(如 2025-11-04T06:00:00.000Z)",
exc
);
}
}
}
}
}
...@@ -2,9 +2,7 @@ package cn.iocoder.foodnexus.framework.jackson.config; ...@@ -2,9 +2,7 @@ package cn.iocoder.foodnexus.framework.jackson.config;
import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollUtil;
import cn.iocoder.foodnexus.framework.common.util.json.JsonUtils; import cn.iocoder.foodnexus.framework.common.util.json.JsonUtils;
import cn.iocoder.foodnexus.framework.common.util.json.databind.NumberSerializer; import cn.iocoder.foodnexus.framework.common.util.json.databind.*;
import cn.iocoder.foodnexus.framework.common.util.json.databind.TimestampLocalDateTimeDeserializer;
import cn.iocoder.foodnexus.framework.common.util.json.databind.TimestampLocalDateTimeSerializer;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.module.SimpleModule; import com.fasterxml.jackson.databind.module.SimpleModule;
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateDeserializer; import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateDeserializer;
...@@ -34,12 +32,12 @@ public class FoodnexusJacksonAutoConfiguration { ...@@ -34,12 +32,12 @@ public class FoodnexusJacksonAutoConfiguration {
.addSerializer(Long.class, NumberSerializer.INSTANCE) .addSerializer(Long.class, NumberSerializer.INSTANCE)
.addSerializer(Long.TYPE, NumberSerializer.INSTANCE) .addSerializer(Long.TYPE, NumberSerializer.INSTANCE)
.addSerializer(LocalDate.class, LocalDateSerializer.INSTANCE) .addSerializer(LocalDate.class, LocalDateSerializer.INSTANCE)
.addDeserializer(LocalDate.class, LocalDateDeserializer.INSTANCE) .addDeserializer(LocalDate.class, new FlexibleLocalDateDeserializer())
.addSerializer(LocalTime.class, LocalTimeSerializer.INSTANCE) .addSerializer(LocalTime.class, LocalTimeSerializer.INSTANCE)
.addDeserializer(LocalTime.class, LocalTimeDeserializer.INSTANCE) .addDeserializer(LocalTime.class, LocalTimeDeserializer.INSTANCE)
// 新增 LocalDateTime 序列化、反序列化规则,使用 Long 时间戳 // 新增 LocalDateTime 序列化、反序列化规则,使用 Long 时间戳
.addSerializer(LocalDateTime.class, TimestampLocalDateTimeSerializer.INSTANCE) .addSerializer(LocalDateTime.class, TimestampLocalDateTimeSerializer.INSTANCE)
.addDeserializer(LocalDateTime.class, TimestampLocalDateTimeDeserializer.INSTANCE); .addDeserializer(LocalDateTime.class, new FlexibleLocalDateTimeDeserializer());
// 1.2 注册到 objectMapper // 1.2 注册到 objectMapper
objectMappers.forEach(objectMapper -> objectMapper.registerModule(simpleModule)); objectMappers.forEach(objectMapper -> objectMapper.registerModule(simpleModule));
......
...@@ -5,7 +5,9 @@ import jakarta.validation.Valid; ...@@ -5,7 +5,9 @@ import jakarta.validation.Valid;
import jakarta.validation.constraints.NotNull; import jakarta.validation.constraints.NotNull;
import java.util.Collection; import java.util.Collection;
import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set;
/** /**
* @author : yanghao * @author : yanghao
...@@ -28,4 +30,6 @@ public interface ErpCustomerApi { ...@@ -28,4 +30,6 @@ public interface ErpCustomerApi {
String queryNameStrById(Long customerId); String queryNameStrById(Long customerId);
Integer queryCustomerTypeByUserId(Long userId); Integer queryCustomerTypeByUserId(Long userId);
Set<Long> queryCustomerDeptIdsByUserId(Long userId);
} }
package cn.iocoder.foodnexus.module.erp.controller.admin.purchase.vo.order; package cn.iocoder.foodnexus.module.erp.controller.admin.purchase.vo.order;
import cn.idev.excel.annotation.ExcelProperty; import cn.idev.excel.annotation.ExcelProperty;
import cn.iocoder.foodnexus.framework.common.enums.CheckTaskStatus;
import cn.iocoder.foodnexus.framework.common.pojo.PageParam; import cn.iocoder.foodnexus.framework.common.pojo.PageParam;
import cn.iocoder.foodnexus.framework.common.validation.InEnum; import cn.iocoder.foodnexus.framework.common.validation.InEnum;
import cn.iocoder.foodnexus.module.erp.api.enums.ErpDeliveryStatus; import cn.iocoder.foodnexus.module.erp.api.enums.ErpDeliveryStatus;
...@@ -106,6 +107,13 @@ public class ErpPurchaseOrderPageReqVO extends PageParam { ...@@ -106,6 +107,13 @@ public class ErpPurchaseOrderPageReqVO extends PageParam {
@InEnum(ErpDeliveryStatus.class) @InEnum(ErpDeliveryStatus.class)
private String deliveryStatus; private String deliveryStatus;
@Schema(description = "质检状态")
@InEnum(CheckTaskStatus.class)
private String checkTaskStatus;
@Schema(description = "质检状态")
private List<String> checkTaskStatusList;
@Schema(description = "配送模式") @Schema(description = "配送模式")
private DeliveryMode deliveryMode; private DeliveryMode deliveryMode;
......
...@@ -58,6 +58,8 @@ public interface ErpPurchaseOrderMapper extends BaseMapperX<ErpPurchaseOrderDO> ...@@ -58,6 +58,8 @@ public interface ErpPurchaseOrderMapper extends BaseMapperX<ErpPurchaseOrderDO>
.eqIfPresent(ErpPurchaseOrderDO::getCreator, reqVO.getCreator()) .eqIfPresent(ErpPurchaseOrderDO::getCreator, reqVO.getCreator())
.eqIfPresent(ErpPurchaseOrderDO::getDeliveryStatus, reqVO.getDeliveryStatus()) .eqIfPresent(ErpPurchaseOrderDO::getDeliveryStatus, reqVO.getDeliveryStatus())
.inIfPresent(ErpPurchaseOrderDO::getDeliveryStatus, reqVO.getDeliveryStatusList()) .inIfPresent(ErpPurchaseOrderDO::getDeliveryStatus, reqVO.getDeliveryStatusList())
.eqIfPresent(ErpPurchaseOrderDO::getCheckTaskStatus, reqVO.getCheckTaskStatus())
.inIfPresent(ErpPurchaseOrderDO::getCheckTaskStatus, reqVO.getCheckTaskStatusList())
.eqIfPresent(ErpPurchaseOrderDO::getCustomerOrderId, reqVO.getCustomerOrderId()) .eqIfPresent(ErpPurchaseOrderDO::getCustomerOrderId, reqVO.getCustomerOrderId())
.orderByDesc(ErpPurchaseOrderDO::getId); .orderByDesc(ErpPurchaseOrderDO::getId);
// 入库状态。为什么需要 t. 的原因,是因为联表查询时,需要指定表名,不然会报 in_count 错误 // 入库状态。为什么需要 t. 的原因,是因为联表查询时,需要指定表名,不然会报 in_count 错误
......
...@@ -3,7 +3,9 @@ package cn.iocoder.foodnexus.module.erp.dal.redis.no; ...@@ -3,7 +3,9 @@ package cn.iocoder.foodnexus.module.erp.dal.redis.no;
import cn.hutool.core.date.DatePattern; import cn.hutool.core.date.DatePattern;
import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.DateUtil;
import cn.iocoder.foodnexus.module.erp.dal.redis.RedisKeyConstants; import cn.iocoder.foodnexus.module.erp.dal.redis.RedisKeyConstants;
import cn.iocoder.foodnexus.module.system.util.GenCodeUtils;
import jakarta.annotation.Resource; import jakarta.annotation.Resource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate; import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
...@@ -77,6 +79,9 @@ public class ErpNoRedisDAO { ...@@ -77,6 +79,9 @@ public class ErpNoRedisDAO {
@Resource @Resource
private StringRedisTemplate stringRedisTemplate; private StringRedisTemplate stringRedisTemplate;
@Autowired
private GenCodeUtils genCodeUtils;
/** /**
* 生成序号,使用当前日期,格式为 {PREFIX} + yyyyMMdd + 6 位自增 * 生成序号,使用当前日期,格式为 {PREFIX} + yyyyMMdd + 6 位自增
* 例如说:QTRK 202109 000001 (没有中间空格) * 例如说:QTRK 202109 000001 (没有中间空格)
...@@ -85,13 +90,14 @@ public class ErpNoRedisDAO { ...@@ -85,13 +90,14 @@ public class ErpNoRedisDAO {
* @return 序号 * @return 序号
*/ */
public String generate(String prefix) { public String generate(String prefix) {
// 递增序号 return genCodeUtils.createAmBatch(prefix);
/*// 递增序号
String noPrefix = prefix + DateUtil.format(LocalDateTime.now(), DatePattern.PURE_DATE_PATTERN); String noPrefix = prefix + DateUtil.format(LocalDateTime.now(), DatePattern.PURE_DATE_PATTERN);
String key = RedisKeyConstants.NO + noPrefix; String key = RedisKeyConstants.NO + noPrefix;
Long no = stringRedisTemplate.opsForValue().increment(key); Long no = stringRedisTemplate.opsForValue().increment(key);
// 设置过期时间 // 设置过期时间
stringRedisTemplate.expire(key, Duration.ofDays(1L)); stringRedisTemplate.expire(key, Duration.ofDays(1L));
return noPrefix + random() + String.format("%06d", no); return noPrefix + random() + String.format("%06d", no);*/
} }
private int random() { private int random() {
......
...@@ -20,21 +20,20 @@ import cn.iocoder.foodnexus.module.erp.service.stock.ErpWarehouseService; ...@@ -20,21 +20,20 @@ import cn.iocoder.foodnexus.module.erp.service.stock.ErpWarehouseService;
import cn.iocoder.foodnexus.module.system.dal.dataobject.dept.DeptDO; import cn.iocoder.foodnexus.module.system.dal.dataobject.dept.DeptDO;
import cn.iocoder.foodnexus.module.system.dal.dataobject.user.AdminUserDO; import cn.iocoder.foodnexus.module.system.dal.dataobject.user.AdminUserDO;
import cn.iocoder.foodnexus.framework.common.enums.UserSystemEnum; import cn.iocoder.foodnexus.framework.common.enums.UserSystemEnum;
import cn.iocoder.foodnexus.module.system.dal.redis.RedisKeyConstants;
import cn.iocoder.foodnexus.module.system.service.dept.DeptService; import cn.iocoder.foodnexus.module.system.service.dept.DeptService;
import cn.iocoder.foodnexus.module.system.service.user.AdminUserService; import cn.iocoder.foodnexus.module.system.service.user.AdminUserService;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
import jakarta.annotation.Resource; import jakarta.annotation.Resource;
import org.apache.commons.compress.utils.Lists; import org.apache.commons.compress.utils.Lists;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.context.annotation.Lazy; import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import java.util.Collection; import java.util.*;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import static cn.iocoder.foodnexus.framework.common.exception.util.ServiceExceptionUtil.exception; import static cn.iocoder.foodnexus.framework.common.exception.util.ServiceExceptionUtil.exception;
import static cn.iocoder.foodnexus.module.erp.enums.ErrorCodeConstants.*; import static cn.iocoder.foodnexus.module.erp.enums.ErrorCodeConstants.*;
...@@ -276,4 +275,24 @@ public class ErpCustomerServiceImpl implements ErpCustomerService, ErpCustomerAp ...@@ -276,4 +275,24 @@ public class ErpCustomerServiceImpl implements ErpCustomerService, ErpCustomerAp
} }
return CustomerTypeEnum.CHIEF.getKey(); return CustomerTypeEnum.CHIEF.getKey();
} }
@Override
public Set<Long> queryCustomerDeptIdsByUserId(Long userId) {
AdminUserDO user = userService.getUser(userId);
if (!UserSystemEnum.CUSTOMER.getKey().equals(user.getUserSystem())) {
throw exception(ERROR_CUSTOMER_USER);
}
DeptDO topDept = deptService.getTopDept(user.getDeptId());
ErpCustomerDO customer = customerMapper.selectOne(ErpCustomerDO::getSystemDeptId, topDept.getId());
if (CommonUtil.isEmpty(customer)) {
throw exception(CUSTOMER_NOT_EXISTS);
}
if (CommonStatusEnum.isDisable(customer.getStatus())) {
throw exception(CUSTOMER_NOT_ENABLE, customer.getName());
}
Set<Long> deptIds = deptService.getChildDeptIdListFromCache(user.getDeptId());
deptIds.add(user.getDeptId());
return deptIds;
}
} }
...@@ -136,6 +136,18 @@ public class CheckTaskController { ...@@ -136,6 +136,18 @@ public class CheckTaskController {
return success(checkTaskService.queryScore(id)); return success(checkTaskService.queryScore(id));
} }
@GetMapping("query-checktask-and-score")
@Operation(summary = "根据采购订单id获取质检报告和评价")
@Parameter(name = "purchaseOrderId", description = "采购订单id", required = true)
public CommonResult<CheckTaskWithScoreRespVO> queryCheckTaskAndScore(@RequestParam("purchaseOrderId") Long purchaseOrderId) {
CheckTaskDO checkTaskDO = checkTaskService.queryScorebyPurchaseOrderId(purchaseOrderId);
if (CommonUtil.isNotEmpty(checkTaskDO)) {
return success(new CheckTaskWithScoreRespVO(
this.getCheckTask(checkTaskDO.getId()).getData(), this.queryScore(checkTaskDO.getId()).getData()));
}
return success(null);
}
@GetMapping("/export-excel") @GetMapping("/export-excel")
@Operation(summary = "导出来料质检 Excel") @Operation(summary = "导出来料质检 Excel")
@PreAuthorize("@ss.hasPermission('order:check-task:export')") @PreAuthorize("@ss.hasPermission('order:check-task:export')")
......
package cn.iocoder.foodnexus.module.order.controller.admin.checktask.vo;
import lombok.AllArgsConstructor;
import lombok.Data;
/**
* @author : yanghao
* create at: 2025/11/3 18:06
* @description:
*/
@Data
@AllArgsConstructor
public class CheckTaskWithScoreRespVO {
private CheckTaskRespVO checkTask;
private CheckTaskSupplierScoreRespVO score;
}
...@@ -40,7 +40,6 @@ public class OrderScoreController { ...@@ -40,7 +40,6 @@ public class OrderScoreController {
@GetMapping("/supplier/page") @GetMapping("/supplier/page")
@Operation(summary = "获得订单评价分页") @Operation(summary = "获得订单评价分页")
@PreAuthorize("@ss.hasPermission('order:score:query')")
public CommonResult<PageResult<OrderScoreSupplierRespVO>> supplierPage(@Valid OrderScoreSupplierPageReqVO pageReqVO) { public CommonResult<PageResult<OrderScoreSupplierRespVO>> supplierPage(@Valid OrderScoreSupplierPageReqVO pageReqVO) {
return success(scoreService.supplierPage(pageReqVO)); return success(scoreService.supplierPage(pageReqVO));
} }
......
...@@ -24,6 +24,7 @@ import io.swagger.v3.oas.annotations.Parameter; ...@@ -24,6 +24,7 @@ import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource; import jakarta.annotation.Resource;
import jakarta.validation.Valid; import jakarta.validation.Valid;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
...@@ -40,6 +41,7 @@ import static cn.iocoder.foodnexus.framework.security.core.util.SecurityFramewor ...@@ -40,6 +41,7 @@ import static cn.iocoder.foodnexus.framework.security.core.util.SecurityFramewor
@RequestMapping("/order/customer-order") @RequestMapping("/order/customer-order")
@Validated @Validated
@AppSystemAuth(UserSystemEnum.CUSTOMER) @AppSystemAuth(UserSystemEnum.CUSTOMER)
@Slf4j
public class AppCustomerOrderController { public class AppCustomerOrderController {
@Resource @Resource
......
...@@ -3,6 +3,8 @@ package cn.iocoder.foodnexus.module.order.controller.app.customerOrder; ...@@ -3,6 +3,8 @@ package cn.iocoder.foodnexus.module.order.controller.app.customerOrder;
import cn.iocoder.foodnexus.framework.common.enums.UserSystemEnum; import cn.iocoder.foodnexus.framework.common.enums.UserSystemEnum;
import cn.iocoder.foodnexus.framework.common.pojo.CommonResult; import cn.iocoder.foodnexus.framework.common.pojo.CommonResult;
import cn.iocoder.foodnexus.framework.common.pojo.PageResult; import cn.iocoder.foodnexus.framework.common.pojo.PageResult;
import cn.iocoder.foodnexus.framework.common.util.CommonUtil;
import cn.iocoder.foodnexus.module.erp.api.service.ErpCustomerApi;
import cn.iocoder.foodnexus.module.order.controller.app.customerOrder.vo.AppCustomerMonthOrderRespVO; import cn.iocoder.foodnexus.module.order.controller.app.customerOrder.vo.AppCustomerMonthOrderRespVO;
import cn.iocoder.foodnexus.module.order.controller.app.customerOrder.vo.AppCustomerMonthOrderTotalRespVO; import cn.iocoder.foodnexus.module.order.controller.app.customerOrder.vo.AppCustomerMonthOrderTotalRespVO;
import cn.iocoder.foodnexus.module.order.controller.app.customerOrder.vo.AppCustomerOrderReconciliationReqVO; import cn.iocoder.foodnexus.module.order.controller.app.customerOrder.vo.AppCustomerOrderReconciliationReqVO;
...@@ -18,7 +20,11 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -18,7 +20,11 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.util.Set;
import static cn.iocoder.foodnexus.framework.common.pojo.CommonResult.success; import static cn.iocoder.foodnexus.framework.common.pojo.CommonResult.success;
import static cn.iocoder.foodnexus.framework.security.core.util.SecurityFrameworkUtils.getLoginUser;
import static cn.iocoder.foodnexus.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
/** /**
* @author : yanghao * @author : yanghao
...@@ -35,9 +41,16 @@ public class AppCustomerOrderReconciliationController { ...@@ -35,9 +41,16 @@ public class AppCustomerOrderReconciliationController {
@Autowired @Autowired
private CustomerOrderService customerOrderService; private CustomerOrderService customerOrderService;
@Autowired
private ErpCustomerApi customerApi;
@GetMapping("/page-year") @GetMapping("/page-year")
@Operation(summary = "分页获取月度账单(按年份)") @Operation(summary = "分页获取月度账单(按年份)")
public CommonResult<AppCustomerMonthOrderRespVO> pageYear(@Valid AppCustomerYearOrderPageReqVO reqVO) { public CommonResult<AppCustomerMonthOrderRespVO> pageYear(@Valid AppCustomerYearOrderPageReqVO reqVO) {
reqVO.setDeptIds(customerApi.queryCustomerDeptIdsByUserId(getLoginUserId()));
if (CommonUtil.isEmpty(reqVO.getDeptIds())) {
return success(null);
}
return success(customerOrderService.reconciliationPageYear(reqVO)); return success(customerOrderService.reconciliationPageYear(reqVO));
} }
...@@ -45,7 +58,8 @@ public class AppCustomerOrderReconciliationController { ...@@ -45,7 +58,8 @@ public class AppCustomerOrderReconciliationController {
@Operation(summary = "分页获取客户订单(按月份)") @Operation(summary = "分页获取客户订单(按月份)")
@Parameter(name = "yearMonth", description = "年月(yyyy-MM)", required = true) @Parameter(name = "yearMonth", description = "年月(yyyy-MM)", required = true)
public CommonResult<AppCustomerMonthOrderTotalRespVO> monthTotal(@RequestParam("yearMonth") String yearMonth) { public CommonResult<AppCustomerMonthOrderTotalRespVO> monthTotal(@RequestParam("yearMonth") String yearMonth) {
return success(customerOrderService.monthTotal(yearMonth)); Set<Long> deptIds = customerApi.queryCustomerDeptIdsByUserId(getLoginUserId());
return success(customerOrderService.monthTotal(yearMonth, deptIds));
} }
@PostMapping("/confirm") @PostMapping("/confirm")
......
...@@ -2,6 +2,7 @@ package cn.iocoder.foodnexus.module.order.controller.app.customerOrder.vo; ...@@ -2,6 +2,7 @@ package cn.iocoder.foodnexus.module.order.controller.app.customerOrder.vo;
import cn.iocoder.foodnexus.framework.common.validation.InEnum; import cn.iocoder.foodnexus.framework.common.validation.InEnum;
import cn.iocoder.foodnexus.module.order.enums.DeliveryMode; import cn.iocoder.foodnexus.module.order.enums.DeliveryMode;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.Valid; import jakarta.validation.Valid;
import jakarta.validation.constraints.NotEmpty; import jakarta.validation.constraints.NotEmpty;
......
...@@ -7,6 +7,9 @@ import jakarta.validation.constraints.Min; ...@@ -7,6 +7,9 @@ import jakarta.validation.constraints.Min;
import jakarta.validation.constraints.NotNull; import jakarta.validation.constraints.NotNull;
import lombok.Data; import lombok.Data;
import java.util.List;
import java.util.Set;
/** /**
* @author : yanghao * @author : yanghao
* create at: 2025/10/13 14:16 * create at: 2025/10/13 14:16
...@@ -19,6 +22,9 @@ public class AppCustomerYearOrderPageReqVO extends PageParam { ...@@ -19,6 +22,9 @@ public class AppCustomerYearOrderPageReqVO extends PageParam {
@NotNull(message = "年份不能为空") @NotNull(message = "年份不能为空")
private String year; private String year;
@Schema(description = "客户灶点集合", hidden = true)
private Set<Long> deptIds;
/*@Schema(description = "月份(1-12)") /*@Schema(description = "月份(1-12)")
@Max(value = 12, message = "异常月份") @Max(value = 12, message = "异常月份")
@Min(value = 1, message = "异常月份") @Min(value = 1, message = "异常月份")
......
...@@ -87,7 +87,7 @@ public interface CustomerOrderMapper extends BaseMapperX<CustomerOrderDO> { ...@@ -87,7 +87,7 @@ public interface CustomerOrderMapper extends BaseMapperX<CustomerOrderDO> {
return this.selectMaps(queryWrapper); return this.selectMaps(queryWrapper);
} }
default AppCustomerMonthOrderRespVO reconciliationPageYearTotal(String year) { default AppCustomerMonthOrderRespVO reconciliationPageYearTotal(String year, Set<Long> deptIds) {
year = year.trim(); year = year.trim();
String begin = year + "-01-01 00:00:00"; String begin = year + "-01-01 00:00:00";
String end = year + "-12-31 23:59:59"; String end = year + "-12-31 23:59:59";
...@@ -96,6 +96,7 @@ public interface CustomerOrderMapper extends BaseMapperX<CustomerOrderDO> { ...@@ -96,6 +96,7 @@ public interface CustomerOrderMapper extends BaseMapperX<CustomerOrderDO> {
queryWrapperX.between("create_time", begin, end); queryWrapperX.between("create_time", begin, end);
queryWrapperX.in("order_status", CommonUtil.asList(CustomerOrderStatus.SIGN_RECEIPT.getKey(), queryWrapperX.in("order_status", CommonUtil.asList(CustomerOrderStatus.SIGN_RECEIPT.getKey(),
CustomerOrderStatus.FINISH.getKey())); CustomerOrderStatus.FINISH.getKey()));
queryWrapperX.in("customer_dept_id", deptIds);
return this.selectJoinOne(AppCustomerMonthOrderRespVO.class, queryWrapperX); return this.selectJoinOne(AppCustomerMonthOrderRespVO.class, queryWrapperX);
} }
...@@ -109,6 +110,7 @@ public interface CustomerOrderMapper extends BaseMapperX<CustomerOrderDO> { ...@@ -109,6 +110,7 @@ public interface CustomerOrderMapper extends BaseMapperX<CustomerOrderDO> {
queryWrapperX.between("create_time", begin, end); queryWrapperX.between("create_time", begin, end);
queryWrapperX.in("order_status", CommonUtil.asList(CustomerOrderStatus.SIGN_RECEIPT.getKey(), queryWrapperX.in("order_status", CommonUtil.asList(CustomerOrderStatus.SIGN_RECEIPT.getKey(),
CustomerOrderStatus.FINISH.getKey())); CustomerOrderStatus.FINISH.getKey()));
queryWrapperX.in("customer_dept_id", reqVO.getDeptIds());
queryWrapperX.groupBy("DATE_FORMAT(create_time, '%Y-%m') "); queryWrapperX.groupBy("DATE_FORMAT(create_time, '%Y-%m') ");
queryWrapperX.orderByDesc("id"); queryWrapperX.orderByDesc("id");
......
package cn.iocoder.foodnexus.module.order.service.checktask; package cn.iocoder.foodnexus.module.order.service.checktask;
import java.util.*; import java.util.*;
import jakarta.validation.*; import jakarta.validation.*;
import cn.iocoder.foodnexus.module.order.controller.admin.checktask.vo.*; import cn.iocoder.foodnexus.module.order.controller.admin.checktask.vo.*;
import cn.iocoder.foodnexus.module.order.dal.dataobject.checktask.CheckTaskDO; import cn.iocoder.foodnexus.module.order.dal.dataobject.checktask.CheckTaskDO;
import cn.iocoder.foodnexus.framework.common.pojo.PageResult; import cn.iocoder.foodnexus.framework.common.pojo.PageResult;
import cn.iocoder.foodnexus.framework.common.pojo.PageParam;
/** /**
* 来料质检 Service 接口 * 来料质检 Service 接口
...@@ -67,4 +67,5 @@ public interface CheckTaskService { ...@@ -67,4 +67,5 @@ public interface CheckTaskService {
CheckTaskSupplierScoreRespVO queryScore(Long id); CheckTaskSupplierScoreRespVO queryScore(Long id);
CheckTaskDO queryScorebyPurchaseOrderId(Long purchaseOrderId);
} }
\ No newline at end of file
...@@ -267,11 +267,19 @@ public class CheckTaskServiceImpl implements CheckTaskService, CheckTaskApi { ...@@ -267,11 +267,19 @@ public class CheckTaskServiceImpl implements CheckTaskService, CheckTaskApi {
return result; return result;
} }
@Override
public CheckTaskDO queryScorebyPurchaseOrderId(Long purchaseOrderId) {
return checkTaskMapper.selectOne(Wrappers.<CheckTaskDO>lambdaQuery()
.eq(CheckTaskDO::getPurchaseOrderId, purchaseOrderId)
.orderByDesc(CheckTaskDO::getId)
.last("LIMIT 1"));
}
public void score(CheckTaskDO checkTaskDO, CheckTaskSupplierScoreReqVO reqVO) { public void score(CheckTaskDO checkTaskDO, CheckTaskSupplierScoreReqVO reqVO) {
Long id = checkTaskDO.getId(); Long id = checkTaskDO.getId();
if (CommonUtil.isNotEmpty(reqVO.getItems())) { if (CommonUtil.isNotEmpty(reqVO.getItems())) {
orderScoreService.deleteByOrderId(id);
reqVO.getItems().forEach(item -> { reqVO.getItems().forEach(item -> {
if (!orderScoreService.exists(id, item.getScoreId())) {
ScoringWeightDO scoringWeight = scoringWeightService.getScoringWeight(item.getScoreId()); ScoringWeightDO scoringWeight = scoringWeightService.getScoringWeight(item.getScoreId());
OrderScoreSaveReqVO saveReqVO = new OrderScoreSaveReqVO(); OrderScoreSaveReqVO saveReqVO = new OrderScoreSaveReqVO();
saveReqVO.setOrderId(id); saveReqVO.setOrderId(id);
...@@ -282,7 +290,6 @@ public class CheckTaskServiceImpl implements CheckTaskService, CheckTaskApi { ...@@ -282,7 +290,6 @@ public class CheckTaskServiceImpl implements CheckTaskService, CheckTaskApi {
saveReqVO.setScore(item.getScore()); saveReqVO.setScore(item.getScore());
saveReqVO.setSort(scoringWeight.getSort()); saveReqVO.setSort(scoringWeight.getSort());
orderScoreService.createScore(saveReqVO); orderScoreService.createScore(saveReqVO);
}
}); });
} }
} }
......
...@@ -130,7 +130,7 @@ public interface CustomerOrderService { ...@@ -130,7 +130,7 @@ public interface CustomerOrderService {
* @param yearMonth * @param yearMonth
* @return * @return
*/ */
AppCustomerMonthOrderTotalRespVO monthTotal(String yearMonth); AppCustomerMonthOrderTotalRespVO monthTotal(String yearMonth, Set<Long> deptIds);
/** /**
* 对账确认 * 对账确认
......
...@@ -656,7 +656,7 @@ public class CustomerOrderServiceImpl implements CustomerOrderService, CustomerO ...@@ -656,7 +656,7 @@ public class CustomerOrderServiceImpl implements CustomerOrderService, CustomerO
*/ */
@Override @Override
public AppCustomerMonthOrderRespVO reconciliationPageYear(AppCustomerYearOrderPageReqVO reqVO) { public AppCustomerMonthOrderRespVO reconciliationPageYear(AppCustomerYearOrderPageReqVO reqVO) {
AppCustomerMonthOrderRespVO respVO = customerOrderMapper.reconciliationPageYearTotal(reqVO.getYear()); AppCustomerMonthOrderRespVO respVO = customerOrderMapper.reconciliationPageYearTotal(reqVO.getYear(), reqVO.getDeptIds());
if (CommonUtil.isNotEmpty(respVO)) { if (CommonUtil.isNotEmpty(respVO)) {
respVO.setPageResult(customerOrderMapper.reconciliationPageYearPage(reqVO)); respVO.setPageResult(customerOrderMapper.reconciliationPageYearPage(reqVO));
} }
...@@ -670,7 +670,7 @@ public class CustomerOrderServiceImpl implements CustomerOrderService, CustomerO ...@@ -670,7 +670,7 @@ public class CustomerOrderServiceImpl implements CustomerOrderService, CustomerO
* @return * @return
*/ */
@Override @Override
public AppCustomerMonthOrderTotalRespVO monthTotal(String yearMonth) { public AppCustomerMonthOrderTotalRespVO monthTotal(String yearMonth, Set<Long> deptIds) {
return customerOrderMapper.reconciliationMonthTotal(yearMonth); return customerOrderMapper.reconciliationMonthTotal(yearMonth);
} }
...@@ -683,11 +683,12 @@ public class CustomerOrderServiceImpl implements CustomerOrderService, CustomerO ...@@ -683,11 +683,12 @@ public class CustomerOrderServiceImpl implements CustomerOrderService, CustomerO
throw exception(CUSTOMER_ORDER_NOT_EXISTS); throw exception(CUSTOMER_ORDER_NOT_EXISTS);
} }
if (CustomerOrderStatus.SIGN_RECEIPT.equals(customerOrder.getOrderStatus())) { if (CustomerOrderStatus.SIGN_RECEIPT.equals(customerOrder.getOrderStatus())) {
this.updateOrderStatus(id, CustomerOrderStatus.FINISH);
// 订单记录 // 订单记录
CustomerOrderRecordEvent event = new CustomerOrderRecordEvent(); /*CustomerOrderRecordEvent event = new CustomerOrderRecordEvent();
event.setOrderStatus(CustomerOrderStatus.FINISH); event.setOrderStatus(CustomerOrderStatus.FINISH);
event.setCustomerOrderId(id); event.setCustomerOrderId(id);
orderRecordApi.recordEvent(event); orderRecordApi.recordEvent(event);*/
} }
}); });
} }
......
...@@ -20,6 +20,7 @@ import cn.iocoder.foodnexus.module.order.dal.mysql.shoppingcart.ShoppingCartMapp ...@@ -20,6 +20,7 @@ import cn.iocoder.foodnexus.module.order.dal.mysql.shoppingcart.ShoppingCartMapp
import static cn.iocoder.foodnexus.framework.common.exception.util.ServiceExceptionUtil.exception; import static cn.iocoder.foodnexus.framework.common.exception.util.ServiceExceptionUtil.exception;
import static cn.iocoder.foodnexus.framework.common.util.collection.CollectionUtils.convertList; import static cn.iocoder.foodnexus.framework.common.util.collection.CollectionUtils.convertList;
import static cn.iocoder.foodnexus.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
import static cn.iocoder.foodnexus.module.order.enums.ErrorCodeConstants.*; import static cn.iocoder.foodnexus.module.order.enums.ErrorCodeConstants.*;
/** /**
...@@ -38,6 +39,7 @@ public class ShoppingCartServiceImpl implements ShoppingCartService { ...@@ -38,6 +39,7 @@ public class ShoppingCartServiceImpl implements ShoppingCartService {
public Long createShoppingCart(ShoppingCartSaveReqVO createReqVO) { public Long createShoppingCart(ShoppingCartSaveReqVO createReqVO) {
ShoppingCartDO cart = shoppingCartMapper.selectOne(Wrappers.<ShoppingCartDO>lambdaQuery() ShoppingCartDO cart = shoppingCartMapper.selectOne(Wrappers.<ShoppingCartDO>lambdaQuery()
.eq(ShoppingCartDO::getProductId, createReqVO.getProductId()) .eq(ShoppingCartDO::getProductId, createReqVO.getProductId())
.eq(ShoppingCartDO::getCreator, getLoginUserId())
.last("LIMIT 1")); .last("LIMIT 1"));
if (CommonUtil.isNotEmpty(cart)) { if (CommonUtil.isNotEmpty(cart)) {
ShoppingCartDO updateCart = new ShoppingCartDO(); ShoppingCartDO updateCart = new ShoppingCartDO();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment