Compare commits
16
Commits
c2e3de244b
..
dev
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
43b95f3f07 | ||
|
|
44f2579e3f | ||
|
|
ca5b6e4672 | ||
|
|
6b991363c6 | ||
|
|
84c7fa7647 | ||
|
|
c0d2faaaf1 | ||
|
|
8324d8dc31 | ||
|
|
6ce35b58e4 | ||
|
|
700556ea63 | ||
|
|
100a8d87ac | ||
|
|
b0c9a41f07 | ||
|
|
82d5eda139 | ||
|
|
07393e43ff | ||
|
|
08858f24d6 | ||
|
|
a994241400 | ||
|
|
a9be03961a |
@@ -536,12 +536,7 @@ public interface WlhyServiceFeign {
|
|||||||
*/
|
*/
|
||||||
@PostMapping("/feign/order/add")
|
@PostMapping("/feign/order/add")
|
||||||
public AjaxResult add(@RequestBody TmsOrderAddDTO tmsOrderAddDTO);
|
public AjaxResult add(@RequestBody TmsOrderAddDTO tmsOrderAddDTO);
|
||||||
/**
|
|
||||||
* 修改运单(OMS调整业务单后同步修改TMS订单)
|
|
||||||
* @param tmsOrderAddDTO 需携带 TMS 订单 id 定位
|
|
||||||
*/
|
|
||||||
@PostMapping("/feign/order/update")
|
|
||||||
public AjaxResult update(@RequestBody TmsOrderAddDTO tmsOrderAddDTO);
|
|
||||||
@GetMapping("/feign/order/cancelIssueDocuments")
|
@GetMapping("/feign/order/cancelIssueDocuments")
|
||||||
public AjaxResult cancelIssueDocuments(@RequestParam(name="executeOrderId") String executeOrderId);
|
public AjaxResult cancelIssueDocuments(@RequestParam(name="executeOrderId") String executeOrderId);
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ import org.springframework.web.bind.annotation.*;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
// 目标地址由 nacos 配置项 feign.url.xxl-job-service 指定,未配置时按服务名走服务发现
|
// 目标地址由 nacos 配置项 feign.url.xxl-job-service 指定,未配置时按服务名走服务发现
|
||||||
@FeignClient(contextId = "XxlJobService", value = ServiceNameConstants.XXL_JOB_SERVICE,url = "http://127.0.0.1:8020",fallbackFactory = RemoteXxlJobFeignFallbackFactory.class, configuration = FeignAutoConfiguration.class)
|
@FeignClient(contextId = "XxlJobService", value = ServiceNameConstants.XXL_JOB_SERVICE,url = "http://10.102.192.33:8020",fallbackFactory = RemoteXxlJobFeignFallbackFactory.class, configuration = FeignAutoConfiguration.class)
|
||||||
public interface XxlJobServiceFeign {
|
public interface XxlJobServiceFeign {
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
-5
@@ -546,11 +546,6 @@ public class RemoteWlhyFallbackFactory implements FallbackFactory<WlhyServiceFei
|
|||||||
return AjaxResult.error(cause.getMessage());
|
return AjaxResult.error(cause.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public AjaxResult update(TmsOrderAddDTO tmsOrderAddDTO) {
|
|
||||||
return AjaxResult.error(cause.getMessage());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AjaxResult cancelIssueDocuments(String executeOrderId) {
|
public AjaxResult cancelIssueDocuments(String executeOrderId) {
|
||||||
return AjaxResult.error(cause.getMessage());
|
return AjaxResult.error(cause.getMessage());
|
||||||
|
|||||||
+27
@@ -0,0 +1,27 @@
|
|||||||
|
package com.mhd.bi.domain.biComprehensive.repository.mapper;
|
||||||
|
|
||||||
|
import com.mhd.bi.domain.biComprehensive.repository.po.RealFuelStatPO;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 综合态势-真实业务数据 Mapper(跨库查询,与月台监测 BiPlatformRealDataMapper 同方案)
|
||||||
|
*
|
||||||
|
* <p>数据来源:</p>
|
||||||
|
* <ul>
|
||||||
|
* <li>运输订单量:NGWL_TEST_OMS.BUSINESS_DOCUMENT_ORDER(OMS 运输业务单)</li>
|
||||||
|
* <li>百公里油耗:NGWL_TEST_WLHY.TMS_EXPENSE_REPORT(TMS 运输作业单,字段 FUEL_CONSUMPTION / HEAVYLOAD_MILEAGE)</li>
|
||||||
|
* </ul>
|
||||||
|
*/
|
||||||
|
public interface BiComprehensiveRealDataMapper {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 运输订单量:统计本年度(CREATE_TIME 在当前年)全部组织的运输业务单数量。
|
||||||
|
* 统计范围:全部组织,不按机构过滤。
|
||||||
|
*/
|
||||||
|
Long countCurrentYearTransportOrders();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 百公里油耗统计:统计本年度油耗量与重载里程均非空的记录,
|
||||||
|
* 返回 总油耗量 / 总重载里程 / 参与条数,由调用方计算百公里油耗。
|
||||||
|
*/
|
||||||
|
RealFuelStatPO queryCurrentYearFuelStat();
|
||||||
|
}
|
||||||
+26
@@ -0,0 +1,26 @@
|
|||||||
|
package com.mhd.bi.domain.biComprehensive.repository.po;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 百公里油耗统计(真实数据,来自 TMS 运输作业单 TMS_EXPENSE_REPORT)
|
||||||
|
*
|
||||||
|
* <p>统计口径:本年度、全部组织、油耗量(FUEL_CONSUMPTION)与重载里程(HEAVYLOAD_MILEAGE)均非空的记录。</p>
|
||||||
|
* <p>百公里油耗 = 总油耗量 ÷ 总重载里程 × 100</p>
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class RealFuelStatPO implements Serializable {
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/** 总油耗量(仅统计油耗量非空的记录) */
|
||||||
|
private BigDecimal totalOil;
|
||||||
|
|
||||||
|
/** 总重载里程(仅统计重载里程非空的记录,且油量非空) */
|
||||||
|
private BigDecimal totalHeavyMileage;
|
||||||
|
|
||||||
|
/** 参与统计的记录数 */
|
||||||
|
private Long totalCount;
|
||||||
|
}
|
||||||
+63
@@ -0,0 +1,63 @@
|
|||||||
|
package com.mhd.bi.domain.biComprehensive.service;
|
||||||
|
|
||||||
|
import com.mhd.bi.domain.biComprehensive.repository.mapper.BiComprehensiveRealDataMapper;
|
||||||
|
import com.mhd.bi.domain.biComprehensive.repository.po.RealFuelStatPO;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.math.RoundingMode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 综合态势-真实业务数据业务层(封装 OMS / TMS 跨库查询)
|
||||||
|
*
|
||||||
|
* <p>实现方案与「月台监测指标查询」一致:每次调用实时查库,查不到/查库异常返回 0,不影响其它字段。</p>
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
@Service
|
||||||
|
public class BiComprehensiveRealDataService {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private BiComprehensiveRealDataMapper biComprehensiveRealDataMapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 运输订单量:本年度 OMS 运输业务单数量,范围全部组织。
|
||||||
|
* 查询失败或无数据返回 0。
|
||||||
|
*/
|
||||||
|
public long countCurrentYearTransportOrders() {
|
||||||
|
try {
|
||||||
|
Long n = biComprehensiveRealDataMapper.countCurrentYearTransportOrders();
|
||||||
|
return n == null ? 0L : n;
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("【OMS】统计本年度运输订单量失败: {}", e.getMessage(), e);
|
||||||
|
return 0L;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 百公里油耗 = 总油耗量 ÷ 总重载里程 × 100,保留一位小数。
|
||||||
|
*
|
||||||
|
* <p>统计范围:TMS 运输作业单 TMS_EXPENSE_REPORT,本年度、全部组织、油耗量与重载里程均非空。</p>
|
||||||
|
* <p>总重载里程为 0 或查询失败时返回 0,避免除零。</p>
|
||||||
|
*/
|
||||||
|
public double calcCurrentYearFuelConsumptionPerHundredKm() {
|
||||||
|
try {
|
||||||
|
RealFuelStatPO po = biComprehensiveRealDataMapper.queryCurrentYearFuelStat();
|
||||||
|
if (po == null) {
|
||||||
|
return 0d;
|
||||||
|
}
|
||||||
|
BigDecimal totalOil = po.getTotalOil();
|
||||||
|
BigDecimal totalMileage = po.getTotalHeavyMileage();
|
||||||
|
if (totalOil == null || totalMileage == null || totalMileage.compareTo(BigDecimal.ZERO) <= 0) {
|
||||||
|
return 0d;
|
||||||
|
}
|
||||||
|
return totalOil.multiply(BigDecimal.valueOf(100))
|
||||||
|
.divide(totalMileage, 1, RoundingMode.HALF_UP)
|
||||||
|
.doubleValue();
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("【TMS】计算本年度百公里油耗失败: {}", e.getMessage(), e);
|
||||||
|
return 0d;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+79
-1
@@ -1,21 +1,99 @@
|
|||||||
package com.mhd.bi.domain.biComprehensive.service;
|
package com.mhd.bi.domain.biComprehensive.service;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import com.mhd.bi.domain.biComprehensive.repository.mapper.BiComprehensiveReportMapper;
|
import com.mhd.bi.domain.biComprehensive.repository.mapper.BiComprehensiveReportMapper;
|
||||||
|
import com.mhd.bi.domain.biSnapshotSync.repository.mapper.BiSnapshotWriteMapper;
|
||||||
import com.mhd.bi.interfaces.facadeApi.biReport.vo.ComprehensiveSituationVO;
|
import com.mhd.bi.interfaces.facadeApi.biReport.vo.ComprehensiveSituationVO;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
import java.util.LinkedHashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 综合态势:数据访问仅经 Mapper(含 XML 内 SQL 与 Mapper 默认方法组装)。
|
* 综合态势:数据访问仅经 Mapper(含 XML 内 SQL 与 Mapper 默认方法组装)。
|
||||||
|
*
|
||||||
|
* <p>其中「运输订单量」「百公里油耗」为实时查询业务库的真实数据,
|
||||||
|
* 每次调用实时组装并覆盖更新快照表最新一条,实现方案与「月台监测指标查询」一致;</p>
|
||||||
|
* <p>其余字段仍取自 BI_COMPREHENSIVE_SNAPSHOT 最新快照。</p>
|
||||||
|
*
|
||||||
|
* <p>仅当这两项实时数据发生变化时才覆盖更新快照,避免无意义的写库。</p>
|
||||||
*/
|
*/
|
||||||
|
@Slf4j
|
||||||
@Service
|
@Service
|
||||||
public class BiComprehensiveReportService {
|
public class BiComprehensiveReportService {
|
||||||
|
|
||||||
|
private static final String REMARK_REALTIME = "realtime comprehensive";
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private BiComprehensiveReportMapper biComprehensiveReportMapper;
|
private BiComprehensiveReportMapper biComprehensiveReportMapper;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private BiSnapshotWriteMapper biSnapshotWriteMapper;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private BiComprehensiveRealDataService biComprehensiveRealDataService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private ObjectMapper objectMapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 实时组装综合态势:快照其余字段 + 实时业务数据(运输订单量、百公里油耗);
|
||||||
|
* 仅当实时业务数据发生变化时,才覆盖更新 BI_COMPREHENSIVE_SNAPSHOT 快照表最新一条后返回。
|
||||||
|
* 表中尚无记录时插入一条兜底。
|
||||||
|
*/
|
||||||
public ComprehensiveSituationVO loadLatestComprehensive() {
|
public ComprehensiveSituationVO loadLatestComprehensive() {
|
||||||
return biComprehensiveReportMapper.loadLatestComprehensive();
|
ComprehensiveSituationVO vo = biComprehensiveReportMapper.loadLatestComprehensive();
|
||||||
|
if (vo == null) {
|
||||||
|
vo = new ComprehensiveSituationVO();
|
||||||
|
}
|
||||||
|
|
||||||
|
// 实时业务数据:运输订单量(OMS 运输业务单,本年度、全部组织)
|
||||||
|
vo.setOrderCount(biComprehensiveRealDataService.countCurrentYearTransportOrders());
|
||||||
|
// 实时业务数据:百公里油耗(TMS 运输作业单,本年度、全部组织,油耗量与重载里程均非空)
|
||||||
|
vo.setFuelConsumptionPerHundredKm(
|
||||||
|
biComprehensiveRealDataService.calcCurrentYearFuelConsumptionPerHundredKm());
|
||||||
|
|
||||||
|
try {
|
||||||
|
String fullJson = objectMapper.writeValueAsString(vo);
|
||||||
|
String fingerprint = realDataFingerprint(vo);
|
||||||
|
|
||||||
|
String latestJson = biComprehensiveReportMapper.selectLatestPayloadJson();
|
||||||
|
if (StringUtils.isNotBlank(latestJson)) {
|
||||||
|
ComprehensiveSituationVO latestVo =
|
||||||
|
objectMapper.readValue(latestJson.trim(), ComprehensiveSituationVO.class);
|
||||||
|
if (Objects.equals(fingerprint, realDataFingerprint(latestVo))) {
|
||||||
|
log.info("BI 综合态势实时业务数据未变化,跳过落库");
|
||||||
|
return vo;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int rows = biSnapshotWriteMapper.updateLatestComprehensiveSnapshot(fullJson, REMARK_REALTIME);
|
||||||
|
if (rows < 1) {
|
||||||
|
// 表中无最新记录可更新,插入一条兜底
|
||||||
|
biSnapshotWriteMapper.insertComprehensiveSnapshot(fullJson, REMARK_REALTIME);
|
||||||
|
}
|
||||||
|
log.info("BI 综合态势实时数据已落库(覆盖最新, 数据变化), affectedRows={}", rows);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("BI 综合态势实时数据落库失败", e);
|
||||||
|
}
|
||||||
|
return vo;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 实时业务数据指纹:仅含实时查库得到的字段(运输订单量、百公里油耗),
|
||||||
|
* 用于判断是否需要覆盖更新快照;其余字段取自快照,不纳入指纹。
|
||||||
|
*/
|
||||||
|
private String realDataFingerprint(ComprehensiveSituationVO vo) throws Exception {
|
||||||
|
Map<String, Object> fp = new LinkedHashMap<>();
|
||||||
|
if (vo == null) {
|
||||||
|
return objectMapper.writeValueAsString(fp);
|
||||||
|
}
|
||||||
|
fp.put("orderCount", vo.getOrderCount());
|
||||||
|
fp.put("fuelConsumptionPerHundredKm", vo.getFuelConsumptionPerHundredKm());
|
||||||
|
return objectMapper.writeValueAsString(fp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+31
-1
@@ -10,6 +10,15 @@ import com.mhd.bi.domain.biPlatformRealData.repository.po.RealPlatformInfoPO;
|
|||||||
import com.mhd.bi.domain.biPlatformRealData.repository.po.RealOnTimeStatPO;
|
import com.mhd.bi.domain.biPlatformRealData.repository.po.RealOnTimeStatPO;
|
||||||
import com.mhd.bi.domain.biPlatformRealData.repository.po.RealTaskTypeStatPO;
|
import com.mhd.bi.domain.biPlatformRealData.repository.po.RealTaskTypeStatPO;
|
||||||
import com.mhd.bi.domain.biPlatformRealData.repository.po.RealMonthlyTaskDurationPO;
|
import com.mhd.bi.domain.biPlatformRealData.repository.po.RealMonthlyTaskDurationPO;
|
||||||
|
import com.mhd.bi.domain.biPlatformRealData.repository.po.RealMonthlyAvgDurationPO;
|
||||||
|
import com.mhd.bi.domain.biPlatformRealData.repository.po.RealTodayAvgDurationPO;
|
||||||
|
import com.mhd.bi.domain.biPlatformRealData.repository.po.RealOvertimeStatPO;
|
||||||
|
import com.mhd.bi.domain.biPlatformRealData.repository.po.RealOvertimeRecordPO;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@@ -29,7 +38,7 @@ public interface BiPlatformRealDataMapper {
|
|||||||
/** 今日作业任务数 */
|
/** 今日作业任务数 */
|
||||||
Long countTodayTasks();
|
Long countTodayTasks();
|
||||||
|
|
||||||
/** 车辆状态统计(今日) */
|
/** 车辆状态统计(今日,含叫号状态合计 callStatusTotal = 已签到+已叫号+已过号) */
|
||||||
RealVehicleStatusPO queryVehicleStatusToday();
|
RealVehicleStatusPO queryVehicleStatusToday();
|
||||||
|
|
||||||
/** 本月任务量 */
|
/** 本月任务量 */
|
||||||
@@ -41,6 +50,27 @@ public interface BiPlatformRealDataMapper {
|
|||||||
/** 任务负荷(今日 24 小时) */
|
/** 任务负荷(今日 24 小时) */
|
||||||
List<RealTaskLoadPO> queryTaskLoadToday();
|
List<RealTaskLoadPO> queryTaskLoadToday();
|
||||||
|
|
||||||
|
/** 近半年平均作业时长(按月分组:月台作业时长 / 园区作业时长 合计 + 任务数) */
|
||||||
|
List<RealMonthlyAvgDurationPO> queryMonthlyAvgDuration();
|
||||||
|
|
||||||
|
/** 今日平均作业时长(月台作业平均时长 / 园区平均时长,仅统计两端时间都非空的记录) */
|
||||||
|
RealTodayAvgDurationPO queryTodayAvgDuration();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 今日月台作业超时统计(超时记录数 / 有效记录总数)。
|
||||||
|
* 参考用时取自 YMS QMS_STATIC_FIELD.FIELD_CODE = 'platform_work_ref_minutes'
|
||||||
|
*/
|
||||||
|
RealOvertimeStatPO queryTodayOvertimeStat(@Param("refCode") String refCode);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 今日园区作业超时统计(超时记录数 / 有效记录总数)。
|
||||||
|
* 参考用时取自 YMS QMS_STATIC_FIELD.FIELD_CODE = 'yard_work_ref_minutes'
|
||||||
|
*/
|
||||||
|
RealOvertimeStatPO queryTodayYardOvertimeStat(@Param("refCode") String refCode);
|
||||||
|
|
||||||
|
/** 今日月台作业超时记录列表(月台名称 / 车牌号 / 超时时长) */
|
||||||
|
List<RealOvertimeRecordPO> queryTodayOvertimeList(@Param("refCode") String refCode);
|
||||||
|
|
||||||
/** 今日预约-业务类型统计(按 businessName 分组统计今日预约数量) */
|
/** 今日预约-业务类型统计(按 businessName 分组统计今日预约数量) */
|
||||||
List<RealBusinessTypeStatPO> queryTodayBusinessTypeStats();
|
List<RealBusinessTypeStatPO> queryTodayBusinessTypeStats();
|
||||||
|
|
||||||
|
|||||||
+32
@@ -0,0 +1,32 @@
|
|||||||
|
package com.mhd.bi.domain.biPlatformRealData.repository.po;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 按月平均作业时长(真实数据,来自 TEST_NGWL_YMS.QMS_MAIN_BUSINESS)
|
||||||
|
*
|
||||||
|
* <p>用于「平均作业时长」近半年趋势图,双系列:月台作业 / 园区作业。</p>
|
||||||
|
* <ul>
|
||||||
|
* <li>月台作业时长 = 离开月台时间(OUT_WINDOWS_TIME) - 进入月台时间(IN_WINDOWS_TIME)</li>
|
||||||
|
* <li>园区作业时长 = 实际出场时间(EXIT_TIME) - 实际进入时间(ENTRY_TIME)</li>
|
||||||
|
* </ul>
|
||||||
|
* <p>各月平均 = 该月有效记录的时长合计 ÷ 该月任务数。</p>
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class RealMonthlyAvgDurationPO implements Serializable {
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/** 月份,格式 yyyy-MM */
|
||||||
|
private String monthOfYear;
|
||||||
|
|
||||||
|
/** 该月任务数(预约记录数,作为平均时长的分母) */
|
||||||
|
private Long taskCount;
|
||||||
|
|
||||||
|
/** 该月月台作业时长合计(小时);未进入月台计 0,已进入未离开按 SYSDATE - IN_WINDOWS_TIME */
|
||||||
|
private Double platformWorkHours;
|
||||||
|
|
||||||
|
/** 该月园区作业时长合计(小时);未进场计 0,已进场未出场按 SYSDATE - ENTRY_TIME */
|
||||||
|
private Double yardWorkHours;
|
||||||
|
}
|
||||||
+8
-4
@@ -6,16 +6,20 @@ import java.io.Serializable;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 本月任务平均时长 / 完成率统计(真实数据,来自 TEST_NGWL_YMS.QMS_MAIN_BUSINESS)
|
* 本月任务平均时长 / 完成率统计(真实数据,来自 TEST_NGWL_YMS.QMS_MAIN_BUSINESS)
|
||||||
* avgDurationHours:累计 (EXIT_TIME - ENTRY_TIME) 小时数(仅 ENTRY_TIME/EXIT_TIME 都不为空时参与)
|
* totalWorkHours:本月任务作业时长合计(小时),未进入月台计 0、已进入未离开按 SYSDATE - IN_WINDOWS_TIME
|
||||||
* durationCount:参与平均时长统计的有效条数
|
|
||||||
* completedCount:已出场(EXIT_TIME IS NOT NULL)且预约日期在本月的数量
|
* completedCount:已出场(EXIT_TIME IS NOT NULL)且预约日期在本月的数量
|
||||||
* totalCount:本月(TARGET_DATE)预约总数量
|
* totalCount:本月(TARGET_DATE)预约总数量(作为平均时长的分母)
|
||||||
|
*
|
||||||
|
* <p>任务平均作业时长 = totalWorkHours ÷ totalCount,由 Service 层计算。</p>
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
public class RealMonthlyTaskDurationPO implements Serializable {
|
public class RealMonthlyTaskDurationPO implements Serializable {
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
/** 平均作业时长(小时) */
|
/** 本月任务作业时长合计(小时) */
|
||||||
|
private Double totalWorkHours;
|
||||||
|
|
||||||
|
/** 平均作业时长(小时),由 Service 层按 totalWorkHours ÷ totalCount 计算 */
|
||||||
private Double avgDurationHours;
|
private Double avgDurationHours;
|
||||||
|
|
||||||
/** 参与平均时长统计的有效条数 */
|
/** 参与平均时长统计的有效条数 */
|
||||||
|
|||||||
+30
@@ -0,0 +1,30 @@
|
|||||||
|
package com.mhd.bi.domain.biPlatformRealData.repository.po;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 今日月台作业超时记录(真实数据)
|
||||||
|
*
|
||||||
|
* <p>用于「超时记录列表」:月台名称 / 车牌号码 / 超时时长(分钟)。</p>
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class RealOvertimeRecordPO implements Serializable {
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/** 月台名称 */
|
||||||
|
private String windowName;
|
||||||
|
|
||||||
|
/** 车牌号码 */
|
||||||
|
private String carNo;
|
||||||
|
|
||||||
|
/** 超时时长(分钟)= 月台作业时长 - 参考用时 */
|
||||||
|
private Long overtimeMinutes;
|
||||||
|
|
||||||
|
/** 月台作业参考用时(分钟) */
|
||||||
|
private Long refMinutes;
|
||||||
|
|
||||||
|
/** 月台作业时长(分钟) */
|
||||||
|
private Long platformMinutes;
|
||||||
|
}
|
||||||
+27
@@ -0,0 +1,27 @@
|
|||||||
|
package com.mhd.bi.domain.biPlatformRealData.repository.po;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 今日作业超时统计(月台作业 / 园区作业 通用)
|
||||||
|
*
|
||||||
|
* <p>分母只计入「能取到参考用时 且 作业时长两端时间都非空」的记录。</p>
|
||||||
|
* <ul>
|
||||||
|
* <li>月台作业:参考用时 code = platform_work_ref_minutes;
|
||||||
|
* 时长 = OUT_WINDOWS_TIME - IN_WINDOWS_TIME</li>
|
||||||
|
* <li>园区作业:参考用时 code = yard_work_ref_minutes;
|
||||||
|
* 时长 = EXIT_TIME - ENTRY_TIME</li>
|
||||||
|
* </ul>
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class RealOvertimeStatPO implements Serializable {
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/** 超时记录数:作业时长 > 参考用时 */
|
||||||
|
private Long overtimeCount;
|
||||||
|
|
||||||
|
/** 有效记录总数(分母) */
|
||||||
|
private Long totalCount;
|
||||||
|
}
|
||||||
+4
@@ -23,4 +23,8 @@ public class RealPlatformFloorStatPO implements Serializable {
|
|||||||
|
|
||||||
/** 当前作业车辆数(FLOW_STATUS IN 5,6,7,8,9,10) */
|
/** 当前作业车辆数(FLOW_STATUS IN 5,6,7,8,9,10) */
|
||||||
private Long operatingVehicles;
|
private Long operatingVehicles;
|
||||||
|
|
||||||
|
/** 该楼层月台作业平均时长(分钟)= SUM(该楼层有效月台作业时长) ÷ 该楼层有效记录数 */
|
||||||
|
private Double avgPlatformMinutes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+5
-3
@@ -4,15 +4,17 @@ import lombok.Data;
|
|||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 任务负荷统计(按小时,来自 TEST_NGWL_YMS.QMS_MAIN_BUSINESS)
|
* 任务负荷统计(按 2 小时分组,来自 TEST_NGWL_YMS.QMS_MAIN_BUSINESS)
|
||||||
|
*
|
||||||
|
* <p>「小时趋势」需求:每 2 小时分组统计一次,按车辆进入月台时间 IN_WINDOWS_TIME 分桶。</p>
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
public class RealTaskLoadPO implements Serializable {
|
public class RealTaskLoadPO implements Serializable {
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
/** 0-23 小时 */
|
/** 2 小时分组的起始小时,取值 0,2,4,...,22 */
|
||||||
private Integer hourOfDay;
|
private Integer hourOfDay;
|
||||||
|
|
||||||
/** 该小时段任务数 */
|
/** 该 2 小时时段任务数 */
|
||||||
private Long taskCount;
|
private Long taskCount;
|
||||||
}
|
}
|
||||||
+34
@@ -0,0 +1,34 @@
|
|||||||
|
package com.mhd.bi.domain.biPlatformRealData.repository.po;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 今日平均作业时长(真实数据,来自 TEST_NGWL_YMS.QMS_MAIN_BUSINESS)
|
||||||
|
*
|
||||||
|
* <p>用于「效率统计(本日)」中的:</p>
|
||||||
|
* <ul>
|
||||||
|
* <li>月台作业平均时长 avgPlatformDurationHours</li>
|
||||||
|
* <li>园区平均时长 avgYardDurationHours</li>
|
||||||
|
* </ul>
|
||||||
|
*
|
||||||
|
* <p>统计范围:今日预约记录(TARGET_DATE = 今天),且只统计时长两端的字段都非空的记录:</p>
|
||||||
|
* <ul>
|
||||||
|
* <li>月台作业时长 = 离开月台时间(OUT_WINDOWS_TIME) - 进入月台时间(IN_WINDOWS_TIME)
|
||||||
|
* → 只统计 IN_WINDOWS_TIME 与 OUT_WINDOWS_TIME 都非空的记录</li>
|
||||||
|
* <li>园区作业时长 = 实际出场时间(EXIT_TIME) - 实际进入时间(ENTRY_TIME)
|
||||||
|
* → 只统计 ENTRY_TIME 与 EXIT_TIME 都非空的记录</li>
|
||||||
|
* </ul>
|
||||||
|
* <p>平均时长 = 有效记录时长合计 ÷ 有效记录数,由 Service 层或 SQL 直接完成。</p>
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class RealTodayAvgDurationPO implements Serializable {
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/** 月台作业平均时长(小时),仅统计同时有进入与离开月台时间的记录 */
|
||||||
|
private Double avgPlatformDurationHours;
|
||||||
|
|
||||||
|
/** 园区平均时长(小时),仅统计同时有实际进入与实际出场时间的记录 */
|
||||||
|
private Double avgYardDurationHours;
|
||||||
|
}
|
||||||
+6
@@ -19,6 +19,12 @@ public class RealVehicleStatusPO implements Serializable {
|
|||||||
/** 当前等待作业(FLOW_STATUS IN '1','2','3' 已预约/已签到/已叫号) */
|
/** 当前等待作业(FLOW_STATUS IN '1','2','3' 已预约/已签到/已叫号) */
|
||||||
private Long waiting;
|
private Long waiting;
|
||||||
|
|
||||||
|
/** 叫号状态合计:已签到 + 已叫号 + 已过号(FLOW_STATUS IN '2','3','4',预约日期为今天) */
|
||||||
|
private Long callStatusTotal;
|
||||||
|
|
||||||
|
/** 今日已出场(FLOW_STATUS = '11',预约日期为今天),用于月台周转率 */
|
||||||
|
private Long todayExited;
|
||||||
|
|
||||||
/** 当前作业中 */
|
/** 当前作业中 */
|
||||||
private Long operatingVehicles;
|
private Long operatingVehicles;
|
||||||
|
|
||||||
|
|||||||
+286
-22
@@ -12,11 +12,23 @@ import com.mhd.bi.domain.biPlatformRealData.repository.po.RealPlatformInfoPO;
|
|||||||
import com.mhd.bi.domain.biPlatformRealData.repository.po.RealOnTimeStatPO;
|
import com.mhd.bi.domain.biPlatformRealData.repository.po.RealOnTimeStatPO;
|
||||||
import com.mhd.bi.domain.biPlatformRealData.repository.po.RealTaskTypeStatPO;
|
import com.mhd.bi.domain.biPlatformRealData.repository.po.RealTaskTypeStatPO;
|
||||||
import com.mhd.bi.domain.biPlatformRealData.repository.po.RealMonthlyTaskDurationPO;
|
import com.mhd.bi.domain.biPlatformRealData.repository.po.RealMonthlyTaskDurationPO;
|
||||||
|
import com.mhd.bi.domain.biPlatformRealData.repository.po.RealMonthlyAvgDurationPO;
|
||||||
|
import com.mhd.bi.domain.biPlatformRealData.repository.po.RealTodayAvgDurationPO;
|
||||||
|
import com.mhd.bi.domain.biPlatformRealData.repository.po.RealOvertimeStatPO;
|
||||||
|
import com.mhd.bi.domain.biPlatformRealData.repository.po.RealOvertimeRecordPO;
|
||||||
|
|
||||||
import com.mhd.bi.domain.biPlatformSurveillance.repository.mapper.BiPlatformSurveillanceReportMapper;
|
import com.mhd.bi.domain.biPlatformSurveillance.repository.mapper.BiPlatformSurveillanceReportMapper;
|
||||||
|
import com.mhd.bi.domain.biStaticField.service.BiStaticFieldService;
|
||||||
|
|
||||||
import com.mhd.bi.domain.biSnapshotSync.repository.mapper.BiSnapshotWriteMapper;
|
import com.mhd.bi.domain.biSnapshotSync.repository.mapper.BiSnapshotWriteMapper;
|
||||||
import com.mhd.bi.domain.biSnapshotSync.support.BiSnapshotWeeklyRandomDataBuilder;
|
import com.mhd.bi.domain.biSnapshotSync.support.BiSnapshotWeeklyRandomDataBuilder;
|
||||||
|
import com.mhd.bi.interfaces.facadeApi.biReport.vo.platform.AvgOperationDurationTrendItemVO;
|
||||||
|
import com.mhd.bi.interfaces.facadeApi.biReport.vo.platform.OvertimeRecordItemVO;
|
||||||
import com.mhd.bi.interfaces.facadeApi.biReport.vo.platform.PlatformSurveillanceVO;
|
import com.mhd.bi.interfaces.facadeApi.biReport.vo.platform.PlatformSurveillanceVO;
|
||||||
|
|
||||||
import com.mhd.bi.interfaces.facadeApi.biReport.vo.platform.PlatformVehicleItemVO;
|
import com.mhd.bi.interfaces.facadeApi.biReport.vo.platform.PlatformVehicleItemVO;
|
||||||
|
|
||||||
|
|
||||||
import com.mhd.bi.interfaces.facadeApi.biReport.vo.platform.TaskLoadItemVO;
|
import com.mhd.bi.interfaces.facadeApi.biReport.vo.platform.TaskLoadItemVO;
|
||||||
import com.mhd.bi.interfaces.facadeApi.biReport.vo.platform.TaskTypeStatisticsVO;
|
import com.mhd.bi.interfaces.facadeApi.biReport.vo.platform.TaskTypeStatisticsVO;
|
||||||
import com.mhd.bi.interfaces.facadeApi.biReport.vo.platform.TaskTypeCountItemVO;
|
import com.mhd.bi.interfaces.facadeApi.biReport.vo.platform.TaskTypeCountItemVO;
|
||||||
@@ -98,17 +110,27 @@ public class BiPlatformRealDataService {
|
|||||||
fp.put("operatingPlatforms", vo.getPlatformOverview().getOperatingPlatforms());
|
fp.put("operatingPlatforms", vo.getPlatformOverview().getOperatingPlatforms());
|
||||||
fp.put("currentOccupancyRate", vo.getPlatformOverview().getCurrentOccupancyRate());
|
fp.put("currentOccupancyRate", vo.getPlatformOverview().getCurrentOccupancyRate());
|
||||||
fp.put("todayTasks", vo.getPlatformOverview().getTodayTasks());
|
fp.put("todayTasks", vo.getPlatformOverview().getTodayTasks());
|
||||||
|
fp.put("platformTurnoverRate", vo.getPlatformOverview().getPlatformTurnoverRate());
|
||||||
}
|
}
|
||||||
|
// 入园超时率/超时数量 按业务要求恒为 0,不纳入指纹
|
||||||
|
// 准时率与平均时长为实时业务数据,纳入指纹
|
||||||
if (vo.getEfficiencyStatistics() != null) {
|
if (vo.getEfficiencyStatistics() != null) {
|
||||||
fp.put("platformOnTimeRate", vo.getEfficiencyStatistics().getPlatformOnTimeRate());
|
fp.put("platformOnTimeRate", vo.getEfficiencyStatistics().getPlatformOnTimeRate());
|
||||||
|
fp.put("yardOnTimeRate", vo.getEfficiencyStatistics().getYardOnTimeRate());
|
||||||
|
fp.put("avgPlatformDuration", vo.getEfficiencyStatistics().getAvgPlatformDuration());
|
||||||
|
fp.put("avgYardDuration", vo.getEfficiencyStatistics().getAvgYardDuration());
|
||||||
}
|
}
|
||||||
if (vo.getVehicleStatus() != null) {
|
if (vo.getVehicleStatus() != null) {
|
||||||
fp.put("todayReservedVehicles", vo.getVehicleStatus().getTodayReservedVehicles());
|
fp.put("todayReservedVehicles", vo.getVehicleStatus().getTodayReservedVehicles());
|
||||||
fp.put("notCheckedIn", vo.getVehicleStatus().getNotCheckedIn());
|
fp.put("notCheckedIn", vo.getVehicleStatus().getNotCheckedIn());
|
||||||
fp.put("waiting", vo.getVehicleStatus().getWaiting());
|
fp.put("waiting", vo.getVehicleStatus().getWaiting());
|
||||||
|
fp.put("callStatusTotal", vo.getVehicleStatus().getCallStatusTotal());
|
||||||
fp.put("operatingVehicles", vo.getVehicleStatus().getOperatingVehicles());
|
fp.put("operatingVehicles", vo.getVehicleStatus().getOperatingVehicles());
|
||||||
|
|
||||||
|
|
||||||
fp.put("completedVehicles", vo.getVehicleStatus().getCompletedVehicles());
|
fp.put("completedVehicles", vo.getVehicleStatus().getCompletedVehicles());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (vo.getMonthlyTaskStatistics() != null) {
|
if (vo.getMonthlyTaskStatistics() != null) {
|
||||||
fp.put("taskTotal", vo.getMonthlyTaskStatistics().getTaskTotal());
|
fp.put("taskTotal", vo.getMonthlyTaskStatistics().getTaskTotal());
|
||||||
fp.put("avgTaskDuration", vo.getMonthlyTaskStatistics().getAvgTaskDuration());
|
fp.put("avgTaskDuration", vo.getMonthlyTaskStatistics().getAvgTaskDuration());
|
||||||
@@ -138,7 +160,34 @@ public class BiPlatformRealDataService {
|
|||||||
}
|
}
|
||||||
fp.put("taskLoadStatistics", loads);
|
fp.put("taskLoadStatistics", loads);
|
||||||
}
|
}
|
||||||
|
if (vo.getAvgOperationDurationTrend() != null) {
|
||||||
|
|
||||||
|
|
||||||
|
List<Map<String, Object>> trend = new ArrayList<>();
|
||||||
|
for (AvgOperationDurationTrendItemVO item : vo.getAvgOperationDurationTrend()) {
|
||||||
|
Map<String, Object> m = new LinkedHashMap<>();
|
||||||
|
m.put("month", item.getMonth());
|
||||||
|
m.put("yardDuration", item.getYardDuration());
|
||||||
|
m.put("platformDuration", item.getPlatformDuration());
|
||||||
|
trend.add(m);
|
||||||
|
}
|
||||||
|
fp.put("avgOperationDurationTrend", trend);
|
||||||
|
}
|
||||||
|
fp.put("taskOvertimeRate", vo.getTaskOvertimeRate());
|
||||||
|
if (vo.getOvertimeRecords() != null) {
|
||||||
|
List<Map<String, Object>> recs = new ArrayList<>();
|
||||||
|
for (OvertimeRecordItemVO r : vo.getOvertimeRecords()) {
|
||||||
|
Map<String, Object> m = new LinkedHashMap<>();
|
||||||
|
m.put("windowName", r.getWindowName());
|
||||||
|
m.put("carNo", r.getCarNo());
|
||||||
|
m.put("overtimeMinutes", r.getOvertimeMinutes());
|
||||||
|
recs.add(m);
|
||||||
|
}
|
||||||
|
fp.put("overtimeRecords", recs);
|
||||||
|
}
|
||||||
|
|
||||||
if (vo.getTaskTypeStatistics() != null) {
|
if (vo.getTaskTypeStatistics() != null) {
|
||||||
|
|
||||||
Map<String, Object> m = new LinkedHashMap<>();
|
Map<String, Object> m = new LinkedHashMap<>();
|
||||||
m.put("totalTasks", vo.getTaskTypeStatistics().getTotalTasks());
|
m.put("totalTasks", vo.getTaskTypeStatistics().getTotalTasks());
|
||||||
if (vo.getTaskTypeStatistics().getTaskTypes() != null) {
|
if (vo.getTaskTypeStatistics().getTaskTypes() != null) {
|
||||||
@@ -226,6 +275,8 @@ public class BiPlatformRealDataService {
|
|||||||
if (po.getTodayReservedVehicles() == null) po.setTodayReservedVehicles(0L);
|
if (po.getTodayReservedVehicles() == null) po.setTodayReservedVehicles(0L);
|
||||||
if (po.getNotCheckedIn() == null) po.setNotCheckedIn(0L);
|
if (po.getNotCheckedIn() == null) po.setNotCheckedIn(0L);
|
||||||
if (po.getWaiting() == null) po.setWaiting(0L);
|
if (po.getWaiting() == null) po.setWaiting(0L);
|
||||||
|
if (po.getCallStatusTotal() == null) po.setCallStatusTotal(0L);
|
||||||
|
if (po.getTodayExited() == null) po.setTodayExited(0L);
|
||||||
if (po.getOperatingVehicles() == null) po.setOperatingVehicles(0L);
|
if (po.getOperatingVehicles() == null) po.setOperatingVehicles(0L);
|
||||||
if (po.getCompletedVehicles() == null) po.setCompletedVehicles(0L);
|
if (po.getCompletedVehicles() == null) po.setCompletedVehicles(0L);
|
||||||
return po;
|
return po;
|
||||||
@@ -235,13 +286,19 @@ public class BiPlatformRealDataService {
|
|||||||
po.setTodayReservedVehicles(0L);
|
po.setTodayReservedVehicles(0L);
|
||||||
po.setNotCheckedIn(0L);
|
po.setNotCheckedIn(0L);
|
||||||
po.setWaiting(0L);
|
po.setWaiting(0L);
|
||||||
|
po.setCallStatusTotal(0L);
|
||||||
|
po.setTodayExited(0L);
|
||||||
po.setOperatingVehicles(0L);
|
po.setOperatingVehicles(0L);
|
||||||
po.setCompletedVehicles(0L);
|
po.setCompletedVehicles(0L);
|
||||||
return po;
|
return po;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public long countMonthTasks() {
|
public long countMonthTasks() {
|
||||||
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Long n = biPlatformRealDataMapper.countMonthTasks();
|
Long n = biPlatformRealDataMapper.countMonthTasks();
|
||||||
return n == null ? 0L : n;
|
return n == null ? 0L : n;
|
||||||
@@ -253,19 +310,31 @@ public class BiPlatformRealDataService {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 本月任务平均时长 / 完成率统计:
|
* 本月任务平均时长 / 完成率统计:
|
||||||
* - avgDurationHours:累计(EXIT_TIME - ENTRY_TIME)小时数 / 参与数;任一为空的行不参与
|
* - totalWorkHours:本月任务作业时长合计(小时);未进入月台计 0,已进入未离开按 SYSDATE - IN_WINDOWS_TIME
|
||||||
|
* - avgDurationHours:任务平均作业时长 = totalWorkHours ÷ 本月任务数(totalCount),保留两位小数
|
||||||
* - taskCompletionRate:已完成(EXIT_TIME 不为空 且 预约日期在本月)/ 本月预约总数量 ×100
|
* - taskCompletionRate:已完成(EXIT_TIME 不为空 且 预约日期在本月)/ 本月预约总数量 ×100
|
||||||
* 任一查询失败均返回 null,由调用方决定是否覆盖模板值。
|
* 任一查询失败均返回 null,由调用方决定是否覆盖模板值。
|
||||||
*/
|
*/
|
||||||
public RealMonthlyTaskDurationPO queryMonthTaskStats() {
|
public RealMonthlyTaskDurationPO queryMonthTaskStats() {
|
||||||
try {
|
try {
|
||||||
return biPlatformRealDataMapper.queryMonthTaskStats();
|
RealMonthlyTaskDurationPO po = biPlatformRealDataMapper.queryMonthTaskStats();
|
||||||
|
if (po == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
// 任务平均作业时长 = 本月作业时长合计 ÷ 本月任务数(分母为 0 时返回 0)
|
||||||
|
long totalCount = po.getTotalCount() == null ? 0L : po.getTotalCount();
|
||||||
|
double totalHours = po.getTotalWorkHours() == null ? 0d : po.getTotalWorkHours();
|
||||||
|
po.setAvgDurationHours(totalCount > 0
|
||||||
|
? Math.round((totalHours / (double) totalCount) * 100.0) / 100.0
|
||||||
|
: 0d);
|
||||||
|
return po;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("【YMS】统计本月任务平均时长/完成率失败: {}", e.getMessage(), e);
|
log.error("【YMS】统计本月任务平均时长/完成率失败: {}", e.getMessage(), e);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public List<RealTaskLoadPO> queryTaskLoadToday() {
|
public List<RealTaskLoadPO> queryTaskLoadToday() {
|
||||||
try {
|
try {
|
||||||
return biPlatformRealDataMapper.queryTaskLoadToday();
|
return biPlatformRealDataMapper.queryTaskLoadToday();
|
||||||
@@ -392,21 +461,50 @@ public class BiPlatformRealDataService {
|
|||||||
template.getPlatformOverview().setCurrentOccupancyRate(rate);
|
template.getPlatformOverview().setCurrentOccupancyRate(rate);
|
||||||
template.getPlatformOverview().setTodayTasks(todayTasks);
|
template.getPlatformOverview().setTodayTasks(todayTasks);
|
||||||
|
|
||||||
// 作业准时率(实际进入时间 < 预约日期+预约结束时间 的车辆 / 今日预约总数 × 100% 取整)
|
// 作业准时率:任务超时率 + 月台作业准时率 = 100%(需求约定)
|
||||||
|
// 月台作业准时率 = 100 - 月台作业超时率
|
||||||
|
double platformOvertime = calcTodayTaskOvertimeRate();
|
||||||
|
template.getEfficiencyStatistics().setPlatformOnTimeRate(
|
||||||
|
(int) Math.round(100.0 - platformOvertime));
|
||||||
|
// 园区作业准时率 = 100 - 园区作业超时率
|
||||||
|
double yardOvertime = calcTodayYardOvertimeRate();
|
||||||
|
template.getEfficiencyStatistics().setYardOnTimeRate(
|
||||||
|
(int) Math.round(100.0 - yardOvertime));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// 平均作业时长(本日):月台作业平均时长 / 园区平均时长(真实数据,仅统计两端时间都非空的今日记录)
|
||||||
if (template.getEfficiencyStatistics() != null) {
|
if (template.getEfficiencyStatistics() != null) {
|
||||||
template.getEfficiencyStatistics().setPlatformOnTimeRate(calcTodayOnTimeRate());
|
RealTodayAvgDurationPO avg = queryTodayAvgDuration();
|
||||||
}
|
template.getEfficiencyStatistics().setAvgPlatformDuration(avg.getAvgPlatformDurationHours());
|
||||||
|
template.getEfficiencyStatistics().setAvgYardDuration(avg.getAvgYardDurationHours());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// 作业车辆状态统计:真实数据源,无条件覆盖(含等待作业 waiting = 今日预约且 已预约/已签到/已叫号)
|
// 作业车辆状态统计:真实数据源,无条件覆盖(含等待作业 waiting = 今日预约且 已预约/已签到/已叫号)
|
||||||
if (template.getVehicleStatus() != null) {
|
if (template.getVehicleStatus() != null) {
|
||||||
RealVehicleStatusPO vs = queryVehicleStatusToday();
|
RealVehicleStatusPO vs = queryVehicleStatusToday();
|
||||||
template.getVehicleStatus().setTodayReservedVehicles(vs.getTodayReservedVehicles().intValue());
|
template.getVehicleStatus().setTodayReservedVehicles(vs.getTodayReservedVehicles().intValue());
|
||||||
template.getVehicleStatus().setNotCheckedIn(vs.getNotCheckedIn().intValue());
|
template.getVehicleStatus().setNotCheckedIn(vs.getNotCheckedIn().intValue());
|
||||||
template.getVehicleStatus().setWaiting(vs.getWaiting().intValue());
|
template.getVehicleStatus().setWaiting(vs.getWaiting().intValue());
|
||||||
|
// 叫号状态合计:已签到 + 已叫号 + 已过号(一个字段表示三个状态的总数量)
|
||||||
|
template.getVehicleStatus().setCallStatusTotal(vs.getCallStatusTotal().intValue());
|
||||||
template.getVehicleStatus().setOperatingVehicles(vs.getOperatingVehicles().intValue());
|
template.getVehicleStatus().setOperatingVehicles(vs.getOperatingVehicles().intValue());
|
||||||
template.getVehicleStatus().setCompletedVehicles(vs.getCompletedVehicles().intValue());
|
template.getVehicleStatus().setCompletedVehicles(vs.getCompletedVehicles().intValue());
|
||||||
|
|
||||||
|
// 月台周转率 = 今日已出场记录数 ÷ 今日全部记录数 × 100%(保留两位小数)
|
||||||
|
if (template.getPlatformOverview() != null) {
|
||||||
|
long todayTotal = vs.getTodayReservedVehicles() == null ? 0L : vs.getTodayReservedVehicles();
|
||||||
|
long todayExited = vs.getTodayExited() == null ? 0L : vs.getTodayExited();
|
||||||
|
double turnover = todayTotal > 0
|
||||||
|
? Math.round(((double) todayExited / (double) todayTotal) * 100.0 * 100.0) / 100.0
|
||||||
|
: 0d;
|
||||||
|
template.getPlatformOverview().setPlatformTurnoverRate(turnover);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// 本月任务统计:taskTotal / avgTaskDuration / taskCompletionRate 均有真实数据源,无条件覆盖;YoY 保留模板写死值
|
// 本月任务统计:taskTotal / avgTaskDuration / taskCompletionRate 均有真实数据源,无条件覆盖;YoY 保留模板写死值
|
||||||
if (template.getMonthlyTaskStatistics() != null) {
|
if (template.getMonthlyTaskStatistics() != null) {
|
||||||
@@ -414,9 +512,8 @@ public class BiPlatformRealDataService {
|
|||||||
RealMonthlyTaskDurationPO monthStats = queryMonthTaskStats();
|
RealMonthlyTaskDurationPO monthStats = queryMonthTaskStats();
|
||||||
if (monthStats != null) {
|
if (monthStats != null) {
|
||||||
if (monthStats.getAvgDurationHours() != null) {
|
if (monthStats.getAvgDurationHours() != null) {
|
||||||
// 保留两位小数
|
// 任务平均作业时长 = 本月任务作业时长合计 ÷ 本月任务数(已在 Service 层算好),保留两位小数
|
||||||
double v = monthStats.getAvgDurationHours();
|
template.getMonthlyTaskStatistics().setAvgTaskDuration(monthStats.getAvgDurationHours());
|
||||||
template.getMonthlyTaskStatistics().setAvgTaskDuration(Math.round(v * 100.0) / 100.0);
|
|
||||||
}
|
}
|
||||||
Long total = monthStats.getTotalCount();
|
Long total = monthStats.getTotalCount();
|
||||||
Long completed = monthStats.getCompletedCount();
|
Long completed = monthStats.getCompletedCount();
|
||||||
@@ -429,41 +526,208 @@ public class BiPlatformRealDataService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 任务负荷:有真实数据源;真实为空则清空不用模板模拟,有数据则按真实小时覆盖
|
// 平均装卸时长按业务要求恒为 0,不用真实值覆盖
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// 小时趋势(今日,每 2 小时分组):有真实数据源则按真实分桶重建,无数据则清空
|
||||||
List<RealTaskLoadPO> loads = queryTaskLoadToday();
|
List<RealTaskLoadPO> loads = queryTaskLoadToday();
|
||||||
if (loads.isEmpty()) {
|
if (loads.isEmpty()) {
|
||||||
template.setTaskLoadStatistics(new ArrayList<>());
|
template.setTaskLoadStatistics(new ArrayList<>());
|
||||||
} else if (template.getTaskLoadStatistics() != null) {
|
} else {
|
||||||
Map<Integer, Long> hourMap = new HashMap<>();
|
Map<Integer, Long> bucketMap = new HashMap<>();
|
||||||
for (RealTaskLoadPO l : loads) {
|
for (RealTaskLoadPO l : loads) {
|
||||||
hourMap.put(l.getHourOfDay(), l.getTaskCount());
|
if (l != null && l.getHourOfDay() != null) {
|
||||||
}
|
bucketMap.put(l.getHourOfDay(), l.getTaskCount() == null ? 0L : l.getTaskCount());
|
||||||
for (TaskLoadItemVO item : template.getTaskLoadStatistics()) {
|
|
||||||
Integer hour = parseHourFromLabel(item.getTime());
|
|
||||||
if (hour != null && hourMap.containsKey(hour)) {
|
|
||||||
item.setTaskCount(hourMap.get(hour).intValue());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// 固定输出 0,2,4,...,22 共 12 个桶,无数据桶补 0,保证前端坐标轴连续
|
||||||
|
List<TaskLoadItemVO> items = new ArrayList<>();
|
||||||
|
for (int h = 0; h < 24; h += 2) {
|
||||||
|
Long cnt = bucketMap.get(h);
|
||||||
|
items.add(TaskLoadItemVO.builder()
|
||||||
|
.time(String.format("%02d:00", h))
|
||||||
|
.taskCount(cnt == null ? 0 : cnt.intValue())
|
||||||
|
.build());
|
||||||
}
|
}
|
||||||
|
template.setTaskLoadStatistics(items);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// 任务类型统计:本月 YMS QMS_MAIN_BUSINESS 按业务类型 BUSINESS_NAME 分组(真实业务数据)
|
// 任务类型统计:本月 YMS QMS_MAIN_BUSINESS 按业务类型 BUSINESS_NAME 分组(真实业务数据)
|
||||||
template.setTaskTypeStatistics(queryMonthTransportOrderByType());
|
template.setTaskTypeStatistics(queryMonthTransportOrderByType());
|
||||||
|
|
||||||
|
// 平均作业时长趋势:近半年按月统计(月台作业平均时长 / 园区作业平均时长)
|
||||||
|
template.setAvgOperationDurationTrend(queryAvgOperationDurationTrend());
|
||||||
|
|
||||||
|
// 任务超时率 + 月台作业超时记录列表(依赖 YMS QMS_STATIC_FIELD 参考用时配置)
|
||||||
|
template.setTaskOvertimeRate(calcTodayTaskOvertimeRate());
|
||||||
|
template.setOvertimeRecords(queryTodayOvertimeRecords());
|
||||||
|
|
||||||
return template;
|
return template;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Integer parseHourFromLabel(String label) {
|
|
||||||
if (label == null) return null;
|
|
||||||
|
/**
|
||||||
|
* 今日平均作业时长(效率统计-本日),保留两位小数,单位:小时。
|
||||||
|
* - avgPlatformDurationHours:月台作业平均时长;仅统计同时有进入与离开月台时间的今日记录
|
||||||
|
* - avgYardDurationHours: 园区平均时长;仅统计同时有实际进入与实际出场时间的今日记录
|
||||||
|
* 查询失败或无有效记录时返回 0。
|
||||||
|
*/
|
||||||
|
public RealTodayAvgDurationPO queryTodayAvgDuration() {
|
||||||
|
RealTodayAvgDurationPO po = new RealTodayAvgDurationPO();
|
||||||
|
po.setAvgPlatformDurationHours(0d);
|
||||||
|
po.setAvgYardDurationHours(0d);
|
||||||
try {
|
try {
|
||||||
String s = label.replace("时", "").trim();
|
RealTodayAvgDurationPO row = biPlatformRealDataMapper.queryTodayAvgDuration();
|
||||||
return Integer.parseInt(s);
|
if (row != null) {
|
||||||
|
if (row.getAvgPlatformDurationHours() != null) {
|
||||||
|
po.setAvgPlatformDurationHours(
|
||||||
|
Math.round(row.getAvgPlatformDurationHours() * 100.0) / 100.0);
|
||||||
|
}
|
||||||
|
if (row.getAvgYardDurationHours() != null) {
|
||||||
|
po.setAvgYardDurationHours(
|
||||||
|
Math.round(row.getAvgYardDurationHours() * 100.0) / 100.0);
|
||||||
|
}
|
||||||
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
return null;
|
log.error("【YMS】统计今日平均作业时长失败: {}", e.getMessage(), e);
|
||||||
|
}
|
||||||
|
return po;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 今日任务超时率(%)= 超时记录数 ÷ 有效记录总数 × 100%,保留两位小数。
|
||||||
|
* 有效记录:月台已配置参考用时(platform_work_ref_minutes),且该记录同时有进入/离开月台时间。
|
||||||
|
* 无有效记录时返回 0。
|
||||||
|
*/
|
||||||
|
public double calcTodayTaskOvertimeRate() {
|
||||||
|
try {
|
||||||
|
RealOvertimeStatPO po = biPlatformRealDataMapper
|
||||||
|
.queryTodayOvertimeStat(BiStaticFieldService.CODE_PLATFORM_WORK_REF_MINUTES);
|
||||||
|
return calcRateFromStat(po);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("【YMS】统计今日任务超时率失败: {}", e.getMessage(), e);
|
||||||
|
return 0d;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 今日园区作业超时率(%)= 园区作业时长 > 园区参考用时的记录数 ÷ 有效记录总数 × 100%。
|
||||||
|
* 有效记录:能取到园区参考用时(yard_work_ref_minutes),且记录同时有实际进入/实际出场时间。
|
||||||
|
* 无有效记录时返回 0。
|
||||||
|
*/
|
||||||
|
public double calcTodayYardOvertimeRate() {
|
||||||
|
try {
|
||||||
|
RealOvertimeStatPO po = biPlatformRealDataMapper
|
||||||
|
.queryTodayYardOvertimeStat(BiStaticFieldService.CODE_YARD_WORK_REF_MINUTES);
|
||||||
|
return calcRateFromStat(po);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("【YMS】统计今日园区作业超时率失败: {}", e.getMessage(), e);
|
||||||
|
return 0d;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 由超时统计 PO 计算百分比,保留两位小数;无有效记录返回 0 */
|
||||||
|
private static double calcRateFromStat(RealOvertimeStatPO po) {
|
||||||
|
if (po == null) {
|
||||||
|
return 0d;
|
||||||
|
}
|
||||||
|
long total = po.getTotalCount() == null ? 0L : po.getTotalCount();
|
||||||
|
long overtime = po.getOvertimeCount() == null ? 0L : po.getOvertimeCount();
|
||||||
|
if (total <= 0) {
|
||||||
|
return 0d;
|
||||||
|
}
|
||||||
|
return Math.round(((double) overtime / (double) total) * 100.0 * 100.0) / 100.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 今日月台作业超时记录列表(月台名称 / 车牌号码 / 超时时长分钟)。
|
||||||
|
* 查询失败返回空列表。
|
||||||
|
*/
|
||||||
|
public List<OvertimeRecordItemVO> queryTodayOvertimeRecords() {
|
||||||
|
List<OvertimeRecordItemVO> result = new ArrayList<>();
|
||||||
|
try {
|
||||||
|
List<RealOvertimeRecordPO> rows = biPlatformRealDataMapper
|
||||||
|
.queryTodayOvertimeList(BiStaticFieldService.CODE_PLATFORM_WORK_REF_MINUTES);
|
||||||
|
|
||||||
|
if (rows == null) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
for (RealOvertimeRecordPO r : rows) {
|
||||||
|
if (r == null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
result.add(OvertimeRecordItemVO.builder()
|
||||||
|
.windowName(r.getWindowName())
|
||||||
|
.carNo(r.getCarNo())
|
||||||
|
.overtimeMinutes(r.getOvertimeMinutes())
|
||||||
|
.refMinutes(r.getRefMinutes())
|
||||||
|
.platformMinutes(r.getPlatformMinutes())
|
||||||
|
.build());
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("【YMS】查询今日月台作业超时记录失败: {}", e.getMessage(), e);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 近半年「平均作业时长」趋势(近 6 个月,按月正序,含无数据月份补 0):
|
||||||
|
|
||||||
|
|
||||||
|
* - platformDuration:月台作业平均时长 = SUM(月台作业时长) ÷ 该月任务数
|
||||||
|
* - yardDuration: 园区作业平均时长 = SUM(园区作业时长) ÷ 该月任务数
|
||||||
|
* 均保留两位小数,单位:小时。
|
||||||
|
*/
|
||||||
|
public List<AvgOperationDurationTrendItemVO> queryAvgOperationDurationTrend() {
|
||||||
|
List<AvgOperationDurationTrendItemVO> result = new ArrayList<>();
|
||||||
|
Map<String, RealMonthlyAvgDurationPO> map = new HashMap<>();
|
||||||
|
try {
|
||||||
|
List<RealMonthlyAvgDurationPO> rows = biPlatformRealDataMapper.queryMonthlyAvgDuration();
|
||||||
|
if (rows != null) {
|
||||||
|
for (RealMonthlyAvgDurationPO r : rows) {
|
||||||
|
if (r != null && r.getMonthOfYear() != null) {
|
||||||
|
map.put(r.getMonthOfYear().trim(), r);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("【YMS】统计近半年平均作业时长失败: {}", e.getMessage(), e);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 生成近 6 个月的标签(含当前月),保证无数据月份也返回一条(值为 0)
|
||||||
|
java.time.LocalDate now = java.time.LocalDate.now();
|
||||||
|
java.time.format.DateTimeFormatter keyFmt = java.time.format.DateTimeFormatter.ofPattern("yyyy-MM");
|
||||||
|
for (int i = 5; i >= 0; i--) {
|
||||||
|
java.time.LocalDate m = now.minusMonths(i);
|
||||||
|
String key = m.format(keyFmt);
|
||||||
|
RealMonthlyAvgDurationPO po = map.get(key);
|
||||||
|
AvgOperationDurationTrendItemVO item = new AvgOperationDurationTrendItemVO();
|
||||||
|
// 展示用月份标签,如 "9月"
|
||||||
|
item.setMonth(m.getMonthValue() + "月");
|
||||||
|
if (po != null) {
|
||||||
|
long cnt = po.getTaskCount() == null ? 0L : po.getTaskCount();
|
||||||
|
double platformHours = po.getPlatformWorkHours() == null ? 0d : po.getPlatformWorkHours();
|
||||||
|
double yardHours = po.getYardWorkHours() == null ? 0d : po.getYardWorkHours();
|
||||||
|
item.setPlatformDuration(cnt > 0
|
||||||
|
? Math.round((platformHours / (double) cnt) * 100.0) / 100.0 : 0d);
|
||||||
|
item.setYardDuration(cnt > 0
|
||||||
|
? Math.round((yardHours / (double) cnt) * 100.0) / 100.0 : 0d);
|
||||||
|
} else {
|
||||||
|
item.setPlatformDuration(0d);
|
||||||
|
item.setYardDuration(0d);
|
||||||
|
}
|
||||||
|
result.add(item);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* FLOW_STATUS 数字转中文:1已预约 2已签到 3已叫号 4已过号 5已进场 6已称重 7已装车 8二次称重 9已结算 10已还卡 11已出场 12已取消
|
* FLOW_STATUS 数字转中文:1已预约 2已签到 3已叫号 4已过号 5已进场 6已称重 7已装车 8二次称重 9已结算 10已还卡 11已出场 12已取消
|
||||||
|
|
||||||
*/
|
*/
|
||||||
private static String translateFlowStatus(String flowStatus) {
|
private static String translateFlowStatus(String flowStatus) {
|
||||||
if (flowStatus == null) return null;
|
if (flowStatus == null) return null;
|
||||||
|
|||||||
+9
-4
@@ -43,9 +43,9 @@ public final class BiReportSnapshotMapperSupport {
|
|||||||
return ComprehensiveSituationVO.builder()
|
return ComprehensiveSituationVO.builder()
|
||||||
.valueAddedServiceIncome(0L)
|
.valueAddedServiceIncome(0L)
|
||||||
.inventoryTurnover(0)
|
.inventoryTurnover(0)
|
||||||
.orderCount(0)
|
.orderCount(0L)
|
||||||
.vehicleUtilizationRate(0d)
|
.vehicleUtilizationRate(0d)
|
||||||
.fuelConsumptionPerHundredKm(0)
|
.fuelConsumptionPerHundredKm(0d)
|
||||||
.incomeTrend(Collections.emptyList())
|
.incomeTrend(Collections.emptyList())
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
@@ -85,9 +85,12 @@ public final class BiReportSnapshotMapperSupport {
|
|||||||
.entryOvertimeRate(0).overtimeCount(0).platformOnTimeRate(0)
|
.entryOvertimeRate(0).overtimeCount(0).platformOnTimeRate(0)
|
||||||
.avgPlatformDuration(0d).yardOnTimeRate(0).avgYardDuration(0d).build())
|
.avgPlatformDuration(0d).yardOnTimeRate(0).avgYardDuration(0d).build())
|
||||||
.platformOverview(PlatformOverviewVO.builder()
|
.platformOverview(PlatformOverviewVO.builder()
|
||||||
.totalPlatforms(0).currentOccupancyRate(0d).operatingPlatforms(0).todayTasks(0).build())
|
.totalPlatforms(0).currentOccupancyRate(0d).operatingPlatforms(0).todayTasks(0)
|
||||||
|
.platformTurnoverRate(0d).build())
|
||||||
.vehicleStatus(VehicleStatusVO.builder()
|
.vehicleStatus(VehicleStatusVO.builder()
|
||||||
.todayReservedVehicles(0).notCheckedIn(0).waiting(0).operatingVehicles(0).completedVehicles(0).build())
|
.todayReservedVehicles(0).notCheckedIn(0).waiting(0)
|
||||||
|
.callStatusTotal(0)
|
||||||
|
.operatingVehicles(0).completedVehicles(0).build())
|
||||||
.avgOperationDurationTrend(Collections.emptyList())
|
.avgOperationDurationTrend(Collections.emptyList())
|
||||||
.monthlyTaskStatistics(MonthlyTaskStatisticsVO.builder()
|
.monthlyTaskStatistics(MonthlyTaskStatisticsVO.builder()
|
||||||
.taskTotal(0).taskTotalYoY(0).avgTaskDuration(0d).avgDurationYoY(0)
|
.taskTotal(0).taskTotalYoY(0).avgTaskDuration(0d).avgDurationYoY(0)
|
||||||
@@ -99,6 +102,8 @@ public final class BiReportSnapshotMapperSupport {
|
|||||||
.platformAlarmStatistics(PlatformAlarmStatisticsVO.builder()
|
.platformAlarmStatistics(PlatformAlarmStatisticsVO.builder()
|
||||||
.todayAlarmTotal(0).handled(0).unhandled(0).build())
|
.todayAlarmTotal(0).handled(0).unhandled(0).build())
|
||||||
.platformAlarmDistribution(Collections.emptyList())
|
.platformAlarmDistribution(Collections.emptyList())
|
||||||
|
.taskOvertimeRate(0d)
|
||||||
|
.overtimeRecords(Collections.emptyList())
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+5
@@ -9,8 +9,13 @@ public interface BiSnapshotWriteMapper {
|
|||||||
|
|
||||||
int insertComprehensiveSnapshot(@Param("payloadJson") String payloadJson, @Param("remark") String remark);
|
int insertComprehensiveSnapshot(@Param("payloadJson") String payloadJson, @Param("remark") String remark);
|
||||||
|
|
||||||
|
int updateLatestComprehensiveSnapshot(@Param("payloadJson") String payloadJson, @Param("remark") String remark);
|
||||||
|
|
||||||
|
|
||||||
int insertWarehouseTransportSnapshot(@Param("payloadJson") String payloadJson, @Param("remark") String remark);
|
int insertWarehouseTransportSnapshot(@Param("payloadJson") String payloadJson, @Param("remark") String remark);
|
||||||
|
|
||||||
|
int updateLatestWarehouseTransportSnapshot(@Param("payloadJson") String payloadJson, @Param("remark") String remark);
|
||||||
|
|
||||||
int insertPlatformSurveillanceSnapshot(@Param("payloadJson") String payloadJson, @Param("remark") String remark);
|
int insertPlatformSurveillanceSnapshot(@Param("payloadJson") String payloadJson, @Param("remark") String remark);
|
||||||
|
|
||||||
int updateLatestPlatformSurveillanceSnapshot(@Param("payloadJson") String payloadJson, @Param("remark") String remark);
|
int updateLatestPlatformSurveillanceSnapshot(@Param("payloadJson") String payloadJson, @Param("remark") String remark);
|
||||||
|
|||||||
+87
-27
@@ -19,6 +19,8 @@ import com.mhd.bi.domain.biPlatformRealData.repository.po.RealPlatformVehiclePO;
|
|||||||
import com.mhd.bi.domain.biPlatformRealData.repository.po.RealPlatformInfoPO;
|
import com.mhd.bi.domain.biPlatformRealData.repository.po.RealPlatformInfoPO;
|
||||||
import com.mhd.bi.domain.biPlatformRealData.repository.po.RealVehicleStatusPO;
|
import com.mhd.bi.domain.biPlatformRealData.repository.po.RealVehicleStatusPO;
|
||||||
import com.mhd.bi.domain.biPlatformRealData.repository.po.RealTaskLoadPO;
|
import com.mhd.bi.domain.biPlatformRealData.repository.po.RealTaskLoadPO;
|
||||||
|
import com.mhd.bi.domain.biWarehouseTransport.repository.po.RealWarehouseOrderStatPO;
|
||||||
|
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
@@ -45,6 +47,8 @@ public class BiReportSnapshotSyncService {
|
|||||||
private final BiSnapshotWriteMapper biSnapshotWriteMapper;
|
private final BiSnapshotWriteMapper biSnapshotWriteMapper;
|
||||||
private final ObjectMapper objectMapper;
|
private final ObjectMapper objectMapper;
|
||||||
private final BiPlatformRealDataService biPlatformRealDataService;
|
private final BiPlatformRealDataService biPlatformRealDataService;
|
||||||
|
private final com.mhd.bi.domain.biWarehouseTransport.service.BiWarehouseTransportRealDataService biWarehouseTransportRealDataService;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 依次同步各快照表;单表失败不影响其它表,只记日志。
|
* 依次同步各快照表;单表失败不影响其它表,只记日志。
|
||||||
@@ -143,11 +147,33 @@ public class BiReportSnapshotSyncService {
|
|||||||
return BiSnapshotWeeklyRandomDataBuilder.comprehensive(new Random());
|
return BiSnapshotWeeklyRandomDataBuilder.comprehensive(new Random());
|
||||||
}
|
}
|
||||||
|
|
||||||
/** TODO 业务落地:改为查询真实数据。临时实现见 {@link BiSnapshotWeeklyRandomDataBuilder#warehouseTransport(Random)}。 */
|
/**
|
||||||
|
* 仓储运输:订单量 / 今日订单 / 今日运输车次 / 客户贡献排名 用真实数据覆盖;
|
||||||
|
* 其余(趋势类、周转率、货量等)仍为写死模板。
|
||||||
|
*/
|
||||||
protected WarehouseTransportSituationVO buildWarehouseTransportSnapshot() {
|
protected WarehouseTransportSituationVO buildWarehouseTransportSnapshot() {
|
||||||
return BiSnapshotWeeklyRandomDataBuilder.warehouseTransport(new Random());
|
WarehouseTransportSituationVO template =
|
||||||
|
BiSnapshotWeeklyRandomDataBuilder.warehouseTransport(new Random(20260825L));
|
||||||
|
|
||||||
|
// ====== 真实数据:仓储订单量(WMS 入库单 + 出库单,本年度/本季度/本月度,全部组织) ======
|
||||||
|
RealWarehouseOrderStatPO orderStat = biWarehouseTransportRealDataService.queryWarehouseOrderStat();
|
||||||
|
template.setCurrentYearOrders(orderStat.getCurrentYearOrders());
|
||||||
|
template.setCurrentQuarterOrders(orderStat.getCurrentQuarterOrders().intValue());
|
||||||
|
template.setCurrentMonthOrders(orderStat.getCurrentMonthOrders().intValue());
|
||||||
|
|
||||||
|
// ====== 真实数据:今日订单数量(OMS 运输业务单) ======
|
||||||
|
template.setOrderCount((int) biWarehouseTransportRealDataService.countTodayTransportOrders());
|
||||||
|
|
||||||
|
// ====== 真实数据:今日运输车次(TMS 运输单) ======
|
||||||
|
template.setTransportTrips((int) biWarehouseTransportRealDataService.countTodayTransportTrips());
|
||||||
|
|
||||||
|
// ====== 真实数据:客户贡献排名(OMS 近半年前 5 名货主) ======
|
||||||
|
template.setCustomerContributionRank(biWarehouseTransportRealDataService.queryCustomerContributionRank());
|
||||||
|
|
||||||
|
return template;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/** TODO 业务落地:部分字段改为真实数据,其余仍写死。 */
|
/** TODO 业务落地:部分字段改为真实数据,其余仍写死。 */
|
||||||
protected PlatformSurveillanceVO buildPlatformSurveillanceSnapshot() {
|
protected PlatformSurveillanceVO buildPlatformSurveillanceSnapshot() {
|
||||||
// 固定种子,保证写死字段每次生成值一致(真实字段随后实时覆盖)
|
// 固定种子,保证写死字段每次生成值一致(真实字段随后实时覆盖)
|
||||||
@@ -194,21 +220,47 @@ public class BiReportSnapshotSyncService {
|
|||||||
template.getPlatformOverview().setCurrentOccupancyRate(rate);
|
template.getPlatformOverview().setCurrentOccupancyRate(rate);
|
||||||
template.getPlatformOverview().setTodayTasks(todayTasks);
|
template.getPlatformOverview().setTodayTasks(todayTasks);
|
||||||
|
|
||||||
// 作业准时率 = 实际进入时间 < 预约日期+预约结束时间 的车辆 / 今日预约总数 × 100%(取整)
|
// 作业准时率:任务超时率 + 月台作业准时率 = 100%;园区作业准时率 = 100 - 园区超时率
|
||||||
|
template.getEfficiencyStatistics().setPlatformOnTimeRate(
|
||||||
|
(int) Math.round(100.0 - biPlatformRealDataService.calcTodayTaskOvertimeRate()));
|
||||||
|
template.getEfficiencyStatistics().setYardOnTimeRate(
|
||||||
|
(int) Math.round(100.0 - biPlatformRealDataService.calcTodayYardOvertimeRate()));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ====== 真实数据:平均作业时长(本日)月台作业平均时长 / 园区平均时长 ======
|
||||||
if (template.getEfficiencyStatistics() != null) {
|
if (template.getEfficiencyStatistics() != null) {
|
||||||
template.getEfficiencyStatistics().setPlatformOnTimeRate(biPlatformRealDataService.calcTodayOnTimeRate());
|
com.mhd.bi.domain.biPlatformRealData.repository.po.RealTodayAvgDurationPO avg =
|
||||||
}
|
biPlatformRealDataService.queryTodayAvgDuration();
|
||||||
|
template.getEfficiencyStatistics().setAvgPlatformDuration(avg.getAvgPlatformDurationHours());
|
||||||
|
template.getEfficiencyStatistics().setAvgYardDuration(avg.getAvgYardDurationHours());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// ====== 真实数据:作业车辆状态统计 ======
|
// ====== 真实数据:作业车辆状态统计 ======
|
||||||
RealVehicleStatusPO vs = biPlatformRealDataService.queryVehicleStatusToday();
|
RealVehicleStatusPO vs = biPlatformRealDataService.queryVehicleStatusToday();
|
||||||
if (template.getVehicleStatus() != null) {
|
if (template.getVehicleStatus() != null) {
|
||||||
template.getVehicleStatus().setTodayReservedVehicles(vs.getTodayReservedVehicles().intValue());
|
template.getVehicleStatus().setTodayReservedVehicles(vs.getTodayReservedVehicles().intValue());
|
||||||
template.getVehicleStatus().setNotCheckedIn(vs.getNotCheckedIn().intValue());
|
template.getVehicleStatus().setNotCheckedIn(vs.getNotCheckedIn().intValue());
|
||||||
template.getVehicleStatus().setWaiting(vs.getWaiting().intValue());
|
template.getVehicleStatus().setWaiting(vs.getWaiting().intValue());
|
||||||
|
// 叫号状态合计:已签到 + 已叫号 + 已过号(一个字段表示三个状态的总数量)
|
||||||
|
template.getVehicleStatus().setCallStatusTotal(vs.getCallStatusTotal() == null ? 0 : vs.getCallStatusTotal().intValue());
|
||||||
template.getVehicleStatus().setOperatingVehicles(vs.getOperatingVehicles().intValue());
|
template.getVehicleStatus().setOperatingVehicles(vs.getOperatingVehicles().intValue());
|
||||||
template.getVehicleStatus().setCompletedVehicles(vs.getCompletedVehicles().intValue());
|
template.getVehicleStatus().setCompletedVehicles(vs.getCompletedVehicles().intValue());
|
||||||
|
|
||||||
|
// 月台周转率 = 今日已出场记录数 ÷ 今日全部记录数 × 100%(保留两位小数)
|
||||||
|
if (template.getPlatformOverview() != null) {
|
||||||
|
long todayTotal = vs.getTodayReservedVehicles() == null ? 0L : vs.getTodayReservedVehicles();
|
||||||
|
long todayExited = vs.getTodayExited() == null ? 0L : vs.getTodayExited();
|
||||||
|
double turnover = todayTotal > 0
|
||||||
|
? Math.round(((double) todayExited / (double) todayTotal) * 100.0 * 100.0) / 100.0
|
||||||
|
: 0d;
|
||||||
|
template.getPlatformOverview().setPlatformTurnoverRate(turnover);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// ====== 真实数据:本月任务统计 taskTotal / avgTaskDuration / taskCompletionRate ======
|
// ====== 真实数据:本月任务统计 taskTotal / avgTaskDuration / taskCompletionRate ======
|
||||||
long monthTasks = biPlatformRealDataService.countMonthTasks();
|
long monthTasks = biPlatformRealDataService.countMonthTasks();
|
||||||
@@ -218,10 +270,11 @@ public class BiReportSnapshotSyncService {
|
|||||||
biPlatformRealDataService.queryMonthTaskStats();
|
biPlatformRealDataService.queryMonthTaskStats();
|
||||||
if (monthStats != null) {
|
if (monthStats != null) {
|
||||||
if (monthStats.getAvgDurationHours() != null) {
|
if (monthStats.getAvgDurationHours() != null) {
|
||||||
double v = monthStats.getAvgDurationHours();
|
// 任务平均作业时长 = 本月作业时长合计 ÷ 本月任务数(Service 层已算好)
|
||||||
template.getMonthlyTaskStatistics().setAvgTaskDuration(Math.round(v * 100.0) / 100.0);
|
template.getMonthlyTaskStatistics().setAvgTaskDuration(monthStats.getAvgDurationHours());
|
||||||
}
|
}
|
||||||
Long total = monthStats.getTotalCount();
|
Long total = monthStats.getTotalCount();
|
||||||
|
|
||||||
Long completed = monthStats.getCompletedCount();
|
Long completed = monthStats.getCompletedCount();
|
||||||
if (total != null && total > 0 && completed != null) {
|
if (total != null && total > 0 && completed != null) {
|
||||||
int rate = (int) Math.round(((double) completed.longValue() / total.longValue()) * 100.0);
|
int rate = (int) Math.round(((double) completed.longValue() / total.longValue()) * 100.0);
|
||||||
@@ -232,42 +285,49 @@ public class BiReportSnapshotSyncService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ====== 真实数据:任务负荷(今日 24 小时) ======
|
// ====== 真实数据:小时趋势(今日,每 2 小时分组) ======
|
||||||
List<RealTaskLoadPO> loads = biPlatformRealDataService.queryTaskLoadToday();
|
List<RealTaskLoadPO> loads = biPlatformRealDataService.queryTaskLoadToday();
|
||||||
if (!loads.isEmpty() && template.getTaskLoadStatistics() != null) {
|
if (loads.isEmpty()) {
|
||||||
Map<Integer, Long> hourMap = new HashMap<>();
|
template.setTaskLoadStatistics(new ArrayList<>());
|
||||||
|
} else {
|
||||||
|
Map<Integer, Long> bucketMap = new HashMap<>();
|
||||||
for (RealTaskLoadPO l : loads) {
|
for (RealTaskLoadPO l : loads) {
|
||||||
hourMap.put(l.getHourOfDay(), l.getTaskCount());
|
if (l != null && l.getHourOfDay() != null) {
|
||||||
}
|
bucketMap.put(l.getHourOfDay(), l.getTaskCount() == null ? 0L : l.getTaskCount());
|
||||||
for (com.mhd.bi.interfaces.facadeApi.biReport.vo.platform.TaskLoadItemVO item : template.getTaskLoadStatistics()) {
|
|
||||||
Integer hour = parseHourFromLabel(item.getTime());
|
|
||||||
if (hour != null) {
|
|
||||||
Long n = hourMap.get(hour);
|
|
||||||
if (n != null) item.setTaskCount(n.intValue());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// 固定输出 0,2,4,...,22 共 12 个桶,无数据桶补 0
|
||||||
|
List<com.mhd.bi.interfaces.facadeApi.biReport.vo.platform.TaskLoadItemVO> items = new ArrayList<>();
|
||||||
|
for (int h = 0; h < 24; h += 2) {
|
||||||
|
Long cnt = bucketMap.get(h);
|
||||||
|
items.add(com.mhd.bi.interfaces.facadeApi.biReport.vo.platform.TaskLoadItemVO.builder()
|
||||||
|
.time(String.format("%02d:00", h))
|
||||||
|
.taskCount(cnt == null ? 0 : cnt.intValue())
|
||||||
|
.build());
|
||||||
}
|
}
|
||||||
|
template.setTaskLoadStatistics(items);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// ====== 真实数据:任务类型统计(本月 YMS QMS_MAIN_BUSINESS 按业务类型 BUSINESS_NAME 分组) ======
|
// ====== 真实数据:任务类型统计(本月 YMS QMS_MAIN_BUSINESS 按业务类型 BUSINESS_NAME 分组) ======
|
||||||
template.setTaskTypeStatistics(biPlatformRealDataService.queryMonthTransportOrderByType());
|
template.setTaskTypeStatistics(biPlatformRealDataService.queryMonthTransportOrderByType());
|
||||||
|
|
||||||
|
// ====== 真实数据:平均作业时长趋势(近半年按月:月台作业平均时长 / 园区作业平均时长) ======
|
||||||
|
template.setAvgOperationDurationTrend(biPlatformRealDataService.queryAvgOperationDurationTrend());
|
||||||
|
|
||||||
|
// ====== 真实数据:任务超时率 + 月台作业超时记录列表(依赖 YMS QMS_STATIC_FIELD 参考用时) ======
|
||||||
|
template.setTaskOvertimeRate(biPlatformRealDataService.calcTodayTaskOvertimeRate());
|
||||||
|
template.setOvertimeRecords(biPlatformRealDataService.queryTodayOvertimeRecords());
|
||||||
|
|
||||||
return template;
|
return template;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Integer parseHourFromLabel(String label) {
|
|
||||||
if (label == null) return null;
|
|
||||||
// "15时" -> 15
|
|
||||||
try {
|
|
||||||
String s = label.replace("时", "").trim();
|
|
||||||
return Integer.parseInt(s);
|
|
||||||
} catch (Exception e) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TODO 业务落地:改为查询真实数据组装 VO。当前为 {@link WarehouseOperationZoneDemoData} 静态示例。
|
* TODO 业务落地:改为查询真实数据组装 VO。当前为 {@link WarehouseOperationZoneDemoData} 静态示例。
|
||||||
*/
|
*/
|
||||||
|
|
||||||
protected WarehouseOperationZoneVO buildWarehouseOperationZoneSnapshot() {
|
protected WarehouseOperationZoneVO buildWarehouseOperationZoneSnapshot() {
|
||||||
return WarehouseOperationZoneDemoData.build();
|
return WarehouseOperationZoneDemoData.build();
|
||||||
}
|
}
|
||||||
|
|||||||
+24
-17
@@ -79,9 +79,9 @@ public final class BiSnapshotWeeklyRandomDataBuilder {
|
|||||||
return ComprehensiveSituationVO.builder()
|
return ComprehensiveSituationVO.builder()
|
||||||
.valueAddedServiceIncome(jitterLong(Baseline.COMP_INCOME, r))
|
.valueAddedServiceIncome(jitterLong(Baseline.COMP_INCOME, r))
|
||||||
.inventoryTurnover(Math.max(1, jitterInt(Baseline.COMP_TURNOVER, r)))
|
.inventoryTurnover(Math.max(1, jitterInt(Baseline.COMP_TURNOVER, r)))
|
||||||
.orderCount(Math.max(0, jitterInt(Baseline.COMP_ORDERS, r)))
|
.orderCount((long) Math.max(0, jitterInt(Baseline.COMP_ORDERS, r)))
|
||||||
.vehicleUtilizationRate(jitterPercentDouble(Baseline.COMP_VEHICLE_PCT, r))
|
.vehicleUtilizationRate(jitterPercentDouble(Baseline.COMP_VEHICLE_PCT, r))
|
||||||
.fuelConsumptionPerHundredKm(Math.max(1, jitterInt(Baseline.COMP_FUEL, r)))
|
.fuelConsumptionPerHundredKm(Math.max(1.0, jitterDouble(Baseline.COMP_FUEL, r)))
|
||||||
.incomeTrend(jitterIntArray(Baseline.COMP_INCOME_TREND, r))
|
.incomeTrend(jitterIntArray(Baseline.COMP_INCOME_TREND, r))
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
@@ -136,13 +136,14 @@ public final class BiSnapshotWeeklyRandomDataBuilder {
|
|||||||
.build());
|
.build());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 效率统计(本日):入园区超时率、超时数量、月台作业准时率、园区作业准时率 按业务要求恒为 0
|
||||||
EfficiencyStatisticsVO eff = EfficiencyStatisticsVO.builder()
|
EfficiencyStatisticsVO eff = EfficiencyStatisticsVO.builder()
|
||||||
.entryOvertimeRate(jitterPercentInt(Baseline.P_ENT_OT, r))
|
.entryOvertimeRate(0)
|
||||||
.overtimeCount(Math.max(0, jitterInt(Baseline.P_OT_CNT, r)))
|
.overtimeCount(0)
|
||||||
.platformOnTimeRate(jitterPercentInt(Baseline.P_PL_OT, r))
|
.platformOnTimeRate(0)
|
||||||
.avgPlatformDuration(Math.max(0.1, jitterDouble(Baseline.P_AVG_PL, r)))
|
.avgPlatformDuration(0d)
|
||||||
.yardOnTimeRate(jitterPercentInt(Baseline.P_YD_OT, r))
|
.yardOnTimeRate(0)
|
||||||
.avgYardDuration(Math.max(0.1, jitterDouble(Baseline.P_AVG_YD, r)))
|
.avgYardDuration(0d)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
PlatformOverviewVO overview = PlatformOverviewVO.builder()
|
PlatformOverviewVO overview = PlatformOverviewVO.builder()
|
||||||
@@ -150,15 +151,19 @@ public final class BiSnapshotWeeklyRandomDataBuilder {
|
|||||||
.currentOccupancyRate((double) jitterPercentInt(Baseline.P_OCC, r))
|
.currentOccupancyRate((double) jitterPercentInt(Baseline.P_OCC, r))
|
||||||
.operatingPlatforms(Math.max(0, jitterInt(Baseline.P_OP, r)))
|
.operatingPlatforms(Math.max(0, jitterInt(Baseline.P_OP, r)))
|
||||||
.todayTasks(Math.max(0, jitterInt(Baseline.P_TASKS, r)))
|
.todayTasks(Math.max(0, jitterInt(Baseline.P_TASKS, r)))
|
||||||
|
.platformTurnoverRate(jitterPercentDouble(Baseline.P_TURNOVER, r))
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
VehicleStatusVO vs = VehicleStatusVO.builder()
|
VehicleStatusVO vs = VehicleStatusVO.builder()
|
||||||
.todayReservedVehicles(Math.max(0, jitterInt(Baseline.P_RESV, r)))
|
.todayReservedVehicles(Math.max(0, jitterInt(Baseline.P_RESV, r)))
|
||||||
.notCheckedIn(Math.max(0, jitterInt(Baseline.P_NC, r)))
|
.notCheckedIn(Math.max(0, jitterInt(Baseline.P_NC, r)))
|
||||||
|
.waiting(Math.max(0, jitterInt(Baseline.P_WAIT, r)))
|
||||||
|
.callStatusTotal(Math.max(0, jitterInt(Baseline.P_CALL_STATUS_TOTAL, r)))
|
||||||
.operatingVehicles(Math.max(0, jitterInt(Baseline.P_OPV, r)))
|
.operatingVehicles(Math.max(0, jitterInt(Baseline.P_OPV, r)))
|
||||||
.completedVehicles(Math.max(0, jitterInt(Baseline.P_DONE, r)))
|
.completedVehicles(Math.max(0, jitterInt(Baseline.P_DONE, r)))
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
|
|
||||||
List<AvgOperationDurationTrendItemVO> avgTrend = new ArrayList<>();
|
List<AvgOperationDurationTrendItemVO> avgTrend = new ArrayList<>();
|
||||||
for (int i = 0; i < Baseline.P_MO_LABELS.length; i++) {
|
for (int i = 0; i < Baseline.P_MO_LABELS.length; i++) {
|
||||||
avgTrend.add(AvgOperationDurationTrendItemVO.builder()
|
avgTrend.add(AvgOperationDurationTrendItemVO.builder()
|
||||||
@@ -221,9 +226,13 @@ public final class BiSnapshotWeeklyRandomDataBuilder {
|
|||||||
.unhandled(unhandled)
|
.unhandled(unhandled)
|
||||||
.build())
|
.build())
|
||||||
.platformAlarmDistribution(dist)
|
.platformAlarmDistribution(dist)
|
||||||
|
// 任务超时率 / 超时记录列表:实时查库覆盖,模板给 0/空兜底
|
||||||
|
.taskOvertimeRate(0d)
|
||||||
|
.overtimeRecords(new ArrayList<>())
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 总体运营态势:与 {@code create_bi_overall_operation_dm.sql} 内置 PAYLOAD_JSON 一致(不随 Random 抖动)。
|
* 总体运营态势:与 {@code create_bi_overall_operation_dm.sql} 内置 PAYLOAD_JSON 一致(不随 Random 抖动)。
|
||||||
*/
|
*/
|
||||||
@@ -359,7 +368,7 @@ public final class BiSnapshotWeeklyRandomDataBuilder {
|
|||||||
static final int COMP_TURNOVER = 18;
|
static final int COMP_TURNOVER = 18;
|
||||||
static final int COMP_ORDERS = 50_120;
|
static final int COMP_ORDERS = 50_120;
|
||||||
static final double COMP_VEHICLE_PCT = 93.2;
|
static final double COMP_VEHICLE_PCT = 93.2;
|
||||||
static final int COMP_FUEL = 12;
|
static final double COMP_FUEL = 12.5;
|
||||||
static final int[] COMP_INCOME_TREND = {195, 248, 302, 415, 366, 488};
|
static final int[] COMP_INCOME_TREND = {195, 248, 302, 415, 366, 488};
|
||||||
|
|
||||||
static final double W_WH_RATE = 96.8;
|
static final double W_WH_RATE = 96.8;
|
||||||
@@ -391,19 +400,15 @@ public final class BiSnapshotWeeklyRandomDataBuilder {
|
|||||||
{"闽D99887", "作业中", "#07", "142"},
|
{"闽D99887", "作业中", "#07", "142"},
|
||||||
{"粤B66220", "已离园", "#29", "201"}
|
{"粤B66220", "已离园", "#29", "201"}
|
||||||
};
|
};
|
||||||
static final int P_ENT_OT = 42;
|
|
||||||
static final int P_OT_CNT = 28;
|
|
||||||
static final int P_PL_OT = 88;
|
|
||||||
static final double P_AVG_PL = 3.8;
|
|
||||||
static final int P_YD_OT = 91;
|
|
||||||
static final double P_AVG_YD = 5.2;
|
|
||||||
static final int P_TOT_PL = 58;
|
static final int P_TOT_PL = 58;
|
||||||
static final int P_OCC = 62;
|
static final int P_OCC = 62;
|
||||||
static final int P_OP = 31;
|
static final int P_OP = 31;
|
||||||
static final int P_TASKS = 418;
|
static final int P_TASKS = 418;
|
||||||
|
static final double P_TURNOVER = 72.5;
|
||||||
static final int P_RESV = 2_850;
|
static final int P_RESV = 2_850;
|
||||||
static final int P_NC = 920;
|
static final int P_NC = 920;
|
||||||
static final int P_WAIT = 680;
|
static final int P_WAIT = 680;
|
||||||
|
static final int P_CALL_STATUS_TOTAL = 680;
|
||||||
static final int P_OPV = 1_180;
|
static final int P_OPV = 1_180;
|
||||||
static final int P_DONE = 1_420;
|
static final int P_DONE = 1_420;
|
||||||
static final String[] P_MO_LABELS = {"5月", "6月", "7月"};
|
static final String[] P_MO_LABELS = {"5月", "6月", "7月"};
|
||||||
@@ -415,8 +420,10 @@ public final class BiSnapshotWeeklyRandomDataBuilder {
|
|||||||
static final int P_MT_AVG_YOY = -3;
|
static final int P_MT_AVG_YOY = -3;
|
||||||
static final int P_MT_CR = 97;
|
static final int P_MT_CR = 97;
|
||||||
static final int P_MT_CR_YOY = 2;
|
static final int P_MT_CR_YOY = 2;
|
||||||
static final String[] P_LOAD_T = {"8时", "10时", "14时"};
|
/** 小时趋势:每 2 小时一个桶,0:00 ~ 22:00 共 12 个 */
|
||||||
static final int[] P_LOAD_C = {45, 120, 156};
|
static final String[] P_LOAD_T = {"00:00", "02:00", "04:00", "06:00", "08:00", "10:00",
|
||||||
|
"12:00", "14:00", "16:00", "18:00", "20:00", "22:00"};
|
||||||
|
static final int[] P_LOAD_C = {5, 3, 2, 8, 45, 120, 130, 156, 110, 70, 30, 12};
|
||||||
static final String[] P_AL_D = {"1日", "2日", "3日"};
|
static final String[] P_AL_D = {"1日", "2日", "3日"};
|
||||||
static final int[] P_AL_C = {6, 9, 4};
|
static final int[] P_AL_C = {6, 9, 4};
|
||||||
static final int P_TT_TOT = 5_100;
|
static final int P_TT_TOT = 5_100;
|
||||||
|
|||||||
+23
@@ -0,0 +1,23 @@
|
|||||||
|
package com.mhd.bi.domain.biStaticField.repository.mapper;
|
||||||
|
|
||||||
|
import com.mhd.bi.domain.biStaticField.repository.po.BiStaticFieldPO;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* BI 业务静态字段配置 Mapper(YMS 库 NGWL_TEST_YMS.QMS_STATIC_FIELD)
|
||||||
|
*
|
||||||
|
* <p>SQL 见 BiStaticFieldMapper.xml。</p>
|
||||||
|
*/
|
||||||
|
public interface BiStaticFieldMapper {
|
||||||
|
|
||||||
|
/** 按字段编码查询全部有效配置(含 GLOBAL / FLOOR / WINDOW 各作用域,供程序按优先级取值) */
|
||||||
|
List<BiStaticFieldPO> queryByCode(@Param("fieldCode") String fieldCode);
|
||||||
|
|
||||||
|
/** 批量按字段编码查询有效配置 */
|
||||||
|
List<BiStaticFieldPO> queryByCodes(@Param("fieldCodes") List<String> fieldCodes);
|
||||||
|
|
||||||
|
/** 查询全部有效配置 */
|
||||||
|
List<BiStaticFieldPO> queryAll();
|
||||||
|
}
|
||||||
+38
@@ -0,0 +1,38 @@
|
|||||||
|
package com.mhd.bi.domain.biStaticField.repository.po;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 业务静态字段配置(来自 NGWL_TEST_YMS.QMS_STATIC_FIELD)
|
||||||
|
*
|
||||||
|
* <p>集中存放指标计算所需的参考值/基准值,当前使用:</p>
|
||||||
|
* <ul>
|
||||||
|
* <li>platform_work_ref_minutes 月台作业参考用时(分钟)</li>
|
||||||
|
* <li>yard_work_ref_minutes 园区作业参考用时(分钟)</li>
|
||||||
|
* </ul>
|
||||||
|
* <p>后续新增静态字段只需往表里 INSERT,无需改代码结构。</p>
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class BiStaticFieldPO implements Serializable {
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/** 静态字段编码 */
|
||||||
|
private String fieldCode;
|
||||||
|
|
||||||
|
/** 静态字段名称 */
|
||||||
|
private String fieldName;
|
||||||
|
|
||||||
|
/** 作用域类型:GLOBAL-全局 FLOOR-按楼层 WINDOW-按月台 */
|
||||||
|
private String scopeType;
|
||||||
|
|
||||||
|
/** 作用域编码:GLOBAL 时为 ALL;FLOOR 时为楼层;WINDOW 时为月台名 */
|
||||||
|
private String scopeCode;
|
||||||
|
|
||||||
|
/** 字段值(字符串,程序按需转换) */
|
||||||
|
private String fieldValue;
|
||||||
|
|
||||||
|
/** 单位 */
|
||||||
|
private String unit;
|
||||||
|
}
|
||||||
+108
@@ -0,0 +1,108 @@
|
|||||||
|
package com.mhd.bi.domain.biStaticField.service;
|
||||||
|
|
||||||
|
import com.mhd.bi.domain.biStaticField.repository.mapper.BiStaticFieldMapper;
|
||||||
|
import com.mhd.bi.domain.biStaticField.repository.po.BiStaticFieldPO;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* BI 业务静态字段配置业务层(YMS 库 QMS_STATIC_FIELD)
|
||||||
|
*
|
||||||
|
* <p>集中提供参考值/基准值等静态配置的读取能力,后续新增静态字段只需往表里 INSERT。</p>
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
@Service
|
||||||
|
public class BiStaticFieldService {
|
||||||
|
|
||||||
|
/** 月台作业参考用时(分钟) */
|
||||||
|
public static final String CODE_PLATFORM_WORK_REF_MINUTES = "platform_work_ref_minutes";
|
||||||
|
|
||||||
|
/** 园区作业参考用时(分钟) */
|
||||||
|
public static final String CODE_YARD_WORK_REF_MINUTES = "yard_work_ref_minutes";
|
||||||
|
|
||||||
|
/** 作用域:全局 */
|
||||||
|
private static final String SCOPE_GLOBAL = "GLOBAL";
|
||||||
|
/** 作用域:按月台 */
|
||||||
|
private static final String SCOPE_WINDOW = "WINDOW";
|
||||||
|
/** 作用域:按楼层 */
|
||||||
|
private static final String SCOPE_FLOOR = "FLOOR";
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private BiStaticFieldMapper biStaticFieldMapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 按字段编码查询全部有效配置;查询失败返回空列表。
|
||||||
|
*/
|
||||||
|
public List<BiStaticFieldPO> queryByCode(String fieldCode) {
|
||||||
|
try {
|
||||||
|
List<BiStaticFieldPO> list = biStaticFieldMapper.queryByCode(fieldCode);
|
||||||
|
return list == null ? Collections.emptyList() : list;
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("【YMS】查询静态字段配置失败, fieldCode={}: {}", fieldCode, e.getMessage(), e);
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 按「WINDOW > FLOOR > GLOBAL」优先级取静态字段值(字符串)。取不到返回 null。
|
||||||
|
*
|
||||||
|
* @param fieldCode 字段编码
|
||||||
|
* @param windowName 月台名(可为空)
|
||||||
|
* @param floor 楼层(可为空)
|
||||||
|
*/
|
||||||
|
public String resolveValue(String fieldCode, String windowName, String floor) {
|
||||||
|
List<BiStaticFieldPO> list = queryByCode(fieldCode);
|
||||||
|
if (list.isEmpty()) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
String globalVal = null;
|
||||||
|
String floorVal = null;
|
||||||
|
for (BiStaticFieldPO po : list) {
|
||||||
|
if (po == null || po.getFieldValue() == null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
String scopeType = po.getScopeType() == null ? "" : po.getScopeType().trim().toUpperCase();
|
||||||
|
String scopeCode = po.getScopeCode();
|
||||||
|
if (SCOPE_WINDOW.equals(scopeType) && windowName != null && windowName.equals(scopeCode)) {
|
||||||
|
return po.getFieldValue(); // 最高优先级,直接返回
|
||||||
|
}
|
||||||
|
if (SCOPE_FLOOR.equals(scopeType) && floor != null && floor.equals(scopeCode)) {
|
||||||
|
floorVal = po.getFieldValue();
|
||||||
|
}
|
||||||
|
if (SCOPE_GLOBAL.equals(scopeType)) {
|
||||||
|
globalVal = po.getFieldValue();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return floorVal != null ? floorVal : globalVal;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 取静态字段的数值(分钟等整数),取不到或非数字返回 null。
|
||||||
|
*/
|
||||||
|
public Long resolveLongValue(String fieldCode, String windowName, String floor) {
|
||||||
|
String v = resolveValue(fieldCode, windowName, floor);
|
||||||
|
if (v == null || v.trim().isEmpty()) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
return Long.valueOf(v.trim());
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.warn("【YMS】静态字段值非数字, fieldCode={}, value={}", fieldCode, v);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 月台作业参考用时(分钟),按月台/楼层解析;取不到返回 null */
|
||||||
|
public Long resolvePlatformWorkRefMinutes(String windowName, String floor) {
|
||||||
|
return resolveLongValue(CODE_PLATFORM_WORK_REF_MINUTES, windowName, floor);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 园区作业参考用时(分钟),按月台/楼层解析;取不到返回 null */
|
||||||
|
public Long resolveYardWorkRefMinutes(String windowName, String floor) {
|
||||||
|
return resolveLongValue(CODE_YARD_WORK_REF_MINUTES, windowName, floor);
|
||||||
|
}
|
||||||
|
}
|
||||||
+32
@@ -0,0 +1,32 @@
|
|||||||
|
package com.mhd.bi.domain.biWarehouseTransport.repository.mapper;
|
||||||
|
|
||||||
|
import com.mhd.bi.domain.biWarehouseTransport.repository.po.RealCustomerRankPO;
|
||||||
|
import com.mhd.bi.domain.biWarehouseTransport.repository.po.RealWarehouseOrderStatPO;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 仓储运输-真实业务数据 Mapper(跨库查询,与月台监测同方案)
|
||||||
|
*
|
||||||
|
* <p>数据来源:</p>
|
||||||
|
* <ul>
|
||||||
|
* <li>库存订单量:NGWL_TEST_WMS.STOCK_IN_ORDER + NGWL_TEST_WMS.STOCK_OUT_ORDER</li>
|
||||||
|
* <li>今日订单数量:NGWL_TEST_OMS.BUSINESS_DOCUMENT_ORDER</li>
|
||||||
|
* <li>今日运输车次:NGWL_TEST_WLHY.TMS_TRANSPORT_NOTE</li>
|
||||||
|
* <li>客户贡献排名:NGWL_TEST_OMS.BUSINESS_DOCUMENT_ORDER 按货主聚合近半年</li>
|
||||||
|
* </ul>
|
||||||
|
*/
|
||||||
|
public interface BiWarehouseTransportRealDataMapper {
|
||||||
|
|
||||||
|
/** 仓储订单量:本年度 / 本季度 / 本月度(WMS 入库单 + 出库单),全部组织 */
|
||||||
|
RealWarehouseOrderStatPO queryWarehouseOrderStat();
|
||||||
|
|
||||||
|
/** 今日订单数量:OMS 运输业务单,今日创建 */
|
||||||
|
Long countTodayTransportOrders();
|
||||||
|
|
||||||
|
/** 今日运输车次:TMS 运单(运输单),今日创建,一个单 = 一个车次 */
|
||||||
|
Long countTodayTransportTrips();
|
||||||
|
|
||||||
|
/** 客户贡献排名:OMS 运输业务单,近半年按货主聚合订单数,取前 5 名 */
|
||||||
|
List<RealCustomerRankPO> queryCustomerRankTop5();
|
||||||
|
}
|
||||||
+21
@@ -0,0 +1,21 @@
|
|||||||
|
package com.mhd.bi.domain.biWarehouseTransport.repository.po;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 客户贡献排名项(真实数据,来自 OMS 运输业务单)
|
||||||
|
*
|
||||||
|
* <p>统计范围:全部组织,近半年,按货主聚合作业量,取前 5 名。</p>
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class RealCustomerRankPO implements Serializable {
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/** 货主/客户名称 */
|
||||||
|
private String customerName;
|
||||||
|
|
||||||
|
/** 订单数(单) */
|
||||||
|
private Long customerAmount;
|
||||||
|
}
|
||||||
+25
@@ -0,0 +1,25 @@
|
|||||||
|
package com.mhd.bi.domain.biWarehouseTransport.repository.po;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 仓储订单量统计(真实数据)
|
||||||
|
*
|
||||||
|
* <p>数据来源:WMS 入库业务单 NGWL_TEST_WMS.STOCK_IN_ORDER + 出库业务单 NGWL_TEST_WMS.STOCK_OUT_ORDER</p>
|
||||||
|
* <p>统计范围:全部组织</p>
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class RealWarehouseOrderStatPO implements Serializable {
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/** 本年度订单数(入库 + 出库) */
|
||||||
|
private Long currentYearOrders;
|
||||||
|
|
||||||
|
/** 本季度订单数(入库 + 出库) */
|
||||||
|
private Long currentQuarterOrders;
|
||||||
|
|
||||||
|
/** 本月度订单数(入库 + 出库) */
|
||||||
|
private Long currentMonthOrders;
|
||||||
|
}
|
||||||
+99
@@ -0,0 +1,99 @@
|
|||||||
|
package com.mhd.bi.domain.biWarehouseTransport.service;
|
||||||
|
|
||||||
|
import com.mhd.bi.domain.biWarehouseTransport.repository.mapper.BiWarehouseTransportRealDataMapper;
|
||||||
|
import com.mhd.bi.domain.biWarehouseTransport.repository.po.RealCustomerRankPO;
|
||||||
|
import com.mhd.bi.domain.biWarehouseTransport.repository.po.RealWarehouseOrderStatPO;
|
||||||
|
import com.mhd.bi.interfaces.facadeApi.biReport.vo.CustomerContributionRankVO;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 仓储运输-真实业务数据业务层(封装 WMS / OMS / TMS 跨库查询)
|
||||||
|
*
|
||||||
|
* <p>实现方案与「月台监测指标查询」一致:实时查库,查不到或异常返回 0/空,不影响其它字段。</p>
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
@Service
|
||||||
|
public class BiWarehouseTransportRealDataService {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private BiWarehouseTransportRealDataMapper biWarehouseTransportRealDataMapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 仓储订单量:本年度 / 本季度 / 本月度(WMS 入库单 + 出库单),全部组织。
|
||||||
|
* 查询失败返回全 0。
|
||||||
|
*/
|
||||||
|
public RealWarehouseOrderStatPO queryWarehouseOrderStat() {
|
||||||
|
RealWarehouseOrderStatPO po = new RealWarehouseOrderStatPO();
|
||||||
|
po.setCurrentYearOrders(0L);
|
||||||
|
po.setCurrentQuarterOrders(0L);
|
||||||
|
po.setCurrentMonthOrders(0L);
|
||||||
|
try {
|
||||||
|
RealWarehouseOrderStatPO row = biWarehouseTransportRealDataMapper.queryWarehouseOrderStat();
|
||||||
|
if (row != null) {
|
||||||
|
po.setCurrentYearOrders(row.getCurrentYearOrders() == null ? 0L : row.getCurrentYearOrders());
|
||||||
|
po.setCurrentQuarterOrders(row.getCurrentQuarterOrders() == null ? 0L : row.getCurrentQuarterOrders());
|
||||||
|
po.setCurrentMonthOrders(row.getCurrentMonthOrders() == null ? 0L : row.getCurrentMonthOrders());
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("【WMS】统计仓储订单量失败: {}", e.getMessage(), e);
|
||||||
|
}
|
||||||
|
return po;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 今日订单数量:OMS 运输业务单,今日创建;查询失败返回 0 */
|
||||||
|
public long countTodayTransportOrders() {
|
||||||
|
try {
|
||||||
|
Long n = biWarehouseTransportRealDataMapper.countTodayTransportOrders();
|
||||||
|
return n == null ? 0L : n;
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("【OMS】统计今日订单数量失败: {}", e.getMessage(), e);
|
||||||
|
return 0L;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 今日运输车次:TMS 运输单,今日创建(一个单 = 一个车次);查询失败返回 0 */
|
||||||
|
public long countTodayTransportTrips() {
|
||||||
|
try {
|
||||||
|
Long n = biWarehouseTransportRealDataMapper.countTodayTransportTrips();
|
||||||
|
return n == null ? 0L : n;
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("【TMS】统计今日运输车次失败: {}", e.getMessage(), e);
|
||||||
|
return 0L;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 客户贡献排名(前 5 名货主,近半年订单数)。
|
||||||
|
* 查询失败返回空数组结构的对象,前端可正常渲染。
|
||||||
|
*/
|
||||||
|
public CustomerContributionRankVO queryCustomerContributionRank() {
|
||||||
|
List<String> names = new ArrayList<>();
|
||||||
|
List<Integer> amounts = new ArrayList<>();
|
||||||
|
try {
|
||||||
|
List<RealCustomerRankPO> rows = biWarehouseTransportRealDataMapper.queryCustomerRankTop5();
|
||||||
|
if (rows != null) {
|
||||||
|
for (RealCustomerRankPO r : rows) {
|
||||||
|
if (r == null || r.getCustomerName() == null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
names.add(r.getCustomerName());
|
||||||
|
amounts.add(r.getCustomerAmount() == null ? 0 : r.getCustomerAmount().intValue());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("【OMS】查询客户贡献排名失败: {}", e.getMessage(), e);
|
||||||
|
names = new ArrayList<>();
|
||||||
|
amounts = new ArrayList<>();
|
||||||
|
}
|
||||||
|
return CustomerContributionRankVO.builder()
|
||||||
|
.customerName(names.isEmpty() ? Collections.emptyList() : names)
|
||||||
|
.customerAmount(amounts.isEmpty() ? Collections.emptyList() : amounts)
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
}
|
||||||
+107
-1
@@ -1,18 +1,124 @@
|
|||||||
package com.mhd.bi.domain.biWarehouseTransport.service;
|
package com.mhd.bi.domain.biWarehouseTransport.service;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
import com.mhd.bi.domain.biSnapshotSync.repository.mapper.BiSnapshotWriteMapper;
|
||||||
import com.mhd.bi.domain.biWarehouseTransport.repository.mapper.BiWarehouseTransportReportMapper;
|
import com.mhd.bi.domain.biWarehouseTransport.repository.mapper.BiWarehouseTransportReportMapper;
|
||||||
|
import com.mhd.bi.domain.biWarehouseTransport.repository.po.RealWarehouseOrderStatPO;
|
||||||
import com.mhd.bi.interfaces.facadeApi.biReport.vo.WarehouseTransportSituationVO;
|
import com.mhd.bi.interfaces.facadeApi.biReport.vo.WarehouseTransportSituationVO;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
import java.util.LinkedHashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 仓储运输:数据访问仅经 Mapper(含 XML 内 SQL 与 Mapper 默认方法组装)。
|
||||||
|
*
|
||||||
|
* <p>实现方案与「月台监测指标查询」完全一致:</p>
|
||||||
|
* <ol>
|
||||||
|
* <li>先读快照最新一条作为基底;</li>
|
||||||
|
* <li>实时查业务库,用真实数据覆盖以下字段:
|
||||||
|
* 本年度订单 / 本季度订单 / 本月度订单(WMS 入库业务单 + 出库业务单)、
|
||||||
|
* 今日订单数量(OMS 运输业务单)、今日运输车次(TMS 运单)、
|
||||||
|
* 客户贡献排名(OMS 近半年前 5 名货主);</li>
|
||||||
|
* <li>对「真实业务数据」计算指纹,与快照最新一条比对:
|
||||||
|
* 未变化则跳过落库直接返回;已变化则覆盖更新快照最新一条,无记录时插入兜底。</li>
|
||||||
|
* </ol>
|
||||||
|
* <p>其余字段(趋势类、周转率、货量等)仍取自快照模板值,不纳入指纹。</p>
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
@Service
|
@Service
|
||||||
public class BiWarehouseTransportReportService {
|
public class BiWarehouseTransportReportService {
|
||||||
|
|
||||||
|
private static final String REMARK_REALTIME = "realtime warehouse-transport";
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private BiWarehouseTransportReportMapper biWarehouseTransportReportMapper;
|
private BiWarehouseTransportReportMapper biWarehouseTransportReportMapper;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private BiWarehouseTransportRealDataService biWarehouseTransportRealDataService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private BiSnapshotWriteMapper biSnapshotWriteMapper;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private ObjectMapper objectMapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 实时组装仓储运输数据:快照基底 + 实时业务数据覆盖;
|
||||||
|
* 仅当实时业务数据(WMS/OMS/TMS 查出的字段)发生变化时,才覆盖更新
|
||||||
|
* BI_WAREHOUSE_TRANSPORT_SNAPSHOT 快照表最新一条后返回。
|
||||||
|
* 表中尚无记录时插入一条兜底。
|
||||||
|
*/
|
||||||
public WarehouseTransportSituationVO loadLatestWarehouseTransport() {
|
public WarehouseTransportSituationVO loadLatestWarehouseTransport() {
|
||||||
return biWarehouseTransportReportMapper.loadLatestWarehouseTransport();
|
WarehouseTransportSituationVO vo = biWarehouseTransportReportMapper.loadLatestWarehouseTransport();
|
||||||
|
if (vo == null) {
|
||||||
|
vo = new WarehouseTransportSituationVO();
|
||||||
|
}
|
||||||
|
|
||||||
|
// 仓储订单量:WMS 入库业务单 + 出库业务单(本年度 / 本季度 / 本月度,全部组织)
|
||||||
|
RealWarehouseOrderStatPO orderStat = biWarehouseTransportRealDataService.queryWarehouseOrderStat();
|
||||||
|
vo.setCurrentYearOrders(orderStat.getCurrentYearOrders());
|
||||||
|
vo.setCurrentQuarterOrders(orderStat.getCurrentQuarterOrders().intValue());
|
||||||
|
vo.setCurrentMonthOrders(orderStat.getCurrentMonthOrders().intValue());
|
||||||
|
|
||||||
|
// 今日订单数量:OMS 运输业务单
|
||||||
|
vo.setOrderCount((int) biWarehouseTransportRealDataService.countTodayTransportOrders());
|
||||||
|
|
||||||
|
// 今日运输车次:TMS 运输单(一个单 = 一个车次)
|
||||||
|
vo.setTransportTrips((int) biWarehouseTransportRealDataService.countTodayTransportTrips());
|
||||||
|
|
||||||
|
// 客户贡献排名:OMS 运输业务单,近半年前 5 名货主(订单数)
|
||||||
|
vo.setCustomerContributionRank(biWarehouseTransportRealDataService.queryCustomerContributionRank());
|
||||||
|
|
||||||
|
try {
|
||||||
|
String fullJson = objectMapper.writeValueAsString(vo);
|
||||||
|
String fingerprint = realDataFingerprint(vo);
|
||||||
|
|
||||||
|
String latestJson = biWarehouseTransportReportMapper.selectLatestPayloadJson();
|
||||||
|
if (StringUtils.isNotBlank(latestJson)) {
|
||||||
|
WarehouseTransportSituationVO latestVo =
|
||||||
|
objectMapper.readValue(latestJson.trim(), WarehouseTransportSituationVO.class);
|
||||||
|
if (Objects.equals(fingerprint, realDataFingerprint(latestVo))) {
|
||||||
|
log.info("BI 仓储运输实时业务数据未变化,跳过落库");
|
||||||
|
return vo;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int rows = biSnapshotWriteMapper.updateLatestWarehouseTransportSnapshot(fullJson, REMARK_REALTIME);
|
||||||
|
if (rows < 1) {
|
||||||
|
// 表中无最新记录可更新,插入一条兜底
|
||||||
|
biSnapshotWriteMapper.insertWarehouseTransportSnapshot(fullJson, REMARK_REALTIME);
|
||||||
|
}
|
||||||
|
log.info("BI 仓储运输实时数据已落库(覆盖最新, 数据变化), affectedRows={}", rows);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("BI 仓储运输实时数据落库失败", e);
|
||||||
|
}
|
||||||
|
return vo;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 实时业务数据指纹:仅含实时查库得到的字段(本年度/本季度/本月度订单、今日订单数量、
|
||||||
|
* 今日运输车次、客户贡献排名),用于判断是否需要覆盖更新快照;
|
||||||
|
* 其余字段取自快照模板,不纳入指纹,其变化不会触发更新。
|
||||||
|
*/
|
||||||
|
private String realDataFingerprint(WarehouseTransportSituationVO vo) throws Exception {
|
||||||
|
Map<String, Object> fp = new LinkedHashMap<>();
|
||||||
|
if (vo == null) {
|
||||||
|
return objectMapper.writeValueAsString(fp);
|
||||||
|
}
|
||||||
|
fp.put("currentYearOrders", vo.getCurrentYearOrders());
|
||||||
|
fp.put("currentQuarterOrders", vo.getCurrentQuarterOrders());
|
||||||
|
fp.put("currentMonthOrders", vo.getCurrentMonthOrders());
|
||||||
|
fp.put("orderCount", vo.getOrderCount());
|
||||||
|
fp.put("transportTrips", vo.getTransportTrips());
|
||||||
|
if (vo.getCustomerContributionRank() != null) {
|
||||||
|
fp.put("customerName", vo.getCustomerContributionRank().getCustomerName());
|
||||||
|
fp.put("customerAmount", vo.getCustomerContributionRank().getCustomerAmount());
|
||||||
|
}
|
||||||
|
return objectMapper.writeValueAsString(fp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-4
@@ -25,14 +25,14 @@ public class ComprehensiveSituationVO {
|
|||||||
@ApiModelProperty("库存周转率,单位:次")
|
@ApiModelProperty("库存周转率,单位:次")
|
||||||
private Integer inventoryTurnover;
|
private Integer inventoryTurnover;
|
||||||
|
|
||||||
@ApiModelProperty("运输订单量,单位:单")
|
@ApiModelProperty("运输订单量,单位:单(实时统计 OMS 运输业务单,本年度、全部组织)")
|
||||||
private Integer orderCount;
|
private Long orderCount;
|
||||||
|
|
||||||
@ApiModelProperty("车辆利用率,单位:%")
|
@ApiModelProperty("车辆利用率,单位:%")
|
||||||
private Double vehicleUtilizationRate;
|
private Double vehicleUtilizationRate;
|
||||||
|
|
||||||
@ApiModelProperty("百公里油耗,单位:升")
|
@ApiModelProperty("百公里油耗,单位:升(实时统计 TMS 运输作业单:总油耗量 ÷ 总重载里程 × 100)")
|
||||||
private Integer fuelConsumptionPerHundredKm;
|
private Double fuelConsumptionPerHundredKm;
|
||||||
|
|
||||||
@ApiModelProperty("运输收入趋势,单位:万元(近半年,按月正序)")
|
@ApiModelProperty("运输收入趋势,单位:万元(近半年,按月正序)")
|
||||||
private List<Integer> incomeTrend;
|
private List<Integer> incomeTrend;
|
||||||
|
|||||||
+1
-1
@@ -19,6 +19,6 @@ public class CustomerContributionRankVO {
|
|||||||
@ApiModelProperty("客户名称")
|
@ApiModelProperty("客户名称")
|
||||||
private List<String> customerName;
|
private List<String> customerName;
|
||||||
|
|
||||||
@ApiModelProperty("客户金额,单位:万元")
|
@ApiModelProperty("客户订单数,单位:单")
|
||||||
private List<Integer> customerAmount;
|
private List<Integer> customerAmount;
|
||||||
}
|
}
|
||||||
|
|||||||
+31
@@ -0,0 +1,31 @@
|
|||||||
|
package com.mhd.bi.interfaces.facadeApi.biReport.vo.platform;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
@ApiModel("月台监测-月台作业超时记录")
|
||||||
|
public class OvertimeRecordItemVO {
|
||||||
|
|
||||||
|
@ApiModelProperty("月台名称")
|
||||||
|
private String windowName;
|
||||||
|
|
||||||
|
@ApiModelProperty("车牌号码")
|
||||||
|
private String carNo;
|
||||||
|
|
||||||
|
@ApiModelProperty("超时时长,单位:分钟(= 月台作业时长 - 参考用时)")
|
||||||
|
private Long overtimeMinutes;
|
||||||
|
|
||||||
|
@ApiModelProperty("月台作业参考用时,单位:分钟")
|
||||||
|
private Long refMinutes;
|
||||||
|
|
||||||
|
@ApiModelProperty("月台作业时长,单位:分钟")
|
||||||
|
private Long platformMinutes;
|
||||||
|
}
|
||||||
+3
@@ -25,4 +25,7 @@ public class PlatformOverviewVO {
|
|||||||
|
|
||||||
@ApiModelProperty("今日作业任务,单位:个")
|
@ApiModelProperty("今日作业任务,单位:个")
|
||||||
private Integer todayTasks;
|
private Integer todayTasks;
|
||||||
|
|
||||||
|
@ApiModelProperty("月台周转率,单位:%(今日已出场的记录数 ÷ 今日全部记录数 × 100)")
|
||||||
|
private Double platformTurnoverRate;
|
||||||
}
|
}
|
||||||
|
|||||||
+6
@@ -48,4 +48,10 @@ public class PlatformSurveillanceVO {
|
|||||||
|
|
||||||
@ApiModelProperty("月台告警分布")
|
@ApiModelProperty("月台告警分布")
|
||||||
private List<PlatformAlarmDistItemVO> platformAlarmDistribution;
|
private List<PlatformAlarmDistItemVO> platformAlarmDistribution;
|
||||||
|
|
||||||
|
@ApiModelProperty("任务超时率,单位:%(月台作业时长 > 参考用时的记录数 ÷ 总记录数 × 100)")
|
||||||
|
private Double taskOvertimeRate;
|
||||||
|
|
||||||
|
@ApiModelProperty("月台作业超时记录列表(月台名称 / 车牌号码 / 超时时长分钟)")
|
||||||
|
private List<OvertimeRecordItemVO> overtimeRecords;
|
||||||
}
|
}
|
||||||
|
|||||||
+3
@@ -23,6 +23,9 @@ public class VehicleStatusVO {
|
|||||||
@ApiModelProperty("当前等待作业(已预约/已签到/已叫号),单位:辆")
|
@ApiModelProperty("当前等待作业(已预约/已签到/已叫号),单位:辆")
|
||||||
private Integer waiting;
|
private Integer waiting;
|
||||||
|
|
||||||
|
@ApiModelProperty("已签到+已叫号+已过号(FLOW_STATUS IN 2/3/4),单位:辆")
|
||||||
|
private Integer callStatusTotal;
|
||||||
|
|
||||||
@ApiModelProperty("当前作业中,单位:辆")
|
@ApiModelProperty("当前作业中,单位:辆")
|
||||||
private Integer operatingVehicles;
|
private Integer operatingVehicles;
|
||||||
|
|
||||||
|
|||||||
@@ -19,14 +19,14 @@ spring:
|
|||||||
# username: nacos
|
# username: nacos
|
||||||
# password: manhuoda@2023
|
# password: manhuoda@2023
|
||||||
#线上正式环境
|
#线上正式环境
|
||||||
server-addr: 10.102.192.30:6848
|
server-addr: 10.102.192.31:6848
|
||||||
username: nacos
|
username: nacos
|
||||||
password: manhuoda@2023
|
password: manhuoda@2023
|
||||||
config:
|
config:
|
||||||
# server-addr: 127.0.0.1:8848
|
# server-addr: 127.0.0.1:8848
|
||||||
# 线上测试环境配置 容器名+端口号
|
# 线上测试环境配置 容器名+端口号
|
||||||
# server-addr: 10.33.0.129:6010
|
# server-addr: 10.33.0.129:6010
|
||||||
server-addr: 10.102.192.30:6848
|
server-addr: 10.102.192.31:6848
|
||||||
username: nacos
|
username: nacos
|
||||||
password: manhuoda@2023
|
password: manhuoda@2023
|
||||||
#线上正式环境
|
#线上正式环境
|
||||||
|
|||||||
@@ -0,0 +1,35 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
<!DOCTYPE mapper
|
||||||
|
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
|
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
<mapper namespace="com.mhd.bi.domain.biComprehensive.repository.mapper.BiComprehensiveRealDataMapper">
|
||||||
|
|
||||||
|
<!-- 运输订单量:本年度、全部组织
|
||||||
|
数据来源:OMS 运输业务单 NGWL_TEST_OMS.BUSINESS_DOCUMENT_ORDER
|
||||||
|
统计口径:CREATE_TIME 在本年度;IS_DELETE = 0 表示未删除。
|
||||||
|
注:若该表删除标记实际为 DEL_FLAG,请将下方 IS_DELETE 替换为 DEL_FLAG -->
|
||||||
|
<select id="countCurrentYearTransportOrders" resultType="java.lang.Long">
|
||||||
|
SELECT COUNT(1)
|
||||||
|
FROM NGWL_TEST_OMS.BUSINESS_DOCUMENT_ORDER
|
||||||
|
WHERE CREATE_TIME IS NOT NULL
|
||||||
|
AND TO_CHAR(CREATE_TIME, 'YYYY') = TO_CHAR(SYSDATE, 'YYYY')
|
||||||
|
AND IS_DELETE = 0
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<!-- 百公里油耗:本年度、全部组织,油耗量与重载里程均非空的记录
|
||||||
|
数据来源:TMS 运输作业单 NGWL_TEST_WLHY.TMS_EXPENSE_REPORT
|
||||||
|
返回:总油耗量、总重载里程、参与条数(由 Service 层做除法)
|
||||||
|
公式:百公里油耗 = 总油耗量(FUEL_CONSUMPTION) ÷ 总重载里程(HEAVYLOAD_MILEAGE) × 100 -->
|
||||||
|
<select id="queryCurrentYearFuelStat" resultType="com.mhd.bi.domain.biComprehensive.repository.po.RealFuelStatPO">
|
||||||
|
SELECT
|
||||||
|
SUM(FUEL_CONSUMPTION) AS totalOil,
|
||||||
|
SUM(HEAVYLOAD_MILEAGE) AS totalHeavyMileage,
|
||||||
|
COUNT(1) AS totalCount
|
||||||
|
FROM NGWL_TEST_WLHY.TMS_EXPENSE_REPORT
|
||||||
|
WHERE FUEL_CONSUMPTION IS NOT NULL
|
||||||
|
AND HEAVYLOAD_MILEAGE IS NOT NULL
|
||||||
|
AND CREATE_TIME IS NOT NULL
|
||||||
|
AND TO_CHAR(CREATE_TIME, 'YYYY') = TO_CHAR(SYSDATE, 'YYYY')
|
||||||
|
</select>
|
||||||
|
|
||||||
|
</mapper>
|
||||||
@@ -8,7 +8,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
plateNumber <- qms_main_business.CAR_NO
|
plateNumber <- qms_main_business.CAR_NO
|
||||||
status <- qms_main_business.FLOW_STATUS
|
status <- qms_main_business.FLOW_STATUS
|
||||||
platformId <- qms_main_business.WINDOW_NAME(叫号月台,主业务表直接有)
|
platformId <- qms_main_business.WINDOW_NAME(叫号月台,主业务表直接有)
|
||||||
platformDuration <- qms_main_business.EXIT_TIME - ENTRY_TIME(分钟)
|
platformDuration <- 月台作业时长(分钟),用「进入月台 / 离开月台」时间:
|
||||||
|
未进入月台(IN_WINDOWS_TIME 为空) -> 0
|
||||||
|
已进入且已离开月台(OUT_WINDOWS_TIME 非空) -> OUT_WINDOWS_TIME - IN_WINDOWS_TIME
|
||||||
|
已进入但未离开月台 -> SYSDATE - IN_WINDOWS_TIME
|
||||||
appointmentTime <- qms_main_business.CREATE_TIME
|
appointmentTime <- qms_main_business.CREATE_TIME
|
||||||
workFloor <- qms_window_info.PLATFORM_FLOOR(按 WINDOW_NAME 关联)
|
workFloor <- qms_window_info.PLATFORM_FLOOR(按 WINDOW_NAME 关联)
|
||||||
-->
|
-->
|
||||||
@@ -18,9 +21,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
mb.FLOW_STATUS AS status,
|
mb.FLOW_STATUS AS status,
|
||||||
mb.WINDOW_NAME AS platformId,
|
mb.WINDOW_NAME AS platformId,
|
||||||
CASE
|
CASE
|
||||||
WHEN mb.EXIT_TIME IS NOT NULL AND mb.ENTRY_TIME IS NOT NULL
|
WHEN mb.IN_WINDOWS_TIME IS NULL THEN 0
|
||||||
THEN CAST((mb.EXIT_TIME - mb.ENTRY_TIME) * 24 * 60 AS BIGINT)
|
WHEN mb.OUT_WINDOWS_TIME IS NOT NULL
|
||||||
ELSE 0
|
THEN CAST((mb.OUT_WINDOWS_TIME - mb.IN_WINDOWS_TIME) * 24 * 60 AS BIGINT)
|
||||||
|
ELSE CAST((SYSDATE - mb.IN_WINDOWS_TIME) * 24 * 60 AS BIGINT)
|
||||||
END AS platformDuration,
|
END AS platformDuration,
|
||||||
TO_CHAR(mb.CREATE_TIME, 'YYYY-MM-DD HH24:MI:SS') AS appointmentTime,
|
TO_CHAR(mb.CREATE_TIME, 'YYYY-MM-DD HH24:MI:SS') AS appointmentTime,
|
||||||
wi.PLATFORM_FLOOR AS workFloor
|
wi.PLATFORM_FLOOR AS workFloor
|
||||||
@@ -32,6 +36,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
ORDER BY mb.CREATE_TIME DESC
|
ORDER BY mb.CREATE_TIME DESC
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<!-- 月台概览:totalPlatforms(总条数)、operatingPlatforms(作业状态=占用,JOB_STATUS: 0空闲 1占用) -->
|
<!-- 月台概览:totalPlatforms(总条数)、operatingPlatforms(作业状态=占用,JOB_STATUS: 0空闲 1占用) -->
|
||||||
<select id="queryPlatformOverview" resultType="com.mhd.bi.domain.biPlatformRealData.repository.po.RealPlatformOverviewPO">
|
<select id="queryPlatformOverview" resultType="com.mhd.bi.domain.biPlatformRealData.repository.po.RealPlatformOverviewPO">
|
||||||
SELECT
|
SELECT
|
||||||
@@ -70,18 +76,109 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
<!-- 车辆状态统计:今日的统计(按创建时间 CREATE_TIME / 流程状态)
|
<!-- 车辆状态统计:今日的统计(按创建时间 CREATE_TIME / 流程状态)
|
||||||
todayReservedVehicles 改为按预约日期 TARGET_DATE(其它 3 项保持 CREATE_TIME)
|
todayReservedVehicles 改为按预约日期 TARGET_DATE(其它 3 项保持 CREATE_TIME)
|
||||||
waiting 等待作业:FLOW_STATUS IN ('1','2','3') 已预约/已签到/已叫号 且 预约日期 = 今天
|
waiting 等待作业:FLOW_STATUS IN ('1','2','3') 已预约/已签到/已叫号 且 预约日期 = 今天
|
||||||
|
callStatusTotal 叫号状态合计:已签到 + 已叫号 + 已过号 = FLOW_STATUS IN ('2','3','4') 且 预约日期 = 今天
|
||||||
|
todayExited 今日已出场:FLOW_STATUS = '11' 且 预约日期 = 今天(月台周转率的分子)
|
||||||
|
completedVehicles 今日作业车辆总数:FLOW_STATUS = '11' 且 预约日期 = 今天
|
||||||
FLOW_STATUS: 1已预约 2已签到 3已叫号 4已过号 5已进场 6已称重 7已装车 8二次称重 9已结算 10已还卡 11已出场 12已取消 -->
|
FLOW_STATUS: 1已预约 2已签到 3已叫号 4已过号 5已进场 6已称重 7已装车 8二次称重 9已结算 10已还卡 11已出场 12已取消 -->
|
||||||
<select id="queryVehicleStatusToday" resultType="com.mhd.bi.domain.biPlatformRealData.repository.po.RealVehicleStatusPO">
|
<select id="queryVehicleStatusToday" resultType="com.mhd.bi.domain.biPlatformRealData.repository.po.RealVehicleStatusPO">
|
||||||
SELECT
|
SELECT
|
||||||
SUM(CASE WHEN TRUNC(TARGET_DATE) = TRUNC(SYSDATE) THEN 1 ELSE 0 END) AS todayReservedVehicles,
|
SUM(CASE WHEN TRUNC(TARGET_DATE) = TRUNC(SYSDATE) THEN 1 ELSE 0 END) AS todayReservedVehicles,
|
||||||
SUM(CASE WHEN FLOW_STATUS = '1' AND TRUNC(CREATE_TIME) = TRUNC(SYSDATE) THEN 1 ELSE 0 END) AS notCheckedIn,
|
SUM(CASE WHEN FLOW_STATUS = '1' AND TRUNC(CREATE_TIME) = TRUNC(SYSDATE) THEN 1 ELSE 0 END) AS notCheckedIn,
|
||||||
SUM(CASE WHEN FLOW_STATUS IN ('1','2','3') AND TRUNC(TARGET_DATE) = TRUNC(SYSDATE) THEN 1 ELSE 0 END) AS waiting,
|
SUM(CASE WHEN FLOW_STATUS IN ('1','2','3') AND TRUNC(TARGET_DATE) = TRUNC(SYSDATE) THEN 1 ELSE 0 END) AS waiting,
|
||||||
|
SUM(CASE WHEN FLOW_STATUS IN ('2','3','4') AND TRUNC(TARGET_DATE) = TRUNC(SYSDATE) THEN 1 ELSE 0 END) AS callStatusTotal,
|
||||||
|
SUM(CASE WHEN FLOW_STATUS = '11' AND TRUNC(TARGET_DATE) = TRUNC(SYSDATE) THEN 1 ELSE 0 END) AS todayExited,
|
||||||
SUM(CASE WHEN FLOW_STATUS IN ('5','6','7','8','9','10') AND TRUNC(CREATE_TIME) = TRUNC(SYSDATE) THEN 1 ELSE 0 END) AS operatingVehicles,
|
SUM(CASE WHEN FLOW_STATUS IN ('5','6','7','8','9','10') AND TRUNC(CREATE_TIME) = TRUNC(SYSDATE) THEN 1 ELSE 0 END) AS operatingVehicles,
|
||||||
SUM(CASE WHEN FLOW_STATUS = '11' AND TRUNC(CREATE_TIME) = TRUNC(SYSDATE) THEN 1 ELSE 0 END) AS completedVehicles
|
SUM(CASE WHEN FLOW_STATUS = '11' AND TRUNC(TARGET_DATE) = TRUNC(SYSDATE) THEN 1 ELSE 0 END) AS completedVehicles
|
||||||
FROM NGWL_TEST_YMS.QMS_MAIN_BUSINESS
|
FROM NGWL_TEST_YMS.QMS_MAIN_BUSINESS
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<!-- ======================= 月台作业参考用时 / 超时相关 =======================
|
||||||
|
参考用时取自 YMS 库静态字段配置表 NGWL_TEST_YMS.QMS_STATIC_FIELD:
|
||||||
|
FIELD_CODE = 'platform_work_ref_minutes'
|
||||||
|
取值优先级:WINDOW(按月台) > FLOOR(按楼层) > GLOBAL(全局)
|
||||||
|
下面用 LEFT JOIN 三级关联 + COALESCE 实现优先级取值,
|
||||||
|
REF_MINUTES 为空表示该月台未配置参考用时,其记录不计入超时率分母 -->
|
||||||
|
|
||||||
|
<!-- 可复用的参考用时关联条件(YMS 库静态字段配置表 QMS_STATIC_FIELD)
|
||||||
|
取值优先级:WINDOW(按月台) > FLOOR(按楼层) > GLOBAL(全局) -->
|
||||||
|
<sql id="joinStaticRef">
|
||||||
|
INNER JOIN NGWL_TEST_YMS.QMS_STATIC_FIELD ref
|
||||||
|
ON ref.FIELD_CODE = #{refCode}
|
||||||
|
AND ref.DEL_FLAG = 1
|
||||||
|
AND ref.FIELD_VALUE IS NOT NULL
|
||||||
|
AND (
|
||||||
|
(ref.SCOPE_TYPE = 'WINDOW' AND ref.SCOPE_CODE = mb.WINDOW_NAME)
|
||||||
|
OR (ref.SCOPE_TYPE = 'FLOOR' AND ref.SCOPE_CODE = wi.PLATFORM_FLOOR)
|
||||||
|
OR (ref.SCOPE_TYPE = 'GLOBAL')
|
||||||
|
)
|
||||||
|
</sql>
|
||||||
|
|
||||||
|
<!-- 今日作业超时统计(通用:月台作业 / 园区作业,由 refCode + 时长表达式区分)
|
||||||
|
分母只计入「能取到参考用时 且 时长两端时间都非空」的记录
|
||||||
|
overtimeCount 超时记录数:作业时长(分钟) > 参考用时
|
||||||
|
totalCount 有效记录总数(分母)
|
||||||
|
超时率 = overtimeCount / totalCount × 100%,由 Service 层计算 -->
|
||||||
|
<select id="queryTodayOvertimeStat" resultType="com.mhd.bi.domain.biPlatformRealData.repository.po.RealOvertimeStatPO">
|
||||||
|
SELECT
|
||||||
|
SUM(CASE WHEN (mb.OUT_WINDOWS_TIME - mb.IN_WINDOWS_TIME) * 24 * 60 > ref.REF_MINUTES
|
||||||
|
THEN 1 ELSE 0 END) AS overtimeCount,
|
||||||
|
COUNT(1) AS totalCount
|
||||||
|
FROM NGWL_TEST_YMS.QMS_MAIN_BUSINESS mb
|
||||||
|
LEFT JOIN NGWL_TEST_YMS.QMS_WINDOW_INFO wi
|
||||||
|
ON wi.WINDOW_NAME = mb.WINDOW_NAME
|
||||||
|
<include refid="joinStaticRef"/>
|
||||||
|
WHERE mb.TARGET_DATE IS NOT NULL
|
||||||
|
AND TRUNC(mb.TARGET_DATE) = TRUNC(SYSDATE)
|
||||||
|
AND mb.IN_WINDOWS_TIME IS NOT NULL
|
||||||
|
AND mb.OUT_WINDOWS_TIME IS NOT NULL
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<!-- 今日园区作业超时统计(时长 = 实际出场 - 实际进入;参考用时 yard_work_ref_minutes)
|
||||||
|
用于计算「园区作业准时率 = 1 - 超时率」 -->
|
||||||
|
<select id="queryTodayYardOvertimeStat" resultType="com.mhd.bi.domain.biPlatformRealData.repository.po.RealOvertimeStatPO">
|
||||||
|
SELECT
|
||||||
|
SUM(CASE WHEN (mb.EXIT_TIME - mb.ENTRY_TIME) * 24 * 60 > ref.REF_MINUTES
|
||||||
|
THEN 1 ELSE 0 END) AS overtimeCount,
|
||||||
|
COUNT(1) AS totalCount
|
||||||
|
FROM NGWL_TEST_YMS.QMS_MAIN_BUSINESS mb
|
||||||
|
LEFT JOIN NGWL_TEST_YMS.QMS_WINDOW_INFO wi
|
||||||
|
ON wi.WINDOW_NAME = mb.WINDOW_NAME
|
||||||
|
<include refid="joinStaticRef"/>
|
||||||
|
WHERE mb.TARGET_DATE IS NOT NULL
|
||||||
|
AND TRUNC(mb.TARGET_DATE) = TRUNC(SYSDATE)
|
||||||
|
AND mb.ENTRY_TIME IS NOT NULL
|
||||||
|
AND mb.EXIT_TIME IS NOT NULL
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<!-- 今日月台作业超时记录列表(月台名称 / 车牌号码 / 超时时长分钟):
|
||||||
|
超时时长 = 月台作业时长 - 参考用时 -->
|
||||||
|
<select id="queryTodayOvertimeList" resultType="com.mhd.bi.domain.biPlatformRealData.repository.po.RealOvertimeRecordPO">
|
||||||
|
SELECT
|
||||||
|
mb.WINDOW_NAME AS windowName,
|
||||||
|
mb.CAR_NO AS carNo,
|
||||||
|
CAST(((mb.OUT_WINDOWS_TIME - mb.IN_WINDOWS_TIME) * 24 * 60 - ref.REF_MINUTES) AS BIGINT) AS overtimeMinutes,
|
||||||
|
ref.REF_MINUTES AS refMinutes,
|
||||||
|
CAST((mb.OUT_WINDOWS_TIME - mb.IN_WINDOWS_TIME) * 24 * 60 AS BIGINT) AS platformMinutes
|
||||||
|
FROM NGWL_TEST_YMS.QMS_MAIN_BUSINESS mb
|
||||||
|
LEFT JOIN NGWL_TEST_YMS.QMS_WINDOW_INFO wi
|
||||||
|
ON wi.WINDOW_NAME = mb.WINDOW_NAME
|
||||||
|
<include refid="joinStaticRef"/>
|
||||||
|
WHERE mb.TARGET_DATE IS NOT NULL
|
||||||
|
AND TRUNC(mb.TARGET_DATE) = TRUNC(SYSDATE)
|
||||||
|
AND mb.IN_WINDOWS_TIME IS NOT NULL
|
||||||
|
AND mb.OUT_WINDOWS_TIME IS NOT NULL
|
||||||
|
AND (mb.OUT_WINDOWS_TIME - mb.IN_WINDOWS_TIME) * 24 * 60 > ref.REF_MINUTES
|
||||||
|
ORDER BY overtimeMinutes DESC
|
||||||
|
</select>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<!-- 本月任务量:按预约日期 TARGET_DATE(Y预约日期)统计本月预约总数量 -->
|
<!-- 本月任务量:按预约日期 TARGET_DATE(Y预约日期)统计本月预约总数量 -->
|
||||||
|
|
||||||
<select id="countMonthTasks" resultType="java.lang.Long">
|
<select id="countMonthTasks" resultType="java.lang.Long">
|
||||||
SELECT COUNT(1)
|
SELECT COUNT(1)
|
||||||
FROM NGWL_TEST_YMS.QMS_MAIN_BUSINESS
|
FROM NGWL_TEST_YMS.QMS_MAIN_BUSINESS
|
||||||
@@ -89,21 +186,22 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
AND TO_CHAR(TARGET_DATE, 'YYYY-MM') = TO_CHAR(SYSDATE, 'YYYY-MM')
|
AND TO_CHAR(TARGET_DATE, 'YYYY-MM') = TO_CHAR(SYSDATE, 'YYYY-MM')
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<!-- 本月任务平均作业时长 / 完成率统计:
|
<!-- 本月任务平均作业时长 / 完成率统计(统计范围:本月 TARGET_DATE 在当月的记录):
|
||||||
avgDurationHours 平均时长(小时)= AVG((EXIT_TIME - ENTRY_TIME) * 24)
|
totalWorkHours 本月任务作业时长合计(小时),用「进入月台 / 离开月台」时间:
|
||||||
仅 ENTRY_TIME 与 EXIT_TIME 都不为空时参与;
|
未进入月台(IN_WINDOWS_TIME 为空) -> 0
|
||||||
durationCount 参与平均时长统计的有效条数;
|
已进入且已离开月台(OUT_WINDOWS_TIME 非空) -> OUT_WINDOWS_TIME - IN_WINDOWS_TIME
|
||||||
completedCount 本月(TARGET_DATE)已出场(EXIT_TIME IS NOT NULL)的数量;
|
已进入但未离开月台 -> SYSDATE - IN_WINDOWS_TIME
|
||||||
totalCount 本月(TARGET_DATE)预约总数量。
|
completedCount 本月已出场(EXIT_TIME IS NOT NULL)的数量;
|
||||||
|
totalCount 本月预约总数量(作为平均时长的分母)。
|
||||||
|
avgDurationHours 由 Service 层计算 = totalWorkHours ÷ totalCount(任务平均作业时长)
|
||||||
-->
|
-->
|
||||||
<select id="queryMonthTaskStats" resultType="com.mhd.bi.domain.biPlatformRealData.repository.po.RealMonthlyTaskDurationPO">
|
<select id="queryMonthTaskStats" resultType="com.mhd.bi.domain.biPlatformRealData.repository.po.RealMonthlyTaskDurationPO">
|
||||||
SELECT
|
SELECT
|
||||||
AVG(CASE WHEN ENTRY_TIME IS NOT NULL AND EXIT_TIME IS NOT NULL
|
SUM(CASE
|
||||||
THEN (EXIT_TIME - ENTRY_TIME) * 24
|
WHEN IN_WINDOWS_TIME IS NULL THEN 0
|
||||||
END) AS avgDurationHours,
|
WHEN OUT_WINDOWS_TIME IS NOT NULL THEN (OUT_WINDOWS_TIME - IN_WINDOWS_TIME) * 24
|
||||||
SUM(CASE WHEN ENTRY_TIME IS NOT NULL AND EXIT_TIME IS NOT NULL
|
ELSE (SYSDATE - IN_WINDOWS_TIME) * 24
|
||||||
AND TO_CHAR(ENTRY_TIME, 'YYYY-MM') = TO_CHAR(SYSDATE, 'YYYY-MM')
|
END) AS totalWorkHours,
|
||||||
THEN 1 ELSE 0 END) AS durationCount,
|
|
||||||
SUM(CASE WHEN EXIT_TIME IS NOT NULL
|
SUM(CASE WHEN EXIT_TIME IS NOT NULL
|
||||||
AND TARGET_DATE IS NOT NULL
|
AND TARGET_DATE IS NOT NULL
|
||||||
AND TO_CHAR(TARGET_DATE, 'YYYY-MM') = TO_CHAR(SYSDATE, 'YYYY-MM')
|
AND TO_CHAR(TARGET_DATE, 'YYYY-MM') = TO_CHAR(SYSDATE, 'YYYY-MM')
|
||||||
@@ -112,8 +210,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
AND TO_CHAR(TARGET_DATE, 'YYYY-MM') = TO_CHAR(SYSDATE, 'YYYY-MM')
|
AND TO_CHAR(TARGET_DATE, 'YYYY-MM') = TO_CHAR(SYSDATE, 'YYYY-MM')
|
||||||
THEN 1 ELSE 0 END) AS totalCount
|
THEN 1 ELSE 0 END) AS totalCount
|
||||||
FROM NGWL_TEST_YMS.QMS_MAIN_BUSINESS
|
FROM NGWL_TEST_YMS.QMS_MAIN_BUSINESS
|
||||||
|
WHERE TARGET_DATE IS NOT NULL
|
||||||
|
AND TO_CHAR(TARGET_DATE, 'YYYY-MM') = TO_CHAR(SYSDATE, 'YYYY-MM')
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
|
||||||
<!-- 今日预约-业务类型统计:按 BUSINESS_NAME(业务类型名称)分组统计今日预约数量,按预约日期 TARGET_DATE 过滤 -->
|
<!-- 今日预约-业务类型统计:按 BUSINESS_NAME(业务类型名称)分组统计今日预约数量,按预约日期 TARGET_DATE 过滤 -->
|
||||||
<select id="queryTodayBusinessTypeStats" resultType="com.mhd.bi.domain.biPlatformRealData.repository.po.RealBusinessTypeStatPO">
|
<select id="queryTodayBusinessTypeStats" resultType="com.mhd.bi.domain.biPlatformRealData.repository.po.RealBusinessTypeStatPO">
|
||||||
SELECT
|
SELECT
|
||||||
@@ -126,11 +227,18 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
ORDER BY COUNT(1) DESC
|
ORDER BY COUNT(1) DESC
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<!-- 月台监控-按楼层统计:楼层从叫号月台 WINDOW_NAME 解析(如 S1-01 / N1-02 -> F1),不依赖字母前缀,只取 - 前面那段的数字
|
<!-- 月台监控-按楼层统计:
|
||||||
platformCount 来自 QMS_WINDOW_INFO;todayReservedVehicles/operatingVehicles 来自 QMS_MAIN_BUSINESS(按 TARGET_DATE=今天) -->
|
floorNo 楼层号,取自月台表 QMS_WINDOW_INFO.PLATFORM_FLOOR
|
||||||
|
platformCount 该楼层月台数量(QMS_WINDOW_INFO)
|
||||||
|
todayReservedVehicles 该楼层今日预约车辆数(按预约时已选的月台/叫号月台关联楼层)
|
||||||
|
operatingVehicles 该楼层当前作业车辆数(FLOW_STATUS IN 5,6,7,8,9,10)
|
||||||
|
avgPlatformMinutes 该楼层月台作业平均时长(分钟)
|
||||||
|
公式:SUM(该楼层有效记录的月台作业时长) ÷ 该楼层有效记录数
|
||||||
|
有效记录:同时有进入月台(IN_WINDOWS_TIME)与离开月台(OUT_WINDOWS_TIME)时间
|
||||||
|
说明:楼层维度以「月台表」为准;车辆预约时若已选月台(WINDOW_NAME 非空)即计入对应楼层。 -->
|
||||||
<select id="queryPlatformFloorStats" resultType="com.mhd.bi.domain.biPlatformRealData.repository.po.RealPlatformFloorStatPO">
|
<select id="queryPlatformFloorStats" resultType="com.mhd.bi.domain.biPlatformRealData.repository.po.RealPlatformFloorStatPO">
|
||||||
SELECT
|
SELECT
|
||||||
'F' || SUBSTR(W.WINDOW_NAME, INSTR(W.WINDOW_NAME,'-')-1, 1) AS floorNo,
|
W.PLATFORM_FLOOR AS floorNo,
|
||||||
COUNT(DISTINCT W.WINDOW_NAME) AS platformCount,
|
COUNT(DISTINCT W.WINDOW_NAME) AS platformCount,
|
||||||
COUNT(DISTINCT CASE
|
COUNT(DISTINCT CASE
|
||||||
WHEN TRUNC(mb.TARGET_DATE) = TRUNC(SYSDATE) THEN mb.CAR_NO
|
WHEN TRUNC(mb.TARGET_DATE) = TRUNC(SYSDATE) THEN mb.CAR_NO
|
||||||
@@ -139,15 +247,21 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
WHEN TRUNC(mb.TARGET_DATE) = TRUNC(SYSDATE)
|
WHEN TRUNC(mb.TARGET_DATE) = TRUNC(SYSDATE)
|
||||||
AND mb.FLOW_STATUS IN ('5','6','7','8','9','10')
|
AND mb.FLOW_STATUS IN ('5','6','7','8','9','10')
|
||||||
THEN mb.CAR_NO
|
THEN mb.CAR_NO
|
||||||
END) AS operatingVehicles
|
END) AS operatingVehicles,
|
||||||
|
ROUND(AVG(CASE
|
||||||
|
WHEN mb.IN_WINDOWS_TIME IS NOT NULL AND mb.OUT_WINDOWS_TIME IS NOT NULL
|
||||||
|
THEN (mb.OUT_WINDOWS_TIME - mb.IN_WINDOWS_TIME) * 24 * 60
|
||||||
|
END), 0) AS avgPlatformMinutes
|
||||||
FROM NGWL_TEST_YMS.QMS_WINDOW_INFO W
|
FROM NGWL_TEST_YMS.QMS_WINDOW_INFO W
|
||||||
LEFT JOIN NGWL_TEST_YMS.QMS_MAIN_BUSINESS mb
|
LEFT JOIN NGWL_TEST_YMS.QMS_MAIN_BUSINESS mb
|
||||||
ON mb.WINDOW_NAME = W.WINDOW_NAME
|
ON mb.WINDOW_NAME = W.WINDOW_NAME
|
||||||
WHERE W.WINDOW_NAME LIKE '%-%'
|
WHERE W.PLATFORM_FLOOR IS NOT NULL
|
||||||
GROUP BY SUBSTR(W.WINDOW_NAME, INSTR(W.WINDOW_NAME,'-')-1, 1)
|
GROUP BY W.PLATFORM_FLOOR
|
||||||
ORDER BY 1 DESC
|
ORDER BY W.PLATFORM_FLOOR DESC
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<!-- 任务类型统计(来自 NGWL_TEST_YMS.QMS_MAIN_BUSINESS 预约登记表):
|
<!-- 任务类型统计(来自 NGWL_TEST_YMS.QMS_MAIN_BUSINESS 预约登记表):
|
||||||
按本月预约车辆数(TARGET_DATE 在当前月)按 BUSINESS_NAME 业务类型分组统计 -->
|
按本月预约车辆数(TARGET_DATE 在当前月)按 BUSINESS_NAME 业务类型分组统计 -->
|
||||||
<select id="queryMonthTransportOrderByType" resultType="com.mhd.bi.domain.biPlatformRealData.repository.po.RealTaskTypeStatPO">
|
<select id="queryMonthTransportOrderByType" resultType="com.mhd.bi.domain.biPlatformRealData.repository.po.RealTaskTypeStatPO">
|
||||||
@@ -162,18 +276,73 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
ORDER BY COUNT(1) DESC
|
ORDER BY COUNT(1) DESC
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<!-- 任务负荷(今日 24 小时时段):按 EXTRACT(HOUR FROM ENTRY_TIME) 统计 -->
|
<!-- 今日平均作业时长(效率统计-本日):
|
||||||
|
avgPlatformDurationHours 月台作业平均时长(小时)
|
||||||
|
统计范围:今日预约记录中「同时有进入月台时间(IN_WINDOWS_TIME)和离开月台时间(OUT_WINDOWS_TIME)」的记录
|
||||||
|
公式:AVG((OUT_WINDOWS_TIME - IN_WINDOWS_TIME) * 24)
|
||||||
|
avgYardDurationHours 园区平均时长(小时)
|
||||||
|
统计范围:今日预约记录中「同时有实际进入时间(ENTRY_TIME)和实际出场时间(EXIT_TIME)」的记录
|
||||||
|
公式:AVG((EXIT_TIME - ENTRY_TIME) * 24) -->
|
||||||
|
<select id="queryTodayAvgDuration" resultType="com.mhd.bi.domain.biPlatformRealData.repository.po.RealTodayAvgDurationPO">
|
||||||
|
SELECT
|
||||||
|
AVG(CASE WHEN IN_WINDOWS_TIME IS NOT NULL AND OUT_WINDOWS_TIME IS NOT NULL
|
||||||
|
THEN (OUT_WINDOWS_TIME - IN_WINDOWS_TIME) * 24
|
||||||
|
END) AS avgPlatformDurationHours,
|
||||||
|
AVG(CASE WHEN ENTRY_TIME IS NOT NULL AND EXIT_TIME IS NOT NULL
|
||||||
|
THEN (EXIT_TIME - ENTRY_TIME) * 24
|
||||||
|
END) AS avgYardDurationHours
|
||||||
|
FROM NGWL_TEST_YMS.QMS_MAIN_BUSINESS
|
||||||
|
WHERE TARGET_DATE IS NOT NULL
|
||||||
|
AND TRUNC(TARGET_DATE) = TRUNC(SYSDATE)
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<!-- 近半年「平均作业时长」趋势(按月分组,取最近 6 个月):
|
||||||
|
|
||||||
|
taskCount 该月任务数(预约记录数,作为平均时长的分母);
|
||||||
|
platformWorkHours 该月月台作业时长合计(小时):
|
||||||
|
未进入月台(IN_WINDOWS_TIME 为空) -> 0
|
||||||
|
已进入且已离开月台(OUT_WINDOWS_TIME 非空) -> OUT_WINDOWS_TIME - IN_WINDOWS_TIME
|
||||||
|
已进入但未离开月台 -> SYSDATE - IN_WINDOWS_TIME
|
||||||
|
yardWorkHours 该月园区作业时长合计(小时):
|
||||||
|
未进场(ENTRY_TIME 为空) -> 0
|
||||||
|
已进场且已出场(EXIT_TIME 非空) -> EXIT_TIME - ENTRY_TIME
|
||||||
|
已进场但未出场 -> SYSDATE - ENTRY_TIME
|
||||||
|
平均时长由 Service 层计算 = 时长合计 ÷ taskCount -->
|
||||||
|
<select id="queryMonthlyAvgDuration" resultType="com.mhd.bi.domain.biPlatformRealData.repository.po.RealMonthlyAvgDurationPO">
|
||||||
|
SELECT
|
||||||
|
TO_CHAR(TARGET_DATE, 'YYYY-MM') AS monthOfYear,
|
||||||
|
COUNT(1) AS taskCount,
|
||||||
|
SUM(CASE
|
||||||
|
WHEN IN_WINDOWS_TIME IS NULL THEN 0
|
||||||
|
WHEN OUT_WINDOWS_TIME IS NOT NULL THEN (OUT_WINDOWS_TIME - IN_WINDOWS_TIME) * 24
|
||||||
|
ELSE (SYSDATE - IN_WINDOWS_TIME) * 24
|
||||||
|
END) AS platformWorkHours,
|
||||||
|
SUM(CASE
|
||||||
|
WHEN ENTRY_TIME IS NULL THEN 0
|
||||||
|
WHEN EXIT_TIME IS NOT NULL THEN (EXIT_TIME - ENTRY_TIME) * 24
|
||||||
|
ELSE (SYSDATE - ENTRY_TIME) * 24
|
||||||
|
END) AS yardWorkHours
|
||||||
|
FROM NGWL_TEST_YMS.QMS_MAIN_BUSINESS
|
||||||
|
WHERE TARGET_DATE IS NOT NULL
|
||||||
|
AND TARGET_DATE >= ADD_MONTHS(TRUNC(SYSDATE, 'MM'), -5)
|
||||||
|
GROUP BY TO_CHAR(TARGET_DATE, 'YYYY-MM')
|
||||||
|
ORDER BY 1
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<!-- 小时趋势(今日,每 2 小时分组统计一次):
|
||||||
|
按车辆进入月台时间 IN_WINDOWS_TIME 分桶,桶为 0,2,4,...,22 -->
|
||||||
<select id="queryTaskLoadToday" resultType="com.mhd.bi.domain.biPlatformRealData.repository.po.RealTaskLoadPO">
|
<select id="queryTaskLoadToday" resultType="com.mhd.bi.domain.biPlatformRealData.repository.po.RealTaskLoadPO">
|
||||||
SELECT
|
SELECT
|
||||||
EXTRACT(HOUR FROM ENTRY_TIME) AS hourOfDay,
|
FLOOR(EXTRACT(HOUR FROM IN_WINDOWS_TIME) / 2) * 2 AS hourOfDay,
|
||||||
COUNT(1) AS taskCount
|
COUNT(1) AS taskCount
|
||||||
FROM NGWL_TEST_YMS.QMS_MAIN_BUSINESS
|
FROM NGWL_TEST_YMS.QMS_MAIN_BUSINESS
|
||||||
WHERE ENTRY_TIME IS NOT NULL
|
WHERE IN_WINDOWS_TIME IS NOT NULL
|
||||||
AND TRUNC(ENTRY_TIME) = TRUNC(SYSDATE)
|
AND TRUNC(IN_WINDOWS_TIME) = TRUNC(SYSDATE)
|
||||||
GROUP BY EXTRACT(HOUR FROM ENTRY_TIME)
|
GROUP BY FLOOR(EXTRACT(HOUR FROM IN_WINDOWS_TIME) / 2) * 2
|
||||||
ORDER BY EXTRACT(HOUR FROM ENTRY_TIME)
|
ORDER BY 1
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
|
||||||
<!-- 月台管理列表:查询 YMS qms_window_info 月台/鹤位窗口
|
<!-- 月台管理列表:查询 YMS qms_window_info 月台/鹤位窗口
|
||||||
机构名称 deptName <- sys_dept.DEPT_NAME(d.dept_id = a.ORG_NO 关联)
|
机构名称 deptName <- sys_dept.DEPT_NAME(d.dept_id = a.ORG_NO 关联)
|
||||||
鹤位屏名称 berrNames <- qms_window_berr(WINDOW_ID/BERR_ID) join qms_berr_config(ID/BERR_NAME),WM_CONCAT 拼接
|
鹤位屏名称 berrNames <- qms_window_berr(WINDOW_ID/BERR_ID) join qms_berr_config(ID/BERR_NAME),WM_CONCAT 拼接
|
||||||
|
|||||||
@@ -8,11 +8,33 @@
|
|||||||
values (#{payloadJson}, SYSDATE, SYSDATE, 1, #{remark})
|
values (#{payloadJson}, SYSDATE, SYSDATE, 1, #{remark})
|
||||||
</insert>
|
</insert>
|
||||||
|
|
||||||
|
<!-- 覆盖更新综合态势快照最新一条(实时组装后落库,同月台监测) -->
|
||||||
|
<update id="updateLatestComprehensiveSnapshot">
|
||||||
|
update NGWL_TEST_BI.BI_COMPREHENSIVE_SNAPSHOT
|
||||||
|
set PAYLOAD_JSON = #{payloadJson},
|
||||||
|
UPDATE_TIME = SYSDATE,
|
||||||
|
REMARK = #{remark}
|
||||||
|
where DEL_FLAG = 1
|
||||||
|
and ID = (select max(t.ID) from NGWL_TEST_BI.BI_COMPREHENSIVE_SNAPSHOT t where t.DEL_FLAG = 1)
|
||||||
|
</update>
|
||||||
|
|
||||||
|
|
||||||
<insert id="insertWarehouseTransportSnapshot">
|
<insert id="insertWarehouseTransportSnapshot">
|
||||||
insert into NGWL_TEST_BI.BI_WAREHOUSE_TRANSPORT_SNAPSHOT (PAYLOAD_JSON, CREATE_TIME, UPDATE_TIME, DEL_FLAG, REMARK)
|
insert into NGWL_TEST_BI.BI_WAREHOUSE_TRANSPORT_SNAPSHOT (PAYLOAD_JSON, CREATE_TIME, UPDATE_TIME, DEL_FLAG, REMARK)
|
||||||
values (#{payloadJson}, SYSDATE, SYSDATE, 1, #{remark})
|
values (#{payloadJson}, SYSDATE, SYSDATE, 1, #{remark})
|
||||||
</insert>
|
</insert>
|
||||||
|
|
||||||
|
<!-- 覆盖更新仓储运输快照最新一条(实时组装后落库,同月台监测) -->
|
||||||
|
<update id="updateLatestWarehouseTransportSnapshot">
|
||||||
|
update NGWL_TEST_BI.BI_WAREHOUSE_TRANSPORT_SNAPSHOT
|
||||||
|
set PAYLOAD_JSON = #{payloadJson},
|
||||||
|
UPDATE_TIME = SYSDATE,
|
||||||
|
REMARK = #{remark}
|
||||||
|
where DEL_FLAG = 1
|
||||||
|
and ID = (select max(t.ID) from NGWL_TEST_BI.BI_WAREHOUSE_TRANSPORT_SNAPSHOT t where t.DEL_FLAG = 1)
|
||||||
|
</update>
|
||||||
|
|
||||||
|
|
||||||
<insert id="insertPlatformSurveillanceSnapshot">
|
<insert id="insertPlatformSurveillanceSnapshot">
|
||||||
insert into NGWL_TEST_BI.BI_PLATFORM_SURVEILLANCE_SNAPSHOT (PAYLOAD_JSON, CREATE_TIME, UPDATE_TIME, DEL_FLAG, REMARK)
|
insert into NGWL_TEST_BI.BI_PLATFORM_SURVEILLANCE_SNAPSHOT (PAYLOAD_JSON, CREATE_TIME, UPDATE_TIME, DEL_FLAG, REMARK)
|
||||||
values (#{payloadJson}, SYSDATE, SYSDATE, 1, #{remark})
|
values (#{payloadJson}, SYSDATE, SYSDATE, 1, #{remark})
|
||||||
|
|||||||
@@ -0,0 +1,52 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
<!DOCTYPE mapper
|
||||||
|
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
|
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
<mapper namespace="com.mhd.bi.domain.biStaticField.repository.mapper.BiStaticFieldMapper">
|
||||||
|
|
||||||
|
<!-- 业务静态字段配置(YMS 库):按字段编码查询全部有效配置
|
||||||
|
含 GLOBAL / FLOOR / WINDOW 各作用域,由程序按「WINDOW > FLOOR > GLOBAL」优先级取值 -->
|
||||||
|
<select id="queryByCode" resultType="com.mhd.bi.domain.biStaticField.repository.po.BiStaticFieldPO">
|
||||||
|
SELECT
|
||||||
|
FIELD_CODE AS fieldCode,
|
||||||
|
FIELD_NAME AS fieldName,
|
||||||
|
SCOPE_TYPE AS scopeType,
|
||||||
|
SCOPE_CODE AS scopeCode,
|
||||||
|
FIELD_VALUE AS fieldValue,
|
||||||
|
UNIT AS unit
|
||||||
|
FROM NGWL_TEST_YMS.QMS_STATIC_FIELD
|
||||||
|
WHERE DEL_FLAG = 1
|
||||||
|
AND FIELD_CODE = #{fieldCode}
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<!-- 批量按字段编码查询 -->
|
||||||
|
<select id="queryByCodes" resultType="com.mhd.bi.domain.biStaticField.repository.po.BiStaticFieldPO">
|
||||||
|
SELECT
|
||||||
|
FIELD_CODE AS fieldCode,
|
||||||
|
FIELD_NAME AS fieldName,
|
||||||
|
SCOPE_TYPE AS scopeType,
|
||||||
|
SCOPE_CODE AS scopeCode,
|
||||||
|
FIELD_VALUE AS fieldValue,
|
||||||
|
UNIT AS unit
|
||||||
|
FROM NGWL_TEST_YMS.QMS_STATIC_FIELD
|
||||||
|
WHERE DEL_FLAG = 1
|
||||||
|
AND FIELD_CODE IN
|
||||||
|
<foreach collection="fieldCodes" item="c" open="(" separator="," close=")">
|
||||||
|
#{c}
|
||||||
|
</foreach>
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<!-- 查询全部有效配置 -->
|
||||||
|
<select id="queryAll" resultType="com.mhd.bi.domain.biStaticField.repository.po.BiStaticFieldPO">
|
||||||
|
SELECT
|
||||||
|
FIELD_CODE AS fieldCode,
|
||||||
|
FIELD_NAME AS fieldName,
|
||||||
|
SCOPE_TYPE AS scopeType,
|
||||||
|
SCOPE_CODE AS scopeCode,
|
||||||
|
FIELD_VALUE AS fieldValue,
|
||||||
|
UNIT AS unit
|
||||||
|
FROM NGWL_TEST_YMS.QMS_STATIC_FIELD
|
||||||
|
WHERE DEL_FLAG = 1
|
||||||
|
</select>
|
||||||
|
|
||||||
|
</mapper>
|
||||||
+77
@@ -0,0 +1,77 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
<!DOCTYPE mapper
|
||||||
|
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
|
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
<mapper namespace="com.mhd.bi.domain.biWarehouseTransport.repository.mapper.BiWarehouseTransportRealDataMapper">
|
||||||
|
|
||||||
|
<!-- 仓储订单量:本年度 / 本季度 / 本月度 = 入库业务单 + 出库业务单 数量合计
|
||||||
|
统计范围:全部组织
|
||||||
|
口径:del_flag = 1(有效);本季度用「月份向上取整 / 3」判断同季度 -->
|
||||||
|
|
||||||
|
<select id="queryWarehouseOrderStat" resultType="com.mhd.bi.domain.biWarehouseTransport.repository.po.RealWarehouseOrderStatPO">
|
||||||
|
SELECT
|
||||||
|
(SELECT NVL(SUM(c), 0) FROM (
|
||||||
|
SELECT COUNT(1) AS c FROM NGWL_TEST_WMS.STOCK_IN_ORDER
|
||||||
|
WHERE del_flag = 1 AND TO_CHAR(CREATE_TIME, 'YYYY') = TO_CHAR(SYSDATE, 'YYYY')
|
||||||
|
UNION ALL
|
||||||
|
SELECT COUNT(1) FROM NGWL_TEST_WMS.STOCK_OUT_ORDER
|
||||||
|
WHERE del_flag = 1 AND TO_CHAR(CREATE_TIME, 'YYYY') = TO_CHAR(SYSDATE, 'YYYY')
|
||||||
|
)) AS currentYearOrders,
|
||||||
|
(SELECT NVL(SUM(c), 0) FROM (
|
||||||
|
SELECT COUNT(1) AS c FROM NGWL_TEST_WMS.STOCK_IN_ORDER
|
||||||
|
WHERE del_flag = 1 AND TO_CHAR(CREATE_TIME, 'YYYY') = TO_CHAR(SYSDATE, 'YYYY')
|
||||||
|
AND CEIL(TO_NUMBER(TO_CHAR(CREATE_TIME, 'MM')) / 3) = CEIL(TO_NUMBER(TO_CHAR(SYSDATE, 'MM')) / 3)
|
||||||
|
UNION ALL
|
||||||
|
SELECT COUNT(1) FROM NGWL_TEST_WMS.STOCK_OUT_ORDER
|
||||||
|
WHERE del_flag = 1 AND TO_CHAR(CREATE_TIME, 'YYYY') = TO_CHAR(SYSDATE, 'YYYY')
|
||||||
|
AND CEIL(TO_NUMBER(TO_CHAR(CREATE_TIME, 'MM')) / 3) = CEIL(TO_NUMBER(TO_CHAR(SYSDATE, 'MM')) / 3)
|
||||||
|
)) AS currentQuarterOrders,
|
||||||
|
(SELECT NVL(SUM(c), 0) FROM (
|
||||||
|
SELECT COUNT(1) AS c FROM NGWL_TEST_WMS.STOCK_IN_ORDER
|
||||||
|
WHERE del_flag = 1 AND TO_CHAR(CREATE_TIME, 'YYYY-MM') = TO_CHAR(SYSDATE, 'YYYY-MM')
|
||||||
|
UNION ALL
|
||||||
|
SELECT COUNT(1) FROM NGWL_TEST_WMS.STOCK_OUT_ORDER
|
||||||
|
WHERE del_flag = 1 AND TO_CHAR(CREATE_TIME, 'YYYY-MM') = TO_CHAR(SYSDATE, 'YYYY-MM')
|
||||||
|
)) AS currentMonthOrders
|
||||||
|
FROM DUAL
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<!-- 今日订单数量:OMS 运输业务单,今日创建,全部组织 -->
|
||||||
|
<select id="countTodayTransportOrders" resultType="java.lang.Long">
|
||||||
|
SELECT COUNT(1)
|
||||||
|
FROM NGWL_TEST_OMS.BUSINESS_DOCUMENT_ORDER
|
||||||
|
WHERE CREATE_TIME IS NOT NULL
|
||||||
|
AND TRUNC(CREATE_TIME) = TRUNC(SYSDATE)
|
||||||
|
AND IS_DELETE = 0
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<!-- 今日运输车次:TMS 运输单(运单),今日创建,全部组织
|
||||||
|
口径:一个单 = 一个车次,直接按单计数(不做单号去重,避免单号为空被漏计) -->
|
||||||
|
<select id="countTodayTransportTrips" resultType="java.lang.Long">
|
||||||
|
SELECT COUNT(1)
|
||||||
|
FROM NGWL_TEST_WLHY.TMS_TRANSPORT_NOTE
|
||||||
|
WHERE CREATE_TIME IS NOT NULL
|
||||||
|
AND TRUNC(CREATE_TIME) = TRUNC(SYSDATE)
|
||||||
|
AND (IS_DELETE IS NULL OR IS_DELETE = 0)
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<!-- 客户贡献排名:OMS 运输业务单,近半年按货主(APPOINT_SHIPPER)聚合订单数,取前 5 名
|
||||||
|
统计范围:全部组织;口径:一个单 = 一单,COUNT(1) -->
|
||||||
|
<select id="queryCustomerRankTop5" resultType="com.mhd.bi.domain.biWarehouseTransport.repository.po.RealCustomerRankPO">
|
||||||
|
SELECT * FROM (
|
||||||
|
SELECT
|
||||||
|
APPOINT_SHIPPER AS customerName,
|
||||||
|
CEIL(COUNT(1)) AS customerAmount
|
||||||
|
FROM NGWL_TEST_OMS.BUSINESS_DOCUMENT_ORDER
|
||||||
|
WHERE CREATE_TIME IS NOT NULL
|
||||||
|
AND CREATE_TIME >= ADD_MONTHS(TRUNC(SYSDATE, 'MM'), -5)
|
||||||
|
AND IS_DELETE = 0
|
||||||
|
AND APPOINT_SHIPPER IS NOT NULL
|
||||||
|
AND APPOINT_SHIPPER != ''
|
||||||
|
GROUP BY APPOINT_SHIPPER
|
||||||
|
ORDER BY COUNT(1) DESC
|
||||||
|
)
|
||||||
|
WHERE ROWNUM <= 5
|
||||||
|
</select>
|
||||||
|
|
||||||
|
</mapper>
|
||||||
+1
-1
@@ -27,7 +27,7 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
// 目标地址由 nacos 配置项 feign.url.mhd-third-party-service 指定,未配置时按服务名走服务发现
|
// 目标地址由 nacos 配置项 feign.url.mhd-third-party-service 指定,未配置时按服务名走服务发现
|
||||||
@FeignClient(value = "mhd-third-party-service",url = "http://10.102.192.32:8012", configuration = FeignAutoConfiguration.class)
|
@FeignClient(value = "mhd-third-party-service",url = "http://10.102.192.31:8012", configuration = FeignAutoConfiguration.class)
|
||||||
public interface ThirdPartyServiceFeign {
|
public interface ThirdPartyServiceFeign {
|
||||||
|
|
||||||
//查询当前组织所有三方接口信息
|
//查询当前组织所有三方接口信息
|
||||||
|
|||||||
+8
-8
@@ -38,13 +38,13 @@ public class XxlJobOpenApiUtil {
|
|||||||
try {
|
try {
|
||||||
Map<String, Object> formMap = BeanUtil.beanToMap(addReq);
|
Map<String, Object> formMap = BeanUtil.beanToMap(addReq);
|
||||||
HttpResponse response = HttpRequest.post(url)
|
HttpResponse response = HttpRequest.post(url)
|
||||||
.header("Authorization", cookie)
|
.header("Cookie", cookie)
|
||||||
.form(formMap)
|
.form(formMap)
|
||||||
.execute();
|
.execute();
|
||||||
int status = response.getStatus();
|
int status = response.getStatus();
|
||||||
log.info("[XxlJob] addJob status:{}", status);
|
log.info("[XxlJob] addJob status:{}", status);
|
||||||
// 新增成功200重定向到列表页
|
// 新增成功200重定向到列表页
|
||||||
return status == 200 || status == 302;
|
return status == 200;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("[XxlJob] addJob异常", e);
|
log.error("[XxlJob] addJob异常", e);
|
||||||
return false;
|
return false;
|
||||||
@@ -128,10 +128,10 @@ public class XxlJobOpenApiUtil {
|
|||||||
String url = adminUrl + "/jobinfo/pause";
|
String url = adminUrl + "/jobinfo/pause";
|
||||||
try {
|
try {
|
||||||
HttpResponse response = HttpRequest.post(url)
|
HttpResponse response = HttpRequest.post(url)
|
||||||
.header("Authorization", cookie)
|
.header("Cookie", cookie)
|
||||||
.form("id", jobId)
|
.form("id", jobId)
|
||||||
.execute();
|
.execute();
|
||||||
return response.getStatus() == 200 || response.getStatus() == 302;
|
return response.getStatus() == 200;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("[XxlJob] pauseJob jobId:{}异常", jobId, e);
|
log.error("[XxlJob] pauseJob jobId:{}异常", jobId, e);
|
||||||
return false;
|
return false;
|
||||||
@@ -150,10 +150,10 @@ public class XxlJobOpenApiUtil {
|
|||||||
String url = adminUrl + "/jobinfo/start";
|
String url = adminUrl + "/jobinfo/start";
|
||||||
try {
|
try {
|
||||||
HttpResponse response = HttpRequest.post(url)
|
HttpResponse response = HttpRequest.post(url)
|
||||||
.header("Authorization", cookie)
|
.header("Cookie", cookie)
|
||||||
.form("id", jobId)
|
.form("id", jobId)
|
||||||
.execute();
|
.execute();
|
||||||
return response.getStatus() == 200 || response.getStatus() == 302;
|
return response.getStatus() == 200;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("[XxlJob] startJob jobId:{}异常", jobId, e);
|
log.error("[XxlJob] startJob jobId:{}异常", jobId, e);
|
||||||
return false;
|
return false;
|
||||||
@@ -172,10 +172,10 @@ public class XxlJobOpenApiUtil {
|
|||||||
String url = adminUrl + "/jobinfo/remove";
|
String url = adminUrl + "/jobinfo/remove";
|
||||||
try {
|
try {
|
||||||
HttpResponse response = HttpRequest.post(url)
|
HttpResponse response = HttpRequest.post(url)
|
||||||
.header("Authorization", cookie)
|
.header("Cookie", cookie)
|
||||||
.form("id", jobId)
|
.form("id", jobId)
|
||||||
.execute();
|
.execute();
|
||||||
return response.getStatus() == 200 || response.getStatus() == 302;
|
return response.getStatus() == 200;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("[XxlJob] removeJob jobId:{}异常", jobId, e);
|
log.error("[XxlJob] removeJob jobId:{}异常", jobId, e);
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
-172
@@ -33,7 +33,6 @@ import com.mhd.bms.infrastructure.constant.BillLogsConstants;
|
|||||||
import com.mhd.bms.interfaces.assembler.billManage.BillManageAssembler;
|
import com.mhd.bms.interfaces.assembler.billManage.BillManageAssembler;
|
||||||
import com.mhd.bms.interfaces.dto.billManage.BillDetailDTO;
|
import com.mhd.bms.interfaces.dto.billManage.BillDetailDTO;
|
||||||
import com.mhd.bms.interfaces.dto.billManage.BillManageDTO;
|
import com.mhd.bms.interfaces.dto.billManage.BillManageDTO;
|
||||||
import com.mhd.bms.interfaces.dto.billManage.CustomerMonthBillVO;
|
|
||||||
import com.mhd.bms.interfaces.dto.billingStatement.BillingStatementDTO;
|
import com.mhd.bms.interfaces.dto.billingStatement.BillingStatementDTO;
|
||||||
import com.mhd.common.core.exception.ServiceException;
|
import com.mhd.common.core.exception.ServiceException;
|
||||||
import com.mhd.common.core.exception.digitalLogisticsException.DigitalLogisticsException;
|
import com.mhd.common.core.exception.digitalLogisticsException.DigitalLogisticsException;
|
||||||
@@ -139,74 +138,6 @@ public class BillManageApplicationService {
|
|||||||
String billNumber = billManagePO.getBillNumber(); // 获取账单编号
|
String billNumber = billManagePO.getBillNumber(); // 获取账单编号
|
||||||
// 原有 - 前端列表用,不变
|
// 原有 - 前端列表用,不变
|
||||||
List<BillDetail> billDetails = billDetailMapper.selectList(new LambdaQueryWrapper<BillDetail>().eq(BillDetail::getBillNumber, billNumber));
|
List<BillDetail> billDetails = billDetailMapper.selectList(new LambdaQueryWrapper<BillDetail>().eq(BillDetail::getBillNumber, billNumber));
|
||||||
BigDecimal totalTaxAmount = billDetails.stream().map(BillDetail::getTaxAmount).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
||||||
BigDecimal totalTaxFreeFee = billDetails.stream().map(BillDetail::getTaxFreeFee).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
||||||
billManagePO.setTaxAmount(totalTaxAmount);
|
|
||||||
billManagePO.setTaxFreeFee(totalTaxFreeFee);
|
|
||||||
billManagePO.setBillDetailList(billDetails);
|
|
||||||
// 新增 - 导出用,LEFT JOIN billing_statement 拿到费用科目
|
|
||||||
List<BillDetailPO> billDetailPOs = billDetailMapper.getDetailsByBillManageId(billManagePO.getBillManageId());
|
|
||||||
billManagePO.setBillDetailPOList(billDetailPOs);
|
|
||||||
}
|
|
||||||
return billManagePOS;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<BillManagePO> customerMonthlyReport(BillManageDO billManageDO) {
|
|
||||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
|
||||||
if (loginUser != null && loginUser.getUserPo() != null) {
|
|
||||||
Long userOrganizationId = loginUser.getUserPo().getOrganizationId();
|
|
||||||
Long frontendOrganizationId = billManageDO.getOrganizationId(); // 前端传递的 organizationId
|
|
||||||
|
|
||||||
// 当前登录用户的 organizationId 为 2827 时,可查全部组织数据;其他组织只能查自己
|
|
||||||
if (userOrganizationId != null && userOrganizationId == 2827L) {
|
|
||||||
// 南光组织(organizationId=2827):可以查询所有组织的数据
|
|
||||||
if (frontendOrganizationId != null) {
|
|
||||||
// 前端传递了 organizationId(包括2827或其他组织),使用前端传递的值进行过滤
|
|
||||||
billManageDO.setOrganizationId(frontendOrganizationId);
|
|
||||||
billManageDO.setTopOrganizationId(null); // 明确设置为 null,避免使用 topOrganizationId 条件
|
|
||||||
} else {
|
|
||||||
// 前端没有传递 organizationId,清空组织过滤条件,查询所有组织的数据
|
|
||||||
billManageDO.setOrganizationId(null);
|
|
||||||
billManageDO.setTopOrganizationId(null);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// 其他组织:设置organizationId,只查询当前组织的数据
|
|
||||||
// 如果前端传递了 organizationId,验证是否与当前登录用户的组织ID一致
|
|
||||||
if (frontendOrganizationId != null && userOrganizationId != null) {
|
|
||||||
// 前端传递了 organizationId,验证是否与当前登录用户的组织ID一致
|
|
||||||
if (!frontendOrganizationId.equals(userOrganizationId)) {
|
|
||||||
// 前端传递了其他组织的 organizationId,强制使用当前登录用户的组织ID,防止越权查询
|
|
||||||
billManageDO.setOrganizationId(userOrganizationId);
|
|
||||||
}
|
|
||||||
// 如果前端传递的 organizationId 与当前登录用户的组织ID一致,使用前端传递的值
|
|
||||||
} else {
|
|
||||||
// 前端没有传递 organizationId,使用当前登录用户的组织ID
|
|
||||||
if (userOrganizationId != null) {
|
|
||||||
billManageDO.setOrganizationId(userOrganizationId);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// 如果 organizationId 不为 null,则优先使用 organizationId,不使用 topOrganizationId
|
|
||||||
if (billManageDO.getOrganizationId() == null) {
|
|
||||||
Long topOrganizationId = loginUser.getUserPo().getTopOrganizationId();
|
|
||||||
if (topOrganizationId != null && topOrganizationId != 1) {
|
|
||||||
billManageDO.setTopOrganizationId(topOrganizationId);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// 对于非2827组织,必须设置 topOrganizationId=2827
|
|
||||||
billManageDO.setTopOrganizationId(2827L);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
List<BillManagePO> billManagePOS = billManageDomainService.customerMonthlyReport(billManageDO);
|
|
||||||
for (BillManagePO billManagePO : billManagePOS) {
|
|
||||||
String billNumber = billManagePO.getBillNumber(); // 获取账单编号
|
|
||||||
// 原有 - 前端列表用,不变
|
|
||||||
List<BillDetail> billDetails = billDetailMapper.selectList(new LambdaQueryWrapper<BillDetail>().eq(BillDetail::getBillNumber, billNumber));
|
|
||||||
BigDecimal totalTaxAmount = billDetails.stream().map(BillDetail::getTaxAmount).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
||||||
BigDecimal totalTaxFreeFee = billDetails.stream().map(BillDetail::getTaxFreeFee).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
||||||
billManagePO.setTaxAmount(totalTaxAmount);
|
|
||||||
billManagePO.setTaxFreeFee(totalTaxFreeFee);
|
|
||||||
|
|
||||||
billManagePO.setBillDetailList(billDetails);
|
billManagePO.setBillDetailList(billDetails);
|
||||||
// 新增 - 导出用,LEFT JOIN billing_statement 拿到费用科目
|
// 新增 - 导出用,LEFT JOIN billing_statement 拿到费用科目
|
||||||
List<BillDetailPO> billDetailPOs = billDetailMapper.getDetailsByBillManageId(billManagePO.getBillManageId());
|
List<BillDetailPO> billDetailPOs = billDetailMapper.getDetailsByBillManageId(billManagePO.getBillManageId());
|
||||||
@@ -253,10 +184,6 @@ public class BillManageApplicationService {
|
|||||||
return billManageDomainService.save(billingStatementDTO);
|
return billManageDomainService.save(billingStatementDTO);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Boolean saveBillJob(BillingStatementDTO billingStatementDTO) {
|
|
||||||
return billManageDomainService.saveJob(billingStatementDTO);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 批量删除账单管理
|
* 批量删除账单管理
|
||||||
*/
|
*/
|
||||||
@@ -360,28 +287,6 @@ public class BillManageApplicationService {
|
|||||||
return billManageDomainService.confirmBilling(billManageDO);
|
return billManageDomainService.confirmBilling(billManageDO);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional
|
|
||||||
public Boolean confirmBillingJob(BillManageDTO billManageDTO) {
|
|
||||||
//确认账单:未收款状态之前都可以进行确认账单,跳过核账流程,直接到未收款状态
|
|
||||||
if(!StringUtils.isNotEmpty(billManageDTO.getBillManageIds())){
|
|
||||||
throw new ServiceException("账单管理ids不能为空");
|
|
||||||
}
|
|
||||||
//校验
|
|
||||||
Set<String> billManageIds = Stream.of(billManageDTO.getBillManageIds().split(",")).collect(Collectors.toSet());
|
|
||||||
BillManageDO billManageDO = new BillManageDO();
|
|
||||||
billManageDO.setBillManageIdSet(billManageIds);
|
|
||||||
List<BillManagePO> billManageList = billManageDomainService.queryList(billManageDO);
|
|
||||||
for (BillManagePO billManage : billManageList) {
|
|
||||||
if(billManage.getBillState() > 2){
|
|
||||||
throw new ServiceException("选中数据"+ billManage.getBillNumber() + "状态不可操作确认账单");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
billManageDO.setOrganizationId(billManageDTO.getOrganizationId());
|
|
||||||
billManageDO.setOrganizationName(billManageDTO.getOrganizationName());
|
|
||||||
billManageDO.setTopOrganizationId(billManageDTO.getTopOrganizationId());
|
|
||||||
return billManageDomainService.confirmBillingJob(billManageDO);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public int editIsInvoice(String billNumber, Integer isInvoice, String invoiceId, String invoiceMakeTime,String applyNumber)
|
public int editIsInvoice(String billNumber, Integer isInvoice, String invoiceId, String invoiceMakeTime,String applyNumber)
|
||||||
{
|
{
|
||||||
@@ -716,22 +621,6 @@ public class BillManageApplicationService {
|
|||||||
return originalBill;
|
return originalBill;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 应收账单-红冲
|
|
||||||
*/
|
|
||||||
@Transactional
|
|
||||||
public Boolean redFlushBill(BillManageDTO billManageDTO) {
|
|
||||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
|
||||||
if (ObjectUtil.isNull(loginUser)) {
|
|
||||||
throw new DigitalLogisticsException(UserError.TIMEOUT);
|
|
||||||
}
|
|
||||||
if (StringUtils.isEmpty(billManageDTO.getBillManageIds())) {
|
|
||||||
throw new ServiceException("账单id不能为空");
|
|
||||||
}
|
|
||||||
return billManageDomainService.redFlushBill(billManageDTO);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 应收账单-客户确认
|
* 应收账单-客户确认
|
||||||
*/
|
*/
|
||||||
@@ -983,66 +872,5 @@ public class BillManageApplicationService {
|
|||||||
return flag && flagTwo;
|
return flag && flagTwo;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 客户每月账单分组查询
|
|
||||||
*/
|
|
||||||
public List<CustomerMonthBillVO> queryCustomerMonthBillList(BillManageDO billManageDO) {
|
|
||||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
|
||||||
if (loginUser != null && loginUser.getUserPo() != null) {
|
|
||||||
Long userOrganizationId = loginUser.getUserPo().getOrganizationId();
|
|
||||||
Long frontendOrganizationId = billManageDO.getOrganizationId();
|
|
||||||
|
|
||||||
if (userOrganizationId != null && userOrganizationId == 2827L) {
|
|
||||||
if (frontendOrganizationId != null) {
|
|
||||||
billManageDO.setOrganizationId(frontendOrganizationId);
|
|
||||||
billManageDO.setTopOrganizationId(null);
|
|
||||||
} else {
|
|
||||||
billManageDO.setOrganizationId(null);
|
|
||||||
billManageDO.setTopOrganizationId(null);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (frontendOrganizationId != null && userOrganizationId != null) {
|
|
||||||
if (!frontendOrganizationId.equals(userOrganizationId)) {
|
|
||||||
billManageDO.setOrganizationId(userOrganizationId);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (userOrganizationId != null) {
|
|
||||||
billManageDO.setOrganizationId(userOrganizationId);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (billManageDO.getOrganizationId() == null) {
|
|
||||||
Long topOrganizationId = loginUser.getUserPo().getTopOrganizationId();
|
|
||||||
if (topOrganizationId != null && topOrganizationId != 1) {
|
|
||||||
billManageDO.setTopOrganizationId(topOrganizationId);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
billManageDO.setTopOrganizationId(2827L);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
List<CustomerMonthBillVO> list = billManageDomainService.queryCustomerMonthBillList(billManageDO);
|
|
||||||
|
|
||||||
// 计算付款状态
|
|
||||||
for (CustomerMonthBillVO vo : list) {
|
|
||||||
BigDecimal totalAmount = vo.getTotalBillAmount() != null ? vo.getTotalBillAmount() : BigDecimal.ZERO;
|
|
||||||
BigDecimal settledAmount = vo.getTotalSettledAmount() != null ? vo.getTotalSettledAmount() : BigDecimal.ZERO;
|
|
||||||
|
|
||||||
if (totalAmount.compareTo(BigDecimal.ZERO) == 0) {
|
|
||||||
vo.setPaymentStatus(3);
|
|
||||||
vo.setPaymentStatusName("已付款");
|
|
||||||
} else if (settledAmount.compareTo(BigDecimal.ZERO) == 0) {
|
|
||||||
vo.setPaymentStatus(1);
|
|
||||||
vo.setPaymentStatusName("未付款");
|
|
||||||
} else if (settledAmount.compareTo(totalAmount) >= 0) {
|
|
||||||
vo.setPaymentStatus(3);
|
|
||||||
vo.setPaymentStatusName("已付款");
|
|
||||||
} else {
|
|
||||||
vo.setPaymentStatus(2);
|
|
||||||
vo.setPaymentStatusName("部分付款");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
+90
-1243
File diff suppressed because it is too large
Load Diff
-19
@@ -147,25 +147,6 @@ public class ReceiptManageApplicationService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 撤销收款
|
|
||||||
*/
|
|
||||||
@Transactional
|
|
||||||
public Boolean cancelCollection(ReceiptManageDO receiptManageDO) {
|
|
||||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
|
||||||
if (ObjectUtil.isNull(loginUser)) {
|
|
||||||
throw new DigitalLogisticsException(UserError.TIMEOUT);
|
|
||||||
}
|
|
||||||
return receiptManageDomainService.cancelCollection(receiptManageDO);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 撤销收款-查询账单涉及的收款单id(用于加锁,防止并发撤销时收款单金额重算冲突)
|
|
||||||
*/
|
|
||||||
public Set<Long> queryCancelCollectionReceiptManageIds(String billManageIds) {
|
|
||||||
return receiptManageDomainService.queryReceiptManageIdsByBillManageIds(billManageIds);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 退款
|
* 退款
|
||||||
*/
|
*/
|
||||||
|
|||||||
-2
@@ -575,8 +575,6 @@ public class ReportFormApplicationService {
|
|||||||
//收款单
|
//收款单
|
||||||
QueryWrapper<ReceiptManage> queryWrapper = new QueryWrapper<>();
|
QueryWrapper<ReceiptManage> queryWrapper = new QueryWrapper<>();
|
||||||
queryWrapper.eq("top_organization_id", loginUser.getUserPo().getTopOrganizationId());
|
queryWrapper.eq("top_organization_id", loginUser.getUserPo().getTopOrganizationId());
|
||||||
//过滤已撤销(逻辑删除)的收款单
|
|
||||||
queryWrapper.eq("del_flag", 1);
|
|
||||||
for (int i = 0; i < formQueryParamsList.size(); i++) {
|
for (int i = 0; i < formQueryParamsList.size(); i++) {
|
||||||
FormQueryParams formQueryParams = formQueryParamsList.get(i);
|
FormQueryParams formQueryParams = formQueryParamsList.get(i);
|
||||||
FormQueryParams beforeFormQueryParams = null;
|
FormQueryParams beforeFormQueryParams = null;
|
||||||
|
|||||||
@@ -47,8 +47,8 @@ public class BillManage extends BaseVOEntity{
|
|||||||
@Excel(name = "账单类型", readConverterExp = "1=-应收,2-应付")
|
@Excel(name = "账单类型", readConverterExp = "1=-应收,2-应付")
|
||||||
private Integer billType;
|
private Integer billType;
|
||||||
|
|
||||||
@ApiModelProperty("账单状态(1-未确认,2-对账中,3-未收款/付款,4-部分收款/付款,5-已收款/付款,6-已作废,7-已退款,8-红冲)")
|
@ApiModelProperty("账单状态(1-未确认,2-对账中,3-未收款/付款,4-部分收款/付款,5-已收款/付款,6-已作废,7-已退款)")
|
||||||
@Excel(name = "账单状态", readConverterExp = "1=-未确认,2-对账中,3-未收款/付款,4-部分收款/付款,5-已收款/付款,6-已作废,7-已退款,8-红冲")
|
@Excel(name = "账单状态", readConverterExp = "1=-未确认,2-对账中,3-未收款/付款,4-部分收款/付款,5-已收款/付款,6-已作废,7-已退款")
|
||||||
private Integer billState;
|
private Integer billState;
|
||||||
|
|
||||||
@ApiModelProperty("账单流程节点(1-发起对账,2-客户确认,3-财务审核,4-收款/付款)")
|
@ApiModelProperty("账单流程节点(1-发起对账,2-客户确认,3-财务审核,4-收款/付款)")
|
||||||
|
|||||||
-9
@@ -4,7 +4,6 @@ import com.baomidou.mybatisplus.extension.service.IService;
|
|||||||
import com.mhd.bms.domain.billManage.entity.BillManage;
|
import com.mhd.bms.domain.billManage.entity.BillManage;
|
||||||
import com.mhd.bms.domain.billManage.repository.po.BillManagePO;
|
import com.mhd.bms.domain.billManage.repository.po.BillManagePO;
|
||||||
import com.mhd.bms.domain.billManage.repository.todo.BillManageDO;
|
import com.mhd.bms.domain.billManage.repository.todo.BillManageDO;
|
||||||
import com.mhd.bms.interfaces.dto.billManage.CustomerMonthBillVO;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@@ -21,14 +20,6 @@ public interface IBillManageService extends IService<BillManage>
|
|||||||
*/
|
*/
|
||||||
public List<BillManagePO> queryList(BillManageDO billManageDO);
|
public List<BillManagePO> queryList(BillManageDO billManageDO);
|
||||||
|
|
||||||
|
|
||||||
public List<BillManagePO> customerMonthlyReport(BillManageDO billManageDO);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 客户每月账单分组查询
|
|
||||||
*/
|
|
||||||
public List<CustomerMonthBillVO> queryCustomerMonthBillList(BillManageDO billManageDO);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 新增账单管理
|
* 新增账单管理
|
||||||
*/
|
*/
|
||||||
|
|||||||
-8
@@ -5,7 +5,6 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
|||||||
import com.mhd.bms.domain.billManage.entity.BillManage;
|
import com.mhd.bms.domain.billManage.entity.BillManage;
|
||||||
import com.mhd.bms.domain.billManage.repository.po.BillManagePO;
|
import com.mhd.bms.domain.billManage.repository.po.BillManagePO;
|
||||||
import com.mhd.bms.domain.billManage.repository.todo.BillManageDO;
|
import com.mhd.bms.domain.billManage.repository.todo.BillManageDO;
|
||||||
import com.mhd.bms.interfaces.dto.billManage.CustomerMonthBillVO;
|
|
||||||
import org.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.Param;
|
||||||
/**
|
/**
|
||||||
* 账单管理Mapper接口
|
* 账单管理Mapper接口
|
||||||
@@ -20,13 +19,6 @@ public interface BillManageMapper extends BaseMapper<BillManage>
|
|||||||
*/
|
*/
|
||||||
public List<BillManagePO> queryList(@Param("billManageDO") BillManageDO billManageDO);
|
public List<BillManagePO> queryList(@Param("billManageDO") BillManageDO billManageDO);
|
||||||
|
|
||||||
public List<BillManagePO> customerMonthlyReport(@Param("billManageDO") BillManageDO billManageDO);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 客户每月账单分组查询
|
|
||||||
*/
|
|
||||||
public List<CustomerMonthBillVO> queryCustomerMonthBillList(@Param("billManageDO") BillManageDO billManageDO);
|
|
||||||
|
|
||||||
String getInvoiceItemName(@Param("invoiceItemId") String invoiceItemId);
|
String getInvoiceItemName(@Param("invoiceItemId") String invoiceItemId);
|
||||||
|
|
||||||
String getInvoiceItemNcCode(@Param("invoiceItemId") String invoiceItemId);
|
String getInvoiceItemNcCode(@Param("invoiceItemId") String invoiceItemId);
|
||||||
|
|||||||
-14
@@ -31,7 +31,6 @@ import com.mhd.bms.domain.settlementCustomers.entity.SettlementCustomers;
|
|||||||
import com.mhd.bms.domain.settlementCustomers.repository.facade.ISettlementCustomersService;
|
import com.mhd.bms.domain.settlementCustomers.repository.facade.ISettlementCustomersService;
|
||||||
import com.mhd.bms.interfaces.dto.billManage.BillDetailDTO;
|
import com.mhd.bms.interfaces.dto.billManage.BillDetailDTO;
|
||||||
import com.mhd.bms.interfaces.dto.billManage.BillManageDTO;
|
import com.mhd.bms.interfaces.dto.billManage.BillManageDTO;
|
||||||
import com.mhd.bms.interfaces.dto.billManage.CustomerMonthBillVO;
|
|
||||||
import com.mhd.common.core.domain.dto.ReconciliationDTO;
|
import com.mhd.common.core.domain.dto.ReconciliationDTO;
|
||||||
import com.mhd.common.core.domain.dto.nc.*;
|
import com.mhd.common.core.domain.dto.nc.*;
|
||||||
import com.mhd.common.core.domain.entity.R;
|
import com.mhd.common.core.domain.entity.R;
|
||||||
@@ -127,14 +126,6 @@ public class BillManageImpl extends ServiceImpl<BillManageMapper, BillManage> im
|
|||||||
return billManageMapper.queryList(billManageDO);
|
return billManageMapper.queryList(billManageDO);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<BillManagePO> customerMonthlyReport(BillManageDO billManageDO)
|
|
||||||
{
|
|
||||||
return billManageMapper.customerMonthlyReport(billManageDO);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 新增账单管理
|
* 新增账单管理
|
||||||
*/
|
*/
|
||||||
@@ -1513,9 +1504,4 @@ public class BillManageImpl extends ServiceImpl<BillManageMapper, BillManage> im
|
|||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<CustomerMonthBillVO> queryCustomerMonthBillList(BillManageDO billManageDO) {
|
|
||||||
return billManageMapper.queryCustomerMonthBillList(billManageDO);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -2,7 +2,6 @@ package com.mhd.bms.domain.billManage.repository.po;
|
|||||||
|
|
||||||
import com.mhd.bms.domain.billManage.entity.BillDetail;
|
import com.mhd.bms.domain.billManage.entity.BillDetail;
|
||||||
import com.mhd.bms.domain.billingStatement.repository.po.BillingStatementPO;
|
import com.mhd.bms.domain.billingStatement.repository.po.BillingStatementPO;
|
||||||
import com.mhd.bms.domain.receiptManage.entity.ReceiptDetail;
|
|
||||||
import com.mhd.common.core.annotation.Excel;
|
import com.mhd.common.core.annotation.Excel;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
@@ -53,8 +52,8 @@ public class BillManagePO extends BaseVOEntity{
|
|||||||
@Excel(name = "账单类型", readConverterExp = "1=-应收,2-应付")
|
@Excel(name = "账单类型", readConverterExp = "1=-应收,2-应付")
|
||||||
private Integer billType;
|
private Integer billType;
|
||||||
|
|
||||||
@ApiModelProperty("账单状态(1-未确认,2-对账中,3-未收款/付款,4-部分收款/付款,5-已收款/付款,6-已作废,7-已退款,8-红冲)")
|
@ApiModelProperty("账单状态(1-未确认,2-对账中,3-未收款/付款,4-部分收款/付款,5-已收款/付款,6-已作废,7-已退款)")
|
||||||
@Excel(name = "账单状态", readConverterExp = "1=-未确认,2-对账中,3-未收款/付款,4-部分收款/付款,5-已收款/付款,6-已作废,7-已退款,8-红冲")
|
@Excel(name = "账单状态", readConverterExp = "1=-未确认,2-对账中,3-未收款/付款,4-部分收款/付款,5-已收款/付款,6-已作废,7-已退款")
|
||||||
private Integer billState;
|
private Integer billState;
|
||||||
|
|
||||||
@ApiModelProperty("账单流程节点(1-发起对账,2-客户确认,3-财务审核,4-收款/付款)")
|
@ApiModelProperty("账单流程节点(1-发起对账,2-客户确认,3-财务审核,4-收款/付款)")
|
||||||
@@ -263,12 +262,9 @@ public class BillManagePO extends BaseVOEntity{
|
|||||||
@ApiModelProperty("收款帐户名称")
|
@ApiModelProperty("收款帐户名称")
|
||||||
private String paymentAccountName;
|
private String paymentAccountName;
|
||||||
private List<BillDetail> billDetailList;
|
private List<BillDetail> billDetailList;
|
||||||
private List<ReceiptDetail> receiptDetailList;
|
|
||||||
|
|
||||||
@ApiModelProperty("最近收款时间")
|
@ApiModelProperty("最近收款时间")
|
||||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||||
@Excel(name = "最近收款时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
|
@Excel(name = "最近收款时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
|
||||||
private Date collectionTime;
|
private Date collectionTime;
|
||||||
@ApiModelProperty("合同编码")
|
|
||||||
private String contractNumbers;
|
|
||||||
}
|
}
|
||||||
+2
-5
@@ -47,8 +47,8 @@ public class BillManageDO extends BaseVOEntity{
|
|||||||
@Excel(name = "账单类型", readConverterExp = "1=-应收,2-应付")
|
@Excel(name = "账单类型", readConverterExp = "1=-应收,2-应付")
|
||||||
private Integer billType;
|
private Integer billType;
|
||||||
|
|
||||||
@ApiModelProperty("账单状态(1-未确认,2-对账中,3-未收款/付款,4-部分收款/付款,5-已收款/付款,6-已作废,7-已退款,8-红冲)")
|
@ApiModelProperty("账单状态(1-未确认,2-对账中,3-未收款/付款,4-部分收款/付款,5-已收款/付款,6-已作废,7-已退款)")
|
||||||
@Excel(name = "账单状态", readConverterExp = "1=-未确认,2-对账中,3-未收款/付款,4-部分收款/付款,5-已收款/付款,6-已作废,7-已退款,8-红冲")
|
@Excel(name = "账单状态", readConverterExp = "1=-未确认,2-对账中,3-未收款/付款,4-部分收款/付款,5-已收款/付款,6-已作废,7-已退款")
|
||||||
private Integer billState;
|
private Integer billState;
|
||||||
|
|
||||||
@ApiModelProperty("账单流程节点(1-发起对账,2-客户确认,3-财务审核,4-收款/付款)")
|
@ApiModelProperty("账单流程节点(1-发起对账,2-客户确认,3-财务审核,4-收款/付款)")
|
||||||
@@ -266,7 +266,4 @@ public class BillManageDO extends BaseVOEntity{
|
|||||||
private String paymentAccountName;
|
private String paymentAccountName;
|
||||||
@ApiModelProperty("业务员ID")
|
@ApiModelProperty("业务员ID")
|
||||||
private String salesmanId;
|
private String salesmanId;
|
||||||
|
|
||||||
@ApiModelProperty("账单月份(yyyy-MM,按创建时间月份筛选,用于客户月账单分组查询)")
|
|
||||||
private String billMonth;
|
|
||||||
}
|
}
|
||||||
-471
@@ -12,9 +12,7 @@ import com.mhd.bms.domain.billManage.repository.facade.IBillManageService;
|
|||||||
import com.mhd.bms.domain.billManage.repository.po.BillManagePO;
|
import com.mhd.bms.domain.billManage.repository.po.BillManagePO;
|
||||||
import com.mhd.bms.domain.billManage.repository.todo.BillDetailDO;
|
import com.mhd.bms.domain.billManage.repository.todo.BillDetailDO;
|
||||||
import com.mhd.bms.domain.billManage.repository.todo.BillManageDO;
|
import com.mhd.bms.domain.billManage.repository.todo.BillManageDO;
|
||||||
import com.mhd.bms.interfaces.dto.billManage.CustomerMonthBillVO;
|
|
||||||
import com.mhd.bms.domain.billOperationLog.entity.BillOperationLog;
|
import com.mhd.bms.domain.billOperationLog.entity.BillOperationLog;
|
||||||
import com.mhd.bms.domain.billOperationLog.repository.po.BillOperationLogPO;
|
|
||||||
import com.mhd.bms.domain.billOperationLog.repository.todo.BillOperationLogDO;
|
import com.mhd.bms.domain.billOperationLog.repository.todo.BillOperationLogDO;
|
||||||
import com.mhd.bms.domain.billOperationLog.service.BillOperationLogDomainService;
|
import com.mhd.bms.domain.billOperationLog.service.BillOperationLogDomainService;
|
||||||
import com.mhd.bms.domain.billingStatement.entity.BillingStatement;
|
import com.mhd.bms.domain.billingStatement.entity.BillingStatement;
|
||||||
@@ -46,7 +44,6 @@ import com.mhd.common.security.utils.SecurityUtils;
|
|||||||
import com.mhd.system.api.SystemServiceFeign;
|
import com.mhd.system.api.SystemServiceFeign;
|
||||||
import com.mhd.system.api.model.LoginUser;
|
import com.mhd.system.api.model.LoginUser;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.BeanUtils;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
@@ -88,10 +85,6 @@ public class BillManageDomainService {
|
|||||||
return billManageService.queryList(billManageDO);
|
return billManageService.queryList(billManageDO);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<BillManagePO> customerMonthlyReport(BillManageDO billManageDO) {
|
|
||||||
return billManageService.customerMonthlyReport(billManageDO);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 新增账单管理
|
* 新增账单管理
|
||||||
@@ -240,124 +233,6 @@ public class BillManageDomainService {
|
|||||||
return flag && flagTwo && three;
|
return flag && flagTwo && three;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Boolean saveBillJob(List<BillingStatementPO> billingStatementPOS,String billingRemark,Date billCreateTime,BillingStatementDTO billingStatementDTO) {
|
|
||||||
// LoginUser loginUser = SecurityUtils.getLoginUser();
|
|
||||||
// if (ObjectUtil.isNull(loginUser)) {
|
|
||||||
//// throw new DigitalLogisticsException(UserError.TIMEOUT);
|
|
||||||
// }
|
|
||||||
BigDecimal taxAmount = billingStatementDTO.getTaxAmount(); // 获取税额
|
|
||||||
Double taxRate = billingStatementDTO.getTaxRate(); // 获取税率
|
|
||||||
BigDecimal taxFreeFee = billingStatementDTO.getTaxFreeFee(); // 获取税免金额
|
|
||||||
String settlementCurrency = billingStatementDTO.getSettlementCurrency(); // 获取结算币种
|
|
||||||
BillManage billManage = new BillManage();
|
|
||||||
billManage.setTaxAmount(taxAmount);
|
|
||||||
billManage.setTaxRate(taxRate);
|
|
||||||
billManage.setTaxFreeFee(taxFreeFee);
|
|
||||||
billManage.setSettlementCurrency(settlementCurrency);
|
|
||||||
// billManage.setCreateBy(loginUser.getUserPo().getUserId());
|
|
||||||
// billManage.setCreateByName(loginUser.getUserPo().getUserName());
|
|
||||||
billManage.setCreateTime(billCreateTime==null ? new Date():billCreateTime);
|
|
||||||
billManage.setDelFlag(1);
|
|
||||||
billManage.setBillNumber(OrderSequence.getOrderCode("ZD"));
|
|
||||||
billManage.setTopOrganizationId(billingStatementDTO.getTopOrganizationId());
|
|
||||||
billManage.setOrganizationId(billingStatementDTO.getOrganizationId());
|
|
||||||
billManage.setOrganizationName(billingStatementDTO.getOrganizationName());
|
|
||||||
billManage.setBillType(billingStatementPOS.get(0).getAccountExpenseType());
|
|
||||||
billManage.setBelongModule(billingStatementPOS.get(0).getBelongModule());
|
|
||||||
billManage.setBelongModuleCode(billingStatementPOS.get(0).getBelongModuleCode());
|
|
||||||
billManage.setSettlementCustomersId(billingStatementPOS.get(0).getSettlementCustomersId());
|
|
||||||
billManage.setSettlementEntity(billingStatementPOS.get(0).getSettlementEntity());
|
|
||||||
billManage.setSettlementCustomersCode(billingStatementPOS.get(0).getSettlementCustomersCode());
|
|
||||||
billManage.setSalesmanId(billingStatementPOS.get(0).getSalesmanId());
|
|
||||||
billManage.setSalesmanName(billingStatementPOS.get(0).getSalesmanName());
|
|
||||||
billManage.setPaymentAccountId(billingStatementPOS.get(0).getPaymentAccountId());
|
|
||||||
billManage.setPaymentAccountName(billingStatementPOS.get(0).getPaymentAccountName());
|
|
||||||
billManage.setBillRemark(billingRemark);
|
|
||||||
//查询结算对象信息
|
|
||||||
SettlementCustomersPO settlementCustomersPO = settlementCustomersDomainService.getInfo(billingStatementPOS.get(0).getSettlementCustomersId());
|
|
||||||
if(null == settlementCustomersPO){
|
|
||||||
throw new ServiceException("结算对象信息未找到");
|
|
||||||
}
|
|
||||||
billManage.setSettlementMethod(settlementCustomersPO.getSettlementMethod());
|
|
||||||
billManage.setSettlementMethodCode(settlementCustomersPO.getSettlementMethodCode());
|
|
||||||
// if(settlementCustomersPO.getMainRole()==1){
|
|
||||||
// billManage.setBillType(1);
|
|
||||||
// }else {
|
|
||||||
// billManage.setBillType(2);
|
|
||||||
// }
|
|
||||||
//计算所有流水列表中的最早周期开始时间和晚周期结束时间
|
|
||||||
List<Date> cycleBeginTimeSet = billingStatementPOS.stream().map(BillingStatementPO::getCycleBeginTime).collect(Collectors.toList());
|
|
||||||
List<Date> cycleEndTimeSet = billingStatementPOS.stream().map(BillingStatementPO::getCycleEndTime).collect(Collectors.toList());
|
|
||||||
cycleBeginTimeSet.removeIf(Objects::isNull);
|
|
||||||
cycleEndTimeSet.removeIf(Objects::isNull);
|
|
||||||
if(cycleBeginTimeSet.size()>0){
|
|
||||||
billManage.setCycleBeginTime(Collections.min(cycleBeginTimeSet));
|
|
||||||
}
|
|
||||||
if(cycleEndTimeSet.size()>0){
|
|
||||||
billManage.setCycleEndTime(Collections.max(cycleEndTimeSet));
|
|
||||||
}
|
|
||||||
//将所有的流水金额相加
|
|
||||||
billManage.setBillTotalAmount(billingStatementPOS.stream().map(BillingStatementPO::getBillingAmount).reduce(BigDecimal.ZERO, BigDecimal::add));
|
|
||||||
billManage.setBillAmount(billManage.getBillTotalAmount());
|
|
||||||
billManage.setBillAmountUnsettled(billManage.getBillTotalAmount());
|
|
||||||
boolean flag = billManageService.save(billManage);
|
|
||||||
billingStatementDTO.setBillManageId(billManage.getBillManageId());
|
|
||||||
List<BillDetail> billDetailList = new ArrayList<>();
|
|
||||||
for (BillingStatementPO billingStatementPO : billingStatementPOS) {
|
|
||||||
//生成对账单详情
|
|
||||||
BillDetail billDetail = new BillDetail();
|
|
||||||
billDetail.setTopOrganizationId(billingStatementPO.getTopOrganizationId());
|
|
||||||
billDetail.setOrganizationId(billingStatementPO.getOrganizationId());
|
|
||||||
billDetail.setOrganizationName(billingStatementPO.getOrganizationName());
|
|
||||||
billDetail.setCreateBy(billManage.getCreateBy());
|
|
||||||
billDetail.setCreateByName(billManage.getCreateByName());
|
|
||||||
billDetail.setCreateTime(billManage.getCreateTime());
|
|
||||||
billDetail.setBillManageId(billManage.getBillManageId());
|
|
||||||
billDetail.setBillNumber(billManage.getBillNumber());
|
|
||||||
billDetail.setBillingStatementId(billingStatementPO.getBillingStatementId());
|
|
||||||
billDetail.setBillingFlow(billingStatementPO.getBillingFlow());
|
|
||||||
billDetail.setBillingTotalAmount(billingStatementPO.getBillingAmount());
|
|
||||||
billDetail.setBillingAmount(billingStatementPO.getBillingAmount());
|
|
||||||
billDetail.setBillType(billingStatementPO.getAccountExpenseType());
|
|
||||||
billDetail.setTaxAmount(billingStatementPO.getTaxAmount());
|
|
||||||
billDetail.setTaxRate(billingStatementPO.getTaxRate());
|
|
||||||
billDetail.setTaxFreeFee(billingStatementPO.getTaxFreeFee());
|
|
||||||
billDetail.setSettlementCurrency(billingStatementPO.getSettlementCurrency());
|
|
||||||
billDetail.setFeeType(billingStatementPO.getFeeType());
|
|
||||||
billDetail.setInvoiceItem(billingStatementPO.getInvoiceItem());
|
|
||||||
billDetail.setInvoiceItemName(billingStatementPO.getInvoiceItemName());
|
|
||||||
billDetailList.add(billDetail);
|
|
||||||
}
|
|
||||||
boolean flagTwo = billDetailDomainService.insertBatch(billDetailList);
|
|
||||||
//保存账单操作记录
|
|
||||||
BillOperationLogDO billOperationLogDO = new BillOperationLogDO();
|
|
||||||
billOperationLogDO.setBillManageId(billManage.getBillManageId());
|
|
||||||
billOperationLogDO.setOperationInfo(StringUtils.format(BillLogsConstants.create_bill_text, billManage.getBillNumber(), billManage.getBillTotalAmount()));
|
|
||||||
billOperationLogDO.setOperationType(1);
|
|
||||||
billOperationLogDO.setCreateByName(billManage.getCreateByName());
|
|
||||||
billOperationLogDO.setUpdateByName(billManage.getUpdateByName());
|
|
||||||
billOperationLogDO.setCreateTime(new Date());
|
|
||||||
billOperationLogDO.setUpdateTime(new Date());
|
|
||||||
billOperationLogDO.setDelFlag(1);
|
|
||||||
billOperationLogDO.setCreateBy(billManage.getCreateBy());
|
|
||||||
billOperationLogDO.setUpdateBy(billManage.getUpdateBy());
|
|
||||||
billOperationLogDO.setTopOrganizationId(billManage.getTopOrganizationId());
|
|
||||||
billOperationLogDO.setOrganizationId(billManage.getOrganizationId());
|
|
||||||
billOperationLogDO.setOrganizationName(billManage.getOrganizationName());
|
|
||||||
|
|
||||||
boolean three = billOperationLogDomainService.saveBillOperationLogJob(billOperationLogDO);
|
|
||||||
//修改流水记录
|
|
||||||
/*billingStatementDTO.getBillingStatementList().forEach(billingStatementADDVO -> {
|
|
||||||
billingStatementMapper.update(null,
|
|
||||||
new LambdaUpdateWrapper<BillingStatement>().set(BillingStatement::getTaxAmount,billingStatementADDVO.getTaxAmount())
|
|
||||||
.set(BillingStatement::getTaxRate,billingStatementADDVO.getTaxRate())
|
|
||||||
.set(BillingStatement::getTaxFreeFee,billingStatementADDVO.getTaxFreeFee())
|
|
||||||
.set(BillingStatement::getSettlementCurrency,billingStatementADDVO.getSettlementCurrency())
|
|
||||||
.eq(BillingStatement::getBillingStatementId,billingStatementADDVO.getBillingStatementId()));
|
|
||||||
});*/
|
|
||||||
return flag && flagTwo && three;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 保存账单
|
* 保存账单
|
||||||
* @param billingStatementDTO
|
* @param billingStatementDTO
|
||||||
@@ -421,64 +296,6 @@ public class BillManageDomainService {
|
|||||||
return saveBill(distinctList,billingStatementDTO.getBillingRemark(),billingStatementDTO.getBillCreateTime(),billingStatementDTO);
|
return saveBill(distinctList,billingStatementDTO.getBillingRemark(),billingStatementDTO.getBillCreateTime(),billingStatementDTO);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Boolean saveJob(BillingStatementDTO billingStatementDTO) {
|
|
||||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
|
||||||
if (ObjectUtil.isNull(loginUser)) {
|
|
||||||
// throw new DigitalLogisticsException(UserError.TIMEOUT);
|
|
||||||
}
|
|
||||||
//根据前端传的流水id,查询计费流水信息列表
|
|
||||||
Set<String> billingSet = Stream.of(billingStatementDTO.getBillingStatementIds().split(",")).collect(Collectors.toSet());
|
|
||||||
BillingStatementDO billingStatementDO = new BillingStatementDO();
|
|
||||||
billingStatementDO.setBillingStatementIdSet(billingSet);
|
|
||||||
List<BillingStatementPO> billingStatementPOS = billingStatementDomainService.queryList(billingStatementDO);
|
|
||||||
|
|
||||||
//获取最新一条的业务员信息
|
|
||||||
String salesmanId = null;
|
|
||||||
String salesmanName = null;
|
|
||||||
if (billingStatementPOS != null && !billingStatementPOS.isEmpty()) {
|
|
||||||
billingStatementPOS.sort((a, b) -> {
|
|
||||||
if (a.getCreateTime() == null && b.getCreateTime() == null) return 0;
|
|
||||||
if (a.getCreateTime() == null) return 1;
|
|
||||||
if (b.getCreateTime() == null) return -1;
|
|
||||||
return b.getCreateTime().compareTo(a.getCreateTime());
|
|
||||||
});
|
|
||||||
salesmanId = billingStatementPOS.get(0).getSalesmanId();
|
|
||||||
salesmanName = billingStatementPOS.get(0).getSalesmanName();
|
|
||||||
}
|
|
||||||
|
|
||||||
List<BillingStatementADDVO> billingStatementList = billingStatementDTO.getBillingStatementList();
|
|
||||||
for (BillingStatementPO billingStatementPO : billingStatementPOS) {
|
|
||||||
String billingStatementId = billingStatementPO.getBillingStatementId() == null ? "" : String.valueOf(billingStatementPO.getBillingStatementId());
|
|
||||||
BillingStatementADDVO billingStatementADDVO = billingStatementList.stream().filter(billingStatementADDVO1 -> billingStatementADDVO1.getBillingStatementId().contains(billingStatementId)).findFirst().orElse(null);
|
|
||||||
billingStatementPO.setTaxAmount(billingStatementADDVO.getTaxAmount()); // 设置税额
|
|
||||||
billingStatementPO.setTaxRate(billingStatementADDVO.getTaxRate()); // 设置税率
|
|
||||||
billingStatementPO.setTaxFreeFee(billingStatementADDVO.getTaxFreeFee()); // 设置税免金额
|
|
||||||
billingStatementPO.setSettlementCurrency(billingStatementADDVO.getSettlementCurrency());//设置结算币种
|
|
||||||
billingStatementPO.setFeeType(billingStatementADDVO.getFeeType());
|
|
||||||
billingStatementPO.setInvoiceItem(billingStatementADDVO.getInvoiceItem());
|
|
||||||
billingStatementPO.setInvoiceItemName(billingStatementADDVO.getInvoiceItemName());
|
|
||||||
billingStatementPO.setBillingAmount(billingStatementADDVO.getBillingAmount());
|
|
||||||
billingStatementPO.setBillingStatementIdStr(billingStatementADDVO.getBillingStatementId());
|
|
||||||
if (salesmanName != null && !salesmanName.isEmpty() && salesmanId != null && !salesmanId.isEmpty()) {
|
|
||||||
billingStatementPO.setSalesmanId(salesmanId);
|
|
||||||
billingStatementPO.setSalesmanName(salesmanName);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
List<BillingStatementPO> distinctList = billingStatementPOS.stream()
|
|
||||||
.filter(Objects::nonNull)
|
|
||||||
.collect(Collectors.toMap(
|
|
||||||
BillingStatementPO::getBillingStatementIdStr, // key:去重字段
|
|
||||||
po -> po, // value:对象本身
|
|
||||||
(existing, replacement) -> existing // 重复时保留第一个
|
|
||||||
))
|
|
||||||
.values()
|
|
||||||
.stream().collect(Collectors.toList());
|
|
||||||
if(billingStatementPOS==null || billingStatementPOS.size()==0){
|
|
||||||
throw new ServiceException("所选流水信息未找到");
|
|
||||||
}
|
|
||||||
return saveBillJob(distinctList,billingStatementDTO.getBillingRemark(),billingStatementDTO.getBillCreateTime(),billingStatementDTO);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public List<BillManage> queryListLambda(LambdaQueryWrapper<BillManage> queryWrapper) {
|
public List<BillManage> queryListLambda(LambdaQueryWrapper<BillManage> queryWrapper) {
|
||||||
return billManageService.list(queryWrapper);
|
return billManageService.list(queryWrapper);
|
||||||
@@ -561,32 +378,6 @@ public class BillManageDomainService {
|
|||||||
return flag && three;
|
return flag && three;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Boolean confirmBillingJob(BillManageDO billManageDO) {
|
|
||||||
//直接修改状态到未收款3状态
|
|
||||||
// LoginUser loginUser = SecurityUtils.getLoginUser();
|
|
||||||
// if (ObjectUtil.isNull(loginUser)) {
|
|
||||||
// throw new DigitalLogisticsException(UserError.TIMEOUT);
|
|
||||||
// }
|
|
||||||
LambdaUpdateWrapper<BillManage> updateWrapper = new LambdaUpdateWrapper<>();
|
|
||||||
updateWrapper.in(BillManage::getBillManageId,billManageDO.getBillManageIdSet())
|
|
||||||
.set(BillManage::getBillStep,4)
|
|
||||||
.set(BillManage::getBillState,3)
|
|
||||||
// .set(BillManage::getUpdateBy,loginUser.getUserPo().getUserId())
|
|
||||||
// .set(BillManage::getUpdateByName,loginUser.getUserPo().getUserName())
|
|
||||||
.set(BillManage::getUpdateTime,new Date());
|
|
||||||
boolean flag = billManageService.update(updateWrapper);
|
|
||||||
//保存账单操作记录
|
|
||||||
BillOperationLogDO billOperationLogDO = new BillOperationLogDO();
|
|
||||||
billOperationLogDO.setBillManageIdSet(billManageDO.getBillManageIdSet());
|
|
||||||
billOperationLogDO.setOperationInfo(BillLogsConstants.confirm_bill_text);
|
|
||||||
billOperationLogDO.setOperationType(3);
|
|
||||||
billOperationLogDO.setOrganizationId(billManageDO.getOrganizationId());
|
|
||||||
billOperationLogDO.setOrganizationName(billManageDO.getOrganizationName());
|
|
||||||
billOperationLogDO.setTopOrganizationId(billManageDO.getTopOrganizationId());
|
|
||||||
boolean three = billOperationLogDomainService.saveBillOperationLogBatchJob(billOperationLogDO);
|
|
||||||
return flag && three;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public int editIsInvoice(String billNumber, Integer isInvoice, String invoiceId, String invoiceMakeTime,String applyNumber)
|
public int editIsInvoice(String billNumber, Integer isInvoice, String invoiceId, String invoiceMakeTime,String applyNumber)
|
||||||
{
|
{
|
||||||
@@ -713,261 +504,6 @@ public class BillManageDomainService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 撤销收款:账单恢复为收款为0状态并保存撤销收款操作日志
|
|
||||||
*/
|
|
||||||
public Boolean cancelCollectionInfo(List<ReceiptDetail> receiptDetails) {
|
|
||||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
|
||||||
if (ObjectUtil.isNull(loginUser)) {
|
|
||||||
throw new DigitalLogisticsException(UserError.TIMEOUT);
|
|
||||||
}
|
|
||||||
//按账单分组收款明细(一个账单可能对应多个收款单)
|
|
||||||
Map<Long, List<ReceiptDetail>> billDetailMap = receiptDetails.stream().collect(Collectors.groupingBy(ReceiptDetail::getBillManageId));
|
|
||||||
LambdaQueryWrapper<BillManage> queryWrapper = new LambdaQueryWrapper<>();
|
|
||||||
queryWrapper.in(BillManage::getBillManageId,billDetailMap.keySet());
|
|
||||||
List<BillManage> billManageList = billManageService.list(queryWrapper);
|
|
||||||
if(billManageList == null || billManageList.size()==0){
|
|
||||||
throw new ServiceException("账单信息未找到");
|
|
||||||
}
|
|
||||||
List<BillManage> billManageListSave = new ArrayList<>();
|
|
||||||
List<BillOperationLog> billOperationLogSave = new ArrayList<>();
|
|
||||||
for (BillManage billManage : billManageList) {
|
|
||||||
List<ReceiptDetail> receiptDetailList = billDetailMap.get(billManage.getBillManageId());
|
|
||||||
if(null == receiptDetailList || receiptDetailList.size() == 0){
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
BillManage billManageSave = new BillManage();
|
|
||||||
billManageSave.setBillManageId(billManage.getBillManageId());
|
|
||||||
//账单恢复为收款为0状态
|
|
||||||
billManageSave.setBillAmountSettlement(BigDecimal.ZERO);
|
|
||||||
billManageSave.setBillAmountUnsettled(billManage.getBillAmount());
|
|
||||||
billManageSave.setActualReceivedAmount(BigDecimal.ZERO);
|
|
||||||
billManageSave.setSettlementDiscountsAmount(BigDecimal.ZERO);
|
|
||||||
billManageSave.setBillState(3);
|
|
||||||
billManageSave.setUpdateBy(loginUser.getUserPo().getUserId());
|
|
||||||
billManageSave.setUpdateByName(loginUser.getUserPo().getUserName());
|
|
||||||
billManageSave.setUpdateTime(new Date());
|
|
||||||
billManageListSave.add(billManageSave);
|
|
||||||
//汇总该账单本次撤销的收款金额与收款单号
|
|
||||||
BigDecimal collectedDiscount = receiptDetailList.stream().map(info -> info.getCollectedDiscount() == null ? BigDecimal.ZERO : info.getCollectedDiscount()).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
||||||
BigDecimal collectedAmount = receiptDetailList.stream().map(info -> info.getCollectedAmount() == null ? BigDecimal.ZERO : info.getCollectedAmount()).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
||||||
BigDecimal all = collectedAmount.add(collectedDiscount);
|
|
||||||
String collectionNums = receiptDetailList.stream().map(ReceiptDetail::getCollectionNum).filter(StringUtils::isNotEmpty).distinct().collect(Collectors.joining(","));
|
|
||||||
//保存账单操作记录
|
|
||||||
BillOperationLog billOperationLog = new BillOperationLog();
|
|
||||||
billOperationLog.setBillManageId(billManage.getBillManageId());
|
|
||||||
billOperationLog.setOperationInfo(StringUtils.format(BillLogsConstants.cancel_collection_bill_text,collectionNums,all,collectedAmount,collectedDiscount));
|
|
||||||
billOperationLog.setOperationType(12);
|
|
||||||
billOperationLog.setDelFlag(1);
|
|
||||||
billOperationLogSave.add(billOperationLog);
|
|
||||||
}
|
|
||||||
Boolean three = billOperationLogDomainService.insertBatch(billOperationLogSave);
|
|
||||||
Boolean flag = billManageService.updateBatchById(billManageListSave);
|
|
||||||
return flag && three;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 应收账单红冲:生成金额为负数的红冲账单对冲原账单,不操作收款单等数据(支持批量)
|
|
||||||
*/
|
|
||||||
public Boolean redFlushBill(BillManageDTO billManageDTO) {
|
|
||||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
|
||||||
if (ObjectUtil.isNull(loginUser)) {
|
|
||||||
throw new DigitalLogisticsException(UserError.TIMEOUT);
|
|
||||||
}
|
|
||||||
if (StringUtils.isEmpty(billManageDTO.getBillManageIds())) {
|
|
||||||
throw new ServiceException("账单id不能为空");
|
|
||||||
}
|
|
||||||
Set<Long> billManageIdSet = Stream.of(billManageDTO.getBillManageIds().split(",")).filter(StringUtils::isNotEmpty).map(String::trim).map(Long::valueOf).collect(Collectors.toSet());
|
|
||||||
if (billManageIdSet.size() == 0) {
|
|
||||||
throw new ServiceException("账单id不能为空");
|
|
||||||
}
|
|
||||||
//查询账单信息
|
|
||||||
LambdaQueryWrapper<BillManage> queryWrapperBill = new LambdaQueryWrapper<>();
|
|
||||||
queryWrapperBill.in(BillManage::getBillManageId, billManageIdSet);
|
|
||||||
queryWrapperBill.eq(BillManage::getDelFlag, 1);
|
|
||||||
List<BillManage> billManageList = billManageService.list(queryWrapperBill);
|
|
||||||
if (null == billManageList || billManageList.size() == 0) {
|
|
||||||
throw new ServiceException("账单信息未找到");
|
|
||||||
}
|
|
||||||
if (billManageList.size() != billManageIdSet.size()) {
|
|
||||||
throw new ServiceException("部分账单信息未找到,请刷新后重试");
|
|
||||||
}
|
|
||||||
//逐个账单红冲,任一账单校验不通过时事务整体回滚
|
|
||||||
Boolean flag = true;
|
|
||||||
for (BillManage originalBill : billManageList) {
|
|
||||||
flag = redFlushSingleBill(originalBill, billManageDTO.getRedFlushRemark(), loginUser) && flag;
|
|
||||||
}
|
|
||||||
return flag;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 红冲单个账单:生成金额为负数的红冲账单对冲原账单,同步镜像计费流水与账单明细
|
|
||||||
*/
|
|
||||||
private Boolean redFlushSingleBill(BillManage originalBill, String redFlushRemark, LoginUser loginUser) {
|
|
||||||
if (ObjectUtil.equal(originalBill.getBillType(), 2)) {
|
|
||||||
throw new ServiceException("账单" + originalBill.getBillNumber() + "为付款账单,仅支持应收账单红冲");
|
|
||||||
}
|
|
||||||
if (!ObjectUtil.equal(originalBill.getBillState(), 5)) {
|
|
||||||
throw new ServiceException("账单" + originalBill.getBillNumber() + "不是已收款状态,仅已收款状态的账单可以红冲,请刷新后重试");
|
|
||||||
}
|
|
||||||
//校验账单是否已红冲,避免重复生成红冲账单
|
|
||||||
BillOperationLogDO redFlushLogQuery = new BillOperationLogDO();
|
|
||||||
redFlushLogQuery.setBillManageId(originalBill.getBillManageId());
|
|
||||||
redFlushLogQuery.setOperationType(13);
|
|
||||||
List<BillOperationLogPO> redFlushLogList = billOperationLogDomainService.queryList(redFlushLogQuery);
|
|
||||||
if (null != redFlushLogList && redFlushLogList.stream().anyMatch(info -> ObjectUtil.equal(info.getDelFlag(), 1))) {
|
|
||||||
throw new ServiceException("账单" + originalBill.getBillNumber() + "已红冲,不能重复红冲");
|
|
||||||
}
|
|
||||||
//生成红冲账单编号
|
|
||||||
String billNumber = OrderSequence.getOrderCode("ZD");
|
|
||||||
BigDecimal redFlushAmount = negateAmount(originalBill.getBillAmount());
|
|
||||||
//构建红冲账单,金额全部取负对冲原账单
|
|
||||||
BillManage redBill = new BillManage();
|
|
||||||
BeanUtils.copyProperties(originalBill, redBill);
|
|
||||||
redBill.setBillManageId(null);
|
|
||||||
redBill.setBillNumber(billNumber);
|
|
||||||
redBill.setBillAmount(redFlushAmount);
|
|
||||||
redBill.setBillTotalAmount(negateAmount(originalBill.getBillTotalAmount()));
|
|
||||||
redBill.setBillDiscountAmount(negateAmount(originalBill.getBillDiscountAmount()));
|
|
||||||
redBill.setBillAmountSettlement(negateAmount(originalBill.getBillAmountSettlement()));
|
|
||||||
redBill.setBillAmountUnsettled(BigDecimal.ZERO);
|
|
||||||
redBill.setActualReceivedAmount(negateAmount(originalBill.getActualReceivedAmount()));
|
|
||||||
redBill.setSettlementDiscountsAmount(negateAmount(originalBill.getSettlementDiscountsAmount()));
|
|
||||||
redBill.setTaxAmount(negateAmount(originalBill.getTaxAmount()));
|
|
||||||
redBill.setTaxFreeFee(negateAmount(originalBill.getTaxFreeFee()));
|
|
||||||
//红冲账单状态为红冲、已核对无误
|
|
||||||
redBill.setBillState(8);
|
|
||||||
redBill.setBillStep(4);
|
|
||||||
redBill.setReconciliationStatus(4);
|
|
||||||
redBill.setSettlementTime(new Date());
|
|
||||||
//重置对账、审核、开票、同步等状态,红冲账单不需要再走这些流程
|
|
||||||
redBill.setBillExpectedAmount(null);
|
|
||||||
redBill.setReconciliationOpinion(null);
|
|
||||||
redBill.setVoucherAddress(null);
|
|
||||||
redBill.setFinancialReviewFlag(null);
|
|
||||||
redBill.setFinancialReviewOpinion(null);
|
|
||||||
redBill.setIsInvoice(0);
|
|
||||||
redBill.setInvoiceId(null);
|
|
||||||
redBill.setInvoiceMakeTime(null);
|
|
||||||
redBill.setApplyNumber(null);
|
|
||||||
redBill.setSynchronousStatus(0);
|
|
||||||
redBill.setSynchronousTime(null);
|
|
||||||
redBill.setNcId(null);
|
|
||||||
redBill.setSkSynchronousStatus(0);
|
|
||||||
redBill.setSkSynchronousTime(null);
|
|
||||||
redBill.setSkNcId(null);
|
|
||||||
//红冲原因写入账单备注
|
|
||||||
String billRemark = "红冲原账单编号:" + originalBill.getBillNumber();
|
|
||||||
if (StringUtils.isNotEmpty(redFlushRemark)) {
|
|
||||||
billRemark = billRemark + ",红冲原因:" + redFlushRemark;
|
|
||||||
}
|
|
||||||
redBill.setBillRemark(billRemark);
|
|
||||||
redBill.setDelFlag(1);
|
|
||||||
redBill.setCreateBy(loginUser.getUserid());
|
|
||||||
redBill.setCreateByName(loginUser.getUserPo().getUserName());
|
|
||||||
redBill.setCreateTime(new Date());
|
|
||||||
redBill.setUpdateBy(loginUser.getUserid());
|
|
||||||
redBill.setUpdateByName(loginUser.getUserPo().getUserName());
|
|
||||||
redBill.setUpdateTime(new Date());
|
|
||||||
Boolean flag = billManageService.save(redBill);
|
|
||||||
if (!flag || null == redBill.getBillManageId()) {
|
|
||||||
throw new ServiceException("生成红冲账单失败");
|
|
||||||
}
|
|
||||||
//镜像红冲计费流水(金额取负),并记录原流水id与新流水的映射
|
|
||||||
Map<Long, BillingStatementDO> statementMapping = new HashMap<>();
|
|
||||||
List<BillingStatementPO> originalStatementList = billingStatementDomainService.getDetailsByManageId(originalBill.getBillManageId());
|
|
||||||
if (null != originalStatementList && originalStatementList.size() > 0) {
|
|
||||||
for (BillingStatementPO originalStatement : originalStatementList) {
|
|
||||||
BillingStatementDO redStatement = new BillingStatementDO();
|
|
||||||
BeanUtils.copyProperties(originalStatement, redStatement);
|
|
||||||
redStatement.setBillingStatementId(null);
|
|
||||||
redStatement.setBillManageId(redBill.getBillManageId());
|
|
||||||
redStatement.setBillingFlow(OrderSequence.getOrderCode("JFLS"));
|
|
||||||
redStatement.setBillingAmount(negateAmount(originalStatement.getBillingAmount()));
|
|
||||||
redStatement.setTaxAmount(negateAmount(originalStatement.getTaxAmount()));
|
|
||||||
redStatement.setTaxFreeFee(negateAmount(originalStatement.getTaxFreeFee()));
|
|
||||||
redStatement.setBillingState(3);
|
|
||||||
redStatement.setRedFlushState(1);
|
|
||||||
redStatement.setRedFlushRemark("红冲自计费流水:" + originalStatement.getBillingFlow());
|
|
||||||
redStatement.setReviewRemarks(null);
|
|
||||||
redStatement.setBusinessDocumentId(null);
|
|
||||||
redStatement.setDelFlag(1);
|
|
||||||
redStatement.setTopOrganizationId(loginUser.getUserPo().getTopOrganizationId());
|
|
||||||
redStatement.setOrganizationId(loginUser.getUserPo().getOrganizationId());
|
|
||||||
redStatement.setOrganizationName(loginUser.getUserPo().getOrganizationName());
|
|
||||||
redStatement.setCreateBy(loginUser.getUserid());
|
|
||||||
redStatement.setCreateByName(loginUser.getUserPo().getUserName());
|
|
||||||
redStatement.setCreateTime(new Date());
|
|
||||||
redStatement.setUpdateBy(loginUser.getUserid());
|
|
||||||
redStatement.setUpdateByName(loginUser.getUserPo().getUserName());
|
|
||||||
redStatement.setUpdateTime(new Date());
|
|
||||||
redStatement.setBillingStatementId(billingStatementDomainService.insertAndReturnId(redStatement));
|
|
||||||
statementMapping.put(originalStatement.getBillingStatementId(), redStatement);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//镜像红冲账单明细(金额取负),并关联新计费流水
|
|
||||||
Boolean flagTwo = true;
|
|
||||||
LambdaQueryWrapper<BillDetail> detailQueryWrapper = new LambdaQueryWrapper<>();
|
|
||||||
detailQueryWrapper.eq(BillDetail::getBillManageId, originalBill.getBillManageId());
|
|
||||||
detailQueryWrapper.eq(BillDetail::getDelFlag, 1);
|
|
||||||
List<BillDetail> originalDetailList = billDetailDomainService.queryByLambda(detailQueryWrapper);
|
|
||||||
if (null != originalDetailList && originalDetailList.size() > 0) {
|
|
||||||
List<BillDetail> redDetailList = new ArrayList<>();
|
|
||||||
for (BillDetail originalDetail : originalDetailList) {
|
|
||||||
BillDetail redDetail = new BillDetail();
|
|
||||||
BeanUtils.copyProperties(originalDetail, redDetail);
|
|
||||||
redDetail.setBillDetailId(null);
|
|
||||||
redDetail.setBillManageId(redBill.getBillManageId());
|
|
||||||
redDetail.setBillNumber(billNumber);
|
|
||||||
redDetail.setBillingTotalAmount(negateAmount(originalDetail.getBillingTotalAmount()));
|
|
||||||
redDetail.setBillingAmount(negateAmount(originalDetail.getBillingAmount()));
|
|
||||||
redDetail.setBillingDiscountAmount(negateAmount(originalDetail.getBillingDiscountAmount()));
|
|
||||||
redDetail.setTaxAmount(negateAmount(originalDetail.getTaxAmount()));
|
|
||||||
redDetail.setTaxFreeFee(negateAmount(originalDetail.getTaxFreeFee()));
|
|
||||||
redDetail.setBillingExpectedAmount(null);
|
|
||||||
BillingStatementDO redStatement = statementMapping.get(originalDetail.getBillingStatementId());
|
|
||||||
if (null != redStatement) {
|
|
||||||
redDetail.setBillingStatementId(redStatement.getBillingStatementId());
|
|
||||||
redDetail.setBillingFlow(redStatement.getBillingFlow());
|
|
||||||
} else {
|
|
||||||
redDetail.setBillingStatementId(null);
|
|
||||||
redDetail.setBillingFlow(null);
|
|
||||||
}
|
|
||||||
redDetail.setDelFlag(1);
|
|
||||||
redDetail.setCreateBy(loginUser.getUserid());
|
|
||||||
redDetail.setCreateByName(loginUser.getUserPo().getUserName());
|
|
||||||
redDetail.setCreateTime(new Date());
|
|
||||||
redDetail.setUpdateBy(loginUser.getUserid());
|
|
||||||
redDetail.setUpdateByName(loginUser.getUserPo().getUserName());
|
|
||||||
redDetail.setUpdateTime(new Date());
|
|
||||||
redDetailList.add(redDetail);
|
|
||||||
}
|
|
||||||
flagTwo = billDetailDomainService.insertBatch(redDetailList);
|
|
||||||
}
|
|
||||||
//红冲账单保存创建账单操作日志
|
|
||||||
BillOperationLogDO redBillLog = new BillOperationLogDO();
|
|
||||||
redBillLog.setBillManageId(redBill.getBillManageId());
|
|
||||||
redBillLog.setOperationInfo(StringUtils.format(BillLogsConstants.create_bill_text, billNumber, redFlushAmount));
|
|
||||||
redBillLog.setOperationType(1);
|
|
||||||
Boolean flagThree = billOperationLogDomainService.saveBillOperationLog(redBillLog);
|
|
||||||
//原账单保存红冲操作日志
|
|
||||||
BillOperationLogDO originalBillLog = new BillOperationLogDO();
|
|
||||||
originalBillLog.setBillManageId(originalBill.getBillManageId());
|
|
||||||
originalBillLog.setOperationInfo(StringUtils.format(BillLogsConstants.red_flush_bill_text, billNumber, null == redFlushAmount ? BigDecimal.ZERO : redFlushAmount.abs()));
|
|
||||||
originalBillLog.setOperationType(13);
|
|
||||||
Boolean flagFour = billOperationLogDomainService.saveBillOperationLog(originalBillLog);
|
|
||||||
return flag && flagTwo && flagThree && flagFour;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 金额取负(空值返回null)
|
|
||||||
*/
|
|
||||||
private BigDecimal negateAmount(BigDecimal amount) {
|
|
||||||
return null == amount ? null : amount.negate();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 更改账单状态(付款)
|
* 更改账单状态(付款)
|
||||||
*/
|
*/
|
||||||
@@ -1064,11 +600,4 @@ public class BillManageDomainService {
|
|||||||
{
|
{
|
||||||
return billManageService.synchronousNcSK(businessDocumentDetaliIds);
|
return billManageService.synchronousNcSK(businessDocumentDetaliIds);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 客户每月账单分组查询
|
|
||||||
*/
|
|
||||||
public List<CustomerMonthBillVO> queryCustomerMonthBillList(BillManageDO billManageDO) {
|
|
||||||
return billManageService.queryCustomerMonthBillList(billManageDO);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
+2
-2
@@ -42,8 +42,8 @@ public class BillOperationLog extends BaseVOEntity{
|
|||||||
@Excel(name = "账单管理id")
|
@Excel(name = "账单管理id")
|
||||||
private Long billManageId;
|
private Long billManageId;
|
||||||
|
|
||||||
@ApiModelProperty("操作类型(1-创建账单,2-调整账单,3-确认账单,4-发起对账,5-客户确认,6-财务审核,7-收款,8-作废账单,9-删除账单,10-退款,11-付款,12-撤销收款,13-红冲)")
|
@ApiModelProperty("操作类型(1-创建账单,2-调整账单,3-确认账单,4-发起对账,5-客户确认,6-财务审核,7-收款,8-作废账单,9-删除账单,10-退款,11-付款)")
|
||||||
@Excel(name = "操作类型", readConverterExp = "1=-创建账单,2-调整账单,3-确认账单,4-发起对账,5-客户确认,6-财务审核,7-收款,8-作废账单,9-删除账单,10-退款,11-付款,12-撤销收款,13-红冲")
|
@Excel(name = "操作类型", readConverterExp = "1=-创建账单,2-调整账单,3-确认账单,4-发起对账,5-客户确认,6-财务审核,7-收款,8-作废账单,9-删除账单,10-退款,11-付款")
|
||||||
private Integer operationType;
|
private Integer operationType;
|
||||||
|
|
||||||
@ApiModelProperty("操作信息")
|
@ApiModelProperty("操作信息")
|
||||||
|
|||||||
+2
-2
@@ -41,8 +41,8 @@ public class BillOperationLogPO extends BaseVOEntity{
|
|||||||
@Excel(name = "账单管理id")
|
@Excel(name = "账单管理id")
|
||||||
private Long billManageId;
|
private Long billManageId;
|
||||||
|
|
||||||
@ApiModelProperty("操作类型(1-创建账单,2-调整账单,3-确认账单,4-发起对账,5-客户确认,6-财务审核,7-收款,8-作废账单,9-删除账单,10-退款,11-付款,12-撤销收款,13-红冲)")
|
@ApiModelProperty("操作类型(1-创建账单,2-调整账单,3-确认账单,4-发起对账,5-客户确认,6-财务审核,7-收款,8-作废账单,9-删除账单,10-退款,11-付款)")
|
||||||
@Excel(name = "操作类型", readConverterExp = "1=-创建账单,2-调整账单,3-确认账单,4-发起对账,5-客户确认,6-财务审核,7-收款,8-作废账单,9-删除账单,10-退款,11-付款,12-撤销收款,13-红冲")
|
@Excel(name = "操作类型", readConverterExp = "1=-创建账单,2-调整账单,3-确认账单,4-发起对账,5-客户确认,6-财务审核,7-收款,8-作废账单,9-删除账单,10-退款,11-付款")
|
||||||
private Integer operationType;
|
private Integer operationType;
|
||||||
|
|
||||||
@ApiModelProperty("操作信息")
|
@ApiModelProperty("操作信息")
|
||||||
|
|||||||
+2
-2
@@ -42,8 +42,8 @@ public class BillOperationLogDO extends BaseVOEntity{
|
|||||||
@Excel(name = "账单管理id")
|
@Excel(name = "账单管理id")
|
||||||
private Long billManageId;
|
private Long billManageId;
|
||||||
|
|
||||||
@ApiModelProperty("操作类型(1-创建账单,2-调整账单,3-确认账单,4-发起对账,5-客户确认,6-财务审核,7-收款,8-作废账单,9-删除账单,10-退款,11-付款,12-撤销收款,13-红冲)")
|
@ApiModelProperty("操作类型(1-创建账单,2-调整账单,3-确认账单,4-发起对账,5-客户确认,6-财务审核,7-收款,8-作废账单,9-删除账单,10-退款,11-付款)")
|
||||||
@Excel(name = "操作类型", readConverterExp = "1=-创建账单,2-调整账单,3-确认账单,4-发起对账,5-客户确认,6-财务审核,7-收款,8-作废账单,9-删除账单,10-退款,11-付款,12-撤销收款,13-红冲")
|
@Excel(name = "操作类型", readConverterExp = "1=-创建账单,2-调整账单,3-确认账单,4-发起对账,5-客户确认,6-财务审核,7-收款,8-作废账单,9-删除账单,10-退款,11-付款")
|
||||||
private Integer operationType;
|
private Integer operationType;
|
||||||
|
|
||||||
@ApiModelProperty("操作信息")
|
@ApiModelProperty("操作信息")
|
||||||
|
|||||||
-40
@@ -95,12 +95,6 @@ public class BillOperationLogDomainService {
|
|||||||
return billOperationLogService.insert(billOperationLogDO);
|
return billOperationLogService.insert(billOperationLogDO);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Boolean saveBillOperationLogJob(BillOperationLogDO billOperationLogDO) {
|
|
||||||
|
|
||||||
billOperationLogDO.setDelFlag(1);
|
|
||||||
return billOperationLogService.insert(billOperationLogDO);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 批量保存操作日志
|
* 批量保存操作日志
|
||||||
@@ -139,40 +133,6 @@ public class BillOperationLogDomainService {
|
|||||||
return billOperationLogService.saveBatch(saveList);
|
return billOperationLogService.saveBatch(saveList);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Boolean saveBillOperationLogBatchJob(BillOperationLogDO billOperationLogDO) {
|
|
||||||
// LoginUser loginUser = SecurityUtils.getLoginUser();
|
|
||||||
// if (ObjectUtil.isNull(loginUser)) {
|
|
||||||
// throw new DigitalLogisticsException(UserError.TIMEOUT);
|
|
||||||
// }
|
|
||||||
if(billOperationLogDO.getBillManageIdSet()==null || billOperationLogDO.getBillManageIdSet().size()==0){
|
|
||||||
throw new ServiceException("账单集合不能为空");
|
|
||||||
}
|
|
||||||
// String userName = loginUser.getUserPo().getUserName();
|
|
||||||
// // 获取登录人id
|
|
||||||
// Long userId = loginUser.getUserid();
|
|
||||||
BillOperationLogDO common = new BillOperationLogDO();
|
|
||||||
// common.setCreateByName(userName);
|
|
||||||
// common.setUpdateByName(userName);
|
|
||||||
common.setCreateTime(new Date());
|
|
||||||
common.setUpdateTime(new Date());
|
|
||||||
common.setDelFlag(1);
|
|
||||||
// common.setCreateBy(userId);
|
|
||||||
// common.setUpdateBy(userId);
|
|
||||||
// common.setTopOrganizationId(loginUser.getUserPo().getTopOrganizationId());
|
|
||||||
// common.setOrganizationId(loginUser.getUserPo().getOrganizationId());
|
|
||||||
// common.setOrganizationName(loginUser.getUserPo().getOrganizationName());
|
|
||||||
common.setOperationType(billOperationLogDO.getOperationType());
|
|
||||||
common.setOperationInfo(billOperationLogDO.getOperationInfo());
|
|
||||||
List<BillOperationLog> saveList = new ArrayList<>();
|
|
||||||
for (String billManageId : billOperationLogDO.getBillManageIdSet()) {
|
|
||||||
BillOperationLog save = new BillOperationLog();
|
|
||||||
BeanUtils.copyProperties(common, save);
|
|
||||||
save.setBillManageId(Long.valueOf(billManageId));
|
|
||||||
saveList.add(save);
|
|
||||||
}
|
|
||||||
return billOperationLogService.saveBatch(saveList);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 批量保存数据
|
* 批量保存数据
|
||||||
|
|||||||
-81
@@ -171,48 +171,6 @@ public class BillingStatementDomainService {
|
|||||||
return billingStatementService.updateBatchById(billingStatements);
|
return billingStatementService.updateBatchById(billingStatements);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Boolean reviewBillingJob(BillingStatementDTO billingStatementDTO) {
|
|
||||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
|
||||||
if (ObjectUtil.isNull(loginUser)) {
|
|
||||||
// throw new DigitalLogisticsException(UserError.TIMEOUT);
|
|
||||||
}
|
|
||||||
List<BillingStatement> billingStatements = new ArrayList<>();
|
|
||||||
Set<String> billingSet = Stream.of(billingStatementDTO.getBillingStatementIds().split(",")).collect(Collectors.toSet());
|
|
||||||
for (String billingId : billingSet) {
|
|
||||||
Long billingStatementId = Long.valueOf(billingId);
|
|
||||||
BillingStatementPO billingStatementPO = billingStatementService.getInfo(billingStatementId);
|
|
||||||
if(null == billingStatementPO){
|
|
||||||
throw new ServiceException("流水不存在");
|
|
||||||
}
|
|
||||||
if(billingStatementPO.getBillingState()!=1){
|
|
||||||
throw new ServiceException("该计费流水状态不为待审核,不能进行审核");
|
|
||||||
}
|
|
||||||
if(billingStatementPO.getRedFlushState()==2){
|
|
||||||
throw new ServiceException("计费流水"+ billingStatementPO.getBillingFlow() +"已红冲,不能进行审核");
|
|
||||||
}
|
|
||||||
BillingStatement billingStatement = new BillingStatement();
|
|
||||||
billingStatement.setBillingStatementId(billingStatementId);
|
|
||||||
billingStatement.setReviewRemarks(billingStatementDTO.getReviewRemarks());
|
|
||||||
if(billingStatementDTO.getAuditOperation()==1){
|
|
||||||
//审核通过
|
|
||||||
billingStatement.setBillingState(2);
|
|
||||||
}else {
|
|
||||||
//审核不通过
|
|
||||||
billingStatement.setBillingState(4);
|
|
||||||
//计费流水审核不通过时,修改业务单据中的状态到已生效
|
|
||||||
BusinessDocumentDO businessDocumentDO = new BusinessDocumentDO();
|
|
||||||
businessDocumentDO.setBusinessDocumentId(billingStatementPO.getBusinessDocumentId());
|
|
||||||
businessDocumentDO.setBusinessState(2);
|
|
||||||
businessDocumentService.update(businessDocumentDO);
|
|
||||||
}
|
|
||||||
billingStatement.setUpdateTime(new Date());
|
|
||||||
// billingStatement.setUpdateBy(loginUser.getUserPo().getUserId());
|
|
||||||
// billingStatement.setUpdateByName(loginUser.getUserPo().getUserName());
|
|
||||||
billingStatements.add(billingStatement);
|
|
||||||
}
|
|
||||||
return billingStatementService.updateBatchById(billingStatements);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 批量红冲
|
* 批量红冲
|
||||||
@@ -341,45 +299,6 @@ public class BillingStatementDomainService {
|
|||||||
return update;
|
return update;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Boolean updateBillingStateJob(BillingStatementDTO billingStatementDTO) {
|
|
||||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
|
||||||
if (ObjectUtil.isNull(loginUser)) {
|
|
||||||
// throw new DigitalLogisticsException(UserError.TIMEOUT);
|
|
||||||
}
|
|
||||||
Set<String> billingSet = Stream.of(billingStatementDTO.getBillingStatementIds().split(",")).collect(Collectors.toSet());
|
|
||||||
LambdaUpdateWrapper<BillingStatement> updateWrapper = new LambdaUpdateWrapper<>();
|
|
||||||
updateWrapper.in(BillingStatement::getBillingStatementId,billingSet);
|
|
||||||
|
|
||||||
updateWrapper.set(BillingStatement::getBillingState,billingStatementDTO.getBillingState());
|
|
||||||
// updateWrapper.set(BillingStatement::getUpdateBy,loginUser.getUserPo().getUserId());
|
|
||||||
updateWrapper.set(BillingStatement::getUpdateTime,new Date());
|
|
||||||
// updateWrapper.set(BillingStatement::getUpdateByName,loginUser.getUserPo().getUserName());
|
|
||||||
updateWrapper.set(BillingStatement::getBillManageId,billingStatementDTO.getBillManageId());
|
|
||||||
boolean update = billingStatementService.update(updateWrapper);
|
|
||||||
List<BillingStatementADDVO> billingStatementList = billingStatementDTO.getBillingStatementList();
|
|
||||||
for (BillingStatementADDVO billingStatementADDVO : billingStatementList) {
|
|
||||||
String billingStatementIds = billingStatementADDVO.getBillingStatementId();
|
|
||||||
Set<String> billings = Stream.of(billingStatementIds.split(",")).collect(Collectors.toSet());
|
|
||||||
if (billings != null && billings.size() > 0) {
|
|
||||||
for (String billing : billings) {
|
|
||||||
Long billingStatementId = Long.valueOf(billing);
|
|
||||||
Double taxRate = billingStatementADDVO.getTaxRate();
|
|
||||||
BillingStatement billingStatement = billingStatementService.getById(billingStatementId);
|
|
||||||
if (billingStatement != null) {
|
|
||||||
BigDecimal billingAmount = billingStatement.getBillingAmount();
|
|
||||||
BigDecimal taxAmount = billingAmount.divide(BigDecimal.ONE.add(new BigDecimal(taxRate).divide(BigDecimal.valueOf(100))),10, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(taxRate).divide(BigDecimal.valueOf(100))).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
||||||
BigDecimal taxFreeFee = billingAmount.subtract(taxAmount);
|
|
||||||
billingStatement.setTaxAmount(taxAmount);
|
|
||||||
billingStatement.setTaxFreeFee(taxFreeFee);
|
|
||||||
billingStatement.setTaxRate(taxRate);
|
|
||||||
billingStatementService.updateById(billingStatement);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return update;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public Boolean nullifyByIds(BillingStatementDTO billingStatementDTO) {
|
public Boolean nullifyByIds(BillingStatementDTO billingStatementDTO) {
|
||||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||||
|
|||||||
-2
@@ -26,8 +26,6 @@ public interface IBmsInvoiceListService extends IService<BmsInvoiceList> {
|
|||||||
|
|
||||||
void addReceivableBill(BmsInvoiceListAddDTO tmsInvoiceListAddDTO);
|
void addReceivableBill(BmsInvoiceListAddDTO tmsInvoiceListAddDTO);
|
||||||
|
|
||||||
void addReceivableBillJob(BmsInvoiceListAddDTO tmsInvoiceListAddDTO);
|
|
||||||
|
|
||||||
void update(BmsInvoiceListDTO tmsInvoiceListDTO);
|
void update(BmsInvoiceListDTO tmsInvoiceListDTO);
|
||||||
|
|
||||||
int delete(List<String> ids);
|
int delete(List<String> ids);
|
||||||
|
|||||||
-109
@@ -188,76 +188,6 @@ public class BmsInvoiceListServiceImpl extends ServiceImpl<BmsInvoiceListMapper,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// BillManage billManage = billManageMapper.selectById(bmsInvoiceListAddDTO.getBillManageId());
|
|
||||||
// if (billManage != null) {
|
|
||||||
// billManage.setIsInvoice(1);
|
|
||||||
// billManage.setInvoiceId(bmsInvoiceList.getId().toString());
|
|
||||||
// billManage.setApplyNumber(bmsInvoiceList.getApplyNumber());
|
|
||||||
// billManageMapper.updateById(billManage);
|
|
||||||
// }
|
|
||||||
List<Long> billManageIds = bmsInvoiceListAddDTO.getBillManageIds();
|
|
||||||
if (billManageIds != null && billManageIds.size() > 0){
|
|
||||||
} else {
|
|
||||||
billManageIds = new ArrayList<>();
|
|
||||||
billManageIds.add(bmsInvoiceListAddDTO.getBillManageId());
|
|
||||||
}
|
|
||||||
List<BillManage> billManages = billManageMapper.selectList(new LambdaQueryWrapper<BillManage>().in(BillManage::getBillManageId, billManageIds));
|
|
||||||
if (billManages != null && billManages.size() > 0) {
|
|
||||||
for (BillManage billManage : billManages) {
|
|
||||||
billManage.setIsInvoice(1);
|
|
||||||
billManage.setInvoiceId(bmsInvoiceList.getId().toString());
|
|
||||||
billManage.setApplyNumber(bmsInvoiceList.getApplyNumber());
|
|
||||||
billManageMapper.updateById(billManage);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/*AjaxResult ajaxResult = financeServiceFeign.editIsInvoice(transportationId,1,bmsInvoiceList.getId(),"",bmsInvoiceList.getApplyNumber());
|
|
||||||
if(!"200".equals(String.valueOf(ajaxResult.get("code")))){
|
|
||||||
throw new com.mhd.common.core.exception.ServiceException(ajaxResult.get("msg").toString());
|
|
||||||
}*/
|
|
||||||
}
|
|
||||||
|
|
||||||
@Transactional
|
|
||||||
@Override
|
|
||||||
public void addReceivableBillJob(BmsInvoiceListAddDTO bmsInvoiceListAddDTO) {
|
|
||||||
//获取登录人
|
|
||||||
// WlhyLoginUser sysUser = SecurityUtils.getLoginUser().getWlhyLoginUser();
|
|
||||||
// if (null == sysUser) {
|
|
||||||
// throw new ServiceException("sysUser是空值!");
|
|
||||||
// }
|
|
||||||
/*if (StringUtils.isEmpty(bmsInvoiceListAddDTO.getInvoiceTitle())){
|
|
||||||
throw new ServiceException("发票抬头不能为空!");
|
|
||||||
}*/
|
|
||||||
bmsInvoiceListAddDTO.setInvoiceValue(bmsInvoiceListAddDTO.getBillAmount());
|
|
||||||
BmsInvoiceList bmsInvoiceList = new BmsInvoiceList(); // 销项发票表
|
|
||||||
BeanUtils.copyProperties(bmsInvoiceListAddDTO, bmsInvoiceList);
|
|
||||||
// String createBy = sysUser.getId(); // 创建人ID
|
|
||||||
|
|
||||||
if(StringUtils.isNotBlank(bmsInvoiceListAddDTO.getCompanyName())){
|
|
||||||
bmsInvoiceList.setShipperName(bmsInvoiceListAddDTO.getCompanyName());
|
|
||||||
bmsInvoiceList.setCompanyName(bmsInvoiceListAddDTO.getCompanyName());
|
|
||||||
}
|
|
||||||
// 保存【销项发票表】数据
|
|
||||||
Long listId = saveBmsInvoiceListJob(bmsInvoiceList, bmsInvoiceListAddDTO, null, null);
|
|
||||||
|
|
||||||
//预保存发票明细信息
|
|
||||||
if(ObjectUtil.isNotNull(listId)){
|
|
||||||
List<BmsMakeOutInvoice> bmsMakeOutInvoices = bmsInvoiceListAddDTO.getBmsMakeOutInvoices();
|
|
||||||
if (ObjectUtil.isNotNull(bmsMakeOutInvoices) && bmsMakeOutInvoices.size() > 0) {
|
|
||||||
for (BmsMakeOutInvoice bmsMakeOutInvoice : bmsMakeOutInvoices) {
|
|
||||||
bmsMakeOutInvoice.setInvoiceId(listId);
|
|
||||||
//bmsMakeOutInvoice.setCreateBy(sysUser.getId());
|
|
||||||
bmsMakeOutInvoice.setCreateTime(new Date());
|
|
||||||
bmsMakeOutInvoiceMapper.insert(bmsMakeOutInvoice);
|
|
||||||
for (BmsMakeOutInvoiceItem bmsMakeOutInvoiceItem : bmsMakeOutInvoice.getBmsMakeOutInvoiceItems()) {
|
|
||||||
bmsMakeOutInvoiceItem.setMakeId(bmsMakeOutInvoice.getId());
|
|
||||||
//bmsMakeOutInvoiceItem.setCreateBy(sysUser.getId());
|
|
||||||
bmsMakeOutInvoiceItem.setCreateTime(new Date());
|
|
||||||
bmsMakeOutInvoiceItemMapper.insert(bmsMakeOutInvoiceItem);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// BillManage billManage = billManageMapper.selectById(bmsInvoiceListAddDTO.getBillManageId());
|
// BillManage billManage = billManageMapper.selectById(bmsInvoiceListAddDTO.getBillManageId());
|
||||||
// if (billManage != null) {
|
// if (billManage != null) {
|
||||||
// billManage.setIsInvoice(1);
|
// billManage.setIsInvoice(1);
|
||||||
@@ -1002,43 +932,4 @@ public class BmsInvoiceListServiceImpl extends ServiceImpl<BmsInvoiceListMapper,
|
|||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Long saveBmsInvoiceListJob(BmsInvoiceList bmsInvoiceList, BmsInvoiceListAddDTO bmsInvoiceListAddDTO, WlhyLoginUser sysUser, String createBy){
|
|
||||||
|
|
||||||
bmsInvoiceList.setReceivingAddressId(bmsInvoiceListAddDTO.getReceivingAddressId());
|
|
||||||
|
|
||||||
//bmsInvoiceList.setCreateBy(createBy);
|
|
||||||
bmsInvoiceList.setApplyNumber(OrderSequence.getOrderCode("XF"));
|
|
||||||
bmsInvoiceList.setCreateTime(new Date());
|
|
||||||
bmsInvoiceList.setInvoiceApplyTime(new Date());
|
|
||||||
// bmsInvoiceList.setApplicantId(sysUser.getId());
|
|
||||||
// bmsInvoiceList.setRealCreateBy(sysUser.getId());
|
|
||||||
// bmsInvoiceList.setRealCreateName(sysUser.getRealname());
|
|
||||||
bmsInvoiceList.setCompanyName(bmsInvoiceListAddDTO.getSettlementEntity());
|
|
||||||
// 设置组织相关字段:从当前登录用户获取组织信息
|
|
||||||
// LoginUser loginUser = SecurityUtils.getLoginUser();
|
|
||||||
// if (loginUser != null && loginUser.getUserPo() != null) {
|
|
||||||
// // 设置组织ID
|
|
||||||
// if (loginUser.getUserPo().getOrganizationId() != null) {
|
|
||||||
// bmsInvoiceList.setOrganizationId(loginUser.getUserPo().getOrganizationId());
|
|
||||||
// }
|
|
||||||
// // 设置组织名称
|
|
||||||
// if (StringUtils.isNotBlank(loginUser.getUserPo().getOrganizationName())) {
|
|
||||||
// bmsInvoiceList.setOrganizationName(loginUser.getUserPo().getOrganizationName());
|
|
||||||
// }
|
|
||||||
// // 设置一级组织ID
|
|
||||||
// if (loginUser.getUserPo().getTopOrganizationId() != null) {
|
|
||||||
// bmsInvoiceList.setTopOrganizationId(loginUser.getUserPo().getTopOrganizationId());
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
boolean saveSuccess = this.save(bmsInvoiceList);
|
|
||||||
// 3. 插入成功后,直接从实体对象获取ID(已被MyBatis-Plus自动赋值)
|
|
||||||
if (saveSuccess) {
|
|
||||||
Long id = bmsInvoiceList.getId();
|
|
||||||
System.out.println("插入成功,生成的ID:" + id);
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
-14
@@ -79,19 +79,5 @@ public class BmsInvoiceListAddDTO implements Serializable {
|
|||||||
@ApiModelProperty(value = "对账单id列表")
|
@ApiModelProperty(value = "对账单id列表")
|
||||||
@Excel(name = "对账单id列表", width = 15)
|
@Excel(name = "对账单id列表", width = 15)
|
||||||
private List<Long> billManageIds;
|
private List<Long> billManageIds;
|
||||||
/**组织ID*/
|
|
||||||
@ApiModelProperty(value = "组织ID")
|
|
||||||
@Excel(name = "组织ID", width = 15)
|
|
||||||
private Long organizationId;
|
|
||||||
|
|
||||||
/**组织名称*/
|
|
||||||
@ApiModelProperty(value = "组织名称")
|
|
||||||
@Excel(name = "组织名称", width = 15)
|
|
||||||
private String organizationName;
|
|
||||||
|
|
||||||
/**一级组织ID*/
|
|
||||||
@ApiModelProperty(value = "一级组织ID")
|
|
||||||
@Excel(name = "一级组织ID", width = 15)
|
|
||||||
private Long topOrganizationId;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
-28
@@ -1,22 +1,16 @@
|
|||||||
package com.mhd.bms.domain.receiptManage.service;
|
package com.mhd.bms.domain.receiptManage.service;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import cn.hutool.core.util.ObjectUtil;
|
|
||||||
import com.mhd.bms.domain.receiptManage.entity.ReceiptDetail;
|
import com.mhd.bms.domain.receiptManage.entity.ReceiptDetail;
|
||||||
import com.mhd.bms.domain.receiptManage.repository.facade.IReceiptDetailService;
|
import com.mhd.bms.domain.receiptManage.repository.facade.IReceiptDetailService;
|
||||||
import com.mhd.bms.domain.receiptManage.repository.po.ReceiptDetailPO;
|
import com.mhd.bms.domain.receiptManage.repository.po.ReceiptDetailPO;
|
||||||
import com.mhd.bms.domain.receiptManage.repository.todo.ReceiptDetailDO;
|
import com.mhd.bms.domain.receiptManage.repository.todo.ReceiptDetailDO;
|
||||||
import com.mhd.common.core.exception.digitalLogisticsException.DigitalLogisticsException;
|
|
||||||
import com.mhd.common.core.exception.digitalLogisticsException.UserError;
|
|
||||||
import com.mhd.common.security.utils.SecurityUtils;
|
|
||||||
import com.mhd.system.api.model.LoginUser;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.BeanUtils;
|
import org.springframework.beans.BeanUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Date;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
@@ -101,28 +95,6 @@ public class ReceiptDetailDomainService {
|
|||||||
public List<ReceiptDetail> queryListByIdSet(Set<Long> orderIdSet) {
|
public List<ReceiptDetail> queryListByIdSet(Set<Long> orderIdSet) {
|
||||||
LambdaQueryWrapper<ReceiptDetail> queryWrapperDetail = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<ReceiptDetail> queryWrapperDetail = new LambdaQueryWrapper<>();
|
||||||
queryWrapperDetail.in(ReceiptDetail::getReceiptManageId, orderIdSet);
|
queryWrapperDetail.in(ReceiptDetail::getReceiptManageId, orderIdSet);
|
||||||
queryWrapperDetail.eq(ReceiptDetail::getDelFlag, 1);
|
|
||||||
return receiptDetailService.list(queryWrapperDetail);
|
return receiptDetailService.list(queryWrapperDetail);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 撤销收款:批量逻辑删除收款明细
|
|
||||||
*/
|
|
||||||
public Boolean cancelCollectionDetails(List<ReceiptDetail> receiptDetails) {
|
|
||||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
|
||||||
if (ObjectUtil.isNull(loginUser)) {
|
|
||||||
throw new DigitalLogisticsException(UserError.TIMEOUT);
|
|
||||||
}
|
|
||||||
List<ReceiptDetail> receiptDetailSaveList = new ArrayList<>();
|
|
||||||
for (ReceiptDetail receiptDetail : receiptDetails) {
|
|
||||||
ReceiptDetail receiptDetailSave = new ReceiptDetail();
|
|
||||||
receiptDetailSave.setReceiptDetailId(receiptDetail.getReceiptDetailId());
|
|
||||||
receiptDetailSave.setDelFlag(2);
|
|
||||||
receiptDetailSave.setUpdateBy(loginUser.getUserPo().getUserId());
|
|
||||||
receiptDetailSave.setUpdateByName(loginUser.getUserPo().getUserName());
|
|
||||||
receiptDetailSave.setUpdateTime(new Date());
|
|
||||||
receiptDetailSaveList.add(receiptDetailSave);
|
|
||||||
}
|
|
||||||
return receiptDetailService.updateBatchById(receiptDetailSaveList);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
-128
@@ -42,9 +42,7 @@ import org.springframework.stereotype.Service;
|
|||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
@@ -302,132 +300,6 @@ public class ReceiptManageDomainService {
|
|||||||
return flag && flagTwo && flagThree;
|
return flag && flagTwo && flagThree;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 撤销收款
|
|
||||||
*/
|
|
||||||
public Boolean cancelCollection(ReceiptManageDO receiptManageDO) {
|
|
||||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
|
||||||
if (ObjectUtil.isNull(loginUser)) {
|
|
||||||
throw new DigitalLogisticsException(UserError.TIMEOUT);
|
|
||||||
}
|
|
||||||
if (StringUtils.isEmpty(receiptManageDO.getBillManageIds())) {
|
|
||||||
throw new ServiceException("撤销账单不能为空");
|
|
||||||
}
|
|
||||||
Set<Long> billManageIdSet = Stream.of(receiptManageDO.getBillManageIds().split(",")).filter(StringUtils::isNotEmpty).map(String::trim).map(Long::valueOf).collect(Collectors.toSet());
|
|
||||||
if (billManageIdSet.size() == 0) {
|
|
||||||
throw new ServiceException("撤销账单不能为空");
|
|
||||||
}
|
|
||||||
//查询账单信息
|
|
||||||
LambdaQueryWrapper<BillManage> queryWrapperBill = new LambdaQueryWrapper<>();
|
|
||||||
queryWrapperBill.in(BillManage::getBillManageId, billManageIdSet);
|
|
||||||
queryWrapperBill.eq(BillManage::getDelFlag, 1);
|
|
||||||
List<BillManage> billManageList = billManageDomainService.queryListLambda(queryWrapperBill);
|
|
||||||
if (null == billManageList || billManageList.size() == 0) {
|
|
||||||
throw new ServiceException("账单信息未找到");
|
|
||||||
}
|
|
||||||
if (billManageList.size() != billManageIdSet.size()) {
|
|
||||||
throw new ServiceException("部分账单信息未找到,请刷新后重试");
|
|
||||||
}
|
|
||||||
//查询账单的全部有效收款明细(一个账单可能对应多个收款单)
|
|
||||||
LambdaQueryWrapper<ReceiptDetail> queryWrapperDetail = new LambdaQueryWrapper<>();
|
|
||||||
queryWrapperDetail.in(ReceiptDetail::getBillManageId, billManageIdSet);
|
|
||||||
queryWrapperDetail.eq(ReceiptDetail::getDelFlag, 1);
|
|
||||||
List<ReceiptDetail> receiptDetails = receiptDetailDomainService.queryListByLambda(queryWrapperDetail);
|
|
||||||
if (null == receiptDetails || receiptDetails.size() == 0) {
|
|
||||||
throw new ServiceException("账单收款记录不存在或已撤销,请刷新后重试");
|
|
||||||
}
|
|
||||||
//校验每个账单都有收款记录
|
|
||||||
Map<Long, List<ReceiptDetail>> billDetailMap = receiptDetails.stream().collect(Collectors.groupingBy(ReceiptDetail::getBillManageId));
|
|
||||||
for (BillManage billManage : billManageList) {
|
|
||||||
if (!billDetailMap.containsKey(billManage.getBillManageId())) {
|
|
||||||
throw new ServiceException("账单" + billManage.getBillNumber() + "收款记录不存在或已撤销,请刷新后重试");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//校验收款单退款状态,已退款的收款单不能撤销收款
|
|
||||||
Set<Long> receiptManageIdSet = receiptDetails.stream().map(ReceiptDetail::getReceiptManageId).collect(Collectors.toSet());
|
|
||||||
LambdaQueryWrapper<ReceiptManage> queryWrapperManage = new LambdaQueryWrapper<>();
|
|
||||||
queryWrapperManage.in(ReceiptManage::getReceiptManageId, receiptManageIdSet);
|
|
||||||
List<ReceiptManage> receiptManageList = receiptManageService.list(queryWrapperManage);
|
|
||||||
if (null != receiptManageList) {
|
|
||||||
ReceiptManage refundManage = receiptManageList.stream().filter(info -> ObjectUtil.equal(info.getPaymentStatus(), 2)).findAny().orElse(null);
|
|
||||||
if (null != refundManage) {
|
|
||||||
throw new ServiceException("收款单" + refundManage.getCollectionNum() + "已退款,无法撤销收款");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//账单恢复为收款为0状态并保存撤销收款操作日志
|
|
||||||
Boolean flagTwo = billManageDomainService.cancelCollectionInfo(receiptDetails);
|
|
||||||
//逻辑删除收款明细
|
|
||||||
Boolean flag = receiptDetailDomainService.cancelCollectionDetails(receiptDetails);
|
|
||||||
//按剩余明细重新计算涉及的收款单金额,明细已全部撤销时逻辑删除收款单
|
|
||||||
Boolean flagThree = true;
|
|
||||||
for (Long receiptManageId : receiptManageIdSet) {
|
|
||||||
flagThree = updateReceiptManageByCancel(receiptManageId) && flagThree;
|
|
||||||
}
|
|
||||||
return flag && flagTwo && flagThree;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 撤销收款后重新计算收款单信息,收款明细已全部撤销时逻辑删除收款单
|
|
||||||
*/
|
|
||||||
private Boolean updateReceiptManageByCancel(Long receiptManageId) {
|
|
||||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
|
||||||
if (ObjectUtil.isNull(loginUser)) {
|
|
||||||
throw new DigitalLogisticsException(UserError.TIMEOUT);
|
|
||||||
}
|
|
||||||
//查询收款单下剩余未撤销的收款明细
|
|
||||||
LambdaQueryWrapper<ReceiptDetail> queryWrapperDetail = new LambdaQueryWrapper<>();
|
|
||||||
queryWrapperDetail.eq(ReceiptDetail::getReceiptManageId, receiptManageId);
|
|
||||||
queryWrapperDetail.eq(ReceiptDetail::getDelFlag, 1);
|
|
||||||
List<ReceiptDetail> receiptDetailList = receiptDetailDomainService.queryListByLambda(queryWrapperDetail);
|
|
||||||
ReceiptManage receiptManageSave = new ReceiptManage();
|
|
||||||
receiptManageSave.setReceiptManageId(receiptManageId);
|
|
||||||
receiptManageSave.setUpdateBy(loginUser.getUserPo().getUserId());
|
|
||||||
receiptManageSave.setUpdateByName(loginUser.getUserPo().getUserName());
|
|
||||||
receiptManageSave.setUpdateTime(new Date());
|
|
||||||
if (null == receiptDetailList || receiptDetailList.size() == 0) {
|
|
||||||
//收款明细已全部撤销,逻辑删除收款单
|
|
||||||
receiptManageSave.setDelFlag(2);
|
|
||||||
return receiptManageService.updateById(receiptManageSave);
|
|
||||||
}
|
|
||||||
//按剩余明细重新计算收款单金额
|
|
||||||
BigDecimal billAmount = receiptDetailList.stream().map(ReceiptDetail::getBillAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
||||||
BigDecimal collectedDiscount = receiptDetailList.stream().map(ReceiptDetail::getCollectedDiscount).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
||||||
BigDecimal collectedAmount = receiptDetailList.stream().map(ReceiptDetail::getCollectedAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
||||||
BigDecimal uncollectedAmount = receiptDetailList.stream().map(ReceiptDetail::getBillAmountUnsettledResidue).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
||||||
BigDecimal billAmountUnsettled = receiptDetailList.stream().map(ReceiptDetail::getBillAmountUnsettled).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
||||||
receiptManageSave.setBillAmount(billAmount);
|
|
||||||
receiptManageSave.setCollectedDiscount(collectedDiscount);
|
|
||||||
receiptManageSave.setCollectedAmount(collectedAmount);
|
|
||||||
receiptManageSave.setUncollectedAmount(uncollectedAmount);
|
|
||||||
receiptManageSave.setBillAmountUnsettled(billAmountUnsettled);
|
|
||||||
//账单金额 = 已收金额 + 剩余未收金额 + 收款优惠金额 + 收款金额
|
|
||||||
receiptManageSave.setBillAmountSettlement(billAmount.subtract(uncollectedAmount).subtract(collectedDiscount).subtract(collectedAmount));
|
|
||||||
return receiptManageService.updateById(receiptManageSave);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 撤销收款-查询账单涉及的收款单id(用于加锁,防止并发撤销时收款单金额重算冲突)
|
|
||||||
*/
|
|
||||||
public Set<Long> queryReceiptManageIdsByBillManageIds(String billManageIds) {
|
|
||||||
Set<Long> receiptManageIdSet = new HashSet<>();
|
|
||||||
if (StringUtils.isEmpty(billManageIds)) {
|
|
||||||
return receiptManageIdSet;
|
|
||||||
}
|
|
||||||
Set<Long> billManageIdSet = Stream.of(billManageIds.split(",")).filter(StringUtils::isNotEmpty).map(String::trim).map(Long::valueOf).collect(Collectors.toSet());
|
|
||||||
if (billManageIdSet.size() == 0) {
|
|
||||||
return receiptManageIdSet;
|
|
||||||
}
|
|
||||||
LambdaQueryWrapper<ReceiptDetail> queryWrapperDetail = new LambdaQueryWrapper<>();
|
|
||||||
queryWrapperDetail.in(ReceiptDetail::getBillManageId, billManageIdSet);
|
|
||||||
queryWrapperDetail.eq(ReceiptDetail::getDelFlag, 1);
|
|
||||||
List<ReceiptDetail> receiptDetails = receiptDetailDomainService.queryListByLambda(queryWrapperDetail);
|
|
||||||
if (null == receiptDetails || receiptDetails.size() == 0) {
|
|
||||||
return receiptManageIdSet;
|
|
||||||
}
|
|
||||||
receiptDetails.forEach(receiptDetail -> receiptManageIdSet.add(receiptDetail.getReceiptManageId()));
|
|
||||||
return receiptManageIdSet;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询收款单详情
|
* 查询收款单详情
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -88,14 +88,6 @@ public class BillLogsConstants
|
|||||||
public static final String refund_bill_text = "退款单号:{},退款金额:{}元";
|
public static final String refund_bill_text = "退款单号:{},退款金额:{}元";
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 撤销收款
|
|
||||||
* 收款单号:{},撤销收款金额:{}元(实收{}元,优惠{}元)
|
|
||||||
*/
|
|
||||||
public static final String cancel_collection_bill_title = "撤销收款";
|
|
||||||
public static final String cancel_collection_bill_text = "收款单号:{},撤销收款金额:{}元(实收{}元,优惠{}元)";
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 付款
|
* 付款
|
||||||
* 付款单号:{},付款金额:{}元
|
* 付款单号:{},付款金额:{}元
|
||||||
@@ -112,11 +104,4 @@ public class BillLogsConstants
|
|||||||
public static final String copy_bill_text = "原账单编号:{},新账单编号:{}";
|
public static final String copy_bill_text = "原账单编号:{},新账单编号:{}";
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 红冲账单
|
|
||||||
* 红冲账单编号:{},红冲金额:{}元
|
|
||||||
*/
|
|
||||||
public static final String red_flush_bill_title = "红冲账单";
|
|
||||||
public static final String red_flush_bill_text = "红冲账单编号:{},红冲金额:{}元";
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -47,8 +47,8 @@ public class BillManageDTO extends BaseVOEntity{
|
|||||||
@Excel(name = "账单类型", readConverterExp = "1=-应收,2-应付")
|
@Excel(name = "账单类型", readConverterExp = "1=-应收,2-应付")
|
||||||
private Integer billType;
|
private Integer billType;
|
||||||
|
|
||||||
@ApiModelProperty("账单状态(1-未确认,2-对账中,3-未收款/付款,4-部分收款/付款,5-已收款/付款,6-已作废,7-已退款,8-红冲)")
|
@ApiModelProperty("账单状态(1-未确认,2-对账中,3-未收款/付款,4-部分收款/付款,5-已收款/付款,6-已作废,7-已退款)")
|
||||||
@Excel(name = "账单状态", readConverterExp = "1=-未确认,2-对账中,3-未收款/付款,4-部分收款/付款,5-已收款/付款,6-已作废,7-已退款,8-红冲")
|
@Excel(name = "账单状态", readConverterExp = "1=-未确认,2-对账中,3-未收款/付款,4-部分收款/付款,5-已收款/付款,6-已作废,7-已退款")
|
||||||
private Integer billState;
|
private Integer billState;
|
||||||
|
|
||||||
@ApiModelProperty("账单流程节点(1-发起对账,2-客户确认,3-财务审核,4-收款/付款)")
|
@ApiModelProperty("账单流程节点(1-发起对账,2-客户确认,3-财务审核,4-收款/付款)")
|
||||||
@@ -276,11 +276,4 @@ public class BillManageDTO extends BaseVOEntity{
|
|||||||
private String paymentAccountId;
|
private String paymentAccountId;
|
||||||
@ApiModelProperty("收款帐户名称")
|
@ApiModelProperty("收款帐户名称")
|
||||||
private String paymentAccountName;
|
private String paymentAccountName;
|
||||||
|
|
||||||
@ApiModelProperty("账单月份(yyyy-MM,按创建时间月份筛选,用于客户月账单分组查询)")
|
|
||||||
private String billMonth;
|
|
||||||
|
|
||||||
@ApiModelProperty("红冲原因")
|
|
||||||
@Excel(name = "红冲原因")
|
|
||||||
private String redFlushRemark;
|
|
||||||
}
|
}
|
||||||
@@ -28,7 +28,7 @@ public class BillManageExportVO {
|
|||||||
@Excel(name = "账单类型", readConverterExp = "1=-应收,2-应付")
|
@Excel(name = "账单类型", readConverterExp = "1=-应收,2-应付")
|
||||||
private Integer billType;
|
private Integer billType;
|
||||||
|
|
||||||
@Excel(name = "账单状态", readConverterExp = "1=-未确认,2-对账中,3-未收款/付款,4-部分收款/付款,5-已收款/付款,6-已作废,7-已退款,8-红冲")
|
@Excel(name = "账单状态", readConverterExp = "1=-未确认,2-对账中,3-未收款/付款,4-部分收款/付款,5-已收款/付款,6-已作废,7-已退款")
|
||||||
private Integer billState;
|
private Integer billState;
|
||||||
|
|
||||||
@Excel(name = "账单流程节点", readConverterExp = "1=-发起对账,2-客户确认,3-财务审核,4-收款/付款")
|
@Excel(name = "账单流程节点", readConverterExp = "1=-发起对账,2-客户确认,3-财务审核,4-收款/付款")
|
||||||
|
|||||||
@@ -1,65 +0,0 @@
|
|||||||
package com.mhd.bms.interfaces.dto.billManage;
|
|
||||||
|
|
||||||
import io.swagger.annotations.ApiModel;
|
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
import java.math.BigDecimal;
|
|
||||||
|
|
||||||
@Data
|
|
||||||
@ApiModel(value = "客户月账单VO", description = "客户每月账单分组统计信息")
|
|
||||||
public class CustomerMonthBillVO implements Serializable {
|
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
|
|
||||||
@ApiModelProperty("结算对象id")
|
|
||||||
private Long settlementCustomersId;
|
|
||||||
|
|
||||||
@ApiModelProperty("结算对象code")
|
|
||||||
private String settlementCustomersCode;
|
|
||||||
|
|
||||||
@ApiModelProperty("结算对象/客户名称")
|
|
||||||
private String settlementEntity;
|
|
||||||
|
|
||||||
@ApiModelProperty("结算主体id")
|
|
||||||
private Long settlementEntityId;
|
|
||||||
|
|
||||||
@ApiModelProperty("结算主体")
|
|
||||||
private String settlementEntityName;
|
|
||||||
|
|
||||||
@ApiModelProperty("组织ID")
|
|
||||||
private Long organizationId;
|
|
||||||
|
|
||||||
@ApiModelProperty("组织名称")
|
|
||||||
private String organizationName;
|
|
||||||
|
|
||||||
@ApiModelProperty("账单月份(yyyy-MM)")
|
|
||||||
private String billMonth;
|
|
||||||
|
|
||||||
@ApiModelProperty("账单总金额合计")
|
|
||||||
private BigDecimal totalBillAmount;
|
|
||||||
|
|
||||||
@ApiModelProperty("已收金额合计")
|
|
||||||
private BigDecimal totalSettledAmount;
|
|
||||||
|
|
||||||
@ApiModelProperty("未收金额合计")
|
|
||||||
private BigDecimal totalUnsettledAmount;
|
|
||||||
|
|
||||||
@ApiModelProperty("账单数量")
|
|
||||||
private Integer billCount;
|
|
||||||
|
|
||||||
@ApiModelProperty("付款状态(1-未付款,2-部分付款,3-已付款)")
|
|
||||||
private Integer paymentStatus;
|
|
||||||
|
|
||||||
@ApiModelProperty("付款状态名称")
|
|
||||||
private String paymentStatusName;
|
|
||||||
|
|
||||||
@ApiModelProperty("应收账单id列表(逗号拼接)")
|
|
||||||
private String billManageIds;
|
|
||||||
|
|
||||||
@ApiModelProperty("结算方式")
|
|
||||||
private String settlementMethod;
|
|
||||||
|
|
||||||
@ApiModelProperty("默认结算币种")
|
|
||||||
private String settlementCurrency;
|
|
||||||
}
|
|
||||||
+2
-2
@@ -40,8 +40,8 @@ public class BillOperationLogDTO extends BaseVOEntity{
|
|||||||
@Excel(name = "账单管理id")
|
@Excel(name = "账单管理id")
|
||||||
private Long billManageId;
|
private Long billManageId;
|
||||||
|
|
||||||
@ApiModelProperty("操作类型(1-创建账单,2-调整账单,3-确认账单,4-发起对账,5-客户确认,6-财务审核,7-收款,8-作废账单,9-删除账单,10-退款,11-付款,12-撤销收款,13-红冲)")
|
@ApiModelProperty("操作类型(1-创建账单,2-调整账单,3-确认账单,4-发起对账,5-客户确认,6-财务审核,7-收款,8-作废账单,9-删除账单,10-退款,11-付款)")
|
||||||
@Excel(name = "操作类型", readConverterExp = "1=-创建账单,2-调整账单,3-确认账单,4-发起对账,5-客户确认,6-财务审核,7-收款,8-作废账单,9-删除账单,10-退款,11-付款,12-撤销收款,13-红冲")
|
@Excel(name = "操作类型", readConverterExp = "1=-创建账单,2-调整账单,3-确认账单,4-发起对账,5-客户确认,6-财务审核,7-收款,8-作废账单,9-删除账单,10-退款,11-付款")
|
||||||
private Integer operationType;
|
private Integer operationType;
|
||||||
|
|
||||||
@ApiModelProperty("操作信息")
|
@ApiModelProperty("操作信息")
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ package com.mhd.bms.interfaces.facadeApi;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.math.BigDecimal;
|
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
@@ -18,7 +17,6 @@ import com.mhd.bms.infrastructure.utils.UniqueKeyUtil;
|
|||||||
import com.mhd.bms.interfaces.dto.billingStatement.BillingStatementDTO;
|
import com.mhd.bms.interfaces.dto.billingStatement.BillingStatementDTO;
|
||||||
import com.mhd.bms.interfaces.dto.billManage.BillManageExportVO;
|
import com.mhd.bms.interfaces.dto.billManage.BillManageExportVO;
|
||||||
import com.mhd.common.core.exception.ServiceException;
|
import com.mhd.common.core.exception.ServiceException;
|
||||||
import com.mhd.common.core.utils.StringUtils;
|
|
||||||
import com.mhd.common.core.utils.poi.ExcelUtil;
|
import com.mhd.common.core.utils.poi.ExcelUtil;
|
||||||
import com.mhd.common.log.annotation.Log;
|
import com.mhd.common.log.annotation.Log;
|
||||||
import com.mhd.common.log.enums.BusinessType;
|
import com.mhd.common.log.enums.BusinessType;
|
||||||
@@ -33,17 +31,9 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import com.mhd.bms.interfaces.dto.billManage.BillManageDTO;
|
import com.mhd.bms.interfaces.dto.billManage.BillManageDTO;
|
||||||
import com.mhd.bms.interfaces.dto.billManage.CustomerMonthBillVO;
|
|
||||||
import com.mhd.bms.domain.billManage.repository.todo.BillManageDO;
|
import com.mhd.bms.domain.billManage.repository.todo.BillManageDO;
|
||||||
import com.mhd.bms.domain.billManage.repository.po.BillManagePO;
|
import com.mhd.bms.domain.billManage.repository.po.BillManagePO;
|
||||||
import com.mhd.bms.interfaces.assembler.billManage.BillManageAssembler;
|
import com.mhd.bms.interfaces.assembler.billManage.BillManageAssembler;
|
||||||
import com.mhd.bms.domain.receiptManage.service.ReceiptDetailDomainService;
|
|
||||||
import com.mhd.bms.domain.receiptManage.entity.ReceiptDetail;
|
|
||||||
import com.mhd.bms.domain.receiptManage.entity.ReceiptManage;
|
|
||||||
import com.mhd.bms.domain.receiptManage.repository.facade.IReceiptManageService;
|
|
||||||
import com.mhd.bms.domain.receiptManage.repository.po.ReceiptManagePO;
|
|
||||||
import com.mhd.bms.domain.receiptManage.repository.po.ReceiptDetailPO;
|
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import com.mhd.common.core.web.controller.BaseController;
|
import com.mhd.common.core.web.controller.BaseController;
|
||||||
@@ -64,10 +54,6 @@ public class BillManageApi extends BaseController{
|
|||||||
private BillManageApplicationService billManageApplicationService;
|
private BillManageApplicationService billManageApplicationService;
|
||||||
@Autowired
|
@Autowired
|
||||||
private RedisLock redisLock;
|
private RedisLock redisLock;
|
||||||
@Autowired
|
|
||||||
private ReceiptDetailDomainService receiptDetailDomainService;
|
|
||||||
@Autowired
|
|
||||||
private IReceiptManageService receiptManageService;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 分页查询账单管理列表
|
* 分页查询账单管理列表
|
||||||
@@ -98,171 +84,6 @@ public class BillManageApi extends BaseController{
|
|||||||
return AjaxResult.success(billManageApplicationService.listCount(billManageDO));
|
return AjaxResult.success(billManageApplicationService.listCount(billManageDO));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 客户每月账单分组列表(应收)
|
|
||||||
*/
|
|
||||||
@ApiOperation("客户每月账单分组列表")
|
|
||||||
@GetMapping("/receivableCustomerMonthList")
|
|
||||||
public TableDataInfo receivableCustomerMonthList(BillManageDTO billManageDTO)
|
|
||||||
{
|
|
||||||
BillManageDO billManageDO = new BillManageDO();
|
|
||||||
BeanUtils.copyProperties(billManageDTO, billManageDO);
|
|
||||||
billManageDO.setBillType(1);
|
|
||||||
startPage();
|
|
||||||
List<CustomerMonthBillVO> list = billManageApplicationService.queryCustomerMonthBillList(billManageDO);
|
|
||||||
return getDataTable(list);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 客户每月账单分组列表统计(应收)
|
|
||||||
*/
|
|
||||||
@ApiOperation("客户每月账单分组列表统计")
|
|
||||||
@GetMapping(value = "/receivableCustomerMonthListCount")
|
|
||||||
public AjaxResult receivableCustomerMonthListCount(BillManageDTO billManageDTO)
|
|
||||||
{
|
|
||||||
BillManageDO billManageDO = new BillManageDO();
|
|
||||||
BeanUtils.copyProperties(billManageDTO, billManageDO);
|
|
||||||
billManageDO.setBillType(1);
|
|
||||||
List<CustomerMonthBillVO> list = billManageApplicationService.queryCustomerMonthBillList(billManageDO);
|
|
||||||
BigDecimal totalBillAmount = list.stream()
|
|
||||||
.map(CustomerMonthBillVO::getTotalBillAmount)
|
|
||||||
.filter(java.util.Objects::nonNull)
|
|
||||||
.reduce(java.math.BigDecimal.ZERO, java.math.BigDecimal::add);
|
|
||||||
BigDecimal totalSettledAmount = list.stream()
|
|
||||||
.map(CustomerMonthBillVO::getTotalSettledAmount)
|
|
||||||
.filter(java.util.Objects::nonNull)
|
|
||||||
.reduce(java.math.BigDecimal.ZERO, java.math.BigDecimal::add);
|
|
||||||
BigDecimal totalUnsettledAmount = list.stream()
|
|
||||||
.map(CustomerMonthBillVO::getTotalUnsettledAmount)
|
|
||||||
.filter(java.util.Objects::nonNull)
|
|
||||||
.reduce(java.math.BigDecimal.ZERO, java.math.BigDecimal::add);
|
|
||||||
java.util.Map<String, Object> resultMap = new java.util.HashMap<>();
|
|
||||||
resultMap.put("totalBillAmount", totalBillAmount);
|
|
||||||
resultMap.put("totalSettledAmount", totalSettledAmount);
|
|
||||||
resultMap.put("totalUnsettledAmount", totalUnsettledAmount);
|
|
||||||
resultMap.put("totalCount", list.size());
|
|
||||||
return AjaxResult.success(resultMap);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据账单ID列表查询应收账单详情(客户月账单点击账单数量回显)
|
|
||||||
*/
|
|
||||||
@ApiOperation("根据账单ID列表查询应收账单详情")
|
|
||||||
@GetMapping("/receivableDetailByMonth")
|
|
||||||
public TableDataInfo receivableDetailByMonth(BillManageDTO billManageDTO)
|
|
||||||
{
|
|
||||||
if (billManageDTO.getBillManageIds() != null && !billManageDTO.getBillManageIds().isEmpty()) {
|
|
||||||
Set<String> idSet = java.util.Arrays.stream(billManageDTO.getBillManageIds().split(","))
|
|
||||||
.collect(java.util.stream.Collectors.toSet());
|
|
||||||
billManageDTO.setBillManageIdSet(idSet);
|
|
||||||
}
|
|
||||||
BillManageDO billManageDO = new BillManageDO();
|
|
||||||
BeanUtils.copyProperties(billManageDTO, billManageDO);
|
|
||||||
billManageDO.setBillType(1);
|
|
||||||
startPage();
|
|
||||||
List<BillManagePO> list = billManageApplicationService.queryList(billManageDO);
|
|
||||||
return getDataTable(list);
|
|
||||||
}
|
|
||||||
|
|
||||||
@ApiOperation("根据账单ID列表查询应收账单汇总")
|
|
||||||
@GetMapping("/receivableSumByMonth")
|
|
||||||
public AjaxResult receivableSumByMonth(BillManageDTO billManageDTO)
|
|
||||||
{
|
|
||||||
if (billManageDTO.getBillManageIds() != null && !billManageDTO.getBillManageIds().isEmpty()) {
|
|
||||||
Set<String> idSet = java.util.Arrays.stream(billManageDTO.getBillManageIds().split(","))
|
|
||||||
.collect(java.util.stream.Collectors.toSet());
|
|
||||||
billManageDTO.setBillManageIdSet(idSet);
|
|
||||||
}
|
|
||||||
BillManageDO billManageDO = new BillManageDO();
|
|
||||||
BeanUtils.copyProperties(billManageDTO, billManageDO);
|
|
||||||
billManageDO.setBillType(1);
|
|
||||||
List<BillManagePO> list = billManageApplicationService.queryList(billManageDO);
|
|
||||||
|
|
||||||
Set<Long> billManageIdSet = list.stream()
|
|
||||||
.map(BillManagePO::getBillManageId)
|
|
||||||
.filter(java.util.Objects::nonNull)
|
|
||||||
.collect(java.util.stream.Collectors.toSet());
|
|
||||||
|
|
||||||
List<ReceiptDetail> allReceiptDetails = new ArrayList<>();
|
|
||||||
Set<Long> receiptManageIdSet = new java.util.HashSet<>();
|
|
||||||
List<ReceiptManagePO> receiptManageList = new ArrayList<>();
|
|
||||||
|
|
||||||
if (!billManageIdSet.isEmpty()) {
|
|
||||||
allReceiptDetails = receiptDetailDomainService.queryListByLambda(
|
|
||||||
new LambdaQueryWrapper<ReceiptDetail>()
|
|
||||||
.in(ReceiptDetail::getBillManageId, billManageIdSet)
|
|
||||||
.eq(ReceiptDetail::getDelFlag, 1));
|
|
||||||
|
|
||||||
java.util.Map<Long, List<ReceiptDetail>> detailByBillId = allReceiptDetails.stream()
|
|
||||||
.collect(java.util.stream.Collectors.groupingBy(ReceiptDetail::getBillManageId));
|
|
||||||
for (BillManagePO bill : list) {
|
|
||||||
bill.setReceiptDetailList(detailByBillId.getOrDefault(bill.getBillManageId(), new ArrayList<>()));
|
|
||||||
}
|
|
||||||
|
|
||||||
receiptManageIdSet = allReceiptDetails.stream()
|
|
||||||
.map(ReceiptDetail::getReceiptManageId)
|
|
||||||
.filter(java.util.Objects::nonNull)
|
|
||||||
.collect(java.util.stream.Collectors.toSet());
|
|
||||||
|
|
||||||
if (!receiptManageIdSet.isEmpty()) {
|
|
||||||
List<ReceiptManage> manages = receiptManageService.list(
|
|
||||||
new LambdaQueryWrapper<ReceiptManage>()
|
|
||||||
.in(ReceiptManage::getReceiptManageId, receiptManageIdSet)
|
|
||||||
.eq(ReceiptManage::getDelFlag, 1));
|
|
||||||
|
|
||||||
java.util.Map<Long, List<ReceiptDetailPO>> detailPOByManageId = allReceiptDetails.stream()
|
|
||||||
.map(d -> {
|
|
||||||
ReceiptDetailPO po = new ReceiptDetailPO();
|
|
||||||
BeanUtils.copyProperties(d, po);
|
|
||||||
return po;
|
|
||||||
})
|
|
||||||
.collect(java.util.stream.Collectors.groupingBy(ReceiptDetailPO::getReceiptManageId));
|
|
||||||
|
|
||||||
for (ReceiptManage m : manages) {
|
|
||||||
ReceiptManagePO po = new ReceiptManagePO();
|
|
||||||
BeanUtils.copyProperties(m, po);
|
|
||||||
po.setReceiptDetailPOList(detailPOByManageId.getOrDefault(m.getReceiptManageId(), new ArrayList<>()));
|
|
||||||
receiptManageList.add(po);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
BigDecimal totalBillAmount = list.stream()
|
|
||||||
.map(BillManagePO::getBillAmount)
|
|
||||||
.filter(java.util.Objects::nonNull)
|
|
||||||
.reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
||||||
BigDecimal totalSettledAmount = list.stream()
|
|
||||||
.map(BillManagePO::getBillAmountSettlement)
|
|
||||||
.filter(java.util.Objects::nonNull)
|
|
||||||
.reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
||||||
BigDecimal totalUnsettledAmount = list.stream()
|
|
||||||
.map(BillManagePO::getBillAmountUnsettled)
|
|
||||||
.filter(java.util.Objects::nonNull)
|
|
||||||
.reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
||||||
int billCount = list.size();
|
|
||||||
|
|
||||||
String collectionStatus;
|
|
||||||
if (billCount == 0) {
|
|
||||||
collectionStatus = "无数据";
|
|
||||||
} else if (totalUnsettledAmount.compareTo(BigDecimal.ZERO) == 0) {
|
|
||||||
collectionStatus = "已收款";
|
|
||||||
} else if (totalSettledAmount.compareTo(BigDecimal.ZERO) == 0) {
|
|
||||||
collectionStatus = "未收款";
|
|
||||||
} else {
|
|
||||||
collectionStatus = "部分收款";
|
|
||||||
}
|
|
||||||
|
|
||||||
java.util.Map<String, Object> resultMap = new java.util.HashMap<>();
|
|
||||||
resultMap.put("totalBillAmount", totalBillAmount);
|
|
||||||
resultMap.put("totalSettledAmount", totalSettledAmount);
|
|
||||||
resultMap.put("totalUnsettledAmount", totalUnsettledAmount);
|
|
||||||
resultMap.put("billCount", billCount);
|
|
||||||
resultMap.put("collectionStatus", collectionStatus);
|
|
||||||
resultMap.put("billList", list);
|
|
||||||
resultMap.put("receiptManageList", receiptManageList);
|
|
||||||
return AjaxResult.success(resultMap);
|
|
||||||
}
|
|
||||||
|
|
||||||
@ApiOperation("导出应收账单")
|
@ApiOperation("导出应收账单")
|
||||||
@GetMapping(value = "/exportReceivableList", produces = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")
|
@GetMapping(value = "/exportReceivableList", produces = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")
|
||||||
public void exportReceivableList(BillManageDTO billManageDTO, HttpServletResponse response) throws IOException
|
public void exportReceivableList(BillManageDTO billManageDTO, HttpServletResponse response) throws IOException
|
||||||
@@ -507,46 +328,6 @@ public class BillManageApi extends BaseController{
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ApiOperation("应收账单-红冲")
|
|
||||||
@PostMapping("/redFlushBill")
|
|
||||||
public AjaxResult redFlushBill(@RequestBody BillManageDTO billManageDTO)
|
|
||||||
{
|
|
||||||
if(!StringUtils.isNotEmpty(billManageDTO.getBillManageIds())){
|
|
||||||
throw new ServiceException("账单id不能为空");
|
|
||||||
}
|
|
||||||
//批量加锁
|
|
||||||
RedissonMultiLock redissonMultiLock = null;
|
|
||||||
boolean lockFlag = false;
|
|
||||||
try {
|
|
||||||
RedisLockTypeEnum redisLockTypeEnum = RedisLockTypeEnum.BMS;
|
|
||||||
List<RLock> locks = new ArrayList<>();
|
|
||||||
Set<String> billIdSet = Stream.of(billManageDTO.getBillManageIds().split(",")).filter(StringUtils::isNotEmpty).map(String::trim).collect(Collectors.toSet());
|
|
||||||
billIdSet.forEach(x -> {
|
|
||||||
//获取唯一key值
|
|
||||||
String key = redisLockTypeEnum.getUniqueKey(UniqueKeyUtil.getBillingKey(x));
|
|
||||||
locks.add(redisLock.getRLock(key));
|
|
||||||
});
|
|
||||||
redissonMultiLock = new RedissonMultiLock(locks.toArray(new RLock[billIdSet.size()]));
|
|
||||||
//尝试获取锁 不等待 持有锁10分钟
|
|
||||||
lockFlag = redissonMultiLock.tryLock(-1, 10, TimeUnit.MINUTES);
|
|
||||||
if (!lockFlag) {
|
|
||||||
redissonMultiLock = null;
|
|
||||||
throw new ServiceException("账单正在操作中,请稍后重试");
|
|
||||||
}
|
|
||||||
log.info("红冲账单加锁成功");
|
|
||||||
billManageApplicationService.redFlushBill(billManageDTO);
|
|
||||||
return AjaxResult.success("操作成功");
|
|
||||||
}catch (Exception e){
|
|
||||||
return AjaxResult.error("红冲账单失败:"+e.getMessage());
|
|
||||||
} finally {
|
|
||||||
if (redissonMultiLock != null && lockFlag){
|
|
||||||
redissonMultiLock.unlock();
|
|
||||||
log.info("红冲账单释放锁成功");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@ApiOperation("应收账单-客户确认")
|
@ApiOperation("应收账单-客户确认")
|
||||||
@PostMapping("/customerConfirmation")
|
@PostMapping("/customerConfirmation")
|
||||||
public AjaxResult customerConfirmation(@RequestBody BillManageDTO billManageDTO)
|
public AjaxResult customerConfirmation(@RequestBody BillManageDTO billManageDTO)
|
||||||
@@ -657,21 +438,6 @@ public class BillManageApi extends BaseController{
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 客户月结报表
|
|
||||||
*/
|
|
||||||
@ApiOperation("客户月结报表")
|
|
||||||
@GetMapping("/customerMonthlyReport")
|
|
||||||
public TableDataInfo customerMonthlyReport(BillManageDTO billManageDTO)
|
|
||||||
{
|
|
||||||
//转换实体
|
|
||||||
BillManageDO billManageDO = new BillManageDO();
|
|
||||||
BeanUtils.copyProperties(billManageDTO,billManageDO);
|
|
||||||
startPage();
|
|
||||||
billManageDO.setBillType(1);
|
|
||||||
List<BillManagePO> list = billManageApplicationService.customerMonthlyReport(billManageDO);
|
|
||||||
return getDataTable(list);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -339,10 +339,7 @@ public class BillingStatementApi extends BaseController {
|
|||||||
String shipperId = XxlJobHelper.getJobParam();
|
String shipperId = XxlJobHelper.getJobParam();
|
||||||
logger.info("XXL-JOB 开始入库业务单推送bms计费流水,货主id参数:{}", shipperId);
|
logger.info("XXL-JOB 开始入库业务单推送bms计费流水,货主id参数:{}", shipperId);
|
||||||
try {
|
try {
|
||||||
//干仓
|
|
||||||
billingStatementApplicationService.pushBillManage(shipperId);
|
billingStatementApplicationService.pushBillManage(shipperId);
|
||||||
//冻仓
|
|
||||||
billingStatementApplicationService.pushBillManageDC(shipperId);
|
|
||||||
// 设置任务执行结果
|
// 设置任务执行结果
|
||||||
XxlJobHelper.handleSuccess("入库业务单推送bms计费流水执行成功");
|
XxlJobHelper.handleSuccess("入库业务单推送bms计费流水执行成功");
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
package com.mhd.bms.interfaces.facadeApi;
|
package com.mhd.bms.interfaces.facadeApi;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.LinkedHashSet;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
@@ -115,57 +114,6 @@ public class ReceiptManageApi extends BaseController{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 撤销收款
|
|
||||||
*/
|
|
||||||
@ApiOperation("撤销收款")
|
|
||||||
@RepeatSubmit
|
|
||||||
@PostMapping("/cancelCollection")
|
|
||||||
public AjaxResult cancelCollection(@RequestBody ReceiptManageDTO receiptManageDTO)
|
|
||||||
{
|
|
||||||
if(!StringUtils.isNotEmpty(receiptManageDTO.getBillManageIds())){
|
|
||||||
throw new ServiceException("撤销账单不能为空");
|
|
||||||
}
|
|
||||||
RedissonMultiLock redissonMultiLock = null;
|
|
||||||
boolean payInfoDetailLock = false;
|
|
||||||
try {
|
|
||||||
RedisLockTypeEnum redisLockTypeEnum = RedisLockTypeEnum.BMS;
|
|
||||||
List<RLock> locks = new ArrayList<>();
|
|
||||||
//账单id与涉及的收款单id去重后加锁,避免同一把锁重复加锁
|
|
||||||
Set<String> lockKeySet = new LinkedHashSet<>();
|
|
||||||
lockKeySet.addAll(Stream.of(receiptManageDTO.getBillManageIds().split(",")).filter(StringUtils::isNotEmpty).map(String::trim).collect(Collectors.toSet()));
|
|
||||||
//查询账单涉及的收款单,一并加锁,避免并发撤销时收款单金额重算冲突
|
|
||||||
Set<Long> receiptManageIdSet = receiptManageApplicationService.queryCancelCollectionReceiptManageIds(receiptManageDTO.getBillManageIds());
|
|
||||||
if (null != receiptManageIdSet) {
|
|
||||||
receiptManageIdSet.forEach(x -> lockKeySet.add(String.valueOf(x)));
|
|
||||||
}
|
|
||||||
lockKeySet.forEach(x -> {
|
|
||||||
//获取唯一key值
|
|
||||||
String key = redisLockTypeEnum.getUniqueKey(UniqueKeyUtil.getBillingKey(x));
|
|
||||||
locks.add(redisLock.getRLock(key));
|
|
||||||
});
|
|
||||||
redissonMultiLock = new RedissonMultiLock(locks.toArray(new RLock[lockKeySet.size()]));
|
|
||||||
//尝试获取锁 不等待 持有锁10分钟
|
|
||||||
payInfoDetailLock = redissonMultiLock.tryLock(-1, 10, TimeUnit.MINUTES);
|
|
||||||
if (!payInfoDetailLock) {
|
|
||||||
redissonMultiLock = null;
|
|
||||||
return AjaxResult.error("收款单正在处理,请稍后再试");
|
|
||||||
}
|
|
||||||
log.info("撤销收款加锁成功");
|
|
||||||
//转换实体
|
|
||||||
ReceiptManageDO receiptManageDO = new ReceiptManageDO();
|
|
||||||
BeanUtils.copyProperties(receiptManageDTO,receiptManageDO);
|
|
||||||
return toAjax(receiptManageApplicationService.cancelCollection(receiptManageDO));
|
|
||||||
}catch (Exception e){
|
|
||||||
return AjaxResult.error("撤销收款失败:" + e.getMessage());
|
|
||||||
}finally {
|
|
||||||
if (redissonMultiLock != null && payInfoDetailLock) {
|
|
||||||
redissonMultiLock.unlock();
|
|
||||||
log.info("撤销收款释放了锁");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 批量删除收款单管理
|
* 批量删除收款单管理
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -22,56 +22,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
ORDER BY a.create_time DESC
|
ORDER BY a.create_time DESC
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="customerMonthlyReport" parameterType="com.mhd.bms.domain.billManage.repository.todo.BillManageDO" resultType="com.mhd.bms.domain.billManage.repository.po.BillManagePO">
|
|
||||||
SELECT
|
|
||||||
a.*,
|
|
||||||
b.SETTLEMENT_ENTITY_ID AS "settlementEntityId",
|
|
||||||
(SELECT MAX(c.collection_time)
|
|
||||||
FROM receipt_detail rd
|
|
||||||
LEFT JOIN receipt_manage c ON rd.receipt_manage_id = c.receipt_manage_id
|
|
||||||
WHERE rd.bill_manage_id = a.bill_manage_id
|
|
||||||
AND rd.del_flag = 1
|
|
||||||
AND c.del_flag = 1) AS "collectionTime",
|
|
||||||
(SELECT LISTAGG(bs.CONTRACT_NUMBER, ',') WITHIN GROUP (ORDER BY bs.CONTRACT_NUMBER)
|
|
||||||
FROM BILLING_STATEMENT bs
|
|
||||||
WHERE bs.BILL_MANAGE_ID = a.bill_manage_id
|
|
||||||
AND bs.CONTRACT_NUMBER IS NOT NULL) AS "contractNumbers"
|
|
||||||
FROM bill_manage a
|
|
||||||
LEFT JOIN SETTLEMENT_CUSTOMERS b ON a.SETTLEMENT_CUSTOMERS_ID = b.SETTLEMENT_CUSTOMERS_ID
|
|
||||||
WHERE a.del_flag = 1
|
|
||||||
<include refid="common_where"/>
|
|
||||||
ORDER BY a.create_time DESC
|
|
||||||
</select>
|
|
||||||
|
|
||||||
<select id="queryCustomerMonthBillList" parameterType="com.mhd.bms.domain.billManage.repository.todo.BillManageDO" resultType="com.mhd.bms.interfaces.dto.billManage.CustomerMonthBillVO">
|
|
||||||
SELECT
|
|
||||||
a.SETTLEMENT_CUSTOMERS_ID AS settlementCustomersId,
|
|
||||||
a.SETTLEMENT_CUSTOMERS_CODE AS settlementCustomersCode,
|
|
||||||
a.SETTLEMENT_ENTITY AS settlementEntity,
|
|
||||||
b.SETTLEMENT_ENTITY_ID AS settlementEntityId,
|
|
||||||
b.SETTLEMENT_ENTITY AS settlementEntityName,
|
|
||||||
a.ORGANIZATION_ID AS organizationId,
|
|
||||||
a.ORGANIZATION_NAME AS organizationName,
|
|
||||||
TO_CHAR(a.CREATE_TIME, 'YYYY-MM') AS billMonth,
|
|
||||||
SUM(a.BILL_AMOUNT) AS totalBillAmount,
|
|
||||||
SUM(NVL(a.BILL_AMOUNT_SETTLEMENT, 0)) AS totalSettledAmount,
|
|
||||||
SUM(NVL(a.BILL_AMOUNT_UNSETTLED, 0)) AS totalUnsettledAmount,
|
|
||||||
COUNT(*) AS billCount,
|
|
||||||
LISTAGG(a.BILL_MANAGE_ID, ',') WITHIN GROUP (ORDER BY a.BILL_MANAGE_ID) AS billManageIds,
|
|
||||||
b.SETTLEMENT_METHOD AS settlementMethod,
|
|
||||||
b.SETTLEMENT_CURRENCY AS settlementCurrency
|
|
||||||
FROM bill_manage a
|
|
||||||
LEFT JOIN SETTLEMENT_CUSTOMERS b ON a.SETTLEMENT_CUSTOMERS_ID = b.SETTLEMENT_CUSTOMERS_ID AND b.del_flag = 1
|
|
||||||
WHERE a.del_flag = 1
|
|
||||||
<include refid="common_where"/>
|
|
||||||
GROUP BY a.SETTLEMENT_CUSTOMERS_ID, TO_CHAR(a.CREATE_TIME, 'YYYY-MM'), a.ORGANIZATION_ID, a.ORGANIZATION_NAME, b.SETTLEMENT_ENTITY_ID, b.SETTLEMENT_ENTITY, b.SETTLEMENT_METHOD, b.SETTLEMENT_CURRENCY, a.SETTLEMENT_CUSTOMERS_CODE, a.SETTLEMENT_ENTITY
|
|
||||||
ORDER BY MAX(a.CREATE_TIME) DESC
|
|
||||||
</select>
|
|
||||||
|
|
||||||
<sql id="common_where">
|
<sql id="common_where">
|
||||||
<if test="billManageDO.billMonth != null and billManageDO.billMonth != ''">
|
|
||||||
AND TO_CHAR(a.CREATE_TIME, 'YYYY-MM') = #{billManageDO.billMonth}
|
|
||||||
</if>
|
|
||||||
<if test="billManageDO.createTimeStart != null and billManageDO.createTimeStart != ''">
|
<if test="billManageDO.createTimeStart != null and billManageDO.createTimeStart != ''">
|
||||||
AND date_format(a.create_time,'%Y-%m-%d') <![CDATA[>=]]> #{billManageDO.createTimeStart}
|
AND date_format(a.create_time,'%Y-%m-%d') <![CDATA[>=]]> #{billManageDO.createTimeStart}
|
||||||
</if>
|
</if>
|
||||||
|
|||||||
@@ -12,39 +12,39 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
|
|
||||||
<sql id="selectBillOperationLogPo1">
|
<sql id="selectBillOperationLogPo1">
|
||||||
<where>
|
<where>
|
||||||
<if test="billOperationLogDO.createByName != null and billOperationLogDO.createByName != ''">
|
<if test="createByName != null and createByName != ''">
|
||||||
and create_by_name like concat('%', #{billOperationLogDO.createByName}, '%')
|
and create_by_name like concat('%', #{createByName}, '%')
|
||||||
</if>
|
</if>
|
||||||
<if test="billOperationLogDO.updateByName != null and billOperationLogDO.updateByName != ''">
|
<if test="updateByName != null and updateByName != ''">
|
||||||
and update_by_name like concat('%', #{billOperationLogDO.updateByName}, '%')
|
and update_by_name like concat('%', #{updateByName}, '%')
|
||||||
</if>
|
</if>
|
||||||
<if test="billOperationLogDO.topOrganizationId != null ">
|
<if test="topOrganizationId != null ">
|
||||||
and top_organization_id = #{billOperationLogDO.topOrganizationId}
|
and top_organization_id = #{topOrganizationId}
|
||||||
</if>
|
</if>
|
||||||
<if test="billOperationLogDO.organizationId != null ">
|
<if test="organizationId != null ">
|
||||||
and organization_id = #{billOperationLogDO.organizationId}
|
and organization_id = #{organizationId}
|
||||||
</if>
|
</if>
|
||||||
<if test="billOperationLogDO.organizationName != null and billOperationLogDO.organizationName != ''">
|
<if test="organizationName != null and organizationName != ''">
|
||||||
and organization_name like concat('%', #{billOperationLogDO.organizationName}, '%')
|
and organization_name like concat('%', #{organizationName}, '%')
|
||||||
</if>
|
</if>
|
||||||
<if test="billOperationLogDO.billManageId != null ">
|
<if test="billManageId != null ">
|
||||||
and bill_manage_id = #{billOperationLogDO.billManageId}
|
and bill_manage_id = #{billManageId}
|
||||||
</if>
|
</if>
|
||||||
<!-- <if test="billOperationLogDO.billNumber != null and billOperationLogDO.billNumber != ''">-->
|
<if test="billNumber != null and billNumber != ''">
|
||||||
<!-- and bill_number = #{billOperationLogDO.billNumber}-->
|
and bill_number = #{billNumber}
|
||||||
<!-- </if>-->
|
|
||||||
<if test="billOperationLogDO.operationType != null ">
|
|
||||||
and operation_type = #{billOperationLogDO.operationType}
|
|
||||||
</if>
|
</if>
|
||||||
<if test="billOperationLogDO.operationInfo != null and billOperationLogDO.operationInfo != ''">
|
<if test="operationType != null ">
|
||||||
and operation_info = #{billOperationLogDO.operationInfo}
|
and operation_type = #{operationType}
|
||||||
|
</if>
|
||||||
|
<if test="operationInfo != null and operationInfo != ''">
|
||||||
|
and operation_info = #{operationInfo}
|
||||||
|
</if>
|
||||||
|
<if test="operator != null and operator != ''">
|
||||||
|
and operator = #{operator}
|
||||||
|
</if>
|
||||||
|
<if test="operationTime != null ">
|
||||||
|
and operation_time = #{operationTime}
|
||||||
</if>
|
</if>
|
||||||
<!-- <if test="billOperationLogDO.operator != null and billOperationLogDO.operator != ''">-->
|
|
||||||
<!-- and operator = #{billOperationLogDO.operator}-->
|
|
||||||
<!-- </if>-->
|
|
||||||
<!-- <if test="billOperationLogDO.operationTime != null ">-->
|
|
||||||
<!-- and operation_time = #{billOperationLogDO.operationTime}-->
|
|
||||||
<!-- </if>-->
|
|
||||||
</where>
|
</where>
|
||||||
</sql>
|
</sql>
|
||||||
|
|
||||||
|
|||||||
@@ -275,7 +275,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
SELECT
|
SELECT
|
||||||
RATE as "taxRate"
|
RATE as "taxRate"
|
||||||
FROM
|
FROM
|
||||||
NGWL_TEST_SYSTEM.EXPENSE_ACCOUNT
|
EXPENSE_ACCOUNT
|
||||||
WHERE
|
WHERE
|
||||||
SUBJECT_CODE = #{subjectCode}
|
SUBJECT_CODE = #{subjectCode}
|
||||||
AND SUBJECT_NAME = #{subjectName}
|
AND SUBJECT_NAME = #{subjectName}
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
WM_CONCAT(b.bill_number) AS billNumbers
|
WM_CONCAT(b.bill_number) AS billNumbers
|
||||||
FROM
|
FROM
|
||||||
receipt_manage a
|
receipt_manage a
|
||||||
LEFT JOIN receipt_detail b ON a.receipt_manage_id = b.receipt_manage_id AND b.del_flag = 1
|
LEFT JOIN receipt_detail b ON a.receipt_manage_id = b.receipt_manage_id
|
||||||
WHERE
|
WHERE
|
||||||
a.del_flag = 1
|
a.del_flag = 1
|
||||||
<include refid="common_where"/>
|
<include refid="common_where"/>
|
||||||
@@ -101,7 +101,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
left join PAYMENT_WALLET c on b.payment_card_id = c.PAYMENT_WALLET_ID
|
left join PAYMENT_WALLET c on b.payment_card_id = c.PAYMENT_WALLET_ID
|
||||||
WHERE
|
WHERE
|
||||||
a.bill_manage_id = #{billManageId}
|
a.bill_manage_id = #{billManageId}
|
||||||
AND a.del_flag = 1
|
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
||||||
+25
-297
@@ -7,16 +7,9 @@ import cn.hutool.core.util.ObjectUtil;
|
|||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import cn.hutool.json.JSONUtil;
|
import cn.hutool.json.JSONUtil;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.mhd.common.core.domain.dto.wlhy.TmsAddressMultiDTO;
|
|
||||||
import com.mhd.common.core.domain.dto.wlhy.TmsCargoInfoDTO;
|
|
||||||
import com.mhd.common.core.domain.dto.wlhy.TmsOrderAccount;
|
|
||||||
import com.mhd.common.core.exception.ServiceException;
|
import com.mhd.common.core.exception.ServiceException;
|
||||||
import com.mhd.common.core.web.domain.AjaxResult;
|
import com.mhd.common.core.web.domain.AjaxResult;
|
||||||
import com.mhd.common.security.utils.SecurityUtils;
|
import com.mhd.common.security.utils.SecurityUtils;
|
||||||
import com.mhd.oms.domain.businessDocumentAddressMulti.entity.BusinessDocumentAddressMulti;
|
|
||||||
import com.mhd.oms.domain.businessDocumentAddressMulti.repository.mapper.BusinessDocumentAddressMultiMapper;
|
|
||||||
import com.mhd.oms.domain.businessDocumentCargoMulti.entity.BusinessDocumentCargoMulti;
|
|
||||||
import com.mhd.oms.domain.businessDocumentCargoMulti.repository.mapper.BusinessDocumentCargoMultiMapper;
|
|
||||||
import com.mhd.oms.domain.businessDocumentOrder.entity.BusinessDocumentOrder;
|
import com.mhd.oms.domain.businessDocumentOrder.entity.BusinessDocumentOrder;
|
||||||
import com.mhd.oms.domain.businessDocumentOrder.repository.mapper.BusinessDocumentOrderMapper;
|
import com.mhd.oms.domain.businessDocumentOrder.repository.mapper.BusinessDocumentOrderMapper;
|
||||||
import com.mhd.oms.domain.businessDocumentOrderAdjust.entity.BusinessDocumentOrderAdjust;
|
import com.mhd.oms.domain.businessDocumentOrderAdjust.entity.BusinessDocumentOrderAdjust;
|
||||||
@@ -27,13 +20,11 @@ import com.mhd.oms.domain.businessOrderAccount.BusinessOrderAccount;
|
|||||||
import com.mhd.oms.domain.businessOrderAccount.repository.mapper.BusinessOrderAccountMapper;
|
import com.mhd.oms.domain.businessOrderAccount.repository.mapper.BusinessOrderAccountMapper;
|
||||||
import com.mhd.oms.domain.executeOrder.entity.ExecuteOrder;
|
import com.mhd.oms.domain.executeOrder.entity.ExecuteOrder;
|
||||||
import com.mhd.oms.domain.executeOrder.repository.mapper.ExecuteOrderMapper;
|
import com.mhd.oms.domain.executeOrder.repository.mapper.ExecuteOrderMapper;
|
||||||
import com.mhd.oms.interfaces.dto.businessDocumentAddressMulti.BusinessDocumentAddressMultiDTO;
|
|
||||||
import com.mhd.oms.interfaces.dto.businessDocumentOrderAdjust.BusinessDocumentOrderAdjustAuditDTO;
|
import com.mhd.oms.interfaces.dto.businessDocumentOrderAdjust.BusinessDocumentOrderAdjustAuditDTO;
|
||||||
import com.mhd.oms.interfaces.dto.businessDocumentOrderAdjust.BusinessDocumentOrderAdjustDTO;
|
import com.mhd.oms.interfaces.dto.businessDocumentOrderAdjust.BusinessDocumentOrderAdjustDTO;
|
||||||
import com.mhd.oms.interfaces.dto.businessDocumentOrderAdjust.BusinessDocumentOrderAdjustQueryDTO;
|
import com.mhd.oms.interfaces.dto.businessDocumentOrderAdjust.BusinessDocumentOrderAdjustQueryDTO;
|
||||||
import com.mhd.oms.interfaces.dto.businessDocumentOrderAdjust.BusinessDocumentOrderAdjustRecordDTO;
|
import com.mhd.oms.interfaces.dto.businessDocumentOrderAdjust.BusinessDocumentOrderAdjustRecordDTO;
|
||||||
import com.mhd.system.api.WlhyServiceFeign;
|
import com.mhd.system.api.WlhyServiceFeign;
|
||||||
import com.mhd.system.api.domain.TmsOrderAddDTO;
|
|
||||||
import com.mhd.system.api.model.LoginUser;
|
import com.mhd.system.api.model.LoginUser;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
@@ -45,7 +36,6 @@ import java.util.ArrayList;
|
|||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -56,23 +46,16 @@ import java.util.stream.Collectors;
|
|||||||
* 2. 费用数据源 = 前端回传的费用明细 business_order_account(feeDetailList);
|
* 2. 费用数据源 = 前端回传的费用明细 business_order_account(feeDetailList);
|
||||||
* 主表金额 deliveryFreight 为其 amount 合计(冗余汇总,后端自动算)。
|
* 主表金额 deliveryFreight 为其 amount 合计(冗余汇总,后端自动算)。
|
||||||
* 3. 是否需审核:一旦任一「金额」发生变化
|
* 3. 是否需审核:一旦任一「金额」发生变化
|
||||||
* = feeDetailList 明细 amount 变化,或主表金额/费用列变化 -> 走业务主管审核;
|
* = feeDetailList 明细 amount 变化,或主表金额列变化 -> 走业务主管审核;
|
||||||
* 否则(仅改非金额字段) -> 直通。
|
* 否则(仅改非金额字段) -> 直通。
|
||||||
* 「金额/费用」字段涵盖: deliveryFreight / collectedFreight / uncollectedFreight /
|
|
||||||
* collectLessFreight / transportationUnitPrice / infoFee / freightUnitPrice /
|
|
||||||
* cargoInsuranceAmount / freightCharges / freightFee / unloadingFee / customsFee /
|
|
||||||
* shortageFee / miscellaneousFee / otherFee / detentionFee,以及 settlementCurrency /
|
|
||||||
* paymentAccountId / accountName / accountInformation(结算币种+收款账户任一变化即视为费用变更)。
|
|
||||||
* 判定口径: 以后端兜底比对为准(主表金额/费用列 + 明细 amount 合计),
|
|
||||||
* 前端 amountChanged 仅作提示;后端比对结果与前端 OR 运算,避免前端误传 false 绕过审核。
|
|
||||||
* 4. 涉及金额提交 -> 仅把业务单 review_status 置为「调整待审核(3)」;主记录 AUDIT_STATUS=0(待审核);
|
* 4. 涉及金额提交 -> 仅把业务单 review_status 置为「调整待审核(3)」;主记录 AUDIT_STATUS=0(待审核);
|
||||||
* 不更新业务单数据,不影响其它状态(order_status / execute_status 不动)。
|
* 不更新业务单数据,不影响其它状态(order_status / execute_status 不动)。
|
||||||
* 5. 审核通过 -> 覆盖业务单(金额) + 替换费用明细;review_status 一律置为 1(已审核),
|
* 5. 审核通过 -> 覆盖业务单(金额) + 替换费用明细;review_status 一律置为 1(已审核),
|
||||||
* 不影响 order_status / execute_status。
|
* 不影响 order_status / execute_status。
|
||||||
* 审核驳回 -> 不更新业务单数据,review_status 置为「调整驳回(4)」,不影响 order_status/execute_status,
|
* 审核驳回 -> 不更新业务单数据,review_status 还原为调整前值(主记录 before_review_status),可再次调整。
|
||||||
* 可再次调整提交审核。
|
|
||||||
* 6. 直通(未改金额) -> 覆盖业务单可编辑字段 + deliveryFreight(明细合计),并替换 business_order_account
|
* 6. 直通(未改金额) -> 覆盖业务单可编辑字段 + deliveryFreight(明细合计),并替换 business_order_account
|
||||||
* (逻辑删旧 is_delete=1 + 插新 is_delete=0);不改动任何审核/执行状态。
|
* (逻辑删旧 is_delete=1 + 插新 is_delete=0);不改动任何审核/执行状态。
|
||||||
|
* 7. 前端以 amountChanged 告知是否改金额(默认前端判定);未传时后端兜底比对。
|
||||||
*
|
*
|
||||||
* 说明:review_status 原枚举 0未审/1通过/2驳回,新增 3=调整待审核;不改变原有用例。
|
* 说明:review_status 原枚举 0未审/1通过/2驳回,新增 3=调整待审核;不改变原有用例。
|
||||||
*
|
*
|
||||||
@@ -87,22 +70,12 @@ public class BusinessDocumentOrderAdjustService {
|
|||||||
private static final Integer AUDIT_PASS = 1; // 调整记录:审核通过
|
private static final Integer AUDIT_PASS = 1; // 调整记录:审核通过
|
||||||
private static final Integer AUDIT_REJECT = 2; // 调整记录:驳回
|
private static final Integer AUDIT_REJECT = 2; // 调整记录:驳回
|
||||||
|
|
||||||
/** 业务单 review_status:调整待审核(提交涉及金额时置) */
|
/** 主表金额(费用)字段,任一变化触发审核 */
|
||||||
private static final Long REVIEW_ADJUST_WAIT = 3L;
|
|
||||||
/** 业务单 review_status:调整驳回(审核驳回时置,与普通驳回 2 区分) */
|
|
||||||
private static final Long REVIEW_ADJUST_REJECT = 4L;
|
|
||||||
|
|
||||||
/** 主表金额(费用)字段,任一变化触发审核
|
|
||||||
* 含: 运费相关 8 项 + 其他费用 8 项 + 结算币种 + 收款账户(3 字段)
|
|
||||||
* 任意一项变化即需要审核(对应前端"费用合计 / 运费 / 装卸费 / 仓租及柜租(走明细) /
|
|
||||||
* 保险 / 压车(走明细) / 运输处理费(走明细) / 报关费 / 其他 / 费用合计 / 结算币种 / 收款账户") */
|
|
||||||
private static final List<String> FEE_FIELDS = Arrays.asList(
|
private static final List<String> FEE_FIELDS = Arrays.asList(
|
||||||
"deliveryFreight", "collectedFreight", "uncollectedFreight", "collectLessFreight",
|
"deliveryFreight", "collectedFreight", "uncollectedFreight", "collectLessFreight",
|
||||||
"transportationUnitPrice", "infoFee", "freightUnitPrice", "cargoInsuranceAmount",
|
"transportationUnitPrice", "infoFee", "freightUnitPrice", "cargoInsuranceAmount",
|
||||||
"freightCharges", "freightFee", "unloadingFee", "customsFee", "shortageFee",
|
"freightCharges", "freightFee", "unloadingFee", "customsFee", "shortageFee",
|
||||||
"miscellaneousFee", "otherFee", "detentionFee",
|
"miscellaneousFee", "otherFee", "detentionFee");
|
||||||
// 结算币种 + 收款账户 任一变化也视为费用变更,需审核
|
|
||||||
"settlementCurrency", "paymentAccountId", "accountName", "accountInformation");
|
|
||||||
|
|
||||||
/** 不允许被前端调整覆盖的系统字段 */
|
/** 不允许被前端调整覆盖的系统字段 */
|
||||||
private static final List<String> PROTECTED_FIELDS = Arrays.asList(
|
private static final List<String> PROTECTED_FIELDS = Arrays.asList(
|
||||||
@@ -110,7 +83,7 @@ public class BusinessDocumentOrderAdjustService {
|
|||||||
"orderStatus", "reviewStatus", "reviewId", "review", "reviewTime", "reviewOpinion",
|
"orderStatus", "reviewStatus", "reviewId", "review", "reviewTime", "reviewOpinion",
|
||||||
"salesManager", "auditStatus", "auditBy", "auditTime",
|
"salesManager", "auditStatus", "auditBy", "auditTime",
|
||||||
"executeStatus", "executeId", "executeTime", "executor",
|
"executeStatus", "executeId", "executeTime", "executor",
|
||||||
"executeOrderId", "executeOrderNumber",
|
"executeOrderId", "executeOrderNumber", "adjustStatus",
|
||||||
"isDelete", "delFlag", "createBy", "createByName", "createTime",
|
"isDelete", "delFlag", "createBy", "createByName", "createTime",
|
||||||
"updateBy", "updateByName", "updateTime",
|
"updateBy", "updateByName", "updateTime",
|
||||||
"pushStatus", "pushTime", "pushBy", "pushByName",
|
"pushStatus", "pushTime", "pushBy", "pushByName",
|
||||||
@@ -139,12 +112,6 @@ public class BusinessDocumentOrderAdjustService {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private ExecuteOrderMapper executeOrderMapper;
|
private ExecuteOrderMapper executeOrderMapper;
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private BusinessDocumentCargoMultiMapper businessDocumentCargoMultiMapper;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private BusinessDocumentAddressMultiMapper businessDocumentAddressMultiMapper;
|
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private WlhyServiceFeign wlhyServiceFeign;
|
private WlhyServiceFeign wlhyServiceFeign;
|
||||||
|
|
||||||
@@ -169,20 +136,12 @@ public class BusinessDocumentOrderAdjustService {
|
|||||||
.eq(BusinessOrderAccount::getOrderId, dbOrder.getId())
|
.eq(BusinessOrderAccount::getOrderId, dbOrder.getId())
|
||||||
.eq(BusinessOrderAccount::getIsDelete, 0));
|
.eq(BusinessOrderAccount::getIsDelete, 0));
|
||||||
|
|
||||||
// 2. 调整后的费用明细(前端);为 null 则视为保持库中不变。
|
// 2. 调整后的费用明细(前端);为 null 则视为保持库中不变
|
||||||
// 兼容前端两种传法:顶层 feeDetailList,或整单回传 order.businessOrderAccountList
|
|
||||||
List<BusinessOrderAccount> newFeeList = dto.getFeeDetailList();
|
List<BusinessOrderAccount> newFeeList = dto.getFeeDetailList();
|
||||||
if ((newFeeList == null || newFeeList.isEmpty()) && front.getBusinessOrderAccountList() != null) {
|
|
||||||
newFeeList = front.getBusinessOrderAccountList();
|
|
||||||
}
|
|
||||||
|
|
||||||
// 3. 生成"调整后"业务单对象:DB原值 + 前端可编辑字段覆盖(忽略null)
|
// 3. 生成"调整后"业务单对象:DB原值 + 前端可编辑字段覆盖(忽略null)
|
||||||
BusinessDocumentOrder afterOrder = buildAfterOrder(dbOrder, front);
|
BusinessDocumentOrder afterOrder = buildAfterOrder(dbOrder, front);
|
||||||
|
|
||||||
// 3.1 地址兼容:前端把地址放在 shipment/receipt 或 loadingAddressList/unloadAddressList,
|
|
||||||
// 映射到 loading*/unload* 扁平字段(与下单主流程 BusinessDocumentOrderDomainService 一致口径)
|
|
||||||
applyAddressMapping(afterOrder, front);
|
|
||||||
|
|
||||||
// 4. 若提供了费用明细,则 deliveryFreight(合计)=明细 amount 之和,并联动到 afterOrder
|
// 4. 若提供了费用明细,则 deliveryFreight(合计)=明细 amount 之和,并联动到 afterOrder
|
||||||
boolean hasFeeDetail = newFeeList != null && !newFeeList.isEmpty();
|
boolean hasFeeDetail = newFeeList != null && !newFeeList.isEmpty();
|
||||||
if (hasFeeDetail) {
|
if (hasFeeDetail) {
|
||||||
@@ -190,10 +149,14 @@ public class BusinessDocumentOrderAdjustService {
|
|||||||
afterOrder.setDeliveryFreight(sum);
|
afterOrder.setDeliveryFreight(sum);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 5. 判定是否修改了金额:以后端兜底比对为准,避免前端误传 false 绕过审核;
|
// 5. 判定是否修改了金额:以前端 amountChanged 为准(前端整单回传已自行判定);
|
||||||
// 前端传 true 也尊重;后端比对结果与前端 OR 运算(任一为真则需审核)。
|
// 若前端未传则后端兜底比对(主表金额列 或 明细 amount 变化)
|
||||||
boolean backendChanged = isAmountChanged(dbOrder, front, hasFeeDetail, dbFeeList, newFeeList);
|
boolean amountChanged;
|
||||||
boolean amountChanged = backendChanged || Boolean.TRUE.equals(dto.getAmountChanged());
|
if (dto.getAmountChanged() != null) {
|
||||||
|
amountChanged = dto.getAmountChanged();
|
||||||
|
} else {
|
||||||
|
amountChanged = isAmountChanged(dbOrder, front, hasFeeDetail, dbFeeList, newFeeList);
|
||||||
|
}
|
||||||
|
|
||||||
// 6. 写主记录
|
// 6. 写主记录
|
||||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||||
@@ -225,7 +188,7 @@ public class BusinessDocumentOrderAdjustService {
|
|||||||
// 8b. 涉及金额:仅把业务单 review_status 置为"调整待审核(3)",其余状态(exec/orderStatus)不动,不更新业务单数据
|
// 8b. 涉及金额:仅把业务单 review_status 置为"调整待审核(3)",其余状态(exec/orderStatus)不动,不更新业务单数据
|
||||||
BusinessDocumentOrder statusOnly = new BusinessDocumentOrder();
|
BusinessDocumentOrder statusOnly = new BusinessDocumentOrder();
|
||||||
statusOnly.setId(dbOrder.getId());
|
statusOnly.setId(dbOrder.getId());
|
||||||
statusOnly.setReviewStatus(REVIEW_ADJUST_WAIT); // 调整待审核
|
statusOnly.setReviewStatus(3L); // 调整待审核
|
||||||
businessDocumentOrderMapper.updateById(statusOnly);
|
businessDocumentOrderMapper.updateById(statusOnly);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -287,27 +250,11 @@ public class BusinessDocumentOrderAdjustService {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 按业务单查询调整记录(供订单详情页"调整记录"Tab用)
|
* 按业务单查询调整记录(供订单详情页"调整记录"Tab用)
|
||||||
* 每条记录同时带出调整后明细快照(detail),前端可自包含展示,无需再单独调详情接口
|
|
||||||
*/
|
*/
|
||||||
public List<BusinessDocumentOrderAdjustRecordDTO> listAdjustRecordByOrder(Long orderId) {
|
public List<BusinessDocumentOrderAdjustRecordDTO> listAdjustRecordByOrder(Long orderId) {
|
||||||
BusinessDocumentOrderAdjustQueryDTO query = new BusinessDocumentOrderAdjustQueryDTO();
|
BusinessDocumentOrderAdjustQueryDTO query = new BusinessDocumentOrderAdjustQueryDTO();
|
||||||
query.setOrderId(orderId);
|
query.setOrderId(orderId);
|
||||||
List<BusinessDocumentOrderAdjustRecordDTO> list = listAdjustRecord(query);
|
return listAdjustRecord(query);
|
||||||
if (list == null || list.isEmpty()) {
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
// 批量取明细快照按 adjust_id 一次性拼上,避免 N+1
|
|
||||||
List<Long> adjustIds = list.stream()
|
|
||||||
.map(BusinessDocumentOrderAdjustRecordDTO::getId)
|
|
||||||
.collect(Collectors.toList());
|
|
||||||
List<BusinessDocumentOrderAdjustDetail> details = adjustDetailMapper.selectList(
|
|
||||||
new LambdaQueryWrapper<BusinessDocumentOrderAdjustDetail>()
|
|
||||||
.in(BusinessDocumentOrderAdjustDetail::getAdjustId, adjustIds)
|
|
||||||
.eq(BusinessDocumentOrderAdjustDetail::getDelFlag, 1));
|
|
||||||
Map<Long, BusinessDocumentOrderAdjustDetail> detailMap = details.stream()
|
|
||||||
.collect(Collectors.toMap(BusinessDocumentOrderAdjustDetail::getAdjustId, d -> d, (a, b) -> a));
|
|
||||||
list.forEach(vo -> vo.setDetail(detailMap.get(vo.getId())));
|
|
||||||
return list;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -406,7 +353,6 @@ public class BusinessDocumentOrderAdjustService {
|
|||||||
syncTmsAsync(order.getGoodsNumber(), toSave);
|
syncTmsAsync(order.getGoodsNumber(), toSave);
|
||||||
} else {
|
} else {
|
||||||
adjust.setAuditStatus(AUDIT_REJECT);
|
adjust.setAuditStatus(AUDIT_REJECT);
|
||||||
adjust.setIsAudit(1); // 走到审核即说明该调整需要审核,保持 is_audit 与 audit_status 语义一致
|
|
||||||
adjust.setAuditBy(auditBy);
|
adjust.setAuditBy(auditBy);
|
||||||
adjust.setAuditByName(auditByName);
|
adjust.setAuditByName(auditByName);
|
||||||
adjust.setAuditTime(now);
|
adjust.setAuditTime(now);
|
||||||
@@ -415,11 +361,10 @@ public class BusinessDocumentOrderAdjustService {
|
|||||||
adjust.setUpdateTime(now);
|
adjust.setUpdateTime(now);
|
||||||
adjustMapper.updateById(adjust);
|
adjustMapper.updateById(adjust);
|
||||||
|
|
||||||
// 驳回:不更新业务单数据,仅把 review_status 置为「调整驳回(4)」;
|
// 驳回:不更新业务单数据,仅把 review_status 还原为调整前值(不影响其它状态)
|
||||||
// 不影响 order_status / execute_status 等其它单据状态;可再次调整提交审核
|
|
||||||
BusinessDocumentOrder statusOnly = new BusinessDocumentOrder();
|
BusinessDocumentOrder statusOnly = new BusinessDocumentOrder();
|
||||||
statusOnly.setId(adjust.getOrderId());
|
statusOnly.setId(adjust.getOrderId());
|
||||||
statusOnly.setReviewStatus(REVIEW_ADJUST_REJECT);
|
statusOnly.setReviewStatus(adjust.getBeforeReviewStatus() == null ? 0L : adjust.getBeforeReviewStatus());
|
||||||
businessDocumentOrderMapper.updateById(statusOnly);
|
businessDocumentOrderMapper.updateById(statusOnly);
|
||||||
}
|
}
|
||||||
return AjaxResult.success();
|
return AjaxResult.success();
|
||||||
@@ -438,50 +383,6 @@ public class BusinessDocumentOrderAdjustService {
|
|||||||
return after;
|
return after;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 地址兼容映射:前端整单回传时地址在 shipment/receipt 或 loadingAddressList/unloadAddressList,
|
|
||||||
* 这里统一映射到 business_document_order 的 loading 与 unload 系列扁平字段。
|
|
||||||
* 口径与 BusinessDocumentOrderDomainService 下单主流程保持一致:
|
|
||||||
* 装货取第一条地址,卸货取最后一条地址。
|
|
||||||
*/
|
|
||||||
private void applyAddressMapping(BusinessDocumentOrder after, BusinessDocumentOrder front) {
|
|
||||||
BusinessDocumentAddressMultiDTO loading = null;
|
|
||||||
BusinessDocumentAddressMultiDTO unloading = null;
|
|
||||||
|
|
||||||
// 优先取 shipment/receipt 单对象,其次取 loadingAddressList/unloadAddressList 集合
|
|
||||||
if (front.getShipment() != null) {
|
|
||||||
loading = front.getShipment();
|
|
||||||
} else if (front.getLoadingAddressList() != null && !front.getLoadingAddressList().isEmpty()) {
|
|
||||||
loading = front.getLoadingAddressList().get(0);
|
|
||||||
}
|
|
||||||
if (front.getReceipt() != null) {
|
|
||||||
unloading = front.getReceipt();
|
|
||||||
} else if (front.getUnloadAddressList() != null && !front.getUnloadAddressList().isEmpty()) {
|
|
||||||
unloading = front.getUnloadAddressList().get(front.getUnloadAddressList().size() - 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (loading != null) {
|
|
||||||
after.setLoadingAreaId(loading.getAreaCode());
|
|
||||||
after.setLoadingName(loading.getAreaName() != null ? loading.getAreaName() : loading.getAreaCode());
|
|
||||||
after.setLoadingAddress(loading.getAddress());
|
|
||||||
after.setLoadingLongitude(loading.getLongitude());
|
|
||||||
after.setLoadingLatitude(loading.getLatitude());
|
|
||||||
after.setFreighterName(loading.getContactName());
|
|
||||||
after.setLoadingPhone(loading.getContactPhone());
|
|
||||||
after.setLoadingDate(loading.getLayDate());
|
|
||||||
}
|
|
||||||
if (unloading != null) {
|
|
||||||
after.setUnloadAreaId(unloading.getAreaCode());
|
|
||||||
after.setUnloadName(unloading.getAreaName() != null ? unloading.getAreaName() : unloading.getAreaCode());
|
|
||||||
after.setUnloadAddress(unloading.getAddress());
|
|
||||||
after.setUnloadLongitude(unloading.getLongitude());
|
|
||||||
after.setUnloadLatitude(unloading.getLatitude());
|
|
||||||
after.setDischargerName(unloading.getContactName());
|
|
||||||
after.setUnloadPhone(unloading.getContactPhone());
|
|
||||||
after.setUnloadingData(unloading.getLayDate());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private BusinessDocumentOrderAdjust buildAdjust(BusinessDocumentOrder dbOrder, LoginUser u, Date now,
|
private BusinessDocumentOrderAdjust buildAdjust(BusinessDocumentOrder dbOrder, LoginUser u, Date now,
|
||||||
boolean amountChanged, String reason) {
|
boolean amountChanged, String reason) {
|
||||||
BusinessDocumentOrderAdjust adjust = new BusinessDocumentOrderAdjust();
|
BusinessDocumentOrderAdjust adjust = new BusinessDocumentOrderAdjust();
|
||||||
@@ -520,25 +421,21 @@ public class BusinessDocumentOrderAdjustService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 是否修改了金额:主表金额/费用列变化 或 明细 amount 变化
|
* 是否修改了金额:主表金额列变化 或 明细 amount 变化
|
||||||
*/
|
*/
|
||||||
private boolean isAmountChanged(BusinessDocumentOrder dbOrder, BusinessDocumentOrder front,
|
private boolean isAmountChanged(BusinessDocumentOrder dbOrder, BusinessDocumentOrder front,
|
||||||
boolean hasFeeDetail, List<BusinessOrderAccount> dbFeeList,
|
boolean hasFeeDetail, List<BusinessOrderAccount> dbFeeList,
|
||||||
List<BusinessOrderAccount> newFeeList) {
|
List<BusinessOrderAccount> newFeeList) {
|
||||||
// a) 主表金额/费用列比对(金额列用 BigDecimal 比对,字符串列用 equals 比对)
|
// a) 主表金额列比对
|
||||||
boolean mainChanged = FEE_FIELDS.stream().anyMatch(field -> {
|
boolean mainChanged = FEE_FIELDS.stream().anyMatch(field -> {
|
||||||
Object newVal = BeanUtil.getFieldValue(front, field);
|
Object newVal = BeanUtil.getFieldValue(front, field);
|
||||||
if (newVal == null) {
|
if (newVal == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
Object oldVal = BeanUtil.getFieldValue(dbOrder, field);
|
Object oldVal = BeanUtil.getFieldValue(dbOrder, field);
|
||||||
if (newVal instanceof BigDecimal || oldVal instanceof BigDecimal) {
|
BigDecimal old = oldVal == null ? BigDecimal.ZERO : (BigDecimal) oldVal;
|
||||||
BigDecimal old = oldVal == null ? BigDecimal.ZERO : new BigDecimal(oldVal.toString());
|
BigDecimal now = (BigDecimal) newVal;
|
||||||
BigDecimal now = new BigDecimal(newVal.toString());
|
|
||||||
return old.compareTo(now) != 0;
|
return old.compareTo(now) != 0;
|
||||||
}
|
|
||||||
// 字符串字段(结算币种/收款账户等)
|
|
||||||
return !newVal.toString().equals(oldVal == null ? "" : oldVal.toString());
|
|
||||||
});
|
});
|
||||||
if (mainChanged) {
|
if (mainChanged) {
|
||||||
return true;
|
return true;
|
||||||
@@ -608,74 +505,6 @@ public class BusinessDocumentOrderAdjustService {
|
|||||||
businessOrderAccountMapper.insert(acc);
|
businessOrderAccountMapper.insert(acc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 同步地址明细表(business_document_address_multi):逻辑删旧 + 按调整后扁平字段插新
|
|
||||||
syncAddressDetail(orderId, toSave, loginUser, now);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 同步地址明细表:把「调整后业务单」的装/卸货扁平字段写回 business_document_address_multi。
|
|
||||||
* 与 applyAddressMapping 口径一致(装货取第一条、卸货取最后一条),此处各保留一条。
|
|
||||||
*/
|
|
||||||
private void syncAddressDetail(Long orderId, BusinessDocumentOrder toSave, LoginUser loginUser, Date now) {
|
|
||||||
// 逻辑删旧
|
|
||||||
List<BusinessDocumentAddressMulti> oldList = businessDocumentAddressMultiMapper.selectList(
|
|
||||||
new LambdaQueryWrapper<BusinessDocumentAddressMulti>()
|
|
||||||
.eq(BusinessDocumentAddressMulti::getOrderId, String.valueOf(orderId))
|
|
||||||
.eq(BusinessDocumentAddressMulti::getDelFlag, 1));
|
|
||||||
if (oldList != null) {
|
|
||||||
for (BusinessDocumentAddressMulti old : oldList) {
|
|
||||||
old.setDelFlag(0);
|
|
||||||
old.setUpdateBy(loginUser != null ? loginUser.getUserid() : null);
|
|
||||||
old.setUpdateTime(now);
|
|
||||||
businessDocumentAddressMultiMapper.updateById(old);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Long userId = loginUser != null ? loginUser.getUserid() : null;
|
|
||||||
// 装货
|
|
||||||
BusinessDocumentAddressMulti loading = new BusinessDocumentAddressMulti();
|
|
||||||
loading.setOrderId(String.valueOf(orderId));
|
|
||||||
loading.setAreaCode(toSave.getLoadingAreaId());
|
|
||||||
loading.setAreaName(toSave.getLoadingName());
|
|
||||||
loading.setAddress(toSave.getLoadingAddress());
|
|
||||||
loading.setLongitude(toSave.getLoadingLongitude());
|
|
||||||
loading.setLatitude(toSave.getLoadingLatitude());
|
|
||||||
loading.setContactName(toSave.getFreighterName());
|
|
||||||
loading.setContactPhone(toSave.getLoadingPhone());
|
|
||||||
loading.setLayDate(toSave.getLoadingDate());
|
|
||||||
loading.setLayType(1L);
|
|
||||||
loading.setDelFlag(1);
|
|
||||||
loading.setOrganizationId(toSave.getOrganizationId());
|
|
||||||
loading.setOrganizationName(toSave.getOrganizationName());
|
|
||||||
loading.setTopOrganizationId(toSave.getTopOrganizationId());
|
|
||||||
loading.setCreateBy(userId);
|
|
||||||
loading.setCreateTime(now);
|
|
||||||
loading.setUpdateBy(userId);
|
|
||||||
loading.setUpdateTime(now);
|
|
||||||
businessDocumentAddressMultiMapper.insert(loading);
|
|
||||||
|
|
||||||
// 卸货
|
|
||||||
BusinessDocumentAddressMulti unload = new BusinessDocumentAddressMulti();
|
|
||||||
unload.setOrderId(String.valueOf(orderId));
|
|
||||||
unload.setAreaCode(toSave.getUnloadAreaId());
|
|
||||||
unload.setAreaName(toSave.getUnloadName());
|
|
||||||
unload.setAddress(toSave.getUnloadAddress());
|
|
||||||
unload.setLongitude(toSave.getUnloadLongitude());
|
|
||||||
unload.setLatitude(toSave.getUnloadLatitude());
|
|
||||||
unload.setContactName(toSave.getDischargerName());
|
|
||||||
unload.setContactPhone(toSave.getUnloadPhone());
|
|
||||||
unload.setLayDate(toSave.getUnloadingData());
|
|
||||||
unload.setLayType(2L);
|
|
||||||
unload.setDelFlag(1);
|
|
||||||
unload.setOrganizationId(toSave.getOrganizationId());
|
|
||||||
unload.setOrganizationName(toSave.getOrganizationName());
|
|
||||||
unload.setTopOrganizationId(toSave.getTopOrganizationId());
|
|
||||||
unload.setCreateBy(userId);
|
|
||||||
unload.setCreateTime(now);
|
|
||||||
unload.setUpdateBy(userId);
|
|
||||||
unload.setUpdateTime(now);
|
|
||||||
businessDocumentAddressMultiMapper.insert(unload);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void copySnapshot(BusinessDocumentOrder order, BusinessDocumentOrderAdjustDetail detail) {
|
private void copySnapshot(BusinessDocumentOrder order, BusinessDocumentOrderAdjustDetail detail) {
|
||||||
@@ -716,111 +545,10 @@ public class BusinessDocumentOrderAdjustService {
|
|||||||
if (executeOrders == null || executeOrders.isEmpty()) {
|
if (executeOrders == null || executeOrders.isEmpty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for (ExecuteOrder executeOrder : executeOrders) {
|
log.info("业务单[{}]调整完成,关联执行单[{}]。如需回写TMS请接入TMS改费Feign。", goodsNumber,
|
||||||
// 仅已下发 TMS(存在 TMS 单号)的执行单需要同步修改
|
executeOrders.stream().map(ExecuteOrder::getGoodsNumber).collect(Collectors.toList()));
|
||||||
if (StrUtil.isBlank(executeOrder.getTmsOrderNumber())) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
syncTmsOrder(executeOrder, after);
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("同步TMS失败,不影响主流程", e);
|
log.error("同步TMS失败,不影响主流程", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 同步修改单个 TMS 订单:按调整后业务单重新组装 TmsOrderAddDTO,
|
|
||||||
* 带 executeOrderNumber 定位 TMS 订单,调用 TMS /feign/order/update 接口。
|
|
||||||
*/
|
|
||||||
private void syncTmsOrder(ExecuteOrder executeOrder, BusinessDocumentOrder after) {
|
|
||||||
TmsOrderAddDTO tmsOrderAddDTO = new TmsOrderAddDTO();
|
|
||||||
BeanUtil.copyProperties(after, tmsOrderAddDTO);
|
|
||||||
// id 传 OMS 业务单主键:TMS 侧用作 tms_order_account.order_id 口径;
|
|
||||||
// TMS 的 update 在覆盖前会保留 tms_order 真实主键,不会被污染
|
|
||||||
tmsOrderAddDTO.setId(String.valueOf(after.getId()));
|
|
||||||
// TMS 侧按执行单号定位订单
|
|
||||||
tmsOrderAddDTO.setExecuteOrderId(String.valueOf(executeOrder.getId()));
|
|
||||||
tmsOrderAddDTO.setExecuteOrderNumber(executeOrder.getGoodsNumber());
|
|
||||||
tmsOrderAddDTO.setGoodsNumber(after.getGoodsNumber());
|
|
||||||
tmsOrderAddDTO.setOrderSource("0");
|
|
||||||
|
|
||||||
// TMS 侧 update 按 appointShipperId(业务单货主) 定位货主,需显式带上,口径与下单一致
|
|
||||||
if (StrUtil.isNotBlank(after.getAppointShipperId())) {
|
|
||||||
tmsOrderAddDTO.setAppointShipperId(after.getAppointShipperId());
|
|
||||||
}
|
|
||||||
if (after.getAppointShipper() != null) {
|
|
||||||
tmsOrderAddDTO.setAppointShipper(after.getAppointShipper());
|
|
||||||
}
|
|
||||||
if (after.getSzwlUserId() != null) {
|
|
||||||
tmsOrderAddDTO.setSzwlUserId(after.getSzwlUserId());
|
|
||||||
}
|
|
||||||
|
|
||||||
// 货物信息
|
|
||||||
List<BusinessDocumentCargoMulti> cargoList = businessDocumentCargoMultiMapper.selectList(
|
|
||||||
new LambdaQueryWrapper<BusinessDocumentCargoMulti>()
|
|
||||||
.eq(BusinessDocumentCargoMulti::getOrderId, String.valueOf(after.getId()))
|
|
||||||
.eq(BusinessDocumentCargoMulti::getDelFlag, 1));
|
|
||||||
List<TmsCargoInfoDTO> cargoInfoList = new ArrayList<>();
|
|
||||||
if (cargoList != null) {
|
|
||||||
for (BusinessDocumentCargoMulti cargo : cargoList) {
|
|
||||||
TmsCargoInfoDTO dto = new TmsCargoInfoDTO();
|
|
||||||
BeanUtil.copyProperties(cargo, dto);
|
|
||||||
cargoInfoList.add(dto);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
tmsOrderAddDTO.setCargoInfoList(cargoInfoList);
|
|
||||||
|
|
||||||
// 装货地址:统一以「调整后业务单」的扁平字段为准,避免明细表(business_document_address_multi)旧值覆盖
|
|
||||||
TmsAddressMultiDTO loadingDto = new TmsAddressMultiDTO();
|
|
||||||
loadingDto.setAreaCode(after.getLoadingAreaId());
|
|
||||||
loadingDto.setAreaName(after.getLoadingName());
|
|
||||||
loadingDto.setAddress(after.getLoadingAddress());
|
|
||||||
loadingDto.setLongitude(after.getLoadingLongitude());
|
|
||||||
loadingDto.setLatitude(after.getLoadingLatitude());
|
|
||||||
loadingDto.setContactName(after.getFreighterName());
|
|
||||||
loadingDto.setContactPhone(after.getLoadingPhone());
|
|
||||||
loadingDto.setLayDate(after.getLoadingDate());
|
|
||||||
loadingDto.setLayType(1);
|
|
||||||
List<TmsAddressMultiDTO> loadingAddressList = new ArrayList<>();
|
|
||||||
loadingAddressList.add(loadingDto);
|
|
||||||
tmsOrderAddDTO.setLoadingAddressList(loadingAddressList);
|
|
||||||
|
|
||||||
// 卸货地址:同样以「调整后业务单」的扁平字段为准
|
|
||||||
TmsAddressMultiDTO unloadDto = new TmsAddressMultiDTO();
|
|
||||||
unloadDto.setAreaCode(after.getUnloadAreaId());
|
|
||||||
unloadDto.setAreaName(after.getUnloadName());
|
|
||||||
unloadDto.setAddress(after.getUnloadAddress());
|
|
||||||
unloadDto.setLongitude(after.getUnloadLongitude());
|
|
||||||
unloadDto.setLatitude(after.getUnloadLatitude());
|
|
||||||
unloadDto.setContactName(after.getDischargerName());
|
|
||||||
unloadDto.setContactPhone(after.getUnloadPhone());
|
|
||||||
unloadDto.setLayDate(after.getUnloadingData());
|
|
||||||
unloadDto.setLayType(2);
|
|
||||||
List<TmsAddressMultiDTO> unloadAddressList = new ArrayList<>();
|
|
||||||
unloadAddressList.add(unloadDto);
|
|
||||||
tmsOrderAddDTO.setUnloadAddressList(unloadAddressList);
|
|
||||||
|
|
||||||
// 费用明细
|
|
||||||
List<BusinessOrderAccount> accountList = businessOrderAccountMapper.selectList(
|
|
||||||
new LambdaQueryWrapper<BusinessOrderAccount>()
|
|
||||||
.eq(BusinessOrderAccount::getOrderId, after.getId())
|
|
||||||
.eq(BusinessOrderAccount::getIsDelete, 0));
|
|
||||||
List<TmsOrderAccount> tmsOrderAccountList = new ArrayList<>();
|
|
||||||
if (accountList != null) {
|
|
||||||
for (BusinessOrderAccount acc : accountList) {
|
|
||||||
TmsOrderAccount dto = new TmsOrderAccount();
|
|
||||||
BeanUtil.copyProperties(acc, dto);
|
|
||||||
tmsOrderAccountList.add(dto);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
tmsOrderAddDTO.setTmsOrderAccountList(tmsOrderAccountList);
|
|
||||||
|
|
||||||
AjaxResult result = wlhyServiceFeign.update(tmsOrderAddDTO);
|
|
||||||
if (result != null && "200".equals(String.valueOf(result.get("code")))) {
|
|
||||||
log.info("调整后同步修改TMS订单成功,执行单[{}],业务单[{}]", executeOrder.getGoodsNumber(), after.getGoodsNumber());
|
|
||||||
} else {
|
|
||||||
log.error("调整后同步修改TMS订单失败,执行单[{}],返回: {}", executeOrder.getGoodsNumber(),
|
|
||||||
result == null ? "null" : result.get("msg"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-32
@@ -8,7 +8,6 @@ import com.mhd.common.core.web.domain.BaseVOEntity;
|
|||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
|
||||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
import org.springframework.format.annotation.DateTimeFormat;
|
import org.springframework.format.annotation.DateTimeFormat;
|
||||||
|
|
||||||
@@ -660,7 +659,7 @@ public class BusinessDocumentOrder extends BaseVOEntity{
|
|||||||
@Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()")
|
@Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()")
|
||||||
private Date documentDate;
|
private Date documentDate;
|
||||||
|
|
||||||
@ApiModelProperty( "审核状态 0-未审核 1-审核通过 2-已驳回 3-调整待审核 4-调整驳回")
|
@ApiModelProperty( "审核状态 0-未审核 1-审核通过 2-已驳回 3-调整待审核")
|
||||||
private Long reviewStatus;
|
private Long reviewStatus;
|
||||||
|
|
||||||
@ApiModelProperty("审核时间")
|
@ApiModelProperty("审核时间")
|
||||||
@@ -827,34 +826,6 @@ public class BusinessDocumentOrder extends BaseVOEntity{
|
|||||||
@Excel(name = "车次")
|
@Excel(name = "车次")
|
||||||
private String shuttleNo;
|
private String shuttleNo;
|
||||||
|
|
||||||
/**
|
@ApiModelProperty("业务单调整状态 0-无 1-调整待审核 2-调整驳回 3-调整已通过")
|
||||||
* 前端整单回传时携带的费用明细(business_order_account),非表字段,仅用于「订单调整」入参接收。
|
private Integer adjustStatus;
|
||||||
* 与顶层 feeDetailList 二选一,后端在 adjust() 中做回退兼容。
|
|
||||||
*/
|
|
||||||
@com.baomidou.mybatisplus.annotation.TableField(exist = false)
|
|
||||||
private List<com.mhd.oms.domain.businessOrderAccount.BusinessOrderAccount> businessOrderAccountList;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 前端整单回传时的装货地址(单个),非表字段,仅用于「订单调整」入参接收与映射到 loading* 扁平字段。
|
|
||||||
*/
|
|
||||||
@com.baomidou.mybatisplus.annotation.TableField(exist = false)
|
|
||||||
private com.mhd.oms.interfaces.dto.businessDocumentAddressMulti.BusinessDocumentAddressMultiDTO shipment;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 前端整单回传时的卸货地址(单个),非表字段,仅用于「订单调整」入参接收与映射到 unload* 扁平字段。
|
|
||||||
*/
|
|
||||||
@com.baomidou.mybatisplus.annotation.TableField(exist = false)
|
|
||||||
private com.mhd.oms.interfaces.dto.businessDocumentAddressMulti.BusinessDocumentAddressMultiDTO receipt;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 前端整单回传时的装货地址集合,非表字段,仅用于「订单调整」入参接收与映射。
|
|
||||||
*/
|
|
||||||
@com.baomidou.mybatisplus.annotation.TableField(exist = false)
|
|
||||||
private List<com.mhd.oms.interfaces.dto.businessDocumentAddressMulti.BusinessDocumentAddressMultiDTO> loadingAddressList;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 前端整单回传时的卸货地址集合,非表字段,仅用于「订单调整」入参接收与映射。
|
|
||||||
*/
|
|
||||||
@com.baomidou.mybatisplus.annotation.TableField(exist = false)
|
|
||||||
private List<com.mhd.oms.interfaces.dto.businessDocumentAddressMulti.BusinessDocumentAddressMultiDTO> unloadAddressList;
|
|
||||||
}
|
}
|
||||||
|
|||||||
-10
@@ -3,10 +3,8 @@ package com.mhd.oms.domain.businessDocumentOrderAdjust.entity;
|
|||||||
import com.baomidou.mybatisplus.annotation.IdType;
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import org.springframework.format.annotation.DateTimeFormat;
|
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
@@ -40,8 +38,6 @@ public class BusinessDocumentOrderAdjust implements Serializable {
|
|||||||
private String adjustByName;
|
private String adjustByName;
|
||||||
|
|
||||||
@ApiModelProperty("调整时间")
|
@ApiModelProperty("调整时间")
|
||||||
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
|
|
||||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
|
||||||
private Date adjustTime;
|
private Date adjustTime;
|
||||||
|
|
||||||
@ApiModelProperty("调整原因")
|
@ApiModelProperty("调整原因")
|
||||||
@@ -63,8 +59,6 @@ public class BusinessDocumentOrderAdjust implements Serializable {
|
|||||||
private String auditByName;
|
private String auditByName;
|
||||||
|
|
||||||
@ApiModelProperty("审核时间")
|
@ApiModelProperty("审核时间")
|
||||||
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
|
|
||||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
|
||||||
private Date auditTime;
|
private Date auditTime;
|
||||||
|
|
||||||
@ApiModelProperty("审核/驳回意见")
|
@ApiModelProperty("审核/驳回意见")
|
||||||
@@ -83,8 +77,6 @@ public class BusinessDocumentOrderAdjust implements Serializable {
|
|||||||
private String createName;
|
private String createName;
|
||||||
|
|
||||||
@ApiModelProperty("创建时间")
|
@ApiModelProperty("创建时间")
|
||||||
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
|
|
||||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
|
||||||
private Date createTime;
|
private Date createTime;
|
||||||
|
|
||||||
@ApiModelProperty("更新人")
|
@ApiModelProperty("更新人")
|
||||||
@@ -94,8 +86,6 @@ public class BusinessDocumentOrderAdjust implements Serializable {
|
|||||||
private String updateName;
|
private String updateName;
|
||||||
|
|
||||||
@ApiModelProperty("更新时间")
|
@ApiModelProperty("更新时间")
|
||||||
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
|
|
||||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
|
||||||
private Date updateTime;
|
private Date updateTime;
|
||||||
|
|
||||||
@ApiModelProperty("删除标记 1-正常 0-删除")
|
@ApiModelProperty("删除标记 1-正常 0-删除")
|
||||||
|
|||||||
-16
@@ -3,12 +3,8 @@ package com.mhd.oms.domain.businessDocumentOrderAdjustDetail.entity;
|
|||||||
import com.baomidou.mybatisplus.annotation.IdType;
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
|
||||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
|
||||||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import org.springframework.format.annotation.DateTimeFormat;
|
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
@@ -28,11 +24,9 @@ public class BusinessDocumentOrderAdjustDetail implements Serializable {
|
|||||||
|
|
||||||
@ApiModelProperty("主键")
|
@ApiModelProperty("主键")
|
||||||
@TableId(type = IdType.ASSIGN_ID)
|
@TableId(type = IdType.ASSIGN_ID)
|
||||||
@JsonSerialize(using = ToStringSerializer.class)
|
|
||||||
private Long id;
|
private Long id;
|
||||||
|
|
||||||
@ApiModelProperty("关联调整主记录ID")
|
@ApiModelProperty("关联调整主记录ID")
|
||||||
@JsonSerialize(using = ToStringSerializer.class)
|
|
||||||
private Long adjustId;
|
private Long adjustId;
|
||||||
|
|
||||||
@ApiModelProperty("业务单ID")
|
@ApiModelProperty("业务单ID")
|
||||||
@@ -57,8 +51,6 @@ public class BusinessDocumentOrderAdjustDetail implements Serializable {
|
|||||||
private String loadingAddress;
|
private String loadingAddress;
|
||||||
|
|
||||||
@ApiModelProperty("装货时间")
|
@ApiModelProperty("装货时间")
|
||||||
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
|
|
||||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
|
||||||
private Date loadingDate;
|
private Date loadingDate;
|
||||||
|
|
||||||
@ApiModelProperty("卸货地")
|
@ApiModelProperty("卸货地")
|
||||||
@@ -68,8 +60,6 @@ public class BusinessDocumentOrderAdjustDetail implements Serializable {
|
|||||||
private String unloadAddress;
|
private String unloadAddress;
|
||||||
|
|
||||||
@ApiModelProperty("卸货时间")
|
@ApiModelProperty("卸货时间")
|
||||||
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
|
|
||||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
|
||||||
private Date unloadingData;
|
private Date unloadingData;
|
||||||
|
|
||||||
@ApiModelProperty("发货人")
|
@ApiModelProperty("发货人")
|
||||||
@@ -91,8 +81,6 @@ public class BusinessDocumentOrderAdjustDetail implements Serializable {
|
|||||||
private String route;
|
private String route;
|
||||||
|
|
||||||
@ApiModelProperty("单据日期")
|
@ApiModelProperty("单据日期")
|
||||||
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
|
|
||||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
|
||||||
private Date documentDate;
|
private Date documentDate;
|
||||||
|
|
||||||
@ApiModelProperty("组织ID")
|
@ApiModelProperty("组织ID")
|
||||||
@@ -166,16 +154,12 @@ public class BusinessDocumentOrderAdjustDetail implements Serializable {
|
|||||||
private String createName;
|
private String createName;
|
||||||
|
|
||||||
@ApiModelProperty("创建时间")
|
@ApiModelProperty("创建时间")
|
||||||
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
|
|
||||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
|
||||||
private Date createTime;
|
private Date createTime;
|
||||||
|
|
||||||
@ApiModelProperty("更新人")
|
@ApiModelProperty("更新人")
|
||||||
private String updateBy;
|
private String updateBy;
|
||||||
|
|
||||||
@ApiModelProperty("更新时间")
|
@ApiModelProperty("更新时间")
|
||||||
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
|
|
||||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
|
||||||
private Date updateTime;
|
private Date updateTime;
|
||||||
|
|
||||||
@ApiModelProperty("删除标记 1-正常 0-删除")
|
@ApiModelProperty("删除标记 1-正常 0-删除")
|
||||||
|
|||||||
-12
@@ -610,12 +610,6 @@ public class OmsAddressMultiService implements IOmsAddressMultiService {
|
|||||||
List<OmsOrderAccount> tmsOrderAccountList = tmsOrderAddDTO.getTmsOrderAccountList();
|
List<OmsOrderAccount> tmsOrderAccountList = tmsOrderAddDTO.getTmsOrderAccountList();
|
||||||
if (ObjectUtil.isNotNull(tmsOrderAccountList) && tmsOrderAccountList.size() > 0) {
|
if (ObjectUtil.isNotNull(tmsOrderAccountList) && tmsOrderAccountList.size() > 0) {
|
||||||
for (OmsOrderAccount tmsOrderAccount : tmsOrderAccountList) {
|
for (OmsOrderAccount tmsOrderAccount : tmsOrderAccountList) {
|
||||||
// 防御:account_id 为空或<=0 时跳过(避免唯一约束撞库 + 插入脏数据)
|
|
||||||
if (tmsOrderAccount.getAccountId() == null || tmsOrderAccount.getAccountId() <= 0) {
|
|
||||||
log.warn("订单费用科目 accountId 为空,已跳过该条, orderId={}, subjectName={}",
|
|
||||||
resevationOrder.getId(), tmsOrderAccount.getSubjectName());
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
tmsOrderAccount.setIsDelete(0);
|
tmsOrderAccount.setIsDelete(0);
|
||||||
tmsOrderAccount.setOrderId(String.valueOf(resevationOrder.getId()));
|
tmsOrderAccount.setOrderId(String.valueOf(resevationOrder.getId()));
|
||||||
tmsOrderAccount.setCreateBy(String.valueOf(userPo.getUserId()));
|
tmsOrderAccount.setCreateBy(String.valueOf(userPo.getUserId()));
|
||||||
@@ -1125,12 +1119,6 @@ public class OmsAddressMultiService implements IOmsAddressMultiService {
|
|||||||
|
|
||||||
// 插入新的费用科目信息
|
// 插入新的费用科目信息
|
||||||
for (OmsOrderAccount tmsOrderAccount : tmsOrderAccountList) {
|
for (OmsOrderAccount tmsOrderAccount : tmsOrderAccountList) {
|
||||||
// 防御:account_id 为空或<=0 时跳过
|
|
||||||
if (tmsOrderAccount.getAccountId() == null || tmsOrderAccount.getAccountId() <= 0) {
|
|
||||||
log.warn("订单费用科目 accountId 为空,已跳过该条, orderId={}, subjectName={}",
|
|
||||||
resevationOrder.getId(), tmsOrderAccount.getSubjectName());
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
tmsOrderAccount.setIsDelete(0);
|
tmsOrderAccount.setIsDelete(0);
|
||||||
tmsOrderAccount.setOrderId(String.valueOf(resevationOrder.getId()));
|
tmsOrderAccount.setOrderId(String.valueOf(resevationOrder.getId()));
|
||||||
tmsOrderAccount.setCreateBy(String.valueOf(userPo.getUserId()));
|
tmsOrderAccount.setCreateBy(String.valueOf(userPo.getUserId()));
|
||||||
|
|||||||
-9
@@ -1,12 +1,8 @@
|
|||||||
package com.mhd.oms.interfaces.dto.businessDocumentOrderAdjust;
|
package com.mhd.oms.interfaces.dto.businessDocumentOrderAdjust;
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
|
||||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
|
||||||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
|
||||||
import com.mhd.oms.domain.businessDocumentOrderAdjustDetail.entity.BusinessDocumentOrderAdjustDetail;
|
import com.mhd.oms.domain.businessDocumentOrderAdjustDetail.entity.BusinessDocumentOrderAdjustDetail;
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import org.springframework.format.annotation.DateTimeFormat;
|
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
@@ -20,7 +16,6 @@ public class BusinessDocumentOrderAdjustRecordDTO implements Serializable {
|
|||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
@ApiModelProperty("主记录ID")
|
@ApiModelProperty("主记录ID")
|
||||||
@JsonSerialize(using = ToStringSerializer.class)
|
|
||||||
private Long id;
|
private Long id;
|
||||||
|
|
||||||
@ApiModelProperty("业务单ID")
|
@ApiModelProperty("业务单ID")
|
||||||
@@ -36,8 +31,6 @@ public class BusinessDocumentOrderAdjustRecordDTO implements Serializable {
|
|||||||
private String adjustByName;
|
private String adjustByName;
|
||||||
|
|
||||||
@ApiModelProperty("调整时间")
|
@ApiModelProperty("调整时间")
|
||||||
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
|
|
||||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
|
||||||
private Date adjustTime;
|
private Date adjustTime;
|
||||||
|
|
||||||
@ApiModelProperty("调整原因")
|
@ApiModelProperty("调整原因")
|
||||||
@@ -56,8 +49,6 @@ public class BusinessDocumentOrderAdjustRecordDTO implements Serializable {
|
|||||||
private String auditByName;
|
private String auditByName;
|
||||||
|
|
||||||
@ApiModelProperty("审核时间")
|
@ApiModelProperty("审核时间")
|
||||||
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
|
|
||||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
|
||||||
private Date auditTime;
|
private Date auditTime;
|
||||||
|
|
||||||
@ApiModelProperty("审核/驳回意见")
|
@ApiModelProperty("审核/驳回意见")
|
||||||
|
|||||||
@@ -19,14 +19,14 @@ spring:
|
|||||||
# server-addr: 127.0.0.1:8848
|
# server-addr: 127.0.0.1:8848
|
||||||
# 线上测试环境配置 容器名+端口号
|
# 线上测试环境配置 容器名+端口号
|
||||||
# server-addr: 10.33.0.129:6010
|
# server-addr: 10.33.0.129:6010
|
||||||
server-addr: 10.102.192.30:6848
|
server-addr: 10.102.192.31:6848
|
||||||
username: nacos
|
username: nacos
|
||||||
password: manhuoda@2023
|
password: manhuoda@2023
|
||||||
config:
|
config:
|
||||||
# server-addr: 127.0.0.1:8848
|
# server-addr: 127.0.0.1:8848
|
||||||
# 线上测试环境配置 容器名+端口号
|
# 线上测试环境配置 容器名+端口号
|
||||||
# server-addr: 10.33.0.129:6010
|
# server-addr: 10.33.0.129:6010
|
||||||
server-addr: 10.102.192.30:6848
|
server-addr: 10.102.192.31:6848
|
||||||
username: nacos
|
username: nacos
|
||||||
password: manhuoda@2023
|
password: manhuoda@2023
|
||||||
#线上正式环境
|
#线上正式环境
|
||||||
|
|||||||
+5
-3
@@ -32,6 +32,7 @@ import lombok.extern.slf4j.Slf4j;
|
|||||||
import org.apache.poi.ss.formula.functions.T;
|
import org.apache.poi.ss.formula.functions.T;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import java.text.ParseException;
|
import java.text.ParseException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -205,12 +206,13 @@ public class HandoverTaskOrderApplicationService {
|
|||||||
* @param handoverTaskOrderDO
|
* @param handoverTaskOrderDO
|
||||||
* @return Boolean
|
* @return Boolean
|
||||||
*/
|
*/
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public Boolean completeHandover(HandoverTaskOrderDO handoverTaskOrderDO){
|
public Boolean completeHandover(HandoverTaskOrderDO handoverTaskOrderDO){
|
||||||
Boolean result = handoverTaskOrderDomainService.completeHandover(handoverTaskOrderDO);
|
Boolean result = handoverTaskOrderDomainService.completeHandover(handoverTaskOrderDO);
|
||||||
List<MaterialInventoryParamDO> clearoutParamDOs = handoverTaskOrderDomainService.getLastClearoutParamDOs();
|
List<MaterialInventoryParamDO> clearoutParamDOs = handoverTaskOrderDomainService.getLastClearoutParamDOs();
|
||||||
for (MaterialInventoryParamDO paramDO : clearoutParamDOs) {
|
// for (MaterialInventoryParamDO paramDO : clearoutParamDOs) {
|
||||||
materialInventoryApplicationService.pushBillingRecordClearout(paramDO.getMaterialInventoryId(), paramDO.getQuantity());
|
// materialInventoryApplicationService.pushBillingRecordClearout(paramDO.getMaterialInventoryId(), paramDO.getQuantity());
|
||||||
}
|
// }
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -994,7 +994,7 @@ public class MaterialInventoryImpl extends ServiceImpl<MaterialInventoryMapper,
|
|||||||
MaterialInventory materialInventory = new MaterialInventory();
|
MaterialInventory materialInventory = new MaterialInventory();
|
||||||
materialInventoryPO.setUpdateTime(new Date());
|
materialInventoryPO.setUpdateTime(new Date());
|
||||||
com.mhd.common.core.utils.bean.BeanUtils.copyProperties(materialInventoryPO, materialInventory);
|
com.mhd.common.core.utils.bean.BeanUtils.copyProperties(materialInventoryPO, materialInventory);
|
||||||
materialInventoryMapper.updateById(materialInventory);
|
materialInventoryMapper.updateById(materialInventoryPO);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private void qxff(BigDecimal netWeight, BigDecimal grossWeight, BigDecimal volume, BigDecimal area, BigDecimal quantity, Long materialInventoryId) {
|
private void qxff(BigDecimal netWeight, BigDecimal grossWeight, BigDecimal volume, BigDecimal area, BigDecimal quantity, Long materialInventoryId) {
|
||||||
@@ -1092,7 +1092,7 @@ public class MaterialInventoryImpl extends ServiceImpl<MaterialInventoryMapper,
|
|||||||
materialInventoryPO.setUpdateTime(new Date());
|
materialInventoryPO.setUpdateTime(new Date());
|
||||||
MaterialInventory materialInventory = new MaterialInventory();
|
MaterialInventory materialInventory = new MaterialInventory();
|
||||||
com.mhd.common.core.utils.bean.BeanUtils.copyProperties(materialInventoryPO, materialInventory);
|
com.mhd.common.core.utils.bean.BeanUtils.copyProperties(materialInventoryPO, materialInventory);
|
||||||
materialInventoryMapper.updateById(materialInventory);
|
materialInventoryMapper.updateById(materialInventoryPO);
|
||||||
|
|
||||||
Long warehouseId = materialInventoryPO.getWarehouseId();
|
Long warehouseId = materialInventoryPO.getWarehouseId();
|
||||||
boolean needPush = false;
|
boolean needPush = false;
|
||||||
|
|||||||
+3
-1
@@ -860,7 +860,9 @@ public class StockShelfOrderDomainService {
|
|||||||
//修改入库单状态: 1-已创建 2-已审核 3-收货中 4-上架中 5-已入库
|
//修改入库单状态: 1-已创建 2-已审核 3-收货中 4-上架中 5-已入库
|
||||||
updateStockInOrder(stockShelfOrderPO, 5);
|
updateStockInOrder(stockShelfOrderPO, 5);
|
||||||
//上架修改物料库存
|
//上架修改物料库存
|
||||||
List<ShelfMaterialDetail> shelfMaterialDetailList = shelfMaterialDetailService.list(new QueryWrapper<ShelfMaterialDetail>().lambda().eq(ShelfMaterialDetail::getShelfOrderNumber, stockShelfOrderPO.getShelfOrderNumber()));
|
List<ShelfMaterialDetail> shelfMaterialDetailList = shelfMaterialDetailService.list(new QueryWrapper<ShelfMaterialDetail>().lambda()
|
||||||
|
.eq(ShelfMaterialDetail::getShelfOrderNumber, stockShelfOrderPO.getShelfOrderNumber())
|
||||||
|
.eq(ShelfMaterialDetail::getDelFlag, 1));
|
||||||
//修改库存
|
//修改库存
|
||||||
StockShelfOrderDO stockShelfOrderDO = new StockShelfOrderDO();
|
StockShelfOrderDO stockShelfOrderDO = new StockShelfOrderDO();
|
||||||
BeanUtils.copyProperties(stockShelfOrderPO, stockShelfOrderDO);
|
BeanUtils.copyProperties(stockShelfOrderPO, stockShelfOrderDO);
|
||||||
|
|||||||
@@ -9,46 +9,46 @@ import org.springframework.context.annotation.Configuration;
|
|||||||
/**
|
/**
|
||||||
* XXL-JOB 配置类
|
* XXL-JOB 配置类
|
||||||
*/
|
*/
|
||||||
@Configuration
|
//@Configuration
|
||||||
public class XxlJobConfig {
|
public class XxlJobConfig {
|
||||||
private Logger logger = LoggerFactory.getLogger(XxlJobConfig.class);
|
// private Logger logger = LoggerFactory.getLogger(XxlJobConfig.class);
|
||||||
|
//
|
||||||
@Value("${xxl.job.admin.addresses}")
|
// @Value("${xxl.job.admin.addresses}")
|
||||||
private String adminAddresses;
|
// private String adminAddresses;
|
||||||
|
//
|
||||||
@Value("${xxl.job.accessToken}")
|
// @Value("${xxl.job.accessToken}")
|
||||||
private String accessToken;
|
// private String accessToken;
|
||||||
|
//
|
||||||
@Value("${xxl.job.executor.appname}")
|
// @Value("${xxl.job.executor.appname}")
|
||||||
private String appname;
|
// private String appname;
|
||||||
|
//
|
||||||
@Value("${xxl.job.executor.address}")
|
// @Value("${xxl.job.executor.address}")
|
||||||
private String address;
|
// private String address;
|
||||||
|
//
|
||||||
@Value("${xxl.job.executor.ip}")
|
// @Value("${xxl.job.executor.ip}")
|
||||||
private String ip;
|
// private String ip;
|
||||||
|
//
|
||||||
@Value("${xxl.job.executor.port}")
|
// @Value("${xxl.job.executor.port}")
|
||||||
private int port;
|
// private int port;
|
||||||
|
//
|
||||||
@Value("${xxl.job.executor.logpath}")
|
// @Value("${xxl.job.executor.logpath}")
|
||||||
private String logPath;
|
// private String logPath;
|
||||||
|
//
|
||||||
@Value("${xxl.job.executor.logretentiondays}")
|
// @Value("${xxl.job.executor.logretentiondays}")
|
||||||
private int logRetentionDays;
|
// private int logRetentionDays;
|
||||||
|
//
|
||||||
@Bean
|
// @Bean
|
||||||
public XxlJobSpringExecutor xxlJobExecutor() {
|
// public XxlJobSpringExecutor xxlJobExecutor() {
|
||||||
logger.info(">>>>>>>>>>> xxl-job config init.");
|
// logger.info(">>>>>>>>>>> xxl-job config init.");
|
||||||
XxlJobSpringExecutor xxlJobSpringExecutor = new XxlJobSpringExecutor();
|
// XxlJobSpringExecutor xxlJobSpringExecutor = new XxlJobSpringExecutor();
|
||||||
xxlJobSpringExecutor.setAdminAddresses(adminAddresses);
|
// xxlJobSpringExecutor.setAdminAddresses(adminAddresses);
|
||||||
xxlJobSpringExecutor.setAppname(appname);
|
// xxlJobSpringExecutor.setAppname(appname);
|
||||||
xxlJobSpringExecutor.setAddress(address);
|
// xxlJobSpringExecutor.setAddress(address);
|
||||||
xxlJobSpringExecutor.setIp(ip);
|
// xxlJobSpringExecutor.setIp(ip);
|
||||||
xxlJobSpringExecutor.setPort(port);
|
// xxlJobSpringExecutor.setPort(port);
|
||||||
xxlJobSpringExecutor.setAccessToken(accessToken);
|
// xxlJobSpringExecutor.setAccessToken(accessToken);
|
||||||
xxlJobSpringExecutor.setLogPath(logPath);
|
// xxlJobSpringExecutor.setLogPath(logPath);
|
||||||
xxlJobSpringExecutor.setLogRetentionDays(logRetentionDays);
|
// xxlJobSpringExecutor.setLogRetentionDays(logRetentionDays);
|
||||||
return xxlJobSpringExecutor;
|
// return xxlJobSpringExecutor;
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
@@ -16,7 +16,7 @@ spring:
|
|||||||
# server-addr: 127.0.0.1:8848
|
# server-addr: 127.0.0.1:8848
|
||||||
# server-addr: 10.33.0.129:6010
|
# server-addr: 10.33.0.129:6010
|
||||||
# 线上测试环境配置 容器名+端口号
|
# 线上测试环境配置 容器名+端口号
|
||||||
server-addr: 10.102.192.30:6848
|
server-addr: 10.102.192.31:6848
|
||||||
username: nacos
|
username: nacos
|
||||||
password: manhuoda@2023
|
password: manhuoda@2023
|
||||||
#线上正式环境
|
#线上正式环境
|
||||||
@@ -25,7 +25,7 @@ spring:
|
|||||||
# server-addr: 127.0.0.1:8848
|
# server-addr: 127.0.0.1:8848
|
||||||
# server-addr: 10.33.0.129:6010
|
# server-addr: 10.33.0.129:6010
|
||||||
# 线上测试环境配置 容器名+端口号
|
# 线上测试环境配置 容器名+端口号
|
||||||
server-addr: 10.102.192.30:6848
|
server-addr: 10.102.192.31:6848
|
||||||
username: nacos
|
username: nacos
|
||||||
password: manhuoda@2023
|
password: manhuoda@2023
|
||||||
#线上正式环境
|
#线上正式环境
|
||||||
|
|||||||
@@ -1864,7 +1864,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
LEFT JOIN NGWL_TEST_BMS.SETTLEMENT_CUSTOMERS bms ON sys.SETTLEMENT_CUSTOMERS_ID = bms.SETTLEMENT_CUSTOMERS_ID
|
LEFT JOIN NGWL_TEST_BMS.SETTLEMENT_CUSTOMERS bms ON sys.SETTLEMENT_CUSTOMERS_ID = bms.SETTLEMENT_CUSTOMERS_ID
|
||||||
WHERE
|
WHERE
|
||||||
1 = 1
|
1 = 1
|
||||||
AND sys.CONTRACT_MANAGE_ID = #{contractManageId} AND sys.DEL_FLAG = 1
|
AND CONTRACT_MANAGE_ID = #{contractManageId} AND DEL_FLAG = 1
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user