|
@@ -6,7 +6,6 @@ import com.ruoyi.business.req.DeviceReq;
|
|
|
import com.ruoyi.business.res.DeviceRes;
|
|
|
import com.ruoyi.business.res.HomeCountsRes;
|
|
|
import com.ruoyi.business.service.IBusinessService;
|
|
|
-import com.ruoyi.common.enums.DataSourceType;
|
|
|
import com.ruoyi.common.utils.DateUtils;
|
|
|
import com.ruoyi.common.utils.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -60,22 +59,29 @@ public class BusinessServiceImpl implements IBusinessService {
|
|
|
List<ZAssayResult> zAssayResults = this.zAssayResultMapper.selectZAssayResultList(ZAssayResult.builder().resultDate("2024-08-13").assayType("3").build());
|
|
|
if(!CollectionUtils.isEmpty(zAssayResults)){
|
|
|
int checkTotals = zAssayResults.size();
|
|
|
- build.setCheckTotals(checkTotals);
|
|
|
+ build.setAssayTotals(checkTotals);
|
|
|
int passCheckTotals = this.getPassedCounts(zAssayResults);
|
|
|
- build.setPassCheckTotals(passCheckTotals);
|
|
|
- build.setPassCheckRates((double)passCheckTotals / (double)checkTotals);//整数除以整数还是整数,所以这里要强转成小数
|
|
|
+ build.setPassAssayTotals(passCheckTotals);
|
|
|
+ build.setPassAssayRates((double)passCheckTotals / (double)checkTotals);//整数除以整数还是整数,所以这里要强转成小数
|
|
|
}
|
|
|
return build;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public List<DeviceRes> devicePageList(DeviceReq deviceReq) {
|
|
|
+ //处理一下化验日期,如果没有,默认是今天
|
|
|
+ String assayDate = deviceReq.getAssayDate();
|
|
|
+ if(StringUtils.isBlank(assayDate)){
|
|
|
+ //todo 日期临时写死,因为数据不会同步,都是历史数据 正式以后,需要改成真实日期
|
|
|
+// assayTime = DateUtils.getDate();
|
|
|
+ assayDate = "2024-08-13";
|
|
|
+ }
|
|
|
//先获取设备列表 直接写SQL了,不使用copy
|
|
|
List<DeviceRes> list =this.bizDeviceMapper.devicePageList(deviceReq);
|
|
|
//额外处理其他数据
|
|
|
if(!CollectionUtils.isEmpty(list)){
|
|
|
for (DeviceRes deviceRes : list) {
|
|
|
- this.addExtra(deviceRes);
|
|
|
+ this.addExtra(deviceRes, assayDate, deviceRes.getDeviceNo());
|
|
|
}
|
|
|
}
|
|
|
return list;
|
|
@@ -83,11 +89,45 @@ public class BusinessServiceImpl implements IBusinessService {
|
|
|
|
|
|
/**
|
|
|
* 额外处理其他的字段 聚合,查询其他表,计算等
|
|
|
+ *
|
|
|
* @param deviceRes
|
|
|
+ * @param assayDate
|
|
|
+ * @param deviceNo
|
|
|
*/
|
|
|
- private void addExtra(DeviceRes deviceRes) {
|
|
|
- //查询最近的一条化验记录明细
|
|
|
-
|
|
|
+ private void addExtra(DeviceRes deviceRes, String assayDate, String deviceNo) {
|
|
|
+ //查询最近的一条化验记录明细 及 化验统计(结果)
|
|
|
+ List<ZAssayResult> zAssayResults = this.zAssayResultMapper.selectZAssayResultList(ZAssayResult.builder().resultDate(assayDate).assayType("3").deviceNo(deviceNo).build());
|
|
|
+ if(!CollectionUtils.isEmpty(zAssayResults)){
|
|
|
+ int checkTotals = zAssayResults.size();
|
|
|
+ int passCheckTotals = this.getPassedCounts(zAssayResults);
|
|
|
+ deviceRes.setAssayTotals(passCheckTotals);
|
|
|
+ deviceRes.setPassAssayRates((double)passCheckTotals / (double)checkTotals);//整数除以整数还是整数,所以这里要强转成小数
|
|
|
+
|
|
|
+ //获取最新的一条化验明细数据
|
|
|
+ ZAssayResult zAssayResult = zAssayResults.get(0);
|
|
|
+ deviceRes.setLastAssayTime(zAssayResult.getUpdateTime());
|
|
|
+ deviceRes.setBeginAssayTime(zAssayResult.getCreateTime());
|
|
|
+ deviceRes.setCurrentTemperature(zAssayResult.getResultWendu());
|
|
|
+ deviceRes.setCurrentHumidity(zAssayResult.getResultShidu());
|
|
|
+
|
|
|
+ //获取最新的一条化验记录 处理化验进度的展示: 因为历史数据有总步进为0的,这种的默认进度就是0处理 只有化验中的才显示进度
|
|
|
+ String assayNo = zAssayResult.getAssayNo();
|
|
|
+ if("2".equals(deviceRes.getAssayStatus()) && StringUtils.isNotBlank(assayNo)){
|
|
|
+ ZAssay zAssay = this.zAssayMapper.selectUniqueRecordByAssayNo(assayNo);
|
|
|
+ if(!Objects.isNull(zAssay)){
|
|
|
+ String stepNow = zAssay.getStepNow();
|
|
|
+ String stepTotal = zAssay.getStepTotal();
|
|
|
+ if(StringUtils.isBlank(stepNow) || StringUtils.isBlank(stepTotal) || "0".equals(stepNow) || "0".equals(stepTotal)){
|
|
|
+ deviceRes.setAssayProgress(0);
|
|
|
+ }else{
|
|
|
+ deviceRes.setAssayProgress(Double.parseDouble(stepNow)/Double.parseDouble(stepTotal));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //todo 废液量暂时无法计算
|
|
|
+ }
|
|
|
+ //因为有重复数据,需要去重
|
|
|
+ deviceRes.setAssayCounts(this.zAssayMapper.getDistinctCountsByDeviceNoAndDate(assayDate, deviceNo));
|
|
|
}
|
|
|
|
|
|
//判断每个质控样的数是否各个,然后获取汇总的数量
|