浏览代码

加密算法调整

wangchangsheng 1 年之前
父节点
当前提交
d41a34c147
共有 16 个文件被更改,包括 353 次插入203 次删除
  1. 1 1
      ims-common/src/main/java/com/ims/common/utils/FormulaUtils.java
  2. 38 0
      ims-common/src/main/java/com/ims/common/utils/MD5Utils.java
  3. 103 0
      ims-common/src/main/java/com/ims/common/utils/RSAUtils.java
  4. 30 1
      ims-service/ims-eval/src/main/java/com/ims/eval/controller/UserController.java
  5. 7 1
      ims-service/ims-eval/src/main/java/com/ims/eval/dao/CalculateIndicatorItemInfoMapper.java
  6. 1 1
      ims-service/ims-eval/src/main/java/com/ims/eval/dao/CiteCalculationIndicatorMapper.java
  7. 8 0
      ims-service/ims-eval/src/main/java/com/ims/eval/entity/dto/result/R.java
  8. 1 2
      ims-service/ims-eval/src/main/java/com/ims/eval/service/ICalculateIndicatorItemInfoService.java
  9. 1 1
      ims-service/ims-eval/src/main/java/com/ims/eval/service/ICiteCalculationIndicatorService.java
  10. 1 1
      ims-service/ims-eval/src/main/java/com/ims/eval/service/IUserService.java
  11. 79 181
      ims-service/ims-eval/src/main/java/com/ims/eval/service/impl/CalculateIndicatorItemInfoServiceImpl.java
  12. 2 2
      ims-service/ims-eval/src/main/java/com/ims/eval/service/impl/CiteCalculationIndicatorServiceImpl.java
  13. 24 8
      ims-service/ims-eval/src/main/java/com/ims/eval/service/impl/OrganizationEvaluationInfoServiceImpl.java
  14. 22 2
      ims-service/ims-eval/src/main/java/com/ims/eval/service/impl/UserServiceImpl.java
  15. 29 2
      ims-service/ims-eval/src/main/resources/mappers/CalculateIndicatorItemInfoMapper.xml
  16. 6 0
      ims-service/ims-eval/src/main/resources/mappers/CiteCalculationIndicatorMapper.xml

+ 1 - 1
ims-common/src/main/java/com/ims/common/utils/FormulaUtils.java

@@ -86,7 +86,7 @@ public class FormulaUtils {
 			cell.setCellType(CellType.FORMULA);
 
 			double value = evaluator.evaluate(cell).getNumberValue() ;
-			return new BigDecimal(value).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
+			return new BigDecimal(value).setScale(4, BigDecimal.ROUND_HALF_UP).doubleValue();
 		} catch (Exception e) {
 			e.printStackTrace();
 			log.error("FormulaUtils==excel公式解析异常: ", e.getMessage());

+ 38 - 0
ims-common/src/main/java/com/ims/common/utils/MD5Utils.java

@@ -0,0 +1,38 @@
+package com.ims.common.utils;
+
+import java.security.MessageDigest;
+
+public class MD5Utils {
+
+
+	public static String md5Encrypt(String input) {
+
+
+		try {
+			// 创建 MessageDigest 实例并指定算法为 MD5
+			MessageDigest md = MessageDigest.getInstance("MD5");
+
+			// 将输入字符串转换为字节数组并计算哈希值
+			byte[] hashBytes = md.digest(input.getBytes());
+
+			// 将字节数组转换为十六进制格式的字符串
+			StringBuilder hexString = new StringBuilder();
+			for (byte b : hashBytes) {
+				String hex = Integer.toHexString(0xFF & b);
+				if (hex.length() == 1) {
+					hexString.append('0');
+				}
+				hexString.append(hex);
+			}
+
+			// 返回 MD5 哈希值
+			return hexString.toString();
+
+		} catch (Exception e) {
+			e.printStackTrace();
+		}
+
+		return null;
+	}
+
+}

+ 103 - 0
ims-common/src/main/java/com/ims/common/utils/RSAUtils.java

@@ -0,0 +1,103 @@
+package com.ims.common.utils;
+
+import javax.crypto.Cipher;
+import java.security.*;
+
+
+public class RSAUtils {
+	private static final String ALGORITHM = "RSA";
+
+	private static KeyPair keyPair ;
+	// 生成密钥对
+	public static KeyPair generateKeyPair(int keySize) throws Exception {
+		if(null == keyPair){
+			KeyPairGenerator keyPairGenerator = KeyPairGenerator.getInstance(ALGORITHM);
+			SecureRandom secureRandom = new SecureRandom();
+			keyPairGenerator.initialize(keySize, secureRandom);
+			keyPair = keyPairGenerator.generateKeyPair();
+		}
+		return keyPair;
+	}
+
+
+
+	// 公钥加密
+	public static byte[] encrypt(byte[] data, PublicKey publicKey) throws Exception {
+		Cipher cipher = Cipher.getInstance(ALGORITHM);
+		cipher.init(Cipher.ENCRYPT_MODE, publicKey);
+		return cipher.doFinal(data);
+	}
+
+	// 私钥解密
+	public static byte[] decrypt(byte[] encryptedData, PrivateKey privateKey) throws Exception {
+		Cipher cipher = Cipher.getInstance(ALGORITHM);
+		cipher.init(Cipher.DECRYPT_MODE, privateKey);
+		return cipher.doFinal(encryptedData);
+	}
+
+	// 数字签名
+	public static byte[] sign(byte[] data, PrivateKey privateKey) throws Exception {
+		Signature signature = Signature.getInstance("SHA256withRSA");
+		signature.initSign(privateKey);
+		signature.update(data);
+		return signature.sign();
+	}
+
+	// 验证数字签名
+	public static boolean verify(byte[] data, byte[] signatureBytes, PublicKey publicKey) throws Exception {
+		Signature signature = Signature.getInstance("SHA256withRSA");
+		signature.initVerify(publicKey);
+		signature.update(data);
+		return signature.verify(signatureBytes);
+	}
+
+	public static KeyPair getKeyPair() throws Exception {
+		if(null == keyPair){
+			keyPair = generateKeyPair(2048);
+		}
+		return keyPair;
+	}
+
+	public static void main1(String[] args) throws Exception {
+		String originalMessage = "Hello, RSA!";
+
+		// 生成密钥对
+		KeyPair keyPair = generateKeyPair(2048);
+		PublicKey publicKey = keyPair.getPublic();
+		PrivateKey privateKey = keyPair.getPrivate();
+
+		// 加密
+		byte[] encryptedData = encrypt(originalMessage.getBytes(), publicKey);
+
+		// 解密
+		byte[] decryptedData = decrypt(encryptedData, privateKey);
+
+		// 数字签名
+		byte[] signature = sign(originalMessage.getBytes(), privateKey);
+
+		// 验证数字签名
+		boolean isSignatureValid = verify(originalMessage.getBytes(), signature, publicKey);
+
+		System.out.println("原始消息:" + originalMessage);
+		System.out.println("加密后的数据:" + new String(encryptedData));
+		System.out.println("解密后的数据:" + new String(decryptedData));
+		System.out.println("数字签名验证结果:" + isSignatureValid);
+	}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+}

+ 30 - 1
ims-service/ims-eval/src/main/java/com/ims/eval/controller/UserController.java

@@ -2,6 +2,7 @@ package com.ims.eval.controller;
 
 
 import com.alibaba.fastjson.JSONObject;
+import com.ims.common.utils.RSAUtils;
 import com.ims.eval.entity.dto.result.R;
 import com.ims.eval.entity.Myuser;
 import com.ims.eval.feign.RemoteServiceBuilder;
@@ -12,6 +13,8 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 
 import javax.servlet.http.HttpServletRequest;
+import java.security.KeyPair;
+import java.util.Base64;
 import java.util.List;
 import java.util.concurrent.atomic.AtomicBoolean;
 
@@ -38,6 +41,30 @@ public class UserController {
 	@Autowired
 	private HttpServletRequest request;
 
+
+	@GetMapping("/publicKey")
+	public  R getPublicKey() throws Exception {
+		try {
+			KeyPair keyPair = RSAUtils.generateKeyPair(2048);
+			String publicKey = Base64.getEncoder().encodeToString(keyPair.getPublic().getEncoded());
+			return R.ok().data(publicKey);
+		} catch (Exception e) {
+			e.printStackTrace();
+			return R.error("登录失败");
+		}
+	}
+
+	@GetMapping("/getEncrypt")
+	public String getEncrypt(String pwd) throws Exception {
+		KeyPair keyPair = RSAUtils.generateKeyPair(2048);
+		// 加密
+		byte[] encryptedData = RSAUtils.encrypt(pwd.getBytes(), keyPair.getPublic());
+
+		String str2 = Base64.getEncoder().encodeToString(encryptedData).replaceAll(" ", "+");
+		return str2;
+	}
+
+
 	/**
 	 * 更具code获取用户信息
 	 * @return
@@ -87,11 +114,13 @@ public class UserController {
 			json = userService.getbladeAuth("000000",username,password,"password","all","account");
 		} catch (Exception e) {
 			log.error("错误",e);
-			return R.error().customError("登录失败");
+			return R.ok().error("登录失败");
 		}
 		return R.ok().data(json);
 	}
 
+
+
 	@GetMapping(value = "pageList")
 	public JSONObject pageList(
 		@RequestParam(value = "current", required = false) Integer current,

+ 7 - 1
ims-service/ims-eval/src/main/java/com/ims/eval/dao/CalculateIndicatorItemInfoMapper.java

@@ -2,6 +2,7 @@ package com.ims.eval.dao;
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.ims.eval.entity.CalculateIndicatorItemInfo;
+import org.apache.ibatis.annotations.Param;
 
 import java.util.List;
 
@@ -15,6 +16,11 @@ import java.util.List;
  */
 public interface CalculateIndicatorItemInfoMapper extends BaseMapper<CalculateIndicatorItemInfo> {
 
-	List<CalculateIndicatorItemInfo> selectList(String organizationType, String checkCycle, String year, String month,String binSection,String organizationEvaluationId,String childCode);
+	List<CalculateIndicatorItemInfo> selectList(String organizationType, String checkCycle, String year, String month,String indicatorId,String organizationEvaluationId,String childCode);
+
+
+	List<CalculateIndicatorItemInfo> selectItemInfoByIndicatorIdList(@Param("binSection") String binSection,
+																	 @Param("organizationEvaluationId") String organizationEvaluationId,
+																	 @Param("indicatorIds")  List<String> indicatorIds);
 
 }

+ 1 - 1
ims-service/ims-eval/src/main/java/com/ims/eval/dao/CiteCalculationIndicatorMapper.java

@@ -24,7 +24,7 @@ public interface CiteCalculationIndicatorMapper extends BaseMapper<CiteCalculati
 																	   @Param("binSection") String binSection);
 
 
-	List<CiteCalculationIndicator> selectListLikeIndicatorIds(@Param("indicatorIds") String indicatorIds);
+	List<CiteCalculationIndicator> selectListLikeIndicatorIds(@Param("indicatorIds") String indicatorIds,@Param("binSection")  String binSection);
 
 
 }

+ 8 - 0
ims-service/ims-eval/src/main/java/com/ims/eval/entity/dto/result/R.java

@@ -47,6 +47,14 @@ public class R {
         r.setMessage("失败");
         return r;
     }
+	public static R error(String msg){
+		R r = new R();
+		r.setSuccess(false);
+		r.setCode(ResultCode.ERROR);
+		r.setMessage(msg);
+		return r;
+	}
+
 	public static R customError(String msg){
 		R r = new R();
 		r.setSuccess(true);

+ 1 - 2
ims-service/ims-eval/src/main/java/com/ims/eval/service/ICalculateIndicatorItemInfoService.java

@@ -18,7 +18,6 @@ import java.util.List;
 public interface ICalculateIndicatorItemInfoService extends IService<CalculateIndicatorItemInfo> {
 
 
-	int saveIndicatorInfoDTO(List<OrganizationEvaluationInfoResDTO> infoResDTOS) throws Exception;
+	int saveIndicatorInfoDTO(String organizationEvaluationId,List<OrganizationEvaluationInfoResDTO> infoResDTOS) throws Exception;
 
-	int saveIndicatorInfoDTO2(List<OrganizationEvaluationInfoResDTO> infoResDTOS) throws Exception;
 }

+ 1 - 1
ims-service/ims-eval/src/main/java/com/ims/eval/service/ICiteCalculationIndicatorService.java

@@ -20,6 +20,6 @@ public interface ICiteCalculationIndicatorService extends IService<CiteCalculati
 	IPage<CiteCalculationIndicator> getCiteCalculationIndicatorList(Integer pageNum, Integer pageSize, String citeCalculationName, String binSection);
 
 
-	List<CiteCalculationIndicator> getListLikeIndicatorIds(String indicatorIds);
+	List<CiteCalculationIndicator> getListLikeIndicatorIds(String indicatorIds,String binSection);
 
 }

+ 1 - 1
ims-service/ims-eval/src/main/java/com/ims/eval/service/IUserService.java

@@ -71,7 +71,7 @@ public interface IUserService extends IService<Myuser> {
 	 * @param password
 	 * @return
 	 */
-	JSONObject getbladeAuth(String tenantId, String username, String password, String grantType, String scope, String type);
+	JSONObject getbladeAuth(String tenantId, String username, String password, String grantType, String scope, String type) throws Exception;
 
 	/**
 	 * 分页获取用户

+ 79 - 181
ims-service/ims-eval/src/main/java/com/ims/eval/service/impl/CalculateIndicatorItemInfoServiceImpl.java

@@ -1,13 +1,13 @@
 package com.ims.eval.service.impl;
 
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.ims.eval.dao.*;
 import com.ims.eval.entity.CalculateIndicatorItemInfo;
-import com.ims.eval.entity.OrganizationEvaluationInfo;
+import com.ims.eval.entity.CiteCalculationIndicator;
 import com.ims.eval.entity.dto.response.OrganizationEvaluationInfoResDTO;
 import com.ims.eval.entity.dto.response.OrganizationEvaluationResDTO;
 import com.ims.eval.service.ICalculateIndicatorItemInfoService;
+import com.ims.eval.service.ICiteCalculationIndicatorService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
@@ -17,7 +17,6 @@ import java.math.BigDecimal;
 import java.util.*;
 import java.util.stream.Collectors;
 
-import static org.codehaus.groovy.runtime.DefaultGroovyMethods.collect;
 
 /**
  * <p>
@@ -38,207 +37,105 @@ public class CalculateIndicatorItemInfoServiceImpl extends ServiceImpl<Calculate
 	@Resource
 	private CalculateIndicatorItemInfoMapper calculateIndicatorItemInfoMapper;
 
+	@Autowired
+	private ICalculateIndicatorItemInfoService calculateIndicatorItemInfoService;
+
+
 	@Resource
 	private IndicatorMapper indicatorMapper;
 
+	@Autowired
+	private ICiteCalculationIndicatorService citeCalculationIndicatorService;
 
 
-	@Override
-	public int saveIndicatorInfoDTO(List<OrganizationEvaluationInfoResDTO> infoResDTOS) throws Exception {
-		List<CalculateIndicatorItemInfo> list = new ArrayList<>();
-		OrganizationEvaluationResDTO organizationEvaluationResDTO = organizationEvaluationMapper.selectById(infoResDTOS.get(0).getOrganizationEvaluationId());
-		Map<String, List<OrganizationEvaluationInfoResDTO>> childCodeGropList = infoResDTOS.stream().collect(Collectors.groupingBy(OrganizationEvaluationInfoResDTO::getChildCode));
-
-		for (Map.Entry<String, List<OrganizationEvaluationInfoResDTO>> childCodeGropListEntry : childCodeGropList.entrySet()){
-			//对指标id进行分组
-			for (OrganizationEvaluationInfoResDTO r : childCodeGropListEntry.getValue()){
-				if (r.getOptionCode().equals("LRZE") || r.getOptionCode().equals("CZ") ||  r.getOptionCode().equals("LRGXKH")|| r.getOptionCode().equals("LRGXL") || r.getOptionCode().equals("DWQWLR")) {
-					CalculateIndicatorItemInfo calculateIndicatorItemInfo = new CalculateIndicatorItemInfo();
-					calculateIndicatorItemInfo.setIndicatorId(r.getIndicatorId());
-					calculateIndicatorItemInfo.setOptionCode(r.getOptionCode());
-					calculateIndicatorItemInfo.setQuantifiedValue(r.getQuantifiedValue());
-					calculateIndicatorItemInfo.setSectionId(r.getBinSection());
-					calculateIndicatorItemInfo.setOrganizationType(organizationEvaluationResDTO.getOrganizationType());
-					calculateIndicatorItemInfo.setCheckCycle(organizationEvaluationResDTO.getCheckCycle());
-					calculateIndicatorItemInfo.setYear(organizationEvaluationResDTO.getYear());
-					calculateIndicatorItemInfo.setMonth(organizationEvaluationResDTO.getMonth());
-					calculateIndicatorItemInfo.setOrganizationEvaluationId(r.getOrganizationEvaluationId());
-					calculateIndicatorItemInfo.setChildCode(r.getChildCode());
-					list.add(calculateIndicatorItemInfo);
-				}
-			}
-		}
-
-		return saveCalculate(list);
-	}
-
 
 	@Override
-	public int saveIndicatorInfoDTO2(List<OrganizationEvaluationInfoResDTO> infoResDTOS) throws Exception {
-		List<CalculateIndicatorItemInfo> list = new ArrayList<>();
-		for (OrganizationEvaluationInfoResDTO r : infoResDTOS){
-			if (r.getOptionCode().equals("LRZE") || r.getOptionCode().equals("CZ") ||  r.getOptionCode().equals("LRGXKH")|| r.getOptionCode().equals("LRGXL") || r.getOptionCode().equals("DWQWLR")) {
-				CalculateIndicatorItemInfo calculateIndicatorItemInfo = new CalculateIndicatorItemInfo();
-				calculateIndicatorItemInfo.setIndicatorId(r.getIndicatorId());
-				calculateIndicatorItemInfo.setOptionCode(r.getOptionCode());
-				calculateIndicatorItemInfo.setQuantifiedValue(r.getQuantifiedValue());
-				calculateIndicatorItemInfo.setSectionId(r.getBinSection());
-//				calculateIndicatorItemInfo.setOrganizationType(organizationEvaluationResDTO.getOrganizationType());
-//				calculateIndicatorItemInfo.setCheckCycle(organizationEvaluationResDTO.getCheckCycle());
-//				calculateIndicatorItemInfo.setYear(organizationEvaluationResDTO.getYear());
-//				calculateIndicatorItemInfo.setMonth(organizationEvaluationResDTO.getMonth());
-				calculateIndicatorItemInfo.setOrganizationEvaluationId(r.getOrganizationEvaluationId());
-				calculateIndicatorItemInfo.setChildCode(r.getChildCode());
-				list.add(calculateIndicatorItemInfo);
-			}
-		}
-
-		return 0;
-	}
-
-	@Transactional
-	public int saveCalculate(List<CalculateIndicatorItemInfo> listall) throws Exception {
-
-		if (listall.size() > 0){
-
-
-			Map<String, List<CalculateIndicatorItemInfo>> childCodeGropList = listall.stream().collect(Collectors.groupingBy(CalculateIndicatorItemInfo::getChildCode));
-			for (Map.Entry<String, List<CalculateIndicatorItemInfo>> childCodeGropListEntry : childCodeGropList.entrySet()){
-
-				List<CalculateIndicatorItemInfo> list = childCodeGropListEntry.getValue();
-				//遍历list解析最大值和最小值
-				Map<String, List<CalculateIndicatorItemInfo>> collect = list.stream().collect(Collectors.groupingBy(CalculateIndicatorItemInfo::getOptionCode));
-				//判断计算指标明细中之前是否存在记录 如果存在删除之前记录,重新新增
-				List<CalculateIndicatorItemInfo> calculateIndicatorItemInfo = calculateIndicatorItemInfoMapper.selectList("","","","","",list.get(0).getOrganizationEvaluationId(),list.get(0).getChildCode());
-
-				if (calculateIndicatorItemInfo.size() > 0){
-					List<String> idList = calculateIndicatorItemInfo.stream().map(CalculateIndicatorItemInfo::getId).collect(Collectors.toList());
-					calculateIndicatorItemInfoMapper.deleteBatchIds(idList);
+	public int saveIndicatorInfoDTO(String organizationEvaluationId,List<OrganizationEvaluationInfoResDTO> infoResDTOS) throws Exception {
+		try {
+			List<CalculateIndicatorItemInfo> list = new ArrayList<>();
+			OrganizationEvaluationResDTO organizationEvaluationResDTO = organizationEvaluationMapper.selectById(infoResDTOS.get(0).getOrganizationEvaluationId());
+			Map<String, List<OrganizationEvaluationInfoResDTO>> childCodeGropList = infoResDTOS.stream().collect(Collectors.groupingBy(OrganizationEvaluationInfoResDTO::getChildCode));
+
+			for (Map.Entry<String, List<OrganizationEvaluationInfoResDTO>> childCodeGropListEntry : childCodeGropList.entrySet()){
+				//对指标id进行分组
+				for (OrganizationEvaluationInfoResDTO r : childCodeGropListEntry.getValue()){
+					if (r.getOptionCode().equals("LRZE") || r.getOptionCode().equals("CZ") ||  r.getOptionCode().equals("LRGXKH")|| r.getOptionCode().equals("LRGXL") || r.getOptionCode().equals("DWQWLR")) {
+						CalculateIndicatorItemInfo calculateIndicatorItemInfo = new CalculateIndicatorItemInfo();
+						calculateIndicatorItemInfo.setIndicatorId(r.getIndicatorId());
+						calculateIndicatorItemInfo.setOptionCode(r.getOptionCode());
+						calculateIndicatorItemInfo.setQuantifiedValue(r.getQuantifiedValue());
+						calculateIndicatorItemInfo.setSectionId(r.getBinSection());
+						calculateIndicatorItemInfo.setOrganizationType(organizationEvaluationResDTO.getOrganizationType());
+						calculateIndicatorItemInfo.setCheckCycle(organizationEvaluationResDTO.getCheckCycle());
+						calculateIndicatorItemInfo.setYear(organizationEvaluationResDTO.getYear());
+						calculateIndicatorItemInfo.setMonth(organizationEvaluationResDTO.getMonth());
+						calculateIndicatorItemInfo.setOrganizationEvaluationId(r.getOrganizationEvaluationId());
+						calculateIndicatorItemInfo.setChildCode(r.getChildCode());
+						list.add(calculateIndicatorItemInfo);
+					}
 				}
-				for (Map.Entry<String, List<CalculateIndicatorItemInfo>> listEntry : collect.entrySet()){
+			}
 
-					//从小到大的顺序排序
-					Collections.sort(listEntry.getValue(), new Comparator<CalculateIndicatorItemInfo>() {
-						@Override
-						public int compare(CalculateIndicatorItemInfo u1, CalculateIndicatorItemInfo u2) {
-							double diff = u1.getQuantifiedValue() - u2.getQuantifiedValue();
-							BigDecimal two = new BigDecimal(diff);
-							double three = two.setScale(2,BigDecimal.ROUND_HALF_UP).doubleValue();
-							if (three > 0) {
-								return 1;
-							} else if (three < 0) {
-								return -1;
+			int code = saveCalculate(list);
+			if(code>0) {
+
+				List<CiteCalculationIndicator> cciList = citeCalculationIndicatorService.getListLikeIndicatorIds("", "");
+				if (null != cciList && cciList.size() > 0) {
+					for (CiteCalculationIndicator cci : cciList) {
+						List<String> indicatorIds =  Arrays.asList(cci.getIndicatorIds().split(","));
+						List<CalculateIndicatorItemInfo> ciiList = calculateIndicatorItemInfoMapper.selectItemInfoByIndicatorIdList("",organizationEvaluationId,indicatorIds);
+						Map<String, List<CalculateIndicatorItemInfo>> optionCodeGropList = ciiList.stream().collect(Collectors.groupingBy(CalculateIndicatorItemInfo::getOptionCode));
+						for (Map.Entry<String, List<CalculateIndicatorItemInfo>> optionCodeGropListEntry : optionCodeGropList.entrySet()){
+
+							//从小到大的顺序排序
+							Collections.sort(optionCodeGropListEntry.getValue(), new Comparator<CalculateIndicatorItemInfo>() {
+								@Override
+								public int compare(CalculateIndicatorItemInfo u1, CalculateIndicatorItemInfo u2) {
+									double diff = u1.getQuantifiedValue() - u2.getQuantifiedValue();
+									BigDecimal two = new BigDecimal(diff);
+									double three = two.setScale(2,BigDecimal.ROUND_HALF_UP).doubleValue();
+									if (three > 0) {
+										return 1;
+									} else if (three < 0) {
+										return -1;
+									}
+									return 0; //相等为0
+								}
+							});
+
+							double value = 0.0;
+							if (optionCodeGropListEntry.getKey().endsWith("MAX")){
+								CalculateIndicatorItemInfo maxNum =  (CalculateIndicatorItemInfo)optionCodeGropListEntry.getValue().get(optionCodeGropListEntry.getValue().size()-1).clone();
+								value = maxNum.getQuantifiedValue();
+							}else if (optionCodeGropListEntry.getKey().endsWith("MIN")){
+								CalculateIndicatorItemInfo minNum  = (CalculateIndicatorItemInfo)optionCodeGropListEntry.getValue().get(0).clone();
+								value = minNum.getQuantifiedValue();
+							}else {
+								continue;
 							}
-							return 0; //相等为0
+							for(CalculateIndicatorItemInfo cii : optionCodeGropListEntry.getValue()){
+								cii.setQuantifiedValue(value);
+							}
+							calculateIndicatorItemInfoService.saveOrUpdateBatch(optionCodeGropListEntry.getValue());
 						}
-					});
-
-					CalculateIndicatorItemInfo maxNum =  (CalculateIndicatorItemInfo)listEntry.getValue().get(listEntry.getValue().size()-1).clone();
-					maxNum.setMark("1");
-
-					CalculateIndicatorItemInfo minNum  = (CalculateIndicatorItemInfo)listEntry.getValue().get(0).clone();
-
-					minNum.setMark("0");
-
-
-					if (listEntry.getKey().equals("CZ")){
-						//存储最大值
-						maxNum.setOptionCode("CZMAX");
-						minNum.setOptionCode("CZMIN");
-					}else if (listEntry.getKey().equals("LRGXL")){
-						//利润贡献
-						maxNum.setOptionCode("LRGXLMAX");
-						minNum.setOptionCode("LRGXLMIN");
-					}else if (listEntry.getKey().equals("DWQWLR")){
-						maxNum.setOptionCode("DWQWLRMAX");
-						minNum.setOptionCode("DWQWLRMIN");
-					}else if (listEntry.getKey().equals("LRGXKH")){
-						maxNum.setOptionCode("LRGXKHMAX");
-						minNum.setOptionCode("LRGXKHMIN");
-					}else if (listEntry.getKey().equals("LRZE")){
-						maxNum.setOptionCode("LRZEMAX");
-						minNum.setOptionCode("LRZEMIN");
 					}
-
-					calculateIndicatorItemInfoMapper.insert(maxNum);
-					calculateIndicatorItemInfoMapper.insert(minNum);
 				}
 			}
 
+			return code;
+		} catch (Exception e) {
+			e.printStackTrace();
+			return -1;
 		}
-		return 1;
 	}
 
 
 
 	@Transactional
-	public int saveCalculate2(List<CalculateIndicatorItemInfo> listall) throws Exception {
+	public int saveCalculate(List<CalculateIndicatorItemInfo> listall) throws Exception {
 
 		if (listall.size() > 0){
 
-			//集合是包含所有需要求最大值和最小值的对象(先使用属性分组)
-
-
-			Map<String, List<CalculateIndicatorItemInfo>> optionCodeGropList = listall.stream().collect(Collectors.groupingBy(CalculateIndicatorItemInfo::getOptionCode));
-
-			for (Map.Entry<String, List<CalculateIndicatorItemInfo>> optionCodeGropListEntry : optionCodeGropList.entrySet()){
-
-				//从小到大的顺序排序
-				Collections.sort(optionCodeGropListEntry.getValue(), new Comparator<CalculateIndicatorItemInfo>() {
-					@Override
-					public int compare(CalculateIndicatorItemInfo u1, CalculateIndicatorItemInfo u2) {
-						double diff = u1.getQuantifiedValue() - u2.getQuantifiedValue();
-						BigDecimal two = new BigDecimal(diff);
-						double three = two.setScale(2,BigDecimal.ROUND_HALF_UP).doubleValue();
-						if (three > 0) {
-							return 1;
-						} else if (three < 0) {
-							return -1;
-						}
-						return 0; //相等为0
-					}
-				});
-
-
-				CalculateIndicatorItemInfo maxNum =  (CalculateIndicatorItemInfo)optionCodeGropListEntry.getValue().get(optionCodeGropListEntry.getValue().size()-1).clone();
-				maxNum.setMark("1");
-
-				CalculateIndicatorItemInfo minNum  = (CalculateIndicatorItemInfo)optionCodeGropListEntry.getValue().get(0).clone();
-				minNum.setMark("0");
-
-
-				Map<String, List<CalculateIndicatorItemInfo>> childCodeGropList = optionCodeGropListEntry.getValue().stream().collect(Collectors.groupingBy(CalculateIndicatorItemInfo::getChildCode));
-				for (Map.Entry<String, List<CalculateIndicatorItemInfo>> childCodeGropListEntry : childCodeGropList.entrySet()){
-					String  childCode  = childCodeGropListEntry.getKey();
-
-					CalculateIndicatorItemInfo childinfo= childCodeGropListEntry.getValue().get(0);
-					//id置空
-					maxNum.setId(null);
-					minNum.setId(null);
-
-				}
-
-
-			}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-			////---------------------------------------------------------------------
 			Map<String, List<CalculateIndicatorItemInfo>> childCodeGropList = listall.stream().collect(Collectors.groupingBy(CalculateIndicatorItemInfo::getChildCode));
 			for (Map.Entry<String, List<CalculateIndicatorItemInfo>> childCodeGropListEntry : childCodeGropList.entrySet()){
 
@@ -246,7 +143,7 @@ public class CalculateIndicatorItemInfoServiceImpl extends ServiceImpl<Calculate
 				//遍历list解析最大值和最小值
 				Map<String, List<CalculateIndicatorItemInfo>> collect = list.stream().collect(Collectors.groupingBy(CalculateIndicatorItemInfo::getOptionCode));
 				//判断计算指标明细中之前是否存在记录 如果存在删除之前记录,重新新增
-				List<CalculateIndicatorItemInfo> calculateIndicatorItemInfo = calculateIndicatorItemInfoMapper.selectList("","","","","",list.get(0).getOrganizationEvaluationId(),list.get(0).getChildCode());
+				List<CalculateIndicatorItemInfo> calculateIndicatorItemInfo = calculateIndicatorItemInfoMapper.selectList("","","","",list.get(0).getIndicatorId(),list.get(0).getOrganizationEvaluationId(),list.get(0).getChildCode());
 
 				if (calculateIndicatorItemInfo.size() > 0){
 					List<String> idList = calculateIndicatorItemInfo.stream().map(CalculateIndicatorItemInfo::getId).collect(Collectors.toList());
@@ -305,4 +202,5 @@ public class CalculateIndicatorItemInfoServiceImpl extends ServiceImpl<Calculate
 		}
 		return 1;
 	}
+
 }

+ 2 - 2
ims-service/ims-eval/src/main/java/com/ims/eval/service/impl/CiteCalculationIndicatorServiceImpl.java

@@ -38,8 +38,8 @@ public class CiteCalculationIndicatorServiceImpl extends ServiceImpl<CiteCalcula
 	}
 
 	@Override
-	public List<CiteCalculationIndicator> getListLikeIndicatorIds(String indicatorIds) {
-		List<CiteCalculationIndicator> list  = baseMapper.selectListLikeIndicatorIds(indicatorIds);
+	public List<CiteCalculationIndicator> getListLikeIndicatorIds(String indicatorIds,String binSection) {
+		List<CiteCalculationIndicator> list  = baseMapper.selectListLikeIndicatorIds(indicatorIds,binSection);
 		return list;
 	}
 

+ 24 - 8
ims-service/ims-eval/src/main/java/com/ims/eval/service/impl/OrganizationEvaluationInfoServiceImpl.java

@@ -211,14 +211,12 @@ public class OrganizationEvaluationInfoServiceImpl extends ServiceImpl<Organizat
 			//根据板块分组
 			Map<String, List<OrganizationEvaluationInfoResDTO>> binSectionGropList = list.stream().collect(Collectors.groupingBy(OrganizationEvaluationInfoResDTO::getBinSection));
 
+			//计算前置属性(差值、利润贡献、单位千瓦利润)的最大最小值
 			for (Map.Entry<String, List<OrganizationEvaluationInfoResDTO>> binSectionGropEntry : binSectionGropList.entrySet()){
 
 				if (binSectionGropEntry.getValue().size() > 0){
 					//按照指标分组
 					Map<String, List<OrganizationEvaluationInfoResDTO>> indicatorGropList = binSectionGropEntry.getValue().stream().collect(Collectors.groupingBy(OrganizationEvaluationInfoResDTO::getIndicatorId));
-
-
-					//计算前置属性(差值、利润贡献、单位千瓦利润)的最大最小值
 					for (Map.Entry<String, List<OrganizationEvaluationInfoResDTO>> indicatorGropListEntry : indicatorGropList.entrySet()) {
 
 						if (indicatorGropListEntry.getValue().size() > 0) {
@@ -261,11 +259,19 @@ public class OrganizationEvaluationInfoServiceImpl extends ServiceImpl<Organizat
 							}
 						}
 						//计算差值等的最大值最小值
-						iCalculateIndicatorItemInfoService.saveIndicatorInfoDTO(indicatorGropListEntry.getValue());
+						iCalculateIndicatorItemInfoService.saveIndicatorInfoDTO( organizationEvaluationId,indicatorGropListEntry.getValue());
 					}
+				}
+			}
 
 
-					//计算前置属性(差值、利润贡献、单位千瓦利润)的最大最小值
+			//计算得分
+			for (Map.Entry<String, List<OrganizationEvaluationInfoResDTO>> binSectionGropEntry : binSectionGropList.entrySet()){
+
+				if (binSectionGropEntry.getValue().size() > 0){
+					//按照指标分组
+					Map<String, List<OrganizationEvaluationInfoResDTO>> indicatorGropList = binSectionGropEntry.getValue().stream().collect(Collectors.groupingBy(OrganizationEvaluationInfoResDTO::getIndicatorId));
+
 					for (Map.Entry<String, List<OrganizationEvaluationInfoResDTO>> indicatorGropListEntry : indicatorGropList.entrySet()){
 						for (OrganizationEvaluationInfoResDTO d : indicatorGropListEntry.getValue()){
 							System.out.println(d.getOrganizationShortName()+"|"+d.getIndicatorName()+"|"+d.getOptionName()+"|"+d.getQuantifiedValue());
@@ -287,7 +293,7 @@ public class OrganizationEvaluationInfoServiceImpl extends ServiceImpl<Organizat
 									double standardScore = 0;
 									for (Map.Entry<String, List<OrganizationEvaluationInfoResDTO>> childCodeGropListEntry : childCodeGropList.entrySet()){
 
-										List<CalculateIndicatorItemInfo> calculateIndicatorItemInfo = calculateIndicatorItemInfoMapper.selectList("","","","","",childCodeGropListEntry.getValue().get(0).getOrganizationEvaluationId(),childCodeGropListEntry.getValue().get(0).getChildCode());
+										List<CalculateIndicatorItemInfo> calculateIndicatorItemInfo = calculateIndicatorItemInfoMapper.selectList("","","","",childCodeGropListEntry.getValue().get(0).getIndicatorId(),childCodeGropListEntry.getValue().get(0).getOrganizationEvaluationId(),childCodeGropListEntry.getValue().get(0).getChildCode());
 										Map<String ,Double>  map = new HashMap<>();
 										for (CalculateIndicatorItemInfo itemInfo :calculateIndicatorItemInfo){
 											map.put(itemInfo.getOptionCode(),itemInfo.getQuantifiedValue());
@@ -304,8 +310,9 @@ public class OrganizationEvaluationInfoServiceImpl extends ServiceImpl<Organizat
 											scoreCount.setBinStage(dto.getBinStage());
 											scoreCount.setBinSection(dto.getBinSection());
 
-											for (OrganizationEvaluationInfoResDTO f : indicator){
+											for (OrganizationEvaluationInfoResDTO f : childCodeGropListEntry.getValue()){
 												if(f.getOptionCode().endsWith("MIN") || f.getOptionCode().endsWith("MAX")){
+													System.out.println("-------"+f.getOptionCode());
 													f.setQuantifiedValue(map.get(f.getOptionCode()));
 												}
 												dto.setFormula(dto.getFormula().replace("["+f.getOptionCode()+"]", f.getQuantifiedValue() + ""));
@@ -336,7 +343,7 @@ public class OrganizationEvaluationInfoServiceImpl extends ServiceImpl<Organizat
 
 									log.info("综合得分:"+totalScore);
 									if(null==scoreCount.getOrganizationEvaluationId()|| null== scoreCount.getOrganizationEvaluationRuleId() || null == scoreCount.getIndicatorId()){
-											continue;
+										continue;
 									}
 									if(standardScore>0 && totalScore != standardScore){
 										scoreCount.setStandard(totalScore>standardScore?"1":"-1");
@@ -359,6 +366,9 @@ public class OrganizationEvaluationInfoServiceImpl extends ServiceImpl<Organizat
 					}
 				}
 			}
+
+
+
 		} catch (Exception e) {
 			e.printStackTrace();
 			return false;
@@ -366,6 +376,7 @@ public class OrganizationEvaluationInfoServiceImpl extends ServiceImpl<Organizat
 		return true;
 	}
 
+
 	@Override
 	public List<Map> getEvaluationIndicatorList(String organizationEvaluationId, String binSection, String binStage, HttpServletRequest request) {
 		//判断是否是(重点专项和管理事项)
@@ -862,6 +873,7 @@ public class OrganizationEvaluationInfoServiceImpl extends ServiceImpl<Organizat
 				OrganizationEvaluationInfo info = new OrganizationEvaluationInfo();
 				info.setId(entry.getValue().toString());
 				String quantified = valueMap.get(entry.getKey().replace("ID_","IS_LH_")).toString();
+				if(null != valueMap.get(entry.getKey().replace("ID_", ""))){
 				if ("1".equals(quantified)) {
 
 					if (MathCalculatorUtil.isNumber(String.valueOf(valueMap.get(entry.getKey().replace("ID_", "")).toString()))) {
@@ -872,6 +884,10 @@ public class OrganizationEvaluationInfoServiceImpl extends ServiceImpl<Organizat
 				}
 
 				info.setNonQuantifiedValue(valueMap.get(entry.getKey().replace("ID_","")).toString());
+				}else {
+					info.setQuantifiedValue(0);
+					info.setNonQuantifiedValue("");
+				}
 				info.setState(valueMap.get("state").toString());//
 				evaluationInfos.add(info);
 			}

+ 22 - 2
ims-service/ims-eval/src/main/java/com/ims/eval/service/impl/UserServiceImpl.java

@@ -3,6 +3,8 @@ package com.ims.eval.service.impl;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.ims.common.utils.MD5Utils;
+import com.ims.common.utils.RSAUtils;
 import com.ims.common.utils.StringUtils;
 import com.ims.eval.config.CustomException;
 import com.ims.eval.config.ImaConfig;
@@ -22,7 +24,10 @@ import org.springframework.web.client.RestTemplate;
 import springfox.documentation.annotations.Cacheable;
 
 import javax.servlet.http.HttpServletRequest;
+import java.nio.charset.StandardCharsets;
+import java.util.Base64;
 import java.util.List;
+import java.util.concurrent.CompletionException;
 
 /**
  * <p>
@@ -122,14 +127,29 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, Myuser> implements
 
 
 	@Override
-	public JSONObject getbladeAuth(String tenantId, String username, String password, String grantType, String scope, String type) {
+	public JSONObject getbladeAuth(String tenantId, String username, String password, String grantType, String scope, String type) throws Exception {
 		MultiValueMap<String, String> headers = new LinkedMultiValueMap<>();
 		headers.add("Authorization", "Basic c2FiZXI6NWMwMmMzZDViNzYxNTNkZGM5ZTczYzc5YzMzNzYzODAxNmE5ZDM2Ng==");
 		headers.add("Tenant-Id", "000000");
+
+
+		// 使用后端私钥解密数据
+		byte[] pwdData = RSAUtils.decrypt(Base64.getDecoder().decode(password.replaceAll(" ", "+")), RSAUtils.getKeyPair().getPrivate());
+
+		String pwdstr = MD5Utils.md5Encrypt(new String(pwdData));
+		// 数字签名
+		byte[] signature = RSAUtils.sign(password.getBytes(), RSAUtils.getKeyPair().getPrivate());
+
+		// 验证数字签名
+		boolean isValid = RSAUtils.verify(password.getBytes(), signature, RSAUtils.getKeyPair().getPublic());
+		if(!isValid){
+			throw new CustomException("登录密码验证错误");
+		}
+
 		HttpEntity<LinkedMultiValueMap<String, Object>> param = new HttpEntity<>(null, headers);
 
 		ResponseEntity<String> responseEntity2 = restTemplate.postForEntity(imaConfig.getGatewayUrl() + "blade-auth/oauth/token?tenantId={1}&username={2}&password={3}&grant_type={4}&scope={5}&type={6}",
-			param, String.class, tenantId, username, password, grantType, scope, type);
+			param, String.class, tenantId, username, pwdstr, grantType, scope, type);
 		log.info("\n code:{}\n header:{}\n body:{}\n", responseEntity2.getStatusCodeValue(), responseEntity2.getHeaders(), responseEntity2.getBody());
 		if(200== responseEntity2.getStatusCodeValue()){
 			return JSON.parseObject(responseEntity2.getBody());

+ 29 - 2
ims-service/ims-eval/src/main/resources/mappers/CalculateIndicatorItemInfoMapper.xml

@@ -21,8 +21,8 @@
             <if test="month !=null and month !=''">
                 and a.month=#{month}
             </if>
-            <if test="binSection !=null and binSection !=''">
-                and a.section_id=#{binSection}
+            <if test="indicatorId !=null and indicatorId !=''">
+                and a.indicator_id=#{indicatorId}
             </if>
 
             <if test="organizationEvaluationId !=null and organizationEvaluationId !=''">
@@ -37,4 +37,31 @@
         </where>
     </select>
 
+
+    <select id="selectItemInfoByIndicatorIdList" resultType="com.ims.eval.entity.CalculateIndicatorItemInfo">
+        SELECT
+        *
+        FROM
+        calculate_indicator_item_info a
+        <where>
+
+            <if test="binSection !=null and binSection !=''">
+                and a.section_id=#{binSection}
+            </if>
+
+            <if test="organizationEvaluationId !=null and organizationEvaluationId !=''">
+                and a.organization_evaluation_id=#{organizationEvaluationId}
+            </if>
+
+            <if test="indicatorIds !=null">
+                AND a.indicator_id in
+                <foreach item="item" collection="indicatorIds" separator="," open="(" close=")" index="">'${item}'</foreach>
+            </if>
+
+
+
+        </where>
+
+    </select>
+
 </mapper>

+ 6 - 0
ims-service/ims-eval/src/main/resources/mappers/CiteCalculationIndicatorMapper.xml

@@ -28,7 +28,13 @@
         SELECT *
         FROM cite_calculation_indicator cci
         <where>
+            <if test="indicatorIds !=null and indicatorIds !=''">
             and cci.indicator_ids like   CONCAT('%',#{indicatorIds},'%')
+            </if>
+
+            <if test="binSection !=null and binSection !=''">
+                and cci.bin_section  = #{binSection}
+            </if>
         </where>
 
     </select>