Browse Source

1、监控页面所需40的接口迁移

develop
bobol 11 months ago
parent
commit
b8b04f286d
  1. 46
      lzbi-common/src/main/java/com/lzbi/common/utils/MD5Utils.java
  2. 2
      lzbi-framework/src/main/java/com/lzbi/framework/config/SecurityConfig.java
  3. 56
      lzbi-module/src/main/java/com/lzbi/bi/controller/DCVedioScreenControler.java
  4. 17
      lzbi-module/src/main/java/com/lzbi/draft/controller/DcBusiTargetAdjustDayMasterController.java
  5. 136
      lzbi-module/src/main/java/com/lzbi/draft/service/DcBusiTargetAdjustDayMasterService.java

46
lzbi-common/src/main/java/com/lzbi/common/utils/MD5Utils.java

@ -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"));
}
}

2
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()

56
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<String, Object> 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);

17
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({

136
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<DcBusiTarget
@Resource
private DcBusiTargetDraftDaynewMapper dcBusiTargetDraftDaynewMapper;
@Resource
private DcBaseAssetTargetMapper dcBaseAssetTargetMapper;
private static final Lock lock = new ReentrantLock();
/**
@ -216,70 +222,6 @@ public class DcBusiTargetAdjustDayMasterService extends ServiceImpl<DcBusiTarget
return baseMapper.updateDcBusiTargetAdjustDayMasterDao(dcBusiTargetAdjustDayMasterDao);
}
/**
* 审核资产指标调整单
*
* @param id
* @return
*/
@Transactional(rollbackFor = Exception.class)
public int dispose(Long id) throws RuntimeException {
lock.lock();
try {
// 查询审核资产指标调整单主表数据
DcBusiTargetAdjustDayMasterDao dcBusiTargetAdjustDayMasterDao = baseMapper.selectDcBusiTargetAdjustDayMasterDaoById(id);
if ("0".equals(dcBusiTargetAdjustDayMasterDao.getCheckStatus())) {
throw new RuntimeException("审核失败,单据未提交");
}
if ("2".equals(dcBusiTargetAdjustDayMasterDao.getCheckStatus())) {
throw new RuntimeException("审核失败,单据已审核");
}
// 查询审核资产指标调整单子表集合
DcBusiTargetAdjustDaySubDao params = new DcBusiTargetAdjustDaySubDao();
params.setBillNoMaster(dcBusiTargetAdjustDayMasterDao.getBillSerial());
List<DcBusiTargetAdjustDaySubDao> 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<DcBusiTargetDraftMonth> 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<DcBusiTarget
}
String dateAdjust = dcBusiTargetAdjustDayMasterDao.getDateAdjust();
String[] dataStrArr = dateAdjust.split("-");
String year = null;
String month = null;
String day = null;
if (dataStrArr.length == 3) {
year = dataStrArr[0];
month = dataStrArr[1];
day = dataStrArr[2];
} else {
throw new RuntimeException("调整目标日期有误");
}
// 查询审核资产指标调整单子表集合
DcBusiTargetAdjustDaySubDao params = new DcBusiTargetAdjustDaySubDao();
params.setBillNoMaster(dcBusiTargetAdjustDayMasterDao.getBillSerial());
List<DcBusiTargetAdjustDaySubDao> 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<DcBusiTargetDraftMonth> 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<DcBusiTargetDraftDaynew> 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);
}
}
// 修改审核状态为已处理

Loading…
Cancel
Save