Merge remote-tracking branch 'origin/master'

This commit is contained in:
sxu 2025-06-05 11:29:59 +08:00
commit 59ff8e5afe
20 changed files with 625 additions and 138 deletions

View File

@ -116,4 +116,11 @@ public class HealthChronicController extends BaseController {
public AjaxResult remove(@PathVariable Long[] chronicIds) {
return toAjax(healthChronicService.deleteHealthChronicByChronicIds(chronicIds));
}
@ApiOperation("获取慢性病字典")
@PostMapping({"/dict-health-chronic"})
public AjaxResult dictHealthChronic(@RequestBody HealthChronic dto) {
List<HealthChronic> list = this.healthChronicService.dictHealthChronic(dto);
return AjaxResult.success(list);
}
}

View File

@ -55,7 +55,7 @@ public class HealthPersonInfoController extends BaseController {
@ApiOperation(value = "导出人员健康情况列表")
//@PreventRepeatSubmit
//@RequiresPermissions("health:info:export")
@SysLog(title = "人员健康情况", businessType = OperaType.EXPORT, logType = 1,module = "仓储管理->导出人员健康情况")
@SysLog(title = "人员健康情况", businessType = OperaType.EXPORT, logType = 1,module = "健康管理->导出人员健康情况")
@PostMapping("/export")
public void export(HttpServletResponse response, HealthPersonInfo healthPersonInfo) {
List<HealthPersonInfo> list = healthPersonInfoService.selectHealthPersonInfoList(healthPersonInfo);
@ -68,9 +68,9 @@ public class HealthPersonInfoController extends BaseController {
*/
@ApiOperation(value = "获取人员健康情况详细信息")
//@RequiresPermissions("health:info:query")
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") Long id) {
return success(healthPersonInfoService.selectHealthPersonInfoById(id));
@PostMapping({"/detail-health-info"})
public AjaxResult getInfo(@RequestBody HealthPersonInfo vo) {
return success(healthPersonInfoService.selectHealthPersonInfoById(vo.getUserId()));
}
/**
@ -79,7 +79,7 @@ public class HealthPersonInfoController extends BaseController {
@ApiOperation(value = "新增人员健康情况")
//@PreventRepeatSubmit
//@RequiresPermissions("health:info:add")
@SysLog(title = "人员健康情况", businessType = OperaType.INSERT, logType = 1,module = "仓储管理->新增人员健康情况")
@SysLog(title = "人员健康情况", businessType = OperaType.INSERT, logType = 1,module = "健康管理->新增人员健康情况")
@PostMapping
public AjaxResult add(@RequestBody HealthPersonInfo healthPersonInfo) {
try {
@ -95,8 +95,8 @@ public class HealthPersonInfoController extends BaseController {
@ApiOperation(value = "修改人员健康情况")
//@PreventRepeatSubmit
//@RequiresPermissions("health:info:edit")
@SysLog(title = "人员健康情况", businessType = OperaType.UPDATE, logType = 1,module = "仓储管理->修改人员健康情况")
@PostMapping("/edit")
@SysLog(title = "人员健康情况", businessType = OperaType.UPDATE, logType = 1,module = "健康管理->修改人员健康情况")
@PostMapping({"/edit-health-info"})
public AjaxResult edit(@RequestBody HealthPersonInfo healthPersonInfo) {
try {
return toAjax(healthPersonInfoService.updateHealthPersonInfo(healthPersonInfo));
@ -112,8 +112,8 @@ public class HealthPersonInfoController extends BaseController {
//@PreventRepeatSubmit
//@RequiresPermissions("health:info:remove")
@SysLog(title = "人员健康情况", businessType = OperaType.DELETE, logType = 1,module = "仓储管理->删除人员健康情况")
@PostMapping("/del/{ids}")
public AjaxResult remove(@PathVariable Long[] ids) {
return toAjax(healthPersonInfoService.deleteHealthPersonInfoByIds(ids));
@PostMapping({"/del-health-info"})
public AjaxResult remove(@RequestBody HealthPersonInfo healthPersonInfo) {
return toAjax(healthPersonInfoService.deleteHealthPersonInfoById(healthPersonInfo));
}
}

View File

@ -1,5 +1,7 @@
package com.bonus.canteen.core.health.domain;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.bonus.common.core.annotation.Excel;
@ -106,5 +108,68 @@ public class HealthPersonInfo extends BaseEntity {
@Excel(name = "健康状态", readConverterExp = "1=-健康、2-残疾、3-瘫痪")
private Long healthState;
private String articleTitle;
@ApiModelProperty("人员名称")
private String nickName;
@ApiModelProperty("手机号")
private String mobile;
@ApiModelProperty("性别 1-男 2-女")
private Integer sex;
@ApiModelProperty("年龄")
private Integer age;
@ApiModelProperty("所属组织id")
private Long orgId;
@ApiModelProperty("所属组织名称")
private String orgFullName;
@ApiModelProperty("人员类别")
private Integer userType;
@ApiModelProperty("所属位置Id")
private Long placeId;
@ApiModelProperty("所属位置")
private String placeFullName;
@ApiModelProperty("生日")
private LocalDate birthday;
@ApiModelProperty("慢性病id多个用逗号分割")
private String chronicIds;
@ApiModelProperty("慢性病名称多个用逗号分割")
private String chronicNames;
@ApiModelProperty("是否删除 0-正常 2-删除")
private Integer delFlag;
@ApiModelProperty("身高")
private BigDecimal height;
@ApiModelProperty("体重")
private BigDecimal weight;
@ApiModelProperty("BMI指数")
private BigDecimal bmi;
@ApiModelProperty("体型")
private String shape;
@ApiModelProperty("胸围")
private BigDecimal bust;
@ApiModelProperty("腰围")
private BigDecimal waistline;
@ApiModelProperty("血糖")
private BigDecimal bloodSugar;
@ApiModelProperty("血脂")
private Integer bloodFat;
@ApiModelProperty("血压高")
private BigDecimal bloodPressureHigh;
@ApiModelProperty("血压低")
private BigDecimal bloodPressureLow;
@ApiModelProperty("心率")
private BigDecimal heartRate;
@ApiModelProperty("血氧")
private BigDecimal bloodOxygen;
@ApiModelProperty("尿酸")
private Integer uricAcid;
@ApiModelProperty("血压")
private Integer bloodPressure;
@ApiModelProperty("创建人")
private String createBy;
@ApiModelProperty("创建时间")
private Date createTime;
@ApiModelProperty("更新人")
private String updateBy;
@ApiModelProperty("更新时间")
private Date updateTime;
}

View File

@ -57,4 +57,5 @@ public interface HealthChronicMapper {
* @return 结果
*/
public int deleteHealthChronicByChronicIds(Long[] chronicIds);
}

View File

@ -2,6 +2,7 @@ package com.bonus.canteen.core.health.mapper;
import java.util.List;
import com.bonus.canteen.core.health.domain.HealthPersonInfo;
import org.apache.ibatis.annotations.Param;
/**
* 人员健康情况Mapper接口
@ -57,4 +58,22 @@ public interface HealthPersonInfoMapper {
* @return 结果
*/
public int deleteHealthPersonInfoByIds(Long[] ids);
List<HealthPersonInfo> selectHealthChronicList(HealthPersonInfo healthInfoSimpleVo);
int updateHealthInfo(HealthPersonInfo entitie);
int getHealthBodyRecordNum(HealthPersonInfo entitie);
int insertHealthBodyRecord(HealthPersonInfo entitie);
int updateHealthBodyRecord(HealthPersonInfo entitie);
int deleteHealthInfoChronic(HealthPersonInfo entitie);
int delHealthInfo(HealthPersonInfo entitie);
int insertHealthInfoChronic(@Param("entities") List<HealthPersonInfo> entities);
int insertHealthInfo(HealthPersonInfo entities);
}

View File

@ -57,4 +57,6 @@ public interface IHealthChronicService {
* @return 结果
*/
public int deleteHealthChronicByChronicId(Long chronicId);
List<HealthChronic> dictHealthChronic(HealthChronic content);
}

View File

@ -56,5 +56,5 @@ public interface IHealthPersonInfoService {
* @param id 人员健康情况主键
* @return 结果
*/
public int deleteHealthPersonInfoById(Long id);
public int deleteHealthPersonInfoById(HealthPersonInfo content);
}

View File

@ -1,8 +1,14 @@
package com.bonus.canteen.core.health.service.impl;
import java.util.List;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.bonus.common.core.exception.ServiceException;
import com.bonus.common.core.utils.DateUtils;
import com.bonus.common.houqin.constant.DelFlagEnum;
import com.bonus.common.houqin.utils.LeBeanUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.bonus.canteen.core.health.mapper.HealthChronicMapper;
@ -95,4 +101,10 @@ public class HealthChronicServiceImpl implements IHealthChronicService {
public int deleteHealthChronicByChronicId(Long chronicId) {
return healthChronicMapper.deleteHealthChronicByChronicId(chronicId);
}
@Override
public List<HealthChronic> dictHealthChronic(HealthChronic content) {
return healthChronicMapper.selectHealthChronicList(content);
}
}

View File

@ -1,6 +1,12 @@
package com.bonus.canteen.core.health.service.impl;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.ArrayList;
import java.util.List;
import cn.hutool.core.util.NumberUtil;
import cn.hutool.core.util.ObjectUtil;
import com.bonus.common.core.exception.ServiceException;
import com.bonus.common.core.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
@ -61,14 +67,52 @@ public class HealthPersonInfoServiceImpl implements IHealthPersonInfoService {
/**
* 修改人员健康情况
*
* @param healthPersonInfo 人员健康情况
* @param content 人员健康情况
* @return 结果
*/
@Override
public int updateHealthPersonInfo(HealthPersonInfo healthPersonInfo) {
healthPersonInfo.setUpdateTime(DateUtils.getNowDate());
public int updateHealthPersonInfo(HealthPersonInfo content) {
content.setUpdateTime(DateUtils.getNowDate());
try {
return healthPersonInfoMapper.updateHealthPersonInfo(healthPersonInfo);
Long userId = content.getUserId();
HealthPersonInfo chronicVo=new HealthPersonInfo();
chronicVo.setChronicIds(content.getChronicIds());
List<HealthPersonInfo> chronicVos=healthPersonInfoMapper.selectHealthChronicList(chronicVo);
if(chronicVos!=null&&chronicVos.size()>0){
/**
* 清空疾病信息
*/
healthPersonInfoMapper.deleteHealthInfoChronic(content);
List<HealthPersonInfo> chronicfVos=new ArrayList<>();
for(HealthPersonInfo vo:chronicVos){
HealthPersonInfo hfd=new HealthPersonInfo();
hfd.setUserId(content.getUserId());
hfd.setChronicIds(vo.getChronicIds());
hfd.setChronicNames(vo.getChronicNames());
chronicfVos.add(hfd);
}
/**
* 重新录入疾病信息
*/
healthPersonInfoMapper.insertHealthInfoChronic(chronicfVos);
}
healthPersonInfoMapper.delHealthInfo(content);
/**
* 重新录入健康信息
*/
healthPersonInfoMapper.delHealthInfo(content);
healthPersonInfoMapper.insertHealthInfo(content);
healthPersonInfoMapper.updateHealthInfo(content);
/**
* 重新录入身体信息
*/
int flag=healthPersonInfoMapper.getHealthBodyRecordNum(content);
if(flag==0){
healthPersonInfoMapper.insertHealthBodyRecord(content);
}
content.setBmi(getBMI(content.getWeight(),content.getHeight()));
healthPersonInfoMapper.updateHealthBodyRecord(content);
return 1;
} catch (Exception e) {
throw new ServiceException(e.getMessage());
}
@ -88,11 +132,30 @@ public class HealthPersonInfoServiceImpl implements IHealthPersonInfoService {
/**
* 删除人员健康情况信息
*
* @param id 人员健康情况主键
* @param content 人员健康情况主键
* @return 结果
*/
@Override
public int deleteHealthPersonInfoById(Long id) {
return healthPersonInfoMapper.deleteHealthPersonInfoById(id);
public int deleteHealthPersonInfoById(HealthPersonInfo content) {
Long userId = content.getUserId();
try{
healthPersonInfoMapper.deleteHealthInfoChronic(content);
healthPersonInfoMapper.delHealthInfo(content);
}catch (Exception e){
}
return 1;
}
public static BigDecimal getBMI(BigDecimal weight, BigDecimal height) {
if (!ObjectUtil.isNull(weight) && !ObjectUtil.isNull(height)) {
if (NumberUtil.equals(height, BigDecimal.ZERO)) {
return new BigDecimal(-1);
} else {
height = NumberUtil.div(height, BigDecimal.valueOf(100L), 2, RoundingMode.HALF_UP);
return NumberUtil.div(weight, NumberUtil.mul(height, height), 2, RoundingMode.HALF_UP);
}
} else {
return new BigDecimal(-1);
}
}
}

View File

@ -32,30 +32,141 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</sql>
<select id="selectHealthPersonInfoList" parameterType="com.bonus.canteen.core.health.domain.HealthPersonInfo" resultMap="HealthPersonInfoResult">
<include refid="selectHealthPersonInfoVo"/>
<where>
<if test="userId != null "> and user_id = #{userId}</if>
<if test="registerDate != null "> and register_date = #{registerDate}</if>
<if test="bloodType != null "> and blood_type = #{bloodType}</if>
<if test="maritalStatus != null "> and marital_status = #{maritalStatus}</if>
<if test="pregnantStatus != null "> and pregnant_status = #{pregnantStatus}</if>
<if test="pregnancyDate != null "> and pregnancy_date = #{pregnancyDate}</if>
<if test="doctorAdvice != null "> and doctor_advice = #{doctorAdvice}</if>
<if test="ifHospitalized != null "> and if_hospitalized = #{ifHospitalized}</if>
<if test="doctorNum != null and doctorNum != ''"> and doctor_num = #{doctorNum}</if>
<if test="hospitalNum != null and hospitalNum != ''"> and hospital_num = #{hospitalNum}</if>
<if test="inpatientDate != null "> and inpatient_date = #{inpatientDate}</if>
<if test="inpatientResult != null and inpatientResult != ''"> and inpatient_result = #{inpatientResult}</if>
<if test="weightControl != null "> and weight_control = #{weightControl}</if>
<if test="allergen != null and allergen != ''"> and allergen = #{allergen}</if>
<if test="labourIntensity != null "> and labour_intensity = #{labourIntensity}</if>
<if test="healthState != null "> and health_state = #{healthState}</if>
</where>
<!-- <include refid="selectHealthPersonInfoVo"/>-->
<!-- <where> -->
<!-- <if test="userId != null "> and user_id = #{userId}</if>-->
<!-- <if test="registerDate != null "> and register_date = #{registerDate}</if>-->
<!-- <if test="bloodType != null "> and blood_type = #{bloodType}</if>-->
<!-- <if test="maritalStatus != null "> and marital_status = #{maritalStatus}</if>-->
<!-- <if test="pregnantStatus != null "> and pregnant_status = #{pregnantStatus}</if>-->
<!-- <if test="pregnancyDate != null "> and pregnancy_date = #{pregnancyDate}</if>-->
<!-- <if test="doctorAdvice != null "> and doctor_advice = #{doctorAdvice}</if>-->
<!-- <if test="ifHospitalized != null "> and if_hospitalized = #{ifHospitalized}</if>-->
<!-- <if test="doctorNum != null and doctorNum != ''"> and doctor_num = #{doctorNum}</if>-->
<!-- <if test="hospitalNum != null and hospitalNum != ''"> and hospital_num = #{hospitalNum}</if>-->
<!-- <if test="inpatientDate != null "> and inpatient_date = #{inpatientDate}</if>-->
<!-- <if test="inpatientResult != null and inpatientResult != ''"> and inpatient_result = #{inpatientResult}</if>-->
<!-- <if test="weightControl != null "> and weight_control = #{weightControl}</if>-->
<!-- <if test="allergen != null and allergen != ''"> and allergen = #{allergen}</if>-->
<!-- <if test="labourIntensity != null "> and labour_intensity = #{labourIntensity}</if>-->
<!-- <if test="healthState != null "> and health_state = #{healthState}</if>-->
<!-- </where>-->
SELECT a.user_id,
a.nick_name,
a.phonenumber as mobile,
a.photo_url as custPhotoUrl,
a.sex,
d.height,
d.weight,
d.bmi,
b.doctor_advice,
b.allergen,
b.labour_intensity,
b.pregnant_status,
b.doctor_num,
b.hospital_num,
b.inpatient_date,
GROUP_CONCAT(c.chronic_name ORDER BY c.chronic_id desc) AS chronic_names,
GROUP_CONCAT(c.chronic_id ORDER BY c.chronic_id desc) AS chronic_ids
from sys_user a
left join health_person_info b on a.user_id = b.user_id
left join health_person_info_chronic c on a.user_id = c.user_id
left join health_person_body_record d on a.user_id = d.user_id and d.if_latest = 1
where 1 = 1
<if test="articleTitle != null and articleTitle != ''">
and(a.nick_name like concat('%', #{articleTitle}, '%') or a.phonenumber like concat('%', #{articleTitle}, '%') or b.doctor_num like concat('%', #{articleTitle}, '%'))
</if>
group by a.user_id,
a.nick_name,
a.dept_id,
a.phonenumber,
a.photo_url,
a.sex,
d.height,
d.weight,
d.bmi,
b.doctor_advice,
b.allergen,
b.labour_intensity,
b.pregnant_status
</select>
<select id="selectHealthPersonInfoById" parameterType="Long" resultMap="HealthPersonInfoResult">
<include refid="selectHealthPersonInfoVo"/>
where id = #{id}
select a.user_id,
a.nick_name,
a.phonenumber as mobile,
a.sex,
a.dept_id as orgId,
a.user_type,
b.marital_status,
b.pregnant_status,
b.pregnancy_date,
b.doctor_advice,
b.if_hospitalized,
b.doctor_num,
b.hospital_num,
b.inpatient_date,
b.inpatient_result,
b.weight_control,
b.allergen,
b.labour_intensity,
b.health_state,
b.blood_type,
c.height,
c.weight,
c.bmi,
c.shape,
c.bust,
c.waistline,
c.blood_sugar,
c.blood_fat,
c.blood_pressure_high,
c.blood_pressure_low,
c.heart_rate,
c.blood_oxygen,
c.uric_acid,
c.blood_pressure,
GROUP_CONCAT(d.chronic_name ORDER BY d.chronic_id desc) AS chronic_names,
GROUP_CONCAT(d.chronic_id ORDER BY d.chronic_id desc) AS chronic_ids
from sys_user a
left join health_person_info b on a.user_id = b.user_id
left join health_person_body_record c on a.user_id = c.user_id and c.if_latest = 1
left join health_person_info_chronic d on a.user_id = d.user_id
where a.user_id = #{userId}
group by a.user_id,
a.user_name,
a.phonenumber,
a.sex,
a.dept_id,
a.user_type,
b.marital_status,
b.pregnant_status,
b.pregnancy_date,
b.doctor_advice,
b.if_hospitalized,
b.doctor_num,
b.hospital_num,
b.inpatient_date,
b.inpatient_result,
b.weight_control,
b.allergen,
b.labour_intensity,
b.health_state,
b.blood_type,
c.height,
c.weight,
c.bmi,
c.shape,
c.bust,
c.waistline,
c.blood_sugar,
c.blood_fat,
c.blood_pressure_high,
c.blood_pressure_low,
c.heart_rate,
c.blood_oxygen,
c.uric_acid,
c.blood_pressure
</select>
<insert id="insertHealthPersonInfo" parameterType="com.bonus.canteen.core.health.domain.HealthPersonInfo">
@ -145,4 +256,211 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
#{id}
</foreach>
</delete>
<select id="selectHealthChronicList" resultType="com.bonus.canteen.core.health.domain.HealthPersonInfo">
SELECT distinct chronic_id as chronic_ids,chronic_name as chronic_names from health_chronic where chronic_id in (${chronicIds})
</select>
<select id="getSimpleInfo" resultType="com.bonus.canteen.core.health.domain.HealthPersonInfo">
SELECT a.user_id,
a.nick_name,
a.phonenumber as mobile,
a.photo_url as custPhotoUrl,
a.sex,
d.height,
d.weight,
d.bmi,
b.doctor_advice,
b.allergen,
b.labour_intensity,
b.pregnant_status,
GROUP_CONCAT(c.chronic_name ORDER BY c.chronic_id desc) AS chronic_names,
GROUP_CONCAT(c.chronic_id ORDER BY c.chronic_id desc) AS chronic_ids
from sys_user a
left join health_person_info b on a.user_id = b.user_id
left join health_person_info_chronic c on a.user_id = c.user_id
left join health_person_body_record d on a.user_id = d.user_id and d.if_latest = 1
where 1 = 1
and a.user_id = #{userId}
group by a.user_id,
a.nick_name,
a.dept_id,
a.phonenumber,
a.photo_url,
a.sex,
d.height,
d.weight,
d.bmi,
b.doctor_advice,
b.allergen,
b.labour_intensity,
b.pregnant_status
</select>
<select id="fullHealthInfo" resultType="com.bonus.canteen.core.health.domain.HealthPersonInfo">
select a.user_id,
a.nick_name,
a.phonenumber as mobile,
a.sex,
a.dept_id as orgId,
a.user_type,
b.marital_status,
b.pregnant_status,
b.pregnancy_date,
b.doctor_advice,
b.if_hospitalized,
b.doctor_num,
b.hospital_num,
b.inpatient_date,
b.inpatient_result,
b.weight_control,
b.allergen,
b.labour_intensity,
b.health_state,
b.blood_type,
c.height,
c.weight,
c.bmi,
c.shape,
c.bust,
c.waistline,
c.blood_sugar,
c.blood_fat,
c.blood_pressure_high,
c.blood_pressure_low,
c.heart_rate,
c.blood_oxygen,
c.uric_acid,
c.blood_pressure,
GROUP_CONCAT(d.chronic_name ORDER BY d.chronic_id desc) AS chronic_names,
GROUP_CONCAT(d.chronic_id ORDER BY d.chronic_id desc) AS chronic_ids
from sys_user a
left join health_person_info b on a.user_id = b.user_id
left join health_person_body_record c on a.user_id = c.user_id and c.if_latest = 1
left join health_person_info_chronic d on a.user_id = d.user_id
where a.user_id = #{userId}
group by a.user_id,
a.user_name,
a.phonenumber,
a.sex,
a.dept_id,
a.user_type,
b.marital_status,
b.pregnant_status,
b.pregnancy_date,
b.doctor_advice,
b.if_hospitalized,
b.doctor_num,
b.hospital_num,
b.inpatient_date,
b.inpatient_result,
b.weight_control,
b.allergen,
b.labour_intensity,
b.health_state,
b.blood_type,
c.height,
c.weight,
c.bmi,
c.shape,
c.bust,
c.waistline,
c.blood_sugar,
c.blood_fat,
c.blood_pressure_high,
c.blood_pressure_low,
c.heart_rate,
c.blood_oxygen,
c.uric_acid,
c.blood_pressure
</select>
<update id="updateHealthInfo" parameterType="com.bonus.canteen.core.health.domain.HealthPersonInfo">
update health_person_info
<set>
<if test="bloodType != null and bloodType != ''">
blood_type = #{bloodType},
</if>
<if test="maritalStatus != null and maritalStatus != ''">
marital_status = #{maritalStatus},
</if>
<if test="pregnantStatus != null and pregnantStatus != ''">
pregnant_status = #{pregnantStatus},
</if>
<if test="pregnancyDate != null ">
pregnancy_date = #{pregnancyDate},
</if>
<if test="doctorAdvice != null and doctorAdvice != ''">
doctor_advice = #{doctorAdvice},
</if>
<if test="ifHospitalized != null and ifHospitalized != ''">
if_hospitalized = #{ifHospitalized},
</if>
<if test="doctorNum != null and doctorNum != ''">
doctor_num = #{doctorNum},
</if>
<if test="hospitalNum != null and hospitalNum != ''">
hospital_num = #{hospitalNum},
</if>
<if test="inpatientDate != null ">
inpatient_date = #{inpatientDate},
</if>
<if test="weightControl != null and weightControl != ''">
weight_control = #{weightControl},
</if>
<if test="allergen != null and allergen != ''">
allergen = #{allergen},
</if>
<if test="labourIntensity != null and labourIntensity != ''">
labour_intensity = #{labourIntensity},
</if>
</set>
where user_id = #{userId} and del_flag='0'
</update>
<select id="getHealthBodyRecordNum" resultType="java.lang.Integer">
select count(1) from health_person_body_record where user_id=#{userId} and if_latest = 1
</select>
<insert id="insertHealthBodyRecord" parameterType="com.bonus.canteen.core.health.domain.HealthPersonInfo">
insert into health_person_body_record(user_id,if_latest)
values
(#{userId},1)
</insert>
<update id="updateHealthBodyRecord" parameterType="com.bonus.canteen.core.health.domain.HealthPersonInfo">
update health_person_body_record
<set>
<if test="height != null and height != ''">
height = #{height},
</if>
<if test="weight != null and weight != ''">
weight = #{weight},
</if>
<if test="bmi != null and bmi != ''">
bmi = #{bmi},
</if>
</set>
where user_id = #{userId} and if_latest = 1
</update>
<update id="deleteHealthInfoChronic" parameterType="com.bonus.canteen.core.health.domain.HealthPersonInfo">
delete from health_person_info_chronic
where user_id = #{userId}
</update>
<update id="delHealthInfo" parameterType="com.bonus.canteen.core.health.domain.HealthPersonInfo">
delete from health_person_info
where user_id = #{userId}
</update>
<insert id="insertHealthInfoChronic" parameterType="com.bonus.canteen.core.health.domain.HealthPersonInfo">
insert into health_person_info_chronic(user_id, chronic_id, chronic_name)
values
<foreach collection="entities" item="entity" separator=",">
(#{entity.userId}, #{entity.chronicIds}, #{entity.chronicNames})
</foreach>
</insert>
<insert id="insertHealthInfo" parameterType="com.bonus.canteen.core.health.domain.HealthPersonInfo">
insert into health_person_info(user_id)
values
(#{userId})
</insert>
</mapper>