From edb454077efbd7aac09347540242aafaee25f6f7 Mon Sep 17 00:00:00 2001 From: bobol Date: Wed, 6 Dec 2023 14:20:01 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B5=84=E4=BA=A7=E6=8C=87=E6=A0=87=E8=B0=83?= =?UTF-8?q?=E6=95=B4=E5=8D=95=E5=A4=84=E7=90=86=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...DcBusiTargetAdjustDayMasterController.java | 21 +++- .../domain/DcBusiTargetAdjustDaySubDao.java | 64 +++++++--- .../DcBusiTargetAdjustDayMasterService.java | 116 ++++++++++++------ .../DcBusiTargetAdjustDayMasterMapper.xml | 16 +-- 4 files changed, 152 insertions(+), 65 deletions(-) diff --git a/lzbi-module/src/main/java/com/lzbi/draft/controller/DcBusiTargetAdjustDayMasterController.java b/lzbi-module/src/main/java/com/lzbi/draft/controller/DcBusiTargetAdjustDayMasterController.java index f0c8f8b..7f0ce40 100644 --- a/lzbi-module/src/main/java/com/lzbi/draft/controller/DcBusiTargetAdjustDayMasterController.java +++ b/lzbi-module/src/main/java/com/lzbi/draft/controller/DcBusiTargetAdjustDayMasterController.java @@ -110,16 +110,33 @@ public class DcBusiTargetAdjustDayMasterController extends BaseController } /** - * 新增资产指标调整单主(日) + * 审核资产指标调整单(日) */ @ApiOperation("审核资产指标调整单") @ApiImplicitParam(name = "id", value = "id", dataType = "Long", dataTypeClass = Long.class, paramType = "path") @PreAuthorize("@ss.hasPermi('lzbi:master:add')") @Log(title = "资产指标调整单主(日)", businessType = BusinessType.OTHER) - @PostMapping("/{id}") + @PostMapping("/audit/{id}") public AjaxResult audit(@PathVariable("id") Long id) { return toAjax(dcBusiTargetAdjustDayMasterService.audit(id)); } + /** + * 处理资产指标调整单主(日) + */ + @ApiOperation("处理资产指标调整单") + @ApiImplicitParam(name = "id", value = "id", dataType = "Long", dataTypeClass = Long.class, paramType = "path") + @PreAuthorize("@ss.hasPermi('lzbi:master:add')") + @Log(title = "资产指标调整单主(日)", businessType = BusinessType.OTHER) + @PostMapping("/dispose/{id}") + public AjaxResult dispose(@PathVariable("id") Long id) + { + try{ + return toAjax(dcBusiTargetAdjustDayMasterService.dispose(id)); + } catch (RuntimeException e) { + return error(e.getMessage()); + } + } + } diff --git a/lzbi-module/src/main/java/com/lzbi/draft/domain/DcBusiTargetAdjustDaySubDao.java b/lzbi-module/src/main/java/com/lzbi/draft/domain/DcBusiTargetAdjustDaySubDao.java index 4264b40..dc1106e 100644 --- a/lzbi-module/src/main/java/com/lzbi/draft/domain/DcBusiTargetAdjustDaySubDao.java +++ b/lzbi-module/src/main/java/com/lzbi/draft/domain/DcBusiTargetAdjustDaySubDao.java @@ -2,6 +2,7 @@ package com.lzbi.draft.domain; import java.math.BigDecimal; import java.util.Date; + import com.fasterxml.jackson.annotation.JsonFormat; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; @@ -13,76 +14,103 @@ import com.lzbi.module.base.BaseModuleEntity; /** * 统计单元指标调整单子(日)对象 dc_busi_target_adjust_day_sub - * + * * @author win * @date 2023-12-05 */ @ApiModel(value = "DcBusiTargetAdjustDaySubDao对象", description = "资产指标调整单子表对象") - @Data -public class DcBusiTargetAdjustDaySubDao extends BaseModuleEntity -{ +@Data +public class DcBusiTargetAdjustDaySubDao extends BaseModuleEntity { private static final long serialVersionUID = 1L; - /** 创建人 */ + /** + * 创建人 + */ @ApiModelProperty(hidden = true) private String createdBy; - /** 创建时间 */ + /** + * 创建时间 + */ @ApiModelProperty(hidden = true) private Date createdTime; - /** 更新人 */ + /** + * 更新人 + */ @ApiModelProperty(hidden = true) private String updatedBy; - /** 更新时间 */ + /** + * 更新时间 + */ @ApiModelProperty(hidden = true) private Date updatedTime; - /** 主键 */ + /** + * 主键 + */ private Long id; - /** 主单据编号 */ + /** + * 主单据编号 + */ @ApiModelProperty(hidden = true) @Excel(name = "主单据编号") private String billNoMaster; - /** 指标编码 */ + /** + * 指标编码 + */ @ApiModelProperty(value = "指标编码") @Excel(name = "指标编码") private String targetCode; - /** 指标名称 */ + /** + * 指标名称 + */ @ApiModelProperty(hidden = true) @Excel(name = "指标名称") private String targetName; - /** 指标单位 */ + /** + * 指标单位 + */ @ApiModelProperty(value = "指标单位") @Excel(name = "指标单位") private String tagetUnit; - /** 日期调整日期 */ + /** + * 日期调整日期 + */ @ApiModelProperty(value = "日期调整日期") @Excel(name = "日期调整日期") private String adjustDate; - /** 调整时间 */ + /** + * 调整时间 + */ @ApiModelProperty(value = "调整时间") @Excel(name = "调整时间") private Long adjstTime; - /** 原值 */ + /** + * 原值 + */ @ApiModelProperty(value = "原值") @Excel(name = "原值") private BigDecimal valOrigin; - /** 调整值 */ + /** + * 调整值 + */ @ApiModelProperty(value = "调整值") @Excel(name = "调整值") private BigDecimal valAdjust; - /** 结果值 */ + /** + * 结果值 + */ @ApiModelProperty(value = "结果值") @Excel(name = "结果值") private BigDecimal valResult; diff --git a/lzbi-module/src/main/java/com/lzbi/draft/service/DcBusiTargetAdjustDayMasterService.java b/lzbi-module/src/main/java/com/lzbi/draft/service/DcBusiTargetAdjustDayMasterService.java index 2b3f388..09f21d0 100644 --- a/lzbi-module/src/main/java/com/lzbi/draft/service/DcBusiTargetAdjustDayMasterService.java +++ b/lzbi-module/src/main/java/com/lzbi/draft/service/DcBusiTargetAdjustDayMasterService.java @@ -8,30 +8,35 @@ import com.lzbi.common.core.domain.entity.SysDept; import com.lzbi.common.utils.DateUtils; import com.lzbi.draft.domain.DcBusiTargetAdjustDayMasterDao; import com.lzbi.draft.domain.DcBusiTargetAdjustDaySubDao; -import com.lzbi.draft.domain.DcBusiTargetDraftDayDao; +import com.lzbi.draft.domain.DcBusiTargetDraftDay; import com.lzbi.draft.mapper.DcBusiTargetAdjustDayMasterMapper; import com.lzbi.draft.mapper.DcBusiTargetAdjustDaySubMapper; import com.lzbi.draft.mapper.DcBusiTargetDraftDayMapper; import com.lzbi.special.domain.DcBaseWorkSpecial; import com.lzbi.special.mapper.DcBaseWorkSpecialMapper; import com.lzbi.system.service.impl.SysDeptServiceImpl; +import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.ObjectUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import org.springframework.util.CollectionUtils; import javax.annotation.Resource; +import java.math.BigDecimal; import java.util.List; +import java.util.concurrent.locks.Lock; +import java.util.concurrent.locks.ReentrantLock; /** * 资产指标调整单主(日)Service业务层处理 - * + * * @author lienbo * @date 2023-12-05 */ +@Slf4j @Service -public class DcBusiTargetAdjustDayMasterService extends ServiceImpl implements IService -{ +public class DcBusiTargetAdjustDayMasterService extends ServiceImpl implements IService { @Resource private DcBaseAssetInfoMapper dcBaseAssetInfoMapper; @@ -51,37 +56,36 @@ public class DcBusiTargetAdjustDayMasterService extends ServiceImpl selectDcBusiTargetAdjustDayMasterDaoList(DcBusiTargetAdjustDayMasterDao dcBusiTargetAdjustDayMasterDao) - { + public List selectDcBusiTargetAdjustDayMasterDaoList(DcBusiTargetAdjustDayMasterDao dcBusiTargetAdjustDayMasterDao) { return baseMapper.selectDcBusiTargetAdjustDayMasterDaoList(dcBusiTargetAdjustDayMasterDao); } /** * 新增资产指标调整单主(日) - * + * * @param dcBusiTargetAdjustDayMasterDao 资产指标调整单主(日) * @return 结果 */ @Transactional(rollbackFor = Exception.class) - public int insertDcBusiTargetAdjustDayMasterDao(DcBusiTargetAdjustDayMasterDao dcBusiTargetAdjustDayMasterDao) - { + public int insertDcBusiTargetAdjustDayMasterDao(DcBusiTargetAdjustDayMasterDao dcBusiTargetAdjustDayMasterDao) { String assetCode = dcBusiTargetAdjustDayMasterDao.getAssetCode(); // 查询公司 SysDept company = sysDeptService.selectDeptById(dcBusiTargetAdjustDayMasterDao.getCompanyId()); @@ -118,38 +122,35 @@ public class DcBusiTargetAdjustDayMasterService extends ServiceImpl dcBusiTargetAdjustDaySubDaoList = dcBusiTargetAdjustDaySubMapper.selectDcBusiTargetAdjustDaySubDaoList(params); - // 遍历子表集合,向指标数据底稿表(日)中同步数据 - for (DcBusiTargetAdjustDaySubDao dcBusiTargetAdjustDaySubDao : dcBusiTargetAdjustDaySubDaoList) { - DcBusiTargetDraftDayDao dcBusiTargetDraftDayDao = new DcBusiTargetDraftDayDao(); -// dcBusiTargetDraftDayDao.setCompanyCode(); -// dcBusiTargetDraftDayMapper.disposeDcBusiTargetDraftDayDao(dcBusiTargetAdjustDaySubDao); + public int dispose(Long id) throws RuntimeException { + lock.lock(); + try { + // 查询审核资产指标调整单主表数据 + DcBusiTargetAdjustDayMasterDao dcBusiTargetAdjustDayMasterDao = baseMapper.selectDcBusiTargetAdjustDayMasterDaoById(id); + // 调整单未审核不能处理 + if (DcBusiTargetAdjustDayMasterDao.CHECK_STATUS_PENDING_CHECK.equals(dcBusiTargetAdjustDayMasterDao.getCheckStauts())) { + throw new RuntimeException("调整单未审核不能处理"); + } + // 调整单已处理 + if (DcBusiTargetAdjustDayMasterDao.CHECK_STATUS_PROCESSED.equals(dcBusiTargetAdjustDayMasterDao.getCheckStauts())) { + throw new RuntimeException("调整单已处理"); + } + // 查询审核资产指标调整单子表集合 + DcBusiTargetAdjustDaySubDao params = new DcBusiTargetAdjustDaySubDao(); + params.setBillNoMaster(dcBusiTargetAdjustDayMasterDao.getBillSerial()); + List dcBusiTargetAdjustDaySubDaoList = dcBusiTargetAdjustDaySubMapper.selectDcBusiTargetAdjustDaySubDaoList(params); + // 遍历子表集合,向指标数据底稿表(日)中同步数据 + for (DcBusiTargetAdjustDaySubDao dcBusiTargetAdjustDaySubDao : dcBusiTargetAdjustDaySubDaoList) { + DcBusiTargetDraftDay dcBusiTargetDraftDay = new DcBusiTargetDraftDay(); + dcBusiTargetDraftDay.setCompanyId(dcBusiTargetAdjustDayMasterDao.getCompanyId()); + dcBusiTargetDraftDay.setOrgId(dcBusiTargetAdjustDayMasterDao.getOragnizeId()); + dcBusiTargetDraftDay.setAssetCode(dcBusiTargetAdjustDayMasterDao.getAssetCode()); + dcBusiTargetDraftDay.setFieldCode(dcBusiTargetAdjustDayMasterDao.getFieldCode()); + dcBusiTargetDraftDay.setTargetCode(dcBusiTargetDraftDay.getTargetCode()); + List dcBusiTargetDraftDayList = dcBusiTargetDraftDayMapper.selectDcBusiTargetDraftDayList(dcBusiTargetDraftDay); + // 如果未查询出来指标数据底稿数据,就新增,否则修改 + if (CollectionUtils.isEmpty(dcBusiTargetDraftDayList)) { + dcBusiTargetDraftDay.setCompanyName(dcBusiTargetAdjustDayMasterDao.getCompanyName()); + dcBusiTargetDraftDay.setOrgName(dcBusiTargetAdjustDayMasterDao.getOrganizeName()); + dcBusiTargetDraftDay.setAssetName(dcBusiTargetAdjustDayMasterDao.getAssetName()); + dcBusiTargetDraftDay.setFieldName(dcBusiTargetAdjustDayMasterDao.getFieldName()); + dcBusiTargetDraftDay.setTargetName(dcBusiTargetAdjustDaySubDao.getTargetName()); + dcBusiTargetDraftDay.setTargetUint(dcBusiTargetAdjustDaySubDao.getTagetUnit()); + dcBusiTargetDraftDay.setCountDate(dcBusiTargetAdjustDayMasterDao.getDateAdjust()); + dcBusiTargetDraftDay.setValOriginal(dcBusiTargetAdjustDaySubDao.getValOrigin()); + dcBusiTargetDraftDay.setValAdjust(dcBusiTargetAdjustDaySubDao.getValAdjust()); + dcBusiTargetDraftDay.setValResult(dcBusiTargetAdjustDaySubDao.getValResult()); + dcBusiTargetDraftDayMapper.insertDcBusiTargetDraftDay(dcBusiTargetDraftDay); + } else { + dcBusiTargetDraftDay = dcBusiTargetDraftDayList.get(0); + BigDecimal valResult = dcBusiTargetDraftDay.getValResult().add(new BigDecimal(0)); + dcBusiTargetDraftDay.setValOriginal(valResult); + dcBusiTargetDraftDay.setValAdjust(dcBusiTargetAdjustDaySubDao.getValAdjust()); + dcBusiTargetDraftDay.setValResult(valResult.add(dcBusiTargetAdjustDaySubDao.getValAdjust())); + dcBusiTargetDraftDayMapper.updateDcBusiTargetDraftDay(dcBusiTargetDraftDay); + } + } + // 修改审核状态为已处理 + dcBusiTargetAdjustDayMasterDao.setCheckStauts(DcBusiTargetAdjustDayMasterDao.CHECK_STATUS_PROCESSED); + return this.updateDcBusiTargetAdjustDayMasterDao(dcBusiTargetAdjustDayMasterDao); + } catch (RuntimeException e) { + log.error("处理异常", e); + throw e; + }finally { + lock.unlock(); } - // 修改审核状态为已处理 - dcBusiTargetAdjustDayMasterDao.setCheckStauts(DcBusiTargetAdjustDayMasterDao.CHECK_STATUS_PROCESSED); - return this.updateDcBusiTargetAdjustDayMasterDao(dcBusiTargetAdjustDayMasterDao); } } diff --git a/lzbi-module/src/main/resources/mapper/asset/DcBusiTargetAdjustDayMasterMapper.xml b/lzbi-module/src/main/resources/mapper/asset/DcBusiTargetAdjustDayMasterMapper.xml index dd0ad08..488380e 100644 --- a/lzbi-module/src/main/resources/mapper/asset/DcBusiTargetAdjustDayMasterMapper.xml +++ b/lzbi-module/src/main/resources/mapper/asset/DcBusiTargetAdjustDayMasterMapper.xml @@ -2,9 +2,9 @@ - + - + @@ -55,7 +55,7 @@ from dc_busi_target_adjust_day_master - - - insert into dc_busi_target_adjust_day_master @@ -136,7 +136,7 @@ - + update dc_busi_target_adjust_day_master bill_serial = #{billSerial}, @@ -164,13 +164,13 @@ where id = #{id} - + delete from dc_busi_target_adjust_day_master where id = #{id} - + delete from dc_busi_target_adjust_day_master where id in #{id}