添加老项目代码,雅诗兰黛代码初始化
parent
55de1615a9
commit
edb807e430
|
@ -47,5 +47,6 @@ src/test/resources/font
|
|||
src/main/resources/WEB-INF/vm/outFile
|
||||
target/
|
||||
*.back
|
||||
src/main/youhong_ai_old_src/
|
||||
src/main/youhong_ai_jitu_src/
|
||||
# 老项目代码
|
||||
#src/main/youhong_ai_old_src/
|
||||
#src/main/youhong_ai_jitu_src/
|
|
@ -0,0 +1,38 @@
|
|||
package com.api.youhong.ai.yashilandai.openbill.controller;
|
||||
|
||||
import aiyh.utils.ApiResult;
|
||||
import aiyh.utils.Util;
|
||||
import com.api.youhong.ai.yashilandai.openbill.service.OpenThenBillService;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import javax.ws.rs.Consumes;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
|
||||
/**
|
||||
* <h1>拆单api接口</h1>
|
||||
*
|
||||
* <p>create: 2023/4/25 10:09</p>
|
||||
*
|
||||
* @author youHong.ai
|
||||
*/
|
||||
|
||||
@Path("/ayh/estee-Lauder/open-bill")
|
||||
public class OpenThenBillController {
|
||||
|
||||
private final OpenThenBillService service = new OpenThenBillService();
|
||||
private final Logger log = Util.getLogger();
|
||||
|
||||
@Path("/data/get")
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
public String dataGet() {
|
||||
try {
|
||||
return ApiResult.success(service.getOpenBillListData());
|
||||
} catch (Exception e) {
|
||||
log.error("get open the bill data error!" + Util.getErrString(e));
|
||||
return ApiResult.error("system error!");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
package com.api.youhong.ai.yashilandai.openbill.mapper;
|
||||
|
||||
import aiyh.utils.annotation.recordset.Select;
|
||||
import aiyh.utils.annotation.recordset.SqlMapper;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* <h1></h1>
|
||||
*
|
||||
* <p>create: 2023/4/25 10:15</p>
|
||||
*
|
||||
* @author youHong.ai
|
||||
*/
|
||||
@SqlMapper
|
||||
public interface OpenThenBillMapper {
|
||||
|
||||
/**
|
||||
* <h2>查询数据列表</h2>
|
||||
*
|
||||
* @return 数据列表
|
||||
*/
|
||||
@Select("select * from v_online")
|
||||
List<Map<String, Object>> selectList();
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
package com.api.youhong.ai.yashilandai.openbill.service;
|
||||
|
||||
import aiyh.utils.Util;
|
||||
import com.api.youhong.ai.yashilandai.openbill.mapper.OpenThenBillMapper;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* <h1></h1>
|
||||
*
|
||||
* <p>create: 2023/4/25 10:12</p>
|
||||
*
|
||||
* @author youHong.ai
|
||||
*/
|
||||
public class OpenThenBillService {
|
||||
|
||||
|
||||
private final OpenThenBillMapper mapper = Util.getMapper(OpenThenBillMapper.class);
|
||||
|
||||
public Object getOpenBillListData() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public List<Map<String, Object>> getData() {
|
||||
List<Map<String, Object>> dataList = mapper.selectList();
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,48 @@
|
|||
package com.api.company;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.engine.common.util.ParamUtil;
|
||||
import jntchina.service.oa.util.ModifyDetailInfo;
|
||||
import weaver.general.Util;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.POST;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.core.Context;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
@Path("/jnt/company")
|
||||
public class CompanyInfo {
|
||||
@GET
|
||||
@Path("/test")
|
||||
@Produces({"text/plain"})
|
||||
public String test(@Context HttpServletRequest request, @Context HttpServletResponse response){
|
||||
Map<String, Object> apidatas = new HashMap<String, Object>();
|
||||
System.out.println("de");
|
||||
String mess="";
|
||||
String path="";
|
||||
boolean api_status=true;
|
||||
try {
|
||||
//String field,String fromtableName,String totableName,int modeid,int billid,String qyid 608 9175
|
||||
/** /api/jnt/company/test?field=djgd,cgbl,cgfs,gfzl&fromtableName=uf_jnqyxxbgb_dt1&totableName=uf_jnqyxxbgb_dt2&modeid=35001&billid=608&qyid=9175& **/
|
||||
Map<String, Object> param= ParamUtil.request2Map(request);
|
||||
String field=(String)param.get("field");
|
||||
String fromtableName=(String)param.get("fromtableName");
|
||||
String totableName=(String)param.get("totableName");
|
||||
int modeid= Util.getIntValue((String)param.get("modeid"),0);
|
||||
int billid=Util.getIntValue((String)param.get("billid"),0);;
|
||||
String qyid=(String)param.get("qyid");
|
||||
ModifyDetailInfo modifyDetailInfo=new ModifyDetailInfo(field, fromtableName, totableName, modeid, billid, qyid);
|
||||
modifyDetailInfo.setDtailJson();
|
||||
} catch (Exception e) {
|
||||
mess="异常"+e.getMessage();
|
||||
e.printStackTrace();
|
||||
apidatas.put("status", false);
|
||||
apidatas.put("msg", "catch exception : " + e.getMessage());
|
||||
}
|
||||
return JSONObject.toJSONString(apidatas);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,56 @@
|
|||
package com.api.dys.wdzxys.controller;
|
||||
|
||||
import aiyh.utils.Util;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.api.dys.wdzxys.service.WdzxysWorkflowService;
|
||||
import io.swagger.v3.oas.annotations.parameters.RequestBody;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import javax.ws.rs.POST;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @Author DYS
|
||||
* @Date 2023/3/21 23:15
|
||||
* @description 网点装修验收流程的controller
|
||||
* create at weaver
|
||||
*/
|
||||
@Path("/dys")
|
||||
public class WdzxysWorkflowController {
|
||||
private final Logger log = Util.getLogger();
|
||||
private final WdzxysWorkflowService wdzxysWorkflowService = new WdzxysWorkflowService();
|
||||
|
||||
/**
|
||||
* 获取网点装修验收流程的所属代理商
|
||||
*
|
||||
* @param map
|
||||
* @return
|
||||
*/
|
||||
@Path("/getSsdlq")
|
||||
@POST
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
public String getSsdlq(@RequestBody Map<String, Object> map) {
|
||||
log.info("网点装修验收流程的controller:" + map.toString());
|
||||
String ssdlqId = (String) map.get("ssdlqId");//所属代理区id
|
||||
String ssdlqName = (String) map.get("ssdlqName");//所属代理区name
|
||||
log.info("所属代理区id:[" + ssdlqId + "], 所属代理区name:[" + ssdlqName + "]");
|
||||
//根据代理区name查询代理区的网点编码,然后根据网点编码查所属代理区的个数
|
||||
int ssdlqNum = wdzxysWorkflowService.getssdlqName(ssdlqName);
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
result.put("code", "200");
|
||||
result.put("msg", "查询成功");
|
||||
//查询验收数量 验收数量需要单独设置一个建模表,从建模表里面查询 如果是第一次的话就给一个默认值0
|
||||
int dlqyssl = wdzxysWorkflowService.getdlqysNum(ssdlqName);
|
||||
Map<String, Integer> dataMap = new HashMap<>();
|
||||
dataMap.put("ssdlqNum", ssdlqNum);
|
||||
dataMap.put("dlqyssl", dlqyssl);
|
||||
result.put("data", dataMap);
|
||||
log.info("代理区个数以及代理区验收数量:[" + dataMap.toString() + "]");
|
||||
log.info("返回结果:[" + result.toString() + "]");
|
||||
return JSON.toJSONString(result);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
package com.api.dys.wdzxys.mapper;
|
||||
|
||||
import aiyh.utils.annotation.recordset.ParamMapper;
|
||||
import aiyh.utils.annotation.recordset.Select;
|
||||
import aiyh.utils.annotation.recordset.SqlMapper;
|
||||
|
||||
/**
|
||||
* @Author DYS
|
||||
* @Date 2023/3/21 23:21
|
||||
* @description 网点装修验收流程mapper
|
||||
* create at weaver
|
||||
*/
|
||||
@SqlMapper
|
||||
public interface WdzxysWorkflowMapper {
|
||||
|
||||
@Select("select count(1) from uf_netsiteinfo " +
|
||||
"group by belong_area having belong_area = " +
|
||||
"(select net_code from uf_netsiteinfo u where u.net_name = #{ssdlqName})")
|
||||
int getssdlqName(@ParamMapper("ssdlqName") String ssdlqName);
|
||||
|
||||
@Select("select dlqyssl from uf_dlqyssl where dlqmc = #{ssdlqName}")
|
||||
int getdlqysNum(@ParamMapper("ssdlqName") String ssdlqName);
|
||||
|
||||
@Select("select count(1) from uf_dlqyssl where dlqmc = #{ssdlqName}")
|
||||
int getIfHasdlqmc(@ParamMapper("ssdlqName") String ssdlqName);
|
||||
}
|
|
@ -0,0 +1,39 @@
|
|||
package com.api.dys.wdzxys.service;
|
||||
|
||||
import aiyh.utils.Util;
|
||||
import com.api.dys.wdzxys.mapper.WdzxysWorkflowMapper;
|
||||
import weaver.conn.RecordSet;
|
||||
|
||||
/**
|
||||
* @Author DYS
|
||||
* @Date 2023/3/21 23:22
|
||||
* @description 网点装修验收流程业务实现类
|
||||
* create at weaver
|
||||
*/
|
||||
public class WdzxysWorkflowService {
|
||||
private final WdzxysWorkflowMapper wdzxysWorkflowMapper = Util.getMapper(WdzxysWorkflowMapper.class);
|
||||
|
||||
/**
|
||||
* 根据所属代理区
|
||||
*
|
||||
* @param ssdlqName
|
||||
* @return
|
||||
*/
|
||||
public int getssdlqName(String ssdlqName) {
|
||||
return wdzxysWorkflowMapper.getssdlqName(ssdlqName);
|
||||
}
|
||||
|
||||
/**
|
||||
* 流程归档时 代理区验收数量
|
||||
*
|
||||
* @param ssdlqName
|
||||
* @return
|
||||
*/
|
||||
public int getdlqysNum(String ssdlqName) {
|
||||
int ifHasdlq = wdzxysWorkflowMapper.getIfHasdlqmc(ssdlqName);
|
||||
if (ifHasdlq == 0) {
|
||||
return 0;
|
||||
}
|
||||
return wdzxysWorkflowMapper.getdlqysNum(ssdlqName);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,323 @@
|
|||
package com.api.lh.action;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.api.lh.config.DemoConfig;
|
||||
import com.api.lh.util.CreateProcessUtil;
|
||||
import selfdev.util.base.BaseUtil;
|
||||
import selfdev.util.log.LogTool;
|
||||
import weaver.conn.RecordSet;
|
||||
import weaver.file.Prop;
|
||||
import weaver.general.Util;
|
||||
import weaver.interfaces.workflow.action.Action;
|
||||
import weaver.soa.workflow.request.*;
|
||||
import weaver.workflow.workflow.WorkflowVersion;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* @ClassName CreateSubprocessAction
|
||||
* @Description 创建 01-付款申请-J&T中国(不对接NCC)流程
|
||||
* @Author louh
|
||||
* @Date 2022/4/6 13:53
|
||||
* @Version 1.0
|
||||
*/
|
||||
public class CreateSubprocessAction implements Action, DemoConfig {
|
||||
LogTool log = new LogTool("/log/lh/CreateSubprocessAction", false);
|
||||
//当前环境
|
||||
String mode = Prop.getPropValue("DevToProcess_jntchina", "mode");
|
||||
//付款申请流程id
|
||||
String fk_workflowid = Prop.getPropValue("DevToProcess_jntchina", mode + "_fk_workflowid");
|
||||
|
||||
|
||||
@Override
|
||||
public String execute(RequestInfo ri) {
|
||||
RecordSet rs = new RecordSet();
|
||||
RecordSet rs1 = new RecordSet();
|
||||
|
||||
String requestid = ri.getRequestid();
|
||||
String workflowid = ri.getWorkflowid();
|
||||
try {
|
||||
WorkflowVersion workflowVersion = new WorkflowVersion(fk_workflowid);
|
||||
String newFid = workflowVersion.getActiveVersionWFID();
|
||||
|
||||
//获取表名
|
||||
String tablename = BaseUtil.getBaseInfoByParm("tablename", "workflow_bill", "1", "1", " and id in (select formid from workflow_base where id=" + workflowid + ")");
|
||||
log.writeLog("requestid---> " + requestid + "对应表名tablename---> " + tablename);
|
||||
//主表数据id
|
||||
String id = BaseUtil.getBaseInfoByParm("id", tablename, "requestid", requestid, "");
|
||||
|
||||
//主表申请日期
|
||||
String sqrq = BaseUtil.getBaseInfoByParm("sqrq", tablename, "requestid", requestid, "");
|
||||
//获取明细表不同批次号数据
|
||||
String sql = "select distinct pch,sfsczlccg from " + tablename + "_dt1 where mainid = " + id;
|
||||
log.writeLog("获取明细表数据sql----> " + sql);
|
||||
rs.execute(sql);
|
||||
while (rs.next()) {
|
||||
//实际付款金额
|
||||
double sum = 0.00;
|
||||
//批次号
|
||||
String pch = Util.null2String(rs.getString("pch")).trim();
|
||||
if ("".equals(pch)) {
|
||||
ri.getRequestManager().setMessagecontent("批次号不允许为空!");
|
||||
return FAILURE_AND_CONTINUE;
|
||||
}
|
||||
//是否生成子流程成功
|
||||
String sfsczlccg = Util.null2String(rs.getString("sfsczlccg"));
|
||||
//成功生成子流程则不再生成
|
||||
if ("0".equals(sfsczlccg)) {
|
||||
continue;
|
||||
}
|
||||
//生成子流程
|
||||
RequestService requestService = new RequestService();
|
||||
RequestInfo requestInfo = new RequestInfo();
|
||||
|
||||
//流程workflowid
|
||||
requestInfo.setWorkflowid(newFid);
|
||||
//提醒
|
||||
requestInfo.setRemindtype("0");
|
||||
//紧急程度
|
||||
requestInfo.setRequestlevel("0");
|
||||
//是否自动流转
|
||||
requestInfo.setIsNextFlow("0");
|
||||
|
||||
/* 根据批次号查询该批次号有多少条数据 */
|
||||
String pchSql = "select * from " + tablename + "_dt1 where mainid = " + id + " and pch = " + pch;
|
||||
log.writeLog("根据批次号查询该批次号有多少条数据---> " + pchSql);
|
||||
|
||||
rs1.execute(pchSql);
|
||||
|
||||
//流程创建人id
|
||||
String peopleId = "";
|
||||
//流程标题
|
||||
String bt = "";
|
||||
//公司名称
|
||||
String gsmc = "";
|
||||
//申请人部门id
|
||||
String departmentid = "";
|
||||
//申请人分部id
|
||||
String subcompanyid1 = "";
|
||||
//是否有合同
|
||||
String sfyht = "";
|
||||
//预计付款日期
|
||||
String yjfkrq = "";
|
||||
//供应商名称
|
||||
String gysmc = "";
|
||||
//账户名称
|
||||
String khmc = "";
|
||||
//银行账号
|
||||
String yxzh = "";
|
||||
//开户行
|
||||
String khx = "";
|
||||
//发票号码
|
||||
String fphm = "";
|
||||
//发票类型
|
||||
String fplx = "";
|
||||
//发票日期
|
||||
String fprq = "";
|
||||
//付款说明
|
||||
String fksm = "";
|
||||
//付款类型
|
||||
String fklx = "";
|
||||
|
||||
//拼接明细表数据
|
||||
DetailTableInfo dti = new DetailTableInfo();
|
||||
DetailTable[] dt = new DetailTable[0];
|
||||
int i = 0;
|
||||
while (rs1.next()) {
|
||||
String sqrgh = Util.null2String(rs1.getString("sqrgh")); /* 申请人工号 */
|
||||
/* 根据人员工号获取人员id */
|
||||
peopleId = BaseUtil.getBaseInfoByParm("id", "hrmresource", "workcode", sqrgh, "");
|
||||
if ("".equals(peopleId)) {
|
||||
ri.getRequestManager().setMessagecontent("当前明细表申请人工号【" + sqrgh + "】未找到对应人员,请确认工号是否正确!");
|
||||
return FAILURE_AND_CONTINUE;
|
||||
}
|
||||
//标题
|
||||
bt = Util.null2String(rs1.getString("bt"));
|
||||
//公司名称
|
||||
gsmc = Util.null2String(rs1.getString("gsmc"));
|
||||
//申请人部门id
|
||||
departmentid = BaseUtil.getBaseInfoByParm("departmentid", "hrmresource", "workcode", sqrgh, "");
|
||||
//申请人分部id
|
||||
subcompanyid1 = BaseUtil.getBaseInfoByParm("subcompanyid1", "hrmresource", "workcode", sqrgh, "");
|
||||
//是否有合同
|
||||
sfyht = Util.null2String(rs1.getString("sfyht")).trim();
|
||||
//预计付款日期
|
||||
yjfkrq = Util.null2String(rs1.getString("yjfkrq"));
|
||||
//供应商名称
|
||||
gysmc = Util.null2String(rs1.getString("gysmc"));
|
||||
//账户名称
|
||||
khmc = Util.null2String(rs1.getString("khmc"));
|
||||
//银行账号
|
||||
yxzh = Util.null2String(rs1.getString("yxzh"));
|
||||
//开户行
|
||||
khx = Util.null2String(rs1.getString("khx"));
|
||||
//发票号码
|
||||
fphm = Util.null2String(rs1.getString("fphm"));
|
||||
//发票类型
|
||||
fplx = Util.null2String(rs1.getString("fplx"));
|
||||
//发票日期
|
||||
fprq = Util.null2String(rs1.getString("fprq"));
|
||||
//付款说明
|
||||
fksm = Util.null2String(rs1.getString("fksm"));
|
||||
//付款类型
|
||||
fklx = Util.null2String(rs1.getString("fklx"));
|
||||
//行数据
|
||||
Row[] row = new Row[0];
|
||||
//添加单元格到行
|
||||
Cell[] c = new Cell[0];
|
||||
//添加子表数据
|
||||
row = Arrays.copyOf(row, (row.length + 1));
|
||||
row[row.length - 1] = new Row();
|
||||
row[row.length - 1].setId((i + 1) + "");
|
||||
//费用承担部门
|
||||
String fycdbmbm = Util.null2String(rs1.getString("fycdbmbm")); /* 费用承担部门编码 */
|
||||
String bmid = BaseUtil.getBaseInfoByParm("id", "hrmdepartment", "departmentcode", fycdbmbm, "");
|
||||
|
||||
c = CreateProcessUtil.setCell(c, "fycdbm", bmid);
|
||||
//不含税金额
|
||||
String bhsje = Util.null2String(rs1.getString("bhsje"));
|
||||
if (!"".equals(bhsje)) {
|
||||
bhsje = bhsje.replaceAll(",", "");
|
||||
} else {
|
||||
bhsje = "0.00";
|
||||
}
|
||||
c = CreateProcessUtil.setCell(c, "bhsje", bhsje);
|
||||
//税率
|
||||
c = CreateProcessUtil.setCell(c, "sl", Util.null2String(rs1.getString("sl")));
|
||||
//税额
|
||||
String se = Util.null2String(rs1.getString("se"));
|
||||
if (!"".equals(se)) {
|
||||
se = se.replaceAll(",", "");
|
||||
} else {
|
||||
se = "0.00";
|
||||
}
|
||||
c = CreateProcessUtil.setCell(c, "se", se);
|
||||
//价税合计
|
||||
String jshj = Util.null2String(rs1.getString("jshj"));
|
||||
if (!"".equals(jshj)) {
|
||||
jshj = jshj.replaceAll(",", "");
|
||||
} else {
|
||||
jshj = "0.00";
|
||||
}
|
||||
sum += Double.parseDouble(jshj);
|
||||
c = CreateProcessUtil.setCell(c, "jshj", jshj);
|
||||
//添加一行
|
||||
row[row.length - 1].setCell(c);
|
||||
|
||||
dt = Arrays.copyOf(dt, (dt.length + 1));
|
||||
dt[dt.length - 1] = new DetailTable();
|
||||
dt[dt.length - 1].setId("1");//明细表 dt1 后面的1
|
||||
dt[dt.length - 1].setRow(row);
|
||||
|
||||
++i;
|
||||
}
|
||||
dti.setDetailTable(dt);
|
||||
log.writeLog("明细表数据: " + JSON.toJSONString(dti));
|
||||
requestInfo.setDetailTableInfo(dti);
|
||||
|
||||
|
||||
/* 流程创建人id */
|
||||
requestInfo.setCreatorid(peopleId);
|
||||
//流程标题
|
||||
requestInfo.setDescription(bt);
|
||||
//设置主表字段
|
||||
Property[] p = new Property[0];
|
||||
//公司名称
|
||||
p = CreateProcessUtil.setProperty(p, "gsmc", gsmc);
|
||||
//创建日期
|
||||
p = CreateProcessUtil.setProperty(p, "cjrq", sqrq);
|
||||
//申请人部门id
|
||||
p = CreateProcessUtil.setProperty(p, "fygsbm", departmentid);
|
||||
p = CreateProcessUtil.setProperty(p, "zz", subcompanyid1);
|
||||
//姓名
|
||||
p = CreateProcessUtil.setProperty(p, "xm", peopleId);
|
||||
//是否有合同
|
||||
sfyht = getSelectValue(sfyht, requestInfo.getWorkflowid(), "sfyht", "");
|
||||
//sfyht = getSelectValue(sfyht_fieldid, sfyht);
|
||||
p = CreateProcessUtil.setProperty(p, "sfyht", sfyht);
|
||||
//预计付款日期
|
||||
p = CreateProcessUtil.setProperty(p, "yjfkrq", yjfkrq);
|
||||
//供应商名称
|
||||
p = CreateProcessUtil.setProperty(p, "gysmc", gysmc);
|
||||
//账户名称
|
||||
p = CreateProcessUtil.setProperty(p, "yzhm", khmc);
|
||||
//银行账号
|
||||
p = CreateProcessUtil.setProperty(p, "yxhm", yxzh);
|
||||
//开户行
|
||||
p = CreateProcessUtil.setProperty(p, "yxmz", khx);
|
||||
//发票号码
|
||||
p = CreateProcessUtil.setProperty(p, "fphm", fphm);
|
||||
//发票类型
|
||||
fplx = getSelectValue(fplx, requestInfo.getWorkflowid(), "fplx", "");
|
||||
//fplx = getSelectValue(fplx_fieldid, fplx);
|
||||
p = CreateProcessUtil.setProperty(p, "fplx", fplx);
|
||||
//发票日期
|
||||
p = CreateProcessUtil.setProperty(p, "fprq", fprq);
|
||||
//付款说明
|
||||
p = CreateProcessUtil.setProperty(p, "fksm", fksm);
|
||||
|
||||
//实际付款金额大写
|
||||
p = CreateProcessUtil.setProperty(p, "sjfkje2", sum + "");
|
||||
|
||||
//付款方式 默认 银行汇款
|
||||
p = CreateProcessUtil.setProperty(p, "fkfs", "0");
|
||||
//币种 默认RMB
|
||||
p = CreateProcessUtil.setProperty(p, "bz", "1");
|
||||
//付款类型 默认航空费
|
||||
p = CreateProcessUtil.setProperty(p, "fklx1", fklx);
|
||||
//区域
|
||||
String fbid = BaseUtil.getBaseInfoByParm("subcompanyid1", "hrmresource", "id", peopleId, "");
|
||||
p = CreateProcessUtil.setProperty(p, "qy", fbid);
|
||||
/**********************************新加字段*****************************************/
|
||||
//是否杭百费用 0:是 1:否 为否则显示付款类型值
|
||||
p = CreateProcessUtil.setProperty(p, "sfhbfy", "1");
|
||||
|
||||
//添加主表数据
|
||||
MainTableInfo mti = new MainTableInfo();
|
||||
mti.setProperty(p);
|
||||
log.writeLog("主表数据: " + JSON.toJSONString(mti));
|
||||
requestInfo.setMainTableInfo(mti);
|
||||
//创建流程
|
||||
String request = requestService.createRequest(requestInfo);
|
||||
JSONObject judge = CreateProcessUtil.judge(request);
|
||||
if ("1".equals(judge.getString("status"))) {
|
||||
ri.getRequestManager().setMessagecontent("流程创建失败!");
|
||||
//修改明细表数据
|
||||
String updSql = "update " + tablename + "_dt1 set sfsczlccg = '" + judge.getString("status") + "', cfzlcxx = '" + judge.getString("msg") + "', cfrequestid = '" + judge.getString("requestid") + "' where mainid = " + id + " and pch = '" + pch + "'";
|
||||
log.writeLog("修改明细表数据sql----> " + updSql);
|
||||
rs.execute(updSql);
|
||||
return FAILURE_AND_CONTINUE;
|
||||
}
|
||||
//修改明细表数据
|
||||
String updSql = "update " + tablename + "_dt1 set sfsczlccg = '" + judge.getString("status") + "', cfzlcxx = '" + judge.getString("msg") + "', cfrequestid = '" + judge.getString("requestid") + "' where mainid = " + id + " and pch = '" + pch + "'";
|
||||
log.writeLog("修改明细表数据sql----> " + updSql);
|
||||
rs.execute(updSql);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.writeLog("出现异常---> " + e);
|
||||
ri.getRequestManager().setMessagecontent("内部出错,联系管理员查看问题!");
|
||||
return FAILURE_AND_CONTINUE;
|
||||
}
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 根据字段id和选中名称获取
|
||||
*
|
||||
* @param fieldid
|
||||
* @param selectname
|
||||
* @return
|
||||
*/
|
||||
public String getSelectValue(String fieldid, String selectname) {
|
||||
RecordSet rs = new RecordSet();
|
||||
String selectValue = "";
|
||||
String sql = "select selectvalue from workflow_selectitem where fieldid = " + fieldid + " and convtomultilang(selectname,7) = '" + selectname + "'";
|
||||
rs.execute(sql);
|
||||
if (rs.next()) {
|
||||
selectValue = Util.null2String(rs.getString("selectvalue"));
|
||||
}
|
||||
return selectValue;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,125 @@
|
|||
package com.api.lh.action;
|
||||
|
||||
import com.api.lh.config.DemoConfig;
|
||||
|
||||
import selfdev.util.log.LogTool;
|
||||
import weaver.conn.RecordSet;
|
||||
import weaver.conn.RecordSetTrans;
|
||||
import weaver.general.Util;
|
||||
import weaver.interfaces.workflow.action.Action;
|
||||
import weaver.soa.workflow.request.RequestInfo;
|
||||
|
||||
/**
|
||||
* @ClassName CurrencyModifyAccountAction
|
||||
* @Description 同步冲抵明细信息数据到 --- 供应商预付欠票台账中
|
||||
* @Author louh
|
||||
* @Date 2022/4/27 16:04
|
||||
* @Version 1.0
|
||||
*/
|
||||
public class CurrencyModifyAccountAction implements Action, DemoConfig {
|
||||
@Override
|
||||
public String execute(RequestInfo ri) {
|
||||
String requestid = ri.getRequestid();
|
||||
String workflowid = ri.getWorkflowid();
|
||||
RecordSet rs = new RecordSet();
|
||||
RecordSet rs1 = new RecordSet();
|
||||
RecordSet rs2 = new RecordSet();
|
||||
RecordSet rs3 = new RecordSet();
|
||||
RecordSetTrans rst = new RecordSetTrans();
|
||||
rst.setAutoCommit(false);
|
||||
try{
|
||||
String tableName = getTableName(workflowid);
|
||||
log.writeLog("requestid---> " + requestid + "对应表名tablename---> " + tableName);
|
||||
String id = getId(tableName, requestid);
|
||||
String sql = "select yfkqptzmxid, count(yfkqptzmxid) as sum from " + tableName + "_dt1 where mainid = " + id + " group by yfkqptzmxid having count(yfkqptzmxid) > 1";
|
||||
log.writeLog("根据主表数据id查询当前明细表数据是否有多次选择同一个预付款欠票台账明细id【yfkqptzmxid】sql---->" + sql);
|
||||
rs.execute(sql);
|
||||
if(rs.next()){
|
||||
ri.getRequestManager().setMessagecontent("同一张单据不允许多次选择相同的【预付款欠票台账明细id】,请重新选择抵扣明细表不同的【预付款欠票台账明细id】数据。");
|
||||
return FAILURE_AND_CONTINUE;
|
||||
}
|
||||
sql = "select * from "+ tableName + "_dt1 where mainid = "+ id;
|
||||
log.writeLog("查询当前单据抵扣明细详细信息sql------> " + sql);
|
||||
rs.execute(sql);
|
||||
while(rs.next()){
|
||||
String yfkqptzmxid = Util.null2String(rs.getString("yfkqptzmxid")); /* 预付款欠票台账明细id */
|
||||
// double yfje = Double.parseDouble(Util.null2String(rs.getString("yfje")) == "" ? "0.00" : Util.null2String(rs.getString("yfje"))); /* 预付金额 */
|
||||
double bcdjje = Double.parseDouble(Util.null2String(rs.getString("bcdjje")) == "" ? "0.00" : Util.null2String(rs.getString("bcdjje"))); /* 本次抵扣金额 */
|
||||
String bz = Util.null2String(rs.getString("bz"));/* 备注 */
|
||||
String nccdh = Util.null2String(rs.getString("nccdh")); /* ncc单号 */
|
||||
String xgyflc = Util.null2String(rs.getString("xgyflc")); //相关预付流程
|
||||
String sql1 = "select * from uf_fksqyfb_dt1 where id = " + yfkqptzmxid;
|
||||
log.writeLog("查询台账本次抵扣流程信息sql----> " + sql1);
|
||||
rs1.execute(sql1);
|
||||
//已核销金额
|
||||
double yhxje = 0.00;
|
||||
//剩余未核销金额
|
||||
double sywhxje = 0.00;
|
||||
//预付款金额
|
||||
double fkje = 0.00;
|
||||
//相关核销流程
|
||||
String xghxlc = "";
|
||||
if(rs1.next()){
|
||||
xghxlc = Util.null2String(rs1.getString("xghxlc"));
|
||||
yhxje = Double.parseDouble(Util.null2String(rs1.getString("yhxje")) == "" ? "0.00" : Util.null2String(rs1.getString("yhxje")));
|
||||
sywhxje = Double.parseDouble(Util.null2String(rs1.getString("sywhxje")) == "" ? "0.00" : Util.null2String(rs1.getString("sywhxje")));
|
||||
fkje = Double.parseDouble(Util.null2String(rs1.getString("fkje")) == "" ? "0.00" : Util.null2String(rs1.getString("fkje")));
|
||||
}
|
||||
if(bcdjje > sywhxje){
|
||||
ri.getRequestManager().setMessagecontent("当前抵扣明细本次抵扣金额【" + bcdjje + "】大于剩余未核销金额【" + sywhxje + "】,请确认金额是否正确。");
|
||||
return FAILURE_AND_CONTINUE;
|
||||
}
|
||||
yhxje = bcdjje + yhxje;
|
||||
if(yhxje > fkje){
|
||||
ri.getRequestManager().setMessagecontent("当前抵扣明细本次抵扣金额与历史抵扣金额共【" + yhxje + "】大于借款总金额【" + fkje + "】,请确认金额是否正确。");
|
||||
return FAILURE_AND_CONTINUE;
|
||||
}
|
||||
sywhxje = fkje - yhxje;
|
||||
if(sywhxje < 0.00){
|
||||
ri.getRequestManager().setMessagecontent("当前抵扣明细单据总金额【"+ fkje + "】,核销总金额【" + yhxje + "】相减,则剩余未核销金额小于0.00元,请确认金额是否正确。");
|
||||
return FAILURE_AND_CONTINUE;
|
||||
}
|
||||
|
||||
if("".equals(xghxlc)){
|
||||
xghxlc = requestid;
|
||||
}else {
|
||||
xghxlc += "," + requestid;
|
||||
}
|
||||
|
||||
|
||||
String updSql = "update uf_fksqyfb_dt1 set " +
|
||||
"yhxje = '" + yhxje + "', " +
|
||||
"sywhxje = '" + sywhxje + "'," +
|
||||
" xghxlc ='" + xghxlc + "' where id = '" + yfkqptzmxid + "'";
|
||||
log.writeLog("修改台账信息sql-----> " + updSql);
|
||||
rst.executeSql(updSql);
|
||||
|
||||
sql1 = "select * from uf_fksqyfb where qqid = '" + xgyflc + "'" ;
|
||||
log.writeLog("查询主表总预付金额及核销金额sql----> " + sql1);
|
||||
rs2.execute(sql1);
|
||||
double fkje1 = 0.00;
|
||||
double yhxje1 = 0.00;
|
||||
double sywhxje1 = 0.00;
|
||||
if (rs2.next()){
|
||||
fkje1 = Double.parseDouble(Util.null2String(rs2.getString("fkje"))==""?"0.00":Util.null2String(rs2.getString("fkje")));//付款金额
|
||||
yhxje1 = Double.parseDouble(Util.null2String(rs2.getString("yhxje"))==""?"0.00":Util.null2String(rs2.getString("yhxje")));//已核销金额
|
||||
sywhxje1 = Double.parseDouble(Util.null2String(rs2.getString("sywhxje"))==""?"0.00":Util.null2String(rs2.getString("sywhxje")));//剩余金额
|
||||
}
|
||||
double bchxje = bcdjje + yhxje1;
|
||||
sywhxje1 = fkje1 - bchxje;
|
||||
updSql = "update uf_fksqyfb set yhxje = '" + bchxje + "'," +
|
||||
" sywhxje ='" + sywhxje1 + "' where ncclcdh = '" + nccdh + "' and qqid = '" + xgyflc + "'" ;
|
||||
log.writeLog("修改本次台账主表信息sql-----> " + updSql);
|
||||
//rst.executeSql(updSql);
|
||||
rs3.execute(updSql);
|
||||
}
|
||||
rst.commit();
|
||||
}catch (Exception e){
|
||||
rst.rollback();
|
||||
log.writeLog("出现异常-----> " + e);
|
||||
ri.getRequestManager().setMessagecontent("系统内部出错----> " + e);
|
||||
return FAILURE_AND_CONTINUE;
|
||||
}
|
||||
return SUCCESS;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,123 @@
|
|||
package com.api.lh.action;
|
||||
|
||||
import com.api.lh.config.DemoConfig;
|
||||
import weaver.conn.RecordSet;
|
||||
import weaver.conn.RecordSetTrans;
|
||||
import weaver.general.Util;
|
||||
import weaver.interfaces.workflow.action.Action;
|
||||
import weaver.soa.workflow.request.RequestInfo;
|
||||
|
||||
/**
|
||||
* @ClassName CurrencyModifyAccountAction
|
||||
* @Description 同步冲抵明细信息数据到 --- 供应商预付欠票台账中
|
||||
* @Author ycf
|
||||
* @Date 2022/4/27 16:04
|
||||
* @Version 1.0
|
||||
*/
|
||||
public class CurrencyModifyAccountActionYY implements Action, DemoConfig {
|
||||
@Override
|
||||
public String execute(RequestInfo ri) {
|
||||
String requestid = ri.getRequestid();
|
||||
String workflowid = ri.getWorkflowid();
|
||||
RecordSet rs = new RecordSet();
|
||||
RecordSet rs1 = new RecordSet();
|
||||
RecordSet rs2 = new RecordSet();
|
||||
RecordSet rs3 = new RecordSet();
|
||||
RecordSetTrans rst = new RecordSetTrans();
|
||||
rst.setAutoCommit(false);
|
||||
try{
|
||||
String tableName = getTableName(workflowid);
|
||||
log.writeLog("requestid---> " + requestid + "对应表名tablename---> " + tableName);
|
||||
String id = getId(tableName, requestid);
|
||||
String sql = "select yfkqptzmxid, count(yfkqptzmxid) as sum from " + tableName + "_dt1 where mainid = " + id + " group by yfkqptzmxid having count(yfkqptzmxid) > 1";
|
||||
log.writeLog("根据主表数据id查询当前明细表数据是否有多次选择同一个预付款欠票台账明细id【yfkqptzmxid】sql---->" + sql);
|
||||
rs.execute(sql);
|
||||
if(rs.next()){
|
||||
ri.getRequestManager().setMessagecontent("同一张单据不允许多次选择相同的【预付款欠票台账明细id】,请重新选择抵扣明细表不同的【预付款欠票台账明细id】数据。");
|
||||
return FAILURE_AND_CONTINUE;
|
||||
}
|
||||
sql = "select * from "+ tableName + "_dt1 where mainid = "+ id;
|
||||
log.writeLog("查询当前单据抵扣明细详细信息sql------> " + sql);
|
||||
rs.execute(sql);
|
||||
while(rs.next()){
|
||||
String yfkqptzmxid = Util.null2String(rs.getString("yfkqptzmxid")); /* 预付款欠票台账明细id */
|
||||
// double yfje = Double.parseDouble(Util.null2String(rs.getString("yfje")) == "" ? "0.00" : Util.null2String(rs.getString("yfje"))); /* 预付金额 */
|
||||
double bcdjje = Double.parseDouble(Util.null2String(rs.getString("bcdjje")) == "" ? "0.00" : Util.null2String(rs.getString("bcdjje"))); /* 本次抵扣金额 */
|
||||
String bz = Util.null2String(rs.getString("bz"));/* 备注 */
|
||||
String nccdh = Util.null2String(rs.getString("nccdh")); /* ncc单号 */
|
||||
String xgyflc = Util.null2String(rs.getString("xgyflc")); //相关预付流程
|
||||
String sql1 = "select * from uf_gysqktzyy_dt1 where id = " + yfkqptzmxid;
|
||||
log.writeLog("查询台账本次抵扣流程信息sql----> " + sql1);
|
||||
rs1.execute(sql1);
|
||||
//已核销金额
|
||||
double yhxje = 0.00;
|
||||
//剩余未核销金额
|
||||
double sywhxje = 0.00;
|
||||
//预付款金额
|
||||
double fkje = 0.00;
|
||||
//相关核销流程
|
||||
String xghxlc = "";
|
||||
if(rs1.next()){
|
||||
xghxlc = Util.null2String(rs1.getString("xghxlc"));
|
||||
yhxje = Double.parseDouble(Util.null2String(rs1.getString("yhxje")) == "" ? "0.00" : Util.null2String(rs1.getString("yhxje")));
|
||||
sywhxje = Double.parseDouble(Util.null2String(rs1.getString("sywhxje")) == "" ? "0.00" : Util.null2String(rs1.getString("sywhxje")));
|
||||
fkje = Double.parseDouble(Util.null2String(rs1.getString("fkje")) == "" ? "0.00" : Util.null2String(rs1.getString("fkje")));
|
||||
}
|
||||
if(bcdjje > sywhxje){
|
||||
ri.getRequestManager().setMessagecontent("当前抵扣明细本次抵扣金额【" + bcdjje + "】大于剩余未核销金额【" + sywhxje + "】,请确认金额是否正确。");
|
||||
return FAILURE_AND_CONTINUE;
|
||||
}
|
||||
yhxje = bcdjje + yhxje;
|
||||
if(yhxje > fkje){
|
||||
ri.getRequestManager().setMessagecontent("当前抵扣明细本次抵扣金额与历史抵扣金额共【" + yhxje + "】大于借款总金额【" + fkje + "】,请确认金额是否正确。");
|
||||
return FAILURE_AND_CONTINUE;
|
||||
}
|
||||
sywhxje = fkje - yhxje;
|
||||
if(sywhxje < 0.00){
|
||||
ri.getRequestManager().setMessagecontent("当前抵扣明细单据总金额【"+ fkje + "】,核销总金额【" + yhxje + "】相减,则剩余未核销金额小于0.00元,请确认金额是否正确。");
|
||||
return FAILURE_AND_CONTINUE;
|
||||
}
|
||||
|
||||
if("".equals(xghxlc)){
|
||||
xghxlc = requestid;
|
||||
}else {
|
||||
xghxlc += "," + requestid;
|
||||
}
|
||||
|
||||
|
||||
String updSql = "update uf_gysqktzyy_dt1 set " +
|
||||
"yhxje = '" + yhxje + "', " +
|
||||
"sywhxje = '" + sywhxje + "'," +
|
||||
" xghxlc ='" + xghxlc + "' where id = '" + yfkqptzmxid + "'";
|
||||
log.writeLog("修改台账信息sql-----> " + updSql);
|
||||
rst.executeSql(updSql);
|
||||
|
||||
sql1 = "select * from uf_gysqktzyy where qqid = '" + xgyflc + "'" ;
|
||||
rs2.execute(sql1);
|
||||
double fkje1 = 0.00;
|
||||
double yhxje1 = 0.00;
|
||||
double sywhxje1 = 0.00;
|
||||
if (rs2.next()){
|
||||
fkje1 = Double.parseDouble(Util.null2String(rs2.getString("fkje"))==""?"0.00":Util.null2String(rs2.getString("fkje")));//付款金额
|
||||
yhxje1 = Double.parseDouble(Util.null2String(rs2.getString("yhxje"))==""?"0.00":Util.null2String(rs2.getString("yhxje")));//已核销金额
|
||||
sywhxje1 = Double.parseDouble(Util.null2String(rs2.getString("sywhxje"))==""?"0.00":Util.null2String(rs2.getString("sywhxje")));//剩余金额
|
||||
}
|
||||
double bchxje = bcdjje + yhxje1;
|
||||
sywhxje1 = fkje1 - bchxje;
|
||||
updSql = "update uf_gysqktzyy set yhxje = '" + bchxje + "'," +
|
||||
" sywhxje ='" + sywhxje1 + "' where ncclcdh = '" + nccdh + "' and qqid = '" + xgyflc + "'" ;
|
||||
log.writeLog("修改本次台账主表信息sql-----> " + updSql);
|
||||
//rst.executeSql(updSql);
|
||||
rs3.execute(updSql);
|
||||
|
||||
}
|
||||
rst.commit();
|
||||
}catch (Exception e){
|
||||
rst.rollback();
|
||||
log.writeLog("出现异常-----> " + e);
|
||||
ri.getRequestManager().setMessagecontent("系统内部出错----> " + e);
|
||||
return FAILURE_AND_CONTINUE;
|
||||
}
|
||||
return SUCCESS;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,191 @@
|
|||
package com.api.lh.action;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.api.lh.port.AddJournal;
|
||||
import com.api.lh.port.Items;
|
||||
import com.api.lh.port.StuData;
|
||||
import com.api.lh.util.DUtil;
|
||||
import jntchina.util.HttpClientToDC;
|
||||
import selfdev.util.base.BaseUtil;
|
||||
import selfdev.util.log.LogTool;
|
||||
import weaver.conn.RecordSet;
|
||||
import weaver.file.Prop;
|
||||
import weaver.general.Util;
|
||||
import weaver.interfaces.workflow.action.Action;
|
||||
import weaver.soa.workflow.request.RequestInfo;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @ClassName NCCAdvanceTossAction
|
||||
* @Description 抛转预付单数据给NCC
|
||||
* @Author louh
|
||||
* @Date 2022/3/9 11:06
|
||||
* @Version 1.0
|
||||
*/
|
||||
public class NCCAdvanceTossAction implements Action {
|
||||
|
||||
LogTool log = new LogTool("/log/lh/action/NCCAdvanceTossAction", false);
|
||||
static final String mode = Prop.getPropValue("DevToDC_jntchina","mode");
|
||||
static final String baseUrl = Prop.getPropValue("DevToDC_jntchina", mode + "_baseUrl");
|
||||
|
||||
@Override
|
||||
public String execute(RequestInfo ri) {
|
||||
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
String date = dateFormat.format(new Date());
|
||||
String startDate = date.substring(0, 10);
|
||||
String endDate = date.substring(11);
|
||||
date = getNewDate(startDate, endDate);
|
||||
JSONObject json = new JSONObject();
|
||||
RecordSet rs = new RecordSet();
|
||||
String xrnccsbcsfts = "";
|
||||
String s= "";
|
||||
//单据属性
|
||||
String djsx = "";
|
||||
String requestid = ri.getRequestid();
|
||||
String workflowid = ri.getWorkflowid();
|
||||
try{
|
||||
//获取表名
|
||||
String tablename = BaseUtil.getBaseInfoByParm("tablename", "workflow_bill", "1", "1", " and id in (select formid from workflow_base where id=" + workflowid + ")");
|
||||
log.writeLog("requestid---> " + requestid + "对应表名tablename---> " + tablename);
|
||||
/* 主表数据id */
|
||||
String id = BaseUtil.getBaseInfoByParm("id", tablename, "requestid", requestid, "");
|
||||
/* 流程编号 */
|
||||
String lcbh = BaseUtil.getBaseInfoByParm("lcbh", tablename, "requestid", requestid, "");
|
||||
/* 供应商名称 */
|
||||
String gysmc = BaseUtil.getBaseInfoByParm("gysmc", tablename, "requestid", requestid, "");
|
||||
/* 付款金额 */
|
||||
String fkje = BaseUtil.getBaseInfoByParm("jshjje", tablename, "requestid", requestid, "");
|
||||
/* 公司名称(NCC财务组织编码) */
|
||||
String gsmc = BaseUtil.getBaseInfoByParm("gsmc", tablename, "requestid", requestid, "");
|
||||
/* 制单人 */
|
||||
String zdr = BaseUtil.getBaseInfoByParm("zdr", tablename, "requestid", requestid, "");
|
||||
/* 制单人编码 */
|
||||
String workcode = BaseUtil.getBaseInfoByParm("workcode", "hrmresource", "id", zdr, "");
|
||||
/* 部门 */
|
||||
String bm = BaseUtil.getBaseInfoByParm("fygsbm", tablename, "requestid", requestid, "");
|
||||
/* 部门编码 */
|
||||
String departmentcode = BaseUtil.getBaseInfoByParm("departmentcode", "hrmdepartment", "id", bm, "");
|
||||
/* 银行账号 */
|
||||
String yxhm = BaseUtil.getBaseInfoByParm("yxhm", tablename, "requestid", requestid, "");
|
||||
//是否提示报错信息
|
||||
xrnccsbcsfts = BaseUtil.getBaseInfoByParm("xrnccsbcsfts", tablename, "requestid", requestid, "");
|
||||
//银行付款备注
|
||||
String yxfkbz = BaseUtil.getBaseInfoByParm("yxfkbz", tablename, "requestid", requestid, "");
|
||||
|
||||
double je = Double.parseDouble(fkje.replaceAll(",", ""));
|
||||
String sql = "select * from " + tablename + "_dt2 where mainid = " + id;
|
||||
log.writeLog("查询应付单明细数据sql-----> " + sql);
|
||||
rs.execute(sql);
|
||||
List<Items> list = new ArrayList<>();
|
||||
while(rs.next()){
|
||||
/* 本次付款金额 */
|
||||
String je1 = Util.null2String(rs.getString("bcfkje"));
|
||||
double v = Double.parseDouble(je1.replaceAll(",", ""));
|
||||
/* 付款计划唯一id */
|
||||
String fkjhwyid = Util.null2String(rs.getString("fkjhwyid"));
|
||||
/* 采购订单明细id */
|
||||
String cgddmxid = Util.null2String(rs.getString("cgddmxid"));
|
||||
/* 采购订单号 */
|
||||
String cgddh = Util.null2String(rs.getString("cgddh"));
|
||||
/* 摘要 */
|
||||
String zy = Util.null2String(rs.getString("zy"));
|
||||
/* 成本中心 */
|
||||
String wd = Util.null2String(rs.getString("wd"));
|
||||
|
||||
djsx = Util.null2String(rs.getString("fkdbm"));
|
||||
s = djsx == "F3-Cxx-06" ? "" : djsx;
|
||||
Items items = new Items("1", gysmc,departmentcode, "", "1","CNY",v + "",
|
||||
"1",v + "","1",v + "","1",
|
||||
v + "","1",v + "",cgddmxid,cgddh,fkjhwyid,"",
|
||||
zy, s, "", departmentcode, yxhm, "", wd);
|
||||
|
||||
list.add(items);
|
||||
}
|
||||
StuData stuData = new StuData(gsmc,s,date,"1","CNY",yxhm,je + "",
|
||||
"1",je + "","1",je + "","1",je + "",
|
||||
workcode,requestid,lcbh,gysmc,list,departmentcode, "", yxfkbz);
|
||||
json = (JSONObject) JSONObject.toJSON(stuData);
|
||||
log.writeLog("json-----> " + json);
|
||||
/* 调用NCC付款单接口 */
|
||||
|
||||
//获取token
|
||||
String token = HttpClientToDC.getToken();
|
||||
log.writeLog("获取中台的数据token----》 " + token);
|
||||
if ("".equals(weaver.general.Util.null2String(token))) {
|
||||
ri.getRequestManager().setMessagecontent("未获取到中台token,请联系管理员查看问题!");
|
||||
return FAILURE_AND_CONTINUE;
|
||||
}
|
||||
String result = HttpClientToDC.sendPostApi(baseUrl + "/dcoaapi/ncc/sendPreBill", token, json.toJSONString());
|
||||
|
||||
//String result = NCCUtils.sendApi(baseUrl + "/dcoaapi/ncc/sendPreBill", json.toJSONString());
|
||||
log.writeLog("result----> " + result);
|
||||
|
||||
JSONObject parse = (JSONObject) JSONObject.parse(result);
|
||||
String success = parse.getString("succ");
|
||||
String msg = parse.getString("msg");
|
||||
if(success.equals("true")) {
|
||||
JSONObject data = parse.getJSONObject("data");
|
||||
String billno = data.getString("billno"); /* ncc单据号 */
|
||||
String pk_bill = data.getString("pk_bill");/* ncc单据主键 */
|
||||
String billmaker = data.getString("billmaker"); /* 制单人 */
|
||||
String pk_org = data.getString("pk_org"); /* 财务组织编码 */
|
||||
String updSql = "update " + tablename + " set nccdjzj = '" + pk_bill + "', ncczdr = '" + billmaker + "', nccfkdh ='" + billno + "',ncccwzzbm = '" + pk_org + "',nccfhxx = '" + msg + "',sfcgscnccfkd = 0 where requestid = " + requestid;
|
||||
log.writeLog("修改当前单据NCC回传信息sql----> " + updSql);
|
||||
rs.execute(updSql);
|
||||
//获取回传的明细表付款单id
|
||||
JSONArray items = data.getJSONArray("items");
|
||||
for (int i = 0; i < items.size(); i++) {
|
||||
JSONObject resultData = items.getJSONObject(i);
|
||||
String itemid = resultData.getString("itemid");/* 采购订单明细id */
|
||||
String pk_payitem = resultData.getString("pk_payitem"); /* 付款单id */
|
||||
String payplanid = resultData.getString("payplanid");/* 付款计划id */
|
||||
String upddelSql = "update " + tablename + "_dt2 set fkdid = '" + pk_payitem + "' where cgddmxid = '" + itemid + "' and fkjhwyid = '" + payplanid + "' and mainid = " + id ;
|
||||
log.writeLog("修改明细表的明细数据sql---->" + upddelSql);
|
||||
rs.execute(upddelSql);
|
||||
}
|
||||
}else{
|
||||
String updSql = "update " + tablename + " set sfcgscnccfkd = 1,nccfhxx = '" + msg + "' where requestid = " + requestid;
|
||||
rs.execute(updSql);
|
||||
AddJournal.addInfo("抛转预付单数据到NCC", json, result, "1", requestid);
|
||||
if("yes".equals(xrnccsbcsfts)) {
|
||||
ri.getRequestManager().setMessagecontent(msg);
|
||||
return FAILURE_AND_CONTINUE;
|
||||
}else{
|
||||
return SUCCESS;
|
||||
}
|
||||
}
|
||||
AddJournal.addInfo("抛转预付单数据到NCC", json, result, "0", requestid);
|
||||
}catch (Exception e){
|
||||
AddJournal.addInfo("抛转预付单数据到NCC", json, "出现异常---> " + e, "1", requestid);
|
||||
if("yes".equals(xrnccsbcsfts)) {
|
||||
ri.getRequestManager().setMessagecontent("数据传递出错-----> " + e.getMessage());
|
||||
return FAILURE_AND_CONTINUE;
|
||||
}else{
|
||||
return SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
System.out.println(getNewDate("2022-06-30", "18:00:00"));
|
||||
}
|
||||
|
||||
public static String getNewDate(String startDate, String endDate){
|
||||
if(DUtil.getLastDayOfMonth(startDate).equals(startDate)){
|
||||
int i = endDate.compareTo("18:00:00");
|
||||
if (i >= 0){
|
||||
startDate = DUtil.getFirstDayOfNextMonth(startDate);
|
||||
endDate = "00:30:00";
|
||||
}
|
||||
}
|
||||
|
||||
return startDate + " " + endDate;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,114 @@
|
|||
package com.api.lh.action;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.api.lh.port.AddJournal;
|
||||
import com.wbi.util.Util;
|
||||
import jntchina.util.HttpClientToDC;
|
||||
import jntchina.util.NCCUtils;
|
||||
import selfdev.util.base.BaseUtil;
|
||||
import selfdev.util.log.LogTool;
|
||||
import weaver.conn.RecordSet;
|
||||
import weaver.file.Prop;
|
||||
import weaver.interfaces.workflow.action.Action;
|
||||
import weaver.soa.workflow.request.RequestInfo;
|
||||
|
||||
/**
|
||||
* @ClassName NCCPayableValidationAction
|
||||
* @Description 提交预付单数据到NCC进行效验,判断数据是否一致
|
||||
* @Author louh
|
||||
* @Date 2022/3/1 14:01
|
||||
* @Version 1.0
|
||||
*/
|
||||
public class NCCAdvanceValidationAction implements Action {
|
||||
static final String mode = Prop.getPropValue("DevToDC_jntchina","mode");
|
||||
static final String baseUrl = Prop.getPropValue("DevToDC_jntchina", mode + "_baseUrl");
|
||||
LogTool log = new LogTool("/log/lh/NCCAdvanceValidationAction", false);
|
||||
@Override
|
||||
public String execute(RequestInfo ri) {
|
||||
JSONObject json = new JSONObject();
|
||||
JSONArray jsonArray = new JSONArray();
|
||||
RecordSet rs = new RecordSet();
|
||||
/* 流程requestid */
|
||||
String requestid = ri.getRequestid();
|
||||
/* 流程id */
|
||||
String workflowid = ri.getWorkflowid();
|
||||
try {
|
||||
//获取表名
|
||||
String tablename = BaseUtil.getBaseInfoByParm("tablename", "workflow_bill", "1", "1", " and id in (select formid from workflow_base where id=" + workflowid + ")");
|
||||
|
||||
log.writeLog("requestid---> " + requestid + "对应表名tablename---> " + tablename);
|
||||
|
||||
/* 主表数据id */
|
||||
String id = BaseUtil.getBaseInfoByParm("id", tablename, "requestid", requestid, "");
|
||||
|
||||
String sql = "select * from " + tablename + "_dt2 where mainid = " + id;
|
||||
log.writeLog("查询明细表预付单数据sql-----> " + sql);
|
||||
rs.execute(sql);
|
||||
|
||||
while (rs.next()) {
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
/* 预付单付款计划唯一id */
|
||||
jsonObject.put("pk_item", Util.null2String(rs.getString("fkjhwyid")));
|
||||
/* 本次付款金额 */
|
||||
jsonObject.put("mny", Util.null2String(rs.getString("bcfkje")));
|
||||
jsonArray.add(jsonObject);
|
||||
}
|
||||
json.put("request", jsonArray);
|
||||
log.writeLog("request: " + json);
|
||||
|
||||
//获取token
|
||||
String token = HttpClientToDC.getToken();
|
||||
log.writeLog("获取中台的数据token----》 " + token);
|
||||
if ("".equals(weaver.general.Util.null2String(token))) {
|
||||
ri.getRequestManager().setMessagecontent("未获取到中台token,请联系管理员查看问题!");
|
||||
return FAILURE_AND_CONTINUE;
|
||||
}
|
||||
String result = HttpClientToDC.sendPostApi(baseUrl + "/dcoaapi/ncc/payApplication", token, json.toJSONString());
|
||||
|
||||
|
||||
//result = NCCUtils.sendApi(baseUrl + "/nccloud/api/jitu/arap/busi/mnycheck", json.toJSONString());
|
||||
/* 解析返回的数据 */
|
||||
JSONObject result_json = (JSONObject) JSONObject.parse(result);
|
||||
String allmsg = "";
|
||||
String success = result_json.getString("succ");
|
||||
String msg = result_json.getString("msg");
|
||||
|
||||
if("true".equals(success)) {
|
||||
JSONArray data = result_json.getJSONArray("data");
|
||||
for (int i = 0; i < data.size(); i++) {
|
||||
JSONObject item = data.getJSONObject(i);
|
||||
String flag = item.getString("flag"); /* 是否正确 */
|
||||
if (!"Y".equals(flag)) { //数据不一致
|
||||
String pk_item = item.getString("pk_item");
|
||||
/* 根据预付单付款计划唯一id去查询表单对应数据 */
|
||||
String podb_sql = "select * from " + tablename + "_dt2 where fkjhwyid = '" + pk_item +"' and mainid = " + id;
|
||||
log.writeLog("根据预付单明细行唯一id去查询表单对应数据sql-----> " + podb_sql);
|
||||
rs.execute(podb_sql);
|
||||
if(rs.next()){
|
||||
/* 采购订单号 */
|
||||
String cgddh = Util.null2String(rs.getString("cgddh"));
|
||||
allmsg += cgddh + ",";
|
||||
}
|
||||
}
|
||||
}
|
||||
}else{
|
||||
ri.getRequestManager().setMessagecontent(msg);
|
||||
AddJournal.addInfo("效验预付单据数据是否正确", json, result, "1", requestid);
|
||||
return FAILURE_AND_CONTINUE;
|
||||
}
|
||||
if(!"".equals(allmsg)){
|
||||
allmsg += "数据效验不通过!请删除当前单据,重新获取NCC数据并选择!";
|
||||
ri.getRequestManager().setMessagecontent(allmsg);
|
||||
AddJournal.addInfo("效验预付单据数据是否正确", json, result, "1", requestid);
|
||||
return FAILURE_AND_CONTINUE;
|
||||
}
|
||||
AddJournal.addInfo("效验预付单据数据是否正确", json, result, "0", requestid);
|
||||
}catch (Exception e) {
|
||||
AddJournal.addInfo("效验预付单据数据是否正确", json, "出现异常" + e, "1", requestid);
|
||||
ri.getRequestManager().setMessagecontent("数据传递出错----> " + e.getMessage());
|
||||
return FAILURE_AND_CONTINUE;
|
||||
}
|
||||
return SUCCESS;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,166 @@
|
|||
package com.api.lh.action;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.alibaba.fastjson.serializer.SerializerFeature;
|
||||
import com.api.lh.config.DemoConfig;
|
||||
import com.api.lh.port.AddJournal;
|
||||
import com.api.lh.port.Billdata;
|
||||
import com.api.lh.port.ErBxcontrast;
|
||||
import jntchina.util.HttpClientToDC;
|
||||
import selfdev.util.base.BaseUtil;
|
||||
import selfdev.util.log.LogTool;
|
||||
import weaver.conn.RecordSet;
|
||||
import weaver.general.Util;
|
||||
import weaver.interfaces.workflow.action.Action;
|
||||
import weaver.soa.workflow.request.RequestInfo;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @ClassName NCCAdvanceWriteOffAction
|
||||
* @Description 供应商预付核销流程核销数据写入NCC
|
||||
* @Author louh
|
||||
* @Date 2022/4/13 14:06
|
||||
* @Version 1.0
|
||||
*/
|
||||
public class NCCAdvanceWriteOffAction implements Action, DemoConfig {
|
||||
LogTool log = new LogTool("/log/lh/NCCAdvanceWriteOffAction", false);
|
||||
|
||||
@Override
|
||||
public String execute(RequestInfo ri) {
|
||||
String requestid = ri.getRequestid(); //requestid
|
||||
String workflowid = ri.getWorkflowid(); //workflowid
|
||||
RecordSet rs = new RecordSet();
|
||||
Billdata billdata = null; //存储主表数据
|
||||
List<ErBxcontrast> bxcontrasts = new ArrayList<>(); //存储明细数据
|
||||
|
||||
JSONObject json = null; //传递数据
|
||||
|
||||
try {
|
||||
//获取表名
|
||||
String tablename = BaseUtil.getBaseInfoByParm("tablename", "workflow_bill", "1", "1", " and id in (select formid from workflow_base where id=" + workflowid + ")");
|
||||
log.writeLog("requestid---> " + requestid + "对应表名tablename---> " + tablename);
|
||||
//主表数据id
|
||||
String id = BaseUtil.getBaseInfoByParm("id", tablename, "requestid", requestid, "");
|
||||
String sql = "select xgyflc, count(xgyflc) as sum from " + tablename + "_dt1 where mainid = " + id + " group by xgyflc having count(xgyflc) > 1";
|
||||
log.writeLog("根据主表数据id查询当前明细表数据是否有多次选择同一个相关预付流程【requestid】sql---->" + sql);
|
||||
rs.execute(sql);
|
||||
if(rs.next()){
|
||||
ri.getRequestManager().setMessagecontent("同一张单据不允许多次选择相同的【相关预付流程】,请重新选择明细表不同的【相关预付流程】数据。");
|
||||
return FAILURE_AND_CONTINUE;
|
||||
}
|
||||
sql = "select * from " + tablename + "_dt1 where mainid = " + id;
|
||||
log.writeLog("根据主表数据id查询当前明细数据sql----> " + sql);
|
||||
rs.execute(sql);
|
||||
while(rs.next()){
|
||||
//已核销金额
|
||||
double yhxje = Double.parseDouble(Util.null2String(rs.getString("yhxje")) == "" ? "0.00": Util.null2String(rs.getString("yhxje")));
|
||||
//剩余未核销金额
|
||||
double sywhxje = Double.parseDouble(Util.null2String(rs.getString("sywhxje")));
|
||||
//预付金额
|
||||
double yfje = Double.parseDouble(Util.null2String(rs.getString("yfje")));
|
||||
//本次核销金额
|
||||
double bchxje = Double.parseDouble(Util.null2String(rs.getString("bchxje")) == "" ? "0.00" : Util.null2String(rs.getString("bchxje")));
|
||||
//相关预付流程
|
||||
String xgyflc = Util.null2String(rs.getString("xgyflc"));
|
||||
//本次核销金额大于剩余未核销金额
|
||||
if(bchxje > sywhxje){
|
||||
ri.getRequestManager().setMessagecontent("【相关预付流程 " + xgyflc + "】 剩余未核销金额【" + sywhxje + "】元、本次核销金额【" + bchxje + "】、大于【剩余未核销金额】,请重新填写【本次核销金额】");
|
||||
return FAILURE_AND_CONTINUE;
|
||||
}
|
||||
//当前条数共计合计金额
|
||||
double money = yhxje + bchxje;
|
||||
if(money > yfje){
|
||||
ri.getRequestManager().setMessagecontent("【相关预付流程 " + xgyflc + "】 已核销金额【" + yhxje + "】元、本次核销金额【" + bchxje + "】、合计【" + money + "】元!大于预付金额,请重新填写【本次核销金额】");
|
||||
return FAILURE_AND_CONTINUE;
|
||||
}
|
||||
|
||||
//ncc借款单号
|
||||
String nccdh = Util.null2String(rs.getString("nccdh"));
|
||||
ErBxcontrast bxcontrast = new ErBxcontrast(nccdh,"",bchxje + "");
|
||||
bxcontrasts.add(bxcontrast);
|
||||
|
||||
}
|
||||
sql = "select * from " + tablename + " where requestid = " + requestid;
|
||||
log.writeLog("查询当前主表数据sql------> " + sql);
|
||||
rs.execute(sql);
|
||||
if(rs.next()){
|
||||
String sqr = Util.null2String(rs.getString("sqr"));//申请人
|
||||
//申请人工号
|
||||
String workcode = BaseUtil.getBaseInfoByParm("workcode", "hrmresource", "id", sqr, "");
|
||||
String sqbm = Util.null2String(rs.getString("sqbm")); //申请部门
|
||||
//申请部门编码
|
||||
String departmentcode = BaseUtil.getBaseInfoByParm("departmentcode", "hrmdepartment", "id", sqbm, "");
|
||||
String gsmc = Util.null2String(rs.getString("gsmc"));
|
||||
billdata = new Billdata(gsmc, //公司名称
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
Util.null2String(rs.getString("sqrq")), //申请日期
|
||||
Util.null2String(rs.getString("hxje")), //核销金额
|
||||
gsmc,
|
||||
"",
|
||||
workcode,
|
||||
"",
|
||||
"",
|
||||
requestid,
|
||||
Util.null2String(rs.getString("lcbh")), //流程编号
|
||||
"",
|
||||
departmentcode, //申请部门
|
||||
Util.null2String(rs.getString("sm")), //说明
|
||||
bxcontrasts
|
||||
);
|
||||
}
|
||||
|
||||
String result = JSON.toJSONString(billdata, SerializerFeature.DisableCircularReferenceDetect);
|
||||
json = (JSONObject) JSONObject.toJSON(billdata);
|
||||
//获取token
|
||||
String token = HttpClientToDC.getToken();
|
||||
log.writeLog("获取中台的数据token----》 " + token);
|
||||
if ("".equals(Util.null2String(token))) {
|
||||
ri.getRequestManager().setMessagecontent("为获取到中台token,请联系管理员查看问题!");
|
||||
AddJournal.addInfo("还款单接口", json, "未获取到中台token,请联系管理员查看问题!", "1", requestid);
|
||||
return FAILURE_AND_CONTINUE;
|
||||
}
|
||||
|
||||
//调用中台还款单接口
|
||||
log.writeLog("开始调用中台还款单接口--------");
|
||||
result = HttpClientToDC.sendPostApi( baseUrl + "/dcoaapi/ncc/repaymentBill", token, result);
|
||||
JSONObject parse = (JSONObject) JSONObject.parse(result);
|
||||
log.writeLog("返回数据----- " + parse.toJSONString());
|
||||
String success = parse.getString("succ");
|
||||
String msg = parse.getString("msg");
|
||||
if(success.equals("true")) {
|
||||
JSONObject data = parse.getJSONObject("data");
|
||||
String pk_bill = data.getString("pk_bill");/* ncc单据id */
|
||||
String billno = data.getString("billno"); /* ncc单据号 */
|
||||
String updSql = "update " + tablename + " set nccdjzj = '" + pk_bill + "', nccfkdh ='" + billno + "', nccfhxx = '" + msg + "',sfcgscnccfkd = 0 where requestid = " + requestid;
|
||||
log.writeLog("修改当前单据NCC回传信息sql----> " + updSql);
|
||||
rs.execute(updSql);
|
||||
|
||||
}else{
|
||||
String updSql = "update " + tablename + " set sfcgscnccfkd = 1,nccfhxx = '" + msg + "' where requestid = " + requestid;
|
||||
rs.execute(updSql);
|
||||
AddJournal.addInfo("还款单接口", json, result, "1", requestid);
|
||||
ri.getRequestManager().setMessagecontent(msg);
|
||||
return FAILURE_AND_CONTINUE;
|
||||
}
|
||||
AddJournal.addInfo("还款单接口", json, result, "0", requestid);
|
||||
}catch (Exception e){
|
||||
ri.getRequestManager().setMessagecontent("数据传递NCC出错----->" + e);
|
||||
AddJournal.addInfo("还款单接口",json, "出现异常+++" + e, "1", requestid);
|
||||
return FAILURE_AND_CONTINUE;
|
||||
}
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
double yhxje = Double.parseDouble("" == "" ? "0.00": "");
|
||||
System.out.println(yhxje);
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,180 @@
|
|||
package com.api.lh.action;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.alibaba.fastjson.serializer.SerializerFeature;
|
||||
import com.api.lh.port.AddJournal;
|
||||
import jntchina.util.HttpClientToDC;
|
||||
import jntchina.util.NCCUtils;
|
||||
import selfdev.util.log.LogTool;
|
||||
import weaver.file.Prop;
|
||||
import weaver.general.Util;
|
||||
import weaver.interfaces.workflow.action.Action;
|
||||
|
||||
import javax.ws.rs.POST;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.Produces;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @ClassName NCCPayableDataAction
|
||||
* @Description 获取ncc应付单数据
|
||||
* @Author louh
|
||||
* @Date 2022/2/24 10:17
|
||||
* @Version 1.0
|
||||
*/
|
||||
@Path("/Data")
|
||||
public class NCCPayableDataAction {
|
||||
LogTool log = new LogTool("/log/lh/action/NCCPayableDataAction", false);
|
||||
static final String mode = Prop.getPropValue("DevToDC_jntchina","mode");
|
||||
static final String baseUrl = Prop.getPropValue("DevToDC_jntchina", mode + "_baseUrl");
|
||||
|
||||
/* 应付单查询接口 */
|
||||
@POST
|
||||
@Path("/getNCCPayableData")
|
||||
@Produces({"application/json"})
|
||||
public String getNCCPayableData(String data){
|
||||
JSONObject json = null;
|
||||
log.writeLog("应付单data: " + data);
|
||||
String result = "";
|
||||
Map<String, Object> return_map = new HashMap<>();
|
||||
try {
|
||||
json = (JSONObject) JSONObject.parse(data);
|
||||
|
||||
//获取token
|
||||
String token = HttpClientToDC.getToken();
|
||||
log.writeLog("获取中台的数据应付接口token----》 " + token);
|
||||
if ("".equals(Util.null2String(token))) {
|
||||
return_map.put("code", 500);
|
||||
return_map.put("msg", "未获取到中台token,请联系管理员查看问题!");
|
||||
return return_map.toString();
|
||||
}
|
||||
result = HttpClientToDC.sendPostApi(baseUrl + "/dcoaapi/ncc/payableBillSearch", token, data);
|
||||
JSONObject parse = (JSONObject) JSONObject.parse(result);
|
||||
String succ = parse.getString("succ");
|
||||
JSONArray jsonArray = new JSONArray();
|
||||
if ("true".equals(succ)){
|
||||
JSONArray datas = parse.getJSONArray("data");
|
||||
for (int i = 0; i < datas.size(); i++) {
|
||||
JSONObject item = datas.getJSONObject(i);
|
||||
String money = item.getString("money"); //剩余未付金额
|
||||
double v = Double.parseDouble(money);
|
||||
if(v > 0){
|
||||
//获取原对象到账日期
|
||||
String denddate = item.getString("denddate");
|
||||
if(!"".equals(denddate)) {
|
||||
item.remove("denddate");
|
||||
//生成新的到账日期
|
||||
denddate = denddate.substring(0, 10);
|
||||
item.put("denddate", denddate);
|
||||
}
|
||||
jsonArray.add(item);
|
||||
}
|
||||
}
|
||||
//删除原有数据
|
||||
parse.remove("data");
|
||||
parse.put("data", jsonArray);
|
||||
}else{
|
||||
return_map.put("code", 500);
|
||||
return_map.put("msg", "获取信息失败");
|
||||
AddJournal.addInfo("应付单查询接口", json, result, "1", "");
|
||||
return JSON.toJSONString(return_map, SerializerFeature.DisableCircularReferenceDetect);
|
||||
}
|
||||
result = parse.toJSONString();
|
||||
//result = NCCUtils.sendApi(baseUrl + "/nccloud/api/jitu/arap/busi/payablebillquery", data);
|
||||
log.writeLog("result: " + result);
|
||||
AddJournal.addInfo("应付单查询接口", json, result, "0", "");
|
||||
}catch (Exception e){
|
||||
log.writeLog("出现异常: " + e);
|
||||
return_map.put("code", 500);
|
||||
return_map.put("msg", "出现异常 " + e);
|
||||
AddJournal.addInfo("应付单查询接口", json, "出现异常---> " + e, "1", "");
|
||||
return JSON.toJSONString(return_map, SerializerFeature.DisableCircularReferenceDetect);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/* 预付单付款计划查询接口 */
|
||||
@POST
|
||||
@Path("/getNCCAdvanceData")
|
||||
@Produces({"application/json"})
|
||||
public String getNCCAdvanceData(String data){
|
||||
|
||||
JSONObject json = null;
|
||||
log.writeLog("预付单data: " + data);
|
||||
String result = "";
|
||||
Map<String, Object> return_map = new HashMap<>();
|
||||
try {
|
||||
json = (JSONObject) JSONObject.parse(data);
|
||||
//获取token
|
||||
String token = HttpClientToDC.getToken();
|
||||
log.writeLog("获取中台预付单的数据token----》 " + token);
|
||||
if ("".equals(Util.null2String(token))) {
|
||||
return_map.put("code", 500);
|
||||
return_map.put("msg", "未获取到中台token,请联系管理员查看问题!");
|
||||
return return_map.toString();
|
||||
}
|
||||
|
||||
result = HttpClientToDC.sendPostApi(baseUrl + "/dcoaapi/ncc/purchasePaymentBillSearch", token, data);
|
||||
|
||||
//result = NCCUtils.sendApi(baseUrl + "/nccloud/api/jitu/arap/busi/orderquery", data);
|
||||
JSONObject parse = (JSONObject) JSONObject.parse(result);
|
||||
String succ = parse.getString("succ");
|
||||
JSONArray jsonArray = new JSONArray();
|
||||
if ("true".equals(succ)){
|
||||
JSONArray datas = parse.getJSONArray("data");
|
||||
for (int i = 0; i < datas.size(); i++) {
|
||||
JSONObject item = datas.getJSONObject(i);
|
||||
String money = item.getString("money"); //剩余未付金额
|
||||
double v = Double.parseDouble(money);
|
||||
if(v > 0){
|
||||
//获取原对象到账日期
|
||||
String denddate = item.getString("denddate");
|
||||
if(!"".equals(denddate)) {
|
||||
item.remove("denddate");
|
||||
//生成新的到账日期
|
||||
denddate = denddate.substring(0, 10);
|
||||
item.put("denddate", denddate);
|
||||
}
|
||||
jsonArray.add(item);
|
||||
}
|
||||
}
|
||||
//删除原有数据
|
||||
parse.remove("data");
|
||||
parse.put("data", jsonArray);
|
||||
}else{
|
||||
return_map.put("code", 500);
|
||||
return_map.put("msg", "获取信息失败");
|
||||
AddJournal.addInfo("预付单计划查询接口", json, result, "1", "");
|
||||
return JSON.toJSONString(return_map, SerializerFeature.DisableCircularReferenceDetect);
|
||||
}
|
||||
result = parse.toJSONString();
|
||||
log.writeLog("result: " + result);
|
||||
AddJournal.addInfo("预付单计划查询接口", json, result, "0", "");
|
||||
}catch (Exception e){
|
||||
log.writeLog("出现异常: " + e);
|
||||
return_map.put("code", 500);
|
||||
return_map.put("msg", "出现异常 " + e);
|
||||
AddJournal.addInfo("预付单计划查询接口", json, "出现异常---> " + e, "1", "");
|
||||
return JSON.toJSONString(return_map, SerializerFeature.DisableCircularReferenceDetect);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
//NCCPayableDataAction nccPayableDataAction = new NCCPayableDataAction();
|
||||
//String nccPayableData = nccPayableDataAction.getNCCPayableData("{\"pk_org\":\"JTSDCN0001\",\"begindate\":\"2020-03-17\",\"enddate\":\"2022-03-17\",\"pk_supplier\":\"JTSDCN0030\"}");
|
||||
//System.out.println(nccPayableData);
|
||||
//String token = HttpClientToDC.getToken();
|
||||
//System.out.println(token);
|
||||
// 密码
|
||||
//final String password = Prop.getPropValue("DevToDC_jntchina", mode+"_password");
|
||||
//System.out.println("密码:" + password);
|
||||
String time = "2021-01-01 00:00:00";
|
||||
System.out.println(time.substring(0,10));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,182 @@
|
|||
package com.api.lh.action;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.api.lh.port.AddJournal;
|
||||
import com.api.lh.port.Items;
|
||||
import com.api.lh.port.StuData;
|
||||
import jntchina.util.HttpClientToDC;
|
||||
import selfdev.util.base.BaseUtil;
|
||||
import selfdev.util.log.LogTool;
|
||||
import weaver.conn.RecordSet;
|
||||
import weaver.file.Prop;
|
||||
import weaver.general.Util;
|
||||
import weaver.interfaces.workflow.action.Action;
|
||||
import weaver.soa.workflow.request.RequestInfo;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @ClassName NCCPayableTossAction
|
||||
* @Description 抛转应付单数据到NCC
|
||||
* @Author louh
|
||||
* @Date 2022/3/1 14:35
|
||||
* @Version 1.0
|
||||
*/
|
||||
public class NCCPayableTossAction implements Action {
|
||||
LogTool log = new LogTool("/log/lh/action/NCCPayableTossAction", false);
|
||||
static final String mode = Prop.getPropValue("DevToDC_jntchina","mode");
|
||||
static final String baseUrl = Prop.getPropValue("DevToDC_jntchina", mode + "_baseUrl");
|
||||
|
||||
@Override
|
||||
public String execute(RequestInfo ri) {
|
||||
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
String date = dateFormat.format(new Date());
|
||||
|
||||
String startDate = date.substring(0, 10);
|
||||
String endDate = date.substring(11);
|
||||
date = NCCAdvanceTossAction.getNewDate(startDate, endDate);
|
||||
JSONObject json = new JSONObject();
|
||||
RecordSet rs = new RecordSet();
|
||||
String xrnccsbcsfts = "";
|
||||
String requestid = ri.getRequestid();
|
||||
String workflowid = ri.getWorkflowid();
|
||||
/* 单据属性 */
|
||||
String djsx = "";
|
||||
try{
|
||||
//获取表名
|
||||
String tablename = BaseUtil.getBaseInfoByParm("tablename", "workflow_bill", "1", "1", " and id in (select formid from workflow_base where id=" + workflowid + ")");
|
||||
log.writeLog("requestid---> " + requestid + "对应表名tablename---> " + tablename);
|
||||
/* 主表数据id */
|
||||
String id = BaseUtil.getBaseInfoByParm("id", tablename, "requestid", requestid, "");
|
||||
/* 流程编号 */
|
||||
String lcbh = BaseUtil.getBaseInfoByParm("lcbh", tablename, "requestid", requestid, "");
|
||||
/* 供应商名称 */
|
||||
String gysmc = BaseUtil.getBaseInfoByParm("gysmc", tablename, "requestid", requestid, "");
|
||||
/* 付款金额 */
|
||||
String fkje = BaseUtil.getBaseInfoByParm("jshjje", tablename, "requestid", requestid, "");
|
||||
/* 公司名称(NCC财务组织编码) */
|
||||
String gsmc = BaseUtil.getBaseInfoByParm("gsmc", tablename, "requestid", requestid, "");
|
||||
/* 制单人 */
|
||||
String zdr = BaseUtil.getBaseInfoByParm("zdr", tablename, "requestid", requestid, "");
|
||||
/* 制单人编码 */
|
||||
String workcode = BaseUtil.getBaseInfoByParm("workcode", "hrmresource", "id", zdr, "");
|
||||
/* 部门 */
|
||||
String bm = BaseUtil.getBaseInfoByParm("fygsbm", tablename, "requestid", requestid, "");
|
||||
/* 部门编码 */
|
||||
String departmentcode = BaseUtil.getBaseInfoByParm("departmentcode", "hrmdepartment", "id", bm, "");
|
||||
/* 银行账号 */
|
||||
String yxhm = BaseUtil.getBaseInfoByParm("yxhm", tablename, "requestid", requestid, "");
|
||||
//是否提示报错信息
|
||||
xrnccsbcsfts = BaseUtil.getBaseInfoByParm("xrnccsbcsfts", tablename, "requestid", requestid, "");
|
||||
//银行付款备注
|
||||
String yxfkbz = BaseUtil.getBaseInfoByParm("yxfkbz", tablename, "requestid", requestid, "");
|
||||
double je = Double.parseDouble(fkje.replaceAll(",", ""));
|
||||
String sql = "select * from " + tablename + "_dt2 where mainid = " + id;
|
||||
log.writeLog("查询应付单明细数据sql-----> " + sql);
|
||||
rs.execute(sql);
|
||||
List<Items> list = new ArrayList<>();
|
||||
while(rs.next()){
|
||||
/* 本次付款金额 */
|
||||
String je1 = Util.null2String(rs.getString("je"));
|
||||
double v = Double.parseDouble(je1.replaceAll(",", ""));
|
||||
/* 应付单明细行唯一id */
|
||||
String yfdmxxwyid = Util.null2String(rs.getString("yfdmxxwyid"));
|
||||
/* 应付单据号 */
|
||||
String yfdh = Util.null2String(rs.getString("yfdh"));
|
||||
/* 摘要 */
|
||||
String zy = Util.null2String(rs.getString("zy"));
|
||||
/* 单据属性 */
|
||||
djsx = Util.null2String(rs.getString("djsx"));
|
||||
/* 物料 */
|
||||
String wl = Util.null2String(rs.getString("wl"));
|
||||
|
||||
/* 成本中心 */
|
||||
String wd = Util.null2String(rs.getString("wd"));
|
||||
//部门编码
|
||||
String bmbm = Util.null2String(rs.getString("bmbm"));
|
||||
Items items = new Items("1", gysmc,departmentcode, "", "0",
|
||||
"CNY",v + "","1",v + "",
|
||||
"1",v + "","1",v + "","1",
|
||||
v + "",yfdmxxwyid,"","",yfdh, zy, djsx,
|
||||
wl, bmbm, yxhm, "", wd);
|
||||
list.add(items);
|
||||
}
|
||||
StuData stuData = new StuData(gsmc,djsx,date,"1","CNY",
|
||||
yxhm,je + "","1",je + "","1",
|
||||
je + "","1",je + "",workcode,requestid,lcbh,
|
||||
gysmc,list,departmentcode, "", yxfkbz);
|
||||
json = (JSONObject) JSONObject.toJSON(stuData);
|
||||
log.writeLog("json-----> " + json);
|
||||
|
||||
//获取token
|
||||
String token = HttpClientToDC.getToken();
|
||||
log.writeLog("获取中台的数据token----》 " + token);
|
||||
if ("".equals(weaver.general.Util.null2String(token))) {
|
||||
ri.getRequestManager().setMessagecontent("未获取到中台token,请联系管理员查看问题!");
|
||||
return FAILURE_AND_CONTINUE;
|
||||
}
|
||||
String result = HttpClientToDC.sendPostApi(baseUrl + "/dcoaapi/ncc/sendPaymentBill", token, json.toJSONString());
|
||||
|
||||
/* 调用NCC付款单接口 */
|
||||
//String result = NCCUtils.sendApi(baseUrl + "/nccloud/api/jitu/arap/fkbill/insert", json.toJSONString());
|
||||
log.writeLog("result----> " + result);
|
||||
|
||||
JSONObject parse = (JSONObject) JSONObject.parse(result);
|
||||
String success = parse.getString("succ");
|
||||
String msg = parse.getString("msg");
|
||||
if(success.equals("true")) {
|
||||
JSONObject data = parse.getJSONObject("data");
|
||||
String billno = data.getString("billno"); /* ncc单据号 */
|
||||
String pk_bill = data.getString("pk_bill");/* ncc单据主键 */
|
||||
String billmaker = data.getString("billmaker"); /* 制单人 */
|
||||
String pk_org = data.getString("pk_org"); /* 财务组织编码 */
|
||||
String updSql = "update " + tablename + " set nccdjzj = '" + pk_bill + "', ncczdr = '" + billmaker + "', nccfkdh ='" + billno + "',ncccwzzbm = '" + pk_org + "', nccfhxx = '" + msg + "',sfcgscnccfkd = 0 where requestid = " + requestid;
|
||||
log.writeLog("修改当前单据NCC回传信息sql----> " + updSql);
|
||||
rs.execute(updSql);
|
||||
//获取回传的明细表付款单id
|
||||
JSONArray items = data.getJSONArray("items");
|
||||
for (int i = 0; i < items.size(); i++) {
|
||||
JSONObject resultData = items.getJSONObject(i);
|
||||
String itemid = resultData.getString("itemid");/* 应付单明细id */
|
||||
String pk_payitem = resultData.getString("pk_payitem"); /* 付款单id */
|
||||
String upddelSql = "update " + tablename + "_dt2 set fkdid = '" + pk_payitem + "' where yfdmxxwyid = '" + itemid + "' and mainid = " + id ;
|
||||
log.writeLog("修改明细表的明细数据sql---->" + upddelSql);
|
||||
rs.execute(upddelSql);
|
||||
}
|
||||
}else{
|
||||
String updSql = "update " + tablename + " set sfcgscnccfkd = 1,nccfhxx = '" + msg + "' where requestid = " + requestid;
|
||||
rs.execute(updSql);
|
||||
AddJournal.addInfo("抛转应付单数据到NCC", json, result, "1", requestid);
|
||||
if("yes".equals(xrnccsbcsfts)) {
|
||||
ri.getRequestManager().setMessagecontent(msg);
|
||||
return FAILURE_AND_CONTINUE;
|
||||
}else{
|
||||
return SUCCESS;
|
||||
}
|
||||
}
|
||||
AddJournal.addInfo("抛转应付单数据到NCC", json, result, "0", requestid);
|
||||
|
||||
}catch (Exception e){
|
||||
|
||||
AddJournal.addInfo("抛转应付单数据到NCC", json, "出现异常---> " + e, "1", requestid);
|
||||
if("yes".equals(xrnccsbcsfts)) {
|
||||
ri.getRequestManager().setMessagecontent("数据传递出错-----> " + e.getMessage());
|
||||
return FAILURE_AND_CONTINUE;
|
||||
}else{
|
||||
return SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
System.out.println(NCCAdvanceTossAction.getNewDate("2022-06-29", "18:00:00"));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,113 @@
|
|||
package com.api.lh.action;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.api.lh.port.AddJournal;
|
||||
import com.wbi.util.Util;
|
||||
import jntchina.util.HttpClientToDC;
|
||||
import jntchina.util.NCCUtils;
|
||||
import selfdev.util.base.BaseUtil;
|
||||
import selfdev.util.log.LogTool;
|
||||
import weaver.conn.RecordSet;
|
||||
import weaver.file.Prop;
|
||||
import weaver.interfaces.workflow.action.Action;
|
||||
import weaver.soa.workflow.request.RequestInfo;
|
||||
|
||||
/**
|
||||
* @ClassName NCCPayableValidationAction
|
||||
* @Description 提交应付单数据到NCC进行效验,判断数据是否一致
|
||||
* @Author louh
|
||||
* @Date 2022/3/1 14:01
|
||||
* @Version 1.0
|
||||
*/
|
||||
public class NCCPayableValidationAction implements Action {
|
||||
static final String mode = Prop.getPropValue("DevToDC_jntchina","mode");
|
||||
static final String baseUrl = Prop.getPropValue("DevToDC_jntchina", mode + "_baseUrl");
|
||||
|
||||
LogTool log = new LogTool("/log/lh/NCCPayableValidationAction", false);
|
||||
@Override
|
||||
public String execute(RequestInfo ri) {
|
||||
JSONObject json = new JSONObject();
|
||||
JSONArray jsonArray = new JSONArray();
|
||||
RecordSet rs = new RecordSet();
|
||||
/* 流程requestid */
|
||||
String requestid = ri.getRequestid();
|
||||
/* 流程id */
|
||||
String workflowid = ri.getWorkflowid();
|
||||
try {
|
||||
//获取表名
|
||||
String tablename = BaseUtil.getBaseInfoByParm("tablename", "workflow_bill", "1", "1", " and id in (select formid from workflow_base where id=" + workflowid + ")");
|
||||
|
||||
log.writeLog("requestid---> " + requestid + "对应表名tablename---> " + tablename);
|
||||
|
||||
/* 主表数据id */
|
||||
String id = BaseUtil.getBaseInfoByParm("id", tablename, "requestid", requestid, "");
|
||||
|
||||
String sql = "select * from " + tablename + "_dt2 where mainid = " + id;
|
||||
log.writeLog("查询明细表应付单数据sql-----> " + sql);
|
||||
rs.execute(sql);
|
||||
|
||||
while (rs.next()) {
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
/* 应付单明细行唯一id */
|
||||
jsonObject.put("pk_item", Util.null2String(rs.getString("yfdmxxwyid")));
|
||||
/* 本次付款金额 */
|
||||
jsonObject.put("mny", Util.null2String(rs.getString("je")));
|
||||
jsonArray.add(jsonObject);
|
||||
}
|
||||
json.put("request", jsonArray);
|
||||
log.writeLog("request: " + json);
|
||||
|
||||
//获取token
|
||||
String token = HttpClientToDC.getToken();
|
||||
log.writeLog("获取中台的数据token----》 " + token);
|
||||
if ("".equals(weaver.general.Util.null2String(token))) {
|
||||
ri.getRequestManager().setMessagecontent("未获取到中台token,请联系管理员查看问题!");
|
||||
return FAILURE_AND_CONTINUE;
|
||||
}
|
||||
String result = HttpClientToDC.sendPostApi(baseUrl + "/dcoaapi/ncc/payApplication", token, json.toJSONString());
|
||||
|
||||
//result = NCCUtils.sendApi(baseUrl + "nccloud/api/jitu/arap/busi/mnycheck", json.toJSONString());
|
||||
/* 解析返回的数据 */
|
||||
JSONObject result_json = (JSONObject) JSONObject.parse(result);
|
||||
String allmsg = "";
|
||||
String success = result_json.getString("succ");
|
||||
String msg = result_json.getString("msg");
|
||||
if("true".equals(success)){
|
||||
JSONArray data = result_json.getJSONArray("data");
|
||||
for (int i = 0; i < data.size(); i++) {
|
||||
JSONObject item = data.getJSONObject(i);
|
||||
String flag = item.getString("flag"); /* 是否正确 */
|
||||
if(!"Y".equals(flag)) { //数据不一致
|
||||
String pk_item = item.getString("pk_item"); /* 应付款单号 */
|
||||
/* 根据应付单明细行唯一id去查询表单对应数据 */
|
||||
String podb_sql = "select * from " + tablename + "_dt2 where yfdmxxwyid = '" + pk_item +"' and mainid = " + id;
|
||||
log.writeLog("根据应付单明细行唯一id去查询表单对应数据sql-----> " + podb_sql);
|
||||
rs.execute(podb_sql);
|
||||
if(rs.next()){
|
||||
/* 采购订单号 */
|
||||
String cgddh = Util.null2String(rs.getString("cgddh"));
|
||||
allmsg += cgddh + ",";
|
||||
}
|
||||
}
|
||||
}
|
||||
}else{
|
||||
ri.getRequestManager().setMessagecontent(msg);
|
||||
AddJournal.addInfo("效验应付单据数据是否正确", json, result, "1", requestid);
|
||||
return FAILURE_AND_CONTINUE;
|
||||
}
|
||||
if(!"".equals(allmsg)){
|
||||
allmsg += "数据效验不通过!请删除当前单据,重新获取NCC数据并选择!";
|
||||
ri.getRequestManager().setMessagecontent(allmsg);
|
||||
AddJournal.addInfo("效验应付单据数据是否正确", json, result, "1", requestid);
|
||||
return FAILURE_AND_CONTINUE;
|
||||
}
|
||||
AddJournal.addInfo("效验应付单据数据是否正确", json, result, "0", requestid);
|
||||
}catch (Exception e) {
|
||||
AddJournal.addInfo("效验应付单据数据是否正确", json, "出现异常" + e, "1", requestid);
|
||||
ri.getRequestManager().setMessagecontent("数据传递出错----> " + e.getMessage());
|
||||
return FAILURE_AND_CONTINUE;
|
||||
}
|
||||
return SUCCESS;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,111 @@
|
|||
package com.api.lh.action;
|
||||
|
||||
import com.api.lh.config.DemoConfig;
|
||||
import selfdev.util.log.LogTool;
|
||||
import weaver.conn.RecordSet;
|
||||
import weaver.conn.RecordSetTrans;
|
||||
import weaver.general.Util;
|
||||
import weaver.interfaces.workflow.action.Action;
|
||||
import weaver.soa.workflow.request.RequestInfo;
|
||||
|
||||
/**
|
||||
* @ClassName UpdPaymentAccountData
|
||||
* @Description 修改 付款申请(NCC集成)预付台账 数据
|
||||
* @Author louh
|
||||
* @Date 2022/4/21 17:38
|
||||
* @Version 1.0
|
||||
*/
|
||||
public class UpdPaymentAccountAction implements Action, DemoConfig {
|
||||
@Override
|
||||
public String execute(RequestInfo ri) {
|
||||
RecordSet rs = new RecordSet();
|
||||
RecordSet rs1 = new RecordSet();
|
||||
RecordSet rs2 = new RecordSet();
|
||||
RecordSetTrans rst = new RecordSetTrans();
|
||||
rst.setAutoCommit(false);
|
||||
String requestid = ri.getRequestid();
|
||||
String workflowid = ri.getWorkflowid();
|
||||
try {
|
||||
//获取表名
|
||||
String tablename = getTableName(workflowid);
|
||||
log.writeLog("requestid---> " + requestid + "对应表名tablename---> " + tablename);
|
||||
//获取当前表单数据id
|
||||
String id = getId(tablename, requestid);
|
||||
String sql = "select yfkqptzmxid, " +
|
||||
"sum(bchxje) as hxje," +
|
||||
" avg(yfje) as zje," +
|
||||
" avg(sywhxje) as whxje," +
|
||||
" avg(xgyflc) as req, avg(yhxje) as yhxje1 " +
|
||||
"from " + tablename + "_dt1 " +
|
||||
"where mainid = '" + id + "'" +
|
||||
"group by yfkqptzmxid having count(yfkqptzmxid) > 0";
|
||||
log.writeLog("查询明细表1sql-----> " + sql);
|
||||
rs.execute(sql);
|
||||
while(rs.next()){
|
||||
String yfkqptzmxid = Util.null2String(rs.getString("yfkqptzmxid")); //预付款欠票台账明细id
|
||||
double bchxje = Double.parseDouble(Util.null2String(rs.getString("hxje")) == "" ? "0.00" : Util.null2String(rs.getString("hxje"))); //核销金额
|
||||
double yfje = Double.parseDouble(Util.null2String(rs.getString("zje"))==""?"0.00":Util.null2String(rs.getString("zje")));//预付金额
|
||||
double sywhxje = Double.parseDouble(Util.null2String(rs.getString("whxje")) == "" ? "0.00":Util.null2String(rs.getString("whxje"))); //未核销金额
|
||||
String req = Util.null2String(rs.getString("req")); //相关预付流程requestid
|
||||
double yhxje = Double.parseDouble(Util.null2String(rs.getString("yhxje1")) == "" ? "0.00" : Util.null2String(rs.getString("yhxje1"))); //核销金额
|
||||
|
||||
if (bchxje > yfje){
|
||||
ri.getRequestManager().setMessagecontent("预付欠票台账明细id【" + yfkqptzmxid + "】本次核销金额【" + bchxje + "】大于预付总金额【" + yfje + "】");
|
||||
return FAILURE_AND_CONTINUE;
|
||||
}
|
||||
|
||||
//根据供应商预付欠票台账明细id查询该数据为还款金额
|
||||
String sql1 = "select * from uf_fksqyfb_dt1 where id = '" + yfkqptzmxid + "'";
|
||||
log.writeLog("获取剩余未核销金额明细sql-----> " + sql1);
|
||||
rs1.execute(sql1);
|
||||
String xghxlc = "";
|
||||
double sywhxje2 = 0.00;
|
||||
if(rs1.next()){
|
||||
xghxlc = Util.null2String(rs1.getString("xghxlc")); //相关核销流程
|
||||
sywhxje2 = Double.parseDouble(Util.null2String(rs1.getString("sywhxje")) == "" ? "0.00":Util.null2String(rs1.getString("sywhxje"))); //剩余未核销金额
|
||||
}
|
||||
if ("".equals(xghxlc)){
|
||||
xghxlc = requestid;
|
||||
}else{
|
||||
xghxlc += "," + requestid;
|
||||
}
|
||||
yhxje = yhxje + bchxje;
|
||||
if(sywhxje2 < bchxje){
|
||||
ri.getRequestManager().setMessagecontent("预付欠票台账明细id【" + yfkqptzmxid + "】本次核销金额【" + bchxje + "】大于剩余未核销金额【" + sywhxje2 + "】,请重新选取抵扣明细数据,获取最新的台账数据!");
|
||||
return FAILURE_AND_CONTINUE;
|
||||
}
|
||||
sywhxje2 = sywhxje2 - bchxje;
|
||||
|
||||
String updSql = "update uf_fksqyfb_dt1 set yhxje = '" + yhxje + "', sywhxje = '" + sywhxje2 + "', xghxlc = '" + xghxlc + "' where id = " + yfkqptzmxid;
|
||||
log.writeLog("修改供应商预付欠票台账明细sql-----> " + updSql);
|
||||
rst.executeSql(updSql);
|
||||
//查询主表总预付金额及核销金额
|
||||
sql1 = "select * from uf_fksqyfb where qqid = '" + req + "'";
|
||||
log.writeLog("查询主表总预付金额及核销金额sql----> " + sql1);
|
||||
rs1.execute(sql1);
|
||||
if(rs1.next()){
|
||||
double fkje = Double.parseDouble(Util.null2String(rs1.getString("fkje"))==""?"0.00":Util.null2String(rs1.getString("fkje")));//付款金额
|
||||
double yhxje1 = Double.parseDouble(Util.null2String(rs1.getString("yhxje"))==""?"0.00":Util.null2String(rs1.getString("yhxje")));//已核销金额
|
||||
double sywhxje1 = Double.parseDouble(Util.null2String(rs1.getString("sywhxje"))==""?"0.00":Util.null2String(rs1.getString("sywhxje")));//剩余金额
|
||||
|
||||
if(bchxje > sywhxje1){
|
||||
ri.getRequestManager().setMessagecontent("本次核销金额【" + bchxje + "】大于剩余为核销金额【" + sywhxje1 + "】");
|
||||
return FAILURE_AND_CONTINUE;
|
||||
}
|
||||
bchxje = bchxje + yhxje1;
|
||||
sywhxje1 = fkje - bchxje;
|
||||
updSql = "update uf_fksqyfb set sywhxje = '" + sywhxje1 + "', yhxje = '" + bchxje + "' where qqid = '" + req + "'";
|
||||
log.writeLog("修改供应商预付欠票台账主数据sql-----> " + updSql);
|
||||
//rst.executeSql(updSql);
|
||||
rs2.execute(updSql);
|
||||
}
|
||||
}
|
||||
rst.commit();
|
||||
} catch (Exception e) {
|
||||
rst.rollback();
|
||||
ri.getRequestManager().setMessagecontent("修改台账出现异常-----" + e);
|
||||
return FAILURE_AND_CONTINUE;
|
||||
}
|
||||
return SUCCESS;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,109 @@
|
|||
package com.api.lh.action;
|
||||
|
||||
import com.api.lh.config.DemoConfig;
|
||||
import weaver.conn.RecordSet;
|
||||
import weaver.conn.RecordSetTrans;
|
||||
import weaver.general.Util;
|
||||
import weaver.interfaces.workflow.action.Action;
|
||||
import weaver.soa.workflow.request.RequestInfo;
|
||||
|
||||
/**
|
||||
* @ClassName UpdPaymentAccountData
|
||||
* @Description 修改 付款申请(NCC集成)预付台账 数据
|
||||
* @Author ycf
|
||||
* @Date 2022/4/21 17:38
|
||||
* @Version 1.0
|
||||
*/
|
||||
public class UpdPaymentAccountActionYY implements Action, DemoConfig {
|
||||
@Override
|
||||
public String execute(RequestInfo ri) {
|
||||
RecordSet rs = new RecordSet();
|
||||
RecordSet rs1 = new RecordSet();
|
||||
RecordSet rs2 = new RecordSet();
|
||||
RecordSetTrans rst = new RecordSetTrans();
|
||||
rst.setAutoCommit(false);
|
||||
String requestid = ri.getRequestid();
|
||||
String workflowid = ri.getWorkflowid();
|
||||
try {
|
||||
//获取表名
|
||||
String tablename = getTableName(workflowid);
|
||||
log.writeLog("requestid---> " + requestid + "对应表名tablename---> " + tablename);
|
||||
//获取当前表单数据id
|
||||
String id = getId(tablename, requestid);
|
||||
String sql = "select yfkqptzmxid, " +
|
||||
"sum(bchxje) as hxje," +
|
||||
" avg(yfje) as zje," +
|
||||
" avg(sywhxje) as whxje," +
|
||||
" avg(xgyflc) as req, avg(yhxje) as yhxje1 " +
|
||||
"from " + tablename + "_dt1 " +
|
||||
"where mainid = '" + id + "'" +
|
||||
"group by yfkqptzmxid having count(yfkqptzmxid) > 0";
|
||||
log.writeLog("查询明细表1sql-----> " + sql);
|
||||
rs.execute(sql);
|
||||
while(rs.next()){
|
||||
String yfkqptzmxid = Util.null2String(rs.getString("yfkqptzmxid")); //预付款欠票台账明细id
|
||||
double bchxje = Double.parseDouble(Util.null2String(rs.getString("hxje")) == "" ? "0.00" : Util.null2String(rs.getString("hxje"))); //核销金额
|
||||
double yfje = Double.parseDouble(Util.null2String(rs.getString("zje"))==""?"0.00":Util.null2String(rs.getString("zje")));//预付金额
|
||||
double sywhxje = Double.parseDouble(Util.null2String(rs.getString("whxje")) == "" ? "0.00":Util.null2String(rs.getString("whxje"))); //未核销金额
|
||||
String req = Util.null2String(rs.getString("req")); //相关预付流程requestid
|
||||
double yhxje = Double.parseDouble(Util.null2String(rs.getString("yhxje1")) == "" ? "0.00" : Util.null2String(rs.getString("yhxje1"))); //核销金额
|
||||
|
||||
if (bchxje > yfje){
|
||||
ri.getRequestManager().setMessagecontent("预付欠票台账明细id【" + yfkqptzmxid + "】本次核销金额【" + bchxje + "】大于预付总金额【" + yfje + "】");
|
||||
return FAILURE_AND_CONTINUE;
|
||||
}
|
||||
|
||||
//根据供应商预付欠票台账明细id查询该数据为还款金额
|
||||
String sql1 = "select * from uf_gysqktzyy_dt1 where id = '" + yfkqptzmxid + "'";
|
||||
|
||||
rs1.execute(sql1);
|
||||
String xghxlc = "";
|
||||
double sywhxje2 = 0.00;
|
||||
if(rs1.next()){
|
||||
xghxlc = Util.null2String(rs1.getString("xghxlc")); //相关核销流程
|
||||
sywhxje2 = Double.parseDouble(Util.null2String(rs1.getString("sywhxje")) == "" ? "0.00":Util.null2String(rs1.getString("sywhxje"))); //剩余未核销金额
|
||||
}
|
||||
if ("".equals(xghxlc)){
|
||||
xghxlc = requestid;
|
||||
}else{
|
||||
xghxlc += "," + requestid;
|
||||
}
|
||||
yhxje = yhxje + bchxje;
|
||||
if(sywhxje2 < bchxje){
|
||||
ri.getRequestManager().setMessagecontent("预付欠票台账明细id【" + yfkqptzmxid + "】本次核销金额【" + bchxje + "】大于剩余未核销金额【" + sywhxje2 + "】,请重新选取抵扣明细数据,获取最新的台账数据!");
|
||||
return FAILURE_AND_CONTINUE;
|
||||
}
|
||||
sywhxje2 = sywhxje2 - bchxje;
|
||||
String updSql = "update uf_gysqktzyy_dt1 set yhxje = '" + yhxje + "', sywhxje = '" + sywhxje2 + "', xghxlc = '" + xghxlc + "' where id = " + yfkqptzmxid;
|
||||
log.writeLog("修改供应商预付欠票台账明细sql-----> " + updSql);
|
||||
rst.executeSql(updSql);
|
||||
//查询主表总预付金额及核销金额
|
||||
sql1 = "select * from uf_gysqktzyy where qqid = '" + req + "'";
|
||||
log.writeLog("查询主表总预付金额及核销金额sql----> " + sql1);
|
||||
rs1.execute(sql1);
|
||||
if(rs1.next()){
|
||||
double fkje = Double.parseDouble(Util.null2String(rs1.getString("fkje"))==""?"0.00":Util.null2String(rs1.getString("fkje")));//付款金额
|
||||
double yhxje1 = Double.parseDouble(Util.null2String(rs1.getString("yhxje"))==""?"0.00":Util.null2String(rs1.getString("yhxje")));//已核销金额
|
||||
double sywhxje1 = Double.parseDouble(Util.null2String(rs1.getString("sywhxje"))==""?"0.00":Util.null2String(rs1.getString("sywhxje")));//剩余金额
|
||||
|
||||
if(bchxje > sywhxje1){
|
||||
ri.getRequestManager().setMessagecontent("本次核销金额【" + bchxje + "】大于剩余未核销金额【" + sywhxje1 + "】");
|
||||
return FAILURE_AND_CONTINUE;
|
||||
}
|
||||
bchxje = bchxje + yhxje1;
|
||||
sywhxje1 = fkje - bchxje;
|
||||
updSql = "update uf_gysqktzyy set sywhxje = '" + sywhxje1 + "', yhxje = '" + bchxje + "' where qqid = '" + req + "'";
|
||||
log.writeLog("修改供应商预付欠票台账主数据sql-----> " + updSql);
|
||||
//rst.executeSql(updSql);
|
||||
rs2.execute(updSql);
|
||||
}
|
||||
}
|
||||
rst.commit();
|
||||
} catch (Exception e) {
|
||||
rst.rollback();
|
||||
ri.getRequestManager().setMessagecontent("修改台账出现异常-----" + e);
|
||||
return FAILURE_AND_CONTINUE;
|
||||
}
|
||||
return SUCCESS;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,45 @@
|
|||
package com.api.lh.action;
|
||||
|
||||
import selfdev.util.base.BaseUtil;
|
||||
import selfdev.util.log.LogTool;
|
||||
import weaver.conn.RecordSet;
|
||||
import weaver.interfaces.workflow.action.Action;
|
||||
import weaver.soa.workflow.request.RequestInfo;
|
||||
|
||||
/**
|
||||
* @ClassName VaildatePayableDocumentTypeAction
|
||||
* @Description 效验明细选取单据类型是否一致
|
||||
* @Author louh
|
||||
* @Date 2022/3/29 11:40
|
||||
* @Version 1.0
|
||||
*/
|
||||
public class VaildateDocumentTypeAction implements Action {
|
||||
@Override
|
||||
public String execute(RequestInfo ri) {
|
||||
LogTool log = new LogTool("/log/lh/VaildateDocumentTypeAction",false);
|
||||
String requestid = ri.getRequestid();
|
||||
RecordSet rs = new RecordSet();
|
||||
String workflowid = ri.getWorkflowid();
|
||||
try{
|
||||
//获取表名
|
||||
String tablename = BaseUtil.getBaseInfoByParm("tablename", "workflow_bill", "1", "1", " and id in (select formid from workflow_base where id=" + workflowid + ")");
|
||||
log.writeLog("requestid---> " + requestid + "对应表名tablename---> " + tablename);
|
||||
//主表id
|
||||
String id = BaseUtil.getBaseInfoByParm("id", tablename, "requestid", requestid, "");
|
||||
//根据主表数据id获取明细数据sql
|
||||
String sql = "select distinct cgddlx from " + tablename + "_dt2 where mainid = " + id;
|
||||
log.writeLog("根据主表数据id获取明细数据sql---> " + sql);
|
||||
rs.execute(sql);
|
||||
int counts = rs.getCounts();
|
||||
log.writeLog("总行数: " + counts);
|
||||
if(counts > 1){
|
||||
ri.getRequestManager().setMessagecontent("同一张付款单,采购类型必须相同,请重新选择要付款的单据!");
|
||||
return FAILURE_AND_CONTINUE;
|
||||
}
|
||||
}catch (Exception e){
|
||||
ri.getRequestManager().setMessagecontent("内部错误---- > " + e);
|
||||
return FAILURE_AND_CONTINUE;
|
||||
}
|
||||
return SUCCESS;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,43 @@
|
|||
package com.api.lh.action;
|
||||
|
||||
import selfdev.util.base.BaseUtil;
|
||||
import selfdev.util.log.LogTool;
|
||||
import weaver.conn.RecordSet;
|
||||
import weaver.interfaces.workflow.action.Action;
|
||||
import weaver.soa.workflow.request.RequestInfo;
|
||||
|
||||
/**
|
||||
* @ClassName ValidateAdvanceMultiplePodhAction
|
||||
* @Description 预付单禁止一张单据选取不同的采购订单号
|
||||
* @Author louh
|
||||
* @Date 2022/3/30 17:29
|
||||
* @Version 1.0
|
||||
*/
|
||||
public class ValidateAdvanceMultiplePodhAction implements Action {
|
||||
LogTool log = new LogTool("/log/lh/ValidateAdvanceMultiplePodhAction", false);
|
||||
@Override
|
||||
public String execute(RequestInfo ri) {
|
||||
RecordSet rs = new RecordSet();
|
||||
String requestid = ri.getRequestid();
|
||||
String workflowid = ri.getWorkflowid();
|
||||
try {
|
||||
//获取表名
|
||||
String tablename = BaseUtil.getBaseInfoByParm("tablename", "workflow_bill", "1", "1", " and id in (select formid from workflow_base where id=" + workflowid + ")");
|
||||
log.writeLog("requestid---> " + requestid + "对应表名tablename---> " + tablename);
|
||||
String id = BaseUtil.getBaseInfoByParm("id", tablename, "requestid", requestid, "");
|
||||
String sql = "select distinct cgddh from " + tablename + "_dt2 where mainid = " + id;
|
||||
log.writeLog("查询当前单据明细sql---->" + sql);
|
||||
rs.execute(sql);
|
||||
int counts = rs.getCounts();
|
||||
if(counts > 1){
|
||||
ri.getRequestManager().setMessagecontent("一张预付单据不允许选择不同的采购订单号!请重新获取ncc数据,并进行选择!");
|
||||
return FAILURE_AND_CONTINUE;
|
||||
}
|
||||
}catch (Exception e){
|
||||
ri.getRequestManager().setMessagecontent("内部错误--->" + e);
|
||||
log.writeLog("出现异常: " + e);
|
||||
return FAILURE_AND_CONTINUE;
|
||||
}
|
||||
return SUCCESS;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,74 @@
|
|||
package com.api.lh.action;
|
||||
|
||||
import selfdev.util.base.BaseUtil;
|
||||
import selfdev.util.log.LogTool;
|
||||
import weaver.conn.RecordSet;
|
||||
import weaver.general.Util;
|
||||
import weaver.interfaces.workflow.action.Action;
|
||||
import weaver.soa.workflow.request.RequestInfo;
|
||||
|
||||
/**
|
||||
* @ClassName ValidateAdvancePodhAction
|
||||
* @Description 效验NCC单号预付单是否有历史流程在审批中
|
||||
* @Author louh
|
||||
* @Date 2022/3/7 15:26
|
||||
* @Version 1.0
|
||||
*/
|
||||
public class ValidateAdvancePodhAction implements Action {
|
||||
|
||||
LogTool log = new LogTool("/log/lh/action/ValidateAdvancePodhAction", false);
|
||||
@Override
|
||||
public String execute(RequestInfo ri) {
|
||||
RecordSet rs = new RecordSet();
|
||||
RecordSet rs1 = new RecordSet();
|
||||
String requestid = ri.getRequestid();
|
||||
|
||||
String workflowid = ri.getWorkflowid();
|
||||
try{
|
||||
//获取表名
|
||||
String tablename = BaseUtil.getBaseInfoByParm("tablename", "workflow_bill", "1", "1", " and id in (select formid from workflow_base where id=" + workflowid + ")");
|
||||
log.writeLog("requestid---> " + requestid + "对应表名tablename---> " + tablename);
|
||||
/* 公司名称 */
|
||||
String gsmc = BaseUtil.getBaseInfoByParm("gsmc", tablename, "requestid", requestid, "");
|
||||
/* 供应商名称 */
|
||||
String gysmc = BaseUtil.getBaseInfoByParm("gysmc", tablename, "requestid", requestid, "");
|
||||
/* 当前主表数据id */
|
||||
String id = BaseUtil.getBaseInfoByParm("id", tablename, "requestid", requestid, "");
|
||||
|
||||
|
||||
String sql = "select * from " + tablename + "_dt2 where mainid = " + id;
|
||||
log.writeLog("查讯当前流程明细表数据sql-----> " + sql);
|
||||
rs.execute(sql);
|
||||
while(rs.next()){
|
||||
/* 采购订单号 */
|
||||
String cgddh = Util.null2String(rs.getString("cgddh"));
|
||||
String sql1 = "select * from cgddcx20220429 where gsmc = '" + gsmc + "' and gysmc ='" + gysmc +"' and cgddh = '" + cgddh + "' and podhName = 0 and stutas not in (0,3)";
|
||||
log.writeLog("获取当前采购订单号是否有在审批中的流程sql----> " + sql1);
|
||||
rs1.execute(sql1);
|
||||
if(rs1.next()){ //如果有值说明有在审批中的流程
|
||||
/* 流程编号 */
|
||||
String lcbh = Util.null2String(rs1.getString("lcbh"));
|
||||
String requestid1 = Util.null2String(rs1.getString("requestid"));
|
||||
ri.getRequestManager().setMessagecontent("当前采购订单号【" + cgddh + "】有在审批中的流程,对应的流程编号【" + lcbh +"】和requestid为【" + requestid1 + "】,请先审批完此流程再次提交该流程!");
|
||||
return FAILURE_AND_CONTINUE;
|
||||
}
|
||||
//没有在审批中的流程则判断本次付款金额是否大于剩余未付金额
|
||||
/* 本次付款金额 */
|
||||
String je = Util.null2String(rs.getString("bcfkje"));
|
||||
/* 剩余未付金额 */
|
||||
String sywfje = Util.null2String(rs.getString("sywfje"));
|
||||
double v = Double.parseDouble(je.replaceAll(",", ""));
|
||||
double v1 = Double.parseDouble(sywfje.replaceAll(",", ""));
|
||||
if(v > v1){
|
||||
ri.getRequestManager().setMessagecontent("当前采购订单号【" + cgddh + "】本次付款金额【" +v + "】元,大于剩余未付金额【" + v1 + "】元!");
|
||||
return FAILURE_AND_CONTINUE;
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
ri.getRequestManager().setMessagecontent("提交失败,请联系管理员查看问题----> " + e);
|
||||
log.writeLog("requestid----> " + requestid + " 出现异常: " + e);
|
||||
return FAILURE_AND_CONTINUE;
|
||||
}
|
||||
return SUCCESS;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,73 @@
|
|||
package com.api.lh.action;
|
||||
|
||||
import selfdev.util.base.BaseUtil;
|
||||
import selfdev.util.log.LogTool;
|
||||
import weaver.conn.RecordSet;
|
||||
import weaver.general.Util;
|
||||
import weaver.interfaces.workflow.action.Action;
|
||||
import weaver.soa.workflow.request.RequestInfo;
|
||||
|
||||
/**
|
||||
* @ClassName NCCValidatePayablePodh
|
||||
* @Description 效验NCC单号应付单是否有历史流程在审批中
|
||||
* @Author louh
|
||||
* @Date 2022/3/7 14:32
|
||||
* @Version 1.0
|
||||
*/
|
||||
public class ValidatePayablePodhAction implements Action {
|
||||
LogTool log = new LogTool("/log/lh/action/ValidatePayablePodhAction", false);
|
||||
@Override
|
||||
public String execute(RequestInfo ri) {
|
||||
RecordSet rs = new RecordSet();
|
||||
RecordSet rs1 = new RecordSet();
|
||||
String requestid = ri.getRequestid();
|
||||
|
||||
String workflowid = ri.getWorkflowid();
|
||||
try{
|
||||
//获取表名
|
||||
String tablename = BaseUtil.getBaseInfoByParm("tablename", "workflow_bill", "1", "1", " and id in (select formid from workflow_base where id=" + workflowid + ")");
|
||||
log.writeLog("requestid---> " + requestid + "对应表名tablename---> " + tablename);
|
||||
/* 公司名称 */
|
||||
String gsmc = BaseUtil.getBaseInfoByParm("gsmc", tablename, "requestid", requestid, "");
|
||||
/* 供应商名称 */
|
||||
String gysmc = BaseUtil.getBaseInfoByParm("gysmc", tablename, "requestid", requestid, "");
|
||||
/* 当前主表数据id */
|
||||
String id = BaseUtil.getBaseInfoByParm("id", tablename, "requestid", requestid, "");
|
||||
|
||||
|
||||
String sql = "select * from " + tablename + "_dt2 where mainid = " + id;
|
||||
log.writeLog("查讯当前流程明细表数据sql-----> " + sql);
|
||||
rs.execute(sql);
|
||||
while(rs.next()){
|
||||
/* 采购订单号 */
|
||||
String cgddh = Util.null2String(rs.getString("cgddh"));
|
||||
String sql1 = "select * from cgddcx20220429 where gsmc = '" + gsmc + "' and gysmc ='" + gysmc +"' and cgddh = '" + cgddh + "' and stutas not in (0,3)";
|
||||
log.writeLog("获取当前采购订单号是否有在审批中的流程sql----> " + sql1);
|
||||
rs1.execute(sql1);
|
||||
if(rs1.next()){ //如果有值说明有在审批中的流程
|
||||
/* 流程编号 */
|
||||
String lcbh = Util.null2String(rs1.getString("lcbh"));
|
||||
String requestid1 = Util.null2String(rs1.getString("requestid"));
|
||||
ri.getRequestManager().setMessagecontent("当前采购订单号【" + cgddh + "】有在审批中的流程,对应的流程编号【" + lcbh +"】和requestid为【" + requestid1 + "】,请先审批完此流程再次提交该流程!");
|
||||
return FAILURE_AND_CONTINUE;
|
||||
}
|
||||
//没有在审批中的流程则判断本次付款金额是否大于剩余未付金额
|
||||
/* 本次付款金额 */
|
||||
String je = Util.null2String(rs.getString("je"));
|
||||
/* 剩余未付金额 */
|
||||
String sywfje = Util.null2String(rs.getString("sywfje"));
|
||||
double v = Double.parseDouble(je.replaceAll(",", ""));
|
||||
double v1 = Double.parseDouble(sywfje.replaceAll(",", ""));
|
||||
if(v > v1){
|
||||
ri.getRequestManager().setMessagecontent("当前采购订单号【" + cgddh + "】本次付款金额【" +v + "】元,大于剩余未付金额【" + v1 + "】元!");
|
||||
return FAILURE_AND_CONTINUE;
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
ri.getRequestManager().setMessagecontent("提交失败,请联系管理员查看问题----> " + e);
|
||||
log.writeLog("requestid----> " + requestid + " 出现异常: " + e);
|
||||
return FAILURE_AND_CONTINUE;
|
||||
}
|
||||
return SUCCESS;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,102 @@
|
|||
package com.api.lh.action.two;
|
||||
|
||||
import com.api.lh.config.DemoConfig;
|
||||
import selfdev.util.base.BaseUtil;
|
||||
import selfdev.util.log.LogTool;
|
||||
import weaver.conn.RecordSet;
|
||||
import weaver.general.Util;
|
||||
import weaver.interfaces.workflow.action.Action;
|
||||
import weaver.soa.workflow.request.RequestInfo;
|
||||
|
||||
/**
|
||||
* @ClassName NCCPaymentValidityAction
|
||||
* @Description 付款申请(NCC集成) 提交效验
|
||||
* @Author louh
|
||||
* @Date 2022/5/9 14:42
|
||||
* @Version 1.0
|
||||
*/
|
||||
public class NCCPaymentValidityAction implements Action, DemoConfig {
|
||||
|
||||
@Override
|
||||
public String execute(RequestInfo ri) {
|
||||
RecordSet rs = new RecordSet();
|
||||
String requestid = ri.getRequestid();
|
||||
String workflowid = ri.getWorkflowid();
|
||||
String tableName = getTableName(workflowid);
|
||||
log.writeLog("当前requestid========> " + requestid + " 对应表名为=======> " + tableName);
|
||||
String id = getId(tableName, requestid);
|
||||
|
||||
//1.效验同一张单据是否选择了两条相同的抵扣明细
|
||||
String sql = "select yfkqptzmxid, count(yfkqptzmxid) as sum from " + tableName + "_dt1 where mainid = " + id + " group by yfkqptzmxid having count(yfkqptzmxid) > 1";
|
||||
log.writeLog("根据主表数据id查询当前明细表数据是否有多次选择同一个预付款欠票台账明细id【yfkqptzmxid】sql---->" + sql);
|
||||
rs.execute(sql);
|
||||
if(rs.next()){
|
||||
ri.getRequestManager().setMessagecontent("同一张单据不允许多次选择相同的【预付款欠票台账明细id】,请重新选择抵扣明细表不同的【预付款欠票台账明细id】数据。");
|
||||
return FAILURE_AND_CONTINUE;
|
||||
}
|
||||
|
||||
//供应商名称
|
||||
String gysmc = BaseUtil.getBaseInfoByParm("gysmc", tableName, "requestid", requestid, "");
|
||||
//公司名称
|
||||
String gsmc = BaseUtil.getBaseInfoByParm("gsmc", tableName, "requestid", requestid, "");
|
||||
|
||||
|
||||
//2.效验明细表本次扣减金额是否大于剩余未付金额
|
||||
sql = "select * from " + tableName + "_dt1 where mainid = " + id;
|
||||
rs.execute(sql);
|
||||
while(rs.next()){
|
||||
//剩余未付金额
|
||||
double sywfje = Double.parseDouble(Util.null2String(rs.getString("sywfje")) == "" ? "0.00" : Util.null2String(rs.getString("sywfje")));
|
||||
//本次抵减金额
|
||||
double bcdjje = Double.parseDouble(Util.null2String(rs.getString("bcdjje")) == "" ? "0.00" : Util.null2String(rs.getString("bcdjje")));
|
||||
//预付流程编号
|
||||
String yflcbh = Util.null2String(rs.getString("yflcbh"));
|
||||
|
||||
//效验是否有历史单据再审批中
|
||||
sql = "select b.requestid," +
|
||||
" b.lcbh," +
|
||||
" b.gsmc," +
|
||||
"b.gysmc," +
|
||||
"a.id," +
|
||||
"(select lcbh from uf_fksqyfb where qqid = a.xgyflc) as bh," +
|
||||
"(select currentnodetype from workflow_requestbase where requestid = b.requestid) as stutas" +
|
||||
" from " + tableName + "_dt1 a left join " + tableName + " b on a.mainid = b.id " +
|
||||
" where b.gysmc = '" + gysmc + "' and b.gsmc = '" + gsmc + "' and a.yflcbh = '" + yflcbh + "'";
|
||||
log.writeLog("效验是否有历史单据再审批中sql-----> " + sql);
|
||||
rs.execute(sql);
|
||||
while(rs.next()){
|
||||
String stutas = Util.null2String(rs.getString("stutas")); /* 流程状态 */
|
||||
if(!"0".equals(stutas) && !"3".equals(stutas)){
|
||||
String bh = Util.null2String(rs.getString("bh")); /* 预付流程编号 */
|
||||
String lcbh = Util.null2String(rs.getString("lcbh")); /* 审批中流程编号 */
|
||||
ri.getRequestManager().setMessagecontent("当前抵扣明细中【" + bh + "】正在审批中,审批的流程编号为【" + lcbh + "】,请先走完审批中的流程后继续提交该流程!");
|
||||
return FAILURE_AND_CONTINUE;
|
||||
}
|
||||
}
|
||||
|
||||
if(bcdjje > sywfje){
|
||||
ri.getRequestManager().setMessagecontent("抵扣明细预付流程编号【" + yflcbh + "】中本次抵减金额【" + bcdjje + "】不允许大于剩余未付金额【" + sywfje + "】");
|
||||
return FAILURE_AND_CONTINUE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//4.效验主表抵扣金额是否大于申请金额
|
||||
sql = "select * from " + tableName + " where requestid = " + requestid;
|
||||
log.writeLog("效验主表抵扣金额是否大于申请金额sql-----> " + sql);
|
||||
rs.execute(sql);
|
||||
if(rs.next()){
|
||||
//抵扣金额
|
||||
double dkje = Double.parseDouble(Util.null2String(rs.getString("dkje")) == "" ? "0.00" : Util.null2String(rs.getString("dkje")));
|
||||
//申请金额
|
||||
double jshjje = Double.parseDouble(Util.null2String(rs.getString("jshjje")) == "" ? "0.00" : Util.null2String(rs.getString("jshjje")));
|
||||
if(dkje > jshjje){
|
||||
ri.getRequestManager().setMessagecontent("抵扣总金额【" + dkje + "】不能大于申请总金额【" + jshjje + "】");
|
||||
return FAILURE_AND_CONTINUE;
|
||||
}
|
||||
}
|
||||
return SUCCESS;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,100 @@
|
|||
package com.api.lh.action.two;
|
||||
|
||||
import com.api.lh.config.DemoConfig;
|
||||
import selfdev.util.base.BaseUtil;
|
||||
import weaver.conn.RecordSet;
|
||||
import weaver.general.Util;
|
||||
import weaver.interfaces.workflow.action.Action;
|
||||
import weaver.soa.workflow.request.RequestInfo;
|
||||
|
||||
/**
|
||||
* @ClassName NCCPaymentValidityAction
|
||||
* @Description 付款申请(NCC集成) 提交效验
|
||||
* @Author ycf
|
||||
* @Date 2022/5/9 14:42
|
||||
* @Version 1.0
|
||||
*/
|
||||
public class NCCPaymentValidityActionYY implements Action, DemoConfig {
|
||||
@Override
|
||||
public String execute(RequestInfo ri) {
|
||||
RecordSet rs = new RecordSet();
|
||||
String requestid = ri.getRequestid();
|
||||
String workflowid = ri.getWorkflowid();
|
||||
String tableName = getTableName(workflowid);
|
||||
log.writeLog("当前requestid========> " + requestid + " 对应表名为=======> " + tableName);
|
||||
String id = getId(tableName, requestid);
|
||||
|
||||
//1.效验同一张单据是否选择了两条相同的抵扣明细
|
||||
String sql = "select yfkqptzmxid, count(yfkqptzmxid) as sum from " + tableName + "_dt1 where mainid = " + id + " group by yfkqptzmxid having count(yfkqptzmxid) > 1";
|
||||
log.writeLog("根据主表数据id查询当前明细表数据是否有多次选择同一个预付款欠票台账明细id【yfkqptzmxid】sql---->" + sql);
|
||||
rs.execute(sql);
|
||||
if(rs.next()){
|
||||
ri.getRequestManager().setMessagecontent("同一张单据不允许多次选择相同的【预付款欠票台账明细id】,请重新选择抵扣明细表不同的【预付款欠票台账明细id】数据。");
|
||||
return FAILURE_AND_CONTINUE;
|
||||
}
|
||||
|
||||
//供应商名称
|
||||
String gysmc = BaseUtil.getBaseInfoByParm("gysmc", tableName, "requestid", requestid, "");
|
||||
//公司名称
|
||||
String gsmc = BaseUtil.getBaseInfoByParm("gsmc", tableName, "requestid", requestid, "");
|
||||
|
||||
|
||||
//2.效验明细表本次扣减金额是否大于剩余未付金额
|
||||
sql = "select * from " + tableName + "_dt1 where mainid = " + id;
|
||||
rs.execute(sql);
|
||||
while(rs.next()){
|
||||
//剩余未付金额
|
||||
double sywfje = Double.parseDouble(Util.null2String(rs.getString("sywfje")) == "" ? "0.00" : Util.null2String(rs.getString("sywfje")));
|
||||
//本次抵减金额
|
||||
double bcdjje = Double.parseDouble(Util.null2String(rs.getString("bcdjje")) == "" ? "0.00" : Util.null2String(rs.getString("bcdjje")));
|
||||
//预付流程编号
|
||||
String yflcbh = Util.null2String(rs.getString("yflcbh"));
|
||||
|
||||
//效验是否有历史单据再审批中
|
||||
sql = "select b.requestid," +
|
||||
" b.lcbh," +
|
||||
" b.gsmc," +
|
||||
"b.gysmc," +
|
||||
"a.id," +
|
||||
"(select lcbh from uf_gysqktzyy where qqid = a.xgyflc) as bh," +
|
||||
"(select currentnodetype from workflow_requestbase where requestid = b.requestid) as stutas" +
|
||||
" from " + tableName + "_dt1 a left join " + tableName + " b on a.mainid = b.id " +
|
||||
" where b.gysmc = '" + gysmc + "' and b.gsmc = '" + gsmc + "' and a.yflcbh = '" + yflcbh + "'";
|
||||
log.writeLog("效验是否有历史单据再审批中sql-----> " + sql);
|
||||
rs.execute(sql);
|
||||
while(rs.next()){
|
||||
String stutas = Util.null2String(rs.getString("stutas")); /* 流程状态 */
|
||||
if(!"0".equals(stutas) && !"3".equals(stutas)){
|
||||
String bh = Util.null2String(rs.getString("bh")); /* 预付流程编号 */
|
||||
String lcbh = Util.null2String(rs.getString("lcbh")); /* 审批中流程编号 */
|
||||
ri.getRequestManager().setMessagecontent("当前抵扣明细中【" + bh + "】正在审批中,审批的流程编号为【" + lcbh + "】,请先走完审批中的流程后继续提交该流程!");
|
||||
return FAILURE_AND_CONTINUE;
|
||||
}
|
||||
}
|
||||
|
||||
if(bcdjje > sywfje){
|
||||
ri.getRequestManager().setMessagecontent("抵扣明细预付流程编号【" + yflcbh + "】中本次抵减金额【" + bcdjje + "】不允许大于剩余未付金额【" + sywfje + "】");
|
||||
return FAILURE_AND_CONTINUE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//4.效验主表抵扣金额是否大于申请金额
|
||||
sql = "select * from " + tableName + " where requestid = " + requestid;
|
||||
log.writeLog("效验主表抵扣金额是否大于申请金额sql-----> " + sql);
|
||||
rs.execute(sql);
|
||||
if(rs.next()){
|
||||
//抵扣金额
|
||||
double dkje = Double.parseDouble(Util.null2String(rs.getString("dkje")) == "" ? "0.00" : Util.null2String(rs.getString("dkje")));
|
||||
//申请金额
|
||||
double jshjje = Double.parseDouble(Util.null2String(rs.getString("jshjje")) == "" ? "0.00" : Util.null2String(rs.getString("jshjje")));
|
||||
if(dkje > jshjje){
|
||||
ri.getRequestManager().setMessagecontent("抵扣总金额【" + dkje + "】不能大于申请总金额【" + jshjje + "】");
|
||||
return FAILURE_AND_CONTINUE;
|
||||
}
|
||||
}
|
||||
return SUCCESS;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,357 @@
|
|||
package com.api.lh.action.two;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.alibaba.fastjson.serializer.SerializerFeature;
|
||||
import com.api.lh.config.DemoConfig;
|
||||
import com.api.lh.port.AddJournal;
|
||||
import jntchina.entity.ErBxcontrast;
|
||||
import jntchina.entity.ReimbursementOrder;
|
||||
import jntchina.entity.ReimbursementOrderBody;
|
||||
import jntchina.util.HttpClientToDC;
|
||||
import selfdev.util.base.BaseUtil;
|
||||
import weaver.conn.RecordSet;
|
||||
import weaver.general.Util;
|
||||
import weaver.hrm.resource.ResourceComInfo;
|
||||
import weaver.interfaces.workflow.action.Action;
|
||||
import weaver.soa.workflow.request.RequestInfo;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* @ClassName NCCSupplierCWOAction
|
||||
* @Description 供应商预付核销流程生成NCC对公报销单
|
||||
* @Author louh
|
||||
* @Date 2022/5/16 17:10
|
||||
* @Version 1.0
|
||||
*/
|
||||
public class NCCSupplierCWOAction implements Action, DemoConfig {
|
||||
|
||||
@Override
|
||||
public String execute(RequestInfo ri) {
|
||||
String requestid = ri.getRequestid();
|
||||
String workflowid = ri.getWorkflowid();
|
||||
|
||||
//获取当前用户的登录账号(即工号)
|
||||
String loginid=ri.getRequestManager().getUser().getLoginid();
|
||||
|
||||
ReimbursementOrder reimbursementOrder = new ReimbursementOrder();
|
||||
String tableName = getTableName(workflowid);
|
||||
log.writeLog("当前requestid========> " + requestid + " 对应表名为=======> " + tableName);
|
||||
String id = getId(tableName, requestid);
|
||||
JSONObject json = null;
|
||||
String mainId = "";
|
||||
String isShowErrorMsg = "";//写入NCC失败时是否显示报错信息
|
||||
String pk_org = ""; // 报销单位 JTSDCN0001
|
||||
String fygsbm = ""; // 申请部门
|
||||
String total = ""; // 报销金额 金额由表体相应字段汇总得出
|
||||
String deptid = ""; // 部门 传输编码
|
||||
String djlxbm = "264X-Cxx-YFKHXD"; // 单据类型编码 对私报销单:264X-Cxx-DSBXD 对公报销单:264X-Cxx-DGBXD
|
||||
String djlxmc = "预付核销"; // 单据类型名称 默认 对公报销单
|
||||
String djrq = ""; // 单据日期 yyyy-mm-dd hh:mm:ss
|
||||
String payflag = ""; // 支付状态
|
||||
String paytarget = "1"; // 收款对象 0=员工,1=供应商,2=客户,默认为供应商
|
||||
String receiver = ""; // 收款人
|
||||
String skyhzh = ""; // 收款人银行账号
|
||||
String hbbm = ""; // yonyou88", //收款人(供应商)
|
||||
String custaccount= ""; //收款银行账户(供应商)
|
||||
String jkbxr = ""; // 借款报销人 传输编码
|
||||
String operator = ""; // 录入人
|
||||
String xm= ""; // 申请人
|
||||
String jsfs = "3"; // 结算方式 3 网银
|
||||
String fkyhzh = ""; // 单位银行账户 传输编码
|
||||
String jobid = ""; // 项目
|
||||
String zy = ""; // 报销事由
|
||||
String kjqj = ""; // 会计期间
|
||||
String kjnd = ""; // 会计年度
|
||||
String fjzs = ""; // 附件张数 需业务人员在OA上传附件同时填写附件张数后传数据到NCC
|
||||
String zyx1 = ""; // OA单据号 OA传过来,用于联查单据
|
||||
String zyx2 = ""; // 提交人 提交人姓名
|
||||
String zyx3 = ""; // OA核销单号
|
||||
String zyx5 = ""; // OARequestID
|
||||
String zyx8="";//银行付款备注
|
||||
String zyx9=ri.getRequestManager().getRequestname();//标题
|
||||
String tablecode = "arap_bxbusitem";
|
||||
RecordSet rs = new RecordSet();
|
||||
|
||||
try{
|
||||
String sql = " select * from " + tableName + " where requestid='" + requestid + "'";
|
||||
rs.execute(sql);
|
||||
if(rs.next()) {
|
||||
mainId = id;
|
||||
isShowErrorMsg = Util.null2String(rs.getString("xrnccsbcsfts"));
|
||||
xm = Util.null2String(rs.getString("sqr")); // 借款报销人(取流程申请人)
|
||||
pk_org = Util.null2String(rs.getString("gsmc")); // 公司名称
|
||||
total = Util.null2String(rs.getString("hxje")); // 报销金额 金额由表体相应字段汇总得出
|
||||
fygsbm = Util.null2String(rs.getString("sqbm")); // 申请部门
|
||||
hbbm = Util.null2String(rs.getString("gysmc")); // 收款人,供应商编码
|
||||
custaccount = Util.null2String(rs.getString("yxzh")); // 收款人银行账号
|
||||
zyx8 = Util.null2String(rs.getString("yxfkbz")); //银行付款备注
|
||||
zy = Util.null2String(rs.getString("sm")); // 付款说明
|
||||
zyx1 = Util.null2String(rs.getString("lcbh")); // OA单据号 OA传过来,用于联查单据
|
||||
zyx2 = Util.null2String(rs.getString("sqr")); // 提交人 提交人姓名
|
||||
djrq = Util.null2String(rs.getString("sqrq")); //申请日期
|
||||
zyx5 = requestid; // OARequestID
|
||||
}
|
||||
kjqj = djrq.substring(5,7); // 会计期间
|
||||
kjnd = djrq.substring(0,4); // 会计年度
|
||||
|
||||
//根据部门ID查询部门编码
|
||||
deptid= BaseUtil.getBaseInfoByParm("departmentcode", "hrmdepartment", "id", fygsbm, "");
|
||||
//获取员工默认的组织对应的类型
|
||||
String userDefaultCompanyType=BaseUtil.getBaseInfoByParm("company_type", "v_oa_user_org_nsrsbh", "userid", xm, "");
|
||||
//获取付款单选择的组织对应的类型
|
||||
String selectCompanyType=BaseUtil.getBaseInfoByParm("company_type", "uf_businessunit", "code", pk_org, "");
|
||||
log.writeLog("userDefaultCompanyType------>" + userDefaultCompanyType);
|
||||
log.writeLog("selectCompanyType------>" + selectCompanyType);
|
||||
|
||||
//跨组织,则说明代理区向总部申请付款
|
||||
if(!userDefaultCompanyType.equals(selectCompanyType)){
|
||||
//查询建模维护的对应关系
|
||||
String defaultDeptNo=BaseUtil.getBaseInfoByParm("mroabmbm", "uf_kzzfkdybmsz", "sqgslx", userDefaultCompanyType, " and fkgslx='"+selectCompanyType+"'");
|
||||
log.writeLog("defaultDeptNo------>" + defaultDeptNo);
|
||||
if(!"".equals(defaultDeptNo)){
|
||||
deptid=defaultDeptNo;
|
||||
}
|
||||
}
|
||||
|
||||
//截取前120位
|
||||
if(zy.length()>120){
|
||||
zy=zy.substring(0,120);
|
||||
}
|
||||
//标题截取前150位
|
||||
if (zyx9.length() > 150){
|
||||
zyx9 = zyx9.substring(0, 150);
|
||||
}
|
||||
|
||||
jkbxr = new ResourceComInfo().getWorkcode(xm); //借款报销人工号(即申请人工号)
|
||||
operator = loginid;//
|
||||
|
||||
//获取UUID
|
||||
String uuid= UUID.randomUUID().toString().replace("-", "").toUpperCase();
|
||||
log.writeLog("receiver------>"+receiver);
|
||||
|
||||
//查询抵扣明细
|
||||
sql = " select * from " + tableName + "_dt1 where mainid='" + mainId + "'";
|
||||
rs.execute(sql);
|
||||
// while (rs.next()) {
|
||||
// zyx3+=Util.null2String(rs.getString("yflcbh"))+",";
|
||||
// }
|
||||
//
|
||||
// //将预付流程编号赋值到zyx3字段中
|
||||
// if(!"".equals(zyx3)){
|
||||
// zyx3=zyx3.substring(0,zyx3.length()-1);
|
||||
// }
|
||||
|
||||
reimbursementOrder.setUuid(uuid);
|
||||
reimbursementOrder.setPk_org(pk_org);
|
||||
reimbursementOrder.setTotal(total);
|
||||
reimbursementOrder.setDeptid(deptid);
|
||||
reimbursementOrder.setDjlxbm(djlxbm);
|
||||
reimbursementOrder.setDjrq(djrq);
|
||||
reimbursementOrder.setPayflag(payflag);
|
||||
reimbursementOrder.setPaytarget(paytarget);
|
||||
reimbursementOrder.setReceiver(receiver);
|
||||
reimbursementOrder.setHbbm(hbbm);
|
||||
reimbursementOrder.setSkyhzh(skyhzh);
|
||||
reimbursementOrder.setCustaccount(custaccount);
|
||||
reimbursementOrder.setJkbxr(jkbxr);
|
||||
reimbursementOrder.setOperator(operator);
|
||||
reimbursementOrder.setJsfs(jsfs);
|
||||
reimbursementOrder.setFkyhzh(fkyhzh);
|
||||
reimbursementOrder.setJobid(jobid);
|
||||
reimbursementOrder.setZy(zy);
|
||||
reimbursementOrder.setKjqj(kjqj);
|
||||
reimbursementOrder.setKjnd(kjnd);
|
||||
reimbursementOrder.setFjzs(fjzs);
|
||||
reimbursementOrder.setZyx1(zyx1);
|
||||
reimbursementOrder.setZyx2(zyx2);
|
||||
reimbursementOrder.setZyx3(zyx3);
|
||||
reimbursementOrder.setZyx5(zyx5);
|
||||
reimbursementOrder.setZyx8(zyx8);
|
||||
reimbursementOrder.setZyx9(zyx9);
|
||||
|
||||
log.writeLog("【header数据准备完毕...】");
|
||||
|
||||
//获取OA-NCC发票映射关系表
|
||||
Map<String,String> map_oafplx_nccfplcx=BaseUtil.getMapKeyValueInfoByParm("uf_oafplx_nccfplx", "", "oafplxid", "nccfplxbm");
|
||||
//对公报销
|
||||
List<ReimbursementOrderBody> reimbursementOrderBodyList = new ArrayList<ReimbursementOrderBody>();
|
||||
List<ErBxcontrast> erBxcontrasts = new ArrayList<>();
|
||||
|
||||
int rowno = 0;
|
||||
String sql1 = " select c.INVOICECODE,c.INVOICENUMBER,c.invoicetype,a.* from " + tableName + "_dt1 a "
|
||||
+ " left join fnainvoiceledger c on a.fphm=c.id "
|
||||
+ " where a.mainid = " + mainId;
|
||||
log.writeLog("SQL1-----> " + sql1);
|
||||
rs.execute(sql1);
|
||||
while (rs.next()){
|
||||
String jobid1 = ""; // 项目
|
||||
|
||||
String fycdbm = BaseUtil.getBaseInfoByParm("fycdbm", "uf_fksqyfb_dt1", "id", Util.null2String(rs.getString("yfkqptzmxid")), ""); //费用承担部门
|
||||
String amount = Util.null2String(rs.getString("bchxje")); // 付款
|
||||
String defitem36 = Util.null2o(rs.getString("fpje")); // 发票金额
|
||||
String tax_rate = Util.null2String(rs.getString("sl")); // 税率 3%
|
||||
String tax_amount = Util.null2String(rs.getString("se")); // 税额
|
||||
String tni_amount = Util.null2String(rs.getString("bhsje")); // 无税金额
|
||||
String szxmid = BaseUtil.getBaseInfoByParm("fylx", "uf_fksqyfb_dt1", "id", Util.null2String(rs.getString("yfkqptzmxid")), ""); // 收支项目 0101 汽车费用
|
||||
String fpdm = Util.null2String(rs.getString("INVOICECODE")); // 发票代码
|
||||
String fphm = Util.null2String(rs.getString("INVOICENUMBER")); // 发票号码
|
||||
String invoicetype = Util.null2String(rs.getString("invoicetype")); // OA发票类型
|
||||
//NCC发票类型
|
||||
String fplxpk=Util.null2String(map_oafplx_nccfplcx.get(invoicetype));
|
||||
|
||||
// String fphmId = Util.null2String(rs.getString("fphm")); // 发票号码
|
||||
// if(!"".equals(fphmId)){
|
||||
// // 得到浏览按钮中发票号码的id,再去数据库中把发票号码和发票代码查出来
|
||||
// rsFna.execute(" select * from fnainvoiceledger where id = " + fphmId);
|
||||
// while (rsFna.next()) {
|
||||
// fpdm = Util.null2String(rsFna.getString("INVOICECODE")); // 发票代码
|
||||
// fphm = Util.null2String(rsFna.getString("INVOICENUMBER")); // 发票号码
|
||||
// fplxpk = Util.null2String(map_oafplx_nccfplcx.get(Util.null2String(rsFna.getString("invoicetype")))); // OA发票类型
|
||||
// }
|
||||
// }
|
||||
//发票金额为空时,默认等于付款金额
|
||||
if(Double.parseDouble(defitem36)==0){
|
||||
defitem36=amount;
|
||||
}
|
||||
|
||||
String defitem46 = BaseUtil.getBaseInfoByParm("cbzx", "uf_fksqyfb_dt1", "id", Util.null2String(rs.getString("yfkqptzmxid")), ""); // 网点(成本中心)
|
||||
String defitem45 = BaseUtil.getBaseInfoByParm("gj", "uf_fksqyfb_dt1", "id", Util.null2String(rs.getString("yfkqptzmxid")), ""); // 国家
|
||||
String defitem44 = BaseUtil.getBaseInfoByParm("ck", "uf_fksqyfb_dt1", "id", Util.null2String(rs.getString("yfkqptzmxid")), ""); // 仓库
|
||||
String defitem43 = BaseUtil.getBaseInfoByParm("cph", "uf_fksqyfb_dt1", "id", Util.null2String(rs.getString("yfkqptzmxid")), ""); //车牌号
|
||||
String defitem42 = BaseUtil.getBaseInfoByParm("oamxxid", "uf_fksqyfb_dt1", "id", Util.null2String(rs.getString("yfkqptzmxid")), ""); // OA明细行ID
|
||||
//根据部门ID查询部门编码(传NCC)
|
||||
String fycdbm_NCC=BaseUtil.getBaseInfoByParm("departmentcode", "hrmdepartment", "id", fycdbm, "");
|
||||
|
||||
rowno++;
|
||||
|
||||
log.writeLog("----fycdbm_NCC:" + fycdbm_NCC);
|
||||
log.writeLog("----amount:" + amount);
|
||||
log.writeLog("----tax_rate:" + tax_rate);
|
||||
log.writeLog("----tax_amount:" + tax_amount);
|
||||
log.writeLog("----tni_amount:" + tni_amount);
|
||||
|
||||
|
||||
ReimbursementOrderBody body = new ReimbursementOrderBody();
|
||||
body.setJobid(jobid1);
|
||||
body.setDeptid(fycdbm_NCC);
|
||||
body.setAmount(amount);
|
||||
body.setTax_rate(tax_rate);
|
||||
body.setTax_amount(tax_amount);
|
||||
body.setTni_amount(tni_amount);
|
||||
body.setTablecode(tablecode);
|
||||
body.setRowno(rowno+"");
|
||||
body.setSzxmid(BaseUtil.getBaseInfoByParm("bm", "uf_fylx", "id", szxmid, ""));
|
||||
body.setFpdm(fpdm);
|
||||
body.setFphm(fphm);
|
||||
body.setFplxpk(fplxpk);
|
||||
body.setDefitem36(defitem36);
|
||||
body.setDefitem46(defitem46);
|
||||
body.setDefitem45(defitem45);
|
||||
body.setDefitem44(defitem44);
|
||||
body.setDefitem43(defitem43);
|
||||
body.setDefitem42(defitem42);
|
||||
//body.setDefitem48(fycdbm_NCC);
|
||||
reimbursementOrderBodyList.add(body);
|
||||
}
|
||||
reimbursementOrder.setEr_busitem(reimbursementOrderBodyList);
|
||||
sql = "select yfkqptzmxid, sum(bchxje) as hxje, avg(yfje) as zje, avg(xgyflc) as req from " + tableName + "_dt1" +
|
||||
" where mainid = '" + id + "' group by yfkqptzmxid having count(yfkqptzmxid) > 0";
|
||||
log.writeLog("获取预付核销数据明细sql-----> " +sql);
|
||||
rs.execute(sql);
|
||||
while(rs.next()){
|
||||
String szxmid = BaseUtil.getBaseInfoByParm("fylx", "uf_fksqyfb_dt1", "id", Util.null2String(rs.getString("yfkqptzmxid")), "");
|
||||
ErBxcontrast erBxcontrast = new ErBxcontrast(
|
||||
BaseUtil.getBaseInfoByParm("ncclcdh", "uf_fksqyfb","qqid", Util.null2String(rs.getString("req")), ""),
|
||||
BaseUtil.getBaseInfoByParm("bm", "uf_fylx", "id", szxmid, ""),
|
||||
Util.null2String(rs.getString("hxje")),
|
||||
BaseUtil.getBaseInfoByParm("oamxxid", "uf_fksqyfb_dt1", "id", Util.null2String(rs.getString("yfkqptzmxid")), ""),
|
||||
Util.null2String(rs.getString("yfkqptzmxid")));
|
||||
erBxcontrasts.add(erBxcontrast);
|
||||
}
|
||||
reimbursementOrder.setEr_bxcontrast(erBxcontrasts);
|
||||
String parm=JSONObject.toJSONString(reimbursementOrder, SerializerFeature.DisableCircularReferenceDetect);
|
||||
log.writeLog(djlxmc+"准备传入中台的数据为------>" + parm);
|
||||
//获取TOKEN
|
||||
String token = HttpClientToDC.getToken();
|
||||
log.writeLog("获取数据中台的token------>" + token);
|
||||
if ("".equals(Util.null2String(token))) {
|
||||
String tokenMsg="流程提交失败,未获取到数据中台接口TOKEN,请联系管理员处理!";
|
||||
//将NCC返回结果回写至OA流程表单
|
||||
rs.execute(" update " + tableName + " set sfcgscnccfkd = 1 ,nccfhxx='" + tokenMsg.replace("'", "''") + "' where requestid = " + requestid);
|
||||
AddJournal.addInfo("费用报销接口", JSON.parseObject(parm), tokenMsg, "1", requestid);
|
||||
//是否需要显示报错信息
|
||||
if("yes".equals(isShowErrorMsg)){
|
||||
ri.getRequestManager().setMessagecontent(tokenMsg);
|
||||
return Action.FAILURE_AND_CONTINUE;
|
||||
}else{
|
||||
return SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
//调用NCC接口,将数据传给NCC
|
||||
String returndata = HttpClientToDC.sendPostApi(baseUrl+"/dcnccapi/claimForm/receiveData",token, parm);
|
||||
log.writeLog("【调用数据中台报销接口返回结果result:】" + returndata);
|
||||
if (!"".equals(returndata) && returndata != null) {
|
||||
JSONObject jsonObject = JSONObject.parseObject(returndata);
|
||||
String success = Util.null2String(jsonObject.get("succ"));
|
||||
log.writeLog("--------发送请求返回的success值为:" + success);
|
||||
if ("true".equals(success)) {
|
||||
JSONObject data = jsonObject.getJSONObject("data");
|
||||
String billno = Util.null2String(data.get("billno"));//NCC单号
|
||||
log.writeLog("--------发送请求返回的billno值为:" + billno);
|
||||
//将NCC返回结果回写至OA流程表单
|
||||
rs.execute(" update " + tableName + " set sfcgscnccfkd = 0 , nccfkdh = '" + billno + "',nccfhxx='' where requestid = " + requestid);
|
||||
AddJournal.addInfo("费用报销接口", JSON.parseObject(parm), returndata, "0", requestid);
|
||||
} else {
|
||||
String message = Util.null2String(jsonObject.get("msg"));
|
||||
String message2=message.replace("'", "''");
|
||||
//超出1333个字符,则只截取前面这部分
|
||||
if(message2.length()>1334){
|
||||
message2=message2.substring(0,1333);
|
||||
}
|
||||
//将NCC返回结果回写至OA流程表单
|
||||
rs.execute(" update " + tableName + " set sfcgscnccfkd = 1 ,nccfhxx='" + message2 + "' where requestid = " + requestid);
|
||||
AddJournal.addInfo("费用报销接口", JSON.parseObject(parm), returndata, "1", requestid);
|
||||
//是否需要显示报错信息
|
||||
if("yes".equals(isShowErrorMsg)){
|
||||
ri.getRequestManager().setMessagecontent("流程数据写入NCC生成"+djlxmc+"失败,失败信息:<br/>"+message);
|
||||
return Action.FAILURE_AND_CONTINUE;
|
||||
}else{
|
||||
return SUCCESS;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
String ermsg="流程数据写入NCC生成"+djlxmc+"失败,未获取到接口返回结果,请联系系统管理员处理!";
|
||||
AddJournal.addInfo("费用报销接口", JSON.parseObject(parm), ermsg, "1", requestid);
|
||||
//将NCC返回结果回写至OA流程表单
|
||||
rs.execute(" update " + tableName + " set sfcgscnccfkd = 1 ,nccfhxx='" + ermsg.replace("'", "''") + "' where requestid = " + requestid);
|
||||
//是否需要显示报错信息
|
||||
if("yes".equals(isShowErrorMsg)){
|
||||
ri.getRequestManager().setMessagecontent(ermsg);
|
||||
return Action.FAILURE_AND_CONTINUE;
|
||||
}else{
|
||||
return SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
}catch (Exception e){
|
||||
String ermsg="流程数据生成预付核销单失败!" + e.toString();
|
||||
//将NCC返回结果回写至OA流程表单
|
||||
AddJournal.addInfo("费用报销接口", json, ermsg, "1", requestid);
|
||||
rs.execute(" update " + tableName + " set sfcgscnccfkd = 1 ,nccfhxx='" + ermsg.replace("'", "''") + "' where requestid = " + requestid);
|
||||
//是否需要显示报错信息
|
||||
if("yes".equals(isShowErrorMsg)){
|
||||
ri.getRequestManager().setMessagecontent(ermsg);
|
||||
return Action.FAILURE_AND_CONTINUE;
|
||||
}else{
|
||||
return SUCCESS;
|
||||
}
|
||||
}
|
||||
return SUCCESS;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,360 @@
|
|||
package com.api.lh.action.two;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.alibaba.fastjson.serializer.SerializerFeature;
|
||||
import com.api.lh.config.DemoConfig;
|
||||
import com.api.lh.port.AddJournal;
|
||||
import jntchina.entity.*;
|
||||
import jntchina.util.DataBaseUtils;
|
||||
import jntchina.util.HttpClientToDC;
|
||||
import selfdev.util.base.BaseUtil;
|
||||
import weaver.conn.RecordSet;
|
||||
import weaver.general.Util;
|
||||
import weaver.hrm.resource.ResourceComInfo;
|
||||
import weaver.interfaces.workflow.action.Action;
|
||||
import weaver.soa.workflow.request.RequestInfo;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* @ClassName NCCSupplierCWOAction
|
||||
* @Description 供应商预付核销流程生成NCC对公报销单
|
||||
* @Author ycf
|
||||
* @Date 2022/5/16 17:10
|
||||
* @Version 1.0
|
||||
*/
|
||||
public class NCCSupplierCWOActionYY implements Action, DemoConfig {
|
||||
|
||||
@Override
|
||||
public String execute(RequestInfo ri) {
|
||||
//
|
||||
String requestid = ri.getRequestid();
|
||||
String workflowid = ri.getWorkflowid();
|
||||
|
||||
//获取当前用户的登录账号(即工号)
|
||||
String loginid=ri.getRequestManager().getUser().getLoginid();
|
||||
|
||||
ReimbursementOrderYY reimbursementOrder = new ReimbursementOrderYY();
|
||||
String tableName = getTableName(workflowid);
|
||||
log.writeLog("当前requestid========> " + requestid + " 对应表名为=======> " + tableName);
|
||||
String id = getId(tableName, requestid);
|
||||
JSONObject json = null;
|
||||
String mainId = "";
|
||||
String isShowErrorMsg = "";//写入NCC失败时是否显示报错信息
|
||||
String pk_org = ""; // 报销单位 JTSDCN0001
|
||||
String fygsbm = ""; // 申请部门
|
||||
String total = ""; // 报销金额 金额由表体相应字段汇总得出
|
||||
String deptid = ""; // 部门 传输编码
|
||||
String djlxbm = "264X-Cxx-YFKHXD"; // 单据类型编码 对私报销单:264X-Cxx-DSBXD 对公报销单:264X-Cxx-DGBXD
|
||||
String djlxmc = "预付核销"; // 单据类型名称 默认 对公报销单
|
||||
String djrq = ""; // 单据日期 yyyy-mm-dd hh:mm:ss
|
||||
String payflag = ""; // 支付状态
|
||||
String paytarget = "1"; // 收款对象 0=员工,1=供应商,2=客户,默认为供应商
|
||||
String receiver = ""; // 收款人
|
||||
String skyhzh = ""; // 收款人银行账号
|
||||
String hbbm = ""; // yonyou88", //收款人(供应商)
|
||||
String custaccount= ""; //收款银行账户(供应商)
|
||||
String jkbxr = ""; // 借款报销人 传输编码
|
||||
String operator = ""; // 录入人
|
||||
String xm= ""; // 申请人
|
||||
String jsfs = "3"; // 结算方式 3 网银
|
||||
String fkyhzh = ""; // 单位银行账户 传输编码
|
||||
String jobid = ""; // 项目
|
||||
String zy = ""; // 报销事由
|
||||
String kjqj = ""; // 会计期间
|
||||
String kjnd = ""; // 会计年度
|
||||
String fjzs = ""; // 附件张数 需业务人员在OA上传附件同时填写附件张数后传数据到NCC
|
||||
String zyx1 = ""; // OA单据号 OA传过来,用于联查单据
|
||||
String zyx2 = ""; // 提交人 提交人姓名
|
||||
String zyx3 = ""; // OA核销单号
|
||||
String zyx5 = ""; // OARequestID
|
||||
String zyx8="";//银行付款备注
|
||||
String zyx9=ri.getRequestManager().getRequestname().length()>140?ri.getRequestManager().getRequestname().substring(0,140):ri.getRequestManager().getRequestname();//标题
|
||||
String tablecode = "arap_bxbusitem";
|
||||
RecordSet rs = new RecordSet();
|
||||
|
||||
try{
|
||||
String sql = " select * from " + tableName + " where requestid='" + requestid + "'";
|
||||
rs.execute(sql);
|
||||
if(rs.next()) {
|
||||
mainId = id;
|
||||
isShowErrorMsg = Util.null2String(rs.getString("xrnccsbcsfts"));
|
||||
xm = Util.null2String(rs.getString("sqr")); // 借款报销人(取流程申请人)
|
||||
pk_org = Util.null2String(rs.getString("gsmc")); // 公司名称
|
||||
total = Util.null2String(rs.getString("hxje")); // 报销金额 金额由表体相应字段汇总得出
|
||||
fygsbm = Util.null2String(rs.getString("sqbm")); // 申请部门
|
||||
hbbm = Util.null2String(rs.getString("gysmc")); // 收款人,供应商编码
|
||||
custaccount = Util.null2String(rs.getString("yxzh")); // 收款人银行账号
|
||||
zyx8 = Util.null2String(rs.getString("yxfkbz")); //银行付款备注
|
||||
zy = Util.null2String(rs.getString("sm")); // 付款说明
|
||||
zyx1 = Util.null2String(rs.getString("lcbh")); // OA单据号 OA传过来,用于联查单据
|
||||
zyx2 = Util.null2String(rs.getString("sqr")); // 提交人 提交人姓名
|
||||
djrq = Util.null2String(rs.getString("sqrq")); //申请日期
|
||||
zyx5 = requestid; // OARequestID
|
||||
}
|
||||
kjqj = djrq.substring(5,7); // 会计期间
|
||||
kjnd = djrq.substring(0,4); // 会计年度
|
||||
|
||||
//根据部门ID查询部门编码
|
||||
deptid= BaseUtil.getBaseInfoByParm("departmentcode", "hrmdepartment", "id", fygsbm, "");
|
||||
//获取员工默认的组织对应的类型
|
||||
String userDefaultCompanyType=BaseUtil.getBaseInfoByParm("company_type", "v_oa_user_org_nsrsbh", "userid", xm, "");
|
||||
//获取付款单选择的组织对应的类型
|
||||
String selectCompanyType=BaseUtil.getBaseInfoByParm("company_type", "uf_businessunit", "code", pk_org, "");
|
||||
log.writeLog("userDefaultCompanyType------>" + userDefaultCompanyType);
|
||||
log.writeLog("selectCompanyType------>" + selectCompanyType);
|
||||
|
||||
//跨组织,则说明代理区向总部申请付款
|
||||
if(!userDefaultCompanyType.equals(selectCompanyType)){
|
||||
//查询建模维护的对应关系
|
||||
String defaultDeptNo=BaseUtil.getBaseInfoByParm("mroabmbm", "uf_kzzfkdybmsz", "sqgslx", userDefaultCompanyType, " and fkgslx='"+selectCompanyType+"'");
|
||||
log.writeLog("defaultDeptNo------>" + defaultDeptNo);
|
||||
if(!"".equals(defaultDeptNo)){
|
||||
deptid=defaultDeptNo;
|
||||
}
|
||||
}
|
||||
|
||||
//截取前120位
|
||||
if(zy.length()>120){
|
||||
zy=zy.substring(0,120);
|
||||
}
|
||||
|
||||
jkbxr = new ResourceComInfo().getWorkcode(xm); //借款报销人工号(即申请人工号)
|
||||
operator = loginid;//
|
||||
|
||||
//获取UUID
|
||||
String uuid= UUID.randomUUID().toString().replace("-", "").toUpperCase();
|
||||
log.writeLog("receiver------>"+receiver);
|
||||
|
||||
//查询抵扣明细
|
||||
sql = " select * from " + tableName + "_dt1 where mainid='" + mainId + "'";
|
||||
rs.execute(sql);
|
||||
// while (rs.next()) {
|
||||
// zyx3+=Util.null2String(rs.getString("yflcbh"))+",";
|
||||
// }
|
||||
//
|
||||
// //将预付流程编号赋值到zyx3字段中
|
||||
// if(!"".equals(zyx3)){
|
||||
// zyx3=zyx3.substring(0,zyx3.length()-1);
|
||||
// }
|
||||
|
||||
reimbursementOrder.setUuid(uuid);
|
||||
reimbursementOrder.setPk_org(pk_org);
|
||||
reimbursementOrder.setTotal(total);
|
||||
reimbursementOrder.setDeptid(deptid);
|
||||
reimbursementOrder.setDjlxbm(djlxbm);
|
||||
reimbursementOrder.setDjrq(djrq);
|
||||
reimbursementOrder.setPayflag(payflag);
|
||||
reimbursementOrder.setPaytarget(paytarget);
|
||||
reimbursementOrder.setReceiver(receiver);
|
||||
reimbursementOrder.setHbbm(hbbm);
|
||||
reimbursementOrder.setSkyhzh(skyhzh);
|
||||
reimbursementOrder.setCustaccount(custaccount);
|
||||
reimbursementOrder.setJkbxr(jkbxr);
|
||||
reimbursementOrder.setOperator(operator);
|
||||
reimbursementOrder.setJsfs(jsfs);
|
||||
reimbursementOrder.setFkyhzh(fkyhzh);
|
||||
reimbursementOrder.setJobid(jobid);
|
||||
reimbursementOrder.setZy(zy);
|
||||
reimbursementOrder.setKjqj(kjqj);
|
||||
reimbursementOrder.setKjnd(kjnd);
|
||||
reimbursementOrder.setFjzs(fjzs);
|
||||
reimbursementOrder.setZyx1(zyx1);
|
||||
reimbursementOrder.setZyx2(zyx2);
|
||||
reimbursementOrder.setZyx3(zyx3);
|
||||
reimbursementOrder.setZyx5(zyx5);
|
||||
reimbursementOrder.setZyx8(zyx8);
|
||||
reimbursementOrder.setZyx9(zyx9);
|
||||
|
||||
log.writeLog("【header数据准备完毕...】");
|
||||
|
||||
//获取OA-NCC发票映射关系表
|
||||
Map<String,String> map_oafplx_nccfplcx=BaseUtil.getMapKeyValueInfoByParm("uf_oafplx_nccfplx", "", "oafplxid", "nccfplxbm");
|
||||
//对公报销
|
||||
List<ReimbursementOrderBodyYY> reimbursementOrderBodyList = new ArrayList<ReimbursementOrderBodyYY>();
|
||||
List<ErBxcontrast> erBxcontrasts = new ArrayList<>();
|
||||
|
||||
int rowno = 0;
|
||||
String sql1 = " select c.INVOICECODE,c.INVOICENUMBER,c.invoicetype,a.* from " + tableName + "_dt1 a "
|
||||
+ " left join fnainvoiceledger c on a.fphm=c.id "
|
||||
+ " where a.mainid = " + mainId;
|
||||
log.writeLog("SQL1-----> " + sql1);
|
||||
rs.execute(sql1);
|
||||
while (rs.next()){
|
||||
String jobid1 = ""; // 项目
|
||||
|
||||
String fycdbm = BaseUtil.getBaseInfoByParm("fycdbm", "uf_gysqktzyy_dt1", "id", Util.null2String(rs.getString("yfkqptzmxid")), ""); //费用承担部门
|
||||
String amount = Util.null2String(rs.getString("bchxje")); // 付款
|
||||
String defitem36 = Util.null2o(rs.getString("fpje")); // 发票金额
|
||||
String tax_rate = Util.null2String(rs.getString("sl")); // 税率 3%
|
||||
String tax_amount = Util.null2String(rs.getString("se")); // 税额
|
||||
String tni_amount = Util.null2String(rs.getString("bhsje")); // 无税金额
|
||||
String szxmid = BaseUtil.getBaseInfoByParm("fylx", "uf_gysqktzyy_dt1", "id", Util.null2String(rs.getString("yfkqptzmxid")), ""); // 收支项目 0101 汽车费用
|
||||
String fpdm = Util.null2String(rs.getString("INVOICECODE")); // 发票代码
|
||||
String fphm = Util.null2String(rs.getString("INVOICENUMBER")); // 发票号码
|
||||
String invoicetype = Util.null2String(rs.getString("invoicetype")); // OA发票类型
|
||||
//NCC发票类型
|
||||
String fplxpk=Util.null2String(map_oafplx_nccfplcx.get(invoicetype));
|
||||
|
||||
// String fphmId = Util.null2String(rs.getString("fphm")); // 发票号码
|
||||
// if(!"".equals(fphmId)){
|
||||
// // 得到浏览按钮中发票号码的id,再去数据库中把发票号码和发票代码查出来
|
||||
// rsFna.execute(" select * from fnainvoiceledger where id = " + fphmId);
|
||||
// while (rsFna.next()) {
|
||||
// fpdm = Util.null2String(rsFna.getString("INVOICECODE")); // 发票代码
|
||||
// fphm = Util.null2String(rsFna.getString("INVOICENUMBER")); // 发票号码
|
||||
// fplxpk = Util.null2String(map_oafplx_nccfplcx.get(Util.null2String(rsFna.getString("invoicetype")))); // OA发票类型
|
||||
// }
|
||||
// }
|
||||
//发票金额为空时,默认等于付款金额
|
||||
if(Double.parseDouble(defitem36)==0){
|
||||
defitem36=amount;
|
||||
}
|
||||
|
||||
sql = "select * from uf_gysqktzyy_dt1 where id = " + Util.null2String(rs.getString("yfkqptzmxid"));
|
||||
log.writeLog("获取明细数据:"+sql);
|
||||
|
||||
|
||||
Map<String, String> dataMap = DataBaseUtils.getDataMap(sql);
|
||||
String defitem46 = dataMap.get("CBZX"); // 网点(成本中心)
|
||||
String defitem45 = dataMap.get("GJ"); // 国家
|
||||
String defitem44 = dataMap.get("CK"); // 仓库
|
||||
String defitem43 = dataMap.get("CPH"); //车牌号
|
||||
String defitem42 = dataMap.get("OAMXXID"); // OA明细行ID
|
||||
//根据部门ID查询部门编码(传NCC)
|
||||
// String fycdbm_NCC=BaseUtil.getBaseInfoByParm("departmentcode", "hrmdepartment", "id", fycdbm, "");
|
||||
// fycdbm_NCC = fycdbm;//直接取NCC的费用承担部门
|
||||
|
||||
rowno++;
|
||||
|
||||
log.writeLog("----fycdbm_NCC:" + fycdbm);
|
||||
log.writeLog("----amount:" + amount);
|
||||
log.writeLog("----tax_rate:" + tax_rate);
|
||||
log.writeLog("----tax_amount:" + tax_amount);
|
||||
log.writeLog("----tni_amount:" + tni_amount);
|
||||
|
||||
|
||||
ReimbursementOrderBodyYY body = new ReimbursementOrderBodyYY();
|
||||
body.setJobid(jobid1);
|
||||
body.setDeptid(fycdbm);
|
||||
body.setAmount(amount);
|
||||
body.setTax_rate(tax_rate);
|
||||
body.setTax_amount(tax_amount);
|
||||
body.setTni_amount(tni_amount);
|
||||
body.setTablecode(tablecode);
|
||||
body.setRowno(rowno+"");
|
||||
body.setSzxmid(BaseUtil.getBaseInfoByParm("bm", "uf_fylx", "id", szxmid, ""));
|
||||
body.setFpdm(fpdm);
|
||||
body.setFphm(fphm);
|
||||
body.setFplxpk(fplxpk);
|
||||
body.setDefitem36(defitem36);
|
||||
body.setDefitem46(defitem46);
|
||||
body.setDefitem45(defitem45);
|
||||
body.setDefitem44(defitem44);
|
||||
body.setDefitem43(defitem43);
|
||||
body.setDefitem42(defitem42);
|
||||
body.setDeptidIsNeedConvert("no");
|
||||
//body.setDefitem48(fycdbm_NCC);
|
||||
reimbursementOrderBodyList.add(body);
|
||||
}
|
||||
reimbursementOrder.setEr_busitem(reimbursementOrderBodyList);
|
||||
sql = "select yfkqptzmxid, sum(bchxje) as hxje, avg(yfje) as zje, avg(xgyflc) as req from " + tableName + "_dt1" +
|
||||
" where mainid = '" + id + "' group by yfkqptzmxid having count(yfkqptzmxid) > 0";
|
||||
log.writeLog("获取预付核销数据明细sql-----> " +sql);
|
||||
rs.execute(sql);
|
||||
while(rs.next()){
|
||||
String szxmid = BaseUtil.getBaseInfoByParm("fylx", "uf_gysqktzyy_dt1", "id", Util.null2String(rs.getString("yfkqptzmxid")), "");
|
||||
ErBxcontrast erBxcontrast = new ErBxcontrast(
|
||||
BaseUtil.getBaseInfoByParm("ncclcdh", "uf_gysqktzyy","qqid", Util.null2String(rs.getString("req")), ""),
|
||||
BaseUtil.getBaseInfoByParm("bm", "uf_fylx", "id", szxmid, ""),
|
||||
Util.null2String(rs.getString("hxje")),
|
||||
BaseUtil.getBaseInfoByParm("oamxxid", "uf_gysqktzyy_dt1", "id", Util.null2String(rs.getString("yfkqptzmxid")), ""),
|
||||
Util.null2String(rs.getString("yfkqptzmxid")));
|
||||
erBxcontrasts.add(erBxcontrast);
|
||||
}
|
||||
reimbursementOrder.setEr_bxcontrast(erBxcontrasts);
|
||||
String parm=JSONObject.toJSONString(reimbursementOrder, SerializerFeature.DisableCircularReferenceDetect);
|
||||
log.writeLog(djlxmc+"准备传入中台的数据为------>" + parm);
|
||||
//获取TOKEN
|
||||
String token = HttpClientToDC.getToken();
|
||||
log.writeLog("获取数据中台的token------>" + token);
|
||||
if ("".equals(Util.null2String(token))) {
|
||||
String tokenMsg="流程提交失败,未获取到数据中台接口TOKEN,请联系管理员处理!";
|
||||
//将NCC返回结果回写至OA流程表单
|
||||
rs.execute(" update " + tableName + " set sfcgscnccfkd = 1 ,nccfhxx='" + tokenMsg.replace("'", "''") + "' where requestid = " + requestid);
|
||||
AddJournal.addInfo("费用报销接口", JSON.parseObject(parm), tokenMsg, "1", requestid);
|
||||
//是否需要显示报错信息
|
||||
if("yes".equals(isShowErrorMsg)){
|
||||
ri.getRequestManager().setMessagecontent(tokenMsg);
|
||||
return Action.FAILURE_AND_CONTINUE;
|
||||
}else{
|
||||
return SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
//调用NCC接口,将数据传给NCC
|
||||
String returndata = HttpClientToDC.sendPostApi(baseUrl+"/dcnccapi/claimForm/receiveData",token, parm);
|
||||
log.writeLog("【调用数据中台报销接口返回结果result:】" + returndata);
|
||||
if (!"".equals(returndata) && returndata != null) {
|
||||
JSONObject jsonObject = JSONObject.parseObject(returndata);
|
||||
String success = Util.null2String(jsonObject.get("succ"));
|
||||
log.writeLog("--------发送请求返回的success值为:" + success);
|
||||
if ("true".equals(success)) {
|
||||
JSONObject data = jsonObject.getJSONObject("data");
|
||||
String billno = Util.null2String(data.get("billno"));//NCC单号
|
||||
log.writeLog("--------发送请求返回的billno值为:" + billno);
|
||||
//将NCC返回结果回写至OA流程表单
|
||||
rs.execute(" update " + tableName + " set sfcgscnccfkd = 0 , nccfkdh = '" + billno + "',nccfhxx='' where requestid = " + requestid);
|
||||
AddJournal.addInfo("费用报销接口", JSON.parseObject(parm), returndata, "0", requestid);
|
||||
} else {
|
||||
String message = Util.null2String(jsonObject.get("msg"));
|
||||
String message2=message.replace("'", "''");
|
||||
//超出1333个字符,则只截取前面这部分
|
||||
if(message2.length()>1334){
|
||||
message2=message2.substring(0,1333);
|
||||
}
|
||||
//将NCC返回结果回写至OA流程表单
|
||||
rs.execute(" update " + tableName + " set sfcgscnccfkd = 1 ,nccfhxx='" + message2 + "' where requestid = " + requestid);
|
||||
AddJournal.addInfo("费用报销接口", JSON.parseObject(parm), returndata, "1", requestid);
|
||||
//是否需要显示报错信息
|
||||
if("yes".equals(isShowErrorMsg)){
|
||||
ri.getRequestManager().setMessagecontent("流程数据写入NCC生成"+djlxmc+"失败,失败信息:<br/>"+message);
|
||||
return Action.FAILURE_AND_CONTINUE;
|
||||
}else{
|
||||
return SUCCESS;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
String ermsg="流程数据写入NCC生成"+djlxmc+"失败,未获取到接口返回结果,请联系系统管理员处理!";
|
||||
AddJournal.addInfo("费用报销接口", JSON.parseObject(parm), ermsg, "1", requestid);
|
||||
//将NCC返回结果回写至OA流程表单
|
||||
rs.execute(" update " + tableName + " set sfcgscnccfkd = 1 ,nccfhxx='" + ermsg.replace("'", "''") + "' where requestid = " + requestid);
|
||||
//是否需要显示报错信息
|
||||
if("yes".equals(isShowErrorMsg)){
|
||||
ri.getRequestManager().setMessagecontent(ermsg);
|
||||
return Action.FAILURE_AND_CONTINUE;
|
||||
}else{
|
||||
return SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
}catch (Exception e){
|
||||
String ermsg="流程数据生成预付核销单失败!" + e.toString();
|
||||
//将NCC返回结果回写至OA流程表单
|
||||
AddJournal.addInfo("费用报销接口", json, ermsg, "1", requestid);
|
||||
rs.execute(" update " + tableName + " set sfcgscnccfkd = 1 ,nccfhxx='" + ermsg.replace("'", "''") + "' where requestid = " + requestid);
|
||||
//是否需要显示报错信息
|
||||
if("yes".equals(isShowErrorMsg)){
|
||||
ri.getRequestManager().setMessagecontent(ermsg);
|
||||
return Action.FAILURE_AND_CONTINUE;
|
||||
}else{
|
||||
return SUCCESS;
|
||||
}
|
||||
}
|
||||
return SUCCESS;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,95 @@
|
|||
package com.api.lh.action.two;
|
||||
|
||||
import com.api.lh.config.DemoConfig;
|
||||
|
||||
import selfdev.util.base.BaseUtil;
|
||||
import selfdev.util.log.LogTool;
|
||||
import weaver.conn.RecordSet;
|
||||
import weaver.general.Util;
|
||||
import weaver.interfaces.workflow.action.Action;
|
||||
import weaver.soa.workflow.request.RequestInfo;
|
||||
|
||||
/**
|
||||
* @ClassName SupplierVerificationAction
|
||||
* @Description 供应商预付核销提交效验action
|
||||
* @Author louh
|
||||
* @Date 2022/5/16 16:04
|
||||
* @Version 1.0
|
||||
*/
|
||||
public class SupplierVerificationAction implements Action, DemoConfig {
|
||||
LogTool log = new LogTool("/log/lh/SupplierVerificationAction", false);
|
||||
@Override
|
||||
public String execute(RequestInfo ri) {
|
||||
RecordSet rs = new RecordSet();
|
||||
RecordSet rs1 = new RecordSet();
|
||||
String requestid = ri.getRequestid();
|
||||
String workflowid = ri.getWorkflowid();
|
||||
String tableName = getTableName(workflowid);
|
||||
log.writeLog("当前requestid========> " + requestid + " 对应表名为=======> " + tableName);
|
||||
String id = getId(tableName, requestid);
|
||||
//供应商名称
|
||||
String gysmc = BaseUtil.getBaseInfoByParm("gysmc", tableName, "requestid", requestid, "");
|
||||
//公司名称
|
||||
String gsmc = BaseUtil.getBaseInfoByParm("gsmc", tableName, "requestid", requestid, "");
|
||||
|
||||
|
||||
//1.效验每张单据的抵扣金额是否超过预付金额
|
||||
String sql = "select yfkqptzmxid, sum(bchxje) as hxje, avg(yfje) as zje from " + tableName + "_dt1 " +
|
||||
" where mainid = '" + id + "'" +
|
||||
"group by yfkqptzmxid having count(yfkqptzmxid) > 0";
|
||||
log.writeLog("效验每张单据的抵扣金额是否超过预付金额sql-----> " + sql);
|
||||
rs.execute(sql);
|
||||
while(rs.next()){
|
||||
String yfkqptzmxid = Util.null2String(rs.getString("yfkqptzmxid")); //预付款欠票台账明细id
|
||||
double hxje = Double.parseDouble(Util.null2String(rs.getString("hxje"))==""?"0.00":Util.null2String(rs.getString("hxje"))); //本次核销金额
|
||||
double zje = Double.parseDouble(Util.null2String(rs.getString("zje"))==""?"0.00":Util.null2String(rs.getString("zje"))); //预付金额
|
||||
if(hxje > zje){
|
||||
ri.getRequestManager().setMessagecontent("当前单据预付核销明细中预付款欠票台账明细id【" + yfkqptzmxid + "】抵扣总金额【" + hxje + "】合计大于预付金额【" + zje + "】,请重新选取要核销的数据!");
|
||||
return FAILURE_AND_CONTINUE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//预付流程编号
|
||||
String yflcbh = weaver.general.Util.null2String(rs.getString("yflcbh"));
|
||||
|
||||
//效验是否有历史单据再审批中
|
||||
sql = "select b.requestid," +
|
||||
" b.lcbh," +
|
||||
" b.gsmc," +
|
||||
"b.gysmc," +
|
||||
"a.id," +
|
||||
"(select lcbh from uf_fksqyfb where qqid = a.xgyflc) as bh," +
|
||||
"(select currentnodetype from workflow_requestbase where requestid = b.requestid) as stutas" +
|
||||
" from " + tableName + "_dt1 a left join " + tableName + " b on a.mainid = b.id " +
|
||||
" where b.gysmc = '" + gysmc + "' and b.gsmc = '" + gsmc + "' and a.yflcbh = '" + yflcbh + "'";
|
||||
log.writeLog("效验是否有历史单据再审批中sql-----> " + sql);
|
||||
rs1.execute(sql);
|
||||
while(rs1.next()){
|
||||
String stutas = Util.null2String(rs1.getString("stutas")); /* 流程状态 */
|
||||
if(!"0".equals(stutas) && !"3".equals(stutas)){
|
||||
String bh = Util.null2String(rs1.getString("bh")); /* 预付流程编号 */
|
||||
String lcbh = Util.null2String(rs1.getString("lcbh")); /* 审批中流程编号 */
|
||||
ri.getRequestManager().setMessagecontent("当前抵扣明细中【" + bh + "】正在审批中,审批的流程编号为【" + lcbh + "】,请先走完审批中的流程后继续提交该流程!");
|
||||
return FAILURE_AND_CONTINUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//2.效验明细表每行抵扣金额不得大于发票金额
|
||||
sql = "select yfkqptzmxid, bchxje, fpje from " + tableName + "_dt1 where mainid = " + id;
|
||||
rs.execute(sql);
|
||||
while(rs.next()){
|
||||
double bchxje = Double.parseDouble(Util.null2o(rs.getString("bchxje")));
|
||||
double fpje = Double.parseDouble(Util.null2o(rs.getString("fpje")));
|
||||
if (bchxje > fpje){
|
||||
String yfkqptzmxid = Util.null2String(rs.getString("yfkqptzmxid"));
|
||||
ri.getRequestManager().setMessagecontent("当前单据预付核销明细中预付款欠票台账明细id【" + yfkqptzmxid + "】抵扣金额【" + bchxje + "】发票金额【" + fpje + "】,请重新选取要核销的数据!");
|
||||
return FAILURE_AND_CONTINUE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return SUCCESS;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,79 @@
|
|||
package com.api.lh.action.two;
|
||||
|
||||
import com.api.lh.config.DemoConfig;
|
||||
import com.wbi.util.Util;
|
||||
import selfdev.util.base.BaseUtil;
|
||||
import selfdev.util.log.LogTool;
|
||||
import weaver.conn.RecordSet;
|
||||
import weaver.interfaces.workflow.action.Action;
|
||||
import weaver.soa.workflow.request.RequestInfo;
|
||||
|
||||
/**
|
||||
* @ClassName SupplierVerificationAction
|
||||
* @Description 供应商预付核销提交效验action
|
||||
* @Author ycf
|
||||
* @Date 2022/5/16 16:04
|
||||
* @Version 1.0
|
||||
*/
|
||||
public class SupplierVerificationActionYY implements Action, DemoConfig {
|
||||
LogTool log = new LogTool("/log/lh/SupplierVerificationAction", false);
|
||||
@Override
|
||||
public String execute(RequestInfo ri) {
|
||||
RecordSet rs = new RecordSet();
|
||||
String requestid = ri.getRequestid();
|
||||
String workflowid = ri.getWorkflowid();
|
||||
String tableName = getTableName(workflowid);
|
||||
log.writeLog("当前requestid========> " + requestid + " 对应表名为=======> " + tableName);
|
||||
String id = getId(tableName, requestid);
|
||||
//供应商名称
|
||||
String gysmc = BaseUtil.getBaseInfoByParm("gysmc", tableName, "requestid", requestid, "");
|
||||
//公司名称
|
||||
String gsmc = BaseUtil.getBaseInfoByParm("gsmc", tableName, "requestid", requestid, "");
|
||||
|
||||
|
||||
//1.效验每张单据的抵扣金额是否超过预付金额
|
||||
String sql = "select yfkqptzmxid, sum(bchxje) as hxje, avg(yfje) as zje from " + tableName + "_dt1 " +
|
||||
" where mainid = '" + id + "'" +
|
||||
"group by yfkqptzmxid having count(yfkqptzmxid) > 0";
|
||||
log.writeLog("效验每张单据的抵扣金额是否超过预付金额sql-----> " + sql);
|
||||
rs.execute(sql);
|
||||
while(rs.next()){
|
||||
String yfkqptzmxid = Util.null2String(rs.getString("yfkqptzmxid")); //预付款欠票台账明细id
|
||||
double hxje = Double.parseDouble(Util.null2String(rs.getString("hxje"))==""?"0.00":Util.null2String(rs.getString("hxje"))); //本次核销金额
|
||||
double zje = Double.parseDouble(Util.null2String(rs.getString("zje"))==""?"0.00":Util.null2String(rs.getString("zje"))); //预付金额
|
||||
if(hxje > zje){
|
||||
ri.getRequestManager().setMessagecontent("当前单据预付核销明细中预付款欠票台账明细id【" + yfkqptzmxid + "】抵扣总金额【" + hxje + "】合计大于预付金额【" + zje + "】,请重新选取要核销的数据!");
|
||||
return FAILURE_AND_CONTINUE;
|
||||
}
|
||||
|
||||
//预付流程编号
|
||||
String yflcbh = weaver.general.Util.null2String(rs.getString("yflcbh"));
|
||||
|
||||
//效验是否有历史单据再审批中
|
||||
sql = "select b.requestid," +
|
||||
" b.lcbh," +
|
||||
" b.gsmc," +
|
||||
"b.gysmc," +
|
||||
"a.id," +
|
||||
"(select lcbh from uf_gysqktzyy where qqid = a.xgyflc) as bh," +
|
||||
"(select currentnodetype from workflow_requestbase where requestid = b.requestid) as stutas" +
|
||||
" from " + tableName + "_dt1 a left join " + tableName + " b on a.mainid = b.id " +
|
||||
" where b.gysmc = '" + gysmc + "' and b.gsmc = '" + gsmc + "' and a.yflcbh = '" + yflcbh + "'";
|
||||
log.writeLog("效验是否有历史单据再审批中sql-----> " + sql);
|
||||
rs.execute(sql);
|
||||
while(rs.next()){
|
||||
String stutas = weaver.general.Util.null2String(rs.getString("stutas")); /* 流程状态 */
|
||||
if(!"0".equals(stutas) && !"3".equals(stutas)){
|
||||
String bh = weaver.general.Util.null2String(rs.getString("bh")); /* 预付流程编号 */
|
||||
String lcbh = weaver.general.Util.null2String(rs.getString("lcbh")); /* 审批中流程编号 */
|
||||
ri.getRequestManager().setMessagecontent("当前抵扣明细中【" + bh + "】正在审批中,审批的流程编号为【" + lcbh + "】,请先走完审批中的流程后继续提交该流程!");
|
||||
return FAILURE_AND_CONTINUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
return SUCCESS;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,57 @@
|
|||
package com.api.lh.config;
|
||||
|
||||
import selfdev.util.base.BaseUtil;
|
||||
import selfdev.util.log.LogTool;
|
||||
import weaver.file.Prop;
|
||||
|
||||
/**
|
||||
* @Description TODO
|
||||
* @Author louh
|
||||
* @Date 2022/4/15 10:46
|
||||
* @Version 1.0
|
||||
*/
|
||||
public interface DemoConfig {
|
||||
|
||||
LogTool log = new LogTool("/log/lh/action", false);
|
||||
//当前环境
|
||||
String mode = Prop.getPropValue("DevToDC_jntchina","mode");
|
||||
//当前路径地址
|
||||
String baseUrl = Prop.getPropValue("DevToDC_jntchina", mode + "_baseUrl");
|
||||
|
||||
//根据流程id或取主表表名
|
||||
default String getTableName(String workflowid){
|
||||
String tableName = BaseUtil.getBaseInfoByParm("tablename", "workflow_bill", "1", "1", " and id in (select formid from workflow_base where id=" + workflowid + ")");
|
||||
return tableName;
|
||||
}
|
||||
|
||||
//根据主表表名和requestid获取当前数据id
|
||||
default String getId(String tablename, String requestid){
|
||||
String id = BaseUtil.getBaseInfoByParm("id", tablename, "requestid", requestid, "");;
|
||||
return id;
|
||||
}
|
||||
|
||||
//根据表名查询建模模块ID
|
||||
default String getModeid(String tablename){
|
||||
String modeid_select=BaseUtil.getBaseInfoByParm("id","modeinfo","1","1"," and formid in (select id from workflow_bill where tablename='uf_triggerwf_log') ");
|
||||
return modeid_select;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据下拉框的描述获取对应的值
|
||||
* @param selectname 下拉框描述
|
||||
* @param workflowid 流程id
|
||||
* @param fieldname 字段名称
|
||||
* @param viewtype 默认0 表示主表字段
|
||||
* @return
|
||||
*/
|
||||
default String getSelectValue(String selectname, String workflowid, String fieldname, String viewtype){
|
||||
viewtype = viewtype == "" ? "0":viewtype;
|
||||
selectname = selectname.trim();
|
||||
fieldname = fieldname.trim();
|
||||
String selectValue=BaseUtil.getBaseInfoByParm("selectvalue", "workflow_selectitem", "convtomultilang(selectname,7)", selectname,
|
||||
" and fieldid in (select id from workflow_billfield where billid in (select formid from workflow_base where id="+ workflowid+") and fieldname='" + fieldname + "' and viewtype= " + viewtype + ")");
|
||||
return selectValue;
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,81 @@
|
|||
package com.api.lh.port;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
|
||||
import com.api.lh.config.DemoConfig;
|
||||
import selfdev.util.base.BaseUtil;
|
||||
import weaver.conn.RecordSet;
|
||||
import weaver.file.Prop;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @ClassName AddJournal
|
||||
* @Description 调用NCC接口日志
|
||||
* @Author louh
|
||||
* @Date 2022/3/1 14:19
|
||||
* @Version 1.0
|
||||
*/
|
||||
public class AddJournal {
|
||||
|
||||
/**
|
||||
* 添加调用日志
|
||||
* @param dyjk 调用接口
|
||||
* @param cdcs 传递参数
|
||||
* @param fhcs 返回参数
|
||||
* @param sfcg 是否成功
|
||||
* @param lcid 流程id
|
||||
*/
|
||||
public static void addInfo(String dyjk, JSONObject cdcs, String fhcs, String sfcg, String lcid){
|
||||
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
String format = dateFormat.format(new Date());
|
||||
RecordSet rs = new RecordSet();
|
||||
String select_modeid = getModeId("uf_dynccjkrzb");
|
||||
String sql = "insert into uf_dynccjkrzb (formmodeid,modedatacreater,modedatacreatertype,modedatacreatedate,modedatacreatetime, dyjk, cdcs, fhcs, sfcg, lcid)" +
|
||||
" values (" + "'" + select_modeid + "'," +
|
||||
"'" + 1 + "'," +
|
||||
"'" + 0 + "'," +
|
||||
"'" + format.substring(0, 10) + "'," +
|
||||
"'" + format.substring(11) + "'," +
|
||||
"'" + dyjk + "'," +
|
||||
"'" + cdcs + "'," +
|
||||
"'" + fhcs + "'," +
|
||||
"'" + sfcg + "'," +
|
||||
"'" + lcid + "')";
|
||||
rs.execute(sql);
|
||||
}
|
||||
|
||||
/**
|
||||
* ncc调用我方接口日志
|
||||
* @param dyjk 调用接口
|
||||
* @param cdcs 传递参数
|
||||
* @param fhcs 返回参数
|
||||
* @param sfcg 是否成功
|
||||
* @param url 接口路径
|
||||
*/
|
||||
public static void addInfo(String dyjk, Object cdcs, Object fhcs, String sfcg, String url, Object obj){
|
||||
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
String format = dateFormat.format(new Date());
|
||||
RecordSet rs = new RecordSet();
|
||||
String select_modeid = getModeId("uf_nccdywfjkrzb");
|
||||
String sql = "insert into uf_nccdywfjkrzb (formmodeid,modedatacreater,modedatacreatertype,modedatacreatedate,modedatacreatetime, dyjk,cdcs,fhcs,sfcg,jklj) " +
|
||||
" values (" + "'" + select_modeid + "'," +
|
||||
"'" + 1 + "'," +
|
||||
"'" + 0 + "'," +
|
||||
"'" + format.substring(0, 10) + "'," +
|
||||
"'" + format.substring(11) + "'," +
|
||||
"'" + dyjk + "'," +
|
||||
"'" + cdcs + "'," +
|
||||
"'" + fhcs + "'," +
|
||||
"'" + sfcg + "'," +
|
||||
"'" + url + "')";
|
||||
rs.execute(sql);
|
||||
}
|
||||
|
||||
//根据表名查询建模模块ID
|
||||
public static String getModeId(String tablename){
|
||||
String modeid_select= BaseUtil.getBaseInfoByParm("id","modeinfo","1","1"," and formid in (select id from workflow_bill where tablename='" + tablename + "') ");
|
||||
return modeid_select;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,216 @@
|
|||
package com.api.lh.port;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @ClassName Billdata
|
||||
* @Description 还款单请求----表头参数
|
||||
* @Author louh
|
||||
* @Date 2022/4/14 13:48
|
||||
* @Version 1.0
|
||||
*/
|
||||
public class Billdata {
|
||||
|
||||
private String pk_org; /* 财务组织 */
|
||||
private String billtypecode; /* 单据类型 */
|
||||
private String bzbm; /* 默认 CNY */
|
||||
private String paytarget; /* 默认 0 */
|
||||
private String dbilldate; /* 单据日期 */
|
||||
private String totalmny; /* 还款金额 */
|
||||
private String payorg; /* 收款单位 */
|
||||
private String payment; /* 结算方式 默认银行转账 17 */
|
||||
private String pk_psndoc; /* 还款人 */
|
||||
private String psnaccnum; /* 还款人银行账户 */
|
||||
private String orgaccnum; /* 收款单位银行账户 */
|
||||
private String oarequestid; /* OA requestid */
|
||||
private String oavbillcode; /* 来源单据号 */
|
||||
private String fydwbm; /* 费用承担单位编码 */
|
||||
private String fydeptid; /* 费用承担部门编码 */
|
||||
private String zy; /* 备注 */
|
||||
private List<ErBxcontrast> er_bxcontrast; /* 冲借款信息 */
|
||||
|
||||
public Billdata(String pk_org, String billtypecode, String bzbm, String paytarget, String dbilldate, String totalmny, String payorg, String payment, String pk_psndoc, String psnaccnum, String orgaccnum, String oarequestid, String oavbillcode, String fydwbm, String fydeptid, String zy, List<ErBxcontrast> er_bxcontrast) {
|
||||
this.pk_org = pk_org;
|
||||
this.billtypecode = billtypecode == "" ? "2647" : billtypecode;
|
||||
this.bzbm = bzbm =="" ? "CNY":bzbm;
|
||||
this.paytarget = paytarget == ""? "0":paytarget;
|
||||
this.dbilldate = dbilldate;
|
||||
this.totalmny = totalmny == "" ? "0.00" : totalmny;
|
||||
this.payorg = payorg;
|
||||
this.payment = payment == "" ? "17": payment;
|
||||
this.pk_psndoc = pk_psndoc;
|
||||
this.psnaccnum = psnaccnum;
|
||||
this.orgaccnum = orgaccnum;
|
||||
this.oarequestid = oarequestid;
|
||||
this.oavbillcode = oavbillcode;
|
||||
this.fydwbm = fydwbm;
|
||||
this.fydeptid = fydeptid;
|
||||
this.zy = zy;
|
||||
this.er_bxcontrast = er_bxcontrast;
|
||||
}
|
||||
|
||||
public String getPk_org() {
|
||||
return pk_org;
|
||||
}
|
||||
|
||||
public void setPk_org(String pk_org) {
|
||||
this.pk_org = pk_org;
|
||||
}
|
||||
|
||||
public String getBilltypecode() {
|
||||
return billtypecode;
|
||||
}
|
||||
|
||||
public void setBilltypecode(String billtypecode) {
|
||||
this.billtypecode = billtypecode == "" ? "263X-Cxx-01" : billtypecode;
|
||||
}
|
||||
|
||||
public String getBzbm() {
|
||||
return bzbm;
|
||||
}
|
||||
|
||||
public void setBzbm(String bzbm) {
|
||||
this.bzbm = bzbm == "" ? "CNY":bzbm;
|
||||
}
|
||||
|
||||
public String getPaytarget() {
|
||||
return paytarget;
|
||||
}
|
||||
|
||||
public void setPaytarget(String paytarget) {
|
||||
this.paytarget = paytarget == ""? "0":paytarget;
|
||||
}
|
||||
|
||||
public String getDbilldate() {
|
||||
return dbilldate;
|
||||
}
|
||||
|
||||
public void setDbilldate(String dbilldate) {
|
||||
this.dbilldate = dbilldate;
|
||||
}
|
||||
|
||||
public String getTotalmny() {
|
||||
return totalmny;
|
||||
}
|
||||
|
||||
public void setTotalmny(String totalmny) {
|
||||
this.totalmny = totalmny == "" ? "0.00" : totalmny;
|
||||
}
|
||||
|
||||
public String getPayorg() {
|
||||
return payorg;
|
||||
}
|
||||
|
||||
public void setPayorg(String payorg) {
|
||||
this.payorg = payorg;
|
||||
}
|
||||
|
||||
public String getPayment() {
|
||||
return payment;
|
||||
}
|
||||
|
||||
public void setPayment(String payment) {
|
||||
this.payment = payment == "" ? "17": payment;
|
||||
}
|
||||
|
||||
public String getPk_psndoc() {
|
||||
return pk_psndoc;
|
||||
}
|
||||
|
||||
public void setPk_psndoc(String pk_psndoc) {
|
||||
this.pk_psndoc = pk_psndoc;
|
||||
}
|
||||
|
||||
public String getPsnaccnum() {
|
||||
return psnaccnum;
|
||||
}
|
||||
|
||||
public void setPsnaccnum(String psnaccnum) {
|
||||
this.psnaccnum = psnaccnum;
|
||||
}
|
||||
|
||||
public String getOrgaccnum() {
|
||||
return orgaccnum;
|
||||
}
|
||||
|
||||
public void setOrgaccnum(String orgaccnum) {
|
||||
this.orgaccnum = orgaccnum;
|
||||
}
|
||||
|
||||
public String getOarequestid() {
|
||||
return oarequestid;
|
||||
}
|
||||
|
||||
public void setOarequestid(String oarequestid) {
|
||||
this.oarequestid = oarequestid;
|
||||
}
|
||||
|
||||
public String getOavbillcode() {
|
||||
return oavbillcode;
|
||||
}
|
||||
|
||||
public void setOavbillcode(String oavbillcode) {
|
||||
this.oavbillcode = oavbillcode;
|
||||
}
|
||||
|
||||
public String getFydwbm() {
|
||||
return fydwbm;
|
||||
}
|
||||
|
||||
public void setFydwbm(String fydwbm) {
|
||||
this.fydwbm = fydwbm;
|
||||
}
|
||||
|
||||
public String getFydeptid() {
|
||||
return fydeptid;
|
||||
}
|
||||
|
||||
public void setFydeptid(String fydeptid) {
|
||||
this.fydeptid = fydeptid;
|
||||
}
|
||||
|
||||
public String getZy() {
|
||||
return zy;
|
||||
}
|
||||
|
||||
public void setZy(String zy) {
|
||||
this.zy = zy;
|
||||
}
|
||||
|
||||
public List<ErBxcontrast> getEr_bxcontrast() {
|
||||
return er_bxcontrast;
|
||||
}
|
||||
|
||||
public void setEr_bxcontrast(List<ErBxcontrast> er_bxcontrast) {
|
||||
this.er_bxcontrast = er_bxcontrast;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Billdata{" +
|
||||
"pk_org='" + pk_org + '\'' +
|
||||
", billtypecode='" + billtypecode + '\'' +
|
||||
", bzbm='" + bzbm + '\'' +
|
||||
", paytarget='" + paytarget + '\'' +
|
||||
", dbilldate='" + dbilldate + '\'' +
|
||||
", totalmny='" + totalmny + '\'' +
|
||||
", payorg='" + payorg + '\'' +
|
||||
", payment='" + payment + '\'' +
|
||||
", pk_psndoc='" + pk_psndoc + '\'' +
|
||||
", psnaccnum='" + psnaccnum + '\'' +
|
||||
", orgaccnum='" + orgaccnum + '\'' +
|
||||
", oarequestid='" + oarequestid + '\'' +
|
||||
", oavbillcode='" + oavbillcode + '\'' +
|
||||
", fydwbm='" + fydwbm + '\'' +
|
||||
", fydeptid='" + fydeptid + '\'' +
|
||||
", zy='" + zy + '\'' +
|
||||
", er_bxcontrast=" + er_bxcontrast +
|
||||
'}';
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
Billdata billdata = new Billdata("","","","","","","","","","","","","","","","",null);
|
||||
System.out.println(billdata);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,45 @@
|
|||
package com.api.lh.port;
|
||||
|
||||
/**
|
||||
* @ClassName ErBxcontrast
|
||||
* @Description 还款单请求----表体数据
|
||||
* @Author louh
|
||||
* @Date 2022/4/14 13:55
|
||||
* @Version 1.0
|
||||
*/
|
||||
public class ErBxcontrast {
|
||||
|
||||
private String jkbillcode; /* ncc借款单号 */
|
||||
private String inoutbusiclass; /* 收支项目 */
|
||||
private String hkmny; /* 还款金额 */
|
||||
|
||||
public ErBxcontrast(String jkbillcode, String inoutbusiclass, String hkmny) {
|
||||
this.jkbillcode = jkbillcode;
|
||||
this.inoutbusiclass = inoutbusiclass == "" ? "901038" : inoutbusiclass;
|
||||
this.hkmny = hkmny == "" ? "0.00" : hkmny;
|
||||
}
|
||||
|
||||
public String getJkbillcode() {
|
||||
return jkbillcode;
|
||||
}
|
||||
|
||||
public void setJkbillcode(String jkbillcode) {
|
||||
this.jkbillcode = jkbillcode;
|
||||
}
|
||||
|
||||
public String getInoutbusiclass() {
|
||||
return inoutbusiclass;
|
||||
}
|
||||
|
||||
public void setInoutbusiclass(String inoutbusiclass) {
|
||||
this.inoutbusiclass = inoutbusiclass == "" ? "901038" : "";
|
||||
}
|
||||
|
||||
public String getHkmny() {
|
||||
return hkmny;
|
||||
}
|
||||
|
||||
public void setHkmny(String hkmny) {
|
||||
this.hkmny = hkmny == "" ? "0.00" : hkmny;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,279 @@
|
|||
package com.api.lh.port;
|
||||
|
||||
/**
|
||||
* @ClassName Items
|
||||
* @Description 需要抛转的,付款应付单.预付付款单-----明细表字段
|
||||
* @Author louh
|
||||
* @Date 2022/3/1 14:49
|
||||
* @Version 1.0
|
||||
*/
|
||||
public class Items {
|
||||
private String objtype; /* 往来对象 1:供应商 2:部门 3:业务员*/
|
||||
private String supplier; /* 供应商编码,往来对象为供应商时必填 */
|
||||
private String pu_deptid; /* 业务部门编码 */
|
||||
private String pk_psndoc; /* 业务员编码, 往来对象为业务员时必填 */
|
||||
private String prepay; /* 付款性质 3:应付款 4:预付款 */
|
||||
private String pk_currtype; /* 币种编码 默认CNY */
|
||||
private String money_de; /* 贷方原币金额 */
|
||||
private String rate; /* 组织本币汇率, 默认1 */
|
||||
private String local_money_de; /* 组织本币金额 */
|
||||
private String grouprate; /* 组织本币汇率. 默认1 */
|
||||
private String groupdebit; /* 集团本币金额 */
|
||||
private String globalrate; /* 全局本币汇率, 默认1 */
|
||||
private String globaldebit; /* 全局本币金额 */
|
||||
private String quantity_de; /* 贷方数量 */
|
||||
private String price; /* 单价 */
|
||||
private String itemid; /* 采购订单/应付订单明细id*/
|
||||
private String ordervbillcode; /* 采购单据号 */
|
||||
private String payplanid; /* 付款计划id */
|
||||
private String paybillcode; /* 应付单据号 */
|
||||
private String scomment; /* 摘要 */
|
||||
private String pk_tradetype; /* 单据类型 */
|
||||
private String material; /* 物料 */
|
||||
private String pk_dept; /* 部门编码 */
|
||||
private String ap_recaccount; /* 收款银行账户编码 */
|
||||
private String ap_payaccount; /* 付款银行账号编码 默认为空*/
|
||||
private String def2; /* 网点编码 */
|
||||
public Items(String objtype, String supplier, String pu_deptid, String pk_psndoc,
|
||||
String prepay, String pk_currtype, String money_de, String rate,
|
||||
String local_money_de, String grouprate, String groupdebit,
|
||||
String globalrate, String globaldebit, String quantity_de,
|
||||
String price, String itemid, String ordervbillcode, String payplanid,
|
||||
String paybillcode, String scomment, String pk_tradetype, String material,
|
||||
String pk_dept, String ap_recaccount, String ap_payaccount, String def2) {
|
||||
this.objtype = objtype;
|
||||
this.supplier = supplier;
|
||||
this.pu_deptid = pu_deptid;
|
||||
this.pk_psndoc = pk_psndoc;
|
||||
this.prepay = prepay;
|
||||
this.pk_currtype = pk_currtype;
|
||||
this.money_de = money_de;
|
||||
this.rate = rate;
|
||||
this.local_money_de = local_money_de;
|
||||
this.grouprate = grouprate;
|
||||
this.groupdebit = groupdebit;
|
||||
this.globalrate = globalrate;
|
||||
this.globaldebit = globaldebit;
|
||||
this.quantity_de = quantity_de;
|
||||
this.price = price;
|
||||
this.itemid = itemid;
|
||||
this.ordervbillcode = ordervbillcode;
|
||||
this.payplanid = payplanid;
|
||||
this.paybillcode = paybillcode;
|
||||
this.scomment = scomment;
|
||||
this.pk_tradetype = pk_tradetype;
|
||||
this.material = material;
|
||||
this.pk_dept = pk_dept;
|
||||
this.ap_recaccount = ap_recaccount;
|
||||
this.ap_payaccount = ap_payaccount;
|
||||
this.def2 = def2;
|
||||
}
|
||||
|
||||
public String getObjtype() {
|
||||
return objtype;
|
||||
}
|
||||
|
||||
public void setObjtype(String objtype) {
|
||||
this.objtype = objtype;
|
||||
}
|
||||
|
||||
public String getSupplier() {
|
||||
return supplier;
|
||||
}
|
||||
|
||||
public void setSupplier(String supplier) {
|
||||
this.supplier = supplier;
|
||||
}
|
||||
|
||||
public String getPu_deptid() {
|
||||
return pu_deptid;
|
||||
}
|
||||
|
||||
public void setPu_deptid(String pu_deptid) {
|
||||
this.pu_deptid = pu_deptid;
|
||||
}
|
||||
|
||||
public String getPk_psndoc() {
|
||||
return pk_psndoc;
|
||||
}
|
||||
|
||||
public void setPk_psndoc(String pk_psndoc) {
|
||||
this.pk_psndoc = pk_psndoc;
|
||||
}
|
||||
|
||||
public String getPrepay() {
|
||||
return prepay;
|
||||
}
|
||||
|
||||
public void setPrepay(String prepay) {
|
||||
this.prepay = prepay;
|
||||
}
|
||||
|
||||
public String getPk_currtype() {
|
||||
return pk_currtype;
|
||||
}
|
||||
|
||||
public void setPk_currtype(String pk_currtype) {
|
||||
this.pk_currtype = pk_currtype;
|
||||
}
|
||||
|
||||
public String getMoney_de() {
|
||||
return money_de;
|
||||
}
|
||||
|
||||
public void setMoney_de(String money_de) {
|
||||
this.money_de = money_de;
|
||||
}
|
||||
|
||||
public String getRate() {
|
||||
return rate;
|
||||
}
|
||||
|
||||
public void setRate(String rate) {
|
||||
this.rate = rate;
|
||||
}
|
||||
|
||||
public String getLocal_money_de() {
|
||||
return local_money_de;
|
||||
}
|
||||
|
||||
public void setLocal_money_de(String local_money_de) {
|
||||
this.local_money_de = local_money_de;
|
||||
}
|
||||
|
||||
public String getGrouprate() {
|
||||
return grouprate;
|
||||
}
|
||||
|
||||
public void setGrouprate(String grouprate) {
|
||||
this.grouprate = grouprate;
|
||||
}
|
||||
|
||||
public String getGroupdebit() {
|
||||
return groupdebit;
|
||||
}
|
||||
|
||||
public void setGroupdebit(String groupdebit) {
|
||||
this.groupdebit = groupdebit;
|
||||
}
|
||||
|
||||
public String getGlobalrate() {
|
||||
return globalrate;
|
||||
}
|
||||
|
||||
public void setGlobalrate(String globalrate) {
|
||||
this.globalrate = globalrate;
|
||||
}
|
||||
|
||||
public String getGlobaldebit() {
|
||||
return globaldebit;
|
||||
}
|
||||
|
||||
public void setGlobaldebit(String globaldebit) {
|
||||
this.globaldebit = globaldebit;
|
||||
}
|
||||
|
||||
public String getQuantity_de() {
|
||||
return quantity_de;
|
||||
}
|
||||
|
||||
public void setQuantity_de(String quantity_de) {
|
||||
this.quantity_de = quantity_de;
|
||||
}
|
||||
|
||||
public String getPrice() {
|
||||
return price;
|
||||
}
|
||||
|
||||
public void setPrice(String price) {
|
||||
this.price = price;
|
||||
}
|
||||
|
||||
public String getItemid() {
|
||||
return itemid;
|
||||
}
|
||||
|
||||
public void setItemid(String itemid) {
|
||||
this.itemid = itemid;
|
||||
}
|
||||
|
||||
public String getOrdervbillcode() {
|
||||
return ordervbillcode;
|
||||
}
|
||||
|
||||
public void setOrdervbillcode(String ordervbillcode) {
|
||||
this.ordervbillcode = ordervbillcode;
|
||||
}
|
||||
|
||||
public String getPayplanid() {
|
||||
return payplanid;
|
||||
}
|
||||
|
||||
public void setPayplanid(String payplanid) {
|
||||
this.payplanid = payplanid;
|
||||
}
|
||||
|
||||
public String getPaybillcode() {
|
||||
return paybillcode;
|
||||
}
|
||||
|
||||
public void setPaybillcode(String paybillcode) {
|
||||
this.paybillcode = paybillcode;
|
||||
}
|
||||
|
||||
public String getScomment() {
|
||||
return scomment;
|
||||
}
|
||||
|
||||
public void setScomment(String scomment) {
|
||||
this.scomment = scomment;
|
||||
}
|
||||
|
||||
public String getPk_tradetype() {
|
||||
return pk_tradetype;
|
||||
}
|
||||
|
||||
public void setPk_tradetype(String pk_tradetype) {
|
||||
this.pk_tradetype = pk_tradetype;
|
||||
}
|
||||
|
||||
public String getMaterial() {
|
||||
return material;
|
||||
}
|
||||
|
||||
public void setMaterial(String material) {
|
||||
this.material = material;
|
||||
}
|
||||
|
||||
public String getPk_dept() {
|
||||
return pk_dept;
|
||||
}
|
||||
|
||||
public void setPk_dept(String pk_dept) {
|
||||
this.pk_dept = pk_dept;
|
||||
}
|
||||
|
||||
public String getAp_recaccount() {
|
||||
return ap_recaccount;
|
||||
}
|
||||
|
||||
public void setAp_recaccount(String ap_recaccount) {
|
||||
this.ap_recaccount = ap_recaccount;
|
||||
}
|
||||
|
||||
public String getAp_payaccount() {
|
||||
return ap_payaccount;
|
||||
}
|
||||
|
||||
public void setAp_payaccount(String ap_payaccount) {
|
||||
this.ap_payaccount = ap_payaccount;
|
||||
}
|
||||
|
||||
public String getDef2() {
|
||||
return def2;
|
||||
}
|
||||
|
||||
public void setDef2(String def2) {
|
||||
this.def2 = def2;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,234 @@
|
|||
package com.api.lh.port;
|
||||
|
||||
import weaver.soa.workflow.request.RequestService;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @ClassName StuData
|
||||
* @Description 需要抛转的,付款应付单.预付付款单-----主表字段
|
||||
* @Author louh
|
||||
* @Date 2022/3/1 14:48
|
||||
* @Version 1.0
|
||||
*/
|
||||
public class StuData {
|
||||
private String local_money; /* 组织本币金额 */
|
||||
private String globallocal; /* 全局本币金额 */
|
||||
private String pk_tradetype; /* 交易类型编码: D3*/
|
||||
private String pk_currtype; /* 币种编码 默认CNY */
|
||||
private String grouplocal; /* 集团本币对象*/
|
||||
private String objtype; /* 往来对象 1:供应商编码,2:部门编码 3:业务员编码 */
|
||||
private String pk_org; /* 财务组织编码 */
|
||||
private String pu_deptid; /* 业务部门编码 */
|
||||
private String money; /* 原币金额 */
|
||||
private String rate; /* 组织本币汇率 默认1*/
|
||||
private String billmaker; /* 制单人编码 */
|
||||
private String supplier; /* 供应商编码 */
|
||||
private String grouprate; /* 集团本币汇率 默认1 */
|
||||
private String billdate; /* 制单日期 yyyy-MM-dd */
|
||||
private String ap_payaccount; /* 付款银行账户 */
|
||||
private String globalrate; /* 全局本币汇率 默认1*/
|
||||
private String oarequestid; /* Oarequestid*/
|
||||
private String oabillcode; /* oa单据编号 */
|
||||
private String ap_recaccount; /* 付款银行账户 */
|
||||
private String def80; /* 付款银行备注 */
|
||||
private List<Items> items;
|
||||
|
||||
public StuData(String pk_org, String pk_tradetype, String billdate,
|
||||
String objtype, String pk_currtype, String ap_recaccount,
|
||||
String money, String rate, String local_money, String grouprate,
|
||||
String grouplocal, String globalrate, String globallocal,
|
||||
String billmaker, String oarequestid, String oabillcode, String supplier,
|
||||
List<Items> items,String pu_deptid, String ap_payaccount, String def80) {
|
||||
this.pk_org = pk_org;
|
||||
this.pk_tradetype = pk_tradetype;
|
||||
this.billdate = billdate;
|
||||
this.objtype = objtype;
|
||||
this.pk_currtype = pk_currtype;
|
||||
this.ap_recaccount = ap_recaccount;
|
||||
this.money = money;
|
||||
this.rate = rate;
|
||||
this.local_money = local_money;
|
||||
this.grouprate = grouprate;
|
||||
this.grouplocal = grouplocal;
|
||||
this.globalrate = globalrate;
|
||||
this.globallocal = globallocal;
|
||||
this.billmaker = billmaker;
|
||||
this.oarequestid = oarequestid;
|
||||
this.oabillcode = oabillcode;
|
||||
this.supplier = supplier;
|
||||
this.items = items;
|
||||
this.pu_deptid = pu_deptid;
|
||||
this.ap_payaccount = ap_payaccount;
|
||||
this.def80 = def80;
|
||||
}
|
||||
|
||||
public String getPk_org() {
|
||||
return pk_org;
|
||||
}
|
||||
|
||||
public void setPk_org(String pk_org) {
|
||||
this.pk_org = pk_org;
|
||||
}
|
||||
|
||||
public String getPk_tradetype() {
|
||||
return pk_tradetype;
|
||||
}
|
||||
|
||||
public void setPk_tradetype(String pk_tradetype) {
|
||||
this.pk_tradetype = pk_tradetype;
|
||||
}
|
||||
|
||||
public String getBilldate() {
|
||||
return billdate;
|
||||
}
|
||||
|
||||
public void setBilldate(String billdate) {
|
||||
this.billdate = billdate;
|
||||
}
|
||||
|
||||
public String getObjtype() {
|
||||
return objtype;
|
||||
}
|
||||
|
||||
public void setObjtype(String objtype) {
|
||||
this.objtype = objtype;
|
||||
}
|
||||
|
||||
public String getPk_currtype() {
|
||||
return pk_currtype;
|
||||
}
|
||||
|
||||
public void setPk_currtype(String pk_currtype) {
|
||||
this.pk_currtype = pk_currtype;
|
||||
}
|
||||
|
||||
public String getAp_recaccount() {
|
||||
return ap_recaccount;
|
||||
}
|
||||
|
||||
public void setAp_recaccount(String ap_recaccount) {
|
||||
this.ap_recaccount = ap_recaccount;
|
||||
}
|
||||
|
||||
public String getMoney() {
|
||||
return money;
|
||||
}
|
||||
|
||||
public void setMoney(String money) {
|
||||
this.money = money;
|
||||
}
|
||||
|
||||
public String getRate() {
|
||||
return rate;
|
||||
}
|
||||
|
||||
public void setRate(String rate) {
|
||||
this.rate = rate;
|
||||
}
|
||||
|
||||
public String getLocal_money() {
|
||||
return local_money;
|
||||
}
|
||||
|
||||
public void setLocal_money(String local_money) {
|
||||
this.local_money = local_money;
|
||||
}
|
||||
|
||||
public String getGrouprate() {
|
||||
return grouprate;
|
||||
}
|
||||
|
||||
public void setGrouprate(String grouprate) {
|
||||
this.grouprate = grouprate;
|
||||
}
|
||||
|
||||
public String getGrouplocal() {
|
||||
return grouplocal;
|
||||
}
|
||||
|
||||
public void setGrouplocal(String grouplocal) {
|
||||
this.grouplocal = grouplocal;
|
||||
}
|
||||
|
||||
public String getGlobalrate() {
|
||||
return globalrate;
|
||||
}
|
||||
|
||||
public void setGlobalrate(String globalrate) {
|
||||
this.globalrate = globalrate;
|
||||
}
|
||||
|
||||
public String getGloballocal() {
|
||||
return globallocal;
|
||||
}
|
||||
|
||||
public void setGloballocal(String globallocal) {
|
||||
this.globallocal = globallocal;
|
||||
}
|
||||
|
||||
public String getBillmaker() {
|
||||
return billmaker;
|
||||
}
|
||||
|
||||
public void setBillmaker(String billmaker) {
|
||||
this.billmaker = billmaker;
|
||||
}
|
||||
|
||||
public String getOarequestid() {
|
||||
return oarequestid;
|
||||
}
|
||||
|
||||
public void setOarequestid(String oarequestid) {
|
||||
this.oarequestid = oarequestid;
|
||||
}
|
||||
|
||||
public String getOabillcode() {
|
||||
return oabillcode;
|
||||
}
|
||||
|
||||
public void setOabillcode(String oabillcode) {
|
||||
this.oabillcode = oabillcode;
|
||||
}
|
||||
|
||||
public String getSupplier() {
|
||||
return supplier;
|
||||
}
|
||||
|
||||
public void setSupplier(String supplier) {
|
||||
this.supplier = supplier;
|
||||
}
|
||||
|
||||
public List<Items> getItems() {
|
||||
return items;
|
||||
}
|
||||
|
||||
public void setItems(List<Items> items) {
|
||||
this.items = items;
|
||||
}
|
||||
|
||||
public String getPu_deptid() {
|
||||
return pu_deptid;
|
||||
}
|
||||
|
||||
public void setPu_deptid(String pu_deptid) {
|
||||
this.pu_deptid = pu_deptid;
|
||||
}
|
||||
|
||||
public String getAp_payaccount() {
|
||||
return ap_payaccount;
|
||||
}
|
||||
|
||||
public void setAp_payaccount(String ap_payaccount) {
|
||||
this.ap_payaccount = ap_payaccount;
|
||||
}
|
||||
|
||||
public String getDef80() {
|
||||
return def80;
|
||||
}
|
||||
|
||||
public void setDef80(String def80) {
|
||||
this.def80 = def80;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,93 @@
|
|||
package com.api.lh.util;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import weaver.general.Util;
|
||||
import weaver.soa.workflow.request.Cell;
|
||||
import weaver.soa.workflow.request.Property;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* @ClassName CreateProcessUtil
|
||||
* @Description 创建流程
|
||||
* @Author louh
|
||||
* @Date 2022/4/6 13:35
|
||||
* @Version 1.0
|
||||
*/
|
||||
public class CreateProcessUtil {
|
||||
|
||||
/**
|
||||
* 拼接流程主表字段
|
||||
* @param p
|
||||
* @param name 字段名
|
||||
* @param value 字段值
|
||||
* @return
|
||||
*/
|
||||
public static Property[] setProperty(Property[] p, String name, String value){
|
||||
if("".equals(Util.null2String(value).trim())){
|
||||
return p;
|
||||
}
|
||||
p = Arrays.copyOf(p, (p.length + 1));
|
||||
p[p.length - 1] = new Property();
|
||||
p[p.length - 1].setName(name);
|
||||
p[p.length - 1].setValue(value);
|
||||
return p;
|
||||
}
|
||||
|
||||
/**
|
||||
* 拼接流程明细表字段
|
||||
* @param c
|
||||
* @param name 字段名
|
||||
* @param value 字段值
|
||||
* @return
|
||||
*/
|
||||
public static Cell[] setCell(Cell[] c, String name, String value){
|
||||
if("".equals(Util.null2String(value).trim())){
|
||||
return c;
|
||||
}
|
||||
c = Arrays.copyOf(c, (c.length+1));
|
||||
c[c.length-1] = new Cell();
|
||||
c[c.length-1].setName(name);
|
||||
c[c.length-1].setValue(value);
|
||||
return c;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 判断流程是否成功
|
||||
* @param requestid
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
public static JSONObject judge(String requestid){
|
||||
JSONObject jsonObject=new JSONObject();
|
||||
jsonObject.put("requestid",requestid);
|
||||
String MSG="";
|
||||
String status = "1"; // 0.成功 1.失败
|
||||
if (requestid.equals("-1")) {
|
||||
MSG="创建流程失败!";
|
||||
}else if (requestid.equals("-2")){
|
||||
MSG="用户没有流程创建权限!";
|
||||
}else if (requestid.equals("-3")) {
|
||||
MSG="流程基本信息失败!";
|
||||
}else if (requestid.equals("-4")) {
|
||||
MSG="流程表单主表信息失败!";
|
||||
}else if (requestid.equals("-5")) {
|
||||
MSG="流程紧急程度失败!";
|
||||
}else if (requestid.equals("-6")) {
|
||||
MSG="流程操作者失效!";
|
||||
}else if (requestid.equals("-7")) {
|
||||
MSG="流转至下一节点失败!";
|
||||
}else if (requestid.equals("-8")) {
|
||||
MSG="流程节点附加操作失败!";
|
||||
}else if (Integer.parseInt(requestid)>0) {
|
||||
status = "0";
|
||||
MSG="流程创建成功!";
|
||||
}
|
||||
jsonObject.put("status", status);
|
||||
jsonObject.put("msg",MSG);
|
||||
return jsonObject;
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,60 @@
|
|||
package com.api.lh.util;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
|
||||
/**
|
||||
* @ClassName DateUtil
|
||||
* @Description TODO
|
||||
* @Author louh
|
||||
* @Date 2022/6/7 14:30
|
||||
* @Version 1.0
|
||||
*/
|
||||
public class DUtil {
|
||||
|
||||
/**
|
||||
* 获取指定月份的最后一天
|
||||
* @param yearMonth 格式yyyy-MM
|
||||
* @return
|
||||
*/
|
||||
public static String getLastDayOfMonth(String yearMonth){
|
||||
int year = Integer.parseInt(yearMonth.split("-")[0]); //年
|
||||
int month = Integer.parseInt(yearMonth.split("-")[1]); //月
|
||||
Calendar cal = Calendar.getInstance();
|
||||
//设置年份
|
||||
cal.set(Calendar.YEAR, year);
|
||||
//设置月份
|
||||
cal.set(Calendar.MONTH, month);
|
||||
//获取某月的最小天数
|
||||
int lastDay = cal.getActualMinimum(Calendar.DAY_OF_MONTH);
|
||||
cal.set(Calendar.DAY_OF_MONTH, lastDay - 1);
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
||||
return sdf.format(cal.getTime());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取指定月份的下个月第一天
|
||||
* @param yearMonth 格式yyyy-MM
|
||||
* @return
|
||||
*/
|
||||
public static String getFirstDayOfNextMonth(String yearMonth){
|
||||
int year = Integer.parseInt(yearMonth.split("-")[0]); //年
|
||||
int month = Integer.parseInt(yearMonth.split("-")[1]); //月
|
||||
Calendar cal = Calendar.getInstance();
|
||||
//设置年份
|
||||
cal.set(Calendar.YEAR, year);
|
||||
//设置月份
|
||||
cal.set(Calendar.MONTH, month - 1);
|
||||
//获取某月的最大天数
|
||||
int lastDay = cal.getActualMaximum(Calendar.DAY_OF_MONTH);
|
||||
cal.set(Calendar.DAY_OF_MONTH, lastDay + 1);
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
||||
return sdf.format(cal.getTime());
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
System.out.println(getLastDayOfMonth("2022-06-11"));
|
||||
System.out.println(getFirstDayOfNextMonth("2022-05-17"));
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,316 @@
|
|||
package com.engine.demo.impl;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.weaverboot.frame.ioc.anno.classAnno.WeaIocReplaceComponent;
|
||||
import com.weaverboot.frame.ioc.anno.methodAnno.WeaReplaceAfter;
|
||||
import com.weaverboot.frame.ioc.handler.replace.weaReplaceParam.impl.WeaAfterReplaceParam;
|
||||
import selfdev.util.log.LogTool;
|
||||
import weaver.conn.RecordSet;
|
||||
import weaver.dateformat.DateTransformer;
|
||||
import weaver.general.Util;
|
||||
import weaver.hrm.HrmUserVarify;
|
||||
import weaver.hrm.User;
|
||||
import weaver.systeminfo.SystemEnv;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* 拦截 建模数据保存 日志
|
||||
*/
|
||||
@WeaIocReplaceComponent
|
||||
public class CubeSaveInterccept {
|
||||
private final static LogTool log = new LogTool("/log/TransField/",false);
|
||||
|
||||
// private static final String qyidField="field7267";//企业ID
|
||||
// private static final String modiflyField="field7267";//修改的uuid 值 用于定位 修改 log
|
||||
// private static final String bbrqField="field7267";//版本日期
|
||||
// private static final String modeId="84";//拦截 模块
|
||||
// public static final int CompanyMaintableFormid=-102;//企业主表 表ID
|
||||
/** 生产 **/
|
||||
private static final String modiflyField="field893767";//""field7267";//修改的uuid 值 用于定位 修改 log uat field677323
|
||||
//private static final String qyidField="field7267";//企业ID
|
||||
private static final String qyidField="field893807";//企业ID uat field659381
|
||||
//private static final String bbrqField="field7267";//版本日期
|
||||
private static final String bbrqField="field893806";//版本日期 uat field659380
|
||||
private static final String modeId="46040";//""84";//拦截 模块 uat 38501
|
||||
public static final String CompanyMaintable="uf_jingneiqiyexinxi";//企业主表
|
||||
public static final int CompanyMaintableFormid=-3055;//-102;//企业主表 表ID uat -1824
|
||||
public static final String CompanyVersionMaintable="formtable_main_3055";//企业版本主表 uat formtable_main_1824
|
||||
public static final String filterField=",operateType,detaildataid,fieldid,fieldvalue,detailtable,";
|
||||
|
||||
|
||||
/** 生产 **/
|
||||
|
||||
// /** 测试 **/
|
||||
// private static final String modiflyField="field677323";//""field7267";//修改的uuid 值 用于定位 修改 log uat field677323
|
||||
// //private static final String qyidField="field7267";//企业ID
|
||||
// private static final String qyidField="field659381";//企业ID uat field659381
|
||||
// //private static final String bbrqField="field7267";//版本日期
|
||||
// private static final String bbrqField="field659380";//版本日期 uat field659380
|
||||
// private static final String modeId="38501";//""84";//拦截 模块 uat 38501
|
||||
// public static final String CompanyMaintable="uf_jingneiqiyexinxi";//企业主表
|
||||
// public static final int CompanyMaintableFormid=-1824;//-102;//企业主表 表ID uat -1824
|
||||
// public static final String CompanyVersionMaintable="formtable_main_1824";//企业版本主表 uat formtable_main_1824
|
||||
// public static final String filterField=",operateType,detaildataid,fieldid,fieldvalue,detailtable,";
|
||||
// /** 测试 **/
|
||||
|
||||
@WeaReplaceAfter(value = "/api/cube/new/card/doSubmit", order = 10010, description = "拦截 建模数据保存 日志")
|
||||
public String cubeSaveInterccept(WeaAfterReplaceParam param){
|
||||
/** 常规获取参数 **/
|
||||
Map<String,Object> params= param.getParamMap();
|
||||
HttpServletRequest req =param.getRequest();
|
||||
HttpServletResponse resp =param.getResponse();
|
||||
String demo =param.getData();
|
||||
/** 只是拦截 type=2(编辑) 以及 modiflyField 字段不为空的 操作 **/
|
||||
String type=(String)params.get("type");
|
||||
String modeIdstr=(String)params.get("modeId");
|
||||
String formId=(String)params.get("formId");
|
||||
String billid=(String)params.get("billid");
|
||||
if("2".equals(type)&&modeId.equals(modeIdstr)){
|
||||
try{
|
||||
//解析表单参数
|
||||
log.writeLog("开始拦截!");
|
||||
JSONObject FormJson= JSONObject.parseObject((String)params.get("JSONStr"));// ;
|
||||
if(FormJson!=null&&FormJson.size()>0){
|
||||
log.writeLog(FormJson.toJSONString());
|
||||
String modiflyFieldValue= Util.null2String(FormJson.getString(modiflyField)).trim() ;
|
||||
if("".equals(modiflyFieldValue)){//为空不取日志数据
|
||||
return demo;
|
||||
}
|
||||
User user = HrmUserVarify.getUser(req, resp);
|
||||
TransField transField=new TransField(Util.getIntValue(formId,0),billid,user);
|
||||
transField.setQyid(Util.null2String(FormJson.getString(qyidField)).trim());//企业ID
|
||||
transField.setBbrq(Util.null2String(FormJson.getString(bbrqField)).trim());//版本日期
|
||||
getMainLog(modiflyFieldValue,transField);
|
||||
}
|
||||
}catch(Exception e){
|
||||
log.writeLog("cubeSaveInterccept-->"+e.getMessage());
|
||||
}
|
||||
}
|
||||
return demo;
|
||||
}
|
||||
|
||||
public void getMainLog(String modiflyFieldValue,TransField transField){
|
||||
|
||||
RecordSet re=new RecordSet();
|
||||
JSONObject valJSon=new JSONObject();
|
||||
JSONObject detailValJSon=new JSONObject();//明细
|
||||
String viewlogid="";
|
||||
String sql="select * from ModeLogFieldDetail where viewlogid in (select viewlogid from ModeLogFieldDetail where modeid="+modeId+" and fieldid='"+(modiflyField.replaceAll("field",""))+"' and fieldvalue=?) and modeid="+modeId;
|
||||
log.writeLog(modiflyFieldValue+""+sql);
|
||||
re.executeQuery(sql,modiflyFieldValue);
|
||||
while(re.next()){
|
||||
|
||||
viewlogid=Util.null2String(re.getString("viewlogid")).trim() ;
|
||||
String fieldid=Util.null2String(re.getString("fieldid")).trim() ;
|
||||
String fieldvalue= Util.null2String(re.getString("fieldvalue")).trim();
|
||||
String PREFIELDVALUE=Util.null2String(re.getString("PREFIELDVALUE")).trim();
|
||||
String detaildataid= Util.null2String(re.getString("detaildataid")).trim();
|
||||
String operateType= Util.null2String(re.getString("operateType")).trim();// operateType EDIT,ADD
|
||||
String detailtable= Util.null2String(re.getString("detailtable")).trim();
|
||||
|
||||
if(fieldid.equals(modiflyField.replaceAll("field",""))){
|
||||
continue;
|
||||
}
|
||||
if("".equals(detaildataid)){
|
||||
valJSon.put(fieldid,fieldvalue);//主表
|
||||
}else{
|
||||
if(!"EDIT".equals(operateType)&&!"ADD".equals(operateType)&&!"DEL".equals(operateType)){//目前只是处理编辑以及 新增 不处理删除
|
||||
continue;
|
||||
}
|
||||
/** 明细表 **/
|
||||
String detailtableindex=detailtable.substring(detailtable.lastIndexOf("_")+1);//明细行的下标
|
||||
|
||||
JSONArray details= detailValJSon.getJSONArray(detailtableindex);
|
||||
if(details==null||details.size()<=0){
|
||||
JSONArray demos=new JSONArray();
|
||||
JSONObject demo=new JSONObject();
|
||||
demo.put("operateType",operateType);
|
||||
demo.put("detailtable",detailtable);
|
||||
demo.put("detaildataid",detaildataid);
|
||||
demo.put(fieldid,fieldvalue);
|
||||
if("EDIT".equals(operateType)){
|
||||
/** 获取mainbillid **/
|
||||
demo.put("mainid",getMainbillid( detaildataid, detailtable)) ;
|
||||
}else if("DEL".equals(operateType)){
|
||||
if(detailtable.indexOf("dt2")>-1&&"893946".equals(fieldid)){
|
||||
demo.put("mainid",PREFIELDVALUE) ;
|
||||
}else if(detailtable.indexOf("dt3")>-1&&"893947".equals(fieldid)){
|
||||
demo.put("mainid",PREFIELDVALUE) ;
|
||||
}
|
||||
|
||||
}
|
||||
demos.add(demo);
|
||||
detailValJSon.put(detailtableindex,demos);
|
||||
}else{
|
||||
JSONObject demo=new JSONObject();
|
||||
demo.put("operateType",operateType);
|
||||
demo.put("detaildataid",detaildataid);
|
||||
demo.put("fieldid",fieldid);
|
||||
demo.put("fieldvalue",fieldvalue);
|
||||
demo.put("PREFIELDVALUE",PREFIELDVALUE);
|
||||
demo.put("detailtable",detailtable);
|
||||
setJSONArraySingle(details, demo);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
transField.setViewlogid(viewlogid);
|
||||
if(valJSon!=null&&valJSon.size()>0){
|
||||
//获取 value 对应的值
|
||||
JSONArray transFieldJSONs=new JSONArray();
|
||||
Set<String> key=valJSon.keySet();
|
||||
for(String str:key){
|
||||
try {
|
||||
//JSONObject transFieldJSON= ModeLogMainfield( viewlogid,Util.getIntValue(modeId,0),transField.getBillid(),str,valJSon.getString(str), transField);
|
||||
JSONObject transFieldJSON= ModeLogMainfield( viewlogid,Util.getIntValue(modeId,0),str, transField);
|
||||
if(transFieldJSON!=null&&transFieldJSON.size()>0){
|
||||
transFieldJSONs.add(transFieldJSON);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
if(transFieldJSONs.size()>0){
|
||||
transField.setTransFieldJSONs(transFieldJSONs);
|
||||
}
|
||||
}
|
||||
transField.updateCompanyInfo(valJSon,detailValJSon);//生产 sql
|
||||
transField.updateallmodflyuuid();//更新明细
|
||||
}
|
||||
public JSONObject ModeLogMainfield(String viewlogid,int modeId,String fieldid,TransField transField) throws Exception {
|
||||
return ModeLogMainfield(viewlogid,modeId,fieldid,transField,"","","");
|
||||
}
|
||||
//public JSONObject ModeLogMainfield(String viewlogid,int modeId,String billid,String fieldid,String value,TransField transField) throws Exception {
|
||||
public JSONObject ModeLogMainfield(String viewlogid,int modeId,String fieldid,TransField transField,String detaildataid,String operateType,String detailtable) throws Exception {
|
||||
RecordSet var3=new RecordSet();
|
||||
String var4 = "select a.id,a.fieldid,a.fieldvalue,a.prefieldvalue,c.fieldlabel,c.fieldname,c.fieldhtmltype,c.type,c.fielddbtype,c.viewtype from ModeLogFieldDetail a left join workflow_billfield c on a.fieldid=c.id where a.viewlogid = " + viewlogid + " and a.modeid = " + modeId + " and (a.detailtable='' or a.detailtable is null) and fieldid="+fieldid;
|
||||
if(!"".equals(detaildataid)){
|
||||
var4=var4+" and detaildataid='"+detaildataid+"' and operateType='"+operateType+"' and detailtable='"+detailtable+"'";
|
||||
}
|
||||
JSONObject var6 = new JSONObject();
|
||||
var3.execute(var4);
|
||||
while(var3.next()) {
|
||||
|
||||
String var7 = Util.null2String(var3.getString("fieldhtmltype"));
|
||||
var6.put("htmltype", var7);
|
||||
int var8 = Util.getIntValue(Util.null2String(var3.getString("type")));
|
||||
var6.put("type", var8);
|
||||
String var9 = Util.null2String(var3.getString("fielddbtype"));
|
||||
var6.put("dbtype", var9);
|
||||
String var10 = Util.null2String(var3.getString("fieldid"));
|
||||
var6.put("fieldid", var10);
|
||||
String var11 = Util.null2String(var3.getString("viewtype"));
|
||||
var6.put("viewtype", var11);
|
||||
String var12 = Util.null2String(var3.getString("fieldvalue"));
|
||||
String var13 = Util.null2String(var3.getString("prefieldvalue"));
|
||||
if (var8 == 290) {
|
||||
var12 = (new DateTransformer()).getLocaleDateTime(var12);
|
||||
var13 = (new DateTransformer()).getLocaleDateTime(var13);
|
||||
}
|
||||
|
||||
var6.put("fieldvalue", var12);
|
||||
var6.put("oldfieldvalue", var12);
|
||||
var6.put("prefieldvalue", var13);
|
||||
var6.put("oldprefieldvalue", var13);
|
||||
String var14 = Util.null2String(SystemEnv.getHtmlLabelName(var3.getInt("fieldlabel"), 7));// 默认 中文
|
||||
var6.put("labelname", var14);
|
||||
String var15 = Util.null2String(var3.getString("fieldname"));
|
||||
var6.put("fieldname", var15);
|
||||
var6.put("fieldlabelname", var14 + "(" + var15 + ")");
|
||||
//此处需要用到 反设置机制
|
||||
//transField.transFieldValue(fieldvalue, fieldhtmltype, fieldid, fielddbtype, viewtype, type)
|
||||
String var16 = BaseUtil.Html2Text(Util.null2String(transField.transFieldValue(var12, var7, var10, var9, var11, var8))).replaceAll(" ","") ;
|
||||
String var17 = BaseUtil.Html2Text(Util.null2String(transField.transFieldValue(var13, var7, var10, var9, var11, var8))).replaceAll(" ","") ;
|
||||
if (!var16.equals(var17)) {
|
||||
var6.put("fieldvalue", var16);
|
||||
var6.put("prefieldvalue", var17);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return var6;
|
||||
}
|
||||
|
||||
public void updateFormLog(JSONObject json,TransField transField){
|
||||
if(json==null||json.size()<=0){
|
||||
return;
|
||||
}
|
||||
/** 开始跟新 **/
|
||||
String fieldname=Util.null2String(json.getString("fieldname")) ;
|
||||
String fieldvalue=Util.null2String(json.getString("fieldvalue"));
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 将 一个json字段信息 拆入到已有的明细表行 根据 detaildataid 来判断
|
||||
* @param jsons
|
||||
* @param demo
|
||||
*/
|
||||
public void setJSONArraySingle(JSONArray jsons,JSONObject demo){
|
||||
if(jsons==null||jsons.size()<=0||demo==null||demo.size()<=0){
|
||||
return;
|
||||
}
|
||||
String detaildataid=Util.null2String(demo.getString("detaildataid")).trim() ;
|
||||
if("".equals(detaildataid)){
|
||||
return;
|
||||
}
|
||||
boolean isvali=false;
|
||||
for(int i=0;i<jsons.size();i++){
|
||||
JSONObject demo1= jsons.getJSONObject(i);
|
||||
if(demo1==null||demo1.size()<=0){
|
||||
continue;
|
||||
}
|
||||
String demo1detaildataid=Util.null2String(demo1.getString("detaildataid")) ;
|
||||
if(demo1detaildataid.equals(detaildataid)){
|
||||
//fieldid,fieldvalue
|
||||
demo1.put(demo.getString("fieldid"),demo.getString("fieldvalue"));
|
||||
if("DEL".equals(demo.getString("operateType"))){
|
||||
if(demo.getString("detailtable").indexOf("dt2")>-1&&"893946".equals(demo.getString("fieldid"))){
|
||||
demo.put("mainid",demo.getString("PREFIELDVALUE")) ;
|
||||
}else if(demo.getString("detailtable").indexOf("dt3")>-1&&"893947".equals(demo.getString("fieldid"))){
|
||||
demo.put("mainid",demo.getString("PREFIELDVALUE")) ;
|
||||
}
|
||||
|
||||
}
|
||||
isvali=true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(!isvali){
|
||||
//不存在 则新能数据
|
||||
JSONObject demo2=new JSONObject();
|
||||
demo2.put("operateType",demo.getString("operateType"));
|
||||
demo2.put("detailtable",demo.getString("detailtable"));
|
||||
demo2.put("detaildataid",demo.getString("detaildataid"));
|
||||
demo2.put(demo.getString("fieldid"),demo.getString("fieldvalue"));
|
||||
if("EDIT".equals(demo.getString("operateType"))){
|
||||
/** 获取mainbillid **/
|
||||
demo2.put("mainid",getMainbillid( detaildataid,demo.getString("detailtable") )) ;
|
||||
}else if("DEL".equals(demo.getString("operateType"))){
|
||||
if(demo.getString("detailtable").indexOf("dt2")>-1&&"893946".equals(demo.getString("fieldid"))){
|
||||
demo.put("mainid",demo.getString("PREFIELDVALUE")) ;
|
||||
}else if(demo.getString("detailtable").indexOf("dt3")>-1&&"893947".equals(demo.getString("fieldid"))){
|
||||
demo.put("mainid",demo.getString("PREFIELDVALUE")) ;
|
||||
}
|
||||
|
||||
}
|
||||
jsons.add(demo2);
|
||||
}
|
||||
}
|
||||
|
||||
public String getMainbillid(String detaildataid,String table){
|
||||
String mainbillid="";
|
||||
RecordSet re=new RecordSet();
|
||||
re.executeQuery("select mainbillid from "+table+" where id="+detaildataid);
|
||||
if(re.next()){
|
||||
mainbillid=Util.null2String(re.getString("mainbillid")) ;
|
||||
}
|
||||
return mainbillid;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,456 @@
|
|||
package com.engine.demo.impl;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import selfdev.util.log.LogTool;
|
||||
import weaver.conn.RecordSet;
|
||||
import weaver.general.Util;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 历史数据拆分表
|
||||
*
|
||||
*/
|
||||
public class HistoryDetail {
|
||||
private final static LogTool log = new LogTool("/log/TransField/",false);
|
||||
private TransField transField=null;
|
||||
private JSONObject detailValJSon=null;
|
||||
|
||||
public HistoryDetail(TransField transField,JSONObject detailValJSon){
|
||||
this.transField=transField;
|
||||
this.detailValJSon=detailValJSon;
|
||||
}
|
||||
//明细变更
|
||||
/**
|
||||
* 如果存在明细表的变更的话 则需要对 版本的历史沿革以及 版本的 明细数据 以及 企业信息表的数据 做变更
|
||||
* 1).当前版本是最新的(跟新历史最新的数据只是跟新最新的一条数据 跟新主表数据)
|
||||
* 2).当前版本是中间的版本(1不存在修改则更新所有之后的明细数据 以及跟新当前版本以及之后的所有新历史沿革最新的变更后数据 更新主表数据,2存在版本)
|
||||
*如果 当前版本是之后的版本 只要跟新 历史沿革
|
||||
* **/
|
||||
public void DetailSplit(){
|
||||
SimpleDateFormat sim=new SimpleDateFormat("yyyy-MM-dd");
|
||||
String currentDate=sim.format(new Date());
|
||||
String AllVersionid= transField.getAllVersionid();//当前版本之后的所有版本
|
||||
String getOldAllVersion=transField.getOldAllVersion();//当前版本的 前版本
|
||||
log.writeLog("AllVersionid-->"+AllVersionid);
|
||||
log.writeLog("getOldAllVersion-->"+getOldAllVersion);
|
||||
List<Map<String,Object>> sqlmaps=transField.getSqlmaps();
|
||||
String allmodflyuuid="";//所有的 新增明细的uuid
|
||||
if(detailValJSon!=null&&detailValJSon.size()>0){
|
||||
log.writeLog(detailValJSon.toJSONString());
|
||||
Set<String> detailKey= detailValJSon.keySet();
|
||||
for(String table:detailKey){
|
||||
JSONArray tableDatas=detailValJSon.getJSONArray(table);
|
||||
String detailtabledesc="";//明细列描述
|
||||
String detailtableValue="";//所有的明细值
|
||||
String changeID="";//当前版本最后一次变更的ID
|
||||
String oldchangeID="";//当前版本之前最后一次变更的ID
|
||||
String currentVersionChange="";
|
||||
if(tableDatas!=null&&tableDatas.size()>0){
|
||||
|
||||
//此处插入的是 正式的数据 版本以及 企业信息
|
||||
|
||||
for(int k=0;k<tableDatas.size();k++){
|
||||
JSONObject K=tableDatas.getJSONObject(k);
|
||||
if(K!=null&&K.size()>0){
|
||||
//开始遍历sql
|
||||
String detaildataid= Util.null2String(K.getString("detaildataid")).trim() ;
|
||||
String operateType=Util.null2String(K.getString("operateType")).trim() ;
|
||||
log.writeLog("operateType--->"+operateType);
|
||||
String mainid=Util.null2String(K.getString("mainid")).trim() ;
|
||||
String detailtable=Util.null2String(K.getString("detailtable")).trim() ;
|
||||
String betoowID="";//中间数据
|
||||
String betoowOldID="";//前面版本的中间数据
|
||||
//if("".equals(detailtabledesc)){
|
||||
detailtabledesc= transField.getFeildnameByNames(TransField.detailField.getString(detailtable+"desc"),CubeSaveInterccept.CompanyMaintableFormid);//获取字段的描述
|
||||
detailtableValue=transField.getDetailAllValue(detailtable,TransField.detailField.getString(detailtable+"desc"),transField.getBillid());
|
||||
changeID=transField.checkDetailFieldCheck(AllVersionid,detailtabledesc,1);//checkFieldCheck(AllVersionid, detailtabledesc);//变更版本
|
||||
oldchangeID=transField.checkDetailFieldCheck(getOldAllVersion,detailtabledesc,0);
|
||||
currentVersionChange=transField.checkDetailFieldCheck(transField.getBillid(),detailtabledesc,1);//获取中间版本
|
||||
betoowID=transField.getBetoowVersion(transField.getBillid(),changeID, AllVersionid);// currentVersionChange
|
||||
betoowOldID=transField.getBetoowVersion(oldchangeID,transField.getBillid(), getOldAllVersion);
|
||||
if(!"".equals(betoowOldID)){
|
||||
//需要添加 之前的数据 betoowOldID
|
||||
betoowOldID=oldchangeID+","+betoowOldID;
|
||||
}
|
||||
log.writeLog("detailtabledesc"+detailtabledesc);
|
||||
log.writeLog("detailtableValue"+detailtableValue);
|
||||
log.writeLog("changeID"+changeID);
|
||||
log.writeLog("oldchangeID"+oldchangeID);
|
||||
log.writeLog("currentVersionChange"+currentVersionChange);
|
||||
log.writeLog("betoowID"+betoowID);
|
||||
log.writeLog("betoowOldID"+betoowOldID);
|
||||
|
||||
//}
|
||||
Set<String> kkey= K.keySet();
|
||||
if("EDIT".equals(operateType)){//编辑 &&!"".equals(mainid) 暂时去掉 mainid
|
||||
Map<String,Object> map=new HashMap<>();
|
||||
String fieldsql="";
|
||||
String insertsql="";
|
||||
String insertsqlsplit="";
|
||||
Object[] kparams=new Object[0];
|
||||
for(String mykey:kkey){
|
||||
String fieldname=transField.getFieldNameByid(mykey);
|
||||
if(CubeSaveInterccept.filterField.indexOf(","+fieldname+",")>-1||CubeSaveInterccept.filterField.indexOf(","+mykey+",")>-1||"".equals(fieldname)){
|
||||
continue;
|
||||
}
|
||||
//log.writeLog(fieldname);
|
||||
fieldsql=fieldsql+fieldname+"=?,";
|
||||
insertsql=insertsql+fieldname+",";
|
||||
insertsqlsplit=insertsqlsplit+"?,";
|
||||
kparams = Arrays.copyOf(kparams, (kparams.length+1));
|
||||
kparams[kparams.length-1] = K.get(mykey);
|
||||
}
|
||||
if(fieldsql.endsWith(",")){
|
||||
fieldsql=fieldsql.substring(0,fieldsql.length()-1);
|
||||
}
|
||||
if(insertsql.endsWith(",")){
|
||||
insertsql=insertsql.substring(0,insertsql.length()-1);
|
||||
}
|
||||
log.writeLog("Edit fieldsql-->"+fieldsql);
|
||||
if(insertsqlsplit.endsWith(",")){
|
||||
insertsqlsplit=insertsqlsplit.substring(0,insertsqlsplit.length()-1);
|
||||
}
|
||||
if("".equals(AllVersionid)||"".equals(changeID)){//当前的最新版本
|
||||
//插入企业信息主表
|
||||
Map<String,Object> map1=new HashMap<>();
|
||||
map1.put("sql","update "+CubeSaveInterccept.CompanyMaintable+"_"+table+" set "+fieldsql+" where id="+mainid);
|
||||
map1.put("params",kparams);
|
||||
sqlmaps.add(map1);
|
||||
}
|
||||
if("".equals(currentVersionChange)&&"".equals(oldchangeID)){
|
||||
|
||||
}
|
||||
if(!"".equals(betoowID)||("".equals(betoowID)&&"".equals(changeID)&&!"".equals(AllVersionid))){//存在之后的中间版本
|
||||
if("".equals(betoowID)&&"".equals(changeID)&&!"".equals(AllVersionid)){
|
||||
betoowID= AllVersionid;
|
||||
}
|
||||
String[] betoowIDs=betoowID.split(",");
|
||||
for(String be:betoowIDs){
|
||||
if("".equals(Util.null2String(be).trim())){
|
||||
continue;
|
||||
}
|
||||
Map<String,Object> map1=new HashMap<>();
|
||||
//map1.put("sql","update "+CubeSaveInterccept.CompanyMaintable+"_"+table+" set "+fieldsql+" where id="+be+" and mainbillid="+mainid);
|
||||
map1.put("sql","update "+CubeSaveInterccept.CompanyVersionMaintable+"_"+table+" set "+fieldsql+" where mainid="+be+" and mainbillid="+mainid);
|
||||
map1.put("params",kparams);
|
||||
sqlmaps.add(map1);
|
||||
}
|
||||
}
|
||||
//跟新之前版本的版本数据以及 历史沿革
|
||||
if(!"".endsWith(betoowOldID)&&"".equals(currentVersionChange)){
|
||||
String[] betoowOldIDs=betoowOldID.split(",");
|
||||
for(String be:betoowOldIDs){
|
||||
if("".equals(Util.null2String(be).trim())){
|
||||
continue;
|
||||
}
|
||||
String whereSql=getDeleteSqlWhere( detaildataid, table);
|
||||
if("".equals(whereSql)){
|
||||
continue;
|
||||
}
|
||||
Map<String,Object> map1=new HashMap<>();
|
||||
//map1.put("sql","update "+CubeSaveInterccept.CompanyMaintable+"_"+table+" set "+fieldsql+" where id="+be+" and mainbillid="+mainid);
|
||||
map1.put("sql","update "+CubeSaveInterccept.CompanyVersionMaintable+"_"+table+" set "+fieldsql+" where mainid="+be+" and "+whereSql);
|
||||
map1.put("params",kparams);
|
||||
sqlmaps.add(map1);
|
||||
}
|
||||
}
|
||||
|
||||
}else if("ADD".equals(operateType)){//新建
|
||||
Map<String,Object> map=new HashMap<>();
|
||||
String fieldsql="";
|
||||
String splitsql="";
|
||||
Object[] kparams=new Object[0];
|
||||
Object[] kinsertparams=new Object[0];
|
||||
String modflyuuid= UUID.randomUUID().toString();
|
||||
allmodflyuuid=allmodflyuuid+table+","+modflyuuid+",";
|
||||
for(String mykey:TransField.detailField.getString(detailtable).split(",")){
|
||||
String fieldname=mykey;//transField.getFieldNameByid(mykey);
|
||||
if(CubeSaveInterccept.filterField.indexOf(","+fieldname+",")>-1||CubeSaveInterccept.filterField.indexOf(","+mykey+",")>-1){
|
||||
continue;
|
||||
}
|
||||
fieldsql=fieldsql+fieldname+",";
|
||||
splitsql=splitsql+"?,";
|
||||
kparams = Arrays.copyOf(kparams, (kparams.length+1));
|
||||
kparams[kparams.length-1] = K.get(this.transField.getSingleFieldIdByName(mykey,detailtable));
|
||||
|
||||
}
|
||||
fieldsql=fieldsql+"modflyuuid,mainid";
|
||||
splitsql=splitsql+"?,?";
|
||||
kparams = Arrays.copyOf(kparams, (kparams.length+1));
|
||||
kparams[kparams.length-1] = modflyuuid;
|
||||
kparams = Arrays.copyOf(kparams, (kparams.length+1));
|
||||
kparams[kparams.length-1] = this.transField.getQyid();
|
||||
|
||||
if(fieldsql.endsWith(",")){
|
||||
fieldsql=fieldsql.substring(0,fieldsql.length()-1);
|
||||
}
|
||||
if(splitsql.endsWith(",")){
|
||||
splitsql=splitsql.substring(0,splitsql.length()-1);
|
||||
}
|
||||
// map.put("sql","insert into "+CubeSaveInterccept.CompanyMaintable+"_"+table+"("+fieldsql+") values("+splitsql+") ");
|
||||
// map.put("params",kparams);
|
||||
// sqlmaps.add(map);
|
||||
// //新增的同时需要 修改 mainbillid
|
||||
// map.put("sql","update "+CubeSaveInterccept.CompanyVersionMaintable+"_"+table+" set mainbillid=(select id from "+CubeSaveInterccept.CompanyMaintable+"_"+table+" where modflyuuid=?) where id="+mainid);
|
||||
// map.put("params",new Object[]{modflyuuid});
|
||||
// sqlmaps.add(map);
|
||||
if("".equals(AllVersionid)){//
|
||||
//插入企业信息主表
|
||||
map.put("sql","insert into "+CubeSaveInterccept.CompanyMaintable+"_"+table+"("+fieldsql+",qymc1) values("+splitsql+",?) ");
|
||||
kparams = Arrays.copyOf(kparams, (kparams.length+1));
|
||||
kparams[kparams.length-1] = this.transField.getQyid();
|
||||
map.put("params",kparams);
|
||||
sqlmaps.add(map);
|
||||
//新增的同时需要 修改 mainbillid
|
||||
Map<String,Object> map2=new HashMap<>();
|
||||
map2.put("sql","update "+CubeSaveInterccept.CompanyVersionMaintable+"_"+table+" set mainbillid=(select id from "+CubeSaveInterccept.CompanyMaintable+"_"+table+" where modflyuuid=?) where id="+detaildataid);
|
||||
map2.put("params",new Object[]{modflyuuid});
|
||||
sqlmaps.add(map2);
|
||||
}else{
|
||||
if(!"".equals(betoowID)||("".equals(betoowID)&&"".equals(changeID)&&!"".equals(AllVersionid))){//存在之后的中间版本
|
||||
String oldbetoowID=betoowID;//记住之前的 betoowID
|
||||
if("".equals(betoowID)&&"".equals(changeID)&&!"".equals(AllVersionid)){
|
||||
betoowID= AllVersionid;
|
||||
}
|
||||
String[] betoowIDs=betoowID.split(",");
|
||||
for(String be:betoowIDs){
|
||||
if("".equals(Util.null2String(be).trim())){
|
||||
continue;
|
||||
}
|
||||
Map<String,Object> map3=new HashMap<>();
|
||||
map3.put("sql","insert into "+CubeSaveInterccept.CompanyVersionMaintable+"_"+table+"("+fieldsql+") values("+splitsql+") ");
|
||||
Object[] kparamss=getNewObjects(kparams);
|
||||
kparamss = Arrays.copyOf(kparamss, (kparamss.length+1));
|
||||
kparamss[kparamss.length-1] = modflyuuid;
|
||||
kparamss = Arrays.copyOf(kparamss, (kparamss.length+1));
|
||||
kparamss[kparamss.length-1] = be;
|
||||
map3.put("params",kparamss);
|
||||
sqlmaps.add(map3);
|
||||
}
|
||||
//先插入主表 在删除
|
||||
Map<String,Object> mainMap=new HashMap<>();
|
||||
mainMap.put("sql","insert into "+CubeSaveInterccept.CompanyMaintable+"_"+table+"("+fieldsql+",qymc1) values("+splitsql+",?) ");
|
||||
Object[] mainMapparams = Arrays.copyOf(kparams, (kparams.length+1));
|
||||
mainMapparams[mainMapparams.length-1] = this.transField.getQyid();
|
||||
mainMap.put("params",mainMapparams);
|
||||
sqlmaps.add(mainMap);
|
||||
//修改 关联企业信息表ID
|
||||
Map<String,Object> map2=new HashMap<>();
|
||||
map2.put("sql","update "+CubeSaveInterccept.CompanyVersionMaintable+"_"+table+" set mainbillid=(select id from "+CubeSaveInterccept.CompanyMaintable+"_"+table+" where modflyuuid=?) where mainid in ("+betoowID+") and modflyuuid=?");
|
||||
map2.put("params",new Object[]{modflyuuid,modflyuuid});
|
||||
sqlmaps.add(map2);
|
||||
//删除
|
||||
if(!"".equals(oldbetoowID)){
|
||||
Map<String,Object> deletemap=new HashMap<>();
|
||||
deletemap.put("sql","delete from "+CubeSaveInterccept.CompanyMaintable+"_"+table+" where modflyuuid=? and mainid="+this.transField.getQyid());
|
||||
deletemap.put("params",new Object[]{modflyuuid});
|
||||
sqlmaps.add(deletemap);
|
||||
}
|
||||
}
|
||||
if(!"".endsWith(betoowOldID)&&"".equals(currentVersionChange)){
|
||||
String[] betoowOldIDs=betoowOldID.split(",");
|
||||
for(String be:betoowOldIDs){
|
||||
if("".equals(Util.null2String(be).trim())){
|
||||
continue;
|
||||
}
|
||||
Map<String,Object> map3=new HashMap<>();
|
||||
map3.put("sql","insert into "+CubeSaveInterccept.CompanyVersionMaintable+"_"+table+"("+fieldsql+") values("+splitsql+",?) ");
|
||||
Object[] kparamss=getNewObjects(kparams);
|
||||
kparamss = Arrays.copyOf(kparamss, (kparamss.length+1));
|
||||
kparamss[kparamss.length-1] = modflyuuid;
|
||||
kparamss = Arrays.copyOf(kparamss, (kparamss.length+1));
|
||||
kparamss[kparamss.length-1] = be;
|
||||
map3.put("params",kparamss);
|
||||
//sqlmaps.add(map3); 之前的数据不做处理
|
||||
}
|
||||
}
|
||||
}
|
||||
}else if("DEL".equals(operateType)){//删除
|
||||
Map<String,Object> map=new HashMap<>();
|
||||
String fieldsql="";
|
||||
String splitsql="";
|
||||
Object[] kparams=new Object[0];
|
||||
Object[] kinsertparams=new Object[0];
|
||||
String modflyuuid= UUID.randomUUID().toString();
|
||||
allmodflyuuid=allmodflyuuid+table+","+modflyuuid+",";
|
||||
for(String mykey:TransField.detailField.getString(detailtable).split(",")){
|
||||
String fieldname=mykey;//transField.getFieldNameByid(mykey);
|
||||
if(CubeSaveInterccept.filterField.indexOf(","+fieldname+",")>-1||CubeSaveInterccept.filterField.indexOf(","+mykey+",")>-1){
|
||||
continue;
|
||||
}
|
||||
fieldsql=fieldsql+fieldname+",";
|
||||
splitsql=splitsql+"?,";
|
||||
kparams = Arrays.copyOf(kparams, (kparams.length+1));
|
||||
kparams[kparams.length-1] = K.get(this.transField.getSingleFieldIdByName(mykey,detailtable));
|
||||
|
||||
}
|
||||
fieldsql=fieldsql+"modflyuuid,mainid";
|
||||
splitsql=splitsql+"?,?";
|
||||
kparams = Arrays.copyOf(kparams, (kparams.length+1));
|
||||
kparams[kparams.length-1] = modflyuuid;
|
||||
kparams = Arrays.copyOf(kparams, (kparams.length+1));
|
||||
kparams[kparams.length-1] = this.transField.getQyid();
|
||||
|
||||
if(fieldsql.endsWith(",")){
|
||||
fieldsql=fieldsql.substring(0,fieldsql.length()-1);
|
||||
}
|
||||
if(splitsql.endsWith(",")){
|
||||
splitsql=splitsql.substring(0,splitsql.length()-1);
|
||||
}
|
||||
if("".equals(AllVersionid)){//
|
||||
//删除企业信息表数据
|
||||
//map.put("sql","insert into "+CubeSaveInterccept.CompanyMaintable+"_"+table+"("+fieldsql+") values("+splitsql+") ");
|
||||
map.put("sql","delete from "+CubeSaveInterccept.CompanyMaintable+"_"+table+" where id=?");
|
||||
map.put("params",new Object[]{mainid});
|
||||
sqlmaps.add(map);
|
||||
|
||||
}else{
|
||||
if(!"".equals(betoowID)||("".equals(betoowID)&&"".equals(changeID)&&!"".equals(AllVersionid))){//存在之后的中间版本
|
||||
if("".equals(betoowID)&&"".equals(changeID)&&!"".equals(AllVersionid)){
|
||||
betoowID= AllVersionid;
|
||||
}
|
||||
String[] betoowIDs=betoowID.split(",");
|
||||
for(String be:betoowIDs){
|
||||
if("".equals(Util.null2String(be).trim())){
|
||||
continue;
|
||||
}
|
||||
String whereSql=getDeleteSqlWhere( detaildataid, table);
|
||||
if("".equals(whereSql)){
|
||||
continue;
|
||||
}
|
||||
Map<String,Object> map3=new HashMap<>();
|
||||
//map3.put("sql","insert into "+CubeSaveInterccept.CompanyVersionMaintable+"_"+table+"("+fieldsql+",mainid) values("+splitsql+",?) ");
|
||||
map3.put("sql","delete from "+CubeSaveInterccept.CompanyVersionMaintable+"_"+table+" where mainid=? and "+whereSql);
|
||||
// Object[] kparamss=getNewObjects(kparams);
|
||||
// kparamss = Arrays.copyOf(kparamss, (kparamss.length+1));
|
||||
// kparamss[kparamss.length-1] = modflyuuid;
|
||||
// kparamss = Arrays.copyOf(kparamss, (kparamss.length+1));
|
||||
// kparamss[kparamss.length-1] = be;
|
||||
map3.put("params",new Object[]{be});
|
||||
sqlmaps.add(map3);
|
||||
}
|
||||
}
|
||||
if(!"".endsWith(betoowOldID)&&"".equals(currentVersionChange)){
|
||||
String[] betoowOldIDs=betoowOldID.split(",");
|
||||
for(String be:betoowOldIDs){
|
||||
if("".equals(Util.null2String(be).trim())){
|
||||
continue;
|
||||
}
|
||||
String whereSql=getDeleteSqlWhere( detaildataid, table);
|
||||
if("".equals(whereSql)){
|
||||
continue;
|
||||
}
|
||||
Map<String,Object> map3=new HashMap<>();
|
||||
//map3.put("sql","insert into "+CubeSaveInterccept.CompanyVersionMaintable+"_"+table+"("+fieldsql+",mainid) values("+splitsql+",?) ");
|
||||
map3.put("sql","delete from "+CubeSaveInterccept.CompanyVersionMaintable+"_"+table+" where mainid=? and "+whereSql);
|
||||
// Object[] kparamss=getNewObjects(kparams);
|
||||
// kparamss = Arrays.copyOf(kparamss, (kparamss.length+1));
|
||||
// kparamss[kparamss.length-1] = modflyuuid;
|
||||
// kparamss = Arrays.copyOf(kparamss, (kparamss.length+1));
|
||||
// kparamss[kparamss.length-1] = be;
|
||||
map3.put("params",new Object[]{be});
|
||||
sqlmaps.add(map3);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//不管是跟新和编辑 都涉及到 历史沿革数据的修改
|
||||
/**
|
||||
* 如果存在明细表的变更的话 则需要对 版本的历史沿革以及 版本的 明细数据 以及 企业信息表的数据 做变更
|
||||
* 1).当前版本是最新的(跟新历史最新的数据只是跟新最新的一条数据 跟新主表数据)
|
||||
* 2).当前版本是中间的版本(1不存在修改则更新所有之后的明细数据 以及跟新当前版本以及之后的所有新历史沿革最新的变更后数据 更新主表数据,2存在版本)
|
||||
*如果 当前版本是之后的版本 只要跟新 历史沿革
|
||||
* **/
|
||||
if("".equals(AllVersionid)){//为空则是最新的版本
|
||||
//如果存在 之前的变更 那么需要跟新 需要建立在 当前版本 没有变更过 明细的值
|
||||
// if(!"".equals(oldchangeID)&&"".equals(currentVersionChange)){
|
||||
// Map<String,Object> map=new HashMap<>();
|
||||
// map.put("sql","update "+CubeSaveInterccept.CompanyVersionMaintable+"_"+table+" set bgh=? where mainid="+oldchangeID+" and bgxm=?");
|
||||
// map.put("params",new Object[]{detailtableValue,detailtabledesc});
|
||||
// sqlmaps.add(map);
|
||||
// }
|
||||
//当前版本的 变更后
|
||||
if(!"".equals(currentVersionChange)) {
|
||||
Map<String, Object> map1 = new HashMap<>();
|
||||
map1.put("sql", "update " + CubeSaveInterccept.CompanyVersionMaintable + "_dt1 set bgh=? where id in (select max(id) from "+CubeSaveInterccept.CompanyVersionMaintable+"_dt1 where mainid=" + transField.getBillid() + " and bgxm=?) ");
|
||||
map1.put("params", new Object[]{detailtableValue, detailtabledesc});
|
||||
sqlmaps.add(map1);
|
||||
}else{
|
||||
//新增历史沿革 不考虑变更 前面的 数据
|
||||
if(!"".equals(oldchangeID)){
|
||||
Map<String, Object> map2 = new HashMap<>();
|
||||
map2.put("sql", "insert into "+CubeSaveInterccept.CompanyVersionMaintable+"_dt1(rq,bgxm,bgq,bgh,mainid)values(?,?,?,?,?) ");
|
||||
map2.put("params", new Object[]{currentDate, detailtabledesc,transField.getDetailAllValue(detailtable,TransField.detailField.getString(detailtable),oldchangeID),detailtabledesc,transField.getBillid()});
|
||||
sqlmaps.add(map2);
|
||||
}
|
||||
}
|
||||
|
||||
}else{
|
||||
//中间版本
|
||||
if(!"".equals(oldchangeID)&&"".equals(currentVersionChange)){//更新之前的数据
|
||||
Map<String,Object> map=new HashMap<>();
|
||||
map.put("sql","update "+CubeSaveInterccept.CompanyVersionMaintable+"_dt1 set bgh=? where mainid="+oldchangeID+" and bgxm=?");
|
||||
map.put("params",new Object[]{detailtableValue,detailtabledesc});
|
||||
sqlmaps.add(map);
|
||||
}else if(!"".equals(currentVersionChange)){
|
||||
Map<String, Object> map1 = new HashMap<>();
|
||||
map1.put("sql", "update " + CubeSaveInterccept.CompanyVersionMaintable + "_dt1 set bgh=? where id in (select max(id) from "+CubeSaveInterccept.CompanyVersionMaintable+"_dt1 where mainid=" + transField.getBillid() + " and bgxm=?) ");
|
||||
map1.put("params", new Object[]{detailtableValue, detailtabledesc});
|
||||
sqlmaps.add(map1);
|
||||
}
|
||||
if(!"".equals(changeID)){//之后版本
|
||||
Map<String,Object> map=new HashMap<>();
|
||||
map.put("sql","update "+CubeSaveInterccept.CompanyVersionMaintable+"_dt1 set bgq=? where id in (select min(id) from "+CubeSaveInterccept.CompanyVersionMaintable+"_dt1 where mainid="+changeID+" and bgxm=?) ");
|
||||
map.put("params",new Object[]{detailtableValue,detailtabledesc});
|
||||
sqlmaps.add(map);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Object[] getNewObjects(Object[] objs){
|
||||
Object[] newobjs=new Object[0];
|
||||
if(objs!=null){
|
||||
for(Object demo:objs){
|
||||
newobjs = Arrays.copyOf(newobjs, (newobjs.length+1));
|
||||
newobjs[newobjs.length-1] = demo;
|
||||
}
|
||||
}
|
||||
return newobjs;
|
||||
}
|
||||
|
||||
public String getDeleteSqlWhere(String detailid,String table){
|
||||
String whereSql="";
|
||||
RecordSet re=new RecordSet();
|
||||
String sql="select * from "+CubeSaveInterccept.CompanyVersionMaintable+"_"+table +" where id="+detailid;
|
||||
log.writeLog(sql);
|
||||
re.execute(sql);
|
||||
if(re.next()){
|
||||
String modflyuuid=Util.null2String(re.getString("modflyuuid")).trim() ;//mainbillid
|
||||
String mainbillid=Util.null2String( re.getString("mainbillid")).trim();//mainbillid
|
||||
if(!"".equals(modflyuuid)){
|
||||
whereSql=whereSql+" modflyuuid='"+modflyuuid+"' ";
|
||||
}
|
||||
if(!"".equals(modflyuuid)&&!"".equals(mainbillid)){
|
||||
whereSql=whereSql+" or mainbillid='"+mainbillid+"' ";
|
||||
}else{
|
||||
if(!"".equals(mainbillid)){
|
||||
whereSql=whereSql+" mainbillid='"+mainbillid+"' ";
|
||||
}
|
||||
}
|
||||
}
|
||||
if(!"".equals(whereSql)){
|
||||
whereSql="("+whereSql+")";
|
||||
}
|
||||
return whereSql;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,966 @@
|
|||
package com.engine.demo.impl;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.api.cube.util.CubeSearchTransMethod;
|
||||
import selfdev.util.log.LogTool;
|
||||
import weaver.conn.RecordSet;
|
||||
import weaver.docs.docs.DocImageManager;
|
||||
import weaver.general.ThreadVarLanguage;
|
||||
import weaver.general.Util;
|
||||
import weaver.hrm.User;
|
||||
import weaver.soa.workflow.request.Property;
|
||||
import weaver.systeminfo.SystemEnv;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
|
||||
public class TransField {
|
||||
private final static LogTool log = new LogTool("/log/TransField/",false);
|
||||
private int formId;
|
||||
private int modeId;
|
||||
private int type;
|
||||
private int layoutid;
|
||||
private User user;
|
||||
private String billid;
|
||||
private String qyid="";//企业ID
|
||||
private String bbrq="";//日期
|
||||
private String viewlogid="";
|
||||
private String allVersionid="";//当前版本之后的所有的版本
|
||||
//private String betoowID="";//中间版本
|
||||
private String allmodflyuuid="";//所有新增明细的uuid
|
||||
|
||||
private boolean isModifyClrq=false;//判断是否是修改了成立日期
|
||||
private String newclrq="";//新成立日期
|
||||
|
||||
private JSONArray transFieldJSONs=new JSONArray();
|
||||
private List<Map<String,Object>> sqlmaps=new ArrayList<>();
|
||||
static JSONObject detailField=new JSONObject();
|
||||
|
||||
static{
|
||||
// detailField.put("uf_configField_dt1","cs1,cs2");
|
||||
// detailField.put("uf_configField_dt1desc","cs1,cs2");
|
||||
// detailField.put("uf_configField_dt2","cs3,cs4");
|
||||
// detailField.put("uf_configField_dt2desc","cs3,cs4");
|
||||
|
||||
// uat
|
||||
// detailField.put("formtable_main_1824_dt2","djgd,cgbl,cgfs,gfzl");
|
||||
// detailField.put("formtable_main_1824_dt2desc","djgd,cgbl,cgfs,gfzl,bz");
|
||||
// detailField.put("formtable_main_1824_dt3","zzzz");
|
||||
// detailField.put("formtable_main_1824_dt3desc","zzzz");
|
||||
//登记股东/持股比例/持股份数/股份种类 生产
|
||||
detailField.put("formtable_main_3055_dt2","djgd,cgbl,cgfs,gfzl,bz");
|
||||
detailField.put("formtable_main_3055_dt2desc","djgd,cgbl,cgfs,gfzl");
|
||||
detailField.put("formtable_main_3055_dt3","zzzz,fjsc,bz");
|
||||
detailField.put("formtable_main_3055_dt3desc","zzzz");
|
||||
}
|
||||
public TransField(int formId,String billid,User user){
|
||||
this.formId=formId;
|
||||
this.billid=billid;
|
||||
this.user=user;
|
||||
}
|
||||
public TransField(){
|
||||
}
|
||||
public String transFieldValue(String var1, JSONObject fieldjson) throws Exception {
|
||||
if(fieldjson==null||fieldjson.size()<=0){
|
||||
return var1;
|
||||
}
|
||||
//(fieldvalue, fieldhtmltype, fieldid, fielddbtype, viewtype, type)
|
||||
log.writeLog("begin!");
|
||||
log.writeLog(fieldjson.getString("fieldhtmltype")+"==="+fieldjson.getString("fieldid")+"==="+fieldjson.getString("fielddbtype")+"==="+fieldjson.getString("viewtype")+"==="+Util.getIntValue(fieldjson.getString("type"),0));
|
||||
return transFieldValue(var1,fieldjson.getString("fieldhtmltype"),fieldjson.getString("fieldid"),fieldjson.getString("fielddbtype"),fieldjson.getString("viewtype"),Util.getIntValue(fieldjson.getString("type"),0) );
|
||||
}
|
||||
public String transFieldValue(String var1, String var2, String var3, String var4, String var5, int var6) throws Exception {
|
||||
CubeSearchTransMethod var7 = CubeSearchTransMethod.INSTANCE;
|
||||
String var8 = "";
|
||||
RecordSet var9 = new RecordSet();
|
||||
if (var2.equals("6")) {
|
||||
DocImageManager var10 = new DocImageManager();
|
||||
if (!var1.equals("")) {
|
||||
ArrayList var11 = Util.TokenizerString(var1, ",");
|
||||
int var12 = -1;
|
||||
|
||||
for(int var13 = 0; var13 < var11.size(); ++var13) {
|
||||
++var12;
|
||||
if (var12 > 0) {
|
||||
var8 = var8 + "<br>";
|
||||
}
|
||||
String var14 = Util.null2String(var11.get(var13));
|
||||
String var15 = "select id,docsubject,accessorycount from docdetail where id = " + var14 + " order by id asc";
|
||||
var9.executeSql(var15);
|
||||
if (!var9.next()) {
|
||||
var8 = var8 + "<a href=\"#\">ID:" + var14 + SystemEnv.getHtmlLabelName(384364, this.user.getLanguage()) + "</a>";
|
||||
} else {
|
||||
String var16 = Util.null2String(var9.getString(1));
|
||||
String var17 = Util.toScreen(var9.getString(2), this.user.getLanguage());
|
||||
int var18 = var9.getInt(3);
|
||||
var10.resetParameter();
|
||||
var10.setDocid(Integer.parseInt(var16));
|
||||
var10.selectDocImageInfo();
|
||||
String var19 = "";
|
||||
String var20 = "";
|
||||
String var21 = "";
|
||||
if (var10.next()) {
|
||||
var19 = var10.getImagefileid();
|
||||
var20 = var10.getImagefilename();
|
||||
var21 = var20.substring(var20.lastIndexOf(".") + 1).toLowerCase();
|
||||
}
|
||||
|
||||
if (var18 != 1 || !var21.equalsIgnoreCase("xls") && !var21.equalsIgnoreCase("doc") && !var21.equalsIgnoreCase("pdf") && !var21.equalsIgnoreCase("xlsx") && !var21.equalsIgnoreCase("docx")) {
|
||||
var8 = var8 + "<a href=javascript:openFullWindowHaveBar(\"/spa/document/index.jsp?id=" + var16 + "\")>" + var17 + "</a> ";
|
||||
} else {
|
||||
var8 = var8 + "<a href=javascript:openFullWindowHaveBar(\"/spa/document/index2file.jsp?id=" + var16 + "&imagefileId=" + var19 + "&isFromAccessory=true\")>" + var20 + "</a> ";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
String var22 = this.billid + "+" + var3 + "+" + var2 + "+" + var6 + "+" + this.user.getLanguage() + "+1+" + var4 + "+0+-1+" + this.formId + "+" + var5;
|
||||
var8 = var7.getOthers(var1, var22);
|
||||
if (var8.indexOf("class='empty-columns'") >= 0) {
|
||||
var8 = "";
|
||||
}
|
||||
}
|
||||
|
||||
if (var2.equals("4")) {
|
||||
if (var1.equals("1")) {
|
||||
var8 = "" + SystemEnv.getHtmlLabelName(163, ThreadVarLanguage.getLang()) + "";
|
||||
} else {
|
||||
var8 = "" + SystemEnv.getHtmlLabelName(25105, ThreadVarLanguage.getLang()) + "";
|
||||
}
|
||||
}
|
||||
if(var6==161){
|
||||
//var8=var8.substring(0,var8.length()-" ".length()); &&var8.endsWith(" ")
|
||||
var8=var8.replaceAll(" ","");
|
||||
}
|
||||
//log.writeLog(var6+"-->"+var8);
|
||||
return var8;
|
||||
}
|
||||
|
||||
public String getAllmodflyuuid() {
|
||||
return allmodflyuuid;
|
||||
}
|
||||
|
||||
public void setAllmodflyuuid(String allmodflyuuid) {
|
||||
this.allmodflyuuid = allmodflyuuid;
|
||||
}
|
||||
|
||||
public String getAllVersionid() {
|
||||
return allVersionid;
|
||||
}
|
||||
|
||||
public void setAllVersionid(String allVersionid) {
|
||||
this.allVersionid = allVersionid;
|
||||
}
|
||||
|
||||
public List<Map<String, Object>> getSqlmaps() {
|
||||
return sqlmaps;
|
||||
}
|
||||
|
||||
public void setSqlmaps(List<Map<String, Object>> sqlmaps) {
|
||||
this.sqlmaps = sqlmaps;
|
||||
}
|
||||
|
||||
public String getViewlogid() {
|
||||
return viewlogid;
|
||||
}
|
||||
|
||||
public void setViewlogid(String viewlogid) {
|
||||
this.viewlogid = viewlogid;
|
||||
}
|
||||
|
||||
public static JSONObject getDetailField() {
|
||||
return detailField;
|
||||
}
|
||||
|
||||
public static void setDetailField(JSONObject detailField) {
|
||||
TransField.detailField = detailField;
|
||||
}
|
||||
|
||||
public JSONArray getTransFieldJSONs() {
|
||||
return transFieldJSONs;
|
||||
}
|
||||
|
||||
public void setTransFieldJSONs(JSONArray transFieldJSONs) {
|
||||
this.transFieldJSONs = transFieldJSONs;
|
||||
}
|
||||
|
||||
public int getFormId() {
|
||||
return formId;
|
||||
}
|
||||
|
||||
public void setFormId(int formId) {
|
||||
this.formId = formId;
|
||||
}
|
||||
|
||||
public int getModeId() {
|
||||
return modeId;
|
||||
}
|
||||
|
||||
public void setModeId(int modeId) {
|
||||
this.modeId = modeId;
|
||||
}
|
||||
|
||||
public int getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(int type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public int getLayoutid() {
|
||||
return layoutid;
|
||||
}
|
||||
|
||||
public void setLayoutid(int layoutid) {
|
||||
this.layoutid = layoutid;
|
||||
}
|
||||
|
||||
public User getUser() {
|
||||
return user;
|
||||
}
|
||||
|
||||
public void setUser(User user) {
|
||||
this.user = user;
|
||||
}
|
||||
|
||||
public String getBillid() {
|
||||
return billid;
|
||||
}
|
||||
|
||||
public void setBillid(String billid) {
|
||||
this.billid = billid;
|
||||
}
|
||||
|
||||
public String getQyid() {
|
||||
return qyid;
|
||||
}
|
||||
|
||||
public void setQyid(String qyid) {
|
||||
this.qyid = qyid;
|
||||
}
|
||||
|
||||
public String getBbrq() {
|
||||
return bbrq;
|
||||
}
|
||||
|
||||
public void setBbrq(String bbrq) {
|
||||
this.bbrq = bbrq;
|
||||
}
|
||||
|
||||
public void updateCompanyInfo(JSONObject valJSon,JSONObject detailValJSon){
|
||||
//组装 sql
|
||||
String detailindex="";
|
||||
|
||||
if(valJSon!=null||valJSon.size()>0){
|
||||
Map<String,Object> map=new HashMap<>();
|
||||
Set<String> mainkey=valJSon.keySet();
|
||||
String fieldsql="";
|
||||
|
||||
Object[] params=new Object[valJSon.size()];
|
||||
int i=0;
|
||||
for(String str:mainkey){
|
||||
fieldsql=fieldsql+str+"=?,";
|
||||
params[i]=valJSon.get(str);
|
||||
}
|
||||
if(fieldsql.endsWith(",")){
|
||||
fieldsql=fieldsql.substring(0,fieldsql.length()-1);
|
||||
}
|
||||
map.put("sql","update "+CubeSaveInterccept.CompanyMaintable+" set "+fieldsql+" where id='"+this.qyid+"'");
|
||||
map.put("params",params);
|
||||
//sqlmaps.add(map);
|
||||
}
|
||||
//明细表的sql 有两个 明细表
|
||||
// if(detailValJSon!=null&&detailValJSon.size()>0){
|
||||
// Set<String> detailKey= detailValJSon.keySet();
|
||||
// for(String table:detailKey){
|
||||
// JSONArray tableDatas=detailValJSon.getJSONArray(table);
|
||||
// if(tableDatas!=null&&tableDatas.size()>0){
|
||||
// for(int k=0;k<tableDatas.size();k++){
|
||||
// JSONObject K=tableDatas.getJSONObject(k);
|
||||
// if(K!=null&&K.size()>0){
|
||||
// //开始遍历sql
|
||||
// String operateType=Util.null2String(K.getString("operateType")).trim() ;
|
||||
// String mainid=Util.null2String(K.getString("mainid")).trim() ;
|
||||
// String detailtable=Util.null2String(K.getString("detailtable")).trim() ;
|
||||
// Set<String> kkey= K.keySet();
|
||||
// if("EDIT".equals(operateType)&&!"".equals(mainid)){//编辑
|
||||
// Set<String> mainkey=valJSon.keySet();
|
||||
// Map<String,Object> map=new HashMap<>();
|
||||
// String fieldsql="";
|
||||
// Object[] kparams=new Object[0];
|
||||
// for(String mykey:kkey){
|
||||
// String fieldname=getFieldNameByid(mykey);
|
||||
// if(CubeSaveInterccept.filterField.indexOf(","+fieldname+",")>-1||CubeSaveInterccept.filterField.indexOf(","+mykey+",")>-1){
|
||||
// continue;
|
||||
// }
|
||||
// fieldsql=fieldsql+fieldname+"=?,";
|
||||
// kparams = Arrays.copyOf(kparams, (kparams.length+1));
|
||||
// kparams[kparams.length-1] = K.get(mykey);
|
||||
// }
|
||||
// if(fieldsql.endsWith(",")){
|
||||
// fieldsql=fieldsql.substring(0,fieldsql.length()-1);
|
||||
// }
|
||||
// map.put("sql","update "+CubeSaveInterccept.CompanyMaintable+"_"+table+" set "+fieldsql+" where id="+mainid);
|
||||
// map.put("params",kparams);
|
||||
// sqlmaps.add(map);
|
||||
// }else if("ADD".equals(operateType)){//新建
|
||||
// Set<String> mainkey=valJSon.keySet();
|
||||
// Map<String,Object> map=new HashMap<>();
|
||||
// String fieldsql="";
|
||||
// String splitsql="";
|
||||
// Object[] kparams=new Object[0];
|
||||
// for(String mykey:kkey){
|
||||
// String fieldname=getFieldNameByid(mykey);
|
||||
// if(CubeSaveInterccept.filterField.indexOf(","+fieldname+",")>-1||CubeSaveInterccept.filterField.indexOf(","+mykey+",")>-1){
|
||||
// continue;
|
||||
// }
|
||||
// fieldsql=fieldsql+fieldname+",";
|
||||
// splitsql=splitsql+"?,";
|
||||
// kparams = Arrays.copyOf(kparams, (kparams.length+1));
|
||||
// kparams[kparams.length-1] = K.get(mykey);
|
||||
// }
|
||||
//
|
||||
// if(fieldsql.endsWith(",")){
|
||||
// fieldsql=fieldsql.substring(0,fieldsql.length()-1);
|
||||
// }
|
||||
// if(splitsql.endsWith(",")){
|
||||
// splitsql=splitsql.substring(0,splitsql.length()-1);
|
||||
// }
|
||||
// map.put("sql","insert into "+CubeSaveInterccept.CompanyMaintable+"_"+table+"("+fieldsql+") values("+splitsql+") ");
|
||||
// map.put("params",kparams);
|
||||
// sqlmaps.add(map);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//明细表
|
||||
|
||||
|
||||
//跟新 历史沿革 记录 判断当期当前是什么版本 前后有没有
|
||||
allVersionid= getAllVersion("1");//获取所有版本的ID
|
||||
if(transFieldJSONs.size()>0){
|
||||
for(int i=0;i<transFieldJSONs.size();i++){
|
||||
JSONObject singlejson=transFieldJSONs.getJSONObject(i);
|
||||
ParaSqlMap(singlejson, allVersionid,sqlmaps);
|
||||
}
|
||||
log.writeLog("isModifyClrq-->"+isModifyClrq+" newclrq-->"+newclrq+"this.billid-->"+this.billid);
|
||||
if(isModifyClrq&&!"".equals(Util.null2String(newclrq).trim())){
|
||||
//跟新所有版本的成立日期 以及 第一个版本的 版本日期
|
||||
String oldVersion= getOldAllVersion();
|
||||
String fristVersion="";
|
||||
if("".equals(oldVersion)){
|
||||
fristVersion=this.billid;
|
||||
}else{
|
||||
if(oldVersion.endsWith(",")) {
|
||||
oldVersion = oldVersion.substring(0, oldVersion.length() - 1);
|
||||
//int index = oldVersion.lastIndexOf(",");
|
||||
}
|
||||
int index = oldVersion.lastIndexOf(",");
|
||||
if(index>-1){
|
||||
fristVersion=Util.null2String(oldVersion.substring(index+1)) ;
|
||||
}
|
||||
}
|
||||
if(!"".equals(fristVersion)){
|
||||
Map<String,Object> map=new HashMap<>();
|
||||
Object[] params=new Object[1];
|
||||
params[0]=newclrq;
|
||||
map.put("sql","update "+CubeSaveInterccept.CompanyVersionMaintable+" set bbrq=? where qyid='"+this.qyid +"' and id in ("+fristVersion+")");
|
||||
map.put("params",params);
|
||||
sqlmaps.add(map);
|
||||
}
|
||||
Map<String,Object> map=new HashMap<>();
|
||||
Object[] params=new Object[1];
|
||||
params[0]=newclrq;
|
||||
map.put("sql","update "+CubeSaveInterccept.CompanyVersionMaintable+" set clrq=? where qyid='"+this.qyid +"' ");
|
||||
map.put("params",params);
|
||||
sqlmaps.add(map);
|
||||
}
|
||||
}
|
||||
|
||||
//明细变更
|
||||
/**
|
||||
* 如果存在明细表的变更的话 则需要对 版本的历史沿革以及 版本的 明细数据 以及 企业信息表的数据 做变更
|
||||
* 1).当前版本是最新的(跟新历史最新的数据只是跟新最新的一条数据 跟新主表数据)
|
||||
* 2).当前版本是中间的版本(1不存在修改则更新所有之后的明细数据 以及跟新当前版本以及之后的所有新历史沿革最新的变更后数据 更新主表数据,2存在版本)
|
||||
*如果 当前版本是之后的版本 只要跟新 历史沿革
|
||||
* **/
|
||||
// if(detailValJSon!=null&&detailValJSon.size()>0){
|
||||
// Set<String> detailKey= detailValJSon.keySet();
|
||||
// for(String table:detailKey){
|
||||
// JSONArray tableDatas=detailValJSon.getJSONArray(table);
|
||||
// if(tableDatas!=null&&tableDatas.size()>0){
|
||||
// for(int k=0;k<tableDatas.size();k++){
|
||||
// JSONObject K=tableDatas.getJSONObject(k);
|
||||
// if(K!=null&&K.size()>0){
|
||||
// //开始遍历sql
|
||||
// String detaildataid=Util.null2String(K.getString("detaildataid")).trim() ;
|
||||
// String operateType=Util.null2String(K.getString("operateType")).trim() ;
|
||||
// String mainid=Util.null2String(K.getString("mainid")).trim() ;
|
||||
// String detailtable=Util.null2String(K.getString("detailtable")).trim() ;
|
||||
// Set<String> kkey= K.keySet();
|
||||
// if("EDIT".equals(operateType)&&!"".equals(mainid)){//编辑
|
||||
// Set<String> mainkey=valJSon.keySet();
|
||||
// Map<String,Object> map=new HashMap<>();
|
||||
// String fieldsql="";
|
||||
// Object[] kparams=new Object[0];
|
||||
// for(String mykey:kkey){
|
||||
// String fieldname=getFieldNameByid(mykey);
|
||||
// if(CubeSaveInterccept.filterField.indexOf(","+fieldname+",")>-1||CubeSaveInterccept.filterField.indexOf(","+mykey+",")>-1){
|
||||
// continue;
|
||||
// }
|
||||
// fieldsql=fieldsql+fieldname+"=?,";
|
||||
// kparams = Arrays.copyOf(kparams, (kparams.length+1));
|
||||
// kparams[kparams.length-1] = K.get(mykey);
|
||||
// }
|
||||
// if(fieldsql.endsWith(",")){
|
||||
// fieldsql=fieldsql.substring(0,fieldsql.length()-1);
|
||||
// }
|
||||
// map.put("sql","update "+CubeSaveInterccept.CompanyMaintable+"_"+table+" set "+fieldsql+" where id="+mainid);
|
||||
// map.put("params",kparams);
|
||||
// sqlmaps.add(map);
|
||||
//
|
||||
// }else if("ADD".equals(operateType)){//新建
|
||||
// Set<String> mainkey=valJSon.keySet();
|
||||
// Map<String,Object> map=new HashMap<>();
|
||||
// String fieldsql="";
|
||||
// String splitsql="";
|
||||
// Object[] kparams=new Object[0];
|
||||
// String modflyuuid=UUID.randomUUID().toString();
|
||||
// for(String mykey:kkey){
|
||||
// String fieldname=getFieldNameByid(mykey);
|
||||
// if(CubeSaveInterccept.filterField.indexOf(","+fieldname+",")>-1||CubeSaveInterccept.filterField.indexOf(","+mykey+",")>-1){
|
||||
// continue;
|
||||
// }
|
||||
// fieldsql=fieldsql+fieldname+",";
|
||||
// splitsql=splitsql+"?,";
|
||||
// kparams = Arrays.copyOf(kparams, (kparams.length+1));
|
||||
// kparams[kparams.length-1] = K.get(mykey);
|
||||
// }
|
||||
// fieldsql=fieldsql+"modflyuuid,";
|
||||
// kparams = Arrays.copyOf(kparams, (kparams.length+1));
|
||||
// kparams[kparams.length-1] = modflyuuid;
|
||||
//
|
||||
// if(fieldsql.endsWith(",")){
|
||||
// fieldsql=fieldsql.substring(0,fieldsql.length()-1);
|
||||
// }
|
||||
// if(splitsql.endsWith(",")){
|
||||
// splitsql=splitsql.substring(0,splitsql.length()-1);
|
||||
// }
|
||||
// map.put("sql","insert into "+CubeSaveInterccept.CompanyMaintable+"_"+table+"("+fieldsql+") values("+splitsql+") ");
|
||||
// map.put("params",kparams);
|
||||
// sqlmaps.add(map);
|
||||
// //新增的同时需要 修改 mainbillid
|
||||
// map.put("sql","update "+CubeSaveInterccept.CompanyVersionMaintable+"_"+table+" set mainbillid=(select id from "+CubeSaveInterccept.CompanyMaintable+"_"+table+" where modflyuuid=?) where id="+mainid);
|
||||
// map.put("params",new Object[]{modflyuuid});
|
||||
// sqlmaps.add(map);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
HistoryDetail historyDetail=new HistoryDetail( this, detailValJSon);
|
||||
historyDetail.DetailSplit();//解析明细
|
||||
printLog();//sql
|
||||
/** 写入SQL **/
|
||||
if(this.sqlmaps!=null&&this.sqlmaps.size()>0){
|
||||
boolean flag= BaseUtil.executeUpdateListTran(this.sqlmaps);
|
||||
if(!flag){
|
||||
log.writeLog("未写入成功");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void printLog(){
|
||||
if(this.sqlmaps!=null&&this.sqlmaps.size()>0){
|
||||
for(Map<String,Object> sqls:sqlmaps) {
|
||||
if (sqls == null || sqls.size() <= 0) {
|
||||
continue;
|
||||
}
|
||||
String sql = (String) sqls.get("sql");
|
||||
log.writeLog("executeUpdateListTran--->" + sql);
|
||||
Object[] params = (Object[]) sqls.get("params");
|
||||
//log.writeLog("executeUpdateListTran--->" + params.length);
|
||||
if (params != null && params.length > 0) {
|
||||
|
||||
log.writeLog("executeUpdateListTran--->" + Arrays.toString(params));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 添加大于当前版本的明细
|
||||
* @param versionids
|
||||
*/
|
||||
public void addHistoryDetail(String versionids){
|
||||
|
||||
}
|
||||
/**
|
||||
*登记股东/持股比例/持股份数/股份种类
|
||||
* 主数据 1.当前最新版本 修改主数据 2.中间版本
|
||||
* 历史沿革 1.当前最新版本 修改主数据的历史沿革最新数据 2.中间版本 当前版本跟新 则更新最新 补不存在 则插入(存在历史变更)
|
||||
*
|
||||
*
|
||||
*
|
||||
* 主表字段的修改
|
||||
* 生产sql shuju
|
||||
* @param singlejson
|
||||
* @return
|
||||
*/
|
||||
public void ParaSqlMap(JSONObject singlejson,String allVersionid,List<Map<String,Object>> sqlmaps){
|
||||
SimpleDateFormat sim=new SimpleDateFormat("yyyy-MM-dd");
|
||||
String currentDate=sim.format(new Date());
|
||||
Map<String,Object> sqlmap=new HashMap<>();
|
||||
if(singlejson==null||singlejson.size()<=0){
|
||||
return ;
|
||||
}
|
||||
log.writeLog(singlejson.toJSONString());
|
||||
String fieldvalue=Util.null2String(singlejson.getString("fieldvalue")) ;//新值 oldfieldvalue
|
||||
String oldfieldvalue=Util.null2String(singlejson.getString("oldfieldvalue")) ;//新值
|
||||
String fieldname=Util.null2String(singlejson.getString("fieldname")) ;//数据库字段名
|
||||
String labelname=Util.null2String(singlejson.getString("labelname")) ;//字段名称
|
||||
String prefieldvalue=Util.null2String(singlejson.getString("prefieldvalue")) ;//旧值
|
||||
String oldprefieldvalue=Util.null2String(singlejson.getString("oldprefieldvalue")) ;//旧值描述
|
||||
String changeID=checkFieldCheck(allVersionid, labelname);//之后变更版本
|
||||
String currentVersionChange=checkDetailFieldCheck(this.getBillid(),labelname,1);//获取中间版本 存在说明当前版本 有修改痕迹
|
||||
String getOldAllVersion=getOldAllVersion();//当前版本的 前版本
|
||||
String oldchangeID=checkDetailFieldCheck(getOldAllVersion,labelname,0);
|
||||
if(!isModifyClrq&&"clrq".equals(fieldname)){
|
||||
newclrq=oldfieldvalue;
|
||||
isModifyClrq=true;
|
||||
}
|
||||
log.writeLog("changeID->"+changeID);
|
||||
log.writeLog("currentVersionChange->"+currentVersionChange);
|
||||
log.writeLog("getOldAllVersion->"+getOldAllVersion);
|
||||
log.writeLog("oldchangeID->"+oldchangeID);
|
||||
if("".equals(changeID)||(allVersionid.equals(this.billid+"")||allVersionid.endsWith(","+this.billid))){//说明从来没有变更过(变更主表数据 ) 或者是 最新的版本
|
||||
Map<String,Object> map=new HashMap<>();
|
||||
Object[] params=new Object[1];
|
||||
params[0]=oldfieldvalue;
|
||||
map.put("sql","update "+CubeSaveInterccept.CompanyMaintable+" set "+fieldname+"=? where id='"+this.qyid+"'");
|
||||
map.put("params",params);
|
||||
sqlmaps.add(map);
|
||||
|
||||
|
||||
/** 跟新下属版本的所有值 **/
|
||||
Map<String,Object> map4=new HashMap<>();
|
||||
Object[] params4=new Object[1];
|
||||
params4[0]=oldfieldvalue;//获取动态的值
|
||||
map4.put("sql","update "+CubeSaveInterccept.CompanyVersionMaintable+" set "+fieldname+"=? where qyid='"+this.qyid+"' and id>"+this.billid);
|
||||
map4.put("params",params4);
|
||||
sqlmaps.add(map4);
|
||||
|
||||
/** 跟新下属版本的所有历史沿革值 **/
|
||||
Map<String,Object> map5=new HashMap<>();
|
||||
Object[] params5=new Object[2];
|
||||
params5[0]=fieldvalue;//获取动态的值 qyid='"+this.qyid+"' and
|
||||
params5[1]=labelname;
|
||||
map5.put("sql","update "+CubeSaveInterccept.CompanyVersionMaintable+"_dt1 set bgh=? where mainid="+this.billid+" and bgxm=? ");
|
||||
map5.put("params",params5);
|
||||
sqlmaps.add(map5);
|
||||
}else{//存在变更(跟新 changeID之前的版本字段数据 以及跟新 changeID的变更前 数据 以及 当前版本的变更后) 考虑到最新版本
|
||||
String betoowID=getBetoowVersion(billid,changeID, allVersionid);//获取中间版本
|
||||
if(!"".equals(betoowID)){
|
||||
Map<String,Object> map=new HashMap<>();
|
||||
Object[] params=new Object[1];
|
||||
params[0]=oldfieldvalue;
|
||||
map.put("sql","update "+CubeSaveInterccept.CompanyMaintable+" set "+fieldname+"=? where id='"+this.qyid +"' and id in ("+betoowID+")");
|
||||
map.put("params",params);
|
||||
sqlmaps.add(map);
|
||||
}
|
||||
if(!"".equals(changeID)){
|
||||
//中间版本的数据 真实 数据
|
||||
/** 跟新历史changeID沿革字段 **/
|
||||
Map<String,Object> map2=new HashMap<>();
|
||||
Object[] params2=new Object[2];
|
||||
params2[0]=fieldvalue;//获取动态的值
|
||||
params2[1]=labelname;
|
||||
map2.put("sql","update "+CubeSaveInterccept.CompanyVersionMaintable+"_dt1 set bgq=? where id in (select min(id) from "+CubeSaveInterccept.CompanyVersionMaintable+"_dt1 where mainid="+changeID+" and bgxm=? ) ");
|
||||
map2.put("params",params2);
|
||||
sqlmaps.add(map2);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//跟新当前节点的 变更后 通用设置
|
||||
if(!"".equals(currentVersionChange)){
|
||||
Map<String,Object> map3=new HashMap<>();
|
||||
Object[] params3=new Object[2];
|
||||
params3[0]=fieldvalue;//获取动态的值
|
||||
params3[1]=labelname;
|
||||
map3.put("sql","update "+CubeSaveInterccept.CompanyVersionMaintable+"_dt1 set bgh=? where id in (select max(id) from "+CubeSaveInterccept.CompanyVersionMaintable+"_dt1 where mainid='"+billid+"' and bgxm=?) ");
|
||||
map3.put("params",params3);
|
||||
sqlmaps.add(map3);
|
||||
}else{
|
||||
if(!"".equals(oldchangeID)){
|
||||
/** 历史沿革 更新 **/
|
||||
Map<String, Object> map2 = new HashMap<>();
|
||||
map2.put("sql", "insert into "+CubeSaveInterccept.CompanyVersionMaintable+"_dt1(rq,bgxm,bgq,bgh,mainid)values(?,?,?,?,?) ");
|
||||
map2.put("params", new Object[]{currentDate, labelname,oldprefieldvalue,fieldvalue,getBillid()});
|
||||
sqlmaps.add(map2);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取区间版本
|
||||
* @param current
|
||||
* @param lastversion
|
||||
* @param allversion
|
||||
* @return
|
||||
*/
|
||||
public static String getBetoowVersion(String current,String lastversion,String allversion){
|
||||
current=Util.null2String(current);
|
||||
lastversion=Util.null2String(lastversion);
|
||||
if("".equals(lastversion)){//如果不存在中间版本直接 返回空数据
|
||||
return "";
|
||||
}
|
||||
if("".equals(current)){//如果不存在中间版本直接 返回空数据
|
||||
return "";
|
||||
}
|
||||
allversion=Util.null2String(allversion);
|
||||
String betoowID="";
|
||||
boolean isbegin=false;
|
||||
String[] allversions=allversion.split(",");
|
||||
for(String str:allversions){
|
||||
str=Util.null2String(str).trim();
|
||||
if("".equals(str)){
|
||||
continue;
|
||||
}
|
||||
if(current.equals(str)){
|
||||
isbegin=true;
|
||||
continue;
|
||||
}
|
||||
if(lastversion.equals(str)){
|
||||
break;
|
||||
}
|
||||
if(isbegin){
|
||||
betoowID=betoowID+str+",";
|
||||
}
|
||||
}
|
||||
if(betoowID.endsWith(",")){
|
||||
betoowID=betoowID.substring(0,betoowID.length()-1);
|
||||
}
|
||||
return betoowID;
|
||||
}
|
||||
/**
|
||||
* 获取版本ID
|
||||
* @param type 0上一个版本 1 下一个版本
|
||||
*/
|
||||
public String getAllVersion(String type){
|
||||
JSONObject version=new JSONObject();
|
||||
RecordSet re=new RecordSet();
|
||||
String ids="";
|
||||
String sql="select * from "+CubeSaveInterccept.CompanyVersionMaintable+" where qyid='"+this.qyid+"' and bbrq>'"+this.bbrq+"' order by bbrq asc";;
|
||||
// if("0".equals(type)){
|
||||
// sql=sql+" and bbrq<'"+this.bbrq+"' order by desc";
|
||||
// }
|
||||
// if("1".equals(type)){
|
||||
// sql=sql+" and bbrq>'"+this.bbrq+"' order by asc";
|
||||
// }else{
|
||||
// return version;
|
||||
// }
|
||||
re.executeQuery(sql);
|
||||
log.writeLog(sql);
|
||||
while(re.next()){
|
||||
String id=Util.null2String(re.getString("id")) ;
|
||||
ids=ids+id+",";
|
||||
}
|
||||
if(ids.endsWith(",")){
|
||||
ids=ids.substring(0,ids.length()-1);
|
||||
}
|
||||
return ids;
|
||||
}
|
||||
public String getOldAllVersion(){
|
||||
JSONObject version=new JSONObject();
|
||||
RecordSet re=new RecordSet();
|
||||
String ids="";
|
||||
String sql="select * from "+CubeSaveInterccept.CompanyVersionMaintable+" where qyid='"+this.qyid+"' and bbrq<'"+this.bbrq+"' order by bbrq desc";;
|
||||
// if("0".equals(type)){
|
||||
// sql=sql+" and bbrq<'"+this.bbrq+"' order by desc";
|
||||
// }
|
||||
// if("1".equals(type)){
|
||||
// sql=sql+" and bbrq>'"+this.bbrq+"' order by asc";
|
||||
// }else{
|
||||
// return version;
|
||||
// }
|
||||
re.executeQuery(sql);
|
||||
log.writeLog(sql);
|
||||
while(re.next()){
|
||||
String id=Util.null2String(re.getString("id")) ;
|
||||
ids=ids+id+",";
|
||||
}
|
||||
if(ids.endsWith(",")){
|
||||
ids=ids.substring(0,ids.length()-1);
|
||||
}
|
||||
return ids;
|
||||
}
|
||||
/**
|
||||
* 返回 字段最新的 修改版本的ID
|
||||
* @param ids 所有版本的 iD
|
||||
* @param fieldname 字段名称
|
||||
* @return
|
||||
*/
|
||||
public String checkFieldCheck(String ids,String fieldname){
|
||||
String id="";
|
||||
RecordSet re=new RecordSet();
|
||||
boolean flag=false;
|
||||
String sql="select a.id from "+CubeSaveInterccept.CompanyVersionMaintable+" a, "+CubeSaveInterccept.CompanyVersionMaintable+"_dt1 b where a.id=b.mainid and a.qyid='"+this.qyid+"' and a.id in ("+ids+") and bgxm=? order by a.bbrq asc";
|
||||
re.executeQuery(sql,fieldname);
|
||||
log.writeLog(sql);
|
||||
if(re.next()){
|
||||
id=Util.null2String(re.getString("id")) ;
|
||||
}
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
* 明细表 返回 字段最新的 修改版本的ID
|
||||
* @param ids 所有版本的 iD
|
||||
* @param type 大于0 的版本 小于 0 之前的版本
|
||||
* @return
|
||||
*/
|
||||
public String checkDetailFieldCheck(String ids,String bgxm,int type){
|
||||
String id="";
|
||||
RecordSet re=new RecordSet();
|
||||
boolean flag=false;
|
||||
//String sql="select a.relatedid from ModeViewLog_84 a,ModeLogFieldDetail b where a.id=b.viewlogid and a.operateType=2 and (a.relatedid in ("+ids+") or a.relatedid="+billid+" ) and b.detailtable='"+tablename+"' ";
|
||||
String sql="select a.id from "+CubeSaveInterccept.CompanyVersionMaintable+" a, "+CubeSaveInterccept.CompanyVersionMaintable+"_dt1 b where a.id=b.mainid and a.qyid='"+this.qyid+"' and a.id in ("+ids+") and bgxm=? ";
|
||||
//改为按照版本日期 排序
|
||||
if(type>0){
|
||||
sql=sql+" order by a.bbrq asc";
|
||||
}else{
|
||||
sql=sql+" order by a.bbrq desc";
|
||||
}
|
||||
// if(type>0){
|
||||
// sql=sql+" order by a.id asc";
|
||||
// }else{
|
||||
// sql=sql+" order by a.id desc";
|
||||
// }
|
||||
re.executeQuery(sql,bgxm);
|
||||
log.writeLog(sql);
|
||||
if(re.next()){
|
||||
id=Util.null2String(re.getString("id")) ;
|
||||
}
|
||||
return id;
|
||||
}
|
||||
|
||||
public String getFieldNameByid(String fieldid){
|
||||
RecordSet re=new RecordSet();
|
||||
String fieldname="";
|
||||
String sql="select fieldname from workflow_billfield where id="+fieldid;
|
||||
re.execute(sql);
|
||||
if(re.next()){
|
||||
fieldname=Util.null2String(re.getString("fieldname")) ;
|
||||
}
|
||||
return fieldname;
|
||||
}
|
||||
//(fieldvalue, fieldhtmltype, fieldid, fielddbtype, viewtype, type)
|
||||
|
||||
public JSONObject getFieldIdByName(String fieldname,String detailtable){
|
||||
RecordSet re=new RecordSet();
|
||||
JSONObject json=new JSONObject();
|
||||
String sql=" select c.id,fieldhtmltype, fielddbtype, viewtype, type from workflow_billfield c where c.billid="+formId+" and fieldname=? ";
|
||||
if(formId<=0&&!"".equals(Util.null2String(detailtable).trim())){
|
||||
sql=" select c.id,fieldhtmltype, fielddbtype, viewtype, type from workflow_billfield c where fieldname=? ";
|
||||
}
|
||||
if(!"".equals(Util.null2String(detailtable) )){
|
||||
sql=sql+" and detailtable='"+detailtable+"'";
|
||||
}
|
||||
log.writeLog(sql);
|
||||
re.executeQuery(sql,fieldname);
|
||||
if(re.next()){
|
||||
String id=Util.null2String(re.getString("id")) ;
|
||||
String fieldhtmltype=Util.null2String(re.getString("fieldhtmltype")) ;
|
||||
String fielddbtype=Util.null2String(re.getString("fielddbtype")) ;
|
||||
String viewtype=Util.null2String(re.getString("viewtype")) ;
|
||||
String type=Util.null2String(re.getString("type")) ;
|
||||
json.put("fieldid",id);
|
||||
json.put("fieldhtmltype",fieldhtmltype);
|
||||
json.put("fielddbtype",fielddbtype);
|
||||
json.put("viewtype",viewtype);
|
||||
json.put("type",type);
|
||||
}
|
||||
return json;
|
||||
}
|
||||
public String getSingleFieldIdByName(String fieldname,String detailtable){
|
||||
RecordSet re=new RecordSet();
|
||||
JSONObject json=new JSONObject();
|
||||
String sql=" select c.id,fieldhtmltype, fielddbtype, viewtype, type from workflow_billfield c where c.billid="+formId+" and fieldname=? ";
|
||||
if(!"".equals(Util.null2String(detailtable) )){
|
||||
sql=sql+" and detailtable='"+detailtable+"'";
|
||||
}
|
||||
String id="";
|
||||
re.executeQuery(sql,fieldname);
|
||||
if(re.next()){
|
||||
id=Util.null2String(re.getString("id")) ;
|
||||
}
|
||||
return id;
|
||||
}
|
||||
/**
|
||||
* 获取明细表的 所有值
|
||||
* @param detailtable
|
||||
* @param fields
|
||||
* @return
|
||||
*/
|
||||
public String getDetailAllValue(String detailtable,String fields,String billidval){
|
||||
String result="";
|
||||
detailtable=Util.null2String(detailtable).trim();
|
||||
fields=Util.null2String(fields);
|
||||
if("".equals(detailtable)||"".equals(fields)){
|
||||
return "";
|
||||
}
|
||||
String[] fieldss=fields.split(",");
|
||||
RecordSet re=new RecordSet();
|
||||
String sql="select * from "+detailtable+" where mainid=";
|
||||
if(!"".equals(billidval)){
|
||||
sql=sql+""+billidval;
|
||||
}
|
||||
re.execute(sql);
|
||||
while(re.next()){
|
||||
String demostr="";
|
||||
for(String str:fieldss){
|
||||
str=Util.null2String(str).trim();
|
||||
if(str.equals("")){
|
||||
continue;
|
||||
}
|
||||
String fieldvalue=Util.null2String(re.getString(str)) ;
|
||||
String newfieldvalue="";
|
||||
try {
|
||||
newfieldvalue=BaseUtil.Html2Text(transFieldValue(fieldvalue, getFieldIdByName(str,detailtable))) ;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
demostr=demostr+newfieldvalue+"/";
|
||||
}
|
||||
if(demostr.endsWith("/")){
|
||||
demostr=demostr.substring(0,demostr.length()-1);
|
||||
}
|
||||
result=result+demostr+"、\n";
|
||||
}
|
||||
// if(result.endsWith("|")){
|
||||
// result=result.substring(0,result.length()-1);
|
||||
// }
|
||||
return result;
|
||||
}
|
||||
//更新历史 版本的 新增的明细表对用的 企业信息明细ID
|
||||
public void updateallmodflyuuid(){
|
||||
RecordSet recordSet=new RecordSet();
|
||||
String[] allmodflyuuids=Util.null2String(this.allmodflyuuid).trim().split(",");
|
||||
for(String str:allmodflyuuids){
|
||||
str=Util.null2String(str).trim();
|
||||
if("".equals(str)||str.indexOf(",")<1){
|
||||
continue;
|
||||
}
|
||||
String tableindex=str.substring(0,str.indexOf(","));
|
||||
log.writeLog(str+"update "+CubeSaveInterccept.CompanyVersionMaintable+"_"+tableindex+" set mainbillid=(select id from "+CubeSaveInterccept.CompanyMaintable+"_"+tableindex+" where modflyuuid=?) where modflyuuid=?");
|
||||
recordSet.executeUpdate("update "+CubeSaveInterccept.CompanyVersionMaintable+"_"+tableindex+" set mainbillid=(select id from "+CubeSaveInterccept.CompanyMaintable+"_"+tableindex+" where modflyuuid=?) where modflyuuid=?",str);
|
||||
}
|
||||
}
|
||||
|
||||
public String getFeildnameByNames(String names,int formid){
|
||||
String resultnames="";
|
||||
String result="";
|
||||
names=Util.null2String(names).trim();
|
||||
if("djgd,cgbl,cgfs,gfzl".equals(names)){
|
||||
return "登记股东/持股比例/持股份数/股份种类";
|
||||
}
|
||||
String namesValue=","+names+",";
|
||||
String[] namess=names.split(",");
|
||||
for(String str:namess){
|
||||
str=Util.null2String(str).trim();
|
||||
if("".equals(str)){
|
||||
continue;
|
||||
}
|
||||
result=result+"'"+str+"',";
|
||||
}
|
||||
if(result.endsWith(",")){
|
||||
result=result.substring(0,result.length()-1);
|
||||
}
|
||||
if(!"".equals(result)){
|
||||
RecordSet re=new RecordSet();
|
||||
log.writeLog("select fieldname,fieldlabel from workflow_billfield where billid="+formid+" and fieldname in ("+result+")");
|
||||
re.execute("select fieldname,fieldlabel from workflow_billfield where billid="+formid+" and fieldname in ("+result+")");
|
||||
|
||||
while(re.next()){
|
||||
String fieldnameStr=Util.null2String(re.getString("fieldname"));
|
||||
String fieldname=SystemEnv.getHtmlLabelName(re.getInt("fieldlabel"), 7);//Util.null2String(re.getString("fieldname")) .trim();
|
||||
if("".equals(fieldname)){
|
||||
continue;
|
||||
}
|
||||
namesValue=namesValue.replaceAll(","+fieldnameStr+",",","+fieldname+",");
|
||||
resultnames=resultnames+fieldname+"/";
|
||||
}
|
||||
if(namesValue.endsWith(",")){
|
||||
namesValue=namesValue.substring(0,namesValue.length()-1);
|
||||
}
|
||||
if(namesValue.startsWith(",")){
|
||||
namesValue=namesValue.substring(1);
|
||||
}
|
||||
namesValue=namesValue.replaceAll(",","/");
|
||||
if(resultnames.endsWith("/")){
|
||||
resultnames=resultnames.substring(0,resultnames.length()-1);
|
||||
}
|
||||
}
|
||||
return namesValue;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param names
|
||||
* @param tablename
|
||||
* @param type 0主表 1明细表
|
||||
* @return
|
||||
*/
|
||||
public String getFeildnameByNames(String names,String tablename,int type){
|
||||
String resultnames="";
|
||||
String result="";
|
||||
names=Util.null2String(names).trim();
|
||||
String[] namess=names.split(",");
|
||||
for(String str:namess){
|
||||
str=Util.null2String(str).trim();
|
||||
if("".equals(str)){
|
||||
continue;
|
||||
}
|
||||
result=result+"'"+str+"',";
|
||||
}
|
||||
if(result.endsWith(",")){
|
||||
result=result.substring(0,result.length()-1);
|
||||
}
|
||||
log.writeLog(result+" "+tablename+" "+type);
|
||||
if(!"".equals(result)){
|
||||
RecordSet re=new RecordSet();
|
||||
//log.writeLog("select fieldname,fieldlabel from workflow_billfield where billid="+formid+" and fieldname in ("+result+")");
|
||||
if(type==0){
|
||||
re.executeQuery("select a.fieldname,a.fieldlabel from workflow_billfield a,workflow_bill b where a.billid=b.id and a.fieldname in ("+result+") and b.tablename=?",tablename);
|
||||
}else{
|
||||
log.writeLog("select a.fieldname,a.fieldlabel from workflow_billfield a,workflow_bill b where a.billid=b.id and a.fieldname in ("+result+") and a.detailtable=?"+tablename);
|
||||
re.executeQuery("select a.fieldname,a.fieldlabel from workflow_billfield a,workflow_bill b where a.billid=b.id and a.fieldname in ("+result+") and a.detailtable=?",tablename);
|
||||
}
|
||||
|
||||
|
||||
while(re.next()){
|
||||
String fieldname=SystemEnv.getHtmlLabelName(re.getInt("fieldlabel"), 7);//Util.null2String(re.getString("fieldname")) .trim();
|
||||
if("".equals(fieldname)){
|
||||
continue;
|
||||
}
|
||||
resultnames=resultnames+fieldname+"/";
|
||||
}
|
||||
if(resultnames.endsWith("/")){
|
||||
resultnames=resultnames.substring(0,resultnames.length()-1);
|
||||
}
|
||||
}
|
||||
return resultnames;
|
||||
}
|
||||
|
||||
public static void main(String[] arg){
|
||||
System.out.println(getBetoowVersion("3","21","1,2,3,21,4,5"));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,56 @@
|
|||
package com.jet.action;
|
||||
|
||||
import weaver.soa.workflow.request.RequestInfo;
|
||||
import weaver.workflow.action.BaseAction;
|
||||
import weaver.conn.RecordSet;
|
||||
import weaver.general.Util;
|
||||
|
||||
import com.working.util.LogTool;
|
||||
import com.working.util.WorkflowUtil;
|
||||
|
||||
/**
|
||||
* 02-费用报销申请-J&T中国
|
||||
* @author lwt
|
||||
*
|
||||
*/
|
||||
public class ApplyForFee extends BaseAction{
|
||||
|
||||
LogTool log = new LogTool("/log/feeChina/",false);
|
||||
|
||||
@Override
|
||||
public String execute(RequestInfo requestInfo) {
|
||||
// TODO Auto-generated method stub
|
||||
String requestid = requestInfo.getRequestid();
|
||||
RecordSet rs = new RecordSet();
|
||||
RecordSet rs1 = new RecordSet();
|
||||
String mainTable = WorkflowUtil.getMainTable(requestid);
|
||||
String detail8Table = mainTable + "_dt8";
|
||||
int mainId = requestInfo.getRequestManager().getBillid();//主表数据id
|
||||
rs.execute("select * from " + detail8Table + " where mainid = '" + mainId + "' order by id desc");
|
||||
String bxlx = "";//报销类型
|
||||
String tdhdVal = "0";//团队活动费
|
||||
String clVal = "0";//差旅费
|
||||
while (rs.next()) {
|
||||
bxlx = Util.null2String(rs.getString("BXLX"));
|
||||
if (bxlx!=null) {
|
||||
if (bxlx.equals("27")) {//团队活动费
|
||||
tdhdVal = "1";
|
||||
} else if (bxlx.equals("3")) {//差旅费
|
||||
clVal = "1";
|
||||
}
|
||||
}
|
||||
}
|
||||
if (tdhdVal.equals("0")&&clVal.equals("0")) {//既没有团队活动费也没有差旅费,设置主表的报销类型为其他
|
||||
rs1.execute("update " + mainTable + " set bxlxzb = '2' where requestid = '" + requestid +"'");
|
||||
} else if (tdhdVal.equals("1")&&clVal.equals("0")) {//只有团队活动费,设置主表的报销类型为团队活动费
|
||||
rs1.execute("update " + mainTable + " set bxlxzb = '0' where requestid = '" + requestid +"'");
|
||||
} else if (tdhdVal.equals("0")&&clVal.equals("1")) {//只有差旅费,设置主表的报销类型为差旅费
|
||||
rs1.execute("update " + mainTable + " set bxlxzb = '1' where requestid = '" + requestid +"'");
|
||||
} else if (tdhdVal.equals("1")&&clVal.equals("1")) {//既有团队活动费也有差旅费,设置主表的报销类型为团队活动费&差旅费
|
||||
rs1.execute("update " + mainTable + " set bxlxzb = '3' where requestid = '" + requestid +"'");
|
||||
}
|
||||
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,202 @@
|
|||
package com.jet.action;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.alibaba.fastjson.serializer.SerializerFeature;
|
||||
import com.working.third.JwtUtil;
|
||||
import com.working.util.HttpManager;
|
||||
import com.working.util.WorkflowUtil;
|
||||
import selfdev.util.log.LogTool;
|
||||
import weaver.conn.RecordSet;
|
||||
import weaver.file.Prop;
|
||||
import weaver.general.Util;
|
||||
import weaver.soa.workflow.request.RequestInfo;
|
||||
import weaver.workflow.action.BaseAction;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @Author Administrator
|
||||
* @Description OA出差申请数据写入东宝HR系统
|
||||
* @Date 2020/10/20 16:26
|
||||
* <p>
|
||||
* 这两个值后需要写在配置文件中
|
||||
* 正式环境
|
||||
* https://hr.jtexpress.com.cn
|
||||
* clientId:TPFKAGB3QGPM2LBD
|
||||
* 测试环境
|
||||
* http://121.36.223.187:9011
|
||||
* clientId: P3F28BIFKGFL0ANX
|
||||
*/
|
||||
public class BusinessTripIntoHRAction extends BaseAction {
|
||||
|
||||
@Override
|
||||
public String execute(RequestInfo requestInfo) {
|
||||
LogTool log = new LogTool("/log/selfdev/action", false);
|
||||
log.writeLog("-----------------------开始OA出差申请数据写入东宝HR系统-----------------------");
|
||||
String requestId = requestInfo.getRequestid(); //获取requestid
|
||||
log.writeLog("------------requestId值为:" + requestId);
|
||||
|
||||
String mainTable = WorkflowUtil.getMainTable(requestId);
|
||||
|
||||
// String clientId = Prop.getPropValue("db_work", "clientId");
|
||||
String clientId = "P3F28BIFKGFL0ANX";
|
||||
String secret = Prop.getPropValue("db_work", "secret");
|
||||
int second = Integer.parseInt(Prop.getPropValue("db_work", "second"));
|
||||
|
||||
// String batchCardDataUrl = Prop.getPropValue("db_work", "batchCardDataUrl");
|
||||
String batchCardDataUrl = "http://121.36.223.187:9011/third/api";
|
||||
|
||||
String code = "saveBusinessTripOrderToThirdNew";
|
||||
String moduleCode = "attBusinessTripOrderService";
|
||||
String token = JwtUtil.createThirdToken(clientId, secret, second).getToken();
|
||||
|
||||
HashMap<String, String> headMap = new HashMap<String, String>(); // 存放head的值
|
||||
headMap.put("code", code);
|
||||
headMap.put("moduleCode", moduleCode);
|
||||
headMap.put("token", token);
|
||||
headMap.put("clientId", clientId);
|
||||
|
||||
HashMap<String, Object> bodyMap = new HashMap<String, Object>(); // 存放body的值
|
||||
|
||||
String userId = ""; // 申请人id
|
||||
String workCode = ""; //人员编号
|
||||
|
||||
String trip_category = "2"; // 出差类型(1-外出,2-出差)
|
||||
String trip_area = ""; // 出差区域(1-市内,2-省内,3-国内,4-海外) 暂时只分3和4
|
||||
String trip_way = "4"; // 出差方式(1-整天,2-上半天,3-下半天,4-连续时间段,5-每天固定时间)
|
||||
|
||||
String begin_date = ""; // 开始日期
|
||||
String end_date = ""; // 结束日期
|
||||
String begin_time = ""; // 开始时间
|
||||
String end_time = ""; // 结束时间
|
||||
String reason = ""; // 出差事由
|
||||
String origin = ""; // 出发地
|
||||
String destination = ""; // 目的地
|
||||
|
||||
String is_overtime = "1"; // 是否出差计加班(默认传入1)
|
||||
String audit_status = "1"; // 提交状态 0-保存 1-提交
|
||||
|
||||
RecordSet rs = new RecordSet();
|
||||
String sql = " select * from " + mainTable + " where requestid='" + requestId + "'";
|
||||
rs.execute(sql);
|
||||
while (rs.next()) {
|
||||
HashMap<String, Object> empOrderMap = new HashMap<String, Object>(); // 存放empOrder的值
|
||||
HashMap<String, Object> businessTripOrderMap = new HashMap<String, Object>(); // 存放businessTripOrder的值
|
||||
|
||||
userId = Util.null2String(rs.getString("sqr"));// 人员转换唯一标识
|
||||
workCode = Util.null2String(WorkflowUtil.getUserInfo(userId).get("workcode"));
|
||||
log.writeLog("------------人员转换唯一标识值为:" + workCode);
|
||||
|
||||
String trip_area1 = Util.null2String(rs.getString("cclb")); // 出差类别
|
||||
if ("0".equals(trip_area1)) {
|
||||
trip_area = "3"; // 国内
|
||||
}
|
||||
if ("1".equals(trip_area1)) {
|
||||
trip_area = "4"; // 国外
|
||||
}
|
||||
|
||||
begin_date = Util.null2String(rs.getString("fsrq")); // 开始日期
|
||||
end_date = Util.null2String(rs.getString("jsrq")); // 结束日期
|
||||
reason = Util.null2String(rs.getString("ccsy")); // 出差事由
|
||||
origin = Util.null2String(rs.getString("cfd")); // 出发地
|
||||
destination = Util.null2String(rs.getString("mdd")); // 目的地
|
||||
|
||||
String[] s = begin_date.split(" ");
|
||||
begin_time = s[1];
|
||||
String[] s1 = end_date.split(" ");
|
||||
end_time = s1[1];
|
||||
|
||||
List<Map<String, String>> scheduleList = new ArrayList<Map<String, String>>(); // 出差行程记录
|
||||
Map<String, String> scheduleMap1 = new HashMap<String, String>();
|
||||
scheduleMap1.put("name", "出发地");
|
||||
scheduleMap1.put("place", origin);
|
||||
scheduleMap1.put("longitude", "");
|
||||
scheduleMap1.put("latitude", "");
|
||||
scheduleMap1.put("id", "");
|
||||
|
||||
Map<String, String> scheduleMap2 = new HashMap<String, String>();
|
||||
scheduleMap2.put("name", "目的地");
|
||||
scheduleMap2.put("place", destination);
|
||||
scheduleMap2.put("longitude", "");
|
||||
scheduleMap2.put("latitude", "");
|
||||
scheduleMap2.put("id", "");
|
||||
scheduleList.add(scheduleMap1);
|
||||
scheduleList.add(scheduleMap2);
|
||||
|
||||
log.writeLog("------------出差类型值为:" + trip_category);
|
||||
log.writeLog("------------出差区域值为:" + trip_area);
|
||||
log.writeLog("------------出差方式值为:" + trip_way);
|
||||
log.writeLog("------------开始日期值为:" + begin_date);
|
||||
log.writeLog("------------结束日期值为:" + end_date);
|
||||
log.writeLog("------------开始时间值为:" + begin_time);
|
||||
log.writeLog("------------结束时间值为:" + end_time);
|
||||
log.writeLog("------------出差事由值为:" + reason);
|
||||
log.writeLog("------------出发地值为:" + origin);
|
||||
log.writeLog("------------目的地值为:" + destination);
|
||||
|
||||
empOrderMap.put("empKey", workCode);
|
||||
empOrderMap.put("empRule", "1"); // 人员转换规则(0-无,1-工号,2-身份证,3邮箱,4-手机号码)
|
||||
|
||||
businessTripOrderMap.put("trip_category", trip_category);
|
||||
businessTripOrderMap.put("trip_area", trip_area);
|
||||
businessTripOrderMap.put("trip_way", trip_way);
|
||||
businessTripOrderMap.put("begin_date", begin_date);
|
||||
businessTripOrderMap.put("end_date", end_date);
|
||||
businessTripOrderMap.put("begin_time", begin_time);
|
||||
businessTripOrderMap.put("end_time", end_time);
|
||||
businessTripOrderMap.put("reason", reason);
|
||||
|
||||
businessTripOrderMap.put("is_overtime", is_overtime);
|
||||
businessTripOrderMap.put("audit_status", audit_status);
|
||||
businessTripOrderMap.put("isChangeTripOrder", false); // 是否变更出差单(默认传入false)
|
||||
|
||||
businessTripOrderMap.put("scheduleList", scheduleList);
|
||||
|
||||
empOrderMap.put("businessTripOrder", businessTripOrderMap);
|
||||
bodyMap.put("empOrder", empOrderMap);
|
||||
}
|
||||
|
||||
HashMap<String, Object> paramMap = new HashMap<String, Object>();
|
||||
paramMap.put("header", headMap);
|
||||
paramMap.put("body", bodyMap);
|
||||
|
||||
try {
|
||||
String param = JSON.toJSONString(paramMap, SerializerFeature.DisableCircularReferenceDetect);
|
||||
log.writeLog("---------------paramMap的值为:" + param);
|
||||
String result = HttpManager.postMap(batchCardDataUrl, headMap, param);
|
||||
log.writeLog("-----------发送请求返回的结果值为:" + result);
|
||||
|
||||
JSONObject jsonObject = JSONObject.parseObject(result);
|
||||
String returnCode = Util.null2String(jsonObject.get("code"));
|
||||
String data = Util.null2String(jsonObject.get("data"));
|
||||
String message = Util.null2String(jsonObject.get("message"));
|
||||
String id = Util.null2String(jsonObject.get("id"));
|
||||
|
||||
log.writeLog("--------发送请求返回的code值为:" + returnCode);
|
||||
log.writeLog("--------发送请求返回的数据值为:" + data);
|
||||
log.writeLog("--------发送请求返回的信息为:" + message);
|
||||
log.writeLog("--------发送请求返回的id值为:" + id);
|
||||
|
||||
if (!"".equals(result) && result != null) {
|
||||
if ("200".equals(returnCode)) {
|
||||
return SUCCESS;
|
||||
} else {
|
||||
requestInfo.getRequestManager().setMessagecontent("写入HR系统失败,失败信息为:" + message);
|
||||
return "0";
|
||||
}
|
||||
} else {
|
||||
requestInfo.getRequestManager().setMessagecontent("写入HR系统失败,发送请求返回的结果值为" + result);
|
||||
return "0";
|
||||
}
|
||||
|
||||
} catch (IOException ioException) {
|
||||
requestInfo.getRequestManager().setMessagecontent("发生异常了,写入HR系统失败");
|
||||
return "0";
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,124 @@
|
|||
package com.jet.action;
|
||||
|
||||
import weaver.conn.RecordSet;
|
||||
import weaver.general.BaseBean;
|
||||
import weaver.general.Util;
|
||||
import weaver.interfaces.workflow.action.Action;
|
||||
import weaver.soa.workflow.request.RequestInfo;
|
||||
import selfdev.util.base.BaseUtil;
|
||||
import selfdev.util.log.LogTool;
|
||||
|
||||
/**
|
||||
* 付款申请流程申请节点提交时的校验判断
|
||||
* 1、判断支付明细中的本次付款金额是否超出未付款金额
|
||||
* 2、判断一个付款流程不能同时选择两行以上相同的批次
|
||||
* @author KangMD
|
||||
* 2019-11-04
|
||||
*/
|
||||
public class CheckPayAction extends BaseBean implements Action {
|
||||
|
||||
public String execute(RequestInfo ri) {
|
||||
LogTool log=new LogTool("/log/selfdev/action", false);
|
||||
//获取requestid
|
||||
String requestid=ri.getRequestid();
|
||||
String workflowid=ri.getWorkflowid();
|
||||
//获取用户语言
|
||||
int language=ri.getRequestManager().getUser().getLanguage();
|
||||
log.writeLog("language---------->"+language);
|
||||
String workflowname=BaseUtil.getBaseInfoByParm("workflowname", "workflow_base", "id", workflowid, "");
|
||||
log.writeLog("---------------"+workflowname+"开始-------------requestId:" + requestid);
|
||||
try {
|
||||
RecordSet rs=new RecordSet();
|
||||
String mainid="";//主键ID
|
||||
String htxx="";//建模合同ID
|
||||
//获取表名
|
||||
String tablename=BaseUtil.getBaseInfoByParm("tablename", "workflow_bill", "1", "1", " and id in (select formid from workflow_base where id="+workflowid+")");;
|
||||
String sql="select * from "+tablename+" where requestid="+requestid;
|
||||
rs.execute(sql);
|
||||
while(rs.next()){
|
||||
mainid=Util.null2String(rs.getString("id"));
|
||||
htxx=Util.null2String(rs.getString("htxx"));
|
||||
}
|
||||
String sfcc="0";//流程是否可通过 0表示可通过 1表示不可通过
|
||||
String msg="";//提示信息
|
||||
//查询1个流程中是否填写了2行相同付款批次
|
||||
sql="select a.pc_num,b.* from (select fkpc,count(*) as pc_num from "+tablename+"_dt5 where mainid= "+mainid+" GROUP BY fkpc having count(*)>1) a left join V_uf_httz_dt1 b on a.fkpc=b.id";
|
||||
log.writeLog("查询付款明细中不能有重复批次的SQL---------->"+sql);
|
||||
rs.execute(sql);
|
||||
while(rs.next()){
|
||||
sfcc="1";//重复
|
||||
if(language==0||language==7){//简体
|
||||
msg+="明细中批次为【"+Util.null2String(rs.getString("fkpc"))+"】的付款重复选择了;<br/>";//超出提示信息
|
||||
}else if(language==8){//英语
|
||||
msg+="明细中批次为【"+Util.null2String(rs.getString("fkpc"))+"】的付款重复选择了;<br/>";//超出提示信息
|
||||
}else if(language==9){//繁体
|
||||
msg+="明细中批次为【"+Util.null2String(rs.getString("fkpc"))+"】的付款重复选择了;<br/>";//超出提示信息
|
||||
}else if(language==22){//印尼语
|
||||
msg+="明细中批次为【"+Util.null2String(rs.getString("fkpc"))+"】的付款重复选择了;<br/>";//超出提示信息
|
||||
}
|
||||
}
|
||||
if("0".equals(sfcc)){
|
||||
//当前明细汇总本次支付金额与批次未付金额对比,若超出未付金额,则不可提交
|
||||
sql="select a.*,b.bcfkje from V_uf_httz_dt1 a,(select fkpc as fkpcid,sum(TO_NUMBER(replace(bcfkje,',',''))) as bcfkje from "+tablename+"_dt5 where mainid="+mainid+" GROUP BY fkpc ) b where a.id=b.fkpcid and a.wfkje<b.bcfkje and a.mainid='"+htxx+"'";
|
||||
log.writeLog("查询明细中本次支付金额是否超出未付金额SQL---------->"+sql);
|
||||
rs.execute(sql);
|
||||
while(rs.next()){
|
||||
sfcc="1";//超出了
|
||||
if(language==0||language==7){//简体
|
||||
msg+="批次【"+Util.null2String(rs.getString("fkpc"))+"】未付金额【"+Util.null2String(rs.getString("wfkje"))+"】元,本次申请支付金额【"+Util.null2String(rs.getString("bcfkje"))+"】元已超出未付金额;<br/>";//超出提示信息
|
||||
}else if(language==8){//英语
|
||||
msg+="批次【"+Util.null2String(rs.getString("fkpc"))+"】未付金额【"+Util.null2String(rs.getString("wfkje"))+"】元,本次申请支付金额【"+Util.null2String(rs.getString("bcfkje"))+"】元已超出未付金额;<br/>";//超出提示信息
|
||||
}else if(language==9){//繁体
|
||||
msg+="批次【"+Util.null2String(rs.getString("fkpc"))+"】未付金额【"+Util.null2String(rs.getString("wfkje"))+"】元,本次申请支付金额【"+Util.null2String(rs.getString("bcfkje"))+"】元已超出未付金额;<br/>";//超出提示信息
|
||||
}else if(language==22){//印尼语
|
||||
msg+="批次【"+Util.null2String(rs.getString("fkpc"))+"】未付金额【"+Util.null2String(rs.getString("wfkje"))+"】元,本次申请支付金额【"+Util.null2String(rs.getString("bcfkje"))+"】元已超出未付金额;<br/>";//超出提示信息
|
||||
}
|
||||
}
|
||||
}
|
||||
if("0".equals(sfcc)){
|
||||
//当前明细汇总本次支付金额+在途流程金额与批次未付金额对比,若超出未付金额,则不可提交
|
||||
sql="select a.*,b.bcfkje,nvl(c.bcfkje_zt,0) as bcfkje_zt from V_uf_httz_dt1 a " +
|
||||
"left join (select fkpc as fkpcid,sum(TO_NUMBER(replace(bcfkje,',',''))) as bcfkje from "+tablename+"_dt5 where mainid="+mainid+" GROUP BY fkpc ) b on a.id=b.fkpcid " +
|
||||
"left join (select a.fkpc as fkpcid,sum(TO_NUMBER(replace(a.bcfkje,',',''))) as bcfkje_zt from "+tablename+"_dt5 a,"+tablename+" b,workflow_requestbase c where a.mainid=b.id and b.requestid=c.requestid and c.currentnodetype not in(0,3) and b.htxx='"+htxx+"' GROUP BY a.fkpc ) c on a.id=c.fkpcid " +
|
||||
"where a.wfkje<b.bcfkje+nvl(c.bcfkje_zt,0) and a.mainid='"+htxx+"'";
|
||||
log.writeLog("查询明细中本次支付金额+在途流程金额是否超出未付金额SQL---------->"+sql);
|
||||
rs.execute(sql);
|
||||
while(rs.next()){
|
||||
sfcc="1";//超出了
|
||||
if(language==0||language==7){//简体
|
||||
msg+="批次【"+Util.null2String(rs.getString("fkpc"))+"】未付金额【"+Util.null2String(rs.getString("wfkje"))+"】元,已提交OA流程在途审批中【"+Util.null2String(rs.getString("bcfkje_zt"))+"】元,本次申请支付金额【"+Util.null2String(rs.getString("bcfkje"))+"】元已超出未付金额;<br/>";//超出提示信息
|
||||
}else if(language==8){//英语
|
||||
msg+="批次【"+Util.null2String(rs.getString("fkpc"))+"】未付金额【"+Util.null2String(rs.getString("wfkje"))+"】元,已提交OA流程在途审批中【"+Util.null2String(rs.getString("bcfkje_zt"))+"】元,本次申请支付金额【"+Util.null2String(rs.getString("bcfkje"))+"】元已超出未付金额;<br/>";//超出提示信息
|
||||
}else if(language==9){//繁体
|
||||
msg+="批次【"+Util.null2String(rs.getString("fkpc"))+"】未付金额【"+Util.null2String(rs.getString("wfkje"))+"】元,已提交OA流程在途审批中【"+Util.null2String(rs.getString("bcfkje_zt"))+"】元,本次申请支付金额【"+Util.null2String(rs.getString("bcfkje"))+"】元已超出未付金额;<br/>";//超出提示信息
|
||||
}else if(language==22){//印尼语
|
||||
msg+="批次【"+Util.null2String(rs.getString("fkpc"))+"】未付金额【"+Util.null2String(rs.getString("wfkje"))+"】元,已提交OA流程在途审批中【"+Util.null2String(rs.getString("bcfkje_zt"))+"】元,本次申请支付金额【"+Util.null2String(rs.getString("bcfkje"))+"】元已超出未付金额;<br/>";//超出提示信息
|
||||
}
|
||||
}
|
||||
}
|
||||
//超出未支付金额,则进行提醒,并阻止流程提交
|
||||
if("1".equals(sfcc)){
|
||||
ri.getRequestManager().setMessage("111100");
|
||||
ri.getRequestManager().setMessagecontent(msg);
|
||||
return "0";
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
String error_msg="付款流程提交失败,错误信息为:------>"+e.toString();
|
||||
if(language==0||language==7){//简体
|
||||
|
||||
}else if(language==8){//英语
|
||||
error_msg="付款流程提交失败,错误信息为:------>"+e.toString();
|
||||
}else if(language==9){//繁体
|
||||
error_msg="付款流程提交失败,错误信息为:------>"+e.toString();
|
||||
}else if(language==22){//印尼语
|
||||
error_msg="付款流程提交失败,错误信息为:------>"+e.toString();
|
||||
}
|
||||
log.writeLog(error_msg);
|
||||
ri.getRequestManager().setMessage("111100");
|
||||
ri.getRequestManager().setMessagecontent(error_msg);
|
||||
return "0";
|
||||
}
|
||||
return SUCCESS;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,122 @@
|
|||
package com.jet.action;
|
||||
|
||||
import weaver.conn.RecordSet;
|
||||
import weaver.general.BaseBean;
|
||||
import weaver.general.Util;
|
||||
import weaver.interfaces.workflow.action.Action;
|
||||
import weaver.soa.workflow.request.RequestInfo;
|
||||
import selfdev.util.base.BaseUtil;
|
||||
import selfdev.util.log.LogTool;
|
||||
|
||||
/**
|
||||
* 费用报销流程申请节点提交时的校验判断
|
||||
* 1、报销明细若存在团队招待费,则明细dt2中的合计金额需与报销明细中的团队招待费金额相等
|
||||
* 2、报销明细若存在客户招待费,则明细dt3中的合计金额需与报销明细中的客户招待费金额相等
|
||||
* @author KangMD
|
||||
* 2019-11-07
|
||||
*/
|
||||
public class CheckReimbursementAction extends BaseBean implements Action {
|
||||
|
||||
public String execute(RequestInfo ri) {
|
||||
LogTool log=new LogTool("/log/selfdev/action", false);
|
||||
//获取requestid
|
||||
String requestid=ri.getRequestid();
|
||||
String workflowid=ri.getWorkflowid();
|
||||
//获取用户语言
|
||||
int language=ri.getRequestManager().getUser().getLanguage();
|
||||
log.writeLog("language---------->"+language);
|
||||
String workflowname=BaseUtil.getBaseInfoByParm("workflowname", "workflow_base", "id", workflowid, "");
|
||||
log.writeLog("---------------"+workflowname+"开始-------------requestId:" + requestid);
|
||||
try {
|
||||
RecordSet rs=new RecordSet();
|
||||
String mainid="";//主键ID
|
||||
//获取表名
|
||||
String tablename=BaseUtil.getBaseInfoByParm("tablename", "workflow_bill", "1", "1", " and id in (select formid from workflow_base where id="+workflowid+")");;
|
||||
String sql="select * from "+tablename+" where requestid="+requestid;
|
||||
rs.execute(sql);
|
||||
while(rs.next()){
|
||||
mainid=Util.null2String(rs.getString("id"));
|
||||
}
|
||||
double tdzdf=0;//团队招待费(报销明细)
|
||||
double khzdf=0;//客户招待费(报销明细)
|
||||
double tdzdf_dt2=0;//团队招待费(团队招待费明细)
|
||||
double khzdf_dt3=0;//客户招待费(客户招待费明细)
|
||||
//查询报销明细中是否存在团队招待费和客户招待费的类型
|
||||
sql="select bxlx1,sum(TO_NUMBER(replace(je,',',''))) as je from "+tablename+"_dt8 where mainid="+mainid+" and bxlx1 in ('3-05.02','3-05.03') group by bxlx1 ";
|
||||
rs.execute(sql);
|
||||
while(rs.next()){
|
||||
if("3-05.02".equals(rs.getString("bxlx1"))){
|
||||
khzdf=rs.getDouble("je");//客户招待费
|
||||
}else if("3-05.03".equals(rs.getString("bxlx1"))){
|
||||
tdzdf=rs.getDouble("je");//团队招待费
|
||||
}
|
||||
}
|
||||
//查询团队招待费明细中金额合计
|
||||
sql="select nvl(sum(TO_NUMBER(replace(je,',',''))),0) as je from "+tablename+"_dt2 where mainid="+mainid;
|
||||
rs.execute(sql);
|
||||
while(rs.next()){
|
||||
tdzdf_dt2=rs.getDouble("je");
|
||||
}
|
||||
//查询客户招待费明细中金额合计
|
||||
sql="select nvl(sum(TO_NUMBER(replace(je,',',''))),0) as je from "+tablename+"_dt3 where mainid="+mainid;
|
||||
rs.execute(sql);
|
||||
while(rs.next()){
|
||||
khzdf_dt3=rs.getDouble("je");
|
||||
}
|
||||
|
||||
String sftg="0";//流程是否可通过 0表示可通过 1表示不可通过
|
||||
String msg="";//提示信息
|
||||
|
||||
//团队招待费校验
|
||||
if(tdzdf!=tdzdf_dt2){
|
||||
sftg="1";//
|
||||
if(language==0||language==7){//简体
|
||||
msg+="报销明细中报销类型为【团队招待费】金额需与团队招待费明细中的金额合计相等;<br/>";//提示信息
|
||||
}else if(language==8){//英语
|
||||
msg+="报销明细中报销类型为【团队招待费】金额需与团队招待费明细中的金额合计相等;<br/>";//提示信息
|
||||
}else if(language==9){//繁体
|
||||
msg+="报销明细中报销类型为【团队招待费】金额需与团队招待费明细中的金额合计相等;<br/>";//提示信息
|
||||
}else if(language==22){//印尼语
|
||||
msg+="报销明细中报销类型为【团队招待费】金额需与团队招待费明细中的金额合计相等;<br/>";//提示信息
|
||||
}
|
||||
}
|
||||
//客户招待费校验
|
||||
if(khzdf!=khzdf_dt3){
|
||||
sftg="1";//
|
||||
if(language==0||language==7){//简体
|
||||
msg+="报销明细中报销类型为【客户招待费】金额需与客户招待费明细中的金额合计相等;<br/>";//提示信息
|
||||
}else if(language==8){//英语
|
||||
msg+="报销明细中报销类型为【客户招待费】金额需与客户招待费明细中的金额合计相等;<br/>";//提示信息
|
||||
}else if(language==9){//繁体
|
||||
msg+="报销明细中报销类型为【客户招待费】金额需与客户招待费明细中的金额合计相等;<br/>";//提示信息
|
||||
}else if(language==22){//印尼语
|
||||
msg+="报销明细中报销类型为【客户招待费】金额需与客户招待费明细中的金额合计相等;<br/>";//提示信息
|
||||
}
|
||||
}
|
||||
|
||||
//不通过则进行提醒,并阻止流程提交
|
||||
if("1".equals(sftg)){
|
||||
ri.getRequestManager().setMessage("111100");
|
||||
ri.getRequestManager().setMessagecontent(msg);
|
||||
return "0";
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
String error_msg="报销流程提交失败,错误信息为:------>"+e.toString();
|
||||
if(language==0||language==7){//简体
|
||||
|
||||
}else if(language==8){//英语
|
||||
error_msg="报销流程提交失败,错误信息为:------>"+e.toString();
|
||||
}else if(language==9){//繁体
|
||||
error_msg="报销流程提交失败,错误信息为:------>"+e.toString();
|
||||
}else if(language==22){//印尼语
|
||||
error_msg="报销流程提交失败,错误信息为:------>"+e.toString();
|
||||
}
|
||||
log.writeLog(error_msg);
|
||||
ri.getRequestManager().setMessage("111100");
|
||||
ri.getRequestManager().setMessagecontent(error_msg);
|
||||
return "0";
|
||||
}
|
||||
return SUCCESS;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,296 @@
|
|||
package com.jet.action;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.jet.util.InvokeHelper;
|
||||
|
||||
import weaver.conn.RecordSet;
|
||||
import weaver.general.BaseBean;
|
||||
import weaver.general.Util;
|
||||
import weaver.interfaces.workflow.action.Action;
|
||||
import weaver.soa.workflow.request.Cell;
|
||||
import weaver.soa.workflow.request.DetailTable;
|
||||
import weaver.soa.workflow.request.DetailTableInfo;
|
||||
import weaver.soa.workflow.request.MainTableInfo;
|
||||
import weaver.soa.workflow.request.Property;
|
||||
import weaver.soa.workflow.request.RequestInfo;
|
||||
import weaver.soa.workflow.request.Row;
|
||||
|
||||
public class CreateBxAP extends BaseBean implements Action{
|
||||
public String execute(RequestInfo request) {
|
||||
Logger log = Logger.getLogger(JSONObject.class);
|
||||
RecordSet urlre=new RecordSet();
|
||||
String urlsql="select * from uf_urlinfo where ms='model'";
|
||||
|
||||
urlre.execute(urlsql);
|
||||
String url="";
|
||||
String username="";
|
||||
String password1="";
|
||||
String dbid1="";
|
||||
String uuid1="";
|
||||
String password2="";
|
||||
while(urlre.next()){
|
||||
url=Util.null2String(urlre.getString("url"));
|
||||
username=Util.null2String(urlre.getString("username"));
|
||||
password1=Util.null2String(urlre.getString("password"));
|
||||
dbid1=Util.null2String(urlre.getString("dbid"));
|
||||
uuid1=Util.null2String(urlre.getString("uuid"));
|
||||
password2=Util.null2String(urlre.getString("password1"));
|
||||
}
|
||||
String baseis=username+":"+password1;
|
||||
|
||||
// TODO Auto-generated method stub
|
||||
SimpleDateFormat sim=new SimpleDateFormat("yyyy-MM-dd");
|
||||
String CurretDate=sim.format(new Date());
|
||||
String requestid=request.getRequestid();
|
||||
String sfxr="";//是否写入标识
|
||||
writeLog("CreateBxAP---->"+requestid);
|
||||
MainTableInfo MainTableInfo=request.getMainTableInfo();
|
||||
Property[] props=MainTableInfo.getProperty();
|
||||
String zt="";//账套
|
||||
String zz="";//组织
|
||||
String K3depCode="";//K3部门编号
|
||||
JSONObject MainJson=new JSONObject();
|
||||
JSONObject FBillTypeID=new JSONObject();
|
||||
FBillTypeID.put("FNumber", "YFD01_SYS");
|
||||
MainJson.put("FBillTypeID", FBillTypeID);//默认应付单
|
||||
MainJson.put("FDATE", CurretDate);//单据日期
|
||||
MainJson.put("FENDDATE_H", CurretDate);//到期日
|
||||
MainJson.put("FBUSINESSTYPE", "CG");
|
||||
MainJson.put("FMatchMethodID", "0");//核销方式
|
||||
MainJson.put("F_RTA_InvoiceNo", CurretDate+requestid+"66");//发票
|
||||
MainJson.put("F_RTA_BusinessType", "");
|
||||
//相关资料 json
|
||||
JSONObject FSUPPLIERID=new JSONObject();//供应商
|
||||
JSONObject FCURRENCYID=new JSONObject();//币别
|
||||
JSONObject FCURRENCYID2=new JSONObject();//币别2
|
||||
JSONObject FSETTLEORGID=new JSONObject();//结算组织
|
||||
JSONObject FTaxType =new JSONObject();//税务分类
|
||||
FTaxType.put("FNumber", "PKP");
|
||||
JSONObject FPAYORGID=new JSONObject();//付款组织
|
||||
MainJson.put("FSUPPLIERID", FSUPPLIERID);
|
||||
MainJson.put("FCURRENCYID", FCURRENCYID);
|
||||
MainJson.put("FSETTLEORGID", FSETTLEORGID);
|
||||
MainJson.put("FTaxType", FTaxType);
|
||||
MainJson.put("FPAYORGID", FPAYORGID);
|
||||
//初始化其他供应商信息
|
||||
JSONArray FsubHeadSuppilers=new JSONArray();
|
||||
JSONObject FsubHeadSuppiler=new JSONObject();
|
||||
MainJson.put("FsubHeadSuppiler", FsubHeadSuppiler);
|
||||
for(Property prop:props){
|
||||
String name=prop.getName();
|
||||
String value=prop.getValue();
|
||||
if("bxzje".equals(name)){//FALLAMOUNTFOR:合计金额
|
||||
MainJson.put("FALLAMOUNTFOR", value);//默认应付单
|
||||
writeLog("bxzje---->"+value);
|
||||
}
|
||||
if("gys".equals(name)){//FSUPPLIERID:供应商
|
||||
FSUPPLIERID.put("FNumber", value);
|
||||
JSONObject FORDERID=new JSONObject();
|
||||
FORDERID.put("FNumber", value);
|
||||
JSONObject FTRANSFERID=new JSONObject();
|
||||
FTRANSFERID.put("FNumber", value);
|
||||
JSONObject FChargeId=new JSONObject();
|
||||
FChargeId.put("FNumber", value);
|
||||
FsubHeadSuppiler.put("FEntryId", 0);
|
||||
FsubHeadSuppiler.put("FORDERID", FORDERID);
|
||||
FsubHeadSuppiler.put("FTRANSFERID", FTRANSFERID);
|
||||
FsubHeadSuppiler.put("FChargeId", FChargeId);
|
||||
//FsubHeadSuppilers.add(FsubHeadSuppiler);
|
||||
writeLog("gys---->"+value);
|
||||
}
|
||||
if("k3bmbh".equals(name)){//FPURCHASEDEPTID:采购组织
|
||||
//MainJson.put("FPURCHASEDEPTID", value);
|
||||
K3depCode=value;
|
||||
writeLog("k3bmbh---->"+value);
|
||||
}
|
||||
if("bz".equals(name)){//FCURRENCYID:币种
|
||||
FCURRENCYID.put("FNumber", value);//默认应付单
|
||||
FCURRENCYID2.put("FNumber", value);//默认应付单
|
||||
writeLog("bz---->"+value);
|
||||
}
|
||||
if("zz".equals(name)){//FSETTLEORGID:结算组织 FPAYORGID:付款组织
|
||||
FSETTLEORGID.put("FNumber", value);
|
||||
FPAYORGID.put("FNumber", value);
|
||||
zz=value;
|
||||
writeLog("zz---->"+value);
|
||||
}
|
||||
if("bxms".equals(name)){//FAP_Remark:备注
|
||||
MainJson.put("FAP_Remark", value);
|
||||
writeLog("bxms---->"+value);
|
||||
}
|
||||
if("sfxr".equals(name)){
|
||||
sfxr=value;
|
||||
writeLog("sfxr---->"+value);
|
||||
}
|
||||
if("zt".equals(name)){
|
||||
zt=value;
|
||||
}
|
||||
|
||||
}
|
||||
String K3bmID=getK3Departmet(K3depCode,zt,zz);//获取K3部门ID
|
||||
if("".equals(K3depCode)){
|
||||
request.getRequestManager().setMessageid("失败");
|
||||
request.getRequestManager().setMessage("失败");//提醒信息id
|
||||
request.getRequestManager().setMessagecontent("写入K3系统不成功:为获取采购组织");//提醒信息内容
|
||||
return FAILURE_AND_CONTINUE;
|
||||
}
|
||||
JSONObject FPURCHASEDEPTID=new JSONObject();
|
||||
FPURCHASEDEPTID.put("FNumber", K3depCode);
|
||||
MainJson.put("FPURCHASEDEPTID", FPURCHASEDEPTID);
|
||||
//初始化其他财务信息 FsubHeadFinc
|
||||
|
||||
JSONObject FsubHeadFinc=new JSONObject();
|
||||
//JSONObject FMAINBOOKSTDCURRID=new JSONObject();
|
||||
JSONObject FEXCHANGETYPE=new JSONObject();
|
||||
FEXCHANGETYPE.put("FNumber", "HLTX01_SYS");
|
||||
FsubHeadFinc.put("FEntryId", 0);
|
||||
FsubHeadFinc.put("FACCNTTIMEJUDGETIME", CurretDate);
|
||||
FsubHeadFinc.put("FMAINBOOKSTDCURRID", FCURRENCYID2);
|
||||
FsubHeadFinc.put("FExchangeRate", 1);
|
||||
FsubHeadFinc.put("FTaxAmountFor", MainJson.get("FALLAMOUNTFOR"));
|
||||
FsubHeadFinc.put("FNoTaxAmountFor", MainJson.get("FALLAMOUNTFOR"));
|
||||
MainJson.put("FsubHeadFinc", FsubHeadFinc);
|
||||
//拼接明细表数据
|
||||
JSONArray FEntityDetails=new JSONArray();
|
||||
JSONArray FEntityPlans=new JSONArray();
|
||||
MainJson.put("FEntityDetail", FEntityDetails) ;
|
||||
MainJson.put("FEntityPlan", FEntityPlans) ;
|
||||
JSONObject FEntityDetail=null;//new JSONObject();
|
||||
JSONObject FEntityPlan=null;
|
||||
FEntityPlan=new JSONObject();
|
||||
DetailTableInfo DetailTableInfo=request.getDetailTableInfo();
|
||||
DetailTable DetailTable=DetailTableInfo.getDetailTable(7);
|
||||
Row[] Rows=DetailTable.getRow();
|
||||
for(Row r:Rows){
|
||||
FEntityDetail=new JSONObject();
|
||||
|
||||
JSONObject FMATERIALID=new JSONObject();//物料
|
||||
JSONObject FPRICEUNITID=new JSONObject();//单位
|
||||
JSONObject FMATERIALID1=new JSONObject();//物料
|
||||
JSONObject FPRICEUNITID1=new JSONObject();//单位
|
||||
// FEntityPlan.put("FPRICEUNITID", FPRICEUNITID1);
|
||||
// FEntityPlan.put("FMATERIALID", FMATERIALID1);
|
||||
//FEntityPlan.put("FEntityPlan", CurretDate);
|
||||
FEntityDetail.put("FPriceQty","1");
|
||||
FEntityDetail.put("FBASICUNITQTY","1");
|
||||
|
||||
FPRICEUNITID.put("FNumber", "Pcs");
|
||||
FPRICEUNITID1.put("FNumber", "Pcs");
|
||||
|
||||
FEntityDetail.put("FPRICEUNITID", FPRICEUNITID);
|
||||
FEntityDetail.put("FMATERIALID", FMATERIALID);
|
||||
FEntityDetail.put("F_RTA_FakturPajakNo_d", "-");
|
||||
FEntityDetail.put("F_RTA_AccumulatedAmount", 0);
|
||||
Cell[] Cells=r.getCell();
|
||||
for(Cell Cell:Cells){
|
||||
String name=Cell.getName();
|
||||
String value=Cell.getValue();
|
||||
if("bxlx1".equals(name)){//物料编号
|
||||
FMATERIALID.put("FNumber", value);
|
||||
FMATERIALID1.put("FNumber", value);
|
||||
writeLog("bxlx1---->"+value);
|
||||
}
|
||||
if("je".equals(name)){//金额
|
||||
FEntityDetail.put("FPrice", value);
|
||||
FEntityDetail.put("FTaxPrice", value);
|
||||
FEntityDetail.put("FNoTaxAmountFor_D", value);
|
||||
FEntityDetail.put("FALLAMOUNTFOR_D", value);
|
||||
|
||||
writeLog("je---->"+value);
|
||||
}
|
||||
if("bz".equals(name)){//备注
|
||||
FEntityDetail.put("F_RTA_EntryRemarks", value);
|
||||
writeLog("bz---->"+value);
|
||||
}
|
||||
}
|
||||
FEntityDetails.add(FEntityDetail);
|
||||
|
||||
}
|
||||
FEntityPlan.put("FPAYRATE",100);
|
||||
FEntityPlan.put("FENDDATE", CurretDate);
|
||||
FEntityPlan.put("FPAYAMOUNTFOR", MainJson.get("FALLAMOUNTFOR"));
|
||||
FEntityPlan.put("FPAYAMOUNT", MainJson.get("FALLAMOUNTFOR"));
|
||||
FEntityPlan.put("FPRICE_P", MainJson.get("FALLAMOUNTFOR"));
|
||||
FEntityPlan.put("FQTY_P", 1);
|
||||
FEntityPlans.add(FEntityPlan);
|
||||
//数据提交
|
||||
writeLog("FEntityDetails---->"+FEntityDetails.toJSONString());
|
||||
writeLog("MainJson---->"+MainJson.toJSONString());
|
||||
JSONObject Model=new JSONObject();
|
||||
Model.put("NeedReturnFields", new String[]{"BillNo"});
|
||||
Model.put("IsAutoSubmitAndAudit", true);
|
||||
Model.put("Model", MainJson);
|
||||
|
||||
//数据写入
|
||||
writeLog("Model--->"+Model.toJSONString());
|
||||
if(Model!=null&&Model.size()>0&&("".equals(sfxr)||"1".equals(sfxr))){
|
||||
RecordSet updRec=new RecordSet();
|
||||
com.jet.util.InvokeHelper.POST_K3CloudURL="http://k3.jet.co.id:8880/k3cloud/";
|
||||
String dbid="5d48f604c8361e";//dbid1;//"5d48f604c8361e";//"5a964ecc967246";
|
||||
String uuid=uuid1;
|
||||
String password=password2;
|
||||
org.json.JSONObject resultjson=null;
|
||||
int lang=2052;
|
||||
try {
|
||||
boolean flag=InvokeHelper.Login(dbid, uuid, password, lang);
|
||||
//out.print(flag);
|
||||
if(flag){//登陆成功
|
||||
resultjson=com.jet.util.InvokeHelper.Save("AP_Payable",Model.toJSONString());
|
||||
boolean flag1=resultjson.getBoolean("flag");
|
||||
String resultstr=resultjson.getString("sResult");
|
||||
log.error("resultstr"+resultstr);
|
||||
if(flag1){
|
||||
JSONObject HAHA=JSONObject.parseObject(resultstr);
|
||||
JSONObject Result=HAHA.getJSONObject("Result");
|
||||
JSONObject ResponseStatus=Result.getJSONObject("ResponseStatus");
|
||||
boolean IsSuccess=ResponseStatus.getBoolean("IsSuccess");
|
||||
if(IsSuccess){
|
||||
JSONArray SuccessEntitys=ResponseStatus.getJSONArray("SuccessEntitys");
|
||||
String Number=SuccessEntitys.getJSONObject(0).getString("Number");
|
||||
updRec.execute("update formtable_main_22 set sfxr='0',yfdbh='"+Number+"' where requestid='"+requestid+"' ");
|
||||
|
||||
}else{
|
||||
//out.print("失败");
|
||||
request.getRequestManager().setMessageid("失败");
|
||||
request.getRequestManager().setMessage("失败");//提醒信息id
|
||||
request.getRequestManager().setMessagecontent("写入K3系统不成功,系统反馈信息如下:"+HAHA.toString());//提醒信息内容
|
||||
|
||||
return Action.FAILURE_AND_CONTINUE;
|
||||
}
|
||||
}else{
|
||||
//out.print("失败"+resultstr);
|
||||
request.getRequestManager().setMessageid("失败");
|
||||
request.getRequestManager().setMessage("失败");//提醒信息id
|
||||
request.getRequestManager().setMessagecontent("写入K3系统不成功,系统反馈信息如下:"+resultstr.toString());//提醒信息内容
|
||||
|
||||
return Action.FAILURE_AND_CONTINUE;
|
||||
}
|
||||
|
||||
}
|
||||
} catch (Exception e) {
|
||||
//TODO Auto-generated catch block
|
||||
log.error("AP_Payable--Exception"+e.getMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return SUCCESS;
|
||||
}
|
||||
//获取K3 部门ID
|
||||
public String getK3Departmet(String k3bm,String zt,String zz){
|
||||
String bmID="";
|
||||
RecordSet re=new RecordSet();
|
||||
String sql="select b.ENTRYID from uf_K3baseinfo a,uf_K3baseinfo_dt1 b where a.id=b.mainid and a.zt='"+zt+"' and a.lx='FFLEX5' and b.FORGNAME='"+zz+"' and bh='"+k3bm+"' ";
|
||||
writeLog("getK3Departmet--->"+sql);
|
||||
re.execute(sql);
|
||||
while(re.next()){
|
||||
bmID=re.getString("ENTRYID");
|
||||
}
|
||||
return bmID;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,266 @@
|
|||
package com.jet.action;
|
||||
|
||||
import java.util.*;
|
||||
import weaver.soa.workflow.request.RequestInfo;
|
||||
import weaver.workflow.action.BaseAction;
|
||||
import weaver.conn.RecordSet;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import weaver.hrm.HrmUserVarify;
|
||||
import weaver.hrm.User;
|
||||
import weaver.general.BaseBean;
|
||||
import weaver.general.Util;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.sql.Connection;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.Statement;
|
||||
import weaver.general.StaticObj;
|
||||
import weaver.interfaces.datasource.DataSource;
|
||||
import weaver.formmode.setup.ModeRightInfo;
|
||||
import java.sql.Connection;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Statement;
|
||||
import weaver.general.StaticObj;
|
||||
import weaver.interfaces.datasource.DataSource;
|
||||
import weaver.interfaces.workflow.action.Action;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.PrintWriter;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
import org.apache.http.Header;
|
||||
import org.apache.http.HttpResponse;
|
||||
import org.apache.http.HttpStatus;
|
||||
import org.apache.http.client.HttpClient;
|
||||
import org.apache.http.client.methods.HttpPost;
|
||||
import org.apache.http.entity.*;
|
||||
import org.apache.http.*;
|
||||
import org.apache.http.util.*;
|
||||
import org.apache.http.impl.client.DefaultHttpClient;
|
||||
import org.apache.http.params.CoreConnectionPNames;
|
||||
import java.util.UUID;
|
||||
import java.nio.charset.Charset;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import weaver.conn.RecordSetTrans;
|
||||
import java.io.PrintWriter;
|
||||
|
||||
public class CreateJD extends BaseAction{
|
||||
@Override
|
||||
public String execute(RequestInfo requestInfo) {
|
||||
// TODO Auto-generated method stub
|
||||
Logger log = Logger.getLogger(JSONObject.class);
|
||||
Map<String,String> Hswd=new HashMap<String,String>();//核算维度对照表
|
||||
Hswd.put("FFLEX4","gys");//供应商
|
||||
Hswd.put("FFLEX6","kh");//客户
|
||||
Hswd.put("FFLEX7","yg");//员工
|
||||
Hswd.put("FFLEX5","bm");//部门
|
||||
Hswd.put("FFLEX9","fyxm");//费用项目
|
||||
Hswd.put("FFLEX8","wl");//物料
|
||||
Hswd.put("FFLEX10","zc");//资产
|
||||
Hswd.put("FFLEX12","wlz");//物料组
|
||||
Hswd.put("FFLEX13","khz");//客户组
|
||||
|
||||
List<String> jlist=new ArrayList<String>();//借方
|
||||
List<String> dlist=new ArrayList<String>();//贷方
|
||||
String requestid=requestInfo.getRequestid();//
|
||||
String mainid="";//
|
||||
String zt="";//账套
|
||||
String zz="";//组织
|
||||
String zb="";//账薄
|
||||
String zzjdhl="";//做账节点汇率
|
||||
String bz="";//币种
|
||||
RecordSet re=new RecordSet();
|
||||
String jsql="";
|
||||
String dsql="";
|
||||
float zje=0.0f;
|
||||
String sql="select a.zzjdhl,a.bz,a.id,a.zt,a.zz,a.zb,sum(je) je,b.bxr,b.bxlx from formtable_main_22 a,formtable_main_22_dt8 b where a.id=b.mainid and a.requestid='"+requestid+"' group by a.zzjdhl,a.bz,a.id,a.zt,a.zz,a.zb,b.bxr,b.bxlx";
|
||||
log.error(requestid+"CreateJD"+sql);
|
||||
re.execute(sql);
|
||||
while(re.next()){
|
||||
mainid=Util.null2String(re.getString("id")).trim();
|
||||
zzjdhl=Util.null2String(re.getString("zzjdhl")).trim();
|
||||
if("".equals(zzjdhl.trim())){
|
||||
zzjdhl="1";
|
||||
}
|
||||
bz=Util.null2String(re.getString("bz")).trim();
|
||||
int xsw=getXsw(bz);
|
||||
zt=Util.null2String(re.getString("zt")).trim();
|
||||
zz=Util.null2String(re.getString("zz")).trim();
|
||||
zb=Util.null2String(re.getString("zb")).trim();
|
||||
String bxlx= re.getString("bxlx");//报销科目
|
||||
String je= Util.null2String(re.getString("je")).trim();//报销金额
|
||||
//je=getfloats(je,zzjdhl,xsw)+"";
|
||||
zje=getfloats1(je,zje+"",2);
|
||||
String FDIMENSION=getFzhx(bxlx,zt,zz,zb,Hswd);
|
||||
String accountname=getKmname(bxlx,zt,zz,zb);
|
||||
|
||||
jsql="insert into formtable_main_22_dt4(mainid,jfkmbm,jfkmmc,hswd,yje,zy)values("+mainid+",'"+bxlx+"','"+accountname+"','"+FDIMENSION+"',"+je+",'')";
|
||||
jlist.add(jsql);
|
||||
}
|
||||
if(jlist.size()>0){
|
||||
//插入贷方
|
||||
jlist.add("insert into formtable_main_22_dt5(mainid,dfkmbm,dfkmmc,hswd,yje,zy)values("+mainid+",'2000.01','AccountPayableIDR','',"+zje+",'')");
|
||||
}
|
||||
if(jlist.size()>0){
|
||||
log.error(jlist.toString());
|
||||
boolean flag=SynInsert1(jlist);
|
||||
if(!flag){
|
||||
requestInfo.getRequestManager().setMessageid("创建借贷失败");
|
||||
requestInfo.getRequestManager().setMessage("创建借贷失败");//提醒信息id
|
||||
requestInfo.getRequestManager().setMessagecontent("创建借贷失败");//提醒信息内容
|
||||
|
||||
return Action.FAILURE_AND_CONTINUE;
|
||||
}
|
||||
}
|
||||
return SUCCESS;
|
||||
}
|
||||
//获取赋值核算类型
|
||||
public String getFzhx(String km,String zt,String zz,String zb,Map<String,String> Hswd){
|
||||
String FDIMENSION="";//核算维度
|
||||
RecordSet re=new RecordSet();
|
||||
String sql="select b.FDIMENSION from uf_accountinfo a,uf_accountinfo_dt1 b where a.id=b.mainid and a.zt='"+zt+"' and b.FNUMBER='"+km+"' and b.forgnumber='"+zz+"' and FAcctBookNumber='"+zb+"' ";
|
||||
//out.print(sql);
|
||||
re.execute(sql);
|
||||
while(re.next()){
|
||||
String str=Util.null2String(re.getString("FDIMENSION")).trim() ;
|
||||
String[] FDIMENSIONs=str.split(",");
|
||||
for(String demo:FDIMENSIONs){
|
||||
if(demo!=null&&!"".equals(demo)){
|
||||
FDIMENSION=FDIMENSION+Hswd.get(FDIMENSION)+",";
|
||||
}
|
||||
}
|
||||
}
|
||||
return FDIMENSION;
|
||||
}
|
||||
//insert 事务
|
||||
public boolean SynInsert1(List<String> array){
|
||||
if(array==null||array.size()<=0){
|
||||
return false;
|
||||
}
|
||||
Logger log = Logger.getLogger(DataSource.class);
|
||||
RecordSetTrans RecordSetTrans=new RecordSetTrans();
|
||||
RecordSetTrans.setAutoCommit(false);
|
||||
boolean flag=true;
|
||||
|
||||
try{
|
||||
RecordSetTrans.setAutoCommit(false);
|
||||
// stmt = conn.createStatement();
|
||||
for(String str:array){
|
||||
//int index =RecordSetTrans.executeUpdate(str);
|
||||
flag=RecordSetTrans.executeSql(str);
|
||||
log.error("SynInsert--"+str);
|
||||
if(!flag){
|
||||
//flag=false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(!flag){//事务回滚
|
||||
RecordSetTrans.rollback();
|
||||
}else{
|
||||
RecordSetTrans.commit();
|
||||
}
|
||||
}catch(Exception e){
|
||||
log.error("SynInsert--Exception "+e.getMessage());
|
||||
flag=false;
|
||||
}
|
||||
|
||||
return flag;
|
||||
}
|
||||
//获取科目名称
|
||||
public String getKmname(String km,String zt,String zz,String zb){
|
||||
String FNAME="";//核算维度
|
||||
RecordSet re=new RecordSet();
|
||||
String sql="select b.FNAME from uf_accountinfo a,uf_accountinfo_dt1 b where a.id=b.mainid and a.zt='"+zt+"' and b.FNUMBER='"+km+"' and b.forgnumber='"+zz+"' and FAcctBookNumber='"+zb+"' ";
|
||||
re.execute(sql);
|
||||
while(re.next()){
|
||||
FNAME=Util.null2String(re.getString("FNAME"));
|
||||
}
|
||||
return FNAME;
|
||||
}
|
||||
//获取币种的小数位
|
||||
public int getXsw(String bz){
|
||||
int xsw=0;
|
||||
RecordSet re=new RecordSet();
|
||||
String sql="select * from uf_k3bz where bh='"+bz+"'";
|
||||
re.execute(sql);
|
||||
while(re.next()){
|
||||
xsw=Integer.parseInt(Util.null2o(re.getString("xsw"))) ;
|
||||
}
|
||||
return xsw;
|
||||
}
|
||||
|
||||
//浮点型转换
|
||||
public static float getfloats(String demo,String demo1,int len){
|
||||
Logger log = Logger.getLogger(BigDecimal.class);
|
||||
if(len==0){
|
||||
len=0;
|
||||
}
|
||||
String str=Util.null2String(demo);
|
||||
String str1=Util.null2String(demo1);
|
||||
if("".equals(str)||"".equals(str.trim())||"null".equalsIgnoreCase(str.trim())){
|
||||
return 0;
|
||||
}
|
||||
if("".equals(str1)||"".equals(str.trim())||"null".equalsIgnoreCase(str1.trim())){
|
||||
str1="1";
|
||||
}
|
||||
float fl=0.0f;
|
||||
//String str=Util.null2String(demo);
|
||||
try{
|
||||
if(str.trim().length()>0){
|
||||
BigDecimal b1 = new BigDecimal(str.trim());
|
||||
BigDecimal b2 = new BigDecimal(str1.trim());
|
||||
BigDecimal b3=b1.multiply(b2);
|
||||
//System.out.println(b1.setScale(2,BigDecimal.ROUND_HALF_UP));
|
||||
fl=b3.setScale(len,BigDecimal.ROUND_HALF_UP).floatValue();
|
||||
}
|
||||
log.error("getfloats"+fl);
|
||||
}catch(Exception e){
|
||||
log.error(demo+"getfloats异常"+e.getMessage());
|
||||
}
|
||||
return fl;
|
||||
}
|
||||
|
||||
|
||||
//浮点型转换
|
||||
public static float getfloats1(String demo,String demo1,int len){
|
||||
Logger log = Logger.getLogger(BigDecimal.class);
|
||||
if(len==0){
|
||||
len=0;
|
||||
}
|
||||
String str=Util.null2String(demo);
|
||||
String str1=Util.null2String(demo1);
|
||||
if("".equals(str)||"".equals(str.trim())||"null".equalsIgnoreCase(str.trim())){
|
||||
str="0";
|
||||
}
|
||||
if("".equals(str1)||"".equals(str.trim())||"null".equalsIgnoreCase(str1.trim())){
|
||||
str1="0";
|
||||
}
|
||||
float fl=0.0f;
|
||||
//String str=Util.null2String(demo);
|
||||
try{
|
||||
if(str.trim().length()>0){
|
||||
BigDecimal b1 = new BigDecimal(str.trim());
|
||||
BigDecimal b2 = new BigDecimal(str1.trim());
|
||||
BigDecimal b3=b1.add(b2);
|
||||
//System.out.println(b1.setScale(2,BigDecimal.ROUND_HALF_UP));
|
||||
fl=b3.setScale(len,BigDecimal.ROUND_HALF_UP).floatValue();
|
||||
}
|
||||
log.error("getfloats"+fl);
|
||||
}catch(Exception e){
|
||||
log.error(demo+"getfloats异常"+e.getMessage());
|
||||
}
|
||||
return fl;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,398 @@
|
|||
package com.jet.action;
|
||||
|
||||
import java.util.*;
|
||||
import weaver.soa.workflow.request.RequestInfo;
|
||||
import weaver.workflow.action.BaseAction;
|
||||
import weaver.conn.RecordSet;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import weaver.general.Util;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.sql.Connection;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.Statement;
|
||||
import weaver.general.StaticObj;
|
||||
import weaver.interfaces.datasource.DataSource;
|
||||
import weaver.formmode.setup.ModeRightInfo;
|
||||
import java.sql.Connection;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Statement;
|
||||
import weaver.general.StaticObj;
|
||||
import weaver.interfaces.datasource.DataSource;
|
||||
import weaver.interfaces.workflow.action.Action;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.PrintWriter;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
import org.apache.http.Header;
|
||||
import org.apache.http.HttpResponse;
|
||||
import org.apache.http.HttpStatus;
|
||||
import org.apache.http.client.HttpClient;
|
||||
import org.apache.http.client.methods.HttpPost;
|
||||
import org.apache.http.entity.*;
|
||||
import org.apache.http.*;
|
||||
import org.apache.http.util.*;
|
||||
import org.apache.http.impl.client.DefaultHttpClient;
|
||||
import org.apache.http.params.CoreConnectionPNames;
|
||||
import java.util.UUID;
|
||||
import java.nio.charset.Charset;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import weaver.conn.RecordSetTrans;
|
||||
import java.io.PrintWriter;
|
||||
|
||||
public class CreateJkJD extends BaseAction{
|
||||
@Override
|
||||
public String execute(RequestInfo requestInfo) {
|
||||
// TODO Auto-generated method stub
|
||||
//创建借款的借贷方
|
||||
//0:贷方现金
|
||||
//1:借方还款(职员)
|
||||
//2:借方借款(职员)
|
||||
Logger log = Logger.getLogger(JSONObject.class);
|
||||
Map<String,String> Hswd=new HashMap<String,String>();//核算维度对照表
|
||||
Hswd.put("FFLEX4","gys");//供应商
|
||||
Hswd.put("FFLEX6","kh");//客户
|
||||
Hswd.put("FFLEX7","yg");//员工
|
||||
Hswd.put("FFLEX5","bm");//部门
|
||||
Hswd.put("FFLEX9","fyxm");//费用项目
|
||||
Hswd.put("FFLEX8","wl");//物料
|
||||
Hswd.put("FFLEX10","zc");//资产
|
||||
Hswd.put("FFLEX12","wlz");//物料组
|
||||
Hswd.put("FFLEX13","khz");//客户组
|
||||
RecordSet urlre=new RecordSet();
|
||||
String urlsql="select * from uf_urlinfo ";
|
||||
|
||||
String url="";
|
||||
String username="";
|
||||
String password="";
|
||||
urlre.execute(urlsql);
|
||||
while(urlre.next()){
|
||||
url=Util.null2String(urlre.getString("url"));
|
||||
username=Util.null2String(urlre.getString("username"));
|
||||
password=Util.null2String(urlre.getString("password"));
|
||||
}
|
||||
List<String> jlist=new ArrayList<String>();//借方
|
||||
List<String> dlist=new ArrayList<String>();//贷方
|
||||
String requestid=requestInfo.getRequestid();//
|
||||
String mainid="";//
|
||||
String zt="";//账套
|
||||
String zz="";//组织
|
||||
String zb="";//账薄
|
||||
String zzjdhl="";//做账节点汇率
|
||||
String bz="";//币种
|
||||
String fkyh="";//付款银行
|
||||
String je="";//借款金额
|
||||
String jklx="";//借款类型
|
||||
String dls="";//代理商
|
||||
String emp="";//代理商
|
||||
RecordSet re=new RecordSet();
|
||||
String jsql="";
|
||||
String dsql="";
|
||||
String sql="select * from formtable_main_24 where requestid='"+requestid+"'";
|
||||
log.error(requestid+"CreateJkJD"+sql);
|
||||
re.execute(sql);
|
||||
while(re.next()){
|
||||
emp=Util.null2String(re.getString("emp")).trim();
|
||||
mainid=Util.null2String(re.getString("id")).trim();
|
||||
zz=Util.null2String(re.getString("zz")).trim();//组织
|
||||
zt=Util.null2String(re.getString("zt")).trim();//账套
|
||||
zb=Util.null2String(re.getString("zb")).trim();//账薄
|
||||
|
||||
fkyh=Util.null2String(re.getString("fkyxzh")).trim();//付款银行
|
||||
je=Util.null2String(re.getString("jkje")).trim();//金额
|
||||
jklx=Util.null2String(re.getString("jklx")).trim();//借款类型
|
||||
dls=Util.null2String(re.getString("dls")).trim();//代理商
|
||||
}
|
||||
//判定借方科目
|
||||
String jfkm="";//借方科目
|
||||
String jfkmDesc="";//借方科目
|
||||
String dfkm="";//贷方科目
|
||||
String dfkmDesc="";//贷方科目
|
||||
if("0".equals(jklx)){//个人
|
||||
jfkm=SpelKm(zt,zz,zb,"2");
|
||||
if("".equals(fkyh)){//现金
|
||||
dfkm=SpelKm(zt,zz,zb,"0");
|
||||
}else{//转账
|
||||
dfkm=fkyh;
|
||||
}
|
||||
}else{//代理商
|
||||
if("".equals(fkyh)){//现金
|
||||
dfkm=SpelKm(zt,zz,zb,"0");
|
||||
}else{//转账
|
||||
dfkm=fkyh;
|
||||
}
|
||||
//通过接口 获取贷方科目
|
||||
if(!"".equals(dls)){
|
||||
String result=sendGet(url+"CusGlbalance/"+dls,"",username+":"+password);
|
||||
//out.print(result);
|
||||
Map<String,String> map=getJSONToMap(result);
|
||||
jfkm=Util.null2String(map.get("FAcctNumber"));
|
||||
}
|
||||
}
|
||||
if(!"".equals(jfkm)){
|
||||
jfkmDesc=getKmname(jfkm,zt,zz,zb);
|
||||
}
|
||||
if(!"".equals(dfkm)){
|
||||
dfkmDesc=getKmname(dfkm,zt,zz,zb);
|
||||
}
|
||||
if("0".equals(jklx)){
|
||||
dls="";
|
||||
}
|
||||
jlist.add("insert into formtable_main_24_dt1(mainid,jfkmbm,jfkmmc,jfje,kh,yg)values('"+mainid+"','"+jfkm+"','"+jfkmDesc+"','"+je+"','"+dls+"','"+emp+"')");
|
||||
jlist.add("insert into formtable_main_24_dt2(mainid,dfkmbm,dfkmmc,dfje)values('"+mainid+"','"+dfkm+"','"+dfkmDesc+"','"+je+"')");
|
||||
if(jlist.size()>0){
|
||||
log.error(jlist.toString());
|
||||
boolean flag=SynInsert1(jlist);
|
||||
if(!flag){
|
||||
requestInfo.getRequestManager().setMessageid("创建借贷失败");
|
||||
requestInfo.getRequestManager().setMessage("创建借贷失败");//提醒信息id
|
||||
requestInfo.getRequestManager().setMessagecontent("创建借贷失败");//提醒信息内容
|
||||
|
||||
return Action.FAILURE_AND_CONTINUE;
|
||||
}
|
||||
}
|
||||
return super.execute(requestInfo);
|
||||
}
|
||||
//将JSON 解析成 Map
|
||||
public Map<String,String> getJSONToMap(String str){
|
||||
Map<String,String> map=new HashMap<String,String>();
|
||||
try{
|
||||
JSONArray jsons=JSONObject.parseArray(str);
|
||||
if(jsons!=null&&jsons.size()>0){
|
||||
JSONObject json=(JSONObject)jsons.get(0);
|
||||
Set<String> set=json.keySet();
|
||||
for(String demo:set){
|
||||
map.put(demo,Util.null2String(json.getString(demo)));
|
||||
}
|
||||
}
|
||||
}catch(Exception e){
|
||||
|
||||
}
|
||||
return map;
|
||||
}
|
||||
//取特殊科目编号
|
||||
public String SpelKm(String zt,String zz,String zb,String lx){
|
||||
Logger log = Logger.getLogger(BigDecimal.class);
|
||||
RecordSet re=new RecordSet();
|
||||
String km="";//科目
|
||||
re.execute("select * from uf_k3tskm a,uf_k3tskm_dt1 b where a.id=b.mainid and zt='"+zt+"' and zz='"+zz+"' and zb='"+zb+"' and lx='"+lx+"'");
|
||||
while(re.next()){
|
||||
km=re.getString("km");
|
||||
}
|
||||
return km;
|
||||
}
|
||||
//获取赋值核算类型
|
||||
public String getFzhx(String km,String zt,String zz,String zb,Map<String,String> Hswd){
|
||||
String FDIMENSION="";//核算维度
|
||||
RecordSet re=new RecordSet();
|
||||
String sql="select b.FDIMENSION from uf_accountinfo a,uf_accountinfo_dt1 b where a.id=b.mainid and a.zt='"+zt+"' and b.FNUMBER='"+km+"' and b.forgnumber='"+zz+"' and FAcctBookNumber='"+zb+"' ";
|
||||
//out.print(sql);
|
||||
re.execute(sql);
|
||||
while(re.next()){
|
||||
String str=Util.null2String(re.getString("FDIMENSION")).trim() ;
|
||||
String[] FDIMENSIONs=str.split(",");
|
||||
for(String demo:FDIMENSIONs){
|
||||
if(demo!=null&&!"".equals(demo)){
|
||||
FDIMENSION=FDIMENSION+Hswd.get(FDIMENSION)+",";
|
||||
}
|
||||
}
|
||||
}
|
||||
return FDIMENSION;
|
||||
}
|
||||
//insert 事务
|
||||
public boolean SynInsert1(List<String> array){
|
||||
if(array==null||array.size()<=0){
|
||||
return false;
|
||||
}
|
||||
Logger log = Logger.getLogger(DataSource.class);
|
||||
RecordSetTrans RecordSetTrans=new RecordSetTrans();
|
||||
RecordSetTrans.setAutoCommit(false);
|
||||
boolean flag=true;
|
||||
|
||||
try{
|
||||
RecordSetTrans.setAutoCommit(false);
|
||||
// stmt = conn.createStatement();
|
||||
for(String str:array){
|
||||
//int index =RecordSetTrans.executeUpdate(str);
|
||||
flag=RecordSetTrans.executeSql(str);
|
||||
log.error("SynInsert--"+str);
|
||||
if(!flag){
|
||||
//flag=false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(!flag){//事务回滚
|
||||
RecordSetTrans.rollback();
|
||||
}else{
|
||||
RecordSetTrans.commit();
|
||||
}
|
||||
}catch(Exception e){
|
||||
log.error("SynInsert--Exception "+e.getMessage());
|
||||
flag=false;
|
||||
}
|
||||
|
||||
return flag;
|
||||
}
|
||||
//获取科目名称
|
||||
public String getKmname(String km,String zt,String zz,String zb){
|
||||
String FNAME="";//核算维度
|
||||
RecordSet re=new RecordSet();
|
||||
String sql="select b.FNAME from uf_accountinfo a,uf_accountinfo_dt1 b where a.id=b.mainid and a.zt='"+zt+"' and b.FNUMBER='"+km+"' and b.forgnumber='"+zz+"' and FAcctBookNumber='"+zb+"' ";
|
||||
re.execute(sql);
|
||||
while(re.next()){
|
||||
FNAME=Util.null2String(re.getString("FNAME"));
|
||||
}
|
||||
return FNAME;
|
||||
}
|
||||
//获取币种的小数位
|
||||
public int getXsw(String bz){
|
||||
int xsw=0;
|
||||
RecordSet re=new RecordSet();
|
||||
String sql="select * from uf_k3bz where bh='"+bz+"'";
|
||||
re.execute(sql);
|
||||
while(re.next()){
|
||||
xsw=Integer.parseInt(Util.null2o(re.getString("xsw"))) ;
|
||||
}
|
||||
return xsw;
|
||||
}
|
||||
|
||||
//浮点型转换
|
||||
public static float getfloats(String demo,String demo1,int len){
|
||||
Logger log = Logger.getLogger(BigDecimal.class);
|
||||
if(len==0){
|
||||
len=0;
|
||||
}
|
||||
String str=Util.null2String(demo);
|
||||
String str1=Util.null2String(demo1);
|
||||
if("".equals(str)||"".equals(str.trim())||"null".equalsIgnoreCase(str.trim())){
|
||||
return 0;
|
||||
}
|
||||
if("".equals(str1)||"".equals(str.trim())||"null".equalsIgnoreCase(str1.trim())){
|
||||
str1="1";
|
||||
}
|
||||
float fl=0.0f;
|
||||
//String str=Util.null2String(demo);
|
||||
try{
|
||||
if(str.trim().length()>0){
|
||||
BigDecimal b1 = new BigDecimal(str.trim());
|
||||
BigDecimal b2 = new BigDecimal(str1.trim());
|
||||
BigDecimal b3=b1.multiply(b2);
|
||||
//System.out.println(b1.setScale(2,BigDecimal.ROUND_HALF_UP));
|
||||
fl=b3.setScale(len,BigDecimal.ROUND_HALF_UP).floatValue();
|
||||
}
|
||||
log.error("getfloats"+fl);
|
||||
}catch(Exception e){
|
||||
log.error(demo+"getfloats异常"+e.getMessage());
|
||||
}
|
||||
return fl;
|
||||
}
|
||||
|
||||
|
||||
//浮点型转换
|
||||
public static float getfloats1(String demo,String demo1,int len){
|
||||
Logger log = Logger.getLogger(BigDecimal.class);
|
||||
if(len==0){
|
||||
len=0;
|
||||
}
|
||||
String str=Util.null2String(demo);
|
||||
String str1=Util.null2String(demo1);
|
||||
if("".equals(str)||"".equals(str.trim())||"null".equalsIgnoreCase(str.trim())){
|
||||
str="0";
|
||||
}
|
||||
if("".equals(str1)||"".equals(str.trim())||"null".equalsIgnoreCase(str1.trim())){
|
||||
str1="0";
|
||||
}
|
||||
float fl=0.0f;
|
||||
//String str=Util.null2String(demo);
|
||||
try{
|
||||
if(str.trim().length()>0){
|
||||
BigDecimal b1 = new BigDecimal(str.trim());
|
||||
BigDecimal b2 = new BigDecimal(str1.trim());
|
||||
BigDecimal b3=b1.add(b2);
|
||||
//System.out.println(b1.setScale(2,BigDecimal.ROUND_HALF_UP));
|
||||
fl=b3.setScale(len,BigDecimal.ROUND_HALF_UP).floatValue();
|
||||
}
|
||||
log.error("getfloats"+fl);
|
||||
}catch(Exception e){
|
||||
log.error(demo+"getfloats异常"+e.getMessage());
|
||||
}
|
||||
return fl;
|
||||
}
|
||||
public static String sendGet(String url, String param,String basis) {
|
||||
String result = "";
|
||||
InputStream in = null;
|
||||
try {
|
||||
String urlNameString = url ;
|
||||
URL realUrl = new URL(urlNameString);
|
||||
URLConnection connection = realUrl.openConnection();
|
||||
String auth="JNT:JNT2019";
|
||||
String code = new sun.misc.BASE64Encoder().encode(auth.getBytes());
|
||||
connection.setRequestProperty("Authorization", "Basic " + code);
|
||||
connection.connect();
|
||||
Map<String, List<String>> map = connection.getHeaderFields();
|
||||
|
||||
|
||||
for (String key : map.keySet()) {
|
||||
System.out.println(key + "--->" + map.get(key));
|
||||
}
|
||||
//接收核心返回过来的数据 xml 需要解析
|
||||
in =connection.getInputStream();
|
||||
byte[] b =getBytes(in);
|
||||
if(b.length>0){
|
||||
result=new String(b);
|
||||
}
|
||||
System.out.println(b.length);
|
||||
} catch (Exception e) {
|
||||
|
||||
System.out.println(e.getMessage());
|
||||
e.printStackTrace();
|
||||
}finally {
|
||||
try {
|
||||
if (in != null) {
|
||||
in.close();
|
||||
}
|
||||
} catch (Exception e2) {
|
||||
System.out.println(e2.getMessage());
|
||||
e2.printStackTrace();
|
||||
}
|
||||
}
|
||||
//System.out.println("de"+result);
|
||||
return result;
|
||||
}
|
||||
public static byte[] getBytes(InputStream fis){
|
||||
Logger log = Logger.getLogger(Logger.class);
|
||||
byte[] buffer = null;
|
||||
try {
|
||||
//File file = new File(filePath);
|
||||
//FileInputStream fis = new FileInputStream(file);
|
||||
ByteArrayOutputStream bos = new ByteArrayOutputStream(1000);
|
||||
byte[] b = new byte[10000];
|
||||
int n;
|
||||
while ((n = fis.read(b)) != -1) {
|
||||
bos.write(b, 0, n);
|
||||
}
|
||||
fis.close();
|
||||
bos.close();
|
||||
buffer = bos.toByteArray();
|
||||
} catch (FileNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
System.out.println("buffer--->"+buffer.length);
|
||||
return buffer;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,319 @@
|
|||
package com.jet.action;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import kingdee.bos.webapi.client.K3CloudApiClient;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.alibaba.fastjson.serializer.SerializerFeature;
|
||||
import com.jet.k3.K3Connect;
|
||||
|
||||
import weaver.conn.RecordSet;
|
||||
import weaver.general.BaseBean;
|
||||
import weaver.general.Util;
|
||||
import weaver.interfaces.workflow.action.Action;
|
||||
import weaver.soa.workflow.request.RequestInfo;
|
||||
import selfdev.util.base.BaseUtil;
|
||||
import selfdev.util.base.TimeCommonUtil;
|
||||
import selfdev.util.log.LogTool;
|
||||
|
||||
/**
|
||||
* 付款申请流程在AP付款节点提交时将数据写入K3生成付款单
|
||||
* @author KangMD
|
||||
* 2019-11-29
|
||||
*/
|
||||
public class CreateK3PayBillAction extends BaseBean implements Action {
|
||||
|
||||
public String execute(RequestInfo ri) {
|
||||
LogTool log=new LogTool("/log/selfdev/action", false);
|
||||
//获取requestid
|
||||
String requestid=ri.getRequestid();
|
||||
String workflowid=ri.getWorkflowid();
|
||||
//获取用户语言
|
||||
int language=ri.getRequestManager().getUser().getLanguage();
|
||||
log.writeLog("language---------->"+language);
|
||||
String workflowname=BaseUtil.getBaseInfoByParm("workflowname", "workflow_base", "id", workflowid, "");
|
||||
log.writeLog("---------------"+workflowname+"开始写入K3生成付款单-------------requestId:" + requestid);
|
||||
//获取表名
|
||||
String tablename=BaseUtil.getBaseInfoByParm("tablename", "workflow_bill", "1", "1", " and id in (select formid from workflow_base where id="+workflowid+")");;
|
||||
RecordSet rs=new RecordSet();
|
||||
try {
|
||||
//获取当前系统日期
|
||||
String nowDate=TimeCommonUtil.obtainDate(0).substring(0,10);
|
||||
String mainid="";//主键ID
|
||||
String fkfs="";//付款方式
|
||||
String gysmc="";//供应商名称
|
||||
String gysmc2="";//供应商名称(无合同)
|
||||
String fphm="";//发票号码
|
||||
String fksm="";//付款说明
|
||||
String zfrq="";//支付日期
|
||||
String sfyht="";//是否有合同
|
||||
double bcfkje=0;//本次付款金额
|
||||
double bcfkje2=0;//本次付款金额(无合同)
|
||||
String bz="";//币种
|
||||
String zz="";//组织
|
||||
String k3yfdh="";//K3应付单号
|
||||
String fkyxzh="";//付款银行账号
|
||||
double fpcfkje=0;//分批次付款金额
|
||||
String sfpcfk="";//是否批次付款
|
||||
double pcyfkzje=0;//批次已付款总金额
|
||||
String htxx="";//相关合同
|
||||
String sql="select * from "+tablename+" where requestid="+requestid;
|
||||
rs.execute(sql);
|
||||
while(rs.next()){
|
||||
mainid=Util.null2String(rs.getString("id"));
|
||||
fkfs=Util.null2String(rs.getString("fkfs"));
|
||||
gysmc=Util.null2String(rs.getString("gysmc"));
|
||||
gysmc2=Util.null2String(rs.getString("gysmc2"));
|
||||
fphm=Util.null2String(rs.getString("fphm"));
|
||||
fksm=Util.null2String(rs.getString("fksm"));
|
||||
zfrq=Util.null2String(rs.getString("zfrq"));
|
||||
sfyht=Util.null2String(rs.getString("sfyht"));
|
||||
bcfkje=Double.parseDouble(Util.null2o(rs.getString("bcfkje")).replaceAll(",", ""));
|
||||
bcfkje2=Double.parseDouble(Util.null2o(rs.getString("bcfkje2")).replaceAll(",", ""));
|
||||
bz=Util.null2String(rs.getString("bz"));
|
||||
zz=Util.null2String(rs.getString("zz"));
|
||||
k3yfdh=Util.null2String(rs.getString("k3yfdh"));
|
||||
fkyxzh=Util.null2String(rs.getString("fkyxzh"));
|
||||
fpcfkje=Double.parseDouble(Util.null2o(rs.getString("fpcfkje")).replaceAll(",", ""));
|
||||
sfpcfk=Util.null2String(rs.getString("sfpcfk"));
|
||||
htxx=Util.null2String(rs.getString("htxx"));
|
||||
pcyfkzje=Double.parseDouble(Util.null2o(rs.getString("pcyfkzje")).replaceAll(",", ""));
|
||||
}
|
||||
//没有合同
|
||||
if("1".equals(sfyht)){
|
||||
gysmc=gysmc2;
|
||||
bcfkje=bcfkje2;
|
||||
}
|
||||
//付款方式
|
||||
if("0".equals(fkfs)){//银行
|
||||
fkfs="JSFS03_SYS";
|
||||
}else{
|
||||
fkfs="JSFS01_SYS";//现金
|
||||
}
|
||||
|
||||
String msg="";
|
||||
double je_k3=0;//传入K3金额
|
||||
DecimalFormat df=new DecimalFormat( "###############0.00 ");// 16位整数位,两小数位
|
||||
//本流程还需要付款金额=流程中本次付款金额-批次已付款总金额
|
||||
double blchxfkje=bcfkje-pcyfkzje;
|
||||
if("0".equals(sfpcfk)){//批次付款,则取输入的分批次付款金额
|
||||
if(fpcfkje>blchxfkje){
|
||||
msg="本流程需要付款金额"+df.format(bcfkje)+",批次已付款总金额"+df.format(pcyfkzje)+",当前批次付款金额"+df.format(fpcfkje)+",已超出剩余未付款金额"+df.format(blchxfkje);
|
||||
//将错误信息更新至表单字段中
|
||||
rs.execute("update "+tablename+" set sfcgsck3yfd='1',k3jkfhxx='"+msg.replaceAll("'", "''")+"' where requestid="+requestid);
|
||||
//写入K3失败则进行提醒,并阻止流程提交
|
||||
ri.getRequestManager().setMessage("111100");
|
||||
ri.getRequestManager().setMessagecontent(msg);
|
||||
return "0";
|
||||
}
|
||||
je_k3=fpcfkje;
|
||||
}else{//全部付款
|
||||
je_k3=blchxfkje;
|
||||
}
|
||||
double pcyfkzje_new=pcyfkzje+je_k3;//批次已付款金额(本次写入K3之后)
|
||||
|
||||
//***************************************拼接K3 Cloud付款单所需的JSON字符串***********************************************//
|
||||
Map<String,Object> data=new HashMap<String,Object>();
|
||||
|
||||
Map<String,Object> Model=new HashMap<String,Object>();
|
||||
//单据类型(必填项)--------默认为采购业务付款单FKDLX01_SYS
|
||||
Map<String,Object> FBillTypeID=new HashMap<String,Object>();
|
||||
FBillTypeID.put("FNUMBER", "FKDLX01_SYS");
|
||||
Model.put("FBillTypeID", FBillTypeID);
|
||||
//业务日期(必填项)--------默认为当前系统日期
|
||||
Model.put("FDATE", nowDate);
|
||||
//往来单位类型,默认为供应商
|
||||
Model.put("FCONTACTUNITTYPE", "BD_Supplier");
|
||||
//往来单位(必填项)--------
|
||||
Map<String,Object> FCONTACTUNIT=new HashMap<String,Object>();
|
||||
FCONTACTUNIT.put("FNUMBER", gysmc);
|
||||
Model.put("FCONTACTUNIT", FCONTACTUNIT);
|
||||
|
||||
//收款单位类型,默认为供应商
|
||||
Model.put("FRECTUNITTYPE", "BD_Supplier");
|
||||
//收款单位(必填项)--------
|
||||
Map<String,Object> FRECTUNIT=new HashMap<String,Object>();
|
||||
FRECTUNIT.put("FNUMBER", gysmc);
|
||||
Model.put("FRECTUNIT", FRECTUNIT);
|
||||
|
||||
//币别(必填项)--------
|
||||
Map<String,Object> FCURRENCYID=new HashMap<String,Object>();
|
||||
FCURRENCYID.put("FNUMBER", bz);
|
||||
Model.put("FCURRENCYID", FCURRENCYID);
|
||||
Model.put("FEXCHANGERATE", 1.0);//汇率
|
||||
Model.put("FSETTLERATE", 1.0);//结算汇率
|
||||
|
||||
//采购部门**************
|
||||
Map<String,Object> FPURCHASEDEPTID=new HashMap<String,Object>();
|
||||
FPURCHASEDEPTID.put("FNUMBER", "BM000001");
|
||||
Model.put("FPURCHASEDEPTID", FPURCHASEDEPTID);
|
||||
|
||||
//结算组织(必填项)----
|
||||
Map<String,Object> FSETTLEORGID=new HashMap<String,Object>();
|
||||
FSETTLEORGID.put("FNumber", zz);
|
||||
Model.put("FSETTLEORGID", FSETTLEORGID);//结算组织(必填项)----
|
||||
//采购组织
|
||||
Model.put("FPURCHASEORGID", FSETTLEORGID);
|
||||
//备注
|
||||
Model.put("FREMARK", fksm);
|
||||
//期望付款日期
|
||||
Model.put("FBookingDate", nowDate);
|
||||
Model.put("FDOCUMENTSTATUS", "Z");//单据状态
|
||||
Model.put("FCancelStatus", "A");//作废状态(必填项)----默认为A
|
||||
//结算组织
|
||||
Model.put("FPAYORGID", FSETTLEORGID);
|
||||
//结算币别
|
||||
Model.put("FSETTLECUR", FCURRENCYID);
|
||||
//结算本位币
|
||||
Model.put("FSETTLEMAINBOOKID", FCURRENCYID);
|
||||
|
||||
//-----------------付款单明细 start-----------------//
|
||||
List<Map<String,Object>> FPAYBILLENTRY=new ArrayList<Map<String,Object>>();
|
||||
//定义一行明细
|
||||
Map<String,Object> PAYBILLENTRY=new HashMap<String, Object>();
|
||||
//结算方式
|
||||
Map<String,Object> FSETTLETYPEID=new HashMap<String,Object>();
|
||||
FSETTLETYPEID.put("FNUMBER", fkfs);
|
||||
PAYBILLENTRY.put("FSETTLETYPEID", FSETTLETYPEID);
|
||||
|
||||
//付款用途,默认为SFKYT08_SYS采购付款
|
||||
Map<String,Object> FPURPOSEID=new HashMap<String,Object>();
|
||||
FPURPOSEID.put("FNUMBER", "SFKYT08_SYS");
|
||||
PAYBILLENTRY.put("FPURPOSEID", FPURPOSEID);
|
||||
|
||||
PAYBILLENTRY.put("FPAYTOTALAMOUNTFOR", je_k3);//表体-应付金额
|
||||
PAYBILLENTRY.put("FPAYAMOUNTFOR_E", je_k3);//付款金额
|
||||
PAYBILLENTRY.put("FSETTLEPAYAMOUNTFOR", je_k3);//折后金额
|
||||
PAYBILLENTRY.put("FREALPAYAMOUNTFOR_D", je_k3);//表体-实付金额
|
||||
//我方银行账号
|
||||
Map<String,Object> FACCOUNTID=new HashMap<String,Object>();
|
||||
FACCOUNTID.put("FNUMBER", fkyxzh);
|
||||
PAYBILLENTRY.put("FACCOUNTID", FACCOUNTID);
|
||||
|
||||
PAYBILLENTRY.put("FPAYAMOUNT_E", je_k3);//付款金额本位币
|
||||
PAYBILLENTRY.put("FPOSTDATE", nowDate);//登账日期
|
||||
PAYBILLENTRY.put("FRuZhangType", "1");//入账类型
|
||||
PAYBILLENTRY.put("FPayType", "A");//支付类型
|
||||
|
||||
//将MAP添加至List中
|
||||
FPAYBILLENTRY.add(PAYBILLENTRY);
|
||||
|
||||
Model.put("FPAYBILLENTRY", FPAYBILLENTRY);//
|
||||
//-----------------付款单明细 end-----------------//
|
||||
|
||||
|
||||
//-----------------付款单源单明细 start-----------------//
|
||||
List<Map<String,Object>> FPAYBILLSRCENTRY=new ArrayList<Map<String,Object>>();
|
||||
//定义一行明细
|
||||
Map<String,Object> PAYBILLSRCENTRY=new HashMap<String, Object>();
|
||||
//源单类型
|
||||
PAYBILLSRCENTRY.put("FSOURCETYPE", "AP_Payable");
|
||||
//源单编号,取K3应付单号
|
||||
PAYBILLSRCENTRY.put("FSRCBILLNO", k3yfdh);
|
||||
//本次付款金额
|
||||
PAYBILLSRCENTRY.put("FREALPAYAMOUNT_S", je_k3);
|
||||
//应付金额
|
||||
PAYBILLSRCENTRY.put("FAFTTAXTOTALAMOUNT", bcfkje);
|
||||
//计划付款金额
|
||||
PAYBILLSRCENTRY.put("FPLANPAYAMOUNT", bcfkje);
|
||||
//源单币别
|
||||
PAYBILLSRCENTRY.put("FSRCCURRENCYID", FCURRENCYID);
|
||||
//到期日
|
||||
PAYBILLSRCENTRY.put("FEXPIRY", nowDate);
|
||||
|
||||
//将MAP添加至List中
|
||||
FPAYBILLSRCENTRY.add(PAYBILLSRCENTRY);
|
||||
Model.put("FPAYBILLSRCENTRY", FPAYBILLSRCENTRY);//
|
||||
|
||||
//-----------------付款单源单明细 end-----------------//
|
||||
|
||||
data.put("Model", Model);
|
||||
|
||||
//将MAP转JSON,fastjson默认开启引用检测将相同的对象写成引用的形式,所以必须加上SerializerFeature.DisableCircularReferenceDetect,否则转换的字符串会出现$ref
|
||||
String jsonStr = JSON.toJSONString(data, SerializerFeature.DisableCircularReferenceDetect);
|
||||
log.writeLog("调用付款单保存接口传入数据jsonStr---------->"+jsonStr);
|
||||
//连接K3
|
||||
K3CloudApiClient client =K3Connect.connect();
|
||||
if(client!=null){
|
||||
//调用付款单保存接口
|
||||
String sResult = client.excuteOperation("AP_PAYBILL", "save", jsonStr);
|
||||
log.writeLog("调用付款单保存接口返回数据sResult---------->"+sResult);
|
||||
//解析K3返回的JSO字符串
|
||||
JSONObject jsonObject = JSONObject.parseObject(sResult);
|
||||
JSONObject ResponseStatus=jsonObject.getJSONObject("Result").getJSONObject("ResponseStatus");
|
||||
//是否成功写入K3
|
||||
String IsSuccess=ResponseStatus.get("IsSuccess").toString();
|
||||
log.writeLog("是否成功写入K3结果IsSuccess---------->"+IsSuccess);
|
||||
//成功写入K3
|
||||
if("true".equals(IsSuccess)){
|
||||
JSONArray SuccessJSONArray=ResponseStatus.getJSONArray("SuccessEntitys");
|
||||
String Id="";//单据ID
|
||||
String Number="";//单据编号
|
||||
for(int p=0;p<SuccessJSONArray.size();p++){
|
||||
Id=SuccessJSONArray.getJSONObject(p).get("Id").toString();//获取返回的单据ID
|
||||
Number=SuccessJSONArray.getJSONObject(p).get("Number").toString();//获取返回的单据编号
|
||||
}
|
||||
log.writeLog("Id------>"+Id+",Number------>"+Number);
|
||||
//将付款单号更新至表单字段中
|
||||
rs.execute("update "+tablename+" set sfcgsck3yfd='0',k3fkdh='"+Number+"',fpcfkje='',k3jkfhxx='',pcyfkzje=TO_CHAR("+pcyfkzje_new+",'FM999,999,999,999,999,999,990.00') where requestid="+requestid);
|
||||
//将付款信息插入至付款明细中
|
||||
rs.execute("insert into "+tablename+"_dt1 (mainid,fkyxzh,fkrq,fkje,k3fkdh) values('"+mainid+"','"+fkyxzh+"','"+nowDate+"',TO_CHAR("+je_k3+",'FM999,999,999,999,999,999,990.00'),'"+Number+"')");
|
||||
|
||||
//存在合同并且是(不需要分批次付款或者分批次的最后一次付款),则将付款信息更新至至建模合同台账中
|
||||
if("0".equals(sfyht)&&bcfkje==pcyfkzje+je_k3){
|
||||
//更新至建模的批次明细中
|
||||
sql="update uf_httz_dt1 a set (yfkje,fkzt)=(select TO_CHAR(to_number(replace(nvl(a.yfkje,0),',',''))+to_number(replace(nvl(b.bcfkje,0),',','')),'FM999,999,999,999,999,999,990.00'),(case when to_number(replace(nvl(a.yfkje,0),',',''))+to_number(replace(nvl(b.bcfkje,0),',',''))=to_number(replace(nvl(a.fkje,0),',','')) then 0 else 2 end) from "+tablename+"_dt5 b where a.id=b.fkpc and b.mainid='"+mainid+"') where a.mainid='"+htxx+"'";
|
||||
log.writeLog("流程中支付金额更新至合同建模明细中的金额SQL---------->"+sql);
|
||||
rs.execute(sql);
|
||||
//更新至建模的主表中
|
||||
sql="update uf_httz a set yfkje=TO_CHAR(to_number(replace(nvl(a.yfkje,0),',',''))+"+je_k3+",'FM999,999,999,999,999,999,990.00') where id='"+htxx+"'";
|
||||
log.writeLog("流程中支付金额更新至合同建模主表中的金额SQL---------->"+sql);
|
||||
rs.execute(sql);
|
||||
}
|
||||
}else{
|
||||
JSONArray ErrorsJSONArray=ResponseStatus.getJSONArray("Errors");
|
||||
for(int p=0;p<ErrorsJSONArray.size();p++){
|
||||
msg+=ErrorsJSONArray.getJSONObject(p).get("Message").toString();
|
||||
}
|
||||
//将错误信息更新至表单字段中
|
||||
rs.execute("update "+tablename+" set sfcgsck3yfd='1',k3jkfhxx='"+msg.replaceAll("'", "''")+"' where requestid="+requestid);
|
||||
//写入K3失败则进行提醒,并阻止流程提交
|
||||
ri.getRequestManager().setMessage("111100");
|
||||
ri.getRequestManager().setMessagecontent(msg);
|
||||
return "0";
|
||||
}
|
||||
}else{
|
||||
//连接K3超时
|
||||
ri.getRequestManager().setMessage("111100");
|
||||
ri.getRequestManager().setMessagecontent("OA连接K3超时,请联系管理员!");
|
||||
return "0";
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
String error_msg="付款流程写入K3失败,错误信息为:------>"+e.toString();
|
||||
if(language==0||language==7){//简体
|
||||
|
||||
}else if(language==8){//英语
|
||||
error_msg="付款流程写入K3失败,错误信息为:------>"+e.toString();
|
||||
}else if(language==9){//繁体
|
||||
error_msg="付款流程写入K3失败,错误信息为:------>"+e.toString();
|
||||
}else if(language==22){//印尼语
|
||||
error_msg="付款流程写入K3失败,错误信息为:------>"+e.toString();
|
||||
}
|
||||
log.writeLog(error_msg);
|
||||
//将错误信息更新至表单字段中
|
||||
rs.execute("update "+tablename+" set sfcgsck3yfd='1',k3jkfhxx='"+error_msg.replaceAll("'", "''")+"' where requestid="+requestid);
|
||||
ri.getRequestManager().setMessage("111100");
|
||||
ri.getRequestManager().setMessagecontent(error_msg);
|
||||
return "0";
|
||||
}
|
||||
return SUCCESS;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,300 @@
|
|||
package com.jet.action;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import kingdee.bos.webapi.client.K3CloudApiClient;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.alibaba.fastjson.serializer.SerializerFeature;
|
||||
import com.jet.k3.K3Connect;
|
||||
|
||||
import weaver.conn.RecordSet;
|
||||
import weaver.general.BaseBean;
|
||||
import weaver.general.Util;
|
||||
import weaver.interfaces.workflow.action.Action;
|
||||
import weaver.soa.workflow.request.RequestInfo;
|
||||
import selfdev.util.base.BaseUtil;
|
||||
import selfdev.util.base.TimeCommonUtil;
|
||||
import selfdev.util.log.LogTool;
|
||||
|
||||
/**
|
||||
* 付款申请流程到达财务AP节点时将数据写入K3生成应付单
|
||||
* @author KangMD
|
||||
* 2019-11-29
|
||||
*/
|
||||
public class CreateK3PayableAction extends BaseBean implements Action {
|
||||
|
||||
public String execute(RequestInfo ri) {
|
||||
LogTool log=new LogTool("/log/selfdev/action", false);
|
||||
//获取requestid
|
||||
String requestid=ri.getRequestid();
|
||||
String workflowid=ri.getWorkflowid();
|
||||
//获取用户语言
|
||||
int language=ri.getRequestManager().getUser().getLanguage();
|
||||
log.writeLog("language---------->"+language);
|
||||
String workflowname=BaseUtil.getBaseInfoByParm("workflowname", "workflow_base", "id", workflowid, "");
|
||||
log.writeLog("---------------"+workflowname+"开始写入K3生成应付单-------------requestId:" + requestid);
|
||||
//获取表名
|
||||
String tablename=BaseUtil.getBaseInfoByParm("tablename", "workflow_bill", "1", "1", " and id in (select formid from workflow_base where id="+workflowid+")");;
|
||||
RecordSet rs=new RecordSet();
|
||||
try {
|
||||
//获取当前系统日期
|
||||
String nowDate=TimeCommonUtil.obtainDate(0).substring(0,10);
|
||||
String fkfs="";//付款方式
|
||||
String fygsbm="";//财务K3所属部门
|
||||
String gysmc="";//供应商名称
|
||||
String gysmc2="";//供应商名称(无合同)
|
||||
String fphm="";//发票号码
|
||||
String fksm="";//付款说明
|
||||
String zfrq="";//支付日期
|
||||
String sfyht="";//是否有合同
|
||||
String bcfkje="";//本次付款金额
|
||||
String bcfkje2="";//本次付款金额(无合同)
|
||||
String sqje="";//税前金额
|
||||
String zzs="";//增值税
|
||||
//String dks="";//代扣税
|
||||
String bz="";//币种
|
||||
String zz="";//组织
|
||||
String sql="select * from "+tablename+" where requestid="+requestid;
|
||||
rs.execute(sql);
|
||||
while(rs.next()){
|
||||
fkfs=Util.null2String(rs.getString("fkfs"));
|
||||
gysmc=Util.null2String(rs.getString("gysmc"));
|
||||
gysmc2=Util.null2String(rs.getString("gysmc2"));
|
||||
fphm=Util.null2String(rs.getString("fphm"));
|
||||
fksm=Util.null2String(rs.getString("fksm")).replaceAll(" ", " ");
|
||||
zfrq=Util.null2String(rs.getString("zfrq"));
|
||||
sfyht=Util.null2String(rs.getString("sfyht"));
|
||||
bcfkje=Util.null2o(rs.getString("bcfkje")).replace(",", "");
|
||||
bcfkje2=Util.null2o (rs.getString("bcfkje2")).replace(",", "");
|
||||
bz=Util.null2String(rs.getString("bz"));
|
||||
zz=Util.null2String(rs.getString("zz"));
|
||||
fygsbm=Util.null2String(rs.getString("fygsbm"));
|
||||
sqje=Util.null2o(rs.getString("sqje")).replace(",", "");
|
||||
zzs=Util.null2o(rs.getString("zzs")).replace(",", "");
|
||||
//dks=Util.null2o(rs.getString("dks")).replace(",", "");
|
||||
}
|
||||
//K3中表头备注字段最多只能存储255位,将付款说明进行截取
|
||||
if(fksm.length()>255){
|
||||
fksm=fksm.substring(0,255);
|
||||
}
|
||||
|
||||
//没有合同
|
||||
if("1".equals(sfyht)){
|
||||
gysmc=gysmc2;
|
||||
bcfkje=bcfkje2;
|
||||
}
|
||||
//付款方式
|
||||
if("0".equals(fkfs)){//银行
|
||||
fkfs="JSFS03_SYS";
|
||||
}else{
|
||||
fkfs="JSFS01_SYS";//现金
|
||||
}
|
||||
|
||||
//含税单价=税前金额+增值税
|
||||
String hsdj=new BigDecimal(sqje).add(new BigDecimal(zzs)).setScale(2, BigDecimal.ROUND_HALF_UP).toString();
|
||||
|
||||
//***************************************拼接K3 Cloud应付单所需的JSON字符串***********************************************//
|
||||
Map<String,Object> data=new LinkedHashMap<String,Object>();
|
||||
|
||||
Map<String,Object> Model=new LinkedHashMap<String,Object>();
|
||||
//单据类型(必填项)--------默认为标准应付单YFD01_SYS
|
||||
Map<String,Object> FBillTypeID=new LinkedHashMap<String,Object>();
|
||||
FBillTypeID.put("FNUMBER", "YFD01_SYS");
|
||||
Model.put("FBillTypeID", FBillTypeID);
|
||||
|
||||
//是否期初单据
|
||||
Model.put("FISINIT", false);
|
||||
//业务日期(必填项)--------默认为当前系统日期
|
||||
Model.put("FDATE", nowDate);
|
||||
//到期日(必填项)--------
|
||||
Model.put("FENDDATE_H", nowDate);
|
||||
//单据状态,默认为创建 Z
|
||||
Model.put("FDOCUMENTSTATUS", "Z");
|
||||
|
||||
//供应商(必填项)--------
|
||||
Map<String,Object> FSUPPLIERID=new LinkedHashMap<String,Object>();
|
||||
FSUPPLIERID.put("FNUMBER", gysmc);
|
||||
Model.put("FSUPPLIERID", FSUPPLIERID);
|
||||
|
||||
//币别(必填项)--------
|
||||
Map<String,Object> FCURRENCYID=new LinkedHashMap<String,Object>();
|
||||
FCURRENCYID.put("FNUMBER", bz);
|
||||
Model.put("FCURRENCYID", FCURRENCYID);
|
||||
|
||||
Model.put("FISPRICEEXCLUDETAX", true);//价外税
|
||||
Model.put("FBUSINESSTYPE", "CG");//业务类型(必填项)----默认为CG
|
||||
Model.put("FISTAX", true);//按含税单价录入----
|
||||
|
||||
//结算组织(必填项)----
|
||||
Map<String,Object> FSETTLEORGID=new LinkedHashMap<String,Object>();
|
||||
FSETTLEORGID.put("FNumber", zz);
|
||||
Model.put("FSETTLEORGID", FSETTLEORGID);//结算组织(必填项)----
|
||||
|
||||
//采购部门----
|
||||
Map<String,Object> FPURCHASEDEPTID=new LinkedHashMap<String,Object>();
|
||||
FPURCHASEDEPTID.put("FNUMBER", fygsbm);
|
||||
Model.put("FPURCHASEDEPTID", FPURCHASEDEPTID);
|
||||
|
||||
//付款组织(必填项)----
|
||||
Map<String,Object> FPAYORGID=new LinkedHashMap<String,Object>();
|
||||
FPAYORGID.put("FNUMBER", zz);
|
||||
Model.put("FPAYORGID", FPAYORGID);
|
||||
|
||||
//作废状态(必填项)----默认为A
|
||||
Model.put("FCancelStatus", "A");
|
||||
//Invoice No(必填项)----
|
||||
Model.put("F_RTA_InvoiceNo", fphm);
|
||||
//business type(必填项)----默认为服务类S
|
||||
Model.put("F_RTA_BusinessType", "S");
|
||||
//备注
|
||||
Model.put("FAP_Remark", fksm);
|
||||
|
||||
//PPH By Company
|
||||
Model.put("F_RTA_PPHByComp", false);
|
||||
|
||||
|
||||
//-----------------表头供应商 start-----------------//
|
||||
Map<String,Object> FsubHeadSuppiler=new LinkedHashMap<String,Object>();
|
||||
FsubHeadSuppiler.put("FORDERID", FSUPPLIERID);//订货方
|
||||
FsubHeadSuppiler.put("FTRANSFERID", FSUPPLIERID);//供货方
|
||||
FsubHeadSuppiler.put("FChargeId", FSUPPLIERID);//收款方
|
||||
Model.put("FsubHeadSuppiler", FsubHeadSuppiler);//将供应商信息加入至Map中
|
||||
//-----------------表头供应商 end-----------------//
|
||||
|
||||
//-----------------表头财务 start-----------------//
|
||||
Map<String,Object> FsubHeadFinc=new LinkedHashMap<String,Object>();
|
||||
FsubHeadFinc.put("FACCNTTIMEJUDGETIME", zfrq);//到期日计算日期(必填项)----
|
||||
//结算方式
|
||||
Map<String,Object> FSettleTypeID=new LinkedHashMap<String,Object>();
|
||||
FSettleTypeID.put("FNUMBER", fkfs);
|
||||
FsubHeadFinc.put("FSettleTypeID", FSettleTypeID);
|
||||
//本位币
|
||||
FsubHeadFinc.put("FMAINBOOKSTDCURRID", FCURRENCYID);
|
||||
Model.put("FsubHeadFinc", FsubHeadFinc);//
|
||||
//-----------------表头财务 end-----------------//
|
||||
|
||||
//-----------------明细 start-----------------//
|
||||
List<Map<String,Object>> FEntityDetail=new ArrayList<Map<String,Object>>();
|
||||
//定义一行明细
|
||||
Map<String,Object> EntityDetail=new LinkedHashMap<String, Object>();
|
||||
//物料编码
|
||||
Map<String,Object> FMATERIALID=new LinkedHashMap<String,Object>();
|
||||
FMATERIALID.put("FNUMBER", "100013");
|
||||
EntityDetail.put("FMATERIALID", FMATERIALID);
|
||||
//K3中明细备注字段最多只能存储50位,将付款说明进行截取
|
||||
if(fksm.length()>50){
|
||||
fksm=fksm.substring(0,50);
|
||||
}
|
||||
EntityDetail.put("F_RTA_EntryRemarks", fksm);//备 注
|
||||
//计价单位
|
||||
Map<String,Object> FPRICEUNITID=new LinkedHashMap<String,Object>();
|
||||
FPRICEUNITID.put("FNUMBER", "Pcs");
|
||||
EntityDetail.put("FPRICEUNITID", FPRICEUNITID);
|
||||
|
||||
EntityDetail.put("FPrice", sqje);//单价
|
||||
EntityDetail.put("FPriceQty", 1.0);//计价数量
|
||||
EntityDetail.put("FTaxPrice", hsdj);//含税单价=税前单价+增值税
|
||||
//EntityDetail.put("F_RTA_PPHAmount", dks);//代扣税
|
||||
EntityDetail.put("FPriceWithTax", bcfkje);//含税净价
|
||||
//PPN Type
|
||||
Map<String,Object> F_RTA_VATType_d=new LinkedHashMap<String,Object>();
|
||||
F_RTA_VATType_d.put("FNUMBER", "000");
|
||||
EntityDetail.put("F_RTA_VATType_d", F_RTA_VATType_d);
|
||||
|
||||
EntityDetail.put("FNoTaxAmountFor_D", sqje);//不含税金额
|
||||
EntityDetail.put("FTAXAMOUNTFOR_D", 0);//税额
|
||||
EntityDetail.put("FALLAMOUNTFOR_D", bcfkje);//价税合计bcfkje
|
||||
EntityDetail.put("F_RTA_FakturPajakNo_d", "-");//Faktur Pajak No
|
||||
EntityDetail.put("F_RTA_SUPPLIER_D", FSUPPLIERID);//表体供应商(用于校验税票号唯一)
|
||||
//将MAP添加至List中
|
||||
FEntityDetail.add(EntityDetail);
|
||||
Model.put("FEntityDetail", FEntityDetail);//
|
||||
//-----------------明细 end-----------------//
|
||||
|
||||
//-----------------付款计划 start-----------------//
|
||||
List<Map<String,Object>> FEntityPlan=new ArrayList<Map<String,Object>>();
|
||||
Map<String,Object> FPlan=new LinkedHashMap<String,Object>();
|
||||
FPlan.put("FENDDATE", zfrq);//表头计划 - 到期日
|
||||
FPlan.put("FPAYAMOUNTFOR", bcfkje);//应付金额
|
||||
FPlan.put("FPAYRATE", 100);//应付比例(%)
|
||||
FEntityPlan.add(FPlan);
|
||||
Model.put("FEntityPlan", FEntityPlan);//
|
||||
//-----------------付款计划 end-----------------//
|
||||
data.put("Model", Model);
|
||||
|
||||
|
||||
//将MAP转JSON,fastjson默认开启引用检测将相同的对象写成引用的形式,所以必须加上SerializerFeature.DisableCircularReferenceDetect,否则转换的字符串会出现$ref
|
||||
String jsonStr = JSON.toJSONString(data, SerializerFeature.DisableCircularReferenceDetect);
|
||||
log.writeLog("调用应付单保存接口传入数据jsonStr---------->"+jsonStr);
|
||||
//连接K3
|
||||
K3CloudApiClient client =K3Connect.connect();
|
||||
if(client!=null){
|
||||
//调用应付单保存接口
|
||||
String sResult = client.excuteOperation("AP_Payable", "save", jsonStr);
|
||||
log.writeLog("调用应付单保存接口返回数据sResult---------->"+sResult);
|
||||
//解析K3返回的JSO字符串
|
||||
JSONObject jsonObject = JSONObject.parseObject(sResult);
|
||||
JSONObject ResponseStatus=jsonObject.getJSONObject("Result").getJSONObject("ResponseStatus");
|
||||
//是否成功写入K3
|
||||
String IsSuccess=ResponseStatus.get("IsSuccess").toString();
|
||||
log.writeLog("是否成功写入K3结果IsSuccess---------->"+IsSuccess);
|
||||
//成功写入K3
|
||||
if("true".equals(IsSuccess)){
|
||||
JSONArray SuccessJSONArray=ResponseStatus.getJSONArray("SuccessEntitys");
|
||||
String Id="";//单据ID
|
||||
String Number="";//单据编号
|
||||
for(int p=0;p<SuccessJSONArray.size();p++){
|
||||
Id=SuccessJSONArray.getJSONObject(p).get("Id").toString();//获取返回的单据ID
|
||||
Number=SuccessJSONArray.getJSONObject(p).get("Number").toString();//获取返回的单据编号
|
||||
}
|
||||
log.writeLog("Id------>"+Id+",Number------>"+Number);
|
||||
//将应付单号更新至表单字段中
|
||||
rs.execute("update "+tablename+" set sfcgsck3yfd='0',sfpcfk='1',fpcfkje='"+bcfkje+"',pcyfkzje='0',gysmc='"+gysmc+"',bcfkje='"+bcfkje+"',k3yfdh='"+Number+"',k3jkfhxx='' where requestid="+requestid);
|
||||
}else{
|
||||
JSONArray ErrorsJSONArray=ResponseStatus.getJSONArray("Errors");
|
||||
String msg="";
|
||||
for(int p=0;p<ErrorsJSONArray.size();p++){
|
||||
msg+=ErrorsJSONArray.getJSONObject(p).get("Message").toString();
|
||||
}
|
||||
//将错误信息更新至表单字段中
|
||||
rs.execute("update "+tablename+" set sfcgsck3yfd='1',sfpcfk='1',fpcfkje='"+bcfkje+"',gysmc='"+gysmc+"',bcfkje='"+bcfkje+"',k3jkfhxx='"+msg.replaceAll("'", "''")+"' where requestid="+requestid);
|
||||
//写入K3失败则进行提醒,并阻止流程提交
|
||||
ri.getRequestManager().setMessage("111100");
|
||||
ri.getRequestManager().setMessagecontent(msg);
|
||||
return "0";
|
||||
}
|
||||
}else{
|
||||
//连接K3超时
|
||||
ri.getRequestManager().setMessage("111100");
|
||||
ri.getRequestManager().setMessagecontent("OA连接K3超时,请联系管理员!");
|
||||
return "0";
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
String error_msg="付款流程写入K3失败,错误信息为:------>"+e.toString();
|
||||
if(language==0||language==7){//简体
|
||||
|
||||
}else if(language==8){//英语
|
||||
error_msg="付款流程写入K3失败,错误信息为:------>"+e.toString();
|
||||
}else if(language==9){//繁体
|
||||
error_msg="付款流程写入K3失败,错误信息为:------>"+e.toString();
|
||||
}else if(language==22){//印尼语
|
||||
error_msg="付款流程写入K3失败,错误信息为:------>"+e.toString();
|
||||
}
|
||||
log.writeLog(error_msg);
|
||||
//将错误信息更新至表单字段中
|
||||
rs.execute("update "+tablename+" set sfcgsck3yfd='1',k3jkfhxx='"+error_msg.replaceAll("'", "''")+"' where requestid="+requestid);
|
||||
ri.getRequestManager().setMessage("111100");
|
||||
ri.getRequestManager().setMessagecontent(error_msg);
|
||||
return "0";
|
||||
}
|
||||
return SUCCESS;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,365 @@
|
|||
package com.jet.action;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import kingdee.bos.webapi.client.K3CloudApiClient;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.alibaba.fastjson.serializer.SerializerFeature;
|
||||
import com.jet.k3.K3Connect;
|
||||
|
||||
import weaver.conn.RecordSet;
|
||||
import weaver.general.BaseBean;
|
||||
import weaver.general.Util;
|
||||
import weaver.interfaces.workflow.action.Action;
|
||||
import weaver.soa.workflow.request.RequestInfo;
|
||||
import selfdev.util.base.BaseUtil;
|
||||
import selfdev.util.base.TimeCommonUtil;
|
||||
import selfdev.util.log.LogTool;
|
||||
|
||||
/**
|
||||
* 借款申请流程到达财务AP节点时将数据写入K3生成应付单或者其他应付单
|
||||
* @author KangMD
|
||||
* 2019-11-29
|
||||
*/
|
||||
public class CreateK3PayableByLoanAction extends BaseBean implements Action {
|
||||
|
||||
public String execute(RequestInfo ri) {
|
||||
LogTool log=new LogTool("/log/selfdev/action", false);
|
||||
//获取requestid
|
||||
String requestid=ri.getRequestid();
|
||||
String workflowid=ri.getWorkflowid();
|
||||
//获取用户语言
|
||||
int language=ri.getRequestManager().getUser().getLanguage();
|
||||
log.writeLog("language---------->"+language);
|
||||
String workflowname=BaseUtil.getBaseInfoByParm("workflowname", "workflow_base", "id", workflowid, "");
|
||||
log.writeLog("---------------"+workflowname+"开始写入K3生成应付单或者其他应付单-------------requestId:" + requestid);
|
||||
//获取表名
|
||||
String tablename=BaseUtil.getBaseInfoByParm("tablename", "workflow_bill", "1", "1", " and id in (select formid from workflow_base where id="+workflowid+")");;
|
||||
RecordSet rs=new RecordSet();
|
||||
try {
|
||||
//获取当前系统日期
|
||||
String nowDate=TimeCommonUtil.obtainDate(0).substring(0,10);
|
||||
String zffs="";//付款方式
|
||||
String fygsbm="";//财务K3所属部门
|
||||
String jklx="";//借款类型
|
||||
String fphm="OA-"+requestid;//发票号码
|
||||
String jkyy="";//借款原因
|
||||
String dls="";//代理商
|
||||
String jkrq="";//期望支付日期
|
||||
String jkje="";//借款金额
|
||||
String bz="";//币种
|
||||
String zz="";//组织
|
||||
String jkrdyk3ygbh="";//借款人对应K3员工编号
|
||||
String sql="select * from "+tablename+" where requestid="+requestid;
|
||||
rs.execute(sql);
|
||||
while(rs.next()){
|
||||
zffs=Util.null2String(rs.getString("zffs"));
|
||||
jklx=Util.null2String(rs.getString("jklx"));
|
||||
fygsbm=Util.null2String(rs.getString("fygsbm"));
|
||||
jkyy=Util.null2String(rs.getString("jkyy")).replaceAll(" ", " ");
|
||||
dls=Util.null2String(rs.getString("dls"));
|
||||
jkrq=Util.null2String(rs.getString("jkrq"));
|
||||
jkje=Util.null2String(rs.getString("jkje"));
|
||||
bz=Util.null2String(rs.getString("bz"));
|
||||
zz=Util.null2String(rs.getString("zz"));
|
||||
jkrdyk3ygbh=Util.null2String(rs.getString("jkrdyk3ygbh"));
|
||||
}
|
||||
|
||||
//K3中表头备注字段最多只能存储255位,将付款说明进行截取
|
||||
if(jkyy.length()>255){
|
||||
jkyy=jkyy.substring(0,255);
|
||||
}
|
||||
|
||||
//付款方式
|
||||
if("0".equals(zffs)){//银行
|
||||
zffs="JSFS03_SYS";
|
||||
}else{
|
||||
zffs="JSFS01_SYS";//现金
|
||||
}
|
||||
//K3接口名
|
||||
String interfaceName="AP_Payable";
|
||||
//K3接口描述
|
||||
String interfaceDesc="应付单";
|
||||
//***************************************拼接K3 Cloud (其他)应付单所需的JSON字符串***********************************************//
|
||||
Map<String,Object> data=new HashMap<String,Object>();
|
||||
Map<String,Object> Model=new HashMap<String,Object>();
|
||||
|
||||
if("0".equals(jklx)){//员工借款,生成K3的其他应付单
|
||||
interfaceName="AP_OtherPayable";
|
||||
interfaceDesc="其他应付单";
|
||||
//单据类型(必填项)--------默认为其他应付单QTYFD01_SYS
|
||||
Map<String,Object> FBillTypeID=new HashMap<String,Object>();
|
||||
FBillTypeID.put("FNUMBER", "QTYFD01_SYS");
|
||||
Model.put("FBillTypeID", FBillTypeID);
|
||||
|
||||
Model.put("FDATE", nowDate);//业务日期(必填项)--------默认为申请日期
|
||||
Model.put("FENDDATE_H", nowDate);//到期日(必填项)--------
|
||||
Model.put("FCONTACTUNITTYPE", "BD_Empinfo");//往来单位类型,默认为员工BD_Empinfo
|
||||
|
||||
//往来单位编码(即员工编码)
|
||||
Map<String,Object> FCONTACTUNIT=new HashMap<String,Object>();
|
||||
FCONTACTUNIT.put("FNUMBER", jkrdyk3ygbh);
|
||||
Model.put("FCONTACTUNIT", FCONTACTUNIT);
|
||||
|
||||
//币别(必填项)--------
|
||||
Map<String,Object> FCURRENCYID=new HashMap<String,Object>();
|
||||
FCURRENCYID.put("FNUMBER", bz);
|
||||
Model.put("FCURRENCYID", FCURRENCYID);
|
||||
|
||||
Model.put("FTOTALAMOUNTFOR_H", jkje);//总金额
|
||||
Model.put("FNOTSETTLEAMOUNTFOR", jkje);//未结算金额
|
||||
|
||||
//申请部门
|
||||
Map<String,Object> FDEPARTMENTID=new HashMap<String,Object>();
|
||||
FDEPARTMENTID.put("FNumber", fygsbm);
|
||||
Model.put("FDEPARTMENTID", FDEPARTMENTID);
|
||||
|
||||
//付款组织(必填项)----
|
||||
Map<String,Object> FPAYORGID=new HashMap<String,Object>();
|
||||
FPAYORGID.put("FNUMBER", zz);
|
||||
Model.put("FPAYORGID", FPAYORGID);
|
||||
//结算组织
|
||||
Model.put("FSETTLEORGID", FPAYORGID);
|
||||
//采购组织
|
||||
Model.put("FPURCHASEORGID", FPAYORGID);
|
||||
//采购部门
|
||||
Model.put("FPURCHASEDEPTID", FDEPARTMENTID);
|
||||
//本位币
|
||||
Model.put("FMAINBOOKSTDCURRID", FCURRENCYID);
|
||||
|
||||
//到期日计算日期(期望支付日期)
|
||||
Model.put("FACCNTTIMEJUDGETIME", jkrq);
|
||||
//作废状态
|
||||
Model.put("FCancelStatus", "A");
|
||||
//备注
|
||||
Model.put("FRemarks", jkyy);
|
||||
|
||||
//-----------------明细 start-----------------//
|
||||
List<Map<String,Object>> FEntity=new ArrayList<Map<String,Object>>();
|
||||
//定义一行明细
|
||||
Map<String,Object> EntityDetail=new HashMap<String, Object>();
|
||||
//费用项目编码,默认为CI074
|
||||
Map<String,Object> FCOSTID=new HashMap<String,Object>();
|
||||
FCOSTID.put("FNUMBER", "CI074");
|
||||
EntityDetail.put("FCOSTID", FCOSTID);
|
||||
//费用归属部门
|
||||
EntityDetail.put("FCOSTDEPARTMENTID", FDEPARTMENTID);
|
||||
//不含税金额
|
||||
EntityDetail.put("FNOTAXAMOUNTFOR", jkje);
|
||||
//总金额
|
||||
EntityDetail.put("FTOTALAMOUNTFOR", jkje);
|
||||
//未结算金额
|
||||
EntityDetail.put("FNOTSETTLEAMOUNTFOR_D", jkje);
|
||||
//不含税金额本位币
|
||||
EntityDetail.put("FNOTAXAMOUNT_D", jkje);
|
||||
//发票类型
|
||||
//EntityDetail.put("FINVOICETYPE", "");
|
||||
//K3中明细备注字段最多只能存储50位,将借款原因进行截取
|
||||
if(jkyy.length()>50){
|
||||
jkyy=jkyy.substring(0,50);
|
||||
}
|
||||
//备注
|
||||
EntityDetail.put("FCOMMENT", jkyy);
|
||||
//将MAP添加至List中
|
||||
FEntity.add(EntityDetail);
|
||||
Model.put("FEntity", FEntity);//
|
||||
//-----------------明细 end-----------------//
|
||||
}else{//代理商借款,生成K3的应付单
|
||||
|
||||
//单据类型(必填项)--------默认为标准应付单YFD01_SYS
|
||||
Map<String,Object> FBillTypeID=new HashMap<String,Object>();
|
||||
FBillTypeID.put("FNUMBER", "YFD01_SYS");
|
||||
Model.put("FBillTypeID", FBillTypeID);
|
||||
|
||||
//是否期初单据
|
||||
Model.put("FISINIT", false);
|
||||
//业务日期(必填项)--------默认为当前系统日期
|
||||
Model.put("FDATE", nowDate);
|
||||
//到期日(必填项)--------
|
||||
Model.put("FENDDATE_H", nowDate);
|
||||
//单据状态,默认为创建 Z
|
||||
Model.put("FDOCUMENTSTATUS", "Z");
|
||||
|
||||
//供应商(必填项)--------
|
||||
Map<String,Object> FSUPPLIERID=new HashMap<String,Object>();
|
||||
FSUPPLIERID.put("FNUMBER", dls);
|
||||
Model.put("FSUPPLIERID", FSUPPLIERID);
|
||||
|
||||
//币别(必填项)--------
|
||||
Map<String,Object> FCURRENCYID=new HashMap<String,Object>();
|
||||
FCURRENCYID.put("FNUMBER", bz);
|
||||
Model.put("FCURRENCYID", FCURRENCYID);
|
||||
|
||||
Model.put("FISPRICEEXCLUDETAX", true);//价外税
|
||||
Model.put("FBUSINESSTYPE", "CG");//业务类型(必填项)----默认为CG
|
||||
Model.put("FISTAX", true);//按含税单价录入----
|
||||
|
||||
//结算组织(必填项)----
|
||||
Map<String,Object> FSETTLEORGID=new HashMap<String,Object>();
|
||||
FSETTLEORGID.put("FNumber", zz);
|
||||
Model.put("FSETTLEORGID", FSETTLEORGID);//结算组织(必填项)----
|
||||
|
||||
//采购部门----
|
||||
Map<String,Object> FPURCHASEDEPTID=new HashMap<String,Object>();
|
||||
FPURCHASEDEPTID.put("FNUMBER", fygsbm);
|
||||
Model.put("FPURCHASEDEPTID", FPURCHASEDEPTID);
|
||||
|
||||
//付款组织(必填项)----
|
||||
Map<String,Object> FPAYORGID=new HashMap<String,Object>();
|
||||
FPAYORGID.put("FNUMBER", zz);
|
||||
Model.put("FPAYORGID", FPAYORGID);
|
||||
|
||||
//作废状态(必填项)----默认为A
|
||||
Model.put("FCancelStatus", "A");
|
||||
//Invoice No(必填项)----
|
||||
Model.put("F_RTA_InvoiceNo", fphm);
|
||||
//business type(必填项)----默认为服务类S
|
||||
Model.put("F_RTA_BusinessType", "S");
|
||||
//备注
|
||||
Model.put("FAP_Remark", jkyy);
|
||||
|
||||
//-----------------表头供应商 start-----------------//
|
||||
Map<String,Object> FsubHeadSuppiler=new HashMap<String,Object>();
|
||||
FsubHeadSuppiler.put("FORDERID", FSUPPLIERID);//订货方
|
||||
FsubHeadSuppiler.put("FTRANSFERID", FSUPPLIERID);//供货方
|
||||
FsubHeadSuppiler.put("FChargeId", FSUPPLIERID);//收款方
|
||||
Model.put("FsubHeadSuppiler", FsubHeadSuppiler);//将供应商信息加入至Map中
|
||||
//-----------------表头供应商 end-----------------//
|
||||
|
||||
//-----------------表头财务 start-----------------//
|
||||
Map<String,Object> FsubHeadFinc=new HashMap<String,Object>();
|
||||
FsubHeadFinc.put("FACCNTTIMEJUDGETIME", jkrq);//到期日计算日期(必填项)----
|
||||
//结算方式
|
||||
Map<String,Object> FSettleTypeID=new HashMap<String,Object>();
|
||||
FSettleTypeID.put("FNUMBER",zffs);
|
||||
FsubHeadFinc.put("FSettleTypeID", FSettleTypeID);
|
||||
//本位币
|
||||
FsubHeadFinc.put("FMAINBOOKSTDCURRID", FCURRENCYID);
|
||||
Model.put("FsubHeadFinc", FsubHeadFinc);//
|
||||
//-----------------表头财务 end-----------------//
|
||||
|
||||
//-----------------明细 start-----------------//
|
||||
List<Map<String,Object>> FEntityDetail=new ArrayList<Map<String,Object>>();
|
||||
//定义一行明细
|
||||
Map<String,Object> EntityDetail=new HashMap<String, Object>();
|
||||
//物料编码
|
||||
Map<String,Object> FMATERIALID=new HashMap<String,Object>();
|
||||
FMATERIALID.put("FNUMBER", "100013");
|
||||
EntityDetail.put("FMATERIALID", FMATERIALID);
|
||||
|
||||
//K3中明细备注字段最多只能存储50位,将借款原因进行截取
|
||||
if(jkyy.length()>50){
|
||||
jkyy=jkyy.substring(0,50);
|
||||
}
|
||||
EntityDetail.put("F_RTA_EntryRemarks", jkyy);//备 注
|
||||
//计价单位
|
||||
Map<String,Object> FPRICEUNITID=new HashMap<String,Object>();
|
||||
FPRICEUNITID.put("FNUMBER", "Pcs");
|
||||
EntityDetail.put("FPRICEUNITID", FPRICEUNITID);
|
||||
|
||||
EntityDetail.put("FPrice", jkje);//单价
|
||||
EntityDetail.put("FPriceQty", 1.0);//计价数量
|
||||
EntityDetail.put("FTaxPrice", jkje);//含税单价
|
||||
EntityDetail.put("FPriceWithTax", jkje);//含税净价
|
||||
//PPN Type
|
||||
Map<String,Object> F_RTA_VATType_d=new HashMap<String,Object>();
|
||||
F_RTA_VATType_d.put("FNUMBER", "000");
|
||||
EntityDetail.put("F_RTA_VATType_d", F_RTA_VATType_d);
|
||||
|
||||
EntityDetail.put("FNoTaxAmountFor_D", jkje);//不含税金额
|
||||
EntityDetail.put("FTAXAMOUNTFOR_D", 0);//税额
|
||||
EntityDetail.put("FALLAMOUNTFOR_D", jkje);//价税合计
|
||||
EntityDetail.put("F_RTA_FakturPajakNo_d", "-");//Faktur Pajak No
|
||||
EntityDetail.put("F_RTA_SUPPLIER_D", FSUPPLIERID);//表体供应商(用于校验税票号唯一)
|
||||
//将MAP添加至List中
|
||||
FEntityDetail.add(EntityDetail);
|
||||
Model.put("FEntityDetail", FEntityDetail);//
|
||||
//-----------------明细 end-----------------//
|
||||
|
||||
//-----------------付款计划 start-----------------//
|
||||
List<Map<String,Object>> FEntityPlan=new ArrayList<Map<String,Object>>();
|
||||
Map<String,Object> FPlan=new HashMap<String,Object>();
|
||||
FPlan.put("FENDDATE", jkrq);//表头计划 - 到期日
|
||||
FPlan.put("FPAYAMOUNTFOR", jkje);//应付金额
|
||||
FPlan.put("FPAYRATE", 100);//应付比例(%)
|
||||
FEntityPlan.add(FPlan);
|
||||
Model.put("FEntityPlan", FEntityPlan);//
|
||||
//-----------------付款计划 end-----------------//
|
||||
}
|
||||
|
||||
data.put("Model", Model);
|
||||
|
||||
//将MAP转JSON,fastjson默认开启引用检测将相同的对象写成引用的形式,所以必须加上SerializerFeature.DisableCircularReferenceDetect,否则转换的字符串会出现$ref
|
||||
String jsonStr = JSON.toJSONString(data, SerializerFeature.DisableCircularReferenceDetect);
|
||||
log.writeLog("调用"+interfaceDesc+"保存接口传入数据jsonStr---------->"+jsonStr);
|
||||
//连接K3
|
||||
K3CloudApiClient client =K3Connect.connect();
|
||||
if(client!=null){
|
||||
//调用应付单保存接口
|
||||
String sResult = client.excuteOperation(interfaceName, "save", jsonStr);
|
||||
log.writeLog("调用"+interfaceDesc+"保存接口返回数据sResult---------->"+sResult);
|
||||
//解析K3返回的JSO字符串
|
||||
JSONObject jsonObject = JSONObject.parseObject(sResult);
|
||||
JSONObject ResponseStatus=jsonObject.getJSONObject("Result").getJSONObject("ResponseStatus");
|
||||
//是否成功写入K3
|
||||
String IsSuccess=ResponseStatus.get("IsSuccess").toString();
|
||||
log.writeLog("是否成功写入K3结果IsSuccess---------->"+IsSuccess);
|
||||
//成功写入K3
|
||||
if("true".equals(IsSuccess)){
|
||||
JSONArray SuccessJSONArray=ResponseStatus.getJSONArray("SuccessEntitys");
|
||||
String Id="";//单据ID
|
||||
String Number="";//单据编号
|
||||
for(int p=0;p<SuccessJSONArray.size();p++){
|
||||
Id=SuccessJSONArray.getJSONObject(p).get("Id").toString();//获取返回的单据ID
|
||||
Number=SuccessJSONArray.getJSONObject(p).get("Number").toString();//获取返回的单据编号
|
||||
}
|
||||
log.writeLog("Id------>"+Id+",Number------>"+Number);
|
||||
//将应付单号更新至表单字段中
|
||||
rs.execute("update "+tablename+" set sfcgsck3yfd='0',k3yfdh='"+Number+"',k3jkfhxx='' where requestid="+requestid);
|
||||
}else{
|
||||
JSONArray ErrorsJSONArray=ResponseStatus.getJSONArray("Errors");
|
||||
String msg="";
|
||||
for(int p=0;p<ErrorsJSONArray.size();p++){
|
||||
msg+=ErrorsJSONArray.getJSONObject(p).get("Message").toString();
|
||||
}
|
||||
//将错误信息更新至表单字段中
|
||||
rs.execute("update "+tablename+" set sfcgsck3yfd='1',k3jkfhxx='"+msg.replaceAll("'", "''")+"' where requestid="+requestid);
|
||||
//写入K3失败则进行提醒,并阻止流程提交
|
||||
ri.getRequestManager().setMessage("111100");
|
||||
ri.getRequestManager().setMessagecontent(msg);
|
||||
return "0";
|
||||
}
|
||||
}else{
|
||||
//连接K3超时
|
||||
ri.getRequestManager().setMessage("111100");
|
||||
ri.getRequestManager().setMessagecontent("OA连接K3超时,请联系管理员!");
|
||||
return "0";
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
String error_msg="借款流程写入K3失败,错误信息为:------>"+e.toString();
|
||||
if(language==0||language==7){//简体
|
||||
|
||||
}else if(language==8){//英语
|
||||
error_msg="借款流程写入K3失败,错误信息为:------>"+e.toString();
|
||||
}else if(language==9){//繁体
|
||||
error_msg="借款流程写入K3失败,错误信息为:------>"+e.toString();
|
||||
}else if(language==22){//印尼语
|
||||
error_msg="借款流程写入K3失败,错误信息为:------>"+e.toString();
|
||||
}
|
||||
log.writeLog(error_msg);
|
||||
//将错误信息更新至表单字段中
|
||||
rs.execute("update "+tablename+" set sfcgsck3yfd='1',k3jkfhxx='"+error_msg.replaceAll("'", "''")+"' where requestid="+requestid);
|
||||
ri.getRequestManager().setMessage("111100");
|
||||
ri.getRequestManager().setMessagecontent(error_msg);
|
||||
return "0";
|
||||
}
|
||||
return SUCCESS;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,305 @@
|
|||
package com.jet.action;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import kingdee.bos.webapi.client.K3CloudApiClient;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.alibaba.fastjson.serializer.SerializerFeature;
|
||||
import com.jet.k3.K3Connect;
|
||||
|
||||
import weaver.conn.RecordSet;
|
||||
import weaver.general.BaseBean;
|
||||
import weaver.general.Util;
|
||||
import weaver.interfaces.workflow.action.Action;
|
||||
import weaver.soa.workflow.request.RequestInfo;
|
||||
import selfdev.util.base.BaseUtil;
|
||||
import selfdev.util.base.TimeCommonUtil;
|
||||
import selfdev.util.log.LogTool;
|
||||
|
||||
/**
|
||||
* 报销流程将数据写入K3生成应付单
|
||||
* @author KangMD
|
||||
* 2019-12-07
|
||||
*/
|
||||
public class CreateK3PayableByReimbursementAction extends BaseBean implements Action {
|
||||
|
||||
public String execute(RequestInfo ri) {
|
||||
LogTool log=new LogTool("/log/selfdev/action", false);
|
||||
//获取requestid
|
||||
String requestid=ri.getRequestid();
|
||||
String workflowid=ri.getWorkflowid();
|
||||
//获取用户语言
|
||||
int language=ri.getRequestManager().getUser().getLanguage();
|
||||
log.writeLog("language---------->"+language);
|
||||
String workflowname=BaseUtil.getBaseInfoByParm("workflowname", "workflow_base", "id", workflowid, "");
|
||||
log.writeLog("---------------"+workflowname+"开始写入K3生成应付单-------------requestId:" + requestid);
|
||||
//获取表名
|
||||
String tablename=BaseUtil.getBaseInfoByParm("tablename", "workflow_bill", "1", "1", " and id in (select formid from workflow_base where id="+workflowid+")");;
|
||||
RecordSet rs=new RecordSet();
|
||||
try {
|
||||
//获取当前系统日期
|
||||
String nowDate=TimeCommonUtil.obtainDate(0).substring(0,10);
|
||||
String mainid="";//主键ID
|
||||
String bxfs="";//报销方式
|
||||
String fygsbm="";//财务K3所属部门
|
||||
String gysmc="";//供应商名称
|
||||
//String fphm="";//发票号码
|
||||
String bxms="";//报销说明
|
||||
String zfrq="";//支付日期
|
||||
String bxzje="";//报销总金额
|
||||
String bz="";//币种
|
||||
String zz="";//组织
|
||||
String sql="select * from "+tablename+" where requestid="+requestid;
|
||||
rs.execute(sql);
|
||||
while(rs.next()){
|
||||
mainid=Util.null2String(rs.getString("id"));
|
||||
bxfs=Util.null2String(rs.getString("bxfs"));
|
||||
fygsbm=Util.null2String(rs.getString("fygsbm"));
|
||||
zfrq=Util.null2String(rs.getString("zfrq"));
|
||||
bxzje=Util.null2String(rs.getString("bxzje"));
|
||||
bz=Util.null2String(rs.getString("bz"));
|
||||
zz=Util.null2String(rs.getString("zz"));
|
||||
bxms=Util.null2String(rs.getString("bxms")).replaceAll(" ", " ");
|
||||
}
|
||||
|
||||
//K3中表头备注字段最多只能存储255位,将付款说明进行截取
|
||||
if(bxms.length()>255){
|
||||
bxms=bxms.substring(0,255);
|
||||
}
|
||||
|
||||
//付款方式
|
||||
if("0".equals(bxfs)){//银行
|
||||
bxfs="JSFS03_SYS";
|
||||
}else{
|
||||
bxfs="JSFS01_SYS";//现金
|
||||
}
|
||||
//根据K3部门查询K3供应商
|
||||
gysmc=BaseUtil.getBaseInfoByParm("k3gys", "uf_bm_gys_K3", "k3bm", fygsbm, "");
|
||||
|
||||
log.writeLog("gysmc-------->"+gysmc);
|
||||
if("".equals(gysmc)){
|
||||
String error_msg="当前K3部门编码【"+fygsbm+"】未维护对应的供应商,请先维护对应关系!";
|
||||
if(language==0||language==7){//简体
|
||||
|
||||
}else if(language==8){//英语
|
||||
error_msg="当前K3部门编码【"+fygsbm+"】未维护对应的供应商,请先维护对应关系!";
|
||||
}else if(language==9){//繁体
|
||||
error_msg="当前K3部门编码【"+fygsbm+"】未维护对应的供应商,请先维护对应关系!";
|
||||
}else if(language==22){//印尼语
|
||||
error_msg="当前K3部门编码【"+fygsbm+"】未维护对应的供应商,请先维护对应关系!";
|
||||
}
|
||||
ri.getRequestManager().setMessage("111100");
|
||||
ri.getRequestManager().setMessagecontent(error_msg);
|
||||
return "0";
|
||||
}
|
||||
|
||||
|
||||
//***************************************拼接K3 Cloud应付单所需的JSON字符串***********************************************//
|
||||
Map<String,Object> data=new HashMap<String,Object>();
|
||||
|
||||
Map<String,Object> Model=new HashMap<String,Object>();
|
||||
//单据类型(必填项)--------默认为标准应付单YFD01_SYS
|
||||
Map<String,Object> FBillTypeID=new HashMap<String,Object>();
|
||||
FBillTypeID.put("FNUMBER", "YFD01_SYS");
|
||||
Model.put("FBillTypeID", FBillTypeID);
|
||||
|
||||
//是否期初单据
|
||||
Model.put("FISINIT", false);
|
||||
//业务日期(必填项)--------默认为当前系统日期
|
||||
Model.put("FDATE", nowDate);
|
||||
//到期日(必填项)--------
|
||||
Model.put("FENDDATE_H", nowDate);
|
||||
//单据状态,默认为创建 Z
|
||||
Model.put("FDOCUMENTSTATUS", "Z");
|
||||
|
||||
//供应商(必填项)--------
|
||||
Map<String,Object> FSUPPLIERID=new HashMap<String,Object>();
|
||||
FSUPPLIERID.put("FNUMBER", gysmc);
|
||||
Model.put("FSUPPLIERID", FSUPPLIERID);
|
||||
|
||||
//币别(必填项)--------
|
||||
Map<String,Object> FCURRENCYID=new HashMap<String,Object>();
|
||||
FCURRENCYID.put("FNUMBER", bz);
|
||||
Model.put("FCURRENCYID", FCURRENCYID);
|
||||
|
||||
Model.put("FISPRICEEXCLUDETAX", true);//价外税
|
||||
Model.put("FBUSINESSTYPE", "CG");//业务类型(必填项)----默认为CG
|
||||
Model.put("FISTAX", true);//按含税单价录入----
|
||||
|
||||
//结算组织(必填项)----
|
||||
Map<String,Object> FSETTLEORGID=new HashMap<String,Object>();
|
||||
FSETTLEORGID.put("FNumber", zz);
|
||||
Model.put("FSETTLEORGID", FSETTLEORGID);//结算组织(必填项)----
|
||||
|
||||
//采购部门----
|
||||
Map<String,Object> FPURCHASEDEPTID=new HashMap<String,Object>();
|
||||
FPURCHASEDEPTID.put("FNUMBER", fygsbm);
|
||||
Model.put("FPURCHASEDEPTID", FPURCHASEDEPTID);
|
||||
|
||||
//付款组织(必填项)----
|
||||
Map<String,Object> FPAYORGID=new HashMap<String,Object>();
|
||||
FPAYORGID.put("FNUMBER", zz);
|
||||
Model.put("FPAYORGID", FPAYORGID);
|
||||
|
||||
//作废状态(必填项)----默认为A
|
||||
Model.put("FCancelStatus", "A");
|
||||
//Invoice No(必填项)----//requestid
|
||||
Model.put("F_RTA_InvoiceNo", "OA-"+requestid);
|
||||
//business type(必填项)----默认为服务类S
|
||||
Model.put("F_RTA_BusinessType", "S");
|
||||
//备注
|
||||
Model.put("FAP_Remark", bxms);
|
||||
|
||||
//-----------------表头供应商 start-----------------//
|
||||
Map<String,Object> FsubHeadSuppiler=new HashMap<String,Object>();
|
||||
FsubHeadSuppiler.put("FORDERID", FSUPPLIERID);//订货方
|
||||
FsubHeadSuppiler.put("FTRANSFERID", FSUPPLIERID);//供货方
|
||||
FsubHeadSuppiler.put("FChargeId", FSUPPLIERID);//收款方
|
||||
Model.put("FsubHeadSuppiler", FsubHeadSuppiler);//将供应商信息加入至Map中
|
||||
//-----------------表头供应商 end-----------------//
|
||||
|
||||
//-----------------表头财务 start-----------------//
|
||||
Map<String,Object> FsubHeadFinc=new HashMap<String,Object>();
|
||||
FsubHeadFinc.put("FACCNTTIMEJUDGETIME", zfrq);//到期日计算日期(必填项)----
|
||||
//结算方式
|
||||
Map<String,Object> FSettleTypeID=new HashMap<String,Object>();
|
||||
FSettleTypeID.put("FNUMBER", bxfs);
|
||||
FsubHeadFinc.put("FSettleTypeID", FSettleTypeID);
|
||||
//本位币
|
||||
FsubHeadFinc.put("FMAINBOOKSTDCURRID", FCURRENCYID);
|
||||
Model.put("FsubHeadFinc", FsubHeadFinc);//
|
||||
//-----------------表头财务 end-----------------//
|
||||
|
||||
|
||||
|
||||
//-----------------明细 start-----------------//
|
||||
sql="select * from "+tablename+"_dt8 where mainid="+mainid;
|
||||
rs.execute(sql);
|
||||
List<Map<String,Object>> FEntityDetail=new ArrayList<Map<String,Object>>();
|
||||
while(rs.next()){
|
||||
String je=Util.null2String(rs.getString("je"));
|
||||
//定义一行明细
|
||||
Map<String,Object> EntityDetail=new HashMap<String, Object>();
|
||||
//物料编码
|
||||
Map<String,Object> FMATERIALID=new HashMap<String,Object>();
|
||||
FMATERIALID.put("FNUMBER", Util.null2String(rs.getString("bxlx1")));
|
||||
EntityDetail.put("FMATERIALID", FMATERIALID);
|
||||
|
||||
String beizhu=Util.null2String(rs.getString("bz")).replaceAll(" ", " ");
|
||||
//K3中明细备注字段最多只能存储50位,将付款说明进行截取
|
||||
if(beizhu.length()>50){
|
||||
beizhu=beizhu.substring(0,50);
|
||||
}
|
||||
|
||||
EntityDetail.put("F_RTA_EntryRemarks", beizhu);//备 注
|
||||
//计价单位
|
||||
Map<String,Object> FPRICEUNITID=new HashMap<String,Object>();
|
||||
FPRICEUNITID.put("FNUMBER", "Pcs");
|
||||
EntityDetail.put("FPRICEUNITID", FPRICEUNITID);
|
||||
|
||||
EntityDetail.put("FPrice", je);//单价
|
||||
EntityDetail.put("FPriceQty", 1.0);//计价数量
|
||||
EntityDetail.put("FTaxPrice", je);//含税单价
|
||||
EntityDetail.put("FPriceWithTax", je);//含税净价
|
||||
//PPN Type
|
||||
Map<String,Object> F_RTA_VATType_d=new HashMap<String,Object>();
|
||||
F_RTA_VATType_d.put("FNUMBER", "000");
|
||||
EntityDetail.put("F_RTA_VATType_d", F_RTA_VATType_d);
|
||||
|
||||
EntityDetail.put("FNoTaxAmountFor_D", je);//不含税金额
|
||||
EntityDetail.put("FTAXAMOUNTFOR_D", 0);//税额
|
||||
EntityDetail.put("FALLAMOUNTFOR_D", je);//价税合计
|
||||
EntityDetail.put("F_RTA_FakturPajakNo_d", "-");//Faktur Pajak No
|
||||
EntityDetail.put("F_RTA_SUPPLIER_D", FSUPPLIERID);//表体供应商(用于校验税票号唯一)
|
||||
//将MAP添加至List中
|
||||
FEntityDetail.add(EntityDetail);
|
||||
}
|
||||
|
||||
Model.put("FEntityDetail", FEntityDetail);//
|
||||
//-----------------明细 end-----------------//
|
||||
|
||||
//-----------------付款计划 start-----------------//
|
||||
List<Map<String,Object>> FEntityPlan=new ArrayList<Map<String,Object>>();
|
||||
Map<String,Object> FPlan=new HashMap<String,Object>();
|
||||
FPlan.put("FENDDATE", zfrq);//表头计划 - 到期日
|
||||
FPlan.put("FPAYAMOUNTFOR", bxzje);//应付金额
|
||||
FPlan.put("FPAYRATE", 100);//应付比例(%)
|
||||
FEntityPlan.add(FPlan);
|
||||
Model.put("FEntityPlan", FEntityPlan);//
|
||||
//-----------------付款计划 end-----------------//
|
||||
data.put("Model", Model);
|
||||
|
||||
//将MAP转JSON,fastjson默认开启引用检测将相同的对象写成引用的形式,所以必须加上SerializerFeature.DisableCircularReferenceDetect,否则转换的字符串会出现$ref
|
||||
String jsonStr = JSON.toJSONString(data, SerializerFeature.DisableCircularReferenceDetect);
|
||||
log.writeLog("调用应付单保存接口传入数据jsonStr---------->"+jsonStr);
|
||||
//连接K3
|
||||
K3CloudApiClient client =K3Connect.connect();
|
||||
if(client!=null){
|
||||
//调用应付单保存接口
|
||||
String sResult = client.excuteOperation("AP_Payable", "save", jsonStr);
|
||||
log.writeLog("调用应付单保存接口返回数据sResult---------->"+sResult);
|
||||
//解析K3返回的JSO字符串
|
||||
JSONObject jsonObject = JSONObject.parseObject(sResult);
|
||||
JSONObject ResponseStatus=jsonObject.getJSONObject("Result").getJSONObject("ResponseStatus");
|
||||
//是否成功写入K3
|
||||
String IsSuccess=ResponseStatus.get("IsSuccess").toString();
|
||||
log.writeLog("是否成功写入K3结果IsSuccess---------->"+IsSuccess);
|
||||
//成功写入K3
|
||||
if("true".equals(IsSuccess)){
|
||||
JSONArray SuccessJSONArray=ResponseStatus.getJSONArray("SuccessEntitys");
|
||||
String Id="";//单据ID
|
||||
String Number="";//单据编号
|
||||
for(int p=0;p<SuccessJSONArray.size();p++){
|
||||
Id=SuccessJSONArray.getJSONObject(p).get("Id").toString();//获取返回的单据ID
|
||||
Number=SuccessJSONArray.getJSONObject(p).get("Number").toString();//获取返回的单据编号
|
||||
}
|
||||
log.writeLog("Id------>"+Id+",Number------>"+Number);
|
||||
//将应付单号更新至表单字段中
|
||||
rs.execute("update "+tablename+" set sfcgsck3yfd='0',k3yfdh='"+Number+"',k3jkfhxx='' where requestid="+requestid);
|
||||
}else{
|
||||
JSONArray ErrorsJSONArray=ResponseStatus.getJSONArray("Errors");
|
||||
String msg="";
|
||||
for(int p=0;p<ErrorsJSONArray.size();p++){
|
||||
msg+=ErrorsJSONArray.getJSONObject(p).get("Message").toString();
|
||||
}
|
||||
//将错误信息更新至表单字段中
|
||||
rs.execute("update "+tablename+" set sfcgsck3yfd='1',k3jkfhxx='"+msg.replaceAll("'", "''")+"' where requestid="+requestid);
|
||||
//写入K3失败则进行提醒,并阻止流程提交
|
||||
ri.getRequestManager().setMessage("111100");
|
||||
ri.getRequestManager().setMessagecontent(msg);
|
||||
return "0";
|
||||
}
|
||||
}else{
|
||||
//连接K3超时
|
||||
ri.getRequestManager().setMessage("111100");
|
||||
ri.getRequestManager().setMessagecontent("OA连接K3超时,请联系管理员!");
|
||||
return "0";
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
String error_msg="付款流程写入K3失败,错误信息为:------>"+e.toString();
|
||||
if(language==0||language==7){//简体
|
||||
|
||||
}else if(language==8){//英语
|
||||
error_msg="付款流程写入K3失败,错误信息为:------>"+e.toString();
|
||||
}else if(language==9){//繁体
|
||||
error_msg="付款流程写入K3失败,错误信息为:------>"+e.toString();
|
||||
}else if(language==22){//印尼语
|
||||
error_msg="付款流程写入K3失败,错误信息为:------>"+e.toString();
|
||||
}
|
||||
log.writeLog(error_msg);
|
||||
//将错误信息更新至表单字段中
|
||||
rs.execute("update "+tablename+" set sfcgsck3yfd='1',k3jkfhxx='"+error_msg.replaceAll("'", "''")+"' where requestid="+requestid);
|
||||
ri.getRequestManager().setMessage("111100");
|
||||
ri.getRequestManager().setMessagecontent(error_msg);
|
||||
return "0";
|
||||
}
|
||||
return SUCCESS;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,567 @@
|
|||
package com.jet.action;
|
||||
|
||||
import weaver.soa.workflow.request.RequestInfo;
|
||||
import weaver.workflow.action.BaseAction;
|
||||
import weaver.conn.RecordSet;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
|
||||
import weaver.hrm.HrmUserVarify;
|
||||
import weaver.hrm.User;
|
||||
import weaver.general.BaseBean;
|
||||
import weaver.general.Util;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.sql.Connection;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.Statement;
|
||||
import weaver.general.StaticObj;
|
||||
import weaver.interfaces.datasource.DataSource;
|
||||
import weaver.formmode.setup.ModeRightInfo;
|
||||
import java.sql.Connection;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Statement;
|
||||
import weaver.general.StaticObj;
|
||||
import weaver.interfaces.datasource.DataSource;
|
||||
import weaver.interfaces.workflow.action.Action;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.PrintWriter;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
import org.apache.http.Header;
|
||||
import org.apache.http.HttpResponse;
|
||||
import org.apache.http.HttpStatus;
|
||||
import org.apache.http.client.HttpClient;
|
||||
import org.apache.http.client.methods.HttpPost;
|
||||
import org.apache.http.entity.*;
|
||||
import org.apache.http.*;
|
||||
import org.apache.http.util.*;
|
||||
import org.apache.http.impl.client.DefaultHttpClient;
|
||||
import org.apache.http.params.CoreConnectionPNames;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.nio.charset.Charset;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import weaver.conn.RecordSetTrans;
|
||||
import java.io.PrintWriter;
|
||||
import com.jet.util.*;
|
||||
import org.json.*;
|
||||
public class CreateVoucherBx extends BaseAction{
|
||||
@Override
|
||||
public String execute(RequestInfo requestInfo) {
|
||||
// TODO Auto-generated method stub
|
||||
Logger log = Logger.getLogger(JSONObject.class);
|
||||
RecordSet urlre=new RecordSet();
|
||||
String urlsql="select * from uf_urlinfo where ms='model'";
|
||||
|
||||
urlre.execute(urlsql);
|
||||
String url="";
|
||||
String username="";
|
||||
String password1="";
|
||||
String dbid1="";
|
||||
String uuid1="";
|
||||
String password2="";
|
||||
while(urlre.next()){
|
||||
url=Util.null2String(urlre.getString("url"));
|
||||
username=Util.null2String(urlre.getString("username"));
|
||||
password1=Util.null2String(urlre.getString("password"));
|
||||
dbid1=Util.null2String(urlre.getString("dbid"));
|
||||
uuid1=Util.null2String(urlre.getString("uuid"));
|
||||
password2=Util.null2String(urlre.getString("password1"));
|
||||
}
|
||||
String baseis=username+":"+password1;
|
||||
String Queryurl=url+"GlVoucher/";
|
||||
log.error("deeded");
|
||||
Map<String,String> Hswd=new HashMap<String,String>();//核算维度对照表
|
||||
JSONObject VOUCHER=new JSONObject();//VOUCHER
|
||||
JSONArray Models=new JSONArray();//ModelS
|
||||
JSONObject Model=new JSONObject();//Model
|
||||
Hswd.put("FFLEX4","gys");//供应商
|
||||
Hswd.put("FFLEX6","kh");//客户
|
||||
Hswd.put("FFLEX7","yg");//员工
|
||||
Hswd.put("FFLEX5","bm");//部门
|
||||
Hswd.put("FFLEX9","fyxm");//费用项目
|
||||
Hswd.put("FFLEX8","wl");//物料
|
||||
Hswd.put("FFLEX10","zc");//资产
|
||||
Hswd.put("FFLEX12","wlz");//物料组
|
||||
Hswd.put("FFLEX13","khz");//客户组
|
||||
Map<String,String> fxHswd=new HashMap<String,String>();//核算维度对照表
|
||||
fxHswd.put("gys","FFLEX4");//供应商
|
||||
fxHswd.put("kh","FFLEX6");//客户
|
||||
fxHswd.put("yg","FFLEX7");//员工
|
||||
fxHswd.put("bm","FFLEX5");//部门
|
||||
fxHswd.put("fyxm","FFLEX9");//费用项目
|
||||
fxHswd.put("wl","FFLEX8");//物料
|
||||
fxHswd.put("zc","FFLEX10");//资产
|
||||
fxHswd.put("wlz","FFLEX12");//物料组
|
||||
fxHswd.put("khz","FFLEX13");//客户组
|
||||
SimpleDateFormat sim=new SimpleDateFormat("yyyy-MM-dd");
|
||||
List<String> jlist=new ArrayList<String>();//借方
|
||||
List<String> dlist=new ArrayList<String>();//贷方
|
||||
String requestid=requestInfo.getRequestid();//
|
||||
String mainid="";//
|
||||
String zt="";//账套
|
||||
String zz="";//组织
|
||||
String zb="";//账薄
|
||||
String zzjdhl="";//做账节点汇率
|
||||
String bz="";//币种
|
||||
String sfxr="";//是否写入
|
||||
RecordSet re=new RecordSet();
|
||||
String errormess="";
|
||||
float zje=0.0f;
|
||||
//1:借方 2:贷方
|
||||
String sql= " select a.sfxr,a.zzjdhl,a.bz,a.id,a.zt,a.zz,a.zb,b.jfkmbm kmbh,b.zy,b.jfje je,b.bm,b.yg,b.kh,b.gys,b.fyxm,b.wl,b.zc,b.wlz,b.khz,b.jfkmmc kmmc,b.hswd,b.yje,'1' entrylx from formtable_main_22 a,formtable_main_22_dt4 b where a.id=b.mainid and a.requestid='"+requestid+"'"+
|
||||
" union all "+
|
||||
" select a.sfxr,a.zzjdhl,a.bz,a.id,a.zt,a.zz,a.zb,b.dfkmbm kmbh,b.zy,b.dfje je,b.bm,b.yg,b.kh,b.gys,b.fyxm,b.wl,b.zc,b.wlz,b.khz,b.dfkmmc kmmc,b.hswd,b.yje,'2' entrylx from formtable_main_22 a,formtable_main_22_dt5 b where a.id=b.mainid and a.requestid='"+requestid+"' ";
|
||||
log.error(requestid+"CreateVoucherBx"+sql);
|
||||
//out.print(sql);
|
||||
|
||||
re.execute(sql);
|
||||
JSONArray FEntity=new JSONArray();
|
||||
lable1:while(re.next()){
|
||||
//拼接科目信息
|
||||
sfxr=Util.null2String(re.getString("sfxr")).trim();
|
||||
zt=Util.null2String(re.getString("zt")).trim();
|
||||
zz=Util.null2String(re.getString("zz")).trim();
|
||||
zb=Util.null2String(re.getString("zb")).trim();
|
||||
JSONObject FEntityDetail=new JSONObject();
|
||||
String FEXPLANATION=Util.null2String(re.getString("zy"));//摘要
|
||||
FEntityDetail.put("FEXPLANATION",FEXPLANATION);
|
||||
JSONObject FACCOUNTID=new JSONObject();//科目 FNumber
|
||||
String demoKm=Util.null2String(re.getString("kmbh")).trim();
|
||||
if("".equals(demoKm)){
|
||||
errormess="科目编号不能为空";//科目编号不能为空
|
||||
break;
|
||||
}else{
|
||||
FACCOUNTID.put("FNumber",demoKm);
|
||||
}
|
||||
FEntityDetail.put("FACCOUNTID",FACCOUNTID);
|
||||
JSONObject FDetailID=new JSONObject();//辅助核算项 FDETAILID__FFLEX10 FNumber
|
||||
//获取科目的辅助核算项
|
||||
String demoHswd=getFzhx(demoKm,zt,zz,zb,Hswd);
|
||||
//out.print("demoHswd--"+demoHswd);
|
||||
if(demoHswd!=null&&!"".equals(demoHswd.trim())){
|
||||
String[] demoHswds=demoHswd.split(",");
|
||||
for(String str:demoHswds){
|
||||
if(str!=null&&!"".equals(str)){
|
||||
JSONObject Hswdjson=new JSONObject();
|
||||
String number=Util.null2String(re.getString(str)).trim();
|
||||
if(!"".equals(number)){
|
||||
Hswdjson.put("FNumber",number);
|
||||
FDetailID.put("FDETAILID__"+fxHswd.get(str),Hswdjson);
|
||||
}else{
|
||||
errormess=str+"核算维度没有设置值!";
|
||||
break lable1;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
FEntityDetail.put("FDetailID",FDetailID);
|
||||
JSONObject FCURRENCYID=new JSONObject();//币别 FNumber
|
||||
FCURRENCYID.put("FNumber","IDR");//默认印尼盾
|
||||
FEntityDetail.put("FCURRENCYID",FCURRENCYID);
|
||||
JSONObject FEXCHANGERATETYPE=new JSONObject();;//汇率类型
|
||||
FEXCHANGERATETYPE.put("FNumber","HLTX01_SYS");//默认
|
||||
FEntityDetail.put("FEXCHANGERATETYPE",FEXCHANGERATETYPE);
|
||||
String FEXCHANGERATE ="1";//汇率
|
||||
FEntityDetail.put("FEXCHANGERATE",FEXCHANGERATE);
|
||||
String FUnitId ="";//单位
|
||||
//FEntityDetail.put("FUnitId",FUnitId);
|
||||
String FPrice="0";//单价
|
||||
//FEntityDetail.put("FPrice",FPrice);
|
||||
String FQty="0";//数量
|
||||
//FEntityDetail.put("FQty",FQty);
|
||||
String FAMOUNTFOR="";//原币金额
|
||||
String entrylx=Util.null2String(re.getString("entrylx"));
|
||||
String FDEBIT="";//借方金额
|
||||
String FCREDIT="";//贷方金额
|
||||
String FDC="";//借贷方向
|
||||
if("1".equals(entrylx)){//借方
|
||||
FDEBIT=Util.null2String(re.getString("je"));
|
||||
FDC="1";
|
||||
}else{
|
||||
FCREDIT=Util.null2String(re.getString("je"));
|
||||
FDC="0";
|
||||
}
|
||||
FEntityDetail.put("FCREDIT",FCREDIT);
|
||||
FEntityDetail.put("FDEBIT",FDEBIT);
|
||||
FEntityDetail.put("FDC",FDC);
|
||||
String FSettleTypeID="";//结束方式 FNumber
|
||||
String FSETTLENO ="";//结算号
|
||||
|
||||
String FAcctFullName=getKmname(demoKm,zt,zz,zb);//科目全称
|
||||
String FACCOUNTNAME=getKmname(demoKm,zt,zz,zb);//科目名称
|
||||
//FEntityDetail.put("FAcctFullName",FAcctFullName);
|
||||
//FEntityDetail.put("FACCOUNTNAME",FACCOUNTNAME);
|
||||
FEntity.add(FEntityDetail);
|
||||
}
|
||||
if(!"".equals(errormess)){
|
||||
requestInfo.getRequestManager().setMessageid(errormess);
|
||||
requestInfo.getRequestManager().setMessage(errormess);//提醒信息id
|
||||
requestInfo.getRequestManager().setMessagecontent("写入K3系统不成功,系统反馈信息如下:"+errormess);//提醒信息内容
|
||||
|
||||
return Action.FAILURE_AND_CONTINUE;
|
||||
}
|
||||
//out.print("errormess"+errormess);
|
||||
//out.print("FEntityDetail"+FEntity.toJSONString());
|
||||
//设置主数据
|
||||
JSONObject FAccountBookID=new JSONObject();//账薄
|
||||
FAccountBookID.put("FNumber",zb);
|
||||
Model.put("FAccountBookID",FAccountBookID);
|
||||
String FDate=sim.format(new Date());
|
||||
Model.put("FDate",FDate);
|
||||
JSONObject FVOUCHERGROUPID=new JSONObject();//凭证字默认AP
|
||||
FVOUCHERGROUPID.put("FNumber","PZZ3");
|
||||
Model.put("FVOUCHERGROUPID",FVOUCHERGROUPID);
|
||||
String FYEAR=sim.format(new Date()).split("-")[0];//会计年度
|
||||
String FPERIOD =sim.format(new Date()).split("-")[1];//期间
|
||||
Model.put("FYEAR",FYEAR);
|
||||
Model.put("FPERIOD",FPERIOD);
|
||||
String FDEBITTOTAL=getjfZje(requestid);//借方总金额:FDEBITTOTAL
|
||||
String FCREDITTOTAL=getdfZje(requestid);//贷方总金额:FCREDITTOTAL
|
||||
Model.put("FDEBITTOTAL",FDEBITTOTAL);
|
||||
Model.put("FCREDITTOTAL",FCREDITTOTAL);
|
||||
String FCreateDate=sim.format(new Date());//创建日期:FCreateDate
|
||||
JSONObject FACCBOOKORGID=new JSONObject();//核算组织:FACCBOOKORGID
|
||||
FACCBOOKORGID.put("FNumber",zz);
|
||||
Model.put("FACCBOOKORGID",FACCBOOKORGID);
|
||||
//Model.put("FCreateDate",FCreateDate);
|
||||
String FPRINTTIMES="0";//打印次数:FPRINTTIMES
|
||||
String FCurrentYear=sim.format(new Date()).split("-")[0];//当前年度:FCurrentYear
|
||||
String FCurrentPeriod=sim.format(new Date()).split("-")[1];//当前期间:FCurrentPeriod
|
||||
Model.put("FPRINTTIMES",FPRINTTIMES);
|
||||
//Model.put("FCurrentYear",FCurrentYear);
|
||||
//Model.put("FCurrentPeriod",FCurrentPeriod);
|
||||
Model.put("FEntity",FEntity);
|
||||
//Models.add(Model);
|
||||
//凭借主数据
|
||||
VOUCHER.put("NeedReturnFields","[\"FVOUCHERID\",\"FVOUCHERGROUPNO\"]");
|
||||
VOUCHER.put("IsAutoSubmitAndAudit",true);
|
||||
VOUCHER.put("Model",Model);
|
||||
log.error(VOUCHER.toJSONString());
|
||||
/*开始调用接口
|
||||
1;登陆
|
||||
2;调用接口
|
||||
*/
|
||||
//String Fv=getFv(Queryurl+"595130",baseis,out);
|
||||
//out.print(Fv);
|
||||
if(VOUCHER!=null&&VOUCHER.size()>0&&("".equals(sfxr)||"1".equals(sfxr))){
|
||||
RecordSet updRec=new RecordSet();
|
||||
com.jet.util.InvokeHelper.POST_K3CloudURL="http://k3.jet.co.id:8880/k3cloud/";
|
||||
String dbid="5d48f604c8361e";//dbid1;//"5d48f604c8361e";//"5a964ecc967246";
|
||||
String uuid=uuid1;
|
||||
String password=password2;
|
||||
org.json.JSONObject resultjson=null;
|
||||
int lang=2052;
|
||||
try {
|
||||
boolean flag=InvokeHelper.Login(dbid, uuid, password, lang);
|
||||
//out.print(flag);
|
||||
if(flag){//登陆成功
|
||||
resultjson=com.jet.util.InvokeHelper.Save("GL_VOUCHER",VOUCHER.toJSONString());
|
||||
boolean flag1=resultjson.getBoolean("flag");
|
||||
String resultstr=resultjson.getString("sResult");
|
||||
log.error("resultstr"+resultstr);
|
||||
if(flag1){
|
||||
JSONObject HAHA=JSONObject.parseObject(resultstr);
|
||||
JSONObject Result=HAHA.getJSONObject("Result");
|
||||
JSONObject ResponseStatus=Result.getJSONObject("ResponseStatus");
|
||||
boolean IsSuccess=ResponseStatus.getBoolean("IsSuccess");
|
||||
if(IsSuccess){
|
||||
updRec.execute("update formtable_main_22 set sfxr='0' where requestid='"+requestid+"' ");
|
||||
String FVOUCHERID=Result.getString("Id");
|
||||
String Fv=getFv(Queryurl+""+FVOUCHERID,baseis);
|
||||
updRec.execute("update formtable_main_22 set pzbhdyc='"+Fv+"' where requestid='"+requestid+"' ");
|
||||
//out.print("成功"+FVOUCHERID);
|
||||
|
||||
}else{
|
||||
//out.print("失败");
|
||||
requestInfo.getRequestManager().setMessageid("失败");
|
||||
requestInfo.getRequestManager().setMessage("失败");//提醒信息id
|
||||
requestInfo.getRequestManager().setMessagecontent("写入K3系统不成功,系统反馈信息如下:"+HAHA.toString());//提醒信息内容
|
||||
|
||||
return Action.FAILURE_AND_CONTINUE;
|
||||
}
|
||||
}else{
|
||||
//out.print("失败"+resultstr);
|
||||
requestInfo.getRequestManager().setMessageid("失败");
|
||||
requestInfo.getRequestManager().setMessage("失败");//提醒信息id
|
||||
requestInfo.getRequestManager().setMessagecontent("写入K3系统不成功,系统反馈信息如下:"+resultstr.toString());//提醒信息内容
|
||||
|
||||
return Action.FAILURE_AND_CONTINUE;
|
||||
}
|
||||
|
||||
}
|
||||
} catch (Exception e) {
|
||||
//TODO Auto-generated catch block
|
||||
log.error("GL_VOUCHER--Exception"+e.getMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
//更具ID获取凭证编号
|
||||
public String getFv(String url,String basis)throws Exception{
|
||||
String Fv="";
|
||||
//out.print("url-"+url+" basis"+basis+" ");
|
||||
try{
|
||||
String result=sendGet(url,"",basis);
|
||||
// out.print("url-"+url+" basis"+basis+" result"+result);
|
||||
JSONArray json=JSONArray.parseArray(result);
|
||||
if(json!=null&&json.size()>0){
|
||||
for(int i=0;i<json.size();i++){
|
||||
JSONObject obj= json.getJSONObject(i);
|
||||
Fv=obj.getString("Voucher No");
|
||||
}
|
||||
}
|
||||
}catch(Exception e){
|
||||
|
||||
}
|
||||
return Fv;
|
||||
}
|
||||
public static String sendGet(String url, String param,String basis) {
|
||||
String result = "";
|
||||
InputStream in = null;
|
||||
try {
|
||||
String urlNameString = url ;
|
||||
URL realUrl = new URL(urlNameString);
|
||||
URLConnection connection = realUrl.openConnection();
|
||||
String auth=basis;//"JNT:JNT2019";
|
||||
String code = new sun.misc.BASE64Encoder().encode(auth.getBytes());
|
||||
connection.setRequestProperty("Authorization", "Basic " + code);
|
||||
connection.connect();
|
||||
Map<String, List<String>> map = connection.getHeaderFields();
|
||||
|
||||
|
||||
for (String key : map.keySet()) {
|
||||
System.out.println(key + "--->" + map.get(key));
|
||||
}
|
||||
//接收核心返回过来的数据 xml 需要解析
|
||||
in =connection.getInputStream();
|
||||
byte[] b =getBytes(in);
|
||||
if(b.length>0){
|
||||
result=new String(b);
|
||||
}
|
||||
System.out.println(b.length);
|
||||
} catch (Exception e) {
|
||||
|
||||
System.out.println(e.getMessage());
|
||||
e.printStackTrace();
|
||||
}finally {
|
||||
try {
|
||||
if (in != null) {
|
||||
in.close();
|
||||
}
|
||||
} catch (Exception e2) {
|
||||
System.out.println(e2.getMessage());
|
||||
e2.printStackTrace();
|
||||
}
|
||||
}
|
||||
//System.out.println("de"+result);
|
||||
return result;
|
||||
}
|
||||
public static byte[] getBytes(InputStream fis){
|
||||
Logger log = Logger.getLogger(Logger.class);
|
||||
byte[] buffer = null;
|
||||
try {
|
||||
//File file = new File(filePath);
|
||||
//FileInputStream fis = new FileInputStream(file);
|
||||
ByteArrayOutputStream bos = new ByteArrayOutputStream(1000);
|
||||
byte[] b = new byte[10000];
|
||||
int n;
|
||||
while ((n = fis.read(b)) != -1) {
|
||||
bos.write(b, 0, n);
|
||||
}
|
||||
fis.close();
|
||||
bos.close();
|
||||
buffer = bos.toByteArray();
|
||||
} catch (FileNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
System.out.println("buffer--->"+buffer.length);
|
||||
return buffer;
|
||||
}
|
||||
//获取借方总金额
|
||||
public static String getjfZje(String requestid){
|
||||
RecordSet re=new RecordSet();
|
||||
String je="";
|
||||
String sql="select sum(jfje) jfje from formtable_main_22 a,formtable_main_22_dt4 b where a.id=b.mainid and a.requestid='"+requestid+"'";
|
||||
re.execute(sql);
|
||||
while(re.next()){
|
||||
je=re.getString("jfje") ;
|
||||
}
|
||||
return je;
|
||||
}
|
||||
//获取贷方总金额
|
||||
public static String getdfZje(String requestid){
|
||||
RecordSet re=new RecordSet();
|
||||
String je="";
|
||||
String sql="select sum(dfje) dfje from formtable_main_22 a,formtable_main_22_dt5 b where a.id=b.mainid and a.requestid='"+requestid+"'";
|
||||
re.execute(sql);
|
||||
while(re.next()){
|
||||
je=re.getString("dfje") ;
|
||||
}
|
||||
return je;
|
||||
}
|
||||
//获取赋值核算类型
|
||||
public String getFzhx(String km,String zt,String zz,String zb,Map<String,String> Hswd ){
|
||||
String FDIMENSION="";//核算维度
|
||||
RecordSet re=new RecordSet();
|
||||
String sql="select b.FDIMENSION from uf_accountinfo a,uf_accountinfo_dt1 b where a.id=b.mainid and a.zt='"+zt+"' and b.FNUMBER='"+km+"' and b.forgnumber='"+zz+"' and FAcctBookNumber='"+zb+"' ";
|
||||
//out.print(sql);
|
||||
re.execute(sql);
|
||||
while(re.next()){
|
||||
String str=Util.null2String(re.getString("FDIMENSION")).trim() ;
|
||||
String[] FDIMENSIONs=str.split(",");
|
||||
for(String demo:FDIMENSIONs){
|
||||
if(demo!=null&&!"".equals(demo)){
|
||||
FDIMENSION=FDIMENSION+Hswd.get(demo)+",";
|
||||
}
|
||||
}
|
||||
}
|
||||
if(FDIMENSION.endsWith(",")){
|
||||
FDIMENSION=FDIMENSION.substring(0,FDIMENSION.length()-1);
|
||||
}
|
||||
return FDIMENSION;
|
||||
}
|
||||
//insert 事务
|
||||
public boolean SynInsert1(List<String> array){
|
||||
if(array==null||array.size()<=0){
|
||||
return false;
|
||||
}
|
||||
Logger log = Logger.getLogger(DataSource.class);
|
||||
RecordSetTrans RecordSetTrans=new RecordSetTrans();
|
||||
RecordSetTrans.setAutoCommit(false);
|
||||
boolean flag=true;
|
||||
|
||||
try{
|
||||
RecordSetTrans.setAutoCommit(false);
|
||||
// stmt = conn.createStatement();
|
||||
for(String str:array){
|
||||
//int index =RecordSetTrans.executeUpdate(str);
|
||||
flag=RecordSetTrans.executeSql(str);
|
||||
log.error("SynInsert--"+str);
|
||||
if(!flag){
|
||||
//flag=false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(!flag){//事务回滚
|
||||
RecordSetTrans.rollback();
|
||||
}else{
|
||||
RecordSetTrans.commit();
|
||||
}
|
||||
}catch(Exception e){
|
||||
log.error("SynInsert--Exception "+e.getMessage());
|
||||
flag=false;
|
||||
}
|
||||
|
||||
return flag;
|
||||
}
|
||||
//获取科目名称
|
||||
public String getKmname(String km,String zt,String zz,String zb){
|
||||
String FNAME="";//核算维度
|
||||
RecordSet re=new RecordSet();
|
||||
String sql="select b.FNAME from uf_accountinfo a,uf_accountinfo_dt1 b where a.id=b.mainid and a.zt='"+zt+"' and b.FNUMBER='"+km+"' and b.forgnumber='"+zz+"' and FAcctBookNumber='"+zb+"' ";
|
||||
re.execute(sql);
|
||||
while(re.next()){
|
||||
FNAME=Util.null2String(re.getString("FNAME"));
|
||||
}
|
||||
return FNAME;
|
||||
}
|
||||
//获取币种的小数位
|
||||
public int getXsw(String bz){
|
||||
int xsw=0;
|
||||
RecordSet re=new RecordSet();
|
||||
String sql="select * from uf_k3bz where bh='"+bz+"'";
|
||||
re.execute(sql);
|
||||
while(re.next()){
|
||||
xsw=Integer.parseInt(Util.null2o(re.getString("xsw"))) ;
|
||||
}
|
||||
return xsw;
|
||||
}
|
||||
|
||||
//浮点型转换
|
||||
public static float getfloats(String demo,String demo1,int len){
|
||||
Logger log = Logger.getLogger(BigDecimal.class);
|
||||
if(len==0){
|
||||
len=0;
|
||||
}
|
||||
String str=Util.null2String(demo);
|
||||
String str1=Util.null2String(demo1);
|
||||
if("".equals(str)||"".equals(str.trim())||"null".equalsIgnoreCase(str.trim())){
|
||||
return 0;
|
||||
}
|
||||
if("".equals(str1)||"".equals(str.trim())||"null".equalsIgnoreCase(str1.trim())){
|
||||
str1="1";
|
||||
}
|
||||
float fl=0.0f;
|
||||
//String str=Util.null2String(demo);
|
||||
try{
|
||||
if(str.trim().length()>0){
|
||||
BigDecimal b1 = new BigDecimal(str.trim());
|
||||
BigDecimal b2 = new BigDecimal(str1.trim());
|
||||
BigDecimal b3=b1.multiply(b2);
|
||||
//System.out.println(b1.setScale(2,BigDecimal.ROUND_HALF_UP));
|
||||
fl=b3.setScale(len,BigDecimal.ROUND_HALF_UP).floatValue();
|
||||
}
|
||||
log.error("getfloats"+fl);
|
||||
}catch(Exception e){
|
||||
log.error(demo+"getfloats异常"+e.getMessage());
|
||||
}
|
||||
return fl;
|
||||
}
|
||||
|
||||
|
||||
//浮点型转换
|
||||
public static float getfloats1(String demo,String demo1,int len){
|
||||
Logger log = Logger.getLogger(BigDecimal.class);
|
||||
if(len==0){
|
||||
len=0;
|
||||
}
|
||||
String str=Util.null2String(demo);
|
||||
String str1=Util.null2String(demo1);
|
||||
if("".equals(str)||"".equals(str.trim())||"null".equalsIgnoreCase(str.trim())){
|
||||
str="0";
|
||||
}
|
||||
if("".equals(str1)||"".equals(str.trim())||"null".equalsIgnoreCase(str1.trim())){
|
||||
str1="0";
|
||||
}
|
||||
float fl=0.0f;
|
||||
//String str=Util.null2String(demo);
|
||||
try{
|
||||
if(str.trim().length()>0){
|
||||
BigDecimal b1 = new BigDecimal(str.trim());
|
||||
BigDecimal b2 = new BigDecimal(str1.trim());
|
||||
BigDecimal b3=b1.add(b2);
|
||||
//System.out.println(b1.setScale(2,BigDecimal.ROUND_HALF_UP));
|
||||
fl=b3.setScale(len,BigDecimal.ROUND_HALF_UP).floatValue();
|
||||
}
|
||||
log.error("getfloats"+fl);
|
||||
}catch(Exception e){
|
||||
log.error(demo+"getfloats异常"+e.getMessage());
|
||||
}
|
||||
return fl;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,787 @@
|
|||
package com.jet.action;
|
||||
|
||||
import weaver.soa.workflow.request.RequestInfo;
|
||||
import weaver.workflow.action.BaseAction;
|
||||
import weaver.conn.RecordSet;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
|
||||
import weaver.hrm.HrmUserVarify;
|
||||
import weaver.hrm.User;
|
||||
import weaver.general.BaseBean;
|
||||
import weaver.general.Util;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.sql.Connection;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.Statement;
|
||||
import weaver.general.StaticObj;
|
||||
import weaver.interfaces.datasource.DataSource;
|
||||
import weaver.formmode.setup.ModeRightInfo;
|
||||
import java.sql.Connection;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Statement;
|
||||
import weaver.general.StaticObj;
|
||||
import weaver.interfaces.datasource.DataSource;
|
||||
import weaver.interfaces.workflow.action.Action;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.PrintWriter;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
import org.apache.http.Header;
|
||||
import org.apache.http.HttpResponse;
|
||||
import org.apache.http.HttpStatus;
|
||||
import org.apache.http.client.HttpClient;
|
||||
import org.apache.http.client.methods.HttpPost;
|
||||
import org.apache.http.entity.*;
|
||||
import org.apache.http.*;
|
||||
import org.apache.http.util.*;
|
||||
import org.apache.http.impl.client.DefaultHttpClient;
|
||||
import org.apache.http.params.CoreConnectionPNames;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.nio.charset.Charset;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import weaver.conn.RecordSetTrans;
|
||||
import java.io.PrintWriter;
|
||||
import com.jet.util.*;
|
||||
import org.json.*;
|
||||
public class CreateVoucherBx2 extends BaseAction{
|
||||
@Override
|
||||
public String execute(RequestInfo requestInfo) {
|
||||
// TODO Auto-generated method stub
|
||||
Logger log = Logger.getLogger(JSONObject.class);
|
||||
RecordSet urlre=new RecordSet();
|
||||
String urlsql="select * from uf_urlinfo where ms='model'";
|
||||
log.error(requestInfo.getRequestid()+"CreateVoucherBx2");
|
||||
urlre.execute(urlsql);
|
||||
String url="";
|
||||
String username="";
|
||||
String password1="";
|
||||
String dbid1="";
|
||||
String uuid1="";
|
||||
String password2="";
|
||||
while(urlre.next()){
|
||||
url=Util.null2String(urlre.getString("url"));
|
||||
username=Util.null2String(urlre.getString("username"));
|
||||
password1=Util.null2String(urlre.getString("password"));
|
||||
dbid1=Util.null2String(urlre.getString("dbid"));
|
||||
uuid1=Util.null2String(urlre.getString("uuid"));
|
||||
password2=Util.null2String(urlre.getString("password1"));
|
||||
}
|
||||
String baseis=username+":"+password1;
|
||||
String Queryurl=url+"GlVoucher/";
|
||||
//log.error("deeded");
|
||||
//out.print("haha");
|
||||
Map<String,String> Hswd=new HashMap<String,String>();//核算维度对照表
|
||||
JSONObject VOUCHER=new JSONObject();//VOUCHER
|
||||
JSONArray Models=new JSONArray();//ModelS
|
||||
JSONObject Model=new JSONObject();//Model
|
||||
Hswd.put("FFLEX4","gys");//供应商
|
||||
Hswd.put("FFLEX6","kh");//客户
|
||||
Hswd.put("FFLEX7","yg");//员工
|
||||
Hswd.put("FFLEX5","bm");//部门
|
||||
Hswd.put("FFLEX9","fyxm");//费用项目
|
||||
Hswd.put("FFLEX8","wl");//物料
|
||||
Hswd.put("FFLEX10","zc");//资产
|
||||
Hswd.put("FFLEX12","wlz");//物料组
|
||||
Hswd.put("FFLEX13","khz");//客户组
|
||||
Map<String,String> fxHswd=new HashMap<String,String>();//核算维度对照表
|
||||
fxHswd.put("gys","FFLEX4");//供应商
|
||||
fxHswd.put("kh","FFLEX6");//客户
|
||||
fxHswd.put("yg","FFLEX7");//员工
|
||||
fxHswd.put("bm","FFLEX5");//部门
|
||||
fxHswd.put("fyxm","FFLEX9");//费用项目
|
||||
fxHswd.put("wl","FFLEX8");//物料
|
||||
fxHswd.put("zc","FFLEX10");//资产
|
||||
fxHswd.put("wlz","FFLEX12");//物料组
|
||||
fxHswd.put("khz","FFLEX13");//客户组
|
||||
SimpleDateFormat sim=new SimpleDateFormat("yyyy-MM-dd");
|
||||
List<String> jlist=new ArrayList<String>();//借方
|
||||
List<String> dlist=new ArrayList<String>();//贷方
|
||||
String requestid="8015";//
|
||||
String mainid="";//
|
||||
String zt="";//账套
|
||||
String zz="";//组织
|
||||
String zb="";//账薄
|
||||
String zzjdhl="";//做账节点汇率
|
||||
String bz="";//币种
|
||||
String sfxr="";//是否写入
|
||||
String cnfkjdhl="";//出纳汇率
|
||||
String fkyxzh="";//付款银行账号
|
||||
String pzbhdyc="";//凭证编号(第一次)
|
||||
RecordSet re=new RecordSet();
|
||||
String errormess="";
|
||||
float zje=0.0f;
|
||||
//1:借方 2:贷方
|
||||
String sql= " select a.* from formtable_main_22 a where a.requestid='"+requestid+"'";
|
||||
re.execute(sql);
|
||||
while(re.next()){
|
||||
zt=Util.null2String(re.getString("zt")).trim();
|
||||
zz=Util.null2String(re.getString("zz")).trim();
|
||||
zb=Util.null2String(re.getString("zb")).trim();
|
||||
cnfkjdhl=Util.null2String(re.getString("cnfkjdhl")).trim();
|
||||
fkyxzh=Util.null2String(re.getString("fkyxzh")).trim();
|
||||
pzbhdyc=Util.null2String(re.getString("pzbhdyc")).trim();
|
||||
}
|
||||
String tskm =SpelKm(zt,zz,zb,"3");//获取特殊科目 汇率差设置
|
||||
|
||||
float dje=getfloats(getDteJe5(requestid),"1",0);//第一次贷方金额
|
||||
String ysje=getDteJe(requestid);//原始金额
|
||||
float newdje=getfloats(ysje,cnfkjdhl,0);//原始换算之后的金额
|
||||
//获取金额差
|
||||
JSONArray FEntitys=null;
|
||||
float hlcJe= getfloats2(newdje+"",dje+"",0);//汇率差
|
||||
//out.print("ysje"+ysje);
|
||||
//out.print("cnfkjdhl"+cnfkjdhl);
|
||||
//out.print("hlcJe"+hlcJe);
|
||||
//out.print("dje"+dje);
|
||||
//out.print("newdje"+newdje);
|
||||
if(dje==newdje){
|
||||
|
||||
JSONObject FEntity=new JSONObject();
|
||||
Map<String,Object> objMap=getModel(requestid,Hswd,fxHswd);
|
||||
Boolean.getBoolean((String)objMap.get("flag"));
|
||||
boolean flag=(Boolean)objMap.get("flag");
|
||||
if(flag){
|
||||
FEntitys=(JSONArray)objMap.get("FEntity");
|
||||
}else{
|
||||
errormess= (String)objMap.get("mess");
|
||||
}
|
||||
//生成贷方
|
||||
FEntity.put("FEXPLANATION","FEXPLANATION");//摘要
|
||||
FEntity.put("FACCOUNTID",fkyxzh);//科目
|
||||
JSONObject FCURRENCYID=new JSONObject();//币别 FNumber
|
||||
FCURRENCYID.put("FNumber","IDR");//默认印尼盾
|
||||
FEntity.put("FCURRENCYID",FCURRENCYID);
|
||||
JSONObject FEXCHANGERATETYPE=new JSONObject();;//汇率类型
|
||||
FEXCHANGERATETYPE.put("FNumber","HLTX01_SYS");//默认
|
||||
FEntity.put("FEXCHANGERATETYPE",FEXCHANGERATETYPE);
|
||||
String FEXCHANGERATE ="1";//汇率
|
||||
FEntity.put("FEXCHANGERATE",FEXCHANGERATE);
|
||||
FEntity.put("FCREDIT",newdje);
|
||||
FEntity.put("FDEBIT","");
|
||||
FEntity.put("FDC","0");
|
||||
FEntitys.add(FEntity);
|
||||
|
||||
|
||||
//FEntity.put("FEXPLANATION","FEXPLANATION");//摘要
|
||||
//FEntity.put("FEXPLANATION","FEXPLANATION");//摘要
|
||||
}else{ //付款小于 做账金额
|
||||
//贷银行存款 借汇率差以及 第一次凭证的贷方
|
||||
JSONObject FEntity=new JSONObject();
|
||||
Map<String,Object> objMap=getModel(requestid,Hswd,fxHswd);
|
||||
|
||||
//Boolean.getBoolean((String)objMap.get("flag"));
|
||||
boolean flag=(Boolean)objMap.get("flag");
|
||||
//out.print(flag);
|
||||
if(flag){
|
||||
FEntitys=(JSONArray)objMap.get("FEntity");
|
||||
}else{
|
||||
errormess= (String)objMap.get("mess");
|
||||
}
|
||||
//out.print(objMap.toString());
|
||||
//借汇率差
|
||||
JSONObject FACCOUNTID=new JSONObject();//科目 FNumber
|
||||
FACCOUNTID.put("FNumber",tskm);
|
||||
FEntity.put("FEXPLANATION","FEXPLANATION");//摘要
|
||||
FEntity.put("FACCOUNTID",FACCOUNTID);//科目
|
||||
JSONObject FCURRENCYID=new JSONObject();//币别 FNumber
|
||||
FCURRENCYID.put("FNumber","IDR");//默认印尼盾
|
||||
FEntity.put("FCURRENCYID",FCURRENCYID);
|
||||
JSONObject FEXCHANGERATETYPE=new JSONObject();;//汇率类型
|
||||
FEXCHANGERATETYPE.put("FNumber","HLTX01_SYS");//默认
|
||||
FEntity.put("FEXCHANGERATETYPE",FEXCHANGERATETYPE);
|
||||
String FEXCHANGERATE ="1";//汇率
|
||||
FEntity.put("FEXCHANGERATE",FEXCHANGERATE);
|
||||
FEntity.put("FCREDIT","");
|
||||
FEntity.put("FDEBIT",hlcJe);
|
||||
FEntity.put("FDC","1");
|
||||
FEntitys.add(FEntity);
|
||||
//贷银行
|
||||
JSONObject FACCOUNTID1=new JSONObject();//科目 FNumber
|
||||
FACCOUNTID1.put("FNumber",fkyxzh);
|
||||
JSONObject FEntity1=new JSONObject();
|
||||
FEntity1.put("FEXPLANATION","FEXPLANATION");//摘要
|
||||
FEntity1.put("FACCOUNTID",FACCOUNTID1);//科目
|
||||
JSONObject FCURRENCYID2=new JSONObject();//币别 FNumber
|
||||
FCURRENCYID2.put("FNumber","IDR");//默认印尼盾
|
||||
FEntity1.put("FCURRENCYID",FCURRENCYID2);
|
||||
JSONObject FEXCHANGERATETYPE2=new JSONObject();;//汇率类型
|
||||
FEXCHANGERATETYPE2.put("FNumber","HLTX01_SYS");//默认
|
||||
FEntity1.put("FEXCHANGERATETYPE",FEXCHANGERATETYPE2);
|
||||
String FEXCHANGERATE2 ="1";//汇率
|
||||
FEntity1.put("FEXCHANGERATE",FEXCHANGERATE2);
|
||||
FEntity1.put("FCREDIT",newdje);
|
||||
FEntity1.put("FDEBIT","");
|
||||
FEntity1.put("FDC","0");
|
||||
FEntitys.add(FEntity1);
|
||||
}
|
||||
if(!"".equals(errormess)){
|
||||
requestInfo.getRequestManager().setMessageid(errormess);
|
||||
requestInfo.getRequestManager().setMessage(errormess);//提醒信息id
|
||||
requestInfo.getRequestManager().setMessagecontent("写入K3系统不成功,系统反馈信息如下:"+errormess);//提醒信息内容
|
||||
|
||||
return Action.FAILURE_AND_CONTINUE;
|
||||
}
|
||||
|
||||
JSONObject FAccountBookID=new JSONObject();//账薄
|
||||
FAccountBookID.put("FNumber",zb);
|
||||
Model.put("FAccountBookID",FAccountBookID);
|
||||
String FDate=sim.format(new Date());
|
||||
Model.put("FDate",FDate);
|
||||
JSONObject FVOUCHERGROUPID=new JSONObject();//凭证字默认AP
|
||||
FVOUCHERGROUPID.put("FNumber","PZZ3");
|
||||
Model.put("FVOUCHERGROUPID",FVOUCHERGROUPID);
|
||||
String FYEAR=sim.format(new Date()).split("-")[0];//会计年度
|
||||
String FPERIOD =sim.format(new Date()).split("-")[1];//期间
|
||||
Model.put("FYEAR",FYEAR);
|
||||
Model.put("FPERIOD",FPERIOD);
|
||||
String FDEBITTOTAL=newdje+"";//借方总金额:FDEBITTOTAL
|
||||
String FCREDITTOTAL=newdje+"";//贷方总金额:FCREDITTOTAL
|
||||
Model.put("FDEBITTOTAL",FDEBITTOTAL);
|
||||
Model.put("FCREDITTOTAL",FCREDITTOTAL);
|
||||
String FCreateDate=sim.format(new Date());//创建日期:FCreateDate
|
||||
JSONObject FACCBOOKORGID=new JSONObject();//核算组织:FACCBOOKORGID
|
||||
FACCBOOKORGID.put("FNumber",zz);
|
||||
Model.put("FACCBOOKORGID",FACCBOOKORGID);
|
||||
//Model.put("FCreateDate",FCreateDate);
|
||||
String FPRINTTIMES="0";//打印次数:FPRINTTIMES
|
||||
String FCurrentYear=sim.format(new Date()).split("-")[0];//当前年度:FCurrentYear
|
||||
String FCurrentPeriod=sim.format(new Date()).split("-")[1];//当前期间:FCurrentPeriod
|
||||
Model.put("FPRINTTIMES",FPRINTTIMES);
|
||||
//Model.put("FCurrentYear",FCurrentYear);
|
||||
//Model.put("FCurrentPeriod",FCurrentPeriod);
|
||||
Model.put("FEntity",FEntitys);
|
||||
//Models.add(Model);
|
||||
Model.put("F_RTA_Remarks",pzbhdyc);
|
||||
//凭借主数据
|
||||
VOUCHER.put("NeedReturnFields","[\"FVOUCHERID\",\"FVOUCHERGROUPNO\"]");
|
||||
VOUCHER.put("IsAutoSubmitAndAudit",true);
|
||||
VOUCHER.put("Model",Model);
|
||||
log.error("CreateVoucherBx2"+VOUCHER.toJSONString());
|
||||
/*开始调用接口
|
||||
1;登陆
|
||||
2;调用接口
|
||||
*/
|
||||
//String Fv=getFv(Queryurl+"595130",baseis,out);
|
||||
//out.print(Fv);
|
||||
if(VOUCHER!=null&&VOUCHER.size()>0&&("".equals(sfxr)||"1".equals(sfxr))){
|
||||
RecordSet updRec=new RecordSet();
|
||||
com.jet.util.InvokeHelper.POST_K3CloudURL="http://k3.jet.co.id:8880/k3cloud/";
|
||||
String dbid="5d48f604c8361e";//dbid1;//"5d48f604c8361e";//"5a964ecc967246";
|
||||
String uuid=uuid1;
|
||||
String password=password2;
|
||||
org.json.JSONObject resultjson=null;
|
||||
int lang=2052;
|
||||
try {
|
||||
boolean flag=InvokeHelper.Login(dbid, uuid, password, lang);
|
||||
//out.print(flag);
|
||||
if(flag){//登陆成功
|
||||
resultjson=com.jet.util.InvokeHelper.Save("GL_VOUCHER",VOUCHER.toJSONString());
|
||||
boolean flag1=resultjson.getBoolean("flag");
|
||||
String resultstr=resultjson.getString("sResult");
|
||||
log.error("resultstr"+resultstr);
|
||||
if(flag1){
|
||||
JSONObject HAHA=JSONObject.parseObject(resultstr);
|
||||
JSONObject Result=HAHA.getJSONObject("Result");
|
||||
JSONObject ResponseStatus=Result.getJSONObject("ResponseStatus");
|
||||
boolean IsSuccess=ResponseStatus.getBoolean("IsSuccess");
|
||||
if(IsSuccess){
|
||||
updRec.execute("update formtable_main_22 set sfxr='0' where requestid='"+requestid+"' ");
|
||||
String FVOUCHERID=Result.getString("Id");
|
||||
String Fv=getFv(Queryurl+""+FVOUCHERID,baseis);
|
||||
updRec.execute("update formtable_main_22 set pzbhdec='"+Fv+"' where requestid='"+requestid+"' ");
|
||||
//out.print("成功"+FVOUCHERID);
|
||||
|
||||
}else{
|
||||
//out.print("失败");
|
||||
requestInfo.getRequestManager().setMessageid("失败");
|
||||
requestInfo.getRequestManager().setMessage("失败");//提醒信息id
|
||||
requestInfo.getRequestManager().setMessagecontent("写入K3系统不成功,系统反馈信息如下:"+HAHA.toString());//提醒信息内容
|
||||
|
||||
return Action.FAILURE_AND_CONTINUE;
|
||||
}
|
||||
}else{
|
||||
//out.print("失败"+resultstr);
|
||||
requestInfo.getRequestManager().setMessageid("失败");
|
||||
requestInfo.getRequestManager().setMessage("失败");//提醒信息id
|
||||
requestInfo.getRequestManager().setMessagecontent("写入K3系统不成功,系统反馈信息如下:"+resultstr.toString());//提醒信息内容
|
||||
|
||||
return Action.FAILURE_AND_CONTINUE;
|
||||
}
|
||||
|
||||
}
|
||||
} catch (Exception e) {
|
||||
//TODO Auto-generated catch block
|
||||
log.error("GL_VOUCHER--Exception"+e.getMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
//更具ID获取凭证编号
|
||||
public String getFv(String url,String basis)throws Exception{
|
||||
String Fv="";
|
||||
//out.print("url-"+url+" basis"+basis+" ");
|
||||
try{
|
||||
String result=sendGet(url,"",basis);
|
||||
// out.print("url-"+url+" basis"+basis+" result"+result);
|
||||
JSONArray json=JSONArray.parseArray(result);
|
||||
if(json!=null&&json.size()>0){
|
||||
for(int i=0;i<json.size();i++){
|
||||
JSONObject obj= json.getJSONObject(i);
|
||||
Fv=obj.getString("Voucher No");
|
||||
}
|
||||
}
|
||||
}catch(Exception e){
|
||||
|
||||
}
|
||||
return Fv;
|
||||
}
|
||||
public static String sendGet(String url, String param,String basis) {
|
||||
String result = "";
|
||||
InputStream in = null;
|
||||
try {
|
||||
String urlNameString = url ;
|
||||
URL realUrl = new URL(urlNameString);
|
||||
URLConnection connection = realUrl.openConnection();
|
||||
String auth=basis;//"JNT:JNT2019";
|
||||
String code = new sun.misc.BASE64Encoder().encode(auth.getBytes());
|
||||
connection.setRequestProperty("Authorization", "Basic " + code);
|
||||
connection.connect();
|
||||
Map<String, List<String>> map = connection.getHeaderFields();
|
||||
|
||||
|
||||
for (String key : map.keySet()) {
|
||||
System.out.println(key + "--->" + map.get(key));
|
||||
}
|
||||
//接收核心返回过来的数据 xml 需要解析
|
||||
in =connection.getInputStream();
|
||||
byte[] b =getBytes(in);
|
||||
if(b.length>0){
|
||||
result=new String(b);
|
||||
}
|
||||
System.out.println(b.length);
|
||||
} catch (Exception e) {
|
||||
|
||||
System.out.println(e.getMessage());
|
||||
e.printStackTrace();
|
||||
}finally {
|
||||
try {
|
||||
if (in != null) {
|
||||
in.close();
|
||||
}
|
||||
} catch (Exception e2) {
|
||||
System.out.println(e2.getMessage());
|
||||
e2.printStackTrace();
|
||||
}
|
||||
}
|
||||
//System.out.println("de"+result);
|
||||
return result;
|
||||
}
|
||||
public static byte[] getBytes(InputStream fis){
|
||||
Logger log = Logger.getLogger(Logger.class);
|
||||
byte[] buffer = null;
|
||||
try {
|
||||
//File file = new File(filePath);
|
||||
//FileInputStream fis = new FileInputStream(file);
|
||||
ByteArrayOutputStream bos = new ByteArrayOutputStream(1000);
|
||||
byte[] b = new byte[10000];
|
||||
int n;
|
||||
while ((n = fis.read(b)) != -1) {
|
||||
bos.write(b, 0, n);
|
||||
}
|
||||
fis.close();
|
||||
bos.close();
|
||||
buffer = bos.toByteArray();
|
||||
} catch (FileNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
System.out.println("buffer--->"+buffer.length);
|
||||
return buffer;
|
||||
}
|
||||
//封装借贷方 Model
|
||||
public Map<String,Object> getModel(String requestid, Map<String,String> Hswd, Map<String,String> fxHswd){
|
||||
RecordSet re=new RecordSet();
|
||||
boolean flag=true;
|
||||
Map<String,Object> map=new HashMap<String,Object>();
|
||||
String errormess="";//
|
||||
String sql= " select a.sfxr,a.zzjdhl,a.bz,a.id,a.zt,a.zz,a.zb,b.dfkmbm kmbh,b.zy,b.dfje je,b.bm,b.yg,b.kh,b.gys,b.fyxm,b.wl,b.zc,b.wlz,b.khz,b.dfkmmc kmmc,b.hswd,b.yje,'1' entrylx from formtable_main_22 a,formtable_main_22_dt5 b where a.id=b.mainid and a.requestid='"+requestid+"' ";
|
||||
//log.error("deeded"+);
|
||||
re.execute(sql);
|
||||
JSONArray FEntity=new JSONArray();
|
||||
lable1:while(re.next()){
|
||||
//拼接科目信息
|
||||
String sfxr=Util.null2String(re.getString("sfxr")).trim();
|
||||
String zt=Util.null2String(re.getString("zt")).trim();
|
||||
String zz=Util.null2String(re.getString("zz")).trim();
|
||||
String zb=Util.null2String(re.getString("zb")).trim();
|
||||
JSONObject FEntityDetail=new JSONObject();
|
||||
String FEXPLANATION=Util.null2String(re.getString("zy"));//摘要
|
||||
FEntityDetail.put("FEXPLANATION",FEXPLANATION);
|
||||
JSONObject FACCOUNTID=new JSONObject();//科目 FNumber
|
||||
String demoKm=Util.null2String(re.getString("kmbh")).trim();
|
||||
if("".equals(demoKm)){
|
||||
errormess="科目编号不能为空";//科目编号不能为空
|
||||
break;
|
||||
}else{
|
||||
FACCOUNTID.put("FNumber",demoKm);
|
||||
}
|
||||
FEntityDetail.put("FACCOUNTID",FACCOUNTID);
|
||||
JSONObject FDetailID=new JSONObject();//辅助核算项 FDETAILID__FFLEX10 FNumber
|
||||
//获取科目的辅助核算项
|
||||
String demoHswd=getFzhx(demoKm,zt,zz,zb,Hswd);
|
||||
//out.print("demoHswd--"+demoHswd);
|
||||
if(demoHswd!=null&&!"".equals(demoHswd.trim())){
|
||||
String[] demoHswds=demoHswd.split(",");
|
||||
for(String str:demoHswds){
|
||||
if(str!=null&&!"".equals(str)){
|
||||
JSONObject Hswdjson=new JSONObject();
|
||||
String number=Util.null2String(re.getString(str)).trim();
|
||||
if(!"".equals(number)){
|
||||
Hswdjson.put("FNumber",number);
|
||||
FDetailID.put("FDETAILID__"+fxHswd.get(str),Hswdjson);
|
||||
}else{
|
||||
//errormess=str+"核算维度没有设置值!";
|
||||
//break lable1;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
FEntityDetail.put("FDetailID",FDetailID);
|
||||
JSONObject FCURRENCYID=new JSONObject();//币别 FNumber
|
||||
FCURRENCYID.put("FNumber","IDR");//默认印尼盾
|
||||
FEntityDetail.put("FCURRENCYID",FCURRENCYID);
|
||||
JSONObject FEXCHANGERATETYPE=new JSONObject();;//汇率类型
|
||||
FEXCHANGERATETYPE.put("FNumber","HLTX01_SYS");//默认
|
||||
FEntityDetail.put("FEXCHANGERATETYPE",FEXCHANGERATETYPE);
|
||||
String FEXCHANGERATE ="1";//汇率
|
||||
FEntityDetail.put("FEXCHANGERATE",FEXCHANGERATE);
|
||||
String FUnitId ="";//单位
|
||||
//FEntityDetail.put("FUnitId",FUnitId);
|
||||
String FPrice="0";//单价
|
||||
//FEntityDetail.put("FPrice",FPrice);
|
||||
String FQty="0";//数量
|
||||
//FEntityDetail.put("FQty",FQty);
|
||||
String FAMOUNTFOR="";//原币金额
|
||||
String entrylx=Util.null2String(re.getString("entrylx"));
|
||||
String FDEBIT="";//借方金额
|
||||
String FCREDIT="";//贷方金额
|
||||
String FDC="";//借贷方向
|
||||
if("1".equals(entrylx)){//借方
|
||||
FDEBIT=getfloats(Util.null2String(re.getString("je")),"1",0)+"";
|
||||
FDC="1";
|
||||
}else{
|
||||
FCREDIT=getfloats(Util.null2String(re.getString("je")),"1",0)+"";
|
||||
FDC="0";
|
||||
}
|
||||
FEntityDetail.put("FCREDIT",FCREDIT);
|
||||
FEntityDetail.put("FDEBIT",FDEBIT);
|
||||
FEntityDetail.put("FDC",FDC);
|
||||
String FSettleTypeID="";//结束方式 FNumber
|
||||
String FSETTLENO ="";//结算号
|
||||
|
||||
String FAcctFullName=getKmname(demoKm,zt,zz,zb);//科目全称
|
||||
String FACCOUNTNAME=getKmname(demoKm,zt,zz,zb);//科目名称
|
||||
//FEntityDetail.put("FAcctFullName",FAcctFullName);
|
||||
//FEntityDetail.put("FACCOUNTNAME",FACCOUNTNAME);
|
||||
FEntity.add(FEntityDetail);
|
||||
}
|
||||
if(!"".equals(errormess)){
|
||||
map.put("flag",false);
|
||||
flag=false;
|
||||
map.put("mess",errormess);
|
||||
}
|
||||
if(FEntity.size()<=0){
|
||||
map.put("flag",false);
|
||||
flag=false;
|
||||
map.put("mess","无法获取原始借贷方");
|
||||
}
|
||||
map.put("flag",flag);
|
||||
map.put("FEntity",FEntity);
|
||||
return map;
|
||||
}
|
||||
//获取赋值核算类型
|
||||
public String getFzhx1(String km,String zt,String zz,String zb,Map<String,String> Hswd){
|
||||
String FDIMENSION="";//核算维度
|
||||
RecordSet re=new RecordSet();
|
||||
String sql="select b.FDIMENSION from uf_accountinfo a,uf_accountinfo_dt1 b where a.id=b.mainid and a.zt='"+zt+"' and b.FNUMBER='"+km+"' and b.forgnumber='"+zz+"' and FAcctBookNumber='"+zb+"' ";
|
||||
//out.print(sql);
|
||||
re.execute(sql);
|
||||
while(re.next()){
|
||||
String str=Util.null2String(re.getString("FDIMENSION")).trim() ;
|
||||
String[] FDIMENSIONs=str.split(",");
|
||||
for(String demo:FDIMENSIONs){
|
||||
if(demo!=null&&!"".equals(demo)){
|
||||
FDIMENSION=FDIMENSION+Hswd.get(demo)+",";
|
||||
}
|
||||
}
|
||||
}
|
||||
if(FDIMENSION.endsWith(",")){
|
||||
FDIMENSION=FDIMENSION.substring(0,FDIMENSION.length()-1);
|
||||
}
|
||||
return FDIMENSION;
|
||||
}
|
||||
//获取原始报销金额
|
||||
public String getDteJe(String requestid){
|
||||
RecordSet re=new RecordSet();
|
||||
String je="";
|
||||
String sql="select sum(je) je from formtable_main_22 a,formtable_main_22_dt8 b where a.id=b.mainid and a.requestid='"+requestid+"'";
|
||||
re.execute(sql);
|
||||
while(re.next()){
|
||||
je=re.getString("je") ;
|
||||
}
|
||||
return je;
|
||||
}
|
||||
//获取贷方总金额
|
||||
public String getDteJe5(String requestid){
|
||||
RecordSet re=new RecordSet();
|
||||
String je="";
|
||||
String sql="select sum(dfje) je from formtable_main_22 a,formtable_main_22_dt5 b where a.id=b.mainid and a.requestid='"+requestid+"'";
|
||||
re.execute(sql);
|
||||
while(re.next()){
|
||||
je=re.getString("je") ;
|
||||
}
|
||||
return je;
|
||||
}
|
||||
|
||||
|
||||
//获取借方总金额
|
||||
public static String getjfZje(String requestid){
|
||||
RecordSet re=new RecordSet();
|
||||
String je="";
|
||||
String sql="select sum(jfje) jfje from formtable_main_22 a,formtable_main_22_dt4 b where a.id=b.mainid and a.requestid='"+requestid+"'";
|
||||
re.execute(sql);
|
||||
while(re.next()){
|
||||
je=re.getString("jfje") ;
|
||||
}
|
||||
return je;
|
||||
}
|
||||
//获取贷方总金额
|
||||
public static String getdfZje(String requestid){
|
||||
RecordSet re=new RecordSet();
|
||||
String je="";
|
||||
String sql="select sum(dfje) dfje from formtable_main_22 a,formtable_main_22_dt5 b where a.id=b.mainid and a.requestid='"+requestid+"'";
|
||||
re.execute(sql);
|
||||
while(re.next()){
|
||||
je=re.getString("dfje") ;
|
||||
}
|
||||
return je;
|
||||
}
|
||||
//获取赋值核算类型
|
||||
public String getFzhx(String km,String zt,String zz,String zb,Map<String,String> Hswd){
|
||||
String FDIMENSION="";//核算维度
|
||||
RecordSet re=new RecordSet();
|
||||
String sql="select b.FDIMENSION from uf_accountinfo a,uf_accountinfo_dt1 b where a.id=b.mainid and a.zt='"+zt+"' and b.FNUMBER='"+km+"' and b.forgnumber='"+zz+"' and FAcctBookNumber='"+zb+"' ";
|
||||
//out.print(sql);
|
||||
re.execute(sql);
|
||||
while(re.next()){
|
||||
String str=Util.null2String(re.getString("FDIMENSION")).trim() ;
|
||||
String[] FDIMENSIONs=str.split(",");
|
||||
for(String demo:FDIMENSIONs){
|
||||
if(demo!=null&&!"".equals(demo)){
|
||||
FDIMENSION=FDIMENSION+Hswd.get(demo)+",";
|
||||
}
|
||||
}
|
||||
}
|
||||
if(FDIMENSION.endsWith(",")){
|
||||
FDIMENSION=FDIMENSION.substring(0,FDIMENSION.length()-1);
|
||||
}
|
||||
return FDIMENSION;
|
||||
}
|
||||
//insert 事务
|
||||
public boolean SynInsert1(List<String> array){
|
||||
if(array==null||array.size()<=0){
|
||||
return false;
|
||||
}
|
||||
Logger log = Logger.getLogger(DataSource.class);
|
||||
RecordSetTrans RecordSetTrans=new RecordSetTrans();
|
||||
RecordSetTrans.setAutoCommit(false);
|
||||
boolean flag=true;
|
||||
|
||||
try{
|
||||
RecordSetTrans.setAutoCommit(false);
|
||||
// stmt = conn.createStatement();
|
||||
for(String str:array){
|
||||
//int index =RecordSetTrans.executeUpdate(str);
|
||||
flag=RecordSetTrans.executeSql(str);
|
||||
log.error("SynInsert--"+str);
|
||||
if(!flag){
|
||||
//flag=false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(!flag){//事务回滚
|
||||
RecordSetTrans.rollback();
|
||||
}else{
|
||||
RecordSetTrans.commit();
|
||||
}
|
||||
}catch(Exception e){
|
||||
log.error("SynInsert--Exception "+e.getMessage());
|
||||
flag=false;
|
||||
}
|
||||
|
||||
return flag;
|
||||
}
|
||||
//获取科目名称
|
||||
public String getKmname(String km,String zt,String zz,String zb){
|
||||
String FNAME="";//核算维度
|
||||
RecordSet re=new RecordSet();
|
||||
String sql="select b.FNAME from uf_accountinfo a,uf_accountinfo_dt1 b where a.id=b.mainid and a.zt='"+zt+"' and b.FNUMBER='"+km+"' and b.forgnumber='"+zz+"' and FAcctBookNumber='"+zb+"' ";
|
||||
re.execute(sql);
|
||||
while(re.next()){
|
||||
FNAME=Util.null2String(re.getString("FNAME"));
|
||||
}
|
||||
return FNAME;
|
||||
}
|
||||
//获取币种的小数位
|
||||
public int getXsw(String bz){
|
||||
int xsw=0;
|
||||
RecordSet re=new RecordSet();
|
||||
String sql="select * from uf_k3bz where bh='"+bz+"'";
|
||||
re.execute(sql);
|
||||
while(re.next()){
|
||||
xsw=Integer.parseInt(Util.null2o(re.getString("xsw"))) ;
|
||||
}
|
||||
return xsw;
|
||||
}
|
||||
|
||||
//浮点型转换
|
||||
public static float getfloats(String demo,String demo1,int len){
|
||||
Logger log = Logger.getLogger(BigDecimal.class);
|
||||
if(len==0){
|
||||
len=0;
|
||||
}
|
||||
String str=Util.null2String(demo);
|
||||
String str1=Util.null2String(demo1);
|
||||
if("".equals(str)||"".equals(str.trim())||"null".equalsIgnoreCase(str.trim())){
|
||||
return 0;
|
||||
}
|
||||
if("".equals(str1)||"".equals(str.trim())||"null".equalsIgnoreCase(str1.trim())){
|
||||
str1="1";
|
||||
}
|
||||
float fl=0.0f;
|
||||
//String str=Util.null2String(demo);
|
||||
try{
|
||||
if(str.trim().length()>0){
|
||||
BigDecimal b1 = new BigDecimal(str.trim());
|
||||
BigDecimal b2 = new BigDecimal(str1.trim());
|
||||
BigDecimal b3=b1.multiply(b2);
|
||||
//System.out.println(b1.setScale(2,BigDecimal.ROUND_HALF_UP));
|
||||
fl=b3.setScale(len,BigDecimal.ROUND_HALF_UP).floatValue();
|
||||
}
|
||||
log.error("getfloats"+fl);
|
||||
}catch(Exception e){
|
||||
log.error(demo+"getfloats异常"+e.getMessage());
|
||||
}
|
||||
return fl;
|
||||
}
|
||||
|
||||
|
||||
//浮点型转换
|
||||
public static float getfloats1(String demo,String demo1,int len){
|
||||
Logger log = Logger.getLogger(BigDecimal.class);
|
||||
if(len==0){
|
||||
len=0;
|
||||
}
|
||||
String str=Util.null2String(demo);
|
||||
String str1=Util.null2String(demo1);
|
||||
if("".equals(str)||"".equals(str.trim())||"null".equalsIgnoreCase(str.trim())){
|
||||
str="0";
|
||||
}
|
||||
if("".equals(str1)||"".equals(str.trim())||"null".equalsIgnoreCase(str1.trim())){
|
||||
str1="0";
|
||||
}
|
||||
float fl=0.0f;
|
||||
//String str=Util.null2String(demo);
|
||||
try{
|
||||
if(str.trim().length()>0){
|
||||
BigDecimal b1 = new BigDecimal(str.trim());
|
||||
BigDecimal b2 = new BigDecimal(str1.trim());
|
||||
BigDecimal b3=b1.add(b2);
|
||||
//System.out.println(b1.setScale(2,BigDecimal.ROUND_HALF_UP));
|
||||
fl=b3.setScale(len,BigDecimal.ROUND_HALF_UP).floatValue();
|
||||
}
|
||||
log.error("getfloats"+fl);
|
||||
}catch(Exception e){
|
||||
log.error(demo+"getfloats异常"+e.getMessage());
|
||||
}
|
||||
return fl;
|
||||
}
|
||||
//浮点型转换 金额差
|
||||
public static float getfloats2(String demo,String demo1,int len){
|
||||
Logger log = Logger.getLogger(BigDecimal.class);
|
||||
if(len==0){
|
||||
len=0;
|
||||
}
|
||||
String str=Util.null2String(demo);
|
||||
String str1=Util.null2String(demo1);
|
||||
if("".equals(str)||"".equals(str.trim())||"null".equalsIgnoreCase(str.trim())){
|
||||
str="0";
|
||||
}
|
||||
if("".equals(str1)||"".equals(str.trim())||"null".equalsIgnoreCase(str1.trim())){
|
||||
str1="0";
|
||||
}
|
||||
float fl=0.0f;
|
||||
//String str=Util.null2String(demo);
|
||||
try{
|
||||
if(str.trim().length()>0){
|
||||
BigDecimal b1 = new BigDecimal(str.trim());
|
||||
BigDecimal b2 = new BigDecimal(str1.trim());
|
||||
BigDecimal b3=b1.subtract(b2);
|
||||
//System.out.println(b1.setScale(2,BigDecimal.ROUND_HALF_UP));
|
||||
fl=b3.setScale(len,BigDecimal.ROUND_HALF_UP).floatValue();
|
||||
}
|
||||
log.error("getfloats"+fl);
|
||||
}catch(Exception e){
|
||||
log.error(demo+"getfloats异常"+e.getMessage());
|
||||
}
|
||||
return fl;
|
||||
}
|
||||
public static float getFloat(String val){
|
||||
float floatval=0.0f;
|
||||
if(val==null||"".equals(Util.null2String(val).trim())){
|
||||
return 0.0f;
|
||||
}
|
||||
try{
|
||||
BigDecimal bg = new BigDecimal(val);
|
||||
floatval=bg.setScale(2, BigDecimal.ROUND_HALF_UP).floatValue();
|
||||
}catch(Exception e){
|
||||
|
||||
}
|
||||
return floatval;
|
||||
}
|
||||
//取特殊科目编号
|
||||
public String SpelKm(String zt,String zz,String zb,String lx){
|
||||
Logger log = Logger.getLogger(BigDecimal.class);
|
||||
RecordSet re=new RecordSet();
|
||||
String km="";//科目
|
||||
re.execute("select * from uf_k3tskm a,uf_k3tskm_dt1 b where a.id=b.mainid and zt='"+zt+"' and zz='"+zz+"' and zb='"+zb+"' and lx='"+lx+"'");
|
||||
while(re.next()){
|
||||
km=re.getString("km");
|
||||
}
|
||||
return km;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,570 @@
|
|||
package com.jet.action;
|
||||
|
||||
import weaver.soa.workflow.request.RequestInfo;
|
||||
import weaver.workflow.action.BaseAction;
|
||||
import weaver.conn.RecordSet;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
|
||||
import weaver.hrm.HrmUserVarify;
|
||||
import weaver.hrm.User;
|
||||
import weaver.general.BaseBean;
|
||||
import weaver.general.Util;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.sql.Connection;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.Statement;
|
||||
import weaver.general.StaticObj;
|
||||
import weaver.interfaces.datasource.DataSource;
|
||||
import weaver.formmode.setup.ModeRightInfo;
|
||||
import java.sql.Connection;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Statement;
|
||||
import weaver.general.StaticObj;
|
||||
import weaver.interfaces.datasource.DataSource;
|
||||
import weaver.interfaces.workflow.action.Action;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.PrintWriter;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
import org.apache.http.Header;
|
||||
import org.apache.http.HttpResponse;
|
||||
import org.apache.http.HttpStatus;
|
||||
import org.apache.http.client.HttpClient;
|
||||
import org.apache.http.client.methods.HttpPost;
|
||||
import org.apache.http.entity.*;
|
||||
import org.apache.http.*;
|
||||
import org.apache.http.util.*;
|
||||
import org.apache.http.impl.client.DefaultHttpClient;
|
||||
import org.apache.http.params.CoreConnectionPNames;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.nio.charset.Charset;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import weaver.conn.RecordSetTrans;
|
||||
import java.io.PrintWriter;
|
||||
import com.jet.util.*;
|
||||
import org.json.*;
|
||||
|
||||
public class CreateVoucherHk extends BaseAction{
|
||||
@Override
|
||||
public String execute(RequestInfo requestInfo) {
|
||||
// TODO Auto-generated method stub
|
||||
Logger log = Logger.getLogger(JSONObject.class);
|
||||
RecordSet urlre=new RecordSet();
|
||||
String urlsql="select * from uf_urlinfo where ms='model'";
|
||||
|
||||
urlre.execute(urlsql);
|
||||
String url="";
|
||||
String username="";
|
||||
String password1="";
|
||||
String dbid1="";
|
||||
String uuid1="";
|
||||
String password2="";
|
||||
while(urlre.next()){
|
||||
url=Util.null2String(urlre.getString("url"));
|
||||
username=Util.null2String(urlre.getString("username"));
|
||||
password1=Util.null2String(urlre.getString("password"));
|
||||
dbid1=Util.null2String(urlre.getString("dbid"));
|
||||
uuid1=Util.null2String(urlre.getString("uuid"));
|
||||
password2=Util.null2String(urlre.getString("password1"));
|
||||
}
|
||||
String baseis=username+":"+password1;
|
||||
String Queryurl=url+"GlVoucher/";
|
||||
Map<String,String> Hswd=new HashMap<String,String>();//核算维度对照表
|
||||
JSONObject VOUCHER=new JSONObject();//VOUCHER
|
||||
JSONArray Models=new JSONArray();//ModelS
|
||||
JSONObject Model=new JSONObject();//Model
|
||||
Hswd.put("FFLEX4","gys");//供应商
|
||||
Hswd.put("FFLEX6","kh");//客户
|
||||
Hswd.put("FFLEX7","yg");//员工
|
||||
Hswd.put("FFLEX5","bm");//部门
|
||||
Hswd.put("FFLEX9","fyxm");//费用项目
|
||||
Hswd.put("FFLEX8","wl");//物料
|
||||
Hswd.put("FFLEX10","zc");//资产
|
||||
Hswd.put("FFLEX12","wlz");//物料组
|
||||
Hswd.put("FFLEX13","khz");//客户组
|
||||
Map<String,String> fxHswd=new HashMap<String,String>();//核算维度对照表
|
||||
fxHswd.put("gys","FFLEX4");//供应商
|
||||
fxHswd.put("kh","FFLEX6");//客户
|
||||
fxHswd.put("yg","FFLEX7");//员工
|
||||
fxHswd.put("bm","FFLEX5");//部门
|
||||
fxHswd.put("fyxm","FFLEX9");//费用项目
|
||||
fxHswd.put("wl","FFLEX8");//物料
|
||||
fxHswd.put("zc","FFLEX10");//资产
|
||||
fxHswd.put("wlz","FFLEX12");//物料组
|
||||
fxHswd.put("khz","FFLEX13");//客户组
|
||||
SimpleDateFormat sim=new SimpleDateFormat("yyyy-MM-dd");
|
||||
List<String> jlist=new ArrayList<String>();//借方
|
||||
List<String> dlist=new ArrayList<String>();//贷方
|
||||
String requestid=requestInfo.getRequestid();//
|
||||
String mainid="";//
|
||||
String zt="";//账套
|
||||
String zz="";//组织
|
||||
String zb="";//账薄
|
||||
String zzjdhl="";//做账节点汇率
|
||||
String bz="";//币种
|
||||
String sfxr="";//是否写入
|
||||
RecordSet re=new RecordSet();
|
||||
String errormess="";
|
||||
float zje=0.0f;
|
||||
//1:借方 2:贷方
|
||||
String sql= " select a.sfxr,a.hklx,a.id,a.zt,a.zz,a.zb,b.jfkmbm kmbh,b.jfkmmc kmmc,b.jfje je,b.zy ,'' yg,'' kh,'1' entrylx from formtable_main_25 a,formtable_main_25_dt1 b where a.id=b.mainid and a.requestid='"+requestid+"'"+
|
||||
" union all "+
|
||||
" select a.sfxr,a.hklx,a.id,a.zt,a.zz,a.zb,b.dfkmbm kmbh,b.dfkmmc kmmc,b.dfje je,b.zy ,b.yg,b.kh,'2' entrylx from formtable_main_25 a,formtable_main_25_dt2 b where a.id=b.mainid and a.requestid='"+requestid+"' ";
|
||||
log.error(requestid+"CreateVoucherHk"+sql);
|
||||
re.execute(sql);
|
||||
JSONArray FEntity=new JSONArray();
|
||||
lable1:while(re.next()){
|
||||
//拼接科目信息
|
||||
sfxr=Util.null2String(re.getString("sfxr"));
|
||||
String entrylx=Util.null2String(re.getString("entrylx"));
|
||||
String hklx=Util.null2String(re.getString("hklx"));//还款类型 0:个人 1:客户
|
||||
zt=Util.null2String(re.getString("zt")).trim();
|
||||
zz=Util.null2String(re.getString("zz")).trim();
|
||||
zb=Util.null2String(re.getString("zb")).trim();
|
||||
String yg=Util.null2String(re.getString("yg")).trim();//员工
|
||||
String kh=Util.null2String(re.getString("kh")).trim();//客户
|
||||
zb=Util.null2String(re.getString("zb")).trim();
|
||||
JSONObject FEntityDetail=new JSONObject();
|
||||
String FEXPLANATION=Util.null2String(re.getString("zy"));//摘要
|
||||
FEntityDetail.put("FEXPLANATION",FEXPLANATION);
|
||||
JSONObject FACCOUNTID=new JSONObject();//科目 FNumber
|
||||
String demoKm=Util.null2String(re.getString("kmbh")).trim();
|
||||
if("".equals(demoKm)){
|
||||
errormess="科目编号不能为空";//科目编号不能为空
|
||||
break;
|
||||
}else{
|
||||
FACCOUNTID.put("FNumber",demoKm);
|
||||
}
|
||||
FEntityDetail.put("FACCOUNTID",FACCOUNTID);
|
||||
JSONObject FDetailID=new JSONObject();//辅助核算项 FDETAILID__FFLEX10 FNumber
|
||||
//获取科目的辅助核算项
|
||||
if("2".equals(entrylx)){//贷方甚至核算项
|
||||
JSONObject Hswdjson=new JSONObject();
|
||||
if("0".equals(hklx)){
|
||||
if("".equals(yg)){
|
||||
errormess="核算维度没有设置值!";
|
||||
break lable1;
|
||||
}else{
|
||||
Hswdjson.put("FNumber",yg);
|
||||
FDetailID.put("FDETAILID__FFLEX7",Hswdjson);
|
||||
}
|
||||
|
||||
}else{
|
||||
if("".equals(kh)){
|
||||
//errormess="核算维度没有设置值!";
|
||||
//break lable1;
|
||||
}else{
|
||||
//Hswdjson.put("FNumber",kh);
|
||||
//FDetailID.put("FDETAILID__FFLEX6",Hswdjson);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
FEntityDetail.put("FDetailID",FDetailID);
|
||||
JSONObject FCURRENCYID=new JSONObject();//币别 FNumber
|
||||
FCURRENCYID.put("FNumber","IDR");//默认印尼盾
|
||||
FEntityDetail.put("FCURRENCYID",FCURRENCYID);
|
||||
JSONObject FEXCHANGERATETYPE=new JSONObject();;//汇率类型
|
||||
FEXCHANGERATETYPE.put("FNumber","HLTX01_SYS");//默认
|
||||
FEntityDetail.put("FEXCHANGERATETYPE",FEXCHANGERATETYPE);
|
||||
String FEXCHANGERATE ="1";//汇率
|
||||
FEntityDetail.put("FEXCHANGERATE",FEXCHANGERATE);
|
||||
String FUnitId ="";//单位
|
||||
//FEntityDetail.put("FUnitId",FUnitId);
|
||||
String FPrice="0";//单价
|
||||
//FEntityDetail.put("FPrice",FPrice);
|
||||
String FQty="0";//数量
|
||||
//FEntityDetail.put("FQty",FQty);
|
||||
String FAMOUNTFOR="";//原币金额
|
||||
|
||||
String FDEBIT="";//借方金额
|
||||
String FCREDIT="";//贷方金额
|
||||
String FDC="";//借贷方向
|
||||
if("1".equals(entrylx)){//借方
|
||||
FDEBIT=Util.null2String(re.getString("je"));
|
||||
FDC="1";
|
||||
}else{
|
||||
FCREDIT=Util.null2String(re.getString("je"));
|
||||
FDC="0";
|
||||
}
|
||||
FEntityDetail.put("FCREDIT",FCREDIT);
|
||||
FEntityDetail.put("FDEBIT",FDEBIT);
|
||||
FEntityDetail.put("FDC",FDC);
|
||||
String FSettleTypeID="";//结束方式 FNumber
|
||||
String FSETTLENO ="";//结算号
|
||||
|
||||
String FAcctFullName=getKmname(demoKm,zt,zz,zb);//科目全称
|
||||
String FACCOUNTNAME=getKmname(demoKm,zt,zz,zb);//科目名称
|
||||
//FEntityDetail.put("FAcctFullName",FAcctFullName);
|
||||
//FEntityDetail.put("FACCOUNTNAME",FACCOUNTNAME);
|
||||
FEntity.add(FEntityDetail);
|
||||
}
|
||||
if(!"".equals(errormess)){
|
||||
requestInfo.getRequestManager().setMessageid(errormess);
|
||||
requestInfo.getRequestManager().setMessage(errormess);//提醒信息id
|
||||
requestInfo.getRequestManager().setMessagecontent("写入K3系统不成功,系统反馈信息如下:"+errormess);//提醒信息内容
|
||||
|
||||
return Action.FAILURE_AND_CONTINUE;
|
||||
}
|
||||
//out.print("errormess"+errormess);
|
||||
//out.print("FEntityDetail"+FEntity.toJSONString());
|
||||
//设置主数据
|
||||
JSONObject FAccountBookID=new JSONObject();//账薄
|
||||
FAccountBookID.put("FNumber",zb);
|
||||
Model.put("FAccountBookID",FAccountBookID);
|
||||
String FDate=sim.format(new Date());
|
||||
Model.put("FDate",FDate);
|
||||
JSONObject FVOUCHERGROUPID=new JSONObject();//凭证字默认AP
|
||||
FVOUCHERGROUPID.put("FNumber","PZZ3");
|
||||
Model.put("FVOUCHERGROUPID",FVOUCHERGROUPID);
|
||||
String FYEAR=sim.format(new Date()).split("-")[0];//会计年度
|
||||
String FPERIOD =sim.format(new Date()).split("-")[1];//期间
|
||||
Model.put("FYEAR",FYEAR);
|
||||
Model.put("FPERIOD",FPERIOD);
|
||||
String FDEBITTOTAL=getjfZje(requestid);//借方总金额:FDEBITTOTAL
|
||||
String FCREDITTOTAL=getdfZje(requestid);//贷方总金额:FCREDITTOTAL
|
||||
Model.put("FDEBITTOTAL",FDEBITTOTAL);
|
||||
Model.put("FCREDITTOTAL",FCREDITTOTAL);
|
||||
String FCreateDate=sim.format(new Date());//创建日期:FCreateDate
|
||||
JSONObject FACCBOOKORGID=new JSONObject();//核算组织:FACCBOOKORGID
|
||||
FACCBOOKORGID.put("FNumber",zz);
|
||||
Model.put("FACCBOOKORGID",FACCBOOKORGID);
|
||||
//Model.put("FCreateDate",FCreateDate);
|
||||
String FPRINTTIMES="0";//打印次数:FPRINTTIMES
|
||||
String FCurrentYear=sim.format(new Date()).split("-")[0];//当前年度:FCurrentYear
|
||||
String FCurrentPeriod=sim.format(new Date()).split("-")[1];//当前期间:FCurrentPeriod
|
||||
Model.put("FPRINTTIMES",FPRINTTIMES);
|
||||
//Model.put("FCurrentYear",FCurrentYear);
|
||||
//Model.put("FCurrentPeriod",FCurrentPeriod);
|
||||
Model.put("FEntity",FEntity);
|
||||
Models.add(Model);
|
||||
//凭借主数据
|
||||
VOUCHER.put("NeedReturnFields","[\"FVOUCHERID\",\"FVOUCHERGROUPNO\"]");
|
||||
VOUCHER.put("Model",Model);
|
||||
VOUCHER.put("IsAutoSubmitAndAudit",true);
|
||||
log.error(VOUCHER.toJSONString());
|
||||
/*开始调用接口
|
||||
1;登陆
|
||||
2;调用接口
|
||||
*/
|
||||
if(VOUCHER!=null&&VOUCHER.size()>0&&("".equals(sfxr)||"1".equals(sfxr))){
|
||||
RecordSet updRec=new RecordSet();
|
||||
com.jet.util.InvokeHelper.POST_K3CloudURL="http://k3.jet.co.id:8880/k3cloud/";
|
||||
String dbid="5d48f604c8361e";//dbid1;//"5d48f604c8361e";//"5a964ecc967246";
|
||||
String uuid=uuid1;
|
||||
String password=password2;
|
||||
org.json.JSONObject resultjson=null;
|
||||
int lang=2052;
|
||||
try {
|
||||
boolean flag=InvokeHelper.Login(dbid, uuid, password, lang);
|
||||
//out.print(flag);
|
||||
if(flag){//登陆成功
|
||||
resultjson=com.jet.util.InvokeHelper.Save("GL_VOUCHER",VOUCHER.toJSONString());
|
||||
boolean flag1=resultjson.getBoolean("flag");
|
||||
String resultstr=resultjson.getString("sResult");
|
||||
log.error("resultstr"+resultstr);
|
||||
if(flag1){
|
||||
JSONObject HAHA=JSONObject.parseObject(resultstr);
|
||||
JSONObject Result=HAHA.getJSONObject("Result");
|
||||
JSONObject ResponseStatus=Result.getJSONObject("ResponseStatus");
|
||||
boolean IsSuccess=ResponseStatus.getBoolean("IsSuccess");
|
||||
if(IsSuccess){
|
||||
updRec.execute("update formtable_main_25 set sfxr='0' where requestid='"+requestid+"' ");
|
||||
String FVOUCHERID=Result.getString("Id");
|
||||
String Fv=getFv(Queryurl+""+FVOUCHERID,baseis);
|
||||
updRec.execute("update formtable_main_25 set pzbh='"+Fv+"' where requestid='"+requestid+"' ");
|
||||
//out.print("成功"+FVOUCHERID);
|
||||
}else{
|
||||
//out.print("失败");
|
||||
requestInfo.getRequestManager().setMessageid("失败");
|
||||
requestInfo.getRequestManager().setMessage("失败");//提醒信息id
|
||||
requestInfo.getRequestManager().setMessagecontent("写入K3系统不成功,系统反馈信息如下:"+HAHA.toString());//提醒信息内容
|
||||
|
||||
return Action.FAILURE_AND_CONTINUE;
|
||||
}
|
||||
}else{
|
||||
requestInfo.getRequestManager().setMessageid("失败");
|
||||
requestInfo.getRequestManager().setMessage("失败");//提醒信息id
|
||||
requestInfo.getRequestManager().setMessagecontent("写入K3系统不成功,系统反馈信息如下:"+resultstr.toString());//提醒信息内容
|
||||
|
||||
return Action.FAILURE_AND_CONTINUE;
|
||||
}
|
||||
|
||||
}
|
||||
} catch (Exception e) {
|
||||
//TODO Auto-generated catch block
|
||||
log.error("GL_VOUCHER--Exception"+e.getMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
//更具ID获取凭证编号
|
||||
public String getFv(String url,String basis)throws Exception{
|
||||
String Fv="";
|
||||
//out.print("url-"+url+" basis"+basis+" ");
|
||||
try{
|
||||
String result=sendGet(url,"",basis);
|
||||
// out.print("url-"+url+" basis"+basis+" result"+result);
|
||||
JSONArray json=JSONArray.parseArray(result);
|
||||
if(json!=null&&json.size()>0){
|
||||
for(int i=0;i<json.size();i++){
|
||||
JSONObject obj= json.getJSONObject(i);
|
||||
Fv=obj.getString("Voucher No");
|
||||
}
|
||||
}
|
||||
}catch(Exception e){
|
||||
|
||||
}
|
||||
return Fv;
|
||||
}
|
||||
public static String sendGet(String url, String param,String basis) {
|
||||
String result = "";
|
||||
InputStream in = null;
|
||||
try {
|
||||
String urlNameString = url ;
|
||||
URL realUrl = new URL(urlNameString);
|
||||
URLConnection connection = realUrl.openConnection();
|
||||
String auth=basis;//"JNT:JNT2019";
|
||||
String code = new sun.misc.BASE64Encoder().encode(auth.getBytes());
|
||||
connection.setRequestProperty("Authorization", "Basic " + code);
|
||||
connection.connect();
|
||||
Map<String, List<String>> map = connection.getHeaderFields();
|
||||
|
||||
|
||||
for (String key : map.keySet()) {
|
||||
System.out.println(key + "--->" + map.get(key));
|
||||
}
|
||||
//接收核心返回过来的数据 xml 需要解析
|
||||
in =connection.getInputStream();
|
||||
byte[] b =getBytes(in);
|
||||
if(b.length>0){
|
||||
result=new String(b);
|
||||
}
|
||||
System.out.println(b.length);
|
||||
} catch (Exception e) {
|
||||
|
||||
System.out.println(e.getMessage());
|
||||
e.printStackTrace();
|
||||
}finally {
|
||||
try {
|
||||
if (in != null) {
|
||||
in.close();
|
||||
}
|
||||
} catch (Exception e2) {
|
||||
System.out.println(e2.getMessage());
|
||||
e2.printStackTrace();
|
||||
}
|
||||
}
|
||||
//System.out.println("de"+result);
|
||||
return result;
|
||||
}
|
||||
public static byte[] getBytes(InputStream fis){
|
||||
Logger log = Logger.getLogger(Logger.class);
|
||||
byte[] buffer = null;
|
||||
try {
|
||||
//File file = new File(filePath);
|
||||
//FileInputStream fis = new FileInputStream(file);
|
||||
ByteArrayOutputStream bos = new ByteArrayOutputStream(1000);
|
||||
byte[] b = new byte[10000];
|
||||
int n;
|
||||
while ((n = fis.read(b)) != -1) {
|
||||
bos.write(b, 0, n);
|
||||
}
|
||||
fis.close();
|
||||
bos.close();
|
||||
buffer = bos.toByteArray();
|
||||
} catch (FileNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
System.out.println("buffer--->"+buffer.length);
|
||||
return buffer;
|
||||
}
|
||||
//获取借方总金额
|
||||
public static String getjfZje(String requestid){
|
||||
RecordSet re=new RecordSet();
|
||||
String je="";
|
||||
String sql="select sum(jfje) jfje from formtable_main_22 a,formtable_main_22_dt4 b where a.id=b.mainid and a.requestid='"+requestid+"'";
|
||||
re.execute(sql);
|
||||
while(re.next()){
|
||||
je=re.getString("jfje") ;
|
||||
}
|
||||
return je;
|
||||
}
|
||||
//获取贷方总金额
|
||||
public static String getdfZje(String requestid){
|
||||
RecordSet re=new RecordSet();
|
||||
String je="";
|
||||
String sql="select sum(dfje) dfje from formtable_main_22 a,formtable_main_22_dt5 b where a.id=b.mainid and a.requestid='"+requestid+"'";
|
||||
re.execute(sql);
|
||||
while(re.next()){
|
||||
je=re.getString("dfje") ;
|
||||
}
|
||||
return je;
|
||||
}
|
||||
//获取赋值核算类型
|
||||
public String getFzhx(String km,String zt,String zz,String zb,Map<String,String> Hswd ){
|
||||
String FDIMENSION="";//核算维度
|
||||
RecordSet re=new RecordSet();
|
||||
String sql="select b.FDIMENSION from uf_accountinfo a,uf_accountinfo_dt1 b where a.id=b.mainid and a.zt='"+zt+"' and b.FNUMBER='"+km+"' and b.forgnumber='"+zz+"' and FAcctBookNumber='"+zb+"' ";
|
||||
//out.print(sql);
|
||||
re.execute(sql);
|
||||
while(re.next()){
|
||||
String str=Util.null2String(re.getString("FDIMENSION")).trim() ;
|
||||
String[] FDIMENSIONs=str.split(",");
|
||||
for(String demo:FDIMENSIONs){
|
||||
if(demo!=null&&!"".equals(demo)){
|
||||
FDIMENSION=FDIMENSION+Hswd.get(demo)+",";
|
||||
}
|
||||
}
|
||||
}
|
||||
if(FDIMENSION.endsWith(",")){
|
||||
FDIMENSION=FDIMENSION.substring(0,FDIMENSION.length()-1);
|
||||
}
|
||||
return FDIMENSION;
|
||||
}
|
||||
//insert 事务
|
||||
public boolean SynInsert1(List<String> array){
|
||||
if(array==null||array.size()<=0){
|
||||
return false;
|
||||
}
|
||||
Logger log = Logger.getLogger(DataSource.class);
|
||||
RecordSetTrans RecordSetTrans=new RecordSetTrans();
|
||||
RecordSetTrans.setAutoCommit(false);
|
||||
boolean flag=true;
|
||||
|
||||
try{
|
||||
RecordSetTrans.setAutoCommit(false);
|
||||
// stmt = conn.createStatement();
|
||||
for(String str:array){
|
||||
//int index =RecordSetTrans.executeUpdate(str);
|
||||
flag=RecordSetTrans.executeSql(str);
|
||||
log.error("SynInsert--"+str);
|
||||
if(!flag){
|
||||
//flag=false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(!flag){//事务回滚
|
||||
RecordSetTrans.rollback();
|
||||
}else{
|
||||
RecordSetTrans.commit();
|
||||
}
|
||||
}catch(Exception e){
|
||||
log.error("SynInsert--Exception "+e.getMessage());
|
||||
flag=false;
|
||||
}
|
||||
|
||||
return flag;
|
||||
}
|
||||
//获取科目名称
|
||||
public String getKmname(String km,String zt,String zz,String zb){
|
||||
String FNAME="";//核算维度
|
||||
RecordSet re=new RecordSet();
|
||||
String sql="select b.FNAME from uf_accountinfo a,uf_accountinfo_dt1 b where a.id=b.mainid and a.zt='"+zt+"' and b.FNUMBER='"+km+"' and b.forgnumber='"+zz+"' and FAcctBookNumber='"+zb+"' ";
|
||||
re.execute(sql);
|
||||
while(re.next()){
|
||||
FNAME=Util.null2String(re.getString("FNAME"));
|
||||
}
|
||||
return FNAME;
|
||||
}
|
||||
//获取币种的小数位
|
||||
public int getXsw(String bz){
|
||||
int xsw=0;
|
||||
RecordSet re=new RecordSet();
|
||||
String sql="select * from uf_k3bz where bh='"+bz+"'";
|
||||
re.execute(sql);
|
||||
while(re.next()){
|
||||
xsw=Integer.parseInt(Util.null2o(re.getString("xsw"))) ;
|
||||
}
|
||||
return xsw;
|
||||
}
|
||||
|
||||
//浮点型转换
|
||||
public static float getfloats(String demo,String demo1,int len){
|
||||
Logger log = Logger.getLogger(BigDecimal.class);
|
||||
if(len==0){
|
||||
len=0;
|
||||
}
|
||||
String str=Util.null2String(demo);
|
||||
String str1=Util.null2String(demo1);
|
||||
if("".equals(str)||"".equals(str.trim())||"null".equalsIgnoreCase(str.trim())){
|
||||
return 0;
|
||||
}
|
||||
if("".equals(str1)||"".equals(str.trim())||"null".equalsIgnoreCase(str1.trim())){
|
||||
str1="1";
|
||||
}
|
||||
float fl=0.0f;
|
||||
//String str=Util.null2String(demo);
|
||||
try{
|
||||
if(str.trim().length()>0){
|
||||
BigDecimal b1 = new BigDecimal(str.trim());
|
||||
BigDecimal b2 = new BigDecimal(str1.trim());
|
||||
BigDecimal b3=b1.multiply(b2);
|
||||
//System.out.println(b1.setScale(2,BigDecimal.ROUND_HALF_UP));
|
||||
fl=b3.setScale(len,BigDecimal.ROUND_HALF_UP).floatValue();
|
||||
}
|
||||
log.error("getfloats"+fl);
|
||||
}catch(Exception e){
|
||||
log.error(demo+"getfloats异常"+e.getMessage());
|
||||
}
|
||||
return fl;
|
||||
}
|
||||
|
||||
|
||||
//浮点型转换
|
||||
public static float getfloats1(String demo,String demo1,int len){
|
||||
Logger log = Logger.getLogger(BigDecimal.class);
|
||||
if(len==0){
|
||||
len=0;
|
||||
}
|
||||
String str=Util.null2String(demo);
|
||||
String str1=Util.null2String(demo1);
|
||||
if("".equals(str)||"".equals(str.trim())||"null".equalsIgnoreCase(str.trim())){
|
||||
str="0";
|
||||
}
|
||||
if("".equals(str1)||"".equals(str.trim())||"null".equalsIgnoreCase(str1.trim())){
|
||||
str1="0";
|
||||
}
|
||||
float fl=0.0f;
|
||||
//String str=Util.null2String(demo);
|
||||
try{
|
||||
if(str.trim().length()>0){
|
||||
BigDecimal b1 = new BigDecimal(str.trim());
|
||||
BigDecimal b2 = new BigDecimal(str1.trim());
|
||||
BigDecimal b3=b1.add(b2);
|
||||
//System.out.println(b1.setScale(2,BigDecimal.ROUND_HALF_UP));
|
||||
fl=b3.setScale(len,BigDecimal.ROUND_HALF_UP).floatValue();
|
||||
}
|
||||
log.error("getfloats"+fl);
|
||||
}catch(Exception e){
|
||||
log.error(demo+"getfloats异常"+e.getMessage());
|
||||
}
|
||||
return fl;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,566 @@
|
|||
package com.jet.action;
|
||||
|
||||
import weaver.soa.workflow.request.RequestInfo;
|
||||
import weaver.workflow.action.BaseAction;
|
||||
import weaver.conn.RecordSet;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import weaver.hrm.HrmUserVarify;
|
||||
import weaver.hrm.User;
|
||||
import weaver.general.BaseBean;
|
||||
import weaver.general.Util;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.sql.Connection;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.Statement;
|
||||
import weaver.general.StaticObj;
|
||||
import weaver.interfaces.datasource.DataSource;
|
||||
import weaver.formmode.setup.ModeRightInfo;
|
||||
import java.sql.Connection;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Statement;
|
||||
import weaver.general.StaticObj;
|
||||
import weaver.interfaces.datasource.DataSource;
|
||||
import weaver.interfaces.workflow.action.Action;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.PrintWriter;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
import org.apache.http.Header;
|
||||
import org.apache.http.HttpResponse;
|
||||
import org.apache.http.HttpStatus;
|
||||
import org.apache.http.client.HttpClient;
|
||||
import org.apache.http.client.methods.HttpPost;
|
||||
import org.apache.http.entity.*;
|
||||
import org.apache.http.*;
|
||||
import org.apache.http.util.*;
|
||||
import org.apache.http.impl.client.DefaultHttpClient;
|
||||
import org.apache.http.params.CoreConnectionPNames;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.nio.charset.Charset;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import weaver.conn.RecordSetTrans;
|
||||
import java.io.PrintWriter;
|
||||
import com.jet.util.*;
|
||||
import org.json.*;
|
||||
|
||||
public class CreateVoucherJk extends BaseAction{
|
||||
@Override
|
||||
public String execute(RequestInfo request) {
|
||||
// TODO Auto-generated method stub
|
||||
Logger log = Logger.getLogger(JSONObject.class);
|
||||
RecordSet urlre=new RecordSet();
|
||||
String urlsql="select * from uf_urlinfo where ms='model'";
|
||||
|
||||
urlre.execute(urlsql);
|
||||
String url="";
|
||||
String username="";
|
||||
String password1="";
|
||||
String dbid1="";
|
||||
String uuid1="";
|
||||
String password2="";
|
||||
while(urlre.next()){
|
||||
url=Util.null2String(urlre.getString("url"));
|
||||
username=Util.null2String(urlre.getString("username"));
|
||||
password1=Util.null2String(urlre.getString("password"));
|
||||
dbid1=Util.null2String(urlre.getString("dbid"));
|
||||
uuid1=Util.null2String(urlre.getString("uuid"));
|
||||
password2=Util.null2String(urlre.getString("password1"));
|
||||
}
|
||||
String baseis=username+":"+password1;
|
||||
String Queryurl=url+"GlVoucher/";
|
||||
Map<String,String> Hswd=new HashMap<String,String>();//核算维度对照表
|
||||
JSONObject VOUCHER=new JSONObject();//VOUCHER
|
||||
JSONArray Models=new JSONArray();//ModelS
|
||||
JSONObject Model=new JSONObject();//Model
|
||||
Hswd.put("FFLEX4","gys");//供应商
|
||||
Hswd.put("FFLEX6","kh");//客户
|
||||
Hswd.put("FFLEX7","yg");//员工
|
||||
Hswd.put("FFLEX5","bm");//部门
|
||||
Hswd.put("FFLEX9","fyxm");//费用项目
|
||||
Hswd.put("FFLEX8","wl");//物料
|
||||
Hswd.put("FFLEX10","zc");//资产
|
||||
Hswd.put("FFLEX12","wlz");//物料组
|
||||
Hswd.put("FFLEX13","khz");//客户组
|
||||
Map<String,String> fxHswd=new HashMap<String,String>();//核算维度对照表
|
||||
fxHswd.put("gys","FFLEX4");//供应商
|
||||
fxHswd.put("kh","FFLEX6");//客户
|
||||
fxHswd.put("yg","FFLEX7");//员工
|
||||
fxHswd.put("bm","FFLEX5");//部门
|
||||
fxHswd.put("fyxm","FFLEX9");//费用项目
|
||||
fxHswd.put("wl","FFLEX8");//物料
|
||||
fxHswd.put("zc","FFLEX10");//资产
|
||||
fxHswd.put("wlz","FFLEX12");//物料组
|
||||
fxHswd.put("khz","FFLEX13");//客户组
|
||||
SimpleDateFormat sim=new SimpleDateFormat("yyyy-MM-dd");
|
||||
List<String> jlist=new ArrayList<String>();//借方
|
||||
List<String> dlist=new ArrayList<String>();//贷方
|
||||
String requestid=request.getRequestid();//
|
||||
String mainid="";//
|
||||
String zt="";//账套
|
||||
String zz="";//组织
|
||||
String zb="";//账薄
|
||||
String zzjdhl="";//做账节点汇率
|
||||
String bz="";//币种
|
||||
String sfxr="";//是否写入
|
||||
RecordSet re=new RecordSet();
|
||||
String errormess="";
|
||||
float zje=0.0f;
|
||||
//1:借方 2:贷方
|
||||
String sql= " select a.sfxr,a.jklx,a.id,a.zt,a.zz,a.zb,b.jfkmbm kmbh,b.jfkmmc kmmc,b.jfje je,b.zy ,b.yg ,b.kh ,'1' entrylx from formtable_main_24 a,formtable_main_24_dt1 b where a.id=b.mainid and a.requestid='"+requestid+"'"+
|
||||
" union all "+
|
||||
" select a.sfxr,a.jklx,a.id,a.zt,a.zz,a.zb,b.dfkmbm kmbh,b.dfkmmc kmmc,b.dfje je,b.zy ,'' yg,'' kh,'2' entrylx from formtable_main_24 a,formtable_main_24_dt2 b where a.id=b.mainid and a.requestid='"+requestid+"' ";
|
||||
log.error(request+"CreateVoucherJk"+sql);
|
||||
re.execute(sql);
|
||||
JSONArray FEntity=new JSONArray();
|
||||
lable1:while(re.next()){
|
||||
//拼接科目信息
|
||||
sfxr=Util.null2String(re.getString("sfxr"));
|
||||
String entrylx=Util.null2String(re.getString("entrylx"));
|
||||
String jklx=Util.null2String(re.getString("jklx"));//借款类型 0:个人 1:客户
|
||||
zt=Util.null2String(re.getString("zt")).trim();
|
||||
zz=Util.null2String(re.getString("zz")).trim();
|
||||
zb=Util.null2String(re.getString("zb")).trim();
|
||||
String yg=Util.null2String(re.getString("yg")).trim();//员工
|
||||
String kh=Util.null2String(re.getString("kh")).trim();//客户
|
||||
zb=Util.null2String(re.getString("zb")).trim();
|
||||
JSONObject FEntityDetail=new JSONObject();
|
||||
String FEXPLANATION=Util.null2String(re.getString("zy"));//摘要
|
||||
FEntityDetail.put("FEXPLANATION",FEXPLANATION);
|
||||
JSONObject FACCOUNTID=new JSONObject();//科目 FNumber
|
||||
String demoKm=Util.null2String(re.getString("kmbh")).trim();
|
||||
if("".equals(demoKm)){
|
||||
errormess="科目编号不能为空";//科目编号不能为空
|
||||
break;
|
||||
}else{
|
||||
FACCOUNTID.put("FNumber",demoKm);
|
||||
}
|
||||
FEntityDetail.put("FACCOUNTID",FACCOUNTID);
|
||||
JSONObject FDetailID=new JSONObject();//辅助核算项 FDETAILID__FFLEX10 FNumber
|
||||
//获取科目的辅助核算项
|
||||
if("1".equals(entrylx)){//贷方甚至核算项
|
||||
JSONObject Hswdjson=new JSONObject();
|
||||
if("0".equals(jklx)){
|
||||
if("".equals(yg)){
|
||||
errormess="核算维度没有设置值!";
|
||||
break lable1;
|
||||
}else{
|
||||
Hswdjson.put("FNumber",yg);
|
||||
FDetailID.put("FDETAILID__FFLEX7",Hswdjson);
|
||||
}
|
||||
|
||||
}else{
|
||||
if("".equals(kh)){
|
||||
errormess="核算维度没有设置值!";
|
||||
break lable1;
|
||||
}else{
|
||||
Hswdjson.put("FNumber",kh);
|
||||
FDetailID.put("FDETAILID__FFLEX6",Hswdjson);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
FEntityDetail.put("FDetailID",FDetailID);
|
||||
JSONObject FCURRENCYID=new JSONObject();//币别 FNumber
|
||||
FCURRENCYID.put("FNumber","IDR");//默认印尼盾
|
||||
FEntityDetail.put("FCURRENCYID",FCURRENCYID);
|
||||
JSONObject FEXCHANGERATETYPE=new JSONObject();;//汇率类型
|
||||
FEXCHANGERATETYPE.put("FNumber","HLTX01_SYS");//默认
|
||||
FEntityDetail.put("FEXCHANGERATETYPE",FEXCHANGERATETYPE);
|
||||
String FEXCHANGERATE ="1";//汇率
|
||||
FEntityDetail.put("FEXCHANGERATE",FEXCHANGERATE);
|
||||
String FUnitId ="";//单位
|
||||
//FEntityDetail.put("FUnitId",FUnitId);
|
||||
String FPrice="0";//单价
|
||||
//FEntityDetail.put("FPrice",FPrice);
|
||||
String FQty="0";//数量
|
||||
//FEntityDetail.put("FQty",FQty);
|
||||
String FAMOUNTFOR="";//原币金额
|
||||
|
||||
String FDEBIT="";//借方金额
|
||||
String FCREDIT="";//贷方金额
|
||||
String FDC="";//借贷方向
|
||||
if("1".equals(entrylx)){//借方
|
||||
FDEBIT=Util.null2String(re.getString("je"));
|
||||
FDC="1";
|
||||
}else{
|
||||
FCREDIT=Util.null2String(re.getString("je"));
|
||||
FDC="0";
|
||||
}
|
||||
FEntityDetail.put("FCREDIT",FCREDIT);
|
||||
FEntityDetail.put("FDEBIT",FDEBIT);
|
||||
FEntityDetail.put("FDC",FDC);
|
||||
String FSettleTypeID="";//结束方式 FNumber
|
||||
String FSETTLENO ="";//结算号
|
||||
|
||||
String FAcctFullName=getKmname(demoKm,zt,zz,zb);//科目全称
|
||||
String FACCOUNTNAME=getKmname(demoKm,zt,zz,zb);//科目名称
|
||||
//FEntityDetail.put("FAcctFullName",FAcctFullName);
|
||||
//FEntityDetail.put("FACCOUNTNAME",FACCOUNTNAME);
|
||||
FEntity.add(FEntityDetail);
|
||||
}
|
||||
if(!"".equals(errormess)){
|
||||
request.getRequestManager().setMessageid(errormess);
|
||||
request.getRequestManager().setMessage(errormess);//提醒信息id
|
||||
request.getRequestManager().setMessagecontent("写入K3系统不成功,系统反馈信息如下:"+errormess);//提醒信息内容
|
||||
|
||||
return Action.FAILURE_AND_CONTINUE;
|
||||
}
|
||||
//out.print("FEntityDetail"+FEntity.toJSONString());
|
||||
//设置主数据
|
||||
JSONObject FAccountBookID=new JSONObject();//账薄
|
||||
FAccountBookID.put("FNumber",zb);
|
||||
Model.put("FAccountBookID",FAccountBookID);
|
||||
String FDate=sim.format(new Date());
|
||||
Model.put("FDate",FDate);
|
||||
JSONObject FVOUCHERGROUPID=new JSONObject();//凭证字默认AP
|
||||
FVOUCHERGROUPID.put("FNumber","PZZ3");
|
||||
Model.put("FVOUCHERGROUPID",FVOUCHERGROUPID);
|
||||
String FYEAR=sim.format(new Date()).split("-")[0];//会计年度
|
||||
String FPERIOD =sim.format(new Date()).split("-")[1];//期间
|
||||
Model.put("FYEAR",FYEAR);
|
||||
Model.put("FPERIOD",FPERIOD);
|
||||
String FDEBITTOTAL=getjfZje(requestid);//借方总金额:FDEBITTOTAL
|
||||
String FCREDITTOTAL=getdfZje(requestid);//贷方总金额:FCREDITTOTAL
|
||||
Model.put("FDEBITTOTAL",FDEBITTOTAL);
|
||||
Model.put("FCREDITTOTAL",FCREDITTOTAL);
|
||||
String FCreateDate=sim.format(new Date());//创建日期:FCreateDate
|
||||
JSONObject FACCBOOKORGID=new JSONObject();//核算组织:FACCBOOKORGID
|
||||
FACCBOOKORGID.put("FNumber",zz);
|
||||
Model.put("FACCBOOKORGID",FACCBOOKORGID);
|
||||
//Model.put("FCreateDate",FCreateDate);
|
||||
String FPRINTTIMES="0";//打印次数:FPRINTTIMES
|
||||
String FCurrentYear=sim.format(new Date()).split("-")[0];//当前年度:FCurrentYear
|
||||
String FCurrentPeriod=sim.format(new Date()).split("-")[1];//当前期间:FCurrentPeriod
|
||||
Model.put("FPRINTTIMES",FPRINTTIMES);
|
||||
//Model.put("FCurrentYear",FCurrentYear);
|
||||
//Model.put("FCurrentPeriod",FCurrentPeriod);
|
||||
Model.put("FEntity",FEntity);
|
||||
Models.add(Model);
|
||||
//凭借主数据
|
||||
VOUCHER.put("NeedReturnFields","[\"FVOUCHERID\",\"FVOUCHERGROUPNO\"]");
|
||||
VOUCHER.put("Model",Model);
|
||||
log.error(VOUCHER.toJSONString());
|
||||
/*开始调用接口
|
||||
1;登陆
|
||||
2;调用接口
|
||||
*/
|
||||
if(VOUCHER!=null&&VOUCHER.size()>0&&("".equals(sfxr)||"1".equals(sfxr))){
|
||||
RecordSet updRec=new RecordSet();
|
||||
com.jet.util.InvokeHelper.POST_K3CloudURL="http://k3.jet.co.id:8880/k3cloud/";
|
||||
String dbid="5d48f604c8361e";//dbid1;//"5d48f604c8361e";//"5a964ecc967246";
|
||||
String uuid=uuid1;
|
||||
String password=password2;
|
||||
org.json.JSONObject resultjson=null;
|
||||
int lang=2052;
|
||||
try {
|
||||
boolean flag=InvokeHelper.Login(dbid, uuid, password, lang);
|
||||
//out.print(flag);
|
||||
if(flag){//登陆成功
|
||||
resultjson=com.jet.util.InvokeHelper.Save("GL_VOUCHER",VOUCHER.toJSONString());
|
||||
boolean flag1=resultjson.getBoolean("flag");
|
||||
String resultstr=resultjson.getString("sResult");
|
||||
log.error("resultstr"+resultstr);
|
||||
if(flag1){
|
||||
JSONObject HAHA=JSONObject.parseObject(resultstr);
|
||||
JSONObject Result=HAHA.getJSONObject("Result");
|
||||
JSONObject ResponseStatus=Result.getJSONObject("ResponseStatus");
|
||||
boolean IsSuccess=ResponseStatus.getBoolean("IsSuccess");
|
||||
if(IsSuccess){
|
||||
updRec.execute("update formtable_main_24 set sfxr='0' where requestid='"+requestid+"' ");
|
||||
String FVOUCHERID=Result.getString("Id");
|
||||
String Fv=getFv(Queryurl+""+FVOUCHERID,baseis);
|
||||
updRec.execute("update formtable_main_24 set pzbh='"+Fv+"' where requestid='"+requestid+"' ");
|
||||
//out.print("成功"+FVOUCHERID);
|
||||
}else{
|
||||
request.getRequestManager().setMessageid("失败");
|
||||
request.getRequestManager().setMessage("失败");//提醒信息id
|
||||
request.getRequestManager().setMessagecontent("写入K3系统不成功,系统反馈信息如下:"+HAHA.toString());//提醒信息内容
|
||||
|
||||
return Action.FAILURE_AND_CONTINUE;
|
||||
}
|
||||
}else{
|
||||
request.getRequestManager().setMessageid("失败");
|
||||
request.getRequestManager().setMessage("失败");//提醒信息id
|
||||
request.getRequestManager().setMessagecontent("写入K3系统不成功,系统反馈信息如下:"+resultstr.toString());//提醒信息内容
|
||||
|
||||
return Action.FAILURE_AND_CONTINUE;
|
||||
}
|
||||
|
||||
}
|
||||
} catch (Exception e) {
|
||||
//TODO Auto-generated catch block
|
||||
log.error("GL_VOUCHER--Exception"+e.getMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return SUCCESS;
|
||||
}
|
||||
//更具ID获取凭证编号
|
||||
public String getFv(String url,String basis)throws Exception{
|
||||
String Fv="";
|
||||
//out.print("url-"+url+" basis"+basis+" ");
|
||||
try{
|
||||
String result=sendGet(url,"",basis);
|
||||
// out.print("url-"+url+" basis"+basis+" result"+result);
|
||||
JSONArray json=JSONArray.parseArray(result);
|
||||
if(json!=null&&json.size()>0){
|
||||
for(int i=0;i<json.size();i++){
|
||||
JSONObject obj= json.getJSONObject(i);
|
||||
Fv=obj.getString("Voucher No");
|
||||
}
|
||||
}
|
||||
}catch(Exception e){
|
||||
|
||||
}
|
||||
return Fv;
|
||||
}
|
||||
public static String sendGet(String url, String param,String basis) {
|
||||
String result = "";
|
||||
InputStream in = null;
|
||||
try {
|
||||
String urlNameString = url ;
|
||||
URL realUrl = new URL(urlNameString);
|
||||
URLConnection connection = realUrl.openConnection();
|
||||
String auth=basis;//"JNT:JNT2019";
|
||||
String code = new sun.misc.BASE64Encoder().encode(auth.getBytes());
|
||||
connection.setRequestProperty("Authorization", "Basic " + code);
|
||||
connection.connect();
|
||||
Map<String, List<String>> map = connection.getHeaderFields();
|
||||
|
||||
|
||||
for (String key : map.keySet()) {
|
||||
System.out.println(key + "--->" + map.get(key));
|
||||
}
|
||||
//接收核心返回过来的数据 xml 需要解析
|
||||
in =connection.getInputStream();
|
||||
byte[] b =getBytes(in);
|
||||
if(b.length>0){
|
||||
result=new String(b);
|
||||
}
|
||||
System.out.println(b.length);
|
||||
} catch (Exception e) {
|
||||
|
||||
System.out.println(e.getMessage());
|
||||
e.printStackTrace();
|
||||
}finally {
|
||||
try {
|
||||
if (in != null) {
|
||||
in.close();
|
||||
}
|
||||
} catch (Exception e2) {
|
||||
System.out.println(e2.getMessage());
|
||||
e2.printStackTrace();
|
||||
}
|
||||
}
|
||||
//System.out.println("de"+result);
|
||||
return result;
|
||||
}
|
||||
public static byte[] getBytes(InputStream fis){
|
||||
Logger log = Logger.getLogger(Logger.class);
|
||||
byte[] buffer = null;
|
||||
try {
|
||||
//File file = new File(filePath);
|
||||
//FileInputStream fis = new FileInputStream(file);
|
||||
ByteArrayOutputStream bos = new ByteArrayOutputStream(1000);
|
||||
byte[] b = new byte[10000];
|
||||
int n;
|
||||
while ((n = fis.read(b)) != -1) {
|
||||
bos.write(b, 0, n);
|
||||
}
|
||||
fis.close();
|
||||
bos.close();
|
||||
buffer = bos.toByteArray();
|
||||
} catch (FileNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
System.out.println("buffer--->"+buffer.length);
|
||||
return buffer;
|
||||
}
|
||||
//获取借方总金额
|
||||
public static String getjfZje(String requestid){
|
||||
RecordSet re=new RecordSet();
|
||||
String je="";
|
||||
String sql="select sum(jfje) jfje from formtable_main_22 a,formtable_main_22_dt4 b where a.id=b.mainid and a.requestid='"+requestid+"'";
|
||||
re.execute(sql);
|
||||
while(re.next()){
|
||||
je=re.getString("jfje") ;
|
||||
}
|
||||
return je;
|
||||
}
|
||||
//获取贷方总金额
|
||||
public static String getdfZje(String requestid){
|
||||
RecordSet re=new RecordSet();
|
||||
String je="";
|
||||
String sql="select sum(dfje) dfje from formtable_main_22 a,formtable_main_22_dt5 b where a.id=b.mainid and a.requestid='"+requestid+"'";
|
||||
re.execute(sql);
|
||||
while(re.next()){
|
||||
je=re.getString("dfje") ;
|
||||
}
|
||||
return je;
|
||||
}
|
||||
//获取赋值核算类型
|
||||
public String getFzhx(String km,String zt,String zz,String zb,Map<String,String> Hswd ){
|
||||
String FDIMENSION="";//核算维度
|
||||
RecordSet re=new RecordSet();
|
||||
String sql="select b.FDIMENSION from uf_accountinfo a,uf_accountinfo_dt1 b where a.id=b.mainid and a.zt='"+zt+"' and b.FNUMBER='"+km+"' and b.forgnumber='"+zz+"' and FAcctBookNumber='"+zb+"' ";
|
||||
//out.print(sql);
|
||||
re.execute(sql);
|
||||
while(re.next()){
|
||||
String str=Util.null2String(re.getString("FDIMENSION")).trim() ;
|
||||
String[] FDIMENSIONs=str.split(",");
|
||||
for(String demo:FDIMENSIONs){
|
||||
if(demo!=null&&!"".equals(demo)){
|
||||
FDIMENSION=FDIMENSION+Hswd.get(demo)+",";
|
||||
}
|
||||
}
|
||||
}
|
||||
if(FDIMENSION.endsWith(",")){
|
||||
FDIMENSION=FDIMENSION.substring(0,FDIMENSION.length()-1);
|
||||
}
|
||||
return FDIMENSION;
|
||||
}
|
||||
//insert 事务
|
||||
public boolean SynInsert1(List<String> array){
|
||||
if(array==null||array.size()<=0){
|
||||
return false;
|
||||
}
|
||||
Logger log = Logger.getLogger(DataSource.class);
|
||||
RecordSetTrans RecordSetTrans=new RecordSetTrans();
|
||||
RecordSetTrans.setAutoCommit(false);
|
||||
boolean flag=true;
|
||||
|
||||
try{
|
||||
RecordSetTrans.setAutoCommit(false);
|
||||
// stmt = conn.createStatement();
|
||||
for(String str:array){
|
||||
//int index =RecordSetTrans.executeUpdate(str);
|
||||
flag=RecordSetTrans.executeSql(str);
|
||||
log.error("SynInsert--"+str);
|
||||
if(!flag){
|
||||
//flag=false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(!flag){//事务回滚
|
||||
RecordSetTrans.rollback();
|
||||
}else{
|
||||
RecordSetTrans.commit();
|
||||
}
|
||||
}catch(Exception e){
|
||||
log.error("SynInsert--Exception "+e.getMessage());
|
||||
flag=false;
|
||||
}
|
||||
|
||||
return flag;
|
||||
}
|
||||
//获取科目名称
|
||||
public String getKmname(String km,String zt,String zz,String zb){
|
||||
String FNAME="";//核算维度
|
||||
RecordSet re=new RecordSet();
|
||||
String sql="select b.FNAME from uf_accountinfo a,uf_accountinfo_dt1 b where a.id=b.mainid and a.zt='"+zt+"' and b.FNUMBER='"+km+"' and b.forgnumber='"+zz+"' and FAcctBookNumber='"+zb+"' ";
|
||||
re.execute(sql);
|
||||
while(re.next()){
|
||||
FNAME=Util.null2String(re.getString("FNAME"));
|
||||
}
|
||||
return FNAME;
|
||||
}
|
||||
//获取币种的小数位
|
||||
public int getXsw(String bz){
|
||||
int xsw=0;
|
||||
RecordSet re=new RecordSet();
|
||||
String sql="select * from uf_k3bz where bh='"+bz+"'";
|
||||
re.execute(sql);
|
||||
while(re.next()){
|
||||
xsw=Integer.parseInt(Util.null2o(re.getString("xsw"))) ;
|
||||
}
|
||||
return xsw;
|
||||
}
|
||||
|
||||
//浮点型转换
|
||||
public static float getfloats(String demo,String demo1,int len){
|
||||
Logger log = Logger.getLogger(BigDecimal.class);
|
||||
if(len==0){
|
||||
len=0;
|
||||
}
|
||||
String str=Util.null2String(demo);
|
||||
String str1=Util.null2String(demo1);
|
||||
if("".equals(str)||"".equals(str.trim())||"null".equalsIgnoreCase(str.trim())){
|
||||
return 0;
|
||||
}
|
||||
if("".equals(str1)||"".equals(str.trim())||"null".equalsIgnoreCase(str1.trim())){
|
||||
str1="1";
|
||||
}
|
||||
float fl=0.0f;
|
||||
//String str=Util.null2String(demo);
|
||||
try{
|
||||
if(str.trim().length()>0){
|
||||
BigDecimal b1 = new BigDecimal(str.trim());
|
||||
BigDecimal b2 = new BigDecimal(str1.trim());
|
||||
BigDecimal b3=b1.multiply(b2);
|
||||
//System.out.println(b1.setScale(2,BigDecimal.ROUND_HALF_UP));
|
||||
fl=b3.setScale(len,BigDecimal.ROUND_HALF_UP).floatValue();
|
||||
}
|
||||
log.error("getfloats"+fl);
|
||||
}catch(Exception e){
|
||||
log.error(demo+"getfloats异常"+e.getMessage());
|
||||
}
|
||||
return fl;
|
||||
}
|
||||
|
||||
|
||||
//浮点型转换
|
||||
public static float getfloats1(String demo,String demo1,int len){
|
||||
Logger log = Logger.getLogger(BigDecimal.class);
|
||||
if(len==0){
|
||||
len=0;
|
||||
}
|
||||
String str=Util.null2String(demo);
|
||||
String str1=Util.null2String(demo1);
|
||||
if("".equals(str)||"".equals(str.trim())||"null".equalsIgnoreCase(str.trim())){
|
||||
str="0";
|
||||
}
|
||||
if("".equals(str1)||"".equals(str.trim())||"null".equalsIgnoreCase(str1.trim())){
|
||||
str1="0";
|
||||
}
|
||||
float fl=0.0f;
|
||||
//String str=Util.null2String(demo);
|
||||
try{
|
||||
if(str.trim().length()>0){
|
||||
BigDecimal b1 = new BigDecimal(str.trim());
|
||||
BigDecimal b2 = new BigDecimal(str1.trim());
|
||||
BigDecimal b3=b1.add(b2);
|
||||
//System.out.println(b1.setScale(2,BigDecimal.ROUND_HALF_UP));
|
||||
fl=b3.setScale(len,BigDecimal.ROUND_HALF_UP).floatValue();
|
||||
}
|
||||
log.error("getfloats"+fl);
|
||||
}catch(Exception e){
|
||||
log.error(demo+"getfloats异常"+e.getMessage());
|
||||
}
|
||||
return fl;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,384 @@
|
|||
package com.jet.action;
|
||||
import java.util.*;
|
||||
import weaver.soa.workflow.request.RequestInfo;
|
||||
import weaver.workflow.action.BaseAction;
|
||||
import weaver.conn.RecordSet;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import weaver.general.Util;
|
||||
import org.apache.log4j.Logger;
|
||||
import weaver.interfaces.datasource.DataSource;
|
||||
import weaver.interfaces.workflow.action.Action;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.InputStream;
|
||||
import weaver.conn.RecordSetTrans;
|
||||
|
||||
|
||||
public class CreatehkJD extends BaseAction{
|
||||
@Override
|
||||
public String execute(RequestInfo requestInfo) {
|
||||
// TODO Auto-generated method stub
|
||||
//创建还款的借贷方
|
||||
//0:贷方现金
|
||||
//1:借方还款(职员)
|
||||
//2:借方借款(职员)
|
||||
Logger log = Logger.getLogger(JSONObject.class);
|
||||
Map<String,String> Hswd=new HashMap<String,String>();//核算维度对照表
|
||||
Hswd.put("FFLEX4","gys");//供应商
|
||||
Hswd.put("FFLEX6","kh");//客户
|
||||
Hswd.put("FFLEX7","yg");//员工
|
||||
Hswd.put("FFLEX5","bm");//部门
|
||||
Hswd.put("FFLEX9","fyxm");//费用项目
|
||||
Hswd.put("FFLEX8","wl");//物料
|
||||
Hswd.put("FFLEX10","zc");//资产
|
||||
Hswd.put("FFLEX12","wlz");//物料组
|
||||
Hswd.put("FFLEX13","khz");//客户组
|
||||
RecordSet urlre=new RecordSet();
|
||||
String urlsql="select * from uf_urlinfo ";
|
||||
|
||||
String url="";
|
||||
String username="";
|
||||
String password="";
|
||||
urlre.execute(urlsql);
|
||||
while(urlre.next()){
|
||||
url=Util.null2String(urlre.getString("url"));
|
||||
username=Util.null2String(urlre.getString("username"));
|
||||
password=Util.null2String(urlre.getString("password"));
|
||||
}
|
||||
List<String> jlist=new ArrayList<String>();//借方
|
||||
List<String> dlist=new ArrayList<String>();//贷方
|
||||
String requestid=requestInfo.getRequestid();//
|
||||
String mainid="";//
|
||||
String zt="";//账套
|
||||
String zz="";//组织
|
||||
String zb="";//账薄
|
||||
String zzjdhl="";//做账节点汇率
|
||||
String bz="";//币种
|
||||
String fkyh="";//付款银行
|
||||
String je="";//借款金额
|
||||
String jklx="";//借款类型
|
||||
String dls="";//代理商
|
||||
String emp="";//职员
|
||||
RecordSet re=new RecordSet();
|
||||
String jsql="";
|
||||
String dsql="";
|
||||
String sql="select * from formtable_main_25 where requestid='"+requestid+"'";
|
||||
log.error(requestid+"CreatehkJD"+sql);
|
||||
re.execute(sql);
|
||||
while(re.next()){
|
||||
mainid=Util.null2String(re.getString("id")).trim();
|
||||
zz=Util.null2String(re.getString("zz")).trim();//组织
|
||||
zt=Util.null2String(re.getString("zt")).trim();//账套
|
||||
zb=Util.null2String(re.getString("zb")).trim();//账薄
|
||||
|
||||
fkyh=Util.null2String(re.getString("hkzh")).trim();//付款银行
|
||||
je=Util.null2String(re.getString("hkje")).trim();//金额
|
||||
jklx=Util.null2String(re.getString("hklx")).trim();//借款类型
|
||||
dls=Util.null2String(re.getString("dls")).trim();//代理商
|
||||
emp=Util.null2String(re.getString("emp")).trim();//职员
|
||||
}
|
||||
//判定借方科目 还款与 借款的 借贷方向 相反 借银行或现金 贷供应商或个人
|
||||
String jfkm="";//借方科目
|
||||
String jfkmDesc="";//借方科目
|
||||
String dfkm="";//贷方科目
|
||||
String dfkmDesc="";//贷方科目
|
||||
if("0".equals(jklx)){//个人
|
||||
//jfkm=SpelKm(zt,zz,zb,"2");
|
||||
//if("".equals(fkyh)){//现金
|
||||
//dfkm=SpelKm(zt,zz,zb,"0");
|
||||
//}else{//转账
|
||||
//dfkm=fkyh;
|
||||
//}
|
||||
dfkm=SpelKm(zt,zz,zb,"2");
|
||||
if("".equals(fkyh)){//现金
|
||||
jfkm=SpelKm(zt,zz,zb,"0");
|
||||
}else{
|
||||
jfkm=fkyh;
|
||||
}
|
||||
}else{//代理商
|
||||
//if("".equals(fkyh)){//现金
|
||||
//dfkm=SpelKm(zt,zz,zb,"0");
|
||||
//}else{//转账
|
||||
//dfkm=fkyh;
|
||||
//}
|
||||
if("".equals(fkyh)){//现金
|
||||
jfkm=SpelKm(zt,zz,zb,"0");
|
||||
}else{//转账
|
||||
jfkm=fkyh;
|
||||
}
|
||||
//通过接口 获取贷方科目
|
||||
if(!"".equals(dls)){
|
||||
String result=sendGet(url+"CusGlbalance/"+dls,"",username+":"+password);
|
||||
//out.print(result);
|
||||
Map<String,String> map=getJSONToMap(result);
|
||||
dfkm=Util.null2String(map.get("FAcctNumber"));
|
||||
}
|
||||
//通过接口 获取贷方科目
|
||||
//if(!"".equals(dls)){
|
||||
//String result=sendGet(url+"CusGlbalance/"+dls,"",username+":"+password);
|
||||
//out.print(result);
|
||||
// Map<String,String> map=getJSONToMap(result);
|
||||
//jfkm=Util.null2String(map.get("FAcctNumber"));
|
||||
//}
|
||||
}
|
||||
if(!"".equals(jfkm)){
|
||||
jfkmDesc=getKmname(jfkm,zt,zz,zb);
|
||||
}
|
||||
if(!"".equals(dfkm)){
|
||||
dfkmDesc=getKmname(dfkm,zt,zz,zb);
|
||||
}
|
||||
if("0".equals(jklx)){
|
||||
dls="";
|
||||
}
|
||||
jlist.add("insert into formtable_main_25_dt1(mainid,jfkmbm,jfkmmc,jfje)values('"+mainid+"','"+jfkm+"','"+jfkmDesc+"','"+je+"')");
|
||||
jlist.add("insert into formtable_main_25_dt2(mainid,dfkmbm,dfkmmc,dfje,kh,yg)values('"+mainid+"','"+dfkm+"','"+dfkmDesc+"','"+je+"','"+dls+"','"+emp+"')");
|
||||
if(jlist.size()>0){
|
||||
log.error(jlist.toString());
|
||||
boolean flag=SynInsert1(jlist);
|
||||
if(!flag){
|
||||
requestInfo.getRequestManager().setMessageid("创建借贷失败");
|
||||
requestInfo.getRequestManager().setMessage("创建借贷失败");//提醒信息id
|
||||
requestInfo.getRequestManager().setMessagecontent("创建借贷失败");//提醒信息内容
|
||||
|
||||
return Action.FAILURE_AND_CONTINUE;
|
||||
}
|
||||
//out.print(flag);
|
||||
}
|
||||
return SUCCESS;
|
||||
}
|
||||
//将JSON 解析成 Map
|
||||
public Map<String,String> getJSONToMap(String str){
|
||||
Map<String,String> map=new HashMap<String,String>();
|
||||
try{
|
||||
JSONArray jsons=JSONObject.parseArray(str);
|
||||
if(jsons!=null&&jsons.size()>0){
|
||||
JSONObject json=(JSONObject)jsons.get(0);
|
||||
Set<String> set=json.keySet();
|
||||
for(String demo:set){
|
||||
map.put(demo,Util.null2String(json.getString(demo)));
|
||||
}
|
||||
}
|
||||
}catch(Exception e){
|
||||
|
||||
}
|
||||
return map;
|
||||
}
|
||||
//取特殊科目编号
|
||||
public String SpelKm(String zt,String zz,String zb,String lx){
|
||||
Logger log = Logger.getLogger(BigDecimal.class);
|
||||
RecordSet re=new RecordSet();
|
||||
String km="";//科目
|
||||
re.execute("select * from uf_k3tskm a,uf_k3tskm_dt1 b where a.id=b.mainid and zt='"+zt+"' and zz='"+zz+"' and zb='"+zb+"' and lx='"+lx+"'");
|
||||
while(re.next()){
|
||||
km=re.getString("km");
|
||||
}
|
||||
return km;
|
||||
}
|
||||
//获取赋值核算类型
|
||||
public String getFzhx(String km,String zt,String zz,String zb,Map<String,String> Hswd){
|
||||
String FDIMENSION="";//核算维度
|
||||
RecordSet re=new RecordSet();
|
||||
String sql="select b.FDIMENSION from uf_accountinfo a,uf_accountinfo_dt1 b where a.id=b.mainid and a.zt='"+zt+"' and b.FNUMBER='"+km+"' and b.forgnumber='"+zz+"' and FAcctBookNumber='"+zb+"' ";
|
||||
//out.print(sql);
|
||||
re.execute(sql);
|
||||
while(re.next()){
|
||||
String str=Util.null2String(re.getString("FDIMENSION")).trim() ;
|
||||
String[] FDIMENSIONs=str.split(",");
|
||||
for(String demo:FDIMENSIONs){
|
||||
if(demo!=null&&!"".equals(demo)){
|
||||
FDIMENSION=FDIMENSION+Hswd.get(FDIMENSION)+",";
|
||||
}
|
||||
}
|
||||
}
|
||||
return FDIMENSION;
|
||||
}
|
||||
//insert 事务
|
||||
public boolean SynInsert1(List<String> array){
|
||||
if(array==null||array.size()<=0){
|
||||
return false;
|
||||
}
|
||||
Logger log = Logger.getLogger(DataSource.class);
|
||||
RecordSetTrans RecordSetTrans=new RecordSetTrans();
|
||||
RecordSetTrans.setAutoCommit(false);
|
||||
boolean flag=true;
|
||||
|
||||
try{
|
||||
RecordSetTrans.setAutoCommit(false);
|
||||
// stmt = conn.createStatement();
|
||||
for(String str:array){
|
||||
//int index =RecordSetTrans.executeUpdate(str);
|
||||
flag=RecordSetTrans.executeSql(str);
|
||||
log.error("SynInsert--"+str);
|
||||
if(!flag){
|
||||
//flag=false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(!flag){//事务回滚
|
||||
RecordSetTrans.rollback();
|
||||
}else{
|
||||
RecordSetTrans.commit();
|
||||
}
|
||||
}catch(Exception e){
|
||||
log.error("SynInsert--Exception "+e.getMessage());
|
||||
flag=false;
|
||||
}
|
||||
|
||||
return flag;
|
||||
}
|
||||
//获取科目名称
|
||||
public String getKmname(String km,String zt,String zz,String zb){
|
||||
String FNAME="";//核算维度
|
||||
RecordSet re=new RecordSet();
|
||||
String sql="select b.FNAME from uf_accountinfo a,uf_accountinfo_dt1 b where a.id=b.mainid and a.zt='"+zt+"' and b.FNUMBER='"+km+"' and b.forgnumber='"+zz+"' and FAcctBookNumber='"+zb+"' ";
|
||||
re.execute(sql);
|
||||
while(re.next()){
|
||||
FNAME=Util.null2String(re.getString("FNAME"));
|
||||
}
|
||||
return FNAME;
|
||||
}
|
||||
//获取币种的小数位
|
||||
public int getXsw(String bz){
|
||||
int xsw=0;
|
||||
RecordSet re=new RecordSet();
|
||||
String sql="select * from uf_k3bz where bh='"+bz+"'";
|
||||
re.execute(sql);
|
||||
while(re.next()){
|
||||
xsw=Integer.parseInt(Util.null2o(re.getString("xsw"))) ;
|
||||
}
|
||||
return xsw;
|
||||
}
|
||||
|
||||
//浮点型转换
|
||||
public static float getfloats(String demo,String demo1,int len){
|
||||
Logger log = Logger.getLogger(BigDecimal.class);
|
||||
if(len==0){
|
||||
len=0;
|
||||
}
|
||||
String str=Util.null2String(demo);
|
||||
String str1=Util.null2String(demo1);
|
||||
if("".equals(str)||"".equals(str.trim())||"null".equalsIgnoreCase(str.trim())){
|
||||
return 0;
|
||||
}
|
||||
if("".equals(str1)||"".equals(str.trim())||"null".equalsIgnoreCase(str1.trim())){
|
||||
str1="1";
|
||||
}
|
||||
float fl=0.0f;
|
||||
//String str=Util.null2String(demo);
|
||||
try{
|
||||
if(str.trim().length()>0){
|
||||
BigDecimal b1 = new BigDecimal(str.trim());
|
||||
BigDecimal b2 = new BigDecimal(str1.trim());
|
||||
BigDecimal b3=b1.multiply(b2);
|
||||
//System.out.println(b1.setScale(2,BigDecimal.ROUND_HALF_UP));
|
||||
fl=b3.setScale(len,BigDecimal.ROUND_HALF_UP).floatValue();
|
||||
}
|
||||
log.error("getfloats"+fl);
|
||||
}catch(Exception e){
|
||||
log.error(demo+"getfloats异常"+e.getMessage());
|
||||
}
|
||||
return fl;
|
||||
}
|
||||
|
||||
|
||||
//浮点型转换
|
||||
public static float getfloats1(String demo,String demo1,int len){
|
||||
Logger log = Logger.getLogger(BigDecimal.class);
|
||||
if(len==0){
|
||||
len=0;
|
||||
}
|
||||
String str=Util.null2String(demo);
|
||||
String str1=Util.null2String(demo1);
|
||||
if("".equals(str)||"".equals(str.trim())||"null".equalsIgnoreCase(str.trim())){
|
||||
str="0";
|
||||
}
|
||||
if("".equals(str1)||"".equals(str.trim())||"null".equalsIgnoreCase(str1.trim())){
|
||||
str1="0";
|
||||
}
|
||||
float fl=0.0f;
|
||||
//String str=Util.null2String(demo);
|
||||
try{
|
||||
if(str.trim().length()>0){
|
||||
BigDecimal b1 = new BigDecimal(str.trim());
|
||||
BigDecimal b2 = new BigDecimal(str1.trim());
|
||||
BigDecimal b3=b1.add(b2);
|
||||
//System.out.println(b1.setScale(2,BigDecimal.ROUND_HALF_UP));
|
||||
fl=b3.setScale(len,BigDecimal.ROUND_HALF_UP).floatValue();
|
||||
}
|
||||
log.error("getfloats"+fl);
|
||||
}catch(Exception e){
|
||||
log.error(demo+"getfloats异常"+e.getMessage());
|
||||
}
|
||||
return fl;
|
||||
}
|
||||
public static String sendGet(String url, String param,String basis) {
|
||||
String result = "";
|
||||
InputStream in = null;
|
||||
try {
|
||||
String urlNameString = url ;
|
||||
URL realUrl = new URL(urlNameString);
|
||||
URLConnection connection = realUrl.openConnection();
|
||||
String auth="JNT:JNT2019";
|
||||
String code = new sun.misc.BASE64Encoder().encode(auth.getBytes());
|
||||
connection.setRequestProperty("Authorization", "Basic " + code);
|
||||
connection.connect();
|
||||
Map<String, List<String>> map = connection.getHeaderFields();
|
||||
|
||||
|
||||
for (String key : map.keySet()) {
|
||||
System.out.println(key + "--->" + map.get(key));
|
||||
}
|
||||
//接收核心返回过来的数据 xml 需要解析
|
||||
in =connection.getInputStream();
|
||||
byte[] b =getBytes(in);
|
||||
if(b.length>0){
|
||||
result=new String(b);
|
||||
}
|
||||
System.out.println(b.length);
|
||||
} catch (Exception e) {
|
||||
|
||||
System.out.println(e.getMessage());
|
||||
e.printStackTrace();
|
||||
}finally {
|
||||
try {
|
||||
if (in != null) {
|
||||
in.close();
|
||||
}
|
||||
} catch (Exception e2) {
|
||||
System.out.println(e2.getMessage());
|
||||
e2.printStackTrace();
|
||||
}
|
||||
}
|
||||
//System.out.println("de"+result);
|
||||
return result;
|
||||
}
|
||||
public static byte[] getBytes(InputStream fis){
|
||||
Logger log = Logger.getLogger(Logger.class);
|
||||
byte[] buffer = null;
|
||||
try {
|
||||
//File file = new File(filePath);
|
||||
//FileInputStream fis = new FileInputStream(file);
|
||||
ByteArrayOutputStream bos = new ByteArrayOutputStream(1000);
|
||||
byte[] b = new byte[10000];
|
||||
int n;
|
||||
while ((n = fis.read(b)) != -1) {
|
||||
bos.write(b, 0, n);
|
||||
}
|
||||
fis.close();
|
||||
bos.close();
|
||||
buffer = bos.toByteArray();
|
||||
} catch (FileNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
System.out.println("buffer--->"+buffer.length);
|
||||
return buffer;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,66 @@
|
|||
package com.jet.action;
|
||||
|
||||
|
||||
import weaver.conn.RecordSet;
|
||||
import weaver.general.BaseBean;
|
||||
import weaver.general.Util;
|
||||
import weaver.interfaces.workflow.action.Action;
|
||||
import weaver.soa.workflow.request.RequestInfo;
|
||||
import selfdev.util.base.BaseUtil;
|
||||
import selfdev.util.log.LogTool;
|
||||
|
||||
/**
|
||||
* 付款申请流程归档时更新合同台账数据
|
||||
* @author KangMD
|
||||
* 2019-12-06
|
||||
*/
|
||||
public class UpdateContractByPayAction extends BaseBean implements Action {
|
||||
|
||||
public String execute(RequestInfo ri) {
|
||||
LogTool log=new LogTool("/log/selfdev/action", false);
|
||||
//获取requestid
|
||||
String requestid=ri.getRequestid();
|
||||
String workflowid=ri.getWorkflowid();
|
||||
//获取用户语言
|
||||
int language=ri.getRequestManager().getUser().getLanguage();
|
||||
log.writeLog("language---------->"+language);
|
||||
String workflowname=BaseUtil.getBaseInfoByParm("workflowname", "workflow_base", "id", workflowid, "");
|
||||
log.writeLog("---------------"+workflowname+"开始写入K3生成付款单-------------requestId:" + requestid);
|
||||
//获取表名
|
||||
String tablename=BaseUtil.getBaseInfoByParm("tablename", "workflow_bill", "1", "1", " and id in (select formid from workflow_base where id="+workflowid+")");;
|
||||
RecordSet rs=new RecordSet();
|
||||
try {
|
||||
String mainid="";//主键ID
|
||||
String sfyht="";//是否有合同
|
||||
double bcfkje=0;//本次付款金额
|
||||
String htxx="";//相关合同
|
||||
String sql="select * from "+tablename+" where requestid="+requestid;
|
||||
rs.execute(sql);
|
||||
while(rs.next()){
|
||||
mainid=Util.null2String(rs.getString("id"));
|
||||
sfyht=Util.null2String(rs.getString("sfyht"));
|
||||
bcfkje=Double.parseDouble(Util.null2o(rs.getString("bcfkje")).replaceAll(",", ""));
|
||||
htxx=Util.null2String(rs.getString("htxx"));
|
||||
}
|
||||
//有合同才需更新合同台账
|
||||
if("0".equals(sfyht)){
|
||||
//更新至建模的批次明细中
|
||||
sql="update uf_httz_dt1 a set (yfkje,fkzt)=(select TO_CHAR(to_number(replace(nvl(a.yfkje,0),',',''))+to_number(replace(nvl(b.bcfkje,0),',','')),'FM999,999,999,999,999,999,990.00'),(case when to_number(replace(nvl(a.yfkje,0),',',''))+to_number(replace(nvl(b.bcfkje,0),',',''))=to_number(replace(nvl(a.fkje,0),',','')) then 0 else 2 end) from "+tablename+"_dt5 b where a.id=b.fkpc and b.mainid='"+mainid+"') where a.mainid='"+htxx+"'";
|
||||
log.writeLog("流程中支付金额更新至合同建模明细中的金额SQL---------->"+sql);
|
||||
rs.execute(sql);
|
||||
//更新至建模的主表中
|
||||
sql="update uf_httz a set yfkje=TO_CHAR(to_number(replace(nvl(a.yfkje,0),',',''))+"+bcfkje+",'FM999,999,999,999,999,999,990.00'),fkzt=(case when to_number(replace(nvl(a.yfkje,0),',',''))+"+bcfkje+"=to_number(replace(nvl(a.htzje,0),',','')) then 0 else 2 end) where id='"+htxx+"'";
|
||||
log.writeLog("流程中支付金额更新至合同建模主表中的金额SQL---------->"+sql);
|
||||
rs.execute(sql);
|
||||
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
String error_msg="付款流程写入K3失败,错误信息为:------>"+e.toString();
|
||||
ri.getRequestManager().setMessage("111100");
|
||||
ri.getRequestManager().setMessagecontent(error_msg);
|
||||
return "0";
|
||||
}
|
||||
return SUCCESS;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,45 @@
|
|||
package com.jet.action;
|
||||
|
||||
import weaver.soa.workflow.request.RequestInfo;
|
||||
import weaver.workflow.action.BaseAction;
|
||||
import weaver.conn.RecordSet;
|
||||
import weaver.general.Util;
|
||||
|
||||
import com.working.util.LogTool;
|
||||
import com.working.util.WorkflowUtil;
|
||||
|
||||
/**
|
||||
* 02-用印申请-J&T中国
|
||||
* @author lwt
|
||||
*
|
||||
*/
|
||||
public class YyApply extends BaseAction{
|
||||
|
||||
LogTool log = new LogTool("/log/feeChina/",false);
|
||||
|
||||
@Override
|
||||
public String execute(RequestInfo requestInfo) {
|
||||
// TODO Auto-generated method stub
|
||||
String requestid = requestInfo.getRequestid();
|
||||
RecordSet rs = new RecordSet();
|
||||
RecordSet rs1 = new RecordSet();
|
||||
String mainTable = WorkflowUtil.getMainTable(requestid);
|
||||
String detail1Table = mainTable + "_dt1";
|
||||
int mainId = requestInfo.getRequestManager().getBillid();//主表数据id
|
||||
rs.execute("select * from " + detail1Table + " where mainid = '" + mainId + "' order by id desc");
|
||||
String sfwjMain = "1";//主表是否外借字段
|
||||
String sfwj = "";//明细表1是否外借字段
|
||||
while (rs.next()) {
|
||||
sfwj = Util.null2String(rs.getString("SFWJ"));
|
||||
if (!sfwj.isEmpty()) {
|
||||
if (sfwj.equals("0")) {//团队活动费
|
||||
sfwjMain = "0";//主表是否外借字段
|
||||
}
|
||||
}
|
||||
}
|
||||
rs1.execute("update " + mainTable + " set sfwj = '" +sfwjMain+ "' where requestid = '" + requestid +"'");
|
||||
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,45 @@
|
|||
package com.jet.k3;
|
||||
|
||||
|
||||
import kingdee.bos.webapi.client.K3CloudApiClient;
|
||||
import selfdev.util.log.LogTool;
|
||||
import weaver.file.Prop;
|
||||
import weaver.general.Util;
|
||||
|
||||
|
||||
/**
|
||||
* K3连接连接配置
|
||||
* @author
|
||||
*/
|
||||
public class K3Connect {
|
||||
//日志类
|
||||
public static LogTool log=new LogTool("/log/selfdev", false);
|
||||
//当前系统模式
|
||||
public static String mode=Util.null2String(Prop.getPropValue("DevToK3_jet", "mode"));
|
||||
//获取K3 连接参数
|
||||
public static String K3CloudURL =Util.null2String(Prop.getPropValue("DevToK3_jet", mode+"_K3CloudURL"));
|
||||
public static String dbId = Util.null2String(Prop.getPropValue("DevToK3_jet", mode+"_dbId"));
|
||||
public static String uid = Util.null2String(Prop.getPropValue("DevToK3_jet", mode+"_uid"));
|
||||
public static String pwd = Util.null2String(Prop.getPropValue("DevToK3_jet", mode+"_pwd"));
|
||||
public static int lang = Integer.parseInt(Util.null2o(Prop.getPropValue("DevToK3_jet", mode+"_lang")));
|
||||
|
||||
/**
|
||||
* 获取K3连接
|
||||
* @return
|
||||
*/
|
||||
public static K3CloudApiClient connect(){
|
||||
K3CloudApiClient client =null;
|
||||
try {
|
||||
client = new K3CloudApiClient(K3CloudURL);
|
||||
boolean result = client.login(dbId, uid, pwd, lang);
|
||||
if(!result){
|
||||
log.writeLog("连接K3失败,可能是用户名或密码错误!");
|
||||
client =null;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.writeLog("连接K3失败, 错误信息为: " + e.toString());
|
||||
client =null;
|
||||
}
|
||||
return client;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,115 @@
|
|||
package com.jet.schedule.syn;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.jet.k3.K3Connect;
|
||||
|
||||
import kingdee.bos.webapi.client.K3CloudApiClient;
|
||||
|
||||
import selfdev.util.base.BaseUtil;
|
||||
import selfdev.util.base.TimeCommonUtil;
|
||||
|
||||
import selfdev.util.log.LogTool;
|
||||
import weaver.conn.RecordSet;
|
||||
import weaver.file.Prop;
|
||||
import weaver.general.Util;
|
||||
import weaver.interfaces.schedule.BaseCronJob;
|
||||
import weaver.interfaces.schedule.CronJob;
|
||||
|
||||
|
||||
/**
|
||||
* 定时将K3中账簿数据同步至OA建模表
|
||||
* @author KangMD
|
||||
* 2019-11-14
|
||||
*/
|
||||
public class SynAccountBookToOA extends BaseCronJob implements CronJob {
|
||||
|
||||
public static RecordSet rs=new RecordSet();
|
||||
public static LogTool log=new LogTool("/log/selfdev/syn", false);
|
||||
|
||||
public void execute(){
|
||||
long startStamp=System.currentTimeMillis();
|
||||
log.writeLog("*******同步K3账簿开始start:(" + weaver.general.TimeUtil.getCurrentTimeString() + ")");
|
||||
try {
|
||||
//连接K3
|
||||
K3CloudApiClient client =K3Connect.connect();
|
||||
if(client!=null){
|
||||
String sql="";
|
||||
String now=TimeCommonUtil.obtainDate(0);//获取当前系统日期yyyy-MM-dd HH:mm:ss格式
|
||||
String currDate = now.substring(0,10);//当前系统日期
|
||||
String currTime = now.substring(11);//当前系统时间
|
||||
//获取账簿key-value MAP值,主键为账簿内码ID
|
||||
Map<String,String> zb_map=BaseUtil.getMapKeyValueInfoByParm("uf_zb_K3","","FBookId","FNumber");
|
||||
//当前系统模式
|
||||
String mode=Util.null2String(Prop.getPropValue("DevToK3_jet", "mode"));
|
||||
//账簿建模ID
|
||||
String modeid_zb=Util.null2String(Prop.getPropValue("DevToK3_jet", mode+"_modeid_zb"));
|
||||
|
||||
//分页查询
|
||||
for(int t=0;t<1000;t++){
|
||||
String sContent = "{\"FormId\":\"BD_ACCOUNTBOOK\","
|
||||
// 账簿formid
|
||||
+"\"TopRowCount\":0,"
|
||||
// 最多允许查询的数量,0或者不要此属性表示不限制
|
||||
+"\"Limit\":2000,"
|
||||
// 分页取数每页允许获取的数据,最大不能超过2000
|
||||
+"\"StartRow\":"+(2000*t)+","
|
||||
//分页取数开始行索引,从0开始,例如每页10行数据,第2页开始是10,第3页开始是20
|
||||
//""FilterString":"FMaterialId.FNumber like 'HG_TEST%'","+// 过滤条件
|
||||
//""FilterString":"FBillNo='CGDD000008'","+// 过滤条件
|
||||
+"\"FilterString\":\"FNumber!=''\"," //过滤条件 编码不为空值
|
||||
//+"\"OrderString\":\"FGoodsNO ASC\","// 排序条件
|
||||
//获取账簿基础信息 组织ID、内码、名称、编码、科目表
|
||||
+"\"FieldKeys\":\"FUseOrgId,FBookId,FName,FNumber,FACCTTABLEID\"}";
|
||||
//获取账簿列表
|
||||
List<List<Object>> sResult = client.executeBillQuery(sContent);
|
||||
int rows=sResult.size();
|
||||
//已经没有数据了,跳出循环
|
||||
if(rows==0){
|
||||
break;
|
||||
}else{
|
||||
for(int k=0;k<rows;k++){
|
||||
String FUseOrgId=Util.null2String(sResult.get(k).get(0));//组织ID
|
||||
String FBookId=Util.null2String(sResult.get(k).get(1));//账簿内码
|
||||
String FName=Util.null2String(sResult.get(k).get(2));//账簿名称
|
||||
String FNumber=Util.null2String(sResult.get(k).get(3));//账簿编码
|
||||
String FAcctTableId=Util.null2String(sResult.get(k).get(4));//科目表
|
||||
|
||||
//判断当前记录是否已同步,若已同步则更新,未同步则插入
|
||||
if(zb_map.containsKey(FBookId)){
|
||||
//更新SQL
|
||||
sql="update uf_zb_K3 set " +
|
||||
"FUseOrgId='"+FUseOrgId+"'," +//组织ID
|
||||
"FName='"+FName+"'," +//账簿名称
|
||||
"FAcctTableId='"+FAcctTableId+"'," +//科目表
|
||||
"FNumber='"+FNumber+"' " +//账簿编码
|
||||
" where FBookId='"+FBookId+"'";
|
||||
log.writeLog("账簿数据更新SQL------->" + sql);
|
||||
}else{
|
||||
//插入SQL
|
||||
sql="insert into uf_zb_K3(formmodeid,modedatacreater,modedatacreatertype,modedatacreatedate,modedatacreatetime," +
|
||||
"FUseOrgId,FBookId,FName,FAcctTableId,FNumber) values(" +
|
||||
"'"+modeid_zb+"','1','0','"+currDate+"','"+currTime+"'," +
|
||||
"'"+FUseOrgId+"','"+FBookId+"','"+FName+"','"+FAcctTableId+"'," +
|
||||
"'"+FNumber+"')";
|
||||
log.writeLog("账簿数据插入SQL------->" + sql);
|
||||
//将新增的数据加入至MAP中
|
||||
zb_map.put(FBookId, FNumber);
|
||||
}
|
||||
rs.execute(sql);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
log.writeLog("获取K3账簿数据错误,错误信息为------->" + e.toString());
|
||||
}
|
||||
//获取同步耗时
|
||||
long hs = (System.currentTimeMillis() - startStamp)/1000;
|
||||
log.writeLog("*******同步K3账簿数据完成end:(" + weaver.general.TimeUtil.getCurrentTimeString() + "),耗时:"+hs+"秒");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,113 @@
|
|||
package com.jet.schedule.syn;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.jet.k3.K3Connect;
|
||||
|
||||
import kingdee.bos.webapi.client.K3CloudApiClient;
|
||||
|
||||
import selfdev.util.base.BaseUtil;
|
||||
import selfdev.util.base.TimeCommonUtil;
|
||||
|
||||
import selfdev.util.log.LogTool;
|
||||
import weaver.conn.RecordSet;
|
||||
import weaver.file.Prop;
|
||||
import weaver.general.Util;
|
||||
import weaver.interfaces.schedule.BaseCronJob;
|
||||
import weaver.interfaces.schedule.CronJob;
|
||||
|
||||
|
||||
/**
|
||||
* 定时将K3中科目数据同步至OA建模表
|
||||
* @author KangMD
|
||||
* 2019-08-28
|
||||
*/
|
||||
public class SynAccountToOA extends BaseCronJob implements CronJob {
|
||||
|
||||
public static RecordSet rs=new RecordSet();
|
||||
public static LogTool log=new LogTool("/log/selfdev", false);
|
||||
|
||||
public void execute(){
|
||||
long startStamp=System.currentTimeMillis();
|
||||
log.writeLog("*******同步K3科目开始start:(" + weaver.general.TimeUtil.getCurrentTimeString() + ")");
|
||||
try {
|
||||
//连接K3
|
||||
K3CloudApiClient client =K3Connect.connect();
|
||||
if(client!=null){
|
||||
String sql="";
|
||||
String now=TimeCommonUtil.obtainDate(0);//获取当前系统日期yyyy-MM-dd HH:mm:ss格式
|
||||
String currDate = now.substring(0,10);//当前系统日期
|
||||
String currTime = now.substring(11);//当前系统时间
|
||||
//获取科目key-value MAP值,主键为科目内码ID
|
||||
Map<String,String> km_map=BaseUtil.getMapKeyValueInfoByParm("uf_km_k3","","FAcctId","FNumber");
|
||||
//当前系统模式
|
||||
String mode=Util.null2String(Prop.getPropValue("DevToK3_winsun", "mode"));
|
||||
//科目建模ID
|
||||
String modeid_km=Util.null2String(Prop.getPropValue("DevToK3_winsun", mode+"_modeid_km"));
|
||||
|
||||
//分页查询
|
||||
for(int t=0;t<1000;t++){
|
||||
String sContent = "{\"FormId\":\"BD_Account\","
|
||||
// 科目formid
|
||||
+"\"TopRowCount\":0,"
|
||||
// 最多允许查询的数量,0或者不要此属性表示不限制
|
||||
+"\"Limit\":2000,"
|
||||
// 分页取数每页允许获取的数据,最大不能超过2000
|
||||
+"\"StartRow\":"+(2000*t)+","
|
||||
//分页取数开始行索引,从0开始,例如每页10行数据,第2页开始是10,第3页开始是20
|
||||
//""FilterString":"FMaterialId.FNumber like 'HG_TEST%'","+// 过滤条件
|
||||
//""FilterString":"FBillNo='CGDD000008'","+// 过滤条件
|
||||
+"\"FilterString\":\"FNumber!=''\"," //过滤条件 编码不为空值
|
||||
//+"\"OrderString\":\"FGoodsNO ASC\","// 排序条件
|
||||
//获取科目基础信息 组织ID、内码、名称、编码
|
||||
+"\"FieldKeys\":\"FCreateOrgId,FAcctId,FName,FNumber\"}";
|
||||
//获取科目列表
|
||||
List<List<Object>> sResult = client.executeBillQuery(sContent);
|
||||
|
||||
int rows=sResult.size();
|
||||
//已经没有数据了,跳出循环
|
||||
if(rows==0){
|
||||
break;
|
||||
}else{
|
||||
for(int k=0;k<rows;k++){
|
||||
String FCreateOrgId=Util.null2String(sResult.get(k).get(0));//组织ID
|
||||
String FAcctId=Util.null2String(sResult.get(k).get(1));//科目内码
|
||||
String FName=Util.null2String(sResult.get(k).get(2));//科目名称
|
||||
String FNumber=Util.null2String(sResult.get(k).get(3));//科目编码
|
||||
|
||||
//判断当前记录是否已同步,若已同步则更新,未同步则插入
|
||||
if(km_map.containsKey(FAcctId)){
|
||||
//更新SQL
|
||||
sql="update uf_km_k3 set " +
|
||||
"FCreateOrgId='"+FCreateOrgId+"'," +//组织ID
|
||||
"FName='"+FName+"'," +//科目名称
|
||||
"FNumber='"+FNumber+"' " +//科目编码
|
||||
" where FAcctId='"+FAcctId+"'";
|
||||
log.writeLog("科目数据更新SQL------->" + sql);
|
||||
}else{
|
||||
//插入SQL
|
||||
sql="insert into uf_km_k3(formmodeid,modedatacreater,modedatacreatertype,modedatacreatedate,modedatacreatetime," +
|
||||
"FCreateOrgId,FAcctId,FName,FNumber) values(" +
|
||||
"'"+modeid_km+"','1','0','"+currDate+"','"+currTime+"'," +
|
||||
"'"+FCreateOrgId+"','"+FAcctId+"','"+FName+"','"+FNumber+"')";
|
||||
log.writeLog("科目数据插入SQL------->" + sql);
|
||||
//将新增的数据加入至MAP中
|
||||
km_map.put(FAcctId, FNumber);
|
||||
}
|
||||
rs.execute(sql);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
log.writeLog("获取K3科目数据错误,错误信息为------->" + e.toString());
|
||||
}
|
||||
//获取同步耗时
|
||||
long hs = (System.currentTimeMillis() - startStamp)/1000;
|
||||
log.writeLog("*******同步K3科目数据完成end:(" + weaver.general.TimeUtil.getCurrentTimeString() + "),耗时:"+hs+"秒");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,110 @@
|
|||
package com.jet.schedule.syn;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import kingdee.bos.webapi.client.K3CloudApiClient;
|
||||
import selfdev.util.base.BaseUtil;
|
||||
import selfdev.util.base.TimeCommonUtil;
|
||||
import selfdev.util.log.LogTool;
|
||||
import weaver.conn.RecordSet;
|
||||
import weaver.file.Prop;
|
||||
import weaver.general.Util;
|
||||
import weaver.interfaces.schedule.BaseCronJob;
|
||||
import weaver.interfaces.schedule.CronJob;
|
||||
|
||||
import com.jet.k3.K3Connect;
|
||||
|
||||
|
||||
/**
|
||||
* 定时将K3中银行数据同步至OA建模表
|
||||
* @author KangMD
|
||||
* 2019-08-28
|
||||
*/
|
||||
public class SynBankToOA extends BaseCronJob implements CronJob {
|
||||
|
||||
public static RecordSet rs=new RecordSet();
|
||||
public static LogTool log=new LogTool("/log/selfdev", false);
|
||||
|
||||
public void execute(){
|
||||
long startStamp=System.currentTimeMillis();
|
||||
log.writeLog("*******同步K3银行开始start:(" + weaver.general.TimeUtil.getCurrentTimeString() + ")");
|
||||
try {
|
||||
//连接K3
|
||||
K3CloudApiClient client =K3Connect.connect();
|
||||
if(client!=null){
|
||||
String sql="";
|
||||
String now=TimeCommonUtil.obtainDate(0);//获取当前系统日期yyyy-MM-dd HH:mm:ss格式
|
||||
String currDate = now.substring(0,10);//当前系统日期
|
||||
String currTime = now.substring(11);//当前系统时间
|
||||
//获取银行key-value MAP值,主键为银行内码ID
|
||||
Map<String,String> yh_map=BaseUtil.getMapKeyValueInfoByParm("uf_yh_k3","","FBankId","FNumber");
|
||||
//当前系统模式
|
||||
String mode=Util.null2String(Prop.getPropValue("DevToK3_winsun", "mode"));
|
||||
//银行建模ID
|
||||
String modeid_yh=Util.null2String(Prop.getPropValue("DevToK3_winsun", mode+"_modeid_yh"));
|
||||
|
||||
//分页查询
|
||||
for(int t=0;t<1000;t++){
|
||||
String sContent = "{\"FormId\":\"BD_BANK\","
|
||||
// 银行formid
|
||||
+"\"TopRowCount\":0,"
|
||||
// 最多允许查询的数量,0或者不要此属性表示不限制
|
||||
+"\"Limit\":2000,"
|
||||
// 分页取数每页允许获取的数据,最大不能超过2000
|
||||
+"\"StartRow\":"+(2000*t)+","
|
||||
//分页取数开始行索引,从0开始,例如每页10行数据,第2页开始是10,第3页开始是20
|
||||
//""FilterString":"FMaterialId.FNumber like 'HG_TEST%'","+// 过滤条件
|
||||
//""FilterString":"FBillNo='CGDD000008'","+// 过滤条件
|
||||
+"\"FilterString\":\"FNumber!=''\"," //过滤条件 编码不为空值
|
||||
//+"\"OrderString\":\"FGoodsNO ASC\","// 排序条件
|
||||
//获取银行基础信息 组织ID、内码、名称、编码
|
||||
+"\"FieldKeys\":\"FCreateOrgId,FBankId,FName,FNumber\"}";
|
||||
//获取银行列表
|
||||
List<List<Object>> sResult = client.executeBillQuery(sContent);
|
||||
int rows=sResult.size();
|
||||
//已经没有数据了,跳出循环
|
||||
if(rows==0){
|
||||
break;
|
||||
}else{
|
||||
for(int k=0;k<rows;k++){
|
||||
String FCreateOrgId=Util.null2String(sResult.get(k).get(0));//组织ID
|
||||
String FBankId=Util.null2String(sResult.get(k).get(1));//银行内码
|
||||
String FName=Util.null2String(sResult.get(k).get(2));//银行名称
|
||||
String FNumber=Util.null2String(sResult.get(k).get(3));//银行编码
|
||||
|
||||
//判断当前记录是否已同步,若已同步则更新,未同步则插入
|
||||
if(yh_map.containsKey(FBankId)){
|
||||
//更新SQL
|
||||
sql="update uf_yh_k3 set " +
|
||||
"FCreateOrgId='"+FCreateOrgId+"'," +//组织ID
|
||||
"FName='"+FName+"'," +//银行名称
|
||||
"FNumber='"+FNumber+"' " +//银行编码
|
||||
" where FBankId='"+FBankId+"'";
|
||||
log.writeLog("银行数据更新SQL------->" + sql);
|
||||
}else{
|
||||
//插入SQL
|
||||
sql="insert into uf_yh_k3(formmodeid,modedatacreater,modedatacreatertype,modedatacreatedate,modedatacreatetime," +
|
||||
"FCreateOrgId,FBankId,FName,FNumber) values(" +
|
||||
"'"+modeid_yh+"','1','0','"+currDate+"','"+currTime+"'," +
|
||||
"'"+FCreateOrgId+"','"+FBankId+"','"+FName+"','"+FNumber+"')";
|
||||
log.writeLog("银行数据插入SQL------->" + sql);
|
||||
//将新增的数据加入至MAP中
|
||||
yh_map.put(FBankId, FNumber);
|
||||
}
|
||||
rs.execute(sql);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
log.writeLog("获取K3银行数据错误,错误信息为------->" + e.toString());
|
||||
}
|
||||
//获取同步耗时
|
||||
long hs = (System.currentTimeMillis() - startStamp)/1000;
|
||||
log.writeLog("*******同步K3银行数据完成end:(" + weaver.general.TimeUtil.getCurrentTimeString() + "),耗时:"+hs+"秒");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,133 @@
|
|||
package com.jet.schedule.syn;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.jet.k3.K3Connect;
|
||||
|
||||
import kingdee.bos.webapi.client.K3CloudApiClient;
|
||||
|
||||
import selfdev.util.base.BaseUtil;
|
||||
import selfdev.util.base.TimeCommonUtil;
|
||||
|
||||
import selfdev.util.log.LogTool;
|
||||
import weaver.conn.RecordSet;
|
||||
import weaver.file.Prop;
|
||||
import weaver.general.Util;
|
||||
import weaver.interfaces.schedule.BaseCronJob;
|
||||
import weaver.interfaces.schedule.CronJob;
|
||||
|
||||
|
||||
/**
|
||||
* 定时将K3中客户数据同步至OA建模表
|
||||
* @author KangMD
|
||||
* 2019-08-28
|
||||
*/
|
||||
public class SynCustomerToOA extends BaseCronJob implements CronJob {
|
||||
|
||||
public static RecordSet rs=new RecordSet();
|
||||
public static LogTool log=new LogTool("/log/selfdev", false);
|
||||
|
||||
public void execute(){
|
||||
long startStamp=System.currentTimeMillis();
|
||||
log.writeLog("*******同步K3客户开始start:(" + weaver.general.TimeUtil.getCurrentTimeString() + ")");
|
||||
try {
|
||||
//连接K3
|
||||
K3CloudApiClient client =K3Connect.connect();
|
||||
if(client!=null){
|
||||
String sql="";
|
||||
String now=TimeCommonUtil.obtainDate(0);//获取当前系统日期yyyy-MM-dd HH:mm:ss格式
|
||||
String currDate = now.substring(0,10);//当前系统日期
|
||||
String currTime = now.substring(11);//当前系统时间
|
||||
//获取客户key-value MAP值,主键为客户内码ID
|
||||
Map<String,String> kh_map=BaseUtil.getMapKeyValueInfoByParm("uf_kh_k3","","FCustId","FNumber");
|
||||
//保存已同步客户key-value MAP值,主键为客户内码ID
|
||||
Map<String,String> ts_map=new HashMap<String, String>();
|
||||
//当前系统模式
|
||||
String mode=Util.null2String(Prop.getPropValue("DevToK3_winsun", "mode"));
|
||||
//客户建模ID
|
||||
String modeid_kh=Util.null2String(Prop.getPropValue("DevToK3_winsun", mode+"_modeid_kh"));
|
||||
|
||||
//分页查询
|
||||
for(int t=0;t<1000;t++){
|
||||
String sContent = "{\"FormId\":\"BD_Customer\","
|
||||
// 客户formid
|
||||
+"\"TopRowCount\":0,"
|
||||
// 最多允许查询的数量,0或者不要此属性表示不限制
|
||||
+"\"Limit\":2000,"
|
||||
// 分页取数每页允许获取的数据,最大不能超过2000
|
||||
+"\"StartRow\":"+(2000*t)+","
|
||||
//分页取数开始行索引,从0开始,例如每页10行数据,第2页开始是10,第3页开始是20
|
||||
//""FilterString":"FMaterialId.FNumber like 'HG_TEST%'","+// 过滤条件
|
||||
//""FilterString":"FBillNo='CGDD000008'","+// 过滤条件
|
||||
+"\"FilterString\":\"FNumber!=''\"," //过滤条件 编码不为空值
|
||||
//+"\"OrderString\":\"FCustId ASC\","// 排序条件
|
||||
//获取客户基础信息 组织ID、内码、名称、编码、银行账号、开户银行、账户名称
|
||||
+"\"FieldKeys\":\"FUseOrgId,FCustId,FName,FNumber,FBankCode,FOpenBankName,FAccountName\"}";
|
||||
//获取客户列表
|
||||
List<List<Object>> sResult = client.executeBillQuery(sContent);
|
||||
int rows=sResult.size();
|
||||
//已经没有数据了,跳出循环
|
||||
if(rows==0){
|
||||
break;
|
||||
}else{
|
||||
for(int k=0;k<rows;k++){
|
||||
String FUseOrgId=Util.null2String(sResult.get(k).get(0));//组织ID
|
||||
String FCustId=Util.null2String(sResult.get(k).get(1));//客户内码
|
||||
String FName=Util.null2String(sResult.get(k).get(2));//客户名称
|
||||
String FNumber=Util.null2String(sResult.get(k).get(3));//客户编码
|
||||
String FBankCode=Util.null2String(sResult.get(k).get(4)).replaceAll("'", "");//银行账号(过滤银行账号带单引号的数据)
|
||||
String FOpenBankName=Util.null2String(sResult.get(k).get(5));//开户银行
|
||||
String FAccountName=Util.null2String(sResult.get(k).get(6));//账户名称
|
||||
|
||||
//如果账户名称为空,则默认取客户名称
|
||||
if("".equals(FAccountName)){
|
||||
FAccountName=FName;
|
||||
}
|
||||
|
||||
//判断当前记录是否有相同数据
|
||||
if(ts_map.containsKey(FCustId)){
|
||||
log.writeLog("客户数据重复------->" + FCustId);
|
||||
continue;
|
||||
}
|
||||
|
||||
//判断当前记录是否已同步,若已同步则更新,未同步则插入
|
||||
if(kh_map.containsKey(FCustId)){
|
||||
//更新SQL
|
||||
sql="update uf_kh_k3 set " +
|
||||
"FUseOrgId='"+FUseOrgId+"'," +//组织ID
|
||||
"FName='"+FName+"'," +//客户名称
|
||||
"FNumber='"+FNumber+"'," +//客户编码
|
||||
"FBankCode='"+FBankCode+"'," +//银行账号
|
||||
"FAccountName='"+FAccountName+"'," +//账户名称
|
||||
"FOpenBankName='"+FOpenBankName+"' " +//开户银行
|
||||
" where FCustId='"+FCustId+"'";
|
||||
log.writeLog("客户数据更新SQL------->" + sql);
|
||||
}else{
|
||||
//插入SQL
|
||||
sql="insert into uf_kh_k3(formmodeid,modedatacreater,modedatacreatertype,modedatacreatedate,modedatacreatetime," +
|
||||
"FUseOrgId,FCustId,FName,FNumber,FBankCode,FOpenBankName,FAccountName) values(" +
|
||||
"'"+modeid_kh+"','1','0','"+currDate+"','"+currTime+"'," +
|
||||
"'"+FUseOrgId+"','"+FCustId+"','"+FName+"','"+FNumber+"','"+FBankCode+"','"+FOpenBankName+"','"+FAccountName+"')";
|
||||
log.writeLog("客户数据插入SQL------->" + sql);
|
||||
//将新增的数据加入至MAP中
|
||||
kh_map.put(FCustId, FNumber);
|
||||
}
|
||||
rs.execute(sql);
|
||||
ts_map.put(FCustId, FNumber);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
log.writeLog("获取K3客户数据错误,错误信息为------->" + e.toString());
|
||||
}
|
||||
//获取同步耗时
|
||||
long hs = (System.currentTimeMillis() - startStamp)/1000;
|
||||
log.writeLog("*******同步K3客户数据完成end:(" + weaver.general.TimeUtil.getCurrentTimeString() + "),耗时:"+hs+"秒");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,113 @@
|
|||
package com.jet.schedule.syn;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.jet.k3.K3Connect;
|
||||
|
||||
import kingdee.bos.webapi.client.K3CloudApiClient;
|
||||
|
||||
import selfdev.util.base.BaseUtil;
|
||||
import selfdev.util.base.TimeCommonUtil;
|
||||
|
||||
import selfdev.util.log.LogTool;
|
||||
import weaver.conn.RecordSet;
|
||||
import weaver.file.Prop;
|
||||
import weaver.general.Util;
|
||||
import weaver.interfaces.schedule.BaseCronJob;
|
||||
import weaver.interfaces.schedule.CronJob;
|
||||
|
||||
|
||||
/**
|
||||
* 定时将K3中部门数据同步至OA建模表
|
||||
* @author KangMD
|
||||
* 2019-12-07
|
||||
*/
|
||||
public class SynDepartmentToOA extends BaseCronJob implements CronJob {
|
||||
|
||||
public static RecordSet rs=new RecordSet();
|
||||
public static LogTool log=new LogTool("/log/selfdev/syn", false);
|
||||
|
||||
public void execute(){
|
||||
long startStamp=System.currentTimeMillis();
|
||||
log.writeLog("*******同步K3部门开始start:(" + weaver.general.TimeUtil.getCurrentTimeString() + ")");
|
||||
try {
|
||||
//连接K3
|
||||
K3CloudApiClient client =K3Connect.connect();
|
||||
if(client!=null){
|
||||
String sql="";
|
||||
String now=TimeCommonUtil.obtainDate(0);//获取当前系统日期yyyy-MM-dd HH:mm:ss格式
|
||||
String currDate = now.substring(0,10);//当前系统日期
|
||||
String currTime = now.substring(11);//当前系统时间
|
||||
//获取部门key-value MAP值,主键为部门内码ID
|
||||
Map<String,String> bm_map=BaseUtil.getMapKeyValueInfoByParm("uf_bm_K3","","FDeptId","FNumber");
|
||||
//当前系统模式
|
||||
String mode=Util.null2String(Prop.getPropValue("DevToK3_jet", "mode"));
|
||||
//部门建模ID
|
||||
String modeid_bm=Util.null2String(Prop.getPropValue("DevToK3_jet", mode+"_modeid_bm"));
|
||||
|
||||
//分页查询
|
||||
for(int t=0;t<1000;t++){
|
||||
String sContent = "{\"FormId\":\"BD_Department\","
|
||||
// 部门formid
|
||||
+"\"TopRowCount\":0,"
|
||||
// 最多允许查询的数量,0或者不要此属性表示不限制
|
||||
+"\"Limit\":2000,"
|
||||
// 分页取数每页允许获取的数据,最大不能超过2000
|
||||
+"\"StartRow\":"+(2000*t)+","
|
||||
//分页取数开始行索引,从0开始,例如每页10行数据,第2页开始是10,第3页开始是20
|
||||
//""FilterString":"FMaterialId.FNumber like 'HG_TEST%'","+// 过滤条件
|
||||
//""FilterString":"FBillNo='CGDD000008'","+// 过滤条件
|
||||
+"\"FilterString\":\"FNumber!=''\"," //过滤条件 编码不为空值
|
||||
//+"\"OrderString\":\"FGoodsNO ASC\","// 排序条件
|
||||
//获取部门基础信息 组织ID、内码、名称、编码
|
||||
+"\"FieldKeys\":\"FUseOrgId,FDeptId,FName,FNumber\"}";
|
||||
//获取部门列表
|
||||
List<List<Object>> sResult = client.executeBillQuery(sContent);
|
||||
int rows=sResult.size();
|
||||
//已经没有数据了,跳出循环
|
||||
if(rows==0){
|
||||
break;
|
||||
}else{
|
||||
for(int k=0;k<rows;k++){
|
||||
String FUseOrgId=Util.null2String(sResult.get(k).get(0));//组织ID
|
||||
String FDeptId=Util.null2String(sResult.get(k).get(1));//部门内码
|
||||
String FName=Util.null2String(sResult.get(k).get(2));//部门名称
|
||||
String FNumber=Util.null2String(sResult.get(k).get(3));//部门编码
|
||||
|
||||
//判断当前记录是否已同步,若已同步则更新,未同步则插入
|
||||
if(bm_map.containsKey(FDeptId)){
|
||||
//更新SQL
|
||||
sql="update uf_bm_K3 set " +
|
||||
"FUseOrgId='"+FUseOrgId+"'," +//组织ID
|
||||
"FName='"+FName+"'," +//部门名称
|
||||
"FNumber='"+FNumber+"' " +//部门编码
|
||||
" where FDeptId='"+FDeptId+"'";
|
||||
log.writeLog("部门数据更新SQL------->" + sql);
|
||||
}else{
|
||||
//插入SQL
|
||||
sql="insert into uf_bm_K3(formmodeid,modedatacreater,modedatacreatertype,modedatacreatedate,modedatacreatetime," +
|
||||
"FUseOrgId,FDeptId,FName,FNumber) values(" +
|
||||
"'"+modeid_bm+"','1','0','"+currDate+"','"+currTime+"'," +
|
||||
"'"+FUseOrgId+"','"+FDeptId+"','"+FName+"'," +
|
||||
"'"+FNumber+"')";
|
||||
log.writeLog("部门数据插入SQL------->" + sql);
|
||||
//将新增的数据加入至MAP中
|
||||
bm_map.put(FDeptId, FNumber);
|
||||
}
|
||||
rs.execute(sql);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
log.writeLog("获取K3部门数据错误,错误信息为------->" + e.toString());
|
||||
}
|
||||
//获取同步耗时
|
||||
long hs = (System.currentTimeMillis() - startStamp)/1000;
|
||||
log.writeLog("*******同步K3部门数据完成end:(" + weaver.general.TimeUtil.getCurrentTimeString() + "),耗时:"+hs+"秒");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,118 @@
|
|||
package com.jet.schedule.syn;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import kingdee.bos.webapi.client.K3CloudApiClient;
|
||||
import selfdev.util.base.BaseUtil;
|
||||
import selfdev.util.base.TimeCommonUtil;
|
||||
import selfdev.util.log.LogTool;
|
||||
import weaver.conn.RecordSet;
|
||||
import weaver.file.Prop;
|
||||
import weaver.general.Util;
|
||||
import weaver.interfaces.schedule.BaseCronJob;
|
||||
import weaver.interfaces.schedule.CronJob;
|
||||
|
||||
import com.jet.k3.K3Connect;
|
||||
|
||||
|
||||
/**
|
||||
* 定时将K3中物料数据同步至OA建模表
|
||||
* @author KangMD
|
||||
* 2019-08-28
|
||||
*/
|
||||
public class SynMaterialToOA extends BaseCronJob implements CronJob {
|
||||
|
||||
public static RecordSet rs=new RecordSet();
|
||||
public static LogTool log=new LogTool("/log/selfdev", false);
|
||||
|
||||
public void execute(){
|
||||
long startStamp=System.currentTimeMillis();
|
||||
log.writeLog("*******同步K3物料开始start:(" + weaver.general.TimeUtil.getCurrentTimeString() + ")");
|
||||
try {
|
||||
//连接K3
|
||||
K3CloudApiClient client =K3Connect.connect();
|
||||
if(client!=null){
|
||||
String sql="";
|
||||
String now=TimeCommonUtil.obtainDate(0);//获取当前系统日期yyyy-MM-dd HH:mm:ss格式
|
||||
String currDate = now.substring(0,10);//当前系统日期
|
||||
String currTime = now.substring(11);//当前系统时间
|
||||
//获取物料key-value MAP值,主键为物料内码ID
|
||||
Map<String,String> wl_map=BaseUtil.getMapKeyValueInfoByParm("uf_wl_k3","","FNumber","FNumber");
|
||||
//当前系统模式
|
||||
String mode=Util.null2String(Prop.getPropValue("DevToK3_winsun", "mode"));
|
||||
//物料建模ID
|
||||
String modeid_wl=Util.null2String(Prop.getPropValue("DevToK3_winsun", mode+"_modeid_wl"));
|
||||
|
||||
//分页查询
|
||||
for(int t=0;t<1000;t++){
|
||||
String sContent = "{\"FormId\":\"BD_MATERIAL\","
|
||||
// 物料formid
|
||||
+"\"TopRowCount\":0,"
|
||||
// 最多允许查询的数量,0或者不要此属性表示不限制
|
||||
+"\"Limit\":2000,"
|
||||
// 分页取数每页允许获取的数据,最大不能超过2000
|
||||
+"\"StartRow\":"+(2000*t)+","
|
||||
//分页取数开始行索引,从0开始,例如每页10行数据,第2页开始是10,第3页开始是20
|
||||
//""FilterString":"FMaterialId.FNumber like 'HG_TEST%'","+// 过滤条件
|
||||
//""FilterString":"FBillNo='CGDD000008'","+// 过滤条件
|
||||
+"\"FilterString\":\"FNumber!=''\"," //过滤条件 编码不为空值
|
||||
//+"\"OrderString\":\"FGoodsNO ASC\","// 排序条件
|
||||
//获取物料基础信息 组织ID、内码、名称、编码、货号、基本单位、规格型号
|
||||
//+"\"FieldKeys\":\"FUseOrgId.FNumber,FMaterialId,FName,FNumber,FMnemonicCode,FBaseUnitId.FNumber,FSpecification\"}";
|
||||
+"\"FieldKeys\":\"FMaterialId,FName,FNumber,FMnemonicCode,FBaseUnitId.FNumber,FSpecification\"}";
|
||||
//获取物料列表
|
||||
List<List<Object>> sResult = client.executeBillQuery(sContent);
|
||||
int rows=sResult.size();
|
||||
//已经没有数据了,跳出循环
|
||||
if(rows==0){
|
||||
break;
|
||||
}else{
|
||||
for(int k=0;k<rows;k++){
|
||||
//String FUseOrgId=Util.null2String(sResult.get(k).get(0));//组织ID
|
||||
String FMaterialId=Util.null2String(sResult.get(k).get(0));//物料内码
|
||||
String FName=Util.null2String(sResult.get(k).get(1));//物料名称
|
||||
String FNumber=Util.null2String(sResult.get(k).get(2));//物料编码
|
||||
String FMnemonicCode=Util.null2String(sResult.get(k).get(3));//货号
|
||||
String FBaseUnitId=Util.null2String(sResult.get(k).get(4));//基本单位
|
||||
String FSpecification=Util.null2String(sResult.get(k).get(5));//规格型号
|
||||
|
||||
//判断当前记录是否已同步,若已同步则更新,未同步则插入
|
||||
if(wl_map.containsKey(FNumber)){
|
||||
//更新SQL
|
||||
sql="update uf_wl_K3 set " +
|
||||
//"FUseOrgId='"+FUseOrgId+"'," +//组织ID
|
||||
"FName='"+FName+"'," +//物料名称
|
||||
"FNumber='"+FNumber+"'," +//物料编码
|
||||
"FMnemonicCode='"+FMnemonicCode+"'," +//货号
|
||||
"FBaseUnitId='"+FBaseUnitId+"'," +//基本单位
|
||||
"FSpecification='"+FSpecification+"' " +//规格型号
|
||||
" where FMaterialId='"+FMaterialId+"'";
|
||||
log.writeLog("物料数据更新SQL------->" + sql);
|
||||
}else{
|
||||
//插入SQL
|
||||
sql="insert into uf_wl_K3(formmodeid,modedatacreater,modedatacreatertype,modedatacreatedate,modedatacreatetime," +
|
||||
"FUseOrgId,FMaterialId,FName,FNumber,FMnemonicCode,FBaseUnitId,FSpecification) values(" +
|
||||
"'"+modeid_wl+"','1','0','"+currDate+"','"+currTime+"'," +
|
||||
"'100','"+FMaterialId+"','"+FName+"','"+FNumber+"','"+FMnemonicCode+"','"+FBaseUnitId+"','"+FSpecification+"')";
|
||||
//"'"+FUseOrgId+"','"+FMaterialId+"','"+FName+"','"+FNumber+"','"+FMnemonicCode+"','"+FBaseUnitId+"','"+FSpecification+"')";
|
||||
log.writeLog("物料数据插入SQL------->" + sql);
|
||||
//将新增的数据加入至MAP中
|
||||
wl_map.put(FNumber, FNumber);
|
||||
}
|
||||
rs.execute(sql);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
log.writeLog("获取K3物料数据错误,错误信息为------->" + e.toString());
|
||||
}
|
||||
//获取同步耗时
|
||||
long hs = (System.currentTimeMillis() - startStamp)/1000;
|
||||
log.writeLog("*******同步K3物料数据完成end:(" + weaver.general.TimeUtil.getCurrentTimeString() + "),耗时:"+hs+"秒");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,110 @@
|
|||
package com.jet.schedule.syn;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.jet.k3.K3Connect;
|
||||
|
||||
import kingdee.bos.webapi.client.K3CloudApiClient;
|
||||
|
||||
import selfdev.util.base.BaseUtil;
|
||||
import selfdev.util.base.TimeCommonUtil;
|
||||
|
||||
import selfdev.util.log.LogTool;
|
||||
import weaver.conn.RecordSet;
|
||||
import weaver.file.Prop;
|
||||
import weaver.general.Util;
|
||||
import weaver.interfaces.schedule.BaseCronJob;
|
||||
import weaver.interfaces.schedule.CronJob;
|
||||
|
||||
|
||||
/**
|
||||
* 定时将K3中组织机构数据同步至OA建模表
|
||||
* @author KangMD
|
||||
* 2019-11-07
|
||||
*/
|
||||
public class SynOrganizationsToOA extends BaseCronJob implements CronJob {
|
||||
|
||||
public static RecordSet rs=new RecordSet();
|
||||
public static LogTool log=new LogTool("/log/selfdev/syn", false);
|
||||
|
||||
public void execute(){
|
||||
long startStamp=System.currentTimeMillis();
|
||||
log.writeLog("*******同步K3组织机构开始start:(" + weaver.general.TimeUtil.getCurrentTimeString() + ")");
|
||||
try {
|
||||
//连接K3
|
||||
K3CloudApiClient client =K3Connect.connect();
|
||||
if(client!=null){
|
||||
String sql="";
|
||||
String now=TimeCommonUtil.obtainDate(0);//获取当前系统日期yyyy-MM-dd HH:mm:ss格式
|
||||
String currDate = now.substring(0,10);//当前系统日期
|
||||
String currTime = now.substring(11);//当前系统时间
|
||||
//获取组织机构key-value MAP值,主键为组织机构内码ID
|
||||
Map<String,String> zz_map=BaseUtil.getMapKeyValueInfoByParm("uf_zz_k3","","Forgid","FNumber");
|
||||
//当前系统模式
|
||||
String mode=Util.null2String(Prop.getPropValue("DevToK3_jet", "mode"));
|
||||
//组织机构建模ID
|
||||
String modeid_zz=Util.null2String(Prop.getPropValue("DevToK3_jet", mode+"_modeid_zz"));
|
||||
|
||||
//分页查询
|
||||
for(int t=0;t<1000;t++){
|
||||
String sContent = "{\"FormId\":\"ORG_Organizations\","
|
||||
// 组织机构formid
|
||||
+"\"TopRowCount\":0,"
|
||||
// 最多允许查询的数量,0或者不要此属性表示不限制
|
||||
+"\"Limit\":2000,"
|
||||
// 分页取数每页允许获取的数据,最大不能超过2000
|
||||
+"\"StartRow\":"+(2000*t)+","
|
||||
//分页取数开始行索引,从0开始,例如每页10行数据,第2页开始是10,第3页开始是20
|
||||
//""FilterString":"FMaterialId.FNumber like 'HG_TEST%'","+// 过滤条件
|
||||
//""FilterString":"FBillNo='CGDD000008'","+// 过滤条件
|
||||
+"\"FilterString\":\"FNumber!=''\"," //过滤条件 编码不为空值
|
||||
//+"\"OrderString\":\"FGoodsNO ASC\","// 排序条件
|
||||
//获取组织机构基础信息 组织ID、名称、编码
|
||||
+"\"FieldKeys\":\"Forgid,FName,FNumber\"}";
|
||||
//获取组织机构列表
|
||||
List<List<Object>> sResult = client.executeBillQuery(sContent);
|
||||
int rows=sResult.size();
|
||||
//已经没有数据了,跳出循环
|
||||
if(rows==0){
|
||||
break;
|
||||
}else{
|
||||
for(int k=0;k<rows;k++){
|
||||
String Forgid=Util.null2String(sResult.get(k).get(0));//组织ID
|
||||
String FName=Util.null2String(sResult.get(k).get(1));//组织机构名称
|
||||
String FNumber=Util.null2String(sResult.get(k).get(2));//组织机构编码
|
||||
|
||||
//判断当前记录是否已同步,若已同步则更新,未同步则插入
|
||||
if(zz_map.containsKey(Forgid)){
|
||||
//更新SQL
|
||||
sql="update uf_zz_k3 set " +
|
||||
"FName='"+FName+"'," +//组织机构名称
|
||||
"FNumber='"+FNumber+"' " +//组织机构编码
|
||||
" where Forgid='"+Forgid+"'";
|
||||
log.writeLog("组织机构数据更新SQL------->" + sql);
|
||||
}else{
|
||||
//插入SQL
|
||||
sql="insert into uf_zz_k3(formmodeid,modedatacreater,modedatacreatertype,modedatacreatedate,modedatacreatetime," +
|
||||
"Forgid,FName,FNumber) values(" +
|
||||
"'"+modeid_zz+"','1','0','"+currDate+"','"+currTime+"'," +
|
||||
"'"+Forgid+"','"+FName+"','"+FNumber+"')";
|
||||
log.writeLog("组织机构数据插入SQL------->" + sql);
|
||||
//将新增的数据加入至MAP中
|
||||
zz_map.put(Forgid, FNumber);
|
||||
}
|
||||
rs.execute(sql);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
log.writeLog("获取K3组织机构数据错误,错误信息为------->" + e.toString());
|
||||
}
|
||||
//获取同步耗时
|
||||
long hs = (System.currentTimeMillis() - startStamp)/1000;
|
||||
log.writeLog("*******同步K3组织机构数据完成end:(" + weaver.general.TimeUtil.getCurrentTimeString() + "),耗时:"+hs+"秒");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,114 @@
|
|||
package com.jet.schedule.syn;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import kingdee.bos.webapi.client.K3CloudApiClient;
|
||||
import selfdev.util.base.BaseUtil;
|
||||
import selfdev.util.base.TimeCommonUtil;
|
||||
import selfdev.util.log.LogTool;
|
||||
import weaver.conn.RecordSet;
|
||||
import weaver.file.Prop;
|
||||
import weaver.general.Util;
|
||||
import weaver.interfaces.schedule.BaseCronJob;
|
||||
import weaver.interfaces.schedule.CronJob;
|
||||
|
||||
import com.jet.k3.K3Connect;
|
||||
|
||||
|
||||
/**
|
||||
* 定时将K3中付款银行同步至OA建模表
|
||||
* @author KangMD
|
||||
* 2019-12-04
|
||||
*/
|
||||
public class SynPayBankAcntToOA extends BaseCronJob implements CronJob {
|
||||
|
||||
public static RecordSet rs=new RecordSet();
|
||||
public static LogTool log=new LogTool("/log/selfdev/syn", false);
|
||||
|
||||
public void execute(){
|
||||
long startStamp=System.currentTimeMillis();
|
||||
log.writeLog("*******同步K3付款银行开始start:(" + weaver.general.TimeUtil.getCurrentTimeString() + ")");
|
||||
try {
|
||||
//连接K3
|
||||
K3CloudApiClient client =K3Connect.connect();
|
||||
if(client!=null){
|
||||
String sql="";
|
||||
String now=TimeCommonUtil.obtainDate(0);//获取当前系统日期yyyy-MM-dd HH:mm:ss格式
|
||||
String currDate = now.substring(0,10);//当前系统日期
|
||||
String currTime = now.substring(11);//当前系统时间
|
||||
//获取付款银行key-value MAP值,主键为付款银行内码ID
|
||||
Map<String,String> fkyh_map=BaseUtil.getMapKeyValueInfoByParm("uf_fkyh_k3","","FBankAcntId","FNumber");
|
||||
//当前系统模式
|
||||
String mode=Util.null2String(Prop.getPropValue("DevToK3_jet", "mode"));
|
||||
//付款银行建模ID
|
||||
String modeid_gys=Util.null2String(Prop.getPropValue("DevToK3_jet", mode+"_modeid_fkyh"));
|
||||
|
||||
//分页查询
|
||||
for(int t=0;t<1000;t++){
|
||||
String sContent = "{\"FormId\":\"CN_BANKACNT\","
|
||||
// 付款银行formid
|
||||
+"\"TopRowCount\":0,"
|
||||
// 最多允许查询的数量,0或者不要此属性表示不限制
|
||||
+"\"Limit\":2000,"
|
||||
// 分页取数每页允许获取的数据,最大不能超过2000
|
||||
+"\"StartRow\":"+(2000*t)+","
|
||||
//分页取数开始行索引,从0开始,例如每页10行数据,第2页开始是10,第3页开始是20
|
||||
//""FilterString":"FMaterialId.FNumber like 'HG_TEST%'","+// 过滤条件
|
||||
//""FilterString":"FBillNo='CGDD000008'","+// 过滤条件
|
||||
+"\"FilterString\":\"FNumber!='' \"," //过滤条件 编码不为空值
|
||||
//+"\"OrderString\":\"FGoodsNO ASC\","// 排序条件
|
||||
//获取付款银行基础信息 组织ID、内码、名称、编码、开户银行
|
||||
+"\"FieldKeys\":\"FUseOrgId,FBankAcntId,FName,FNumber,FBankId\"}";
|
||||
//获取付款银行列表
|
||||
List<List<Object>> sResult = client.executeBillQuery(sContent);
|
||||
int rows=sResult.size();
|
||||
//已经没有数据了,跳出循环
|
||||
if(rows==0){
|
||||
break;
|
||||
}else{
|
||||
for(int k=0;k<rows;k++){
|
||||
String FUseOrgId=Util.null2String(sResult.get(k).get(0));//组织ID
|
||||
String FBankAcntId=Util.null2String(sResult.get(k).get(1));//付款银行内码
|
||||
String FName=Util.null2String(sResult.get(k).get(2));//账号名称
|
||||
String FNumber=Util.null2String(sResult.get(k).get(3));//付款银行账号
|
||||
String FBankId=Util.null2String(sResult.get(k).get(4));//开户行
|
||||
|
||||
//判断当前记录是否已同步,若已同步则更新,未同步则插入
|
||||
if(fkyh_map.containsKey(FBankAcntId)){
|
||||
//更新SQL
|
||||
sql="update uf_fkyh_k3 set " +
|
||||
"FUseOrgId='"+FUseOrgId+"'," +//组织ID
|
||||
"FName='"+FName+"'," +//账号名称
|
||||
"FNumber='"+FNumber+"'," +//付款银行账号
|
||||
"FBankId='"+FBankId+"' " +//开户银行
|
||||
" where FBankAcntId='"+FBankAcntId+"'";
|
||||
log.writeLog("付款银行数据更新SQL------->" + sql);
|
||||
}else{
|
||||
//插入SQL
|
||||
sql="insert into uf_fkyh_k3(formmodeid,modedatacreater,modedatacreatertype,modedatacreatedate,modedatacreatetime," +
|
||||
"FUseOrgId,FBankAcntId,FName,FNumber,FBankId) values(" +
|
||||
"'"+modeid_gys+"','1','0','"+currDate+"','"+currTime+"'," +
|
||||
"'"+FUseOrgId+"','"+FBankAcntId+"','"+FName+"','"+FNumber+"'," +
|
||||
"'"+FBankId+"')";
|
||||
log.writeLog("付款银行数据插入SQL------->" + sql);
|
||||
|
||||
//将新增的数据加入至MAP中
|
||||
fkyh_map.put(FBankAcntId, FNumber);
|
||||
}
|
||||
rs.execute(sql);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
log.writeLog("获取K3付款银行数据错误,错误信息为------->" + e.toString());
|
||||
}
|
||||
//获取同步耗时
|
||||
long hs = (System.currentTimeMillis() - startStamp)/1000;
|
||||
log.writeLog("*******同步K3付款银行数据完成end:(" + weaver.general.TimeUtil.getCurrentTimeString() + "),耗时:"+hs+"秒");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,109 @@
|
|||
package com.jet.schedule.syn;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import kingdee.bos.webapi.client.K3CloudApiClient;
|
||||
import selfdev.util.base.BaseUtil;
|
||||
import selfdev.util.base.TimeCommonUtil;
|
||||
import selfdev.util.log.LogTool;
|
||||
import weaver.conn.RecordSet;
|
||||
import weaver.file.Prop;
|
||||
import weaver.general.Util;
|
||||
import weaver.interfaces.schedule.BaseCronJob;
|
||||
import weaver.interfaces.schedule.CronJob;
|
||||
|
||||
import com.jet.k3.K3Connect;
|
||||
|
||||
|
||||
/**
|
||||
* 定时将K3中结算方式数据同步至OA建模表
|
||||
* @author KangMD
|
||||
* 2019-09-04
|
||||
*/
|
||||
public class SynSettleTypeToOA extends BaseCronJob implements CronJob {
|
||||
|
||||
public static RecordSet rs=new RecordSet();
|
||||
public static LogTool log=new LogTool("/log/selfdev", false);
|
||||
|
||||
public void execute(){
|
||||
long startStamp=System.currentTimeMillis();
|
||||
log.writeLog("*******同步K3结算方式开始start:(" + weaver.general.TimeUtil.getCurrentTimeString() + ")");
|
||||
try {
|
||||
//连接K3
|
||||
K3CloudApiClient client =K3Connect.connect();
|
||||
if(client!=null){
|
||||
String sql="";
|
||||
String now=TimeCommonUtil.obtainDate(0);//获取当前系统日期yyyy-MM-dd HH:mm:ss格式
|
||||
String currDate = now.substring(0,10);//当前系统日期
|
||||
String currTime = now.substring(11);//当前系统时间
|
||||
//获取结算方式key-value MAP值,主键为结算方式内码ID
|
||||
Map<String,String> jsfs_map=BaseUtil.getMapKeyValueInfoByParm("uf_jsfs_K3","","FID","FNumber");
|
||||
//当前系统模式
|
||||
String mode=Util.null2String(Prop.getPropValue("DevToK3_winsun", "mode"));
|
||||
//结算方式建模ID
|
||||
String modeid_jsfs=Util.null2String(Prop.getPropValue("DevToK3_winsun", mode+"_modeid_jsfs"));
|
||||
|
||||
//分页查询
|
||||
for(int t=0;t<1000;t++){
|
||||
String sContent = "{\"FormId\":\"BD_SETTLETYPE\","
|
||||
// 结算方式formid
|
||||
+"\"TopRowCount\":0,"
|
||||
// 最多允许查询的数量,0或者不要此属性表示不限制
|
||||
+"\"Limit\":2000,"
|
||||
// 分页取数每页允许获取的数据,最大不能超过2000
|
||||
+"\"StartRow\":"+(2000*t)+","
|
||||
//分页取数开始行索引,从0开始,例如每页10行数据,第2页开始是10,第3页开始是20
|
||||
//""FilterString":"FMaterialId.FNumber like 'HG_TEST%'","+// 过滤条件
|
||||
//""FilterString":"FBillNo='CGDD000008'","+// 过滤条件
|
||||
+"\"FilterString\":\"FNumber!=''\"," //过滤条件 编码不为空值
|
||||
//+"\"OrderString\":\"FGoodsNO ASC\","// 排序条件
|
||||
//获取结算方式基础信息 内码、名称、编码
|
||||
+"\"FieldKeys\":\"FID,FName,FNumber\"}";
|
||||
//获取结算方式列表
|
||||
List<List<Object>> sResult = client.executeBillQuery(sContent);
|
||||
int rows=sResult.size();
|
||||
//已经没有数据了,跳出循环
|
||||
if(rows==0){
|
||||
break;
|
||||
}else{
|
||||
for(int k=0;k<rows;k++){
|
||||
String FID=Util.null2String(sResult.get(k).get(0));//结算方式内码
|
||||
String FName=Util.null2String(sResult.get(k).get(1));//结算方式名称
|
||||
String FNumber=Util.null2String(sResult.get(k).get(2));//结算方式编码
|
||||
|
||||
//判断当前记录是否已同步,若已同步则更新,未同步则插入
|
||||
if(jsfs_map.containsKey(FID)){
|
||||
//更新SQL
|
||||
sql="update uf_jsfs_K3 set " +
|
||||
"FName='"+FName+"'," +//结算方式名称
|
||||
"FNumber='"+FNumber+"' " +//结算方式编码
|
||||
" where FID='"+FID+"'";
|
||||
log.writeLog("结算方式数据更新SQL------->" + sql);
|
||||
}else{
|
||||
//插入SQL
|
||||
sql="insert into uf_jsfs_K3(formmodeid,modedatacreater,modedatacreatertype,modedatacreatedate,modedatacreatetime," +
|
||||
"FID,FName,FNumber) values(" +
|
||||
"'"+modeid_jsfs+"','1','0','"+currDate+"','"+currTime+"'," +
|
||||
"'"+FID+"','"+FName+"'," +
|
||||
"'"+FNumber+"')";
|
||||
log.writeLog("结算方式数据插入SQL------->" + sql);
|
||||
//将新增的数据加入至MAP中
|
||||
jsfs_map.put(FID, FNumber);
|
||||
}
|
||||
rs.execute(sql);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
log.writeLog("获取K3结算方式数据错误,错误信息为------->" + e.toString());
|
||||
}
|
||||
//获取同步耗时
|
||||
long hs = (System.currentTimeMillis() - startStamp)/1000;
|
||||
log.writeLog("*******同步K3结算方式数据完成end:(" + weaver.general.TimeUtil.getCurrentTimeString() + "),耗时:"+hs+"秒");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,128 @@
|
|||
package com.jet.schedule.syn;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import kingdee.bos.webapi.client.K3CloudApiClient;
|
||||
import selfdev.util.base.BaseUtil;
|
||||
import selfdev.util.base.TimeCommonUtil;
|
||||
import selfdev.util.log.LogTool;
|
||||
import weaver.conn.RecordSet;
|
||||
import weaver.file.Prop;
|
||||
import weaver.general.Util;
|
||||
import weaver.interfaces.schedule.BaseCronJob;
|
||||
import weaver.interfaces.schedule.CronJob;
|
||||
|
||||
import com.jet.k3.K3Connect;
|
||||
|
||||
|
||||
/**
|
||||
* 定时将K3中供应商数据同步至OA建模表
|
||||
* @author KangMD
|
||||
* 2019-11-08
|
||||
*/
|
||||
public class SynSupplierToOA extends BaseCronJob implements CronJob {
|
||||
|
||||
public static RecordSet rs=new RecordSet();
|
||||
public static LogTool log=new LogTool("/log/selfdev/syn", false);
|
||||
|
||||
public void execute(){
|
||||
long startStamp=System.currentTimeMillis();
|
||||
log.writeLog("*******同步K3供应商开始start:(" + weaver.general.TimeUtil.getCurrentTimeString() + ")");
|
||||
try {
|
||||
//连接K3
|
||||
K3CloudApiClient client =K3Connect.connect();
|
||||
if(client!=null){
|
||||
String sql="";
|
||||
String now=TimeCommonUtil.obtainDate(0);//获取当前系统日期yyyy-MM-dd HH:mm:ss格式
|
||||
String currDate = now.substring(0,10);//当前系统日期
|
||||
String currTime = now.substring(11);//当前系统时间
|
||||
//获取供应商key-value MAP值,主键为供应商内码ID
|
||||
Map<String,String> gys_map=BaseUtil.getMapKeyValueInfoByParm("uf_gys_k3","","FSupplierId","FNumber");
|
||||
//当前系统模式
|
||||
String mode=Util.null2String(Prop.getPropValue("DevToK3_jet", "mode"));
|
||||
//供应商建模ID
|
||||
String modeid_gys=Util.null2String(Prop.getPropValue("DevToK3_jet", mode+"_modeid_gys"));
|
||||
|
||||
//分页查询
|
||||
for(int t=0;t<1000;t++){
|
||||
String sContent = "{\"FormId\":\"BD_Supplier\","
|
||||
// 供应商formid
|
||||
+"\"TopRowCount\":0,"
|
||||
// 最多允许查询的数量,0或者不要此属性表示不限制
|
||||
+"\"Limit\":2000,"
|
||||
// 分页取数每页允许获取的数据,最大不能超过2000
|
||||
+"\"StartRow\":"+(2000*t)+","
|
||||
//分页取数开始行索引,从0开始,例如每页10行数据,第2页开始是10,第3页开始是20
|
||||
//""FilterString":"FMaterialId.FNumber like 'HG_TEST%'","+// 过滤条件
|
||||
//""FilterString":"FBillNo='CGDD000008'","+// 过滤条件
|
||||
+"\"FilterString\":\"FNumber!='' and FDocumentStatus='C'\"," //过滤条件 编码不为空值,FDocumentStatus='C'标识数据状态为已审核
|
||||
//+"\"OrderString\":\"FGoodsNO ASC\","// 排序条件
|
||||
//获取供应商基础信息 组织ID、内码、名称、编码、银行账号、账户名称、开户银行
|
||||
+"\"FieldKeys\":\"FUseOrgId,FSupplierId,FName,FNumber,FBankCode,FBankHolder,FOpenBankName,F_RTA_VATType.FNumber,FTaxRateId.FNumber\"}";
|
||||
//获取供应商列表
|
||||
List<List<Object>> sResult = client.executeBillQuery(sContent);
|
||||
int rows=sResult.size();
|
||||
//已经没有数据了,跳出循环
|
||||
if(rows==0){
|
||||
break;
|
||||
}else{
|
||||
for(int k=0;k<rows;k++){
|
||||
String FUseOrgId=Util.null2String(sResult.get(k).get(0));//组织ID
|
||||
String FSupplierId=Util.null2String(sResult.get(k).get(1));//供应商内码
|
||||
String FName=Util.null2String(sResult.get(k).get(2));//供应商名称
|
||||
String FNumber=Util.null2String(sResult.get(k).get(3));//供应商编码
|
||||
String FBankCode=Util.null2String(sResult.get(k).get(4));//银行账号
|
||||
String FBankHolder=Util.null2String(sResult.get(k).get(5));//账户名称
|
||||
String FOpenBankName=Util.null2String(sResult.get(k).get(6));//开户银行
|
||||
String F_RTA_VATType=Util.null2String(sResult.get(k).get(7));//PPN Type
|
||||
String FTaxRate=Util.null2String(sResult.get(k).get(8));//默认税率
|
||||
|
||||
//如果账户名称为空,则默认取供应商名称
|
||||
if("".equals(FBankHolder)){
|
||||
FBankHolder=FName;
|
||||
}
|
||||
|
||||
//判断当前记录是否已同步,若已同步则更新,未同步则插入
|
||||
if(gys_map.containsKey(FSupplierId)){
|
||||
//更新SQL
|
||||
sql="update uf_gys_K3 set " +
|
||||
"FUseOrgId='"+FUseOrgId+"'," +//组织ID
|
||||
"FName='"+FName+"'," +//供应商名称
|
||||
"FNumber='"+FNumber+"'," +//供应商编码
|
||||
"FBankCode='"+FBankCode+"'," +//银行账号
|
||||
"FBankHolder='"+FBankHolder+"'," +//账户名称
|
||||
"F_RTA_VATType='"+F_RTA_VATType+"'," +//PPN Type
|
||||
"FTaxRate='"+FTaxRate+"'," +//默认税率
|
||||
"FOpenBankName='"+FOpenBankName+"' " +//开户银行
|
||||
" where FSupplierId='"+FSupplierId+"'";
|
||||
log.writeLog("供应商数据更新SQL------->" + sql);
|
||||
}else{
|
||||
//插入SQL
|
||||
sql="insert into uf_gys_K3(formmodeid,modedatacreater,modedatacreatertype,modedatacreatedate,modedatacreatetime," +
|
||||
"FUseOrgId,FSupplierId,FName,FNumber,FBankCode,FBankHolder,F_RTA_VATType,FTaxRate,FOpenBankName) values(" +
|
||||
"'"+modeid_gys+"','1','0','"+currDate+"','"+currTime+"'," +
|
||||
"'"+FUseOrgId+"','"+FSupplierId+"','"+FName+"','"+FNumber+"','"+FBankCode+"'," +
|
||||
"'"+FBankHolder+"','"+F_RTA_VATType+"','"+FTaxRate+"'," +
|
||||
"'"+FOpenBankName+"')";
|
||||
log.writeLog("供应商数据插入SQL------->" + sql);
|
||||
|
||||
//将新增的数据加入至MAP中
|
||||
gys_map.put(FSupplierId, FNumber);
|
||||
}
|
||||
rs.execute(sql);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
log.writeLog("获取K3供应商数据错误,错误信息为------->" + e.toString());
|
||||
}
|
||||
//获取同步耗时
|
||||
long hs = (System.currentTimeMillis() - startStamp)/1000;
|
||||
log.writeLog("*******同步K3供应商数据完成end:(" + weaver.general.TimeUtil.getCurrentTimeString() + "),耗时:"+hs+"秒");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,175 @@
|
|||
package com.jet.test;
|
||||
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.alibaba.fastjson.serializer.SerializerFeature;
|
||||
|
||||
import kingdee.bos.webapi.client.K3CloudApiClient;
|
||||
|
||||
/**
|
||||
* 其他应付款
|
||||
* @author KangMD
|
||||
*
|
||||
*/
|
||||
public class AP_OtherPayableSaveTestK3 {
|
||||
static String K3CloudURL = "http://k3.jet.co.id:8880/K3Cloud/";
|
||||
static String dbId = "5da41554614595";
|
||||
static String uid = "lulu yang";
|
||||
static String pwd = "20190716";
|
||||
static int lang = 2052;
|
||||
|
||||
|
||||
public static void main(String[] args) {
|
||||
// TODO Auto-generated method stub
|
||||
try {
|
||||
queryBD_Expense();
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
//供应商
|
||||
public static void queryBD_Expense() throws Exception {
|
||||
K3CloudApiClient client = new K3CloudApiClient(K3CloudURL);
|
||||
boolean result = client.login(dbId, uid, pwd, lang);
|
||||
if (result) {
|
||||
Map<String,Object> data=new HashMap<String,Object>();
|
||||
|
||||
Map<String,Object> Model=new HashMap<String,Object>();
|
||||
//单据类型(必填项)--------默认为标准应付单YFD01_SYS
|
||||
Map<String,Object> FBillTypeID=new HashMap<String,Object>();
|
||||
FBillTypeID.put("FNUMBER", "QTYFD01_SYS");
|
||||
Model.put("FBillTypeID", FBillTypeID);
|
||||
|
||||
//Model.put("FISINIT", false);//是否期初单据
|
||||
Model.put("FDATE", "2019-11-28");//业务日期(必填项)--------默认为申请日期
|
||||
Model.put("FENDDATE_H", "2019-11-28");//到期日(必填项)--------
|
||||
Model.put("FCONTACTUNITTYPE", "BD_Empinfo");//往来单位类型,默认为员工
|
||||
//Model.put("FDOCUMENTSTATUS", "Z");//单据状态
|
||||
|
||||
//往来单位编码(即员工编码)
|
||||
Map<String,Object> FCONTACTUNIT=new HashMap<String,Object>();
|
||||
FCONTACTUNIT.put("FNUMBER", "E0003");
|
||||
Model.put("FCONTACTUNIT", FCONTACTUNIT);
|
||||
|
||||
//币别(必填项)--------
|
||||
Map<String,Object> FCURRENCYID=new HashMap<String,Object>();
|
||||
FCURRENCYID.put("FNUMBER", "IDR");
|
||||
Model.put("FCURRENCYID", FCURRENCYID);
|
||||
|
||||
Model.put("FTOTALAMOUNTFOR_H", 10000.0);//总金额
|
||||
Model.put("FNOTSETTLEAMOUNTFOR", 10000.0);//未结算金额
|
||||
|
||||
//申请部门
|
||||
Map<String,Object> FDEPARTMENTID=new HashMap<String,Object>();
|
||||
FDEPARTMENTID.put("FNumber", "BM000002");
|
||||
Model.put("FDEPARTMENTID", FDEPARTMENTID);
|
||||
|
||||
//付款组织(必填项)----
|
||||
Map<String,Object> FPAYORGID=new HashMap<String,Object>();
|
||||
FPAYORGID.put("FNUMBER", "100");
|
||||
Model.put("FPAYORGID", FPAYORGID);
|
||||
//结算组织
|
||||
Model.put("FSETTLEORGID", FPAYORGID);
|
||||
//采购组织
|
||||
Model.put("FPURCHASEORGID", FPAYORGID);
|
||||
//采购部门
|
||||
Map<String,Object> FPURCHASEDEPTID=new HashMap<String,Object>();
|
||||
FPURCHASEDEPTID.put("FNumber", "BM000001");
|
||||
Model.put("FPURCHASEDEPTID", FPURCHASEDEPTID);
|
||||
//本位币
|
||||
Model.put("FMAINBOOKSTDCURRID", FCURRENCYID);
|
||||
|
||||
|
||||
//汇率类型
|
||||
// Map<String,Object> FEXCHANGETYPE=new HashMap<String,Object>();
|
||||
// FEXCHANGETYPE.put("FNUMBER", "HLTX01_SYS");
|
||||
// Model.put("FEXCHANGETYPE", FEXCHANGETYPE);
|
||||
|
||||
//到期日计算日期(期望支付日期)
|
||||
Model.put("FACCNTTIMEJUDGETIME", "2019-12-20");
|
||||
//作废状态
|
||||
Model.put("FCancelStatus", "A");
|
||||
|
||||
|
||||
//-----------------明细 start-----------------//
|
||||
List<Map<String,Object>> FEntity=new ArrayList<Map<String,Object>>();
|
||||
//定义一行明细
|
||||
Map<String,Object> EntityDetail=new HashMap<String, Object>();
|
||||
//费用项目编码
|
||||
Map<String,Object> FCOSTID=new HashMap<String,Object>();
|
||||
FCOSTID.put("FNUMBER", "CI074");
|
||||
EntityDetail.put("FCOSTID", FCOSTID);
|
||||
//费用归属部门
|
||||
EntityDetail.put("FCOSTDEPARTMENTID", FDEPARTMENTID);
|
||||
//不含税金额
|
||||
EntityDetail.put("FNOTAXAMOUNTFOR", 10000);
|
||||
//总金额
|
||||
EntityDetail.put("FTOTALAMOUNTFOR", 10000);
|
||||
//未结算金额
|
||||
EntityDetail.put("FNOTSETTLEAMOUNTFOR_D", 10000);
|
||||
//不含税金额本位币
|
||||
EntityDetail.put("FNOTAXAMOUNT_D", 10000);
|
||||
//发票类型
|
||||
//EntityDetail.put("FINVOICETYPE", "");
|
||||
//将MAP添加至List中
|
||||
FEntity.add(EntityDetail);
|
||||
//EntityDetail.clear();//清空继续循环----------
|
||||
|
||||
Model.put("FEntity", FEntity);//
|
||||
|
||||
//-----------------明细 end-----------------//
|
||||
|
||||
|
||||
data.put("Model", Model);
|
||||
|
||||
//将MAP转JSON,fastjson默认开启引用检测将相同的对象写成引用的形式,所以必须加上SerializerFeature.DisableCircularReferenceDetect,否则转换的字符串会出现$ref
|
||||
String jsonStr = JSON.toJSONString(data, SerializerFeature.DisableCircularReferenceDetect);
|
||||
System.out.println(jsonStr);
|
||||
//调用应付单保存接口
|
||||
String sResult = client.excuteOperation("AP_OtherPayable", "save", jsonStr);
|
||||
System.out.println(sResult);
|
||||
|
||||
//解析K3返回的JSO字符串
|
||||
JSONObject jsonObject = JSONObject.parseObject(sResult);
|
||||
JSONObject ResponseStatus=jsonObject.getJSONObject("Result").getJSONObject("ResponseStatus");
|
||||
//是否成功写入K3
|
||||
String IsSuccess=ResponseStatus.get("IsSuccess").toString();
|
||||
System.out.println(IsSuccess);
|
||||
if("true".equals(IsSuccess)){
|
||||
JSONArray SuccessJSONArray=ResponseStatus.getJSONArray("SuccessEntitys");
|
||||
String Id="";//单据ID
|
||||
String Number="";//单据编号
|
||||
|
||||
for(int p=0;p<SuccessJSONArray.size();p++){
|
||||
Id=SuccessJSONArray.getJSONObject(p).get("Id").toString();
|
||||
Number=SuccessJSONArray.getJSONObject(p).get("Number").toString();
|
||||
}
|
||||
System.out.println("Id------>"+Id+",Number------>"+Number);
|
||||
// String jsonStr2="{\"CreateOrgId\":0,\"Numbers\":[],\"Ids\":\""+Id+"\",\"SelectedPostId\":0}";
|
||||
// //调用应付单提交接口(将单据状态由创建--->审核中)
|
||||
// String sResult2 = client.excuteOperation("AP_Payable", "submit", jsonStr2);
|
||||
// System.out.println(sResult2);
|
||||
|
||||
}else{
|
||||
JSONArray ErrorsJSONArray=ResponseStatus.getJSONArray("Errors");
|
||||
String msg="";
|
||||
for(int p=0;p<ErrorsJSONArray.size();p++){
|
||||
msg+=ErrorsJSONArray.getJSONObject(p).get("Message").toString();
|
||||
}
|
||||
System.out.println(msg);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,83 @@
|
|||
package com.jet.test;
|
||||
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.alibaba.fastjson.serializer.SerializerFeature;
|
||||
|
||||
import kingdee.bos.webapi.client.K3CloudApiClient;
|
||||
|
||||
/**
|
||||
* 其他应付款
|
||||
* @author KangMD
|
||||
*
|
||||
*/
|
||||
public class AP_OtherPayableViewTestK3 {
|
||||
static String K3CloudURL = "http://k3.jet.co.id:8880/K3Cloud/";
|
||||
static String dbId = "5da41554614595";
|
||||
static String uid = "lulu yang";
|
||||
static String pwd = "20190716";
|
||||
static int lang = 2052;
|
||||
|
||||
|
||||
public static void main(String[] args) {
|
||||
// TODO Auto-generated method stub
|
||||
try {
|
||||
queryBD_Expense();
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
//供应商
|
||||
public static void queryBD_Expense() throws Exception {
|
||||
K3CloudApiClient client = new K3CloudApiClient(K3CloudURL);
|
||||
boolean result = client.login(dbId, uid, pwd, lang);
|
||||
if (result) {
|
||||
String jsonStr="{\"CreateOrgId\":100,\"Number\":\"QTYFD00001592\",\"Id\":\"\"}";//
|
||||
//调用应付单保存接口
|
||||
String sResult = client.excuteOperation("AP_OtherPayable", "view", jsonStr);
|
||||
System.out.println(sResult);
|
||||
|
||||
//解析K3返回的JSO字符串
|
||||
JSONObject jsonObject = JSONObject.parseObject(sResult);
|
||||
JSONObject ResponseStatus=jsonObject.getJSONObject("Result").getJSONObject("ResponseStatus");
|
||||
//是否成功写入K3
|
||||
String IsSuccess=ResponseStatus.get("IsSuccess").toString();
|
||||
System.out.println(IsSuccess);
|
||||
if("true".equals(IsSuccess)){
|
||||
JSONArray SuccessJSONArray=ResponseStatus.getJSONArray("SuccessEntitys");
|
||||
String Id="";//单据ID
|
||||
String Number="";//单据编号
|
||||
|
||||
for(int p=0;p<SuccessJSONArray.size();p++){
|
||||
Id=SuccessJSONArray.getJSONObject(p).get("Id").toString();
|
||||
Number=SuccessJSONArray.getJSONObject(p).get("Number").toString();
|
||||
}
|
||||
System.out.println("Id------>"+Id+",Number------>"+Number);
|
||||
// String jsonStr2="{\"CreateOrgId\":0,\"Numbers\":[],\"Ids\":\""+Id+"\",\"SelectedPostId\":0}";
|
||||
// //调用应付单提交接口(将单据状态由创建--->审核中)
|
||||
// String sResult2 = client.excuteOperation("AP_Payable", "submit", jsonStr2);
|
||||
// System.out.println(sResult2);
|
||||
|
||||
}else{
|
||||
JSONArray ErrorsJSONArray=ResponseStatus.getJSONArray("Errors");
|
||||
String msg="";
|
||||
for(int p=0;p<ErrorsJSONArray.size();p++){
|
||||
msg+=ErrorsJSONArray.getJSONObject(p).get("Message").toString();
|
||||
}
|
||||
System.out.println(msg);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,196 @@
|
|||
package com.jet.test;
|
||||
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.alibaba.fastjson.serializer.SerializerFeature;
|
||||
|
||||
import kingdee.bos.webapi.client.K3CloudApiClient;
|
||||
|
||||
public class AP_PayBillSaveTestK3 {
|
||||
static String K3CloudURL = "http://k3.jet.co.id:8880/K3Cloud/";
|
||||
static String dbId = "5da41554614595";
|
||||
static String uid = "lulu yang";
|
||||
static String pwd = "20190716";
|
||||
static int lang = 2052;
|
||||
|
||||
|
||||
public static void main(String[] args) {
|
||||
// TODO Auto-generated method stub
|
||||
try {
|
||||
queryBD_Expense();
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
//供应商
|
||||
public static void queryBD_Expense() throws Exception {
|
||||
K3CloudApiClient client = new K3CloudApiClient(K3CloudURL);
|
||||
boolean result = client.login(dbId, uid, pwd, lang);
|
||||
if (result) {
|
||||
//传入的JSON格式
|
||||
Map<String,Object> data=new HashMap<String,Object>();
|
||||
Map<String,Object> Model=new HashMap<String,Object>();
|
||||
//单据类型(必填项)--------默认为采购业务付款单FKDLX01_SYS
|
||||
Map<String,Object> FBillTypeID=new HashMap<String,Object>();
|
||||
FBillTypeID.put("FNUMBER", "FKDLX01_SYS");
|
||||
Model.put("FBillTypeID", FBillTypeID);
|
||||
Model.put("FDATE", "2019-11-28");//业务日期(必填项)--------默认为申请日期
|
||||
//往来单位类型,默认为供应商
|
||||
Model.put("FCONTACTUNITTYPE", "BD_Supplier");
|
||||
//往来单位(必填项)--------
|
||||
Map<String,Object> FCONTACTUNIT=new HashMap<String,Object>();
|
||||
FCONTACTUNIT.put("FNUMBER", "1009");
|
||||
Model.put("FCONTACTUNIT", FCONTACTUNIT);
|
||||
|
||||
//收款单位类型,默认为供应商
|
||||
Model.put("FRECTUNITTYPE", "BD_Supplier");
|
||||
//收款单位(必填项)--------
|
||||
Map<String,Object> FRECTUNIT=new HashMap<String,Object>();
|
||||
FRECTUNIT.put("FNUMBER", "1009");
|
||||
Model.put("FRECTUNIT", FRECTUNIT);
|
||||
|
||||
//币别(必填项)--------
|
||||
Map<String,Object> FCURRENCYID=new HashMap<String,Object>();
|
||||
FCURRENCYID.put("FNUMBER", "IDR");
|
||||
Model.put("FCURRENCYID", FCURRENCYID);
|
||||
Model.put("FEXCHANGERATE", 1.0);//汇率
|
||||
Model.put("FSETTLERATE", 1.0);//结算汇率
|
||||
//采购部门
|
||||
Map<String,Object> FPURCHASEDEPTID=new HashMap<String,Object>();
|
||||
FPURCHASEDEPTID.put("FNUMBER", "BM000001");
|
||||
Model.put("FPURCHASEDEPTID", FPURCHASEDEPTID);
|
||||
//结算组织(必填项)----
|
||||
Map<String,Object> FSETTLEORGID=new HashMap<String,Object>();
|
||||
FSETTLEORGID.put("FNumber", "100");
|
||||
Model.put("FSETTLEORGID", FSETTLEORGID);//结算组织(必填项)----
|
||||
//采购组织
|
||||
Model.put("FPURCHASEORGID", FSETTLEORGID);
|
||||
//备注
|
||||
Model.put("FREMARK", "备注test123");
|
||||
//期望付款日期
|
||||
Model.put("FBookingDate", "2019-12-12");
|
||||
Model.put("FDOCUMENTSTATUS", "Z");//单据状态
|
||||
Model.put("FCancelStatus", "A");//作废状态(必填项)----默认为A
|
||||
//结算组织
|
||||
Model.put("FPAYORGID", FSETTLEORGID);
|
||||
//结算币别
|
||||
Model.put("FSETTLECUR", FCURRENCYID);
|
||||
//结算本位币
|
||||
Model.put("FSETTLEMAINBOOKID", FCURRENCYID);
|
||||
|
||||
//-----------------付款单明细 start-----------------//
|
||||
List<Map<String,Object>> FPAYBILLENTRY=new ArrayList<Map<String,Object>>();
|
||||
//定义一行明细
|
||||
Map<String,Object> PAYBILLENTRY=new HashMap<String, Object>();
|
||||
//结算方式
|
||||
Map<String,Object> FSETTLETYPEID=new HashMap<String,Object>();
|
||||
FSETTLETYPEID.put("FNUMBER", "JSFS03_SYS");
|
||||
PAYBILLENTRY.put("FSETTLETYPEID", FSETTLETYPEID);
|
||||
|
||||
//付款用途
|
||||
Map<String,Object> FPURPOSEID=new HashMap<String,Object>();
|
||||
FPURPOSEID.put("FNUMBER", "SFKYT08_SYS");
|
||||
PAYBILLENTRY.put("FPURPOSEID", FPURPOSEID);
|
||||
|
||||
PAYBILLENTRY.put("FPAYTOTALAMOUNTFOR", 88.0);//表体-应付金额
|
||||
PAYBILLENTRY.put("FPAYAMOUNTFOR_E", 88.0);//付款金额
|
||||
PAYBILLENTRY.put("FSETTLEPAYAMOUNTFOR", 88.0);//折后金额
|
||||
PAYBILLENTRY.put("FREALPAYAMOUNTFOR_D", 88.0);//表体-实付金额
|
||||
//我方银行账号
|
||||
Map<String,Object> FACCOUNTID=new HashMap<String,Object>();
|
||||
FACCOUNTID.put("FNUMBER", "1683066137");
|
||||
PAYBILLENTRY.put("FACCOUNTID", FACCOUNTID);
|
||||
|
||||
PAYBILLENTRY.put("FPAYAMOUNT_E", 88.0);//付款金额本位币
|
||||
PAYBILLENTRY.put("FPOSTDATE", "2019-12-03");//登账日期
|
||||
PAYBILLENTRY.put("FRuZhangType", "1");//入账类型
|
||||
PAYBILLENTRY.put("FPayType", "A");//支付类型
|
||||
|
||||
|
||||
//将MAP添加至List中
|
||||
FPAYBILLENTRY.add(PAYBILLENTRY);
|
||||
|
||||
Model.put("FPAYBILLENTRY", FPAYBILLENTRY);//
|
||||
|
||||
//-----------------付款单明细 end-----------------//
|
||||
|
||||
|
||||
//-----------------付款单源单明细 start-----------------//
|
||||
List<Map<String,Object>> FPAYBILLSRCENTRY=new ArrayList<Map<String,Object>>();
|
||||
//定义一行明细
|
||||
Map<String,Object> PAYBILLSRCENTRY=new HashMap<String, Object>();
|
||||
//源单类型
|
||||
PAYBILLSRCENTRY.put("FSOURCETYPE", "AP_Payable");
|
||||
//源单编号
|
||||
PAYBILLSRCENTRY.put("FSRCBILLNO", "AP00000081");
|
||||
//本次付款金额
|
||||
PAYBILLSRCENTRY.put("FREALPAYAMOUNT_S", 88);
|
||||
//应付金额
|
||||
PAYBILLSRCENTRY.put("FAFTTAXTOTALAMOUNT", 100);
|
||||
//计划付款金额
|
||||
PAYBILLSRCENTRY.put("FPLANPAYAMOUNT", 100);
|
||||
//源单币别
|
||||
PAYBILLSRCENTRY.put("FSRCCURRENCYID", FCURRENCYID);
|
||||
//到期日
|
||||
PAYBILLSRCENTRY.put("FEXPIRY", "2019-12-01");
|
||||
|
||||
//将MAP添加至List中
|
||||
FPAYBILLSRCENTRY.add(PAYBILLSRCENTRY);
|
||||
Model.put("FPAYBILLSRCENTRY", FPAYBILLSRCENTRY);//
|
||||
|
||||
//-----------------付款单源单明细 end-----------------//
|
||||
|
||||
|
||||
|
||||
data.put("Model", Model);
|
||||
|
||||
//将MAP转JSON,fastjson默认开启引用检测将相同的对象写成引用的形式,所以必须加上SerializerFeature.DisableCircularReferenceDetect,否则转换的字符串会出现$ref
|
||||
String jsonStr = JSON.toJSONString(data, SerializerFeature.DisableCircularReferenceDetect);
|
||||
System.out.println(jsonStr);
|
||||
//String str="{\"Model\":{\"FBUSINESSTYPE\":\"CG\",\"FBillTypeID\":{\"FNUMBER\":\"YFD01_SYS\"},\"FISINIT\":false,\"FDATE\":\"2019-11-28\",\"FENDDATE_H\":\"2019-11-28\",\"FDOCUMENTSTATUS\":\"Z\",\"FSUPPLIERID\":{\"FNumber\":\"1009\"},\"FCURRENCYID\":{\"FNumber\":\"IDR\"},\"FISPRICEEXCLUDETAX\":true,\"FISTAX\":true,\"FSETTLEORGID\":{\"FNumber\":\"100\"},\"FTaxType\":{\"FNumber\":\"Non-PKP\"},\"FPAYORGID\":{\"FNumber\":\"100\"},\"FSetAccountType\":\"1\",\"FISTAXINCOST\":false,\"FISHookMatch\":false,\"FCancelStatus\":\"A\",\"F_RTA_NPWPNumber\":\"000000000000000\",\"F_RTA_EntityType\":\"Company\",\"F_RTA_PPH_H\":{\"FNumber\":\"PPH23-4\"},\"FISBYIV\":false,\"FISGENHSADJ\":false,\"FISINVOICEARLIER\":false,\"F_RTA_VATType\":{\"FNUMBER\":\"000\"},\"F_RTA_InvoiceNo\":\"1574998101931\",\"F_RTA_CanDeductVAT\":false,\"F_RTA_PPHByComp\":true,\"F_RTA_BusinessType\":\"S\",\"F_RTA_CalculateFlag\":false,\"F_RTA_PPNByComp\":false,\"FsubHeadSuppiler\":{\"FORDERID\":{\"FNumber\":\"1009\"},\"FTRANSFERID\":{\"FNumber\":\"1009\"},\"FChargeId\":{\"FNumber\":\"1009\"}},\"FsubHeadFinc\":{\"FACCNTTIMEJUDGETIME\":\"2019-11-28\",\"FMAINBOOKSTDCURRID\":{\"FNumber\":\"IDR\"},\"FEXCHANGETYPE\":{\"FNumber\":\"HLTX01_SYS\"},\"FExchangeRate\":1.0,\"FNoTaxAmountFor\":11.0},\"FEntityDetail\":[{\"FMATERIALID\":{\"FNumber\":\"100013\"},\"FMaterialDesc\":\"ROYALTYFEE\",\"FPRICEUNITID\":{\"FNumber\":\"Pcs\"},\"FPrice\":11.0,\"FPriceQty\":1.0,\"FTaxPrice\":11.0,\"FPriceWithTax\":11.0,\"F_RTA_VATType_d\":{\"FNUMBER\":\"000\"},\"FNoTaxAmountFor_D\":11.0,\"FALLAMOUNTFOR_D\":11.0,\"F_RTA_PPH\":{\"FNUMBER\":\"PPH23-4\"},\"FINCLUDECOST\":false,\"FISOUTSTOCK\":false,\"F_RTA_FakturPajakNo_d\":\"6666666666\",\"FIsFree\":false,\"FStockUnitId\":{\"FNumber\":\"Pcs\"},\"FStockQty\":1.0,\"FStockBaseQty\":1.0,\"FPriceBaseDen\":1.0,\"FStockBaseNum\":1.0,\"F_RTA_SUPPLIER_D\":{\"FNUMBER\":\"1009\"}}],\"FEntityPlan\":[{\"FENDDATE\":\"2019-11-28\",\"FPAYAMOUNTFOR\":11.0,\"FPAYRATE\":100.0}]}}";
|
||||
//String str2="{\"Model\":{\"FBUSINESSTYPE\":\"CG\",\"FBillTypeID\":{\"FNUMBER\":\"YFD01_SYS\"},\"FISINIT\":false,\"FDATE\":\"2019-11-28\",\"FENDDATE_H\":\"2019-11-28\",\"FDOCUMENTSTATUS\":\"Z\",\"FSUPPLIERID\":{\"FNUMBER\":\"1009\"},\"FCURRENCYID\":{\"FNUMBER\":\"IDR\"},\"FISPRICEEXCLUDETAX\":true,\"FISTAX\":true,\"FSETTLEORGID\":{\"FNumber\":\"100\"},\"FTaxType\":{\"FNumber\":\"Non-PKP\"},\"FPAYORGID\":{\"FNUMBER\":\"100\"},\"FSetAccountType\":\"1\",\"FISTAXINCOST\":false,\"FISHookMatch\":false,\"FCancelStatus\":\"A\",\"F_RTA_NPWPNumber\":\"000000000000000\",\"F_RTA_EntityType\":\"Company\",\"F_RTA_PPH_H\":{\"FNUMBER\":\"PPH23-4\"},\"FISBYIV\":false,\"FISGENHSADJ\":false,\"FISINVOICEARLIER\":false,\"F_RTA_VATType\":{\"FNUMBER\":\"000\"},\"F_RTA_InvoiceNo\":\"4184918116892\",\"F_RTA_CanDeductVAT\":false,\"F_RTA_PPHByComp\":true,\"F_RTA_BusinessType\":\"S\",\"F_RTA_CalculateFlag\":false,\"F_RTA_PPNByComp\":false,\"FsubHeadSuppiler\":{\"FORDERID\":{\"FNUMBER\":\"1009\"},\"FTRANSFERID\":{\"FNUMBER\":\"1009\"},\"FChargeId\":{\"FNUMBER\":\"1009\"}},\"FsubHeadFinc\":{\"FACCNTTIMEJUDGETIME\":\"2019-11-28\",\"FMAINBOOKSTDCURRID\":{\"FNUMBER\":\"IDR\"},\"FEXCHANGETYPE\":{\"FNUMBER\":\"HLTX01_SYS\"},\"FExchangeRate\":1.0,\"FNoTaxAmountFor\":11.0},\"FEntityDetail\":[{\"FMATERIALID\":{\"FNUMBER\":\"100013\"},\"FMaterialDesc\":\"ROYALTYFEE\",\"FPRICEUNITID\":{\"FNUMBER\":\"Pcs\"},\"FPrice\":11.0,\"FPriceQty\":1.0,\"FTaxPrice\":11.0,\"FPriceWithTax\":11.0,\"F_RTA_VATType_d\":{\"FNUMBER\":\"000\"},\"FNoTaxAmountFor_D\":11.0,\"FALLAMOUNTFOR_D\":11.0,\"FAUXPROPID\":{},\"FBASICUNITQTY\":1,\"FBUYIVQTY\":0,\"FINCLUDECOST\":false,\"FISOUTSTOCK\":false,\"FIVALLAMOUNTFOR\":0,\"FIsFree\":false,\"FPriceBaseDen\":1,\"FStockBaseNum\":1,\"FStockBaseQty\":1,\"FStockQty\":1,\"F_RTA_PPH\":{\"FNUMBER\":\"PPH23-4\"},\"FStockUnitId\":{\"FNUMBER\":\"Pcs\"},\"FTAXAMOUNTFOR_D\":0,\"F_RTA_EntryRemarks\":\"testtest\",\"F_RTA_FakturPajakNo_d\":\"9999999999\",\"F_RTA_SUPPLIER_D\":{\"FNUMBER\":\"1009\"}}],\"FEntityPlan\":[{\"FENDDATE\":\"2019-11-27\",\"FPAYAMOUNTFOR\":11,\"FPAYRATE\":100}]}}";
|
||||
//System.out.println(str);
|
||||
//调用应付单保存接口
|
||||
String sResult = client.excuteOperation("AP_PAYBILL", "save", jsonStr);
|
||||
System.out.println(sResult);
|
||||
|
||||
//解析K3返回的JSO字符串
|
||||
JSONObject jsonObject = JSONObject.parseObject(sResult);
|
||||
JSONObject ResponseStatus=jsonObject.getJSONObject("Result").getJSONObject("ResponseStatus");
|
||||
//是否成功写入K3
|
||||
String IsSuccess=ResponseStatus.get("IsSuccess").toString();
|
||||
System.out.println(IsSuccess);
|
||||
if("true".equals(IsSuccess)){
|
||||
JSONArray SuccessJSONArray=ResponseStatus.getJSONArray("SuccessEntitys");
|
||||
String Id="";//单据ID
|
||||
String Number="";//单据编号
|
||||
|
||||
for(int p=0;p<SuccessJSONArray.size();p++){
|
||||
Id=SuccessJSONArray.getJSONObject(p).get("Id").toString();
|
||||
Number=SuccessJSONArray.getJSONObject(p).get("Number").toString();
|
||||
}
|
||||
System.out.println("Id------>"+Id+",Number------>"+Number);
|
||||
|
||||
}else{
|
||||
JSONArray ErrorsJSONArray=ResponseStatus.getJSONArray("Errors");
|
||||
String msg="";
|
||||
for(int p=0;p<ErrorsJSONArray.size();p++){
|
||||
msg+=ErrorsJSONArray.getJSONObject(p).get("Message").toString();
|
||||
}
|
||||
System.out.println(msg);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,73 @@
|
|||
package com.jet.test;
|
||||
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.alibaba.fastjson.serializer.SerializerFeature;
|
||||
|
||||
import kingdee.bos.webapi.client.K3CloudApiClient;
|
||||
|
||||
public class AP_PayBillViewTestK3 {
|
||||
static String K3CloudURL = "http://k3.jet.co.id:8880/K3Cloud/";
|
||||
static String dbId = "5da41554614595";
|
||||
static String uid = "lulu yang";
|
||||
static String pwd = "20190716";
|
||||
static int lang = 2052;
|
||||
|
||||
|
||||
public static void main(String[] args) {
|
||||
// TODO Auto-generated method stub
|
||||
try {
|
||||
queryBD_Expense();
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
//供应商
|
||||
public static void queryBD_Expense() throws Exception {
|
||||
K3CloudApiClient client = new K3CloudApiClient(K3CloudURL);
|
||||
boolean result = client.login(dbId, uid, pwd, lang);
|
||||
if (result) {
|
||||
//调用应付单保存接口
|
||||
String sResult = client.excuteOperation("AP_PAYBILL", "view", "{\"CreateOrgId\":0,\"Number\":\"FKD00000055\",\"Id\":\"\"}");
|
||||
System.out.println(sResult);
|
||||
|
||||
//解析K3返回的JSO字符串
|
||||
JSONObject jsonObject = JSONObject.parseObject(sResult);
|
||||
JSONObject ResponseStatus=jsonObject.getJSONObject("Result").getJSONObject("ResponseStatus");
|
||||
//是否成功写入K3
|
||||
String IsSuccess=ResponseStatus.get("IsSuccess").toString();
|
||||
System.out.println(IsSuccess);
|
||||
if("true".equals(IsSuccess)){
|
||||
JSONArray SuccessJSONArray=ResponseStatus.getJSONArray("SuccessEntitys");
|
||||
String Id="";//单据ID
|
||||
String Number="";//单据编号
|
||||
|
||||
for(int p=0;p<SuccessJSONArray.size();p++){
|
||||
Id=SuccessJSONArray.getJSONObject(p).get("Id").toString();
|
||||
Number=SuccessJSONArray.getJSONObject(p).get("Number").toString();
|
||||
}
|
||||
System.out.println("Id------>"+Id+",Number------>"+Number);
|
||||
|
||||
}else{
|
||||
JSONArray ErrorsJSONArray=ResponseStatus.getJSONArray("Errors");
|
||||
String msg="";
|
||||
for(int p=0;p<ErrorsJSONArray.size();p++){
|
||||
msg+=ErrorsJSONArray.getJSONObject(p).get("Message").toString();
|
||||
}
|
||||
System.out.println(msg);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,99 @@
|
|||
package com.jet.test;
|
||||
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.alibaba.fastjson.serializer.SerializerFeature;
|
||||
|
||||
import kingdee.bos.webapi.client.K3CloudApiClient;
|
||||
|
||||
public class AP_PayablePushTestK3 {
|
||||
static String K3CloudURL = "http://k3.jet.co.id:8880/K3Cloud/";
|
||||
static String dbId = "5da41554614595";
|
||||
static String uid = "lulu yang";
|
||||
static String pwd = "20190716";
|
||||
static int lang = 2052;
|
||||
|
||||
|
||||
public static void main(String[] args) {
|
||||
// TODO Auto-generated method stub
|
||||
try {
|
||||
queryBD_Expense();
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
//供应商
|
||||
public static void queryBD_Expense() throws Exception {
|
||||
K3CloudApiClient client = new K3CloudApiClient(K3CloudURL);
|
||||
boolean result = client.login(dbId, uid, pwd, lang);
|
||||
if (result) {
|
||||
Map<String,Object> data=new HashMap<String,Object>();
|
||||
Map<String,Object> Model=new HashMap<String,Object>();
|
||||
List<Map<String,Object>> FPAYBILLENTRY=new ArrayList<Map<String,Object>>();
|
||||
//定义一行明细
|
||||
Map<String,Object> PAYBILLENTRY=new HashMap<String, Object>();
|
||||
//结算方式
|
||||
Map<String,Object> FSETTLETYPEID=new HashMap<String,Object>();
|
||||
FSETTLETYPEID.put("FNUMBER", "JSFS03_SYS");
|
||||
PAYBILLENTRY.put("FSETTLETYPEID", FSETTLETYPEID);
|
||||
//将MAP添加至List中
|
||||
FPAYBILLENTRY.add(PAYBILLENTRY);
|
||||
Model.put("FPAYBILLENTRY", FPAYBILLENTRY);//
|
||||
|
||||
data.put("Model", Model);
|
||||
|
||||
//将MAP转JSON,fastjson默认开启引用检测将相同的对象写成引用的形式,所以必须加上SerializerFeature.DisableCircularReferenceDetect,否则转换的字符串会出现$ref
|
||||
String str = JSON.toJSONString(data, SerializerFeature.DisableCircularReferenceDetect);
|
||||
System.out.println(str);
|
||||
|
||||
//传入的JSON格式
|
||||
String jsonStr="{\"Ids\": \"\",\"Numbers\": \"AP00022976\",\"EntryIds\": \"\",\"RuleId\": \"AP_PayableToPayBill\",\"TargetBillTypeId\": \"\",\"TargetOrgId\": 0,\"TargetFormId\": \"\",\"IsEnableDefaultRule\": \"false\",\"IsDraftWhenSaveFail\": \"false\",\"CustomParams\": "+str+"}";
|
||||
System.out.println(jsonStr);
|
||||
//调用应付单保存接口
|
||||
String sResult = client.excuteOperation("AP_Payable", "push", jsonStr);
|
||||
System.out.println(sResult);
|
||||
|
||||
//解析K3返回的JSO字符串
|
||||
JSONObject jsonObject = JSONObject.parseObject(sResult);
|
||||
JSONObject ResponseStatus=jsonObject.getJSONObject("Result").getJSONObject("ResponseStatus");
|
||||
//是否成功写入K3
|
||||
String IsSuccess=ResponseStatus.get("IsSuccess").toString();
|
||||
System.out.println(IsSuccess);
|
||||
if("true".equals(IsSuccess)){
|
||||
JSONArray SuccessJSONArray=ResponseStatus.getJSONArray("SuccessEntitys");
|
||||
String Id="";//单据ID
|
||||
String Number="";//单据编号
|
||||
|
||||
|
||||
for(int p=0;p<SuccessJSONArray.size();p++){
|
||||
Id=SuccessJSONArray.getJSONObject(p).get("Id").toString();
|
||||
Number=SuccessJSONArray.getJSONObject(p).get("Number").toString();
|
||||
}
|
||||
System.out.println("Id------>"+Id+",Number------>"+Number);
|
||||
// String jsonStr2="{\"CreateOrgId\":0,\"Numbers\":[],\"Ids\":\""+Id+"\",\"SelectedPostId\":0}";
|
||||
// //调用应付单提交接口(将单据状态由创建--->审核中)
|
||||
// String sResult2 = client.excuteOperation("AP_Payable", "submit", jsonStr2);
|
||||
// System.out.println(sResult2);
|
||||
|
||||
}else{
|
||||
JSONArray ErrorsJSONArray=ResponseStatus.getJSONArray("Errors");
|
||||
String msg="";
|
||||
for(int p=0;p<ErrorsJSONArray.size();p++){
|
||||
msg+=ErrorsJSONArray.getJSONObject(p).get("Message").toString();
|
||||
}
|
||||
System.out.println(msg);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,390 @@
|
|||
package com.jet.test;
|
||||
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.alibaba.fastjson.serializer.SerializerFeature;
|
||||
|
||||
import kingdee.bos.webapi.client.K3CloudApiClient;
|
||||
|
||||
public class AP_PayableSaveTestK3 {
|
||||
static String K3CloudURL = "http://k3.jet.co.id:8880/K3Cloud/";
|
||||
static String dbId = "5f33b66059caeb";
|
||||
static String uid = "lulu yang";
|
||||
static String pwd = "123456";
|
||||
static int lang = 2052;
|
||||
|
||||
|
||||
public static void main(String[] args) {
|
||||
// TODO Auto-generated method stub
|
||||
try {
|
||||
queryBD_Expense();
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
//供应商
|
||||
public static void queryBD_Expense() throws Exception {
|
||||
K3CloudApiClient client = new K3CloudApiClient(K3CloudURL);
|
||||
boolean result = client.login(dbId, uid, pwd, lang);
|
||||
if (result) {
|
||||
//传入的JSON格式
|
||||
//String data="";
|
||||
|
||||
Map<String,Object> data=new HashMap<String,Object>();
|
||||
// data.put("Creator", "");
|
||||
// data.put("NeedUpDateFields", new String[0]);
|
||||
// data.put("NeedReturnFields", new String[0]);
|
||||
// data.put("IsDeleteEntry", "true");
|
||||
// data.put("SubSystemId", "");
|
||||
// data.put("IsVerifyBaseDataField", "false");
|
||||
// data.put("IsEntryBatchFill", "true");
|
||||
// data.put("ValidateFlag", "true");
|
||||
// data.put("NumberSearch", "true");
|
||||
// data.put("InterationFlags", "");
|
||||
// data.put("IsAutoSubmitAndAudit", "false");
|
||||
|
||||
Map<String,Object> Model=new HashMap<String,Object>();
|
||||
//Model.put("FID", "0");//实体主键
|
||||
//单据类型(必填项)--------默认为标准应付单YFD01_SYS
|
||||
Map<String,Object> FBillTypeID=new HashMap<String,Object>();
|
||||
FBillTypeID.put("FNUMBER", "YFD01_SYS");
|
||||
Model.put("FBillTypeID", FBillTypeID);
|
||||
|
||||
//Model.put("FBillNo", "");//单据编号--------K3动生成
|
||||
Model.put("FISINIT", false);//是否期初单据
|
||||
Model.put("FDATE", "2019-11-28");//业务日期(必填项)--------默认为申请日期
|
||||
Model.put("FENDDATE_H", "2019-11-28");//到期日(必填项)--------
|
||||
Model.put("FDOCUMENTSTATUS", "Z");//单据状态
|
||||
|
||||
//供应商(必填项)--------
|
||||
Map<String,Object> FSUPPLIERID=new HashMap<String,Object>();
|
||||
FSUPPLIERID.put("FNUMBER", "1009");
|
||||
Model.put("FSUPPLIERID", FSUPPLIERID);
|
||||
|
||||
//币别(必填项)--------
|
||||
Map<String,Object> FCURRENCYID=new HashMap<String,Object>();
|
||||
FCURRENCYID.put("FNUMBER", "IDR");
|
||||
Model.put("FCURRENCYID", FCURRENCYID);
|
||||
|
||||
Model.put("FISPRICEEXCLUDETAX", true);//价外税
|
||||
Model.put("FBUSINESSTYPE", "CG");//业务类型(必填项)----默认为CG
|
||||
Model.put("FISTAX", true);//按含税单价录入----
|
||||
|
||||
//结算组织(必填项)----
|
||||
Map<String,Object> FSETTLEORGID=new HashMap<String,Object>();
|
||||
FSETTLEORGID.put("FNumber", "100");
|
||||
Model.put("FSETTLEORGID", FSETTLEORGID);//结算组织(必填项)----
|
||||
|
||||
//税分类----//根据供应商自动带出
|
||||
// Map<String,Object> FTaxType=new HashMap<String,Object>();
|
||||
// FTaxType.put("FNumber", "Non-PKP");
|
||||
// Model.put("FTaxType", FTaxType);
|
||||
|
||||
//付款组织(必填项)----
|
||||
Map<String,Object> FPAYORGID=new HashMap<String,Object>();
|
||||
FPAYORGID.put("FNUMBER", "100");
|
||||
Model.put("FPAYORGID", FPAYORGID);
|
||||
|
||||
//Model.put("FSetAccountType", "1");//立账类型----默认为1
|
||||
// Model.put("FISTAXINCOST", false);//税额计入成本
|
||||
// Model.put("FISHookMatch", false);//参与暂估应付核销
|
||||
Model.put("FCancelStatus", "A");//作废状态(必填项)----默认为A
|
||||
|
||||
//Model.put("F_RTA_NPWPNumber", "000000000000000");//NPWP Number----//根据供应商自动带出
|
||||
//Model.put("F_RTA_EntityType", "Company");//Entity Type----//根据供应商自动带出
|
||||
|
||||
//PPH----
|
||||
// Map<String,Object> F_RTA_PPH_H=new HashMap<String,Object>();
|
||||
// F_RTA_PPH_H.put("FNUMBER", "PPH23-4");
|
||||
// Model.put("F_RTA_PPH_H", F_RTA_PPH_H);
|
||||
|
||||
// Model.put("FISBYIV", false);//是发票审核自动生成
|
||||
// Model.put("FISGENHSADJ", false);//是否需要成本调整
|
||||
//Model.put("FMatchMethodID", 0);//核销方式
|
||||
// Model.put("FISINVOICEARLIER", false);//先到票后入库
|
||||
|
||||
// Map<String,Object> F_RTA_VATType=new HashMap<String,Object>();
|
||||
// F_RTA_VATType.put("FNUMBER", "000");
|
||||
// Model.put("F_RTA_VATType", F_RTA_VATType);//PPN Type
|
||||
|
||||
Model.put("F_RTA_InvoiceNo", System.currentTimeMillis()+"");//Invoice No(必填项)----
|
||||
//Model.put("F_RTA_CanDeductVAT", false);//可否抵扣增值税选项
|
||||
//Model.put("FBILLMATCHLOGID", 0);//开票核销记录序号
|
||||
//Model.put("F_RTA_PPHByComp", true);//PPH By Company
|
||||
Model.put("F_RTA_BusinessType", "S");//business type(必填项)----默认为服务类
|
||||
//Model.put("F_RTA_CalculateFlag", false);//PPH21已计算标识
|
||||
//Model.put("F_RTA_PPNByComp", false);//PPN By Company
|
||||
|
||||
|
||||
//-----------------表头供应商 start-----------------//
|
||||
Map<String,Object> FsubHeadSuppiler=new HashMap<String,Object>();
|
||||
//FsubHeadSuppiler.put("FEntryId", 0);//实体主键
|
||||
FsubHeadSuppiler.put("FORDERID", FSUPPLIERID);//订货方
|
||||
FsubHeadSuppiler.put("FTRANSFERID", FSUPPLIERID);//供货方
|
||||
FsubHeadSuppiler.put("FChargeId", FSUPPLIERID);//收款方
|
||||
|
||||
Model.put("FsubHeadSuppiler", FsubHeadSuppiler);//
|
||||
//-----------------表头供应商 end-----------------//
|
||||
|
||||
|
||||
|
||||
//付款条件----
|
||||
// Map<String,Object> FPayConditon=new HashMap<String,Object>();
|
||||
// FPayConditon.put("FNUMBER", "FKTJ01_SYS");
|
||||
// Model.put("FPayConditon", FPayConditon);
|
||||
//
|
||||
//
|
||||
// Model.put("FSourceBillType", "");//源单类型----
|
||||
//
|
||||
//
|
||||
Model.put("FAP_Remark", "test测试");//备注----
|
||||
//
|
||||
// //Model.put("FACCOUNTSYSTEM", "{\"FNUMBER\":\"\"}");//会计核算体系
|
||||
//
|
||||
// //采购部门----
|
||||
// Map<String,Object> FPURCHASEDEPTID=new HashMap<String,Object>();
|
||||
// FPURCHASEDEPTID.put("FNUMBER", "BM000009");
|
||||
// Model.put("FPURCHASEDEPTID", FPURCHASEDEPTID);
|
||||
//
|
||||
// //采购组----
|
||||
// Map<String,Object> FPURCHASERGROUPID=new HashMap<String,Object>();
|
||||
// FPURCHASERGROUPID.put("FNUMBER", "");
|
||||
// Model.put("FPURCHASERGROUPID", FPURCHASERGROUPID);
|
||||
//
|
||||
// //采购员----
|
||||
// Map<String,Object> FPURCHASERID=new HashMap<String,Object>();
|
||||
// FPURCHASERID.put("FNUMBER", "");
|
||||
// Model.put("FPURCHASERID", FPURCHASERID);
|
||||
//
|
||||
//
|
||||
// Model.put("F_RTA_Isclerka", "");//Is Staff----//根据供应商自动带出
|
||||
|
||||
|
||||
|
||||
|
||||
//Model.put("FScanPoint", "{\"FNUMBER\":\"\"}");//扫描点
|
||||
//Model.put("F_RTA_DPwithPPN", "A1");//Down Payment with PPN(必填项)----
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------表头财务 start-----------------//
|
||||
Map<String,Object> FsubHeadFinc=new HashMap<String,Object>();
|
||||
//FsubHeadFinc.put("FEntryId", 0);//实体主键
|
||||
FsubHeadFinc.put("FACCNTTIMEJUDGETIME", "2019-11-28");//到期日计算日期(必填项)----
|
||||
|
||||
//结算方式
|
||||
Map<String,Object> FSettleTypeID=new HashMap<String,Object>();
|
||||
FSettleTypeID.put("FNUMBER", "JSFS03_SYS");
|
||||
FsubHeadFinc.put("FSettleTypeID", FSettleTypeID);
|
||||
//本位币
|
||||
FsubHeadFinc.put("FMAINBOOKSTDCURRID", FCURRENCYID);
|
||||
//汇率类型
|
||||
// Map<String,Object> FEXCHANGETYPE=new HashMap<String,Object>();
|
||||
// FEXCHANGETYPE.put("FNUMBER", "HLTX01_SYS");
|
||||
// FsubHeadFinc.put("FEXCHANGETYPE", FEXCHANGETYPE);//
|
||||
// FsubHeadFinc.put("FExchangeRate", 1.0);//汇率
|
||||
//FsubHeadFinc.put("FTaxAmountFor", 2276.0);//税额
|
||||
//FsubHeadFinc.put("FNoTaxAmountFor", 11.0);//不含税金额
|
||||
|
||||
Model.put("FsubHeadFinc", FsubHeadFinc);//
|
||||
//-----------------表头财务 end-----------------//
|
||||
|
||||
|
||||
//-----------------明细 start-----------------//
|
||||
List<Map<String,Object>> FEntityDetail=new ArrayList<Map<String,Object>>();
|
||||
//定义一行明细
|
||||
Map<String,Object> EntityDetail=new HashMap<String, Object>();
|
||||
//EntityDetail.put("FEntryId", 0);//实体主键
|
||||
//EntityDetail.put("FCOSTID", "{\"FNUMBER\":\"\"}");//费用项目编码
|
||||
//物料编码
|
||||
Map<String,Object> FMATERIALID=new HashMap<String,Object>();
|
||||
FMATERIALID.put("FNUMBER", "100013");
|
||||
EntityDetail.put("FMATERIALID", FMATERIALID);
|
||||
//EntityDetail.put("FMaterialDesc", "ROYALTY FEE");//物料说明
|
||||
|
||||
EntityDetail.put("F_RTA_EntryRemarks", "testtest");//备 注
|
||||
|
||||
//EntityDetail.put("FASSETID", "{\"FNUMBER\":\"\"}");//卡片编码
|
||||
//计价单位
|
||||
Map<String,Object> FPRICEUNITID=new HashMap<String,Object>();
|
||||
FPRICEUNITID.put("FNUMBER", "Pcs");
|
||||
EntityDetail.put("FPRICEUNITID", FPRICEUNITID);
|
||||
|
||||
EntityDetail.put("FPrice", 11.0);//单价
|
||||
EntityDetail.put("FPriceQty", 1.0);//计价数量
|
||||
//EntityDetail.put("FBASICUNITQTY", 1);//计价基本数量
|
||||
EntityDetail.put("FTaxPrice", 11.0);//含税单价
|
||||
//EntityDetail.put("F_RTA_PPHAmount", 3035);//PPH Amount
|
||||
EntityDetail.put("FPriceWithTax", 11);//含税净价
|
||||
|
||||
//PPN Type
|
||||
Map<String,Object> F_RTA_VATType_d=new HashMap<String,Object>();
|
||||
F_RTA_VATType_d.put("FNUMBER", "000");
|
||||
EntityDetail.put("F_RTA_VATType_d", F_RTA_VATType_d);
|
||||
|
||||
//EntityDetail.put("FEntryTaxRate", 0);//税率(%)
|
||||
//EntityDetail.put("FTaxCombination", "{\"FNUMBER\":\"\"}");//税组合
|
||||
//EntityDetail.put("FEntryDiscountRate", 0);//折扣率(%)
|
||||
//EntityDetail.put("FDISCOUNTAMOUNTFOR", 0);//折扣额
|
||||
EntityDetail.put("FNoTaxAmountFor_D", 11.0);//不含税金额
|
||||
EntityDetail.put("FTAXAMOUNTFOR_D", 0);//税额
|
||||
EntityDetail.put("FALLAMOUNTFOR_D", 11.0);//价税合计
|
||||
|
||||
//PPH-------------
|
||||
// Map<String,Object> F_RTA_PPH=new HashMap<String,Object>();
|
||||
// F_RTA_PPH.put("FNUMBER", "PPH23-4");
|
||||
// EntityDetail.put("F_RTA_PPH", F_RTA_PPH);
|
||||
|
||||
//EntityDetail.put("FINCLUDECOST", false);//计入成本
|
||||
//EntityDetail.put("FOUTSTOCKID", "[{\"FNUMBER\":\"\"}]");//出库单号
|
||||
//EntityDetail.put("FAUXPROPID", new HashMap<String, Object>());//辅助属性
|
||||
//EntityDetail.put("FBUYIVQTY", 0);//采购发票数量
|
||||
//EntityDetail.put("FIVALLAMOUNTFOR", 0);//采购发票价税合计
|
||||
//EntityDetail.put("FISOUTSTOCK", false);//是否有出库单号
|
||||
EntityDetail.put("F_RTA_FakturPajakNo_d", "-");//Faktur Pajak No
|
||||
//EntityDetail.put("FIsFree", false);//是否赠品
|
||||
//EntityDetail.put("FStockUnitId", FPRICEUNITID);//库存单位
|
||||
|
||||
|
||||
//EntityDetail.put("FCOSTDEPARTMENTID", "{\"FNUMBER\":\"\"}");//费用承担部门
|
||||
//EntityDetail.put("FLot", "{\"FNUMBER\":\"\"}");//批号
|
||||
// EntityDetail.put("FMONUMBER", "");//生产订单编号
|
||||
// EntityDetail.put("FMOENTRYSEQ", 0);//生产订单行号
|
||||
// EntityDetail.put("FOPNO", "");//工序计划号
|
||||
// EntityDetail.put("FSEQNUMBER", "");//序列号
|
||||
// EntityDetail.put("FOPERNUMBER", 0);//工序号
|
||||
//EntityDetail.put("FPROCESSID", "{\"FNUMBER\":\"\"}");//作业
|
||||
//EntityDetail.put("FFPRODEPARTMENTID", "{\"FNUMBER\":\"\"}");//生产车间
|
||||
// EntityDetail.put("FWWINTYPE", "");//入库类型
|
||||
|
||||
|
||||
|
||||
// EntityDetail.put("FStockQty", 1);//库存数量
|
||||
// EntityDetail.put("FStockBaseQty", 1);//库存基本数量
|
||||
// EntityDetail.put("FPriceBaseDen", 1);//计价基本分母
|
||||
// EntityDetail.put("FStockBaseNum", 1);//库存基本分子
|
||||
//EntityDetail.put("FOrderEntryID", 0);//采购订单明细内码
|
||||
//EntityDetail.put("FORDERENTRYSEQ", 0);//采购订单行号
|
||||
//EntityDetail.put("FBUYIVINIQTY", 0);//采购发票数量期初
|
||||
//EntityDetail.put("FBUYIVINIBASICQTY", 0);//采购发票基本单位数量期初
|
||||
//EntityDetail.put("FIVINIALLAMOUNTFOR", 0);//采购发票价税合计期初
|
||||
//EntityDetail.put("FPushRedQty", 0);//已下推负数财务应付数量
|
||||
EntityDetail.put("F_RTA_SUPPLIER_D", FSUPPLIERID);//表体供应商(用于校验税票号唯一)
|
||||
//EntityDetail.put("F_RTA_AccumulatedAmount", 0);//累计金额
|
||||
//EntityDetail.put("FSRCROWID", 0);//源单行内码
|
||||
//EntityDetail.put("F_RTA_AccumulatedPPH21", 0);//累计PPH21税额
|
||||
//EntityDetail.put("F_RTA_PPHAmountM", 0);//PPH Amount(本位币)
|
||||
|
||||
//-----------------税务明细 start-----------------//
|
||||
// List<Map<String,Object>> FTaxDetailSubEntity=new ArrayList<Map<String,Object>>();
|
||||
// Map<String,Object> FTax=new HashMap<String,Object>();
|
||||
// FTax.put("FDetailID", 0);//实体主键
|
||||
// //FTax.put("FTaxRateId", "{\"FNUMBER\":\"\"}");//税率名称
|
||||
// FTax.put("FTaxRate", 0);//税率(%)
|
||||
// FTax.put("FTaxAmount_T", 0);//税额
|
||||
// FTax.put("FCostPercent", 0);//计入成本比例
|
||||
// FTax.put("FCostAmount", 0);//计入成本金额
|
||||
// FTax.put("FVAT", "false");//增值税
|
||||
// FTax.put("FSellerWithholding", "false");//卖方代扣代缴
|
||||
// FTax.put("FBuyerWithholding", "false");//买方代扣代缴
|
||||
//
|
||||
// FTaxDetailSubEntity.add(FTax);
|
||||
// EntityDetail.put("FTaxDetailSubEntity", FTaxDetailSubEntity);//
|
||||
//-----------------税务明细 end-----------------//
|
||||
//将MAP添加至List中
|
||||
FEntityDetail.add(EntityDetail);
|
||||
//EntityDetail.clear();//清空继续循环----------
|
||||
|
||||
Model.put("FEntityDetail", FEntityDetail);//
|
||||
|
||||
//-----------------明细 end-----------------//
|
||||
|
||||
|
||||
//-----------------付款计划 start-----------------//
|
||||
List<Map<String,Object>> FEntityPlan=new ArrayList<Map<String,Object>>();
|
||||
Map<String,Object> FPlan=new HashMap<String,Object>();
|
||||
//FPlan.put("FEntryID", 0);//实体主键
|
||||
FPlan.put("FENDDATE", "2019-11-27");//表头计划 - 到期日
|
||||
FPlan.put("FPAYAMOUNTFOR", 11.0);//应付金额
|
||||
//FPlan.put("FPAYAMOUNT", 11);//应付金额
|
||||
FPlan.put("FPAYRATE", 100);//应付比例(%)
|
||||
// FPlan.put("FPURCHASEORDERID", 0);//采购订单ID
|
||||
// FPlan.put("FPAYABLEENTRYID", 0);//采购订单明细内码
|
||||
|
||||
//物料编码
|
||||
// Map<String,Object> FMATERIALID_P=new HashMap<String,Object>();
|
||||
// FMATERIALID_P.put("FNUMBER", "2-07.01");
|
||||
// FPlan.put("FMATERIALID_P", FMATERIALID_P);
|
||||
// FPlan.put("FPRICEUNITID_P", FPRICEUNITID);//计价单位
|
||||
// FPlan.put("FPRICE_P", 11);//含税单价
|
||||
// FPlan.put("FQTY_P", 1);//数量
|
||||
// FPlan.put("FPURCHASEORDERNO", "");//采购订单号
|
||||
// FPlan.put("FMATERIALSEQ", 0);//订单行号
|
||||
// FPlan.put("FRELATEHADPAYQTY", 1);//付(退)款关联数量
|
||||
FEntityPlan.add(FPlan);
|
||||
//FPlan.clear();
|
||||
Model.put("FEntityPlan", FEntityPlan);//
|
||||
//-----------------付款计划 end-----------------//
|
||||
|
||||
data.put("Model", Model);
|
||||
|
||||
//将MAP转JSON,fastjson默认开启引用检测将相同的对象写成引用的形式,所以必须加上SerializerFeature.DisableCircularReferenceDetect,否则转换的字符串会出现$ref
|
||||
String jsonStr = JSON.toJSONString(data, SerializerFeature.DisableCircularReferenceDetect);
|
||||
System.out.println(jsonStr);
|
||||
|
||||
//MAP转JSON
|
||||
//JSONObject json = new JSONObject(data);
|
||||
//System.out.println(json.toJSONString());
|
||||
|
||||
String str="{\"Model\": {\"FBillTypeID\": {\"FNUMBER\": \"YFD01_SYS\"},\"FISINIT\": false,\"FDATE\": \"2020-08-26\",\"FENDDATE_H\": \"2020-08-26\",\"FDOCUMENTSTATUS\": \"Z\",\"FSUPPLIERID\": {\"FNUMBER\": \"1160\"},\"FCURRENCYID\": {\"FNUMBER\": \"IDR\"},\"FISPRICEEXCLUDETAX\": true,\"FBUSINESSTYPE\": \"CG\",\"FISTAX\": true,\"FSETTLEORGID\": {\"FNumber\": \"100\"},\"FPURCHASEDEPTID\": {\"FNUMBER\": \"BM000002\"},\"FPAYORGID\": {\"FNUMBER\": \"100\"},\"F_RTA_VATType\": {\"FNUMBER\": \"II-6\"},\"FCancelStatus\": \"A\",\"F_RTA_InvoiceNo\": \"TEST\",\"F_RTA_BusinessType\": \"S\",\"FAP_Remark\": \"TEST\",\"F_RTA_PPHByComp\": false,\"FsubHeadSuppiler\": {\"FORDERID\": {\"FNUMBER\": \"1160\"},\"FTRANSFERID\": {\"FNUMBER\": \"1160\"},\"FChargeId\": {\"FNUMBER\": \"1160\"}},\"FsubHeadFinc\": {\"FACCNTTIMEJUDGETIME\": \"2020-08-19\",\"FSettleTypeID\": {\"FNUMBER\": \"JSFS03_SYS\"},\"FMAINBOOKSTDCURRID\": {\"FNUMBER\": \"IDR\"}},\"FEntityDetail\": [{\"FMATERIALID\": {\"FNUMBER\": \"100013\"},\"F_RTA_EntryRemarks\": \"TEST\",\"FPRICEUNITID\": {\"FNUMBER\": \"Pcs\"},\"FPrice\": \"1000000.00\",\"FPriceQty\": 1.0,\"FTaxPrice\": \"1100000.00\",\"FTAXAMOUNTFOR_D\": \"100000.00\",\"FPriceWithTax\": \"1000000.00\",\"F_RTA_VATType_d\": {\"FNUMBER\": \"II-6\"},\"FNoTaxAmountFor_D\": \"1000000.00\",\"FTAXAMOUNTFOR_D\": 0,\"FALLAMOUNTFOR_D\": \"1000000.00\",\"F_RTA_FakturPajakNo_d\": \"-\",\"F_RTA_SUPPLIER_D\": {\"FNUMBER\": \"1160\"}}],\"FEntityPlan\": [{\"FENDDATE\": \"2020-08-19\",\"FPAYAMOUNTFOR\": \"1000000.00\",\"FPAYRATE\": 100}]}}";
|
||||
//String str2="{\"Model\":{\"FBUSINESSTYPE\":\"CG\",\"FBillTypeID\":{\"FNUMBER\":\"YFD01_SYS\"},\"FISINIT\":false,\"FDATE\":\"2019-11-28\",\"FENDDATE_H\":\"2019-11-28\",\"FDOCUMENTSTATUS\":\"Z\",\"FSUPPLIERID\":{\"FNUMBER\":\"1009\"},\"FCURRENCYID\":{\"FNUMBER\":\"IDR\"},\"FISPRICEEXCLUDETAX\":true,\"FISTAX\":true,\"FSETTLEORGID\":{\"FNumber\":\"100\"},\"FTaxType\":{\"FNumber\":\"Non-PKP\"},\"FPAYORGID\":{\"FNUMBER\":\"100\"},\"FSetAccountType\":\"1\",\"FISTAXINCOST\":false,\"FISHookMatch\":false,\"FCancelStatus\":\"A\",\"F_RTA_NPWPNumber\":\"000000000000000\",\"F_RTA_EntityType\":\"Company\",\"F_RTA_PPH_H\":{\"FNUMBER\":\"PPH23-4\"},\"FISBYIV\":false,\"FISGENHSADJ\":false,\"FISINVOICEARLIER\":false,\"F_RTA_VATType\":{\"FNUMBER\":\"000\"},\"F_RTA_InvoiceNo\":\"4184918116892\",\"F_RTA_CanDeductVAT\":false,\"F_RTA_PPHByComp\":true,\"F_RTA_BusinessType\":\"S\",\"F_RTA_CalculateFlag\":false,\"F_RTA_PPNByComp\":false,\"FsubHeadSuppiler\":{\"FORDERID\":{\"FNUMBER\":\"1009\"},\"FTRANSFERID\":{\"FNUMBER\":\"1009\"},\"FChargeId\":{\"FNUMBER\":\"1009\"}},\"FsubHeadFinc\":{\"FACCNTTIMEJUDGETIME\":\"2019-11-28\",\"FMAINBOOKSTDCURRID\":{\"FNUMBER\":\"IDR\"},\"FEXCHANGETYPE\":{\"FNUMBER\":\"HLTX01_SYS\"},\"FExchangeRate\":1.0,\"FNoTaxAmountFor\":11.0},\"FEntityDetail\":[{\"FMATERIALID\":{\"FNUMBER\":\"100013\"},\"FMaterialDesc\":\"ROYALTYFEE\",\"FPRICEUNITID\":{\"FNUMBER\":\"Pcs\"},\"FPrice\":11.0,\"FPriceQty\":1.0,\"FTaxPrice\":11.0,\"FPriceWithTax\":11.0,\"F_RTA_VATType_d\":{\"FNUMBER\":\"000\"},\"FNoTaxAmountFor_D\":11.0,\"FALLAMOUNTFOR_D\":11.0,\"FAUXPROPID\":{},\"FBASICUNITQTY\":1,\"FBUYIVQTY\":0,\"FINCLUDECOST\":false,\"FISOUTSTOCK\":false,\"FIVALLAMOUNTFOR\":0,\"FIsFree\":false,\"FPriceBaseDen\":1,\"FStockBaseNum\":1,\"FStockBaseQty\":1,\"FStockQty\":1,\"F_RTA_PPH\":{\"FNUMBER\":\"PPH23-4\"},\"FStockUnitId\":{\"FNUMBER\":\"Pcs\"},\"FTAXAMOUNTFOR_D\":0,\"F_RTA_EntryRemarks\":\"testtest\",\"F_RTA_FakturPajakNo_d\":\"9999999999\",\"F_RTA_SUPPLIER_D\":{\"FNUMBER\":\"1009\"}}],\"FEntityPlan\":[{\"FENDDATE\":\"2019-11-27\",\"FPAYAMOUNTFOR\":11,\"FPAYRATE\":100}]}}";
|
||||
//System.out.println(str);
|
||||
//调用应付单保存接口
|
||||
String sResult = client.excuteOperation("AP_Payable", "save", str);
|
||||
System.out.println(sResult);
|
||||
|
||||
//解析K3返回的JSO字符串
|
||||
JSONObject jsonObject = JSONObject.parseObject(sResult);
|
||||
JSONObject ResponseStatus=jsonObject.getJSONObject("Result").getJSONObject("ResponseStatus");
|
||||
//是否成功写入K3
|
||||
String IsSuccess=ResponseStatus.get("IsSuccess").toString();
|
||||
System.out.println(IsSuccess);
|
||||
if("true".equals(IsSuccess)){
|
||||
JSONArray SuccessJSONArray=ResponseStatus.getJSONArray("SuccessEntitys");
|
||||
String Id="";//单据ID
|
||||
String Number="";//单据编号
|
||||
|
||||
for(int p=0;p<SuccessJSONArray.size();p++){
|
||||
Id=SuccessJSONArray.getJSONObject(p).get("Id").toString();
|
||||
Number=SuccessJSONArray.getJSONObject(p).get("Number").toString();
|
||||
}
|
||||
System.out.println("Id------>"+Id+",Number------>"+Number);
|
||||
// String jsonStr2="{\"CreateOrgId\":0,\"Numbers\":[],\"Ids\":\""+Id+"\",\"SelectedPostId\":0}";
|
||||
// //调用应付单提交接口(将单据状态由创建--->审核中)
|
||||
// String sResult2 = client.excuteOperation("AP_Payable", "submit", jsonStr2);
|
||||
// System.out.println(sResult2);
|
||||
|
||||
}else{
|
||||
JSONArray ErrorsJSONArray=ResponseStatus.getJSONArray("Errors");
|
||||
String msg="";
|
||||
for(int p=0;p<ErrorsJSONArray.size();p++){
|
||||
msg+=ErrorsJSONArray.getJSONObject(p).get("Message").toString();
|
||||
}
|
||||
System.out.println(msg);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,72 @@
|
|||
package com.jet.test;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import weaver.general.Util;
|
||||
|
||||
|
||||
import kingdee.bos.webapi.client.K3CloudApiClient;
|
||||
|
||||
public class BD_SupplierTestK3 {
|
||||
static String K3CloudURL = "http://k3.jet.co.id:8880/K3Cloud/";
|
||||
static String dbId = "5f33b66059caeb";
|
||||
static String uid = "lulu yang";
|
||||
static String pwd = "123456";
|
||||
static int lang = 2052;
|
||||
|
||||
public static void main(String[] args) {
|
||||
// TODO Auto-generated method stub
|
||||
try {
|
||||
queryBD_Expense();
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
//供应商
|
||||
public static void queryBD_Expense() throws Exception {
|
||||
K3CloudApiClient client = new K3CloudApiClient(K3CloudURL);
|
||||
boolean result = client.login(dbId, uid, pwd, lang);
|
||||
if (result) {
|
||||
String sContent = "{\"FormId\":\"BD_Supplier\","
|
||||
// 供应商formid
|
||||
+"\"TopRowCount\":0,"
|
||||
// 最多允许查询的数量,0或者不要此属性表示不限制
|
||||
+"\"Limit\":100,"
|
||||
// 分页取数每页允许获取的数据,最大不能超过2000
|
||||
+"\"StartRow\":0,"
|
||||
//分页取数开始行索引,从0开始,例如每页10行数据,第2页开始是10,第3页开始是20
|
||||
//""FilterString":"FMaterialId.FNumber like 'HG_TEST%'","+// 过滤条件
|
||||
//""FilterString":"FBillNo='CGDD000008'","+// 过滤条件
|
||||
+"\"FilterString\":\"FNumber!='' and FDocumentStatus='C'\"," //过滤条件 编码不为空值
|
||||
//+"\"OrderString\":\"FGoodsNO ASC\","// 排序条件
|
||||
//获取供应商基础信息 组织ID、内码、名称、编码、银行账号、账户名称、开户银行
|
||||
+"\"FieldKeys\":\"FUseOrgId,FSupplierId,FName,FNumber,FBankCode,FBankHolder,FOpenBankName,FForbidStatus,FDocumentStatus,F_RTA_VATType.FNumber,FTaxRateId.FNumber\"}";
|
||||
|
||||
List<List<Object>> sResult = client.executeBillQuery(sContent);
|
||||
int rows=sResult.size();
|
||||
for(int k=0;k<rows;k++){
|
||||
String FUseOrgId=Util.null2String(sResult.get(k).get(0));//组织ID
|
||||
String FSupplierId=Util.null2String(sResult.get(k).get(1));//供应商内码
|
||||
String FName=Util.null2String(sResult.get(k).get(2));//供应商名称
|
||||
String FNumber=Util.null2String(sResult.get(k).get(3));//供应商编码
|
||||
String FBankCode=Util.null2String(sResult.get(k).get(4));//银行账号
|
||||
String FBankHolder=Util.null2String(sResult.get(k).get(5));//账户名称
|
||||
String FOpenBankName=Util.null2String(sResult.get(k).get(6));//开户银行
|
||||
String FForbidStatus=Util.null2String(sResult.get(k).get(7));//禁用状态
|
||||
String FDocumentStatus=Util.null2String(sResult.get(k).get(8));//数据状态(D重新审核 B审核中 C已审核)
|
||||
String F_RTA_VATType=Util.null2String(sResult.get(k).get(9));//PPN Type
|
||||
String FTaxRateId=Util.null2String(sResult.get(k).get(10));//默认税率
|
||||
if(!"A".equals(FForbidStatus)){
|
||||
System.out.println("FName----->"+FName+";FNumber----->"+FNumber+";FForbidStatus----->"+FForbidStatus);
|
||||
}
|
||||
System.out.println("F_RTA_VATType----->"+F_RTA_VATType+";FTaxRateId----->"+FTaxRateId+";FForbidStatus----->"+FForbidStatus);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,64 @@
|
|||
package com.jet.test;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import weaver.general.Util;
|
||||
|
||||
|
||||
import kingdee.bos.webapi.client.K3CloudApiClient;
|
||||
|
||||
public class CN_BankAcntTestK3 {
|
||||
static String K3CloudURL = "http://k3.jet.co.id:8880/K3Cloud/";
|
||||
static String dbId = "5da41554614595";
|
||||
static String uid = "lulu yang";
|
||||
static String pwd = "20190716";
|
||||
static int lang = 2052;
|
||||
|
||||
|
||||
public static void main(String[] args) {
|
||||
// TODO Auto-generated method stub
|
||||
try {
|
||||
queryBD_Expense();
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
//供应商
|
||||
public static void queryBD_Expense() throws Exception {
|
||||
K3CloudApiClient client = new K3CloudApiClient(K3CloudURL);
|
||||
boolean result = client.login(dbId, uid, pwd, lang);
|
||||
if (result) {
|
||||
String sContent = "{\"FormId\":\"CN_BANKACNT\","
|
||||
// 供应商formid
|
||||
+"\"TopRowCount\":0,"
|
||||
// 最多允许查询的数量,0或者不要此属性表示不限制
|
||||
+"\"Limit\":2000,"
|
||||
// 分页取数每页允许获取的数据,最大不能超过2000
|
||||
+"\"StartRow\":0,"
|
||||
//分页取数开始行索引,从0开始,例如每页10行数据,第2页开始是10,第3页开始是20
|
||||
//""FilterString":"FMaterialId.FNumber like 'HG_TEST%'","+// 过滤条件
|
||||
//""FilterString":"FBillNo='CGDD000008'","+// 过滤条件
|
||||
+"\"FilterString\":\"FNumber!=''\"," //过滤条件 编码不为空值
|
||||
//+"\"OrderString\":\"FGoodsNO ASC\","// 排序条件
|
||||
//获取供应商基础信息 组织ID、内码、名称、编码、银行账号、账户名称、开户银行
|
||||
+"\"FieldKeys\":\"FUseOrgId,FBANKACNTID,FName,FNumber,FBANKID\"}";
|
||||
|
||||
List<List<Object>> sResult = client.executeBillQuery(sContent);
|
||||
int rows=sResult.size();
|
||||
for(int k=0;k<rows;k++){
|
||||
String FUseOrgId=Util.null2String(sResult.get(k).get(0));//组织ID
|
||||
String FBANKACNTID=Util.null2String(sResult.get(k).get(1));//供应商内码
|
||||
String FName=Util.null2String(sResult.get(k).get(2));//供应商名称
|
||||
String FNumber=Util.null2String(sResult.get(k).get(3));//供应商编码
|
||||
String FBANKID=Util.null2String(sResult.get(k).get(4));//银行账号
|
||||
System.out.println("FBANKACNTID----->"+FBANKACNTID+";FName----->"+FName+";FNumber----->"+FNumber+";FBANKID----->"+FBANKID);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
package com.jet.test;
|
||||
|
||||
import org.apache.commons.codec.digest.DigestUtils;
|
||||
|
||||
import com.jet.util.JwtUtil;
|
||||
|
||||
public class DBSSO_Test {
|
||||
|
||||
public static void main(String[] args) {
|
||||
String aa= DigestUtils.shaHex("782ZfF谢莹1603935541292");
|
||||
System.out.println("aa------->"+aa);
|
||||
String token=JwtUtil.createSsoToken("00001304","TPFKAGB3QGPM2LBD","DPQY6CN2UT",36000).getToken();
|
||||
System.out.println("token------->"+token);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
package com.jet.test;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URLDecoder;
|
||||
public class Decode_Encode {
|
||||
|
||||
|
||||
public static void main(String[] args) {
|
||||
String pcurlsrc="/openDoc?title=Suhana%25E7%259A%2584%25E8%25AF%25B7%25E5%2581%2587%25E5%258D%2595%2528JT20191121000001%25EF%25BC%2589&templateId=1122317121229303809&workId=1197361606271516673";
|
||||
try {
|
||||
String s=URLDecoder.decode(pcurlsrc,"UTF-8");
|
||||
System.out.println(s);
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,43 @@
|
|||
package com.jet.test;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
|
||||
public class Test {
|
||||
|
||||
/**
|
||||
* @param args
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
double te=88888888888.00;
|
||||
DecimalFormat df = new DecimalFormat( "###############0.00 ");// 16位整数位,两小数位
|
||||
String temp = df.format(te);
|
||||
System.out.println(temp);
|
||||
// TODO Auto-generated method stub
|
||||
Map<String,Object> data=new HashMap<String,Object>();
|
||||
List<Map<String,Object>> Model=new ArrayList<Map<String,Object>>();
|
||||
Map<String,Object> map1=new HashMap<String, Object>();
|
||||
Map<String,Object> map2=new HashMap<String, Object>();
|
||||
|
||||
map1.put("A", "test1");
|
||||
map1.put("B", "test2");
|
||||
|
||||
map2.put("C", "test3");
|
||||
map2.put("D", "test4");
|
||||
|
||||
Model.add(map1);
|
||||
Model.add(map2);
|
||||
|
||||
data.put("Model", Model);
|
||||
//MAP转JSON
|
||||
JSONObject json = new JSONObject(data);
|
||||
|
||||
System.out.println(json.toJSONString());
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
package com.jet.util;
|
||||
|
||||
import weaver.conn.RecordSet;
|
||||
import weaver.general.Util;
|
||||
|
||||
public class BaseUtil {
|
||||
public static String getFormidId(String workflowid){
|
||||
StringBuffer lSQL = new StringBuffer();
|
||||
lSQL.append(" SELECT formid FROM workflow_base WHERE id='"+workflowid+"' ");
|
||||
RecordSet rs = new RecordSet();
|
||||
rs.execute(lSQL.toString());
|
||||
String formid="0";
|
||||
if(rs.next()){
|
||||
formid=Util.null2String(rs.getString("formid"));
|
||||
formid=Math.abs(Integer.parseInt(formid))+"";
|
||||
}
|
||||
return formid;
|
||||
}
|
||||
public static String getWorkflowId(String requestid){
|
||||
StringBuffer lSQL = new StringBuffer();
|
||||
lSQL.append(" SELECT workflowid FROM workflow_requestbase WHERE requestid='"+requestid+"' ");
|
||||
RecordSet rs = new RecordSet();
|
||||
rs.execute(lSQL.toString());
|
||||
String workflowid="";
|
||||
if(rs.next()){
|
||||
workflowid=Util.null2String(rs.getString("workflowid"));
|
||||
}
|
||||
return workflowid;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,226 @@
|
|||
package com.jet.util;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONObject;
|
||||
|
||||
public class InvokeHelper {
|
||||
|
||||
// K3 Cloud WebSite URL Example "http://192.168.19.113/K3Cloud/"
|
||||
public static String POST_K3CloudURL = "http://k3.jet.co.id:8880/k3cloud/";
|
||||
|
||||
// Cookie 值
|
||||
private static String CookieVal = null;
|
||||
|
||||
private static Map map = new HashMap();
|
||||
static {
|
||||
map.put("Save",
|
||||
"Kingdee.BOS.WebApi.ServicesStub.DynamicFormService.Save.common.kdsvc");
|
||||
map.put("View",
|
||||
"Kingdee.BOS.WebApi.ServicesStub.DynamicFormService.View.common.kdsvc");
|
||||
map.put("Submit",
|
||||
"Kingdee.BOS.WebApi.ServicesStub.DynamicFormService.Submit.common.kdsvc");
|
||||
map.put("Audit",
|
||||
"Kingdee.BOS.WebApi.ServicesStub.DynamicFormService.Audit.common.kdsvc");
|
||||
map.put("UnAudit",
|
||||
"Kingdee.BOS.WebApi.ServicesStub.DynamicFormService.UnAudit.common.kdsvc");
|
||||
map.put("StatusConvert",
|
||||
"Kingdee.BOS.WebApi.ServicesStub.DynamicFormService.StatusConvert.common.kdsvc");
|
||||
}
|
||||
|
||||
// HttpURLConnection
|
||||
private static HttpURLConnection initUrlConn(String url, JSONArray paras)
|
||||
throws Exception {
|
||||
System.out.println(POST_K3CloudURL.concat(url));
|
||||
URL postUrl = new URL(POST_K3CloudURL.concat(url));
|
||||
HttpURLConnection connection = (HttpURLConnection) postUrl
|
||||
.openConnection();
|
||||
if (CookieVal != null) {
|
||||
connection.setRequestProperty("Cookie", CookieVal);
|
||||
}
|
||||
if (!connection.getDoOutput()) {
|
||||
connection.setDoOutput(true);
|
||||
}
|
||||
connection.setRequestMethod("POST");
|
||||
connection.setUseCaches(false);
|
||||
connection.setInstanceFollowRedirects(true);
|
||||
connection.setRequestProperty("Content-Type", "application/json");
|
||||
DataOutputStream out = new DataOutputStream(
|
||||
connection.getOutputStream());
|
||||
|
||||
UUID uuid = UUID.randomUUID();
|
||||
int hashCode = uuid.toString().hashCode();
|
||||
|
||||
JSONObject jObj = new JSONObject();
|
||||
|
||||
jObj.put("format", 1);
|
||||
jObj.put("useragent", "ApiClient");
|
||||
jObj.put("rid", hashCode);
|
||||
jObj.put("parameters", chinaToUnicode(paras.toString()));
|
||||
jObj.put("timestamp", new Date().toString());
|
||||
jObj.put("v", "1.0");
|
||||
|
||||
out.writeBytes(jObj.toString());
|
||||
out.flush();
|
||||
out.close();
|
||||
|
||||
return connection;
|
||||
}
|
||||
|
||||
// Login
|
||||
public static boolean Login(String dbId, String user, String pwd, int lang)
|
||||
throws Exception {
|
||||
|
||||
boolean bResult = false;
|
||||
|
||||
String sUrl = "Kingdee.BOS.WebApi.ServicesStub.AuthService.ValidateUser.common.kdsvc";
|
||||
|
||||
JSONArray jParas = new JSONArray();
|
||||
jParas.put(dbId);// 帐套Id
|
||||
jParas.put(user);// 用户名
|
||||
jParas.put(pwd);// 密码
|
||||
jParas.put(lang);// 语言
|
||||
|
||||
HttpURLConnection connection = initUrlConn(sUrl, jParas);
|
||||
// 获取Cookie
|
||||
String key = null;
|
||||
for (int i = 1; (key = connection.getHeaderFieldKey(i)) != null; i++) {
|
||||
if (key.equalsIgnoreCase("Set-Cookie")) {
|
||||
String tempCookieVal = connection.getHeaderField(i);
|
||||
if (tempCookieVal.startsWith("kdservice-sessionid")) {
|
||||
CookieVal = tempCookieVal;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(
|
||||
connection.getInputStream()));
|
||||
String line;
|
||||
System.out.println(" ============================= ");
|
||||
System.out.println(" Contents of post request ");
|
||||
System.out.println(" ============================= ");
|
||||
while ((line = reader.readLine()) != null) {
|
||||
String sResult = new String(line.getBytes());
|
||||
System.out.println(sResult);
|
||||
bResult = line.contains("\"LoginResultType\":1");
|
||||
}
|
||||
System.out.println(" ============================= ");
|
||||
System.out.println(" Contents of post request ends ");
|
||||
System.out.println(" ============================= ");
|
||||
reader.close();
|
||||
|
||||
connection.disconnect();
|
||||
|
||||
return bResult;
|
||||
}
|
||||
|
||||
// Save
|
||||
public static JSONObject Save(String formId, String content) throws Exception {
|
||||
JSONObject JSONObject=Invoke("Save", formId, content);
|
||||
return JSONObject;
|
||||
}
|
||||
|
||||
// View
|
||||
public static void View(String formId, String content) throws Exception {
|
||||
Invoke("View", formId, content);
|
||||
}
|
||||
|
||||
// Submit
|
||||
public static void Submit(String formId, String content) throws Exception {
|
||||
Invoke("Submit", formId, content);
|
||||
}
|
||||
|
||||
// Audit
|
||||
public static void Audit(String formId, String content) throws Exception {
|
||||
Invoke("Audit", formId, content);
|
||||
}
|
||||
|
||||
// UnAudit
|
||||
public static void UnAudit(String formId, String content) throws Exception {
|
||||
Invoke("UnAudit", formId, content);
|
||||
}
|
||||
|
||||
// StatusConvert
|
||||
public static void StatusConvert(String formId, String content)
|
||||
throws Exception {
|
||||
Invoke("StatusConvert", formId, content);
|
||||
}
|
||||
|
||||
private static JSONObject Invoke(String deal, String formId, String content)
|
||||
throws Exception {
|
||||
Logger log = Logger.getLogger(JSONObject.class);
|
||||
JSONObject json=new JSONObject();
|
||||
boolean flag=false;
|
||||
BufferedReader reader =null;
|
||||
HttpURLConnection connectionInvoke =null;
|
||||
String sResult="";
|
||||
try{
|
||||
String sUrl = map.get(deal).toString();
|
||||
JSONArray jParas = new JSONArray();
|
||||
jParas.put(formId);
|
||||
jParas.put(content);
|
||||
|
||||
connectionInvoke = initUrlConn(sUrl, jParas);
|
||||
|
||||
reader = new BufferedReader(new InputStreamReader(
|
||||
connectionInvoke.getInputStream()));
|
||||
|
||||
String line;
|
||||
System.out.println(" ============================= ");
|
||||
System.out.println(" Contents of post request ");
|
||||
System.out.println(" ============================= ");
|
||||
while ((line = reader.readLine()) != null) {
|
||||
sResult = new String(line.getBytes(), "utf-8");
|
||||
System.out.println(sResult);
|
||||
log.error("sResult--"+sResult);
|
||||
}
|
||||
|
||||
System.out.println(" ============================= ");
|
||||
System.out.println(" Contents of post request ends ");
|
||||
System.out.println(" ============================= ");
|
||||
flag=true;
|
||||
reader.close();
|
||||
connectionInvoke.disconnect();
|
||||
|
||||
}catch(Exception e){
|
||||
sResult=e.getMessage();
|
||||
reader.close();
|
||||
connectionInvoke.disconnect();
|
||||
}
|
||||
json.put("flag", flag);
|
||||
json.put("sResult", sResult);
|
||||
return json;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 把中文转成Unicode码
|
||||
*
|
||||
* @param str
|
||||
* @return
|
||||
*/
|
||||
public static String chinaToUnicode(String str) {
|
||||
String result = "";
|
||||
for (int i = 0; i < str.length(); i++) {
|
||||
int chr1 = (char) str.charAt(i);
|
||||
if (chr1 >= 19968 && chr1 <= 171941) {// 汉字范围 \u4e00-\u9fa5 (中文)
|
||||
result += "\\u" + Integer.toHexString(chr1);
|
||||
} else {
|
||||
result += str.charAt(i);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
package com.jet.util;
|
||||
|
||||
public class JwtSsoTokenResult {
|
||||
|
||||
public JwtSsoTokenResult(String token){
|
||||
this.token = token;
|
||||
}
|
||||
|
||||
private String token;
|
||||
private Long expires = 7200L;
|
||||
|
||||
public String getToken(){
|
||||
return token;
|
||||
}
|
||||
|
||||
public Long getExpires(){
|
||||
return expires;
|
||||
}
|
||||
|
||||
public Boolean IsSuccess(){
|
||||
return token != null;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,53 @@
|
|||
package com.jet.util;
|
||||
|
||||
import com.auth0.jwt.JWT;
|
||||
import com.auth0.jwt.algorithms.Algorithm;
|
||||
import com.auth0.jwt.exceptions.JWTCreationException;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.util.*;
|
||||
|
||||
public class JwtUtil {
|
||||
|
||||
/**
|
||||
* 简单Sso登录
|
||||
*
|
||||
* @param account:工号
|
||||
* @param clientId:客户端ID
|
||||
* @param secret:秘钥
|
||||
* @param second:有效时长
|
||||
* @return
|
||||
*/
|
||||
public static JwtSsoTokenResult createSsoToken(String account, String clientId, String secret, int second) {
|
||||
try {
|
||||
Algorithm algorithm = Algorithm.HMAC256(secret);
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
|
||||
map.put("alg", "HS256");
|
||||
map.put("typ", "JWT");
|
||||
Date nowDate = new Date();
|
||||
Calendar cal = new GregorianCalendar();
|
||||
cal.setTime(nowDate);
|
||||
cal.add(Calendar.SECOND, second);
|
||||
Date expireDate = cal.getTime();
|
||||
String token = JWT.create()
|
||||
.withHeader(map)
|
||||
.withClaim("uid", account)
|
||||
.withClaim("clientId", clientId)
|
||||
.withIssuer("DbSsoServer")
|
||||
.withSubject("DbSso_AccessToken")
|
||||
.withAudience("Web")
|
||||
.withIssuedAt(nowDate)
|
||||
.withExpiresAt(expireDate)
|
||||
.sign(algorithm);
|
||||
return new JwtSsoTokenResult(token);
|
||||
|
||||
} catch (JWTCreationException exception) {
|
||||
exception.printStackTrace();
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
return new JwtSsoTokenResult(null);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
package com.working.link;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.jsp.JspWriter;
|
||||
|
||||
import weaver.hrm.User;
|
||||
import weaver.soa.workflow.request.RequestInfo;
|
||||
|
||||
public interface RequestLink {
|
||||
|
||||
public abstract Object ExecuteRequest(HttpServletRequest request,HttpServletResponse response,
|
||||
User user,JspWriter out,RequestInfo requestinfo,StringBuffer sb) throws Exception;
|
||||
|
||||
}
|
|
@ -0,0 +1,159 @@
|
|||
package com.working.schedule;
|
||||
|
||||
import com.working.util.LogTool;
|
||||
|
||||
import weaver.conn.RecordSet;
|
||||
import weaver.general.Util;
|
||||
import weaver.interfaces.schedule.BaseCronJob;
|
||||
|
||||
/**
|
||||
* 第一次初始化是同步部门或者分部信息
|
||||
* @author lwt
|
||||
*
|
||||
*/
|
||||
public class SynDeptOrSubCom extends BaseCronJob{
|
||||
|
||||
public void execute() {
|
||||
LogTool log = new LogTool("/log/working/",false);
|
||||
log.writeLog("同步部门或分部信息开始.");
|
||||
RecordSet rs = new RecordSet();
|
||||
RecordSet rs1 = new RecordSet();
|
||||
RecordSet rs2 = new RecordSet();
|
||||
RecordSet rs3 = new RecordSet();
|
||||
String name = "";//组织名称
|
||||
String code = "";//组织编码
|
||||
String type = "";//组织类型
|
||||
String supId = "";//上级组织id
|
||||
String supName = "";//上级组织名称
|
||||
String datasourType = rs.getDBType();
|
||||
log.writeLog("datasourType="+datasourType);
|
||||
if ("oracle".equals(datasourType)) {
|
||||
rs.executeQuery("select * from uf_dept_subcom order by length(code) asc");
|
||||
} else if ("sqlserver".equals(datasourType)) {
|
||||
rs.executeQuery("select * from uf_dept_subcom order by len(code) asc");
|
||||
}
|
||||
while (rs.next()) {
|
||||
name = Util.null2String(rs.getString("NAME"));
|
||||
code = Util.null2String(rs.getString("CODE"));
|
||||
type = Util.null2String(rs.getString("TYPE"));
|
||||
supName = Util.null2String(rs.getString("SUP_NAME"));
|
||||
if ("oracle".equals(datasourType)) {
|
||||
if (name.indexOf("&")!=-1) {//包含&
|
||||
name = name.replaceAll("&", "'||chr(38)||'");
|
||||
}
|
||||
if (supName.indexOf("&")!=-1) {//包含&
|
||||
supName = supName.replaceAll("&", "'||chr(38)||'");
|
||||
}
|
||||
log.writeLog("name="+name+";supName="+supName);
|
||||
}
|
||||
if ("0".equals(type)) {//分部
|
||||
//先查询上级分部的id
|
||||
rs1.execute("select * from hrmsubcompany where subcompanyname like '%"+supName+"%'");
|
||||
log.writeLog("sql1="+"select * from hrmsubcompany where subcompanyname like '%"+supName+"%'");
|
||||
while (rs1.next()) {
|
||||
supId = Util.null2String(rs1.getInt("ID"));
|
||||
rs2.executeQuery("select * from hrmsubcompany where subcompanyname like '%"+name+"%' and supsubcomid = " + supId);
|
||||
log.writeLog("sql2="+"select * from hrmsubcompany where subcompanyname like '%"+name+"%' and supsubcomid = " + supId);
|
||||
while (rs2.next()) {
|
||||
log.writeLog("sql3="+"update hrmsubcompany set subcompanycode = '"+code+"' where subcompanyname like '%"
|
||||
+name+"%' and supsubcomid = "+supId);
|
||||
rs3.executeQuery("update hrmsubcompany set subcompanycode = '"+code+"' where subcompanyname like '%"
|
||||
+name+"%' and supsubcomid = "+supId);
|
||||
}
|
||||
}
|
||||
} else if ("1".equals(type)) {//部门
|
||||
if (code.length()==4) {//表示是jnt-->部门
|
||||
//先查询上级分部的id
|
||||
rs1.executeQuery("select * from hrmsubcompany where subcompanycode = ?", code.substring(0, 2));
|
||||
while (rs1.next()) {
|
||||
supId = Util.null2String(rs1.getInt("ID"));
|
||||
log.writeLog("sql2="+"select * from hrmdepartment where departmentname like '%"+name+"%' and subcompanyid1 = "+ supId);
|
||||
rs2.executeQuery("select * from hrmdepartment where departmentname like '%"+name+"%' and subcompanyid1 = "+ supId);
|
||||
while (rs2.next()) {
|
||||
log.writeLog("sql3="+"update hrmdepartment set departmentcode = '"+code+"' where departmentname like '%"
|
||||
+name+"%' and subcompanyid1 = "+supId);
|
||||
rs3.executeQuery("update hrmdepartment set departmentcode = '"+code+"' where departmentname like '%"
|
||||
+name+"%' and subcompanyid1 = "+supId);
|
||||
}
|
||||
}
|
||||
} else if (code.length()==6) {//表示是分部-->部门
|
||||
//先查询上级分部的id
|
||||
rs1.executeQuery("select * from hrmsubcompany where subcompanycode = ?", code.substring(0, 4));
|
||||
while (rs1.next()) {
|
||||
supId = Util.null2String(rs1.getInt("ID"));
|
||||
log.writeLog("sql2="+"select * from hrmdepartment where departmentname like '%"+name+"%' and subcompanyid1 = "+ supId);
|
||||
rs2.executeQuery("select * from hrmdepartment where departmentname like '%"+name+"%' and subcompanyid1 = "+ supId);
|
||||
while (rs2.next()) {
|
||||
log.writeLog("sql3="+"update hrmdepartment set departmentcode = '"+code+"' where departmentname like '%"
|
||||
+name+"%' and subcompanyid1 = "+supId);
|
||||
rs3.executeQuery("update hrmdepartment set departmentcode = '"+code+"' where departmentname like '%"
|
||||
+name+"%' and subcompanyid1 = "+supId);
|
||||
}
|
||||
}
|
||||
} else if (code.length()==8) {//表示是分部-->部门-->部门
|
||||
//先查询上级部门的id
|
||||
rs1.executeQuery("select * from hrmdepartment where departmentcode = ?", code.substring(0, 6));
|
||||
while (rs1.next()) {
|
||||
supId = Util.null2String(rs1.getInt("ID"));
|
||||
log.writeLog("sql2="+"select * from hrmdepartment where departmentname like '%"+name+"%' and supdepid = "+supId);
|
||||
rs2.executeQuery("select * from hrmdepartment where departmentname like '%"+name+"%' and supdepid = "+supId);
|
||||
while (rs2.next()) {
|
||||
log.writeLog("sql3="+"update hrmdepartment set departmentcode = '"+code+"' where departmentname like '%"
|
||||
+name+"%' and supdepid = "+supId);
|
||||
rs3.executeQuery("update hrmdepartment set departmentcode = '"+code+"' where departmentname like '%"
|
||||
+name+"%' and supdepid = "+supId);
|
||||
}
|
||||
}
|
||||
} else if (code.length()==10) {//表示是分部-->分部-->部门
|
||||
//先查询上级分部的id
|
||||
rs1.executeQuery("select * from hrmsubcompany where subcompanycode = ?", code.substring(0, 8));
|
||||
while (rs1.next()) {
|
||||
supId = Util.null2String(rs1.getInt("ID"));
|
||||
log.writeLog("sql2="+"select * from hrmdepartment where departmentname like '%"+name+"%' and subcompanyid1 = "+ supId);
|
||||
rs2.executeQuery("select * from hrmdepartment where departmentname like '%"+name+"%' and subcompanyid1 = "+ supId);
|
||||
while (rs2.next()) {
|
||||
log.writeLog("sql3="+"update hrmdepartment set departmentcode = '"+code+"' where departmentname like '%"
|
||||
+name+"%' and subcompanyid1 = "+supId);
|
||||
rs3.executeQuery("update hrmdepartment set departmentcode = '"+code+"' where departmentname like '%"
|
||||
+name+"%' and subcompanyid1 = "+supId);
|
||||
}
|
||||
}
|
||||
//再查询上级部门的id
|
||||
rs1.executeQuery("select * from hrmdepartment where departmentcode = ?", code.substring(0, 8));
|
||||
while (rs1.next()) {
|
||||
supId = Util.null2String(rs1.getInt("ID"));
|
||||
log.writeLog("sql2="+"select * from hrmdepartment where departmentname like '%"+name+"%' and supdepid = "+ supId);
|
||||
rs2.executeQuery("select * from hrmdepartment where departmentname like '%"+name+"%' and supdepid = "+ supId);
|
||||
while (rs2.next()) {
|
||||
log.writeLog("sql3="+"update hrmdepartment set departmentcode = '"+code+"' where departmentname like '%"
|
||||
+name+"%' and supdepid = "+supId);
|
||||
rs3.executeQuery("update hrmdepartment set departmentcode = '"+code+"' where departmentname like '%"
|
||||
+name+"%' and supdepid = "+supId);
|
||||
}
|
||||
}
|
||||
} else if (code.length()==12) {//表示分部-->分部-->部门-->部门
|
||||
//先查询上级部门的id
|
||||
rs1.executeQuery("select * from hrmdepartment where departmentcode = ?", code.substring(0, 10));
|
||||
while (rs1.next()) {
|
||||
supId = Util.null2String(rs1.getInt("ID"));
|
||||
log.writeLog("sql2="+"select * from hrmdepartment where departmentname like '%"+name+"%' and supdepid = "+ supId);
|
||||
rs2.executeQuery("select * from hrmdepartment where departmentname like '%"+name+"%' and supdepid = "+ supId);
|
||||
while (rs2.next()) {
|
||||
log.writeLog("sql3="+"update hrmdepartment set departmentcode = '"+code+"' where departmentname like '%"
|
||||
+name+"%' and supdepid = "+supId);
|
||||
rs3.executeQuery("update hrmdepartment set departmentcode = '"+code+"' where departmentname like '%"
|
||||
+name+"%' and supdepid = "+supId);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
log.writeLog("同步部门或分部信息结束.");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,193 @@
|
|||
package com.working.schedule;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.commons.httpclient.HttpException;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.alibaba.fastjson.serializer.SerializerFeature;
|
||||
|
||||
import weaver.file.Prop;
|
||||
|
||||
import com.working.third.JwtUtil;
|
||||
import com.working.util.HttpManager;
|
||||
import com.working.util.LogTool;
|
||||
import com.working.util.WorkflowUtil;
|
||||
|
||||
import weaver.conn.RecordSet;
|
||||
import weaver.general.Util;
|
||||
import weaver.interfaces.schedule.BaseCronJob;
|
||||
|
||||
/**
|
||||
* 查询人员移动端考勤信息,并同步更新到东宝系统
|
||||
* @author lwt
|
||||
*
|
||||
*/
|
||||
public class SynScheduleSignDatas extends BaseCronJob{
|
||||
|
||||
public void execute() {
|
||||
LogTool log = new LogTool("/log/working/schedule",false);
|
||||
String clientId = Prop.getPropValue("db_work","clientId");
|
||||
String secret = Prop.getPropValue("db_work","secret");
|
||||
Integer second = Integer.valueOf(Prop.getPropValue("db_work","second"));
|
||||
String code = Prop.getPropValue("db_work","code");
|
||||
String moduleCode = Prop.getPropValue("db_work","moduleCode");
|
||||
String batchCardDataUrl = Prop.getPropValue("db_work","batchCardDataUrl");
|
||||
log.writeLog("同步人员移动端考勤信息更新到东宝系统开始.clientId="+clientId+";secret="+secret+";second="+second
|
||||
+";code="+code+";moduleCode="+moduleCode+";batchCardDataUrl="+batchCardDataUrl);
|
||||
String token = JwtUtil.createThirdToken(clientId,secret,second).getToken();
|
||||
Map<String,String> dataMap = new HashMap<String,String>();//保存数据id和员工编号的集合
|
||||
Map headMap = new HashMap();
|
||||
headMap.put("code",code);
|
||||
headMap.put("moduleCode",moduleCode);
|
||||
headMap.put("token",token);
|
||||
headMap.put("clientId",clientId);
|
||||
Map bodyMap2 = new HashMap();
|
||||
Map bodyMap3 = new HashMap();
|
||||
List list = new ArrayList();//存储打卡数据
|
||||
List idList = new ArrayList();//存储数据id
|
||||
|
||||
RecordSet rs = new RecordSet();
|
||||
RecordSet rs1 = new RecordSet();
|
||||
String id = "";//签到id
|
||||
String workCode = "";//人员编号
|
||||
String userId = "";//签到人id
|
||||
String signDate = "";//签到日期
|
||||
String signTime = "";//签到时间
|
||||
String longitude = "";//经度
|
||||
String latitude = "";//纬度
|
||||
String address = "";//地址
|
||||
String remark = "";//签到备注
|
||||
//查询考勤数据
|
||||
String datasource = rs.getDBType();
|
||||
log.writeLog("datasource="+datasource);
|
||||
if ("oracle".equals(datasource)) {
|
||||
rs.execute("select * from hrmschedulesign where syn_flag != 2 order by signdate desc");
|
||||
} else if ("sqlserver".equals(datasource)) {
|
||||
rs.execute("select * from hrmschedulesign where syn_flag != 2 order by signdate desc");
|
||||
}
|
||||
//取到考勤数据,调用同步接口
|
||||
while (rs.next()) {
|
||||
Map bodyMap = new HashMap();
|
||||
Map bodyMap1 = new HashMap();
|
||||
id = Util.null2String(rs.getInt("ID"));
|
||||
idList.add(id);
|
||||
userId = Util.null2String(rs.getString("USERID"));
|
||||
workCode = Util.null2String(WorkflowUtil.getUserInfo(userId).get("workcode"));
|
||||
dataMap.put(id, workCode);
|
||||
signDate = Util.null2String(rs.getString("SIGNDATE"));
|
||||
signTime = Util.null2String(rs.getString("SIGNTIME"));
|
||||
longitude = Util.null2String(rs.getString("LONGITUDE"));
|
||||
latitude = Util.null2String(rs.getString("LATITUDE"));
|
||||
address = Util.null2String(rs.getString("ADDR"));
|
||||
remark = Util.null2String(rs.getString("REMARK"));
|
||||
// log.writeLog("id="+id+";workCode="+workCode+";userId="+userId+";signDate="+signDate+";signTime="+signTime
|
||||
// +";longitude="+longitude+";latitude="+latitude+";address="+address);
|
||||
bodyMap.put("cardTime", signDate + " " +signTime);
|
||||
bodyMap.put("dataSource", "8");
|
||||
bodyMap.put("signPlace", address);
|
||||
bodyMap.put("status", "1");
|
||||
bodyMap.put("longitude", longitude);
|
||||
bodyMap.put("latitude", latitude);
|
||||
bodyMap.put("describe", remark);
|
||||
bodyMap.put("timeZone", "GMT+8");
|
||||
bodyMap1.put("empRule","1");
|
||||
bodyMap1.put("empKey",workCode);
|
||||
bodyMap1.put("cardData",bodyMap);
|
||||
//存储所有数据在集合中
|
||||
list.add(bodyMap1);
|
||||
}
|
||||
// bodyMap2.put("empOrders", list);
|
||||
bodyMap3.put("header",headMap);
|
||||
bodyMap3.put("body",bodyMap2);
|
||||
try {
|
||||
if (list.size()>0) {
|
||||
//循环次数,每次传输1000条数据
|
||||
int num = list.size()/1000+1;
|
||||
for (int i=0;i<=num;i++) {
|
||||
//初始化传输的list
|
||||
List listSign = new ArrayList();
|
||||
List listSignId = new ArrayList();
|
||||
for (int j=i*1000;j<(i+1)*1000;j++) {
|
||||
if (j>=list.size()) {//超出list的下标,跳出循环
|
||||
break;
|
||||
}
|
||||
listSign.add(list.get(j));
|
||||
listSignId.add(idList.get(j));
|
||||
}
|
||||
if (listSign.size() ==0) {
|
||||
continue;
|
||||
} else {
|
||||
bodyMap2.put("empOrders", listSign);
|
||||
}
|
||||
String param = JSON.toJSONString(bodyMap3,SerializerFeature.DisableCircularReferenceDetect);
|
||||
// log.writeLog("param="+param);
|
||||
String result = HttpManager.postMap(batchCardDataUrl,headMap,param);
|
||||
log.writeLog("result="+result);
|
||||
//解析返回值result
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
//解析JOSN
|
||||
jsonObject = JSONObject.parseObject(result);
|
||||
String returnCode = Util.null2String(jsonObject.get("code"));
|
||||
String data = Util.null2String(jsonObject.get("data"));
|
||||
if ("200".equals(returnCode)) {//同步成功(可能存在部分数据失败)
|
||||
//先全部更新为同步成功
|
||||
log.writeLog("sql1="+"update hrmschedulesign set syn_flag = 2 where id in ("+listSignId.toString().replace("[", "'").replace("]", "'").replace(",", "','")+")");
|
||||
rs1.execute("update hrmschedulesign set syn_flag = 2 where id in ("+listSignId.toString().replace("[", "'").replace("]", "'").replace(",", "','")+")");
|
||||
if (!data.isEmpty()) {//有更新失败的
|
||||
//解析返回值data
|
||||
JSONObject dataObject = new JSONObject();
|
||||
dataObject = JSONObject.parseObject(data);
|
||||
String key = "";//返回的错误的数据的员工编号
|
||||
String mapKey = "";//保存map的key
|
||||
String mapValue = "";//保存map的value
|
||||
Iterator<String> dataIterator = dataObject.keySet().iterator();
|
||||
Iterator<String> dataMapIter = dataMap.keySet().iterator();
|
||||
while (dataIterator.hasNext()) {
|
||||
// 获得key
|
||||
key = dataIterator.next();
|
||||
while (dataMapIter.hasNext()) {
|
||||
mapKey = dataMapIter.next();
|
||||
mapValue = dataMap.get(mapKey);
|
||||
if (key.equals(mapValue)) {
|
||||
//更新为同步失败
|
||||
rs1.executeQuery("update hrmschedulesign set syn_flag = 1 where id = ?", mapKey);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {//同步异常,更新这批数据为同步失败
|
||||
rs1.executeQuery("update hrmschedulesign set syn_flag = 1 where id in (?)", listSignId.toString().replace("[", "'").replace("]", "'").replace(",", "','"));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
log.writeLog("此次查询无符合数据!");
|
||||
}
|
||||
} catch (HttpException e) {
|
||||
// TODO Auto-generated catch block
|
||||
log.writeLog("HttpException="+e.toString());
|
||||
e.printStackTrace();
|
||||
} catch (IOException e) {
|
||||
// TODO Auto-generated catch block
|
||||
log.writeLog("IOException="+e.toString());
|
||||
e.printStackTrace();
|
||||
} catch (Exception e) {
|
||||
log.writeLog("Exception="+e.toString());
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
log.writeLog("同步人员移动端考勤信息更新到东宝系统结束.");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,193 @@
|
|||
package com.working.schedule;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.commons.httpclient.HttpException;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.alibaba.fastjson.serializer.SerializerFeature;
|
||||
|
||||
import weaver.file.Prop;
|
||||
|
||||
import com.working.third.JwtUtil;
|
||||
import com.working.util.HttpManager;
|
||||
import com.working.util.LogTool;
|
||||
import com.working.util.WorkflowUtil;
|
||||
|
||||
import weaver.conn.RecordSet;
|
||||
import weaver.general.Util;
|
||||
import weaver.interfaces.schedule.BaseCronJob;
|
||||
|
||||
/**
|
||||
* 查询人员移动端外勤考勤信息,并同步更新到东宝系统
|
||||
* @author lwt
|
||||
*
|
||||
*/
|
||||
public class SynSignDatas extends BaseCronJob{
|
||||
|
||||
public void execute() {
|
||||
LogTool log = new LogTool("/log/working/sign",false);
|
||||
String clientId = Prop.getPropValue("db_work","clientId");
|
||||
String secret = Prop.getPropValue("db_work","secret");
|
||||
Integer second = Integer.valueOf(Prop.getPropValue("db_work","second"));
|
||||
String code = Prop.getPropValue("db_work","code");
|
||||
String moduleCode = Prop.getPropValue("db_work","moduleCode");
|
||||
String batchCardDataUrl = Prop.getPropValue("db_work","batchCardDataUrl");
|
||||
log.writeLog("同步人员移动端考勤信息更新到东宝系统开始.clientId="+clientId+";secret="+secret+";second="+second
|
||||
+";code="+code+";moduleCode="+moduleCode+";batchCardDataUrl="+batchCardDataUrl);
|
||||
String token = JwtUtil.createThirdToken(clientId,secret,second).getToken();
|
||||
Map<String,String> dataMap = new HashMap<String,String>();//保存数据id和员工编号的集合
|
||||
Map headMap = new HashMap();
|
||||
headMap.put("code",code);
|
||||
headMap.put("moduleCode",moduleCode);
|
||||
headMap.put("token",token);
|
||||
headMap.put("clientId",clientId);
|
||||
Map bodyMap2 = new HashMap();
|
||||
Map bodyMap3 = new HashMap();
|
||||
List list = new ArrayList();//存储打卡数据
|
||||
List idList = new ArrayList();//存储数据id
|
||||
|
||||
RecordSet rs = new RecordSet();
|
||||
RecordSet rs1 = new RecordSet();
|
||||
String id = "";//移动签到id
|
||||
String workCode = "";//人员编号
|
||||
String operater = "";//签到人id
|
||||
String operateDate = "";//签到日期
|
||||
String operateTime = "";//签到时间
|
||||
String longitude = "";//经度
|
||||
String latitude = "";//纬度
|
||||
String address = "";//地址
|
||||
String remark = "";//签到备注
|
||||
//查询考勤数据
|
||||
String datasource = rs.getDBType();
|
||||
log.writeLog("datasource="+datasource);
|
||||
if ("oracle".equals(datasource)) {
|
||||
rs.execute("select * from mobile_sign where syn_flag != 2 order by operate_date desc");
|
||||
} else if ("sqlserver".equals(datasource)) {
|
||||
rs.execute("select * from mobile_sign where syn_flag != 2 order by operate_date desc");
|
||||
}
|
||||
//取到考勤数据,调用同步接口
|
||||
while (rs.next()) {
|
||||
Map bodyMap = new HashMap();
|
||||
Map bodyMap1 = new HashMap();
|
||||
id = Util.null2String(rs.getInt("ID"));
|
||||
idList.add(id);
|
||||
operater = Util.null2String(rs.getString("OPERATER"));
|
||||
workCode = Util.null2String(WorkflowUtil.getUserInfo(operater).get("workcode"));
|
||||
dataMap.put(id, workCode);
|
||||
operateDate = Util.null2String(rs.getString("OPERATE_DATE"));
|
||||
operateTime = Util.null2String(rs.getString("OPERATE_TIME"));
|
||||
longitude = Util.null2String(rs.getString("LONGITUDE"));
|
||||
latitude = Util.null2String(rs.getString("LATITUDE"));
|
||||
address = Util.null2String(rs.getString("ADDRESS"));
|
||||
remark = Util.null2String(rs.getString("REMARK"));
|
||||
// log.writeLog("id="+id+";workCode="+workCode+";operater="+operater+";operateDate="+operateDate+";operateTime="+operateTime
|
||||
// +";longitude="+longitude+";latitude="+latitude+";address="+address+";remark="+remark);
|
||||
bodyMap.put("cardTime", operateDate + " " +operateTime);
|
||||
bodyMap.put("dataSource", "8");
|
||||
bodyMap.put("signPlace", address);
|
||||
bodyMap.put("status", "1");
|
||||
bodyMap.put("longitude", longitude);
|
||||
bodyMap.put("latitude", latitude);
|
||||
bodyMap.put("describe", remark);
|
||||
bodyMap.put("timeZone", "GMT+8");
|
||||
bodyMap1.put("empRule","1");
|
||||
bodyMap1.put("empKey",workCode);
|
||||
bodyMap1.put("cardData",bodyMap);
|
||||
//查询所有数据放入集合
|
||||
list.add(bodyMap1);
|
||||
}
|
||||
// bodyMap2.put("empOrders", list);
|
||||
bodyMap3.put("header",headMap);
|
||||
bodyMap3.put("body",bodyMap2);
|
||||
try {
|
||||
if (list.size()>0) {
|
||||
//循环次数,每次传输1000条数据
|
||||
int num = list.size()/1000+1;
|
||||
for (int i=0;i<=num;i++) {
|
||||
//初始化传输的list
|
||||
List listSign = new ArrayList();
|
||||
List listSignId = new ArrayList();
|
||||
for (int j=i*1000;j<(i+1)*1000;j++) {
|
||||
if (j>=list.size()) {//超出list的下标,跳出循环
|
||||
break;
|
||||
}
|
||||
listSign.add(list.get(j));
|
||||
listSignId.add(idList.get(j));
|
||||
}
|
||||
if (listSign.size() ==0) {
|
||||
continue;
|
||||
} else {
|
||||
bodyMap2.put("empOrders", listSign);
|
||||
}
|
||||
String param = JSON.toJSONString(bodyMap3,SerializerFeature.DisableCircularReferenceDetect);
|
||||
// log.writeLog("param="+param);
|
||||
String result = HttpManager.postMap(batchCardDataUrl,headMap,param);
|
||||
log.writeLog("result="+result);
|
||||
//解析返回值result
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
//解析JOSN
|
||||
jsonObject = JSONObject.parseObject(result);
|
||||
String returnCode = Util.null2String(jsonObject.get("code"));
|
||||
String data = Util.null2String(jsonObject.get("data"));
|
||||
if ("200".equals(returnCode)) {//同步成功(可能存在部分数据失败)
|
||||
//先全部更新为同步成功
|
||||
log.writeLog("sql1="+"update mobile_sign set syn_flag = 2 where id in ("+listSignId.toString().replace("[", "'").replace("]", "'").replace(",", "','")+")");
|
||||
rs1.execute("update mobile_sign set syn_flag = 2 where id in ("+listSignId.toString().replace("[", "'").replace("]", "'").replace(",", "','")+")");
|
||||
if (!data.isEmpty()) {//有更新失败的
|
||||
//解析返回值data
|
||||
JSONObject dataObject = new JSONObject();
|
||||
dataObject = JSONObject.parseObject(data);
|
||||
String key = "";//返回的错误的数据的员工编号
|
||||
String mapKey = "";//保存map的key
|
||||
String mapValue = "";//保存map的value
|
||||
Iterator<String> dataIterator = dataObject.keySet().iterator();
|
||||
Iterator<String> dataMapIter = dataMap.keySet().iterator();
|
||||
while (dataIterator.hasNext()) {
|
||||
// 获得key
|
||||
key = dataIterator.next();
|
||||
while (dataMapIter.hasNext()) {
|
||||
mapKey = dataMapIter.next();
|
||||
mapValue = dataMap.get(mapKey);
|
||||
if (key.equals(mapValue)) {
|
||||
//更新为同步失败
|
||||
rs1.executeQuery("update mobile_sign set syn_flag = 1 where id = ?", mapKey);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {//同步异常,更新这批数据为同步失败
|
||||
rs1.executeQuery("update mobile_sign set syn_flag = 1 where id in (?)", listSignId.toString().replace("[", "'").replace("]", "'").replace(",", "','"));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
log.writeLog("此次查询无符合数据!");
|
||||
}
|
||||
} catch (HttpException e) {
|
||||
// TODO Auto-generated catch block
|
||||
log.writeLog("HttpException="+e.toString());
|
||||
e.printStackTrace();
|
||||
} catch (IOException e) {
|
||||
// TODO Auto-generated catch block
|
||||
log.writeLog("IOException="+e.toString());
|
||||
e.printStackTrace();
|
||||
} catch (Exception e) {
|
||||
log.writeLog("Exception="+e.toString());
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
log.writeLog("同步人员移动端考勤信息更新到东宝系统结束.");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
package com.working.schedule;
|
||||
|
||||
import com.working.util.LogTool;
|
||||
import weaver.interfaces.schedule.BaseCronJob;
|
||||
|
||||
/**
|
||||
* 考勤同步数据总的定时器
|
||||
* @author lwt
|
||||
*
|
||||
*/
|
||||
public class WorkingTimer extends BaseCronJob{
|
||||
|
||||
public void execute() {
|
||||
LogTool log = new LogTool("/log/working",false);
|
||||
log.writeLog("考勤总的同步定时开始.");
|
||||
SynSignDatas ssd = new SynSignDatas();
|
||||
ssd.execute();
|
||||
SynScheduleSignDatas sssd = new SynScheduleSignDatas();
|
||||
sssd.execute();
|
||||
log.writeLog("考勤总的同步定时结束.");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,35 @@
|
|||
package com.working.test;
|
||||
|
||||
import java.security.cert.CertificateException;
|
||||
import java.security.cert.X509Certificate;
|
||||
import javax.net.ssl.SSLContext;
|
||||
import javax.net.ssl.TrustManager;
|
||||
import javax.net.ssl.X509TrustManager;
|
||||
import org.apache.http.conn.ClientConnectionManager;
|
||||
import org.apache.http.conn.scheme.Scheme;
|
||||
import org.apache.http.conn.scheme.SchemeRegistry;
|
||||
import org.apache.http.conn.ssl.SSLSocketFactory;
|
||||
import org.apache.http.impl.client.DefaultHttpClient;
|
||||
//用于进行Https请求的HttpClient
|
||||
public class SSLClient extends DefaultHttpClient{
|
||||
public SSLClient() throws Exception{
|
||||
super();
|
||||
SSLContext ctx = SSLContext.getInstance("TLS");
|
||||
X509TrustManager tm = new X509TrustManager() {
|
||||
public void checkClientTrusted(X509Certificate[] chain,
|
||||
String authType) throws CertificateException {
|
||||
}
|
||||
public void checkServerTrusted(X509Certificate[] chain,
|
||||
String authType) throws CertificateException {
|
||||
}
|
||||
public X509Certificate[] getAcceptedIssuers() {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
ctx.init(null, new TrustManager[]{tm}, null);
|
||||
SSLSocketFactory ssf = new SSLSocketFactory(ctx,SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
|
||||
ClientConnectionManager ccm = this.getConnectionManager();
|
||||
SchemeRegistry sr = ccm.getSchemeRegistry();
|
||||
sr.register(new Scheme("https", 443, ssf));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,82 @@
|
|||
package com.working.test;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.serializer.SerializerFeature;
|
||||
import com.working.third.JwtUtil;
|
||||
import com.working.util.HttpManager;
|
||||
|
||||
public class Test {
|
||||
|
||||
/**
|
||||
* 单个接口
|
||||
* @param args
|
||||
* @throws Exception
|
||||
*/
|
||||
public static void main(String[] args) throws Exception {
|
||||
// TODO Auto-generated method stub
|
||||
try {
|
||||
String token = JwtUtil.createThirdToken("P3F28BIFKGFL0ANX","5UGY7G1N8O",36000).getToken();
|
||||
// System.out.println(token);
|
||||
String param =
|
||||
"{"+
|
||||
"\"header\":{"+
|
||||
"\"code\":\"saveCardDataToThird\","+
|
||||
"\"moduleCode\":\"attCardDataService\","+
|
||||
"\"token\":\""+token+"\","+
|
||||
"\"clientId\":\"P3F28BIFKGFL0ANX\","+
|
||||
"\"empRule\":\"1\","+
|
||||
"\"empInfo\":\"00000775\""+
|
||||
"},"+
|
||||
"\"body\":{"+
|
||||
"\"cardData\":{"+
|
||||
"\"cardTime\":\"\","+
|
||||
"\"dataSource\":\"8\","+
|
||||
"\"signPlace\":\"上海市王者村\","+
|
||||
"\"status\":\"1\","+
|
||||
"\"longitude\":\"121.45787447\","+
|
||||
"\"latitude\":\"124.54444411\","+
|
||||
"\"orderId\":\"1168801193654599682\","+
|
||||
"\"orderCode\":\"BT20190903000204\","+
|
||||
"\"describe\":\"移动签到测试\","+
|
||||
"\"timeZone\":\"\""+
|
||||
"}"+
|
||||
"}"+
|
||||
"}";
|
||||
Map headMap = new HashMap();
|
||||
headMap.put("code","saveCardDataToThird");
|
||||
headMap.put("moduleCode","attCardDataService");
|
||||
headMap.put("token",token);
|
||||
headMap.put("clientId","P3F28BIFKGFL0ANX");
|
||||
headMap.put("empRule","1");
|
||||
headMap.put("empInfo","00000775");
|
||||
Map bodyMap = new HashMap();
|
||||
Map bodyMap1 = new HashMap();
|
||||
Map bodyMap2 = new HashMap();
|
||||
bodyMap.put("cardTime", "");
|
||||
bodyMap.put("dataSource", "8");
|
||||
bodyMap.put("signPlace", "上海市王者村");
|
||||
bodyMap.put("status", "1");
|
||||
bodyMap.put("longitude", "121.45787447");
|
||||
bodyMap.put("latitude", "124.54444411");
|
||||
bodyMap.put("orderId", "1168801193654599682");
|
||||
bodyMap.put("orderCode", "BT20190903000204");
|
||||
bodyMap.put("describe", "移动签到测试");
|
||||
bodyMap.put("timeZone", "GMT+8");
|
||||
bodyMap1.put("cardData",bodyMap);
|
||||
bodyMap2.put("header",headMap);
|
||||
bodyMap2.put("body",bodyMap1);
|
||||
param = JSON.toJSONString(bodyMap2,SerializerFeature.DisableCircularReferenceDetect);
|
||||
System.out.println(param);
|
||||
String result = HttpManager.postMap("https://hr.jtexpress.com:9022/third/api",headMap,param);
|
||||
System.out.println(result);
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,63 @@
|
|||
package com.working.test;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.serializer.SerializerFeature;
|
||||
import com.working.third.JwtUtil;
|
||||
import com.working.util.HttpManager;
|
||||
|
||||
public class Test1 {
|
||||
|
||||
/**
|
||||
* 批量接口
|
||||
* @param args
|
||||
* @throws Exception
|
||||
*/
|
||||
public static void main(String[] args) throws Exception {
|
||||
// TODO Auto-generated method stub
|
||||
try {
|
||||
String token = JwtUtil.createThirdToken("P3F28BIFKGFL0ANX","5UGY7G1N8O",36000).getToken();
|
||||
// System.out.println(token);
|
||||
Map headMap = new HashMap();
|
||||
headMap.put("code","saveBatchCardDataToThird");
|
||||
headMap.put("moduleCode","attCardDataService");
|
||||
headMap.put("token",token);
|
||||
headMap.put("clientId","P3F28BIFKGFL0ANX");
|
||||
Map bodyMap2 = new HashMap();
|
||||
Map bodyMap3 = new HashMap();
|
||||
List list = new ArrayList();
|
||||
for (int i=0;i<=2;i++) {
|
||||
Map bodyMap = new HashMap();
|
||||
Map bodyMap1 = new HashMap();
|
||||
bodyMap.put("cardTime", "2019-07-20 13:22:13");
|
||||
bodyMap.put("dataSource", "8");
|
||||
bodyMap.put("signPlace", "上海市王者村");
|
||||
bodyMap.put("status", "1");
|
||||
bodyMap.put("longitude", "121.45787447");
|
||||
bodyMap.put("latitude", "124.54444411");
|
||||
bodyMap.put("describe", "移动签到测试");
|
||||
bodyMap.put("timeZone", "GMT+8");
|
||||
bodyMap1.put("empRule","1");
|
||||
bodyMap1.put("empKey","00000006");
|
||||
bodyMap1.put("cardData",bodyMap);
|
||||
list.add(bodyMap1);
|
||||
}
|
||||
bodyMap2.put("empOrders", list);
|
||||
bodyMap3.put("header",headMap);
|
||||
bodyMap3.put("body",bodyMap2);
|
||||
String param = JSON.toJSONString(bodyMap3,SerializerFeature.DisableCircularReferenceDetect);
|
||||
System.out.println(param);
|
||||
String result = HttpManager.postMap("https://hr.jtexpress.com:9022/third/api",headMap,param);
|
||||
System.out.println(result);
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,47 @@
|
|||
package com.working.test;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.alibaba.fastjson.serializer.SerializerFeature;
|
||||
import com.working.third.JwtUtil;
|
||||
import com.working.util.HttpManager;
|
||||
|
||||
public class Test2 {
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
// TODO Auto-generated method stub
|
||||
//解析JOSN()
|
||||
Map map = new HashMap();
|
||||
map.put("deptCode", "01010101");
|
||||
map.put("bmfzr", "00000001");
|
||||
map.put("bmfgld", "");
|
||||
String json = JSON.toJSONString(map);
|
||||
System.out.println(json);
|
||||
// List<String> list = new ArrayList<String>();
|
||||
// System.out.println(list);
|
||||
// JSONObject jsonObject = new JSONObject();
|
||||
// //解析JOSN
|
||||
// jsonObject = JSONObject.parseObject(json);
|
||||
// String bmfzr = jsonObject.getString("bmfzr");
|
||||
// System.out.println(bmfzr.isEmpty());
|
||||
|
||||
// Map comMap = new HashMap();
|
||||
// comMap.put("subComCode", "JTyn");
|
||||
// comMap.put("cwsh", "389,390");
|
||||
// comMap.put("zzcw", "412,413");
|
||||
// comMap.put("cwzj", "MSIL15,MSIL47");
|
||||
// comMap.put("ceozjl", "MSIL15,MSIL47");
|
||||
// comMap.put("cn", "389,390");
|
||||
// comMap.put("cnfh", "MSIL15,MSIL47");
|
||||
// comMap.put("zjbfzr", "412,413");
|
||||
// String comJson = JSON.toJSONString(comMap);
|
||||
// System.out.println(comJson);
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
package com.working.test;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
import weaver.general.Util;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
|
||||
public class Test3 {
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
// String json = "{\"code\":200,\"data\":{\"123000007701\":\"用户信息为空\",\"12300000770\":\"用户信息为空\",\"1230000077012\":\"用户信息为空\"},\"id\":\"\",\"list\":[],\"message\":\"操作成功\",\"rows\":null}";
|
||||
// //解析返回值result
|
||||
// JSONObject jsonObject = new JSONObject();
|
||||
// //解析JOSN
|
||||
// jsonObject = JSONObject.parseObject(json);
|
||||
// String returnCode = Util.null2String(jsonObject.getString("code"));
|
||||
// String data = Util.null2String(jsonObject.getString("data"));
|
||||
// JSONObject dataObject = jsonObject.parseObject(data);
|
||||
// String key = "";
|
||||
// Iterator<String> entry = dataObject.keySet().iterator();
|
||||
// while(entry.hasNext()){
|
||||
// // 获得key
|
||||
// key = entry.next();
|
||||
// System.out.println(key);
|
||||
// }
|
||||
String code = "01091138";
|
||||
System.out.println(code.substring(0, 6));
|
||||
System.out.println(code.length());
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
package com.working.test;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
import weaver.general.Util;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
|
||||
public class Test4 {
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
StringBuffer a = new StringBuffer();
|
||||
a.append("'").append("'");
|
||||
System.out.println(a);
|
||||
System.out.println(a.toString().equals("''"));
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
package com.working.third;
|
||||
|
||||
public class JwtThirdTokenResult extends JwtTokenResult{
|
||||
|
||||
public JwtThirdTokenResult(String token) {
|
||||
super(token);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
package com.working.third;
|
||||
|
||||
public class JwtTokenResult {
|
||||
|
||||
public JwtTokenResult(String token){
|
||||
this.token = token;
|
||||
}
|
||||
|
||||
private String token;
|
||||
private Long expires = 7200L;
|
||||
|
||||
public String getToken(){
|
||||
return token;
|
||||
}
|
||||
|
||||
public Long getExpires(){
|
||||
return expires;
|
||||
}
|
||||
|
||||
public Boolean IsSuccess(){
|
||||
return token != null;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,60 @@
|
|||
package com.working.third;
|
||||
|
||||
import com.auth0.jwt.JWT;
|
||||
import com.auth0.jwt.JWTVerifier;
|
||||
import com.auth0.jwt.algorithms.Algorithm;
|
||||
import com.auth0.jwt.interfaces.Claim;
|
||||
import com.auth0.jwt.interfaces.DecodedJWT;
|
||||
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.GregorianCalendar;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class JwtUtil {
|
||||
|
||||
private static final String SECRET = "5UGY7G1N8O";
|
||||
|
||||
/**
|
||||
* 生成token
|
||||
* @param secret
|
||||
* @param second
|
||||
* @return
|
||||
*/
|
||||
public static JwtThirdTokenResult createThirdToken(String clientId,String secret,int second){
|
||||
try {
|
||||
Algorithm algorithm = Algorithm.HMAC256(secret);
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
|
||||
map.put("alg", "HS256");
|
||||
map.put("typ", "JWT");
|
||||
Date nowDate = new Date();
|
||||
Calendar cal = new GregorianCalendar();
|
||||
cal.setTime(nowDate);
|
||||
cal.add(Calendar.SECOND, -3600);
|
||||
nowDate = cal.getTime();
|
||||
|
||||
cal = new GregorianCalendar();
|
||||
cal.setTime(nowDate);
|
||||
cal.add(Calendar.SECOND, second);
|
||||
|
||||
Date expireDate = cal.getTime();
|
||||
String token = JWT.create()
|
||||
.withHeader(map)
|
||||
.withClaim("clientId", clientId)
|
||||
.withIssuer("DbSsoServer")
|
||||
.withSubject("DbSso_AccessToken")
|
||||
.withAudience("Web")
|
||||
.withIssuedAt(nowDate)
|
||||
.withExpiresAt(expireDate)
|
||||
.sign(algorithm);
|
||||
return new JwtThirdTokenResult(token);
|
||||
|
||||
} catch (Exception exception){
|
||||
exception.printStackTrace();
|
||||
}
|
||||
return new JwtThirdTokenResult(null);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,49 @@
|
|||
package com.working.util;
|
||||
|
||||
import weaver.conn.RecordSet;
|
||||
import weaver.general.Util;
|
||||
import weaver.soa.workflow.request.RequestInfo;
|
||||
|
||||
public class ActionUtil {
|
||||
|
||||
/**
|
||||
* 通过请求id获得流程基本参数
|
||||
* @param requsetid
|
||||
* @return
|
||||
*/
|
||||
public static WAction getMainTable(RequestInfo requestInfo){
|
||||
WAction action=new WAction();
|
||||
String requestid = Util.getIntValue(requestInfo.getRequestid())+"";
|
||||
String workflowId = requestInfo.getWorkflowid();
|
||||
RecordSet rs0 = new RecordSet();
|
||||
rs0.execute("select formid from workflow_base where id in(select workflowid from workflow_requestbase where requestid='"+requestid+"')");
|
||||
String mainTabName="";
|
||||
String formid="";
|
||||
if(rs0.next()){
|
||||
formid=Util.null2String(rs0.getString("formid").replace("-", ""));
|
||||
mainTabName="formtable_main_"+formid;
|
||||
}
|
||||
action.setRequestid(requestid);
|
||||
action.setFormid(formid);
|
||||
action.setMainTabName(mainTabName);
|
||||
action.setWorkflowId(workflowId);
|
||||
return action;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得流程主表的id
|
||||
* @param tableName
|
||||
* @param requestid
|
||||
* @return
|
||||
*/
|
||||
public static String getMainId(String tableName,String requestid){
|
||||
RecordSet rsRecordSet = new RecordSet();
|
||||
String sql=" select id from "+tableName+" where requestid='"+requestid+"' ";
|
||||
rsRecordSet.execute(sql);
|
||||
if(rsRecordSet.next()){
|
||||
return rsRecordSet.getString("id");
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue