ycl-common/src/main/java/com/ycl/utils/MD5Util.java
@@ -101,22 +101,28 @@ } public static String md5Encrypt(String string) { byte[] hash; try { //创建一个MD5算法对象,并获得MD5字节数组,16*8=128位 hash = MessageDigest.getInstance("MD5").digest(string.getBytes("UTF-8")); } catch (NoSuchAlgorithmException e) { throw new RuntimeException("Huh, MD5 should be supported?", e); } catch (UnsupportedEncodingException e) { throw new RuntimeException("Huh, UTF-8 should be supported?", e); } MessageDigest md5 = null; try { md5 = MessageDigest.getInstance("MD5"); } catch (NoSuchAlgorithmException e) { return "check jdk"; } catch (Exception e) { e.printStackTrace(); return ""; } char[] charArray = string.toCharArray(); byte[] byteArray = new byte[charArray.length]; //转换为十六进制字符串 StringBuilder hex = new StringBuilder(hash.length * 2); for (byte b : hash) { if ((b & 0xFF) < 0x10) hex.append("0"); hex.append(Integer.toHexString(b & 0xFF)); for (int i = 0; i < charArray.length; i++) byteArray[i] = (byte) charArray[i]; byte[] md5Bytes = md5.digest(byteArray); StringBuffer hexValue = new StringBuffer(); for (int i = 0; i < md5Bytes.length; i++) { int val = ((int) md5Bytes[i]) & 0xff; if (val < 16) hexValue.append("0"); hexValue.append(Integer.toHexString(val)); } return hexValue.toString(); } return hex.toString(); } } ycl-platform/src/main/java/com/ycl/controller/caseHandler/BaseCaseController.java
@@ -71,7 +71,7 @@ @ApiOperation(value = "上传市平台") @PostMapping("/upload-event") public CommonResult uploadEvent(@RequestParam Integer caseId, CommonResult<Object> success) { public CommonResult uploadEvent(@RequestParam Long caseId, CommonResult<Object> success) { String msg = baseCaseService.uploadEvent(caseId); if (StringUtils.isEmpty(msg)) { return success; ycl-platform/src/main/java/com/ycl/dto/casePool/ViolationParam.java
@@ -1,6 +1,7 @@ package com.ycl.dto.casePool; import com.baomidou.mybatisplus.annotation.TableField; import com.ycl.dto.caseHandler.DispatchInfoParam; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; @@ -10,10 +11,13 @@ @Data @ApiModel(value = "添加违规案件") public class ViolationParam { public class ViolationParam extends DispatchInfoParam { private Long baseId; @ApiModelProperty(value = "状态") private Integer state; /** * 大类 */ ycl-platform/src/main/java/com/ycl/service/caseHandler/IBaseCaseService.java
@@ -31,7 +31,7 @@ * @author AI * @date 2022-09-28 16:52 */ String uploadEvent(Integer caseId); String uploadEvent(Long caseId); Page listViolationsPage(Page page, Integer state, Integer resource); ycl-platform/src/main/java/com/ycl/service/caseHandler/impl/BaseCaseServiceImpl.java
@@ -11,6 +11,8 @@ import com.ycl.controller.video.common.constant.BaseCaseStatus; import com.ycl.controller.video.common.constant.StepName; import com.ycl.controller.video.common.util.DateUtil; import com.ycl.controller.video.common.util.UtilNumber; import com.ycl.dto.caseHandler.DispatchInfoParam; import com.ycl.dto.caseHandler.QueryForViolationParam; import com.ycl.dto.casePool.IllegalBuildingParam; import com.ycl.dto.casePool.ViolationParam; @@ -25,6 +27,7 @@ import com.ycl.remote.dto.*; import com.ycl.remote.service.CityPlatformService; import com.ycl.service.caseHandler.IBaseCaseService; import com.ycl.service.caseHandler.IDispatchHandleService; import com.ycl.service.caseHandler.IViolationsService; import com.ycl.service.video.IVideoAlarmReportService; import com.ycl.vo.casePool.*; @@ -58,6 +61,7 @@ private CityPlatformService cityPlatformService; private IViolationsService violationsService; private IVideoAlarmReportService videoAlarmReportService; @Value("${fdfs.fileUrl}") private String fileUrl; @@ -106,9 +110,18 @@ @Resource PartyInfoMapper partyInfoMapper; @Resource UtilNumber utilNumber; @Resource IDispatchHandleService iDispatchHandleService; @Resource IBaseCaseService baseCaseService; @Override public String uploadEvent(Integer caseId) { public String uploadEvent(Long caseId) { BaseCase baseCase = this.getById(caseId); Violations violations = violationsService.getById(caseId); String medias = ""; @@ -389,7 +402,7 @@ @Override public List<QueryForViolationVO> selectViolationList(QueryForViolationParam queryForViolationParam) { return baseCaseMapper.selectViolationPage(queryForViolationParam); return baseCaseMapper.selectViolationPage(queryForViolationParam); } @Override @@ -411,10 +424,22 @@ BaseCase baseCase = new BaseCase(); BeanUtils.copyProperties(violationParam, baseCase); baseCase.setId(violationParam.getBaseId()); baseCase.setCode(utilNumber.createCaseCode()); baseCaseMapper.updateById(baseCase); Violations violations = new Violations(); BeanUtils.copyProperties(violationParam, violations); violations.setId(violations.getId()); return violationsMapper.updateById(violations) == 1 ? true : false; if (violationParam.getState() == 6) { AdminUserDetails user = (AdminUserDetails) SecurityContextHolder.getContext().getAuthentication().getPrincipal(); violationParam.setCreateUser(user.getUserId()); DispatchInfoParam dispatchInfoParam = new DispatchInfoParam(); BeanUtils.copyProperties(violationParam, dispatchInfoParam); dispatchInfoParam.setBaseCaseId(violationParam.getBaseId()); iDispatchHandleService.dispatch(dispatchInfoParam); } if (violationParam.getState() == 2) { baseCaseService.uploadEvent(violationParam.getBaseId()); } return violationsMapper.insert(violations) == 1 ? true : false; } } ycl-platform/src/test/java/com/ycl/sccgplatform/SccgPlatformApplicationTests.java
@@ -4,12 +4,11 @@ import com.ycl.enums.common.DictTypeEnum; import com.ycl.service.caseHandler.IBaseCaseService; import com.ycl.utils.MD5Util; import org.apache.commons.codec.digest.Md5Crypt; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; import java.util.Map; @SpringBootTest @@ -36,14 +35,23 @@ @Test void createCode() { // LocalDateTime parse = LocalDateTime.parse("2017-02-02 08:59:12", DateTimeFormatter.ofPattern("yyyy-MM-dd hh:mm:ss")); LocalDateTime ldt = LocalDateTime.parse("2017-02-02 08:44:12", DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")); System.out.println( MD5Util.md5Encrypt32Lower("123456")); String randomKey ="f83bf56491350983146a1e463f46e59d_7312712453128192"; String realm = "D62D265605378973"; String userName = "suichang"; /// 用户名 String password = "a12345677"; /// 该用户的明文密码 /// 一共计算五次MD5 String signature = MD5Util.md5Encrypt(password); signature = MD5Util.md5Encrypt(userName+signature); signature = MD5Util.md5Encrypt(signature); signature = MD5Util.md5Encrypt(userName+":"+realm+":"+signature); signature = MD5Util.md5Encrypt(signature+":"+randomKey); System.out.println(signature); } @Test void enumMapTest(){ Map<String,String> s =DictTypeEnum.getAllToMap(); void enumMapTest() { Map<String, String> s = DictTypeEnum.getAllToMap(); } }