11 changed files with 206 additions and 7 deletions
@ -0,0 +1,90 @@ |
|||||
|
package com.zdxt.code.task; |
||||
|
|
||||
|
import com.alibaba.fastjson.JSONArray; |
||||
|
import com.alibaba.fastjson.JSONObject; |
||||
|
import com.google.common.collect.Lists; |
||||
|
import com.zdxt.code.domain.EnterpriseComplaint; |
||||
|
import com.zdxt.code.domain.MssqAddOrder; |
||||
|
import com.zdxt.code.mapper.EnterpriseComplaintMapper; |
||||
|
import com.zdxt.code.service.IEnterpriseComplaintService; |
||||
|
import com.zdxt.code.service.MssqApiService; |
||||
|
import com.zdxt.common.util.DateUtils; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.stereotype.Component; |
||||
|
import org.springframework.stereotype.Service; |
||||
|
|
||||
|
import java.util.*; |
||||
|
import java.util.function.Function; |
||||
|
import java.util.stream.Collectors; |
||||
|
|
||||
|
/** |
||||
|
* 民生诉求接口定时获取工单状态 |
||||
|
*/ |
||||
|
@Component("mssqTask") |
||||
|
public class MssqTask { |
||||
|
|
||||
|
@Autowired |
||||
|
private MssqApiService mssqApiService; |
||||
|
|
||||
|
@Autowired |
||||
|
private EnterpriseComplaintMapper enterpriseComplaintMapper; |
||||
|
|
||||
|
|
||||
|
public void getMssqStatus() throws Exception { |
||||
|
EnterpriseComplaint enterpriseComplaint = new EnterpriseComplaint(); |
||||
|
enterpriseComplaint.setStatus(15); |
||||
|
List<EnterpriseComplaint> enterpriseComplaints = enterpriseComplaintMapper.selectByStatus(enterpriseComplaint); |
||||
|
if(enterpriseComplaints.size() == 0 ){ |
||||
|
return; |
||||
|
} |
||||
|
//获取列表中所有工单
|
||||
|
List<String> collect = enterpriseComplaints.stream().map(EnterpriseComplaint::getProWoCode).collect(Collectors.toList()); |
||||
|
|
||||
|
//集合数据拆分
|
||||
|
List<List<String>> partition = Lists.partition(collect, 19); |
||||
|
|
||||
|
for (List<String> stringList : partition) { |
||||
|
//查询民生诉求工单状态
|
||||
|
MssqAddOrder mssqAddOrder = new MssqAddOrder(); |
||||
|
mssqAddOrder.setProWoCodes(stringList); |
||||
|
String jsonStr = mssqApiService.queryMssq(mssqAddOrder, "/api/API_YX/proProcess/queryCurState"); |
||||
|
|
||||
|
//存储工单中的状态
|
||||
|
Map<String,Integer> map = new HashMap<>(); |
||||
|
|
||||
|
JSONObject jsonObject = JSONObject.parseObject(jsonStr); |
||||
|
JSONArray formList = jsonObject.getJSONArray("formList"); |
||||
|
for (int i = 0; i < formList.size(); i++) { |
||||
|
JSONObject jsonObject1 = formList.getJSONObject(i); |
||||
|
//工单编码
|
||||
|
String proWoCode = jsonObject1.getString("proWoCode"); |
||||
|
//工单状态
|
||||
|
Integer state = jsonObject1.getInteger("state"); |
||||
|
map.put(proWoCode,state); |
||||
|
} |
||||
|
Set<String> strings = map.keySet(); |
||||
|
|
||||
|
//TODO 民生诉求状态
|
||||
|
//状态为6 待评价
|
||||
|
//状态为 15 已完成
|
||||
|
//状态为 20 办理中
|
||||
|
//TODO 系统投诉工单状态
|
||||
|
//0 已受理 1 已办结 2 已归档
|
||||
|
for (String string : strings) { |
||||
|
EnterpriseComplaint enterpriseComplaintUpdate = new EnterpriseComplaint(); |
||||
|
enterpriseComplaintUpdate.setProWoCode(string); |
||||
|
if(map.get(string) == 6){ |
||||
|
enterpriseComplaintUpdate.setStatus(1); |
||||
|
enterpriseComplaintUpdate.setEvaluateTime(DateUtils.getDate()); |
||||
|
enterpriseComplaintMapper.updateEnterpriseComplaintByCode(enterpriseComplaintUpdate); |
||||
|
} |
||||
|
if(map.get(string) == 15){ |
||||
|
enterpriseComplaintUpdate.setStatus(2); |
||||
|
// enterpriseComplaintUpdate.setEvaluateTime(DateUtils.getDate());
|
||||
|
enterpriseComplaintMapper.updateEnterpriseComplaintByCode(enterpriseComplaintUpdate); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
} |
||||
Loading…
Reference in new issue