|
@@ -414,6 +414,209 @@ public class SaleOrderService {
|
|
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
+ * 钉钉创建销售订单审批实列
|
|
|
+ * @param processCode
|
|
|
+ * @param agentid
|
|
|
+ * @param userid 发起人
|
|
|
+ * @param deptid 部门
|
|
|
+ * @param map 数据
|
|
|
+ * @throws ApiException
|
|
|
+ */
|
|
|
+ public Object createOrder2(String processCode, Long agentid, String userid, Long deptid, YonyouSaleOrder so,String data) throws ApiException {
|
|
|
+ String useridshenh = prop.getProperty("shenhe_userid");
|
|
|
+ DingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/topapi/processinstance/create");
|
|
|
+ OapiProcessinstanceCreateRequest req = new OapiProcessinstanceCreateRequest();
|
|
|
+ req.setAgentId(agentid);
|
|
|
+ req.setProcessCode(processCode);
|
|
|
+ req.setOriginatorUserId(userid);
|
|
|
+ req.setDeptId(deptid);
|
|
|
+ req.setCcPosition("START");
|
|
|
+ BigDecimal countSum=new BigDecimal("0");
|
|
|
+ if (!useridshenh.equals("")){
|
|
|
+ List<OapiProcessinstanceCreateRequest.ProcessInstanceApproverVo> processInstanceApproverVoList = new ArrayList<OapiProcessinstanceCreateRequest.ProcessInstanceApproverVo>();
|
|
|
+ OapiProcessinstanceCreateRequest.ProcessInstanceApproverVo processInstanceApproverVo = new OapiProcessinstanceCreateRequest.ProcessInstanceApproverVo();
|
|
|
+ processInstanceApproverVoList.add(processInstanceApproverVo);
|
|
|
+ processInstanceApproverVo.setTaskActionType("NONE");
|
|
|
+ processInstanceApproverVo.setUserIds(Arrays.asList(useridshenh));
|
|
|
+ req.setApproversV2(processInstanceApproverVoList);
|
|
|
+ }
|
|
|
+ if (so!=null){
|
|
|
+ List<OapiProcessinstanceCreateRequest.FormComponentValueVo> formComponentValueVoList = new ArrayList<OapiProcessinstanceCreateRequest.FormComponentValueVo>();
|
|
|
+ OapiProcessinstanceCreateRequest.FormComponentValueVo formComponentValueVo = new OapiProcessinstanceCreateRequest.FormComponentValueVo();
|
|
|
+ formComponentValueVo.setName("业务类型");
|
|
|
+ if(so.getBusinesstype()!=null&&!so.getBusinesstype().equals("")){
|
|
|
+ formComponentValueVo.setValue(so.getBusinesstype());
|
|
|
+ }else {
|
|
|
+ formComponentValueVo.setValue("暂无");
|
|
|
+ }
|
|
|
+ formComponentValueVoList.add(formComponentValueVo);
|
|
|
+
|
|
|
+ OapiProcessinstanceCreateRequest.FormComponentValueVo fc = new OapiProcessinstanceCreateRequest.FormComponentValueVo();
|
|
|
+ fc.setName("订单日期");
|
|
|
+ fc.setValue(so.getDate());
|
|
|
+ formComponentValueVoList.add(fc);
|
|
|
+
|
|
|
+ OapiProcessinstanceCreateRequest.FormComponentValueVo fc2 = new OapiProcessinstanceCreateRequest.FormComponentValueVo();
|
|
|
+ fc2.setName("单据编号");
|
|
|
+ fc2.setValue(so.getCode());
|
|
|
+ fc2.setExtValue(data);
|
|
|
+ formComponentValueVoList.add(fc2);
|
|
|
+
|
|
|
+ OapiProcessinstanceCreateRequest.FormComponentValueVo fc3 = new OapiProcessinstanceCreateRequest.FormComponentValueVo();
|
|
|
+ fc3.setName("客户名称");
|
|
|
+ if(so.getCusname()!=null&&!so.getCusname().equals("")){
|
|
|
+ fc3.setValue(so.getCusname());
|
|
|
+ }else {
|
|
|
+ fc3.setValue("暂无");
|
|
|
+ }
|
|
|
+ formComponentValueVoList.add(fc3);
|
|
|
+
|
|
|
+ OapiProcessinstanceCreateRequest.FormComponentValueVo fc4 = new OapiProcessinstanceCreateRequest.FormComponentValueVo();
|
|
|
+ fc4.setName("下单部门");
|
|
|
+ if(so.getDeptname()!=null&&!so.getDeptname().equals("")){
|
|
|
+ fc4.setValue(so.getDeptname());
|
|
|
+ }else {
|
|
|
+ fc4.setValue("暂无");
|
|
|
+ }
|
|
|
+ formComponentValueVoList.add(fc4);
|
|
|
+
|
|
|
+ OapiProcessinstanceCreateRequest.FormComponentValueVo fc5 = new OapiProcessinstanceCreateRequest.FormComponentValueVo();
|
|
|
+ fc5.setName("业务员");
|
|
|
+ if(so.getPersonname()!=null&&!so.getPersonname().equals("")){
|
|
|
+ fc5.setValue(so.getPersonname());
|
|
|
+ }else {
|
|
|
+ fc5.setValue("暂无");
|
|
|
+ }
|
|
|
+ formComponentValueVoList.add(fc5);
|
|
|
+
|
|
|
+
|
|
|
+ List<List<OapiProcessinstanceCreateRequest.FormComponentValueVo>>ls=new ArrayList<>();
|
|
|
+
|
|
|
+ for (YonyouMaterial s:so.getentry()){
|
|
|
+ List<OapiProcessinstanceCreateRequest.FormComponentValueVo>mingxilist=new ArrayList<>();
|
|
|
+ OapiProcessinstanceCreateRequest.FormComponentValueVo sot = new OapiProcessinstanceCreateRequest.FormComponentValueVo();
|
|
|
+ sot.setName("存货编码");
|
|
|
+ if(s.getInventorycode()!=null&&!s.getInventorycode().equals("")){
|
|
|
+ sot.setValue(s.getInventorycode());
|
|
|
+ }else{
|
|
|
+ sot.setValue("暂无");
|
|
|
+ }
|
|
|
+ mingxilist.add(sot);
|
|
|
+ OapiProcessinstanceCreateRequest.FormComponentValueVo mingxi2 = new OapiProcessinstanceCreateRequest.FormComponentValueVo();
|
|
|
+ mingxi2.setName("存货名称");
|
|
|
+ if(s.getInventoryname()!=null&&!s.getInventoryname().equals("")){
|
|
|
+ mingxi2.setValue(s.getInventoryname());
|
|
|
+ }else {
|
|
|
+ mingxi2.setValue("暂无");
|
|
|
+ }
|
|
|
+ mingxilist.add(mingxi2);
|
|
|
+
|
|
|
+ OapiProcessinstanceCreateRequest.FormComponentValueVo sot2 = new OapiProcessinstanceCreateRequest.FormComponentValueVo();
|
|
|
+ sot2.setName("单位");
|
|
|
+ if(s.getUnitname()!=null&&!s.getUnitname().equals("")){
|
|
|
+ sot2.setValue(s.getUnitname());
|
|
|
+ }else{
|
|
|
+ sot2.setValue("暂无");
|
|
|
+ }
|
|
|
+ mingxilist.add(sot2);
|
|
|
+
|
|
|
+ OapiProcessinstanceCreateRequest.FormComponentValueVo fc7 = new OapiProcessinstanceCreateRequest.FormComponentValueVo();
|
|
|
+ fc7.setName("单价(含税)");
|
|
|
+ if(s.getTaxunitprice()!=null&&!s.getTaxunitprice().equals("0E-10")){
|
|
|
+ fc7.setValue(s.getTaxunitprice());
|
|
|
+ }else {
|
|
|
+ fc7.setValue("0");
|
|
|
+ }
|
|
|
+ mingxilist.add(fc7);
|
|
|
+
|
|
|
+ OapiProcessinstanceCreateRequest.FormComponentValueVo fc8 = new OapiProcessinstanceCreateRequest.FormComponentValueVo();
|
|
|
+ fc8.setName("订购数量");
|
|
|
+ if(s.getQuantity()!=null&&!s.getQuantity().equals("")){
|
|
|
+ fc8.setValue(s.getQuantity());
|
|
|
+ }else {
|
|
|
+ fc8.setValue("0");
|
|
|
+ }
|
|
|
+ mingxilist.add(fc8);
|
|
|
+
|
|
|
+
|
|
|
+ OapiProcessinstanceCreateRequest.FormComponentValueVo fc12= new OapiProcessinstanceCreateRequest.FormComponentValueVo();
|
|
|
+ fc12.setName("总金额(含税)");
|
|
|
+ if(s.getSum()!=null&&!s.getSum().equals("0E-10")){
|
|
|
+ countSum=countSum.add(new BigDecimal(s.getSum()));
|
|
|
+ fc12.setValue(s.getSum());
|
|
|
+ }else {
|
|
|
+ fc12.setValue("0");
|
|
|
+ }
|
|
|
+ mingxilist.add(fc12);
|
|
|
+
|
|
|
+ OapiProcessinstanceCreateRequest.FormComponentValueVo fc13= new OapiProcessinstanceCreateRequest.FormComponentValueVo();
|
|
|
+ fc13.setName("预计交期");
|
|
|
+ if (s.getDefine23()!=null&&!s.getDefine23().equals("")){
|
|
|
+ fc13.setValue(s.getDefine23());
|
|
|
+ }else {
|
|
|
+ fc13.setValue(so.getDpredatebt());
|
|
|
+ }
|
|
|
+
|
|
|
+ mingxilist.add(fc13);
|
|
|
+
|
|
|
+
|
|
|
+ OapiProcessinstanceCreateRequest.FormComponentValueVo je= new OapiProcessinstanceCreateRequest.FormComponentValueVo();
|
|
|
+ je.setName("收货人姓名及联系电话");
|
|
|
+ String n="暂无";
|
|
|
+ if(so.getDefine8()!=null&&!so.getDefine8().equals("")){
|
|
|
+ n=so.getDefine8();
|
|
|
+ }if (so.getDefine13()!=null&&!so.getDefine13().equals("")){
|
|
|
+ n=so.getDefine13();
|
|
|
+ }if (so.getDefine13()!=null&&so.getDefine8()!=null){
|
|
|
+ n=so.getDefine8()+":"+so.getDefine13();
|
|
|
+ }
|
|
|
+ je.setValue(n);
|
|
|
+ mingxilist.add(je);
|
|
|
+
|
|
|
+ OapiProcessinstanceCreateRequest.FormComponentValueVo je2= new OapiProcessinstanceCreateRequest.FormComponentValueVo();
|
|
|
+ je2.setName("到货地址");
|
|
|
+ if (so.getSendaddress()!=null&&!so.getSendaddress().equals("")){
|
|
|
+ je2.setValue(so.getSendaddress());
|
|
|
+ }else {
|
|
|
+ je2.setValue("暂无");
|
|
|
+ }
|
|
|
+ mingxilist.add(je2);
|
|
|
+
|
|
|
+
|
|
|
+ OapiProcessinstanceCreateRequest.FormComponentValueVo je3= new OapiProcessinstanceCreateRequest.FormComponentValueVo();
|
|
|
+ je3.setName("备注");
|
|
|
+ if (so.getMemo()!=null&&!so.getMemo().equals("")){
|
|
|
+ je3.setValue(so.getMemo());
|
|
|
+ }else {
|
|
|
+ je3.setValue("暂无");
|
|
|
+ }
|
|
|
+ mingxilist.add(je3);
|
|
|
+
|
|
|
+ ls.add(mingxilist);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ OapiProcessinstanceCreateRequest.FormComponentValueVo obj7 = new OapiProcessinstanceCreateRequest.FormComponentValueVo();
|
|
|
+ obj7.setName("表格");
|
|
|
+ obj7.setValue(JSON.toJSONString(ls));
|
|
|
+ formComponentValueVoList.add(obj7);
|
|
|
+
|
|
|
+ req.setFormComponentValues(formComponentValueVoList);
|
|
|
+ dingdingOpenInterface.getToken();
|
|
|
+ OapiProcessinstanceCreateResponse rsp = client.execute(req, dingdingOpenInterface.gettoken);
|
|
|
+ System.out.println(rsp.getBody());
|
|
|
+ String code = rsp.getErrorCode();
|
|
|
+ if (code.equals("0")||code.equals(0)){
|
|
|
+ return rsp.getProcessInstanceId();
|
|
|
+ }else {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
/**
|
|
|
* 销售发货单
|
|
|
* @param
|