Merge branch 'dev' into updateMenu

This commit is contained in:
2025-12-19 14:54:11 +08:00
111 changed files with 5168 additions and 177 deletions

View File

@ -0,0 +1,66 @@
package org.dromara.bigscreen.controller;
import lombok.RequiredArgsConstructor;
import org.dromara.bigscreen.domain.bo.DpznglBo;
import org.dromara.bigscreen.domain.vo.DpznglAqyVo;
import org.dromara.bigscreen.domain.vo.DpznglVo;
import org.dromara.bigscreen.service.DpzaglService;
import org.dromara.common.core.domain.R;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/**
* 大屏-质安管理
*
* @author Lion Li
* @date 2025-11-05
*/
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/dpzagl")
public class DpzaglController {
private final DpzaglService dpzaglService;
/**
* 查询大屏-质安管理-站班会,巡检工单,整改情况
*/
@GetMapping("/list")
public R<DpznglVo> list(DpznglBo bo) {
return R.ok(dpzaglService.queryList(bo));
}
/**
* 查询大屏-质安管理-站班会
*/
@GetMapping("/listByzbh")
public R<DpznglVo> listByzbh(DpznglBo bo) {
return R.ok(dpzaglService.listByzbh(bo));
}
/**
* 查询大屏-质安管理-安全员分布情况
*/
@GetMapping("/listByAqy")
public R<List<DpznglAqyVo>> listByAqy(DpznglBo bo) {
return R.ok(dpzaglService.listByAqy(bo));
}
}

View File

@ -0,0 +1,133 @@
package org.dromara.bigscreen.controller;
import jakarta.annotation.Resource;
import lombok.RequiredArgsConstructor;
import org.dromara.bigscreen.domain.vo.*;
import org.dromara.bigscreen.service.IMaterialsManagementService;
import org.dromara.cailiaoshebei.domain.vo.BusPurchaseDocVo;
import org.dromara.cailiaoshebei.service.IBusMrpBaseService;
import org.dromara.cailiaoshebei.service.IBusPurchaseDocService;
import org.dromara.common.core.domain.R;
import org.dromara.common.web.core.BaseController;
import org.dromara.manager.ys7manager.Ys7Manager;
import org.dromara.materials.domain.vo.materials.MatMaterialsUseDetailVo;
import org.dromara.materials.service.IMatMaterialsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/**
* 物资管理
*/
@Validated
@RestController
@RequiredArgsConstructor
@RequestMapping("/materialsManagement")
public class MaterialsManagementController extends BaseController {
@Autowired
private IMaterialsManagementService materialsManagementService;
@Autowired
private IBusPurchaseDocService busPurchaseDocService;
@Autowired
private IBusMrpBaseService busMrpBaseService;
@Autowired
private IMatMaterialsService materialsService;
@Resource
private Ys7Manager ys7Manager;
/**
* 库存结构分析
* @return
*/
@GetMapping("/inventoryStructureAnalysis")
public R<InventoryStructureAnalysisVo> inventoryStructureAnalysis(Long projectId) {
return R.ok(materialsManagementService.inventoryStructureAnalysis(projectId));
}
/**
* 采购单
* @return
*/
@GetMapping("/purchaseNote")
public R<List<BusPurchaseDocVo>> purchaseNote(Long projectId) {
return R.ok(busPurchaseDocService.purchaseNote(projectId));
}
/**
* 获取采购单详情
* @return
*/
@GetMapping("/purchaseNoteDetail")
public R<BusPurchaseDocVo> purchaseNoteDetail(Long id) {
return R.ok(busPurchaseDocService.queryById(id));
}
/**
* 获取采购单详情PDF
*/
@GetMapping("/purchaseNoteDetailPdf")
public R<String> purchaseNoteDetailPdf(Long id) {
return R.ok(busPurchaseDocService.queryPicBase64ById(id));
}
/**
* 设计量与到货量对比
*/
@GetMapping("/designAndArrivalComparison")
public R<List<designAndArrivalComparisonVo>> designAndArrivalComparison(Long projectId) {
return R.ok(busMrpBaseService.designAndArrivalComparison(projectId));
}
/**
* 物资需求与实际到货对比
*/
@GetMapping("/wzxqysjdhdb")
public R<List<wzxqysjdhdbVo>> wzxqysjdhdb(Long projectId) {
return R.ok(busMrpBaseService.wzxqysjdhdb(projectId));
}
/**
* 消耗趋势对比
*/
@GetMapping("/xhqsdb")
public R<List<xhqsdbVo>> xhqsdb(Long projectId) {
return R.ok(materialsManagementService.xhqsdb(projectId));
}
/**
* 获取材料使用详情列表
*/
@GetMapping("/listUseDetail")
public R<List<MatMaterialsUseDetailVo>> listUseDetail(Long projectId) {
return R.ok(materialsService.listUseDetail(projectId));
}
/**
* 仓库实时监控
*/
@GetMapping("/warehouseMonitoring")
public R<List<WarehouseMonitoringVo>> warehouseMonitoring(Long projectId) {
return R.ok(materialsManagementService.warehouseMonitoring(projectId));
}
/**
* 监控以及仓库出入库详情
*/
@GetMapping("/warehouseInAndOutDetail")
public R<List<StockInAndStockOutRecordVo>> warehouseInAndOutDetail(Long projectId, Long warehouseId) {
return R.ok(materialsManagementService.warehouseInAndOutDetail(projectId, warehouseId));
}
/**
* 获取YS7摄像头token
*/
@GetMapping("/get/token")
public R<String> getToken() {
return R.ok("操作成功", ys7Manager.getToken());
}
}

View File

@ -0,0 +1,80 @@
package org.dromara.bigscreen.controller;
import jakarta.annotation.Resource;
import jakarta.validation.constraints.NotNull;
import lombok.RequiredArgsConstructor;
import org.dromara.bigscreen.domain.dto.ProjectImageProgressDetailReq;
import org.dromara.bigscreen.domain.progress.DesignProgressVo;
import org.dromara.bigscreen.domain.progress.MaterialProgressDetailVo;
import org.dromara.bigscreen.domain.progress.MilestoneProgressVo;
import org.dromara.bigscreen.domain.progress.ProjectTotalProgressVo;
import org.dromara.bigscreen.domain.vo.ProjectImageProgressDetailVo;
import org.dromara.bigscreen.service.ProgressBigScreenService;
import org.dromara.common.core.domain.R;
import org.dromara.common.web.core.BaseController;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/**
* 进度管理大屏接口
*
* @author lilemy
* @date 2025-12-15 11:35
*/
@Validated
@RestController
@RequiredArgsConstructor
@RequestMapping("/progress/big/screen")
public class ProgressBigScreenController extends BaseController {
@Resource
private ProgressBigScreenService progressBigScreenService;
/**
* 获取项目总进度
*/
@GetMapping("/projectTotalProgress/{projectId}")
public R<ProjectTotalProgressVo> getProjectTotalProgress(@NotNull(message = "项目主键不能为空")
@PathVariable Long projectId) {
return R.ok(progressBigScreenService.getProjectTotalProgress(projectId));
}
/**
* 获取里程碑进度
*/
@GetMapping("/milestoneProgress/{projectId}")
public R<List<MilestoneProgressVo>> getMilestoneProgress(@NotNull(message = "项目主键不能为空")
@PathVariable Long projectId) {
return R.ok(progressBigScreenService.getMilestoneProgress(projectId));
}
/**
* 获取设计进度
*/
@GetMapping("/designProgress/{projectId}")
public R<DesignProgressVo> getDesignProgress(@NotNull(message = "项目主键不能为空")
@PathVariable Long projectId) {
return R.ok(progressBigScreenService.getDesignProgress(projectId));
}
/**
* 获取施工进度详情
*/
@GetMapping("/constructionProgress/detail")
public R<List<ProjectImageProgressDetailVo>> getProjectTotalProgressDetail(@Validated ProjectImageProgressDetailReq req) {
return R.ok(progressBigScreenService.getProjectTotalProgressDetail(req));
}
/**
* 获取材料进度详情
*/
@GetMapping("/materialProgress/detail")
public R<List<MaterialProgressDetailVo>> getMaterialProgressDetail(Long project, String name, String specification) {
return R.ok(progressBigScreenService.getMaterialProgressDetail(project, name, specification));
}
}

View File

@ -0,0 +1,41 @@
package org.dromara.bigscreen.domain.bo;
import lombok.Data;
import java.io.Serializable;
import java.time.LocalDate;
@Data
public class DpznglBo implements Serializable {
/**
* 分页大小
*/
private Integer pageSize = 10;
/**
* 当前页数
*/
private Integer pageNum = 1;
/**
* 项目id
*/
private Long projectId;
/**
* 开始时间
*/
private LocalDate startDate;
/**
* 结束时间
*/
private LocalDate endDate;
}

View File

@ -27,4 +27,9 @@ public class ProjectImageProgressDetailReq implements Serializable {
*/
@NotNull(message = "进度名称不能为空")
private String progressName;
/**
* 是否查询光伏场区所有数据
*/
private Boolean isAll = false;
}

View File

@ -0,0 +1,27 @@
package org.dromara.bigscreen.domain.progress;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.math.BigDecimal;
/**
* @author lilemy
* @date 2025-12-15 17:30
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
public class DesignProgressMajorVo {
/**
* 专业名称
*/
private String majorName;
/**
* 完成率
*/
private BigDecimal completionRate;
}

View File

@ -0,0 +1,94 @@
package org.dromara.bigscreen.domain.progress;
import lombok.Data;
import java.io.Serial;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.List;
/**
* @author lilemy
* @date 2025-12-15 17:07
*/
@Data
public class DesignProgressVo implements Serializable {
@Serial
private static final long serialVersionUID = 379443600182489913L;
/**
* 总设计任务进度
*/
private Long totalDesignProgress;
/**
* 当前设计任务进度
*/
private Long currentDesignProgress;
/**
* 设计任务进度趋势
*/
private Boolean designProgressTrend;
/**
* 设计任务进度环比
*/
private BigDecimal designProgressRate;
/**
* 总设计
*/
private Long totalDesign;
/**
* 已审核设计
*/
private Long reviewedDesign;
/**
* 已审核设计进度趋势
*/
private Boolean reviewedDesignTrend;
/**
* 已审核设计进度环比
*/
private BigDecimal reviewedDesignRate;
/**
* 待审核设计
*/
private Long pendingDesignReview;
/**
* 待审核设计进度趋势
*/
private Boolean pendingDesignReviewTrend;
/**
* 待审核设计进度环比
*/
private BigDecimal pendingDesignReviewRate;
/**
* 已逾期设计
*/
private Long delayedDesign;
/**
* 已逾期设计进度趋势
*/
private Boolean delayedDesignTrend;
/**
* 已逾期设计进度环比
*/
private BigDecimal delayedDesignRate;
/**
* 设计专业详情
*/
List<DesignProgressMajorVo> majorList;
}

View File

@ -0,0 +1,73 @@
package org.dromara.bigscreen.domain.progress;
import lombok.Data;
import java.io.Serial;
import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDate;
/**
* @author lilemy
* @date 2025-12-16 17:03
*/
@Data
public class MaterialProgressDetailVo implements Serializable {
@Serial
private static final long serialVersionUID = -4499381537680421083L;
/**
* 主键id
*/
private Long id;
/**
* 名称
*/
private String name;
/**
* 数量
*/
private BigDecimal quantity;
/**
* 验收
*/
private BigDecimal acceptedQuantity;
/**
* 缺件
*/
private BigDecimal shortageQuantity;
// region 接收单数据
/**
* 表单编号
*/
private String formCode;
/**
* 合同名称
*/
private String contractName;
/**
* 订货单位
*/
private String orderingUnit;
/**
* 供货单位
*/
private String supplierUnit;
/**
* 到货时间
*/
private LocalDate arrivalDate;
// endregion
}

View File

@ -0,0 +1,64 @@
package org.dromara.bigscreen.domain.progress;
import lombok.Data;
import java.io.Serial;
import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDate;
/**
* @author lilemy
* @date 2025-12-15 16:15
*/
@Data
public class MilestoneProgressVo implements Serializable {
@Serial
private static final long serialVersionUID = 5731146976460407811L;
/**
* 主键 ID
*/
private Long id;
/**
* 节点名称
*/
private String nodeName;
/**
* 对应项目结构
*/
private Long projectStructure;
/**
* 对应项目结构名称
*/
private String projectStructureName;
/**
* 预计开始时间
*/
private LocalDate planStartDate;
/**
* 预计结束时间
*/
private LocalDate planEndDate;
/**
* 实际开始时间
*/
private LocalDate practicalStartDate;
/**
* 实际结束时间
*/
private LocalDate practicalEndDate;
/**
* 当前进度
*/
private BigDecimal currentProgress;
}

View File

@ -0,0 +1,37 @@
package org.dromara.bigscreen.domain.progress;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.math.BigDecimal;
/**
* @author lilemy
* @date 2025-12-15 14:40
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
public class ProjectTotalProgressDetailVo {
/**
* 名称
*/
private String name;
/**
* 实际进度
*/
private BigDecimal actualProgress;
/**
* 计划进度
*/
private BigDecimal planProgress;
/**
* 完成率
*/
private BigDecimal completionRate;
}

View File

@ -0,0 +1,49 @@
package org.dromara.bigscreen.domain.progress;
import lombok.Data;
import java.io.Serial;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.List;
/**
* @author lilemy
* @date 2025-12-15 14:23
*/
@Data
public class ProjectTotalProgressVo implements Serializable {
@Serial
private static final long serialVersionUID = -5706098940478706815L;
/**
* 总进度
*/
private BigDecimal totalProgress;
/**
* 总计划工期(天)
*/
private Long totalPlannedDuration;
/**
* 当前计划工期(天)
*/
private Long currentPlannedDuration;
/**
* 总完成情况(万元)
*/
private BigDecimal totalCompletionAmount;
/**
* 当前完成情况(万元)
*/
private BigDecimal currentCompletionAmount;
/**
* 详情
*/
private List<ProjectTotalProgressDetailVo> detailList;
}

View File

@ -0,0 +1,37 @@
package org.dromara.bigscreen.domain.vo;
import com.google.type.Decimal;
import lombok.Data;
import org.dromara.common.translation.annotation.Translation;
import org.dromara.common.translation.constant.TransConstant;
import java.io.Serializable;
import java.math.BigDecimal;
@Data
public class DpznglAqyVo implements Serializable {
private Long userId;
@Translation(type = TransConstant.USER_ID_TO_NICKNAME, mapper = "userId")
private String userName;
/**
* 经度
*/
private BigDecimal locLatitude;
/**
* 纬度
*/
private BigDecimal locLongitude;
/**
* 是否在岗
*/
private String sfzg ;
}

View File

@ -0,0 +1,103 @@
package org.dromara.bigscreen.domain.vo;
import lombok.Data;
import org.dromara.quality.domain.vo.qualityinspection.QltQualityInspectionVo;
import org.dromara.safety.domain.vo.safetyinspection.HseSafetyInspectionVo;
import org.dromara.safety.domain.vo.teammeeting.HseTeamMeetingVo;
import java.io.Serializable;
import java.util.List;
@Data
public class DpznglVo implements Serializable {
/**
* 站班会
*/
private List<HseTeamMeetingVo> zbhList;
// 质量管理
/**
* 质量总数
*/
private Long zlZS;
/**
* 质量数据
*/
private List<QltQualityInspectionVo> zlList;
/**
* 质量 专项检查
*/
private Long zxjcZl;
/**
* 质量 定期检查
*/
private Long dqjcZl;
/**
* 质量 日常巡检
*/
private Long rcxjZl;
/**
* 质量 整改数量
*/
private Long zlZgsl;
/**
* 质量数据-整改
*/
private List<QltQualityInspectionVo> zlZgList;
// 安全管理
/**
* 安全总数
*/
private Long aqZS;
/**
* 安全数据
*/
private List<HseSafetyInspectionVo> aqList;
/**
* 安全 专项检查
*/
private Long zxjcAq;
/**
* 安全定期检查
*/
private Long dqjcAq;
/**
* 安全 日常巡检
*/
private Long rcxjAq;
/**
* 安全 整改数量
*/
private Long aqZgsl;
/**
* 安全数据-整改
*/
private List<HseSafetyInspectionVo> aqZgList;
}

View File

@ -0,0 +1,68 @@
package org.dromara.bigscreen.domain.vo;
import lombok.Data;
import java.io.Serializable;
import java.math.BigDecimal;
@Data
public class InventoryStructureAnalysisVo implements Serializable {
/**
* 本月入库总价
*/
public BigDecimal enterTotalPrices;
/**
* 上月入库总价
*/
public BigDecimal oldEnterTotalPrices;
/**
* 本月出库总价
*/
public BigDecimal leaveTotalPrices;
/**
* 上月出库总价
*/
public BigDecimal oldLeaveTotalPrices;
/**
* 库存总价
*/
public BigDecimal inventoryTotalPrices;
/**
* 出库总价
*/
public BigDecimal outTotalPrices;
/**
* 库存逆变器总价
*/
public BigDecimal inventoryInverterTotalPrices;
/**
* 库存箱变总价
*/
public BigDecimal inventoryBoxTransformerTotalPrices;
/**
* 库存光伏支架总价
*/
public BigDecimal inventoryPhotovoltaicSupportTotalPrices;
/**
* 库存环网柜总价
*/
public BigDecimal inventoryCircuitBreakerTotalPrices;
/**
* 当前库存总价
*/
public BigDecimal nowInventoryTotalPrices;
}

View File

@ -41,6 +41,11 @@ public class ProjectImageProgressDetailVo implements Serializable {
*/
private BigDecimal totalProgress;
/**
* 完成率
*/
private BigDecimal completionRate;
/**
* 单位
*/

View File

@ -0,0 +1,46 @@
package org.dromara.bigscreen.domain.vo;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
/**
* 仓库出入库列表
*/
@Data
public class StockInAndStockOutRecordVo implements Serializable {
/**
* id
*/
public Long id;
/**
* 材料名称
*/
public String name;
/**
* 库存数量
*/
public Long inventoryNumber;
/**
* 出入库数量
*/
public Long inAndOutNumber;
/**
* 出入库类型0、入库1、出库
*/
public String type;
/**
* 出入库时间
*/
public Date time;
/**
* 操作人
*/
public String operator;
}

View File

@ -0,0 +1,52 @@
package org.dromara.bigscreen.domain.vo;
import lombok.Data;
import java.io.Serializable;
/**
* 物资需求与实际到货对比vo
*/
@Data
public class WarehouseMonitoringVo implements Serializable {
/**
* 摄像头id
*/
public Long cameraId;
/**
* 仓库id
*/
public Long warehouseId;
/**
* 仓库名称
*/
public String name;
/**
* 摄像头序列号
*/
public String cameraSerial;
/**
* 摄像头名称
*/
public String cameraName;
/**
* 设备在线状态(0离线 1在线)
*/
private Integer status;
/**
* 状态0-关闭1-开启
*/
private Integer enable;
/**
* 摄像头最后一张抓图地址
*/
public String imgUrl;
}

View File

@ -0,0 +1,40 @@
package org.dromara.bigscreen.domain.vo;
import lombok.Data;
import java.io.Serializable;
import java.math.BigDecimal;
/**
* 设计量与到货量对比
*/
@Data
public class designAndArrivalComparisonVo implements Serializable {
/**
* 名称
*/
public String name;
/**
* 规格
*/
public String specification;
/**
* 单位
*/
public String unit;
/**
* 设计量
*/
public BigDecimal designTotalPrices;
/**
* 到货量
*/
public BigDecimal arrivalTotalPrices;
}

View File

@ -0,0 +1,35 @@
package org.dromara.bigscreen.domain.vo;
import lombok.Data;
import java.io.Serializable;
import java.math.BigDecimal;
/**
* 物资需求与实际到货对比vo
*/
@Data
public class wzxqysjdhdbVo implements Serializable {
/**
* 名称
*/
public String name;
/**
* 规格
*/
public String specification;
/**
* 设计量
*/
public BigDecimal designTotalPrices;
/**
* 到货量
*/
public BigDecimal arrivalTotalPrices;
}

View File

@ -0,0 +1,35 @@
package org.dromara.bigscreen.domain.vo;
import lombok.Data;
import java.io.Serializable;
import java.math.BigDecimal;
/**
* 物资需求与实际到货对比vo
*/
@Data
public class xhqsdbVo implements Serializable {
/**
* 名称
*/
public String name;
/**
* 规格
*/
public String specification;
/**
* 出库量
*/
public BigDecimal outTotalPrices;
/**
* 使用量
*/
public BigDecimal useTotalPrices;
}

View File

@ -0,0 +1,29 @@
package org.dromara.bigscreen.enums;
public enum DpEnum {
ZLGLLX_ZXGL("专项检查", "1"),
ZLGLLX_DQJC("定期检查", "2"),
ZLGLLX_RCXJ("日常巡检", "3"),
ZLGDZT_ZG("工单状态-整改", "2"),
RYZT_ZG("人员状态-在岗", "1"),
RYZT_LG("工单状态-离岗", "0"),
JSLX_AQY("角色类型-安全员", "SAFETY_OFFICER");
private final String TypeName;
private final String TypeValue;
public String getTypeName() {
return TypeName;
}
public String getTypeValue() {
return TypeValue;
}
DpEnum(String TypeName, String TypeValue) {
this.TypeName = TypeName;
this.TypeValue = TypeValue;
}
}

View File

@ -0,0 +1,22 @@
package org.dromara.bigscreen.enums;
public enum WuZhiEnum {
LBQ("逆变器"),
GFZJ("光伏支架"),
XB("箱变"),
HWG("环网柜");
private final String TypeName;
public String getTypeName() {
return TypeName;
}
WuZhiEnum(String TypeName) {
this.TypeName = TypeName;
}
}

View File

@ -0,0 +1,28 @@
package org.dromara.bigscreen.service;
import org.dromara.bigscreen.domain.bo.DpznglBo;
import org.dromara.bigscreen.domain.vo.DpznglAqyVo;
import org.dromara.bigscreen.domain.vo.DpznglVo;
import java.util.List;
/**
* 大屏-质安管理
*
* @author Lion Li
* @date 2025-11-05
*/
public interface DpzaglService {
/**
* 查询大屏-质安管理-站班会,巡检工单,整改情况
*/
DpznglVo queryList(DpznglBo bo);
/**
* 查询大屏-质安管理-安全员分布情况
*/
List<DpznglAqyVo> listByAqy(DpznglBo bo);
DpznglVo listByzbh(DpznglBo bo);
}

View File

@ -0,0 +1,45 @@
package org.dromara.bigscreen.service;
import org.dromara.bigscreen.domain.vo.InventoryStructureAnalysisVo;
import org.dromara.bigscreen.domain.vo.StockInAndStockOutRecordVo;
import org.dromara.bigscreen.domain.vo.WarehouseMonitoringVo;
import org.dromara.bigscreen.domain.vo.xhqsdbVo;
import java.util.List;
/**
* 物资管理大屏Service接口
*/
public interface IMaterialsManagementService {
/**
* 库存结构分析
* @param projectId
* @return
*/
InventoryStructureAnalysisVo inventoryStructureAnalysis(Long projectId);
/**
* 消耗趋势对比
* @param projectId
* @return
*/
List<xhqsdbVo> xhqsdb(Long projectId);
/**
* 仓库实时监控
* @param projectId
* @return
*/
List<WarehouseMonitoringVo> warehouseMonitoring(Long projectId);
/**
* 仓库出入库详情
*
* @param projectId
* @param warehouseId
* @return
*/
List<StockInAndStockOutRecordVo> warehouseInAndOutDetail(Long projectId, Long warehouseId);
}

View File

@ -0,0 +1,67 @@
package org.dromara.bigscreen.service;
import org.dromara.bigscreen.domain.dto.ProjectImageProgressDetailReq;
import org.dromara.bigscreen.domain.progress.DesignProgressVo;
import org.dromara.bigscreen.domain.progress.MaterialProgressDetailVo;
import org.dromara.bigscreen.domain.progress.MilestoneProgressVo;
import org.dromara.bigscreen.domain.progress.ProjectTotalProgressVo;
import org.dromara.bigscreen.domain.vo.ProjectImageProgressDetailVo;
import org.dromara.bigscreen.domain.vo.wzxqysjdhdbVo;
import org.springframework.validation.annotation.Validated;
import java.util.List;
/**
* @author lilemy
* @date 2025-12-15 14:18
*/
public interface ProgressBigScreenService {
/**
* 获取项目总进度
*
* @param projectId 项目 id
* @return 项目总进度
*/
ProjectTotalProgressVo getProjectTotalProgress(Long projectId);
/**
* 获取施工进度详情
*
* @param req 请求参数
* @return 施工进度详情
*/
List<ProjectImageProgressDetailVo> getProjectTotalProgressDetail(@Validated ProjectImageProgressDetailReq req);
/**
* 获取里程碑进度
*
* @param projectId 项目 id
* @return 里程碑进度
*/
List<MilestoneProgressVo> getMilestoneProgress(Long projectId);
/**
* 获取设计进度
*
* @param projectId 项目 id
* @return 设计进度
*/
DesignProgressVo getDesignProgress(Long projectId);
/**
* 获取物料进度详情
*
* @param projectId 项目 id
* @return 物料进度详情
*/
List<MaterialProgressDetailVo> getMaterialProgressDetail(Long projectId, String name, String specification);
/**
* 获取物资进度
*
* @param projectId 项目 id
* @return 物资进度
*/
List<wzxqysjdhdbVo> getMaterialProgress(Long projectId);
}

View File

@ -0,0 +1,244 @@
package org.dromara.bigscreen.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.dromara.bigscreen.domain.bo.DpznglBo;
import org.dromara.bigscreen.domain.vo.DpznglAqyVo;
import org.dromara.bigscreen.domain.vo.DpznglVo;
import org.dromara.bigscreen.enums.DpEnum;
import org.dromara.bigscreen.service.DpzaglService;
import org.dromara.common.core.service.UserService;
import org.dromara.common.core.utils.MapstructUtils;
import org.dromara.common.domain.GeoPoint;
import org.dromara.common.mybatis.core.page.PageQuery;
import org.dromara.common.mybatis.core.page.TableDataInfo;
import org.dromara.common.utils.JSTUtil;
import org.dromara.gps.domain.GpsEquipmentSon;
import org.dromara.gps.mapper.GpsEquipmentSonMapper;
import org.dromara.gps.service.IGpsEquipmentSonService;
import org.dromara.project.domain.BusProjectPunchrange;
import org.dromara.project.domain.BusUserProjectRelevancy;
import org.dromara.project.mapper.BusUserProjectRelevancyMapper;
import org.dromara.project.service.IBusProjectPunchrangeService;
import org.dromara.quality.domain.QltQualityInspection;
import org.dromara.quality.domain.dto.qualityinspection.QltQualityInspectionQueryReq;
import org.dromara.quality.domain.vo.qualityinspection.QltQualityInspectionVo;
import org.dromara.quality.service.IQltQualityInspectionService;
import org.dromara.safety.domain.HseSafetyInspection;
import org.dromara.safety.domain.HseTeamMeeting;
import org.dromara.safety.domain.dto.safetyinspection.HseSafetyInspectionQueryReq;
import org.dromara.safety.domain.dto.teammeeting.HseTeamMeetingQueryReq;
import org.dromara.safety.domain.vo.safetyinspection.HseSafetyInspectionVo;
import org.dromara.safety.domain.vo.teammeeting.HseTeamMeetingVo;
import org.dromara.safety.service.IHseSafetyInspectionService;
import org.dromara.safety.service.IHseTeamMeetingService;
import org.dromara.system.domain.SysRole;
import org.dromara.system.domain.SysUserRole;
import org.dromara.system.mapper.SysRoleMapper;
import org.dromara.system.mapper.SysUserRoleMapper;
import org.dromara.system.service.ISysRoleService;
import org.dromara.system.service.ISysUserService;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
/**
* 大屏-质安管理
*
* @author Lion Li
* @date 2025-11-05
*/
@RequiredArgsConstructor
@Service
@Slf4j
public class DpzaglServiceImpl implements DpzaglService {
//站班会
private final IHseTeamMeetingService teamMeetingService;
//质量-检查工单
private final IQltQualityInspectionService qualityInspectionService;
// 安全工单
private final IHseSafetyInspectionService safetyInspectionService;
private final SysRoleMapper sysRoleMapper;
private final UserService userService;
private final SysUserRoleMapper sysUserRoleMapper;
private final GpsEquipmentSonMapper gpsEquipmentSonMapper;
private final IBusProjectPunchrangeService busProjectPunchrangeService;
private final BusUserProjectRelevancyMapper busUserProjectRelevancyMapper;
@Override
public DpznglVo queryList(DpznglBo bo) {
DpznglVo dpznglVo = new DpznglVo();
PageQuery pageQuery = new PageQuery(bo.getPageSize(),bo.getPageNum());
// 质量
saveZl(pageQuery,dpznglVo,bo);
// 安全
saveAq(pageQuery,dpznglVo,bo);
return dpznglVo;
}
@Override
public List<DpznglAqyVo> listByAqy(DpznglBo bo) {
List<DpznglAqyVo> dpznglAqyVos = new ArrayList<>();
if (bo == null || bo.getProjectId() == null) throw new RuntimeException("项目不能为空");
//// 查询该项目下的人员id
// List<BusUserProjectRelevancy> busUserProjectRelevancies = busUserProjectRelevancyMapper.selectList(new LambdaQueryWrapper<BusUserProjectRelevancy>().eq(BusUserProjectRelevancy::getProjectId, bo.getProjectId()));
// if (busUserProjectRelevancies == null || busUserProjectRelevancies.size() == 0){
// return dpznglAqyVos;
// }
// 查询拥有安全员的角色
List<SysRole> sysRoles = sysRoleMapper.selectList(new LambdaQueryWrapper<SysRole>().eq(SysRole::getRoleIdentity, DpEnum.JSLX_AQY.getTypeValue()));
if (sysRoles == null || sysRoles.size() == 0){
return dpznglAqyVos;
}
// 根据角色查询人员
List<Long> roles = sysRoles.stream().map(SysRole::getRoleId).collect(Collectors.toList());
List<SysUserRole> sysUserRoles = sysUserRoleMapper.selectList(new LambdaQueryWrapper<SysUserRole>().in(SysUserRole::getRoleId, roles).groupBy(SysUserRole::getUserId));
if (sysUserRoles == null && sysUserRoles.size() == 0){
return dpznglAqyVos;
}
// 查询人员的最新经纬度
List<Long> collect = sysUserRoles.stream().map(SysUserRole::getUserId).collect(Collectors.toList());
if (collect == null || collect.size() == 0){
return dpznglAqyVos;
}
List<GpsEquipmentSon> temp = gpsEquipmentSonMapper.listByAqy(collect,bo.getProjectId());
if (temp != null && temp.size() > 0){
// 回填数据
dpznglAqyVos = temp.stream().map(gpsEquipmentSon -> {
DpznglAqyVo dpznglAqyVo = new DpznglAqyVo();
dpznglAqyVo.setUserId(gpsEquipmentSon.getUserId());
dpznglAqyVo.setLocLatitude(gpsEquipmentSon.getLocLatitude());
dpznglAqyVo.setLocLongitude(gpsEquipmentSon.getLocLongitude());
return dpznglAqyVo;
}).collect(Collectors.toList());
// 判断是否离岗
judgeFw(dpznglAqyVos,bo.getProjectId());
}
return dpznglAqyVos;
}
private void judgeFw(List<DpznglAqyVo> dpznglAqyVos, Long projectId) {
// 获取该项目的打卡范围
List<BusProjectPunchrange> busProjectPunchranges = busProjectPunchrangeService.getBaseMapper().selectList(new LambdaQueryWrapper<BusProjectPunchrange>().eq(BusProjectPunchrange::getProjectId, projectId));
if (busProjectPunchranges == null || busProjectPunchranges.size() == 0){
return;
}
//判断是否在岗
for (DpznglAqyVo dpznglAqyVo : dpznglAqyVos) {
dpznglAqyVo.setSfzg(DpEnum.RYZT_LG.getTypeValue());
dpznglAqyVo.setUserName(userService.selectNicknameByIds(dpznglAqyVo.getUserId().toString()));
for (BusProjectPunchrange busProjectPunchrange : busProjectPunchranges) {
List<String> coordinates = List.of(busProjectPunchrange.getPunchRange());
List<GeoPoint> matchingRange = JSTUtil.findMatchingRange(dpznglAqyVo.getLocLatitude().toString(), dpznglAqyVo.getLocLongitude().toString(), coordinates);
if (matchingRange != null && matchingRange.size() > 0){
dpznglAqyVo.setSfzg(DpEnum.RYZT_ZG.getTypeValue());
}
}
}
}
@Override
public DpznglVo listByzbh(DpznglBo bo) {
DpznglVo dpznglVo = new DpznglVo();
// 站班会
HseTeamMeetingQueryReq hseTeamMeetingQueryReq = new HseTeamMeetingQueryReq();
// List<HseTeamMeetingVo> hseTeamMeetingVos = teamMeetingService.queryList(hseTeamMeetingQueryReq);
List<HseTeamMeeting> hseTeamMeetings = teamMeetingService.getBaseMapper().selectList(new LambdaQueryWrapper<HseTeamMeeting>().ge(HseTeamMeeting::getProjectId, bo.getProjectId()));
dpznglVo.setZbhList(MapstructUtils.convert(hseTeamMeetings, HseTeamMeetingVo.class));
dpznglVo.getZbhList().forEach(hseTeamMeetingVo -> {if ( hseTeamMeetingVo.getCompereId() != null){hseTeamMeetingVo.setCompereName(userService.selectNicknameByIds(hseTeamMeetingVo.getCompereId().toString()));}});
return dpznglVo;
}
private void saveAq(PageQuery pageQuery, DpznglVo dpznglVo,DpznglBo bo) {
// 安全 巡检工单,整改情况
HseSafetyInspectionQueryReq req = new HseSafetyInspectionQueryReq();
// 质量展示数据
// TableDataInfo<HseSafetyInspectionVo> anList = safetyInspectionService.queryPageList(req, pageQuery);
// 质量展示数据-整改
// req.setStatus(DpEnum.ZLGDZT_ZG.getTypeValue());
// TableDataInfo<HseSafetyInspectionVo> aqZgList = safetyInspectionService.queryPageList(req, pageQuery);
// 安全总数(用于判断巡检类型)
List<HseSafetyInspection> list = safetyInspectionService.list(new LambdaQueryWrapper<HseSafetyInspection>().eq(HseSafetyInspection::getProjectId, bo.getProjectId()).ge(bo.getStartDate() != null ,HseSafetyInspection::getCreateTime, bo.getStartDate()).le(bo.getEndDate() != null ,HseSafetyInspection::getCreateTime, bo.getEndDate()));
// List<HseSafetyInspectionVo> rows = anList.getRows();
if (list != null && list.size() > 0){
dpznglVo.setAqZS(Long.valueOf(list.size()));
dpznglVo.setAqList(MapstructUtils.convert(list, HseSafetyInspectionVo.class));
dpznglVo.getAqList().forEach(zl ->{zl.setCreatorName(userService.selectNicknameByIds(zl.getCreateBy().toString()));});
dpznglVo.setZxjcAq(list.stream().filter(zl -> DpEnum.ZLGLLX_ZXGL.getTypeValue().equals(zl.getCheckType())).count());
dpznglVo.setDqjcAq(list.stream().filter(zl -> DpEnum.ZLGLLX_DQJC.getTypeValue().equals(zl.getCheckType())).count());
dpznglVo.setRcxjAq(list.stream().filter(zl -> DpEnum.ZLGLLX_RCXJ.getTypeValue().equals(zl.getCheckType())).count());
dpznglVo.setAqZgsl(list.stream().filter(zl -> DpEnum.ZLGDZT_ZG.getTypeValue().equals(zl.getStatus())).count());
List<HseSafetyInspectionVo> convert = MapstructUtils.convert(list.stream().filter(zl -> DpEnum.ZLGDZT_ZG.getTypeValue().equals(zl.getStatus())).collect(Collectors.toList()), HseSafetyInspectionVo.class);
convert.forEach(zl ->{if (zl.getCorrectorId() != null)zl.setCorrectorName(userService.selectNicknameByIds(zl.getCorrectorId().toString()));});
dpznglVo.setAqZgList(convert);
}
// if (aqZgList.getRows() != null && aqZgList.getRows().size() > 0){
// aqZgList.getRows().forEach(zl ->{if (zl.getCorrectorId() != null){zl.setCorrectorName(userService.selectNicknameByIds(zl.getCorrectorId().toString()));}});
// dpznglVo.setAqZgList(aqZgList.getRows());
// }
}
private void saveZl(PageQuery pageQuery,DpznglVo dpznglVo,DpznglBo bo) {
// 质量 巡检工单,整改情况
QltQualityInspectionQueryReq req = new QltQualityInspectionQueryReq();
//// 质量展示数据
// TableDataInfo<QltQualityInspectionVo> zlLists = qualityInspectionService.queryPageList(req, pageQuery);
// 质量展示数据-整改
// req.setInspectionStatus(DpEnum.ZLGDZT_ZG.getTypeValue());
// TableDataInfo<QltQualityInspectionVo> zlZgLists = qualityInspectionService.queryPageList(req, pageQuery);
// 质量总数
List<QltQualityInspection> zsZl = qualityInspectionService.getBaseMapper()
.selectList(new LambdaQueryWrapper<QltQualityInspection>().eq(QltQualityInspection::getProjectId, bo.getProjectId())
.ge(bo.getStartDate() != null ,QltQualityInspection::getCreateTime, bo.getStartDate()).le(bo.getEndDate() != null ,QltQualityInspection::getCreateTime, bo.getEndDate()));
// List<QltQualityInspectionVo> rows = zlLists.getRows();
if (zsZl != null && zsZl.size() > 0){
dpznglVo.setZlZS(Long.valueOf(zsZl.size()));
dpznglVo.setZlList(MapstructUtils.convert(zsZl, QltQualityInspectionVo.class));
dpznglVo.getZlList().forEach(zl ->{zl.setCreateByName(userService.selectNicknameByIds(zl.getCreateBy().toString()));});
dpznglVo.setZxjcZl(zsZl.stream().filter(zl -> DpEnum.ZLGLLX_ZXGL.getTypeValue().equals(zl.getInspectionType())).count());
dpznglVo.setDqjcZl(zsZl.stream().filter(zl -> DpEnum.ZLGLLX_DQJC.getTypeValue().equals(zl.getInspectionType())).count());
dpznglVo.setRcxjZl(zsZl.stream().filter(zl -> DpEnum.ZLGLLX_RCXJ.getTypeValue().equals(zl.getInspectionType())).count());
dpznglVo.setZlZgsl(zsZl.stream().filter(zl -> DpEnum.ZLGDZT_ZG.getTypeValue().equals(zl.getInspectionStatus())).count());
List<QltQualityInspection> collect = zsZl.stream().filter(zl -> DpEnum.ZLGDZT_ZG.getTypeValue().equals(zl.getInspectionStatus())).collect(Collectors.toList());
List<QltQualityInspectionVo> convert = MapstructUtils.convert(collect, QltQualityInspectionVo.class);
convert.forEach(zl ->{if (zl.getCorrectorId() != null)zl.setCorrectorName(userService.selectNicknameByIds(zl.getCorrectorId().toString()));});
dpznglVo.setZlZgList(convert);
}
}
}

View File

@ -0,0 +1,431 @@
package org.dromara.bigscreen.service.impl;
import cn.hutool.core.collection.CollUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import jakarta.annotation.Resource;
import org.dromara.bigscreen.domain.vo.InventoryStructureAnalysisVo;
import org.dromara.bigscreen.domain.vo.StockInAndStockOutRecordVo;
import org.dromara.bigscreen.domain.vo.WarehouseMonitoringVo;
import org.dromara.bigscreen.domain.vo.xhqsdbVo;
import org.dromara.bigscreen.enums.WuZhiEnum;
import org.dromara.bigscreen.service.IMaterialsManagementService;
import org.dromara.materials.domain.*;
import org.dromara.materials.service.*;
import org.dromara.other.domain.OthYs7Device;
import org.dromara.other.domain.OthYs7DeviceImg;
import org.dromara.other.service.IOthYs7DeviceImgService;
import org.dromara.other.service.IOthYs7DeviceService;
import org.dromara.tender.domain.BusBillofquantitiesLimitList;
import org.dromara.tender.service.IBusBillofquantitiesLimitListService;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.time.temporal.TemporalAdjusters;
import java.util.*;
import java.util.stream.Collectors;
@Service
public class MaterialsManagementServiceImpl implements IMaterialsManagementService {
@Lazy
@Resource
private IMatMaterialReceiveItemService materialReceiveItemService;
@Lazy
@Resource
private IMatMaterialIssueItemService materialIssueItemService;
@Lazy
@Resource
private IMatMaterialsService materialsService;
@Lazy
@Resource
private IBusBillofquantitiesLimitListService billofquantitiesLimitListService;
@Lazy
@Resource
private IMatMaterialsInventoryService materialsInventoryService;
@Lazy
@Resource
private IMatMaterialsUseRecordService matMaterialsUseRecordService;
@Lazy
@Resource
private IMatMaterialIssueService materialIssueService;
@Resource
private IMatWarehouseService warehouseService;
@Lazy
@Resource
private IMatWarehouseCameraService warehouseCameraService;
@Lazy
@Resource
private IOthYs7DeviceService othYs7DeviceService;
@Lazy
@Resource
private IOthYs7DeviceImgService ys7DeviceImgService;
@Lazy
@Resource
private IMatMaterialReceiveService materialReceiveService;
@Override
public InventoryStructureAnalysisVo inventoryStructureAnalysis(Long projectId) {
InventoryStructureAnalysisVo vo = new InventoryStructureAnalysisVo();
// 获取当月第一天
LocalDateTime monthStart = LocalDateTime.now()
// 调整到当月第一天
.with(TemporalAdjusters.firstDayOfMonth())
// 重置时分秒毫秒为0
.withHour(0)
.withMinute(0)
.withSecond(0)
.withNano(0);
// 获取当前时间
LocalDateTime currentTime = LocalDateTime.now();
// 获取上月第一天
LocalDateTime lastMonthFirstDay = LocalDateTime.now()
// 先回退一个月
.minusMonths(1)
// 调整到当月第一天
.with(TemporalAdjusters.firstDayOfMonth())
// 重置时间为 00:00:00.000000000
.withHour(0)
.withMinute(0)
.withSecond(0);
// 获取上月最后一天
LocalDateTime lastMonthLastDay = LocalDateTime.now()
// 先回退一个月
.minusMonths(1)
// 调整到当月最后一天
.with(TemporalAdjusters.lastDayOfMonth())
// 设置时间为 23:59:59.999999999纳秒最大值对应毫秒级的999
.withHour(23)
.withMinute(59)
.withSecond(59);
// 获取当月入库数据
List<MatMaterialReceiveItem> matMaterialReceiveItems = materialReceiveItemService.getBaseMapper().selectList(new LambdaQueryWrapper<MatMaterialReceiveItem>()
.eq(MatMaterialReceiveItem::getProjectId, projectId)
.ne(MatMaterialReceiveItem::getAcceptedQuantity, BigDecimal.ZERO)
.between(MatMaterialReceiveItem::getCreateTime, monthStart, currentTime));
if (CollUtil.isEmpty(matMaterialReceiveItems)) {
vo.setEnterTotalPrices(BigDecimal.ZERO);
} else {
// 计算本月入库金额
BigDecimal enterTotalPrices = matMaterialReceiveItems.stream()
.map(item -> item.getAcceptedQuantity().multiply(item.getUnitPrice() != null ? item.getUnitPrice() : BigDecimal.ZERO))
.reduce(BigDecimal.ZERO, BigDecimal::add);
vo.setEnterTotalPrices(enterTotalPrices.setScale(4, BigDecimal.ROUND_HALF_UP));
}
// 获取上月入库数据
List<MatMaterialReceiveItem> oldMatMaterialReceiveItems = materialReceiveItemService.getBaseMapper().selectList(new LambdaQueryWrapper<MatMaterialReceiveItem>()
.eq(MatMaterialReceiveItem::getProjectId, projectId)
.ne(MatMaterialReceiveItem::getAcceptedQuantity, BigDecimal.ZERO)
.between(MatMaterialReceiveItem::getCreateTime, lastMonthFirstDay, lastMonthLastDay));
if (CollUtil.isEmpty(oldMatMaterialReceiveItems)) {
vo.setOldEnterTotalPrices(BigDecimal.ZERO);
} else {
// 计算上月入库金额
BigDecimal oldEnterTotalPrices = oldMatMaterialReceiveItems.stream()
.map(item -> item.getAcceptedQuantity().multiply(item.getUnitPrice() != null ? item.getUnitPrice() : BigDecimal.ZERO))
.reduce(BigDecimal.ZERO, BigDecimal::add);
vo.setOldEnterTotalPrices(oldEnterTotalPrices.setScale(4, BigDecimal.ROUND_HALF_UP));
}
// 获取当月出库数据
List<MatMaterialIssueItem> matMaterialIssueItems = materialIssueItemService.getBaseMapper()
.selectList(new LambdaQueryWrapper<MatMaterialIssueItem>()
.eq(MatMaterialIssueItem::getProjectId, projectId)
.ne(MatMaterialIssueItem::getIssuedQuantity, BigDecimal.ZERO)
.between(MatMaterialIssueItem::getCreateTime, monthStart, currentTime));
//计算本月出库金额
if (CollUtil.isEmpty(matMaterialIssueItems)) {
vo.setLeaveTotalPrices(BigDecimal.ZERO);
} else {
BigDecimal leaveTotalPrices = matMaterialIssueItems.stream()
.map(item -> item.getIssuedQuantity().multiply(item.getUnitPrice() != null ? item.getUnitPrice() : BigDecimal.ZERO))
.reduce(BigDecimal.ZERO, BigDecimal::add);
vo.setLeaveTotalPrices(leaveTotalPrices.setScale(4, BigDecimal.ROUND_HALF_UP));
}
// 获取上月出库数据
List<MatMaterialIssueItem> oldMatMaterialIssueItems = materialIssueItemService.getBaseMapper()
.selectList(new LambdaQueryWrapper<MatMaterialIssueItem>()
.eq(MatMaterialIssueItem::getProjectId, projectId)
.ne(MatMaterialIssueItem::getIssuedQuantity, BigDecimal.ZERO)
.between(MatMaterialIssueItem::getCreateTime, lastMonthFirstDay, lastMonthLastDay));
//计算上月出库金额
if (CollUtil.isEmpty(oldMatMaterialIssueItems)) {
vo.setOldLeaveTotalPrices(BigDecimal.ZERO);
} else {
BigDecimal oldLeaveTotalPrices = oldMatMaterialIssueItems.stream()
.map(item -> item.getIssuedQuantity().multiply(item.getUnitPrice() != null ? item.getUnitPrice() : BigDecimal.ZERO))
.reduce(BigDecimal.ZERO, BigDecimal::add);
vo.setOldLeaveTotalPrices(oldLeaveTotalPrices.setScale(4, BigDecimal.ROUND_HALF_UP));
}
//获取总入库存金额 入库 * 单价
List<MatMaterialReceiveItem> totalMatMaterialReceiveItems = materialReceiveItemService.getBaseMapper().selectList(new LambdaQueryWrapper<MatMaterialReceiveItem>().eq(MatMaterialReceiveItem::getProjectId, projectId));
if (CollUtil.isEmpty(totalMatMaterialReceiveItems)) {
vo.setInventoryTotalPrices(BigDecimal.ZERO);
} else {
// 计算总入库存金额
BigDecimal inventoryTotalPrices = totalMatMaterialReceiveItems.stream()
.map(item -> item.getAcceptedQuantity().multiply(item.getUnitPrice() != null ? item.getUnitPrice() : BigDecimal.ZERO))
.reduce(BigDecimal.ZERO, BigDecimal::add);
vo.setInventoryTotalPrices(inventoryTotalPrices.setScale(4, BigDecimal.ROUND_HALF_UP));
}
// 获取总出库金额 出库 * 单价
List<MatMaterialIssueItem> totalMatMaterialIssueItems = materialIssueItemService.getBaseMapper().selectList(new LambdaQueryWrapper<MatMaterialIssueItem>().eq(MatMaterialIssueItem::getProjectId, projectId));
if (CollUtil.isEmpty(totalMatMaterialIssueItems)) {
vo.setOutTotalPrices(BigDecimal.ZERO);
} else {
// 计算总出库金额
BigDecimal outTotalPrices = totalMatMaterialIssueItems.stream()
.map(item -> item.getIssuedQuantity().multiply(item.getUnitPrice() != null ? item.getUnitPrice() : BigDecimal.ZERO))
.reduce(BigDecimal.ZERO, BigDecimal::add);
vo.setOutTotalPrices(outTotalPrices.setScale(4, BigDecimal.ROUND_HALF_UP));
}
// 获取施工图一览大类名下所有小类名
List<BusBillofquantitiesLimitList> limitLists = billofquantitiesLimitListService.getBaseMapper().selectList(new LambdaQueryWrapper<BusBillofquantitiesLimitList>()
.eq(BusBillofquantitiesLimitList::getProjectId, projectId)
.eq(BusBillofquantitiesLimitList::getPid, "0")
.eq(BusBillofquantitiesLimitList::getType, "3")
.eq(BusBillofquantitiesLimitList::getName, WuZhiEnum.LBQ.getTypeName()).or()
.eq(BusBillofquantitiesLimitList::getName, WuZhiEnum.GFZJ.getTypeName()).or()
.eq(BusBillofquantitiesLimitList::getName, WuZhiEnum.XB.getTypeName()).or()
.eq(BusBillofquantitiesLimitList::getName, WuZhiEnum.HWG.getTypeName())
);
List<String> lBQNames = new ArrayList<>();
List<String> sFZJNames = new ArrayList<>();
List<String> xBNames = new ArrayList<>();
List<String> hWGNames = new ArrayList<>();
for (BusBillofquantitiesLimitList item : limitLists) {
if (item.getName().equals(WuZhiEnum.LBQ.getTypeName())) {
lBQNames.add(item.getName());
continue;
}
if (item.getName().equals(WuZhiEnum.GFZJ.getTypeName())) {
sFZJNames.add(item.getName());
continue;
}
if (item.getName().equals(WuZhiEnum.XB.getTypeName())) {
xBNames.add(item.getName());
continue;
}
if (item.getName().equals(WuZhiEnum.HWG.getTypeName())) {
hWGNames.add(item.getName());
}
}
//获取库存逆变器总价
BigDecimal inventoryInverterTotalPrices = materialsService.selectTotalPricesByNames(projectId, lBQNames);
vo.setInventoryInverterTotalPrices(inventoryInverterTotalPrices);
//获取库存箱变总价
BigDecimal inventoryBoxTransformerTotalPrices = materialsService.selectTotalPricesByNames(projectId, xBNames);
vo.setInventoryBoxTransformerTotalPrices(inventoryBoxTransformerTotalPrices);
//获取库存光伏支架总价
BigDecimal inventoryPhotovoltaicSupportTotalPrices = materialsService.selectTotalPricesByNames(projectId, sFZJNames);
vo.setInventoryPhotovoltaicSupportTotalPrices(inventoryPhotovoltaicSupportTotalPrices);
//获取库存环网柜总价
BigDecimal inventoryCircuitBreakerTotalPrices = materialsService.selectTotalPricesByNames(projectId, hWGNames);
vo.setInventoryCircuitBreakerTotalPrices(inventoryCircuitBreakerTotalPrices);
//获取当前库存总价
BigDecimal nowInventoryTotalPrices = materialsService.selectTotalPrices(projectId);
vo.setNowInventoryTotalPrices(nowInventoryTotalPrices);
return vo;
}
/**
* 消耗趋势对比
*
* @param projectId
* @return
*/
@Override
public List<xhqsdbVo> xhqsdb(Long projectId) {
List<xhqsdbVo> list = new ArrayList<>();
//获取出库记录
List<MatMaterialIssue> issuesList = materialIssueService.getBaseMapper()
.selectList(new LambdaQueryWrapper<MatMaterialIssue>()
.eq(MatMaterialIssue::getProjectId, projectId)
.eq(MatMaterialIssue::getMaterialSource, "1"));
if (CollUtil.isEmpty(issuesList)) {
return List.of();
}
Set<Long> issueIds = issuesList.stream().map(MatMaterialIssue::getId).collect(Collectors.toSet());
if (CollUtil.isEmpty(issueIds)){
return List.of();
}
//获取领料明细列表
List<MatMaterialIssueItem> issueItems = materialIssueItemService.getBaseMapper().selectList(new LambdaQueryWrapper<MatMaterialIssueItem>()
.in(MatMaterialIssueItem::getIssueId, issueIds));
if (CollUtil.isEmpty(issueItems)){
return List.of();
}
Set<Long> iIds = issueItems.stream().filter(item -> item.getInventoryId() != null).map(MatMaterialIssueItem::getInventoryId).collect(Collectors.toSet());
if (CollUtil.isEmpty(iIds)){
return List.of();
}
//获取出入库表中出库记录
List<MatMaterialsInventory> inventories = materialsInventoryService.getBaseMapper()
.selectList(new LambdaQueryWrapper<MatMaterialsInventory>()
.in(MatMaterialsInventory::getId, iIds));
if (CollUtil.isEmpty(inventories)) {
return List.of();
}
//获取每个材料的库存数量
HashMap<Long, BigDecimal> inventoryHashMap = new HashMap<>();
inventories.forEach(item -> {
if (inventoryHashMap.containsKey(item.getMaterialsId())){
inventoryHashMap.put(item.getMaterialsId(), inventoryHashMap.get(item.getMaterialsId()).add(new BigDecimal(item.getNumber())));
}else {
inventoryHashMap.put(item.getMaterialsId(), new BigDecimal(item.getNumber()));
}
});
Set<Long> mids = inventories.stream().filter(item -> item.getMaterialsId() != null).map(MatMaterialsInventory::getMaterialsId).collect(Collectors.toSet());
if (CollUtil.isEmpty(mids)){
return List.of();
}
//获取材料名称列表
List<MatMaterials> materials = materialsService.getBaseMapper().selectList(new LambdaQueryWrapper<MatMaterials>()
.eq(MatMaterials::getProjectId, projectId)
.in(MatMaterials::getId, mids));
if (CollUtil.isEmpty(materials)) {
return List.of();
}
//获取材料名称
Map<Long, String> map1 = materials.stream()
.collect(Collectors.toMap(MatMaterials::getId, MatMaterials::getMaterialsName));
//获取所有出入库记录id
Set<Long> ids = inventories.stream()
.map(MatMaterialsInventory::getId)
.collect(Collectors.toSet());
if (CollUtil.isEmpty(ids)) {
return List.of();
}
//根据出入库id获取使用记录
List<MatMaterialsUseRecord> useRecords = matMaterialsUseRecordService.getBaseMapper()
.selectList(new LambdaQueryWrapper<MatMaterialsUseRecord>()
.eq(MatMaterialsUseRecord::getProjectId, projectId)
.in(MatMaterialsUseRecord::getInventoryId, ids));
Map<Long, BigDecimal> map = useRecords.stream()
.collect(Collectors.groupingBy(
MatMaterialsUseRecord::getInventoryId,
Collectors.reducing(BigDecimal.ZERO, MatMaterialsUseRecord::getUseNumber, BigDecimal::add)
));
inventoryHashMap.forEach((key, value) -> {
xhqsdbVo vo = new xhqsdbVo();
vo.setName(map1.get(key));
vo.setOutTotalPrices( value);
vo.setUseTotalPrices(map.getOrDefault(key, BigDecimal.ZERO));
list.add(vo);
});
return list;
}
@Override
public List<WarehouseMonitoringVo> warehouseMonitoring(Long projectId) {
List<WarehouseMonitoringVo> list = new ArrayList<>();
//根据项目id获取仓库列表
List<MatWarehouse> warehouseList = warehouseService.getBaseMapper().selectList(new LambdaQueryWrapper<MatWarehouse>()
.eq(MatWarehouse::getProjectId, projectId));
//构建仓库id与仓库对象映射
if (CollUtil.isEmpty(warehouseList)){
return list;
}
Map<Long, MatWarehouse> warehouseMap = warehouseList.stream().collect(Collectors.toMap(MatWarehouse::getId, item -> item));
//根据仓库列表获取仓库id
Set<Long> warehouseIds = warehouseList.stream().map(MatWarehouse::getId).collect(Collectors.toSet());
//根据仓库id获取摄像头id列表
List<MatWarehouseCamera> warehouseCameraList = warehouseCameraService.getBaseMapper().selectList(new LambdaQueryWrapper<MatWarehouseCamera>()
.in(MatWarehouseCamera::getWarehouseId, warehouseIds));
if (CollUtil.isEmpty(warehouseCameraList)){
return list;
}
Set<Long> cameraIds = warehouseCameraList.stream().filter(item -> item.getCameraId() != null).map(MatWarehouseCamera::getCameraId).collect(Collectors.toSet());
//生成摄像头与仓库关系
Map<Long, Long> warehouseCameraMap = warehouseCameraList.stream().collect(Collectors.toMap(MatWarehouseCamera::getCameraId, MatWarehouseCamera::getWarehouseId));
//根据摄像头id列表获取摄像头列表
List<OthYs7Device> cameraList = othYs7DeviceService.getBaseMapper()
.selectList(new LambdaQueryWrapper<OthYs7Device>()
.in(OthYs7Device::getId, cameraIds));
if (CollUtil.isEmpty(cameraList)){
return list;
}
//获取摄像头最后一张抓拍图片
Set<String> deviceSerialSet = cameraList.stream().map(OthYs7Device::getDeviceSerial).collect(Collectors.toSet());
List<OthYs7DeviceImg> deviceImgs = ys7DeviceImgService.getBaseMapper()
.selectList(new LambdaQueryWrapper<OthYs7DeviceImg>()
.in(OthYs7DeviceImg::getDeviceSerial, deviceSerialSet));
Map<String, String> deviceImgMap = new HashMap<>();
if (CollUtil.isNotEmpty(deviceImgs)){
//构建摄像头与图片关系
deviceImgMap = deviceImgs.stream().collect(Collectors.toMap(OthYs7DeviceImg::getDeviceSerial, OthYs7DeviceImg::getUrl));
}
//遍历摄像头列表组装返回数据
for (OthYs7Device item : cameraList) {
WarehouseMonitoringVo vo = new WarehouseMonitoringVo();
vo.setCameraId(item.getId());
vo.setWarehouseId(warehouseCameraMap.get(item.getId()));
vo.setCameraSerial(item.getDeviceSerial());
vo.setCameraName(item.getDeviceName());
vo.setStatus(item.getStatus());
vo.setEnable(item.getEnable());
vo.setName(warehouseMap.get(vo.getWarehouseId()).getWarehouseName());
vo.setImgUrl(deviceImgMap.get(item.getDeviceSerial()) != null ? deviceImgMap.get(item.getDeviceSerial()) : "");
list.add(vo);
}
return list;
}
/**
* 仓库出入库明细
*
* @param projectId
* @param warehouseId
* @return
*/
@Override
public List<StockInAndStockOutRecordVo> warehouseInAndOutDetail(Long projectId, Long warehouseId) {
List<StockInAndStockOutRecordVo> list = new ArrayList<>();
//根据项目id和仓库id获取入库列表
List<MatMaterials> matMaterials = materialsService.getBaseMapper().selectList(new LambdaQueryWrapper<MatMaterials>()
.eq(MatMaterials::getProjectId, projectId)
.eq(MatMaterials::getWarehouseId, warehouseId));
if (CollUtil.isEmpty(matMaterials)) {
return list;
}
//生成材料id与材料名称关系
Map<Long, String> map1 = matMaterials.stream().collect(Collectors.toMap(MatMaterials::getId, MatMaterials::getMaterialsName));
//获取入库的材料id列表
Set<Long> mIds = matMaterials.stream()
.map(MatMaterials::getId)
.collect(Collectors.toSet());
if (CollUtil.isEmpty(mIds)){
return list;
}
//根据材料id列表查询出入库记录表获取到所有材料的出入库记录
List<MatMaterialsInventory> materialsInventoryList = materialsInventoryService.getBaseMapper()
.selectList(new LambdaQueryWrapper<MatMaterialsInventory>()
.in(MatMaterialsInventory::getMaterialsId, mIds)
.orderByDesc(MatMaterialsInventory::getCreateTime));
if (CollUtil.isEmpty(materialsInventoryList)){
return list;
}
//遍历出入库记录列表,组装返回数据
for (MatMaterialsInventory item : materialsInventoryList) {
StockInAndStockOutRecordVo vo = new StockInAndStockOutRecordVo();
vo.setId(item.getId());
vo.setName(map1.get(item.getMaterialsId()));
vo.setInventoryNumber(item.getResidue());
vo.setInAndOutNumber(item.getNumber());
vo.setType(item.getOutPut());
vo.setTime(item.getOutPutTime());
vo.setOperator(item.getOperator());
list.add(vo);
}
return list;
}
}

View File

@ -0,0 +1,403 @@
package org.dromara.bigscreen.service.impl;
import cn.hutool.core.collection.CollUtil;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.dromara.bigscreen.domain.dto.ProjectImageProgressDetailReq;
import org.dromara.bigscreen.domain.progress.*;
import org.dromara.bigscreen.domain.vo.ProjectImageProgressDetailVo;
import org.dromara.bigscreen.domain.vo.wzxqysjdhdbVo;
import org.dromara.bigscreen.service.ProgressBigScreenService;
import org.dromara.bigscreen.service.ProjectBigScreenService;
import org.dromara.cailiaoshebei.service.IBusMrpBaseService;
import org.dromara.common.core.enums.BusinessStatusEnum;
import org.dromara.common.core.utils.DateUtils;
import org.dromara.common.utils.BigDecimalUtil;
import org.dromara.design.domain.DesVolumeCatalog;
import org.dromara.design.domain.DesVolumeFile;
import org.dromara.design.service.IDesVolumeCatalogService;
import org.dromara.design.service.IDesVolumeFileService;
import org.dromara.materials.domain.MatMaterialReceive;
import org.dromara.materials.domain.MatMaterialReceiveItem;
import org.dromara.materials.service.IMatMaterialReceiveItemService;
import org.dromara.materials.service.IMatMaterialReceiveService;
import org.dromara.materials.service.IMatMaterialsService;
import org.dromara.progress.constant.PgsProgressCategoryConstant;
import org.dromara.progress.domain.PgsConstructionSchedulePlan;
import org.dromara.progress.domain.PgsProgressCategory;
import org.dromara.progress.domain.dto.progressplan.PgsProgressPlanQueryReq;
import org.dromara.progress.domain.vo.progresscategory.PgsProgressCategoryValueTotalVo;
import org.dromara.progress.domain.vo.progressplan.PgsProgressPlanDateVo;
import org.dromara.progress.service.IPgsConstructionSchedulePlanService;
import org.dromara.progress.service.IPgsProgressCategoryService;
import org.dromara.progress.service.IPgsProgressPlanService;
import org.dromara.project.domain.BusProject;
import org.dromara.project.service.IBusProjectService;
import org.dromara.system.domain.vo.SysDictDataVo;
import org.dromara.system.service.ISysDictDataService;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.ZoneId;
import java.time.temporal.ChronoUnit;
import java.util.*;
import java.util.stream.Collectors;
/**
* @author lilemy
* @date 2025-12-15 14:18
*/
@Slf4j
@Service
public class ProgressBigScreenServiceImpl implements ProgressBigScreenService {
@Resource
private ProjectBigScreenService projectBigScreenService;
@Resource
private IBusProjectService projectService;
@Resource
private IPgsProgressCategoryService progressCategoryService;
@Resource
private IPgsProgressPlanService progressPlanService;
@Resource
private IPgsConstructionSchedulePlanService constructionSchedulePlanService;
@Resource
private IDesVolumeCatalogService volumeCatalogService;
@Resource
private IDesVolumeFileService volumeFileService;
@Resource
private ISysDictDataService dictDataService;
@Resource
private IMatMaterialReceiveService materialReceiveService;
@Resource
private IMatMaterialReceiveItemService materialReceiveItemService;
@Resource
private IBusMrpBaseService mrpBaseService;
@Resource
private IMatMaterialsService matMaterialsService;
/**
* 获取项目总进度
*
* @param projectId 项目 id
* @return 项目总进度
*/
@Override
public ProjectTotalProgressVo getProjectTotalProgress(Long projectId) {
ProjectTotalProgressVo vo = new ProjectTotalProgressVo();
// 获取项目和项目子项
BusProject project = projectService.getById(projectId);
if (project == null) {
return vo;
}
List<BusProject> projects = projectService.lambdaQuery()
.eq(BusProject::getPId, projectId)
.list();
projects.add(project);
List<Long> projectIds = projects.stream().map(BusProject::getId).toList();
// 获取当前项目所有父级类别
List<PgsProgressCategory> topList = progressCategoryService.lambdaQuery()
.in(PgsProgressCategory::getProjectId, projectIds)
.eq(PgsProgressCategory::getParentId, PgsProgressCategoryConstant.TOP_PARENT_ID)
.list();
if (CollUtil.isEmpty(topList)) {
return vo;
}
List<Long> topIds = topList.stream().map(PgsProgressCategory::getId).toList();
List<PgsProgressCategory> children = progressCategoryService.getLeafNodesByTopIds(topIds);
BigDecimal completedPercentage = progressCategoryService.getCompletedPercentage(children);
vo.setTotalProgress(completedPercentage);
// 获取总计划工期
PgsProgressPlanQueryReq queryDate = new PgsProgressPlanQueryReq();
queryDate.setProjectId(projectId);
PgsProgressPlanDateVo dateVo = progressPlanService.queryDate(queryDate);
if (dateVo != null && dateVo.getStartDate() != null && dateVo.getEndDate() != null) {
LocalDate startDate = dateVo.getStartDate();
LocalDate endDate = dateVo.getEndDate();
LocalDate now = LocalDate.now();
long totalDays = ChronoUnit.DAYS.between(startDate, endDate);
vo.setTotalPlannedDuration(totalDays);
if (now.isAfter(endDate)) {
vo.setCurrentPlannedDuration(totalDays);
} else if (now.isBefore(startDate)) {
vo.setCurrentPlannedDuration(0L);
} else {
vo.setCurrentPlannedDuration(ChronoUnit.DAYS.between(startDate, now) + 1);
}
}
// 获取整体完成情况
PgsProgressCategoryValueTotalVo valueTotal = progressCategoryService.getValueTotal(children, true);
vo.setTotalCompletionAmount(valueTotal.getTotalValue().divide(BigDecimal.valueOf(10000), 0, RoundingMode.HALF_UP));
vo.setCurrentCompletionAmount(valueTotal.getCurrentValue().divide(BigDecimal.valueOf(10000), 0, RoundingMode.HALF_UP));
// 获取详情
Map<String, List<PgsProgressCategory>> nameMap = topList.stream()
.collect(Collectors.groupingBy(PgsProgressCategory::getName));
List<ProjectTotalProgressDetailVo> detailList = new ArrayList<>();
for (Map.Entry<String, List<PgsProgressCategory>> entry : nameMap.entrySet()) {
ProjectTotalProgressDetailVo detailVo = new ProjectTotalProgressDetailVo();
String name = entry.getKey();
detailVo.setName(name);
List<PgsProgressCategory> value = entry.getValue();
List<Long> top = value.stream().map(PgsProgressCategory::getId).toList();
List<PgsProgressCategory> nameChildren = progressCategoryService.getLeafNodesByTopIds(top, children);
BigDecimal completedTotal = nameChildren.stream().map(PgsProgressCategory::getCompleted)
.reduce(BigDecimal.ZERO, BigDecimal::add);
BigDecimal planTotal = nameChildren.stream().map(PgsProgressCategory::getPlanTotal)
.reduce(BigDecimal.ZERO, BigDecimal::add);
BigDecimal total = nameChildren.stream().map(PgsProgressCategory::getTotal)
.reduce(BigDecimal.ZERO, BigDecimal::add);
detailVo.setActualProgress(completedTotal);
detailVo.setPlanProgress(planTotal);
detailVo.setCompletionRate(BigDecimalUtil.toPercentage(completedTotal, total));
detailList.add(detailVo);
}
vo.setDetailList(detailList);
return vo;
}
/**
* 获取施工进度详情
*
* @param req 请求参数
* @return 施工进度详情
*/
@Override
public List<ProjectImageProgressDetailVo> getProjectTotalProgressDetail(ProjectImageProgressDetailReq req) {
req.setIsAll(true);
return projectBigScreenService.getProjectImageProgressDetail(req);
}
/**
* 获取里程碑进度
*
* @param projectId 项目 id
* @return 里程碑进度
*/
@Override
public List<MilestoneProgressVo> getMilestoneProgress(Long projectId) {
List<MilestoneProgressVo> voList = new ArrayList<>();
List<PgsConstructionSchedulePlan> planList = constructionSchedulePlanService.lambdaQuery()
.eq(PgsConstructionSchedulePlan::getProjectId, projectId)
.list();
if (CollUtil.isEmpty(planList)) {
return voList;
}
List<PgsConstructionSchedulePlan> topList = planList.stream().filter(plan -> plan.getParentId().equals(0L)).toList();
return topList.stream().map(plan -> {
MilestoneProgressVo vo = new MilestoneProgressVo();
BeanUtils.copyProperties(plan, vo);
// 获取子节点
List<PgsConstructionSchedulePlan> allChildren = constructionSchedulePlanService.getAllChildren(plan.getId(), planList);
long count = allChildren.stream().filter(child -> child.getStatus().equals("4")).count();
BigDecimal percentage = BigDecimalUtil.toPercentage(new BigDecimal(count), new BigDecimal(allChildren.size()));
vo.setCurrentProgress(percentage);
return vo;
}).toList();
}
/**
* 获取设计进度
*
* @param projectId 项目 id
* @return 设计进度
*/
@Override
public DesignProgressVo getDesignProgress(Long projectId) {
DesignProgressVo vo = new DesignProgressVo();
List<DesVolumeCatalog> catalogList = volumeCatalogService.lambdaQuery()
.eq(DesVolumeCatalog::getProjectId, projectId).list();
if (CollUtil.isEmpty(catalogList)) {
return vo;
}
LocalDate nowDate = LocalDate.now();
long currentDesignProgress = 0L;
BigDecimal designProgressThisM = BigDecimal.ZERO;
BigDecimal designProgressLastM = BigDecimal.ZERO;
long currentDelay = 0L;
BigDecimal delayThisD = BigDecimal.ZERO;
BigDecimal delayLastD = BigDecimal.ZERO;
// 总数量
vo.setTotalDesignProgress((long) catalogList.size());
LocalDateTime firstDayOfMonth = LocalDateTime.now().withDayOfMonth(1).with(LocalTime.MIN);
LocalDateTime lastMonthFirstDay = LocalDateTime.now().minusMonths(1).withDayOfMonth(1).with(LocalTime.MIN);
for (DesVolumeCatalog catalog : catalogList) {
// 已出图状态
if (catalog.getDesignState().equals("1")) {
currentDesignProgress++;
// 获取当月和上月的完成数量
LocalDateTime finishTime = catalog.getFinishTime();
if (finishTime != null) {
if (finishTime.isAfter(firstDayOfMonth)) {
designProgressThisM = designProgressThisM.add(BigDecimal.ONE);
} else if (finishTime.isBefore(lastMonthFirstDay)) {
designProgressLastM = designProgressLastM.add(BigDecimal.ONE);
}
}
} else if (!catalog.getPlannedCompletion().isAfter(nowDate) && catalog.getDesignState().equals("2")) {
currentDelay++;
if (catalog.getPlannedCompletion().isEqual(nowDate)) {
delayThisD = delayThisD.add(BigDecimal.ONE);
} else if (catalog.getPlannedCompletion().isEqual(nowDate.minusDays(1))) {
delayLastD = delayLastD.add(BigDecimal.ONE);
}
}
}
// 计算完成情况
vo.setCurrentDesignProgress(currentDesignProgress);
vo.setDesignProgressTrend(designProgressThisM.compareTo(designProgressLastM) >= 0);
vo.setDesignProgressRate(BigDecimalUtil.toLoopPercentage(designProgressThisM, designProgressLastM));
// 总逾期数量
vo.setDelayedDesign(currentDelay);
vo.setDelayedDesignTrend(delayThisD.compareTo(delayLastD) >= 0);
vo.setDelayedDesignRate(BigDecimalUtil.toLoopPercentage(delayThisD, delayLastD));
// 获取各专业完成情况
List<DesignProgressMajorVo> majorList = new ArrayList<>();
Map<String, List<DesVolumeCatalog>> specialtyMap = catalogList.stream()
.collect(Collectors.groupingBy(DesVolumeCatalog::getSpecialty));
List<SysDictDataVo> desUserMajor = dictDataService.selectByDictType("des_user_major");
if (CollUtil.isEmpty(desUserMajor)) {
log.error("专业字典 des_user_major 数据不存在");
} else {
Map<String, String> dictMap = desUserMajor.stream()
.collect(Collectors.toMap(SysDictDataVo::getDictValue, SysDictDataVo::getDictLabel));
specialtyMap.forEach((specialty, list) -> {
DesignProgressMajorVo majorVo = new DesignProgressMajorVo();
majorVo.setMajorName(dictMap.getOrDefault(specialty, specialty));
BigDecimal total = new BigDecimal(list.size());
long count = list.stream().filter(catalog -> catalog.getDesignState().equals("1")).count();
majorVo.setCompletionRate(BigDecimalUtil.toPercentage(new BigDecimal(count), total));
majorList.add(majorVo);
});
}
vo.setMajorList(majorList);
// 审核信息
Set<Long> ids = catalogList.stream().map(DesVolumeCatalog::getDesign).collect(Collectors.toSet());
List<DesVolumeFile> fileList = volumeFileService.lambdaQuery()
.in(DesVolumeFile::getVolumeCatalogId, ids)
.list();
long reviewedDesign = 0L;
BigDecimal reviewedDesignThisM = BigDecimal.ZERO;
BigDecimal reviewedDesignLastM = BigDecimal.ZERO;
long pendingReviewDesign = 0L;
BigDecimal pendingReviewDesignThisD = BigDecimal.ZERO;
BigDecimal pendingReviewDesignLastD = BigDecimal.ZERO;
for (DesVolumeFile file : fileList) {
String status = file.getStatus();
if (BusinessStatusEnum.FINISH.getStatus().equals(status)) {
reviewedDesign++;
// 获取当月和上月的完成数量
LocalDateTime finishTime = file.getFinishTime();
if (finishTime != null) {
if (finishTime.isAfter(firstDayOfMonth)) {
reviewedDesignThisM = reviewedDesignThisM.add(BigDecimal.ONE);
} else if (finishTime.isBefore(lastMonthFirstDay)) {
reviewedDesignLastM = reviewedDesignLastM.add(BigDecimal.ONE);
}
}
} else if (BusinessStatusEnum.WAITING.getStatus().equals(status)) {
pendingReviewDesign++;
Date createTime = file.getCreateTime();
LocalDate createDate = createTime.toInstant()
.atZone(ZoneId.systemDefault())
.toLocalDate();
if (createDate.isEqual(nowDate)) {
pendingReviewDesignThisD = pendingReviewDesignThisD.add(BigDecimal.ONE);
} else if (createDate.isEqual(nowDate.minusDays(1))) {
pendingReviewDesignLastD = pendingReviewDesignLastD.add(BigDecimal.ONE);
}
}
}
vo.setTotalDesign((long) fileList.size());
vo.setReviewedDesign(reviewedDesign);
vo.setReviewedDesignTrend(reviewedDesignThisM.compareTo(reviewedDesignLastM) >= 0);
vo.setReviewedDesignRate(BigDecimalUtil.toLoopPercentage(reviewedDesignThisM, reviewedDesignLastM));
vo.setPendingDesignReview(pendingReviewDesign);
vo.setPendingDesignReviewTrend(pendingReviewDesignThisD.compareTo(pendingReviewDesignLastD) >= 0);
vo.setPendingDesignReviewRate(BigDecimalUtil.toLoopPercentage(pendingReviewDesignThisD, pendingReviewDesignLastD));
return vo;
}
/**
* 获取物料进度详情
*
* @param projectId 项目 id
* @return 物料进度详情
*/
@Override
public List<MaterialProgressDetailVo> getMaterialProgressDetail(Long projectId, String name, String specification) {
// 根据名称 规格获取材料
List<MatMaterialReceiveItem> itemList = materialReceiveItemService.lambdaQuery()
.eq(MatMaterialReceiveItem::getName, name)
.eq(MatMaterialReceiveItem::getSpecification, specification)
.list();
if (CollUtil.isEmpty(itemList)) {
return List.of();
}
Set<Long> ids = itemList.stream().map(MatMaterialReceiveItem::getReceiveId).collect(Collectors.toSet());
List<MatMaterialReceive> receiveList = materialReceiveService.lambdaQuery()
.in(MatMaterialReceive::getId, ids)
.list();
Map<Long, MatMaterialReceive> receiveMap = receiveList.stream()
.collect(Collectors.toMap(MatMaterialReceive::getId, receive -> receive));
return itemList.stream().map(item -> {
Long receiveId = item.getReceiveId();
MatMaterialReceive receive = receiveMap.get(receiveId);
if (receive == null) {
return null;
}
MaterialProgressDetailVo vo = new MaterialProgressDetailVo();
vo.setId(item.getId());
vo.setName(item.getName());
vo.setQuantity(item.getQuantity());
vo.setAcceptedQuantity(item.getAcceptedQuantity());
vo.setShortageQuantity(item.getShortageQuantity());
vo.setFormCode(receive.getFormCode());
vo.setContractName(receive.getContractName());
vo.setOrderingUnit(receive.getOrderingUnit());
vo.setSupplierUnit(receive.getSupplierUnit());
vo.setArrivalDate(DateUtils.toLocalDate(receive.getCreateTime()));
return vo;
}).filter(Objects::nonNull).toList();
}
/**
* 获取物资进度
*
* @param projectId 项目 id
* @return 物资进度
*/
@Override
public List<wzxqysjdhdbVo> getMaterialProgress(Long projectId) {
List<wzxqysjdhdbVo> wzxqysjdhdb = mrpBaseService.wzxqysjdhdb(projectId);
Map<String, List<wzxqysjdhdbVo>> map = wzxqysjdhdb.stream()
.collect(Collectors.groupingBy(o -> o.getName() + o.getSpecification()));
List<wzxqysjdhdbVo> wzxqysjdhdbList = new ArrayList<>();
map.forEach((k, v) -> {
wzxqysjdhdbVo vo = new wzxqysjdhdbVo();
vo.setName(v.getFirst().getName());
vo.setSpecification(v.getFirst().getSpecification());
BigDecimal design = v.stream().map(wzxqysjdhdbVo::getDesignTotalPrices).reduce(BigDecimal.ZERO, BigDecimal::add);
vo.setDesignTotalPrices(design);
BigDecimal arrival = v.stream().map(wzxqysjdhdbVo::getArrivalTotalPrices).reduce(BigDecimal.ZERO, BigDecimal::add);
vo.setArrivalTotalPrices(arrival);
wzxqysjdhdbList.add(vo);
});
return wzxqysjdhdbList;
}
}

View File

@ -4,6 +4,7 @@ import cn.hutool.core.collection.CollUtil;
import cn.hutool.json.JSONArray;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import jakarta.annotation.Resource;
import org.dromara.bigscreen.domain.dto.ProjectImageProgressDetailReq;
@ -370,7 +371,7 @@ public class ProjectBigScreenServiceImpl implements ProjectBigScreenService {
// 如果有叶子节点,统计进度和状态;否则初始化为未完成
if (CollUtil.isNotEmpty(leafNodesByTopIds)) {
topVo.setProgressTotal(progressCategoryService.getCompletedPercentage(leafNodesByTopIds));
topVo.setValueTotal(progressCategoryService.getValueTotal(leafNodesByTopIds, true));
topVo.setValueTotal(progressCategoryService.getValueTotal(leafNodesByTopIds, true).getCurrentValue());
} else {
topVo.setProgressTotal(BigDecimal.ZERO);
topVo.setValueTotal(BigDecimal.ZERO);
@ -530,25 +531,38 @@ public class ProjectBigScreenServiceImpl implements ProjectBigScreenService {
Set<Long> projectIds = subProjects.stream().map(BusProject::getId).collect(Collectors.toSet());
projectIds.add(projectId);
// 获取对应进度
PgsProgressCategory progressCategory = progressCategoryService.lambdaQuery()
List<PgsProgressCategory> progressCategoryList = progressCategoryService.lambdaQuery()
.in(PgsProgressCategory::getProjectId, projectIds)
.eq(PgsProgressCategory::getName, progressName)
.last("limit 1")
.one();
if (progressCategory == null) {
.list();
if (CollUtil.isEmpty(progressCategoryList)) {
return List.of();
}
Long topId = progressCategory.getId();
final List<String> gfcqName = List.of("场地平整", "桩基成孔", "桩基浇筑", "支架安装", "组件安装");
// 查出所有属于该顶级节点的子孙节点
List<PgsProgressCategory> allChildren = progressCategoryService.list(
LambdaQueryWrapper<PgsProgressCategory> lqw = new LambdaQueryWrapper<>();
List<PgsProgressCategory> allChildren;
if (progressName.equals("光伏场区")) {
final List<String> gfcqName = List.of("场地平整", "桩基成孔", "桩基浇筑", "支架安装", "组件安装");
List<Long> topIds = progressCategoryList.stream().map(PgsProgressCategory::getId).toList();
// 查出所有属于这些顶级节点的子孙节点
allChildren = progressCategoryService.list(
Wrappers.<PgsProgressCategory>lambdaQuery()
.in(progressName.equals("光伏场区"), PgsProgressCategory::getName, gfcqName)
.and(wrapper ->
wrapper.like(PgsProgressCategory::getAncestors, "," + topId + ",")
.or()
.like(PgsProgressCategory::getAncestors, "," + topId))
.in(!req.getIsAll(), PgsProgressCategory::getName, gfcqName)
.and(wrapper -> {
for (Long topId : topIds) {
wrapper.or(q -> q.like(PgsProgressCategory::getAncestors, "," + topId + ","))
.or(q -> q.like(PgsProgressCategory::getAncestors, "," + topId));
}
})
);
} else {
PgsProgressCategory first = progressCategoryList.getFirst();
lqw.and(wrapper ->
wrapper.like(PgsProgressCategory::getAncestors, "," + first.getId() + ",")
.or()
.like(PgsProgressCategory::getAncestors, "," + first.getId()));
allChildren = progressCategoryService.list(lqw);
}
if (allChildren.isEmpty()) {
return Collections.emptyList();
}
@ -556,7 +570,6 @@ public class ProjectBigScreenServiceImpl implements ProjectBigScreenService {
Set<Long> parentIds = allChildren.stream()
.map(PgsProgressCategory::getParentId)
.collect(Collectors.toSet());
List<PgsProgressCategory> dierList = allChildren.stream()
.filter(item -> !parentIds.contains(item.getId()))
.toList();
@ -568,6 +581,7 @@ public class ProjectBigScreenServiceImpl implements ProjectBigScreenService {
vo.setPlanProgress(c.getPlanTotal());
vo.setActualProgress(c.getCompleted());
vo.setTotalProgress(c.getTotal());
vo.setCompletionRate(BigDecimalUtil.toPercentage(c.getCompleted(), c.getTotal()));
return vo;
}).toList();
}
@ -575,26 +589,48 @@ public class ProjectBigScreenServiceImpl implements ProjectBigScreenService {
Set<Long> parentIds = allChildren.stream()
.map(PgsProgressCategory::getParentId)
.collect(Collectors.toSet());
List<PgsProgressCategory> dierList = allChildren.stream()
.filter(item -> parentIds.contains(item.getId()))
.toList();
List<ProjectImageProgressDetailVo> detailVoList = new ArrayList<>();
if (CollUtil.isEmpty(dierList)) {
return allChildren.stream().map(c -> {
// 根据名称进行分类汇总
Map<String, List<PgsProgressCategory>> childrenMap = allChildren.stream()
.collect(Collectors.groupingBy(PgsProgressCategory::getName));
childrenMap.forEach((name, children) -> {
if (CollUtil.isEmpty(children)) {
return;
}
ProjectImageProgressDetailVo vo = new ProjectImageProgressDetailVo();
vo.setId(c.getId());
vo.setUnit(c.getUnit());
vo.setProgressName(c.getName());
vo.setPlanProgress(c.getPlanTotal());
vo.setActualProgress(c.getCompleted());
vo.setTotalProgress(c.getTotal());
return vo;
}).toList();
String unit = children.stream().map(PgsProgressCategory::getUnit)
.filter(Objects::nonNull)
.findFirst().orElse(null);
vo.setUnit(unit);
vo.setProgressName(name);
BigDecimal plan = children.stream().map(PgsProgressCategory::getPlanTotal)
.reduce(BigDecimal.ZERO, BigDecimal::add);
vo.setPlanProgress(plan);
BigDecimal completed = children.stream().map(PgsProgressCategory::getCompleted)
.reduce(BigDecimal.ZERO, BigDecimal::add);
vo.setActualProgress(completed);
BigDecimal total = children.stream().map(PgsProgressCategory::getTotal)
.reduce(BigDecimal.ZERO, BigDecimal::add);
vo.setTotalProgress(total);
vo.setCompletionRate(BigDecimalUtil.toPercentage(completed, total));
detailVoList.add(vo);
});
} else {
return dierList.stream().map(c -> {
// 根据名称进行分类汇总
Map<String, List<PgsProgressCategory>> dierMap = dierList.stream()
.collect(Collectors.groupingBy(PgsProgressCategory::getName));
dierMap.forEach((name, value) -> {
ProjectImageProgressDetailVo vo = new ProjectImageProgressDetailVo();
Set<Long> parentIdSet = value.stream()
.map(PgsProgressCategory::getId)
.collect(Collectors.toSet());
// 获取子集
List<PgsProgressCategory> children = allChildren.stream()
.filter(item -> item.getParentId().equals(c.getId()))
.filter(item -> parentIdSet.contains(item.getParentId()))
.toList();
// 计算
BigDecimal plan = children.stream().map(PgsProgressCategory::getPlanTotal)
@ -603,16 +639,19 @@ public class ProjectBigScreenServiceImpl implements ProjectBigScreenService {
.reduce(BigDecimal.ZERO, BigDecimal::add);
BigDecimal total = children.stream().map(PgsProgressCategory::getTotal)
.reduce(BigDecimal.ZERO, BigDecimal::add);
ProjectImageProgressDetailVo vo = new ProjectImageProgressDetailVo();
vo.setId(c.getId());
vo.setUnit(c.getUnit());
vo.setProgressName(c.getName());
vo.setPlanProgress(plan);
vo.setActualProgress(actual);
vo.setTotalProgress(total);
return vo;
}).toList();
vo.setProgressName(name);
String unit = value.stream().map(PgsProgressCategory::getUnit)
.filter(Objects::nonNull)
.findFirst().orElse(null);
vo.setUnit(unit);
vo.setCompletionRate(BigDecimalUtil.toPercentage(actual, total));
detailVoList.add(vo);
});
}
return detailVoList;
}
/**

View File

@ -91,6 +91,7 @@ public class SysRoleWorkServiceImpl extends ServiceImpl<SysRoleWorkMapper, SysRo
LambdaQueryWrapper<SysRoleWork> lqw = Wrappers.lambdaQuery();
lqw.orderByDesc(SysRoleWork::getCreateTime);
lqw.eq(bo.getRoleId() != null, SysRoleWork::getRoleId, bo.getRoleId());
lqw.eq(bo.getProjectId() != null, SysRoleWork::getProjectId, bo.getProjectId());
lqw.eq(StringUtils.isNotBlank(bo.getLcmc()), SysRoleWork::getLcmc, bo.getLcmc());
lqw.eq(StringUtils.isNotBlank(bo.getLcms()), SysRoleWork::getLcms, bo.getLcms());
lqw.eq(StringUtils.isNotBlank(bo.getLcxq()), SysRoleWork::getLcxq, bo.getLcxq());

View File

@ -94,6 +94,12 @@ public class BusMaterialbatchdemandplan extends BaseEntity {
*/
private BigDecimal demandQuantity;
/**
* 单价
*/
private BigDecimal unitPrice;
/**
* 计划到场时间
*/

View File

@ -93,6 +93,11 @@ public class BusMaterialbatchdemandplanBo extends BaseEntity {
*/
private BigDecimal demandQuantity;
/**
* 单价
*/
private BigDecimal unitPrice;
/**
* 计划到场时间
*/

View File

@ -118,6 +118,11 @@ public class BusMaterialbatchdemandplanVo implements Serializable {
@ExcelProperty(value = "需求数量")
private BigDecimal demandQuantity;
/**
* 单价
*/
private BigDecimal unitPrice;
/**
* 计划到场时间
*/

View File

@ -1,5 +1,7 @@
package org.dromara.cailiaoshebei.service;
import org.dromara.bigscreen.domain.vo.designAndArrivalComparisonVo;
import org.dromara.bigscreen.domain.vo.wzxqysjdhdbVo;
import org.dromara.cailiaoshebei.domain.bo.BusMrpBaseReq;
import org.dromara.cailiaoshebei.domain.dto.BusMrpDto;
import org.dromara.cailiaoshebei.domain.dto.BusMrpExportDto;
@ -90,4 +92,14 @@ public interface IBusMrpBaseService extends IService<BusMrpBase>{
Map<String, Object> remaining(Long projectId,Long limitListId,Long mrpBaseId);
List<BusMrpBaseVo> getListByName(BusMrpBaseReq req);
/**
* 设计量与到货量对比
*/
List<designAndArrivalComparisonVo> designAndArrivalComparison(Long projectId);
/**
* 物资需求与实际到货对比
*/
List<wzxqysjdhdbVo> wzxqysjdhdb(Long projectId);
}

View File

@ -105,4 +105,6 @@ public interface IBusPurchaseDocService extends IService<BusPurchaseDoc> {
* @return 是否修改成功
*/
Boolean updateFeedback(FeedbackDto dto);
List<BusPurchaseDocVo> purchaseNote(Long projectId);
}

View File

@ -1,20 +1,33 @@
package org.dromara.cailiaoshebei.service.impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.convert.Convert;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import jakarta.annotation.Resource;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.dromara.bigscreen.domain.vo.designAndArrivalComparisonVo;
import org.dromara.bigscreen.domain.vo.wzxqysjdhdbVo;
import org.dromara.cailiaoshebei.domain.BusMaterialbatchdemandplan;
import org.dromara.cailiaoshebei.domain.BusMrpBase;
import org.dromara.cailiaoshebei.domain.BusPlanDocAssociation;
import org.dromara.cailiaoshebei.domain.bo.BusMaterialbatchdemandplanBo;
import org.dromara.cailiaoshebei.domain.bo.BusMrpBaseBo;
import org.dromara.cailiaoshebei.domain.bo.BusMrpBaseReq;
import org.dromara.cailiaoshebei.domain.dto.BusMaterialbatchdemandplanExportDto;
import org.dromara.cailiaoshebei.domain.dto.BusMrpDto;
import org.dromara.cailiaoshebei.domain.dto.BusMrpExportDto;
import org.dromara.cailiaoshebei.domain.vo.BusMaterialbatchdemandplanVo;
import org.dromara.cailiaoshebei.domain.vo.BusMrpBaseVo;
import org.dromara.cailiaoshebei.domain.vo.BusMrpVo;
import org.dromara.cailiaoshebei.mapper.BusMrpBaseMapper;
import org.dromara.cailiaoshebei.service.IBusMaterialbatchdemandplanService;
import org.dromara.cailiaoshebei.service.IBusMrpBaseService;
import org.dromara.cailiaoshebei.service.IBusPlanDocAssociationService;
import org.dromara.common.core.domain.event.ProcessDeleteEvent;
import org.dromara.common.core.domain.event.ProcessEvent;
@ -23,26 +36,20 @@ import org.dromara.common.core.enums.BusinessStatusEnum;
import org.dromara.common.core.exception.ServiceException;
import org.dromara.common.core.utils.MapstructUtils;
import org.dromara.common.core.utils.StringUtils;
import org.dromara.common.mybatis.core.page.TableDataInfo;
import org.dromara.common.mybatis.core.page.PageQuery;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import lombok.RequiredArgsConstructor;
import org.dromara.common.mybatis.core.page.TableDataInfo;
import org.dromara.common.utils.excel.ExcelDynamicReader;
import org.dromara.design.domain.BusBillofquantities;
import org.dromara.design.service.IBusBillofquantitiesService;
import org.dromara.materials.domain.MatMaterialReceiveItem;
import org.dromara.materials.service.IMatMaterialReceiveItemService;
import org.dromara.tender.domain.BusBillofquantitiesLimitList;
import org.dromara.tender.domain.BusTenderPlanningLimitList;
import org.dromara.tender.enums.LimitListTypeEnum;
import org.dromara.tender.service.IBusBillofquantitiesLimitListService;
import org.dromara.tender.service.IBusTenderPlanningLimitListService;
import org.jetbrains.annotations.NotNull;
import org.springframework.context.annotation.Lazy;
import org.springframework.context.event.EventListener;
import org.springframework.stereotype.Service;
import org.dromara.cailiaoshebei.domain.bo.BusMrpBaseBo;
import org.dromara.cailiaoshebei.domain.vo.BusMrpBaseVo;
import org.dromara.cailiaoshebei.domain.BusMrpBase;
import org.dromara.cailiaoshebei.mapper.BusMrpBaseMapper;
import org.dromara.cailiaoshebei.service.IBusMrpBaseService;
import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal;
@ -70,6 +77,9 @@ public class BusMrpBaseServiceImpl extends ServiceImpl<BusMrpBaseMapper, BusMrpB
private final IBusTenderPlanningLimitListService tenderPlanningLimitListService;
@Lazy
@Resource
private IMatMaterialReceiveItemService matMaterialReceiveItemService;
/**
@ -327,6 +337,7 @@ public class BusMrpBaseServiceImpl extends ServiceImpl<BusMrpBaseMapper, BusMrpB
if (busBillofquantities != null) {
map.put("specification", busBillofquantities.getSpecification());
map.put("unit", busBillofquantities.getUnit());
map.put("unitPrice", busBillofquantities.getUnitPrice());
map.put("remark", busBillofquantities.getRemark());
map.put("name", busBillofquantities.getName());
}
@ -365,6 +376,84 @@ public class BusMrpBaseServiceImpl extends ServiceImpl<BusMrpBaseMapper, BusMrpB
.eq(BusMrpBase::getStatus, BusinessStatusEnum.FINISH.getStatus()).in(BusMrpBase::getId, mrpIds));
}
@Override
public List<designAndArrivalComparisonVo> designAndArrivalComparison(Long projectId) {
// 获取施工图一览的所有材料数据
List<BusBillofquantitiesLimitList> limitLists = busBillofquantitiesService.getBaseMapper().selectList(new LambdaQueryWrapper<BusBillofquantitiesLimitList>()
.eq(BusBillofquantitiesLimitList::getProjectId, projectId)
.eq(BusBillofquantitiesLimitList::getType, LimitListTypeEnum.SPECIAL.getCode())
.isNotNull(BusBillofquantitiesLimitList::getQuantity));
Map<Long, BigDecimal> wuZiMap = getWuZiMap(projectId);
// 根据批次需求计划的物资id获取到施工图一览对应数据
List<designAndArrivalComparisonVo> list = new ArrayList<>();
limitLists.forEach(limitList -> {
designAndArrivalComparisonVo vo = new designAndArrivalComparisonVo();
vo.setName(limitList.getName());
vo.setSpecification(limitList.getSpecification());
vo.setUnit(limitList.getUnit());
vo.setDesignTotalPrices(limitList.getQuantity());
vo.setArrivalTotalPrices(wuZiMap.getOrDefault(limitList.getId(), BigDecimal.ZERO));
list.add(vo);
});
return list;
}
@NotNull
private Map<Long, BigDecimal> getWuZiMap(Long projectId) {
// 获取所有入库数据 mat_material_receive_item
List<MatMaterialReceiveItem> matMaterialReceiveItems = matMaterialReceiveItemService.getBaseMapper()
.selectList(new LambdaQueryWrapper<MatMaterialReceiveItem>()
.eq(MatMaterialReceiveItem::getProjectId, projectId));
//将相同计划批次数据进行分组合并
Set<Long> planIds = matMaterialReceiveItems.stream()
.map(MatMaterialReceiveItem::getPlanId)
.collect(Collectors.toSet());
if (CollUtil.isEmpty(planIds)) {
return new HashMap<>();
}
Map<Long, BigDecimal> planMap = matMaterialReceiveItems.stream()
.filter(matMaterialReceiveItem -> matMaterialReceiveItem.getPlanId() != null)
.collect(Collectors.groupingBy(
MatMaterialReceiveItem::getPlanId,
Collectors.reducing(BigDecimal.ZERO, MatMaterialReceiveItem::getAcceptedQuantity, BigDecimal::add)
));
// 根据入库数据反查批次需求计划数据 bus_materialbatchdemandplan
List<BusMaterialbatchdemandplan> materialbatchdemandplans = planservice.getBaseMapper().selectList(new LambdaQueryWrapper<BusMaterialbatchdemandplan>()
.eq(BusMaterialbatchdemandplan::getProjectId, projectId)
.in(BusMaterialbatchdemandplan::getId, planIds));
Map<Long, BigDecimal> wuZiMap = new HashMap<>();
materialbatchdemandplans.forEach(materialbatchdemandplan -> {
//merge()方法如果键存在则合并值,否则直接放入
wuZiMap.merge(
materialbatchdemandplan.getSuppliespriceId(),
planMap.get(materialbatchdemandplan.getId()),
BigDecimal::add
);
});
return wuZiMap;
}
@Override
public List<wzxqysjdhdbVo> wzxqysjdhdb(Long projectId) {
// 获取施工图一览的所有材料数据
List<BusBillofquantitiesLimitList> limitLists = busBillofquantitiesService.getBaseMapper().selectList(new LambdaQueryWrapper<BusBillofquantitiesLimitList>()
.eq(BusBillofquantitiesLimitList::getProjectId, projectId)
.eq(BusBillofquantitiesLimitList::getType, LimitListTypeEnum.SPECIAL.getCode())
.isNotNull(BusBillofquantitiesLimitList::getQuantity));
Map<Long, BigDecimal> wuZiMap = getWuZiMap(projectId);
// 根据批次需求计划的物资id获取到施工图一览对应数据
List<wzxqysjdhdbVo> list = new ArrayList<>();
limitLists.forEach(limitList -> {
wzxqysjdhdbVo vo = new wzxqysjdhdbVo();
vo.setName(limitList.getName());
vo.setSpecification(limitList.getSpecification());
vo.setDesignTotalPrices(limitList.getQuantity());
vo.setArrivalTotalPrices(wuZiMap.getOrDefault(limitList.getId(), BigDecimal.ZERO));
list.add(vo);
});
return list;
}
/**
* 总体流程监听(例如: 草稿,撤销,退回,作废,终止,已完成,单任务完成等)
* 正常使用只需#processEvent.flowCode=='leave1'

View File

@ -111,6 +111,9 @@ public class BusPurchaseDocServiceImpl extends ServiceImpl<BusPurchaseDocMapper,
@Override
public BusPurchaseDocVo queryById(Long id) {
BusPurchaseDocVo busPurchaseDocVo = baseMapper.selectVoById(id);
if (busPurchaseDocVo == null){
return busPurchaseDocVo;
}
BusPlanDocAssociationBo busPlanDocAssociationBo = new BusPlanDocAssociationBo();
busPlanDocAssociationBo.setDocId(id);
List<BusPlanDocAssociationVo> busPlanDocAssociationVos = planDocAssociationService.queryList(busPlanDocAssociationBo);
@ -411,7 +414,12 @@ public class BusPurchaseDocServiceImpl extends ServiceImpl<BusPurchaseDocMapper,
.eq(BusPlanDocAssociation::getDocId, purchaseDoc.getId())
.list();
if (CollUtil.isNotEmpty(planDocAssociationList)) {
Map<Long, BigDecimal> map = planDocAssociationList.stream().collect(Collectors.toMap(BusPlanDocAssociation::getPlanId, BusPlanDocAssociation::getDemandQuantity));
Map<Long, BigDecimal> map = planDocAssociationList.stream()
.peek(item -> {
if (item.getDemandQuantity() == null) {
item.setDemandQuantity(BigDecimal.ZERO);
}
}).collect(Collectors.toMap(BusPlanDocAssociation::getPlanId, BusPlanDocAssociation::getDemandQuantity));
items = materialbatchdemandplanService.listByIds(map.keySet());
items.forEach(item -> item.setDemandQuantity(map.get(item.getId())));
}
@ -575,6 +583,25 @@ public class BusPurchaseDocServiceImpl extends ServiceImpl<BusPurchaseDocMapper,
return updateById(busPurchaseDoc);
}
@Override
public List<BusPurchaseDocVo> purchaseNote(Long projectId) {
List<BusPurchaseDocVo> busPurchaseDocVos = baseMapper.selectVoList(new LambdaQueryWrapper<BusPurchaseDoc>()
.eq(BusPurchaseDoc::getProjectId, projectId)
.eq(BusPurchaseDoc::getDocType, "1")
.eq(BusPurchaseDoc::getStatus, BusinessStatusEnum.FINISH.getStatus())
.orderByDesc(BusPurchaseDoc::getCreateTime));
if (busPurchaseDocVos == null){
return List.of();
}
busPurchaseDocVos.forEach(v -> {
BusMrpBase byId = mrpBaseService.getById(v.getMrpBaseId());
if (byId != null) {
v.setPlanCode(byId.getPlanCode());
}
});
return busPurchaseDocVos;
}
/**
* 根据实体获取替换数据
*

View File

@ -25,4 +25,26 @@ public class BigDecimalUtil {
.divide(divisor, 2, RoundingMode.HALF_UP);
}
/**
* 计算环比 = (本次 - 上次) / 上次 × 100% 的绝对值
*
* @param thisNum 本次数量
* @param lastNum 上次数量
* @return 环比 = (本次 - 上次) / 上次 × 100% 的绝对值
*/
public static BigDecimal toLoopPercentage(BigDecimal thisNum, BigDecimal lastNum) {
if (thisNum == null || lastNum == null) {
return BigDecimal.valueOf(0.00);
}
if (lastNum.compareTo(BigDecimal.ZERO) == 0 && thisNum.compareTo(BigDecimal.ZERO) > 0) {
return BigDecimal.valueOf(100.00);
} else if (lastNum.compareTo(BigDecimal.ZERO) == 0) {
return BigDecimal.valueOf(0.00);
}
return thisNum.subtract(lastNum)
.multiply(new BigDecimal("100"))
.divide(lastNum, 2, RoundingMode.HALF_UP)
.abs();
}
}

View File

@ -79,6 +79,38 @@ public class JtsPointMatcher {
return matched;
}
/**
* 计算多边形的中心点
*
* @param points 多边形的顶点坐标
* @return 中心点的坐标
*/
public static List<Double> polygonCentroid(List<List<Double>> points) {
double area = 0;
double cx = 0;
double cy = 0;
int size = points.size();
for (int i = 0; i < size - 1; i++) {
double x0 = points.get(i).get(0);
double y0 = points.get(i).get(1);
double x1 = points.get(i + 1).get(0);
double y1 = points.get(i + 1).get(1);
double cross = x0 * y1 - x1 * y0;
area += cross;
cx += (x0 + x1) * cross;
cy += (y0 + y1) * cross;
}
area *= 0.5;
cx /= (6 * area);
cy /= (6 * area);
return List.of(cx, cy);
}
public static void main(String[] args) {
// A列表待匹配点
List<Coordinate> listA = List.of(

View File

@ -8,6 +8,7 @@ import org.dromara.common.mybatis.core.domain.BaseEntity;
import java.io.Serial;
import java.time.LocalDate;
import java.time.LocalDateTime;
/**
* 卷册目录对象 des_volume_catalog
@ -74,6 +75,11 @@ public class DesVolumeCatalog extends BaseEntity {
*/
private LocalDate plannedCompletion;
/**
* 实际完成时间
*/
private LocalDateTime finishTime;
/**
* 状态(字典)
*/

View File

@ -1,11 +1,13 @@
package org.dromara.design.domain;
import org.dromara.common.mybatis.core.domain.BaseEntity;
import com.baomidou.mybatisplus.annotation.*;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.dromara.common.mybatis.core.domain.BaseEntity;
import java.io.Serial;
import java.time.LocalDateTime;
/**
* 卷册文件对象 des_volume_file
@ -28,7 +30,6 @@ public class DesVolumeFile extends BaseEntity {
public static final String WASTE = "4";
/**
* 主键ID
*/
@ -80,4 +81,9 @@ public class DesVolumeFile extends BaseEntity {
*/
private String auditStatus;
/**
* 实际完成时间
*/
private LocalDateTime finishTime;
}

View File

@ -89,6 +89,11 @@ public class DesVolumeCatalogVo implements Serializable {
*/
private LocalDate plannedCompletion;
/**
* 实际完成时间
*/
private LocalDateTime finishTime;
/**
* 状态(字典)
*/

View File

@ -6,6 +6,7 @@ import org.dromara.design.domain.DesVolumeFile;
import java.io.Serial;
import java.io.Serializable;
import java.time.LocalDateTime;
/**
@ -76,6 +77,11 @@ public class DesVolumeFileVo implements Serializable {
*/
private String auditStatus;
/**
* 实际完成时间
*/
private LocalDateTime finishTime;
/**
* 是否弹窗
*/

View File

@ -12,7 +12,6 @@ import io.micrometer.common.util.StringUtils;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.dromara.common.core.constant.HttpStatus;
import org.dromara.common.core.domain.dto.UserDTO;
import org.dromara.common.core.domain.event.ProcessDeleteEvent;
import org.dromara.common.core.domain.event.ProcessEvent;
import org.dromara.common.core.domain.event.ProcessTaskEvent;
@ -48,8 +47,8 @@ import org.springframework.context.event.EventListener;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.time.LocalDateTime;
import java.util.*;
import java.util.stream.Collectors;
/**
* 卷册文件Service业务层处理
@ -602,9 +601,12 @@ public class DesVolumeFileServiceImpl extends ServiceImpl<DesVolumeFileMapper, D
return;
}
desVolumeFile.setAuditStatus(processEvent.getStatus());
if (processEvent.getStatus().equals(BusinessStatusEnum.FINISH.getStatus())) {
desVolumeFile.setFinishTime(LocalDateTime.now());
}
this.updateById(desVolumeFile);
//如果完成,以前的图纸类型变为作废图纸,状态改为作废 暂定
if (processEvent.getStatus().equals("finish")) {
if (processEvent.getStatus().equals(BusinessStatusEnum.FINISH.getStatus())) {
// this.lambdaUpdate().set(DesVolumeFile::getStatus, "2")
// .set(DesVolumeFile::getType, "4")
// .eq(DesVolumeFile::getVolumeCatalogId, desVolumeFile.getVolumeCatalogId())
@ -684,6 +686,7 @@ public class DesVolumeFileServiceImpl extends ServiceImpl<DesVolumeFileMapper, D
//修改目录状态
volumeCatalogService.update(Wrappers.<DesVolumeCatalog>lambdaUpdate()
.set(DesVolumeCatalog::getDesignState, "1")
.set(DesVolumeCatalog::getFinishTime, LocalDateTime.now())
.eq(DesVolumeCatalog::getDesign, desVolumeFile.getVolumeCatalogId())
);
//异步处理二维码

View File

@ -53,7 +53,6 @@ public class DroProjectDroneController extends BaseController {
/**
* 查询项目无人机信息列表
*/
@SaCheckPermission("drone:projectDrone:list")
@GetMapping("/list")
public TableDataInfo<DroProjectDroneVo> list(DroProjectDroneBo bo, PageQuery pageQuery) {
return droProjectDroneService.queryPageList(bo, pageQuery);

View File

@ -4,6 +4,9 @@ import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serial;
import java.io.Serializable;
/**
* @author lilemy
* @date 2025/4/24 17:38
@ -11,7 +14,10 @@ import lombok.NoArgsConstructor;
@Data
@NoArgsConstructor
@AllArgsConstructor
public class FacFeature {
public class FacFeature implements Serializable {
@Serial
private static final long serialVersionUID = -6103275857879306244L;
private String type;

View File

@ -4,6 +4,8 @@ import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serial;
import java.io.Serializable;
import java.util.List;
/**
@ -13,7 +15,10 @@ import java.util.List;
@Data
@NoArgsConstructor
@AllArgsConstructor
public class FacGeometry {
public class FacGeometry implements Serializable {
@Serial
private static final long serialVersionUID = -2582318447932685848L;
private String type;

View File

@ -1,6 +1,7 @@
package org.dromara.facility.domain.dto.photovoltaicpanelparts;
import lombok.Data;
import org.dromara.facility.domain.dto.geojson.FacGeoJson;
import org.dromara.facility.domain.dto.geojson.FacGeoJsonByPoint;
import java.io.Serial;
@ -24,7 +25,7 @@ public class FacPhotovoltaicPanelPartsCreateByGeoJsonReq implements Serializable
/**
* 桩点、立柱、支架 GeoJson
*/
private FacGeoJsonByPoint locationGeoJson;
private FacGeoJson locationGeoJson;
/**
* 批次上传标识

View File

@ -24,7 +24,7 @@ import org.dromara.facility.domain.FacPhotovoltaicPanel;
import org.dromara.facility.domain.FacPhotovoltaicPanelColumn;
import org.dromara.facility.domain.FacPhotovoltaicPanelPoint;
import org.dromara.facility.domain.FacPhotovoltaicPanelSupport;
import org.dromara.facility.domain.dto.geojson.FacFeatureByPoint;
import org.dromara.facility.domain.dto.geojson.FacFeature;
import org.dromara.facility.domain.dto.photovoltaicpanelparts.FacPhotovoltaicPanelPartsCreateByGeoJsonReq;
import org.dromara.facility.domain.dto.photovoltaicpanelparts.FacPhotovoltaicPanelPartsCreateReq;
import org.dromara.facility.domain.dto.photovoltaicpanelparts.FacPhotovoltaicPanelPartsQueryReq;
@ -38,6 +38,7 @@ import org.dromara.progress.constant.PgsProgressCategoryConstant;
import org.dromara.progress.domain.PgsProgressCategory;
import org.dromara.progress.domain.vo.progressplandetail.PgsProgressPlanDetailRecognizerVo;
import org.dromara.progress.service.IPgsProgressCategoryService;
import org.dromara.project.domain.BusProject;
import org.dromara.project.service.IBusProjectService;
import org.locationtech.jts.geom.Coordinate;
import org.springframework.beans.BeanUtils;
@ -146,12 +147,19 @@ public class FacPhotovoltaicPanelPartsServiceImpl implements IFacPhotovoltaicPan
// 第一次接收请求,进行数据校验
int batchNum = geoJson.getBatchNum();
if (batchNum == 1) {
if (projectService.getById(projectId) == null) {
BusProject project = projectService.getById(projectId);
if (project == null) {
throw new ServiceException("项目不存在", HttpStatus.NOT_FOUND);
}
Long pId = project.getPId();
List<BusProject> subProject = projectService.lambdaQuery()
.eq(BusProject::getPId, pId)
.list();
List<Long> projectIds = subProject.stream().map(BusProject::getId).collect(Collectors.toList());
projectIds.add(projectId);
// 查询项目下光伏板
Long count = photovoltaicPanelService.lambdaQuery()
.eq(FacPhotovoltaicPanel::getProjectId, projectId).count();
.in(FacPhotovoltaicPanel::getProjectId, projectIds).count();
if (count <= 0) {
throw new ServiceException("项目下无光伏板信息,请先创建光伏板信息后再添加桩点、立柱、支架信息", HttpStatus.NOT_FOUND);
}
@ -159,7 +167,7 @@ public class FacPhotovoltaicPanelPartsServiceImpl implements IFacPhotovoltaicPan
// 获取 redis key
String sessionId = geoJson.getSessionId();
int totalBatch = geoJson.getTotalBatch();
List<FacFeatureByPoint> dataList = geoJson.getLocationGeoJson().getFeatures();
List<FacFeature> dataList = geoJson.getLocationGeoJson().getFeatures();
String redisKey = FacRedisKeyConstant.getBatchUploadPartsRedisKey(sessionId, batchNum);
// 存储到 Redis设置过期时间 30 分钟
redisTemplate.opsForValue().set(redisKey, dataList, 1800, TimeUnit.SECONDS);
@ -172,13 +180,13 @@ public class FacPhotovoltaicPanelPartsServiceImpl implements IFacPhotovoltaicPan
messageDto.setProjectId(projectId);
// 如果是最后一批,开始合并
if (batchNum == totalBatch) {
List<FacFeatureByPoint> allData = new ArrayList<>();
List<FacFeature> allData = new ArrayList<>();
for (int i = 1; i <= totalBatch; i++) {
String batchKey = FacRedisKeyConstant.getBatchUploadPartsRedisKey(sessionId, i);
Object batchObj = redisTemplate.opsForValue().get(batchKey);
if (batchObj instanceof List<?>) {
@SuppressWarnings("unchecked")
List<FacFeatureByPoint> batch = (List<FacFeatureByPoint>) batchObj;
List<FacFeature> batch = (List<FacFeature>) batchObj;
allData.addAll(batch);
}
}
@ -222,11 +230,19 @@ public class FacPhotovoltaicPanelPartsServiceImpl implements IFacPhotovoltaicPan
* @param features 数据
* @param userId 操作用户id
*/
private void saveBatch(Long projectId, List<FacFeatureByPoint> features, Long userId) {
private void saveBatch(Long projectId, List<FacFeature> features, Long userId) {
BusProject project = projectService.getById(projectId);
Long pId = project.getPId();
List<BusProject> subProject = projectService.lambdaQuery()
.eq(BusProject::getPId, pId)
.list();
List<Long> projectIds = subProject.stream().map(BusProject::getId).collect(Collectors.toList());
projectIds.add(projectId);
// 获取进度类别 Map
List<PgsProgressCategory> progressCategoryList = progressCategoryService.lambdaQuery()
.select(PgsProgressCategory::getId, PgsProgressCategory::getName, PgsProgressCategory::getMatrixId, PgsProgressCategory::getWorkType)
.eq(PgsProgressCategory::getProjectId, projectId)
.select(PgsProgressCategory::getId, PgsProgressCategory::getName, PgsProgressCategory::getProjectId,
PgsProgressCategory::getMatrixId, PgsProgressCategory::getWorkType)
.in(PgsProgressCategory::getProjectId, projectIds)
.and(lqw -> lqw
.likeRight(PgsProgressCategory::getWorkType, PgsProgressCategoryConstant.PHOTOVOLTAIC_PANEL_POINT_WORK_TYPE + "_")
.or()
@ -241,7 +257,7 @@ public class FacPhotovoltaicPanelPartsServiceImpl implements IFacPhotovoltaicPan
));
// 查询项目下光伏板
List<FacPhotovoltaicPanel> photovoltaicPanelList = photovoltaicPanelService.lambdaQuery()
.eq(FacPhotovoltaicPanel::getProjectId, projectId)
.in(FacPhotovoltaicPanel::getProjectId, projectIds)
.list();
Map<String, FacPhotovoltaicPanel> photovoltaicPanelMap = photovoltaicPanelList.stream()
.collect(Collectors.toMap(
@ -256,7 +272,7 @@ public class FacPhotovoltaicPanelPartsServiceImpl implements IFacPhotovoltaicPan
FacPhotovoltaicPanelPoint::getFinishType,
FacPhotovoltaicPanelPoint::getFinishDate,
FacPhotovoltaicPanelPoint::getStatus)
.eq(FacPhotovoltaicPanelPoint::getProjectId, projectId)
.in(FacPhotovoltaicPanelPoint::getProjectId, projectIds)
.list();
Map<String, FacPhotovoltaicPanelPoint> oldPointMap = oldPointList.stream()
.collect(Collectors.toMap(
@ -270,7 +286,7 @@ public class FacPhotovoltaicPanelPartsServiceImpl implements IFacPhotovoltaicPan
FacPhotovoltaicPanelColumn::getFinishType,
FacPhotovoltaicPanelColumn::getFinishDate,
FacPhotovoltaicPanelColumn::getStatus)
.eq(FacPhotovoltaicPanelColumn::getProjectId, projectId)
.in(FacPhotovoltaicPanelColumn::getProjectId, projectIds)
.list();
Map<String, FacPhotovoltaicPanelColumn> oldColumnMap = oldColumnList.stream()
.collect(Collectors.toMap(
@ -284,7 +300,7 @@ public class FacPhotovoltaicPanelPartsServiceImpl implements IFacPhotovoltaicPan
FacPhotovoltaicPanelSupport::getFinishType,
FacPhotovoltaicPanelSupport::getFinishDate,
FacPhotovoltaicPanelSupport::getStatus)
.eq(FacPhotovoltaicPanelSupport::getProjectId, projectId)
.in(FacPhotovoltaicPanelSupport::getProjectId, projectIds)
.list();
Map<String, FacPhotovoltaicPanelSupport> oldSupportMap = oldSupportList.stream()
.collect(Collectors.toMap(
@ -299,7 +315,15 @@ public class FacPhotovoltaicPanelPartsServiceImpl implements IFacPhotovoltaicPan
try (ExecutorService executor = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors())) {
// 所有点列表
List<List<Double>> pointPositionList = new ArrayList<>(features.stream()
.map(featureByPoint -> featureByPoint.getGeometry().getCoordinates())
.map(feature -> {
String type = feature.getProperties().getType();
List<Object> coordinates = feature.getGeometry().getCoordinates();
if (type.equalsIgnoreCase("CIRCLE")) {
return JtsPointMatcher.polygonCentroid(castToDoubleList(coordinates));
} else {
return toDoubleList(coordinates);
}
})
.toList());
// 多线程处理
List<Future<?>> futures = new ArrayList<>();
@ -324,7 +348,7 @@ public class FacPhotovoltaicPanelPartsServiceImpl implements IFacPhotovoltaicPan
if (CollUtil.isNotEmpty(categoryList)) {
for (PgsProgressCategory category : categoryList) {
FacPhotovoltaicPanelPoint point = new FacPhotovoltaicPanelPoint();
point.setProjectId(projectId);
point.setProjectId(category.getProjectId());
point.setMatrixId(matrixId);
point.setName(name);
point.setPositions(jsonStr);
@ -349,7 +373,7 @@ public class FacPhotovoltaicPanelPartsServiceImpl implements IFacPhotovoltaicPan
if (CollUtil.isNotEmpty(categoryList)) {
for (PgsProgressCategory category : categoryList) {
FacPhotovoltaicPanelColumn column = new FacPhotovoltaicPanelColumn();
column.setProjectId(projectId);
column.setProjectId(category.getProjectId());
column.setMatrixId(matrixId);
column.setName(name);
column.setPositions(jsonStr);
@ -374,7 +398,7 @@ public class FacPhotovoltaicPanelPartsServiceImpl implements IFacPhotovoltaicPan
if (CollUtil.isNotEmpty(categoryList)) {
for (PgsProgressCategory category : categoryList) {
FacPhotovoltaicPanelSupport support = new FacPhotovoltaicPanelSupport();
support.setProjectId(projectId);
support.setProjectId(category.getProjectId());
support.setMatrixId(matrixId);
support.setName(name);
support.setPositions(jsonStr);
@ -941,4 +965,45 @@ public class FacPhotovoltaicPanelPartsServiceImpl implements IFacPhotovoltaicPan
}
}
/**
* 将原始数据转换为List<List<Double>>
*
* @param rawList 原始数据
* @return 转换后的数据
*/
public static List<List<Double>> castToDoubleList(List<?> rawList) {
List<List<Double>> result = new ArrayList<>();
for (Object item : rawList) {
if (item instanceof List<?> innerList) {
List<Double> point = new ArrayList<>();
for (Object value : innerList) {
if (value instanceof Number num) {
point.add(num.doubleValue());
}
}
result.add(point);
}
}
return result;
}
/**
* 将原始数据转换为 List<Double>
*
* @param list 原始数据
* @return 转换后的数据
*/
public static List<Double> toDoubleList(List<Object> list) {
return list.stream()
.filter(Objects::nonNull)
.map(o -> {
if (o instanceof Number n) {
return n.doubleValue();
}
throw new IllegalArgumentException("非数字类型:" + o);
})
.toList();
}
}

View File

@ -154,4 +154,17 @@ public interface GpsEquipmentSonMapper extends BaseMapperPlus<GpsEquipmentSon, G
"WHERE\n" +
" rn = 1;")
List<GpsEquipmentSonVo> getUeUserListByProjectId(@Param("startTime") LocalDateTime startOfDay, @Param("endTime") LocalDateTime now);
@Select("<script> SELECT a.user_id , a.loc_latitude, a.loc_longitude " +
" FROM (\n" +
" SELECT user_id , loc_latitude,loc_longitude, ROW_NUMBER() OVER (PARTITION BY user_id ORDER BY create_time DESC) AS rn\n" +
" FROM gps_equipment_son\n" +
") a , bus_user_project_relevancy as b WHERE a.user_id = b.user_id and b.project_id = #{projectId} " +
" and rn = 1 and a.user_id IN <foreach collection=\"collect\" item=\"id\" separator=\",\" open=\"(\" close=\")\">\n" +
" #{id}\n" +
" </foreach>\n" +
" GROUP BY a.user_id </script>")
List<GpsEquipmentSon> listByAqy(@Param("collect") List<Long> collect, @Param("projectId") Long projectId);
}

View File

@ -1,9 +1,11 @@
package org.dromara.job.ys7;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.dromara.manager.ys7manager.Ys7Manager;
import org.dromara.manager.ys7manager.vo.Ys7QueryDeviceResponseVo;
import org.dromara.other.domain.OthYs7Device;
import org.dromara.other.service.IOthYs7DeviceService;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.scheduling.annotation.Scheduled;
@ -41,4 +43,18 @@ public class IncSyncYs7DeviceData {
}
}
//同步摄像头全天录像开关状态 每 1 天执行一次
@Scheduled(cron = "1 0 0 * * ?")
// @Scheduled(cron = "0 */10 * * * ?")
public void getEnable() {
log.info("定时同步摄像头全天录像开关状态");
List<OthYs7Device> ys7DeviceList = ys7DeviceService.getBaseMapper().selectList(new LambdaQueryWrapper<OthYs7Device>().orderByDesc(OthYs7Device::getCreateTime));
Boolean result = ys7DeviceService.saveOrUpdateEnableByDeviceList(ys7DeviceList);
if (result) {
log.info("定时同步摄像头全天录像开关状态成功");
} else {
log.info("没有需要定时同步的摄像头全天录像开关状态");
}
}
}

View File

@ -71,4 +71,13 @@ public interface Ys7Constant {
*/
String getDeviceLappVideoUrlByPost = "https://open.ys7.com/api/lapp/v2/live/address/get";
/**
* 设置全天录像开关 POST
*/
String UPDATEONEKEYSWITCH = "https://open.ys7.com/api/lapp/device/fullday/record/switch/set";
/**
* 获取全天录像开关状态 POST
*/
String GETONEKEYSWITCHSTATUS = "https://open.ys7.com/api/lapp/device/fullday/record/switch/status";
}

View File

@ -11,6 +11,7 @@ import org.dromara.common.core.exception.ServiceException;
import org.dromara.common.core.utils.StringUtils;
import org.dromara.common.core.utils.TimestampUtils;
import org.dromara.manager.ys7manager.dto.DeviceLocalVideoRequstDto;
import org.dromara.manager.ys7manager.dto.DeviceOneKeySwitchRequstDto;
import org.dromara.manager.ys7manager.dto.DevicePlayBackUrlRequstDto;
import org.dromara.manager.ys7manager.vo.*;
@ -448,4 +449,75 @@ public class Ys7RequestUtils {
}
}
/**
* 设置全天录像开关
* @param dto
* @return
*/
public static Boolean putDeviceOneKeySwitch(DeviceOneKeySwitchRequstDto dto) {
if (StringUtils.isAnyBlank(dto.getAccessToken(), dto.getDeviceSerial())) {
throw new ServiceException("设置全天录像开关参数为空", HttpStatus.BAD_REQUEST);
}
if (dto.getEnable() == null){
throw new ServiceException("请选择开关状态", HttpStatus.BAD_REQUEST);
}
HashMap<String, Object> paramMap = new HashMap<>();
paramMap.put("accessToken", dto.getAccessToken());
paramMap.put("deviceSerial", dto.getDeviceSerial());
paramMap.put("enable", dto.getEnable());
if (dto.getChannelNo() != null) {
paramMap.put("channelNo", dto.getChannelNo());
}
String errorMsg = "设置全天录像开关请求失败";
try (HttpResponse response = HttpRequest.post(Ys7Constant.UPDATEONEKEYSWITCH)
.form(paramMap)
.execute()) {
if (!response.isOk()) {
log.error("{}{}", errorMsg, response.getStatus());
throw new ServiceException(errorMsg + response.getStatus());
}
String body = response.body();
log.info("设置全天录像开关body{}",body);
Ys7ResponseVo responseVo = JSONUtil.toBean(body, Ys7ResponseVo.class);
if (!responseVo.getCode().equals("200")) {
log.error("{},状态码:{}{}", errorMsg, responseVo.getCode(), responseVo.getMsg());
throw new ServiceException("序列号:"+dto.getDeviceSerial()+errorMsg + responseVo.getMsg());
}
return true;
}
}
/**
* 获取全天录像开关状态
* @param dto
* @return
*/
public static Integer getDeviceSwitchStatus(DeviceOneKeySwitchRequstDto dto) {
if (StringUtils.isAnyBlank(dto.getAccessToken(), dto.getDeviceSerial())) {
throw new ServiceException("获取全天录像开关状态参数为空", HttpStatus.BAD_REQUEST);
}
HashMap<String, Object> paramMap = new HashMap<>();
paramMap.put("accessToken", dto.getAccessToken());
paramMap.put("deviceSerial", dto.getDeviceSerial());
String errorMsg = "获取全天录像开关状态请求失败";
try (HttpResponse response = HttpRequest.post(Ys7Constant.GETONEKEYSWITCHSTATUS)
.form(paramMap)
.execute()) {
if (!response.isOk()) {
log.error("{}{}", errorMsg, response.getStatus());
throw new ServiceException(errorMsg + response.getStatus());
}
String body = response.body();
log.info("获取全天录像开关状态body{}",body);
Ys7ResponseVo responseVo = JSONUtil.toBean(body, Ys7ResponseVo.class);
if (!responseVo.getCode().equals("200")) {
log.error("{},状态码:{}{}", errorMsg, responseVo.getCode(), responseVo.getMsg());
throw new ServiceException("序列号:"+dto.getDeviceSerial()+errorMsg + responseVo.getMsg());
}
String data = responseVo.getData();
return JSONUtil.parseObj(data).getInt("enable");
}
}
}

View File

@ -0,0 +1,13 @@
package org.dromara.manager.ys7manager.dto;
import lombok.Data;
import java.io.Serializable;
@Data
public class DeviceOneKeySwitchRequstDto implements Serializable {
private String accessToken; //toke
private String deviceSerial; //设备序列号
private Integer channelNo; // 通道号默认1
private Integer enable; // 状态0-关闭1-开启
}

View File

@ -1,6 +1,8 @@
package org.dromara.materials.controller;
import cn.dev33.satoken.annotation.SaCheckPermission;
import cn.dev33.satoken.annotation.SaMode;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
@ -18,6 +20,8 @@ import org.dromara.common.web.core.BaseController;
import org.dromara.materials.domain.bo.MatWarehouseBo;
import org.dromara.materials.domain.vo.MatWarehouseVo;
import org.dromara.materials.service.IMatWarehouseService;
import org.dromara.other.domain.vo.ys7device.OthYs7DeviceVo;
import org.dromara.other.service.IOthYs7DeviceService;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
@ -37,6 +41,19 @@ public class MatWarehouseController extends BaseController {
private final IMatWarehouseService matWarehouseService;
@Resource
private IOthYs7DeviceService othYs7DeviceService;
/**
* 根据项目查询萤石摄像头列表
*/
@SaCheckPermission( value = {"materials:warehouse:list","materials:warehouse:add","materials:warehouse:edit"}, mode = SaMode.OR)
@GetMapping("/device/project")
public TableDataInfo<OthYs7DeviceVo> listByProject(Long projectId, PageQuery pageQuery) {
return othYs7DeviceService.queryPageListByProject(projectId, pageQuery);
}
/**
* 查询物资仓库列表
*/

View File

@ -54,6 +54,11 @@ public class MatMaterialIssueItem extends BaseEntity {
*/
private String unit;
/**
* 单价
*/
private BigDecimal unitPrice;
/**
* 库存
*/

View File

@ -59,6 +59,11 @@ public class MatMaterialReceiveItem extends BaseEntity {
*/
private BigDecimal quantity;
/**
* 单价
*/
private BigDecimal unitPrice;
/**
* 验收
*/
@ -79,4 +84,9 @@ public class MatMaterialReceiveItem extends BaseEntity {
*/
private Long planId;
/**
* 仓库id
*/
private Long warehouseId;
}

View File

@ -7,6 +7,7 @@ import lombok.EqualsAndHashCode;
import org.dromara.common.mybatis.core.domain.BaseEntity;
import java.io.Serial;
import java.math.BigDecimal;
/**
* 材料名称对象 mat_materials
@ -68,6 +69,11 @@ public class MatMaterials extends BaseEntity {
*/
private String weightId;
/**
* 单价
*/
private BigDecimal unitPrice;
/**
* 备注
*/

View File

@ -0,0 +1,36 @@
package org.dromara.materials.domain;
import org.dromara.common.mybatis.core.domain.BaseEntity;
import com.baomidou.mybatisplus.annotation.*;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.io.Serial;
import java.io.Serializable;
/**
* 物资仓库与摄像头绑定对象 mat_warehouse_camera
*
* @author Lion Li
* @date 2025-12-17
*/
@Data
@TableName("mat_warehouse_camera")
public class MatWarehouseCamera implements Serializable{
@Serial
private static final long serialVersionUID = 1L;
/**
* 仓库id
*/
@TableId(value = "warehouse_id")
private Long warehouseId;
/**
* 摄像头id
*/
private Long cameraId;
}

View File

@ -10,6 +10,8 @@ import org.dromara.common.core.validate.EditGroup;
import org.dromara.common.mybatis.core.domain.BaseEntity;
import org.dromara.materials.domain.MatWarehouse;
import java.util.List;
/**
* 物资仓库业务对象 mat_warehouse
*
@ -91,4 +93,9 @@ public class MatWarehouseBo extends BaseEntity {
*/
private String remark;
/**
* 萤石设备id
*/
private List<Long> ys7DeviceIds;
}

View File

@ -0,0 +1,34 @@
package org.dromara.materials.domain.bo;
import org.dromara.common.core.validate.AddGroup;
import org.dromara.common.core.validate.EditGroup;
import lombok.Data;
import jakarta.validation.constraints.*;
import java.io.Serializable;
/**
* 物资仓库与摄像头绑定业务对象 mat_warehouse_camera
*
* @author Lion Li
* @date 2025-12-17
*/
@Data
public class MatWarehouseCameraBo implements Serializable {
/**
* 仓库id
*/
@NotNull(message = "仓库id不能为空", groups = { EditGroup.class })
private Long warehouseId;
/**
* 摄像头id
*/
@NotNull(message = "摄像头id不能为空", groups = { AddGroup.class, EditGroup.class })
private Long cameraId;
}

View File

@ -45,6 +45,11 @@ public class MatMaterialIssueItemDto {
@NotBlank(message = "单位不能为空")
private String unit;
/**
* 单价
*/
private BigDecimal unitPrice;
/**
* 库存
*/

View File

@ -4,6 +4,8 @@ import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.math.BigDecimal;
@Data
@NoArgsConstructor
@AllArgsConstructor
@ -13,6 +15,7 @@ public class MatMaterialIssueItemWordDto {
private String name; // 名称
private String specification; // 规格
private String unit; // 单位
private BigDecimal unitPrice; //单价
private Integer stockQuantity; // 库存数量
private Integer issuedQuantity; // 领取数量
private Integer remainingQuantity;// 剩余数量

View File

@ -50,6 +50,11 @@ public class MatMaterialReceiveItemDto {
*/
private BigDecimal shortageQuantity;
/**
* 单价
*/
private BigDecimal unitPrice;
/**
* 备注
*/

View File

@ -4,6 +4,8 @@ import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.math.BigDecimal;
/**
* @author lilemy
* @date 2025/7/6 14:04
@ -38,6 +40,11 @@ public class MatMaterialReceiveItemWordDto {
*/
private Integer quantity;
/**
* 单价
*/
private BigDecimal unitPrice;
/**
* 验收
*/

View File

@ -4,6 +4,7 @@ import lombok.Data;
import java.io.Serial;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Map;
/**
@ -61,6 +62,11 @@ public class MatMaterialsCreateReq implements Serializable {
*/
private String weightId;
/**
* 单价
*/
private BigDecimal unitPrice;
/**
* 备注
*/

View File

@ -4,6 +4,7 @@ import lombok.Data;
import java.io.Serial;
import java.io.Serializable;
import java.math.BigDecimal;
/**
* @author lilemy
@ -50,6 +51,11 @@ public class MatMaterialsQueryReq implements Serializable {
*/
private String weightId;
/**
* 单价
*/
private BigDecimal unitPrice;
/**
* 预计材料数量
*/

View File

@ -4,6 +4,7 @@ import lombok.Data;
import java.io.Serial;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Map;
/**
@ -61,6 +62,12 @@ public class MatMaterialsUpdateReq implements Serializable {
*/
private String weightId;
/**
* 单价
*/
private BigDecimal unitPrice;
/**
* 备注
*/

View File

@ -0,0 +1,41 @@
package org.dromara.materials.domain.vo;
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
import com.alibaba.excel.annotation.ExcelProperty;
import io.github.linpeilie.annotations.AutoMapper;
import lombok.Data;
import org.dromara.materials.domain.MatWarehouseCamera;
import java.io.Serial;
import java.io.Serializable;
/**
* 物资仓库与摄像头绑定视图对象 mat_warehouse_camera
*
* @author Lion Li
* @date 2025-12-17
*/
@Data
@ExcelIgnoreUnannotated
@AutoMapper(target = MatWarehouseCamera.class)
public class MatWarehouseCameraVo implements Serializable {
@Serial
private static final long serialVersionUID = 1L;
/**
* 仓库id
*/
@ExcelProperty(value = "仓库id")
private Long warehouseId;
/**
* 摄像头id
*/
@ExcelProperty(value = "摄像头id")
private Long cameraId;
}

View File

@ -7,9 +7,12 @@ import lombok.Data;
import org.dromara.common.excel.annotation.ExcelDictFormat;
import org.dromara.common.excel.convert.ExcelDictConvert;
import org.dromara.materials.domain.MatWarehouse;
import org.dromara.other.domain.OthYs7Device;
import org.dromara.other.domain.vo.ys7device.OthYs7DeviceVo;
import java.io.Serial;
import java.io.Serializable;
import java.util.List;
/**
@ -105,4 +108,14 @@ public class MatWarehouseVo implements Serializable {
@ExcelProperty(value = "备注")
private String remark;
/**
* 萤石设备id
*/
private List<Long> ys7DeviceIds;
/**
* 萤石摄像头信息
*/
private List<OthYs7Device> ys7DeviceList;
}

View File

@ -52,6 +52,12 @@ public class MatMaterialIssueItemVo implements Serializable {
*/
private String unit;
/**
* 单价
*/
private BigDecimal unitPrice;
/**
* 库存
*/

View File

@ -52,6 +52,11 @@ public class MatMaterialReceiveItemVo implements Serializable {
*/
private String unit;
/**
* 单价
*/
private BigDecimal unitPrice;
/**
* 数量
*/
@ -72,4 +77,9 @@ public class MatMaterialReceiveItemVo implements Serializable {
*/
private String remark;
/**
* 仓库id
*/
private Long warehouseId;
}

View File

@ -37,6 +37,11 @@ public class MatMaterialsNumberVo implements Serializable {
*/
private String weightId;
/**
* 单价
*/
private BigDecimal unitPrice;
/**
* 库存数量
*/

View File

@ -12,6 +12,7 @@ import org.dromara.xzd.domain.vo.XzdSupplierInfoVo;
import java.io.Serial;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import java.util.Map;
@ -95,6 +96,11 @@ public class MatMaterialsVo implements Serializable {
@ExcelProperty(value = "备注")
private String remark;
/**
* 单价
*/
private BigDecimal unitPrice;
/**
* 预计材料数量
*/

View File

@ -0,0 +1,16 @@
package org.dromara.materials.mapper;
import org.dromara.common.mybatis.core.mapper.BaseMapperPlus;
import org.dromara.materials.domain.MatWarehouseCamera;
import org.dromara.materials.domain.vo.MatWarehouseCameraVo;
/**
* 物资仓库与摄像头绑定Mapper接口
*
* @author Lion Li
* @date 2025-12-17
*/
public interface MatWarehouseCameraMapper extends BaseMapperPlus<MatWarehouseCamera, MatWarehouseCameraVo> {
}

View File

@ -3,6 +3,7 @@ package org.dromara.materials.service;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import org.dromara.common.core.domain.R;
import org.dromara.common.mybatis.core.page.PageQuery;
import org.dromara.common.mybatis.core.page.TableDataInfo;
import org.dromara.materials.domain.MatMaterials;
@ -16,6 +17,7 @@ import org.dromara.materials.domain.dto.materials.MatMaterialsQueryReq;
import org.dromara.materials.domain.dto.materials.MatMaterialsUpdateReq;
import org.dromara.materials.domain.vo.materials.*;
import java.math.BigDecimal;
import java.util.Collection;
import java.util.List;
@ -187,4 +189,26 @@ public interface IMatMaterialsService extends IService<MatMaterials> {
* @return 材料库存数据列表
*/
List<MatMaterialsExcelVo> queryExcelList(MatMaterialsQueryReq req);
/**
* 根据项目id和材料名称获取当前库存总价
* @param projectId
* @param lBQNames
* @return
*/
BigDecimal selectTotalPricesByNames(Long projectId, List<String> lBQNames);
/**
* 根据项目id获取当前库存总价
* @param projectId
* @return
*/
BigDecimal selectTotalPrices(Long projectId);
/**
* 大屏获取物资跟踪管理台账
* @param projectId
* @return
*/
List<MatMaterialsUseDetailVo> listUseDetail(Long projectId);
}

View File

@ -0,0 +1,71 @@
package org.dromara.materials.service;
import org.dromara.common.mybatis.core.page.TableDataInfo;
import org.dromara.common.mybatis.core.page.PageQuery;
import com.baomidou.mybatisplus.extension.service.IService;
import org.dromara.materials.domain.MatWarehouseCamera;
import org.dromara.materials.domain.bo.MatWarehouseCameraBo;
import org.dromara.materials.domain.vo.MatWarehouseCameraVo;
import java.util.Collection;
import java.util.List;
/**
* 物资仓库与摄像头绑定Service接口
*
* @author Lion Li
* @date 2025-12-17
*/
public interface IMatWarehouseCameraService extends IService<MatWarehouseCamera>{
/**
* 查询物资仓库与摄像头绑定
*
* @param warehouseId 主键
* @return 物资仓库与摄像头绑定
*/
MatWarehouseCameraVo queryById(Long warehouseId);
/**
* 分页查询物资仓库与摄像头绑定列表
*
* @param bo 查询条件
* @param pageQuery 分页参数
* @return 物资仓库与摄像头绑定分页列表
*/
TableDataInfo<MatWarehouseCameraVo> queryPageList(MatWarehouseCameraBo bo, PageQuery pageQuery);
/**
* 查询符合条件的物资仓库与摄像头绑定列表
*
* @param bo 查询条件
* @return 物资仓库与摄像头绑定列表
*/
List<MatWarehouseCameraVo> queryList(MatWarehouseCameraBo bo);
/**
* 新增物资仓库与摄像头绑定
*
* @param bo 物资仓库与摄像头绑定
* @return 是否新增成功
*/
Boolean insertByBo(MatWarehouseCameraBo bo);
/**
* 修改物资仓库与摄像头绑定
*
* @param bo 物资仓库与摄像头绑定
* @return 是否修改成功
*/
Boolean updateByBo(MatWarehouseCameraBo bo);
/**
* 校验并批量删除物资仓库与摄像头绑定信息
*
* @param ids 待删除的主键集合
* @param isValid 是否进行有效性校验
* @return 是否删除成功
*/
Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid);
}

View File

@ -253,18 +253,6 @@ public class MatMaterialIssueServiceImpl extends ServiceImpl<MatMaterialIssueMap
List<MatMaterialIssueItemDto> itemList = req.getItemList();
if (CollUtil.isNotEmpty(itemList)) {
List<MatMaterialIssueItem> materialIssueItemList = itemList.stream().map(item -> {
MatMaterialIssueItem materialIssueItem = new MatMaterialIssueItem();
BeanUtils.copyProperties(item, materialIssueItem);
materialIssueItem.setIssueId(materialIssue.getId());
materialIssueItem.setProjectId(materialIssue.getProjectId());
return materialIssueItem;
}).toList();
boolean result = materialIssueItemService.saveBatch(materialIssueItemList);
if (!result) {
throw new ServiceException("物料领料单明细项新增失败", HttpStatus.ERROR);
}
// 创建设备材料出库记录
List<MatMaterialsInventory> inventoryList = itemList.stream().map(item -> {
MatMaterialsInventory inventory = new MatMaterialsInventory();
inventory.setNumber(item.getIssuedQuantity().longValue());
inventory.setOutPutTime(new Date());
@ -278,12 +266,30 @@ public class MatMaterialIssueServiceImpl extends ServiceImpl<MatMaterialIssueMap
inventory.setProjectId(materialIssue.getProjectId());
inventory.setOutPut(MatMaterialsInventoryOutPutEnum.OUT.getValue());
inventory.setRemark(item.getRemark());
return inventory;
}).toList();
boolean saved = materialsInventoryService.saveBatch(inventoryList);
boolean saved = materialsInventoryService.save(inventory);
if (!saved) {
throw new ServiceException("物料出库记录新增失败", HttpStatus.ERROR);
}
MatMaterialIssueItem materialIssueItem = new MatMaterialIssueItem();
BeanUtils.copyProperties(item, materialIssueItem);
materialIssueItem.setIssueId(materialIssue.getId());
materialIssueItem.setProjectId(materialIssue.getProjectId());
materialIssueItem.setInventoryId(inventory.getId());
return materialIssueItem;
}).toList();
boolean result = materialIssueItemService.saveBatch(materialIssueItemList);
if (!result) {
throw new ServiceException("物料领料单明细项新增失败", HttpStatus.ERROR);
}
// // 创建设备材料出库记录
// List<MatMaterialsInventory> inventoryList = itemList.stream().map(item -> {
//
// return inventory;
// }).toList();
// boolean saved = materialsInventoryService.saveBatch(inventoryList);
// if (!saved) {
// throw new ServiceException("物料出库记录新增失败", HttpStatus.ERROR);
// }
}
return true;
}
@ -565,6 +571,7 @@ public class MatMaterialIssueServiceImpl extends ServiceImpl<MatMaterialIssueMap
BeanUtils.copyProperties(item, itemDto);
itemDto.setNo(i);
itemDto.setIssuedQuantity(item.getIssuedQuantity() != null ? item.getIssuedQuantity().intValue() : 0);
itemDto.setUnitPrice(item.getUnitPrice() != null ? item.getUnitPrice() : BigDecimal.ZERO);
itemDto.setRemainingQuantity(item.getRemainingQuantity() != null ? item.getRemainingQuantity().intValue() : 0);
itemDto.setStockQuantity(item.getStockQuantity().intValue());
dtoItems.add(itemDto);

View File

@ -586,6 +586,7 @@ public class MatMaterialReceiveServiceImpl extends ServiceImpl<MatMaterialReceiv
BeanUtils.copyProperties(item, itemDto);
itemDto.setNo(i);
itemDto.setQuantity(item.getQuantity().intValue());
itemDto.setUnitPrice(item.getUnitPrice());
itemDto.setShortageQuantity(item.getShortageQuantity().intValue());
itemDto.setAcceptedQuantity(item.getAcceptedQuantity().intValue());
dtoItems.add(itemDto);

View File

@ -382,6 +382,7 @@ public class MatMaterialsServiceImpl extends ServiceImpl<MatMaterialsMapper, Mat
matMaterials.setWeightId(item.getUnit());
matMaterials.setQuantityCount(item.getQuantity().toString());
matMaterials.setFormCode(formCode);
matMaterials.setUnitPrice(item.getUnitPrice());
matMaterials.setWarehouseId(item.getWarehouseId());
save(matMaterials);
Long materialsId = matMaterials.getId();
@ -473,6 +474,7 @@ public class MatMaterialsServiceImpl extends ServiceImpl<MatMaterialsMapper, Mat
}
BeanUtils.copyProperties(m, numberVo);
numberVo.setInventoryNumber(BigDecimal.valueOf(inv.getResidue()));
numberVo.setUnitPrice(m.getUnitPrice());
return numberVo;
})
.filter(Objects::nonNull)
@ -772,6 +774,109 @@ public class MatMaterialsServiceImpl extends ServiceImpl<MatMaterialsMapper, Mat
return excelVoList;
}
/**
* 根据材料名称查询材料库存总价数据
* @param projectId
* @param lBQNames
* @return
*/
@Override
public BigDecimal selectTotalPricesByNames(Long projectId, List<String> lBQNames) {
if (CollUtil.isEmpty(lBQNames)) {
return BigDecimal.ZERO;
}
// 根据材料名称获取材料列表数据
List<MatMaterials> matMaterials = baseMapper.selectList(new LambdaQueryWrapper<MatMaterials>().eq(MatMaterials::getProjectId, projectId).in(MatMaterials::getMaterialsName, lBQNames));
if (CollUtil.isEmpty(matMaterials)) {
return BigDecimal.ZERO;
}
// 获取材料id和单价
Map<Long, BigDecimal> map = matMaterials.stream()
.collect(Collectors.toMap(
MatMaterials::getId,
MatMaterials::getUnitPrice
));
// 获取材料id
List<Long> ids = matMaterials.stream().map(MatMaterials::getId).toList();
// 获取材料库存数据
List<MatMaterialsInventory> inventories = materialsInventoryService.selectLatestByMaterialIds(ids);
if (CollUtil.isEmpty(inventories)){
return BigDecimal.ZERO;
}
// 计算材料总价
return inventories.stream()
.map(inventory -> map.getOrDefault(inventory.getMaterialsId(), BigDecimal.ZERO)
.multiply(BigDecimal.valueOf(inventory.getNumber())))
.reduce(BigDecimal.ZERO, BigDecimal::add);
}
@Override
public BigDecimal selectTotalPrices(Long projectId) {
// 根据材料名称获取材料列表数据
List<MatMaterials> matMaterials = baseMapper.selectList(new LambdaQueryWrapper<MatMaterials>().eq(MatMaterials::getProjectId, projectId));
if (CollUtil.isEmpty(matMaterials)) {
return BigDecimal.ZERO;
}
// 获取材料id和单价
Map<Long, BigDecimal> map = matMaterials.stream()
.collect(Collectors.toMap(
MatMaterials::getId,
MatMaterials::getUnitPrice
));
// 获取材料id
List<Long> ids = matMaterials.stream().map(MatMaterials::getId).toList();
// 获取材料库存数据
List<MatMaterialsInventory> inventories = materialsInventoryService.selectLatestByMaterialIds(ids);
if (CollUtil.isEmpty(inventories)){
return BigDecimal.ZERO;
}
// 计算材料总价
return inventories.stream()
.map(inventory -> map.getOrDefault(inventory.getMaterialsId(), BigDecimal.ZERO)
.multiply(BigDecimal.valueOf(inventory.getNumber())))
.reduce(BigDecimal.ZERO, BigDecimal::add);
}
@Override
public List<MatMaterialsUseDetailVo> listUseDetail(Long projectId) {
// 查询数据库
List<MatMaterials> matMaterials = baseMapper.selectList(new LambdaQueryWrapper<MatMaterials>().eq(MatMaterials::getProjectId, projectId));
if (CollUtil.isEmpty(matMaterials)) {
return List.of();
}
// 查询材料出入库列表
List<Long> ids = matMaterials.stream().map(MatMaterials::getId).toList();
List<MatMaterialsInventory> materialsInventoryList = materialsInventoryService.lambdaQuery()
.in(MatMaterialsInventory::getMaterialsId, ids)
.list();
List<MatMaterialsInventory> putList = materialsInventoryList.stream()
.filter(inventory -> inventory.getOutPut().equals(MatMaterialsInventoryOutPutEnum.PUT.getValue()))
.toList();
// 查询使用列表
List<MatMaterialsInventory> outList = materialsInventoryList.stream()
.filter(inventory -> inventory.getOutPut().equals(MatMaterialsInventoryOutPutEnum.OUT.getValue()))
.toList();
List<MatMaterialsUseRecord> useList = new ArrayList<>();
if (CollUtil.isNotEmpty(outList)) {
List<Long> outIds = outList.stream().map(MatMaterialsInventory::getId).toList();
useList = materialsUseRecordService.lambdaQuery()
.in(MatMaterialsUseRecord::getInventoryId, outIds)
.list();
}
// 查询仓库列表
Set<Long> warehouseIds = matMaterials.stream().filter(material -> material.getWarehouseId() != null).map(MatMaterials::getWarehouseId).collect(Collectors.toSet());
List<MatWarehouse> warehouseList = new ArrayList<>();
if (CollUtil.isNotEmpty(warehouseIds)) {
warehouseList = warehouseService.lambdaQuery()
.in(MatWarehouse::getId, warehouseIds)
.list();
}
List<MatMaterialsUseDetailVo> useDetailList = this.getUseDetailList(matMaterials, putList, outList, useList, warehouseList);
return useDetailList;
}
/**
* 构建一行导出数据

View File

@ -0,0 +1,129 @@
package org.dromara.materials.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.dromara.common.core.utils.MapstructUtils;
import org.dromara.common.mybatis.core.page.TableDataInfo;
import org.dromara.common.mybatis.core.page.PageQuery;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import lombok.RequiredArgsConstructor;
import org.dromara.materials.domain.MatWarehouseCamera;
import org.dromara.materials.domain.bo.MatWarehouseCameraBo;
import org.dromara.materials.domain.vo.MatWarehouseCameraVo;
import org.dromara.materials.mapper.MatWarehouseCameraMapper;
import org.dromara.materials.service.IMatWarehouseCameraService;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Map;
import java.util.Collection;
/**
* 物资仓库与摄像头绑定Service业务层处理
*
* @author Lion Li
* @date 2025-12-17
*/
@RequiredArgsConstructor
@Service
public class MatWarehouseCameraServiceImpl extends ServiceImpl<MatWarehouseCameraMapper, MatWarehouseCamera> implements IMatWarehouseCameraService {
private final MatWarehouseCameraMapper baseMapper;
/**
* 查询物资仓库与摄像头绑定
*
* @param warehouseId 主键
* @return 物资仓库与摄像头绑定
*/
@Override
public MatWarehouseCameraVo queryById(Long warehouseId){
return baseMapper.selectVoById(warehouseId);
}
/**
* 分页查询物资仓库与摄像头绑定列表
*
* @param bo 查询条件
* @param pageQuery 分页参数
* @return 物资仓库与摄像头绑定分页列表
*/
@Override
public TableDataInfo<MatWarehouseCameraVo> queryPageList(MatWarehouseCameraBo bo, PageQuery pageQuery) {
LambdaQueryWrapper<MatWarehouseCamera> lqw = buildQueryWrapper(bo);
Page<MatWarehouseCameraVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
return TableDataInfo.build(result);
}
/**
* 查询符合条件的物资仓库与摄像头绑定列表
*
* @param bo 查询条件
* @return 物资仓库与摄像头绑定列表
*/
@Override
public List<MatWarehouseCameraVo> queryList(MatWarehouseCameraBo bo) {
LambdaQueryWrapper<MatWarehouseCamera> lqw = buildQueryWrapper(bo);
return baseMapper.selectVoList(lqw);
}
private LambdaQueryWrapper<MatWarehouseCamera> buildQueryWrapper(MatWarehouseCameraBo bo) {
LambdaQueryWrapper<MatWarehouseCamera> lqw = Wrappers.lambdaQuery();
lqw.orderByDesc(MatWarehouseCamera::getWarehouseId);
lqw.eq(bo.getCameraId() != null, MatWarehouseCamera::getCameraId, bo.getCameraId());
return lqw;
}
/**
* 新增物资仓库与摄像头绑定
*
* @param bo 物资仓库与摄像头绑定
* @return 是否新增成功
*/
@Override
public Boolean insertByBo(MatWarehouseCameraBo bo) {
MatWarehouseCamera add = MapstructUtils.convert(bo, MatWarehouseCamera.class);
validEntityBeforeSave(add);
boolean flag = baseMapper.insert(add) > 0;
if (flag) {
bo.setWarehouseId(add.getWarehouseId());
}
return flag;
}
/**
* 修改物资仓库与摄像头绑定
*
* @param bo 物资仓库与摄像头绑定
* @return 是否修改成功
*/
@Override
public Boolean updateByBo(MatWarehouseCameraBo bo) {
MatWarehouseCamera update = MapstructUtils.convert(bo, MatWarehouseCamera.class);
validEntityBeforeSave(update);
return baseMapper.updateById(update) > 0;
}
/**
* 保存前的数据校验
*/
private void validEntityBeforeSave(MatWarehouseCamera entity){
//TODO 做一些数据校验,如唯一约束
}
/**
* 校验并批量删除物资仓库与摄像头绑定信息
*
* @param ids 待删除的主键集合
* @param isValid 是否进行有效性校验
* @return 是否删除成功
*/
@Override
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
if(isValid){
//TODO 做一些业务上的校验,判断是否需要校验
}
return baseMapper.deleteByIds(ids) > 0;
}
}

View File

@ -4,21 +4,25 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import jakarta.annotation.Resource;
import lombok.RequiredArgsConstructor;
import org.dromara.common.core.utils.MapstructUtils;
import org.dromara.common.core.utils.StringUtils;
import org.dromara.common.mybatis.core.page.PageQuery;
import org.dromara.common.mybatis.core.page.TableDataInfo;
import org.dromara.materials.domain.MatWarehouse;
import org.dromara.materials.domain.MatWarehouseCamera;
import org.dromara.materials.domain.bo.MatWarehouseBo;
import org.dromara.materials.domain.vo.MatWarehouseVo;
import org.dromara.materials.mapper.MatWarehouseMapper;
import org.dromara.materials.service.IMatWarehouseCameraService;
import org.dromara.materials.service.IMatWarehouseService;
import org.dromara.other.domain.OthYs7Device;
import org.dromara.other.service.IOthYs7DeviceService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.*;
/**
* 物资仓库Service业务层处理
@ -31,6 +35,12 @@ import java.util.Map;
public class MatWarehouseServiceImpl extends ServiceImpl<MatWarehouseMapper, MatWarehouse>
implements IMatWarehouseService {
@Resource
private IMatWarehouseCameraService matWarehouseCameraService;
@Resource
private IOthYs7DeviceService othYs7DeviceService;
/**
* 查询物资仓库
*
@ -39,7 +49,22 @@ public class MatWarehouseServiceImpl extends ServiceImpl<MatWarehouseMapper, Mat
*/
@Override
public MatWarehouseVo queryById(Long id) {
return baseMapper.selectVoById(id);
MatWarehouseVo vo = baseMapper.selectVoById(id);
if (vo !=null){
List<MatWarehouseCamera> list = matWarehouseCameraService.getBaseMapper().selectList(new LambdaQueryWrapper<MatWarehouseCamera>().eq(MatWarehouseCamera::getWarehouseId, id));
if (list != null && !list.isEmpty()){
Set<Long> cameraIds = new HashSet<>();
for (MatWarehouseCamera item : list) {
cameraIds.add(item.getCameraId());
}
List<OthYs7Device> ys7DeviceList = othYs7DeviceService.getBaseMapper().selectList(new LambdaQueryWrapper<OthYs7Device>().in(OthYs7Device::getId, cameraIds));
if (ys7DeviceList != null && !ys7DeviceList.isEmpty()){
vo.setYs7DeviceList(ys7DeviceList);
}
vo.setYs7DeviceIds(cameraIds.stream().toList());
}
}
return vo;
}
/**
@ -93,12 +118,29 @@ public class MatWarehouseServiceImpl extends ServiceImpl<MatWarehouseMapper, Mat
* @return 是否新增成功
*/
@Override
@Transactional(rollbackFor = Exception.class)
public Boolean insertByBo(MatWarehouseBo bo) {
MatWarehouse add = MapstructUtils.convert(bo, MatWarehouse.class);
validEntityBeforeSave(add);
boolean flag = baseMapper.insert(add) > 0;
if (flag) {
bo.setId(add.getId());
if (bo.getYs7DeviceIds() != null){
Long count = matWarehouseCameraService.getBaseMapper()
.selectCount(new LambdaQueryWrapper<MatWarehouseCamera>()
.in(MatWarehouseCamera::getCameraId, bo.getYs7DeviceIds()));
if (count > 0){
throw new RuntimeException("摄像头已与仓库绑定请重新选择摄像头");
}
List<MatWarehouseCamera> list = new ArrayList<>();
for (Long item : bo.getYs7DeviceIds()) {
MatWarehouseCamera matWarehouseCamera = new MatWarehouseCamera();
matWarehouseCamera.setWarehouseId(add.getId());
matWarehouseCamera.setCameraId(item);
list.add(matWarehouseCamera);
}
matWarehouseCameraService.saveBatch(list);
}
}
return flag;
}
@ -110,9 +152,27 @@ public class MatWarehouseServiceImpl extends ServiceImpl<MatWarehouseMapper, Mat
* @return 是否修改成功
*/
@Override
@Transactional(rollbackFor = Exception.class)
public Boolean updateByBo(MatWarehouseBo bo) {
MatWarehouse update = MapstructUtils.convert(bo, MatWarehouse.class);
validEntityBeforeSave(update);
matWarehouseCameraService.remove(new LambdaQueryWrapper<MatWarehouseCamera>().eq(MatWarehouseCamera::getWarehouseId, bo.getId()));
if (bo.getYs7DeviceIds() != null){
Long count = matWarehouseCameraService.getBaseMapper()
.selectCount(new LambdaQueryWrapper<MatWarehouseCamera>()
.in(MatWarehouseCamera::getCameraId, bo.getYs7DeviceIds()));
if (count > 0){
throw new RuntimeException("摄像头已与仓库绑定请重新选择摄像头");
}
List<MatWarehouseCamera> list = new ArrayList<>();
for (Long item : bo.getYs7DeviceIds()) {
MatWarehouseCamera matWarehouseCamera = new MatWarehouseCamera();
matWarehouseCamera.setWarehouseId(bo.getId());
matWarehouseCamera.setCameraId(item);
list.add(matWarehouseCamera);
}
matWarehouseCameraService.saveBatch(list);
}
return baseMapper.updateById(update) > 0;
}
@ -135,6 +195,7 @@ public class MatWarehouseServiceImpl extends ServiceImpl<MatWarehouseMapper, Mat
if (isValid) {
//TODO 做一些业务上的校验,判断是否需要校验
}
matWarehouseCameraService.remove(new LambdaQueryWrapper<MatWarehouseCamera>().in(MatWarehouseCamera::getWarehouseId, ids));
return baseMapper.deleteByIds(ids) > 0;
}
}

View File

@ -0,0 +1,51 @@
package org.dromara.other.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import java.util.concurrent.ThreadPoolExecutor;
@Configuration
public class ThreadPoolConfig {
/**
* 摄像头全天录像开关操作专用线程池
*/
@Bean("deviceSwitchExecutor")
public ThreadPoolTaskExecutor deviceSwitchExecutor() {
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
executor.setCorePoolSize(5); // 核心线程数
executor.setMaxPoolSize(10); // 最大线程数
executor.setKeepAliveSeconds(60); // 空闲线程存活时间(秒)
executor.setQueueCapacity(100); // 任务队列容量
executor.setThreadNamePrefix("device-switch-task-"); // 线程名前缀替代自定义ThreadFactory
// 拒绝策略:队列满时由调用线程执行
executor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy());
// 初始化线程池
executor.initialize();
// 应用关闭时优雅关闭
Runtime.getRuntime().addShutdownHook(new Thread(executor::shutdown));
return executor;
}
/**
* 获取摄像头全天录像开关状态操作专用线程池
*/
@Bean("getDeviceSwitchExecutor")
public ThreadPoolTaskExecutor getDeviceSwitchExecutor() {
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
executor.setCorePoolSize(5); // 核心线程数
executor.setMaxPoolSize(10); // 最大线程数
executor.setKeepAliveSeconds(60); // 空闲线程存活时间(秒)
executor.setQueueCapacity(100); // 任务队列容量
executor.setThreadNamePrefix("get-device-switch-task-"); // 线程名前缀替代自定义ThreadFactory
// 拒绝策略:队列满时由调用线程执行
executor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy());
// 初始化线程池
executor.initialize();
// 应用关闭时优雅关闭
Runtime.getRuntime().addShutdownHook(new Thread(executor::shutdown));
return executor;
}
}

View File

@ -285,4 +285,20 @@ public class OthYs7DeviceController extends BaseController {
return R.ok(othYs7DeviceService.getDateAndDeviceLocalVideo(req));
}
/**
* 一键开关萤石摄像头全天录像开关
* @return
*/
@SaCheckPermission("other:ys7Device:edit")
@PostMapping("/updateOneKeySwitch")
public R<String> updateOneKeySwitch(@RequestBody OthYs7DeviceOneKeySwitchReq req){
if (req.getDeviceSerial() == null){
throw new ServiceException("设备序列号不能为空!!!");
}
if (req.getEnable() == null){
throw new ServiceException("状态不能为空!!!");
}
int i = othYs7DeviceService.updateOneKeySwitch(req);
return R.ok(i>0?"正在处理中,请稍后刷新页面查看":"操作失败");
}
}

View File

@ -53,6 +53,11 @@ public class OthYs7Device implements Serializable {
*/
private Integer status;
/**
* 状态0-关闭1-开启
*/
private Integer enable;
/**
* 布撤防状态
*/
@ -106,6 +111,11 @@ public class OthYs7Device implements Serializable {
*/
private String detail;
/**
* 排序
*/
private Integer sortData;
/**
* 备注
*/

View File

@ -0,0 +1,24 @@
package org.dromara.other.domain.dto.ys7device;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
/**
* @author lilemy
* @date 2025/6/13 10:19
*/
@Data
public class OthYs7DeviceOneKeySwitchReq implements Serializable {
/**
* 设备序列号
*/
private List<String> deviceSerial;
/**
* 状态0-关闭1-开启
*/
private Integer enable;
}

View File

@ -40,6 +40,11 @@ public class OthYs7DeviceUpdateReq implements Serializable {
*/
private String detail;
/**
* 排序
*/
private Integer sortData;
/**
* 备注
*/

View File

@ -69,6 +69,11 @@ public class OthYs7DeviceVo implements Serializable {
@ExcelProperty(value = "设备在线状态(0离线 1在线)")
private Integer status;
/**
* 状态0-关闭1-开启
*/
private Integer enable;
/**
* 固件版本号
*/
@ -92,6 +97,11 @@ public class OthYs7DeviceVo implements Serializable {
*/
private String detail;
/**
* 排序
*/
private Integer sortData;
/**
* 备注
*/

View File

@ -165,4 +165,19 @@ public interface IOthYs7DeviceService extends IService<OthYs7Device> {
* @return
*/
DateAndDeviceLocalVideoVo getDateAndDeviceLocalVideo(OthYs7DevicePlayBackUrlReq req);
/**
* 一键开关
* @param req
* @return
*/
int updateOneKeySwitch(OthYs7DeviceOneKeySwitchReq req);
/**
* 保存或更新萤石摄像开关状态对象列表
*
* @param ys7DeviceList 萤石摄像对象列表
* @return 是否有值发生更改
*/
Boolean saveOrUpdateEnableByDeviceList(List<OthYs7Device> ys7DeviceList);
}

View File

@ -4,6 +4,7 @@ import cn.hutool.core.collection.CollUtil;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@ -19,6 +20,7 @@ import org.dromara.manager.ys7manager.Ys7Constant;
import org.dromara.manager.ys7manager.Ys7Manager;
import org.dromara.manager.ys7manager.Ys7RequestUtils;
import org.dromara.manager.ys7manager.dto.DeviceLocalVideoRequstDto;
import org.dromara.manager.ys7manager.dto.DeviceOneKeySwitchRequstDto;
import org.dromara.manager.ys7manager.dto.DevicePlayBackUrlRequstDto;
import org.dromara.manager.ys7manager.enums.DeviceOnOffLineEnum;
import org.dromara.manager.ys7manager.vo.DeviceLocalVideoRecordsVo;
@ -35,10 +37,12 @@ import org.dromara.other.utils.DateRangeUtils;
import org.dromara.project.domain.BusProject;
import org.dromara.project.service.IBusProjectService;
import org.springframework.beans.BeanUtils;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.*;
import java.util.concurrent.CompletableFuture;
import java.util.function.Function;
import java.util.stream.Collectors;
@ -59,6 +63,11 @@ public class OthYs7DeviceServiceImpl extends ServiceImpl<OthYs7DeviceMapper, Oth
@Resource
private Ys7Manager ys7Manager;
@Resource
private ThreadPoolTaskExecutor deviceSwitchExecutor; // 摄像头全天录像开关操作专用线程池
@Resource
private ThreadPoolTaskExecutor getDeviceSwitchExecutor; // 注入获取摄像头全天录像开关状态线程池
/**
* 查询萤石摄像头
*
@ -281,6 +290,7 @@ public class OthYs7DeviceServiceImpl extends ServiceImpl<OthYs7DeviceMapper, Oth
lqw.like(StringUtils.isNotBlank(deviceType), OthYs7Device::getDeviceType, deviceType);
lqw.like(StringUtils.isNotBlank(deviceSerial), OthYs7Device::getDeviceSerial, deviceSerial);
lqw.like(StringUtils.isNotBlank(deviceVersion), OthYs7Device::getDeviceVersion, deviceVersion);
lqw.orderByAsc(OthYs7Device::getSortData);
lqw.orderByDesc(OthYs7Device::getProjectId);
lqw.orderByDesc(OthYs7Device::getStatus);
return lqw;
@ -469,6 +479,7 @@ public class OthYs7DeviceServiceImpl extends ServiceImpl<OthYs7DeviceMapper, Oth
/**
* 查询范围日期和设备本地录像列表
*
* @param req
* @return
*/
@ -487,6 +498,101 @@ public class OthYs7DeviceServiceImpl extends ServiceImpl<OthYs7DeviceMapper, Oth
return vo;
}
@Override
public int updateOneKeySwitch(OthYs7DeviceOneKeySwitchReq req) {
String token = ys7Manager.getToken();
if (token == null || token.isEmpty()) {
log.error("updateOneKeySwitch获取token失败无法执行设备开关操作");
return 0;
}
// 3. 遍历设备序列号,提交异步任务
List<String> deviceSerials = req.getDeviceSerial();
Integer enable = req.getEnable();
for (String deviceSerial : deviceSerials) {
// lambda内变量需为final/有效final重新赋值
String finalDeviceSerial = deviceSerial;
Integer finalEnable = enable;
String finalToken = token;
// 4. 异步执行单个设备的开关操作
CompletableFuture.runAsync(() -> {
try {
// 构建请求DTO
DeviceOneKeySwitchRequstDto dto = new DeviceOneKeySwitchRequstDto();
dto.setAccessToken(finalToken);
dto.setDeviceSerial(finalDeviceSerial);
dto.setEnable(finalEnable);
// 调用第三方接口可能抛出异常已被try-catch捕获
Boolean b = Ys7RequestUtils.putDeviceOneKeySwitch(dto);
if (b != null && b) {
// 接口调用成功,更新数据库
int updateRows = baseMapper.update(new LambdaUpdateWrapper<OthYs7Device>()
.set(OthYs7Device::getEnable, finalEnable)
.eq(OthYs7Device::getDeviceSerial, finalDeviceSerial));
log.info("设备{}一键开关更新成功,开关状态:{},影响行数:{}",
finalDeviceSerial, finalEnable, updateRows);
} else {
log.warn("设备{}一键开关接口返回false未更新数据库开关状态{}",
finalDeviceSerial, finalEnable);
}
} catch (Exception e) {
// 捕获所有异常,确保单个设备失败不影响其他设备
log.error("设备{}一键开关处理失败,开关状态:{}", finalDeviceSerial, finalEnable, e);
}
}, deviceSwitchExecutor); // 指定自定义线程池
}
// 5. 主线程快速返回(异步任务后台执行)
log.info("已提交{}个设备的一键开关异步任务,开关状态:{}", deviceSerials.size(), enable);
return 1;
}
@Override
public Boolean saveOrUpdateEnableByDeviceList(List<OthYs7Device> ys7DeviceList) {
if (CollectionUtils.isEmpty(ys7DeviceList)) {
return false;
}
String token = ys7Manager.getToken();
if (token == null || token.isEmpty()) {
log.error("updateOneKeySwitch获取token失败无法执行设备开关操作");
return false;
}
for (OthYs7Device ys7Device : ys7DeviceList) {
// lambda内变量需为final/有效final重新赋值
String finalDeviceSerial = ys7Device.getDeviceSerial();
String finalToken = token;
// 4. 异步执行单个设备的开关操作
CompletableFuture.runAsync(() -> {
try {
// 构建请求DTO
DeviceOneKeySwitchRequstDto dto = new DeviceOneKeySwitchRequstDto();
dto.setAccessToken(finalToken);
dto.setDeviceSerial(finalDeviceSerial);
// 调用第三方接口可能抛出异常已被try-catch捕获
Integer b = Ys7RequestUtils.getDeviceSwitchStatus(dto);
if (b != null) {
// 接口调用成功,更新数据库
int updateRows = baseMapper.update(new LambdaUpdateWrapper<OthYs7Device>()
.set(OthYs7Device::getEnable, b)
.eq(OthYs7Device::getDeviceSerial, finalDeviceSerial));
log.info("设备{}全天录像开关状态更新成功,开关状态:{},影响行数:{}",
finalDeviceSerial, b, updateRows);
}
} catch (Exception e) {
// 捕获所有异常,确保单个设备失败不影响其他设备
log.error("设备{}全天录像开关状态获取失败", finalDeviceSerial, e);
}
}, getDeviceSwitchExecutor); // 指定自定义线程池
}
return true;
}
/**
* 验证萤石摄像对象是否发生更改
*

View File

@ -0,0 +1,28 @@
package org.dromara.progress.domain.vo.progresscategory;
import lombok.Data;
import java.io.Serial;
import java.io.Serializable;
import java.math.BigDecimal;
/**
* @author lilemy
* @date 2025-12-15 15:28
*/
@Data
public class PgsProgressCategoryValueTotalVo implements Serializable {
@Serial
private static final long serialVersionUID = 3568038376181464491L;
/**
* 总产值
*/
private BigDecimal totalValue;
/**
* 当前产值
*/
private BigDecimal currentValue;
}

View File

@ -0,0 +1,28 @@
package org.dromara.progress.domain.vo.progressplan;
import lombok.Data;
import java.io.Serial;
import java.io.Serializable;
import java.time.LocalDate;
/**
* @author lilemy
* @date 2025-12-15 15:01
*/
@Data
public class PgsProgressPlanDateVo implements Serializable {
@Serial
private static final long serialVersionUID = -2179633422685929795L;
/**
* 计划开始时间
*/
private LocalDate startDate;
/**
* 计划结束时间
*/
private LocalDate endDate;
}

View File

@ -91,6 +91,15 @@ public interface IPgsConstructionSchedulePlanService extends IService<PgsConstru
*/
List<PgsConstructionSchedulePlanVo> getVoList(List<PgsConstructionSchedulePlan> constructionSchedulePlanList);
/**
* 获取所有子节点
*
* @param parentId 父节点 ID
* @param allList 所有节点列表
* @return 所有子节点列表
*/
List<PgsConstructionSchedulePlan> getAllChildren(Long parentId, List<PgsConstructionSchedulePlan> allList);
/**
* 导出Excel
*

View File

@ -220,7 +220,7 @@ public interface IPgsProgressCategoryService extends IService<PgsProgressCategor
* @param selectValue true:业主产值 false:分包产值
* @return 项目进度产值
*/
BigDecimal getValueTotal(List<PgsProgressCategory> categoryList, Boolean selectValue);
PgsProgressCategoryValueTotalVo getValueTotal(List<PgsProgressCategory> categoryList, Boolean selectValue);
/**
* 获取项目进度类别未完成数量

View File

@ -9,6 +9,7 @@ import org.dromara.progress.domain.PgsProgressCategory;
import org.dromara.progress.domain.PgsProgressPlan;
import org.dromara.progress.domain.dto.progressplan.PgsProgressPlanCreateReq;
import org.dromara.progress.domain.dto.progressplan.PgsProgressPlanQueryReq;
import org.dromara.progress.domain.vo.progressplan.PgsProgressPlanDateVo;
import org.dromara.progress.domain.vo.progressplan.PgsProgressPlanVo;
import java.math.BigDecimal;
@ -47,6 +48,14 @@ public interface IPgsProgressPlanService extends IService<PgsProgressPlan> {
*/
List<PgsProgressPlanVo> queryList(PgsProgressPlanQueryReq req);
/**
* 查询进度计划日期(最早的开始时间和最晚的结束时间)
*
* @param req 查询条件
* @return 进度计划日期(最早的开始时间和最晚的结束时间)
*/
PgsProgressPlanDateVo queryDate(PgsProgressPlanQueryReq req);
/**
* 新增进度计划
*

View File

@ -199,6 +199,26 @@ public class PgsConstructionSchedulePlanServiceImpl extends ServiceImpl<PgsConst
return constructionSchedulePlanList.stream().map(this::getVo).toList();
}
/**
* 获取所有子节点
*
* @param parentId 父节点 ID
* @param allList 所有节点列表
* @return 所有子节点列表
*/
@Override
public List<PgsConstructionSchedulePlan> getAllChildren(Long parentId, List<PgsConstructionSchedulePlan> allList) {
List<PgsConstructionSchedulePlan> result = new ArrayList<>();
for (PgsConstructionSchedulePlan node : allList) {
if (Objects.equals(node.getParentId(), parentId)) {
result.add(node);
// 递归找子节点
result.addAll(getAllChildren(node.getId(), allList));
}
}
return result;
}
// region 导出 excel
/**

View File

@ -1547,10 +1547,14 @@ public class PgsProgressCategoryServiceImpl extends ServiceImpl<PgsProgressCateg
// 遍历所有项目进度,计算总完成数和总数
for (PgsProgressCategory category : categoryList) {
String unitType = category.getUnitType();
if (StringUtils.isBlank(unitType) || PgsProgressUnitTypeEnum.NULL.getValue().equals(unitType)) {
continue;
}
BigDecimal completed = category.getCompleted();
BigDecimal total = category.getTotal();
if (PgsProgressUnitTypeEnum.PERCENTAGE.getValue().equals(category.getUnitType())) {
if (PgsProgressUnitTypeEnum.PERCENTAGE.getValue().equals(unitType)) {
completed = completed.divide(BigDecimal.valueOf(100L), 4, RoundingMode.HALF_UP).multiply(total);
}
@ -1646,14 +1650,17 @@ public class PgsProgressCategoryServiceImpl extends ServiceImpl<PgsProgressCateg
* @return 项目进度产值
*/
@Override
public BigDecimal getValueTotal(List<PgsProgressCategory> categoryList, Boolean selectValue) {
public PgsProgressCategoryValueTotalVo getValueTotal(List<PgsProgressCategory> categoryList, Boolean selectValue) {
PgsProgressCategoryValueTotalVo vo = new PgsProgressCategoryValueTotalVo();
vo.setCurrentValue(BigDecimal.ZERO);
vo.setTotalValue(BigDecimal.ZERO);
// 如果没有数据则返回0
if (CollUtil.isEmpty(categoryList)) {
return BigDecimal.ZERO;
return vo;
}
BigDecimal currentValue = BigDecimal.ZERO;
BigDecimal totalValue = BigDecimal.ZERO;
// 遍历所有项目进度,计算总完成数和总数
for (PgsProgressCategory category : categoryList) {
BigDecimal completed = category.getCompleted();
@ -1662,9 +1669,12 @@ public class PgsProgressCategoryServiceImpl extends ServiceImpl<PgsProgressCateg
if (PgsProgressUnitTypeEnum.PERCENTAGE.getValue().equals(category.getUnitType())) {
completed = completed.divide(BigDecimal.valueOf(100L), 4, RoundingMode.HALF_UP).multiply(total);
}
totalValue = totalValue.add(completed.multiply(price));
currentValue = currentValue.add(completed.multiply(price));
totalValue = totalValue.add(selectValue ? category.getOwnerOutputValue() : category.getConstructionOutputValue());
}
return totalValue.setScale(4, RoundingMode.HALF_UP);
vo.setCurrentValue(currentValue.setScale(4, RoundingMode.HALF_UP));
vo.setTotalValue(totalValue.setScale(4, RoundingMode.HALF_UP));
return vo;
}
/**

View File

@ -22,6 +22,7 @@ import org.dromara.progress.domain.dto.progressplandetail.PgsProgressPlanDetailC
import org.dromara.progress.domain.enums.PgsDelayStatusEnum;
import org.dromara.progress.domain.enums.PgsFinishStatusEnum;
import org.dromara.progress.domain.enums.PgsProgressUnitTypeEnum;
import org.dromara.progress.domain.vo.progressplan.PgsProgressPlanDateVo;
import org.dromara.progress.domain.vo.progressplan.PgsProgressPlanVo;
import org.dromara.progress.domain.vo.progressplandetail.PgsProgressPlanDetailNumVo;
import org.dromara.progress.mapper.PgsProgressPlanMapper;
@ -104,6 +105,24 @@ public class PgsProgressPlanServiceImpl extends ServiceImpl<PgsProgressPlanMappe
return list.stream().map(this::getVo).toList();
}
/**
* 查询进度计划日期(最早的开始时间和最晚的结束时间)
*
* @param req 查询条件
* @return 进度计划日期(最早的开始时间和最晚的结束时间)
*/
@Override
public PgsProgressPlanDateVo queryDate(PgsProgressPlanQueryReq req) {
List<PgsProgressPlan> planList = this.list(this.buildQueryWrapper(req));
PgsProgressPlanDateVo dateVo = new PgsProgressPlanDateVo();
if (CollUtil.isEmpty(planList)) {
return dateVo;
}
dateVo.setStartDate(planList.stream().map(PgsProgressPlan::getStartDate).min(LocalDate::compareTo).orElse(null));
dateVo.setEndDate(planList.stream().map(PgsProgressPlan::getEndDate).max(LocalDate::compareTo).orElse(null));
return dateVo;
}
/**
* 新增进度计划
*

View File

@ -81,6 +81,7 @@ public class BusProjectTeamMemberVo implements Serializable {
/**
* 头像
*/
@Translation(type = TransConstant.OSS_ID_TO_URL)
private String avatar;
/**

View File

@ -1,11 +1,15 @@
package org.dromara.project.mapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Select;
import org.dromara.common.mybatis.core.mapper.BaseMapperPlus;
import org.dromara.common.mybatis.core.page.PageQuery;
import org.dromara.contractor.domain.SubContractor;
import org.dromara.project.domain.BusAttendance;
import org.dromara.project.domain.bo.BusAttendanceBo;
import org.dromara.project.domain.vo.BusAttendanceVo;
import org.dromara.common.mybatis.core.mapper.BaseMapperPlus;
import java.util.List;
/**
* 考勤Mapper接口
@ -18,4 +22,6 @@ public interface BusAttendanceMapper extends BaseMapperPlus<BusAttendance, BusAt
Page<BusAttendanceVo> queryPageList(BusAttendanceBo bo, PageQuery pageQuery);
@Select("select * from sub_contractor")
List<SubContractor> getSubContractor();
}

Some files were not shown because too many files have changed in this diff Show More