huminmin
6 天以前 a723ddd9b7cfefc94af4f15c1f9f30e59cd38ecc
src/main/java/com/ruoyi/device/service/impl/DeviceLedgerServiceImpl.java
@@ -13,7 +13,7 @@
import com.ruoyi.device.mapper.DeviceLedgerMapper;
import com.ruoyi.device.pojo.DeviceLedger;
import com.ruoyi.device.service.IDeviceLedgerService;
import com.ruoyi.framework.web.domain.R;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.project.system.domain.SysUser;
import com.ruoyi.project.system.mapper.SysUserMapper;
import jakarta.servlet.http.HttpServletResponse;
@@ -44,25 +44,25 @@
    }
    @Override
    public R<?> saveDeviceLedger(DeviceLedger deviceLedger) {
    public AjaxResult saveDeviceLedger(DeviceLedger deviceLedger) {
        LambdaQueryWrapper<DeviceLedger> deviceLedgerLambdaQueryWrapper = new LambdaQueryWrapper<>();
        deviceLedgerLambdaQueryWrapper.eq(DeviceLedger::getDeviceName,deviceLedger.getDeviceName());
        if (this.count(deviceLedgerLambdaQueryWrapper) > 0) {
            return R.fail("设备名称已存在");
            return AjaxResult.error("设备名称已存在");
        }
        boolean save = this.save(deviceLedger);
        if (save){
            return R.ok();
            return AjaxResult.success();
        }
        return R.fail();
        return AjaxResult.error();
    }
    @Override
    public R<?> updateDeviceLedger(DeviceLedger deviceLedger) {
    public AjaxResult updateDeviceLedger(DeviceLedger deviceLedger) {
        if (this.updateById(deviceLedger)) {
            return R.ok();
            return AjaxResult.success();
        }
        return R.fail();
        return AjaxResult.error();
    }
    @Override
@@ -116,7 +116,10 @@
            deviceLedger.setTaxIncludingPriceTotal(c.getTaxIncludingPriceUnit());
            deviceLedger.setNumber(BigDecimal.ONE);
            deviceLedger.setPlanRuntimeTime(DateUtils.toLocalDate(c.getPlanRuntimeTime()));
            deviceLedger.setUnTaxIncludingPriceTotal(deviceLedger.getTaxIncludingPriceTotal().divide(BigDecimal.ONE.add(c.getTaxRate()),2, RoundingMode.HALF_UP));
            // 计算不含税总价,处理空值情况
            if (deviceLedger.getTaxIncludingPriceTotal() != null && c.getTaxRate() != null) {
                deviceLedger.setUnTaxIncludingPriceTotal(deviceLedger.getTaxIncludingPriceTotal().divide(BigDecimal.ONE.add(c.getTaxRate()), 2, RoundingMode.HALF_UP));
            }
            deviceLedgerMapper.insert(deviceLedger);
        });