Commit d035c7cc by huangshunlin

即期结汇初始化 和保存

parent 6c9f37c0
0002=This field is mandatory
funds_fxtssb_000000=Settlement
0002=This field is mandatory
funds_fxtssb_000000=Settlement
\ No newline at end of file
package com.brilliance.isc.funds.common.component;
import com.brilliance.isc.bo.Cbb;
import com.brilliance.isc.bo.Fxd;
import com.brilliance.isc.bo.Fxt;
import com.brilliance.isc.bo.model.Cpacbs;
import com.brilliance.isc.bo.model.Fxacbs;
import com.brilliance.isc.bo.model.Fxdgrp;
import com.brilliance.isc.common.cbsmod.service.CbsmodService;
import com.brilliance.isc.common.component.PtsptaToolComponent;
import com.brilliance.isc.common.context.SettleContext;
import com.brilliance.isc.common.exception.CommonServiceException;
import com.brilliance.isc.common.sysmod.SysmodService;
import com.brilliance.isc.common.transaction.help.TransactionServiceSet;
import com.brilliance.isc.common.trnmod.service.TrnmodService;
import com.brilliance.isc.common.util.StringUtils;
import com.brilliance.isc.common.util.Utils;
import com.brilliance.isc.common.vo.PtsptaVo;
import com.brilliance.isc.mda.dao.FxdMapper;
import com.brilliance.isc.mda.dao.FxtMapper;
import com.brilliance.mda.runtime.mda.util.Dates;
import com.brilliance.mda.runtime.mda.util.MdaUtils;
import com.brilliance.mda.runtime.mda.util.Strings;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.lang.reflect.Field;
import java.math.BigDecimal;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
import static com.brilliance.mda.runtime.mda.Constants.NULLSTR;
@Component
public class FxToolComponent {
@Autowired
private FxdMapper fxdMapper;
@Autowired
private FxtMapper fxtMapper;
@Autowired
private PtsptaToolComponent ptsptaToolComponent;
@Autowired
private CbsmodService cbsmodService;
@Autowired
private SysmodService sysmodService;
@Autowired
private TrnmodService trnmodService;
public Fxdgrp getFxdgrpByInr(String inr) {
Fxd rec = new Fxd();
rec.setInr(inr);
rec = fxdMapper.selectByPrimaryKey(rec);
if (Objects.isNull(rec)) {
throw new CommonServiceException("主键" + inr + "找不到FXD数据");
}
Fxdgrp fxdgrp = new Fxdgrp();
fxdgrp.reset();
fxdgrp.setRec(rec);
Fxt blk = new Fxt();
blk.setInr(inr);
blk = fxtMapper.selectByPrimaryKey(blk);
fxdgrp.setBlk(blk);
//获取cbs金额信息
Date date = Dates.add(Utils.getMaxDate(), -1);
cbsmodService.cbsGetBalance(fxdgrp.getCbs().getMax(), "CPD", inr, "MAXSUM", "AMT1", date);
cbsmodService.cbsGetBalance(fxdgrp.getCbs().getNom1(), "CPD", inr, "NOMSUM", "AMT1", date);
//获取ptspta信息
storePtsToGrp(fxdgrp, inr, "FXD");
return fxdgrp;
}
public void storePtsToGrp(Object grpObject, String objInr, String objType) {
//找ptspta数据
Map<String, PtsptaVo> maps = ptsptaToolComponent.getPtsptaList(objInr, objType);
if (maps.size() > 0) {
maps.keySet().forEach(key -> {
PtsptaVo ptsptaVo = maps.get(key);
if (key.equalsIgnoreCase("INT")) {
key = "tmpint";
}
Utils.setFieldValue(grpObject, key.toLowerCase(), ptsptaVo);
});
}
}
public void collectCbsMap(TransactionServiceSet set, String prefix, Fxacbs cbs, String... cbsNames) {
Map<String, Cbb> cbsMap = set.getCbsMap();
if (cbsMap == null) {
cbsMap = new HashMap<>();
}
for (String name : cbsNames) {
Cbb cbb = Utils.getFieldValue(cbs, name);
if (cbb != null) {
cbsMap.put(prefix.toUpperCase() + name.toUpperCase(), cbb);
}
}
set.setCbsMap(cbsMap);
}
public void collectPtsList(TransactionServiceSet set, Fxdgrp fxdgrp, String... ptsNames) {
if (ptsNames == null) {
//找所有的ptspta对象
Field[] fields = fxdgrp.getClass().getDeclaredFields();
for (Field field : fields) {
field.setAccessible(true);
if (PtsptaVo.class.equals(field.getType())) {
PtsptaVo ptspta = Utils.getFieldValue(fxdgrp, field.getName());
if (ptspta != null) {
set.addPtspta(transferFrom(ptspta));
}
}
}
} else {
for (String name : ptsNames) {
PtsptaVo ptspta = Utils.getFieldValue(fxdgrp, name);
if (ptspta != null && ptspta.getPts() != null && StringUtils.isNotEmpty(ptspta.getPts().getRol())) {
set.addPtspta(transferFrom(ptspta));
}
}
}
}
/**
* 根据STL结构的ptspta转化成抽象组件的ptspta,结构不一样
*
* @param ptsptas
* @return List<com.brilliance.common.vo.PtsptaVo>
*/
protected PtsptaVo transferFrom(PtsptaVo ptsptas) {
PtsptaVo ptspta = ptsptas;
ptspta.setRol(ptsptas.getPts().getRol());
ptspta.setPtsinr(ptsptas.getPts().getInr());
ptspta.setNam(ptsptas.getPts().getNam());
ptspta.setPtyinr(ptsptas.getPts().getPtyinr());
ptspta.setPtainr(ptsptas.getPts().getPtainr());
ptspta.setExtkey(ptsptas.getPts().getExtkey());
ptspta.setDftdsp(ptsptas.getPts().getDftdsp());
ptspta.setDftcur(ptsptas.getPts().getDftcur());
ptspta.setDftact(ptsptas.getPts().getDftact());
ptspta.setDftfeecur(ptsptas.getPts().getDftfeecur());
ptspta.setDftactptainr(ptsptas.getPts().getDftactptainr());
ptspta.setDftselrol(ptsptas.getPts().getDftsetrol());
ptspta.setGlggrpflg(ptsptas.getPts().getGlggrpflg());
ptspta.setRef(ptsptas.getPts().getRef());
ptspta.setPtytyp(ptsptas.getPtytyp());
ptspta.setPtyextkey(ptsptas.getPtyextkey());
ptspta.setAdrblk(ptsptas.getPts().getAdrblk());
return ptspta;
}
/**
* source:fxtmod.0000.script
*/
public void getref(Fxdgrp fxdgrp) {
//! Set reference number, if not already set (usually called in transaction`s MTABUT\\SAV Event)
String tbl = NULLSTR;
int len = 0;
switch (fxdgrp.getRec().getFxtyp()) {
case "LS":
case "LB":
tbl = "FX";
len = 4;
break;
case "XS":
case "XB":
tbl = "DX";
len = 4;
break;
case "US":
tbl = "S" + Strings.mid(fxdgrp.getCbs().getMax().getCur(), 1, 1);
len = 4;
break;
case "UB":
tbl = "B" + Strings.mid(fxdgrp.getCbs().getMax().getCur(), 1, 1);
len = 4;
break;
default:
tbl = "J" + Strings.mid(fxdgrp.getCbs().getMax().getCur(), 1, 1);
len = 4;
}
if (MdaUtils.isEmpty(fxdgrp.getRec().getOwnref())) {
fxdgrp.getRec().setOwnref(sysmodService.getRef(tbl, len));
}
}
/**
* source:fxtmod.0001.script
*/
public void sav(Fxdgrp fxdgrp, BigDecimal cshpct) {
// saves contract including texts. CBS resp. of transaction
String frm = SettleContext.getTransName();
switch (frm) {
case "FXTSUS":
case "FXTSUB":
case "FXTSST":
case "FXTSCN":
//Datas.getContentNumeric(this, "\\LIAALL\\LIACCV\\CSHPCT")
fxdgrp.getRec().setCshpct(cshpct);
break;
}
trnmodService.trnStoreContract(fxdgrp);
}
/**
* source:fxtmod.0002.script
*/
public void setObjNam(String objref, String nam) {
//Setting OBJNAM. If the setting of OBJREF is not standard, here you can change it.
// ctx.absGet(Sysmod.class).setObjnam(NULLSTR);
// ctx.absGet(Sysmod.class).setObjnam(objref + "/" + nam);
}
}
package com.brilliance.isc.funds.fxtssb.service;
import com.brilliance.isc.bo.model.Fxacbs;
import com.brilliance.isc.bo.model.Fxdgrp;
import com.brilliance.isc.common.cbsmod.service.CbsmodService;
import com.brilliance.isc.common.cbsmod.service.XrtmodService;
import com.brilliance.isc.common.contants.CommonContants;
import com.brilliance.isc.common.context.SettleContext;
import com.brilliance.isc.common.sysmod.SysmodService;
import com.brilliance.isc.common.transaction.AbstractTransactionService;
import com.brilliance.isc.common.transaction.help.TransactionHelpService;
import com.brilliance.isc.common.transaction.help.TransactionServiceSet;
import com.brilliance.isc.common.trnmod.service.TrnmodService;
import com.brilliance.isc.common.trnmod.vo.TrnmodVo;
import com.brilliance.isc.common.util.I18nUtil;
import com.brilliance.isc.common.vo.BizAmdInfoVo;
import com.brilliance.isc.common.vo.BizInfoVo;
import com.brilliance.isc.funds.bo.funds.FxtssbStoreBo;
import com.brilliance.isc.funds.common.component.FxToolComponent;
import com.brilliance.isc.funds.fxtssb.check.FxtssbValidator;
import com.brilliance.isc.vo.funds.FxdBizInfoVo;
import com.brilliance.mda.runtime.mda.impl.Argument;
import com.brilliance.mda.runtime.mda.util.Dates;
import com.brilliance.mda.runtime.mda.util.MdaUtils;
import org.springframework.stereotype.Service;
import javax.annotation.PostConstruct;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.Map;
/**
......@@ -25,6 +42,28 @@ public class FxtssbTransactionServiceImpl extends AbstractTransactionService<Fxt
@Resource
private FxtssbValidator fxtssbValidator;
@Resource
private XrtmodService xrtmodService;
@Resource
private SysmodService sysmodService;
@Resource
private FxToolComponent fxToolComponent;
@Resource
private TransactionHelpService transactionHelpService;
@Resource
private SettleContext settleContext;
@Resource
private CbsmodService cbsmodService;
@Resource
private TrnmodService trnmodService;
@PostConstruct
public void regisertService() {
......@@ -48,6 +87,24 @@ public class FxtssbTransactionServiceImpl extends AbstractTransactionService<Fxt
}
public void ruleMtabutSavN500(FxtssbStoreBo bo) {
TrnmodVo trnmodVo = transactionHelpService.getTransactionStoreSet().getTrnmodVo();
Fxdgrp fxdgrp = bo.getFxdgrp();
fxToolComponent.getref(fxdgrp);
// 1. Create (rsp. update) Contract (incl. Texts)
Argument<String> pathBox = new Argument<String>("", fxdgrp.getRec().getAccmng());
Argument<String> pathBox1 = new Argument<String>("", fxdgrp.getRec().getHdbch());
sysmodService.getPtyAccMng(fxdgrp.getApl().getPta().getPtyinr(), "", "", "", pathBox, pathBox1);
fxdgrp.getRec().setAccmng(pathBox.value);
fxdgrp.getRec().setHdbch(pathBox1.value);
fxToolComponent.sav(fxdgrp, BigDecimal.ZERO);
// 2. Build Transaction from FTDGRP
trnmodService.trnSetFromContract(trnmodVo);
cbsSav(bo, trnmodVo);
// save documents
}
@Override
......@@ -57,8 +114,9 @@ public class FxtssbTransactionServiceImpl extends AbstractTransactionService<Fxt
@Override
protected BizInfoVo buildBizInfo(FxtssbStoreBo transactionVo) {
return null;
FxdBizInfoVo bizInfoVo = new FxdBizInfoVo();
bizInfoVo.setObjtyp("FXD");
return bizInfoVo;
}
@Override
......@@ -69,19 +127,58 @@ public class FxtssbTransactionServiceImpl extends AbstractTransactionService<Fxt
@Override
public FxtssbStoreBo init(FxtssbStoreBo fxtssbStoreBo) {
fxtssbStoreBo.reset();
init950(fxtssbStoreBo);
init1000(fxtssbStoreBo);
return fxtssbStoreBo;
}
/**
* source:fxtssb.0001.script
*/
public void init1000(FxtssbStoreBo bo) {
bo.getFxdgrp().getCbs().getNom1().setCur(xrtmodService.sysiso());
// MAXAMT = 200000.00
// Systems.setValues(this.getFxdgrp().getRec(), "fxtyp", "SB");
bo.getFxdgrp().getRec().setFxtyp("SB");
String extkey = SettleContext.getUserSession().getUsr().getExtkey();
bo.getFxdgrp().getRec().setUsr(extkey);
}
private void init950(FxtssbStoreBo fxtssbStoreBo) {
}
@Override
public void beforeSave(FxtssbStoreBo transactionVo) {
transactionVo.reset();
Fxdgrp fxdgrp = transactionVo.getFxdgrp();
TransactionServiceSet transactionServiceSet = transactionHelpService.getTransactionStoreSet();
transactionServiceSet.setRec(fxdgrp.getRec());
transactionServiceSet.setBlk(fxdgrp.getBlk());
transactionServiceSet.setTransactionVo(transactionVo);
fxToolComponent.collectCbsMap(transactionServiceSet, "", fxdgrp.getCbs(), "max", "nom1", "opn1", "opn2");
fxToolComponent.collectPtsList(transactionServiceSet, fxdgrp, null);
settleContext.loadSettleSession(transactionVo.getTransName(), transactionVo.getUserId(), buildBizInfo(transactionVo), transactionServiceSet.getPtsList());
}
@Override
protected void updateBizInfoVo(BizInfoVo bizInfoVo, FxtssbStoreBo transactionVo) {
bizInfoVo.setObjinr(transactionVo.getFxdgrp().getRec().getInr());
}
/**
* source:fxtssb.0003.script
*/
public void cbsSav(FxtssbStoreBo transactionVo, TrnmodVo trnmodVo) {
cbsmodService.cbsTrnSetNew("TRN", trnmodVo.getTrn().getInr());
Fxacbs cbs = transactionVo.getFxdgrp().getCbs();
String trninr = transactionHelpService.getTrninr();
trnmodService.cbsTrnStore("MAXAMT", "AMT1", Dates.today(), cbs.getMax().getCur(), cbs.getMax().getAmt(), I18nUtil.getMessage("funds_fxtssb_000000"), transactionVo.getFxdgrp(), trninr);
if (!MdaUtils.isEmpty(cbs.getNom1().getAmt())) {
trnmodService.cbsTrnStore("NOMAMT", "AMT1", Dates.today(), cbs.getNom1().getCur(), cbs.getNom1().getAmt(), I18nUtil.getMessage("funds_fxtssb_000000"), transactionVo.getFxdgrp(), trninr);
trnmodService.cbsTrnStore("UTLAMT", "AMT1", Dates.today(), cbs.getMax().getCur(), cbs.getMax().getAmt(), I18nUtil.getMessage("funds_fxtssb_000000"), transactionVo.getFxdgrp(), trninr);
}
}
}
package com.brilliance.isc.funds.bo.funds;
import com.brilliance.isc.bo.model.Fxdgrp;
import com.brilliance.isc.bo.model.Fxtp;
import com.brilliance.isc.common.transaction.vo.BaseTransactionVo;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.Data;
......@@ -14,4 +16,22 @@ import lombok.Data;
@Data
@JsonIgnoreProperties(ignoreUnknown = true)
public class FxtssbStoreBo extends BaseTransactionVo {
private Fxdgrp fxdgrp;
private Fxtp fxtp;
@Override
public void reset() {
super.reset();
if (fxdgrp == null) {
fxdgrp = new Fxdgrp();
}
fxdgrp.reset();
if (fxtp == null) {
fxtp = new Fxtp();
}
fxtp.reset();
}
}
package com.brilliance.isc.funds.bo.funds;
import com.brilliance.isc.bo.model.Fxdgrp;
import com.brilliance.isc.bo.model.Fxtp;
import com.brilliance.isc.common.transaction.vo.BaseTransactionVo;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.Data;
......@@ -14,4 +16,20 @@ import lombok.Data;
@Data
@JsonIgnoreProperties(ignoreUnknown = true)
public class FxtsssStoreBo extends BaseTransactionVo {
private Fxdgrp fxdgrp;
private Fxtp fxtp;
@Override
public void reset() {
super.reset();
if (fxdgrp == null) {
fxdgrp = new Fxdgrp();
}
fxdgrp.reset();
if (fxtp == null) {
fxtp = new Fxtp();
}
fxtp.reset();
}
}
package com.brilliance.isc.funds.vo.funds;
import com.brilliance.isc.bo.model.Fxdgrp;
import com.brilliance.isc.bo.model.Fxtp;
import com.brilliance.isc.common.transaction.vo.BaseTransactionVo;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.Data;
......@@ -14,4 +16,22 @@ import lombok.Data;
@Data
@JsonIgnoreProperties(ignoreUnknown = true)
public class FxtssbStoreVo extends BaseTransactionVo {
private Fxdgrp fxdgrp;
private Fxtp fxtp;
@Override
public void reset() {
super.reset();
if (fxdgrp == null) {
fxdgrp = new Fxdgrp();
}
fxdgrp.reset();
if (fxtp == null) {
fxtp = new Fxtp();
}
fxtp.reset();
}
}
package com.brilliance.isc.funds.vo.funds;
import com.brilliance.isc.bo.model.Fxdgrp;
import com.brilliance.isc.bo.model.Fxtp;
import com.brilliance.isc.common.transaction.vo.BaseTransactionVo;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.Data;
......@@ -14,4 +16,21 @@ import lombok.Data;
@Data
@JsonIgnoreProperties(ignoreUnknown = true)
public class FxtsssStoreVo extends BaseTransactionVo {
private Fxdgrp fxdgrp;
private Fxtp fxtp;
@Override
public void reset() {
super.reset();
if (fxdgrp == null) {
fxdgrp = new Fxdgrp();
}
fxdgrp.reset();
if (fxtp == null) {
fxtp = new Fxtp();
}
fxtp.reset();
}
}
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