|
|
@@ -115,7 +115,7 @@ public class AssetServiceImpl extends BaseServiceImpl<AssetMapper, AssetEntity>
|
|
|
}
|
|
|
idenfifierList.add(identifier);
|
|
|
asset.setYearAndMonth(yearAndMonth);
|
|
|
- //yearAndMonth 是否存在该物资
|
|
|
+ //yearAndMonth 是否存在该资产
|
|
|
LambdaQueryWrapper<AssetEntity> queryWrapper = Wrappers.lambdaQuery();
|
|
|
queryWrapper.eq(AssetEntity::getZcbm, excel.getZcbm());
|
|
|
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.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.正常);
|
|
|
asset.setStatus(assetStatusEnum.getCode());
|
|
|
this.save(asset);
|
|
|
@@ -136,6 +139,7 @@ public class AssetServiceImpl extends BaseServiceImpl<AssetMapper, AssetEntity>
|
|
|
@Transactional
|
|
|
@Override
|
|
|
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);
|
|
|
@@ -151,6 +155,10 @@ public class AssetServiceImpl extends BaseServiceImpl<AssetMapper, AssetEntity>
|
|
|
// throw new ServiceException("资产【" + temp.getZcbm() + "】已存在");
|
|
|
continue;
|
|
|
}
|
|
|
+
|
|
|
+ if (Arrays.asList(AssetStatusEnum.停用.getCode(), AssetStatusEnum.已足额折旧.getCode()).contains(temp.getStatus())) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
temp.setYearAndMonth(zc.getYearAndMonth());
|
|
|
if (Func.equals(temp.getStatus(), AssetStatusEnum.正常.getCode())) {
|
|
|
temp.setYsysm(getYsysm(temp.getYearAndMonth(), temp.getKssj(), temp.getZclb()));
|
|
|
@@ -160,7 +168,12 @@ public class AssetServiceImpl extends BaseServiceImpl<AssetMapper, AssetEntity>
|
|
|
}
|
|
|
}
|
|
|
temp.setId(null);
|
|
|
- this.save(temp);
|
|
|
+ if (this.save(temp)) {
|
|
|
+ count.incrementAndGet();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(count.get()==0){
|
|
|
+ throw new ServiceException("上个月无资产数据可读取");
|
|
|
}
|
|
|
return true;
|
|
|
}
|
|
|
@@ -325,17 +338,17 @@ public class AssetServiceImpl extends BaseServiceImpl<AssetMapper, AssetEntity>
|
|
|
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);
|
|
|
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个月
|
|
|
ysysm = cn.hutool.core.date.DateUtil.betweenMonth(month, kssj, true);
|
|
|
if (!Func.equals("仪器设备", zclb)) {
|
|
|
ysysm++;
|
|
|
}
|
|
|
}
|
|
|
- return (int)ysysm;
|
|
|
+ return (int) ysysm;
|
|
|
}
|
|
|
|
|
|
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())) {
|
|
|
|
|
|
- updateEntity.setYsysm(getYsysm(entity.getYearAndMonth(), entity.getKssj(), entity.getZclb()));
|
|
|
+ updateEntity.setYsysm(getYsysm(entity.getYearAndMonth(), asset.getKssj(), entity.getZclb()));
|
|
|
//使用寿命-已使用月份数=0时,即已足额折旧
|
|
|
if (updateEntity.getSysm() - updateEntity.getYsysm() <= 0) {
|
|
|
updateEntity.setStatus(AssetStatusEnum.已足额折旧.getCode());
|