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");
|
2024-08-26 09:04:37 +00:00
|
|
|
param.put("page", 1);
|
2024-08-26 08:49:29 +00:00
|
|
|
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");
|
|
|
|
|
2024-08-26 09:04:37 +00:00
|
|
|
Map<String, Object> resultMap = new HashMap<>();
|
|
|
|
resultMap.put("orderTotal", total);
|
2024-08-26 08:49:29 +00:00
|
|
|
|
|
|
|
List<JSONObject> data = JSONObject.parseObject(jsonObject.getString("data"), List.class);
|
|
|
|
Integer waitDoneTotal = 0;
|
|
|
|
Integer doneTotal = 0;
|
|
|
|
for (JSONObject obj : data) {
|
2024-08-26 09:04:37 +00:00
|
|
|
if ("0".equals(obj.getString("approve_status"))) {
|
2024-08-26 08:49:29 +00:00
|
|
|
waitDoneTotal++;
|
2024-08-26 09:04:37 +00:00
|
|
|
} else {
|
2024-08-26 08:49:29 +00:00
|
|
|
doneTotal++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-08-26 09:04:37 +00:00
|
|
|
resultMap.put("waitDoneTotal", waitDoneTotal);
|
|
|
|
resultMap.put("doneTotal", doneTotal);
|
2024-08-26 08:49:29 +00:00
|
|
|
|
2024-08-26 09:04:37 +00:00
|
|
|
return new GeneralResult(true, resultMap, "查询成功");
|
|
|
|
} catch (Exception e) {
|
|
|
|
log.info("查询失败", e);
|
|
|
|
return new GeneralResult(false, "查询失败");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public GeneralResult userDataStatic(RequestContext requestContext) {
|
|
|
|
try {
|
|
|
|
//查询当前用户授权应用
|
2024-08-26 10:58:08 +00:00
|
|
|
JSONObject param = new JSONObject();
|
|
|
|
param.put("userId", "1111");
|
|
|
|
param.put("type", "user");
|
|
|
|
String result = ykUtil.call(YkInfo.getUserAppList, param, JSONArray.class);
|
2024-08-26 09:04:37 +00:00
|
|
|
|
|
|
|
//获取用户信息
|
|
|
|
JSONObject userParam = new JSONObject();
|
2024-08-26 09:31:45 +00:00
|
|
|
userParam.put("userId", "1111");
|
|
|
|
String userRolesStr = ykUtil.call(YkInfo.getUserRoles, userParam, JSONArray.class);
|
2024-08-26 09:04:37 +00:00
|
|
|
|
|
|
|
|
|
|
|
return new GeneralResult(true, "查询成功");
|
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, "查询失败");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|