|
|
@@ -2,6 +2,7 @@
|
|
|
package org.sky.scientific.service.impl;
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
+import jakarta.annotation.Resource;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.sky.core.log.exception.ServiceException;
|
|
|
import org.sky.core.mp.base.BaseServiceImpl;
|
|
|
@@ -9,7 +10,9 @@ import org.sky.core.tool.utils.CollectionUtil;
|
|
|
import org.sky.core.tool.utils.DateUtil;
|
|
|
import org.sky.core.tool.utils.StringUtil;
|
|
|
import org.sky.scientific.mapper.XmAssetMapper;
|
|
|
+import org.sky.scientific.mapper.YsZjfyycqdtfyMapper;
|
|
|
import org.sky.scientific.pojo.entity.XmAssetEntity;
|
|
|
+import org.sky.scientific.pojo.entity.YsZjfyycqdtfyEntity;
|
|
|
import org.sky.scientific.service.IXmAssetService;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
@@ -27,23 +30,35 @@ import java.util.List;
|
|
|
@Service
|
|
|
public class XmAssetServiceImpl extends BaseServiceImpl<XmAssetMapper, XmAssetEntity> implements IXmAssetService {
|
|
|
|
|
|
-
|
|
|
+ @Resource
|
|
|
+ private YsZjfyycqdtfyMapper ysZjfyycqdtfyMapper;
|
|
|
|
|
|
@Override
|
|
|
- public IPage<XmAssetEntity> keyanyiqishebeimingxibiao_fenye(IPage<XmAssetEntity> page, XmAssetEntity xmAsset) {
|
|
|
+ public IPage<XmAssetEntity> keyanyiqishebeimingxibiao_page(IPage<XmAssetEntity> page, XmAssetEntity xmAsset) {
|
|
|
+ if (StringUtil.isBlank(xmAsset.getYearAndMonth())) {
|
|
|
+ throw new ServiceException("参数yearAndMonth不能为空");
|
|
|
+ }
|
|
|
+ List<XmAssetEntity> list = null;
|
|
|
+ if(xmAsset.getYearAndMonth().length() == 4){
|
|
|
+ //全年
|
|
|
+ list = baseMapper.keyanyiqishebeimingxibiao_year(page, xmAsset);
|
|
|
+ }else {
|
|
|
+ //按月
|
|
|
+ list = baseMapper.keyanyiqishebeimingxibiao_monthly(page, xmAsset);
|
|
|
+ }
|
|
|
|
|
|
- return null;
|
|
|
+ return page.setRecords(list);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public boolean keyanyiqishebeimingxibiao_zhijieyinyong(String yearAndMonth) {
|
|
|
- if(StringUtil.isBlank(yearAndMonth)){
|
|
|
+ if (StringUtil.isBlank(yearAndMonth)) {
|
|
|
throw new ServiceException("参数yearAndMonth不能为空");
|
|
|
}
|
|
|
Date lastDate = DateUtil.minusMonths(DateUtil.parse(yearAndMonth, DateUtil.PATTERN_YYYYMM), 1);
|
|
|
//获取上个月数据
|
|
|
List<XmAssetEntity> lastMonthList = baseMapper.keyanyiqishebeimingxibiao_getLastMonthData(DateUtil.format(lastDate, DateUtil.PATTERN_YYYYMM));
|
|
|
- if(!CollectionUtil.isEmpty(lastMonthList)){
|
|
|
+ if (!CollectionUtil.isEmpty(lastMonthList)) {
|
|
|
//复制上个月数据到本月
|
|
|
List<XmAssetEntity> insertList = new ArrayList<>();
|
|
|
for (XmAssetEntity dbAsset : lastMonthList) {
|
|
|
@@ -54,10 +69,21 @@ public class XmAssetServiceImpl extends BaseServiceImpl<XmAssetMapper, XmAssetEn
|
|
|
insertList.add(asset);
|
|
|
}
|
|
|
return this.saveBatch(insertList);
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
//若无,则获取预算表中的科研仪器设备,研发项目周期(含变更)包含本月的
|
|
|
-
|
|
|
+ List<YsZjfyycqdtfyEntity> ysZjfyycqdtfyEntities = ysZjfyycqdtfyMapper.selectByYearAndMonth(yearAndMonth);
|
|
|
+ if (CollectionUtil.isEmpty(ysZjfyycqdtfyEntities)) {
|
|
|
+ throw new ServiceException("未能从项目预算表中读取科研仪器设备");
|
|
|
+ }
|
|
|
+ List<XmAssetEntity> insertList = new ArrayList<>();
|
|
|
+ for (YsZjfyycqdtfyEntity ysZjfyycqdtfyEntity : ysZjfyycqdtfyEntities) {
|
|
|
+ XmAssetEntity asset = new XmAssetEntity();
|
|
|
+ asset.setYearAndMonth(yearAndMonth);
|
|
|
+ asset.setXmId(ysZjfyycqdtfyEntity.getXmId());
|
|
|
+ asset.setAssetId(ysZjfyycqdtfyEntity.getAssetId());
|
|
|
+ insertList.add(asset);
|
|
|
+ }
|
|
|
+ return this.saveBatch(insertList);
|
|
|
}
|
|
|
- return true;
|
|
|
}
|
|
|
}
|