领悦凭证推送

This commit is contained in:
Harryxzy 2024-10-12 16:39:09 +08:00
parent 9621882a04
commit a4b6ca6048
7 changed files with 142 additions and 115 deletions

View File

@ -26,4 +26,7 @@ public class LyFzhsBrowser {
// 辅助核算类型
private String fzhslx;
// 辅助核算类型编号
private String fzhslxbh;
}

View File

@ -33,4 +33,17 @@ public class LyNCVoucherReturn {
@XStreamAsAttribute
private String successful;
@XStreamAsAttribute
private String isexchange;
@XStreamAsAttribute
private String replace;
@XStreamAsAttribute
private String roottag;
@XStreamAsAttribute
private String sender;
}

View File

@ -1,5 +1,6 @@
package com.engine.salary.entity.ly.param;
import com.engine.salary.entity.ly.dto.LyFzhsBrowser;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
@ -27,19 +28,19 @@ public class LyVoucherDetailPushParam {
private String kjkm;
// 辅助核算项目期数编码
private String fzhsXmqs;
private LyFzhsBrowser fzhsXmqs;
// 辅助核算房屋类别
private String fzhsFwlb;
private LyFzhsBrowser fzhsFwlb;
// 辅助核算税率类别
private String fzhsSllb;
private LyFzhsBrowser fzhsSllb;
// 辅助核算客商
private String fzhsKs;
private LyFzhsBrowser fzhsKs;
// 辅助核算其余辅助核算信息
private List<String> fzhsOtherBmList;
private List<LyFzhsBrowser> fzhsOtherBmList;
private String fzhsOtherBmStr;
// 借方金额

View File

@ -69,7 +69,7 @@ public class LyVoucherPO {
* 创建时间
*/
@TableTitle(title = "推送时间", dataIndex = "createTime", key = "createTime")
@JsonFormat(pattern = "yyyy-MM-dd hh:mm:ss", timezone = "GMT+8")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date createTime;

View File

@ -38,7 +38,7 @@ public interface LyPZService {
*
* @param pushParam
*/
void pushUCAndSave(LyVoucherPushParam pushParam);
Map<String, Object> pushUCAndSave(LyVoucherPushParam pushParam);
/**
* 本地历史凭证列表

View File

@ -294,12 +294,13 @@ public class LyPZServiceImpl extends Service implements LyPZService {
List<List<String>> partition = Lists.partition(fzhsBmList, 500);
partition.forEach(part -> {
String bmIdStr = StringUtils.join(part, "','");
rs.execute("SELECT fzhslx,bh,mc FROM uf_ncfuhs where bh in ('" + bmIdStr + "')");
rs.execute("SELECT fzhslx,fzhslxbh,bh,mc FROM uf_ncfuhs where bh in ('" + bmIdStr + "')");
while (rs.next()) {
LyFzhsBrowser browser = new LyFzhsBrowser();
browser.setFzhslx(LyPZTypeEnum.getDefaultLabelByValue(rs.getInt("fzhslx")));
browser.setBh(rs.getString("bh"));
browser.setMc(rs.getString("mc"));
browser.setFzhslxbh(rs.getString("fzhslxbh"));
lyFzhsBrowserList.add(browser);
}
});
@ -335,9 +336,9 @@ public class LyPZServiceImpl extends Service implements LyPZService {
BaseBean baseBean = new BaseBean();
String fzhslxFieldId = baseBean.getPropValue("lySalaryNCVoucher", "fzhslx_field_id");
if (queryParam.getFzhslx() == null ) {
rs.execute("select bh,mc,fzhslx,b.selectname from uf_NCfuhs a left join workflow_selectitem b on a. fzhslx= b.SELECTVALUE where b.FIELDID=" + fzhslxFieldId );
rs.execute("select bh,mc,fzhslx,fzhslxbh,b.selectname from uf_NCfuhs a left join workflow_selectitem b on a. fzhslx= b.SELECTVALUE where b.FIELDID=" + fzhslxFieldId );
} else {
rs.execute("select bh,mc,fzhslx,b.selectname from uf_NCfuhs a left join workflow_selectitem b on a. fzhslx= b.SELECTVALUE where b.FIELDID=" + fzhslxFieldId + "and a.fzhslx = "+ queryParam.getFzhslx());
rs.execute("select bh,mc,fzhslx,fzhslxbh,b.selectname from uf_NCfuhs a left join workflow_selectitem b on a. fzhslx= b.SELECTVALUE where b.FIELDID=" + fzhslxFieldId + " and a.fzhslx = "+ queryParam.getFzhslx());
}
List<Map<String, Object>> resultList = new ArrayList<>();
while (rs.next()) {
@ -350,6 +351,7 @@ public class LyPZServiceImpl extends Service implements LyPZService {
resultMap.put("bh", rs.getString("bh"));
resultMap.put("mc", rs.getString("mc"));
resultMap.put("fzhslx", rs.getString("selectname"));
resultMap.put("fzhslxbh", rs.getString("fzhslxbh"));
resultList.add(resultMap);
}
}
@ -599,7 +601,7 @@ public class LyPZServiceImpl extends Service implements LyPZService {
* @param pushParam
*/
@Override
public void pushUCAndSave(LyVoucherPushParam pushParam) {
public Map<String, Object> pushUCAndSave(LyVoucherPushParam pushParam) {
// 校验会计科目是否合法
verifyKjkm(pushParam);
// 推送凭证
@ -607,7 +609,7 @@ public class LyPZServiceImpl extends Service implements LyPZService {
// 推送成功后修改报表数据的凭证生成状态
updateReportStatus(pushParam);
// 推送成功后保存凭证
saveVoucher(pushParam);
return saveVoucher(pushParam);
}
/**
@ -649,7 +651,8 @@ public class LyPZServiceImpl extends Service implements LyPZService {
* 保存凭证
* @param pushParam
*/
private void saveVoucher(LyVoucherPushParam pushParam) {
private Map<String, Object> saveVoucher(LyVoucherPushParam pushParam) {
Map<String, Object> resultMap = new HashMap<String, Object>();
Date now = new Date();
long mainId = IdGenerator.generate();
LyVoucherPO voucher = LyVoucherPO
@ -675,11 +678,11 @@ public class LyPZServiceImpl extends Service implements LyPZService {
.voucherId(mainId)
.zy(detail.getZy())
.kjkmId(detail.getKjkm())
.fzhsXmqsBm(detail.getFzhsXmqs())
.fzhsFwlbBm(detail.getFzhsFwlb())
.fzhsSllbBm(detail.getFzhsSllb())
.fzhsKsBm(detail.getFzhsKs())
.fzhsOtherBms(CollectionUtils.isEmpty(detail.getFzhsOtherBmList()) ? "" : StringUtils.join(detail.getFzhsOtherBmList(), ","))
.fzhsXmqsBm(detail.getFzhsXmqs().getBh())
.fzhsFwlbBm(detail.getFzhsFwlb().getBh())
.fzhsSllbBm(detail.getFzhsSllb().getBh())
.fzhsKsBm(detail.getFzhsKs().getBh())
.fzhsOtherBms(CollectionUtils.isEmpty(detail.getFzhsOtherBmList()) ? "" : detail.getFzhsOtherBmList().stream().map(LyFzhsBrowser::getBh).collect(Collectors.joining(",")) )
.jfValue(detail.getJfValue())
.dfValue(detail.getDfValue())
.creator(Long.valueOf(user.getUID()))
@ -688,7 +691,9 @@ public class LyPZServiceImpl extends Service implements LyPZService {
.deleteType(0).build();
getLyVoucherDetailMapper().insertIgnoreNull(voucherDetail);
});
resultMap.put("status", (pushParam.getStatus() != null && pushParam.getStatus().equals(NumberUtils.INTEGER_ONE)) ? Boolean.TRUE : Boolean.FALSE);
resultMap.put("errMsg", pushParam.getPushMsg());
return resultMap;
}
/**
@ -696,31 +701,38 @@ public class LyPZServiceImpl extends Service implements LyPZService {
* @param pushParam
*/
private void pushVoucher(LyVoucherPushParam pushParam) {
pushParam.setStatus(NumberUtils.INTEGER_ONE);
pushParam.setPushMsg("推送成功");
Date salaryDate = SalaryDateUtil.dateStrToLocalYearMonth(pushParam.getSalaryMonth());
if (salaryDate == null) {
throw new SalaryRunTimeException("薪资所属月为空");
}
Calendar cal = Calendar.getInstance();
cal.setTime(new Date());
cal.setTime(salaryDate);
BaseBean baseBean = new BaseBean();
LyNCVoucher lyNCVoucher = new LyNCVoucher();
// 凭证类别 非空 凭证类别)
lyNCVoucher.setPkVouchertype("01");
String pkVoucherType = baseBean.getPropValue("lySalaryNCVoucherPushParam", "pk_voucher_type");
lyNCVoucher.setPkVouchertype(pkVoucherType);
// 会计年度 非空
lyNCVoucher.setYear(String.valueOf(cal.get(Calendar.YEAR)));
// 来源系统 非空 只支持模块编号
lyNCVoucher.setPkSystem("GL");
String pkSystem = baseBean.getPropValue("lySalaryNCVoucherPushParam", "pk_system");
lyNCVoucher.setPkSystem(pkSystem);
// 凭证类型值 0正常凭证 3数量调整凭证 不可空
lyNCVoucher.setVoucherkind("0");
String voucherKind = baseBean.getPropValue("lySalaryNCVoucherPushParam", "voucher_kind");
lyNCVoucher.setVoucherkind(voucherKind);
// 核算账簿 非空 账簿_财务核算账簿
lyNCVoucher.setPkAccountingbook("201-0003");
lyNCVoucher.setPkAccountingbook(pushParam.getZbbm());
// lyNCVoucher.setPkAccountingbook("12re23r32");
// 会计期间 非空
lyNCVoucher.setPeriod(String.valueOf(cal.get(Calendar.MONTH)+1));
// 制单日期 非空
lyNCVoucher.setPrepareddate(SalaryDateUtil.getFormatLocalDateTime(new Date()));
// 制单人 非空 用户
lyNCVoucher.setPkPrepared("fw");
String pkPrepared = baseBean.getPropValue("lySalaryNCVoucherPushParam", "pk_prepared");
lyNCVoucher.setPkPrepared(pkPrepared);
//所属组织 非空 组织
// lyNCVoucher.setPkOrg(pushParam.getZbbm().split("-")[0]);
lyNCVoucher.setPkOrg("201");
lyNCVoucher.setPkOrg(pushParam.getZbbm().split("-")[0]);
// lyNCVoucher.setPkOrg("201");
lyNCVoucher.setDiscardflag("N");
@ -734,6 +746,7 @@ public class LyPZServiceImpl extends Service implements LyPZService {
}
});
ArrayList<LyNCVoucherDetail> lyNCVoucherDetailList = new ArrayList<>();
RecordSet rs = new RecordSet();
// 借方分录
for (int i = 0; i < jfDetailList.size(); i++) {
LyVoucherDetailPushParam detailParam = jfDetailList.get(i);
@ -756,36 +769,45 @@ public class LyPZServiceImpl extends Service implements LyPZService {
lyNCVoucherDetail.setPkAccasoa(kjkmbm);
// 辅助核算
List<LyNCVoucherAss> lyNCVoucherAssList = new ArrayList<>();
if (StringUtils.isNotBlank(detailParam.getFzhsXmqs())) {
if (detailParam.getFzhsXmqs() != null) {
// 项目期数
LyNCVoucherAss ass = new LyNCVoucherAss();
ass.setPkChecktype("0010");
ass.setPkCheckvalue(detailParam.getFzhsXmqs());
ass.setPkChecktype(detailParam.getFzhsXmqs().getFzhslxbh());
ass.setPkCheckvalue(detailParam.getFzhsXmqs().getBh());
lyNCVoucherAssList.add(ass);
}
if (StringUtils.isNotBlank(detailParam.getFzhsFwlb())) {
if (detailParam.getFzhsFwlb() != null) {
// 房屋列别
LyNCVoucherAss ass = new LyNCVoucherAss();
ass.setPkChecktype("xz001");
ass.setPkCheckvalue(detailParam.getFzhsFwlb());
ass.setPkChecktype(detailParam.getFzhsFwlb().getFzhslxbh());
ass.setPkCheckvalue(detailParam.getFzhsFwlb().getBh());
lyNCVoucherAssList.add(ass);
}
if (StringUtils.isNotBlank(detailParam.getFzhsSllb())) {
if (detailParam.getFzhsSllb() != null) {
// 税率类别
LyNCVoucherAss ass = new LyNCVoucherAss();
ass.setPkChecktype("yy001");
ass.setPkCheckvalue(detailParam.getFzhsSllb());
ass.setPkChecktype(detailParam.getFzhsSllb().getFzhslxbh());
ass.setPkCheckvalue(detailParam.getFzhsSllb().getBh());
lyNCVoucherAssList.add(ass);
}
if (StringUtils.isNotBlank(detailParam.getFzhsKs())) {
if (detailParam.getFzhsKs() != null) {
LyNCVoucherAss ass = new LyNCVoucherAss();
// 客商
ass.setPkChecktype("0004");
ass.setPkCheckvalue(detailParam.getFzhsKs());
ass.setPkChecktype(detailParam.getFzhsKs().getFzhslxbh());
ass.setPkCheckvalue(detailParam.getFzhsKs().getBh());
lyNCVoucherAssList.add(ass);
}
// TODO 其他
lyNCVoucherDetail.setAss(lyNCVoucherAssList);
// 其他
if (CollectionUtils.isNotEmpty(detailParam.getFzhsOtherBmList())) {
detailParam.getFzhsOtherBmList().stream().forEach(fzhs -> {
LyNCVoucherAss ass = new LyNCVoucherAss();
ass.setPkChecktype(fzhs.getFzhslxbh());
ass.setPkCheckvalue(fzhs.getBh());
lyNCVoucherAssList.add(ass);
});
}
List<LyNCVoucherAss> assList = lyNCVoucherAssList.stream().filter(ass -> StringUtils.isNotBlank(ass.getPkChecktype())).collect(Collectors.toList());
lyNCVoucherDetail.setAss(assList);
lyNCVoucherDetailList.add(lyNCVoucherDetail);
}
@ -811,32 +833,45 @@ public class LyPZServiceImpl extends Service implements LyPZService {
lyNCVoucherDetail.setPkAccasoa(kjkmbm);
// 辅助核算
List<LyNCVoucherAss> lyNCVoucherAssList = new ArrayList<>();
if (StringUtils.isNotBlank(detailParam.getFzhsXmqs())) {
if (detailParam.getFzhsXmqs() != null) {
// 项目期数
LyNCVoucherAss ass = new LyNCVoucherAss();
ass.setPkChecktype("0010");
ass.setPkCheckvalue(detailParam.getFzhsXmqs());
ass.setPkChecktype(detailParam.getFzhsXmqs().getFzhslxbh());
ass.setPkCheckvalue(detailParam.getFzhsXmqs().getBh());
lyNCVoucherAssList.add(ass);
}
if (StringUtils.isNotBlank(detailParam.getFzhsFwlb())) {
if (detailParam.getFzhsFwlb() != null) {
// 房屋列别
LyNCVoucherAss ass = new LyNCVoucherAss();
ass.setPkChecktype("xz001");
ass.setPkCheckvalue(detailParam.getFzhsFwlb());
ass.setPkChecktype(detailParam.getFzhsFwlb().getFzhslxbh());
ass.setPkCheckvalue(detailParam.getFzhsFwlb().getBh());
lyNCVoucherAssList.add(ass);
}
if (StringUtils.isNotBlank(detailParam.getFzhsSllb())) {
if (detailParam.getFzhsSllb() != null) {
// 税率类别
LyNCVoucherAss ass = new LyNCVoucherAss();
ass.setPkChecktype("yy001");
ass.setPkCheckvalue(detailParam.getFzhsSllb());
ass.setPkChecktype(detailParam.getFzhsSllb().getFzhslxbh());
ass.setPkCheckvalue(detailParam.getFzhsSllb().getBh());
lyNCVoucherAssList.add(ass);
}
if (StringUtils.isNotBlank(detailParam.getFzhsKs())) {
if (detailParam.getFzhsKs() != null) {
LyNCVoucherAss ass = new LyNCVoucherAss();
ass.setPkChecktype("0004");
ass.setPkCheckvalue(detailParam.getFzhsKs());
// 客商
ass.setPkChecktype(detailParam.getFzhsKs().getFzhslxbh());
ass.setPkCheckvalue(detailParam.getFzhsKs().getBh());
lyNCVoucherAssList.add(ass);
}
// todo 其他
lyNCVoucherDetail.setAss(lyNCVoucherAssList);
// 其他
if (CollectionUtils.isNotEmpty(detailParam.getFzhsOtherBmList())) {
detailParam.getFzhsOtherBmList().stream().forEach(fzhs -> {
LyNCVoucherAss ass = new LyNCVoucherAss();
ass.setPkChecktype(fzhs.getFzhslxbh());
ass.setPkCheckvalue(fzhs.getBh());
lyNCVoucherAssList.add(ass);
});
}
List<LyNCVoucherAss> assList = lyNCVoucherAssList.stream().filter(ass -> StringUtils.isNotBlank(ass.getPkChecktype())).collect(Collectors.toList());
lyNCVoucherDetail.setAss(assList);
lyNCVoucherDetailList.add(lyNCVoucherDetail);
}
lyNCVoucher.setDetails(lyNCVoucherDetailList);
@ -845,9 +880,13 @@ public class LyPZServiceImpl extends Service implements LyPZService {
LyNCVoucherUfinterface lyNCVoucherUfinterface = new LyNCVoucherUfinterface();
lyNCVoucherUfinterface.setVoucher(voucherHead);
lyNCVoucherUfinterface.setAccount("develop");
lyNCVoucherUfinterface.setBilltype("vouchergl");
lyNCVoucherUfinterface.setBusinessunitcode("develop");
String account = baseBean.getPropValue("lySalaryNCVoucherPushParam", "account");
lyNCVoucherUfinterface.setAccount(account);
String billtype = baseBean.getPropValue("lySalaryNCVoucherPushParam", "billtype");
lyNCVoucherUfinterface.setBilltype(billtype);
String businessunitcode = baseBean.getPropValue("lySalaryNCVoucherPushParam", "businessunitcode");
lyNCVoucherUfinterface.setBusinessunitcode(businessunitcode);
lyNCVoucherUfinterface.setFilename("");
lyNCVoucherUfinterface.setGroupcode("");
lyNCVoucherUfinterface.setIsexchange("");
@ -855,70 +894,41 @@ public class LyPZServiceImpl extends Service implements LyPZService {
lyNCVoucherUfinterface.setReceiver("");
lyNCVoucherUfinterface.setReplace("");
lyNCVoucherUfinterface.setRoottag("");
lyNCVoucherUfinterface.setSender("OA");
String sender = baseBean.getPropValue("lySalaryNCVoucherPushParam", "sender");
lyNCVoucherUfinterface.setSender(sender);
// "<?xml version=\"1.0\" encoding='gb2312'?>"
String xml = XStreamUtil.marshal(lyNCVoucherUfinterface);
System.out.println(xml);
HttpClient httpClient = new HttpClient();
PostMethod httpPost = new PostMethod("http://172.18.0.10:8090/service/XChangeServlet?account=002&groupcode=leading");
String accountParam = baseBean.getPropValue("lySalaryNCVoucherPushParam", "account_param");
String groupcodeParam = baseBean.getPropValue("lySalaryNCVoucherPushParam", "groupcode_param");
PostMethod httpPost = new PostMethod("http://172.18.0.10:8090/service/XChangeServlet?account="+accountParam+"&groupcode="+groupcodeParam);
httpPost.setRequestHeader("content-type", "application/json;charset=utf-8");
String result = "";
try {
RequestEntity entity = new StringRequestEntity(xml, "application/json", "UTF-8");
RequestEntity entity = new StringRequestEntity( xml, "application/json", "UTF-8");
httpPost.setRequestEntity(entity);
httpClient.executeMethod(httpPost);
result = httpPost.getResponseBodyAsString();
System.out.println(result);
LyNCVoucherReturn lyNCVoucherReturn = XStreamUtil.unmarshal(LyNCVoucherReturn.class, result);
System.out.println(lyNCVoucherReturn);
LyNCVoucherReturn lyNCVoucherReturn = XStreamUtil.unmarshal(LyNCVoucherReturn.class, StringUtils.substring(result,result.indexOf("<ufinterface"),result.indexOf("</ufinterface>")+14));
boolean success = lyNCVoucherReturn.getSuccessful().equals("Y");
if (!success) {
// 失败
String errorMsg = lyNCVoucherReturn.getSendresult().getResultdescription();
pushParam.setStatus(NumberUtils.INTEGER_ZERO);
pushParam.setPushMsg(errorMsg);
} else {
pushParam.setStatus(NumberUtils.INTEGER_ONE);
pushParam.setPushMsg("推送成功");
}
} catch (Exception e) {
System.out.println("d");
baseBean.writeLog("推送错误" + e.getMessage());
throw new SalaryRunTimeException("推送错误,请联系管理员");
}
throw new SalaryRunTimeException("hi");
// test 生成xml
// List<LyVoucherAss> assList = new ArrayList<>();
// assList.add(LyVoucherAss.builder()
// .pkChecktype("first")
// .pkCheckvalue("ff")
// .build());
// assList.add(LyVoucherAss.builder()
// .pkChecktype("second")
// .pkCheckvalue("fd")
// .build());
//
// List<LyVoucherDetail> lyVoucherDetails = new ArrayList<>();
// lyVoucherDetails.add(LyVoucherDetail.builder()
// .detailindex("what")
// .explanation("hfdsuhfad")
// .debitamount("1000")
// .pkCurrtype("RMB")
// .pkAccasoa("kemu")
// .ass(assList)
// .build());
//
// LyVoucher build = LyVoucher.builder()
// .pkVoucher("123")
// .pkVouchertype("type")
// .year("2024")
// .pkSystem("system")
// .voucherkind("0")
// .pkAccountingbook("1")
// .period("04")
// .prepareddate("2024-08-01")
// .pkPrepared("par")
// .pkOrg("org")
// .details(lyVoucherDetails)
// .build();
//
// String xml = XStreamUtil.marshal(build);
// System.out.println(xml);
}
/**
@ -926,9 +936,9 @@ public class LyPZServiceImpl extends Service implements LyPZService {
* @param pushParam
*/
private void verifyKjkm(LyVoucherPushParam pushParam) {
// if(StringUtils.isBlank(pushParam.getZbbm())) {
// throw new SalaryRunTimeException("账簿编码不能为空");
// }
if(StringUtils.isBlank(pushParam.getZbbm())) {
throw new SalaryRunTimeException("账簿编码不能为空");
}
// 校验科目id是否合规
Map<String, String> kmbmInfoMap = new HashMap<>();
List<UfKjkmPO> allKjkm = getUfKjkmMapper().listAll();
@ -986,7 +996,7 @@ public class LyPZServiceImpl extends Service implements LyPZService {
list.stream().forEach(voucher -> {
voucher.setPzlxStr(LyPZTypeEnum.getDefaultLabelByValue(voucher.getPzlx()));
voucher.setPushStatusStr(voucher.getStatus() != null && voucher.getStatus().equals(NumberUtils.INTEGER_ONE) ? "成功" : "失败");
voucher.setErrorMsg(voucher.getStatus() != null && voucher.getStatus().equals(NumberUtils.INTEGER_ONE) ? "" : voucher.getErrorMsg());
voucher.setErrorMsg(voucher.getStatus() != null && voucher.getStatus().equals(NumberUtils.INTEGER_ONE) ? "" : voucher.getPushMsg());
});
return SalaryPageUtil.buildPage(queryParam.getCurrent(), queryParam.getPageSize(), lyVoucherPOS, LyVoucherPO.class);
}

View File

@ -154,8 +154,8 @@ public class LySalaryWrapper extends Service {
* 推送凭证到UC并保存到本地
* @param pushParam
*/
public void pushUCAndSave(LyVoucherPushParam pushParam) {
getLyPZService(user).pushUCAndSave(pushParam);
public Map<String, Object> pushUCAndSave(LyVoucherPushParam pushParam) {
return getLyPZService(user).pushUCAndSave(pushParam);
}
/**