From 67a4e02e5a927681028c7c99c216b13e3efa8a21 Mon Sep 17 00:00:00 2001
From: 云 <2163098428@qq.com>
Date: 星期五, 07 八月 2026 17:28:17 +0800
Subject: [PATCH] feat(account): 增加增值税报表功能并优化设备维护流程
---
src/main/java/com/ruoyi/account/mapper/AccountStatementMapper.java | 18
src/main/java/com/ruoyi/home/mapper/HomeMapper.java | 17
src/main/java/com/ruoyi/sales/dto/SalesLedgerDto.java | 2
src/main/resources/mapper/account/AccountStatementMapper.xml | 135 +++++-
src/main/java/com/ruoyi/inspectiontask/service/impl/InspectionTaskServiceImpl.java | 54 ++
src/main/resources/mapper/sales/SalesLedgerMapper.xml | 1
src/main/java/com/ruoyi/home/controller/HomeController.java | 73 ++-
src/main/java/com/ruoyi/device/dto/DeviceMaintenanceDto.java | 3
src/main/java/com/ruoyi/purchase/service/impl/PurchaseReturnOrdersServiceImpl.java | 14
src/main/java/com/ruoyi/common/enums/SparePartsRequisitionRecordSourceTypeEnum.java | 3
src/main/java/com/ruoyi/measuringinstrumentledger/service/SparePartsRequisitionRecordService.java | 11
src/main/java/com/ruoyi/purchase/service/impl/PurchaseLedgerServiceImpl.java | 4
src/main/java/com/ruoyi/purchase/service/PurchaseReportService.java | 10
src/main/java/com/ruoyi/sales/pojo/SalesLedgerProduct.java | 10
src/main/java/com/ruoyi/sales/pojo/SalesLedger.java | 5
src/main/java/com/ruoyi/home/service/impl/HomeServiceImpl.java | 258 ++++++++---
src/main/java/com/ruoyi/sales/service/impl/SalesLedgerProductServiceImpl.java | 25
src/main/resources/mapper/sales/SalesLedgerProductMapper.xml | 53 ++
src/main/java/com/ruoyi/purchase/service/impl/PurchaseReportServiceImpl.java | 16
src/main/java/com/ruoyi/purchase/controller/AccountingReportController.java | 42 +
src/main/java/com/ruoyi/sales/service/impl/SalesLedgerServiceImpl.java | 41 -
src/main/java/com/ruoyi/device/service/impl/DeviceMaintenanceServiceImpl.java | 85 ++++
src/main/resources/application-dev.yml | 2
src/main/java/com/ruoyi/sales/controller/SalesLedgerProductController.java | 47 +
src/main/resources/mapper/home/HomeMapper.xml | 24 +
src/main/java/com/ruoyi/device/controller/DeviceMaintenanceController.java | 20
src/main/java/com/ruoyi/purchase/pojo/PurchaseLedger.java | 6
src/main/java/com/ruoyi/purchase/dto/VatDto.java | 69 +++
src/main/java/com/ruoyi/device/service/IDeviceMaintenanceService.java | 7
src/main/java/com/ruoyi/inspectiontask/pojo/InspectionTask.java | 3
src/main/java/com/ruoyi/measuringinstrumentledger/service/impl/SparePartsRequisitionRecordServiceImpl.java | 43 +
src/main/java/com/ruoyi/inspectiontask/service/InspectionTaskService.java | 8
src/main/resources/mapper/sales/ShippingInfoMapper.xml | 5
src/main/java/com/ruoyi/inspectiontask/controller/InspectionTaskController.java | 35
src/main/java/com/ruoyi/procurementrecord/service/impl/ReturnManagementServiceImpl.java | 45 -
src/main/java/com/ruoyi/home/service/HomeService.java | 14
src/main/java/com/ruoyi/measuringinstrumentledger/controller/SparePartsRequisitionRecordController.java | 20
src/main/java/com/ruoyi/sales/mapper/SalesLedgerProductMapper.java | 4
38 files changed, 869 insertions(+), 363 deletions(-)
diff --git a/src/main/java/com/ruoyi/account/mapper/AccountStatementMapper.java b/src/main/java/com/ruoyi/account/mapper/AccountStatementMapper.java
index 89730cb..7c66129 100644
--- a/src/main/java/com/ruoyi/account/mapper/AccountStatementMapper.java
+++ b/src/main/java/com/ruoyi/account/mapper/AccountStatementMapper.java
@@ -7,22 +7,20 @@
import com.ruoyi.account.bean.vo.StatementAccountVo;
import com.ruoyi.account.pojo.AccountStatement;
import com.ruoyi.purchase.dto.VatDto;
+import com.ruoyi.purchase.dto.VatSummaryDto;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
-/**
- * <p>
- * Mapper 鎺ュ彛
- * </p>
- *
- * @author 鑺杞欢锛堟睙鑻忥級鏈夐檺鍏徃
- * @since 2026-05-19 09:42:47
- */
+import java.util.List;
+
@Mapper
public interface AccountStatementMapper extends BaseMapper<AccountStatement> {
-
IPage<StatementAccountVo> listPageAccountStatement(Page page, @Param("req") StatementAccountDto statementAccountDto);
- IPage<VatDto> selectVatDtoPage(Page page, @Param("month") String month);
+ IPage<VatDto> selectVatDtoPage(Page page, @Param("month") String month, @Param("type") String type);
+
+ List<VatSummaryDto> selectVatSummary(@Param("year") String year);
+
+ IPage<VatDto> listVatDetail(Page page, @Param("month") String month);
}
diff --git a/src/main/java/com/ruoyi/common/enums/SparePartsRequisitionRecordSourceTypeEnum.java b/src/main/java/com/ruoyi/common/enums/SparePartsRequisitionRecordSourceTypeEnum.java
index b9acc40..d853453 100644
--- a/src/main/java/com/ruoyi/common/enums/SparePartsRequisitionRecordSourceTypeEnum.java
+++ b/src/main/java/com/ruoyi/common/enums/SparePartsRequisitionRecordSourceTypeEnum.java
@@ -5,7 +5,8 @@
@Getter
public enum SparePartsRequisitionRecordSourceTypeEnum implements BaseEnum<Integer> {
SparePartsRequisitionRecordSourceTypeRepair(0, "缁翠慨"),
- SparePartsRequisitionRecordSourceTypeMaintenance(1, "淇濆吇");
+ SparePartsRequisitionRecordSourceTypeMaintenance(1, "淇濆吇"),
+ SparePartsRequisitionRecordSourceTypeDirectOutbound(2, "鐩存帴鍑哄簱");
private final Integer code;
private final String value;
diff --git a/src/main/java/com/ruoyi/device/controller/DeviceMaintenanceController.java b/src/main/java/com/ruoyi/device/controller/DeviceMaintenanceController.java
index e34fc37..28e9b0d 100644
--- a/src/main/java/com/ruoyi/device/controller/DeviceMaintenanceController.java
+++ b/src/main/java/com/ruoyi/device/controller/DeviceMaintenanceController.java
@@ -2,6 +2,7 @@
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.ruoyi.device.dto.DeviceMaintenanceBatchCompleteDto;
import com.ruoyi.device.dto.DeviceMaintenanceDto;
import com.ruoyi.device.pojo.DeviceLedger;
import com.ruoyi.device.pojo.DeviceMaintenance;
@@ -12,6 +13,7 @@
import io.swagger.v3.oas.annotations.Operation;
import jakarta.servlet.http.HttpServletResponse;
import lombok.AllArgsConstructor;
+import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
import java.util.Arrays;
@@ -79,5 +81,23 @@
deviceMaintenanceService.export(response, ids);
}
+ @PostMapping("/batchComplete")
+ @Operation(summary = "涓�閿繚鍏诲畬鎴�")
+ @Transactional(rollbackFor = Exception.class)
+ public AjaxResult batchComplete(@RequestBody DeviceMaintenanceBatchCompleteDto dto) {
+ return deviceMaintenanceService.batchComplete(dto);
+ }
+
+ @PutMapping("/complete/{id}")
+ @Operation(summary = "淇濆吇瀹屾垚")
+ public AjaxResult complete(@PathVariable Long id) {
+ return deviceMaintenanceService.complete(id);
+ }
+
+ @PutMapping("/batchComplete")
+ @Operation(summary = "涓�閿繚鍏诲畬鎴�")
+ public AjaxResult batchComplete(String dateStr) {
+ return deviceMaintenanceService.batchComplete(dateStr);
+ }
}
diff --git a/src/main/java/com/ruoyi/device/dto/DeviceMaintenanceDto.java b/src/main/java/com/ruoyi/device/dto/DeviceMaintenanceDto.java
index 127d82b..81d34a0 100644
--- a/src/main/java/com/ruoyi/device/dto/DeviceMaintenanceDto.java
+++ b/src/main/java/com/ruoyi/device/dto/DeviceMaintenanceDto.java
@@ -53,5 +53,8 @@
@Schema(description = "淇濆吇鍥剧墖")
private List<StorageBlobDTO> storageBlobDTOs;
+ @Schema(description = "鏃ユ湡鍒嗙粍瀛楁(yyyy-MM-dd)")
+ private String dateStr;
+
}
diff --git a/src/main/java/com/ruoyi/device/service/IDeviceMaintenanceService.java b/src/main/java/com/ruoyi/device/service/IDeviceMaintenanceService.java
index e5a4080..3f1d770 100644
--- a/src/main/java/com/ruoyi/device/service/IDeviceMaintenanceService.java
+++ b/src/main/java/com/ruoyi/device/service/IDeviceMaintenanceService.java
@@ -3,6 +3,7 @@
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
+import com.ruoyi.device.dto.DeviceMaintenanceBatchCompleteDto;
import com.ruoyi.device.dto.DeviceMaintenanceDto;
import com.ruoyi.device.pojo.DeviceMaintenance;
import com.ruoyi.device.vo.DeviceMaintenanceVo;
@@ -21,4 +22,10 @@
void export(HttpServletResponse response, Long[] ids);
DeviceMaintenanceVo detailById(Long id);
+
+ AjaxResult batchComplete(DeviceMaintenanceBatchCompleteDto dto);
+
+ AjaxResult complete(Long id);
+
+ AjaxResult batchComplete(String dateStr);
}
diff --git a/src/main/java/com/ruoyi/device/service/impl/DeviceMaintenanceServiceImpl.java b/src/main/java/com/ruoyi/device/service/impl/DeviceMaintenanceServiceImpl.java
index fbf03ad..e426bfe 100644
--- a/src/main/java/com/ruoyi/device/service/impl/DeviceMaintenanceServiceImpl.java
+++ b/src/main/java/com/ruoyi/device/service/impl/DeviceMaintenanceServiceImpl.java
@@ -1,13 +1,16 @@
package com.ruoyi.device.service.impl;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.basic.enums.RecordTypeEnum;
import com.ruoyi.basic.utils.FileUtil;
+import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.bean.BeanUtils;
import com.ruoyi.common.utils.poi.ExcelUtil;
+import com.ruoyi.device.dto.DeviceMaintenanceBatchCompleteDto;
import com.ruoyi.device.dto.DeviceMaintenanceDto;
import com.ruoyi.device.execl.DeviceMaintenanceExeclDto;
import com.ruoyi.device.mapper.DeviceMaintenanceMapper;
@@ -27,6 +30,9 @@
import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal;
+import java.time.LocalDate;
+import java.time.LocalDateTime;
+import java.time.LocalTime;
import java.util.ArrayList;
import java.util.List;
@@ -95,6 +101,11 @@
}
}
+ // 鑻ヨ缃簡瀹為檯淇濆吇鏃ユ湡锛屽垯鑷姩鏍囪涓哄畬缁�
+ if (deviceMaintenance.getMaintenanceActuallyTime() != null && deviceMaintenance.getStatus() == null) {
+ deviceMaintenance.setStatus(1);
+ }
+
if (this.updateById(deviceMaintenance)) {
// 澶勭悊鍥剧墖涓婁紶
fileUtil.saveStorageAttachmentByRecordTypeAndRecordId("file", RecordTypeEnum.DEVICE_MAINTENANCE, deviceMaintenance.getId(), deviceMaintenance.getStorageBlobDTOs());
@@ -104,6 +115,80 @@
}
@Override
+ @Transactional(rollbackFor = Exception.class)
+ public AjaxResult complete(Long id) {
+ DeviceMaintenance record = this.getById(id);
+ if (record == null) {
+ return AjaxResult.error("淇濆吇璁板綍涓嶅瓨鍦�");
+ }
+ if (record.getStatus() != null && record.getStatus() == 1) {
+ return AjaxResult.error("璇ヤ繚鍏昏褰曞凡瀹屾垚");
+ }
+ record.setStatus(1);
+ record.setMaintenanceActuallyName(SecurityUtils.getLoginUser().getNickName());
+ record.setMaintenanceActuallyTime(LocalDateTime.now());
+ this.updateById(record);
+ return AjaxResult.success();
+ }
+
+ @Override
+ @Transactional(rollbackFor = Exception.class)
+ public AjaxResult batchComplete(String dateStr) {
+ if (StringUtils.isBlank(dateStr)) {
+ return AjaxResult.error("鏃ユ湡鍙傛暟涓嶈兘涓虹┖");
+ }
+ LocalDate date = LocalDate.parse(dateStr);
+ LocalDateTime startOfDay = date.atStartOfDay();
+ LocalDateTime endOfDay = date.atTime(LocalTime.MAX);
+ List<DeviceMaintenance> records = this.lambdaQuery()
+ .eq(DeviceMaintenance::getStatus, 0)
+ .ge(DeviceMaintenance::getCreateTime, startOfDay)
+ .le(DeviceMaintenance::getCreateTime, endOfDay)
+ .list();
+ if (records.isEmpty()) {
+ return AjaxResult.error("璇ユ棩鏈熶笅娌℃湁寰呭畬鎴愮殑淇濆吇璁板綍");
+ }
+ String nickName = SecurityUtils.getLoginUser().getNickName();
+ LocalDateTime now = LocalDateTime.now();
+ for (DeviceMaintenance record : records) {
+ record.setStatus(1);
+ record.setMaintenanceActuallyName(nickName);
+ record.setMaintenanceActuallyTime(now);
+ }
+ this.updateBatchById(records);
+ return AjaxResult.success("宸插畬鎴� " + records.size() + " 鏉′繚鍏昏褰�");
+ }
+
+ @Override
+ @Transactional(rollbackFor = Exception.class)
+ public AjaxResult batchComplete(DeviceMaintenanceBatchCompleteDto dto) {
+ if (dto.getMaintenancePlanDate() == null) {
+ return AjaxResult.error("璁″垝淇濆吇鏃ユ湡涓嶈兘涓虹┖");
+ }
+ LambdaQueryWrapper<DeviceMaintenance> wrapper = new LambdaQueryWrapper<>();
+ wrapper.eq(DeviceMaintenance::getStatus, 0)
+ .apply("DATE(maintenance_plan_time) = {0}", dto.getMaintenancePlanDate().toString());
+ List<DeviceMaintenance> list = this.list(wrapper);
+ if (list.isEmpty()) {
+ return AjaxResult.success("璇ユ棩鏈熶笅娌℃湁寰呬繚鍏荤殑璁板綍");
+ }
+ list.forEach(task -> {
+ task.setStatus(1);
+ if (StringUtils.isNotBlank(dto.getMaintenanceActuallyName())) {
+ task.setMaintenanceActuallyName(dto.getMaintenanceActuallyName());
+ }
+ if (dto.getMaintenanceActuallyTime() != null) {
+ task.setMaintenanceActuallyTime(dto.getMaintenanceActuallyTime());
+ }
+ if (StringUtils.isNotBlank(dto.getMaintenanceResult())) {
+ task.setMaintenanceResult(dto.getMaintenanceResult());
+ }
+ });
+ this.updateBatchById(list);
+ return AjaxResult.success("鍏卞畬鎴� " + list.size() + " 鏉′繚鍏昏褰�");
+ }
+
+ @Override
public void export(HttpServletResponse response, Long[] ids) {
List<DeviceMaintenance> supplierManageList = deviceMaintenanceMapper.selectList(null);
ArrayList<DeviceMaintenanceExeclDto> deviceLedgerExeclDtos = new ArrayList<>();
diff --git a/src/main/java/com/ruoyi/home/controller/HomeController.java b/src/main/java/com/ruoyi/home/controller/HomeController.java
index 35c3954..e5f8513 100644
--- a/src/main/java/com/ruoyi/home/controller/HomeController.java
+++ b/src/main/java/com/ruoyi/home/controller/HomeController.java
@@ -61,8 +61,7 @@
private static final Integer ORDER_STATUS_WAIT = 1;
private static final Integer ORDER_STATUS_RUNNING = 2;
private static final Integer ORDER_STATUS_COMPLETED = 3;
- //private static final Integer ORDER_STATUS_END = 4; // 宸插彇娑�
- private static final Integer ORDER_STATUS_END = 5;
+ private static final Integer ORDER_STATUS_PAUSED = 4;
/********************************************************鍩虹绫�*****************************************************/
@GetMapping("/todos")
@@ -104,8 +103,10 @@
/********************************************************钀ラ攢閲囪喘绫�**************************************************/
@GetMapping("/supplierPurchaseRanking")
@Operation(summary = "渚涘簲鍟嗛噰璐帓鍚�")
- public R supplierPurchaseRanking(@DefaultType Integer type) {
- List<SupplierPurchaseRankingDto> list = homeService.supplierPurchaseRanking(type);
+ public R supplierPurchaseRanking(@DefaultType Integer type,
+ @RequestParam(required = false) String startDate,
+ @RequestParam(required = false) String endDate) {
+ List<SupplierPurchaseRankingDto> list = homeService.supplierPurchaseRanking(type, startDate, endDate);
return R.ok(list);
}
@@ -118,22 +119,28 @@
@GetMapping("/customerContributionRanking")
@Operation(summary = "瀹㈡埛閲戦璐$尞鎺掑悕")
- public R customerContributionRanking(@DefaultType Integer type) {
- List<CustomerContributionRankingDto> list = homeService.customerContributionRanking(type);
+ public R customerContributionRanking(@DefaultType Integer type,
+ @RequestParam(required = false) String startDate,
+ @RequestParam(required = false) String endDate) {
+ List<CustomerContributionRankingDto> list = homeService.customerContributionRanking(type, startDate, endDate);
return R.ok(list);
}
@GetMapping("/productSalesAnalysis")
@Operation(summary = "鍚勪骇鍝侀攢鍞噾棰濆垎鏋�")
- public R productSalesAnalysis() {
- List<MapDto> list = homeService.productSalesAnalysis();
+ public R productSalesAnalysis(
+ @RequestParam(required = false) String startDate,
+ @RequestParam(required = false) String endDate) {
+ List<MapDto> list = homeService.productSalesAnalysis(startDate, endDate);
return R.ok(list);
}
@GetMapping("/rawMaterialPurchaseAmountRatio")
@Operation(summary = "鍘熸潗鏂欓噰璐噾棰濆崰姣�")
- public R rawMaterialPurchaseAmountRatio(){
- List<MapDto> list = homeService.rawMaterialPurchaseAmountRatio();
+ public R rawMaterialPurchaseAmountRatio(
+ @RequestParam(required = false) String startDate,
+ @RequestParam(required = false) String endDate){
+ List<MapDto> list = homeService.rawMaterialPurchaseAmountRatio(startDate, endDate);
return R.ok(list);
}
@@ -261,7 +268,7 @@
}
Integer statusFromParam = parseOrderStatus(status);
if (!isBlank(status) && statusFromParam == null && !"all".equalsIgnoreCase(status.trim())) {
- return R.fail("status鍙傛暟涓嶅悎娉曪紝鍙�夊�硷細all/waiting/inProgress/completed/end 鎴� 1/2/3/5");
+ return R.fail("status鍙傛暟涓嶅悎娉曪紝鍙�夊�硷細all/waiting/inProgress/completed/paused 鎴� 1/2/3/4");
}
Integer queryStatus = resolveOrderStatus(status, tab);
@@ -283,7 +290,7 @@
long waitingCount = 0L;
long inProgressCount = 0L;
long completedCount = 0L;
- long endCount = 0L;
+ long pausedCount = 0L;
List<Map<String, Object>> statusCountRows = productionOrderMapper.countHomeOrderProgressByStatus(startTime, endTime);
if (statusCountRows != null) {
for (Map<String, Object> countRow : statusCountRows) {
@@ -295,8 +302,8 @@
inProgressCount = cnt;
} else if (Objects.equals(statusKey, ORDER_STATUS_COMPLETED)) {
completedCount = cnt;
- } else if (Objects.equals(statusKey, ORDER_STATUS_END)) {
- endCount = cnt;
+ } else if (Objects.equals(statusKey, ORDER_STATUS_PAUSED)) {
+ pausedCount = cnt;
}
}
}
@@ -311,7 +318,7 @@
result.put("waitingCount", waitingCount);
result.put("inProgressCount", inProgressCount);
result.put("completedCount", completedCount);
- result.put("endCount", endCount);
+ result.put("pausedCount", pausedCount);
result.put("records", records);
return R.ok(result);
}
@@ -474,22 +481,28 @@
@GetMapping("/salesPurchaseStorageProductCount")
@Operation(summary = "閿�鍞�-閲囪喘-鍌ㄥ瓨浜у搧鏁�")
- public R salesPurchaseStorageProductCount(){
- List<MapDto> list = homeService.salesPurchaseStorageProductCount();
+ public R salesPurchaseStorageProductCount(
+ @RequestParam(required = false) String startDate,
+ @RequestParam(required = false) String endDate){
+ List<MapDto> list = homeService.salesPurchaseStorageProductCount(startDate, endDate);
return R.ok(list);
}
@GetMapping("/productInOutAnalysis")
@Operation(summary = "浜у搧鍑哄叆搴撳垎鏋�")
- public R productInOutAnalysis(@DefaultType Integer type){
- List<Map<String, Object>> result = homeService.productInOutAnalysis(type);
+ public R productInOutAnalysis(@DefaultType Integer type,
+ @RequestParam(required = false) String startDate,
+ @RequestParam(required = false) String endDate){
+ List<Map<String, Object>> result = homeService.productInOutAnalysis(type, startDate, endDate);
return R.ok(result);
}
@GetMapping("/productTurnoverDays")
@Operation(summary = "浜у搧鍛ㄨ浆澶╂暟")
- public R productTurnoverDays(){
- List<MapDto> list = homeService.productTurnoverDays();
+ public R productTurnoverDays(
+ @RequestParam(required = false) String startDate,
+ @RequestParam(required = false) String endDate){
+ List<MapDto> list = homeService.productTurnoverDays(startDate, endDate);
return R.ok(list);
}
@@ -531,8 +544,8 @@
if ("3".equals(normalized) || "completed".equals(normalized)) {
return ORDER_STATUS_COMPLETED;
}
- if ("5".equals(normalized) || "end".equals(normalized)) {
- return ORDER_STATUS_END;
+ if ("4".equals(normalized) || "paused".equals(normalized)) {
+ return ORDER_STATUS_PAUSED;
}
return null;
}
@@ -544,8 +557,8 @@
if (Objects.equals(status, ORDER_STATUS_COMPLETED)) {
return "completed";
}
- if (Objects.equals(status, ORDER_STATUS_END)) {
- return "end";
+ if (Objects.equals(status, ORDER_STATUS_PAUSED)) {
+ return "paused";
}
if (Objects.equals(status, ORDER_STATUS_WAIT)) {
return "waiting";
@@ -563,8 +576,8 @@
if (Objects.equals(status, ORDER_STATUS_COMPLETED)) {
return "completed";
}
- if (Objects.equals(status, ORDER_STATUS_END)) {
- return "end";
+ if (Objects.equals(status, ORDER_STATUS_PAUSED)) {
+ return "paused";
}
return "all";
}
@@ -579,8 +592,8 @@
if (Objects.equals(status, ORDER_STATUS_COMPLETED)) {
return "宸插畬鎴�";
}
- if (Objects.equals(status, ORDER_STATUS_END)) {
- return "宸茬粨鏉�";
+ if (Objects.equals(status, ORDER_STATUS_PAUSED)) {
+ return "宸叉殏鍋�";
}
return "鏈煡";
}
@@ -637,7 +650,7 @@
.select(ProductionOrder::getQuantity, ProductionOrder::getCompleteQuantity)
.ge(ProductionOrder::getCreateTime, day.atStartOfDay())
.lt(ProductionOrder::getCreateTime, day.plusDays(1).atStartOfDay())
- .ne(ProductionOrder::getStatus, ORDER_STATUS_END));
+ .ne(ProductionOrder::getStatus, ORDER_STATUS_PAUSED));
BigDecimal totalQuantity = BigDecimal.ZERO;
BigDecimal totalCompleteQuantity = BigDecimal.ZERO;
diff --git a/src/main/java/com/ruoyi/home/mapper/HomeMapper.java b/src/main/java/com/ruoyi/home/mapper/HomeMapper.java
index 1bf30e4..3049159 100644
--- a/src/main/java/com/ruoyi/home/mapper/HomeMapper.java
+++ b/src/main/java/com/ruoyi/home/mapper/HomeMapper.java
@@ -2,19 +2,24 @@
import com.ruoyi.dto.MapDto;
import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
import java.util.List;
-/**
- * 棣栭〉缁熻 Mapper
- *
- * @author antigravity
- */
@Mapper
public interface HomeMapper {
/**
* 鏌ヨ浜у搧鍛ㄨ浆澶╂暟
- *
+ *
* @return 浜у搧鍛ㄨ浆澶╂暟鍒楄〃
*/
List<MapDto> productTurnoverDays();
+
+ List<MapDto> productTurnoverDaysByDate(@Param("startDate") String startDate, @Param("endDate") String endDate);
+
+ /**
+ * 鏌ヨ閲囪喘鍝佸ぇ绫诲垎甯冿紙鍚勪骇鍝佸皬绫荤殑閲囪喘鏁伴噺/閲戦锛�
+ *
+ * @return 閲囪喘鍒嗗竷鍒楄〃
+ */
+ List<MapDto> selectPurchaseCategoryDistribution();
}
diff --git a/src/main/java/com/ruoyi/home/service/HomeService.java b/src/main/java/com/ruoyi/home/service/HomeService.java
index 2c3c89b..ce335b2 100644
--- a/src/main/java/com/ruoyi/home/service/HomeService.java
+++ b/src/main/java/com/ruoyi/home/service/HomeService.java
@@ -38,23 +38,23 @@
HomeSummaryDto summaryStatistics();
- List<SupplierPurchaseRankingDto> supplierPurchaseRanking(Integer type);
+ List<SupplierPurchaseRankingDto> supplierPurchaseRanking(Integer type, String startDate, String endDate);
CustomerRevenueAnalysisDto customerRevenueAnalysis(Long customerId, Integer type);
ProductCategoryDistributionDto productCategoryDistribution();
- List<CustomerContributionRankingDto> customerContributionRanking(Integer type);
+ List<CustomerContributionRankingDto> customerContributionRanking(Integer type, String startDate, String endDate);
- List<MapDto> productSalesAnalysis();
+ List<MapDto> productSalesAnalysis(String startDate, String endDate);
- List<MapDto> rawMaterialPurchaseAmountRatio();
+ List<MapDto> rawMaterialPurchaseAmountRatio(String startDate, String endDate);
- List<MapDto> salesPurchaseStorageProductCount();
+ List<MapDto> salesPurchaseStorageProductCount(String startDate, String endDate);
- List<Map<String, Object>> productInOutAnalysis(Integer type);
+ List<Map<String, Object>> productInOutAnalysis(Integer type, String startDate, String endDate);
- List<MapDto> productTurnoverDays();
+ List<MapDto> productTurnoverDays(String startDate, String endDate);
List<Map<String, Object>> incomeExpenseAnalysis(Integer type);
diff --git a/src/main/java/com/ruoyi/home/service/impl/HomeServiceImpl.java b/src/main/java/com/ruoyi/home/service/impl/HomeServiceImpl.java
index 8aa7871..dece740 100644
--- a/src/main/java/com/ruoyi/home/service/impl/HomeServiceImpl.java
+++ b/src/main/java/com/ruoyi/home/service/impl/HomeServiceImpl.java
@@ -697,36 +697,39 @@
}
@Override
- public List<SupplierPurchaseRankingDto> supplierPurchaseRanking(Integer type) {
- LocalDate today = LocalDate.now();
+ public List<SupplierPurchaseRankingDto> supplierPurchaseRanking(Integer type, String startDateStr, String endDateStr) {
LocalDate startDate;
LocalDate endDate;
- switch (type) {
- case 1: // 鍛�
- startDate = today.with(DayOfWeek.MONDAY);
- endDate = today.with(DayOfWeek.SUNDAY);
- break;
- case 2: // 鏈�
- startDate = today.with(TemporalAdjusters.firstDayOfMonth());
- endDate = today.with(TemporalAdjusters.lastDayOfMonth());
- break;
- case 3: // 瀛e害
- Month currentMonth = today.getMonth();
- Month firstMonthOfQuarter = currentMonth.firstMonthOfQuarter();
- Month lastMonthOfQuarter = Month.of(firstMonthOfQuarter.getValue() + 2);
-
- startDate = today.withMonth(firstMonthOfQuarter.getValue()).with(TemporalAdjusters.firstDayOfMonth());
- endDate = today.withMonth(lastMonthOfQuarter.getValue()).with(TemporalAdjusters.lastDayOfMonth());
- break;
- default:
- return new ArrayList<>();
+ if (com.ruoyi.common.utils.StringUtils.isNotBlank(startDateStr) && com.ruoyi.common.utils.StringUtils.isNotBlank(endDateStr)) {
+ startDate = LocalDate.parse(startDateStr);
+ endDate = LocalDate.parse(endDateStr);
+ } else {
+ LocalDate today = LocalDate.now();
+ switch (type) {
+ case 1: // 鍛�
+ startDate = today.with(DayOfWeek.MONDAY);
+ endDate = today.with(DayOfWeek.SUNDAY);
+ break;
+ case 2: // 鏈�
+ startDate = today.with(TemporalAdjusters.firstDayOfMonth());
+ endDate = today.with(TemporalAdjusters.lastDayOfMonth());
+ break;
+ case 3: // 瀛e害
+ Month currentMonth = today.getMonth();
+ Month firstMonthOfQuarter = currentMonth.firstMonthOfQuarter();
+ Month lastMonthOfQuarter = Month.of(firstMonthOfQuarter.getValue() + 2);
+ startDate = today.withMonth(firstMonthOfQuarter.getValue()).with(TemporalAdjusters.firstDayOfMonth());
+ endDate = today.withMonth(lastMonthOfQuarter.getValue()).with(TemporalAdjusters.lastDayOfMonth());
+ break;
+ default:
+ return new ArrayList<>();
+ }
}
QueryWrapper<PurchaseLedger> queryWrapper = new QueryWrapper<>();
queryWrapper.select("supplier_name", "SUM(contract_amount) as total_amount")
.ge("entry_date", startDate)
.le("entry_date", endDate)
- // .ne("approval_status", 3)
.groupBy("supplier_name")
.orderByDesc("total_amount")
.last("LIMIT 5");
@@ -862,17 +865,81 @@
majorDto.setRate("0.00");
}
+ // 鏌ヨ鍚勪骇鍝佸皬绫荤殑閲囪喘鏁伴噺
+ Map<String, BigDecimal> purchaseDataMap = new java.util.HashMap<>();
+ List<com.ruoyi.dto.MapDto> purchaseDistribution = homeMapper.selectPurchaseCategoryDistribution();
+ if (purchaseDistribution != null) {
+ for (com.ruoyi.dto.MapDto item : purchaseDistribution) {
+ if (item.getName() != null && item.getValue() != null) {
+ purchaseDataMap.put(item.getName(), new BigDecimal(item.getValue()));
+ }
+ }
+ }
+
+ BigDecimal majorTotalChildrenValue = BigDecimal.ZERO;
List<ProductCategoryDistributionDto.MinorCategoryDto> minorDtos = new ArrayList<>();
for (Product minor : children) {
ProductCategoryDistributionDto.MinorCategoryDto minorDto = new ProductCategoryDistributionDto.MinorCategoryDto();
minorDto.setName(minor.getProductName());
- minorDto.setValue("0");
+ BigDecimal minorValue = purchaseDataMap.getOrDefault(minor.getProductName(), BigDecimal.ZERO);
+ minorDto.setValue(minorValue.toString());
minorDto.setRate("0.00");
minorDto.setChildren(new ArrayList<>());
minorDtos.add(minorDto);
+ majorTotalChildrenValue = majorTotalChildrenValue.add(minorValue);
}
majorDto.setChildren(minorDtos);
+ // 浣跨敤瀹為檯閲囪喘鏁版嵁鏇存柊澶х被鐨� value
+ if (majorTotalChildrenValue.compareTo(BigDecimal.ZERO) > 0) {
+ majorDto.setValue(majorTotalChildrenValue.toString());
+ }
majorItems.add(majorDto);
+ }
+
+ // 璁$畻澶х被鍗犳瘮
+ BigDecimal totalAllValue = BigDecimal.ZERO;
+ for (ProductCategoryDistributionDto.MajorCategoryDto m : majorItems) {
+ try {
+ totalAllValue = totalAllValue.add(new BigDecimal(m.getValue()));
+ } catch (NumberFormatException ignored) {
+ }
+ }
+ if (totalAllValue.compareTo(BigDecimal.ZERO) > 0) {
+ for (ProductCategoryDistributionDto.MajorCategoryDto m : majorItems) {
+ try {
+ BigDecimal val = new BigDecimal(m.getValue());
+ m.setRate(val.divide(totalAllValue, 4, RoundingMode.HALF_UP)
+ .multiply(new BigDecimal("100"))
+ .setScale(2, RoundingMode.HALF_UP)
+ .toString());
+ } catch (NumberFormatException ignored) {
+ }
+ }
+ }
+ // 璁$畻灏忕被鍗犳瘮锛堝湪鍚屽ぇ绫诲唴锛�
+ for (ProductCategoryDistributionDto.MajorCategoryDto m : majorItems) {
+ if (m.getChildren() == null || m.getChildren().isEmpty()) {
+ continue;
+ }
+ BigDecimal parentVal = BigDecimal.ZERO;
+ for (ProductCategoryDistributionDto.MinorCategoryDto child : m.getChildren()) {
+ try {
+ parentVal = parentVal.add(new BigDecimal(child.getValue()));
+ } catch (NumberFormatException ignored) {
+ }
+ }
+ if (parentVal.compareTo(BigDecimal.ZERO) > 0) {
+ for (ProductCategoryDistributionDto.MinorCategoryDto child : m.getChildren()) {
+ try {
+ BigDecimal childVal = new BigDecimal(child.getValue());
+ child.setRate(childVal.divide(parentVal, 4, RoundingMode.HALF_UP)
+ .multiply(new BigDecimal("100"))
+ .setScale(2, RoundingMode.HALF_UP)
+ .toString());
+ } catch (NumberFormatException ignored) {
+ }
+ }
+ }
}
dto.setItems(majorItems);
@@ -880,38 +947,42 @@
}
@Override
- public List<CustomerContributionRankingDto> customerContributionRanking(Integer type) {
- LocalDate today = LocalDate.now();
- LocalDate startDate = null;
- LocalDate endDate = null;
- switch (type) {
- case 1:
- startDate = today.with(DayOfWeek.MONDAY);
- endDate = today.with(DayOfWeek.SUNDAY);
- break;
- case 2:
- startDate = today.with(TemporalAdjusters.firstDayOfMonth());
- endDate = today.with(TemporalAdjusters.lastDayOfMonth());
- break;
- case 3:
- Month currentMonth = today.getMonth();
- Month firstMonthOfQuarter = currentMonth.firstMonthOfQuarter();
- Month lastMonthOfQuarter = Month.of(firstMonthOfQuarter.getValue() + 2);
- startDate = today.withMonth(firstMonthOfQuarter.getValue()).with(TemporalAdjusters.firstDayOfMonth());
- endDate = today.withMonth(lastMonthOfQuarter.getValue()).with(TemporalAdjusters.lastDayOfMonth());
- break;
+ public List<CustomerContributionRankingDto> customerContributionRanking(Integer type, String startDateStr, String endDateStr) {
+ LocalDate startDate;
+ LocalDate endDate;
+ if (com.ruoyi.common.utils.StringUtils.isNotBlank(startDateStr) && com.ruoyi.common.utils.StringUtils.isNotBlank(endDateStr)) {
+ startDate = LocalDate.parse(startDateStr);
+ endDate = LocalDate.parse(endDateStr);
+ } else {
+ LocalDate today = LocalDate.now();
+ switch (type) {
+ case 1:
+ startDate = today.with(DayOfWeek.MONDAY);
+ endDate = today.with(DayOfWeek.SUNDAY);
+ break;
+ case 2:
+ startDate = today.with(TemporalAdjusters.firstDayOfMonth());
+ endDate = today.with(TemporalAdjusters.lastDayOfMonth());
+ break;
+ case 3:
+ Month currentMonth = today.getMonth();
+ Month firstMonthOfQuarter = currentMonth.firstMonthOfQuarter();
+ Month lastMonthOfQuarter = Month.of(firstMonthOfQuarter.getValue() + 2);
+ startDate = today.withMonth(firstMonthOfQuarter.getValue()).with(TemporalAdjusters.firstDayOfMonth());
+ endDate = today.withMonth(lastMonthOfQuarter.getValue()).with(TemporalAdjusters.lastDayOfMonth());
+ break;
+ default:
+ return new ArrayList<>();
+ }
}
QueryWrapper<SalesLedger> queryWrapper = new QueryWrapper<>();
queryWrapper.select("customer_name", "SUM(contract_amount) as total_amount")
.isNotNull("customer_name")
+ .between("entry_date", startDate, endDate)
.groupBy("customer_name")
.orderByDesc("total_amount")
.last("LIMIT 5");
-
- if (startDate != null && endDate != null) {
- queryWrapper.between("entry_date", startDate, endDate);
- }
List<Map<String, Object>> maps = salesLedgerMapper.selectMaps(queryWrapper);
List<CustomerContributionRankingDto> result = new ArrayList<>();
@@ -927,9 +998,13 @@
}
@Override
- public List<MapDto> productSalesAnalysis() {
- // 鑾峰彇鎵�鏈変骇鍝佸ぇ绫荤殑閿�鍞
- List<Map<String, Object>> analysisResults = salesLedgerProductMapper.selectProductSalesAnalysis();
+ public List<MapDto> productSalesAnalysis(String startDateStr, String endDateStr) {
+ List<Map<String, Object>> analysisResults;
+ if (com.ruoyi.common.utils.StringUtils.isNotBlank(startDateStr) && com.ruoyi.common.utils.StringUtils.isNotBlank(endDateStr)) {
+ analysisResults = salesLedgerProductMapper.selectProductSalesAnalysisByDate(startDateStr, endDateStr);
+ } else {
+ analysisResults = salesLedgerProductMapper.selectProductSalesAnalysis();
+ }
if (CollectionUtils.isEmpty(analysisResults)) {
return new ArrayList<>();
}
@@ -964,9 +1039,13 @@
}
@Override
- public List<MapDto> rawMaterialPurchaseAmountRatio() {
- // 鑾峰彇鎵�鏈夊師鏉愭枡鐨勯噰璐
- List<Map<String, Object>> analysisResults = salesLedgerProductMapper.selectRawMaterialPurchaseAnalysis();
+ public List<MapDto> rawMaterialPurchaseAmountRatio(String startDateStr, String endDateStr) {
+ List<Map<String, Object>> analysisResults;
+ if (com.ruoyi.common.utils.StringUtils.isNotBlank(startDateStr) && com.ruoyi.common.utils.StringUtils.isNotBlank(endDateStr)) {
+ analysisResults = salesLedgerProductMapper.selectRawMaterialPurchaseAnalysisByDate(startDateStr, endDateStr);
+ } else {
+ analysisResults = salesLedgerProductMapper.selectRawMaterialPurchaseAnalysis();
+ }
if (CollectionUtils.isEmpty(analysisResults)) {
return new ArrayList<>();
}
@@ -1001,25 +1080,47 @@
}
@Override
- public List<MapDto> salesPurchaseStorageProductCount() {
+ public List<MapDto> salesPurchaseStorageProductCount(String startDate, String endDate) {
LocalDateTime now = LocalDateTime.now();
- LocalDateTime currentMonthStart = now.with(TemporalAdjusters.firstDayOfMonth()).with(LocalTime.MIN);
- LocalDateTime lastMonth = now.minusMonths(1);
- LocalDateTime lastMonthStart = lastMonth.with(TemporalAdjusters.firstDayOfMonth()).with(LocalTime.MIN);
- LocalDateTime lastMonthEnd = lastMonth.with(TemporalAdjusters.lastDayOfMonth()).with(LocalTime.MAX);
+ LocalDateTime currentMonthStart;
+ LocalDateTime currentMonthEnd;
+ LocalDateTime lastMonthStart;
+ LocalDateTime lastMonthEnd;
- // 閿�鍞�
- int currentSales = salesLedgerProductMapper.selectProductCountByTypeAndDate(1, currentMonthStart, now);
- int lastSales = salesLedgerProductMapper.selectProductCountByTypeAndDate(1, lastMonthStart, lastMonthEnd);
- // 閲囪喘
- int currentPurchase = salesLedgerProductMapper.selectProductCountByTypeAndDate(2, currentMonthStart, now);
+ if (StringUtils.isNotBlank(startDate) && StringUtils.isNotBlank(endDate)) {
+ LocalDate start = LocalDate.parse(startDate);
+ LocalDate end = LocalDate.parse(endDate);
+ currentMonthStart = start.atStartOfDay();
+ currentMonthEnd = end.atTime(LocalTime.MAX);
+ long daysBetween = java.time.temporal.ChronoUnit.DAYS.between(start, end) + 1;
+ LocalDate lastStart = start.minusDays(daysBetween);
+ LocalDate lastEnd = start.minusDays(1);
+ lastMonthStart = lastStart.atStartOfDay();
+ lastMonthEnd = lastEnd.atTime(LocalTime.MAX);
+ } else {
+ currentMonthStart = now.with(TemporalAdjusters.firstDayOfMonth()).with(LocalTime.MIN);
+ currentMonthEnd = now;
+ LocalDateTime lastMonth = now.minusMonths(1);
+ lastMonthStart = lastMonth.with(TemporalAdjusters.firstDayOfMonth()).with(LocalTime.MIN);
+ lastMonthEnd = lastMonth.with(TemporalAdjusters.lastDayOfMonth()).with(LocalTime.MAX);
+ }
+
+ // 閿�鍞鍗曟暟锛堢粺璁ales_ledger琛級
+ int currentSales = Math.toIntExact(salesLedgerMapper.selectCount(new LambdaQueryWrapper<SalesLedger>()
+ .ge(SalesLedger::getEntryDate, currentMonthStart)
+ .le(SalesLedger::getEntryDate, currentMonthEnd)));
+ int lastSales = Math.toIntExact(salesLedgerMapper.selectCount(new LambdaQueryWrapper<SalesLedger>()
+ .ge(SalesLedger::getEntryDate, lastMonthStart)
+ .le(SalesLedger::getEntryDate, lastMonthEnd)));
+ // 閲囪喘浜у搧鏁�
+ int currentPurchase = salesLedgerProductMapper.selectProductCountByTypeAndDate(2, currentMonthStart, currentMonthEnd);
int lastPurchase = salesLedgerProductMapper.selectProductCountByTypeAndDate(2, lastMonthStart, lastMonthEnd);
- // 鍌ㄥ瓨
- int currentStorage = stockInventoryMapper.selectStorageProductCountByDate(currentMonthStart, now);
+ // 鍌ㄥ瓨浜у搧鏁�
+ int currentStorage = stockInventoryMapper.selectStorageProductCountByDate(currentMonthStart, currentMonthEnd);
int lastStorage = stockInventoryMapper.selectStorageProductCountByDate(lastMonthStart, lastMonthEnd);
List<MapDto> list = new ArrayList<>();
- list.add(createMapDto("閿�鍞骇鍝佹暟", currentSales, lastSales));
+ list.add(createMapDto("閿�鍞鍗曟暟", currentSales, lastSales));
list.add(createMapDto("閲囪喘浜у搧鏁�", currentPurchase, lastPurchase));
list.add(createMapDto("鍌ㄥ瓨浜у搧鏁�", currentStorage, lastStorage));
@@ -1048,7 +1149,7 @@
}
@Override
- public List<Map<String, Object>> productInOutAnalysis(Integer type) {
+ public List<Map<String, Object>> productInOutAnalysis(Integer type, String startDateStr, String endDateStr) {
String targetName;
if (type == 1) {
targetName = "鍘熸潗鏂�";
@@ -1073,8 +1174,17 @@
LocalDate now = LocalDate.now();
DateTimeFormatter displayDtf = DateTimeFormatter.ofPattern("M/d");
- String startDate = now.minusDays(6).toString();
- String endDate = now.toString();
+ LocalDate start;
+ LocalDate end;
+ if (com.ruoyi.common.utils.StringUtils.isNotBlank(startDateStr) && com.ruoyi.common.utils.StringUtils.isNotBlank(endDateStr)) {
+ start = LocalDate.parse(startDateStr);
+ end = LocalDate.parse(endDateStr);
+ } else {
+ end = now;
+ start = now.minusDays(6);
+ }
+ String startDate = start.toString();
+ String endDate = end.toString();
List<Map<String, Object>> inCounts = stockInventoryMapper.selectDailyStockInCounts(rootCategoryId, startDate,
endDate + " 23:59:59");
@@ -1096,8 +1206,9 @@
List<Map<String, Object>> result = new ArrayList<>();
- for (int i = 6; i >= 0; i--) {
- LocalDate date = now.minusDays(i);
+ long daysBetween = ChronoUnit.DAYS.between(start, end);
+ for (int i = (int) daysBetween; i >= 0; i--) {
+ LocalDate date = end.minusDays(i);
Map<String, Object> dataPoint = new LinkedHashMap<>();
dataPoint.put("date", date.format(displayDtf)); // 1/23
@@ -1111,7 +1222,10 @@
}
@Override
- public List<MapDto> productTurnoverDays() {
+ public List<MapDto> productTurnoverDays(String startDateStr, String endDateStr) {
+ if (com.ruoyi.common.utils.StringUtils.isNotBlank(startDateStr) && com.ruoyi.common.utils.StringUtils.isNotBlank(endDateStr)) {
+ return homeMapper.productTurnoverDaysByDate(startDateStr, endDateStr);
+ }
return homeMapper.productTurnoverDays();
}
diff --git a/src/main/java/com/ruoyi/inspectiontask/controller/InspectionTaskController.java b/src/main/java/com/ruoyi/inspectiontask/controller/InspectionTaskController.java
index be8dda5..42d2d4e 100644
--- a/src/main/java/com/ruoyi/inspectiontask/controller/InspectionTaskController.java
+++ b/src/main/java/com/ruoyi/inspectiontask/controller/InspectionTaskController.java
@@ -15,12 +15,6 @@
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
-import java.io.IOException;
-
-/**
- * @author :yys
- * @date : 2025/9/19 10:52
- */
@RestController
@Tag(name = "宸℃浠诲姟璁板綍")
@RequestMapping("/inspectionTask")
@@ -29,20 +23,13 @@
private InspectionTaskService inspectionTaskService;
- /**
- * 宸℃浠诲姟琛ㄨ〃鏌ヨ
- */
@GetMapping("/list")
- @Operation(summary = "宸℃浠诲姟琛ㄨ〃鏌ヨ")
+ @Operation(summary = "宸℃浠诲姟琛ㄦ煡璇�")
public R<IPage<InspectionTaskDto>> list(Page<InspectionTask> page, InspectionTaskDto inspectionTaskDto) {
IPage<InspectionTaskDto> list = inspectionTaskService.selectInspectionTaskList(page, inspectionTaskDto);
return R.ok(list);
}
-
- /**
- * 瀵煎嚭
- */
@PostMapping("/export")
@Operation(summary = "瀵煎嚭瀹氭椂浠诲姟璁板綍")
public void export(HttpServletResponse response) {
@@ -53,9 +40,6 @@
util.exportExcel(response, list.getRecords(), "瀵煎嚭瀹氭椂浠诲姟璁板綍");
}
- /**
- * 宸℃浠诲姟琛ㄦ柊澧炰慨鏀�
- */
@PostMapping("/addOrEditInspectionTask")
@Operation(summary = "宸℃浠诲姟琛ㄦ柊澧炰慨鏀�")
@Transactional(rollbackFor = Exception.class)
@@ -63,9 +47,6 @@
return R.ok(inspectionTaskService.addOrEditInspectionTask(inspectionTaskDto));
}
- /**
- * 宸℃浠诲姟琛ㄥ垹闄�
- */
@DeleteMapping("/delInspectionTask")
@Operation(summary = "宸℃浠诲姟琛ㄥ垹闄�")
@Transactional(rollbackFor = Exception.class)
@@ -73,4 +54,18 @@
return R.ok(inspectionTaskService.delByIds(ids));
}
+ @PutMapping("/complete/{id}")
+ @Operation(summary = "宸℃瀹屾垚")
+ @Transactional(rollbackFor = Exception.class)
+ public R complete(@PathVariable Long id) {
+ return R.ok(inspectionTaskService.complete(id));
+ }
+
+ @PutMapping("/batchComplete")
+ @Operation(summary = "涓�閿贰妫�瀹屾垚")
+ @Transactional(rollbackFor = Exception.class)
+ public R batchComplete(String dateStr) {
+ return R.ok(inspectionTaskService.batchComplete(dateStr));
+ }
+
}
diff --git a/src/main/java/com/ruoyi/inspectiontask/pojo/InspectionTask.java b/src/main/java/com/ruoyi/inspectiontask/pojo/InspectionTask.java
index 4e7efad..d5b265a 100644
--- a/src/main/java/com/ruoyi/inspectiontask/pojo/InspectionTask.java
+++ b/src/main/java/com/ruoyi/inspectiontask/pojo/InspectionTask.java
@@ -82,6 +82,9 @@
@Schema(description = "宸℃鍦扮偣璇︾粏鎻忚堪")
private String inspectionLocation;
+ @Schema(description = "鐘舵�� 0=寰呭贰妫�, 1=宸插畬鎴�")
+ private Integer status;
+
@Schema(description = "杞垹闄ゆ爣蹇楋紝0=鏈垹闄わ紝1=宸插垹闄�")
private Integer deleted;
diff --git a/src/main/java/com/ruoyi/inspectiontask/service/InspectionTaskService.java b/src/main/java/com/ruoyi/inspectiontask/service/InspectionTaskService.java
index de175f2..23d4b62 100644
--- a/src/main/java/com/ruoyi/inspectiontask/service/InspectionTaskService.java
+++ b/src/main/java/com/ruoyi/inspectiontask/service/InspectionTaskService.java
@@ -6,10 +6,6 @@
import com.ruoyi.inspectiontask.dto.InspectionTaskDto;
import com.ruoyi.inspectiontask.pojo.InspectionTask;
-/**
- * @author :yys
- * @date : 2025/9/19 10:49
- */
public interface InspectionTaskService extends IService<InspectionTask> {
IPage<InspectionTaskDto> selectInspectionTaskList(Page<InspectionTask> page, InspectionTaskDto inspectionTaskDto);
@@ -17,4 +13,8 @@
int addOrEditInspectionTask(InspectionTaskDto inspectionTaskDto);
int delByIds(Long[] ids);
+
+ int complete(Long id);
+
+ int batchComplete(String dateStr);
}
diff --git a/src/main/java/com/ruoyi/inspectiontask/service/impl/InspectionTaskServiceImpl.java b/src/main/java/com/ruoyi/inspectiontask/service/impl/InspectionTaskServiceImpl.java
index 9729b40..3335de3 100644
--- a/src/main/java/com/ruoyi/inspectiontask/service/impl/InspectionTaskServiceImpl.java
+++ b/src/main/java/com/ruoyi/inspectiontask/service/impl/InspectionTaskServiceImpl.java
@@ -187,9 +187,63 @@
// 淇濆瓨鏂囦欢锛堝瓧娈典笉浼犲垯淇濈暀鍘嗗彶锛�
saveInspectionAttachments(inspectionTask.getId(), inspectionTaskDto);
+ // 宸℃缁撴灉璁剧疆鍚庯紝鑷姩鏍囪涓哄凡瀹屾垚
+ if (StringUtils.isNotBlank(inspectionTaskDto.getInspectionResult())) {
+ InspectionTask statusUpdate = new InspectionTask();
+ statusUpdate.setId(inspectionTask.getId());
+ statusUpdate.setStatus(1);
+ inspectionTaskMapper.updateById(statusUpdate);
+ }
+
return i;
}
+ @Override
+ @Transactional(rollbackFor = Exception.class)
+ public int complete(Long id) {
+ InspectionTask task = inspectionTaskMapper.selectById(id);
+ if (task == null) {
+ throw new IllegalArgumentException("宸℃浠诲姟涓嶅瓨鍦�");
+ }
+ if (task.getStatus() != null && task.getStatus() == 1) {
+ throw new IllegalArgumentException("璇ュ贰妫�浠诲姟宸插畬鎴�");
+ }
+ task.setStatus(1);
+ if (task.getInspectionResult() == null) {
+ task.setInspectionResult("1");
+ }
+ return inspectionTaskMapper.updateById(task);
+ }
+
+ @Override
+ @Transactional(rollbackFor = Exception.class)
+ public int batchComplete(String dateStr) {
+ if (StringUtils.isBlank(dateStr)) {
+ throw new IllegalArgumentException("鏃ユ湡鍙傛暟涓嶈兘涓虹┖");
+ }
+ java.time.LocalDate date = java.time.LocalDate.parse(dateStr);
+ java.time.LocalDateTime startOfDay = date.atStartOfDay();
+ java.time.LocalDateTime endOfDay = date.atTime(java.time.LocalTime.MAX);
+ List<InspectionTask> tasks = inspectionTaskMapper.selectList(
+ new LambdaQueryWrapper<InspectionTask>()
+ .eq(InspectionTask::getStatus, 0)
+ .ge(InspectionTask::getCreateTime, startOfDay)
+ .le(InspectionTask::getCreateTime, endOfDay));
+ if (tasks.isEmpty()) {
+ throw new IllegalArgumentException("璇ユ棩鏈熶笅娌℃湁寰呭畬鎴愮殑宸℃璁板綍");
+ }
+ int count = 0;
+ for (InspectionTask task : tasks) {
+ task.setStatus(1);
+ if (task.getInspectionResult() == null) {
+ task.setInspectionResult("1");
+ }
+ inspectionTaskMapper.updateById(task);
+ count++;
+ }
+ return count;
+ }
+
private void validateInspectionInput(InspectionTaskDto inspectionTaskDto, InspectionTask oldInspectionTask) {
String inspectionResult = inspectionTaskDto.getInspectionResult();
if (StringUtils.isBlank(inspectionResult) && oldInspectionTask != null) {
diff --git a/src/main/java/com/ruoyi/measuringinstrumentledger/controller/SparePartsRequisitionRecordController.java b/src/main/java/com/ruoyi/measuringinstrumentledger/controller/SparePartsRequisitionRecordController.java
index 26195a4..ddebfa1 100644
--- a/src/main/java/com/ruoyi/measuringinstrumentledger/controller/SparePartsRequisitionRecordController.java
+++ b/src/main/java/com/ruoyi/measuringinstrumentledger/controller/SparePartsRequisitionRecordController.java
@@ -3,23 +3,18 @@
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruoyi.framework.web.domain.AjaxResult;
+import com.ruoyi.measuringinstrumentledger.dto.SparePartsOutboundDto;
import com.ruoyi.measuringinstrumentledger.dto.SparePartsRequisitionRecordDto;
import com.ruoyi.measuringinstrumentledger.service.SparePartsRequisitionRecordService;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
-/**
- * <p>
- * 鍓嶇鎺у埗鍣�
- * </p>
- *
- * @author 鑺杞欢锛堟睙鑻忥級鏈夐檺鍏徃
- * @since 2026-04-02 03:59:56
- */
@RestController
@RequestMapping("/sparePartsRequisitionRecord")
@Tag(name = "澶囦欢棰嗙敤璁板綍鎺ュ彛")
@@ -28,9 +23,16 @@
private SparePartsRequisitionRecordService sparePartsRequisitionRecordService;
@GetMapping("/listPage")
- @Operation(summary = "澶囦欢鍒嗙被-鍒嗛〉鏌ヨ")
+ @Operation(summary = "澶囦欢棰嗙敤璁板綍-鍒嗛〉鏌ヨ")
public AjaxResult listPage(Page page, SparePartsRequisitionRecordDto sparePartsRequisitionRecordDto){
IPage<SparePartsRequisitionRecordDto> listPage = sparePartsRequisitionRecordService.listPage(page, sparePartsRequisitionRecordDto);
return AjaxResult.success(listPage);
}
+
+ @PostMapping("/outbound")
+ @Operation(summary = "澶囦欢鐙珛鍑哄簱")
+ public AjaxResult outbound(@RequestBody SparePartsOutboundDto dto){
+ sparePartsRequisitionRecordService.outbound(dto);
+ return AjaxResult.success();
+ }
}
diff --git a/src/main/java/com/ruoyi/measuringinstrumentledger/service/SparePartsRequisitionRecordService.java b/src/main/java/com/ruoyi/measuringinstrumentledger/service/SparePartsRequisitionRecordService.java
index 2306a3a..38a681a 100644
--- a/src/main/java/com/ruoyi/measuringinstrumentledger/service/SparePartsRequisitionRecordService.java
+++ b/src/main/java/com/ruoyi/measuringinstrumentledger/service/SparePartsRequisitionRecordService.java
@@ -3,17 +3,12 @@
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
+import com.ruoyi.measuringinstrumentledger.dto.SparePartsOutboundDto;
import com.ruoyi.measuringinstrumentledger.dto.SparePartsRequisitionRecordDto;
import com.ruoyi.measuringinstrumentledger.pojo.SparePartsRequisitionRecord;
-/**
- * <p>
- * 鏈嶅姟绫�
- * </p>
- *
- * @author 鑺杞欢锛堟睙鑻忥級鏈夐檺鍏徃
- * @since 2026-04-02 03:59:56
- */
public interface SparePartsRequisitionRecordService extends IService<SparePartsRequisitionRecord> {
IPage<SparePartsRequisitionRecordDto> listPage(Page page, SparePartsRequisitionRecordDto sparePartsRequisitionRecordDto);
+
+ void outbound(SparePartsOutboundDto dto);
}
diff --git a/src/main/java/com/ruoyi/measuringinstrumentledger/service/impl/SparePartsRequisitionRecordServiceImpl.java b/src/main/java/com/ruoyi/measuringinstrumentledger/service/impl/SparePartsRequisitionRecordServiceImpl.java
index 19746f5..a372a9b 100644
--- a/src/main/java/com/ruoyi/measuringinstrumentledger/service/impl/SparePartsRequisitionRecordServiceImpl.java
+++ b/src/main/java/com/ruoyi/measuringinstrumentledger/service/impl/SparePartsRequisitionRecordServiceImpl.java
@@ -4,35 +4,58 @@
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.common.enums.SparePartsRequisitionRecordSourceTypeEnum;
+import com.ruoyi.measuringinstrumentledger.dto.SparePartsOutboundDto;
import com.ruoyi.measuringinstrumentledger.dto.SparePartsRequisitionRecordDto;
+import com.ruoyi.measuringinstrumentledger.mapper.SparePartsMapper;
import com.ruoyi.measuringinstrumentledger.mapper.SparePartsRequisitionRecordMapper;
+import com.ruoyi.measuringinstrumentledger.pojo.SpareParts;
import com.ruoyi.measuringinstrumentledger.pojo.SparePartsRequisitionRecord;
import com.ruoyi.measuringinstrumentledger.service.SparePartsRequisitionRecordService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
-/**
- * <p>
- * 鏈嶅姟瀹炵幇绫�
- * </p>
- *
- * @author 鑺杞欢锛堟睙鑻忥級鏈夐檺鍏徃
- * @since 2026-04-02 03:59:56
- */
+import java.math.BigDecimal;
+
@Service
@RequiredArgsConstructor
public class SparePartsRequisitionRecordServiceImpl extends ServiceImpl<SparePartsRequisitionRecordMapper, SparePartsRequisitionRecord> implements SparePartsRequisitionRecordService {
private final SparePartsRequisitionRecordMapper sparePartsRequisitionRecordMapper;
+ private final SparePartsMapper sparePartsMapper;
@Override
public IPage<SparePartsRequisitionRecordDto> listPage(Page page, SparePartsRequisitionRecordDto sparePartsRequisitionRecordDto) {
IPage<SparePartsRequisitionRecordDto> result = sparePartsRequisitionRecordMapper.listPage(page, sparePartsRequisitionRecordDto);
- // 澶勭悊鏉ユ簮绫诲瀷鏂囨湰
result.getRecords().forEach(record -> {
if (record.getSourceType() != null) {
- record.setSourceText(SparePartsRequisitionRecordSourceTypeEnum.getByCode(record.getSourceType()).getValue());
+ SparePartsRequisitionRecordSourceTypeEnum typeEnum = SparePartsRequisitionRecordSourceTypeEnum.getByCode(record.getSourceType());
+ if (typeEnum != null) {
+ record.setSourceText(typeEnum.getValue());
+ }
}
});
return result;
}
+
+ @Override
+ @Transactional(rollbackFor = Exception.class)
+ public void outbound(SparePartsOutboundDto dto) {
+ SpareParts spareParts = sparePartsMapper.selectById(dto.getSparePartsId());
+ if (spareParts == null) {
+ throw new IllegalArgumentException("澶囦欢涓嶅瓨鍦�");
+ }
+ if (spareParts.getQuantity().compareTo(new BigDecimal(dto.getQuantity())) < 0) {
+ throw new IllegalArgumentException("澶囦欢 " + spareParts.getName() + " 搴撳瓨涓嶈冻");
+ }
+ // 鎵e噺搴撳瓨
+ spareParts.setQuantity(spareParts.getQuantity().subtract(new BigDecimal(dto.getQuantity())));
+ sparePartsMapper.updateById(spareParts);
+ // 鍒涘缓棰嗙敤璁板綍
+ SparePartsRequisitionRecord record = new SparePartsRequisitionRecord();
+ record.setSourceType(SparePartsRequisitionRecordSourceTypeEnum.SparePartsRequisitionRecordSourceTypeDirectOutbound.getCode());
+ record.setSparePartsId(dto.getSparePartsId());
+ record.setQuantity(dto.getQuantity());
+ record.setDeviceLedgerId(dto.getDeviceLedgerId());
+ this.save(record);
+ }
}
\ No newline at end of file
diff --git a/src/main/java/com/ruoyi/procurementrecord/service/impl/ReturnManagementServiceImpl.java b/src/main/java/com/ruoyi/procurementrecord/service/impl/ReturnManagementServiceImpl.java
index 048f1df..2a56e0e 100644
--- a/src/main/java/com/ruoyi/procurementrecord/service/impl/ReturnManagementServiceImpl.java
+++ b/src/main/java/com/ruoyi/procurementrecord/service/impl/ReturnManagementServiceImpl.java
@@ -20,8 +20,6 @@
import com.ruoyi.procurementrecord.service.ReturnManagementService;
import com.ruoyi.procurementrecord.service.ReturnSaleProductService;
import com.ruoyi.procurementrecord.utils.StockUtils;
-import com.ruoyi.sales.mapper.SalesLedgerMapper;
-import com.ruoyi.sales.pojo.SalesLedger;
import com.ruoyi.sales.pojo.ShippingInfo;
import com.ruoyi.sales.service.ShippingInfoService;
import lombok.RequiredArgsConstructor;
@@ -46,7 +44,6 @@
private final ReturnManagementMapper returnManagementMapper;
private final ReturnSaleProductService returnSaleProductService;
private final ShippingInfoService shippingInfoService;
- private final SalesLedgerMapper salesLedgerMapper;
private final SalesRefundAmountOrderService salesRefundAmountOrderService;
private final StockUtils stockUtils;
@@ -101,42 +98,26 @@
public boolean handle(Long returnManagementId) {
ReturnManagement byId = this.getById(returnManagementId);
List<ReturnSaleProductDto> list = returnSaleProductService.listReturnSaleProduct(returnManagementId);
-
- // 1. 璁$畻姝g‘鐨勯��娆炬�婚锛堥噾棰�=鍗曚环脳鏁伴噺锛�
- BigDecimal totalRefund = BigDecimal.ZERO;
+ byId.setStatus(1);
+ byId.setSettler(SecurityUtils.getLoginUser().getNickName());
+ updateById(byId);
+ SalesRefundAmountOrderDto salesRefundAmountOrder = new SalesRefundAmountOrderDto();
+ salesRefundAmountOrder.setReturnManagementId(returnManagementId);
+ salesRefundAmountOrder.setStatus(0);
+ salesRefundAmountOrder.setCreateTime(byId.getCreateTime());
+ salesRefundAmountOrder.setCreateUserId(SecurityUtils.getUserId());
+ BigDecimal bigDecimal = new BigDecimal(0);
for (ReturnSaleProductDto returnSaleProduct : list) {
- BigDecimal itemAmount = returnSaleProduct.getAmount() != null
- ? returnSaleProduct.getAmount()
- : BigDecimal.ZERO;
- totalRefund = totalRefund.add(itemAmount);
- // 鏄惁鏈夎川閲忛棶棰�
+ bigDecimal = bigDecimal.add(returnSaleProduct.getPrice());
+ salesRefundAmountOrder.setRefundedAmount(new BigDecimal(0));
if (returnSaleProduct.getIsQuality() == 1) {
stockUtils.addUnStockWithBatchNo(returnSaleProduct.getProductModelId(), returnSaleProduct.getNum(), StockInQualifiedRecordTypeEnum.RETURN_UNSTOCK_IN.getCode(), returnSaleProduct.getId(), returnSaleProduct.getBatchNo());
} else {
stockUtils.addStockWithBatchNo(returnSaleProduct.getProductModelId(), returnSaleProduct.getNum(), StockInQualifiedRecordTypeEnum.RETURN_HE_IN.getCode(), returnSaleProduct.getId(), returnSaleProduct.getBatchNo());
}
}
-
- // 2. 鏇存柊閫�璐у崟鐘舵�佸拰閫�娆炬�婚
- byId.setStatus(1);
- byId.setSettler(SecurityUtils.getLoginUser().getNickName());
- byId.setRefundAmount(totalRefund);
- updateById(byId);
-
- // 3. 鏇存柊閿�鍞彴璐︾殑瀹為檯鍚堝悓閲戦
- if (byId.getShippingId() != null) {
- ShippingInfo shippingInfo = shippingInfoService.getById(byId.getShippingId());
- if (shippingInfo != null && shippingInfo.getSalesLedgerId() != null) {
- SalesLedger salesLedger = salesLedgerMapper.selectById(shippingInfo.getSalesLedgerId());
- if (salesLedger != null && salesLedger.getContractAmount() != null) {
- BigDecimal baseAmount = salesLedger.getNetContractAmount() != null
- ? salesLedger.getNetContractAmount()
- : salesLedger.getContractAmount();
- salesLedger.setNetContractAmount(baseAmount.subtract(totalRefund));
- salesLedgerMapper.updateById(salesLedger);
- }
- }
- }
+ salesRefundAmountOrder.setRefundAmount(bigDecimal);
+ salesRefundAmountOrder.setNotRefundedAmount(salesRefundAmountOrder.getRefundedAmount());
return true;
}
diff --git a/src/main/java/com/ruoyi/purchase/controller/AccountingReportController.java b/src/main/java/com/ruoyi/purchase/controller/AccountingReportController.java
index 798112b..bc2aa48 100644
--- a/src/main/java/com/ruoyi/purchase/controller/AccountingReportController.java
+++ b/src/main/java/com/ruoyi/purchase/controller/AccountingReportController.java
@@ -1,12 +1,15 @@
package com.ruoyi.purchase.controller;
+import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruoyi.basic.service.ISupplierService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
+import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.framework.web.domain.R;
import com.ruoyi.purchase.dto.VatDto;
+import com.ruoyi.purchase.dto.VatSummaryDto;
import com.ruoyi.purchase.service.PurchaseReportService;
import com.ruoyi.purchase.vo.PurchaseReportVo;
import io.swagger.v3.oas.annotations.Operation;
@@ -29,49 +32,62 @@
private final ISupplierService supplierService;
private final PurchaseReportService purchaseReportService;
-
@GetMapping("/list")
@Log(title = "閲囪喘鎶ヨ〃-椤圭洰鍒╂鼎", businessType = BusinessType.OTHER)
public R list(Page page, String customerName) {
- return R.ok(purchaseReportService.list(page,customerName));
+ return R.ok(purchaseReportService.list(page, customerName));
}
@Log(title = "閲囪喘鎶ヨ〃-椤圭洰鍒╂鼎瀵煎嚭", businessType = BusinessType.EXPORT)
@PostMapping("/export")
@Operation(summary = "閲囪喘鎶ヨ〃-椤圭洰鍒╂鼎瀵煎嚭")
public void export(HttpServletResponse response, String customerName) {
- List<PurchaseReportVo> list = purchaseReportService.list(new Page(1,-1),customerName).getRecords();
+ List<PurchaseReportVo> list = purchaseReportService.list(new Page(1, -1), customerName).getRecords();
ExcelUtil<PurchaseReportVo> util = new ExcelUtil<>(PurchaseReportVo.class);
- util.exportExcel(response, list , "椤圭洰鍒╂鼎");
-
+ util.exportExcel(response, list, "椤圭洰鍒╂鼎");
}
@Log(title = "閲囪喘鎶ヨ〃-澧炲�肩◣姣斿", businessType = BusinessType.OTHER)
@GetMapping("/listVat")
- public R listVat(Page page,String month) {
- return R.ok(purchaseReportService.listVat(page,month));
+ public R listVat(Page page, String month, String type) {
+ return R.ok(purchaseReportService.listVat(page, month, type));
}
@Log(title = "閲囪喘鎶ヨ〃-澧炲�肩◣姣斿", businessType = BusinessType.EXPORT)
@PostMapping("/exportTwo")
- @Operation(summary = "閲囪喘鎶ヨ〃-澧炲�肩◣姣斿")
- public void exportTwo(HttpServletResponse response,String month) {
- List<VatDto> list = purchaseReportService.listVat(new Page(1,-1),month).getRecords();
+ @Operation(summary = "閲囪喘鎶ヨ〃-澧炲�肩◣姣斿瀵煎嚭")
+ public void exportTwo(HttpServletResponse response, String month) {
+ List<VatDto> list = purchaseReportService.listVat(new Page(1, -1), month, null).getRecords();
ExcelUtil<VatDto> util = new ExcelUtil<>(VatDto.class);
- util.exportExcel(response, list , "澧炲�肩◣姣斿");
+ util.exportExcel(response, list, "澧炲�肩◣姣斿");
+ }
+
+ @Log(title = "閲囪喘鎶ヨ〃-澧炲�肩◣鍥捐〃鏁版嵁", businessType = BusinessType.OTHER)
+ @GetMapping("/vatChart")
+ @Operation(summary = "澧炲�肩◣杩涢攢椤瑰姣斿浘琛ㄦ暟鎹�")
+ public R vatChart(String year) {
+ List<VatSummaryDto> list = purchaseReportService.vatSummary(year);
+ return R.ok(list);
+ }
+
+ @GetMapping("/listVatDetail")
+ @Operation(summary = "澧炲�肩◣鏄庣粏-鎸夊彂绁�/璁㈠崟灞曠ず")
+ public AjaxResult listVatDetail(Page page, String month) {
+ IPage<VatDto> result = purchaseReportService.listVatDetail(page, month);
+ return AjaxResult.success(result);
}
@GetMapping("/supplierTransactions")
@Log(title = "渚涘簲鍟嗗線鏉�", businessType = BusinessType.OTHER)
@Operation(summary = "渚涘簲鍟嗗線鏉�")
public R supplierTransactions(Page page, String supplierName) {
- return R.ok(supplierService.supplierTransactions(page,supplierName));
+ return R.ok(supplierService.supplierTransactions(page, supplierName));
}
@GetMapping("/supplierTransactionsDetails")
@Log(title = "渚涘簲鍟嗗線鏉ユ槑缁�", businessType = BusinessType.OTHER)
@Operation(summary = "渚涘簲鍟嗗線鏉ユ槑缁�")
public R supplierTransactionsDetails(Page page, Long supplierId) {
- return R.ok(supplierService.supplierTransactionsDetails(page,supplierId));
+ return R.ok(supplierService.supplierTransactionsDetails(page, supplierId));
}
}
diff --git a/src/main/java/com/ruoyi/purchase/dto/VatDto.java b/src/main/java/com/ruoyi/purchase/dto/VatDto.java
index 3564183..62ceff2 100644
--- a/src/main/java/com/ruoyi/purchase/dto/VatDto.java
+++ b/src/main/java/com/ruoyi/purchase/dto/VatDto.java
@@ -1,19 +1,59 @@
package com.ruoyi.purchase.dto;
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
+import com.fasterxml.jackson.annotation.JsonFormat;
import com.ruoyi.framework.aspectj.lang.annotation.Excel;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.math.BigDecimal;
+import java.time.LocalDate;
+
@Data
-@Schema(name = "VatDto", description = "绠$悊椹鹃┒鑸�--澧炲�肩◣姣斿鍙傛暟")
+@Schema(name = "VatDto", description = "澧炲�肩◣姣斿鏄庣粏")
@ExcelIgnoreUnannotated
public class VatDto {
+ @Excel(name = "ID")
+ @Schema(description = "鍙戠エID")
+ private Long id;
+
+ @Excel(name = "鍙戠エ鍙风爜")
+ @Schema(description = "鍙戠エ鍙风爜")
+ private String invoiceNumber;
+
+ @Excel(name = "寮�绁ㄦ棩鏈�")
+ @Schema(description = "寮�绁ㄦ棩鏈�")
+ @JsonFormat(pattern = "yyyy-MM-dd")
+ private LocalDate issueDate;
+
+ @Excel(name = "绫诲瀷")
+ @Schema(description = "绫诲瀷 sales-閿�椤� purchase-杩涢」")
+ private String type;
+
+ @Excel(name = "鍙戠エ绫诲瀷")
+ @Schema(description = "鍙戠エ绫诲瀷")
+ private String invoiceType;
+
+ @Excel(name = "绋庨")
+ @Schema(description = "绋庨")
+ private BigDecimal taxAmount;
+
+ @Excel(name = "浠风◣鍚堣")
+ @Schema(description = "浠风◣鍚堣")
+ private BigDecimal totalAmount;
+
+ @Excel(name = "瀹㈡埛鍚嶇О")
+ @Schema(description = "瀹㈡埛鍚嶇О")
+ private String customerName;
+
+ @Excel(name = "渚涘簲鍟嗗悕绉�")
+ @Schema(description = "渚涘簲鍟嗗悕绉�")
+ private String supplierName;
+
@Excel(name = "鏈堜唤")
@Schema(description = "鏈堜唤")
- private String month ;
+ private String month;
@Excel(name = "閿�椤圭◣棰�")
@Schema(description = "閿�椤圭◣棰�")
@@ -23,8 +63,27 @@
@Schema(description = "杩涢」绋庨")
private BigDecimal xTaxAmount;
- @Excel(name = "閿�-杩�")
- @Schema(description = "閿�-杩�")
- private BigDecimal taxAmount;
+ // ========== 鏄庣粏瑙嗗浘瀛楁 ==========
+
+ @Excel(name = "鍙戠エ鍙�")
+ @Schema(description = "鍙戠エ鍙�")
+ private String invoiceNo;
+
+ @Excel(name = "閿�鍞悎鍚屽彿")
+ @Schema(description = "閿�鍞悎鍚屽彿")
+ private String salesContractNo;
+
+ @Excel(name = "璁㈠崟绫诲瀷")
+ @Schema(description = "绫诲瀷 杩涢」/閿�椤�")
+ private String orderType;
+
+ @Excel(name = "寮�绁ㄦ棩鏈�")
+ @Schema(description = "寮�绁ㄦ棩鏈�")
+ @JsonFormat(pattern = "yyyy-MM-dd")
+ private LocalDate invoiceDate;
+
+ @Excel(name = "绋庣巼")
+ @Schema(description = "绋庣巼")
+ private BigDecimal taxRate;
}
diff --git a/src/main/java/com/ruoyi/purchase/pojo/PurchaseLedger.java b/src/main/java/com/ruoyi/purchase/pojo/PurchaseLedger.java
index ec96643..fdac8d3 100644
--- a/src/main/java/com/ruoyi/purchase/pojo/PurchaseLedger.java
+++ b/src/main/java/com/ruoyi/purchase/pojo/PurchaseLedger.java
@@ -119,12 +119,6 @@
* 鍚堝悓閲戦锛堜骇鍝佸惈绋庢�讳环锛�
*/
private BigDecimal contractAmount;
-
- /**
- * 瀹為檯鍚堝悓閲戦锛堟墸鍑忛��璐у悗锛�
- */
- @Schema(description = "瀹為檯鍚堝悓閲戦")
- private BigDecimal netContractAmount;
//
// /**
// * 涓氬姟鍛�
diff --git a/src/main/java/com/ruoyi/purchase/service/PurchaseReportService.java b/src/main/java/com/ruoyi/purchase/service/PurchaseReportService.java
index 4ec6522..3f7d263 100644
--- a/src/main/java/com/ruoyi/purchase/service/PurchaseReportService.java
+++ b/src/main/java/com/ruoyi/purchase/service/PurchaseReportService.java
@@ -1,14 +1,20 @@
package com.ruoyi.purchase.service;
-
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruoyi.purchase.dto.VatDto;
+import com.ruoyi.purchase.dto.VatSummaryDto;
import com.ruoyi.purchase.vo.PurchaseReportVo;
+
+import java.util.List;
public interface PurchaseReportService {
IPage<PurchaseReportVo> list(Page page, String customerName);
- IPage<VatDto> listVat(Page page, String month);
+ IPage<VatDto> listVat(Page page, String month, String type);
+
+ List<VatSummaryDto> vatSummary(String year);
+
+ IPage<VatDto> listVatDetail(Page page, String month);
}
diff --git a/src/main/java/com/ruoyi/purchase/service/impl/PurchaseLedgerServiceImpl.java b/src/main/java/com/ruoyi/purchase/service/impl/PurchaseLedgerServiceImpl.java
index e1e6ffb..777438f 100644
--- a/src/main/java/com/ruoyi/purchase/service/impl/PurchaseLedgerServiceImpl.java
+++ b/src/main/java/com/ruoyi/purchase/service/impl/PurchaseLedgerServiceImpl.java
@@ -162,10 +162,6 @@
purchaseLedger.setRecorderId(purchaseLedgerDto.getRecorderId());
purchaseLedger.setApprovalStatus(1);
- // 鏂板鏃跺垵濮嬪寲瀹為檯鍚堝悓閲戦
- if (purchaseLedger.getId() == null) {
- purchaseLedger.setNetContractAmount(purchaseLedger.getContractAmount());
- }
// 3. 鏂板鎴栨洿鏂颁富琛�
if (purchaseLedger.getId() == null) {
if (!StringUtils.hasText(purchaseLedger.getPurchaseContractNumber())) {
diff --git a/src/main/java/com/ruoyi/purchase/service/impl/PurchaseReportServiceImpl.java b/src/main/java/com/ruoyi/purchase/service/impl/PurchaseReportServiceImpl.java
index 676cf46..9b88ce7 100644
--- a/src/main/java/com/ruoyi/purchase/service/impl/PurchaseReportServiceImpl.java
+++ b/src/main/java/com/ruoyi/purchase/service/impl/PurchaseReportServiceImpl.java
@@ -4,6 +4,7 @@
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruoyi.account.mapper.AccountStatementMapper;
import com.ruoyi.purchase.dto.VatDto;
+import com.ruoyi.purchase.dto.VatSummaryDto;
import com.ruoyi.purchase.service.PurchaseReportService;
import com.ruoyi.purchase.vo.PurchaseReportVo;
import com.ruoyi.sales.mapper.SalesLedgerMapper;
@@ -11,6 +12,7 @@
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
+import java.util.List;
@Service
@Slf4j
@@ -26,7 +28,17 @@
}
@Override
- public IPage<VatDto> listVat(Page page, String month) {
- return accountStatementMapper.selectVatDtoPage(page, month);
+ public IPage<VatDto> listVat(Page page, String month, String type) {
+ return accountStatementMapper.selectVatDtoPage(page, month, type);
+ }
+
+ @Override
+ public List<VatSummaryDto> vatSummary(String year) {
+ return accountStatementMapper.selectVatSummary(year);
+ }
+
+ @Override
+ public IPage<VatDto> listVatDetail(Page page, String month) {
+ return accountStatementMapper.listVatDetail(page, month);
}
}
diff --git a/src/main/java/com/ruoyi/purchase/service/impl/PurchaseReturnOrdersServiceImpl.java b/src/main/java/com/ruoyi/purchase/service/impl/PurchaseReturnOrdersServiceImpl.java
index dd8fa0f..318c36d 100644
--- a/src/main/java/com/ruoyi/purchase/service/impl/PurchaseReturnOrdersServiceImpl.java
+++ b/src/main/java/com/ruoyi/purchase/service/impl/PurchaseReturnOrdersServiceImpl.java
@@ -14,7 +14,6 @@
import com.ruoyi.purchase.mapper.PurchaseLedgerMapper;
import com.ruoyi.purchase.mapper.PurchaseReturnOrderProductsMapper;
import com.ruoyi.purchase.mapper.PurchaseReturnOrdersMapper;
-import com.ruoyi.purchase.pojo.PurchaseLedger;
import com.ruoyi.purchase.pojo.PurchaseReturnOrderProducts;
import com.ruoyi.purchase.pojo.PurchaseReturnOrders;
import com.ruoyi.purchase.service.PurchaseReturnOrdersService;
@@ -29,7 +28,6 @@
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
-import java.math.BigDecimal;
import java.util.List;
/**
@@ -77,18 +75,6 @@
}
}else {
throw new RuntimeException("璇烽�夋嫨閫�璐у晢鍝�");
- }
-
- // 鏇存柊閲囪喘鍙拌处鐨勫疄闄呭悎鍚岄噾棰�
- if (purchaseReturnOrderDto.getPurchaseLedgerId() != null && purchaseReturnOrderDto.getTotalAmount() != null) {
- PurchaseLedger purchaseLedger = purchaseLedgerMapper.selectById(purchaseReturnOrderDto.getPurchaseLedgerId());
- if (purchaseLedger != null) {
- BigDecimal baseAmount = purchaseLedger.getNetContractAmount() != null
- ? purchaseLedger.getNetContractAmount()
- : purchaseLedger.getContractAmount();
- purchaseLedger.setNetContractAmount(baseAmount.subtract(purchaseReturnOrderDto.getTotalAmount()));
- purchaseLedgerMapper.updateById(purchaseLedger);
- }
}
return true;
}
diff --git a/src/main/java/com/ruoyi/sales/controller/SalesLedgerProductController.java b/src/main/java/com/ruoyi/sales/controller/SalesLedgerProductController.java
index 9efcc89..6d45432 100644
--- a/src/main/java/com/ruoyi/sales/controller/SalesLedgerProductController.java
+++ b/src/main/java/com/ruoyi/sales/controller/SalesLedgerProductController.java
@@ -7,13 +7,20 @@
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.framework.web.domain.R;
+import com.ruoyi.procurementrecord.service.ProcurementRecordService;
+import com.ruoyi.procurementrecord.utils.StockUtils;
+import com.ruoyi.purchase.dto.SimpleReturnOrderGroupDto;
+import com.ruoyi.purchase.mapper.PurchaseReturnOrderProductsMapper;
import com.ruoyi.sales.pojo.SalesLedgerProduct;
import com.ruoyi.sales.service.ISalesLedgerProductService;
import jakarta.servlet.http.HttpServletResponse;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
+import java.math.BigDecimal;
import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
/**
* 浜у搧淇℃伅Controller
@@ -27,6 +34,9 @@
public class SalesLedgerProductController extends BaseController
{
private final ISalesLedgerProductService salesLedgerProductService;
+ private final ProcurementRecordService procurementRecordService;
+ private final StockUtils stockUtils;
+ private final PurchaseReturnOrderProductsMapper purchaseReturnOrderProductsMapper;
/**
@@ -35,25 +45,26 @@
@GetMapping("/list")
public AjaxResult list(SalesLedgerProduct salesLedgerProduct) {
List<SalesLedgerProduct> list = salesLedgerProductService.selectSalesLedgerProductList(salesLedgerProduct);
- if (CollUtil.isNotEmpty(list)) {
- list.forEach(item -> {
- if (item.getApproveStatus() != 2) {
- if (item.getHasSufficientStock() == 0) {
- item.setApproveStatus(0);
- } else {
- item.setApproveStatus(1);
- }
- }
- java.math.BigDecimal returnQuantity = item.getReturnQuantity() == null
- ? java.math.BigDecimal.ZERO
- : item.getReturnQuantity();
- java.math.BigDecimal quantity = item.getQuantity() == null
- ? java.math.BigDecimal.ZERO
- : item.getQuantity();
- item.setReturnQuantity(returnQuantity);
- item.setAvailableQuality(quantity.subtract(returnQuantity));
- });
+ if (CollUtil.isEmpty(list)) {
+ return AjaxResult.success(list);
}
+ List<Long> productIds = list.stream().map(SalesLedgerProduct::getProductModelId).collect(Collectors.toList());
+ List<SimpleReturnOrderGroupDto> groupListByProductIds = purchaseReturnOrderProductsMapper.getReturnOrderGroupListByProductIds(productIds);
+ Map<Long, BigDecimal> returnOrderGroupDtoMap = groupListByProductIds.stream().collect(Collectors.toMap(SimpleReturnOrderGroupDto::getProductModelId, item -> item.getSumReturnQuantity()));
+
+ list.forEach(item -> {
+ if (item.getApproveStatus() != 2) {
+ if (item.getHasSufficientStock() == 0) {
+ item.setApproveStatus(0);
+ } else {
+ item.setApproveStatus(1);
+ }
+ }
+ // 缁熻閫�璐ф暟閲�
+ BigDecimal returnQuality = returnOrderGroupDtoMap.getOrDefault(item.getProductModelId(), BigDecimal.ZERO);
+ item.setReturnQuality(returnQuality);
+ item.setAvailableQuality(item.getQuantity().subtract(returnQuality));
+ });
return AjaxResult.success(list);
}
diff --git a/src/main/java/com/ruoyi/sales/dto/SalesLedgerDto.java b/src/main/java/com/ruoyi/sales/dto/SalesLedgerDto.java
index a4fc57c..c119e94 100644
--- a/src/main/java/com/ruoyi/sales/dto/SalesLedgerDto.java
+++ b/src/main/java/com/ruoyi/sales/dto/SalesLedgerDto.java
@@ -19,7 +19,7 @@
private String salesContractNo;
private String customerContractNo;
private String projectName;
- @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
+ @JsonFormat(pattern = "yyyy-MM-dd")
private Date entryDate;
private String entryDateStart;
diff --git a/src/main/java/com/ruoyi/sales/mapper/SalesLedgerProductMapper.java b/src/main/java/com/ruoyi/sales/mapper/SalesLedgerProductMapper.java
index 2615d19..dd29a7e 100644
--- a/src/main/java/com/ruoyi/sales/mapper/SalesLedgerProductMapper.java
+++ b/src/main/java/com/ruoyi/sales/mapper/SalesLedgerProductMapper.java
@@ -32,8 +32,12 @@
List<Map<String, Object>> selectProductSalesAnalysis();
+ List<Map<String, Object>> selectProductSalesAnalysisByDate(@Param("startDate") String startDate, @Param("endDate") String endDate);
+
List<Map<String, Object>> selectRawMaterialPurchaseAnalysis();
+ List<Map<String, Object>> selectRawMaterialPurchaseAnalysisByDate(@Param("startDate") String startDate, @Param("endDate") String endDate);
+
int selectProductCountByTypeAndDate(@Param("type") Integer type, @Param("startDate") LocalDateTime startDate, @Param("endDate") LocalDateTime endDate);
BigDecimal selectRawMaterialExpense();
diff --git a/src/main/java/com/ruoyi/sales/pojo/SalesLedger.java b/src/main/java/com/ruoyi/sales/pojo/SalesLedger.java
index c8a0443..00736ba 100644
--- a/src/main/java/com/ruoyi/sales/pojo/SalesLedger.java
+++ b/src/main/java/com/ruoyi/sales/pojo/SalesLedger.java
@@ -50,7 +50,7 @@
/**
* 褰曞叆鏃ユ湡
*/
- @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
+ @JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "褰曞叆鏃ユ湡", width = 30, dateFormat = "yyyy-MM-dd")
@DateTimeFormat(pattern = "yyyy-MM-dd")
private Date entryDate;
@@ -108,9 +108,6 @@
@Schema(description = "浠樻鏂瑰紡")
private String paymentMethod;
-
- @Schema(description = "瀹為檯鍚堝悓閲戦")
- private BigDecimal netContractAmount;
@TableField(exist = false)
@Schema(description = "鐢熶骇鐘舵��")
diff --git a/src/main/java/com/ruoyi/sales/pojo/SalesLedgerProduct.java b/src/main/java/com/ruoyi/sales/pojo/SalesLedgerProduct.java
index 4aa9ff5..d9f8eff 100644
--- a/src/main/java/com/ruoyi/sales/pojo/SalesLedgerProduct.java
+++ b/src/main/java/com/ruoyi/sales/pojo/SalesLedgerProduct.java
@@ -164,7 +164,11 @@
@TableField(exist = false)
private Integer hasSufficientStock;
- // 鍙敤鏁伴噺 quantity - returnQuantity
+ // 閫�璐ф暟閲�
+ @TableField(exist = false)
+ private BigDecimal returnQuality;
+
+ // 鍙敤鏁伴噺 quantity - returnQuality
@TableField(exist = false)
private BigDecimal availableQuality;
@Schema(description = "鍒涘缓鐢ㄦ埛")
@@ -181,10 +185,6 @@
@TableField(exist = false)
@Schema(description = "寰呭彂璐ф暟閲�")
private BigDecimal noQuantity;
-
- @TableField(exist = false)
- @Schema(description = "閫�璐ф暟閲�")
- private BigDecimal returnQuantity;
@TableField(exist = false)
@Schema(description = "瀹℃壒涓暟閲�")
diff --git a/src/main/java/com/ruoyi/sales/service/impl/SalesLedgerProductServiceImpl.java b/src/main/java/com/ruoyi/sales/service/impl/SalesLedgerProductServiceImpl.java
index 92c44c3..b8042d8 100644
--- a/src/main/java/com/ruoyi/sales/service/impl/SalesLedgerProductServiceImpl.java
+++ b/src/main/java/com/ruoyi/sales/service/impl/SalesLedgerProductServiceImpl.java
@@ -98,27 +98,16 @@
List<SalesLedgerProduct> salesLedgerProducts = salesLedgerProductMapper.selectSalesLedgerProductList(salesLedgerProduct);
if(!CollectionUtils.isEmpty(salesLedgerProducts)){
salesLedgerProducts.forEach(item -> {
- // 鍙戣揣淇℃伅锛堝彇鏈�鏂颁竴鏉★級
- ShippingInfo latestShippingInfo = shippingInfoMapper.selectOne(new LambdaQueryWrapper<ShippingInfo>()
+ // 鍙戣揣淇℃伅
+ ShippingInfo shippingInfo = shippingInfoMapper.selectOne(new LambdaQueryWrapper<ShippingInfo>()
.eq(ShippingInfo::getSalesLedgerProductId, item.getId())
.orderByDesc(ShippingInfo::getCreateTime)
.last("limit 1"));
- if(latestShippingInfo != null){
- item.setShippingDate(latestShippingInfo.getShippingDate());
- item.setExpressCompany(latestShippingInfo.getExpressCompany());
- item.setExpressNumber(latestShippingInfo.getExpressNumber());
- }
- // 杞︾墝鍙凤細鍙栨墍鏈夊彂璐ц褰曠殑杞︾墝鍙凤紝閫楀彿鎷兼帴
- List<ShippingInfo> allShippingInfos = shippingInfoMapper.selectList(new LambdaQueryWrapper<ShippingInfo>()
- .eq(ShippingInfo::getSalesLedgerProductId, item.getId())
- .orderByAsc(ShippingInfo::getCreateTime));
- if(!CollectionUtils.isEmpty(allShippingInfos)){
- String carNumbers = allShippingInfos.stream()
- .map(ShippingInfo::getShippingCarNumber)
- .filter(carNo -> carNo != null && !carNo.trim().isEmpty())
- .distinct()
- .collect(Collectors.joining(","));
- item.setShippingCarNumber(carNumbers);
+ if(shippingInfo != null){
+ item.setShippingDate(shippingInfo.getShippingDate());
+ item.setShippingCarNumber(shippingInfo.getShippingCarNumber());
+ item.setExpressCompany(shippingInfo.getExpressCompany());
+ item.setExpressNumber(shippingInfo.getExpressNumber());
}
});
}
diff --git a/src/main/java/com/ruoyi/sales/service/impl/SalesLedgerServiceImpl.java b/src/main/java/com/ruoyi/sales/service/impl/SalesLedgerServiceImpl.java
index d19edad..b3a7727 100644
--- a/src/main/java/com/ruoyi/sales/service/impl/SalesLedgerServiceImpl.java
+++ b/src/main/java/com/ruoyi/sales/service/impl/SalesLedgerServiceImpl.java
@@ -38,6 +38,8 @@
import com.ruoyi.project.system.domain.SysUser;
import com.ruoyi.project.system.mapper.SysDeptMapper;
import com.ruoyi.project.system.mapper.SysUserMapper;
+import com.ruoyi.purchase.dto.SimpleReturnOrderGroupDto;
+import com.ruoyi.purchase.mapper.PurchaseReturnOrderProductsMapper;
import com.ruoyi.quality.mapper.QualityInspectMapper;
import com.ruoyi.sales.dto.*;
import com.ruoyi.sales.mapper.CommonFileMapper;
@@ -119,6 +121,9 @@
@Autowired
private ProductionProductMainService productionProductMainService;
@Autowired
+ private PurchaseReturnOrderProductsMapper purchaseReturnOrderProductsMapper;
+ ;
+ @Autowired
private SysUserMapper sysUserMapper;
@Override
@@ -143,11 +148,17 @@
productWrapper.eq(SalesLedgerProduct::getType, type.getCode());
List<SalesLedgerProduct> salesLedgerProducts = salesLedgerProductMapper.selectList(productWrapper);
if (type.equals(SaleEnum.PURCHASE)) {
+ // 鏌ヨ閫�璐т俊鎭�
+ List<Long> productIds = salesLedgerProducts.stream().map(SalesLedgerProduct::getProductModelId).collect(Collectors.toList());
+ List<SimpleReturnOrderGroupDto> groupListByProductIds = new ArrayList<>();
+ if(CollectionUtils.isNotEmpty(productIds)){
+ groupListByProductIds = purchaseReturnOrderProductsMapper.getReturnOrderGroupListByProductIds(productIds);
+ }
+ Map<Long, BigDecimal> returnOrderGroupDtoMap = groupListByProductIds.stream().collect(Collectors.toMap(SimpleReturnOrderGroupDto::getProductModelId, SimpleReturnOrderGroupDto::getSumReturnQuantity));
salesLedgerProducts.forEach(item -> {
- BigDecimal returnQuantity = item.getReturnQuantity() == null ? BigDecimal.ZERO : item.getReturnQuantity();
- item.setReturnQuantity(returnQuantity);
- BigDecimal quantity = item.getQuantity() == null ? BigDecimal.ZERO : item.getQuantity();
- item.setAvailableQuality(quantity.subtract(returnQuantity));
+ BigDecimal returnQuality = returnOrderGroupDtoMap.getOrDefault(item.getProductModelId(), BigDecimal.ZERO);
+ item.setReturnQuality(returnQuality);
+ item.setAvailableQuality(item.getQuantity().subtract(returnQuality));
});
}
return salesLedgerProducts;
@@ -590,18 +601,7 @@
);
}
- // 5. 鍏滃簳锛氱‘淇濆疄闄呭悎鍚岄噾棰濇湁鍒濆鍊肩瓑浜庡悎鍚岄噾棰�
- if (salesLedger.getNetContractAmount() == null) {
- SalesLedger dbLedger = salesLedgerMapper.selectById(salesLedger.getId());
- if (dbLedger != null && dbLedger.getNetContractAmount() == null && dbLedger.getContractAmount() != null) {
- SalesLedger updateEntity = new SalesLedger();
- updateEntity.setId(salesLedger.getId());
- updateEntity.setNetContractAmount(dbLedger.getContractAmount());
- salesLedgerMapper.updateById(updateEntity);
- }
- }
-
- // 6. 淇濆瓨閿�鍞彴璐﹂檮浠�
+ // 5. 淇濆瓨閿�鍞彴璐﹂檮浠�
fileUtil.saveStorageAttachment(ApplicationTypeEnum.FILE, RecordTypeEnum.SALES_LEDGER, salesLedger.getId(), salesLedgerDto.getStorageBlobDTOs());
return 1;
@@ -738,15 +738,6 @@
Field amountField = mainEntityClass.getDeclaredField("contractAmount");
amountField.setAccessible(true);
amountField.set(entity, totalAmount);
-
- // 瀹為檯鍚堝悓閲戦鍒濆鍊肩瓑浜庡悎鍚岄噾棰�
- try {
- Field netAmountField = mainEntityClass.getDeclaredField("netContractAmount");
- netAmountField.setAccessible(true);
- netAmountField.set(entity, totalAmount);
- } catch (NoSuchFieldException ignored) {
- // 瀛愮被鍙兘娌℃湁璇ュ瓧娈碉紝蹇界暐
- }
mainMapper.updateById(entity);
} catch (Exception e) {
diff --git a/src/main/resources/application-dev.yml b/src/main/resources/application-dev.yml
index e5e2f9a..f1a5bf9 100644
--- a/src/main/resources/application-dev.yml
+++ b/src/main/resources/application-dev.yml
@@ -74,7 +74,7 @@
druid:
# 涓诲簱鏁版嵁婧�
master:
- url: jdbc:mysql://localhost:3306/product-inventory-management-bdpro?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
+ url: jdbc:mysql://localhost:3306/product-inventory-management-new-pro?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
username: root
password: 123456
# 浠庡簱鏁版嵁婧�
diff --git a/src/main/resources/mapper/account/AccountStatementMapper.xml b/src/main/resources/mapper/account/AccountStatementMapper.xml
index 32b1621..324d243 100644
--- a/src/main/resources/mapper/account/AccountStatementMapper.xml
+++ b/src/main/resources/mapper/account/AccountStatementMapper.xml
@@ -41,38 +41,129 @@
ORDER BY lj.statement_month DESC
</select>
<select id="selectVatDtoPage" resultType="com.ruoyi.purchase.dto.VatDto">
- SELECT
- month,
- jTaxAmount,
- xTaxAmount,
- (jTaxAmount - xTaxAmount) AS taxAmount
- FROM (
+ SELECT * FROM (
+ SELECT
+ asi.id,
+ asi.invoice_number AS invoiceNumber,
+ asi.issue_date AS issueDate,
+ 'sales' AS type,
+ asi.invoice_type AS invoiceType,
+ asi.tax_price AS taxAmount,
+ asi.tax_inclusive_price AS totalAmount,
+ c.customer_name AS customerName,
+ NULL AS supplierName,
+ DATE_FORMAT(asi.issue_date, '%Y-%m') AS month
+ FROM account_sales_invoice asi
+ LEFT JOIN customer c ON c.id = asi.customer_id
+ WHERE (asi.status IS NULL OR asi.status = 0)
+ UNION ALL
+ SELECT
+ api.id,
+ api.invoice_number AS invoiceNumber,
+ api.issue_date AS issueDate,
+ 'purchase' AS type,
+ api.invoice_type AS invoiceType,
+ api.tax_price AS taxAmount,
+ api.tax_inclusive_price AS totalAmount,
+ NULL AS customerName,
+ s.supplier_name AS supplierName,
+ DATE_FORMAT(api.issue_date, '%Y-%m') AS month
+ FROM account_purchase_invoice api
+ LEFT JOIN supplier_manage s ON s.id = api.supplier_id
+ WHERE (api.status IS NULL OR api.status = 0)
+ ) AS invoice_detail
+ <where>
+ <if test="month != null and month != ''">
+ AND month = #{month}
+ </if>
+ <if test="type != null and type != ''">
+ AND type = #{type}
+ </if>
+ </where>
+ ORDER BY issueDate DESC, type
+ </select>
+
+ <select id="selectVatSummary" resultType="com.ruoyi.purchase.dto.VatSummaryDto">
SELECT
month,
- SUM(IF(type = 'purchase', tax_price, 0)) AS xTaxAmount,
- SUM(IF(type = 'sales', tax_price, 0)) AS jTaxAmount
+ SUM(jTaxAmount) AS jTaxAmount,
+ SUM(xTaxAmount) AS xTaxAmount,
+ SUM(jTaxAmount) - SUM(xTaxAmount) AS taxAmount
FROM (
SELECT
DATE_FORMAT(issue_date, '%Y-%m') AS month,
- tax_price,
- 'sales' AS type
+ SUM(tax_price) AS jTaxAmount,
+ 0 AS xTaxAmount
FROM account_sales_invoice
- WHERE status != 1
+ WHERE (status IS NULL OR status = 0)
+ <if test="year != null and year != ''">
+ AND YEAR(issue_date) = #{year}
+ </if>
+ GROUP BY DATE_FORMAT(issue_date, '%Y-%m')
UNION ALL
SELECT
DATE_FORMAT(issue_date, '%Y-%m') AS month,
- tax_price,
- 'purchase' AS type
+ 0 AS jTaxAmount,
+ SUM(tax_price) AS xTaxAmount
FROM account_purchase_invoice
- WHERE status != 1
- ) AS all_data
- GROUP BY month
- ) AS TT
- <where>
- <if test="month != null">
- and TT.month = #{month}
+ WHERE (status IS NULL OR status = 0)
+ <if test="year != null and year != ''">
+ AND YEAR(issue_date) = #{year}
</if>
- </where>
- ORDER BY TT.month
+ GROUP BY DATE_FORMAT(issue_date, '%Y-%m')
+ ) t
+ GROUP BY month
+ ORDER BY month
+ </select>
+
+ <select id="listVatDetail" resultType="com.ruoyi.purchase.dto.VatDto">
+ SELECT *
+ FROM (
+ -- 杩涢」绋庢槑缁嗭紙閲囪喘璁㈠崟锛�
+ SELECT
+ pl.purchase_contract_number AS invoiceNo,
+ pl.sales_contract_no AS salesContractNo,
+ pl.supplier_name AS supplierName,
+ NULL AS customerName,
+ '杩涢」' AS orderType,
+ pl.entry_date AS invoiceDate,
+ slp.tax_rate AS taxRate,
+ ROUND(SUM(slp.tax_inclusive_total_price - slp.tax_exclusive_total_price), 2) AS jTaxAmount,
+ 0 AS xTaxAmount,
+ ROUND(SUM(slp.tax_inclusive_total_price - slp.tax_exclusive_total_price), 2) AS taxAmount
+ FROM sales_ledger_product slp
+ LEFT JOIN purchase_ledger pl ON pl.id = slp.sales_ledger_id
+ WHERE slp.type = 2
+ AND slp.tax_rate IS NOT NULL
+ AND slp.tax_rate > 0
+ GROUP BY pl.id
+
+ UNION ALL
+
+ -- 閿�椤圭◣鏄庣粏锛堥攢鍞鍗曪級
+ SELECT
+ sl.sales_contract_no AS invoiceNo,
+ sl.sales_contract_no AS salesContractNo,
+ NULL AS supplierName,
+ sl.customer_name AS customerName,
+ '閿�椤�' AS orderType,
+ sl.entry_date AS invoiceDate,
+ slp.tax_rate AS taxRate,
+ 0 AS jTaxAmount,
+ ROUND(SUM(slp.tax_inclusive_total_price - slp.tax_exclusive_total_price), 2) AS xTaxAmount,
+ ROUND(SUM(slp.tax_inclusive_total_price - slp.tax_exclusive_total_price), 2) AS taxAmount
+ FROM sales_ledger_product slp
+ LEFT JOIN sales_ledger sl ON sl.id = slp.sales_ledger_id
+ WHERE slp.type = 1
+ AND slp.tax_rate IS NOT NULL
+ AND slp.tax_rate > 0
+ GROUP BY sl.id
+ ) a
+ <where>
+ <if test="month != null and month != ''">
+ AND DATE_FORMAT(a.invoiceDate, '%Y-%m') = #{month}
+ </if>
+ </where>
+ ORDER BY a.invoiceDate DESC
</select>
</mapper>
diff --git a/src/main/resources/mapper/home/HomeMapper.xml b/src/main/resources/mapper/home/HomeMapper.xml
index 060099a..71a4df6 100644
--- a/src/main/resources/mapper/home/HomeMapper.xml
+++ b/src/main/resources/mapper/home/HomeMapper.xml
@@ -13,4 +13,28 @@
GROUP BY p.id, p.product_name
</select>
+ <select id="productTurnoverDaysByDate" resultType="com.ruoyi.dto.MapDto">
+ SELECT p.product_name AS name,
+ DATEDIFF(IFNULL(MAX(sor.create_time), NOW()), MAX(sir.create_time)) AS value
+ FROM product p
+ JOIN product_model pm ON p.id = pm.product_id
+ JOIN stock_in_record sir ON pm.id = sir.product_model_id
+ AND sir.create_time >= #{startDate}
+ AND sir.create_time <= #{endDate}
+ LEFT JOIN stock_out_record sor ON pm.id = sor.product_model_id
+ GROUP BY p.id, p.product_name
+ </select>
+
+ <select id="selectPurchaseCategoryDistribution" resultType="com.ruoyi.dto.MapDto">
+ SELECT p2.product_name AS name,
+ COUNT(DISTINCT slp.id) AS value
+ FROM sales_ledger_product slp
+ LEFT JOIN product p ON p.id = slp.product_category
+ LEFT JOIN product p2 ON p2.id = p.parent_id
+ WHERE slp.type = 2
+ AND p.parent_id IS NOT NULL
+ GROUP BY p2.product_name
+ ORDER BY value DESC
+ </select>
+
</mapper>
diff --git a/src/main/resources/mapper/sales/SalesLedgerMapper.xml b/src/main/resources/mapper/sales/SalesLedgerMapper.xml
index 2d6b7f8..a5650f9 100644
--- a/src/main/resources/mapper/sales/SalesLedgerMapper.xml
+++ b/src/main/resources/mapper/sales/SalesLedgerMapper.xml
@@ -56,7 +56,6 @@
T1.attachment_materials,
T1.tenant_id,
T1.contract_amount,
- T1.net_contract_amount,
T1.contract_amount AS noInvoiceAmountTotal,
T1.execution_date,
T2.nick_name AS entry_person_name,
diff --git a/src/main/resources/mapper/sales/SalesLedgerProductMapper.xml b/src/main/resources/mapper/sales/SalesLedgerProductMapper.xml
index b39b720..6059825 100644
--- a/src/main/resources/mapper/sales/SalesLedgerProductMapper.xml
+++ b/src/main/resources/mapper/sales/SalesLedgerProductMapper.xml
@@ -34,7 +34,6 @@
ELSE 0
END as has_sufficient_stock,
(IFNULL(T1.quantity, 0) - IFNULL(t3.shipped_quantity, 0) - IFNULL(t5.pending_approval_quantity, 0)) as no_quantity,
- IFNULL(t6.return_quantity, 0) as return_quantity,
IFNULL(t5.pending_approval_quantity, 0) as pending_approval_quantity,
CASE
WHEN IFNULL(t3.shipped_quantity, 0) = 0 AND IFNULL(t5.pending_approval_quantity, 0) = 0 THEN '寰呭彂璐�'
@@ -114,14 +113,6 @@
))
GROUP BY si.sales_ledger_product_id
) t5 ON t5.sales_ledger_product_id = T1.id
- LEFT JOIN (
- SELECT si.sales_ledger_product_id, IFNULL(SUM(rsp.num), 0) AS return_quantity
- FROM return_management rm
- INNER JOIN return_sale_product rsp ON rm.id = rsp.return_management_id
- INNER JOIN shipping_info si ON rm.shipping_id = si.id
- WHERE rm.status = 1
- GROUP BY si.sales_ledger_product_id
- ) t6 ON t6.sales_ledger_product_id = T1.id
left join product_model pm ON T1.product_model_id = pm.id
left join product p ON pm.product_id = p.id
<where>
@@ -228,7 +219,29 @@
LIMIT 5
</select>
+ <select id="selectProductSalesAnalysisByDate" resultType="java.util.Map">
+ SELECT
+ product_category as name,
+ SUM( tax_inclusive_total_price ) AS value
+ FROM
+ sales_ledger_product
+ WHERE
+ type = 1
+ AND register_date >= #{startDate}
+ AND register_date <= #{endDate}
+ GROUP BY
+ product_category
+ ORDER BY
+ value DESC
+ LIMIT 5
+ </select>
+
<select id="selectRawMaterialPurchaseAnalysis" resultType="java.util.Map">
+ WITH RECURSIVE raw_material_tree AS (
+ SELECT id FROM product WHERE product_name = '鍘熸潗鏂�' AND parent_id IS NULL
+ UNION ALL
+ SELECT p.id FROM product p INNER JOIN raw_material_tree rmt ON p.parent_id = rmt.id
+ )
SELECT
pr.product_name AS name,
SUM( slp.tax_inclusive_total_price ) AS value
@@ -237,6 +250,26 @@
JOIN product pr ON slp.product_id = pr.id
WHERE
slp.type = 2
+ AND pr.id IN (SELECT id FROM raw_material_tree)
+ GROUP BY
+ pr.id,
+ pr.product_name
+ ORDER BY
+ value DESC
+ LIMIT 5
+ </select>
+
+ <select id="selectRawMaterialPurchaseAnalysisByDate" resultType="java.util.Map">
+ SELECT
+ pr.product_name AS name,
+ SUM( slp.tax_inclusive_total_price ) AS value
+ FROM
+ sales_ledger_product slp
+ JOIN product pr ON slp.product_id = pr.id
+ WHERE
+ slp.type = 2
+ AND slp.register_date >= #{startDate}
+ AND slp.register_date <= #{endDate}
AND pr.parent_id = ( SELECT id FROM product WHERE product_name = '鍘熸潗鏂�' )
GROUP BY
pr.id,
@@ -261,7 +294,7 @@
<select id="selectRawMaterialExpense" resultType="java.math.BigDecimal">
WITH RECURSIVE product_tree AS (SELECT id
FROM product
- WHERE product_name = '鍘熸潗鏂�'
+ WHERE product_name = '鍘熸潗鏂�' AND parent_id IS NULL
UNION ALL
diff --git a/src/main/resources/mapper/sales/ShippingInfoMapper.xml b/src/main/resources/mapper/sales/ShippingInfoMapper.xml
index 6fc1842..762c2d4 100644
--- a/src/main/resources/mapper/sales/ShippingInfoMapper.xml
+++ b/src/main/resources/mapper/sales/ShippingInfoMapper.xml
@@ -101,9 +101,8 @@
order by sor.id
</select>
<select id="getShippingInfoByCustomerName" resultType="com.ruoyi.sales.pojo.ShippingInfo">
- select distinct si.* from shipping_info si
+ select * from shipping_info si
left join sales_ledger sl on si.sales_ledger_id = sl.id
- inner join stock_out_record sor on sor.record_id = si.id and sor.record_type = '13' and sor.approval_status = 1
- where sl.customer_name = #{customerName} and si.status = '瀹℃牳閫氳繃'
+ where sl.customer_name = #{customerName}
</select>
</mapper>
--
Gitblit v1.9.3