|
|
@@ -87,13 +87,14 @@ public class AssetServiceImpl extends BaseServiceImpl<AssetMapper, AssetEntity>
|
|
|
//使用寿命-已使用月份数=0时,即已足额折旧
|
|
|
// 仪器设置的算法:当前时间为2025年01月-2024年5月,差额为9个月,因为折旧从次月开始,所以已使用月数为8个月(即9-1=8),再将使用寿命-已使用月份数=0时,即已足额折旧。
|
|
|
// 无形资产:当月即摊销,不需要-1
|
|
|
+//
|
|
|
+// long ysysm = cn.hutool.core.date.DateUtil.betweenMonth(DateUtil.parse(asset.getYearAndMonth(), DateUtil.PATTERN_YYYYMM), asset.getKssj(), true);
|
|
|
+//// 这里
|
|
|
+// if (!isFixedAsset(asset.getZclb())) {
|
|
|
+// ysysm++;
|
|
|
+// }
|
|
|
+ asset.setYsysm(getYsysm(asset.getYearAndMonth(), asset.getKssj(), asset.getZclb()));
|
|
|
|
|
|
- long ysysm = cn.hutool.core.date.DateUtil.betweenMonth(DateUtil.parse(asset.getYearAndMonth(), DateUtil.PATTERN_YYYYMM), asset.getKssj(), true);
|
|
|
-// 这里
|
|
|
- if (!isFixedAsset(asset.getZclb())) {
|
|
|
- ysysm++;
|
|
|
- }
|
|
|
- asset.setYsysm((int) ysysm);
|
|
|
asset.setStatus((asset.getSysm() - asset.getYsysm() <= 0) ? AssetStatusEnum.已足额折旧.getCode() : AssetStatusEnum.正常.getCode());
|
|
|
return this.save(asset);
|
|
|
}
|
|
|
@@ -107,13 +108,13 @@ public class AssetServiceImpl extends BaseServiceImpl<AssetMapper, AssetEntity>
|
|
|
List<String> idenfifierList = new ArrayList<>(dbAssetList.stream().map(tmp -> tmp.getZcbm() + ":" + tmp.getZcmc()).toList());
|
|
|
|
|
|
for (AssetExcel excel : data) {
|
|
|
- AssetEntity zc = Objects.requireNonNull(BeanUtil.copyProperties(excel, AssetDTO.class));
|
|
|
+ AssetEntity asset = Objects.requireNonNull(BeanUtil.copyProperties(excel, AssetDTO.class));
|
|
|
String identifier = excel.getZcbm() + ":" + excel.getZcmc();
|
|
|
if (idenfifierList.contains(identifier)) {
|
|
|
throw new ServiceException("数据已存在,导入失败!");
|
|
|
}
|
|
|
idenfifierList.add(identifier);
|
|
|
- zc.setYearAndMonth(yearAndMonth);
|
|
|
+ asset.setYearAndMonth(yearAndMonth);
|
|
|
//yearAndMonth 是否存在该物资
|
|
|
LambdaQueryWrapper<AssetEntity> queryWrapper = Wrappers.lambdaQuery();
|
|
|
queryWrapper.eq(AssetEntity::getZcbm, excel.getZcbm());
|
|
|
@@ -122,13 +123,13 @@ public class AssetServiceImpl extends BaseServiceImpl<AssetMapper, AssetEntity>
|
|
|
// throw new ServiceException("资产编号【" + excel.getZcbm() + "】已存在");
|
|
|
continue;
|
|
|
}
|
|
|
-
|
|
|
- if (Func.notNull(zc.getJcz())) {
|
|
|
- zc.setJcz(Math.min(zc.getJcz(), 1.0));
|
|
|
+ if (Func.notNull(asset.getJcz())) {
|
|
|
+ asset.setJcz(Math.min(asset.getJcz(), 1.0));
|
|
|
}
|
|
|
+ asset.setYsysm(getYsysm(yearAndMonth, asset.getKssj(), asset.getZclb()));
|
|
|
AssetStatusEnum assetStatusEnum = Arrays.stream(AssetStatusEnum.values()).filter(temp -> temp.getName().equalsIgnoreCase(excel.getStatusName())).findFirst().orElse(AssetStatusEnum.正常);
|
|
|
- zc.setStatus(assetStatusEnum.getCode());
|
|
|
- this.save(zc);
|
|
|
+ asset.setStatus(assetStatusEnum.getCode());
|
|
|
+ this.save(asset);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -152,7 +153,7 @@ public class AssetServiceImpl extends BaseServiceImpl<AssetMapper, AssetEntity>
|
|
|
}
|
|
|
temp.setYearAndMonth(zc.getYearAndMonth());
|
|
|
if (Func.equals(temp.getStatus(), AssetStatusEnum.正常.getCode())) {
|
|
|
- temp.setYsysm(Func.toInt(temp.getYsysm(), 0) + 1);
|
|
|
+ temp.setYsysm(getYsysm(temp.getYearAndMonth(), temp.getKssj(), temp.getZclb()));
|
|
|
//使用寿命-已使用月份数=0时,即已足额折旧
|
|
|
if (temp.getSysm() - temp.getYsysm() <= 0) {
|
|
|
temp.setStatus(AssetStatusEnum.已足额折旧.getCode());
|
|
|
@@ -324,6 +325,19 @@ public class AssetServiceImpl extends BaseServiceImpl<AssetMapper, AssetEntity>
|
|
|
return this.updateOtherMonthAsset(asset);
|
|
|
}
|
|
|
|
|
|
+ private Integer getYsysm(String yearAndMonth, Date kssj, String zclb){
|
|
|
+ Date month = DateUtil.parse(yearAndMonth, DateUtil.PATTERN_YYYYMM);
|
|
|
+ long ysysm = 0;
|
|
|
+ if(month.compareTo(kssj) >=0 || (cn.hutool.core.date.DateUtil.isSameMonth(month, kssj) && new Date().compareTo(kssj) >=0)){
|
|
|
+ //2025年01月-2024年5月 = 8个月
|
|
|
+ ysysm = cn.hutool.core.date.DateUtil.betweenMonth(month, kssj, true);
|
|
|
+ if (!Func.equals("仪器设备", zclb)) {
|
|
|
+ ysysm++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return (int)ysysm;
|
|
|
+ }
|
|
|
+
|
|
|
public boolean updateOtherMonthAsset(AssetEntity asset) {
|
|
|
LambdaQueryWrapper<AssetEntity> queryWrapper = Wrappers.<AssetEntity>lambdaQuery()
|
|
|
.eq(AssetEntity::getZcbm, asset.getZcbm()).ge(AssetEntity::getYearAndMonth, asset.getYearAndMonth());
|
|
|
@@ -338,12 +352,8 @@ public class AssetServiceImpl extends BaseServiceImpl<AssetMapper, AssetEntity>
|
|
|
updateEntity.setZgs(null);
|
|
|
|
|
|
if (Func.equals(entity.getStatus(), AssetStatusEnum.正常.getCode()) || Func.equals(entity.getStatus(), AssetStatusEnum.停用.getCode())) {
|
|
|
- long ysysm = cn.hutool.core.date.DateUtil.betweenMonth(DateUtil.parse(entity.getYearAndMonth(), DateUtil.PATTERN_YYYYMM), asset.getKssj(), true);
|
|
|
- if (!Func.equals("仪器设备", updateEntity.getZclb())) {
|
|
|
- ysysm++;
|
|
|
- }
|
|
|
- updateEntity.setYsysm((int) ysysm);
|
|
|
|
|
|
+ updateEntity.setYsysm(getYsysm(entity.getYearAndMonth(), entity.getKssj(), entity.getZclb()));
|
|
|
//使用寿命-已使用月份数=0时,即已足额折旧
|
|
|
if (updateEntity.getSysm() - updateEntity.getYsysm() <= 0) {
|
|
|
updateEntity.setStatus(AssetStatusEnum.已足额折旧.getCode());
|