免疫保健
This commit is contained in:
parent
693c73f30e
commit
af811ad8b5
@ -52,7 +52,7 @@ public class Health extends BaseEntity
|
||||
|
||||
/** 用药记录 */
|
||||
@Excel(name = "用药记录")
|
||||
private Long usageId;
|
||||
private Integer usageId;
|
||||
|
||||
|
||||
/** 技术员 */
|
||||
|
@ -57,7 +57,7 @@ public class Immunity extends BaseEntity
|
||||
|
||||
/** 使用记录 */
|
||||
@Excel(name = "使用记录")
|
||||
private Long usageId;
|
||||
private Integer usageId;
|
||||
|
||||
|
||||
/** 免疫日期 */
|
||||
|
@ -35,7 +35,7 @@ public interface HealthMapper
|
||||
* @param health 保健
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertHealth(Health health);
|
||||
public int insertHealth(List<Health> health);
|
||||
|
||||
/**
|
||||
* 修改保健
|
||||
|
@ -35,7 +35,7 @@ public interface ImmunityMapper
|
||||
* @param immunity 免疫
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertImmunity(Immunity immunity);
|
||||
public int insertImmunity(List<Immunity> immunity);
|
||||
|
||||
/**
|
||||
* 修改免疫
|
||||
|
@ -102,8 +102,7 @@ public class DewormServiceImpl implements IDewormService
|
||||
dew.setUsageId(usageId);
|
||||
deworms.add(dew);
|
||||
}
|
||||
// 药品使用记录
|
||||
medicineUsage.setSwMedicineUsageDetailsList(deworm.getUsageDetails());
|
||||
|
||||
|
||||
return dewormMapper.insertDeworm(deworms);
|
||||
}
|
||||
@ -115,6 +114,7 @@ public class DewormServiceImpl implements IDewormService
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
@Transactional
|
||||
public int updateDeworm(Deworm deworm)
|
||||
{
|
||||
|
||||
|
@ -1,7 +1,15 @@
|
||||
package com.zhyc.module.biosafety.service.impl;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
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.stereotype.Service;
|
||||
import com.zhyc.module.biosafety.mapper.HealthMapper;
|
||||
@ -20,6 +28,15 @@ public class HealthServiceImpl implements IHealthService
|
||||
@Autowired
|
||||
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
|
||||
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
|
||||
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());
|
||||
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
|
||||
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());
|
||||
return healthMapper.updateHealth(health);
|
||||
}
|
||||
|
@ -1,12 +1,21 @@
|
||||
package com.zhyc.module.biosafety.service.impl;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
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.stereotype.Service;
|
||||
import com.zhyc.module.biosafety.mapper.ImmunityMapper;
|
||||
import com.zhyc.module.biosafety.domain.Immunity;
|
||||
import com.zhyc.module.biosafety.service.IImmunityService;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
/**
|
||||
* 免疫Service业务层处理
|
||||
@ -20,6 +29,16 @@ public class ImmunityServiceImpl implements IImmunityService
|
||||
@Autowired
|
||||
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
|
||||
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
|
||||
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());
|
||||
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 结果
|
||||
*/
|
||||
@Override
|
||||
@Transactional
|
||||
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());
|
||||
return immunityMapper.updateImmunity(immunity);
|
||||
}
|
||||
|
@ -8,6 +8,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<result property="id" column="id" />
|
||||
<result property="datetime" column="datetime" />
|
||||
<result property="sheepId" column="sheep_id" />
|
||||
<result property="sheepNo" column="sheep_no"/>
|
||||
<result property="usageId" column="usage_id" />
|
||||
<result property="variety" column="variety" />
|
||||
<result property="sheepType" column="sheep_type" />
|
||||
@ -24,7 +25,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
</resultMap>
|
||||
|
||||
<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>
|
||||
|
||||
<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">
|
||||
<include refid="selectHealthVo"/>
|
||||
where id = #{id}
|
||||
where s.id = #{id}
|
||||
</select>
|
||||
|
||||
<insert id="insertHealth" parameterType="Health" useGeneratedKeys="true" keyProperty="id">
|
||||
insert into sw_health
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="datetime != null">datetime,</if>
|
||||
<if test="sheepId != null">sheep_id,</if>
|
||||
<if test="usageId != null">usage_id,</if>
|
||||
<if test="variety != null">variety,</if>
|
||||
<if test="sheepType != null">sheep_type,</if>
|
||||
<if test="gender != null">gender,</if>
|
||||
<if test="monthAge != null">month_age,</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">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>
|
||||
(sheep_id, usage_id, variety, sheep_type, gender, month_age,
|
||||
parity, breed,datetime, technical, comment,
|
||||
update_by, update_time, create_by, create_time)
|
||||
values
|
||||
<foreach collection="list" item="d" separator=",">
|
||||
(#{d.sheepId}, #{d.usageId}, #{d.variety}, #{d.sheepType},
|
||||
#{d.gender}, #{d.monthAge}, #{d.parity},#{d.breed}, #{d.datetime},
|
||||
#{d.technical}, #{d.comment},
|
||||
#{d.updateBy}, #{d.updateTime}, #{d.createBy}, #{d.createTime})
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
<update id="updateHealth" parameterType="Health">
|
||||
|
@ -7,24 +7,28 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<resultMap type="Immunity" id="ImmunityResult">
|
||||
<result property="id" column="id" />
|
||||
<result property="sheepId" column="sheep_id" />
|
||||
<result property="sheepNo" column="sheep_no"/>
|
||||
<result property="usageId" column="usage_id" />
|
||||
<result property="variety" column="variety" />
|
||||
<result property="sheepType" column="sheep_type" />
|
||||
<result property="gender" column="gender" />
|
||||
<result property="monthAge" column="month_age" />
|
||||
<result property="parity" column="parity" />
|
||||
<result property="breed" column="breed" />
|
||||
<result property="breed" column="breed"/>
|
||||
<result property="datetime" column="datetime" />
|
||||
<result property="technical" column="technical" />
|
||||
<result property="comment" column="comment" />
|
||||
<result property="updateBy" column="update_by" />
|
||||
<result property="updateTime" column="update_time" />
|
||||
<result property="createBy" column="create_by" />
|
||||
<result property="createTime" column="create_time" />
|
||||
</resultMap>
|
||||
|
||||
<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>
|
||||
|
||||
<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">
|
||||
<include refid="selectImmunityVo"/>
|
||||
where id = #{id}
|
||||
where s.id = #{id}
|
||||
</select>
|
||||
|
||||
<insert id="insertImmunity" parameterType="Immunity" useGeneratedKeys="true" keyProperty="id">
|
||||
insert into sw_immunity
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="sheepId != null">sheep_id,</if>
|
||||
<if test="usageId != null">usage_id,</if>
|
||||
<if test="variety != null">variety,</if>
|
||||
<if test="sheepType != null">sheep_type,</if>
|
||||
<if test="gender != null">gender,</if>
|
||||
<if test="monthAge != null">month_age,</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">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>
|
||||
(sheep_id, usage_id, variety, sheep_type, gender, month_age,
|
||||
parity, breed,datetime, technical, comment,
|
||||
update_by, update_time, create_by, create_time)
|
||||
values
|
||||
<foreach collection="list" item="d" separator=",">
|
||||
(#{d.sheepId}, #{d.usageId}, #{d.variety}, #{d.sheepType},
|
||||
#{d.gender}, #{d.monthAge}, #{d.parity},#{d.breed}, #{d.datetime},
|
||||
#{d.technical}, #{d.comment},
|
||||
#{d.updateBy}, #{d.updateTime}, #{d.createBy}, #{d.createTime})
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
<update id="updateImmunity" parameterType="Immunity">
|
||||
|
Loading…
x
Reference in New Issue
Block a user