吉安感知网项目-后端
linwei
2026-02-05 08d4bb2bf4bfadc9ab5fcf6b0a2bfb543d22b2a0
drone-service/drone-gd/src/main/java/org/sxkj/gd/orderdata/service/impl/GdSupplyDemandServiceImpl.java
@@ -22,6 +22,7 @@
import org.springblade.core.log.exception.ServiceException;
import org.springblade.core.mp.base.BaseServiceImpl;
import org.springblade.core.secure.utils.AuthUtil;
import org.springblade.core.tool.utils.BeanUtil;
import org.springblade.core.tool.utils.Func;
import org.springblade.core.tool.utils.StringUtil;
import org.springframework.stereotype.Service;
@@ -41,6 +42,7 @@
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
/**
 * 供需需求信息表 服务实现类
@@ -72,7 +74,12 @@
   @Override
   public IPage<GdSupplyDemandVO> selectGdSupplyDemandPage(IPage<GdSupplyDemandVO> page, GdSupplyDemandPageParam gdSupplyDemand) {
      return page.setRecords(baseMapper.selectGdSupplyDemandPage(page, gdSupplyDemand, SysCache.getDeptChildIds(Long.valueOf(AuthUtil.getDeptId()))));
      List<Long> deptList = new ArrayList<>();
      if (!AuthUtil.isAdministrator()) {
         deptList = SysCache.getDeptChildIds(Long.valueOf(AuthUtil.getDeptId()));
      }
      gdSupplyDemand.setDeptList(deptList);
      return page.setRecords(baseMapper.selectGdSupplyDemandPage(page, gdSupplyDemand));
   }
   @Override
@@ -85,7 +92,11 @@
      if (Func.isEmpty(gdSupplyDemand)) {
         throw new ServiceException("需求参数不能为空");
      }
      GdSupplyDemandEntity detail = baseMapper.selectGdSupplyDemandDetail(gdSupplyDemand, SysCache.getDeptChildIds(Long.valueOf(AuthUtil.getDeptId())));
      List<Long> deptList = new ArrayList<>();
      if (!AuthUtil.isAdministrator()) {
         deptList = SysCache.getDeptChildIds(Long.valueOf(AuthUtil.getDeptId()));
      }
      GdSupplyDemandEntity detail = baseMapper.selectGdSupplyDemandDetail(gdSupplyDemand, deptList);
      if (detail == null) {
         throw new ServiceException("未查询到数据");
      }
@@ -94,13 +105,14 @@
   @Override
   @Transactional(rollbackFor = Exception.class)
   public boolean submitSupplyDemand(GdSupplyDemandEntity gdSupplyDemand) {
   public boolean submitSupplyDemand(GdSupplyDemandDTO gdSupplyDemand) {
      if (Func.isEmpty(gdSupplyDemand)) {
         throw new ServiceException("需求参数不能为空");
      }
      GdSupplyDemandEntity supplyDemand = Objects.requireNonNull(BeanUtil.copy(gdSupplyDemand, GdSupplyDemandEntity.class));
      // 获取前端传入的需求状态
      String demandStatus = gdSupplyDemand.getDemandStatus();
      String demandStatus = supplyDemand.getDemandStatus();
      if (StringUtil.isBlank(demandStatus)) {
         throw new ServiceException("需求状态不能为空");
      }
@@ -110,18 +122,18 @@
         throw new ServiceException("需求状态值无效,仅支持 0(草稿) 或 1(申请中)");
      }
      boolean isInsert = Func.isEmpty(gdSupplyDemand.getId());
      boolean isInsert = Func.isEmpty(supplyDemand.getId());
      Long userId = AuthUtil.getUserId();
      Long deptId = Long.valueOf(AuthUtil.getDeptId());
      gdSupplyDemand.setUpdateUser(userId);
      supplyDemand.setUpdateUser(userId);
      boolean saved;
      if (isInsert) {
         gdSupplyDemand.setCreateUser(userId);
         gdSupplyDemand.setCreateDept(deptId);
         saved = baseMapper.insertGdSupplyDemand(gdSupplyDemand) > 0;
         supplyDemand.setCreateUser(userId);
         supplyDemand.setCreateDept(deptId);
         saved = baseMapper.insertGdSupplyDemand(supplyDemand) > 0;
      } else {
         saved = baseMapper.updateGdSupplyDemand(gdSupplyDemand) > 0;
         saved = baseMapper.updateGdSupplyDemand(supplyDemand) > 0;
      }
      if (!saved) {
@@ -130,8 +142,8 @@
      // 仅当状态为"申请中"(1)时才创建审核记录
      if (STATUS_APPLY.equals(demandStatus)) {
         GdSupplyDemandEntity supplyDemand = loadSupplyDemandForAudit(gdSupplyDemand.getId());
         GdSupplyDemandAuditEntity auditEntity = buildAuditEntity(supplyDemand, AUDIT_PENDING, null);
         GdSupplyDemandEntity auditDemand = loadSupplyDemandForAudit(supplyDemand.getId());
         GdSupplyDemandAuditEntity auditEntity = buildAuditEntity(auditDemand, AUDIT_PENDING, null);
         return gdSupplyDemandAuditService.saveSupplyDemandAudit(auditEntity);
      }