Commit 8d71de82 by fukai

Merge remote-tracking branch 'origin/develop' into develop

parents 9d098bb5 53d36940
......@@ -40,7 +40,7 @@ public class BopCalPilotController {
@Autowired
private BchService bchService;
@PostMapping("/bopcalcom/pilotbopbch")
@PostMapping("/pilotbopbch")
public ResponseSet<String> bopPilotBch(@RequestBody Map<String, String> params) {
try {
settleContext.simpleLoadSettleSession();
......
package com.brilliance.isc.common.lock.impl;
import org.slf4j.LoggerFactory;
import org.slf4j.Logger;
import com.brilliance.isc.bo.Lck;
import com.brilliance.isc.bo.Stb;
import com.brilliance.isc.common.lock.LockInfo;
import com.brilliance.isc.mda.dao.StbMapper;
import com.brilliance.isc.vo.manager.StbVo;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Service;
......@@ -31,63 +32,62 @@ public class DBLckBizLocker extends AbstractBizLocker {
private final String DBLOCKER = "DBLOCK";
private boolean getSwitchFlag(){
private boolean getSwitchFlag() {
StbVo stbVo = new StbVo();
stbVo.setTbl(DBLOCKER);
List<Stb> stbs = stbMapper.queryByPage(stbVo);
if(stbs == null || stbs.size() == 0){
if (stbs == null || stbs.size() == 0) {
return false;
}
return "Y".equals(stbs.get(0).getCod()) ? true : false;
}
/**
* @param key 为业务主键,使用LockInfo的方法生成key
* @param value 为业务锁定信息,一般为交易码+操作人,使用LockInfo的方法生成value
* @param key 为业务主键,使用LockInfo的方法生成key
* @param value 为业务锁定信息,一般为交易码+操作人,使用LockInfo的方法生成value
* @param seconds 锁定时间,db模式下无效
* @return
*/
@Transactional(propagation = Propagation.REQUIRES_NEW,rollbackFor = Exception.class)
public boolean lock(String key,String value, long seconds) {
if(!getSwitchFlag()){
@Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Exception.class)
public boolean lock(String key, String value, long seconds) {
if (!getSwitchFlag()) {
logger.info("锁定函数暂时关闭");
return true;
}
LockInfo lockInfo = new LockInfo(key,value);
boolean isSuccess = lckComponent.tryInsert(lockInfo);
LockInfo lockInfo = new LockInfo(key, value);
boolean isSuccess = lckComponent.tryInsert(lockInfo);
// 插入成功,新增
if (isSuccess) {
logger.info("锁key:{},value:{},结果:成功",key,value);
logger.info("锁key:{},value:{},结果:成功", key, value);
return true;
}
lockInfo = getLock(lockInfo);
String oldValue = lockInfo.genLockValue();
// 相同时,刷新时间
if (oldValue.equals(value)) {
if(value.endsWith("#true")) {
logger.info("锁已重入key:{},value:{}",key,value);
if (value.endsWith("#true")) {
logger.info("锁已重入key:{},value:{}", key, value);
isSuccess = true;
}else{
logger.info("锁无法重入key:{},value:{}",key,value);
} else {
logger.info("锁无法重入key:{},value:{}", key, value);
}
}
return isSuccess;
}
@Override
public LockInfo getLock(LockInfo lockInfo) {
if(!getSwitchFlag()){
if (!getSwitchFlag()) {
logger.info("锁定函数暂时关闭");
return null;
}
String key = lockInfo.genLockKey();
LockInfo dbLockInfo = lckComponent.getLck(lockInfo);
if(dbLockInfo != null){
if (dbLockInfo != null) {
String value = dbLockInfo.genLockValue();
logger.info("返回锁信息key:{},value:{}",key,value);
logger.info("返回锁信息key:{},value:{}", key, value);
return dbLockInfo;
}
return null;
......@@ -96,37 +96,36 @@ public class DBLckBizLocker extends AbstractBizLocker {
@Override
public boolean unlock(LockInfo lockInfo) {
if(!getSwitchFlag()){
if (!getSwitchFlag()) {
logger.info("锁定函数暂时关闭");
return true;
}
String key = lockInfo.genLockKey();
LockInfo oldLockInfo = getLock(lockInfo);
if(oldLockInfo != null){
logger.info("返回锁信息key:{},value:{}",key,oldLockInfo.genLockValue());
if(oldLockInfo.getUsrId().equals(lockInfo.getUsrId())){
logger.info("删除锁{}",key);
if (oldLockInfo != null) {
logger.info("返回锁信息key:{},value:{}", key, oldLockInfo.genLockValue());
if (oldLockInfo.getUsrId().equals(lockInfo.getUsrId())) {
logger.info("删除锁{}", key);
int cnt = lckComponent.deleteLck(oldLockInfo);
logger.info("删除锁成功{},影响行数{}",key,cnt);
logger.info("删除锁成功{},影响行数{}", key, cnt);
return true;
}else{
logger.info("{}锁定人不一致,不允许删除,oldUserId:{},curUserId{},",key,oldLockInfo.getUsrId(),lockInfo.getUsrId());
} else {
logger.info("{}锁定人不一致,不允许删除,oldUserId:{},curUserId{},", key, oldLockInfo.getUsrId(), lockInfo.getUsrId());
}
}
return false;
}
@Transactional(propagation = Propagation.REQUIRES_NEW,rollbackFor = Exception.class)
public boolean lockForce(String key,String value, long seconds) {
logger.info("强制占用锁{}:{}",key,value);
LockInfo lockInfo = new LockInfo(key,value);
@Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Exception.class)
public boolean lockForce(String key, String value, long seconds) {
logger.info("强制占用锁{}:{}", key, value);
LockInfo lockInfo = new LockInfo(key, value);
lckComponent.updateLockInfo(lockInfo);
logger.info("强制占用锁{}:{}成功",key,value);
logger.info("强制占用锁{}:{}成功", key, value);
return true;
}
/**
* 强制解锁
*
......@@ -136,9 +135,9 @@ public class DBLckBizLocker extends AbstractBizLocker {
@Override
public boolean unlockForce(LockInfo lockInfo) {
String key = lockInfo.genLockKey();
logger.info("强制删除锁{}",key);
logger.info("强制删除锁{}", key);
int cnt = lckComponent.deleteLck(lockInfo);
logger.info("强制删除锁成功{},影响行数{}",key,cnt);
logger.info("强制删除锁成功{},影响行数{}", key, cnt);
return true;
}
......@@ -151,10 +150,10 @@ public class DBLckBizLocker extends AbstractBizLocker {
@Override
public boolean unlockAllOfTrans(String transName, String userId) {
Lck lck = new Lck();
lck.setLcktrn(transName);
lck.setLcktrn(StringUtils.upperCase(transName));
lck.setLckusr(userId);
int cnt = lckComponent.deleteLckByUserAndTrn(lck);
logger.info("解除{}用户在{}交易的所有锁定,影响行数{}",userId,transName,cnt);
logger.info("解除{}用户在{}交易的所有锁定,影响行数{}", userId, transName, cnt);
return true;
}
......@@ -166,12 +165,12 @@ public class DBLckBizLocker extends AbstractBizLocker {
*/
@Override
public boolean unlockAllOfUser(String userId) {
logger.info("退出锁定{}",userId);
logger.info("退出锁定{}", userId);
Lck lck = new Lck();
lck.setLcktrn(null);
lck.setLckusr(userId);
int cnt = lckComponent.deleteLckByUserAndTrn(lck);
logger.info("退出锁定成功{},影响行数{}",userId,cnt);
logger.info("退出锁定成功{},影响行数{}", userId, cnt);
return false;
}
}
package com.brilliance.isc.common.lock.impl;
import org.slf4j.LoggerFactory;
import org.slf4j.Logger;
import com.brilliance.isc.bo.Lck;
import com.brilliance.isc.common.lock.LockInfo;
import com.brilliance.isc.mda.dao.LckMapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.DuplicateKeyException;
import org.springframework.stereotype.Service;
import java.util.Date;
......@@ -25,40 +24,39 @@ public class LckComponent {
int cnt = lckMapper.insert(lck);
logger.info("锁定信息插入成功,影响行数:{}", cnt);
return true;
}catch(DuplicateKeyException e){
logger.info("已存在锁{}",lockInfo.genLockKey());
}
finally {
} catch (Exception e) {
logger.info("已存在锁{}", lockInfo.genLockKey());
} finally {
}
return false;
}
public Lck lockInfo2Lck(LockInfo lockInfo){
public Lck lockInfo2Lck(LockInfo lockInfo) {
Lck dataLck = new Lck();
dataLck.setLckdattim(new Date());
dataLck.setLcktrn(lockInfo.getTrnName());
dataLck.setLckusr(lockInfo.getUsrId());
dataLck.setLckstr(lockInfo.genLockKey());
if(lockInfo.isReentrant()){
if (lockInfo.isReentrant()) {
dataLck.setLckhld("");
}else{
} else {
dataLck.setLckhld("X");
}
return dataLck;
}
public LockInfo lck2Info(Lck dataLck){
if(dataLck == null){
public LockInfo lck2Info(Lck dataLck) {
if (dataLck == null) {
return null;
}
LockInfo lockInfo = new LockInfo(dataLck.getLckstr());
lockInfo.setTrnName(dataLck.getLcktrn());
lockInfo.setUsrId(dataLck.getLckusr());
if(dataLck.getLckhld() == null || dataLck.getLckhld().trim().isEmpty()){
if (dataLck.getLckhld() == null || dataLck.getLckhld().trim().isEmpty()) {
lockInfo.setReentrant(true);
}else{
} else {
lockInfo.setReentrant(false);
}
return lockInfo;
......
......@@ -1350,9 +1350,10 @@ public class GlemodServiceImpl implements GlemodService {
* source:glemod.0017.script
*/
public String actgetsql(String ptyinr, String dsp, String cur) {
String res = "WHERE EXTKEY <> ''";
// String res = "WHERE EXTKEY <> ''";
String res = "WHERE (EXTKEY is not null or EXTKEY <> '') ";
if (StringUtils.isNotEmpty(cur)) {
res += " AND (CUR = '" + cur + "' or CUR = ' ')";
res += " AND (CUR = '" + cur + "' or CUR = ' ' or cur is null)";
}
//String res = "WHERE (CUR = '" + cur + "' or CUR = ' ')";
// DSP有两种情况,一个是确定的单个账号,比如AS-LIS,另一个是账号列表,比如LOD
......@@ -1689,11 +1690,11 @@ public class GlemodServiceImpl implements GlemodService {
}
String res = "";
if (MdaUtils.compareTo(amt, 0) < 0) {
sqlblk += " AND DIRFLG <> 'D'";
sqlblk += " AND (DIRFLG is null or DIRFLG <> 'D' )";
} else {
sqlblk += " AND DIRFLG <> 'C'";
sqlblk += " AND (DIRFLG is null or DIRFLG <> 'C' )";
}
sqlblk += " AND DELFLG <> 'X' ";
sqlblk += " AND (DELFLG is null or DELFLG <> 'X') ";
sqlblk = Utils.sdbEtyGenSql("ACT", sqlblk);
sqlblk += " ORDER BY PRI DESC, INR DESC";
String sql = "select EXTKEY from ACT " + sqlblk;
......
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