fix: 健康管理系统,新增婴幼儿管理-吃奶记录。

This commit is contained in:
tianyongbao
2025-02-01 18:31:33 +08:00
parent 83d11768cb
commit 5d7416445b
8 changed files with 646 additions and 0 deletions

View File

@@ -0,0 +1,116 @@
package com.intc.health.controller;
import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import javax.annotation.Resource;
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.intc.common.log.annotation.Log;
import com.intc.common.log.enums.BusinessType;
import com.intc.common.security.annotation.RequiresPermissions;
import com.intc.health.domain.HealthMilkPowderRecord;
import com.intc.health.domain.vo.HealthMilkPowderRecordVo;
import com.intc.health.domain.dto.HealthMilkPowderRecordDto;
import com.intc.health.service.IHealthMilkPowderRecordService;
import com.intc.common.core.web.controller.BaseController;
import com.intc.common.core.web.domain.AjaxResult;
import com.intc.common.core.utils.poi.ExcelUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import com.intc.common.core.web.page.TableDataInfo;
/**
* 吃奶记录Controller
*
* @author tianyongbao
* @date 2025-02-01
*/
@Api(tags=" 吃奶记录")
@RestController
@RequestMapping("/milkPowderRecord")
public class HealthMilkPowderRecordController extends BaseController
{
@Resource
private IHealthMilkPowderRecordService healthMilkPowderRecordService;
/**
* 查询吃奶记录列表
*/
@ApiOperation(value="查询吃奶记录列表",response = HealthMilkPowderRecordVo.class)
@RequiresPermissions("health:milkPowderRecord:list")
@GetMapping("/list")
public TableDataInfo list(HealthMilkPowderRecordDto healthMilkPowderRecordDto)
{
startPage();
List<HealthMilkPowderRecordVo> list = healthMilkPowderRecordService.selectHealthMilkPowderRecordList(healthMilkPowderRecordDto);
return getDataTable(list);
}
/**
* 导出吃奶记录列表
*/
@ApiOperation(value="导出吃奶记录列表")
@RequiresPermissions("health:milkPowderRecord:export")
@Log(title = "吃奶记录", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, HealthMilkPowderRecordDto healthMilkPowderRecordDto)
{
List<HealthMilkPowderRecordVo> list = healthMilkPowderRecordService.selectHealthMilkPowderRecordList(healthMilkPowderRecordDto);
ExcelUtil<HealthMilkPowderRecordVo> util = new ExcelUtil<HealthMilkPowderRecordVo>(HealthMilkPowderRecordVo.class);
util.exportExcel(response, list, "吃奶记录数据");
}
/**
* 获取吃奶记录详细信息
*/
@ApiOperation(value="获取吃奶记录详细信息")
@RequiresPermissions("health:milkPowderRecord:query")
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") Long id)
{
return success(healthMilkPowderRecordService.selectHealthMilkPowderRecordById(id));
}
/**
* 新增吃奶记录
*/
@ApiOperation(value="新增吃奶记录")
@RequiresPermissions("health:milkPowderRecord:add")
@Log(title = "吃奶记录", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody HealthMilkPowderRecord healthMilkPowderRecord)
{
return toAjax(healthMilkPowderRecordService.insertHealthMilkPowderRecord(healthMilkPowderRecord));
}
/**
* 修改吃奶记录
*/
@ApiOperation(value="修改吃奶记录")
@RequiresPermissions("health:milkPowderRecord:edit")
@Log(title = "吃奶记录", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody HealthMilkPowderRecord healthMilkPowderRecord)
{
return toAjax(healthMilkPowderRecordService.updateHealthMilkPowderRecord(healthMilkPowderRecord));
}
/**
* 删除吃奶记录
*/
@ApiOperation(value="删除吃奶记录")
@RequiresPermissions("health:milkPowderRecord:remove")
@Log(title = "吃奶记录", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Long[] ids)
{
return toAjax(healthMilkPowderRecordService.deleteHealthMilkPowderRecordByIds(ids));
}
}

View File

@@ -0,0 +1,74 @@
package com.intc.health.domain;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.intc.common.core.annotation.Excel;
import com.intc.common.core.web.domain.BaseEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import javax.validation.constraints.NotNull;
import java.util.Date;
/**
* 吃奶记录对象 health_milk_powder_record
*
* @author tianyongbao
* @date 2025-02-01
*/
@ApiModel("吃奶记录对象")
@Data
public class HealthMilkPowderRecord extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** 主键 */
private Long id;
/** 删除标志0代表存在 1代表删除 */
private String delFlag;
/** 吃奶时间 */
@ApiModelProperty(value="吃奶时间)")
@NotNull(message="吃奶时间不能为空")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@Excel(name = "吃奶时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
private Date sucklesTime;
/** 吃奶量 */
@ApiModelProperty(value="吃奶量)")
@NotNull(message="吃奶量不能为空")
@Excel(name = "吃奶量")
private Double consumption;
/** 人员id */
@ApiModelProperty(value="人员id)")
@NotNull(message="人员id不能为空")
@Excel(name = "人员id")
private Long personId;
/** 奶粉品牌 */
private String milkPowderBrand;
/** 几勺 */
private Double spoonful;
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("id", getId())
.append("createBy", getCreateBy())
.append("createTime", getCreateTime())
.append("updateBy", getUpdateBy())
.append("updateTime", getUpdateTime())
.append("delFlag", getDelFlag())
.append("remark", getRemark())
.append("sucklesTime", getSucklesTime())
.append("consumption", getConsumption())
.append("personId", getPersonId())
.append("milkPowderBrand", getMilkPowderBrand())
.append("spoonful", getSpoonful())
.toString();
}
}

View File

@@ -0,0 +1,45 @@
package com.intc.health.domain.dto;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.intc.common.core.web.domain.BaseEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
/**
* 吃奶记录Dto对象 health_milk_powder_record
*
* @author tianyongbao
* @date 2025-02-01
*/
@ApiModel("吃奶记录Dto对象")
@Data
public class HealthMilkPowderRecordDto extends BaseEntity implements Serializable
{
private static final long serialVersionUID = 1L;
/** 吃奶时间 */
@ApiModelProperty(value="吃奶时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date sucklesTime;
/** 人员id */
@ApiModelProperty(value="人员id")
private Long personId;
/** 奶粉品牌 */
@ApiModelProperty(value="奶粉品牌")
private String milkPowderBrand;
/** 开始日期 */
@ApiModelProperty(value="开始日期")
private String startTime;
/** 结束日期 */
@ApiModelProperty(value="结束日期")
private String endTime;
}

View File

@@ -0,0 +1,23 @@
package com.intc.health.domain.vo;
import com.intc.common.core.annotation.Excel;
import com.intc.health.domain.HealthMilkPowderRecord;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import io.swagger.annotations.ApiModel;
/**
* 吃奶记录Vo对象 health_milk_powder_record
*
* @author tianyongbao
* @date 2025-02-01
*/
@ApiModel("吃奶记录Vo对象")
@Data
public class HealthMilkPowderRecordVo extends HealthMilkPowderRecord
{
/** 人员名称 */
@ApiModelProperty(value="人员姓名)")
@Excel(name = "人员姓名")
private String personName;
}

View File

@@ -0,0 +1,82 @@
package com.intc.health.mapper;
import com.intc.common.datascope.annotation.DataScope;
import com.intc.health.domain.HealthMilkPowderRecord;
import com.intc.health.domain.dto.HealthMilkPowderRecordDto;
import com.intc.health.domain.vo.HealthMilkPowderRecordVo;
import java.util.List;
/**
* 吃奶记录Mapper接口
*
* @author tianyongbao
* @date 2025-02-01
*/
public interface HealthMilkPowderRecordMapper
{
/**
* 查询吃奶记录
*
* @param id 吃奶记录主键
* @return 吃奶记录
*/
public HealthMilkPowderRecordVo selectHealthMilkPowderRecordById(Long id);
/**
* 查询吃奶记录列表
*
* @param healthMilkPowderRecordDto 吃奶记录
* @return 吃奶记录集合
*/
@DataScope(businessAlias = "a")
public List<HealthMilkPowderRecordVo> selectHealthMilkPowderRecordList(HealthMilkPowderRecordDto healthMilkPowderRecordDto);
/**
* 新增吃奶记录
*
* @param healthMilkPowderRecord 吃奶记录
* @return 结果
*/
public int insertHealthMilkPowderRecord(HealthMilkPowderRecord healthMilkPowderRecord);
/**
* 修改吃奶记录
*
* @param healthMilkPowderRecord 吃奶记录
* @return 结果
*/
public int updateHealthMilkPowderRecord(HealthMilkPowderRecord healthMilkPowderRecord);
/**
* 删除吃奶记录
*
* @param id 吃奶记录主键
* @return 结果
*/
public int deleteHealthMilkPowderRecordById(Long id);
/**
* 批量删除吃奶记录
*
* @param ids 需要删除的数据主键集合
* @return 结果
*/
public int deleteHealthMilkPowderRecordByIds(Long[] ids);
/**
* 逻辑删除吃奶记录
*
* @param id 吃奶记录主键
* @return 结果
*/
public int removeHealthMilkPowderRecordById(Long id);
/**
* 批量逻辑删除吃奶记录
*
* @param ids 需要删除的数据主键集合
* @return 结果
*/
public int removeHealthMilkPowderRecordByIds(Long[] ids);
}

View File

@@ -0,0 +1,63 @@
package com.intc.health.service;
import java.util.List;
import com.intc.health.domain.HealthMilkPowderRecord;
import com.intc.health.domain.dto.HealthMilkPowderRecordDto;
import com.intc.health.domain.vo.HealthMilkPowderRecordVo;
/**
* 吃奶记录Service接口
*
* @author tianyongbao
* @date 2025-02-01
*/
public interface IHealthMilkPowderRecordService
{
/**
* 查询吃奶记录
*
* @param id 吃奶记录主键
* @return 吃奶记录
*/
public HealthMilkPowderRecordVo selectHealthMilkPowderRecordById(Long id);
/**
* 查询吃奶记录列表
*
* @param healthMilkPowderRecordDto 吃奶记录
* @return 吃奶记录集合
*/
public List<HealthMilkPowderRecordVo> selectHealthMilkPowderRecordList(HealthMilkPowderRecordDto healthMilkPowderRecordDto);
/**
* 新增吃奶记录
*
* @param healthMilkPowderRecord 吃奶记录
* @return 结果
*/
public int insertHealthMilkPowderRecord(HealthMilkPowderRecord healthMilkPowderRecord);
/**
* 修改吃奶记录
*
* @param healthMilkPowderRecord 吃奶记录
* @return 结果
*/
public int updateHealthMilkPowderRecord(HealthMilkPowderRecord healthMilkPowderRecord);
/**
* 批量删除吃奶记录
*
* @param ids 需要删除的吃奶记录主键集合
* @return 结果
*/
public int deleteHealthMilkPowderRecordByIds(Long[] ids);
/**
* 删除吃奶记录信息
*
* @param id 吃奶记录主键
* @return 结果
*/
public int deleteHealthMilkPowderRecordById(Long id);
}

View File

@@ -0,0 +1,104 @@
package com.intc.health.service.impl;
import com.intc.common.core.utils.DateUtils;
import com.intc.common.core.utils.IdWorker;
import com.intc.common.security.utils.SecurityUtils;
import com.intc.health.domain.HealthMilkPowderRecord;
import com.intc.health.domain.dto.HealthMilkPowderRecordDto;
import com.intc.health.domain.vo.HealthMilkPowderRecordVo;
import com.intc.health.mapper.HealthMilkPowderRecordMapper;
import com.intc.health.service.IHealthMilkPowderRecordService;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
/**
* 吃奶记录Service业务层处理
*
* @author tianyongbao
* @date 2025-02-01
*/
@Service
public class HealthMilkPowderRecordServiceImpl implements IHealthMilkPowderRecordService
{
@Resource
private HealthMilkPowderRecordMapper healthMilkPowderRecordMapper;
/**
* 查询吃奶记录
*
* @param id 吃奶记录主键
* @return 吃奶记录
*/
@Override
public HealthMilkPowderRecordVo selectHealthMilkPowderRecordById(Long id)
{
return healthMilkPowderRecordMapper.selectHealthMilkPowderRecordById(id);
}
/**
* 查询吃奶记录列表
*
* @param healthMilkPowderRecordDto 吃奶记录
* @return 吃奶记录
*/
@Override
public List<HealthMilkPowderRecordVo> selectHealthMilkPowderRecordList(HealthMilkPowderRecordDto healthMilkPowderRecordDto)
{
return healthMilkPowderRecordMapper.selectHealthMilkPowderRecordList(healthMilkPowderRecordDto);
}
/**
* 新增吃奶记录
*
* @param healthMilkPowderRecord 吃奶记录
* @return 结果
*/
@Override
public int insertHealthMilkPowderRecord(HealthMilkPowderRecord healthMilkPowderRecord)
{
healthMilkPowderRecord.setCreateBy(SecurityUtils.getUsername());
healthMilkPowderRecord.setCreateTime(DateUtils.getNowDate());
healthMilkPowderRecord.setId(IdWorker.getId());
return healthMilkPowderRecordMapper.insertHealthMilkPowderRecord(healthMilkPowderRecord);
}
/**
* 修改吃奶记录
*
* @param healthMilkPowderRecord 吃奶记录
* @return 结果
*/
@Override
public int updateHealthMilkPowderRecord(HealthMilkPowderRecord healthMilkPowderRecord)
{
healthMilkPowderRecord.setUpdateBy(SecurityUtils.getUsername());
healthMilkPowderRecord.setUpdateTime(DateUtils.getNowDate());
return healthMilkPowderRecordMapper.updateHealthMilkPowderRecord(healthMilkPowderRecord);
}
/**
* 批量删除吃奶记录
*
* @param ids 需要删除的吃奶记录主键
* @return 结果
*/
@Override
public int deleteHealthMilkPowderRecordByIds(Long[] ids)
{
return healthMilkPowderRecordMapper.removeHealthMilkPowderRecordByIds(ids);
}
/**
* 删除吃奶记录信息
*
* @param id 吃奶记录主键
* @return 结果
*/
@Override
public int deleteHealthMilkPowderRecordById(Long id)
{
return healthMilkPowderRecordMapper.removeHealthMilkPowderRecordById(id);
}
}

View File

@@ -0,0 +1,139 @@
<?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.intc.health.mapper.HealthMilkPowderRecordMapper">
<resultMap type="HealthMilkPowderRecordVo" id="HealthMilkPowderRecordResult">
<result property="id" column="id" />
<result property="createBy" column="create_by" />
<result property="createTime" column="create_time" />
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" />
<result property="delFlag" column="del_flag" />
<result property="remark" column="remark" />
<result property="sucklesTime" column="suckles_time" />
<result property="consumption" column="consumption" />
<result property="personId" column="person_id" />
<result property="milkPowderBrand" column="milk_powder_brand" />
<result property="spoonful" column="spoonful" />
<result property="personName" column="person_name" />
</resultMap>
<sql id="selectHealthMilkPowderRecordVo">
select
a.id,
a.create_by,
a.create_time,
a.update_by,
a.update_time,
a.del_flag,
a.remark,
a.suckles_time,
a.consumption,
a.person_id,
a.milk_powder_brand,
a.spoonful,
hp."name" as person_name
from
health_milk_powder_record a
left join health_person hp on
hp.id = a.person_id
</sql>
<select id="selectHealthMilkPowderRecordList" parameterType="HealthMilkPowderRecordDto" resultMap="HealthMilkPowderRecordResult">
<include refid="selectHealthMilkPowderRecordVo"/>
<where>
a.del_flag='0'
<if test="sucklesTime != null "> and a.suckles_time = #{sucklesTime}</if>
<if test="personId != null "> and a.person_id = #{personId}</if>
<if test="endTime!=null and endTime !=''">
and #{endTime}>=to_char(a.suckles_time, 'yyyy-MM-dd')
</if>
<if test="startTime!=null and startTime !=''">
and to_char(a.suckles_time, 'yyyy-MM-dd')>=#{startTime}
</if>
<if test="milkPowderBrand != null and milkPowderBrand != ''"> and a.milk_powder_brand like '%'|| #{milkPowderBrand}||'%'</if>
</where>
<!-- 数据范围过滤 -->
${params.dataScope}
order by a.suckles_time desc
</select>
<select id="selectHealthMilkPowderRecordById" parameterType="Long" resultMap="HealthMilkPowderRecordResult">
<include refid="selectHealthMilkPowderRecordVo"/>
where a.id = #{id}
</select>
<insert id="insertHealthMilkPowderRecord" parameterType="HealthMilkPowderRecord">
insert into health_milk_powder_record
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">id,</if>
<if test="createBy != null">create_by,</if>
<if test="createTime != null">create_time,</if>
<if test="updateBy != null">update_by,</if>
<if test="updateTime != null">update_time,</if>
<if test="delFlag != null">del_flag,</if>
<if test="remark != null">remark,</if>
<if test="sucklesTime != null">suckles_time,</if>
<if test="consumption != null">consumption,</if>
<if test="personId != null">person_id,</if>
<if test="milkPowderBrand != null">milk_powder_brand,</if>
<if test="spoonful != null">spoonful,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">#{id},</if>
<if test="createBy != null">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateBy != null">#{updateBy},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="delFlag != null">#{delFlag},</if>
<if test="remark != null">#{remark},</if>
<if test="sucklesTime != null">#{sucklesTime},</if>
<if test="consumption != null">#{consumption},</if>
<if test="personId != null">#{personId},</if>
<if test="milkPowderBrand != null">#{milkPowderBrand},</if>
<if test="spoonful != null">#{spoonful},</if>
</trim>
</insert>
<update id="updateHealthMilkPowderRecord" parameterType="HealthMilkPowderRecord">
update health_milk_powder_record
<trim prefix="SET" suffixOverrides=",">
<if test="createBy != null">create_by = #{createBy},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="delFlag != null">del_flag = #{delFlag},</if>
<if test="remark != null">remark = #{remark},</if>
<if test="sucklesTime != null">suckles_time = #{sucklesTime},</if>
<if test="consumption != null">consumption = #{consumption},</if>
<if test="personId != null">person_id = #{personId},</if>
<if test="milkPowderBrand != null">milk_powder_brand = #{milkPowderBrand},</if>
<if test="spoonful != null">spoonful = #{spoonful},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteHealthMilkPowderRecordById" parameterType="Long">
delete from health_milk_powder_record where id = #{id}
</delete>
<delete id="deleteHealthMilkPowderRecordByIds" parameterType="String">
delete from health_milk_powder_record where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
<update id="removeHealthMilkPowderRecordById" parameterType="Long">
update health_milk_powder_record set del_flag='1' where id = #{id}
</update>
<update id="removeHealthMilkPowderRecordByIds" parameterType="String">
update health_milk_powder_record set del_flag='1' where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</update>
</mapper>