Commit c5a1308b authored by 竹天卫's avatar 竹天卫

校核优化

parent 25b50a5e
package cn.wise.sc.cement.business.model;
/**
* @author: Seven.wk
* @description: 数据返回类
* @create: 2018/07/04
*/
public class ResultVO<T> {
private Integer code;
private String message;
private T data;
public ResultVO() {
}
public ResultVO(Integer code, String message) {
this.code = code;
this.message = message;
}
public ResultVO(Integer code, String message, T data) {
this.code = code;
this.message = message;
this.data = data;
}
public Integer getCode() {
return code;
}
public void setCode(Integer code) {
this.code = code;
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
public T getData() {
return data;
}
public void setData(T data) {
this.data = data;
}
}
......@@ -37,6 +37,6 @@ import java.util.Map;
private String equipmentName;
@ApiModelProperty("输入信息集合")
private Map<String, Object> intputResult;
private Map<String, String> intputResult;
}
......@@ -11,7 +11,9 @@ import cn.wise.sc.cement.business.model.BaseResponse;
import cn.wise.sc.cement.business.model.query.EnclosureQuery;
import cn.wise.sc.cement.business.service.IEntityEnclosureService;
import cn.wise.sc.cement.business.util.CheckCountUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import io.swagger.models.auth.In;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -154,13 +156,25 @@ public class CommonServiceImpl {
return entityEnclosureList;
}
//Map转json数组
public JSONArray mapToJSONArray( Map<String, String> map){
JSONArray jsonArray = new JSONArray();
for(Map.Entry<String,String> entry : map.entrySet()){
JSONObject jsonObject = new JSONObject();
jsonObject.put("name",entry.getKey());
jsonObject.put("value",entry.getValue());
jsonArray.add(jsonObject);
}
return jsonArray;
}
/**
*
* @param checkResutlList 检测组id集合
* @param resultMap 输入集合
* @return
*/
public Map<String, String> checkCount(List<String> checkResutlList, Map<String, Object> resultMap ){
public Map<String, String> checkCount(List<String> checkResutlList, Map<String, String> resultMap ){
// List<String> checkResutlList = teamMapper.getByGroup(teamGroupId);
//定义输出集合
Map<String, String> countMap = new HashMap<>();
......
......@@ -19,6 +19,7 @@ import cn.wise.sc.cement.business.util.ExcelUtil;
import cn.wise.sc.cement.business.util.PageUtil;
import cn.wise.sc.cement.business.util.RedisUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
......@@ -1866,21 +1867,27 @@ public class EntrustServiceImpl extends ServiceImpl<EntrustMapper, Entrust> impl
if(sampleQuery.getIntputResult() == null){
return BaseResponse.errorMsg("请输入检测数据");
}
JSONArray inputResult_jsonArray = commonService.mapToJSONArray(sampleQuery.getIntputResult());
String inputResult_String = JSON.toJSON(inputResult_jsonArray).toString();
System.out.println(inputResult_String);
//计算检测结果
Map<String, String> resultMap = commonService.checkCount(checkResutlList, sampleQuery.getIntputResult());
resultMapList.add(resultMap);
JSONArray resultMap_jsonArray = commonService.mapToJSONArray(resultMap);
String resultMap_String = JSON.toJSON(resultMap_jsonArray).toString();
System.out.println(resultMap_String);
//保存校核检测组检测项信息
SampleCheckTeam sampleCheckTeam = null;
if(sampleQuery.getId() == null){
sampleCheckTeam = new SampleCheckTeam();
sampleCheckTeam = new SampleCheckTeam();
sampleCheckTeam.setCheckId(check.getId())
.setSampleId(sampleQuery.getSmapleId())
.setParallelCode(sampleQuery.getParallelCode())
.setUserId(sampleQuery.getUserId())
.setEquipmentId(sampleQuery.getEquipmentId())
.setEquipmentName(sampleQuery.getEquipmentName())
.setInputResult(JSON.toJSONString(sampleQuery.getIntputResult()))
.setCountResult(JSON.toJSONString(resultMap))
.setInputResult(inputResult_String)
.setCountResult(resultMap_String)
.setCreateTime(LocalDateTime.now());
sampleCheckTeamMapper.insert(sampleCheckTeam);
//添加设备使用记录 设备使用记录表 equipment_use
......@@ -1900,15 +1907,10 @@ public class EntrustServiceImpl extends ServiceImpl<EntrustMapper, Entrust> impl
}else{
sampleCheckTeam = sampleCheckTeamMapper.selectById(sampleQuery.getId());
sampleCheckTeam.setCheckId(check.getId())
.setInputResult(JSON.toJSONString(sampleQuery.getIntputResult()))
.setCountResult(JSON.toJSONString(resultMap));
.setInputResult(inputResult_String)
.setCountResult(resultMap_String);
sampleCheckTeamMapper.updateById(sampleCheckTeam);
}
}
countResultMap.put("resultMapList", resultMapList);
//计算最终计算结果 和 结果误差值
......@@ -2020,12 +2022,18 @@ public class EntrustServiceImpl extends ServiceImpl<EntrustMapper, Entrust> impl
Map<String,Map<String,String>> mapResult = CheckCountUtil.countParallelAvgError(groupMap);
if(mapResult != null){
Map<String,String> countResults= mapResult.get("countResults");
JSONArray countResults_jsonArray = commonService.mapToJSONArray(countResults);
String countResults_String = JSON.toJSON(countResults_jsonArray).toString();
System.out.println(countResults_String);
Map<String,String> countError= mapResult.get("countError");
check.setCountResults(JSON.toJSONString(countResults));
check.setCountError(JSON.toJSONString(countError));
JSONArray countError_jsonArray = commonService.mapToJSONArray(countError);
String countError_String = JSON.toJSON(countError_jsonArray).toString();
System.out.println(countError_String);
check.setCountResults(countResults_String);
check.setCountError(countError_String);
sampleCheckMapper.updateById(check);
countResultMap.put("countResults", countResults);
countResultMap.put("countError", countError);
countResultMap.put("countResults", countResults_String);
countResultMap.put("countError", countError_String);
}
}
Boolean ret = true; //全部校核计算完成
......
......@@ -122,13 +122,6 @@ public class WeiXinService {
//获取用户信息
public JSONObject getUser(String accessToken, String userId) {
try {
......@@ -152,6 +145,14 @@ public class WeiXinService {
return BaseResponse.okData(loginUser);
}
/**
* 消息发送
*/
public void sendMessage(){
WeixinInterfaceUtil.sendPostRequest(null, null);
}
......
......@@ -53,7 +53,7 @@ public class CheckCountUtil {
* @return
*/
//加 add 减 subtract 乘 multiply 除 divide
public static String checkCount(String name, Map<String, Object> resultMap) {
public static String checkCount(String name, Map<String, String> resultMap) {
BigDecimal endResult = null;
if(name.equals("L.O.I")){
//样重m1—保留4位⼩数
......@@ -280,7 +280,7 @@ public class CheckCountUtil {
* @param countMap
* @return
*/
public static String countSO3(Map<String, Object> resultMap, Map<String, String> countMap) {
public static String countSO3(Map<String, String> resultMap, Map<String, String> countMap) {
BigDecimal weightSO3 = getBigDecimal(countMap.get("重量法_SO3"));
BigDecimal displaySO3= getBigDecimal(resultMap.get("显示值"));
BigDecimal mSO3= getBigDecimal(resultMap.get("样重SO3"));
......@@ -309,18 +309,18 @@ public class CheckCountUtil {
*/
public static String countHL(Map<String, String> countMap) {
List<String> list = new ArrayList<>();
list.add(countMap.get("L.O.I").toString());
list.add(countMap.get("SiO2").toString());
// list.add(countMap.get("Al2O3+TiO2").toString());
list.add(countMap.get("Al2O3").toString());
list.add(countMap.get("Fe2O3").toString());
list.add(countMap.get("CaO").toString());
list.add(countMap.get("MgO").toString());
list.add(countMap.get("TiO2").toString());
list.add(countMap.get("K2O").toString());
list.add(countMap.get("Na2O").toString());
list.add(countMap.get("MnO").toString());
list.add(countMap.get("SO3").toString());
list.add(countMap.get("L.O.I"));
list.add(countMap.get("SiO2"));
// list.add(countMap.get("Al2O3+TiO2"));
list.add(countMap.get("Al2O3"));
list.add(countMap.get("Fe2O3"));
list.add(countMap.get("CaO"));
list.add(countMap.get("MgO"));
list.add(countMap.get("TiO2"));
list.add(countMap.get("K2O"));
list.add(countMap.get("Na2O"));
list.add(countMap.get("MnO"));
list.add(countMap.get("SO3"));
BigDecimal count=new BigDecimal(0);
for(String s:list) {
count = count.add(new BigDecimal(s));
......@@ -374,7 +374,7 @@ public class CheckCountUtil {
* @param countMap 输出集合
* @return
*/
public static String countBurnupLevel(Map<String, Object> resultMap, Map<String, String> countMap) {
public static String countBurnupLevel(Map<String, String> resultMap, Map<String, String> countMap) {
BigDecimal fCaO_1450 = getBigDecimal(resultMap.get("fCaO_1450"));
BigDecimal KH= getBigDecimal(countMap.get("KH"));
BigDecimal E = new BigDecimal(45).multiply(KH).subtract(new BigDecimal(37.4));
......@@ -464,7 +464,7 @@ public class CheckCountUtil {
* @param countMap
* @return
*/
public static String countVad1(Map<String, Object> resultMap, Map<String, String> countMap) {
public static String countVad1(Map<String, String> resultMap, Map<String, String> countMap) {
BigDecimal YZ_V1 = getBigDecimal(resultMap.get("样重V1"));
BigDecimal MZ_V1 = getBigDecimal(resultMap.get("皿重V1"));
BigDecimal SZ_V1 = getBigDecimal(resultMap.get("烧重V1"));
......@@ -481,7 +481,7 @@ public class CheckCountUtil {
* @param countMap
* @return
*/
public static String countVad2(Map<String, Object> resultMap, Map<String, String> countMap) {
public static String countVad2(Map<String, String> resultMap, Map<String, String> countMap) {
BigDecimal YZ_V2 = getBigDecimal(resultMap.get("样重V2"));
BigDecimal MZ_V2 = getBigDecimal(resultMap.get("皿重V2"));
BigDecimal SZ_V2 = getBigDecimal(resultMap.get("烧重V2"));
......@@ -561,8 +561,8 @@ public class CheckCountUtil {
* @param countMap
* @return
*/
public static String countK(Map<String, Object> resultMap, Map<String, String> countMap) {
String JZTZ= resultMap.get("焦渣特征").toString();
public static String countK(Map<String, String> resultMap, Map<String, String> countMap) {
String JZTZ= resultMap.get("焦渣特征");
BigDecimal Vdaf= getBigDecimal(countMap.get("Vdaf"));
//获取焦渣特征序号对应的值
Map<String, String> map = JZTZCountUtil.getJZTZ(Vdaf);
......@@ -710,7 +710,7 @@ public class CheckCountUtil {
* @param countMap
* @return
*/
public static String countQnet_adMJ_kg(Map<String, Object> resultMap, Map<String, String> countMap) {
public static String countQnet_adMJ_kg(Map<String, String> resultMap, Map<String, String> countMap) {
BigDecimal YWH_123= getBigDecimal(resultMap.get("烟无褐123"));
BigDecimal K1_= getBigDecimal(countMap.get("K1,"));
BigDecimal BC_Mad= getBigDecimal(countMap.get("报出_Mad"));
......@@ -741,7 +741,7 @@ public class CheckCountUtil {
* @param resultMap
* @return
*/
public static String countYMXGrade(Map<String, Object> resultMap) {
public static String countYMXGrade(Map<String, String> resultMap) {
BigDecimal YMX_kWh_t = getBigDecimal(resultMap.get("易磨性(kWh/t)"));
if(YMX_kWh_t.compareTo(new BigDecimal(18))==1){
return "E";
......@@ -761,10 +761,10 @@ public class CheckCountUtil {
* @param resultMap
* @return
*/
public static String countYMXCode(Map<String, Object> resultMap) {
Double G = Double.valueOf(resultMap.get("G").toString());
Double P80 = Double.valueOf(resultMap.get("P80").toString());
Double F80 = Double.valueOf(resultMap.get("F80").toString());
public static String countYMXCode(Map<String, String> resultMap) {
Double G = Double.valueOf(resultMap.get("G"));
Double P80 = Double.valueOf(resultMap.get("P80"));
Double F80 = Double.valueOf(resultMap.get("F80"));
BigDecimal YMX_kWh_t = getBigDecimal(resultMap.get("易磨性(kWh/t)"));
BigDecimal YMX_MJ_t = getBigDecimal(resultMap.get("易磨性(MJ/t)"));
Double countResult =
......
......@@ -30,6 +30,12 @@ public interface Global {
*/
public static final String USERURL = "https://qyapi.weixin.qq.com/cgi-bin/user/get";
/**
* 微信公众平台,发送应用消息的接口地址,Https请求方式:GET
* 接口地址示例:https://qyapi.weixin.qq.com/cgi-bin/message/send?access_token=ACCESS_TOKEN
*/
public static final String SENDMESSAGE = "https://qyapi.weixin.qq.com/cgi-bin/message/send";
......
package cn.wise.sc.cement.business.util.weixin;
import cn.wise.sc.cement.business.model.ResultVO;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import org.apache.commons.lang3.StringUtils;
import org.springframework.http.*;
import org.springframework.util.MultiValueMap;
import org.springframework.web.client.RestTemplate;
import java.util.*;
/**
* 艺哚哚对外开放接口 工具类
* 对外开放接口 工具类
*/
public class WeixinInterfaceUtil {
......@@ -44,7 +47,28 @@ public class WeixinInterfaceUtil {
return resultMap;
}
/**
/**
* 向目的URL发送post请求
* @param url 目的url
* @param params 发送的参数
* @return ResultVO
*/
public static ResultVO sendPostRequest(String url, MultiValueMap<String, String> params){
RestTemplate client = new RestTemplate();
HttpHeaders headers = new HttpHeaders();
HttpMethod method = HttpMethod.POST;
// 以表单的方式提交
headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED);
//将请求头部和参数合成一个请求
HttpEntity<MultiValueMap<String, String>> requestEntity = new HttpEntity<>(params, headers);
//执行HTTP请求,将返回的结构使用ResultVO类格式化
ResponseEntity<ResultVO> response = client.exchange(url, method, requestEntity, ResultVO.class);
return response.getBody();
}
/**
* 将请求参数放到map里,
* 按照字母请求参数名的字母升序排列非空请求参数(包含 appid)
* @param sortedParams
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment