消毒
This commit is contained in:
parent
af811ad8b5
commit
cf11d9f711
@ -1,6 +1,8 @@
|
||||
package com.zhyc.module.biosafety.domain;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
@ -27,8 +29,12 @@ public class Disinfect extends BaseEntity
|
||||
private Long id;
|
||||
|
||||
/** 羊舍id */
|
||||
@Excel(name = "羊舍id")
|
||||
private Long sheepfoldId;
|
||||
@Excel(name = "羊舍")
|
||||
private String sheepfoldName;
|
||||
|
||||
private Integer sheepfoldId;
|
||||
|
||||
private Integer[] sheepfoldIds;
|
||||
|
||||
/** 消毒日期 */
|
||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||
@ -45,7 +51,7 @@ public class Disinfect extends BaseEntity
|
||||
|
||||
/** 药品使用记录id */
|
||||
@Excel(name = "药品使用记录id")
|
||||
private Long usageId;
|
||||
private Integer usageId;
|
||||
|
||||
/** 比例 */
|
||||
@Excel(name = "比例")
|
||||
@ -55,4 +61,7 @@ public class Disinfect extends BaseEntity
|
||||
@Excel(name = "备注")
|
||||
private String comment;
|
||||
|
||||
// 药品使用
|
||||
private List<SwMedicineUsageDetails> usageDetails;
|
||||
|
||||
}
|
||||
|
@ -35,7 +35,7 @@ public interface DisinfectMapper
|
||||
* @param disinfect 消毒记录
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertDisinfect(Disinfect disinfect);
|
||||
public int insertDisinfect(List<Disinfect> disinfect);
|
||||
|
||||
/**
|
||||
* 修改消毒记录
|
||||
|
@ -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.DisinfectMapper;
|
||||
import com.zhyc.module.biosafety.domain.Disinfect;
|
||||
import com.zhyc.module.biosafety.service.IDisinfectService;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
/**
|
||||
* 消毒记录Service业务层处理
|
||||
@ -20,6 +29,15 @@ public class DisinfectServiceImpl implements IDisinfectService
|
||||
@Autowired
|
||||
private DisinfectMapper disinfectMapper;
|
||||
|
||||
@Autowired
|
||||
private SwMedicineUsageServiceImpl medicineUsageService;
|
||||
|
||||
@Autowired
|
||||
private SwMedicineUsageMapper medicineUsageMapper;
|
||||
|
||||
@Autowired
|
||||
private SheepFileMapper sheepFileMapper;
|
||||
|
||||
/**
|
||||
* 查询消毒记录
|
||||
*
|
||||
@ -29,7 +47,10 @@ public class DisinfectServiceImpl implements IDisinfectService
|
||||
@Override
|
||||
public Disinfect selectDisinfectById(Long id)
|
||||
{
|
||||
return disinfectMapper.selectDisinfectById(id);
|
||||
Disinfect disinfect = disinfectMapper.selectDisinfectById(id);
|
||||
SwMedicineUsage swMedicineUsage = medicineUsageService.selectSwMedicineUsageById(disinfect.getUsageId());
|
||||
disinfect.setUsageDetails(swMedicineUsage.getSwMedicineUsageDetailsList());
|
||||
return disinfect;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -53,8 +74,26 @@ public class DisinfectServiceImpl implements IDisinfectService
|
||||
@Override
|
||||
public int insertDisinfect(Disinfect disinfect)
|
||||
{
|
||||
// 使用记录的文件
|
||||
SwMedicineUsage medicineUsage = new SwMedicineUsage();
|
||||
medicineUsage.setSwMedicineUsageDetailsList(disinfect.getUsageDetails());
|
||||
medicineUsage.setName("羊舍消毒");
|
||||
medicineUsage.setUseType("3");
|
||||
|
||||
|
||||
List<Disinfect> disinfects = new ArrayList<>();
|
||||
disinfect.setCreateTime(DateUtils.getNowDate());
|
||||
return disinfectMapper.insertDisinfect(disinfect);
|
||||
for (Integer sheepfold : disinfect.getSheepfoldIds()) {
|
||||
Disinfect dis = new Disinfect();
|
||||
BeanUtils.copyProperties(disinfect,dis);
|
||||
dis.setSheepfoldId(sheepfold);
|
||||
// 获取药品使用记录的id
|
||||
Integer usageId = medicineUsageService.insertSwMedicineUsage(medicineUsage);
|
||||
dis.setUsageId(usageId);
|
||||
disinfects.add(dis);
|
||||
}
|
||||
|
||||
return disinfectMapper.insertDisinfect(disinfects);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -64,8 +103,14 @@ public class DisinfectServiceImpl implements IDisinfectService
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
@Transactional
|
||||
public int updateDisinfect(Disinfect disinfect)
|
||||
{
|
||||
for (SwMedicineUsageDetails usageDetail : disinfect.getUsageDetails()) {
|
||||
usageDetail.setMediUsage(disinfect.getUsageId());
|
||||
}
|
||||
medicineUsageMapper.deleteSwMedicineUsageDetailsByMediUsage(disinfect.getUsageId());
|
||||
medicineUsageMapper.batchSwMedicineUsageDetails(disinfect.getUsageDetails());
|
||||
disinfect.setUpdateTime(DateUtils.getNowDate());
|
||||
return disinfectMapper.updateDisinfect(disinfect);
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<resultMap type="Disinfect" id="DisinfectResult">
|
||||
<result property="id" column="id" />
|
||||
<result property="sheepfoldId" column="sheepfold_id" />
|
||||
<result property="sheepfoldName" column="sheepfold_name"/>
|
||||
<result property="datetime" column="datetime" />
|
||||
<result property="technician" column="technician" />
|
||||
<result property="way" column="way" />
|
||||
@ -20,7 +21,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectDisinfectVo">
|
||||
select id, sheepfold_id, datetime, technician, way, usage_id, ratio, comment, update_by, update_time, create_by, create_time from sw_disinfect
|
||||
select sd.id, sheepfold_id, datetime, technician, way, usage_id, ratio, sd.comment, update_by, update_time, create_by, create_time,
|
||||
ds.sheepfold_name
|
||||
from sw_disinfect sd
|
||||
left join da_sheepfold ds on sd.sheepfold_id = ds.id
|
||||
</sql>
|
||||
|
||||
<select id="selectDisinfectList" parameterType="Disinfect" resultMap="DisinfectResult">
|
||||
@ -38,37 +42,18 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
|
||||
<select id="selectDisinfectById" parameterType="Long" resultMap="DisinfectResult">
|
||||
<include refid="selectDisinfectVo"/>
|
||||
where id = #{id}
|
||||
where sd.id = #{id}
|
||||
</select>
|
||||
|
||||
<insert id="insertDisinfect" parameterType="Disinfect" useGeneratedKeys="true" keyProperty="id">
|
||||
insert into sw_disinfect
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="sheepfoldId != null">sheepfold_id,</if>
|
||||
<if test="datetime != null">datetime,</if>
|
||||
<if test="technician != null">technician,</if>
|
||||
<if test="way != null">way,</if>
|
||||
<if test="usageId != null">usage_id,</if>
|
||||
<if test="ratio != null">ratio,</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="sheepfoldId != null">#{sheepfoldId},</if>
|
||||
<if test="datetime != null">#{datetime},</if>
|
||||
<if test="technician != null">#{technician},</if>
|
||||
<if test="way != null">#{way},</if>
|
||||
<if test="usageId != null">#{usageId},</if>
|
||||
<if test="ratio != null">#{ratio},</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>
|
||||
(sheepfold_id, datetime, technician, way, usage_id, ratio, comment, update_by, update_time, create_by, create_time)
|
||||
values
|
||||
<foreach collection="list" item="d" separator=",">
|
||||
(#{d.sheepfoldId}, #{d.datetime}, #{d.technician}, #{d.way},
|
||||
#{d.usageId}, #{d.ratio}, #{d.comment},
|
||||
#{d.updateBy}, #{d.updateTime}, #{d.createBy}, #{d.createTime})
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
<update id="updateDisinfect" parameterType="Disinfect">
|
||||
@ -86,7 +71,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="createBy != null">create_by = #{createBy},</if>
|
||||
<if test="createTime != null">create_time = #{createTime},</if>
|
||||
</trim>
|
||||
where id = #{id}
|
||||
where sd.id = #{id}
|
||||
</update>
|
||||
|
||||
<delete id="deleteDisinfectById" parameterType="Long">
|
||||
|
Loading…
x
Reference in New Issue
Block a user