| | |
| | | import com.ruoyi.common.utils.SecurityUtils; |
| | | import com.ruoyi.common.utils.bean.BeanUtils; |
| | | import com.ruoyi.common.utils.poi.ExcelUtil; |
| | | import com.ruoyi.device.dto.DeviceAssetInfoDto; |
| | | import com.ruoyi.device.dto.DeviceLedgerDto; |
| | | import com.ruoyi.device.execl.DeviceLedgerExeclDto; |
| | | import com.ruoyi.device.mapper.DeviceLedgerMapper; |
| | |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.io.IOException; |
| | | import java.math.BigDecimal; |
| | | import java.time.ZoneOffset; |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | |
| | | @Override |
| | | public AjaxResult saveDeviceLedger(DeviceLedger deviceLedger) { |
| | | LambdaQueryWrapper<DeviceLedger> deviceLedgerLambdaQueryWrapper = new LambdaQueryWrapper<>(); |
| | | deviceLedgerLambdaQueryWrapper.eq(DeviceLedger::getDeviceModel,deviceLedger.getDeviceModel()); |
| | | deviceLedgerLambdaQueryWrapper.eq(DeviceLedger::getDeviceName,deviceLedger.getDeviceName()); |
| | | if (this.count(deviceLedgerLambdaQueryWrapper) > 0) { |
| | | return AjaxResult.error("设备型号已存在"); |
| | | return AjaxResult.error("设备名称已存在"); |
| | | } |
| | | boolean save = this.save(deviceLedger); |
| | | if (save){ |
| | |
| | | |
| | | @Override |
| | | public AjaxResult updateDeviceLedger(DeviceLedger deviceLedger) { |
| | | if (ObjectUtils.isNotNull(deviceLedger.getStartRuntimeTime()) && ObjectUtils.isNotNull(deviceLedger.getEndRuntimeTime())){ |
| | | //计算运行时长 |
| | | long start = deviceLedger.getStartRuntimeTime().toEpochSecond(ZoneOffset.UTC) * 1000; |
| | | long end = deviceLedger.getEndRuntimeTime().toEpochSecond(ZoneOffset.UTC) * 1000; |
| | | long diffMillis = Math.abs(end - start); |
| | | double time = diffMillis / (1000.0 * 60 * 60);// 毫秒 -> 秒 -> 分钟 -> 小时 |
| | | deviceLedger.setRuntimeDuration(time+"h"); |
| | | } |
| | | if (this.updateById(deviceLedger)) { |
| | | return AjaxResult.success(); |
| | | } |
| | |
| | | |
| | | return true; |
| | | } |
| | | @Override |
| | | public DeviceAssetInfoDto report() { |
| | | List<DeviceLedger> list = deviceLedgerMapper.selectList(null); |
| | | DeviceAssetInfoDto deviceAssetInfoDto = new DeviceAssetInfoDto(); |
| | | deviceAssetInfoDto.setTotalEquipment(list.stream().map(DeviceLedger::getNumber).reduce(BigDecimal.ZERO, BigDecimal::add).intValue()); |
| | | deviceAssetInfoDto.setTotalOriginalValue(list.stream().map(DeviceLedger::getTaxIncludingPriceTotal).reduce(BigDecimal.ZERO, BigDecimal::add)); |
| | | deviceAssetInfoDto.setTotalNetValue(list.stream().map(DeviceLedger::getUnTaxIncludingPriceTotal).reduce(BigDecimal.ZERO, BigDecimal::add)); |
| | | deviceAssetInfoDto.setTotalDepreciation(deviceAssetInfoDto.getTotalOriginalValue().subtract(deviceAssetInfoDto.getTotalNetValue())); |
| | | return deviceAssetInfoDto; |
| | | } |
| | | } |