jsk 健康
This commit is contained in:
parent
a667b8ef68
commit
a77562526b
|
|
@ -1,11 +1,13 @@
|
|||
package com.bonus.canteen.core.nutrition.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.bonus.canteen.core.nutrition.common.dto.HealthInfoFullDto;
|
||||
import com.bonus.canteen.core.nutrition.common.model.HealthInfo;
|
||||
import com.bonus.canteen.core.nutrition.common.vo.HealthInfoFullVo;
|
||||
import com.bonus.canteen.core.nutrition.common.vo.HealthInfoSimpleVo;
|
||||
import com.bonus.canteen.core.nutrition.domain.HealthPopularScience;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
|
@ -19,9 +21,17 @@ public interface HealthInfoMapper extends BaseMapper<HealthInfo> {
|
|||
* @return 健康档案集合
|
||||
*/
|
||||
public List<HealthInfoSimpleVo> selectHealthInfoList(HealthInfoSimpleVo healthInfoSimpleVo);
|
||||
|
||||
List<HealthInfoSimpleVo> selectHealthChronicList(HealthInfoSimpleVo healthInfoSimpleVo);
|
||||
HealthInfoSimpleVo getSimpleInfo(Long userId);
|
||||
|
||||
HealthInfoFullVo fullHealthInfo(Long userId);
|
||||
|
||||
int updateHealthInfo(HealthInfoFullDto entitie);
|
||||
|
||||
int updateHealthBodyRecord(HealthInfoFullDto entitie);
|
||||
|
||||
int deleteHealthInfoChronic(HealthInfoFullDto entitie);
|
||||
|
||||
int insertHealthInfoChronic(@Param("entities") List<HealthInfoFullDto> entities);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ import org.springframework.stereotype.Service;
|
|||
import org.springframework.transaction.annotation.Transactional;
|
||||
import javax.annotation.Resource;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
|
@ -79,25 +80,35 @@ public class HealthInfoServiceImpl extends ServiceImpl<HealthInfoMapper, HealthI
|
|||
@Override
|
||||
public Integer editHealthInfo(HealthInfoFullDto content) {
|
||||
Long userId = content.getUserId();
|
||||
BigDecimal bmi = NuConvertUtil.getBMI(content.getWeight(), content.getHeight());
|
||||
content.setBmi(bmi);
|
||||
this.remove((Wrapper) Wrappers.lambdaQuery(HealthInfo.class).eq(HealthInfo::getUserId, userId));
|
||||
this.healthInfoChronicService.remove((Wrapper)Wrappers.lambdaQuery(HealthInfoChronic.class).eq(HealthInfoChronic::getUserId, userId));
|
||||
HealthInfo healthInfo = (HealthInfo)LeBeanUtil.copyCreateProperties(content, HealthInfo.class);
|
||||
healthInfo.setId(Id.next());
|
||||
this.save(healthInfo);
|
||||
List<Long> chronicIds = StrUtil.isNotBlank(content.getChronicIds()) ? Arrays.stream(content.getChronicIds().split(",")).map((s) -> {
|
||||
return Long.parseLong(s);
|
||||
}).collect(Collectors.toList()) : CollUtil.newArrayList(new Long[0]);
|
||||
if (CollUtil.isNotEmpty((Collection)chronicIds)) {
|
||||
this.healthInfoChronicService.insertAssociateBatch(userId, (List)chronicIds);
|
||||
HealthInfoSimpleVo chronicVo=new HealthInfoSimpleVo();
|
||||
chronicVo.setChronicIds(content.getChronicIds());
|
||||
List<HealthInfoSimpleVo> chronicVos=baseMapper.selectHealthChronicList(chronicVo);
|
||||
if(chronicVos!=null&&chronicVos.size()>0){
|
||||
/**
|
||||
* 清空疾病信息
|
||||
*/
|
||||
baseMapper.deleteHealthInfoChronic(content);
|
||||
List<HealthInfoFullDto> chronicfVos=new ArrayList<>();
|
||||
for(HealthInfoSimpleVo vo:chronicVos){
|
||||
HealthInfoFullDto hfd=new HealthInfoFullDto();
|
||||
hfd.setUserId(content.getUserId());
|
||||
hfd.setChronicIds(vo.getChronicIds());
|
||||
hfd.setChronicNames(vo.getChronicNames());
|
||||
chronicfVos.add(hfd);
|
||||
}
|
||||
|
||||
HealthBodyRecord healthBodyRecord = (HealthBodyRecord)LeBeanUtil.copyCreateProperties(content, HealthBodyRecord.class);
|
||||
healthBodyRecord.setId(Id.next());
|
||||
healthBodyRecord.setHealthInfoSource(HealthInfoSourceEnum.WEB.key());
|
||||
this.healthBodyRecordService.insertLatestRecord(healthBodyRecord);
|
||||
|
||||
/**
|
||||
* 重新录入疾病信息
|
||||
*/
|
||||
baseMapper.insertHealthInfoChronic(chronicfVos);
|
||||
}
|
||||
/**
|
||||
* 重新录入健康信息
|
||||
*/
|
||||
baseMapper.updateHealthInfo(content);
|
||||
/**
|
||||
* 重新录入身体信息
|
||||
*/
|
||||
baseMapper.updateHealthBodyRecord(content);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ import com.bonus.common.houqin.encrypt.RequiresGuest;
|
|||
import com.bonus.common.houqin.i18n.I18n;
|
||||
import com.bonus.common.log.enums.OperaType;
|
||||
import com.bonus.system.api.domain.SysUser;
|
||||
import com.bonus.system.api.domain.SysUserFace;
|
||||
//import com.bonus.system.api.domain.SysUserFace;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
|
@ -42,14 +42,14 @@ public class UserFaceController extends BaseController {
|
|||
@Autowired
|
||||
private IUserFaceService UserFaceService;
|
||||
|
||||
@ApiOperation("保存人脸图片")
|
||||
@PostMapping({"/uploadUserFace"})
|
||||
@RequiresGuest
|
||||
public AjaxResult uploadUserFace(@RequestBody @Valid SysUserFace sysUserFace) {
|
||||
UserFace dto = new UserFace();
|
||||
dto.setUserId(sysUserFace.getUserId());
|
||||
dto.setPhotoUrl(sysUserFace.getPhotoUrl());
|
||||
return UserFaceService.uploadUserFace(dto);
|
||||
}
|
||||
// @ApiOperation("保存人脸图片")
|
||||
// @PostMapping({"/uploadUserFace"})
|
||||
// @RequiresGuest
|
||||
// public AjaxResult uploadUserFace(@RequestBody @Valid SysUserFace sysUserFace) {
|
||||
// UserFace dto = new UserFace();
|
||||
// dto.setUserId(sysUserFace.getUserId());
|
||||
// dto.setPhotoUrl(sysUserFace.getPhotoUrl());
|
||||
// return UserFaceService.uploadUserFace(dto);
|
||||
// }
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,6 +37,11 @@
|
|||
b.labour_intensity,
|
||||
b.pregnant_status
|
||||
</select>
|
||||
|
||||
<select id="selectHealthChronicList" resultType="com.bonus.canteen.core.nutrition.common.vo.HealthInfoSimpleVo">
|
||||
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.nutrition.common.vo.HealthInfoSimpleVo">
|
||||
SELECT a.user_id,
|
||||
a.nick_name,
|
||||
|
|
@ -150,4 +155,72 @@
|
|||
c.uric_acid,
|
||||
c.blood_pressure
|
||||
</select>
|
||||
<update id="updateHealthInfo" parameterType="com.bonus.canteen.core.nutrition.common.vo.HealthInfoFullVo">
|
||||
update health_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 and pregnancyDate != ''">
|
||||
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 and inpatientDate != ''">
|
||||
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>
|
||||
<update id="updateHealthBodyRecord" parameterType="com.bonus.canteen.core.nutrition.common.vo.HealthInfoFullVo">
|
||||
update health_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 del_flag='0'
|
||||
</update>
|
||||
<update id="deleteHealthInfoChronic" parameterType="com.bonus.canteen.core.nutrition.common.vo.HealthInfoFullVo">
|
||||
delete from health_info_chronic
|
||||
where user_id = #{userId}
|
||||
</update>
|
||||
<insert id="insertHealthInfoChronic" parameterType="com.bonus.canteen.core.nutrition.common.vo.HealthInfoFullVo">
|
||||
insert into health_info_chronic(user_id, chronic_id, chronic_name)
|
||||
values
|
||||
<foreach collection="entities" item="entity" separator=",">
|
||||
(#{entity.userId}, #{entity.chronicIds}, #{entity.chronicNames})
|
||||
</foreach>
|
||||
</insert>
|
||||
</mapper>
|
||||
|
|
|
|||
Loading…
Reference in New Issue