|
|
@ -8,20 +8,25 @@ 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业务层处理 |
|
|
@ -29,9 +34,9 @@ import java.util.List; |
|
|
|
* @author lienbo |
|
|
|
* @date 2023-12-05 |
|
|
|
*/ |
|
|
|
@Slf4j |
|
|
|
@Service |
|
|
|
public class DcBusiTargetAdjustDayMasterService extends ServiceImpl<DcBusiTargetAdjustDayMasterMapper, DcBusiTargetAdjustDayMasterDao> implements IService<DcBusiTargetAdjustDayMasterDao> |
|
|
|
{ |
|
|
|
public class DcBusiTargetAdjustDayMasterService extends ServiceImpl<DcBusiTargetAdjustDayMasterMapper, DcBusiTargetAdjustDayMasterDao> implements IService<DcBusiTargetAdjustDayMasterDao> { |
|
|
|
|
|
|
|
@Resource |
|
|
|
private DcBaseAssetInfoMapper dcBaseAssetInfoMapper; |
|
|
@ -51,14 +56,15 @@ public class DcBusiTargetAdjustDayMasterService extends ServiceImpl<DcBusiTarget |
|
|
|
@Resource |
|
|
|
private DcBusiTargetDraftDayMapper dcBusiTargetDraftDayMapper; |
|
|
|
|
|
|
|
private static final Lock lock = new ReentrantLock(); |
|
|
|
|
|
|
|
/** |
|
|
|
* 查询资产指标调整单主(日) |
|
|
|
* |
|
|
|
* @param id 资产指标调整单主(日)主键 |
|
|
|
* @return 资产指标调整单主(日) |
|
|
|
*/ |
|
|
|
public DcBusiTargetAdjustDayMasterDao selectDcBusiTargetAdjustDayMasterDaoById(Long id) |
|
|
|
{ |
|
|
|
public DcBusiTargetAdjustDayMasterDao selectDcBusiTargetAdjustDayMasterDaoById(Long id) { |
|
|
|
return baseMapper.selectDcBusiTargetAdjustDayMasterDaoById(id); |
|
|
|
} |
|
|
|
|
|
|
@ -68,8 +74,7 @@ public class DcBusiTargetAdjustDayMasterService extends ServiceImpl<DcBusiTarget |
|
|
|
* @param dcBusiTargetAdjustDayMasterDao 资产指标调整单主(日) |
|
|
|
* @return 资产指标调整单主(日) |
|
|
|
*/ |
|
|
|
public List<DcBusiTargetAdjustDayMasterDao> selectDcBusiTargetAdjustDayMasterDaoList(DcBusiTargetAdjustDayMasterDao dcBusiTargetAdjustDayMasterDao) |
|
|
|
{ |
|
|
|
public List<DcBusiTargetAdjustDayMasterDao> selectDcBusiTargetAdjustDayMasterDaoList(DcBusiTargetAdjustDayMasterDao dcBusiTargetAdjustDayMasterDao) { |
|
|
|
return baseMapper.selectDcBusiTargetAdjustDayMasterDaoList(dcBusiTargetAdjustDayMasterDao); |
|
|
|
} |
|
|
|
|
|
|
@ -80,8 +85,7 @@ public class DcBusiTargetAdjustDayMasterService extends ServiceImpl<DcBusiTarget |
|
|
|
* @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()); |
|
|
@ -123,8 +127,7 @@ public class DcBusiTargetAdjustDayMasterService extends ServiceImpl<DcBusiTarget |
|
|
|
* @return 结果 |
|
|
|
*/ |
|
|
|
|
|
|
|
public int updateDcBusiTargetAdjustDayMasterDao(DcBusiTargetAdjustDayMasterDao dcBusiTargetAdjustDayMasterDao) |
|
|
|
{ |
|
|
|
public int updateDcBusiTargetAdjustDayMasterDao(DcBusiTargetAdjustDayMasterDao dcBusiTargetAdjustDayMasterDao) { |
|
|
|
dcBusiTargetAdjustDayMasterDao.setUpdatedTime(DateUtils.getNowDate()); |
|
|
|
return baseMapper.updateDcBusiTargetAdjustDayMasterDao(dcBusiTargetAdjustDayMasterDao); |
|
|
|
} |
|
|
@ -136,8 +139,7 @@ public class DcBusiTargetAdjustDayMasterService extends ServiceImpl<DcBusiTarget |
|
|
|
* @return 结果 |
|
|
|
*/ |
|
|
|
|
|
|
|
public int deleteDcBusiTargetAdjustDayMasterDaoByIds(Long[] ids) |
|
|
|
{ |
|
|
|
public int deleteDcBusiTargetAdjustDayMasterDaoByIds(Long[] ids) { |
|
|
|
return baseMapper.deleteDcBusiTargetAdjustDayMasterDaoByIds(ids); |
|
|
|
} |
|
|
|
|
|
|
@ -148,8 +150,7 @@ public class DcBusiTargetAdjustDayMasterService extends ServiceImpl<DcBusiTarget |
|
|
|
* @return 结果 |
|
|
|
*/ |
|
|
|
|
|
|
|
public int deleteDcBusiTargetAdjustDayMasterDaoById(Long id) |
|
|
|
{ |
|
|
|
public int deleteDcBusiTargetAdjustDayMasterDaoById(Long id) { |
|
|
|
return baseMapper.deleteDcBusiTargetAdjustDayMasterDaoById(id); |
|
|
|
} |
|
|
|
|
|
|
@ -173,21 +174,62 @@ public class DcBusiTargetAdjustDayMasterService extends ServiceImpl<DcBusiTarget |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public int dispose(Long id) { |
|
|
|
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<DcBusiTargetAdjustDaySubDao> dcBusiTargetAdjustDaySubDaoList = dcBusiTargetAdjustDaySubMapper.selectDcBusiTargetAdjustDaySubDaoList(params); |
|
|
|
// 遍历子表集合,向指标数据底稿表(日)中同步数据
|
|
|
|
for (DcBusiTargetAdjustDaySubDao dcBusiTargetAdjustDaySubDao : dcBusiTargetAdjustDaySubDaoList) { |
|
|
|
DcBusiTargetDraftDayDao dcBusiTargetDraftDayDao = new DcBusiTargetDraftDayDao(); |
|
|
|
// dcBusiTargetDraftDayDao.setCompanyCode();
|
|
|
|
// dcBusiTargetDraftDayMapper.disposeDcBusiTargetDraftDayDao(dcBusiTargetAdjustDaySubDao);
|
|
|
|
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<DcBusiTargetDraftDay> 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(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|