From b8b04f286d0b9c503fddeab4a549a2baccb872fb Mon Sep 17 00:00:00 2001 From: bobol Date: Thu, 28 Dec 2023 18:50:11 +0800 Subject: [PATCH] =?UTF-8?q?1=E3=80=81=E7=9B=91=E6=8E=A7=E9=A1=B5=E9=9D=A2?= =?UTF-8?q?=E6=89=80=E9=9C=8040=E7=9A=84=E6=8E=A5=E5=8F=A3=E8=BF=81?= =?UTF-8?q?=E7=A7=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/lzbi/common/utils/MD5Utils.java | 46 ------ .../lzbi/framework/config/SecurityConfig.java | 2 +- .../bi/controller/DCVedioScreenControler.java | 56 +++++--- ...DcBusiTargetAdjustDayMasterController.java | 17 --- .../DcBusiTargetAdjustDayMasterService.java | 136 ++++++------------ 5 files changed, 79 insertions(+), 178 deletions(-) delete mode 100644 lzbi-common/src/main/java/com/lzbi/common/utils/MD5Utils.java diff --git a/lzbi-common/src/main/java/com/lzbi/common/utils/MD5Utils.java b/lzbi-common/src/main/java/com/lzbi/common/utils/MD5Utils.java deleted file mode 100644 index e98cfae..0000000 --- a/lzbi-common/src/main/java/com/lzbi/common/utils/MD5Utils.java +++ /dev/null @@ -1,46 +0,0 @@ -package com.lzbi.common.utils; - -import java.security.MessageDigest; -import java.security.NoSuchAlgorithmException; -/** - * 南宫乘风 - */ -public class MD5Utils { - /** - * MD5加密类 - * @param str 要加密的字符串 - * @return 加密后的字符串 - */ - public static String code(String str){ - try { - MessageDigest md = MessageDigest.getInstance("MD5"); - md.update(str.getBytes()); - byte[]byteDigest = md.digest(); - int i; - StringBuffer buf = new StringBuffer(""); - for (int offset = 0; offset < byteDigest.length; offset++) { - i = byteDigest[offset]; - if (i < 0) - i += 256; - if (i < 16) - buf.append("0"); - buf.append(Integer.toHexString(i)); - } - //32位加密 - return buf.toString(); - // 16位的加密 - //return buf.toString().substring(8, 24); - } catch (NoSuchAlgorithmException e) { - e.printStackTrace(); - return null; - } - } - - /** - * 测试方法 - * @param args - */ - public static void main(String[] args) { - System.out.println(code("lmLz@2019")); - } -} \ No newline at end of file diff --git a/lzbi-framework/src/main/java/com/lzbi/framework/config/SecurityConfig.java b/lzbi-framework/src/main/java/com/lzbi/framework/config/SecurityConfig.java index 24b46b8..281cdb3 100644 --- a/lzbi-framework/src/main/java/com/lzbi/framework/config/SecurityConfig.java +++ b/lzbi-framework/src/main/java/com/lzbi/framework/config/SecurityConfig.java @@ -111,7 +111,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter // 过滤请求 .authorizeRequests() // 对于登录login 注册register 验证码captchaImage 允许匿名访问 - .antMatchers("/login", "/register", "/captchaImage","/assetData/**","/magic/api/**", "/report/**").permitAll() + .antMatchers("/login", "/register", "/captchaImage","/assetData/**","/magic/api/**", "/report/**", "/api/v1/**").permitAll() // 静态资源,可匿名访问 .antMatchers(HttpMethod.GET, "/", "/*.html", "/**/*.html", "/**/*.css", "/**/*.js", "/profile/**").permitAll() .antMatchers( "/swagger-resources/**", "/webjars/**", "/*/api-docs", "/druid/**").permitAll() diff --git a/lzbi-module/src/main/java/com/lzbi/bi/controller/DCVedioScreenControler.java b/lzbi-module/src/main/java/com/lzbi/bi/controller/DCVedioScreenControler.java index 9cfe4d7..9132ba2 100644 --- a/lzbi-module/src/main/java/com/lzbi/bi/controller/DCVedioScreenControler.java +++ b/lzbi-module/src/main/java/com/lzbi/bi/controller/DCVedioScreenControler.java @@ -2,11 +2,13 @@ package com.lzbi.bi.controller; import com.alibaba.fastjson2.JSONObject; import com.lzbi.common.config.VideoConfig; +import com.lzbi.common.constant.Constants; import com.lzbi.common.core.controller.BaseController; import com.lzbi.common.core.domain.AjaxResult; import com.lzbi.common.core.redis.RedisCache; import com.lzbi.common.utils.SecurityUtils; import com.lzbi.common.utils.StringUtils; +import com.lzbi.framework.web.service.SysLoginService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParams; @@ -48,29 +50,34 @@ public class DCVedioScreenControler extends BaseController { @Autowired private VideoConfig videoConfig; - //String md532Upper=md532Lower.toUpperCase(); - //16位,小写 - //String md516Lower =md532Lower.substring(8, 24); - //16位,大写 - //String md516Upper=md532Lower.substring(8, 24).toUpperCase(); + @Autowired + private SysLoginService loginService; + @ApiOperation("根据用户对照信息并获取视频的用户登录token") + @ApiImplicitParams({ + @ApiImplicitParam(name = "username", value = "用户名", dataType = "String", dataTypeClass = String.class, required = true), + @ApiImplicitParam(name = "password", value = "密码(经过md5加密,32位长度,不带中划线,不区分大小写)", dataType = "String", dataTypeClass = String.class, required = true) + }) @GetMapping("/login") - public AjaxResult getToken2() { - return AjaxResult.success(getToken()); + public AjaxResult getToken(@RequestParam(value = "username") String username, + @RequestParam(value = "password") String password) { + // 生成令牌 + String token = loginService.login(username, password, null, null); + this.getToken(username); + return AjaxResult.success("操作成功", token); } - private String getToken() { - String userName = SecurityUtils.getUsername(); + public String getToken(String userName) { String token = redisCache.getCacheObject("video:" + userName); //没有tokean需要重新获取 if (StringUtils.isEmpty(token)) { - String vedio_userName = "easycvr"; - String vedio_password = "lmLz@2019"; // - //根据平台用户名查询 对应的监控用户名和密码,如果不需要则默认给出easycvr lmlz@2019 - String passwordMd532 = DigestUtils.md5DigestAsHex(vedio_password.getBytes()); + String username = "easycvr"; + String password = "lmLz@2019"; + password = DigestUtils.md5DigestAsHex(password.getBytes()); + //根据平台用户名查询 对应的监控用户名和密码,如果不需要则默认给出easycvr lmLz@2019 Map query = new HashMap<>(); - query.put("username", vedio_userName); - query.put("password", passwordMd532); + query.put("username", username); + query.put("password", password); JSONObject resp = restTemplate.getForObject(videoConfig.getLogin(), JSONObject.class, query); log.info("登录请求结果:{}", resp); if (null != resp) { @@ -79,7 +86,7 @@ public class DCVedioScreenControler extends BaseController { token = body.getString("Token"); redisCache.setCacheObject("video:" + userName, token, 1, TimeUnit.DAYS); } - log.info("token:{}", token); + log.info("视频服务 token:{}", token); } } return token; @@ -99,7 +106,8 @@ public class DCVedioScreenControler extends BaseController { @RequestParam(value = "limit") Integer limit, @RequestParam(value = "protocol_type", required = false) String protocol_type, @RequestParam(value = "q", required = false) String q) { - String token = getToken(); + String userName = SecurityUtils.getUsername(); + String token = getToken(userName); HttpHeaders headers = new HttpHeaders(); headers.set("Token", token); HttpEntity entity = new HttpEntity<>(headers); @@ -130,7 +138,8 @@ public class DCVedioScreenControler extends BaseController { @RequestParam(value = "start") Integer start, @RequestParam(value = "limit") Integer limit, @RequestParam(value = "q", required = false) String q) { - String token = getToken(); + String userName = SecurityUtils.getUsername(); + String token = getToken(userName); HttpHeaders headers = new HttpHeaders(); headers.set("Token", token); HttpEntity entity = new HttpEntity<>(headers); @@ -158,11 +167,12 @@ public class DCVedioScreenControler extends BaseController { }) @GetMapping("/devices/channelstream") public AjaxResult getChannelStream(@RequestParam(value = "device") Integer device, - @RequestParam(value = "channel") Integer channel, - @RequestParam(value = "protocol") String protocol, - @RequestParam(value = "Token", required = false) String Token, - @RequestParam(value = "type", required = false) String type) { - String token = getToken(); + @RequestParam(value = "channel") Integer channel, + @RequestParam(value = "protocol") String protocol, + @RequestParam(value = "Token", required = false) String Token, + @RequestParam(value = "type", required = false) String type) { + String userName = SecurityUtils.getUsername(); + String token = getToken(userName); HttpHeaders headers = new HttpHeaders(); headers.set("Token", token); HttpEntity entity = new HttpEntity<>(headers); diff --git a/lzbi-module/src/main/java/com/lzbi/draft/controller/DcBusiTargetAdjustDayMasterController.java b/lzbi-module/src/main/java/com/lzbi/draft/controller/DcBusiTargetAdjustDayMasterController.java index a06c36d..dc874cb 100644 --- a/lzbi-module/src/main/java/com/lzbi/draft/controller/DcBusiTargetAdjustDayMasterController.java +++ b/lzbi-module/src/main/java/com/lzbi/draft/controller/DcBusiTargetAdjustDayMasterController.java @@ -126,23 +126,6 @@ public class DcBusiTargetAdjustDayMasterController extends BaseController return toAjax(dcBusiTargetAdjustDayMasterService.audit(id)); } - /** - * 处理资产指标调整单主(日) - */ - @ApiOperation("处理资产指标调整单") - @ApiImplicitParam(name = "id", value = "id", dataType = "Long", dataTypeClass = Long.class, paramType = "path", required = true) - @PreAuthorize("@ss.hasPermi('asset:targetDayAdjustBill:dispose')") - @Log(title = "资产指标调整单主(日)", businessType = BusinessType.OTHER) - @PostMapping("/dispose/{id}") - public AjaxResult dispose(@PathVariable("id") Long id) - { - try{ - return toAjax(dcBusiTargetAdjustDayMasterService.dispose(id)); - } catch (RuntimeException e) { - return error(e.getMessage()); - } - } - @ApiOperation("驳回") @PreAuthorize("@ss.hasPermi('bill:dayPlanBill:check')") @ApiImplicitParams({ diff --git a/lzbi-module/src/main/java/com/lzbi/draft/service/DcBusiTargetAdjustDayMasterService.java b/lzbi-module/src/main/java/com/lzbi/draft/service/DcBusiTargetAdjustDayMasterService.java index 757ee75..bac2c03 100644 --- a/lzbi-module/src/main/java/com/lzbi/draft/service/DcBusiTargetAdjustDayMasterService.java +++ b/lzbi-module/src/main/java/com/lzbi/draft/service/DcBusiTargetAdjustDayMasterService.java @@ -4,19 +4,22 @@ import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.lzbi.asset.domain.DcBaseAssetInfo; import com.lzbi.asset.mapper.DcBaseAssetInfoMapper; -import com.lzbi.draft.mapper.DcBusiTargetDraftDaynewMapper; import com.lzbi.common.core.domain.entity.SysDept; import com.lzbi.common.utils.DateUtils; import com.lzbi.common.utils.SecurityUtils; import com.lzbi.draft.domain.DcBusiTargetAdjustDayMasterDao; import com.lzbi.draft.domain.DcBusiTargetAdjustDaySubDao; +import com.lzbi.draft.domain.DcBusiTargetDraftDaynew; import com.lzbi.draft.domain.DcBusiTargetDraftMonth; import com.lzbi.draft.mapper.DcBusiTargetAdjustDayMasterMapper; import com.lzbi.draft.mapper.DcBusiTargetAdjustDaySubMapper; +import com.lzbi.draft.mapper.DcBusiTargetDraftDaynewMapper; import com.lzbi.draft.mapper.DcBusiTargetDraftMonthMapper; import com.lzbi.special.domain.DcBaseWorkSpecial; import com.lzbi.special.mapper.DcBaseWorkSpecialMapper; import com.lzbi.system.service.impl.SysDeptServiceImpl; +import com.lzbi.targetFolder.domain.DcBaseAssetTarget; +import com.lzbi.targetFolder.mapper.DcBaseAssetTargetMapper; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.ObjectUtils; import org.springframework.beans.factory.annotation.Autowired; @@ -61,6 +64,9 @@ public class DcBusiTargetAdjustDayMasterService extends ServiceImpl dcBusiTargetAdjustDaySubDaoList = dcBusiTargetAdjustDaySubMapper.selectDcBusiTargetAdjustDaySubDaoList(params); - // 遍历子表集合,向指标数据底稿表(日)中同步数据 - for (DcBusiTargetAdjustDaySubDao dcBusiTargetAdjustDaySubDao : dcBusiTargetAdjustDaySubDaoList) { - DcBusiTargetDraftMonth dcBusiTargetDraftMonth = new DcBusiTargetDraftMonth(); - dcBusiTargetDraftMonth.setCompanyId(dcBusiTargetAdjustDayMasterDao.getCompanyId()); - dcBusiTargetDraftMonth.setOrgId(dcBusiTargetAdjustDayMasterDao.getOragnizeId()); - dcBusiTargetDraftMonth.setAssetCode(dcBusiTargetAdjustDayMasterDao.getAssetCode()); - dcBusiTargetDraftMonth.setFieldCode(dcBusiTargetAdjustDayMasterDao.getFieldCode()); - dcBusiTargetDraftMonth.setTargetCode(dcBusiTargetAdjustDaySubDao.getTargetCode()); - List dcBusiTargetDraftMonthList = dcBusiTargetDraftMonthMapper.selectDcBusiTargetDraftMonthList(dcBusiTargetDraftMonth); - // 如果未查询出来指标数据底稿数据,就新增,否则修改 - if (CollectionUtils.isEmpty(dcBusiTargetDraftMonthList)) { - dcBusiTargetDraftMonth.setCompanyName(dcBusiTargetAdjustDayMasterDao.getCompanyName()); - dcBusiTargetDraftMonth.setOrgName(dcBusiTargetAdjustDayMasterDao.getOrganizeName()); - dcBusiTargetDraftMonth.setAssetName(dcBusiTargetAdjustDayMasterDao.getAssetName()); - dcBusiTargetDraftMonth.setFieldName(dcBusiTargetAdjustDayMasterDao.getFieldName()); - dcBusiTargetDraftMonth.setTargetName(dcBusiTargetAdjustDaySubDao.getTargetName()); - dcBusiTargetDraftMonth.setTargetUint(dcBusiTargetAdjustDaySubDao.getTagetUnit()); - dcBusiTargetDraftMonth.setCountDate(dcBusiTargetAdjustDayMasterDao.getDateAdjust()); - dcBusiTargetDraftMonth.setValOriginal(dcBusiTargetAdjustDaySubDao.getValOrigin()); - dcBusiTargetDraftMonth.setValAdjust(dcBusiTargetAdjustDaySubDao.getValAdjust()); - dcBusiTargetDraftMonth.setValResult(dcBusiTargetAdjustDaySubDao.getValResult()); - dcBusiTargetDraftMonthMapper.insertDcBusiTargetDraftMonth(dcBusiTargetDraftMonth); - } else { - dcBusiTargetDraftMonth = dcBusiTargetDraftMonthList.get(0); - BigDecimal valResult = dcBusiTargetDraftMonth.getValResult().add(new BigDecimal(0)); - dcBusiTargetDraftMonth.setValOriginal(valResult); - dcBusiTargetDraftMonth.setValAdjust(dcBusiTargetAdjustDaySubDao.getValAdjust()); - dcBusiTargetDraftMonth.setValResult(valResult.add(dcBusiTargetAdjustDaySubDao.getValAdjust())); - dcBusiTargetDraftMonthMapper.updateDcBusiTargetDraftMonth(dcBusiTargetDraftMonth); - } - } - // 修改审核状态为已处理 - dcBusiTargetAdjustDayMasterDao.setCheckStatus("2"); - return baseMapper.updateDcBusiTargetAdjustDayMasterDao(dcBusiTargetAdjustDayMasterDao); - } catch (RuntimeException e) { - log.error("处理异常", e); - throw e; - } finally { - lock.unlock(); - } - } - public int checkBack(String billNo) { DcBusiTargetAdjustDayMasterDao master = baseMapper.selectDcBusiTargetAdjustDayMasterDaoByBillNo(billNo); master.setUpdatedBy(SecurityUtils.getUsername()); @@ -302,43 +244,55 @@ public class DcBusiTargetAdjustDayMasterService extends ServiceImpl dcBusiTargetAdjustDaySubDaoList = dcBusiTargetAdjustDaySubMapper.selectDcBusiTargetAdjustDaySubDaoList(params); - DcBusiTargetDraftMonth dcBusiTargetDraftMonth; + DcBusiTargetDraftDaynew dcBusiTargetDraftDaynew; // 遍历子表集合,向指标数据底稿表(日)中同步数据 for (DcBusiTargetAdjustDaySubDao dcBusiTargetAdjustDaySubDao : dcBusiTargetAdjustDaySubDaoList) { - dcBusiTargetDraftMonth = new DcBusiTargetDraftMonth(); - dcBusiTargetDraftMonth.setCompanyId(dcBusiTargetAdjustDayMasterDao.getCompanyId()); - dcBusiTargetDraftMonth.setOrgId(dcBusiTargetAdjustDayMasterDao.getOragnizeId()); - dcBusiTargetDraftMonth.setAssetCode(dcBusiTargetAdjustDayMasterDao.getAssetCode()); - dcBusiTargetDraftMonth.setFieldCode(dcBusiTargetAdjustDayMasterDao.getFieldCode()); - dcBusiTargetDraftMonth.setTargetCode(dcBusiTargetAdjustDaySubDao.getTargetCode()); - List dcBusiTargetDraftMonthList = dcBusiTargetDraftMonthMapper.selectDcBusiTargetDraftMonthList(dcBusiTargetDraftMonth); + dcBusiTargetDraftDaynew = new DcBusiTargetDraftDaynew(); + dcBusiTargetDraftDaynew.setCompanyId(dcBusiTargetAdjustDayMasterDao.getCompanyId()); + dcBusiTargetDraftDaynew.setOrganizeId(dcBusiTargetAdjustDayMasterDao.getOragnizeId()); + dcBusiTargetDraftDaynew.setAssetCode(dcBusiTargetAdjustDayMasterDao.getAssetCode()); + dcBusiTargetDraftDaynew.setFieldCode(dcBusiTargetAdjustDayMasterDao.getFieldCode()); + dcBusiTargetDraftDaynew.setTargetCode(dcBusiTargetAdjustDaySubDao.getTargetCode()); + dcBusiTargetDraftDaynew.setDateYear(year); + dcBusiTargetDraftDaynew.setDateMonth(month); + dcBusiTargetDraftDaynew.setDateDay(day); + List dcBusiTargetDraftDaynewList = dcBusiTargetDraftDaynewMapper.selectDcBusiTargetDraftDaynewList(dcBusiTargetDraftDaynew); // 如果未查询出来指标数据底稿数据,就新增,否则修改 - if (CollectionUtils.isEmpty(dcBusiTargetDraftMonthList)) { - dcBusiTargetDraftMonth.setCompanyName(dcBusiTargetAdjustDayMasterDao.getCompanyName()); - dcBusiTargetDraftMonth.setOrgName(dcBusiTargetAdjustDayMasterDao.getOrganizeName()); - dcBusiTargetDraftMonth.setAssetName(dcBusiTargetAdjustDayMasterDao.getAssetName()); - dcBusiTargetDraftMonth.setFieldName(dcBusiTargetAdjustDayMasterDao.getFieldName()); - dcBusiTargetDraftMonth.setTargetName(dcBusiTargetAdjustDaySubDao.getTargetName()); - dcBusiTargetDraftMonth.setTargetUint(dcBusiTargetAdjustDaySubDao.getTagetUnit()); - dcBusiTargetDraftMonth.setCountDate(dcBusiTargetAdjustDayMasterDao.getDateAdjust()); - dcBusiTargetDraftMonth.setValOriginal(dcBusiTargetAdjustDaySubDao.getValOrigin()); - dcBusiTargetDraftMonth.setValAdjust(dcBusiTargetAdjustDaySubDao.getValAdjust()); - dcBusiTargetDraftMonth.setValResult(dcBusiTargetAdjustDaySubDao.getValResult()); - dcBusiTargetDraftMonthMapper.insertDcBusiTargetDraftMonth(dcBusiTargetDraftMonth); + if (CollectionUtils.isEmpty(dcBusiTargetDraftDaynewList)) { + dcBusiTargetDraftDaynew.setCompanyName(dcBusiTargetAdjustDayMasterDao.getCompanyName()); + dcBusiTargetDraftDaynew.setOrganizeName(dcBusiTargetAdjustDayMasterDao.getOrganizeName()); + dcBusiTargetDraftDaynew.setAssetName(dcBusiTargetAdjustDayMasterDao.getAssetName()); + dcBusiTargetDraftDaynew.setFieldName(dcBusiTargetAdjustDayMasterDao.getFieldName()); + dcBusiTargetDraftDaynew.setTagetName(dcBusiTargetAdjustDaySubDao.getTargetName()); + dcBusiTargetDraftDaynew.setValueOriginal(dcBusiTargetAdjustDaySubDao.getValOrigin()); + dcBusiTargetDraftDaynew.setValueAdjust(dcBusiTargetAdjustDaySubDao.getValAdjust()); + dcBusiTargetDraftDaynew.setValueResult(dcBusiTargetAdjustDaySubDao.getValResult()); + DcBaseAssetTarget dcBaseAssetTarget = dcBaseAssetTargetMapper.selectDcBaseAssetTargetByTargetCodeAndAssetCode(dcBusiTargetAdjustDaySubDao.getTargetCode(), dcBusiTargetAdjustDayMasterDao.getAssetCode()); + if (ObjectUtils.isNotEmpty(dcBaseAssetTarget)) { + dcBusiTargetDraftDaynew.setTargetModelCode(dcBaseAssetTarget.getTargetModelCode()); + } + dcBusiTargetDraftDaynewMapper.insertDcBusiTargetDraftDaynew(dcBusiTargetDraftDaynew); } else { - dcBusiTargetDraftMonth = dcBusiTargetDraftMonthList.get(0); - BigDecimal valResult = dcBusiTargetDraftMonth.getValResult().add(new BigDecimal(0)); - dcBusiTargetDraftMonth.setValOriginal(valResult); - dcBusiTargetDraftMonth.setValAdjust(dcBusiTargetAdjustDaySubDao.getValAdjust()); - dcBusiTargetDraftMonth.setValResult(valResult.add(dcBusiTargetAdjustDaySubDao.getValAdjust())); - dcBusiTargetDraftMonthMapper.updateDcBusiTargetDraftMonth(dcBusiTargetDraftMonth); + dcBusiTargetDraftDaynew = dcBusiTargetDraftDaynewList.get(0); + BigDecimal valResult = dcBusiTargetDraftDaynew.getValueResult().add(new BigDecimal(0)); + dcBusiTargetDraftDaynew.setValueOriginal(valResult); + dcBusiTargetDraftDaynew.setValueAdjust(dcBusiTargetAdjustDaySubDao.getValAdjust()); + dcBusiTargetDraftDaynew.setValueResult(valResult.add(dcBusiTargetAdjustDaySubDao.getValAdjust())); + dcBusiTargetDraftDaynewMapper.updateDcBusiTargetDraftDaynew(dcBusiTargetDraftDaynew); } } // 修改审核状态为已处理