|
@@ -3,10 +3,15 @@ package org.jeecg.modules.itdmgongdanshuju.service.impl;
|
|
|
import cn.hutool.core.date.DateUnit;
|
|
|
import cn.hutool.core.date.DateUtil;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import org.apache.commons.collections4.BagUtils;
|
|
|
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.jeecg.modules.itdmDataHistory.entity.ItdmWenxiang;
|
|
|
+import org.jeecg.modules.itdmDataHistory.mapper.ItdmWenxiangMapper;
|
|
|
import org.jeecg.modules.itdmgongdanshuju.dto.ItdmGongdanDto;
|
|
|
+import org.jeecg.modules.itdmgongdanshuju.dto.ItdmGongdanUploadDto;
|
|
|
import org.jeecg.modules.itdmgongdanshuju.entity.ItdmGongdanDetail;
|
|
|
import org.jeecg.modules.itdmgongdanshuju.entity.ItdmGongdanShuju;
|
|
|
import org.jeecg.modules.itdmgongdanshuju.mapper.ItdmGongdanDetail1Mapper;
|
|
@@ -18,8 +23,11 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
+import java.util.Arrays;
|
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* @Description: 委托信息
|
|
@@ -35,6 +43,9 @@ public class ItdmGongdanShujuServiceImpl extends ServiceImpl<ItdmGongdanShujuMap
|
|
|
@Autowired
|
|
|
ItdmGongdanShujuMapper itdmGongdanShujuMapper;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ ItdmWenxiangMapper itdmWenxiangMapper;
|
|
|
+
|
|
|
@Override
|
|
|
@Transactional
|
|
|
public Boolean generate(ItdmGongdanDto itdmGongdanDto) {
|
|
@@ -43,6 +54,16 @@ public class ItdmGongdanShujuServiceImpl extends ServiceImpl<ItdmGongdanShujuMap
|
|
|
ItdmGongdanDetail itdmGongdanDetail = itdmGongdanDetailList.get(0);
|
|
|
String startTime = itdmGongdanDto.getShiyanKaishitime();
|
|
|
String endTime = itdmGongdanDto.getShiyanJieshutime();
|
|
|
+ String shijiShebeiId = itdmGongdanDetail.getShijiShebeiId();
|
|
|
+ String ShijiWorkDate = new SimpleDateFormat("yyyy-MM-dd").format(itdmGongdanDetail.getShijiWorkDate());
|
|
|
+
|
|
|
+ String startDateTime = ShijiWorkDate + " " + startTime + ":00";
|
|
|
+ String endDateTime = ShijiWorkDate + " " + startTime + ":00";
|
|
|
+
|
|
|
+ boolean b = itdmWenxiangMapper.exists(Wrappers.lambdaQuery(ItdmWenxiang.class).eq(ItdmWenxiang::getDeviceId, shijiShebeiId)
|
|
|
+ .between(ItdmWenxiang::getCreateTime, startDateTime, endDateTime));
|
|
|
+
|
|
|
+
|
|
|
Date date1 = DateUtil.parse(startTime);
|
|
|
Date date2 = DateUtil.parse(endTime);
|
|
|
long betweenMinute = DateUtil.between(date1, date2, DateUnit.MINUTE);
|
|
@@ -52,20 +73,50 @@ public class ItdmGongdanShujuServiceImpl extends ServiceImpl<ItdmGongdanShujuMap
|
|
|
ItdmGongdanShuju itdmGongdanShuju = new ItdmGongdanShuju();
|
|
|
itdmGongdanShuju.setShiyanType(itdmGongdanDto.getShiyanType());
|
|
|
itdmGongdanShuju.setPinci(itdmGongdanDto.getPinci());
|
|
|
+
|
|
|
itdmGongdanDetail.setId(null);
|
|
|
BeanUtils.copyProperties(itdmGongdanDetail, itdmGongdanShuju);
|
|
|
- itdmGongdanShuju.setShiyanTime(DateUtil.offsetMinute(date1, i * Integer.parseInt(itdmGongdanDto.getPinci())).toString().split(" ")[1]);
|
|
|
+ itdmGongdanShuju.setShiyanTime(DateUtil.offsetMinute(date1, i * Integer.parseInt(itdmGongdanDto.getPinci())).toString().split(" ")[1]);
|
|
|
+
|
|
|
+ if (b) {
|
|
|
+ String[] endt = itdmGongdanShuju.getShiyanTime().split(",");
|
|
|
+ endt[1] = "10";
|
|
|
+ String nextDateTIme = String.join(":", endt);
|
|
|
+ ItdmWenxiang itdmWenxiang = itdmWenxiangMapper.selectOne(Wrappers.lambdaQuery(ItdmWenxiang.class).eq(ItdmWenxiang::getDeviceId, shijiShebeiId)
|
|
|
+ .between(ItdmWenxiang::getCreateTime, ShijiWorkDate + " " + itdmGongdanShuju.getShiyanTime(), ShijiWorkDate + " " + nextDateTIme)
|
|
|
+ .apply("limit 1"));
|
|
|
+ if (itdmWenxiang != null) {
|
|
|
+ itdmGongdanShuju.setShiyanWendu(itdmWenxiang.getTemperature().toEngineeringString());
|
|
|
+ if (StringUtils.isNotBlank(itdmGongdanDto.getShiyanType()) && itdmGongdanDto.getShiyanType().contains("2")) {
|
|
|
+ itdmGongdanShuju.setShiyanShidu(itdmWenxiang.getHumidity().toEngineeringString());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
boolean save = this.save(itdmGongdanShuju);
|
|
|
- if (!save){
|
|
|
+ if (!save) {
|
|
|
throw new IllegalArgumentException();
|
|
|
}
|
|
|
}
|
|
|
- }catch (Exception e){
|
|
|
+ } catch (Exception e) {
|
|
|
return false;
|
|
|
}
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
|
|
|
+ @Override
|
|
|
+ public void upload(ItdmGongdanUploadDto upload) {
|
|
|
+ ItdmGongdanShuju itdmGongdanShuju = itdmGongdanShujuMapper.selectOne(Wrappers.lambdaQuery(ItdmGongdanShuju.class)
|
|
|
+ .eq(ItdmGongdanShuju::getWoId, upload.getWoId()).orderByAsc(ItdmGongdanShuju::getId)
|
|
|
+ .apply("limit 1"));
|
|
|
+ itdmGongdanShuju.setExtraPic(upload.getImages());
|
|
|
+
|
|
|
|
|
|
+ itdmGongdanShujuMapper.updateById(itdmGongdanShuju);
|
|
|
+
|
|
|
+ }
|
|
|
}
|