l3能源成本分摊(部分完成留存)
This commit is contained in:
@@ -2,6 +2,7 @@ package com.klp.ems.controller;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
|
||||
import com.klp.ems.domain.bo.EmsEnergyConsumptionQueryBo;
|
||||
import com.klp.ems.domain.vo.*;
|
||||
@@ -80,6 +81,14 @@ public class EmsEnergyConsumptionController extends BaseController {
|
||||
return R.ok(iEmsEnergyConsumptionService.getChainAnalysis(queryBo));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取能耗统计信息
|
||||
*/
|
||||
@GetMapping("/statistics")
|
||||
public R<Map<String, Object>> getStatistics(EmsEnergyConsumptionBo bo) {
|
||||
return R.ok(iEmsEnergyConsumptionService.getStatistics(bo));
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询能耗记录列表
|
||||
*/
|
||||
@@ -109,6 +118,31 @@ public class EmsEnergyConsumptionController extends BaseController {
|
||||
return R.ok(iEmsEnergyConsumptionService.queryById(energyConsumptionId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取设备的上次抄表记录(用于自动填充起始数据)
|
||||
* 如果是首次抄表,返回null;否则返回上次抄表的结束读数作为本次的起始读数
|
||||
*
|
||||
* @param meterId 设备ID
|
||||
*/
|
||||
@GetMapping("/lastReading/{meterId}")
|
||||
public R<EmsEnergyConsumptionVo> getLastReading(@NotNull(message = "设备ID不能为空")
|
||||
@PathVariable Long meterId) {
|
||||
EmsEnergyConsumptionVo lastReading = iEmsEnergyConsumptionService.getLastReadingForMeter(meterId);
|
||||
return R.ok(lastReading);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取设备本月的累计消耗量
|
||||
*
|
||||
* @param meterId 设备ID
|
||||
*/
|
||||
@GetMapping("/monthlyConsumption/{meterId}")
|
||||
public R<Double> getMonthlyConsumption(@NotNull(message = "设备ID不能为空")
|
||||
@PathVariable Long meterId) {
|
||||
Double monthlyConsumption = iEmsEnergyConsumptionService.getMonthlyConsumption(meterId);
|
||||
return R.ok(monthlyConsumption);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增能耗记录
|
||||
*/
|
||||
|
||||
@@ -18,12 +18,18 @@ import com.klp.common.core.validate.EditGroup;
|
||||
import com.klp.common.enums.BusinessType;
|
||||
import com.klp.common.utils.poi.ExcelUtil;
|
||||
import com.klp.ems.domain.vo.EmsEnergyRateVo;
|
||||
import com.klp.ems.domain.vo.EmsRateTierVo;
|
||||
import com.klp.ems.domain.vo.EmsRateTimePeriodLinkVo;
|
||||
import com.klp.ems.domain.bo.EmsEnergyRateBo;
|
||||
import com.klp.ems.domain.bo.EmsRateTierBo;
|
||||
import com.klp.ems.domain.bo.EmsRateTimePeriodLinkBo;
|
||||
import com.klp.ems.domain.bo.EmsRateTierPeriodLinkBo;
|
||||
import com.klp.ems.service.IEmsEnergyRateService;
|
||||
import com.klp.common.core.page.TableDataInfo;
|
||||
|
||||
/**
|
||||
* 能源费率(currency 为 INT:0=CNY,1=USD,2=EUR)
|
||||
* 能源费率
|
||||
* 支持:固定费率、峰谷分时、阶梯电价、峰谷+阶梯组合
|
||||
*
|
||||
* @author Joshi
|
||||
* @date 2025-09-28
|
||||
@@ -86,14 +92,73 @@ public class EmsEnergyRateController extends BaseController {
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除能源费率(currency 为 INT:0=CNY,1=USD,2=EUR)
|
||||
* 删除能源费率(级联删除梯度和时段费率)
|
||||
*
|
||||
* @param energyRateIds 主键串
|
||||
*/
|
||||
@Log(title = "能源费率(currency 为 INT:0=CNY,1=USD,2=EUR)", businessType = BusinessType.DELETE)
|
||||
@Log(title = "能源费率", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{energyRateIds}")
|
||||
public R<Void> remove(@NotEmpty(message = "主键不能为空")
|
||||
@PathVariable Long[] energyRateIds) {
|
||||
return toAjax(iEmsEnergyRateService.deleteWithValidByIds(Arrays.asList(energyRateIds), true));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取费率的梯度费率列表
|
||||
*/
|
||||
@GetMapping("/{energyRateId}/tiers")
|
||||
public R<List<EmsRateTierVo>> getRateTiers(@NotNull(message = "费率ID不能为空")
|
||||
@PathVariable Long energyRateId) {
|
||||
return R.ok(iEmsEnergyRateService.getRateTiers(energyRateId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取费率的时段费率列表
|
||||
*/
|
||||
@GetMapping("/{energyRateId}/timePeriods")
|
||||
public R<List<EmsRateTimePeriodLinkVo>> getRateTimePeriods(@NotNull(message = "费率ID不能为空")
|
||||
@PathVariable Long energyRateId) {
|
||||
return R.ok(iEmsEnergyRateService.getRateTimePeriods(energyRateId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存梯度费率,返回保存后的梯度列表(包含tierId)
|
||||
*/
|
||||
@Log(title = "能源费率梯度", businessType = BusinessType.UPDATE)
|
||||
@PostMapping("/{energyRateId}/tiers")
|
||||
public R<List<EmsRateTierVo>> saveTiers(@NotNull(message = "费率ID不能为空") @PathVariable Long energyRateId,
|
||||
@RequestBody List<EmsRateTierBo> tiers) {
|
||||
return R.ok(iEmsEnergyRateService.saveTiers(energyRateId, tiers));
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存时段费率
|
||||
*/
|
||||
@Log(title = "能源费率时段", businessType = BusinessType.UPDATE)
|
||||
@PostMapping("/{energyRateId}/timePeriods")
|
||||
public R<Void> saveTimePeriods(@NotNull(message = "费率ID不能为空") @PathVariable Long energyRateId,
|
||||
@RequestBody List<EmsRateTimePeriodLinkBo> timePeriods) {
|
||||
return toAjax(iEmsEnergyRateService.saveTimePeriods(energyRateId, timePeriods));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取梯度的峰谷时段费率(用于梯度+峰谷组合模式)
|
||||
*/
|
||||
@GetMapping("/{energyRateId}/tier/{tierId}/periods")
|
||||
public R<List<EmsRateTierPeriodLinkBo>> getTierPeriodLinks(@NotNull(message = "费率ID不能为空") @PathVariable Long energyRateId,
|
||||
@NotNull(message = "梯度ID不能为空") @PathVariable Long tierId) {
|
||||
// 返回该梯度对应的所有时段费率
|
||||
return R.ok(iEmsEnergyRateService.getTierPeriodLinks(tierId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存梯度-时段关联费率(用于梯度+峰谷组合模式)
|
||||
*/
|
||||
@Log(title = "梯度-时段关联费率", businessType = BusinessType.UPDATE)
|
||||
@PostMapping("/{energyRateId}/tier/{tierId}/periods")
|
||||
public R<Void> saveTierPeriodLinks(@NotNull(message = "费率ID不能为空") @PathVariable Long energyRateId,
|
||||
@NotNull(message = "梯度ID不能为空") @PathVariable Long tierId,
|
||||
@RequestBody List<EmsRateTierPeriodLinkBo> tierPeriodLinks) {
|
||||
return toAjax(iEmsEnergyRateService.saveTierPeriodLinks(tierId, tierPeriodLinks));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,11 +2,13 @@ package com.klp.ems.controller;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Arrays;
|
||||
import java.io.IOException;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.validation.constraints.*;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import com.klp.common.annotation.RepeatSubmit;
|
||||
import com.klp.common.annotation.Log;
|
||||
@@ -96,4 +98,21 @@ public class EmsMeterController extends BaseController {
|
||||
@PathVariable Long[] meterIds) {
|
||||
return toAjax(iEmsMeterService.deleteWithValidByIds(Arrays.asList(meterIds), true));
|
||||
}
|
||||
|
||||
/**
|
||||
* 下载设备导入模板
|
||||
*/
|
||||
@GetMapping("/template")
|
||||
public void downloadTemplate(HttpServletResponse response) {
|
||||
iEmsMeterService.downloadTemplate(response);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导入设备
|
||||
*/
|
||||
@Log(title = "计量设备(阈值移至此处)", businessType = BusinessType.IMPORT)
|
||||
@PostMapping("/import")
|
||||
public R<Void> importMeters(@RequestParam("file") MultipartFile file) {
|
||||
return toAjax(iEmsMeterService.importMeters(file));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,105 @@
|
||||
package com.klp.ems.controller;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Arrays;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.validation.constraints.*;
|
||||
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import com.klp.common.annotation.RepeatSubmit;
|
||||
import com.klp.common.annotation.Log;
|
||||
import com.klp.common.core.controller.BaseController;
|
||||
import com.klp.common.core.domain.PageQuery;
|
||||
import com.klp.common.core.domain.R;
|
||||
import com.klp.common.core.validate.AddGroup;
|
||||
import com.klp.common.core.validate.EditGroup;
|
||||
import com.klp.common.enums.BusinessType;
|
||||
import com.klp.common.utils.poi.ExcelUtil;
|
||||
import com.klp.ems.domain.bo.EmsRateTierBo;
|
||||
import com.klp.ems.domain.vo.EmsRateTierVo;
|
||||
import com.klp.ems.service.IEmsRateTierService;
|
||||
import com.klp.common.core.page.TableDataInfo;
|
||||
|
||||
/**
|
||||
* 梯度费率
|
||||
*
|
||||
* @author Joshi
|
||||
* @date 2025-12-05
|
||||
*/
|
||||
@Validated
|
||||
@RequiredArgsConstructor
|
||||
@RestController
|
||||
@RequestMapping("/ems/rateTier")
|
||||
public class EmsRateTierController extends BaseController {
|
||||
|
||||
private final IEmsRateTierService iEmsRateTierService;
|
||||
|
||||
/**
|
||||
* 查询梯度费率列表
|
||||
*/
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo<EmsRateTierVo> list(EmsRateTierBo bo, PageQuery pageQuery) {
|
||||
return iEmsRateTierService.queryPageList(bo, pageQuery);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据费率ID查询梯度费率列表
|
||||
*/
|
||||
@GetMapping("/listByRate/{energyRateId}")
|
||||
public R<List<EmsRateTierVo>> listByRate(@NotNull(message = "费率ID不能为空")
|
||||
@PathVariable Long energyRateId) {
|
||||
return R.ok(iEmsRateTierService.queryByRateId(energyRateId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出梯度费率列表
|
||||
*/
|
||||
@Log(title = "梯度费率", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/export")
|
||||
public void export(EmsRateTierBo bo, HttpServletResponse response) {
|
||||
List<EmsRateTierVo> list = iEmsRateTierService.queryList(bo);
|
||||
ExcelUtil.exportExcel(list, "梯度费率", EmsRateTierVo.class, response);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取梯度费率详细信息
|
||||
*/
|
||||
@GetMapping("/{tierId}")
|
||||
public R<EmsRateTierVo> getInfo(@NotNull(message = "主键不能为空")
|
||||
@PathVariable Long tierId) {
|
||||
return R.ok(iEmsRateTierService.queryById(tierId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增梯度费率
|
||||
*/
|
||||
@Log(title = "梯度费率", businessType = BusinessType.INSERT)
|
||||
@RepeatSubmit()
|
||||
@PostMapping()
|
||||
public R<Void> add(@Validated(AddGroup.class) @RequestBody EmsRateTierBo bo) {
|
||||
return toAjax(iEmsRateTierService.insertByBo(bo));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改梯度费率
|
||||
*/
|
||||
@Log(title = "梯度费率", businessType = BusinessType.UPDATE)
|
||||
@RepeatSubmit()
|
||||
@PutMapping()
|
||||
public R<Void> edit(@Validated(EditGroup.class) @RequestBody EmsRateTierBo bo) {
|
||||
return toAjax(iEmsRateTierService.updateByBo(bo));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除梯度费率
|
||||
*/
|
||||
@Log(title = "梯度费率", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{tierIds}")
|
||||
public R<Void> remove(@NotEmpty(message = "主键不能为空")
|
||||
@PathVariable Long[] tierIds) {
|
||||
return toAjax(iEmsRateTierService.deleteWithValidByIds(Arrays.asList(tierIds), true));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
package com.klp.ems.controller;
|
||||
|
||||
import com.klp.common.core.controller.BaseController;
|
||||
import com.klp.common.core.domain.R;
|
||||
import com.klp.ems.domain.bo.EmsRateTierPeriodLinkBo;
|
||||
import com.klp.ems.domain.vo.EmsRateTierPeriodLinkVo;
|
||||
import com.klp.ems.service.IEmsRateTierPeriodLinkService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 梯度与时段关联 Controller
|
||||
*
|
||||
* @author Joshi
|
||||
* @date 2025-12-05
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/ems/rateTierPeriodLink")
|
||||
@RequiredArgsConstructor
|
||||
@Validated
|
||||
public class EmsRateTierPeriodLinkController extends BaseController {
|
||||
|
||||
private final IEmsRateTierPeriodLinkService iEmsRateTierPeriodLinkService;
|
||||
|
||||
/**
|
||||
* 根据梯度ID查询所有关联的时段费率
|
||||
*
|
||||
* @param tierId 梯度ID
|
||||
* @return 梯度-时段关联列表
|
||||
*/
|
||||
@GetMapping("/tier/{tierId}")
|
||||
public R<List<EmsRateTierPeriodLinkVo>> getByTierId(@NotNull @PathVariable Long tierId) {
|
||||
// 这里返回的是该梯度对应的所有时段费率
|
||||
// 前端需要调用此接口获取梯度的峰谷费率配置
|
||||
return R.ok(iEmsRateTierPeriodLinkService.getByTierId(tierId).stream()
|
||||
.map(link -> {
|
||||
EmsRateTierPeriodLinkVo vo = new EmsRateTierPeriodLinkVo();
|
||||
vo.setLinkId(link.getLinkId());
|
||||
vo.setTierId(link.getTierId());
|
||||
vo.setPeriodId(link.getPeriodId());
|
||||
vo.setRate(link.getRate());
|
||||
return vo;
|
||||
})
|
||||
.collect(Collectors.toList()));
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据费率ID查询梯度-时段关联的完整信息
|
||||
*
|
||||
* @param energyRateId 费率ID
|
||||
* @return 梯度-时段关联VO列表
|
||||
*/
|
||||
@GetMapping("/rate/{energyRateId}")
|
||||
public R<List<EmsRateTierPeriodLinkVo>> getByEnergyRateId(@NotNull @PathVariable Long energyRateId) {
|
||||
return R.ok(iEmsRateTierPeriodLinkService.getVoByEnergyRateId(energyRateId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存梯度的时段费率关联
|
||||
*
|
||||
* @param tierId 梯度ID
|
||||
* @param tierPeriodLinks 梯度-时段关联列表
|
||||
* @return 保存结果
|
||||
*/
|
||||
@PostMapping("/tier/{tierId}")
|
||||
public R<Void> saveTierPeriodLinks(@NotNull @PathVariable Long tierId,
|
||||
@RequestBody List<EmsRateTierPeriodLinkBo> tierPeriodLinks) {
|
||||
return toAjax(iEmsRateTierPeriodLinkService.saveTierPeriodLinks(tierId, tierPeriodLinks));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除梯度的时段费率关联
|
||||
*
|
||||
* @param tierId 梯度ID
|
||||
* @return 删除结果
|
||||
*/
|
||||
@DeleteMapping("/tier/{tierId}")
|
||||
public R<Void> deleteByTierId(@NotNull @PathVariable Long tierId) {
|
||||
return toAjax(iEmsRateTierPeriodLinkService.deleteByTierId(tierId));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,105 @@
|
||||
package com.klp.ems.controller;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Arrays;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.validation.constraints.*;
|
||||
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import com.klp.common.annotation.RepeatSubmit;
|
||||
import com.klp.common.annotation.Log;
|
||||
import com.klp.common.core.controller.BaseController;
|
||||
import com.klp.common.core.domain.PageQuery;
|
||||
import com.klp.common.core.domain.R;
|
||||
import com.klp.common.core.validate.AddGroup;
|
||||
import com.klp.common.core.validate.EditGroup;
|
||||
import com.klp.common.enums.BusinessType;
|
||||
import com.klp.common.utils.poi.ExcelUtil;
|
||||
import com.klp.ems.domain.bo.EmsRateTimePeriodLinkBo;
|
||||
import com.klp.ems.domain.vo.EmsRateTimePeriodLinkVo;
|
||||
import com.klp.ems.service.IEmsRateTimePeriodLinkService;
|
||||
import com.klp.common.core.page.TableDataInfo;
|
||||
|
||||
/**
|
||||
* 费率与时间段关联
|
||||
*
|
||||
* @author Joshi
|
||||
* @date 2025-12-05
|
||||
*/
|
||||
@Validated
|
||||
@RequiredArgsConstructor
|
||||
@RestController
|
||||
@RequestMapping("/ems/rateTimePeriodLink")
|
||||
public class EmsRateTimePeriodLinkController extends BaseController {
|
||||
|
||||
private final IEmsRateTimePeriodLinkService iEmsRateTimePeriodLinkService;
|
||||
|
||||
/**
|
||||
* 查询费率与时间段关联列表
|
||||
*/
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo<EmsRateTimePeriodLinkVo> list(EmsRateTimePeriodLinkBo bo, PageQuery pageQuery) {
|
||||
return iEmsRateTimePeriodLinkService.queryPageList(bo, pageQuery);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据费率ID查询峰谷时段费率列表
|
||||
*/
|
||||
@GetMapping("/listByRate/{energyRateId}")
|
||||
public R<List<EmsRateTimePeriodLinkVo>> listByRate(@NotNull(message = "费率ID不能为空")
|
||||
@PathVariable Long energyRateId) {
|
||||
return R.ok(iEmsRateTimePeriodLinkService.queryByRateId(energyRateId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出费率与时间段关联列表
|
||||
*/
|
||||
@Log(title = "费率与时间段关联", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/export")
|
||||
public void export(EmsRateTimePeriodLinkBo bo, HttpServletResponse response) {
|
||||
List<EmsRateTimePeriodLinkVo> list = iEmsRateTimePeriodLinkService.queryList(bo);
|
||||
ExcelUtil.exportExcel(list, "费率与时间段关联", EmsRateTimePeriodLinkVo.class, response);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取费率与时间段关联详细信息
|
||||
*/
|
||||
@GetMapping("/{linkId}")
|
||||
public R<EmsRateTimePeriodLinkVo> getInfo(@NotNull(message = "主键不能为空")
|
||||
@PathVariable Long linkId) {
|
||||
return R.ok(iEmsRateTimePeriodLinkService.queryById(linkId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增费率与时间段关联
|
||||
*/
|
||||
@Log(title = "费率与时间段关联", businessType = BusinessType.INSERT)
|
||||
@RepeatSubmit()
|
||||
@PostMapping()
|
||||
public R<Void> add(@Validated(AddGroup.class) @RequestBody EmsRateTimePeriodLinkBo bo) {
|
||||
return toAjax(iEmsRateTimePeriodLinkService.insertByBo(bo));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改费率与时间段关联
|
||||
*/
|
||||
@Log(title = "费率与时间段关联", businessType = BusinessType.UPDATE)
|
||||
@RepeatSubmit()
|
||||
@PutMapping()
|
||||
public R<Void> edit(@Validated(EditGroup.class) @RequestBody EmsRateTimePeriodLinkBo bo) {
|
||||
return toAjax(iEmsRateTimePeriodLinkService.updateByBo(bo));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除费率与时间段关联
|
||||
*/
|
||||
@Log(title = "费率与时间段关联", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{linkIds}")
|
||||
public R<Void> remove(@NotEmpty(message = "主键不能为空")
|
||||
@PathVariable Long[] linkIds) {
|
||||
return toAjax(iEmsRateTimePeriodLinkService.deleteWithValidByIds(Arrays.asList(linkIds), true));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
package com.klp.ems.controller;
|
||||
|
||||
import com.klp.common.annotation.Log;
|
||||
import com.klp.common.core.controller.BaseController;
|
||||
import com.klp.common.core.domain.PageQuery;
|
||||
import com.klp.common.core.domain.R;
|
||||
import com.klp.common.core.page.TableDataInfo;
|
||||
import com.klp.common.enums.BusinessType;
|
||||
import com.klp.ems.domain.bo.EnergyCostReportBo;
|
||||
import com.klp.ems.domain.vo.EnergyCostSummaryVo;
|
||||
import com.klp.ems.domain.vo.WmsEnergyCoilDailyVo;
|
||||
import com.klp.ems.service.IEnergyCostReportService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 能源成本报表 Controller
|
||||
*/
|
||||
@Validated
|
||||
@RequiredArgsConstructor
|
||||
@RestController
|
||||
@RequestMapping("/ems/energy/report")
|
||||
public class EnergyCostReportController extends BaseController {
|
||||
|
||||
private final IEnergyCostReportService reportService;
|
||||
|
||||
@Log(title = "能源成本报表", businessType = BusinessType.OTHER)
|
||||
@GetMapping("/overview")
|
||||
public R<Map<String, Object>> overview(EnergyCostReportBo bo) {
|
||||
return R.ok(reportService.overview(bo));
|
||||
}
|
||||
|
||||
@Log(title = "能源成本报表", businessType = BusinessType.OTHER)
|
||||
@GetMapping("/summary")
|
||||
public R<List<EnergyCostSummaryVo>> summary(EnergyCostReportBo bo) {
|
||||
return R.ok(reportService.summary(bo));
|
||||
}
|
||||
|
||||
@Log(title = "能源成本报表", businessType = BusinessType.OTHER)
|
||||
@GetMapping("/detail")
|
||||
public TableDataInfo<WmsEnergyCoilDailyVo> detail(EnergyCostReportBo bo, PageQuery pageQuery) {
|
||||
return reportService.detail(bo, pageQuery);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,99 @@
|
||||
package com.klp.ems.controller;
|
||||
|
||||
import com.klp.common.annotation.Log;
|
||||
import com.klp.common.annotation.RepeatSubmit;
|
||||
import com.klp.common.core.controller.BaseController;
|
||||
import com.klp.common.core.domain.PageQuery;
|
||||
import com.klp.common.core.domain.R;
|
||||
import com.klp.common.core.page.TableDataInfo;
|
||||
import com.klp.common.core.validate.AddGroup;
|
||||
import com.klp.common.core.validate.EditGroup;
|
||||
import com.klp.common.enums.BusinessType;
|
||||
import com.klp.common.utils.poi.ExcelUtil;
|
||||
import com.klp.ems.domain.bo.WmsEnergyCoilDailyBo;
|
||||
import com.klp.ems.domain.vo.WmsEnergyCoilDailyVo;
|
||||
import com.klp.ems.domain.vo.WmsEnergyCoilDailyStatisticsVo;
|
||||
import com.klp.ems.service.IWmsEnergyCoilDailyService;
|
||||
import lombok.Data;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.time.LocalDate;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 钢卷日能源成本分摊结果 Controller
|
||||
*/
|
||||
@Validated
|
||||
@RequiredArgsConstructor
|
||||
@RestController
|
||||
@RequestMapping("/ems/energy/coilDaily")
|
||||
public class WmsEnergyCoilDailyController extends BaseController {
|
||||
|
||||
private final IWmsEnergyCoilDailyService coilDailyService;
|
||||
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo<WmsEnergyCoilDailyVo> list(WmsEnergyCoilDailyBo bo, PageQuery pageQuery) {
|
||||
return coilDailyService.queryPageList(bo, pageQuery);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询待操作钢卷的能源成本(基于待操作时间范围计算)
|
||||
*/
|
||||
@GetMapping("/pendingAction")
|
||||
public TableDataInfo<WmsEnergyCoilDailyVo> pendingAction(WmsEnergyCoilDailyBo bo, PageQuery pageQuery) {
|
||||
// 调用Service方法计算待操作钢卷的成本
|
||||
return coilDailyService.queryPendingActionCoilCost(bo, pageQuery);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询待操作钢卷的能源成本统计
|
||||
*/
|
||||
@GetMapping("/pendingAction/statistics")
|
||||
public R<WmsEnergyCoilDailyStatisticsVo> pendingActionStatistics(
|
||||
@RequestParam(required = false) String enterCoilNo,
|
||||
@RequestParam(required = false) String currentCoilNo,
|
||||
@RequestParam(required = false) Long warehouseId
|
||||
) {
|
||||
WmsEnergyCoilDailyStatisticsVo statistics = coilDailyService.queryPendingActionCoilCostStatistics(enterCoilNo, currentCoilNo, warehouseId);
|
||||
return R.ok(statistics);
|
||||
}
|
||||
|
||||
@Log(title = "钢卷能源分摊", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/export")
|
||||
public void export(WmsEnergyCoilDailyBo bo, HttpServletResponse response) {
|
||||
List<WmsEnergyCoilDailyVo> list = coilDailyService.queryList(bo);
|
||||
ExcelUtil.exportExcel(list, "钢卷能源分摊", WmsEnergyCoilDailyVo.class, response);
|
||||
}
|
||||
|
||||
@GetMapping("/{energyCostId}")
|
||||
public R<WmsEnergyCoilDailyVo> getInfo(@NotNull @PathVariable Long energyCostId) {
|
||||
return R.ok(coilDailyService.queryById(energyCostId));
|
||||
}
|
||||
|
||||
@Log(title = "钢卷能源分摊", businessType = BusinessType.INSERT)
|
||||
@RepeatSubmit
|
||||
@PostMapping
|
||||
public R<Void> add(@Validated(AddGroup.class) @RequestBody WmsEnergyCoilDailyBo bo) {
|
||||
return toAjax(coilDailyService.insertByBo(bo));
|
||||
}
|
||||
|
||||
@Log(title = "钢卷能源分摊", businessType = BusinessType.UPDATE)
|
||||
@RepeatSubmit
|
||||
@PutMapping
|
||||
public R<Void> edit(@Validated(EditGroup.class) @RequestBody WmsEnergyCoilDailyBo bo) {
|
||||
return toAjax(coilDailyService.updateByBo(bo));
|
||||
}
|
||||
|
||||
@Log(title = "钢卷能源分摊", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{energyCostIds}")
|
||||
public R<Void> remove(@NotEmpty @PathVariable Long[] energyCostIds) {
|
||||
return toAjax(coilDailyService.deleteWithValidByIds(Arrays.asList(energyCostIds), true));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user