From ef4f32c7eae1cf2c9441eb64604672449e67f6a9 Mon Sep 17 00:00:00 2001 From: zzc Date: Mon, 12 May 2025 17:45:12 +0800 Subject: [PATCH] =?UTF-8?q?=E8=BA=AB=E9=AB=98=E4=BD=93=E9=87=8D=E4=BB=AA?= =?UTF-8?q?=E5=AF=B9=E6=8E=A5=E5=AE=8C=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/web/ExternalController.java | 19 + .../src/main/resources/mbg.xml | 3 +- .../system/domain/po/HmsWeightHeight.java | 50 +++ .../domain/po/HmsWeightHeightExample.java | 400 ++++++++++++++++++ .../persist/mapper/HmsWeightHeightMapper.java | 28 ++ .../system/service/ExternalService.java | 8 + .../service/impl/ExternalServiceImpl.java | 50 +++ .../mapper/system/HmsWeightHeightMapper.xml | 175 ++++++++ 8 files changed, 732 insertions(+), 1 deletion(-) create mode 100644 acupuncture-system/src/main/java/com/acupuncture/system/domain/po/HmsWeightHeight.java create mode 100644 acupuncture-system/src/main/java/com/acupuncture/system/domain/po/HmsWeightHeightExample.java create mode 100644 acupuncture-system/src/main/java/com/acupuncture/system/persist/mapper/HmsWeightHeightMapper.java create mode 100644 acupuncture-system/src/main/resources/mapper/system/HmsWeightHeightMapper.xml diff --git a/acupuncture-admin/src/main/java/com/acupuncture/web/controller/web/ExternalController.java b/acupuncture-admin/src/main/java/com/acupuncture/web/controller/web/ExternalController.java index e26940dd..90f07f42 100644 --- a/acupuncture-admin/src/main/java/com/acupuncture/web/controller/web/ExternalController.java +++ b/acupuncture-admin/src/main/java/com/acupuncture/web/controller/web/ExternalController.java @@ -20,6 +20,7 @@ import com.acupuncture.common.utils.file.FileUtils; import com.acupuncture.framework.config.ServerConfig; import com.acupuncture.framework.datasource.DynamicDataSourceContextHolder; import com.acupuncture.system.domain.dto.ExternalDto; +import com.acupuncture.system.domain.po.HmsWeightHeight; import com.acupuncture.system.domain.po.UplReportImage; import com.acupuncture.system.domain.po.UplRtcfInfo; import com.acupuncture.system.domain.vo.ExternalVo; @@ -191,4 +192,22 @@ public class ExternalController { public JsonResponse selectReportByMemberId(@RequestBody @Validated ExternalDto.MemberDto dto){ return JsonResponse.ok(externalService.selectReportByMemberId(dto.getId())); } + + @Anonymous + @ApiOperation("身高体重仪和针灸系统的对接") + @RequestMapping(value = "/api/http/dmh", method = {RequestMethod.GET, RequestMethod.POST}) + public JsonResponse dmh(@RequestBody String str){ + //W:066.5 H:173.5\r\n + log.info("身高体重仪和针灸系统的对接:{}", str); + externalService.dmh(str); + return JsonResponse.ok(); + } + + @DataSource(DataSourceType.MASTER) + @ApiOperation("查询身高体重") + @PostMapping("/api/http/getWeightHeight") + public JsonResponse getWeightHeight(){ + return JsonResponse.ok(externalService.getWeightHeight()); + } + } diff --git a/acupuncture-generator/src/main/resources/mbg.xml b/acupuncture-generator/src/main/resources/mbg.xml index d3e1f019..dcff7c0c 100644 --- a/acupuncture-generator/src/main/resources/mbg.xml +++ b/acupuncture-generator/src/main/resources/mbg.xml @@ -80,7 +80,8 @@ - + +
diff --git a/acupuncture-system/src/main/java/com/acupuncture/system/domain/po/HmsWeightHeight.java b/acupuncture-system/src/main/java/com/acupuncture/system/domain/po/HmsWeightHeight.java new file mode 100644 index 00000000..a0a17883 --- /dev/null +++ b/acupuncture-system/src/main/java/com/acupuncture/system/domain/po/HmsWeightHeight.java @@ -0,0 +1,50 @@ +package com.acupuncture.system.domain.po; + +import java.io.Serializable; + +public class HmsWeightHeight implements Serializable { + private Long id; + + private String height; + + private String weight; + + private static final long serialVersionUID = 1L; + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getHeight() { + return height; + } + + public void setHeight(String height) { + this.height = height == null ? null : height.trim(); + } + + public String getWeight() { + return weight; + } + + public void setWeight(String weight) { + this.weight = weight == null ? null : weight.trim(); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append(getClass().getSimpleName()); + sb.append(" ["); + sb.append("Hash = ").append(hashCode()); + sb.append(", id=").append(id); + sb.append(", height=").append(height); + sb.append(", weight=").append(weight); + sb.append("]"); + return sb.toString(); + } +} \ No newline at end of file diff --git a/acupuncture-system/src/main/java/com/acupuncture/system/domain/po/HmsWeightHeightExample.java b/acupuncture-system/src/main/java/com/acupuncture/system/domain/po/HmsWeightHeightExample.java new file mode 100644 index 00000000..a22550b7 --- /dev/null +++ b/acupuncture-system/src/main/java/com/acupuncture/system/domain/po/HmsWeightHeightExample.java @@ -0,0 +1,400 @@ +package com.acupuncture.system.domain.po; + +import java.util.ArrayList; +import java.util.List; + +public class HmsWeightHeightExample { + protected String orderByClause; + + protected boolean distinct; + + protected List oredCriteria; + + public HmsWeightHeightExample() { + oredCriteria = new ArrayList(); + } + + public void setOrderByClause(String orderByClause) { + this.orderByClause = orderByClause; + } + + public String getOrderByClause() { + return orderByClause; + } + + public void setDistinct(boolean distinct) { + this.distinct = distinct; + } + + public boolean isDistinct() { + return distinct; + } + + public List getOredCriteria() { + return oredCriteria; + } + + public void or(Criteria criteria) { + oredCriteria.add(criteria); + } + + public Criteria or() { + Criteria criteria = createCriteriaInternal(); + oredCriteria.add(criteria); + return criteria; + } + + public Criteria createCriteria() { + Criteria criteria = createCriteriaInternal(); + if (oredCriteria.size() == 0) { + oredCriteria.add(criteria); + } + return criteria; + } + + protected Criteria createCriteriaInternal() { + Criteria criteria = new Criteria(); + return criteria; + } + + public void clear() { + oredCriteria.clear(); + orderByClause = null; + distinct = false; + } + + protected abstract static class GeneratedCriteria { + protected List criteria; + + protected GeneratedCriteria() { + super(); + criteria = new ArrayList(); + } + + public boolean isValid() { + return criteria.size() > 0; + } + + public List getAllCriteria() { + return criteria; + } + + public List getCriteria() { + return criteria; + } + + protected void addCriterion(String condition) { + if (condition == null) { + throw new RuntimeException("Value for condition cannot be null"); + } + criteria.add(new Criterion(condition)); + } + + protected void addCriterion(String condition, Object value, String property) { + if (value == null) { + throw new RuntimeException("Value for " + property + " cannot be null"); + } + criteria.add(new Criterion(condition, value)); + } + + protected void addCriterion(String condition, Object value1, Object value2, String property) { + if (value1 == null || value2 == null) { + throw new RuntimeException("Between values for " + property + " cannot be null"); + } + criteria.add(new Criterion(condition, value1, value2)); + } + + public Criteria andIdIsNull() { + addCriterion("id is null"); + return (Criteria) this; + } + + public Criteria andIdIsNotNull() { + addCriterion("id is not null"); + return (Criteria) this; + } + + public Criteria andIdEqualTo(Long value) { + addCriterion("id =", value, "id"); + return (Criteria) this; + } + + public Criteria andIdNotEqualTo(Long value) { + addCriterion("id <>", value, "id"); + return (Criteria) this; + } + + public Criteria andIdGreaterThan(Long value) { + addCriterion("id >", value, "id"); + return (Criteria) this; + } + + public Criteria andIdGreaterThanOrEqualTo(Long value) { + addCriterion("id >=", value, "id"); + return (Criteria) this; + } + + public Criteria andIdLessThan(Long value) { + addCriterion("id <", value, "id"); + return (Criteria) this; + } + + public Criteria andIdLessThanOrEqualTo(Long value) { + addCriterion("id <=", value, "id"); + return (Criteria) this; + } + + public Criteria andIdIn(List values) { + addCriterion("id in", values, "id"); + return (Criteria) this; + } + + public Criteria andIdNotIn(List values) { + addCriterion("id not in", values, "id"); + return (Criteria) this; + } + + public Criteria andIdBetween(Long value1, Long value2) { + addCriterion("id between", value1, value2, "id"); + return (Criteria) this; + } + + public Criteria andIdNotBetween(Long value1, Long value2) { + addCriterion("id not between", value1, value2, "id"); + return (Criteria) this; + } + + public Criteria andHeightIsNull() { + addCriterion("height is null"); + return (Criteria) this; + } + + public Criteria andHeightIsNotNull() { + addCriterion("height is not null"); + return (Criteria) this; + } + + public Criteria andHeightEqualTo(String value) { + addCriterion("height =", value, "height"); + return (Criteria) this; + } + + public Criteria andHeightNotEqualTo(String value) { + addCriterion("height <>", value, "height"); + return (Criteria) this; + } + + public Criteria andHeightGreaterThan(String value) { + addCriterion("height >", value, "height"); + return (Criteria) this; + } + + public Criteria andHeightGreaterThanOrEqualTo(String value) { + addCriterion("height >=", value, "height"); + return (Criteria) this; + } + + public Criteria andHeightLessThan(String value) { + addCriterion("height <", value, "height"); + return (Criteria) this; + } + + public Criteria andHeightLessThanOrEqualTo(String value) { + addCriterion("height <=", value, "height"); + return (Criteria) this; + } + + public Criteria andHeightLike(String value) { + addCriterion("height like", value, "height"); + return (Criteria) this; + } + + public Criteria andHeightNotLike(String value) { + addCriterion("height not like", value, "height"); + return (Criteria) this; + } + + public Criteria andHeightIn(List values) { + addCriterion("height in", values, "height"); + return (Criteria) this; + } + + public Criteria andHeightNotIn(List values) { + addCriterion("height not in", values, "height"); + return (Criteria) this; + } + + public Criteria andHeightBetween(String value1, String value2) { + addCriterion("height between", value1, value2, "height"); + return (Criteria) this; + } + + public Criteria andHeightNotBetween(String value1, String value2) { + addCriterion("height not between", value1, value2, "height"); + return (Criteria) this; + } + + public Criteria andWeightIsNull() { + addCriterion("weight is null"); + return (Criteria) this; + } + + public Criteria andWeightIsNotNull() { + addCriterion("weight is not null"); + return (Criteria) this; + } + + public Criteria andWeightEqualTo(String value) { + addCriterion("weight =", value, "weight"); + return (Criteria) this; + } + + public Criteria andWeightNotEqualTo(String value) { + addCriterion("weight <>", value, "weight"); + return (Criteria) this; + } + + public Criteria andWeightGreaterThan(String value) { + addCriterion("weight >", value, "weight"); + return (Criteria) this; + } + + public Criteria andWeightGreaterThanOrEqualTo(String value) { + addCriterion("weight >=", value, "weight"); + return (Criteria) this; + } + + public Criteria andWeightLessThan(String value) { + addCriterion("weight <", value, "weight"); + return (Criteria) this; + } + + public Criteria andWeightLessThanOrEqualTo(String value) { + addCriterion("weight <=", value, "weight"); + return (Criteria) this; + } + + public Criteria andWeightLike(String value) { + addCriterion("weight like", value, "weight"); + return (Criteria) this; + } + + public Criteria andWeightNotLike(String value) { + addCriterion("weight not like", value, "weight"); + return (Criteria) this; + } + + public Criteria andWeightIn(List values) { + addCriterion("weight in", values, "weight"); + return (Criteria) this; + } + + public Criteria andWeightNotIn(List values) { + addCriterion("weight not in", values, "weight"); + return (Criteria) this; + } + + public Criteria andWeightBetween(String value1, String value2) { + addCriterion("weight between", value1, value2, "weight"); + return (Criteria) this; + } + + public Criteria andWeightNotBetween(String value1, String value2) { + addCriterion("weight not between", value1, value2, "weight"); + return (Criteria) this; + } + } + + public static class Criteria extends GeneratedCriteria { + + protected Criteria() { + super(); + } + } + + public static class Criterion { + private String condition; + + private Object value; + + private Object secondValue; + + private boolean noValue; + + private boolean singleValue; + + private boolean betweenValue; + + private boolean listValue; + + private String typeHandler; + + public String getCondition() { + return condition; + } + + public Object getValue() { + return value; + } + + public Object getSecondValue() { + return secondValue; + } + + public boolean isNoValue() { + return noValue; + } + + public boolean isSingleValue() { + return singleValue; + } + + public boolean isBetweenValue() { + return betweenValue; + } + + public boolean isListValue() { + return listValue; + } + + public String getTypeHandler() { + return typeHandler; + } + + protected Criterion(String condition) { + super(); + this.condition = condition; + this.typeHandler = null; + this.noValue = true; + } + + protected Criterion(String condition, Object value, String typeHandler) { + super(); + this.condition = condition; + this.value = value; + this.typeHandler = typeHandler; + if (value instanceof List) { + this.listValue = true; + } else { + this.singleValue = true; + } + } + + protected Criterion(String condition, Object value) { + this(condition, value, null); + } + + protected Criterion(String condition, Object value, Object secondValue, String typeHandler) { + super(); + this.condition = condition; + this.value = value; + this.secondValue = secondValue; + this.typeHandler = typeHandler; + this.betweenValue = true; + } + + protected Criterion(String condition, Object value, Object secondValue) { + this(condition, value, secondValue, null); + } + } +} \ No newline at end of file diff --git a/acupuncture-system/src/main/java/com/acupuncture/system/persist/mapper/HmsWeightHeightMapper.java b/acupuncture-system/src/main/java/com/acupuncture/system/persist/mapper/HmsWeightHeightMapper.java new file mode 100644 index 00000000..5914d4c6 --- /dev/null +++ b/acupuncture-system/src/main/java/com/acupuncture/system/persist/mapper/HmsWeightHeightMapper.java @@ -0,0 +1,28 @@ +package com.acupuncture.system.persist.mapper; + +import com.acupuncture.system.domain.po.HmsWeightHeight; +import com.acupuncture.system.domain.po.HmsWeightHeightExample; +import java.util.List; +import org.apache.ibatis.annotations.Param; + +public interface HmsWeightHeightMapper { + long countByExample(HmsWeightHeightExample example); + + int deleteByPrimaryKey(Long id); + + int insert(HmsWeightHeight record); + + int insertSelective(HmsWeightHeight record); + + List selectByExample(HmsWeightHeightExample example); + + HmsWeightHeight selectByPrimaryKey(Long id); + + int updateByExampleSelective(@Param("record") HmsWeightHeight record, @Param("example") HmsWeightHeightExample example); + + int updateByExample(@Param("record") HmsWeightHeight record, @Param("example") HmsWeightHeightExample example); + + int updateByPrimaryKeySelective(HmsWeightHeight record); + + int updateByPrimaryKey(HmsWeightHeight record); +} \ No newline at end of file diff --git a/acupuncture-system/src/main/java/com/acupuncture/system/service/ExternalService.java b/acupuncture-system/src/main/java/com/acupuncture/system/service/ExternalService.java index 57f13367..eee96d91 100644 --- a/acupuncture-system/src/main/java/com/acupuncture/system/service/ExternalService.java +++ b/acupuncture-system/src/main/java/com/acupuncture/system/service/ExternalService.java @@ -1,6 +1,7 @@ package com.acupuncture.system.service; import com.acupuncture.system.domain.dto.ExternalDto; +import com.acupuncture.system.domain.po.HmsWeightHeight; import com.acupuncture.system.domain.po.UplReportImage; import com.acupuncture.system.domain.po.UplRtcfInfo; import com.acupuncture.system.domain.vo.ExternalVo; @@ -54,4 +55,11 @@ public interface ExternalService { */ UplReportImage selectReportByMemberId(Long id); + /** + * DHM人体秤通讯协议对接 + * @param str + */ + void dmh(String str); + + HmsWeightHeight getWeightHeight(); } diff --git a/acupuncture-system/src/main/java/com/acupuncture/system/service/impl/ExternalServiceImpl.java b/acupuncture-system/src/main/java/com/acupuncture/system/service/impl/ExternalServiceImpl.java index 2e6478f1..95b468b6 100644 --- a/acupuncture-system/src/main/java/com/acupuncture/system/service/impl/ExternalServiceImpl.java +++ b/acupuncture-system/src/main/java/com/acupuncture/system/service/impl/ExternalServiceImpl.java @@ -10,15 +10,19 @@ import com.acupuncture.system.domain.po.*; import com.acupuncture.system.domain.vo.ExternalVo; import com.acupuncture.system.domain.vo.UplRtcfInfoVo; import com.acupuncture.system.persist.dao.ExternalDao; +import com.acupuncture.system.persist.mapper.HmsWeightHeightMapper; import com.acupuncture.system.persist.mapper.PmsTreatmentMapper; import com.acupuncture.system.persist.mapper.UplReportImageMapper; import com.acupuncture.system.persist.mapper.UplRtcfInfoMapper; import com.acupuncture.system.service.ExternalService; +import com.github.pagehelper.PageHelper; import org.springframework.stereotype.Service; import javax.annotation.Resource; import java.util.Date; import java.util.List; +import java.util.regex.Matcher; +import java.util.regex.Pattern; /** * @Author zzc @@ -39,6 +43,8 @@ public class ExternalServiceImpl implements ExternalService { private RedisCache redisCache; @Resource private PmsTreatmentMapper pmsTreatmentMapper; + @Resource + private HmsWeightHeightMapper hmsWeightHeightMapper; @Override public ExternalVo.Result query(String from, String memberid) { @@ -220,4 +226,48 @@ public class ExternalServiceImpl implements ExternalService { } return new UplReportImage(); } + + @Override + public void dmh(String str) { + // 1. 去除首尾空格和换行符 + String trimmedInput = str.trim(); + + // 2. 定义正则表达式匹配模式 + Pattern pattern = Pattern.compile("W:(\\d+\\.\\d+)\\s+H:(\\d+\\.\\d+)"); + Matcher matcher = pattern.matcher(trimmedInput); + + // 3. 提取并处理匹配结果 + if (matcher.find()) { + String wValue = matcher.group(1); // 提取 W 的数值部分 + String hValue = matcher.group(2); // 提取 H 的数值部分 + + // 转换为 Double(自动忽略前导零) + double width = Double.parseDouble(wValue); + double height = Double.parseDouble(hValue); + + HmsWeightHeight hmsWeightHeight = new HmsWeightHeight(); + hmsWeightHeight.setHeight(height + ""); + hmsWeightHeight.setWeight(width + ""); + hmsWeightHeight.setId(IdUtil.getSnowflakeNextId()); + hmsWeightHeightMapper.insertSelective(hmsWeightHeight); + + // 输出结果(或按需处理) + System.out.println("W: " + width); // 输出: W: 66.5 + System.out.println("H: " + height); // 输出: H: 173.5 + } else { + System.out.println("未找到有效的 W 或 H 值"); + } + } + + @Override + public HmsWeightHeight getWeightHeight() { + PageHelper.startPage(1, 1); + HmsWeightHeightExample hmsWeightHeightExample = new HmsWeightHeightExample(); + hmsWeightHeightExample.setOrderByClause("id desc"); + List hmsWeightHeights = hmsWeightHeightMapper.selectByExample(hmsWeightHeightExample); + if (CollectionUtil.isNotEmpty(hmsWeightHeights)) { + return hmsWeightHeights.get(0); + } + return null; + } } diff --git a/acupuncture-system/src/main/resources/mapper/system/HmsWeightHeightMapper.xml b/acupuncture-system/src/main/resources/mapper/system/HmsWeightHeightMapper.xml new file mode 100644 index 00000000..7ae6854a --- /dev/null +++ b/acupuncture-system/src/main/resources/mapper/system/HmsWeightHeightMapper.xml @@ -0,0 +1,175 @@ + + + + + + + + + + + + + + + + + and ${criterion.condition} + + + and ${criterion.condition} #{criterion.value} + + + and ${criterion.condition} #{criterion.value} and #{criterion.secondValue} + + + and ${criterion.condition} + + #{listItem} + + + + + + + + + + + + + + + + + + and ${criterion.condition} + + + and ${criterion.condition} #{criterion.value} + + + and ${criterion.condition} #{criterion.value} and #{criterion.secondValue} + + + and ${criterion.condition} + + #{listItem} + + + + + + + + + + + id, height, weight + + + + + delete from hms_weight_height + where id = #{id,jdbcType=BIGINT} + + + insert into hms_weight_height (id, height, weight + ) + values (#{id,jdbcType=BIGINT}, #{height,jdbcType=VARCHAR}, #{weight,jdbcType=VARCHAR} + ) + + + insert into hms_weight_height + + + id, + + + height, + + + weight, + + + + + #{id,jdbcType=BIGINT}, + + + #{height,jdbcType=VARCHAR}, + + + #{weight,jdbcType=VARCHAR}, + + + + + + update hms_weight_height + + + id = #{record.id,jdbcType=BIGINT}, + + + height = #{record.height,jdbcType=VARCHAR}, + + + weight = #{record.weight,jdbcType=VARCHAR}, + + + + + + + + update hms_weight_height + set id = #{record.id,jdbcType=BIGINT}, + height = #{record.height,jdbcType=VARCHAR}, + weight = #{record.weight,jdbcType=VARCHAR} + + + + + + update hms_weight_height + + + height = #{height,jdbcType=VARCHAR}, + + + weight = #{weight,jdbcType=VARCHAR}, + + + where id = #{id,jdbcType=BIGINT} + + + update hms_weight_height + set height = #{height,jdbcType=VARCHAR}, + weight = #{weight,jdbcType=VARCHAR} + where id = #{id,jdbcType=BIGINT} + + \ No newline at end of file