Compare commits

..

2 Commits

Author SHA1 Message Date
80d5e7b248 Merge remote-tracking branch 'origin/main'
# Conflicts:
#	zhyc-module/src/main/java/com/zhyc/module/produce/breed/service/impl/ScSheepDeathServiceImpl.java
2025-08-24 18:25:59 +08:00
12da9cf3a0 修改2.0 2025-08-24 18:23:16 +08:00
11 changed files with 152 additions and 15 deletions

View File

@ -8,6 +8,7 @@ import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.time.temporal.ChronoUnit;
import java.util.Date;
import org.apache.commons.lang3.time.DateFormatUtils;

View File

@ -3,6 +3,7 @@ package com.zhyc.module.base.mapper;
import java.util.List;
import com.zhyc.module.base.domain.BasSheep;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
/**
@ -11,6 +12,7 @@ import org.apache.ibatis.annotations.Param;
* @author ruoyi
* @date 2025-07-15
*/
@Mapper
public interface BasSheepMapper
{
/**

View File

@ -88,7 +88,6 @@ public class DiagnosisController extends BaseController
@PostMapping("/adds")
public AjaxResult adds(@RequestBody Diagnosis diagnosis)
{
System.out.println(diagnosis);
return toAjax(diagnosisService.insertDiagnosisList(diagnosis));
}

View File

@ -1,11 +1,14 @@
package com.zhyc.module.biosafety.domain;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import com.zhyc.common.annotation.Excel;
import com.zhyc.common.core.domain.BaseEntity;
import java.util.Date;
/**
* 药品使用记录详情对象 sw_medicine_usage_details
*
@ -46,6 +49,11 @@ public class SwMedicineUsageDetails extends BaseEntity
@Excel(name = "使用方法")
private String usageId;
/** 使用时间 */
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@Excel(name = "使用时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
private Date usetime;
/** 生产厂家 */
@Excel(name = "生产厂家")
private String manufacturer;

View File

@ -89,6 +89,10 @@ public class Treatment extends BaseEntity
/** 兽医 */
@Excel(name = "兽医")
private String veterinary;
/** 治疗状态 */
@Excel(name = "治疗状态")
private String status;
/** 药品使用记录id */
@Excel(name = "药品使用记录id")

View File

@ -63,4 +63,7 @@ public interface TreatmentMapper
public int deleteTreatmentByIds(Long[] ids);
int insertTreatmentList(List<Treatment> treatments);
List<Treatment> selectTreatmentStatus(Long sheepId);
}

View File

@ -1,5 +1,6 @@
package com.zhyc.module.biosafety.service.impl;
import java.util.Date;
import java.util.List;
import java.util.Objects;
@ -9,13 +10,18 @@ import com.zhyc.module.base.domain.BasSheep;
import com.zhyc.module.base.domain.SheepFile;
import com.zhyc.module.base.mapper.BasSheepMapper;
import com.zhyc.module.base.mapper.SheepFileMapper;
import com.zhyc.module.biosafety.domain.Treatment;
import com.zhyc.module.biosafety.mapper.DiagnosisMapper;
import com.zhyc.module.biosafety.mapper.TreatmentMapper;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.zhyc.module.biosafety.domain.Diagnosis;
import com.zhyc.module.biosafety.service.IDiagnosisService;
import org.springframework.transaction.annotation.Transactional;
/**
* 诊疗结果Service业务层处理
*
@ -31,6 +37,8 @@ public class DiagnosisServiceImpl implements IDiagnosisService
private SheepFileMapper sheepFileMapper;
@Autowired
private BasSheepMapper sheepMapper;
@Autowired
private TreatmentMapper treatmentMapper;
/**
* 查询诊疗结果
@ -75,21 +83,85 @@ public class DiagnosisServiceImpl implements IDiagnosisService
String username = SecurityUtils.getLoginUser().getUser().getNickName();
diagnosis.setCreateBy(username);
diagnosis.setCreateTime(DateUtils.getNowDate());
if (!Objects.equals(sheepFile.getSheepfoldId(), diagnosis.getSheepfoldId())){
if (diagnosis.getSheepfoldId() != null)
if (!Objects.equals(sheepFile.getSheepfoldId(), diagnosis.getSheepfoldId())) {
BasSheep basSheep = new BasSheep();
basSheep.setId(diagnosis.getSheepId());
basSheep.setSheepfoldId(diagnosis.getSheepfoldId());
sheepMapper.updateBasSheep(basSheep);
}
// 更改治疗记录的状态
Treatment treatment = new Treatment();
treatment.setId(diagnosis.getTreatId());
if (diagnosis.getResult().equals("0")){
treatment.setStatus("-1");
treatmentMapper.updateTreatment(treatment);
}else if (diagnosis.getResult().equals("1")){
treatment.setStatus("2");
treatmentMapper.updateTreatment(treatment);
}
// 转入其他羊舍
return diagnosisMapper.insertDiagnosis(diagnosis);
}
@Override
@Transactional
public int insertDiagnosisList(Diagnosis diagnosis) {
if (diagnosis.getTreatIds() != null && diagnosis.getTreatIds().length > 0){
for (Integer treatId : diagnosis.getTreatIds()) {
System.out.println(treatId);
Treatment treatment = treatmentMapper.selectTreatmentById(Long.valueOf(treatId));
System.out.println(treatment);
// BasSheep basSheep = sheepMapper.selectBasSheepById(treatment.getSheepId());
return 0;
Diagnosis diag = new Diagnosis();
BeanUtils.copyProperties(treatment,diag);
diag.setResult(diagnosis.getResult());
diag.setParity(String.valueOf(treatment.getParity()));
// treatment diagnosis 是你的两个实体对象
Date start = treatment.getDatetime(); // 已经是 Date
Date end = diagnosis.getDatetime(); // 已经是 Date
diag.setBegindate(start);
diag.setEnddate(end);
long oneDayMillis = 24 * 60 * 60 * 1000L;
long days = (end.getTime() / oneDayMillis) - (start.getTime() / oneDayMillis);
if (days<0){
days=0;
}
diag.setTreatDay(days);
diag.setTreatId(treatment.getId());
String username = SecurityUtils.getLoginUser().getUser().getNickName();
diag.setCreateBy(username);
diag.setCreateTime(DateUtils.getNowDate());
diagnosisMapper.insertDiagnosis(diag);
treatment.setDiagId(diag.getId());
// 更改治疗记录的状态
if (diagnosis.getResult().equals("0")){
treatment.setStatus("-1");
treatmentMapper.updateTreatment(treatment);
}else if (diagnosis.getResult().equals("1")){
treatment.setStatus("2");
treatmentMapper.updateTreatment(treatment);
}
if (diagnosis.getSheepfoldId() != null){
BasSheep basSheep = new BasSheep();
basSheep.setId(diagnosis.getSheepId());
basSheep.setSheepfoldId(diagnosis.getSheepfoldId());
sheepMapper.updateBasSheep(basSheep);
}
}
}
return 1;
}
/**

View File

@ -7,8 +7,10 @@ import com.zhyc.common.utils.SecurityUtils;
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.Diagnosis;
import com.zhyc.module.biosafety.domain.SwMedicineUsage;
import com.zhyc.module.biosafety.domain.SwMedicineUsageDetails;
import com.zhyc.module.biosafety.mapper.DiagnosisMapper;
import com.zhyc.module.biosafety.mapper.SwMedicineUsageMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@ -34,6 +36,8 @@ public class TreatmentServiceImpl implements ITreatmentService
private SwMedicineUsageMapper medicineUsageMapper;
@Autowired
private SheepFileMapper sheepFileMapper;
@Autowired
private DiagnosisMapper diagnosisMapper;
/**
* 查询治疗记录
@ -47,7 +51,9 @@ public class TreatmentServiceImpl implements ITreatmentService
Treatment treatment = treatmentMapper.selectTreatmentById(id);
// 获取药品使用记录
SwMedicineUsage swMedicineUsage = medicineUsageService.selectSwMedicineUsageById(treatment.getUsageId());
if (swMedicineUsage!=null){
treatment.setUsageDetails(swMedicineUsage.getSwMedicineUsageDetailsList());
}
return treatment;
}
@ -176,4 +182,21 @@ public class TreatmentServiceImpl implements ITreatmentService
{
return treatmentMapper.deleteTreatmentById(id);
}
public void updateTreatmentStatus(Long sheepId) {
List<Treatment> treatments=treatmentMapper.selectTreatmentStatus(sheepId);
Diagnosis diagnosis = new Diagnosis();
for (Treatment treatment : treatments) {
if (treatment.getDiagId()!=null){
diagnosis.setId(treatment.getDiagId());
diagnosis.setResult("-1");
diagnosisMapper.updateDiagnosis(diagnosis);
if (treatment.getDiagId()!=null){
Treatment treat = new Treatment();
treat.setId(treatment.getId());
treatmentMapper.updateTreatment(treat);
}
}
}
}
}

View File

@ -3,11 +3,17 @@ package com.zhyc.module.produce.breed.service.impl;
import java.util.List;
import java.util.Map;
import com.zhyc.common.utils.DateUtils;
import com.zhyc.module.biosafety.domain.Diagnosis;
import com.zhyc.module.biosafety.domain.Treatment;
import com.zhyc.module.biosafety.mapper.DiagnosisMapper;
import com.zhyc.module.biosafety.mapper.TreatmentMapper;
import com.zhyc.module.biosafety.service.impl.TreatmentServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.zhyc.module.produce.breed.mapper.ScSheepDeathMapper;
import com.zhyc.module.produce.breed.domain.ScSheepDeath;
import com.zhyc.module.produce.breed.service.IScSheepDeathService;
import org.springframework.transaction.annotation.Transactional;
/**
* 羊只死淘记录Service业务层处理
@ -20,6 +26,13 @@ public class ScSheepDeathServiceImpl implements IScSheepDeathService
{
@Autowired
private ScSheepDeathMapper scSheepDeathMapper;
@Autowired
private DiagnosisMapper diagnosisMapper;
@Autowired
private TreatmentServiceImpl treatmentService;
/**
* 查询羊只死淘记录
@ -100,6 +113,7 @@ public class ScSheepDeathServiceImpl implements IScSheepDeathService
* @return 结果
*/
@Override
@Transactional
public int insertScSheepDeath(ScSheepDeath scSheepDeath)
{
// 设置事件类型默认为"死亡"
@ -121,7 +135,10 @@ public class ScSheepDeathServiceImpl implements IScSheepDeathService
}
}
treatmentService.updateTreatmentStatus(scSheepDeath.getSheepId());
scSheepDeath.setCreateTime(DateUtils.getNowDate());
return scSheepDeathMapper.insertScSheepDeath(scSheepDeath);
}
@ -147,7 +164,6 @@ public class ScSheepDeathServiceImpl implements IScSheepDeathService
}
}
}
scSheepDeath.setUpdateTime(DateUtils.getNowDate());
return scSheepDeathMapper.updateScSheepDeath(scSheepDeath);
}

View File

@ -31,6 +31,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="dosage" column="dosage" />
<result property="unit" column="unit" />
<result property="usageId" column="usageId" />
<result property="usetime" column="usetime" />
<result property="manufacturer" column="manufacturer" />
<result property="batchNumber" column="batch_number" />
</resultMap>
@ -63,7 +64,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</select>
<select id="selectSwMedicineUsageDetailsList" resultMap="SwMedicineUsageDetailsResult">
select smud.id, medi_usage, medi_id, dosage, unit, usageId, manufacturer, batch_number,
select smud.id, medi_usage, medi_id, dosage, unit, usageId,usetime, manufacturer, batch_number,
sm.name
from sw_medicine_usage_details smud
join sw_medicine sm on smud.medi_id = sm.id
@ -133,9 +134,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</delete>
<insert id="batchSwMedicineUsageDetails">
insert into sw_medicine_usage_details( id, medi_usage, medi_id, dosage, unit, usageId, manufacturer, batch_number) values
insert into sw_medicine_usage_details( id, medi_usage, medi_id, dosage, unit, usageId,usetime, manufacturer, batch_number) values
<foreach item="item" index="index" collection="list" separator=",">
( #{item.id}, #{item.mediUsage}, #{item.mediId}, #{item.dosage}, #{item.unit}, #{item.usageId}, #{item.manufacturer}, #{item.batchNumber})
( #{item.id}, #{item.mediUsage}, #{item.mediId}, #{item.dosage}, #{item.unit}, #{item.usageId}, #{item.usetime},#{item.manufacturer}, #{item.batchNumber})
</foreach>
</insert>
</mapper>

View File

@ -24,6 +24,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="diseasePName" column="disease_pname"/>
<result property="veterinary" column="veterinary" />
<result property="usageId" column="usage_id" />
<result property="status" column="status"/>
<result property="comment" column="comment" />
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" />
@ -32,7 +33,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</resultMap>
<sql id="selectTreatmentVo">
select t.id, diag_id, sheep_id, variety, sheep_type, month_age, t.gender, t.parity, breed, lact_day, gest_day, datetime, disease_id, disease_pid, veterinary, usage_id, t.comment, t.update_by, t.update_time, t.create_by, t.create_time,
select t.id, diag_id, sheep_id, variety, sheep_type, month_age, t.gender, t.parity, breed, lact_day, gest_day, datetime, disease_id, disease_pid, veterinary, usage_id,status, t.comment, t.update_by, t.update_time, t.create_by, t.create_time,
bs.manage_tags,
sd.name disease_name,
sd2.name disease_pname
@ -48,6 +49,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="sheepId != null "> and sheep_id = #{sheepId}</if>
<if test="params.beginDatetime != null and params.beginDatetime != '' and params.endDatetime != null and params.endDatetime != ''"> and datetime between #{params.beginDatetime} and #{params.endDatetime}</if>
<if test="diseaseId != null "> and disease_id = #{diseaseId}</if>
<if test="status != null and status !=''"> and status = #{status}</if>
<if test="veterinary != null and veterinary != ''"> and veterinary = #{veterinary}</if>
</where>
ORDER BY datetime DESC
@ -57,6 +59,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<include refid="selectTreatmentVo"/>
where t.id = #{id}
</select>
<select id="selectTreatmentStatus" resultMap="TreatmentResult">
select * from sw_treatment where sheep_id = #{sheepId} and status in (0, 1)
</select>
<insert id="insertTreatment" parameterType="Treatment" useGeneratedKeys="true" keyProperty="id">
insert into sw_treatment
@ -76,6 +81,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="diseasePid != null">disease_pid,</if>
<if test="veterinary != null">veterinary,</if>
<if test="usageId != null">usage_id,</if>
<if test="status != null">status,</if>
<if test="comment != null">comment,</if>
<if test="updateBy != null">update_by,</if>
<if test="updateTime != null">update_time,</if>
@ -98,6 +104,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="diseasePid != null">#{diseasePid},</if>
<if test="veterinary != null">#{veterinary},</if>
<if test="usageId != null">#{usageId},</if>
<if test="status != null">#{status},</if>
<if test="comment != null">#{comment},</if>
<if test="updateBy != null">#{updateBy},</if>
<if test="updateTime != null">#{updateTime},</if>
@ -110,14 +117,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
insert into sw_treatment
(diag_id, sheep_id, variety, sheep_type, month_age, gender,
parity, breed, lact_day, gest_day, datetime,
disease_id, disease_pid, veterinary, usage_id,
disease_id, disease_pid, veterinary, usage_id,status ,
comment, update_by, update_time, create_by, create_time)
values
<foreach collection="list" item="t" separator=",">
(#{t.diagId}, #{t.sheepId}, #{t.variety}, #{t.sheepType},
#{t.monthAge}, #{t.gender}, #{t.parity}, #{t.breed},
#{t.lactDay}, #{t.gestDay}, #{t.datetime}, #{t.diseaseId},
#{t.diseasePid}, #{t.veterinary},#{t.usageId}, #{t.comment},
#{t.diseasePid}, #{t.veterinary},#{t.usageId}, #{t.status}, #{t.comment},
#{t.updateBy}, #{t.updateTime},#{t.createBy}, #{t.createTime})
</foreach>
</insert>
@ -140,6 +147,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="diseasePid != null">disease_pid = #{diseasePid},</if>
<if test="veterinary != null">veterinary = #{veterinary},</if>
<if test="usageId != null">usage_id = #{usageId},</if>
<if test="status != null">status = #{status},</if>
<if test="comment != null">comment = #{comment},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>