Browse Source

000000015

zhoulisky 6 months ago
parent
commit
a4529fb327

+ 19 - 6
kd-service/kd-scientific/src/main/java/org/sky/scientific/service/impl/AssetServiceImpl.java

@@ -115,7 +115,7 @@ public class AssetServiceImpl extends BaseServiceImpl<AssetMapper, AssetEntity>
 			}
 			}
 			idenfifierList.add(identifier);
 			idenfifierList.add(identifier);
 			asset.setYearAndMonth(yearAndMonth);
 			asset.setYearAndMonth(yearAndMonth);
-			//yearAndMonth 是否存在该
+			//yearAndMonth 是否存在该资
 			LambdaQueryWrapper<AssetEntity> queryWrapper = Wrappers.lambdaQuery();
 			LambdaQueryWrapper<AssetEntity> queryWrapper = Wrappers.lambdaQuery();
 			queryWrapper.eq(AssetEntity::getZcbm, excel.getZcbm());
 			queryWrapper.eq(AssetEntity::getZcbm, excel.getZcbm());
 			queryWrapper.eq(AssetEntity::getYearAndMonth, yearAndMonth);
 			queryWrapper.eq(AssetEntity::getYearAndMonth, yearAndMonth);
@@ -127,6 +127,9 @@ public class AssetServiceImpl extends BaseServiceImpl<AssetMapper, AssetEntity>
 				asset.setJcz(Math.min(asset.getJcz(), 1.0));
 				asset.setJcz(Math.min(asset.getJcz(), 1.0));
 			}
 			}
 			asset.setYsysm(getYsysm(yearAndMonth, asset.getKssj(), asset.getZclb()));
 			asset.setYsysm(getYsysm(yearAndMonth, asset.getKssj(), asset.getZclb()));
+//			if(asset.getYsysm() <=0){
+//				continue;
+//			}
 			AssetStatusEnum assetStatusEnum = Arrays.stream(AssetStatusEnum.values()).filter(temp -> temp.getName().equalsIgnoreCase(excel.getStatusName())).findFirst().orElse(AssetStatusEnum.正常);
 			AssetStatusEnum assetStatusEnum = Arrays.stream(AssetStatusEnum.values()).filter(temp -> temp.getName().equalsIgnoreCase(excel.getStatusName())).findFirst().orElse(AssetStatusEnum.正常);
 			asset.setStatus(assetStatusEnum.getCode());
 			asset.setStatus(assetStatusEnum.getCode());
 			this.save(asset);
 			this.save(asset);
@@ -136,6 +139,7 @@ public class AssetServiceImpl extends BaseServiceImpl<AssetMapper, AssetEntity>
 	@Transactional
 	@Transactional
 	@Override
 	@Override
 	public boolean fetchLastMonthData(AssetDTO zc) {
 	public boolean fetchLastMonthData(AssetDTO zc) {
+		AtomicInteger count = new AtomicInteger(0);
 		//查询上个月的数据
 		//查询上个月的数据
 		//得到上个月的年月
 		//得到上个月的年月
 		String lastDate = DateUtil.format(DateUtil.minusMonths(DateUtil.parse(zc.getYearAndMonth(), DateUtil.PATTERN_YYYYMM), 1), DateUtil.PATTERN_YYYYMM);
 		String lastDate = DateUtil.format(DateUtil.minusMonths(DateUtil.parse(zc.getYearAndMonth(), DateUtil.PATTERN_YYYYMM), 1), DateUtil.PATTERN_YYYYMM);
@@ -151,6 +155,10 @@ public class AssetServiceImpl extends BaseServiceImpl<AssetMapper, AssetEntity>
 //				throw new ServiceException("资产【" + temp.getZcbm() + "】已存在");
 //				throw new ServiceException("资产【" + temp.getZcbm() + "】已存在");
 				continue;
 				continue;
 			}
 			}
+
+			if (Arrays.asList(AssetStatusEnum.停用.getCode(), AssetStatusEnum.已足额折旧.getCode()).contains(temp.getStatus())) {
+				continue;
+			}
 			temp.setYearAndMonth(zc.getYearAndMonth());
 			temp.setYearAndMonth(zc.getYearAndMonth());
 			if (Func.equals(temp.getStatus(), AssetStatusEnum.正常.getCode())) {
 			if (Func.equals(temp.getStatus(), AssetStatusEnum.正常.getCode())) {
 				temp.setYsysm(getYsysm(temp.getYearAndMonth(), temp.getKssj(), temp.getZclb()));
 				temp.setYsysm(getYsysm(temp.getYearAndMonth(), temp.getKssj(), temp.getZclb()));
@@ -160,7 +168,12 @@ public class AssetServiceImpl extends BaseServiceImpl<AssetMapper, AssetEntity>
 				}
 				}
 			}
 			}
 			temp.setId(null);
 			temp.setId(null);
-			this.save(temp);
+			if (this.save(temp)) {
+				count.incrementAndGet();
+			}
+		}
+		if(count.get()==0){
+			throw new ServiceException("上个月无资产数据可读取");
 		}
 		}
 		return true;
 		return true;
 	}
 	}
@@ -325,17 +338,17 @@ public class AssetServiceImpl extends BaseServiceImpl<AssetMapper, AssetEntity>
 		return this.updateOtherMonthAsset(asset);
 		return this.updateOtherMonthAsset(asset);
 	}
 	}
 
 
-	private Integer getYsysm(String yearAndMonth, Date kssj, String zclb){
+	private Integer getYsysm(String yearAndMonth, Date kssj, String zclb) {
 		Date month = DateUtil.parse(yearAndMonth, DateUtil.PATTERN_YYYYMM);
 		Date month = DateUtil.parse(yearAndMonth, DateUtil.PATTERN_YYYYMM);
 		long ysysm = 0;
 		long ysysm = 0;
-		if(month.compareTo(kssj) >=0 || (cn.hutool.core.date.DateUtil.isSameMonth(month, kssj) && new Date().compareTo(kssj) >=0)){
+		if (month.compareTo(kssj) >= 0 || (cn.hutool.core.date.DateUtil.isSameMonth(month, kssj) && new Date().compareTo(kssj) >= 0)) {
 			//2025年01月-2024年5月 = 8个月
 			//2025年01月-2024年5月 = 8个月
 			ysysm = cn.hutool.core.date.DateUtil.betweenMonth(month, kssj, true);
 			ysysm = cn.hutool.core.date.DateUtil.betweenMonth(month, kssj, true);
 			if (!Func.equals("仪器设备", zclb)) {
 			if (!Func.equals("仪器设备", zclb)) {
 				ysysm++;
 				ysysm++;
 			}
 			}
 		}
 		}
-		return (int)ysysm;
+		return (int) ysysm;
 	}
 	}
 
 
 	public boolean updateOtherMonthAsset(AssetEntity asset) {
 	public boolean updateOtherMonthAsset(AssetEntity asset) {
@@ -353,7 +366,7 @@ public class AssetServiceImpl extends BaseServiceImpl<AssetMapper, AssetEntity>
 
 
 			if (Func.equals(entity.getStatus(), AssetStatusEnum.正常.getCode()) || Func.equals(entity.getStatus(), AssetStatusEnum.停用.getCode())) {
 			if (Func.equals(entity.getStatus(), AssetStatusEnum.正常.getCode()) || Func.equals(entity.getStatus(), AssetStatusEnum.停用.getCode())) {
 
 
-				updateEntity.setYsysm(getYsysm(entity.getYearAndMonth(), entity.getKssj(), entity.getZclb()));
+				updateEntity.setYsysm(getYsysm(entity.getYearAndMonth(), asset.getKssj(), entity.getZclb()));
 				//使用寿命-已使用月份数=0时,即已足额折旧
 				//使用寿命-已使用月份数=0时,即已足额折旧
 				if (updateEntity.getSysm() - updateEntity.getYsysm() <= 0) {
 				if (updateEntity.getSysm() - updateEntity.getYsysm() <= 0) {
 					updateEntity.setStatus(AssetStatusEnum.已足额折旧.getCode());
 					updateEntity.setStatus(AssetStatusEnum.已足额折旧.getCode());

+ 5 - 6
kd-service/kd-scientific/src/main/java/org/sky/scientific/service/impl/EnterpriseInfoServiceImpl.java

@@ -329,7 +329,7 @@ public class EnterpriseInfoServiceImpl extends BaseServiceImpl<EnterpriseInfoMap
 		param.setYearAndMonth(year + "12");
 		param.setYearAndMonth(year + "12");
 		List<XmFixedAsset> yiqishebeiList = fixedAssetMapper.selectXmFixedAssetPageByYearAndMonth(p2, param, AssetCategoryEnum.仪器设备.getCode());
 		List<XmFixedAsset> yiqishebeiList = fixedAssetMapper.selectXmFixedAssetPageByYearAndMonth(p2, param, AssetCategoryEnum.仪器设备.getCode());
 		for (XmFixedAsset asset : yiqishebeiList) {
 		for (XmFixedAsset asset : yiqishebeiList) {
-			vo.setD27(vo.getD7().add(asset.getAsset().getZcyz()));
+			vo.setD27(vo.getD7().add(asset.getAsset() != null ? asset.getAsset().getZcyz() : BigDecimal.ZERO));
 		}
 		}
 		vo.setD27(vo.getD27().setScale(2, RoundingMode.HALF_UP));
 		vo.setD27(vo.getD27().setScale(2, RoundingMode.HALF_UP));
 
 
@@ -405,7 +405,7 @@ public class EnterpriseInfoServiceImpl extends BaseServiceImpl<EnterpriseInfoMap
 		BigDecimal yiqishebeiTotal = BigDecimal.ZERO;
 		BigDecimal yiqishebeiTotal = BigDecimal.ZERO;
 		for (XmFixedAsset yiqishebei : yiqishebeiList) {
 		for (XmFixedAsset yiqishebei : yiqishebeiList) {
 			AssetEntity asset = yiqishebei.getAsset();
 			AssetEntity asset = yiqishebei.getAsset();
-			if (Func.equals(DateUtil.format(asset.getKssj(), DateUtil.PATTERN_YYYY), year)) {
+			if (asset != null && Func.equals(DateUtil.format(asset.getKssj(), DateUtil.PATTERN_YYYY), year)) {
 				yiqishebeiTotal = yiqishebeiTotal.add(asset.getZcyz());
 				yiqishebeiTotal = yiqishebeiTotal.add(asset.getZcyz());
 			}
 			}
 		}
 		}
@@ -413,11 +413,10 @@ public class EnterpriseInfoServiceImpl extends BaseServiceImpl<EnterpriseInfoMap
 		BigDecimal fangwujianzhuwuTotal = BigDecimal.ZERO;
 		BigDecimal fangwujianzhuwuTotal = BigDecimal.ZERO;
 		for (XmFixedAsset fangwujianzhuwu : fangwujianzhuwuList) {
 		for (XmFixedAsset fangwujianzhuwu : fangwujianzhuwuList) {
 			AssetEntity asset = fangwujianzhuwu.getAsset();
 			AssetEntity asset = fangwujianzhuwu.getAsset();
-			if (Func.equals(DateUtil.format(asset.getKssj(), DateUtil.PATTERN_YYYY), year)) {
+			if (asset != null && Func.equals(DateUtil.format(asset.getKssj(), DateUtil.PATTERN_YYYY), year)) {
 				yiqishebeiTotal = fangwujianzhuwuTotal.add(asset.getZcyz());
 				yiqishebeiTotal = fangwujianzhuwuTotal.add(asset.getZcyz());
 			}
 			}
 		}
 		}
-
 		vo.setD20(fangwujianzhuwuTotal.add(yiqishebeiTotal).multiply(new BigDecimal("0.001")).setScale(2, RoundingMode.HALF_UP));
 		vo.setD20(fangwujianzhuwuTotal.add(yiqishebeiTotal).multiply(new BigDecimal("0.001")).setScale(2, RoundingMode.HALF_UP));
 		// d21 其中:仪器和设备
 		// d21 其中:仪器和设备
 		vo.setD21(yiqishebeiTotal.multiply(new BigDecimal("0.001")).setScale(2, RoundingMode.HALF_UP));
 		vo.setD21(yiqishebeiTotal.multiply(new BigDecimal("0.001")).setScale(2, RoundingMode.HALF_UP));
@@ -1024,7 +1023,7 @@ public class EnterpriseInfoServiceImpl extends BaseServiceImpl<EnterpriseInfoMap
 		BigDecimal yiqishebeiTotal = BigDecimal.ZERO;
 		BigDecimal yiqishebeiTotal = BigDecimal.ZERO;
 		for (XmFixedAsset yiqishebei : yiqishebeiList) {
 		for (XmFixedAsset yiqishebei : yiqishebeiList) {
 			AssetEntity asset = yiqishebei.getAsset();
 			AssetEntity asset = yiqishebei.getAsset();
-			if (Func.equals(DateUtil.format(asset.getKssj(), DateUtil.PATTERN_YYYY), year)) {
+			if (asset != null && Func.equals(DateUtil.format(asset.getKssj(), DateUtil.PATTERN_YYYY), year)) {
 				yiqishebeiTotal = yiqishebeiTotal.add(asset.getZcyz());
 				yiqishebeiTotal = yiqishebeiTotal.add(asset.getZcyz());
 			}
 			}
 		}
 		}
@@ -1032,7 +1031,7 @@ public class EnterpriseInfoServiceImpl extends BaseServiceImpl<EnterpriseInfoMap
 		BigDecimal fangwujianzhuwuTotal = BigDecimal.ZERO;
 		BigDecimal fangwujianzhuwuTotal = BigDecimal.ZERO;
 		for (XmFixedAsset fangwujianzhuwu : fangwujianzhuwuList) {
 		for (XmFixedAsset fangwujianzhuwu : fangwujianzhuwuList) {
 			AssetEntity asset = fangwujianzhuwu.getAsset();
 			AssetEntity asset = fangwujianzhuwu.getAsset();
-			if (Func.equals(DateUtil.format(asset.getKssj(), DateUtil.PATTERN_YYYY), year)) {
+			if (asset != null && Func.equals(DateUtil.format(asset.getKssj(), DateUtil.PATTERN_YYYY), year)) {
 				yiqishebeiTotal = fangwujianzhuwuTotal.add(asset.getZcyz());
 				yiqishebeiTotal = fangwujianzhuwuTotal.add(asset.getZcyz());
 			}
 			}
 		}
 		}