2024-08-25 08:42:26 +00:00
|
|
|
package com.bocloud.sms.service;
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
import com.bocloud.sms.entity.User;
|
|
|
|
import com.bocloud.sms.enums.YkInfo;
|
|
|
|
import com.bocloud.sms.interfaces.IndexService;
|
|
|
|
import com.bocloud.sms.repository.UserRepository;
|
2024-08-26 02:00:17 +00:00
|
|
|
import com.bocloud.sms.utils.YkUtil;
|
2024-08-25 08:42:26 +00:00
|
|
|
import com.megatron.common.model.GeneralResult;
|
|
|
|
import com.megatron.common.model.Pager;
|
|
|
|
import com.megatron.common.model.RequestContext;
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
2024-08-26 08:49:29 +00:00
|
|
|
import java.util.HashMap;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.Map;
|
|
|
|
|
2024-08-25 08:42:26 +00:00
|
|
|
@Service("IndexService")
|
|
|
|
@Slf4j
|
|
|
|
public class IndexServiceImpl implements IndexService {
|
|
|
|
|
|
|
|
@Autowired
|
2024-08-26 02:00:17 +00:00
|
|
|
private YkUtil ykUtil;
|
2024-08-25 08:42:26 +00:00
|
|
|
@Autowired
|
|
|
|
private UserRepository userRepository;
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public GeneralResult doneWorkOrder(Pager pager, RequestContext requestContext) {
|
|
|
|
try {
|
|
|
|
JSONObject param = new JSONObject();
|
|
|
|
User user = userRepository.query(requestContext.getTarget());
|
2024-08-26 08:49:29 +00:00
|
|
|
param.put("userId", "1111");
|
|
|
|
param.put("page", pager.getPage());
|
|
|
|
param.put("limit", pager.getRows());
|
2024-08-26 02:00:17 +00:00
|
|
|
String result = ykUtil.call(YkInfo.getTaskList, param, JSONArray.class);
|
2024-08-26 08:49:29 +00:00
|
|
|
JSONObject jsonObject = JSONArray.parseObject(result, JSONObject.class);
|
|
|
|
return new GeneralResult(true, jsonObject, "查询成功");
|
|
|
|
} catch (Exception e) {
|
|
|
|
log.info("查询失败", e);
|
|
|
|
return new GeneralResult(false, "查询失败");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public GeneralResult workOrderStatic(RequestContext requestContext) {
|
|
|
|
try {
|
2024-08-25 08:42:26 +00:00
|
|
|
|
2024-08-26 08:49:29 +00:00
|
|
|
JSONObject param = new JSONObject();
|
|
|
|
User user = userRepository.query(requestContext.getTarget());
|
|
|
|
param.put("userId", "1111");
|
|
|
|
param.put("page",1);
|
|
|
|
param.put("limit", Integer.MAX_VALUE);
|
|
|
|
String result = ykUtil.call(YkInfo.getTaskList, param, JSONArray.class);
|
2024-08-26 08:38:32 +00:00
|
|
|
JSONObject jsonObject = JSONArray.parseObject(result, JSONObject.class);
|
2024-08-26 08:49:29 +00:00
|
|
|
Integer total = jsonObject.getInteger("total");
|
|
|
|
|
|
|
|
Map<String,Object> resultMap = new HashMap<>();
|
|
|
|
resultMap.put("orderTotal",total);
|
|
|
|
|
|
|
|
List<JSONObject> data = JSONObject.parseObject(jsonObject.getString("data"), List.class);
|
|
|
|
Integer waitDoneTotal = 0;
|
|
|
|
Integer doneTotal = 0;
|
|
|
|
for (JSONObject obj : data) {
|
|
|
|
if("0".equals(obj.getString("approve_status"))){
|
|
|
|
waitDoneTotal++;
|
|
|
|
}else {
|
|
|
|
doneTotal++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
resultMap.put("waitDoneTotal",waitDoneTotal);
|
|
|
|
resultMap.put("doneTotal",doneTotal);
|
|
|
|
|
2024-08-26 08:51:57 +00:00
|
|
|
return new GeneralResult(true, resultMap,"查询成功");
|
2024-08-25 08:42:26 +00:00
|
|
|
} catch (Exception e) {
|
2024-08-26 08:49:29 +00:00
|
|
|
log.info("查询失败", e);
|
2024-08-25 08:42:26 +00:00
|
|
|
return new GeneralResult(false, "查询失败");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|