|
@@ -19,6 +19,7 @@ import org.sky.core.mp.support.Condition;
|
|
|
import org.sky.core.mp.support.Query;
|
|
import org.sky.core.mp.support.Query;
|
|
|
import org.sky.core.secure.utils.SecureUtil;
|
|
import org.sky.core.secure.utils.SecureUtil;
|
|
|
import org.sky.core.tool.utils.*;
|
|
import org.sky.core.tool.utils.*;
|
|
|
|
|
+import org.sky.scientific.e.AssetStatusEnum;
|
|
|
import org.sky.scientific.excel.AssetExcel;
|
|
import org.sky.scientific.excel.AssetExcel;
|
|
|
import org.sky.scientific.mapper.AssetMapper;
|
|
import org.sky.scientific.mapper.AssetMapper;
|
|
|
import org.sky.scientific.pojo.dto.AssetDTO;
|
|
import org.sky.scientific.pojo.dto.AssetDTO;
|
|
@@ -37,6 +38,7 @@ import java.io.InputStream;
|
|
|
import java.math.BigDecimal;
|
|
import java.math.BigDecimal;
|
|
|
import java.math.RoundingMode;
|
|
import java.math.RoundingMode;
|
|
|
import java.net.URLEncoder;
|
|
import java.net.URLEncoder;
|
|
|
|
|
+import java.util.Arrays;
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
import java.util.Objects;
|
|
import java.util.Objects;
|
|
|
import java.util.concurrent.atomic.AtomicInteger;
|
|
import java.util.concurrent.atomic.AtomicInteger;
|
|
@@ -94,6 +96,7 @@ public class AssetServiceImpl extends BaseServiceImpl<AssetMapper, AssetEntity>
|
|
|
|
|
|
|
|
for (AssetExcel excel : data) {
|
|
for (AssetExcel excel : data) {
|
|
|
AssetEntity zc = Objects.requireNonNull(BeanUtil.copyProperties(excel, AssetDTO.class));
|
|
AssetEntity zc = Objects.requireNonNull(BeanUtil.copyProperties(excel, AssetDTO.class));
|
|
|
|
|
+
|
|
|
zc.setYearAndMonth(yearAndMonth);
|
|
zc.setYearAndMonth(yearAndMonth);
|
|
|
//yearAndMonth 是否存在该物资
|
|
//yearAndMonth 是否存在该物资
|
|
|
LambdaQueryWrapper<AssetEntity> queryWrapper = Wrappers.lambdaQuery();
|
|
LambdaQueryWrapper<AssetEntity> queryWrapper = Wrappers.lambdaQuery();
|
|
@@ -102,6 +105,9 @@ public class AssetServiceImpl extends BaseServiceImpl<AssetMapper, AssetEntity>
|
|
|
if (this.count(queryWrapper) > 0) {
|
|
if (this.count(queryWrapper) > 0) {
|
|
|
throw new ServiceException("资产编号【" + excel.getZcbm() + "】已存在");
|
|
throw new ServiceException("资产编号【" + excel.getZcbm() + "】已存在");
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ int status = AssetStatusEnum.valueOf(excel.getStatusName()).getCode();
|
|
|
|
|
+ zc.setStatus(status);
|
|
|
this.save(zc);
|
|
this.save(zc);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -118,25 +124,22 @@ public class AssetServiceImpl extends BaseServiceImpl<AssetMapper, AssetEntity>
|
|
|
throw new ServiceException("上个月资产数据为空");
|
|
throw new ServiceException("上个月资产数据为空");
|
|
|
}
|
|
}
|
|
|
//与本月数据对比,去重后保存至数据库
|
|
//与本月数据对比,去重后保存至数据库
|
|
|
-// Integer okCount = 0;
|
|
|
|
|
for (AssetEntity temp : lastMonthDataList) {
|
|
for (AssetEntity temp : lastMonthDataList) {
|
|
|
LambdaQueryWrapper<AssetEntity> qw = Wrappers.<AssetEntity>lambdaQuery().eq(AssetEntity::getZcbm, temp.getZcbm()).eq(AssetEntity::getYearAndMonth, zc.getYearAndMonth());
|
|
LambdaQueryWrapper<AssetEntity> qw = Wrappers.<AssetEntity>lambdaQuery().eq(AssetEntity::getZcbm, temp.getZcbm()).eq(AssetEntity::getYearAndMonth, zc.getYearAndMonth());
|
|
|
if (this.baseMapper.selectCount(qw) > 0) {
|
|
if (this.baseMapper.selectCount(qw) > 0) {
|
|
|
throw new ServiceException("资产【" + temp.getZcbm() + "】已存在");
|
|
throw new ServiceException("资产【" + temp.getZcbm() + "】已存在");
|
|
|
-// log.info("资产【{}】已存在, 年月【{}】", temp.getZcbm(), zc.getYearAndMonth());
|
|
|
|
|
-// continue;
|
|
|
|
|
- } else {
|
|
|
|
|
-// okCount++;
|
|
|
|
|
- temp.setYearAndMonth(zc.getYearAndMonth());
|
|
|
|
|
-
|
|
|
|
|
|
|
+ }
|
|
|
|
|
+ temp.setYearAndMonth(zc.getYearAndMonth());
|
|
|
|
|
+ if (Func.equals(temp.getStatus(), AssetStatusEnum.正常.getCode())) {
|
|
|
temp.setYsysm(Func.toInt(temp.getYsysm(), 0) + 1);
|
|
temp.setYsysm(Func.toInt(temp.getYsysm(), 0) + 1);
|
|
|
//使用寿命-已使用月份数=0时,即已足额折旧
|
|
//使用寿命-已使用月份数=0时,即已足额折旧
|
|
|
- temp.setStatus((temp.getSysm() - temp.getYsysm() <= 0) ? 2 : 0);
|
|
|
|
|
- temp.setId(null);
|
|
|
|
|
- this.save(temp);
|
|
|
|
|
|
|
+ if (temp.getSysm() - temp.getYsysm() <= 0) {
|
|
|
|
|
+ temp.setStatus(AssetStatusEnum.已足额折旧.getCode());
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
+ temp.setId(null);
|
|
|
|
|
+ this.save(temp);
|
|
|
}
|
|
}
|
|
|
-// log.info("{}共{}个资产,成功导入【{}】条数据", lastDate, lastMonthDataList.size(), okCount);
|
|
|
|
|
return true;
|
|
return true;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -227,30 +230,91 @@ public class AssetServiceImpl extends BaseServiceImpl<AssetMapper, AssetEntity>
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
public boolean updateAsset(AssetEntity asset) {
|
|
public boolean updateAsset(AssetEntity asset) {
|
|
|
- if(Func.isNull(asset.getId())){
|
|
|
|
|
|
|
+ if (Func.isNull(asset.getId())) {
|
|
|
throw new ServiceException("参数id不能为空");
|
|
throw new ServiceException("参数id不能为空");
|
|
|
}
|
|
}
|
|
|
LambdaQueryWrapper<AssetEntity> qw = Wrappers.<AssetEntity>lambdaQuery().eq(AssetEntity::getZcbm, asset.getZcbm()).eq(AssetEntity::getYearAndMonth, asset.getYearAndMonth());
|
|
LambdaQueryWrapper<AssetEntity> qw = Wrappers.<AssetEntity>lambdaQuery().eq(AssetEntity::getZcbm, asset.getZcbm()).eq(AssetEntity::getYearAndMonth, asset.getYearAndMonth());
|
|
|
AssetEntity dbAsset = this.getOne(qw);
|
|
AssetEntity dbAsset = this.getOne(qw);
|
|
|
- if (dbAsset != null && Func.equals(dbAsset.getZcbm(), asset.getZcbm()) && !Func.equals(dbAsset.getId(), asset.getId())) {
|
|
|
|
|
|
|
+ if (Func.isNull(dbAsset)) {
|
|
|
|
|
+ throw new ServiceException("资产不存在");
|
|
|
|
|
+ }
|
|
|
|
|
+ if (Func.equals(dbAsset.getZcbm(), asset.getZcbm()) && !Func.equals(dbAsset.getId(), asset.getId())) {
|
|
|
throw new ServiceException("资产【" + asset.getZcbm() + "】已存在");
|
|
throw new ServiceException("资产【" + asset.getZcbm() + "】已存在");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- //使用寿命-已使用月份数=0时,即已足额折旧
|
|
|
|
|
|
|
+// 正常状态、停用状态,可修改资产数据。其他情况不能修改。假设在修改资产时,正好出现使用寿命-已使用月份数=0时,即已足额折旧状态时,就显示为已足额折旧状态了,不可以再次修改了。
|
|
|
|
|
+// 修改资产时,系统需要二次确认。
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ if (Func.equals(dbAsset.getStatus(), AssetStatusEnum.正常.getCode()) || Func.equals(dbAsset.getStatus(), AssetStatusEnum.停用.getCode())) {
|
|
|
|
|
+ if (Func.isNull(asset.getYsysm())) {
|
|
|
|
|
+ //使用寿命-已使用月份数=0时,即已足额折旧
|
|
|
// 仪器设置的算法:当前时间为2025年01月-2024年5月,差额为9个月,因为折旧从次月开始,所以已使用月数为8个月(即9-1=8),再将使用寿命-已使用月份数=0时,即已足额折旧。
|
|
// 仪器设置的算法:当前时间为2025年01月-2024年5月,差额为9个月,因为折旧从次月开始,所以已使用月数为8个月(即9-1=8),再将使用寿命-已使用月份数=0时,即已足额折旧。
|
|
|
// 无形资产:当月即摊销,不需要-1
|
|
// 无形资产:当月即摊销,不需要-1
|
|
|
-
|
|
|
|
|
- if(Func.isNull(asset.getYsysm())){
|
|
|
|
|
- long ysysm = cn.hutool.core.date.DateUtil.betweenMonth(cn.hutool.core.date.DateUtil.date(), asset.getKssj(), false);
|
|
|
|
|
|
|
+ long ysysm = cn.hutool.core.date.DateUtil.betweenMonth(cn.hutool.core.date.DateUtil.date(), asset.getKssj(), false);
|
|
|
// 这里
|
|
// 这里
|
|
|
- if (!Func.equals("仪器设备", asset.getZclb())) {
|
|
|
|
|
- ysysm++;
|
|
|
|
|
|
|
+ if (!Func.equals("仪器设备", asset.getZclb())) {
|
|
|
|
|
+ ysysm++;
|
|
|
|
|
+ }
|
|
|
|
|
+ asset.setYsysm((int) ysysm);
|
|
|
|
|
+ }
|
|
|
|
|
+ if (asset.getSysm() - asset.getYsysm() <= 0) {
|
|
|
|
|
+ asset.setStatus(AssetStatusEnum.已足额折旧.getCode());
|
|
|
}
|
|
}
|
|
|
- asset.setYsysm((int) ysysm);
|
|
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
- asset.setStatus((asset.getSysm() - asset.getYsysm() <= 0) ? 2 : 0);
|
|
|
|
|
return this.updateById(asset);
|
|
return this.updateById(asset);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public boolean updateStatus(AssetEntity asset) {
|
|
|
|
|
+ if (asset.getId() == null) {
|
|
|
|
|
+ throw new ServiceException("参数assetId不能为空");
|
|
|
|
|
+ }
|
|
|
|
|
+ if (Func.isNull(asset.getStatus())) {
|
|
|
|
|
+ throw new ServiceException("参数status不能为空");
|
|
|
|
|
+ }
|
|
|
|
|
+ AssetEntity dbAsset = baseMapper.selectById(asset.getId());
|
|
|
|
|
+ if (Func.isNull(dbAsset)) {
|
|
|
|
|
+ throw new ServiceException("资产不存在");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (List.of("仪器设备", "房屋建筑物").contains(dbAsset.getZclb())) {
|
|
|
|
|
+ throw new ServiceException("只有固定资产才能改造");
|
|
|
|
|
+ }
|
|
|
|
|
+// String name = AssetStatusEnum.改造.name();
|
|
|
|
|
+// ① 正常状态:表示正常使用中;正常折旧,已使用寿命/月数累加。可进行“改造”、“停用”、“资产处置”。
|
|
|
|
|
+// ② 停用状态:表示停止使用状态;虽然停用,但是正常折旧,已使用寿命/月数继续累加。停用后,可点击“恢复”恢复为正常状态。可进行“改造”、“资产处置”。
|
|
|
|
|
+// ③ 改造状态:表示改造中,改造期已使用寿命/月数/折旧为“全部暂停”状态。改造完成,需点击“恢复按钮”,恢复时需对资产内容进行修改完成。恢复为正常状态。
|
|
|
|
|
+// ④ 已足额折扣状态:按照使用寿命,全部折旧完毕;不可以进行操作;后续不再提折旧。不再使用,不再显示。
|
|
|
|
|
+// ⑤ 资产处理状态:表示资产已被转让、报废、捐赠或其他处理等;不可以进行操作;后续不属于企业 ,不再计提折旧,不能再使用。
|
|
|
|
|
+// ⑥ /:表示无操作
|
|
|
|
|
+// ⑦ 注意,资产总表涉及资产明细统计,需进行相应的处理
|
|
|
|
|
+ if (Func.equals(dbAsset.getStatus(), AssetStatusEnum.已足额折旧.getCode())) {
|
|
|
|
|
+ throw new ServiceException("该资产已足额折旧");
|
|
|
|
|
+ }
|
|
|
|
|
+ if (Func.equals(dbAsset.getStatus(), AssetStatusEnum.资产处置.getCode())) {
|
|
|
|
|
+ throw new ServiceException("该资产已处置");
|
|
|
|
|
+ }
|
|
|
|
|
+ if (Func.equals(AssetStatusEnum.正常.getCode(), dbAsset.getStatus())) {
|
|
|
|
|
+ //① 正常状态:表示正常使用中;正常折旧,已使用寿命/月数累加。可进行“改造”、“停用”、“资产处置”。
|
|
|
|
|
+
|
|
|
|
|
+ if (!Arrays.asList(AssetStatusEnum.改造.getCode(), AssetStatusEnum.停用.getCode(), AssetStatusEnum.资产处置.getCode()).contains(asset.getStatus())) {
|
|
|
|
|
+ throw new ServiceException("状态为正常的资产,可进行改造、停用、资产处置操作");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ } else if (Func.equals(AssetStatusEnum.停用.getCode(), dbAsset.getStatus())) {
|
|
|
|
|
+ //② 停用状态:表示停止使用状态;虽然停用,但是正常折旧,已使用寿命/月数继续累加。停用后,可点击“恢复”恢复为正常状态。可进行“改造”、“资产处置”。
|
|
|
|
|
+ if (!Arrays.asList(AssetStatusEnum.改造.getCode(), AssetStatusEnum.资产处置.getCode(), AssetStatusEnum.正常.getCode()).contains(asset.getStatus())) {
|
|
|
|
|
+ throw new ServiceException("状态为停用的资产,可进行改造、恢复、资产处置操作");
|
|
|
|
|
+ }
|
|
|
|
|
+ } else if (Func.equals(AssetStatusEnum.改造.getCode(), dbAsset.getStatus())) {
|
|
|
|
|
+ //改造状态:表示改造中,改造期已使用寿命/月数/折旧为“全部暂停”状态。改造完成,需点击“恢复按钮”,恢复时需对资产内容进行修改完成。恢复为正常状态。
|
|
|
|
|
+ if (!List.of(AssetStatusEnum.正常.getCode()).contains(asset.getStatus())) {
|
|
|
|
|
+ throw new ServiceException("状态为改造的资产,可进行恢复操作");
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return baseMapper.updateStatus(asset.getId(), asset.getStatus()) == 1;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
}
|
|
}
|