三方健康体检接口、健康体检一体机数据接口
This commit is contained in:
parent
f846554187
commit
ef52300bf4
|
|
@ -45,9 +45,15 @@ public class BodyResponse<T> {
|
|||
private T data;
|
||||
|
||||
// 快速创建成功响应
|
||||
public static <T> BodyResponse<T> success(T data) {
|
||||
public static <T> BodyResponse<T> success() {
|
||||
BodyResponse<T> response = new BodyResponse<>();
|
||||
response.setData(data);
|
||||
response.setReturnCode("FAIL");
|
||||
response.setReturnMsg("数据上传成功");
|
||||
response.setSuccess(true);
|
||||
response.setResCode(200);
|
||||
response.setMessage("数据上传成功");
|
||||
response.setStatusCode(200);
|
||||
response.setResMsg("数据上传成功");
|
||||
return response;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
package com.bonus.canteen.core.healthmachine.bean;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
public class UserData {
|
||||
private String userId;
|
||||
private String nickName;
|
||||
|
|
@ -10,7 +12,6 @@ public class UserData {
|
|||
|
||||
// 构造方法
|
||||
public UserData() {
|
||||
this.isSure = false; // 默认值
|
||||
}
|
||||
|
||||
public UserData(String userId, String nickName, String sex, String avatar, int age, boolean isSure) {
|
||||
|
|
@ -62,12 +63,12 @@ public class UserData {
|
|||
public void setAge(int age) {
|
||||
this.age = age;
|
||||
}
|
||||
|
||||
public boolean isSure() {
|
||||
@JsonProperty("isSure")
|
||||
public boolean getIsSure() {
|
||||
return isSure;
|
||||
}
|
||||
|
||||
public void setSure(boolean sure) {
|
||||
isSure = sure;
|
||||
@JsonProperty("isSure")
|
||||
public void setIsSure(boolean isSure) {
|
||||
this.isSure = isSure;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,12 +1,17 @@
|
|||
package com.bonus.canteen.core.healthmachine.controller;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.bonus.canteen.core.healthmachine.bean.*;
|
||||
import com.bonus.canteen.core.healthmachine.mapper.HealthMachineMapper;
|
||||
import com.bonus.common.core.utils.encryption.Sm4Utils;
|
||||
import com.bonus.common.core.web.controller.BaseController;
|
||||
import com.bonus.common.houqin.utils.SM4EncryptUtils;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.validation.Valid;
|
||||
|
||||
|
||||
|
|
@ -21,19 +26,33 @@ import javax.validation.Valid;
|
|||
@RequestMapping("/api/anthropometer")
|
||||
@Slf4j
|
||||
public class HealthMachineController extends BaseController {
|
||||
@Resource
|
||||
private HealthMachineMapper healthMachineMapper;
|
||||
private static final String MINUS_ONE = "-1";
|
||||
|
||||
@ApiOperation("检查人员是否存在并获取人员信息")
|
||||
@GetMapping({"/getPhoneUser/restful"})
|
||||
public BaseUserResponse<UserData> checkUserIsExist(@Valid UserDTO dto) {
|
||||
UserData userData = new UserData("1","张三","13800138000","http://example.com/photo.jpg",22,false);
|
||||
System.out.println("dto = " + dto);
|
||||
return BaseUserResponse.success(userData);
|
||||
public String checkUserIsExist(@Valid UserDTO dto) {
|
||||
//从数据库查询是否存在当前手机
|
||||
dto.setPhoneNumber(SM4EncryptUtils.sm4Encrypt(dto.getPhoneNumber()));
|
||||
UserData userData = healthMachineMapper.checkIsExistCurrentUser(dto);
|
||||
if (userData == null){
|
||||
userData = new UserData("-1","外部人员","man","",18,true);
|
||||
}
|
||||
return JSON.toJSONString(BaseUserResponse.success(userData));
|
||||
}
|
||||
|
||||
@ApiOperation("健康体检一体机-体检数据上传")
|
||||
@PostMapping({"/userTest/restful"})
|
||||
public BodyResponse<BodyMeasurement> physicalExaminationDataUpload(@RequestBody @Valid BodyMeasurement dto) {
|
||||
System.out.println("dto = " + dto);
|
||||
return BodyResponse.success(dto);
|
||||
public String physicalExaminationDataUpload(@RequestBody @Valid BodyMeasurement dto) {
|
||||
try {
|
||||
if (MINUS_ONE.equals(dto.getUserId())){
|
||||
return JSON.toJSONString(BodyResponse.success());
|
||||
}
|
||||
healthMachineMapper.addPhysicalExaminationData(dto);
|
||||
}catch (Exception e){
|
||||
return JSON.toJSONString(BodyResponse.fail("上传数据失败",500,"上传数据失败"));
|
||||
}
|
||||
return JSON.toJSONString(BodyResponse.success());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,24 @@
|
|||
package com.bonus.canteen.core.healthmachine.mapper;
|
||||
|
||||
import com.bonus.canteen.core.healthmachine.bean.BodyMeasurement;
|
||||
import com.bonus.canteen.core.healthmachine.bean.UserDTO;
|
||||
import com.bonus.canteen.core.healthmachine.bean.UserData;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
/**
|
||||
* @author tqzhang
|
||||
*/
|
||||
public interface HealthMachineMapper {
|
||||
/**
|
||||
* 从数据库查询是否存在当前手机
|
||||
* @param dto 入参
|
||||
* @return 用户数据集
|
||||
*/
|
||||
UserData checkIsExistCurrentUser(UserDTO dto);
|
||||
|
||||
/**
|
||||
* 添加体检数据
|
||||
* @param dto 入参
|
||||
*/
|
||||
void addPhysicalExaminationData(@Param("dto") BodyMeasurement dto);
|
||||
}
|
||||
|
|
@ -0,0 +1,65 @@
|
|||
package com.bonus.canteen.core.zhhq.controller;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import com.bonus.canteen.core.account.constants.AccStatusEnum;
|
||||
import com.bonus.canteen.core.account.domain.param.AccountInfoQueryParam;
|
||||
import com.bonus.canteen.core.account.domain.vo.AccInfoDetailsVO;
|
||||
import com.bonus.canteen.core.account.service.IAccInfoService;
|
||||
import com.bonus.canteen.core.common.utils.HeaderFetchUtil;
|
||||
import com.bonus.canteen.core.zhhq.domain.AccountInfoDTO;
|
||||
import com.bonus.canteen.core.zhhq.domain.AccountInfoVO;
|
||||
import com.bonus.canteen.core.zhhq.domain.PhysicalExaminationDTO;
|
||||
import com.bonus.canteen.core.zhhq.domain.PhysicalExaminationVO;
|
||||
import com.bonus.canteen.core.zhhq.mapper.ZhhqPhysicalExaminationMapper;
|
||||
import com.bonus.common.core.exception.ServiceException;
|
||||
import com.bonus.common.core.utils.encryption.Sm4Utils;
|
||||
import com.bonus.common.core.web.controller.BaseController;
|
||||
import com.bonus.common.core.web.domain.AjaxResult;
|
||||
import com.bonus.common.houqin.constant.GlobalConstants;
|
||||
import com.bonus.common.houqin.utils.SM4EncryptUtils;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.validation.Valid;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static com.bonus.canteen.core.common.utils.DateUtil.getCurrentDateStr;
|
||||
|
||||
/**
|
||||
* 体检信息Controller
|
||||
*
|
||||
* @author tqzhang
|
||||
* @date 2025-09-02
|
||||
*/
|
||||
@Api(tags = "健康体检一体机数据接口")
|
||||
@RestController
|
||||
@RequestMapping("/api/zhhq/physical_examination")
|
||||
@Slf4j
|
||||
public class ZhhqPhysicalExaminationController extends BaseController {
|
||||
@Resource
|
||||
private ZhhqPhysicalExaminationMapper mapper;
|
||||
|
||||
@ApiOperation("根据手机号获取体检数据")
|
||||
@PostMapping({"/recordByPhone"})
|
||||
public AjaxResult recordByPhone(@RequestHeader Map<String, String> requestHeader, @RequestBody @Valid PhysicalExaminationDTO dto) {
|
||||
if (!(GlobalConstants.JYY + getCurrentDateStr()).equals(Sm4Utils.decrypt(HeaderFetchUtil.getSign(requestHeader)))) {
|
||||
throw new ServiceException("访问缺少认证信息");
|
||||
}
|
||||
try {
|
||||
dto.setSelectPhone(SM4EncryptUtils.sm4Encrypt(dto.getPhone()));
|
||||
List<PhysicalExaminationVO> list = this.mapper.selectRecordByPhone(dto);
|
||||
if(CollUtil.isEmpty(list)) {
|
||||
return AjaxResult.error("暂无相关体检数据");
|
||||
}
|
||||
return AjaxResult.success("体检数据查询成功", list);
|
||||
} catch (Exception e) {
|
||||
log.error(e.toString(), e);
|
||||
return AjaxResult.error(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
package com.bonus.canteen.core.zhhq.domain;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* @author tqzhang
|
||||
* @version 1.0
|
||||
* @date 2025/9/2
|
||||
*/
|
||||
@Data
|
||||
public class PhysicalExaminationDTO {
|
||||
@ApiModelProperty(value = "手机号")
|
||||
@NotNull(message = "手机号不能为空")
|
||||
private String phone;
|
||||
private String selectPhone;
|
||||
}
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
package com.bonus.canteen.core.zhhq.domain;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author tqzhang
|
||||
* @version 1.0
|
||||
* @date 2025/9/2
|
||||
*/
|
||||
@Data
|
||||
public class PhysicalExaminationVO {
|
||||
private String machineId;
|
||||
private String userId;
|
||||
private String userName;
|
||||
private String sex;
|
||||
private Integer age;
|
||||
private Double height;
|
||||
private Integer weight;
|
||||
private Double bmi;
|
||||
private Double bodyFat;
|
||||
private Double muscle;
|
||||
private Double boneMass;
|
||||
private Double waterContent;
|
||||
private Double extwater;
|
||||
private Double protein;
|
||||
private Integer metabolism;
|
||||
private Integer fatLevel;
|
||||
private Integer bodyAge;
|
||||
}
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
package com.bonus.canteen.core.zhhq.mapper;
|
||||
|
||||
import com.bonus.canteen.core.zhhq.domain.PhysicalExaminationDTO;
|
||||
import com.bonus.canteen.core.zhhq.domain.PhysicalExaminationVO;
|
||||
import com.bonus.canteen.core.zhhq.domain.WeekRecipeDetailVO;
|
||||
import com.bonus.canteen.core.zhhq.domain.WeekRecipeIngredientVO;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 获取体检信息接口
|
||||
*
|
||||
* @author tqzhang
|
||||
* @date 2025-09-02
|
||||
*/
|
||||
public interface ZhhqPhysicalExaminationMapper {
|
||||
/**
|
||||
* 根据手机号查询体检记录
|
||||
* @param dto 手机号
|
||||
* @return 体检记录集合
|
||||
*/
|
||||
List<PhysicalExaminationVO> selectRecordByPhone(PhysicalExaminationDTO dto);
|
||||
}
|
||||
|
|
@ -38,7 +38,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
</resultMap>
|
||||
|
||||
<sql id="selectCookMaterialVo">
|
||||
select cm.material_id, material_name, material_code,cm.img_url,
|
||||
select DISTINCT cm.material_id, material_name, material_code,cm.img_url,
|
||||
cm.goods_type, bar_code,
|
||||
sale_price, unit_price, sales_mode, shelf_life_type, shelf_life_days,
|
||||
pur_price_ceiling, big_category_id, size, cm.description,cm.create_by,
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
<?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">
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.bonus.canteen.core.health.mapper.HealthChronicMapper">
|
||||
<resultMap type="com.bonus.canteen.core.health.domain.HealthChronic" id="HealthChronicResult">
|
||||
<result property="chronicId" column="chronic_id" />
|
||||
|
|
@ -19,16 +19,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
|
||||
<select id="selectHealthChronicList" parameterType="com.bonus.canteen.core.health.domain.HealthChronic" resultMap="HealthChronicResult">
|
||||
<include refid="selectHealthChronicVo"/>
|
||||
<where>
|
||||
<where>
|
||||
<if test="chronicName != null and chronicName != ''"> and chronic_name like concat('%', #{chronicName}, '%')</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
|
||||
<select id="selectHealthChronicByChronicId" parameterType="Long" resultMap="HealthChronicResult">
|
||||
<include refid="selectHealthChronicVo"/>
|
||||
where chronic_id = #{chronicId}
|
||||
</select>
|
||||
|
||||
|
||||
<insert id="insertHealthChronic" parameterType="com.bonus.canteen.core.health.domain.HealthChronic" useGeneratedKeys="true" keyProperty="chronicId">
|
||||
insert into health_chronic
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
|
|
@ -38,7 +38,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="updateBy != null">update_by,</if>
|
||||
<if test="updateTime != null">update_time,</if>
|
||||
<if test="remark != null">remark,</if>
|
||||
</trim>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="chronicName != null and chronicName != ''">#{chronicName},</if>
|
||||
<if test="createBy != null">#{createBy},</if>
|
||||
|
|
@ -46,7 +46,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="updateBy != null">#{updateBy},</if>
|
||||
<if test="updateTime != null">#{updateTime},</if>
|
||||
<if test="remark != null">#{remark},</if>
|
||||
</trim>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<update id="updateHealthChronic" parameterType="com.bonus.canteen.core.health.domain.HealthChronic">
|
||||
|
|
@ -67,7 +67,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
</delete>
|
||||
|
||||
<delete id="deleteHealthChronicByChronicIds" parameterType="String">
|
||||
delete from health_chronic where chronic_id in
|
||||
delete from health_chronic where chronic_id in
|
||||
<foreach item="chronicId" collection="array" open="(" separator="," close=")">
|
||||
#{chronicId}
|
||||
</foreach>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,23 @@
|
|||
<?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.bonus.canteen.core.healthmachine.mapper.HealthMachineMapper">
|
||||
|
||||
<select id="checkIsExistCurrentUser" resultType="com.bonus.canteen.core.healthmachine.bean.UserData">
|
||||
select staff_id as userId,
|
||||
staff_name as nickName,
|
||||
case when sex = 0 then 'man' when sex = 1 then 'women' else '' end as sex,
|
||||
0 as age,
|
||||
'' as avatar
|
||||
from kitchen_staff_info
|
||||
where mobile = #{phoneNumber}
|
||||
</select>
|
||||
|
||||
<insert id="addPhysicalExaminationData">
|
||||
insert into kitchen_staff_physical_examination(staff_id, device_id, sex, age, height, weight, bmi, bodyFat, muscle, boneMass,
|
||||
waterContent, extwater, protein, metabolism, fatLevel, bodyAge)
|
||||
values (#{dto.userId},#{dto.machineId},#{dto.sex},#{dto.age},#{dto.height},#{dto.weight},#{dto.bmi},#{dto.bodyFat},#{dto.muscle},#{dto.boneMass},#{dto.waterContent},#{dto.extwater},#{dto.protein}
|
||||
,#{dto.metabolism},#{dto.fatLevel},#{dto.bodyAge})
|
||||
</insert>
|
||||
</mapper>
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
<?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.bonus.canteen.core.zhhq.mapper.ZhhqPhysicalExaminationMapper">
|
||||
|
||||
<select id="selectRecordByPhone" resultType="com.bonus.canteen.core.zhhq.domain.PhysicalExaminationVO">
|
||||
select
|
||||
staff_id as userId,
|
||||
device_id as machineId,
|
||||
sex,
|
||||
age,
|
||||
height,
|
||||
weight,
|
||||
bmi,
|
||||
boneMass,
|
||||
waterContent,
|
||||
extwater,
|
||||
protein,
|
||||
metabolism,
|
||||
fatLevel,
|
||||
bodyAge,
|
||||
bodyFat
|
||||
from kitchen_staff_physical_examination
|
||||
where phone = #{selectPhone}
|
||||
order by create_time desc
|
||||
</select>
|
||||
</mapper>
|
||||
|
||||
Loading…
Reference in New Issue