|
@@ -1,11 +1,31 @@
|
|
|
package com.usky.fire.service.impl;
|
|
|
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
+import com.usky.common.core.util.HttpUtils;
|
|
|
+import com.usky.common.core.util.StringUtils;
|
|
|
import com.usky.common.mybatis.core.AbstractCrudService;
|
|
|
+import com.usky.fire.domain.MhPostInspect;
|
|
|
import com.usky.fire.domain.PostInspect;
|
|
|
import com.usky.fire.mapper.PostInspectMapper;
|
|
|
+import com.usky.fire.service.BaseUserCompanyService;
|
|
|
+import com.usky.fire.service.MhPostInspectService;
|
|
|
import com.usky.fire.service.PostInspectService;
|
|
|
+import com.usky.fire.service.util.OnlineMethod;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
+import java.io.IOException;
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
+import java.time.LocalDateTime;
|
|
|
+import java.time.ZoneOffset;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.Date;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
/**
|
|
|
* <p>
|
|
|
* 查岗信息 服务实现类
|
|
@@ -17,9 +37,83 @@ import org.springframework.stereotype.Service;
|
|
|
@Service
|
|
|
public class PostInspectServiceImpl extends AbstractCrudService<PostInspectMapper, PostInspect> implements PostInspectService {
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private BaseUserCompanyService baseUserCompanyService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private MhPostInspectService mhPostInspectService;
|
|
|
+
|
|
|
@Override
|
|
|
public void postInspectRecept(PostInspect postInspect) {
|
|
|
this.save(postInspect);
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public List<PostInspect> postInspectPlatform() {
|
|
|
+ List<PostInspect> list = new ArrayList<>();
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
+ List<String> companyIdList = baseUserCompanyService.companyIdList();
|
|
|
+ if (CollectionUtils.isNotEmpty(companyIdList)) {
|
|
|
+ Date date = new Date();
|
|
|
+ String startTime = OnlineMethod.minuteDateTime(new Date(), -10);
|
|
|
+ String endTime = sdf.format(date);
|
|
|
+ LambdaQueryWrapper<PostInspect> queryWrapper = Wrappers.lambdaQuery();
|
|
|
+ queryWrapper.in(PostInspect::getCompanyId, companyIdList)
|
|
|
+ .between(PostInspect::getInspectTime, startTime, endTime)
|
|
|
+ .eq(PostInspect::getInspectStatus, 0);
|
|
|
+ list = this.list(queryWrapper);
|
|
|
+ for (int i = 0; i < list.size(); i++) {
|
|
|
+ long data1 = LocalDateTime.now().toEpochSecond(ZoneOffset.of("+8"));
|
|
|
+ long data2 = list.get(i).getInspectTime().toEpochSecond(ZoneOffset.of("+8"));
|
|
|
+ long time = data1 - data2;
|
|
|
+ list.get(i).setCountdown(600 - time);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return list;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<PostInspect> postInspectAnswerRecept() {
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
+ Date date = new Date();
|
|
|
+ String startTime = OnlineMethod.minuteDateTime(new Date(), -5);
|
|
|
+ String endTime = sdf.format(date);
|
|
|
+ LambdaQueryWrapper<PostInspect> queryWrapper = Wrappers.lambdaQuery();
|
|
|
+ queryWrapper.between(PostInspect::getInspectTime, startTime, endTime);
|
|
|
+ List<PostInspect> list = this.list(queryWrapper);
|
|
|
+ for (int i = 0; i < list.size(); i++) {
|
|
|
+ long data1 = LocalDateTime.now().toEpochSecond(ZoneOffset.of("+8"));
|
|
|
+ long data2 = list.get(i).getInspectTime().toEpochSecond(ZoneOffset.of("+8"));
|
|
|
+ long time = data1 - data2;
|
|
|
+ if (list.get(i).getInspectStatus() == 0) {
|
|
|
+ if (time < 600) {
|
|
|
+ list.get(i).setCountdown(600 - time);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return list;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void postInspectAnswerRequest() {
|
|
|
+ String url = "http://172.16.120.165:13200/prod-api/service-fire/postInspect/postInspectAnswerRecept";
|
|
|
+ String res = null;
|
|
|
+ try {
|
|
|
+ res = HttpUtils.get(url, null);
|
|
|
+ } catch (IOException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotBlank(res)) {
|
|
|
+ JSONObject jsonObj = JSONObject.parseObject(res);
|
|
|
+ String userStr = jsonObj.getString("data");
|
|
|
+ if(StringUtils.isNotBlank(userStr)&&!userStr.equals("[]")){
|
|
|
+ List<MhPostInspect> mhPostInspectList = JSON.parseArray(userStr, MhPostInspect.class);
|
|
|
+ for (int i = 0; i < mhPostInspectList.size(); i++) {
|
|
|
+// mhPostInspectService.updateById(mhPostInspectList.get(i));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
}
|