155 lines
5.8 KiB
Plaintext
155 lines
5.8 KiB
Plaintext
package com.sercurityControl.proteam.dutyTask.service;
|
|
|
|
import com.securityControl.common.core.utils.aes.DateTimeHelper;
|
|
import com.securityControl.common.core.utils.aes.ListHelper;
|
|
import com.securityControl.common.core.utils.aes.StringHelper;
|
|
|
|
import com.sercurityControl.proteam.domain.TClassMettingWarnVo;
|
|
import com.sercurityControl.proteam.domain.vo.ImageVo;
|
|
import com.sercurityControl.proteam.dutyTask.domain.ClassMettingWarnVo;
|
|
import com.sercurityControl.proteam.dutyTask.mapper.TaskDao;
|
|
import com.sercurityControl.proteam.service.DeviceService;
|
|
import com.sercurityControl.proteam.util.ClassMettingImageUtil;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.LoggerFactory;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
import javax.annotation.Resource;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
|
|
/**
|
|
* 任务调度中心
|
|
*/
|
|
@Service
|
|
public class TaskServiceImpl implements TaskService {
|
|
|
|
private static final Logger log = LoggerFactory.getLogger(TaskServiceImpl.class);
|
|
|
|
@Resource
|
|
private TaskDao mapper;
|
|
|
|
@Override
|
|
public void getAllClassMettingWarn() {
|
|
try{
|
|
|
|
// 高风险 +重点关注班组+工序变化+作业类型变化+新增班组+低星评价班组+
|
|
List<ClassMettingWarnVo> cList=mapper.getAllClassMetting(DateTimeHelper.getNowDay());
|
|
for (ClassMettingWarnVo vo:cList) {
|
|
Integer num=0;
|
|
StringBuffer stringBuffer = new StringBuffer();
|
|
if ("3".equals(vo.getRiskLevel()) || "2".equals(vo.getRiskLevel()) || "二级风险".equals(vo.getRiskLevel()) || "三级风险".equals(vo.getRiskLevel()) || "3级".equals(vo.getRiskLevel()) || "2级".equals(vo.getRiskLevel())) {
|
|
stringBuffer.append("高风险,");
|
|
num++;
|
|
}
|
|
if ("1".equals(vo.getImportTeam())) {
|
|
stringBuffer.append("重点关注班组,");
|
|
num++;
|
|
}
|
|
if(StringHelper.isNotEmpty(vo.getQjxh())){
|
|
Integer qjxh=Integer.parseInt(vo.getQjxh());
|
|
if(qjxh<40){
|
|
stringBuffer.append("球机信号弱,");
|
|
num++;
|
|
}
|
|
}
|
|
String tgx="";
|
|
String ygx="";
|
|
String tzylx="";
|
|
String yzylx="";
|
|
ClassMettingWarnVo cmVo=mapper.getYesGxLxData(vo);
|
|
if(cmVo!=null){
|
|
//工序变化
|
|
if (StringHelper.isNotEmpty(vo.getWorkGx()) && StringHelper.isNotEmpty(cmVo.getYesWorkGx())) {
|
|
if (!vo.getWorkGx().equals(cmVo.getYesWorkGx()) ) {
|
|
stringBuffer.append("工序变化,");
|
|
tgx=vo.getWorkGx();
|
|
ygx=cmVo.getYesWorkGx();
|
|
num++;
|
|
}
|
|
}
|
|
//类型变化
|
|
if (StringHelper.isNotEmpty(vo.getWorkType()) && StringHelper.isNotEmpty(cmVo.getYesWorkType())) {
|
|
if (!vo.getWorkType().equals(cmVo.getYesWorkType())) {
|
|
stringBuffer.append("作业类型变化,");
|
|
tzylx=vo.getWorkType();
|
|
yzylx=cmVo.getYesWorkType();
|
|
num++;
|
|
}
|
|
}
|
|
}
|
|
try{
|
|
Integer newTeam= mapper.getNewTeamNums(vo);
|
|
if (newTeam>0) {
|
|
stringBuffer.append("新进班组,");
|
|
num++;
|
|
}
|
|
}catch (Exception e){
|
|
log.error(e.toString(),e);
|
|
}
|
|
if (vo.getZhpj() != new Double(0) && vo.getZhpj() < new Double(6)) {
|
|
stringBuffer.append("低星班组,");
|
|
num++;
|
|
}
|
|
|
|
//较昨日比较人数变化大
|
|
if(StringHelper.isNotEmpty(vo.getWorkNum())){
|
|
//查询昨日施工数量
|
|
Integer nums = mapper.getWorkTeamNum(vo);
|
|
if(nums!=null){
|
|
int workNum=Integer.parseInt(vo.getWorkNum());
|
|
if (Math.abs(nums - workNum) >=5) {
|
|
stringBuffer.append("作业人数变化大,");
|
|
num++;
|
|
}
|
|
}
|
|
}
|
|
TClassMettingWarnVo entity=new TClassMettingWarnVo();
|
|
entity.setClassId(vo.getClassId());
|
|
entity.setNum(num);
|
|
entity.setStatus(0);
|
|
entity.setTimes(DateTimeHelper.getNowTime());
|
|
entity.setWarnType(stringBuffer.toString());
|
|
entity.setYgx(ygx);
|
|
entity.setTgx(tgx);
|
|
entity.setYzylx(yzylx);
|
|
entity.setTzylx(tzylx);
|
|
// mapper.replaceWarn(entity);
|
|
Integer count=mapper.getWarnStatus(entity);
|
|
if(count<1){
|
|
mapper.replaceWarn(entity);
|
|
}
|
|
}
|
|
}catch (Exception e){
|
|
log.error(e.toString(),e);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 更新任务执行状态及时间
|
|
* @param code
|
|
* @param state
|
|
* @param nowTime
|
|
*/
|
|
@Override
|
|
public void updateTask(String code, String state, String nowTime) {
|
|
mapper.updateTask(code,state,nowTime);
|
|
}
|
|
|
|
|
|
@Autowired
|
|
private DeviceService service;
|
|
|
|
@Override
|
|
public void updateAllState() {
|
|
try{
|
|
service.refresh();
|
|
}catch (Exception e){
|
|
log.error(e.toString(),e);
|
|
}
|
|
}
|
|
|
|
|
|
}
|