鞍钢鲅鱼圈能源管控系统后端代码
liriming
2025-05-22 5afaa78542e9e78346696e4f683f49b7f60bd288
ansteel-biz/src/main/java/com/iailab/module/ansteel/power/service/impl/PowerPriceMainServiceImpl.java
@@ -81,4 +81,28 @@
        }
        return true;
    }
    @Override
    @Transactional(rollbackFor = Exception.class)
    public Boolean update(PowerPriceMainDTO mainDTO) {
        if (!CollectionUtils.isEmpty(mainDTO.getDetList())) {
            PowerPriceMainEntity powerPriceMainEntity = powerPriceMainDao.selectById(mainDTO.getId());
            powerPriceMainEntity.setCreator(SecurityFrameworkUtils.getLoginUser().getId());
            powerPriceMainEntity.setCreateDate(new Date());
            powerPriceMainDao.updateById(powerPriceMainEntity);
            QueryWrapper queryWrapper = new QueryWrapper<>();
            queryWrapper.eq("main_id", powerPriceMainEntity.getId());
            powerPriceDetDao.delete(queryWrapper);
            for (int i = 0; i < mainDTO.getDetList().size(); i++) {
                PowerPriceDetEntity powerPriceDetEntity = ConvertUtils.sourceToTarget(mainDTO.getDetList().get(i), PowerPriceDetEntity.class);
                powerPriceDetEntity.setMainId(powerPriceMainEntity.getId());
                powerPriceDetEntity.setSort(i + 1);
                powerPriceDetDao.insert(powerPriceDetEntity);
            }
        }
        return true;
    }
}