From 9c6a8dc3e69c878ed7491a72fbd633056ee610ee Mon Sep 17 00:00:00 2001 From: ALEI_ALEI Date: Wed, 18 Dec 2024 17:46:56 +0800 Subject: [PATCH] =?UTF-8?q?=E7=81=8C=E6=BA=89=E8=AE=B0=E5=BD=95=E7=9A=84?= =?UTF-8?q?=E9=80=BB=E8=BE=91=E5=AE=9E=E7=8E=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../UserIrrigationRecordController.java | 132 +++++++++++++++ .../domain/UserIrrigationRecord.java | 114 +++++++++++++ .../domain/dto/UserIrrigationRecordDto.java | 17 ++ .../mapper/UserIrrigationRecordMapper.java | 71 ++++++++ .../service/IUserIrrigationRecordService.java | 78 +++++++++ .../impl/UserIrrigationRecordServiceImpl.java | 140 ++++++++++++++++ .../UserIrrigationRecordMapper.xml | 154 ++++++++++++++++++ 7 files changed, 706 insertions(+) create mode 100644 fastbee-open-api/src/main/java/com/fastbee/data/controller/userRecharge/UserIrrigationRecordController.java create mode 100644 fastbee-service/fastbee-rechargecard-service/src/main/java/com/fastbee/rechargecard/domain/UserIrrigationRecord.java create mode 100644 fastbee-service/fastbee-rechargecard-service/src/main/java/com/fastbee/rechargecard/domain/dto/UserIrrigationRecordDto.java create mode 100644 fastbee-service/fastbee-rechargecard-service/src/main/java/com/fastbee/rechargecard/mapper/UserIrrigationRecordMapper.java create mode 100644 fastbee-service/fastbee-rechargecard-service/src/main/java/com/fastbee/rechargecard/service/IUserIrrigationRecordService.java create mode 100644 fastbee-service/fastbee-rechargecard-service/src/main/java/com/fastbee/rechargecard/service/impl/UserIrrigationRecordServiceImpl.java create mode 100644 fastbee-service/fastbee-rechargecard-service/src/main/resources/mapper/rechargecard/UserIrrigationRecordMapper.xml diff --git a/fastbee-open-api/src/main/java/com/fastbee/data/controller/userRecharge/UserIrrigationRecordController.java b/fastbee-open-api/src/main/java/com/fastbee/data/controller/userRecharge/UserIrrigationRecordController.java new file mode 100644 index 0000000..eafd3f7 --- /dev/null +++ b/fastbee-open-api/src/main/java/com/fastbee/data/controller/userRecharge/UserIrrigationRecordController.java @@ -0,0 +1,132 @@ +package com.fastbee.data.controller.userRecharge; + +import java.util.List; +import javax.servlet.http.HttpServletResponse; + +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; +import com.fastbee.common.annotation.Log; +import com.fastbee.common.core.controller.BaseController; +import com.fastbee.common.core.domain.AjaxResult; +import com.fastbee.common.enums.BusinessType; +import com.fastbee.rechargecard.domain.UserIrrigationRecord; +import com.fastbee.rechargecard.service.IUserIrrigationRecordService; +import com.fastbee.common.utils.poi.ExcelUtil; +import com.fastbee.common.core.page.TableDataInfo; + +/** + * 灌溉记录Controller + * + * @author kerwincui + * @date 2024-12-18 + */ +@RestController +@RequestMapping("/rechargecard/record") +@Api(tags = "灌溉记录") +public class UserIrrigationRecordController extends BaseController +{ + @Autowired + private IUserIrrigationRecordService userIrrigationRecordService; + + /** + * 查询灌溉记录列表 + */ + @PreAuthorize("@ss.hasPermi('rechargecard:record:list')") + @GetMapping("/list") + @ApiOperation("查询灌溉记录列表") + public TableDataInfo list(UserIrrigationRecord userIrrigationRecord) + { + startPage(); + List list = userIrrigationRecordService.selectUserIrrigationRecordList(userIrrigationRecord); + return getDataTable(list); + } + + /** + * 获取用户灌溉记录详细信息列表 + */ + @PreAuthorize("@ss.hasPermi('rechargecard:record:query')") + @GetMapping(value = "/list/{cardNumber}") + @ApiOperation("获取灌溉记录详细信息") + public AjaxResult getInfo(@PathVariable("cardNumber") String cardNumber) + { + return success(userIrrigationRecordService.selectUserIrrigationRecordListBycardNumber(cardNumber)); + } + + /** + * 获取用户灌溉记录展示详细信息列表 + */ + @PreAuthorize("@ss.hasPermi('rechargecard:record:query')") + @GetMapping(value = "/list/show/{cardNumber}") + @ApiOperation("获取灌溉记录详细信息") + public AjaxResult getShowInfo(@PathVariable("cardNumber") String cardNumber) + { + return success(userIrrigationRecordService.selectUserIrrigationRecordListShowBycardNumber(cardNumber)); + } + + /** + * 导出灌溉记录列表 + */ + @ApiOperation("导出灌溉记录列表") + @PreAuthorize("@ss.hasPermi('rechargecard:record:export')") + @PostMapping("/export") + public void export(HttpServletResponse response, UserIrrigationRecord userIrrigationRecord) + { + List list = userIrrigationRecordService.selectUserIrrigationRecordList(userIrrigationRecord); + ExcelUtil util = new ExcelUtil(UserIrrigationRecord.class); + util.exportExcel(response, list, "灌溉记录数据"); + } + + /** + * 获取灌溉记录详细信息 + */ + @PreAuthorize("@ss.hasPermi('rechargecard:record:query')") + @GetMapping(value = "/{id}") + @ApiOperation("获取灌溉记录详细信息") + public AjaxResult getInfo(@PathVariable("id") Long id) + { + return success(userIrrigationRecordService.selectUserIrrigationRecordById(id)); + } + + /** + * 新增灌溉记录 + */ + @PreAuthorize("@ss.hasPermi('rechargecard:record:add')") + @PostMapping + @ApiOperation("新增灌溉记录") + public AjaxResult add(@RequestBody UserIrrigationRecord userIrrigationRecord) + { + return toAjax(userIrrigationRecordService.insertUserIrrigationRecord(userIrrigationRecord)); + } + + /** + * 修改灌溉记录 + */ + @PreAuthorize("@ss.hasPermi('rechargecard:record:edit')") + @PutMapping + @ApiOperation("修改灌溉记录") + public AjaxResult edit(@RequestBody UserIrrigationRecord userIrrigationRecord) + { + return toAjax(userIrrigationRecordService.updateUserIrrigationRecord(userIrrigationRecord)); + } + + /** + * 删除灌溉记录 + */ + @PreAuthorize("@ss.hasPermi('rechargecard:record:remove')") + @DeleteMapping("/{ids}") + @ApiOperation("删除灌溉记录") + public AjaxResult remove(@PathVariable Long[] ids) + { + return toAjax(userIrrigationRecordService.deleteUserIrrigationRecordByIds(ids)); + } +} diff --git a/fastbee-service/fastbee-rechargecard-service/src/main/java/com/fastbee/rechargecard/domain/UserIrrigationRecord.java b/fastbee-service/fastbee-rechargecard-service/src/main/java/com/fastbee/rechargecard/domain/UserIrrigationRecord.java new file mode 100644 index 0000000..8138c34 --- /dev/null +++ b/fastbee-service/fastbee-rechargecard-service/src/main/java/com/fastbee/rechargecard/domain/UserIrrigationRecord.java @@ -0,0 +1,114 @@ +package com.fastbee.rechargecard.domain; + +import java.math.BigDecimal; +import java.util.Date; +import com.fasterxml.jackson.annotation.JsonFormat; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; +import com.fastbee.common.annotation.Excel; +import com.fastbee.common.core.domain.BaseEntity; + +/** + * 灌溉记录对象 user_irrigation_record + * + * @author kerwincui + * @date 2024-12-18 + */ +@ApiModel(value = "UserIrrigationRecord",description = "灌溉记录 user_irrigation_record") +@Data +@EqualsAndHashCode(callSuper = true) +public class UserIrrigationRecord extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** 序号 */ + private Long id; + + /** 用户id,关联用户 */ + @Excel(name = "用户id,关联用户") + @ApiModelProperty("用户id,关联用户") + private Long userId; + + /** 设备编码 */ + @Excel(name = "设备编码") + @ApiModelProperty("设备编码") + private String deviceNumber; + + /** 所属项目id */ + @Excel(name = "所属项目id") + @ApiModelProperty("所属项目id") + private Long projectId; + + /** 所属机构 */ + @Excel(name = "所属机构") + @ApiModelProperty("所属机构") + private Long deptId; + + /** 购水卡号 */ + @Excel(name = "购水卡号") + @ApiModelProperty("购水卡号") + private String cardNumber; + + /** 区域号 */ + @Excel(name = "区域号") + @ApiModelProperty("区域号") + private String areaCode; + + /** 本次用水量,以立方米为单位 */ + @Excel(name = "本次用水量,以立方米为单位") + @ApiModelProperty("本次用水量,以立方米为单位") + private BigDecimal curFlow; + + /** 本次用电量 */ + @Excel(name = "本次用电量") + @ApiModelProperty("本次用电量") + private BigDecimal curEle; + + /** 卡内余额 */ + @Excel(name = "卡内余额") + @ApiModelProperty("卡内余额") + private BigDecimal balance; + + /** 开泵时间 */ + @JsonFormat(pattern = "yyyy-MM-dd") + @Excel(name = "开泵时间", width = 30, dateFormat = "yyyy-MM-dd") + @ApiModelProperty("开泵时间") + private Date startTime; + + /** 关泵时间 */ + @JsonFormat(pattern = "yyyy-MM-dd") + @Excel(name = "关泵时间", width = 30, dateFormat = "yyyy-MM-dd") + @ApiModelProperty("关泵时间") + private Date endTime; + + /** 灌溉持续时间 */ + @Excel(name = "灌溉持续时间") + @ApiModelProperty("灌溉持续时间") + private BigDecimal duration; + + /** 灌溉时间单位,0=小时、1=天、2=周、3=月、4=季度、5=年 */ + @Excel(name = "灌溉时间单位,0=小时、1=天、2=周、3=月、4=季度、5=年") + @ApiModelProperty("灌溉时间单位,0=小时、1=天、2=周、3=月、4=季度、5=年") + private Integer unit; + + /** 灌溉上报时间 */ + @JsonFormat(pattern = "yyyy-MM-dd") + @Excel(name = "灌溉上报时间", width = 30, dateFormat = "yyyy-MM-dd") + @ApiModelProperty("灌溉上报时间") + private Date lastTime; + + /** 灌溉状态,1=开始灌溉,2=结束灌溉 */ + @Excel(name = "灌溉状态,1=开始灌溉,2=结束灌溉") + @ApiModelProperty("灌溉状态,1=开始灌溉,2=结束灌溉") + private Integer status; + + /** 关于灌溉记录的额外信息或备注 */ + @Excel(name = "关于灌溉记录的额外信息或备注") + @ApiModelProperty("关于灌溉记录的额外信息或备注") + private String remarks; + +} diff --git a/fastbee-service/fastbee-rechargecard-service/src/main/java/com/fastbee/rechargecard/domain/dto/UserIrrigationRecordDto.java b/fastbee-service/fastbee-rechargecard-service/src/main/java/com/fastbee/rechargecard/domain/dto/UserIrrigationRecordDto.java new file mode 100644 index 0000000..9574aac --- /dev/null +++ b/fastbee-service/fastbee-rechargecard-service/src/main/java/com/fastbee/rechargecard/domain/dto/UserIrrigationRecordDto.java @@ -0,0 +1,17 @@ +package com.fastbee.rechargecard.domain.dto; + +import cn.hutool.core.date.DateTime; +import com.fastbee.rechargecard.domain.UserIrrigationRecord; + +import java.math.BigDecimal; +import java.util.Date; + +public class UserIrrigationRecordDto +{ + public String userName; + public String deviceName; + public String cardNumber; + public BigDecimal flow; + public Date startTime; + public Date endTime; +} diff --git a/fastbee-service/fastbee-rechargecard-service/src/main/java/com/fastbee/rechargecard/mapper/UserIrrigationRecordMapper.java b/fastbee-service/fastbee-rechargecard-service/src/main/java/com/fastbee/rechargecard/mapper/UserIrrigationRecordMapper.java new file mode 100644 index 0000000..23f8b23 --- /dev/null +++ b/fastbee-service/fastbee-rechargecard-service/src/main/java/com/fastbee/rechargecard/mapper/UserIrrigationRecordMapper.java @@ -0,0 +1,71 @@ +package com.fastbee.rechargecard.mapper; + +import java.util.List; +import com.fastbee.rechargecard.domain.UserIrrigationRecord; +import org.apache.ibatis.annotations.Mapper; + +/** + * 灌溉记录Mapper接口 + * + * @author kerwincui + * @date 2024-12-18 + */ +@Mapper +public interface UserIrrigationRecordMapper +{ + /** + * 查询用户灌溉记录列表 + * + * @param cardNumber + * @return 灌溉记录集合 + */ + public List selectUserIrrigationRecordListBycardNumber(String cardNumber); + + /** + * 查询灌溉记录 + * + * @param id 灌溉记录主键 + * @return 灌溉记录 + */ + public UserIrrigationRecord selectUserIrrigationRecordById(Long id); + + /** + * 查询灌溉记录列表 + * + * @param userIrrigationRecord 灌溉记录 + * @return 灌溉记录集合 + */ + public List selectUserIrrigationRecordList(UserIrrigationRecord userIrrigationRecord); + + /** + * 新增灌溉记录 + * + * @param userIrrigationRecord 灌溉记录 + * @return 结果 + */ + public int insertUserIrrigationRecord(UserIrrigationRecord userIrrigationRecord); + + /** + * 修改灌溉记录 + * + * @param userIrrigationRecord 灌溉记录 + * @return 结果 + */ + public int updateUserIrrigationRecord(UserIrrigationRecord userIrrigationRecord); + + /** + * 删除灌溉记录 + * + * @param id 灌溉记录主键 + * @return 结果 + */ + public int deleteUserIrrigationRecordById(Long id); + + /** + * 批量删除灌溉记录 + * + * @param ids 需要删除的数据主键集合 + * @return 结果 + */ + public int deleteUserIrrigationRecordByIds(Long[] ids); +} diff --git a/fastbee-service/fastbee-rechargecard-service/src/main/java/com/fastbee/rechargecard/service/IUserIrrigationRecordService.java b/fastbee-service/fastbee-rechargecard-service/src/main/java/com/fastbee/rechargecard/service/IUserIrrigationRecordService.java new file mode 100644 index 0000000..99f348b --- /dev/null +++ b/fastbee-service/fastbee-rechargecard-service/src/main/java/com/fastbee/rechargecard/service/IUserIrrigationRecordService.java @@ -0,0 +1,78 @@ +package com.fastbee.rechargecard.service; + +import java.util.List; +import com.fastbee.rechargecard.domain.UserIrrigationRecord; +import com.fastbee.rechargecard.domain.dto.UserIrrigationRecordDto; + +/** + * 灌溉记录Service接口 + * + * @author kerwincui + * @date 2024-12-18 + */ +public interface IUserIrrigationRecordService +{ + /** + * 查询用户灌溉展示记录列表 + * + * @param cardNumber 卡号 + * @return 灌溉记录 + */ + public List selectUserIrrigationRecordListShowBycardNumber(String cardNumber); + + /** + * 查询用户灌溉记录列表 + * + * @param cardNumber 卡号 + * @return 灌溉记录 + */ + public List selectUserIrrigationRecordListBycardNumber(String cardNumber); + + /** + * 查询灌溉记录 + * + * @param id 灌溉记录主键 + * @return 灌溉记录 + */ + public UserIrrigationRecord selectUserIrrigationRecordById(Long id); + + /** + * 查询灌溉记录列表 + * + * @param userIrrigationRecord 灌溉记录 + * @return 灌溉记录集合 + */ + public List selectUserIrrigationRecordList(UserIrrigationRecord userIrrigationRecord); + + /** + * 新增灌溉记录 + * + * @param userIrrigationRecord 灌溉记录 + * @return 结果 + */ + public int insertUserIrrigationRecord(UserIrrigationRecord userIrrigationRecord); + + /** + * 修改灌溉记录 + * + * @param userIrrigationRecord 灌溉记录 + * @return 结果 + */ + public int updateUserIrrigationRecord(UserIrrigationRecord userIrrigationRecord); + + /** + * 批量删除灌溉记录 + * + * @param ids 需要删除的灌溉记录主键集合 + * @return 结果 + */ + public int deleteUserIrrigationRecordByIds(Long[] ids); + + /** + * 删除灌溉记录信息 + * + * @param id 灌溉记录主键 + * @return 结果 + */ + public int deleteUserIrrigationRecordById(Long id); +} diff --git a/fastbee-service/fastbee-rechargecard-service/src/main/java/com/fastbee/rechargecard/service/impl/UserIrrigationRecordServiceImpl.java b/fastbee-service/fastbee-rechargecard-service/src/main/java/com/fastbee/rechargecard/service/impl/UserIrrigationRecordServiceImpl.java new file mode 100644 index 0000000..941c8d0 --- /dev/null +++ b/fastbee-service/fastbee-rechargecard-service/src/main/java/com/fastbee/rechargecard/service/impl/UserIrrigationRecordServiceImpl.java @@ -0,0 +1,140 @@ +package com.fastbee.rechargecard.service.impl; + +import java.util.ArrayList; +import java.util.List; +import com.fastbee.common.utils.DateUtils; +import com.fastbee.iot.mapper.DeviceMapper; +import com.fastbee.rechargecard.domain.dto.UserIrrigationRecordDto; +import com.fastbee.system.mapper.SysUserMapper; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import com.fastbee.rechargecard.mapper.UserIrrigationRecordMapper; +import com.fastbee.rechargecard.domain.UserIrrigationRecord; +import com.fastbee.rechargecard.service.IUserIrrigationRecordService; + +/** + * 灌溉记录Service业务层处理 + * + * @author kerwincui + * @date 2024-12-18 + */ +@Service +public class UserIrrigationRecordServiceImpl implements IUserIrrigationRecordService +{ + @Autowired + private UserIrrigationRecordMapper userIrrigationRecordMapper; + @Autowired + private SysUserMapper sysUserMapper; + @Autowired + private DeviceMapper deviceMapper; + + /** + * 获取用户灌溉记录列表 + * @param cardNumber 卡号 + * @return + */ + @Override + public List selectUserIrrigationRecordListBycardNumber(String cardNumber) + { + return userIrrigationRecordMapper.selectUserIrrigationRecordListBycardNumber(cardNumber); + } + + /** + * 获取用户灌溉记录展示数据列表 + * @param cardNumber 卡号 + * @return + */ + @Override + public List selectUserIrrigationRecordListShowBycardNumber(String cardNumber) + { + List result=new ArrayList<>(); + List list=userIrrigationRecordMapper.selectUserIrrigationRecordListBycardNumber(cardNumber); + for(int i=0;i selectUserIrrigationRecordList(UserIrrigationRecord userIrrigationRecord) + { + return userIrrigationRecordMapper.selectUserIrrigationRecordList(userIrrigationRecord); + } + + /** + * 新增灌溉记录 + * + * @param userIrrigationRecord 灌溉记录 + * @return 结果 + */ + @Override + public int insertUserIrrigationRecord(UserIrrigationRecord userIrrigationRecord) + { + userIrrigationRecord.setCreateTime(DateUtils.getNowDate()); + return userIrrigationRecordMapper.insertUserIrrigationRecord(userIrrigationRecord); + } + + /** + * 修改灌溉记录 + * + * @param userIrrigationRecord 灌溉记录 + * @return 结果 + */ + @Override + public int updateUserIrrigationRecord(UserIrrigationRecord userIrrigationRecord) + { + userIrrigationRecord.setUpdateTime(DateUtils.getNowDate()); + return userIrrigationRecordMapper.updateUserIrrigationRecord(userIrrigationRecord); + } + + /** + * 批量删除灌溉记录 + * + * @param ids 需要删除的灌溉记录主键 + * @return 结果 + */ + @Override + public int deleteUserIrrigationRecordByIds(Long[] ids) + { + return userIrrigationRecordMapper.deleteUserIrrigationRecordByIds(ids); + } + + /** + * 删除灌溉记录信息 + * + * @param id 灌溉记录主键 + * @return 结果 + */ + @Override + public int deleteUserIrrigationRecordById(Long id) + { + return userIrrigationRecordMapper.deleteUserIrrigationRecordById(id); + } +} diff --git a/fastbee-service/fastbee-rechargecard-service/src/main/resources/mapper/rechargecard/UserIrrigationRecordMapper.xml b/fastbee-service/fastbee-rechargecard-service/src/main/resources/mapper/rechargecard/UserIrrigationRecordMapper.xml new file mode 100644 index 0000000..dc8348a --- /dev/null +++ b/fastbee-service/fastbee-rechargecard-service/src/main/resources/mapper/rechargecard/UserIrrigationRecordMapper.xml @@ -0,0 +1,154 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + select id, user_id, device_number, project_id, dept_id, card_number, area_code, cur_flow, cur_ele, balance, start_time, end_time, duration, unit, last_time, status, remarks, create_time, update_time, create_by, update_by from user_irrigation_record + + + + + + + + + + insert into user_irrigation_record + + user_id, + device_number, + project_id, + dept_id, + card_number, + area_code, + cur_flow, + cur_ele, + balance, + start_time, + end_time, + duration, + unit, + last_time, + status, + remarks, + create_time, + update_time, + create_by, + update_by, + + + #{userId}, + #{deviceNumber}, + #{projectId}, + #{deptId}, + #{cardNumber}, + #{areaCode}, + #{curFlow}, + #{curEle}, + #{balance}, + #{startTime}, + #{endTime}, + #{duration}, + #{unit}, + #{lastTime}, + #{status}, + #{remarks}, + #{createTime}, + #{updateTime}, + #{createBy}, + #{updateBy}, + + + + + update user_irrigation_record + + user_id = #{userId}, + device_number = #{deviceNumber}, + project_id = #{projectId}, + dept_id = #{deptId}, + card_number = #{cardNumber}, + area_code = #{areaCode}, + cur_flow = #{curFlow}, + cur_ele = #{curEle}, + balance = #{balance}, + start_time = #{startTime}, + end_time = #{endTime}, + duration = #{duration}, + unit = #{unit}, + last_time = #{lastTime}, + status = #{status}, + remarks = #{remarks}, + create_time = #{createTime}, + update_time = #{updateTime}, + create_by = #{createBy}, + update_by = #{updateBy}, + + where id = #{id} + + + + delete from user_irrigation_record where id = #{id} + + + + delete from user_irrigation_record where id in + + #{id} + + + \ No newline at end of file