|
|
@@ -7,8 +7,8 @@ import com.alibaba.excel.write.metadata.WriteSheet;
|
|
|
import com.alibaba.excel.write.metadata.fill.FillConfig;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
-import jakarta.annotation.Resource;
|
|
|
import jakarta.servlet.http.HttpServletResponse;
|
|
|
+import lombok.AllArgsConstructor;
|
|
|
import lombok.SneakyThrows;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.sky.core.excel.util.ExcelUtil;
|
|
|
@@ -19,7 +19,6 @@ import org.sky.core.mp.support.Query;
|
|
|
import org.sky.core.secure.utils.SecureUtil;
|
|
|
import org.sky.core.tool.utils.*;
|
|
|
import org.sky.scientific.e.AssetStatusEnum;
|
|
|
-import org.sky.scientific.e.XmStatusEnum;
|
|
|
import org.sky.scientific.excel.XmFixedAssetExcel;
|
|
|
import org.sky.scientific.mapper.AssetMapper;
|
|
|
import org.sky.scientific.mapper.XmFixedAssetMapper;
|
|
|
@@ -31,6 +30,7 @@ import org.sky.scientific.pojo.entity.XmFixedAsset;
|
|
|
import org.sky.scientific.pojo.entity.YsZjfyycqdtfyEntity;
|
|
|
import org.sky.scientific.pojo.vo.XmFixedAssetCostVo;
|
|
|
import org.sky.scientific.service.IXmFixedAssetService;
|
|
|
+import org.sky.scientific.service.IXmService;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
@@ -50,14 +50,13 @@ import java.util.concurrent.atomic.AtomicInteger;
|
|
|
*/
|
|
|
@Slf4j
|
|
|
@Service
|
|
|
+@AllArgsConstructor
|
|
|
public class XmFixedAssetServiceImpl extends BaseServiceImpl<XmFixedAssetMapper, XmFixedAsset> implements IXmFixedAssetService {
|
|
|
|
|
|
- @Resource
|
|
|
- private YsZjfyycqdtfyMapper ysZjfyycqdtfyMapper;
|
|
|
- @Resource
|
|
|
- private XmMapper xmMapper;
|
|
|
- @Resource
|
|
|
- private AssetMapper assetMapper;
|
|
|
+ private final YsZjfyycqdtfyMapper ysZjfyycqdtfyMapper;
|
|
|
+ private final XmMapper xmMapper;
|
|
|
+ private final AssetMapper assetMapper;
|
|
|
+ private final IXmService xmService;
|
|
|
|
|
|
@Override
|
|
|
public IPage<XmFixedAsset> selectXmFixAssetPage(IPage<XmFixedAsset> page, XmAssetQueryParam param, String zclb) {
|
|
|
@@ -85,23 +84,26 @@ public class XmFixedAssetServiceImpl extends BaseServiceImpl<XmFixedAssetMapper,
|
|
|
Date lastDate = DateUtil.minusMonths(DateUtil.parse(yearAndMonth, DateUtil.PATTERN_YYYYMM), 1);
|
|
|
//获取上个月数据
|
|
|
List<XmFixedAsset> lastMonthList = baseMapper.selectXmFixedAssetByYearAndMonth(DateUtil.format(lastDate, DateUtil.PATTERN_YYYYMM), zclb);
|
|
|
- List<Long> list = lastMonthList.stream().map(XmFixedAsset::getXmId).toList();
|
|
|
- for (Long xmId : list) {
|
|
|
- Integer xmStatus = xmMapper.getXmStatusByXmId(xmId);
|
|
|
- if (Func.equals(xmStatus, XmStatusEnum.已结题.getCode())) {
|
|
|
- throw new ServiceException("项目已结题,不可操作");
|
|
|
- }
|
|
|
- }
|
|
|
//获取本月数据
|
|
|
List<XmFixedAsset> thisMonthList = baseMapper.selectXmFixedAssetByYearAndMonth(yearAndMonth, zclb);
|
|
|
-
|
|
|
List<String> zcbmList = thisMonthList.stream().map(XmFixedAsset::getZcbm).toList();
|
|
|
+
|
|
|
+ //已结题项目列表
|
|
|
+ List<Long> jtXmIdList = new ArrayList<>();
|
|
|
+ //待新增的数据
|
|
|
+ List<XmFixedAsset> insertList = new ArrayList<>();
|
|
|
if (!CollectionUtil.isEmpty(lastMonthList)) {
|
|
|
//复制上个月数据到本月
|
|
|
- List<XmFixedAsset> insertList = new ArrayList<>();
|
|
|
for (XmFixedAsset dbAsset : lastMonthList) {
|
|
|
//dbAsset已存在,则跳过
|
|
|
- if (CollectionUtil.isNotEmpty(zcbmList) && zcbmList.contains(dbAsset.getZcbm())) {
|
|
|
+ if (zcbmList.contains(dbAsset.getZcbm())) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if (jtXmIdList.contains(dbAsset.getXmId())) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if(xmService.judgeXmIsOver(dbAsset.getXmId(), false)){
|
|
|
+ jtXmIdList.add(dbAsset.getXmId());
|
|
|
continue;
|
|
|
}
|
|
|
XmFixedAsset asset = new XmFixedAsset();
|
|
|
@@ -110,31 +112,34 @@ public class XmFixedAssetServiceImpl extends BaseServiceImpl<XmFixedAssetMapper,
|
|
|
asset.setZcbm(dbAsset.getZcbm());
|
|
|
insertList.add(asset);
|
|
|
}
|
|
|
- if (CollectionUtil.isNotEmpty(insertList)) {
|
|
|
- return this.saveBatch(insertList);
|
|
|
- }
|
|
|
} else {
|
|
|
//若无,则获取预算表中的资产,研发项目周期(含变更)包含本月的
|
|
|
List<YsZjfyycqdtfyEntity> ysList = ysZjfyycqdtfyMapper.selectByYearAndMonth(yearAndMonth, zclb);
|
|
|
if (CollectionUtil.isEmpty(ysList)) {
|
|
|
throw new ServiceException("项目预算表中无" + zclb);
|
|
|
}
|
|
|
- List<XmFixedAsset> insertList = new ArrayList<>();
|
|
|
for (YsZjfyycqdtfyEntity ys : ysList) {
|
|
|
if (CollectionUtil.isNotEmpty(zcbmList) && zcbmList.contains(ys.getZcbm())) {
|
|
|
continue;
|
|
|
}
|
|
|
+ if (jtXmIdList.contains(ys.getXmId())) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if(xmService.judgeXmIsOver(ys.getXmId(), false)){
|
|
|
+ jtXmIdList.add(ys.getXmId());
|
|
|
+ continue;
|
|
|
+ }
|
|
|
XmFixedAsset asset = new XmFixedAsset();
|
|
|
asset.setYearAndMonth(yearAndMonth);
|
|
|
asset.setXmId(ys.getXmId());
|
|
|
asset.setZcbm(ys.getZcbm());
|
|
|
insertList.add(asset);
|
|
|
}
|
|
|
- if (CollectionUtil.isNotEmpty(insertList)) {
|
|
|
- return this.saveBatch(insertList);
|
|
|
- }
|
|
|
}
|
|
|
- return true;
|
|
|
+ if (CollectionUtil.isEmpty(insertList)) {
|
|
|
+ throw new ServiceException("数据已全部引用");
|
|
|
+ }
|
|
|
+ return this.saveBatch(insertList);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -158,7 +163,7 @@ public class XmFixedAssetServiceImpl extends BaseServiceImpl<XmFixedAssetMapper,
|
|
|
if (CollectionUtil.isNotEmpty(zcbmList) && zcbmList.contains(excel.getZcbm())) {
|
|
|
continue;
|
|
|
}
|
|
|
- if (StringUtil.isBlank(excel.getXmbh())) {
|
|
|
+ if (Func.isBlank(excel.getXmbh())) {
|
|
|
throw new ServiceException("序号为[" + excel.getXh() + "]的项目研发编号为空");
|
|
|
}
|
|
|
String xmkey = "xm:" + excel.getXmbh();
|
|
|
@@ -168,10 +173,8 @@ public class XmFixedAssetServiceImpl extends BaseServiceImpl<XmFixedAssetMapper,
|
|
|
if (xmId == null) {
|
|
|
throw new ServiceException("序号为[" + excel.getXh() + "]的项目不存在");
|
|
|
}
|
|
|
- Integer status = xmMapper.getXmStatusByXmId(xmId);
|
|
|
- if (Func.equals(status, XmStatusEnum.已结题.getCode())) {
|
|
|
- throw new ServiceException("项目已结题,不可操作");
|
|
|
- }
|
|
|
+
|
|
|
+ xmService.judgeXmIsOver(xmId, true);
|
|
|
}
|
|
|
|
|
|
xmIdMap.put(xmkey, xmId);
|
|
|
@@ -208,10 +211,7 @@ public class XmFixedAssetServiceImpl extends BaseServiceImpl<XmFixedAssetMapper,
|
|
|
public boolean physicalDeleteByIds(List<Long> ids) {
|
|
|
for (Long id : ids) {
|
|
|
XmFixedAsset fixedAsset = baseMapper.selectById(id);
|
|
|
- Integer status = xmMapper.getXmStatusByXmId(fixedAsset.getXmId());
|
|
|
- if (Func.equals(status, XmStatusEnum.已结题.getCode())) {
|
|
|
- throw new ServiceException("项目已结题,不可操作");
|
|
|
- }
|
|
|
+ xmService.judgeXmIsOver(fixedAsset.getXmId(), true);
|
|
|
}
|
|
|
return baseMapper.physicalDeleteByIds(ids);
|
|
|
}
|
|
|
@@ -221,10 +221,8 @@ public class XmFixedAssetServiceImpl extends BaseServiceImpl<XmFixedAssetMapper,
|
|
|
if (StringUtil.isBlank(xmAsset.getYearAndMonth())) {
|
|
|
throw new ServiceException("参数yearAndMonth不能为空");
|
|
|
}
|
|
|
- Integer status = xmMapper.getXmStatusByXmId(xmAsset.getXmId());
|
|
|
- if (Func.equals(status, XmStatusEnum.已结题.getCode())) {
|
|
|
- throw new ServiceException("项目已结题,不可操作");
|
|
|
- }
|
|
|
+
|
|
|
+ xmService.judgeXmIsOver(xmAsset.getXmId(), true);
|
|
|
//获取本月数据
|
|
|
List<XmFixedAsset> thisMonthList = baseMapper.selectXmFixedAssetByYearAndMonth(xmAsset.getYearAndMonth(), zclb);
|
|
|
|