免疫保健

This commit is contained in:
piaobo 2025-07-25 15:12:35 +08:00
parent 693c73f30e
commit af811ad8b5
9 changed files with 162 additions and 84 deletions

View File

@ -52,7 +52,7 @@ public class Health extends BaseEntity
/** 用药记录 */ /** 用药记录 */
@Excel(name = "用药记录") @Excel(name = "用药记录")
private Long usageId; private Integer usageId;
/** 技术员 */ /** 技术员 */

View File

@ -57,7 +57,7 @@ public class Immunity extends BaseEntity
/** 使用记录 */ /** 使用记录 */
@Excel(name = "使用记录") @Excel(name = "使用记录")
private Long usageId; private Integer usageId;
/** 免疫日期 */ /** 免疫日期 */

View File

@ -35,7 +35,7 @@ public interface HealthMapper
* @param health 保健 * @param health 保健
* @return 结果 * @return 结果
*/ */
public int insertHealth(Health health); public int insertHealth(List<Health> health);
/** /**
* 修改保健 * 修改保健

View File

@ -35,7 +35,7 @@ public interface ImmunityMapper
* @param immunity 免疫 * @param immunity 免疫
* @return 结果 * @return 结果
*/ */
public int insertImmunity(Immunity immunity); public int insertImmunity(List<Immunity> immunity);
/** /**
* 修改免疫 * 修改免疫

View File

@ -102,8 +102,7 @@ public class DewormServiceImpl implements IDewormService
dew.setUsageId(usageId); dew.setUsageId(usageId);
deworms.add(dew); deworms.add(dew);
} }
// 药品使用记录
medicineUsage.setSwMedicineUsageDetailsList(deworm.getUsageDetails());
return dewormMapper.insertDeworm(deworms); return dewormMapper.insertDeworm(deworms);
} }
@ -115,6 +114,7 @@ public class DewormServiceImpl implements IDewormService
* @return 结果 * @return 结果
*/ */
@Override @Override
@Transactional
public int updateDeworm(Deworm deworm) public int updateDeworm(Deworm deworm)
{ {

View File

@ -1,7 +1,15 @@
package com.zhyc.module.biosafety.service.impl; package com.zhyc.module.biosafety.service.impl;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import com.zhyc.common.utils.DateUtils; import com.zhyc.common.utils.DateUtils;
import com.zhyc.common.utils.bean.BeanUtils;
import com.zhyc.module.base.domain.SheepFile;
import com.zhyc.module.base.mapper.SheepFileMapper;
import com.zhyc.module.biosafety.domain.Health;
import com.zhyc.module.biosafety.domain.SwMedicineUsage;
import com.zhyc.module.biosafety.domain.SwMedicineUsageDetails;
import com.zhyc.module.biosafety.mapper.SwMedicineUsageMapper;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.zhyc.module.biosafety.mapper.HealthMapper; import com.zhyc.module.biosafety.mapper.HealthMapper;
@ -20,6 +28,15 @@ public class HealthServiceImpl implements IHealthService
@Autowired @Autowired
private HealthMapper healthMapper; private HealthMapper healthMapper;
@Autowired
private SwMedicineUsageServiceImpl medicineUsageService;
@Autowired
private SwMedicineUsageMapper medicineUsageMapper;
@Autowired
private SheepFileMapper sheepFileMapper;
/** /**
* 查询保健 * 查询保健
* *
@ -29,7 +46,10 @@ public class HealthServiceImpl implements IHealthService
@Override @Override
public Health selectHealthById(Long id) public Health selectHealthById(Long id)
{ {
return healthMapper.selectHealthById(id); Health health = healthMapper.selectHealthById(id);
SwMedicineUsage swMedicineUsage = medicineUsageMapper.selectSwMedicineUsageById(health.getUsageId());
health.setUsageDetails(swMedicineUsage.getSwMedicineUsageDetailsList());
return health;
} }
/** /**
@ -53,8 +73,39 @@ public class HealthServiceImpl implements IHealthService
@Override @Override
public int insertHealth(Health health) public int insertHealth(Health health)
{ {
// 使用记录的文件
SwMedicineUsage medicineUsage = new SwMedicineUsage();
medicineUsage.setSwMedicineUsageDetailsList(health.getUsageDetails());
medicineUsage.setName("羊只保健");
medicineUsage.setUseType("2");
List<Health> healths = new ArrayList<>();
health.setCreateTime(DateUtils.getNowDate()); health.setCreateTime(DateUtils.getNowDate());
return healthMapper.insertHealth(health); for (Integer sheepId : health.getSheepIds()) {
SheepFile sheepFile = sheepFileMapper.selectSheepFileById(Long.valueOf(sheepId));
System.out.println(sheepFile);
Health heal = new Health();
BeanUtils.copyProperties(health, heal);
heal.setSheepId(Long.valueOf(sheepId));
heal.setVariety(sheepFile.getVariety());
heal.setSheepType(sheepFile.getName());
heal.setMonthAge(sheepFile.getMonthAge());
heal.setGender(String.valueOf(sheepFile.getGender()));
heal.setBreed(sheepFile.getBreed());
heal.setParity(sheepFile.getParity());
// 获取药品使用记录的id
Integer usageId = medicineUsageService.insertSwMedicineUsage(medicineUsage);
heal.setUsageId(usageId);
healths.add(heal);
}
health.setCreateTime(DateUtils.getNowDate());
return healthMapper.insertHealth(healths);
} }
/** /**
@ -66,6 +117,11 @@ public class HealthServiceImpl implements IHealthService
@Override @Override
public int updateHealth(Health health) public int updateHealth(Health health)
{ {
for (SwMedicineUsageDetails usageDetail : health.getUsageDetails()) {
usageDetail.setMediUsage(health.getUsageId());
}
medicineUsageMapper.deleteSwMedicineUsageDetailsByMediUsage(health.getUsageId());
medicineUsageMapper.batchSwMedicineUsageDetails(health.getUsageDetails());
health.setUpdateTime(DateUtils.getNowDate()); health.setUpdateTime(DateUtils.getNowDate());
return healthMapper.updateHealth(health); return healthMapper.updateHealth(health);
} }

View File

@ -1,12 +1,21 @@
package com.zhyc.module.biosafety.service.impl; package com.zhyc.module.biosafety.service.impl;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import com.zhyc.common.utils.DateUtils; import com.zhyc.common.utils.DateUtils;
import com.zhyc.common.utils.bean.BeanUtils;
import com.zhyc.module.base.domain.SheepFile;
import com.zhyc.module.base.mapper.SheepFileMapper;
import com.zhyc.module.biosafety.domain.Deworm;
import com.zhyc.module.biosafety.domain.SwMedicineUsage;
import com.zhyc.module.biosafety.domain.SwMedicineUsageDetails;
import com.zhyc.module.biosafety.mapper.SwMedicineUsageMapper;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.zhyc.module.biosafety.mapper.ImmunityMapper; import com.zhyc.module.biosafety.mapper.ImmunityMapper;
import com.zhyc.module.biosafety.domain.Immunity; import com.zhyc.module.biosafety.domain.Immunity;
import com.zhyc.module.biosafety.service.IImmunityService; import com.zhyc.module.biosafety.service.IImmunityService;
import org.springframework.transaction.annotation.Transactional;
/** /**
* 免疫Service业务层处理 * 免疫Service业务层处理
@ -20,6 +29,16 @@ public class ImmunityServiceImpl implements IImmunityService
@Autowired @Autowired
private ImmunityMapper immunityMapper; private ImmunityMapper immunityMapper;
@Autowired
private SwMedicineUsageServiceImpl medicineUsageService;
@Autowired
private SwMedicineUsageMapper medicineUsageMapper;
@Autowired
private SheepFileMapper sheepFileMapper;
/** /**
* 查询免疫 * 查询免疫
* *
@ -29,7 +48,10 @@ public class ImmunityServiceImpl implements IImmunityService
@Override @Override
public Immunity selectImmunityById(Long id) public Immunity selectImmunityById(Long id)
{ {
return immunityMapper.selectImmunityById(id); Immunity immunity = immunityMapper.selectImmunityById(id);
SwMedicineUsage swMedicineUsage = medicineUsageMapper.selectSwMedicineUsageById(immunity.getUsageId());
immunity.setUsageDetails(swMedicineUsage.getSwMedicineUsageDetailsList());
return immunity;
} }
/** /**
@ -53,8 +75,40 @@ public class ImmunityServiceImpl implements IImmunityService
@Override @Override
public int insertImmunity(Immunity immunity) public int insertImmunity(Immunity immunity)
{ {
// 使用记录的文件
SwMedicineUsage medicineUsage = new SwMedicineUsage();
medicineUsage.setSwMedicineUsageDetailsList(immunity.getUsageDetails());
medicineUsage.setName("羊只免疫");
medicineUsage.setUseType("0");
List<Immunity> immunities = new ArrayList<>();
immunity.setCreateTime(DateUtils.getNowDate()); immunity.setCreateTime(DateUtils.getNowDate());
return immunityMapper.insertImmunity(immunity); System.out.println();
for (Integer sheepId : immunity.getSheepIds()) {
SheepFile sheepFile = sheepFileMapper.selectSheepFileById(Long.valueOf(sheepId));
System.out.println(sheepFile);
Immunity imm = new Immunity();
BeanUtils.copyProperties(immunity, imm);
imm.setSheepId(Long.valueOf(sheepId));
imm.setVariety(sheepFile.getVariety());
imm.setSheepType(sheepFile.getName());
imm.setMonthAge(sheepFile.getMonthAge());
imm.setGender(String.valueOf(sheepFile.getGender()));
imm.setBreed(sheepFile.getBreed());
imm.setParity(sheepFile.getParity());
// 获取药品使用记录的id
Integer usageId = medicineUsageService.insertSwMedicineUsage(medicineUsage);
imm.setUsageId(usageId);
immunities.add(imm);
}
immunity.setCreateTime(DateUtils.getNowDate());
return immunityMapper.insertImmunity(immunities);
} }
/** /**
@ -64,8 +118,14 @@ public class ImmunityServiceImpl implements IImmunityService
* @return 结果 * @return 结果
*/ */
@Override @Override
@Transactional
public int updateImmunity(Immunity immunity) public int updateImmunity(Immunity immunity)
{ {
for (SwMedicineUsageDetails usageDetail : immunity.getUsageDetails()) {
usageDetail.setMediUsage(immunity.getUsageId());
}
medicineUsageMapper.deleteSwMedicineUsageDetailsByMediUsage(immunity.getUsageId());
medicineUsageMapper.batchSwMedicineUsageDetails(immunity.getUsageDetails());
immunity.setUpdateTime(DateUtils.getNowDate()); immunity.setUpdateTime(DateUtils.getNowDate());
return immunityMapper.updateImmunity(immunity); return immunityMapper.updateImmunity(immunity);
} }

View File

@ -8,6 +8,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="id" column="id" /> <result property="id" column="id" />
<result property="datetime" column="datetime" /> <result property="datetime" column="datetime" />
<result property="sheepId" column="sheep_id" /> <result property="sheepId" column="sheep_id" />
<result property="sheepNo" column="sheep_no"/>
<result property="usageId" column="usage_id" /> <result property="usageId" column="usage_id" />
<result property="variety" column="variety" /> <result property="variety" column="variety" />
<result property="sheepType" column="sheep_type" /> <result property="sheepType" column="sheep_type" />
@ -24,7 +25,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</resultMap> </resultMap>
<sql id="selectHealthVo"> <sql id="selectHealthVo">
select id, datetime, sheep_id, usage_id, variety, sheep_type, gender, month_age, parity, breed, technical, comment, update_by, update_time, create_by, create_time from sw_health select s.id, datetime, sheep_id, usage_id, variety, sheep_type, s.gender, month_age, s.parity, breed, technical,
s.comment, s.update_by, s.update_time, s.create_by, s.create_time,
bs.manage_tags sheep_no
from sw_health s
left join bas_sheep bs on s.sheep_id = bs.id
</sql> </sql>
<select id="selectHealthList" parameterType="Health" resultMap="HealthResult"> <select id="selectHealthList" parameterType="Health" resultMap="HealthResult">
@ -37,45 +43,21 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="selectHealthById" parameterType="Long" resultMap="HealthResult"> <select id="selectHealthById" parameterType="Long" resultMap="HealthResult">
<include refid="selectHealthVo"/> <include refid="selectHealthVo"/>
where id = #{id} where s.id = #{id}
</select> </select>
<insert id="insertHealth" parameterType="Health" useGeneratedKeys="true" keyProperty="id"> <insert id="insertHealth" parameterType="Health" useGeneratedKeys="true" keyProperty="id">
insert into sw_health insert into sw_health
<trim prefix="(" suffix=")" suffixOverrides=","> (sheep_id, usage_id, variety, sheep_type, gender, month_age,
<if test="datetime != null">datetime,</if> parity, breed,datetime, technical, comment,
<if test="sheepId != null">sheep_id,</if> update_by, update_time, create_by, create_time)
<if test="usageId != null">usage_id,</if> values
<if test="variety != null">variety,</if> <foreach collection="list" item="d" separator=",">
<if test="sheepType != null">sheep_type,</if> (#{d.sheepId}, #{d.usageId}, #{d.variety}, #{d.sheepType},
<if test="gender != null">gender,</if> #{d.gender}, #{d.monthAge}, #{d.parity},#{d.breed}, #{d.datetime},
<if test="monthAge != null">month_age,</if> #{d.technical}, #{d.comment},
<if test="parity != null">parity,</if> #{d.updateBy}, #{d.updateTime}, #{d.createBy}, #{d.createTime})
<if test="breed != null">breed,</if> </foreach>
<if test="technical != null">technical,</if>
<if test="comment != null">comment,</if>
<if test="updateBy != null">update_by,</if>
<if test="updateTime != null">update_time,</if>
<if test="createBy != null">create_by,</if>
<if test="createTime != null">create_time,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="datetime != null">#{datetime},</if>
<if test="sheepId != null">#{sheepId},</if>
<if test="usageId != null">#{usageId},</if>
<if test="variety != null">#{variety},</if>
<if test="sheepType != null">#{sheepType},</if>
<if test="gender != null">#{gender},</if>
<if test="monthAge != null">#{monthAge},</if>
<if test="parity != null">#{parity},</if>
<if test="breed != null">#{breed},</if>
<if test="technical != null">#{technical},</if>
<if test="comment != null">#{comment},</if>
<if test="updateBy != null">#{updateBy},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="createBy != null">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
</trim>
</insert> </insert>
<update id="updateHealth" parameterType="Health"> <update id="updateHealth" parameterType="Health">

View File

@ -7,24 +7,28 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<resultMap type="Immunity" id="ImmunityResult"> <resultMap type="Immunity" id="ImmunityResult">
<result property="id" column="id" /> <result property="id" column="id" />
<result property="sheepId" column="sheep_id" /> <result property="sheepId" column="sheep_id" />
<result property="sheepNo" column="sheep_no"/>
<result property="usageId" column="usage_id" /> <result property="usageId" column="usage_id" />
<result property="variety" column="variety" /> <result property="variety" column="variety" />
<result property="sheepType" column="sheep_type" /> <result property="sheepType" column="sheep_type" />
<result property="gender" column="gender" /> <result property="gender" column="gender" />
<result property="monthAge" column="month_age" /> <result property="monthAge" column="month_age" />
<result property="parity" column="parity" /> <result property="parity" column="parity" />
<result property="breed" column="breed" /> <result property="breed" column="breed"/>
<result property="datetime" column="datetime" /> <result property="datetime" column="datetime" />
<result property="technical" column="technical" /> <result property="technical" column="technical" />
<result property="comment" column="comment" /> <result property="comment" column="comment" />
<result property="updateBy" column="update_by" /> <result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" /> <result property="updateTime" column="update_time" />
<result property="createBy" column="create_by" /> <result property="createBy" column="create_by" />
<result property="createTime" column="create_time" />
</resultMap> </resultMap>
<sql id="selectImmunityVo"> <sql id="selectImmunityVo">
select id, sheep_id, usage_id, variety, sheep_type, gender, month_age, parity, breed, datetime, technical, comment, update_by, update_time, create_by, create_time from sw_immunity select s.id, datetime, sheep_id, usage_id, variety, sheep_type, s.gender, month_age, s.parity, breed, technical,
s.comment, s.update_by, s.update_time, s.create_by, s.create_time,
bs.manage_tags sheep_no
from sw_immunity s
left join bas_sheep bs on s.sheep_id = bs.id
</sql> </sql>
<select id="selectImmunityList" parameterType="Immunity" resultMap="ImmunityResult"> <select id="selectImmunityList" parameterType="Immunity" resultMap="ImmunityResult">
@ -39,45 +43,21 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="selectImmunityById" parameterType="Long" resultMap="ImmunityResult"> <select id="selectImmunityById" parameterType="Long" resultMap="ImmunityResult">
<include refid="selectImmunityVo"/> <include refid="selectImmunityVo"/>
where id = #{id} where s.id = #{id}
</select> </select>
<insert id="insertImmunity" parameterType="Immunity" useGeneratedKeys="true" keyProperty="id"> <insert id="insertImmunity" parameterType="Immunity" useGeneratedKeys="true" keyProperty="id">
insert into sw_immunity insert into sw_immunity
<trim prefix="(" suffix=")" suffixOverrides=","> (sheep_id, usage_id, variety, sheep_type, gender, month_age,
<if test="sheepId != null">sheep_id,</if> parity, breed,datetime, technical, comment,
<if test="usageId != null">usage_id,</if> update_by, update_time, create_by, create_time)
<if test="variety != null">variety,</if> values
<if test="sheepType != null">sheep_type,</if> <foreach collection="list" item="d" separator=",">
<if test="gender != null">gender,</if> (#{d.sheepId}, #{d.usageId}, #{d.variety}, #{d.sheepType},
<if test="monthAge != null">month_age,</if> #{d.gender}, #{d.monthAge}, #{d.parity},#{d.breed}, #{d.datetime},
<if test="parity != null">parity,</if> #{d.technical}, #{d.comment},
<if test="breed != null">breed,</if> #{d.updateBy}, #{d.updateTime}, #{d.createBy}, #{d.createTime})
<if test="datetime != null">datetime,</if> </foreach>
<if test="technical != null">technical,</if>
<if test="comment != null">comment,</if>
<if test="updateBy != null">update_by,</if>
<if test="updateTime != null">update_time,</if>
<if test="createBy != null">create_by,</if>
<if test="createTime != null">create_time,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="sheepId != null">#{sheepId},</if>
<if test="usageId != null">#{usageId},</if>
<if test="variety != null">#{variety},</if>
<if test="sheepType != null">#{sheepType},</if>
<if test="gender != null">#{gender},</if>
<if test="monthAge != null">#{monthAge},</if>
<if test="parity != null">#{parity},</if>
<if test="breed != null">#{breed},</if>
<if test="datetime != null">#{datetime},</if>
<if test="technical != null">#{technical},</if>
<if test="comment != null">#{comment},</if>
<if test="updateBy != null">#{updateBy},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="createBy != null">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
</trim>
</insert> </insert>
<update id="updateImmunity" parameterType="Immunity"> <update id="updateImmunity" parameterType="Immunity">