| | |
| | | KEY `idx_form_instance_id` (`form_instance_id`) |
| | | ) ENGINE = INNODB |
| | | DEFAULT CHARSET = utf8mb4 COMMENT = 'éå®çäº§éæ±'; |
| | | |
| | | CREATE TABLE `product-inventory-management-zsjc`.`energy` ( |
| | | `id` int NOT NULL AUTO_INCREMENT, |
| | | `energy_tyep` varchar(255) NULL COMMENT 'è½æºç±»å', |
| | | `energy_name` varchar(255) NULL COMMENT 'è½æºåç§°', |
| | | `unit` varchar(255) NULL COMMENT 'åä½', |
| | | `unit_price` decimal(10, 2) NULL COMMENT 'åä»·', |
| | | `remark` varchar(255) NULL COMMENT '夿³¨', |
| | | `create_time` datetime(0) NULL DEFAULT NULL COMMENT 'å建æ¶é´', |
| | | `update_time` datetime(0) NULL DEFAULT NULL COMMENT 'æ´æ°æ¶é´', |
| | | `create_user` bigint NULL DEFAULT NULL COMMENT 'å建è
', |
| | | `update_user` bigint NULL DEFAULT NULL COMMENT 'æ´æ°è
', |
| | | PRIMARY KEY (`id`) |
| | | ) COMMENT = 'è½æºç±»å'; |
| | | |
| | | CREATE TABLE `product-inventory-management-zsjc`.`energy_consumption_detail` ( |
| | | `id` int NOT NULL AUTO_INCREMENT, |
| | | `energy_id` int NULL COMMENT '夿£å
³èè½æºç±»åid', |
| | | `type` varchar(255) NULL COMMENT 'åå
¬/ç产', |
| | | `meter_reading_location` varchar(255) NULL COMMENT 'æè¡¨ä½ç½®', |
| | | `meter_reading_date` date NULL COMMENT 'æè¡¨æ¥æ', |
| | | `start_code` decimal(10, 2) NULL COMMENT 'èµ·ç ', |
| | | `stop_code` decimal(10, 2) NULL COMMENT 'æ¢ç ', |
| | | `dosage` decimal(10, 2) NULL COMMENT 'ç¨é', |
| | | `remark` varchar(255) NULL COMMENT '夿³¨', |
| | | `create_time` datetime(0) NULL DEFAULT NULL COMMENT 'å建æ¶é´', |
| | | `update_time` datetime(0) NULL DEFAULT NULL COMMENT 'æ´æ°æ¶é´', |
| | | `create_user` bigint NULL DEFAULT NULL COMMENT 'å建è
', |
| | | `update_user` bigint NULL DEFAULT NULL COMMENT 'æ´æ°è
', |
| | | PRIMARY KEY (`id`) |
| | | ) COMMENT = 'è½æºç±»å-è½èæè¡¨æç»'; |
| | |
| | | // æ¼ç¤ºä¾åï¼æ§è¡ main æ¹æ³æ§å¶å°è¾å
¥æ¨¡å表åå车èªå¨çæå¯¹åºé¡¹ç®ç®å½ä¸ |
| | | public class CodeGenerator { |
| | | |
| | | public static String database_url = "jdbc:mysql://1.15.17.182:9999/product-inventory-management-new"; |
| | | public static String database_url = "jdbc:mysql://1.15.17.182:9999/product-inventory-management-zsjc"; |
| | | public static String database_username = "root"; |
| | | public static String database_password= "xd@123456.."; |
| | | public static String author = "è¯å¯¼è½¯ä»¶ï¼æ±èï¼æéå
¬å¸"; |
| | | public static String model = "staff"; // 模å |
| | | public static String model = "energy"; // 模å |
| | | public static String setParent = "com.ruoyi."+ model; // å
è·¯å¾ |
| | | public static String tablePrefix = ""; // è®¾ç½®è¿æ»¤è¡¨åç¼ |
| | | public static void main(String[] args) { |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.energy.controller; |
| | | |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.ruoyi.common.utils.poi.ExcelUtil; |
| | | import com.ruoyi.energy.dto.EnergyConsumptionDetailDto; |
| | | import com.ruoyi.energy.pojo.Energy; |
| | | import com.ruoyi.energy.pojo.EnergyConsumptionDetail; |
| | | import com.ruoyi.energy.service.EnergyConsumptionDetailService; |
| | | import com.ruoyi.energy.service.EnergyService; |
| | | import com.ruoyi.framework.aspectj.lang.annotation.Log; |
| | | import com.ruoyi.framework.aspectj.lang.enums.BusinessType; |
| | | import com.ruoyi.framework.web.domain.R; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.util.Arrays; |
| | | |
| | | /** |
| | | * <p> |
| | | * è½æºç±»å-è½èæè¡¨æç» å端æ§å¶å¨ |
| | | * </p> |
| | | * |
| | | * @author è¯å¯¼è½¯ä»¶ï¼æ±èï¼æéå
¬å¸ |
| | | * @since 2026-03-10 11:22:20 |
| | | */ |
| | | @RestController |
| | | @RequestMapping("/energyConsumptionDetail") |
| | | @Api(tags = "è½è管ç-è½èæè¡¨æç»") |
| | | public class EnergyConsumptionDetailController { |
| | | |
| | | @Autowired |
| | | private EnergyConsumptionDetailService energyConsumptionDetailService; |
| | | |
| | | @GetMapping("page") |
| | | @ApiOperation("å页æ¥è¯¢") |
| | | public R page(Page<EnergyConsumptionDetailDto> page, EnergyConsumptionDetailDto energyConsumptionDetailDto) { |
| | | return R.ok(energyConsumptionDetailService.pageEnergyConsumptionDetail(page, energyConsumptionDetailDto)); |
| | | } |
| | | |
| | | @ApiOperation("æ°å¢/ä¿®æ¹è½èæè¡¨") |
| | | @PostMapping() |
| | | public R add(@RequestBody EnergyConsumptionDetail energyConsumptionDetail) { |
| | | return R.ok(energyConsumptionDetailService.saveOrUpdate(energyConsumptionDetail)); |
| | | } |
| | | |
| | | @ApiOperation("å é¤è½èæè¡¨") |
| | | @DeleteMapping("/{ids}") |
| | | public R delete(@PathVariable("ids") Long[] ids) { |
| | | return R.ok(energyConsumptionDetailService.removeBatchByIds(Arrays.asList(ids))); |
| | | } |
| | | |
| | | @Log(title = "è½èæè¡¨æç»-导å
¥", businessType = BusinessType.IMPORT) |
| | | @PostMapping("/importData") |
| | | public R importData(MultipartFile file) throws Exception { |
| | | return energyConsumptionDetailService.importData(file); |
| | | } |
| | | |
| | | @PostMapping("/downloadTemplate") |
| | | @Log(title = "è½èæè¡¨-ä¸è½½æ¨¡æ¿", businessType = BusinessType.EXPORT) |
| | | public void downloadTemplate(HttpServletResponse response) { |
| | | ExcelUtil<EnergyConsumptionDetailDto> util = new ExcelUtil<EnergyConsumptionDetailDto>(EnergyConsumptionDetailDto.class); |
| | | util.importTemplateExcel(response, "è½èæè¡¨æ¨¡ç"); |
| | | } |
| | | |
| | | @PostMapping("/export") |
| | | @ApiOperation("è½èæè¡¨-导åº") |
| | | @Log(title = "è½èæè¡¨-导åº", businessType = BusinessType.EXPORT) |
| | | public void export(HttpServletResponse response) { |
| | | energyConsumptionDetailService.export(response); |
| | | } |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.energy.controller; |
| | | |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.ruoyi.common.utils.poi.ExcelUtil; |
| | | import com.ruoyi.energy.pojo.Energy; |
| | | import com.ruoyi.energy.service.EnergyService; |
| | | import com.ruoyi.framework.aspectj.lang.annotation.Log; |
| | | import com.ruoyi.framework.aspectj.lang.enums.BusinessType; |
| | | import com.ruoyi.framework.web.domain.AjaxResult; |
| | | import com.ruoyi.framework.web.domain.R; |
| | | import com.ruoyi.production.dto.ProcessRouteDto; |
| | | import com.ruoyi.production.pojo.ProcessRoute; |
| | | import com.ruoyi.production.pojo.ProductProcess; |
| | | import com.ruoyi.production.service.ProcessRouteService; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.util.Arrays; |
| | | |
| | | /** |
| | | * <p> |
| | | * è½æºç±»å å端æ§å¶å¨ |
| | | * </p> |
| | | * |
| | | * @author è¯å¯¼è½¯ä»¶ï¼æ±èï¼æéå
¬å¸ |
| | | * @since 2026-03-10 10:50:18 |
| | | */ |
| | | @RestController |
| | | @RequestMapping("/energy") |
| | | @Api(tags = "è½è管ç-è½æºç±»å") |
| | | public class EnergyController { |
| | | |
| | | @Autowired |
| | | private EnergyService energyService; |
| | | |
| | | @GetMapping("page") |
| | | @ApiOperation("å页æ¥è¯¢") |
| | | public R page(Page<Energy> page, Energy energy) { |
| | | return R.ok(energyService.pageEnergy(page, energy)); |
| | | } |
| | | |
| | | @ApiOperation("æ°å¢/ä¿®æ¹è½æºç±»å") |
| | | @PostMapping() |
| | | public R add(@RequestBody Energy energy) { |
| | | return R.ok(energyService.saveOrUpdate(energy)); |
| | | } |
| | | |
| | | @ApiOperation("å é¤è½æºç±»å") |
| | | @DeleteMapping("/{ids}") |
| | | public R delete(@PathVariable("ids") Long[] ids) { |
| | | return R.ok(energyService.batchDelete(Arrays.asList(ids))); |
| | | } |
| | | |
| | | @Log(title = "è½æºç±»å-导å
¥", businessType = BusinessType.IMPORT) |
| | | @PostMapping("/importData") |
| | | public R importData(MultipartFile file) throws Exception { |
| | | return energyService.importData(file); |
| | | } |
| | | |
| | | @PostMapping("/downloadTemplate") |
| | | @Log(title = "è½æºç±»å-ä¸è½½æ¨¡æ¿", businessType = BusinessType.EXPORT) |
| | | public void downloadTemplate(HttpServletResponse response) { |
| | | ExcelUtil<Energy> util = new ExcelUtil<Energy>(Energy.class); |
| | | util.importTemplateExcel(response, "è½æºç±»å模ç"); |
| | | } |
| | | |
| | | @PostMapping("/export") |
| | | @ApiOperation("è½æºç±»å-导åº") |
| | | @Log(title = "è½æºç±»å-导åº", businessType = BusinessType.EXPORT) |
| | | public void export(HttpServletResponse response) { |
| | | energyService.export(response); |
| | | } |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.energy.dto; |
| | | |
| | | import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; |
| | | import com.baomidou.mybatisplus.annotation.TableField; |
| | | import com.ruoyi.energy.pojo.EnergyConsumptionDetail; |
| | | import com.ruoyi.framework.aspectj.lang.annotation.Excel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | |
| | | //è½èæè¡¨æç» |
| | | @Data |
| | | @ExcelIgnoreUnannotated |
| | | public class EnergyConsumptionDetailDto extends EnergyConsumptionDetail { |
| | | |
| | | @ApiModelProperty("è½æºç±»å") |
| | | @Excel(name = "è½æºç±»å") |
| | | private String energyTyep; |
| | | |
| | | @ApiModelProperty("è½æºåç§°") |
| | | @Excel(name = "è½æºåç§°") |
| | | private String energyName; |
| | | |
| | | @ApiModelProperty("åä½") |
| | | @Excel(name = "åä½") |
| | | private String unit; |
| | | |
| | | //å建人 |
| | | private String createUserName; |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.energy.mapper; |
| | | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.ruoyi.energy.dto.EnergyConsumptionDetailDto; |
| | | import com.ruoyi.energy.pojo.EnergyConsumptionDetail; |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | import org.apache.ibatis.annotations.Param; |
| | | |
| | | /** |
| | | * <p> |
| | | * è½æºç±»å-è½èæè¡¨æç» Mapper æ¥å£ |
| | | * </p> |
| | | * |
| | | * @author è¯å¯¼è½¯ä»¶ï¼æ±èï¼æéå
¬å¸ |
| | | * @since 2026-03-10 11:22:20 |
| | | */ |
| | | @Mapper |
| | | public interface EnergyConsumptionDetailMapper extends BaseMapper<EnergyConsumptionDetail> { |
| | | |
| | | IPage<EnergyConsumptionDetailDto> pageEnergyConsumptionDetail(Page<EnergyConsumptionDetailDto> page, @Param("c") EnergyConsumptionDetailDto energyConsumptionDetailDto); |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.energy.mapper; |
| | | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.ruoyi.energy.pojo.Energy; |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | import org.apache.ibatis.annotations.Param; |
| | | |
| | | /** |
| | | * <p> |
| | | * è½æºç±»å Mapper æ¥å£ |
| | | * </p> |
| | | * |
| | | * @author è¯å¯¼è½¯ä»¶ï¼æ±èï¼æéå
¬å¸ |
| | | * @since 2026-03-10 10:50:18 |
| | | */ |
| | | @Mapper |
| | | public interface EnergyMapper extends BaseMapper<Energy> { |
| | | |
| | | IPage<Energy> pageEnergy(Page<Energy> page, @Param("c") Energy energy); |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.energy.pojo; |
| | | |
| | | import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; |
| | | import com.baomidou.mybatisplus.annotation.FieldFill; |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableField; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import java.io.Serializable; |
| | | import java.math.BigDecimal; |
| | | import java.time.LocalDateTime; |
| | | |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import com.ruoyi.framework.aspectj.lang.annotation.Excel; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Getter; |
| | | import lombok.Setter; |
| | | import org.springframework.format.annotation.DateTimeFormat; |
| | | |
| | | /** |
| | | * <p> |
| | | * è½æºç±»å |
| | | * </p> |
| | | * |
| | | * @author è¯å¯¼è½¯ä»¶ï¼æ±èï¼æéå
¬å¸ |
| | | * @since 2026-03-10 10:50:18 |
| | | */ |
| | | @Getter |
| | | @Setter |
| | | @TableName("energy") |
| | | @ApiModel(value = "Energy对象", description = "è½æºç±»å") |
| | | @ExcelIgnoreUnannotated |
| | | public class Energy implements Serializable { |
| | | |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | @TableId(value = "id", type = IdType.AUTO) |
| | | private Integer id; |
| | | |
| | | @ApiModelProperty("è½æºç±»å") |
| | | @Excel(name = "è½æºç±»å") |
| | | private String energyTyep; |
| | | |
| | | @ApiModelProperty("è½æºåç§°") |
| | | @Excel(name = "è½æºåç§°") |
| | | private String energyName; |
| | | |
| | | @ApiModelProperty("åä½") |
| | | @Excel(name = "åä½") |
| | | private String unit; |
| | | |
| | | @ApiModelProperty("åä»·") |
| | | @Excel(name = "åä»·") |
| | | private BigDecimal unitPrice; |
| | | |
| | | @ApiModelProperty("夿³¨") |
| | | @Excel(name = "夿³¨") |
| | | private String remark; |
| | | |
| | | @ApiModelProperty("å建æ¶é´") |
| | | @TableField(fill = FieldFill.INSERT) |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | private LocalDateTime createTime; |
| | | |
| | | @ApiModelProperty("æ´æ°æ¶é´") |
| | | @TableField(fill = FieldFill.INSERT_UPDATE) |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | private LocalDateTime updateTime; |
| | | |
| | | @ApiModelProperty("å建è
") |
| | | @TableField(fill = FieldFill.INSERT) |
| | | private Long createUser; |
| | | |
| | | @ApiModelProperty("æ´æ°è
") |
| | | @TableField(fill = FieldFill.INSERT_UPDATE) |
| | | private Long updateUser; |
| | | |
| | | //å建人 |
| | | @TableField(exist = false) |
| | | private String createUserName; |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.energy.pojo; |
| | | |
| | | import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; |
| | | import com.baomidou.mybatisplus.annotation.FieldFill; |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableField; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import java.io.Serializable; |
| | | import java.math.BigDecimal; |
| | | import java.time.LocalDate; |
| | | import java.time.LocalDateTime; |
| | | |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import com.ruoyi.framework.aspectj.lang.annotation.Excel; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Getter; |
| | | import lombok.Setter; |
| | | import org.springframework.format.annotation.DateTimeFormat; |
| | | |
| | | /** |
| | | * <p> |
| | | * è½æºç±»å-è½èæè¡¨æç» |
| | | * </p> |
| | | * |
| | | * @author è¯å¯¼è½¯ä»¶ï¼æ±èï¼æéå
¬å¸ |
| | | * @since 2026-03-10 11:22:20 |
| | | */ |
| | | @Getter |
| | | @Setter |
| | | @TableName("energy_consumption_detail") |
| | | @ApiModel(value = "EnergyConsumptionDetail对象", description = "è½æºç±»å-è½èæè¡¨æç»") |
| | | @ExcelIgnoreUnannotated |
| | | public class EnergyConsumptionDetail implements Serializable { |
| | | |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | @TableId(value = "id", type = IdType.AUTO) |
| | | private Integer id; |
| | | |
| | | @ApiModelProperty("夿£å
³èè½æºç±»åid") |
| | | private Integer energyId; |
| | | |
| | | @ApiModelProperty("åå
¬/ç产") |
| | | @Excel(name = "è½èåºæ¯") |
| | | private String type; |
| | | |
| | | @ApiModelProperty("æè¡¨ä½ç½®") |
| | | private String meterReadingLocation; |
| | | |
| | | @ApiModelProperty("æè¡¨æ¥æ") |
| | | @JsonFormat(pattern = "yyyy-MM-dd") |
| | | @DateTimeFormat(pattern = "yyyy-MM-dd") |
| | | @Excel(name = "æ¥æ") |
| | | private LocalDate meterReadingDate; |
| | | |
| | | @ApiModelProperty("èµ·ç ") |
| | | @Excel(name = "èµ·ç ") |
| | | private BigDecimal startCode; |
| | | |
| | | @ApiModelProperty("æ¢ç ") |
| | | @Excel(name = "æ¢ç ") |
| | | private BigDecimal stopCode; |
| | | |
| | | @ApiModelProperty("ç¨é") |
| | | @Excel(name = "ç¨é") |
| | | private BigDecimal dosage; |
| | | |
| | | @ApiModelProperty("夿³¨") |
| | | @Excel(name = "夿³¨") |
| | | private String remark; |
| | | |
| | | @ApiModelProperty("å建æ¶é´") |
| | | @TableField(fill = FieldFill.INSERT) |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | private LocalDateTime createTime; |
| | | |
| | | @ApiModelProperty("æ´æ°æ¶é´") |
| | | @TableField(fill = FieldFill.INSERT_UPDATE) |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | private LocalDateTime updateTime; |
| | | |
| | | @ApiModelProperty("å建è
") |
| | | @TableField(fill = FieldFill.INSERT) |
| | | private Long createUser; |
| | | |
| | | @ApiModelProperty("æ´æ°è
") |
| | | @TableField(fill = FieldFill.INSERT_UPDATE) |
| | | private Long updateUser; |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.energy.service; |
| | | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.ruoyi.energy.dto.EnergyConsumptionDetailDto; |
| | | import com.ruoyi.energy.pojo.EnergyConsumptionDetail; |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import com.ruoyi.framework.web.domain.R; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | |
| | | /** |
| | | * <p> |
| | | * è½æºç±»å-è½èæè¡¨æç» æå¡ç±» |
| | | * </p> |
| | | * |
| | | * @author è¯å¯¼è½¯ä»¶ï¼æ±èï¼æéå
¬å¸ |
| | | * @since 2026-03-10 11:22:20 |
| | | */ |
| | | public interface EnergyConsumptionDetailService extends IService<EnergyConsumptionDetail> { |
| | | |
| | | IPage<EnergyConsumptionDetailDto> pageEnergyConsumptionDetail(Page<EnergyConsumptionDetailDto> page, EnergyConsumptionDetailDto energyConsumptionDetailDto); |
| | | |
| | | R importData(MultipartFile file); |
| | | |
| | | void export(HttpServletResponse response); |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.energy.service; |
| | | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.ruoyi.energy.pojo.Energy; |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import com.ruoyi.framework.web.domain.R; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * <p> |
| | | * è½æºç±»å æå¡ç±» |
| | | * </p> |
| | | * |
| | | * @author è¯å¯¼è½¯ä»¶ï¼æ±èï¼æéå
¬å¸ |
| | | * @since 2026-03-10 10:50:18 |
| | | */ |
| | | public interface EnergyService extends IService<Energy> { |
| | | |
| | | IPage<Energy> pageEnergy(Page<Energy> page, Energy energy); |
| | | |
| | | boolean batchDelete(List<Long> ids); |
| | | |
| | | R importData(MultipartFile file); |
| | | |
| | | void export(HttpServletResponse response); |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.energy.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; |
| | | import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.ruoyi.common.utils.poi.ExcelUtil; |
| | | import com.ruoyi.energy.dto.EnergyConsumptionDetailDto; |
| | | import com.ruoyi.energy.mapper.EnergyMapper; |
| | | import com.ruoyi.energy.pojo.Energy; |
| | | import com.ruoyi.energy.pojo.EnergyConsumptionDetail; |
| | | import com.ruoyi.energy.mapper.EnergyConsumptionDetailMapper; |
| | | import com.ruoyi.energy.service.EnergyConsumptionDetailService; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.framework.web.domain.R; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * <p> |
| | | * è½æºç±»å-è½èæè¡¨æç» æå¡å®ç°ç±» |
| | | * </p> |
| | | * |
| | | * @author è¯å¯¼è½¯ä»¶ï¼æ±èï¼æéå
¬å¸ |
| | | * @since 2026-03-10 11:22:20 |
| | | */ |
| | | @Service |
| | | public class EnergyConsumptionDetailServiceImpl extends ServiceImpl<EnergyConsumptionDetailMapper, EnergyConsumptionDetail> implements EnergyConsumptionDetailService { |
| | | |
| | | @Autowired |
| | | private EnergyConsumptionDetailMapper energyConsumptionDetailMapper; |
| | | |
| | | @Autowired |
| | | private EnergyMapper energyMapper; |
| | | |
| | | @Override |
| | | public IPage<EnergyConsumptionDetailDto> pageEnergyConsumptionDetail(Page<EnergyConsumptionDetailDto> page, EnergyConsumptionDetailDto energyConsumptionDetailDto) { |
| | | return energyConsumptionDetailMapper.pageEnergyConsumptionDetail(page,energyConsumptionDetailDto); |
| | | } |
| | | |
| | | @Override |
| | | public R importData(MultipartFile file) { |
| | | try { |
| | | ExcelUtil<EnergyConsumptionDetailDto> util = new ExcelUtil<EnergyConsumptionDetailDto>(EnergyConsumptionDetailDto.class); |
| | | List<EnergyConsumptionDetailDto> energyConsumptionDetailDtoList = util.importExcel(file.getInputStream()); |
| | | if(CollectionUtils.isEmpty(energyConsumptionDetailDtoList)){ |
| | | return R.fail("模æ¿é误æå¯¼å
¥æ°æ®ä¸ºç©º"); |
| | | } |
| | | List<EnergyConsumptionDetail> list = energyConsumptionDetailDtoList.stream().map(energyConsumptionDetailDto -> { |
| | | if (ObjectUtils.isEmpty(energyConsumptionDetailDto)) { |
| | | throw new RuntimeException("ä½¿ç¨æ¨¡æ¿è¿è¡å¯¼å
¥"); |
| | | } |
| | | if (ObjectUtils.isEmpty(energyConsumptionDetailDto.getEnergyTyep()) && ObjectUtils.isEmpty(energyConsumptionDetailDto.getEnergyName())) { |
| | | throw new RuntimeException("è½æºç±»åä¸è½ä¸ºç©º"); |
| | | } |
| | | List<Energy> energy = energyMapper.selectList(Wrappers.<Energy>lambdaQuery() |
| | | .eq(Energy::getEnergyTyep, energyConsumptionDetailDto.getEnergyTyep()) |
| | | .eq(Energy::getEnergyName, energyConsumptionDetailDto.getEnergyName())); |
| | | if (CollectionUtils.isEmpty(energy)) { |
| | | throw new RuntimeException("导å
¥æ°æ®ä¸çè½æºç±»åå¨ç³»ç»ä¸ä¸åå¨,请å
åå¾è½æºç±»åä¸é
ç½®!"); |
| | | } |
| | | EnergyConsumptionDetail energyConsumptionDetail = new EnergyConsumptionDetail(); |
| | | BeanUtils.copyProperties(energyConsumptionDetailDto, energyConsumptionDetail); |
| | | energyConsumptionDetail.setEnergyId(energy.get(0).getId()); |
| | | return energyConsumptionDetail; |
| | | }).collect(Collectors.toList()); |
| | | this.saveOrUpdateBatch(list); |
| | | return R.ok(true); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | return R.fail(e.getMessage()); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void export(HttpServletResponse response) { |
| | | List<EnergyConsumptionDetailDto> list = energyConsumptionDetailMapper.pageEnergyConsumptionDetail(new Page<>(-1,-1),null).getRecords(); |
| | | if(CollectionUtils.isEmpty(list)){ |
| | | throw new RuntimeException("æ å¯¼åºæ°æ®"); |
| | | } |
| | | ExcelUtil<EnergyConsumptionDetailDto> util = new ExcelUtil<>(EnergyConsumptionDetailDto.class); |
| | | util.exportExcel(response, list, "è½èæè¡¨"); |
| | | } |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.energy.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; |
| | | import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.ruoyi.common.utils.poi.ExcelUtil; |
| | | import com.ruoyi.energy.mapper.EnergyConsumptionDetailMapper; |
| | | import com.ruoyi.energy.pojo.Energy; |
| | | import com.ruoyi.energy.mapper.EnergyMapper; |
| | | import com.ruoyi.energy.pojo.EnergyConsumptionDetail; |
| | | import com.ruoyi.energy.service.EnergyService; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.framework.web.domain.R; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * <p> |
| | | * è½æºç±»å æå¡å®ç°ç±» |
| | | * </p> |
| | | * |
| | | * @author è¯å¯¼è½¯ä»¶ï¼æ±èï¼æéå
¬å¸ |
| | | * @since 2026-03-10 10:50:18 |
| | | */ |
| | | @Service |
| | | public class EnergyServiceImpl extends ServiceImpl<EnergyMapper, Energy> implements EnergyService { |
| | | |
| | | @Autowired |
| | | private EnergyMapper energyMapper; |
| | | |
| | | @Autowired |
| | | private EnergyConsumptionDetailMapper energyConsumptionDetailMapper; |
| | | |
| | | @Override |
| | | public IPage<Energy> pageEnergy(Page<Energy> page, Energy energy) { |
| | | return energyMapper.pageEnergy(page,energy); |
| | | } |
| | | |
| | | @Override |
| | | public boolean batchDelete(List<Long> ids) { |
| | | //å
夿æ¯å¦å·²ç»æå¡«åçè½èæ°æ® |
| | | List<EnergyConsumptionDetail> energyConsumptionDetails = energyConsumptionDetailMapper.selectList(Wrappers.<EnergyConsumptionDetail>lambdaQuery().in(EnergyConsumptionDetail::getEnergyId, ids)); |
| | | if (CollectionUtils.isNotEmpty(energyConsumptionDetails)){ |
| | | throw new RuntimeException("éä¸çè½æºç±»åå·²æå¯¹åºçè½èæ°æ®,æ æ³è¿è¡å é¤!"); |
| | | } |
| | | return removeBatchByIds(ids); |
| | | } |
| | | |
| | | @Override |
| | | public R importData(MultipartFile file) { |
| | | try { |
| | | ExcelUtil<Energy> util = new ExcelUtil<Energy>(Energy.class); |
| | | List<Energy> energyList = util.importExcel(file.getInputStream()); |
| | | if(CollectionUtils.isEmpty(energyList)){ |
| | | return R.fail("模æ¿é误æå¯¼å
¥æ°æ®ä¸ºç©º"); |
| | | } |
| | | energyList.forEach(energy -> { |
| | | if (ObjectUtils.isEmpty(energy)) { |
| | | throw new RuntimeException("ä½¿ç¨æ¨¡æ¿è¿è¡å¯¼å
¥"); |
| | | } |
| | | if (ObjectUtils.isEmpty(energy.getEnergyTyep())) { |
| | | throw new RuntimeException("è½æºç±»åä¸è½ä¸ºç©º"); |
| | | } |
| | | }); |
| | | this.saveOrUpdateBatch(energyList); |
| | | return R.ok(true); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | return R.fail(e.getMessage()); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void export(HttpServletResponse response) { |
| | | List<Energy> list = energyMapper.selectList(null); |
| | | if(CollectionUtils.isEmpty(list)){ |
| | | throw new RuntimeException("æ å¯¼åºæ°æ®"); |
| | | } |
| | | ExcelUtil<Energy> util = new ExcelUtil<>(Energy.class); |
| | | util.exportExcel(response, list, "è½æºç±»å"); |
| | | } |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="com.ruoyi.energy.mapper.EnergyConsumptionDetailMapper"> |
| | | |
| | | <!-- éç¨æ¥è¯¢æ å°ç»æ --> |
| | | <resultMap id="BaseResultMap" type="com.ruoyi.energy.pojo.EnergyConsumptionDetail"> |
| | | <id column="id" property="id"/> |
| | | <result column="energy_id" property="energyId"/> |
| | | <result column="type" property="type"/> |
| | | <result column="meter_reading_location" property="meterReadingLocation"/> |
| | | <result column="meter_reading_date" property="meterReadingDate"/> |
| | | <result column="start_code" property="startCode"/> |
| | | <result column="stop_code" property="stopCode"/> |
| | | <result column="dosage" property="dosage"/> |
| | | <result column="remark" property="remark"/> |
| | | <result column="create_time" property="createTime"/> |
| | | <result column="update_time" property="updateTime"/> |
| | | <result column="create_user" property="createUser"/> |
| | | <result column="update_user" property="updateUser"/> |
| | | </resultMap> |
| | | <select id="pageEnergyConsumptionDetail" |
| | | resultType="com.ruoyi.energy.dto.EnergyConsumptionDetailDto"> |
| | | select * |
| | | from (select ecd.*, e.energy_tyep, e.energy_name, e.unit, su.nick_name createUserName |
| | | from energy_consumption_detail ecd |
| | | left join energy e on ecd.energy_id = e.id |
| | | left join sys_user su on ecd.create_user = su.user_id) A |
| | | <where> |
| | | <if test="c.energyTyep != null and c.energyTyep != ''"> |
| | | and energy_tyep like concat('%',#{c.energyTyep},'%') |
| | | </if> |
| | | <if test="c.energyName != null and c.energyName != ''"> |
| | | and energy_name like concat('%',#{c.energyName},'%') |
| | | </if> |
| | | <if test="c.meterReadingDate != null and c.meterReadingDate != ''"> |
| | | and meter_reading_date =#{c.meterReadingDate} |
| | | </if> |
| | | </where> |
| | | </select> |
| | | |
| | | </mapper> |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="com.ruoyi.energy.mapper.EnergyMapper"> |
| | | |
| | | <!-- éç¨æ¥è¯¢æ å°ç»æ --> |
| | | <resultMap id="BaseResultMap" type="com.ruoyi.energy.pojo.Energy"> |
| | | <id column="id" property="id"/> |
| | | <result column="energy_tyep" property="energyTyep"/> |
| | | <result column="energy_name" property="energyName"/> |
| | | <result column="unit" property="unit"/> |
| | | <result column="unit_price" property="unitPrice"/> |
| | | <result column="remark" property="remark"/> |
| | | <result column="create_time" property="createTime"/> |
| | | <result column="update_time" property="updateTime"/> |
| | | <result column="create_user" property="createUser"/> |
| | | <result column="update_user" property="updateUser"/> |
| | | </resultMap> |
| | | <select id="pageEnergy" resultType="com.ruoyi.energy.pojo.Energy"> |
| | | select * from (select e.*, su.nick_name createUserName |
| | | from energy e |
| | | left join sys_user su on e.create_user = su.user_id)A |
| | | <where> |
| | | <if test="c.energyTyep != null and c.energyTyep != ''"> |
| | | and energy_tyep like concat('%',#{c.energyTyep},'%') |
| | | </if> |
| | | <if test="c.energyName != null and c.energyName != ''"> |
| | | and energy_name like concat('%',#{c.energyName},'%') |
| | | </if> |
| | | </where> |
| | | </select> |
| | | |
| | | </mapper> |