diff --git a/main/java/shkd/repc/recon/formplugin/ContractFormPlugin.java b/main/java/shkd/repc/recon/formplugin/ContractFormPlugin.java index ab66c2f..229d0e0 100644 --- a/main/java/shkd/repc/recon/formplugin/ContractFormPlugin.java +++ b/main/java/shkd/repc/recon/formplugin/ContractFormPlugin.java @@ -193,7 +193,7 @@ public class ContractFormPlugin extends AbstractFormPlugin implements UploadLis //删除单据体数据 qeug_invoiceentryinfos.clear(); - SaveServiceHelper.save(new DynamicObject[]{this.getModel().getDataEntity()}); + SaveServiceHelper.save(new DynamicObject[]{this.getModel().getDataEntity(true)}); // 删除完成之后刷新界面 this.getView().invokeOperation("refresh"); return result; @@ -547,8 +547,9 @@ public class ContractFormPlugin extends AbstractFormPlugin implements UploadLis QFilter q1 = new QFilter("qeug_sheetname", QCP.equals, qeug_summarycontent); QFilter q2 = new QFilter("qeug_contractid",QCP.equals, String.valueOf(pkValue)); + QFilter q3 = new QFilter("qeug_workloadcfmid",QCP.equals, ""); List listQF = Lists.newArrayList(); - listQF.add(q1.and(q2)); + listQF.add(q1.and(q2).and(q3)); parameter.setListFilterParameter(new ListFilterParameter(listQF, null)); this.getView().showForm(parameter); } diff --git a/main/java/shkd/repc/recon/formplugin/WorkloadcfmbillFormPlugin.java b/main/java/shkd/repc/recon/formplugin/WorkloadcfmbillFormPlugin.java index 3066a48..310d56c 100644 --- a/main/java/shkd/repc/recon/formplugin/WorkloadcfmbillFormPlugin.java +++ b/main/java/shkd/repc/recon/formplugin/WorkloadcfmbillFormPlugin.java @@ -20,11 +20,13 @@ import kd.bos.orm.query.QCP; import kd.bos.orm.query.QFilter; import kd.bos.servicehelper.BusinessDataServiceHelper; import kd.bos.servicehelper.operation.SaveServiceHelper; +import kd.bos.util.StringUtils; import kd.scm.pds.common.util.OpenFormUtils; import org.apache.cxf.Bus; import java.math.BigDecimal; import java.util.EventObject; +import java.util.HashMap; import java.util.List; import java.util.Map; @@ -88,6 +90,7 @@ public class WorkloadcfmbillFormPlugin extends AbstractFormPlugin implements Tab // QFilter q1 = new QFilter("qeug_sheetname", QCP.equals, qeug_summarycontent); QFilter q2 = new QFilter("qeug_contractid",QCP.equals, contentId); + QFilter q3 = new QFilter("qeug_workloadcfmid",QCP.equals,String.valueOf(this.getModel().getDataEntity().getPkValue())); // List listQF = Lists.newArrayList(); // listQF.add(q1.and(q2)); // parameter.setListFilterParameter(new ListFilterParameter(listQF, null)); @@ -96,7 +99,9 @@ public class WorkloadcfmbillFormPlugin extends AbstractFormPlugin implements Tab // parameter.setStatus(OperationStatus.ADDNEW); // this.getView().showForm(parameter); // OpenFormUtils.openListPage(); - OpenFormUtils.openListPage(this.getView(), "qeug_contractsummarylist", ShowType.MainNewTabPage, (Map) null, q1.and(q2), (CloseCallBack) null); + Map map = new HashMap(); + map.put("Workloadcfmbill_id", this.getModel().getDataEntity().getPkValue()); + OpenFormUtils.openListPage(this.getView(), "qeug_contractsummarylist", ShowType.MainNewTabPage,map, q1.and(q2).and(q3), (CloseCallBack) null); } @@ -147,6 +152,45 @@ public class WorkloadcfmbillFormPlugin extends AbstractFormPlugin implements Tab this.getView().updateView("qeug_invoiceentryinfo"); this.getView().updateView("qeug_engmanager"); SaveServiceHelper.save(new DynamicObject[]{this.getModel().getDataEntity(true)}); + //todo 根据汇总的条件查出明细,复制一个明细单据将产值确认id存放 + // 汇总查看明细时,条件再加一个产值确认id + // 合同/补充/暂转固查看清单时,新增过滤条件,产值确认id=null + // 产值确认删除时,删除对应的清单明细 + + for (DynamicObject invoiceentryinfo : invoiceentryinfos) { + QFilter q3 = new QFilter("qeug_sheetname", QCP.equals, invoiceentryinfo.getString("qeug_summarycontent")); + QFilter q4 = new QFilter("qeug_contractid",QCP.equals, String.valueOf(id)); + QFilter q5 = new QFilter("qeug_workloadcfmid",QCP.equals, "");//防止第二次产值确认时,id覆盖确认过的清单产值确认 + DynamicObject[] recon_contractbills = BusinessDataServiceHelper.load("qeug_contractsummarylist", + "id,qeug_seq,qeug_projectnumber,qeug_projectname,qeug_featuredescript,qeug_engincontent," + + "qeug_unit,qeug_decimalqty,qeug_unitprice,qeug_amounttotal,qeug_artificial,qeug_provisional," + + "qeug_remarks,qeug_contractid,qeug_sheetname", new QFilter[]{q3,q4,q5}); + if (recon_contractbills.length > 0) { + for (int i = 0; i < recon_contractbills.length; i++) { + DynamicObject contractsummarylist = recon_contractbills[i]; + DynamicObject add = BusinessDataServiceHelper.newDynamicObject("qeug_contractsummarylist"); + add.set("qeug_seq", contractsummarylist.getString("qeug_seq")); + add.set("qeug_projectnumber", contractsummarylist.getString("qeug_projectnumber")); + add.set("qeug_projectname", contractsummarylist.getString("qeug_projectname")); + add.set("qeug_featuredescript", contractsummarylist.getString("qeug_featuredescript")); + add.set("qeug_engincontent", contractsummarylist.getString("qeug_engincontent")); + add.set("qeug_unit", contractsummarylist.getString("qeug_unit")); + add.set("qeug_decimalqty", contractsummarylist.getBigDecimal("qeug_decimalqty")); + add.set("qeug_unitprice", contractsummarylist.getBigDecimal("qeug_unitprice")); + add.set("qeug_amounttotal", contractsummarylist.getBigDecimal("qeug_amounttotal")); + add.set("qeug_artificial", contractsummarylist.getBigDecimal("qeug_artificial")); + add.set("qeug_provisional", contractsummarylist.getBigDecimal("qeug_provisional")); + add.set("qeug_remarks", contractsummarylist.getString("qeug_remarks")); + add.set("qeug_contractid", contractsummarylist.getString("qeug_contractid")); + add.set("qeug_sheetname", contractsummarylist.getString("qeug_sheetname")); + add.set("qeug_workloadcfmid",String.valueOf(this.getModel().getDataEntity().getPkValue())); + add.set("enable","1");//使用状态 + add.set("status","A");//数据状态 + SaveServiceHelper.save(new DynamicObject[]{add}); + } + } + } + break; default: break; @@ -195,29 +239,37 @@ public class WorkloadcfmbillFormPlugin extends AbstractFormPlugin implements Tab String tabKey = tabSelectEvent.getTabKey(); if ("tabbillinfo".equals(tabKey)) { //获取产值确认当前合同对应的所有清单明细 - - DynamicObject cqcontract = (DynamicObject) this.getModel().getValue("contractbill"); - long id = 0; - if (null != cqcontract) { - id = cqcontract.getLong("id"); - } - - QFilter q1 = new QFilter("qeug_contractid",QCP.equals, String.valueOf(id)); - DynamicObject[] recon_contractbills = BusinessDataServiceHelper.load("qeug_contractsummarylist", - "id,qeug_bcdecimalqty,qeug_unitprice", new QFilter[]{q1}); - if (recon_contractbills.length > 0) { - BigDecimal bigDecimal = BigDecimal.ZERO; - for (DynamicObject recon_contractbill : recon_contractbills) { - BigDecimal qeugBcdecimalqty = recon_contractbill.getBigDecimal("qeug_bcdecimalqty");//本次完工量 - BigDecimal qeugUnitprice = recon_contractbill.getBigDecimal("qeug_unitprice");//综合单价 - BigDecimal qeugAmount = qeugBcdecimalqty.multiply(qeugUnitprice).setScale(2, BigDecimal.ROUND_HALF_UP);//四舍五入金额 - bigDecimal = bigDecimal.add(qeugAmount); + String billstatus = (String)this.getModel().getValue("billstatus"); + if ("A".equals(billstatus)) { + DynamicObject cqcontract = (DynamicObject) this.getModel().getValue("contractbill"); + long id = 0; + if (null != cqcontract) { + id = cqcontract.getLong("id"); } - this.getModel().setValue("amount", bigDecimal);//合同总金额 - this.getView().updateView("amount");// + Object pkValue = this.getModel().getDataEntity().getPkValue(); + String qeug_workloadcfmid = String.valueOf(pkValue); + if (StringUtils.isNotEmpty(qeug_workloadcfmid)) { + QFilter q1 = new QFilter("qeug_contractid",QCP.equals, String.valueOf(id)); + QFilter q2 = new QFilter("qeug_workloadcfmid",QCP.equals, String.valueOf(this.getModel().getDataEntity().getPkValue())); + DynamicObject[] recon_contractbills = BusinessDataServiceHelper.load("qeug_contractsummarylist", + "id,qeug_bcdecimalqty,qeug_unitprice,qeug_bcdecimalqtys", new QFilter[]{q1,q2}); + if (recon_contractbills.length > 0) { + BigDecimal bigDecimal = BigDecimal.ZERO; + for (DynamicObject recon_contractbill : recon_contractbills) { + BigDecimal qeugBcdecimalqty = recon_contractbill.getBigDecimal("qeug_bcdecimalqtys");//本次完工量 + BigDecimal qeugUnitprice = recon_contractbill.getBigDecimal("qeug_unitprice");//综合单价 + BigDecimal qeugAmount = qeugBcdecimalqty.multiply(qeugUnitprice).setScale(2, BigDecimal.ROUND_HALF_UP);//四舍五入金额 + bigDecimal = bigDecimal.add(qeugAmount); + } + this.getModel().setValue("amount", bigDecimal);//合同总金额 + this.getView().updateView("amount");// // this.getModel().setValue("notaxamount", bigDecimal);//合同总金额 // this.getView().updateView("notaxamount");// + } + } } + + } } } diff --git a/main/java/shkd/repc/recon/listplugin/ContractSummaryListPlugin.java b/main/java/shkd/repc/recon/listplugin/ContractSummaryListPlugin.java index f37f3c6..4a546c5 100644 --- a/main/java/shkd/repc/recon/listplugin/ContractSummaryListPlugin.java +++ b/main/java/shkd/repc/recon/listplugin/ContractSummaryListPlugin.java @@ -6,10 +6,8 @@ import kd.bos.dataentity.entity.DynamicObject; import kd.bos.entity.datamodel.ListSelectedRow; import kd.bos.entity.datamodel.ListSelectedRowCollection; import kd.bos.entity.filter.FilterParameter; -import kd.bos.form.events.AfterDoOperationEventArgs; -import kd.bos.form.events.ExportFileEvent; -import kd.bos.form.events.FlexBeforeClosedEvent; -import kd.bos.form.events.SetFilterEvent; +import kd.bos.form.events.*; +import kd.bos.form.operate.FormOperate; import kd.bos.list.BillList; import kd.bos.list.events.BillClosedCallBackEvent; import kd.bos.list.plugin.AbstractListPlugin; @@ -19,8 +17,12 @@ import kd.bos.orm.query.QFilter; import kd.bos.servicehelper.BusinessDataServiceHelper; import kd.bos.servicehelper.operation.SaveServiceHelper; import kd.bos.servicehelper.user.UserServiceHelper; +import org.apache.poi.ss.usermodel.*; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; import java.math.BigDecimal; import java.util.List; import java.util.Map; @@ -33,10 +35,45 @@ import java.util.stream.Collectors; */ public class ContractSummaryListPlugin extends AbstractListPlugin implements IListPlugin { + @Override + public void beforeDoOperation(BeforeDoOperationEventArgs args) { + super.beforeDoOperation(args); + + Map customParams = this.getView().getFormShowParameter().getCustomParams(); + Object Workloadcfmbill_id = customParams.get("Workloadcfmbill_id"); + + FormOperate source = (FormOperate) args.getSource(); + String operateKey = source.getOperateKey(); + if ("exportlist".equals(operateKey)) { + +// ListSelectedRowCollection rows = this.getSelectedRows(); +// for (ListSelectedRow row : rows) { +// Long pk = (Long) row.getPrimaryKeyValue(); +// DynamicObject dataEntity = BusinessDataServiceHelper.loadSingle(pk, "qeug_contractsummarylist"); +// dataEntity.set("qeug_workloadcfmid",Workloadcfmbill_id); +// SaveServiceHelper.save(new DynamicObject[]{dataEntity}); +// } + +// // 获取单据列表 +// BillList billList = this.getControl(AbstractListPlugin.BILLLISTID); +// //获取过滤参数 +// FilterParameter generalFilterParameter = billList.generalFilterParameter(); +// //获取过滤条件 +// List qFilters = generalFilterParameter.getQFilters(); +// QFilter[] array = qFilters.toArray(new QFilter[0]); +// DynamicObject[] loads = BusinessDataServiceHelper.load("qeug_contractsummarylist", +// "id,qeug_workloadcfmid", array); +// for (DynamicObject load : loads) { +// load.set("qeug_workloadcfmid",Workloadcfmbill_id); +// } +// SaveServiceHelper.save(loads); + } + } + @Override public void afterDoOperation(AfterDoOperationEventArgs afterDoOperationEventArgs) { super.afterDoOperation(afterDoOperationEventArgs); - +// // String operateKey = afterDoOperationEventArgs.getOperateKey(); // if ("importdata".equals(operateKey)) { // @@ -90,9 +127,51 @@ public class ContractSummaryListPlugin extends AbstractListPlugin implements ILi // qFilters.addAll(listQF); } - /** 导出文件后事件,可以用来修改导出的文件内容,比如修改excel数据、格式、加密等 */ + @Override + public void afterQueryOfExport(AfterQueryOfExportEvent e) { + super.afterQueryOfExport(e); + +// DynamicObject[] datas = e.getQueryValues(); +// for (DynamicObject data : datas) { +// String billno = (String) data.get("billno"); +// if (billno != null) { +// billno = "****" + billno.substring(4); +// } else { +// billno = "******"; +// } +// data.set("billno", billno); +// } + + } + + /** + * 导出文件后事件,可以用来修改导出的文件内容,比如修改excel数据、格式、加密等 + */ public void afterExportFile(ExportFileEvent e) { - File file = e.getFile(); +// Map customParams = this.getView().getFormShowParameter().getCustomParams(); +// Object Workloadcfmbill_id = customParams.get("Workloadcfmbill_id"); +// File file = e.getFile(); +// if (file != null) { +// try (FileInputStream fis = new FileInputStream(file)) { +// Workbook wb = new XSSFWorkbook(fis); +// Sheet sheet = wb.getSheetAt(0); +// // 写入产值确认id +// int rowCountsheet = sheet.getPhysicalNumberOfRows();//总行数 +// for (int i = 4; i < rowCountsheet; i++) { +// Row row = sheet.getRow(i); +// Cell cell = row.getCell(16); +// cell.setCellValue(String.valueOf(Workloadcfmbill_id)); +// } +// // 保存 +// FileOutputStream out = new FileOutputStream(file); +// wb.write(out); +// wb.close(); +// out.close(); +// } catch +// (Throwable ex) { +// ex.printStackTrace(); +// } +// } } diff --git a/main/java/shkd/repc/recon/opplugin/IntroduceContractPlugin.java b/main/java/shkd/repc/recon/opplugin/IntroduceContractPlugin.java index bcd1c40..63ed8b5 100644 --- a/main/java/shkd/repc/recon/opplugin/IntroduceContractPlugin.java +++ b/main/java/shkd/repc/recon/opplugin/IntroduceContractPlugin.java @@ -21,17 +21,18 @@ public class IntroduceContractPlugin extends BatchImportPlugin { while (iterator.hasNext()){ ImportBillData importBillData = iterator.next(); JSONObject data = importBillData.getData(); - String qeug_bcdecimalqty = (String) data.get("qeug_bcdecimalqty");//本次完工量 + String qeug_bcdecimalqtys = (String) data.get("qeug_bcdecimalqtys");//本次完工量 String qeug_decimalqty = (String) data.get("qeug_decimalqty");//工程量 String qeug_preofpro = (String) data.get("qeug_preofpro");//进度百分比 - double bcdecimalqty = 0; - double decimalqty =0; - double preofpro =0; + String qeug_workloadcfmid = (String) data.get("qeug_workloadcfmid");//产值确认id + BigDecimal bcdecimalqty = null; + BigDecimal decimalqty =null; + BigDecimal preofpro =null; if (qeug_decimalqty != null && qeug_preofpro!= null) { //校验 工程量&进度百分比 数据格式是否正确 try { - decimalqty = Double.parseDouble(qeug_decimalqty); - preofpro = Double.parseDouble(qeug_preofpro); + decimalqty = new BigDecimal(qeug_decimalqty); + preofpro = new BigDecimal(qeug_preofpro); } catch (NumberFormatException e) { logger.log(importBillData.getStartIndex(),"工程量数据格式有误").fail(); iterator.remove(); @@ -39,14 +40,15 @@ public class IntroduceContractPlugin extends BatchImportPlugin { // 本次完工量 = 工程量 * 进度百分比 BigDecimal bd1 = new BigDecimal(qeug_decimalqty); BigDecimal bd2 = new BigDecimal(qeug_preofpro); - BigDecimal result = bd1.multiply(bd2); - result = result.setScale(2, BigDecimal.ROUND_HALF_UP); - data.put("qeug_bcdecimalqty",result); + BigDecimal result = bd1.multiply(bd2).multiply(BigDecimal.valueOf(0.01)); +// result = result.setScale(2, BigDecimal.ROUND_HALF_UP); + data.put("qeug_bcdecimalqtys",result); if (StringUtils.isNotEmpty(qeug_preofpro)) { - preofpro = Double.parseDouble(qeug_preofpro); + preofpro = new BigDecimal(qeug_preofpro); } - if (preofpro>1){ - logger.log(importBillData.getStartIndex(),"进度百分比不能大于1").fail(); + if (preofpro != null && preofpro.compareTo(BigDecimal.valueOf(100)) > 0) { + + logger.log(importBillData.getStartIndex(), "进度百分比不能大于100").fail(); iterator.remove(); } } diff --git a/main/java/shkd/repc/resm/opplugin/PushOASupplierOPPlugin.java b/main/java/shkd/repc/resm/opplugin/PushOASupplierOPPlugin.java index 338c45a..6bb9a8c 100644 --- a/main/java/shkd/repc/resm/opplugin/PushOASupplierOPPlugin.java +++ b/main/java/shkd/repc/resm/opplugin/PushOASupplierOPPlugin.java @@ -23,6 +23,8 @@ import java.util.Date; import java.util.HashMap; import java.util.Map; +import static shkd.utils.OAUtils.pushOASupplier; + /** * 推送OA供应商 */ @@ -42,43 +44,11 @@ public class PushOASupplierOPPlugin extends AbstractOperationServicePlugIn { if ("audit".equals(operationKey)) { for (DynamicObject dataEntity : e.getDataEntities()) { - //String url = System.getProperty("efms.infcompany.url.ip"); - //logger.info("url"); //获取token -// String oaToken = OAUtils.getOaToken(); - String oaToken = "OAUtils.getOaToken()"; + String oaToken = OAUtils.getOaToken(dataEntity.getString("name")); if (StringUtils.isNotEmpty(oaToken)) { - //ICS新增/更新OA客户租户接口 - String customerUrl = "http://172.31.254.240:9090/seeyon/rest/ats/type/customer"; - - Map customerHeader = new HashMap<>(); - customerHeader.put("Content-Type", "application/json"); - customerHeader.put("token", oaToken); - - //组装请求体 - DynamicObject supplier = dataEntity.getDynamicObject("supplier"); - if (null != supplier) { - JSONObject customerBody = assembleBody(OAUtils.l(supplier.getPkValue())); - if (null != customerBody) { - String customerPostjson = null; - try { - customerPostjson = HttpClientUtils.postjson(customerUrl, customerHeader, customerBody.toJSONString()); - JSONObject jsonObject = JSONObject.parseObject(customerPostjson); - if (!jsonObject.isEmpty()) { - String result = (String) JSONObject.parseObject(customerPostjson).get("success"); - if ("success".equals(result)) { -// logger.info("ICS新增/更新OA客户租户接口返回结果:\n{}", customerPostjson); - } - } - logger.info("ICS新增/更新OA客户租户接口返回结果:\n{}", customerPostjson); - } catch (Exception ex) { - logger.info(String.format("ICS新增/更新OA客户租户接口异常:%s", ex.getMessage())); - throw new RuntimeException(ex); - } - } - } - + pushOASupplier(oaToken,dataEntity); } } } @@ -87,7 +57,7 @@ public class PushOASupplierOPPlugin extends AbstractOperationServicePlugIn { /** * 组装供应商入参 */ - private static JSONObject assembleBody(long supplierID){ + public static JSONObject assembleBody(long supplierID){ JSONObject customerBody = null; //获取正式供应商 QFilter q = new QFilter("id", QCP.equals, supplierID); diff --git a/main/java/shkd/utils/OAUtils.java b/main/java/shkd/utils/OAUtils.java index eda8225..aaec0da 100644 --- a/main/java/shkd/utils/OAUtils.java +++ b/main/java/shkd/utils/OAUtils.java @@ -13,6 +13,8 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import static shkd.repc.resm.opplugin.PushOASupplierOPPlugin.assembleBody; + /** * @author :weiyunlong * @date :Created 2024/9/11 16:02 @@ -21,8 +23,8 @@ import java.util.Map; public class OAUtils { private static final Log logger = LogFactory.getLog(OAUtils.class); - private static final String oaUrl = System.getProperty("oaurl");//(测试环境外网地址) -// private static final String oaUrl = "http://172.31.254.240:9090";//本地(内网地址) + public static final String oaUrl = System.getProperty("oaurl");//(测试环境外网地址) +// public static final String oaUrl = "http://172.31.254.240:9090";//本地(内网地址) //致远服务前获取token接口 public static String getOaToken(String billNo){ @@ -67,6 +69,46 @@ public class OAUtils { } } + /** + * OA供应商同步接口 + */ + public static void pushOASupplier(String oaToken, DynamicObject dataEntity){ + //ICS新增/更新OA客户租户接口 + String customerUrl = OAUtils.oaUrl+"/seeyon/rest/ats/type/customer"; + + Map customerHeader = new HashMap<>(); + customerHeader.put("Content-Type", "application/json"); + customerHeader.put("token", oaToken); + + //组装请求体 +// DynamicObject supplier = dataEntity.getDynamicObject("syssupplier");//系统供应商 +// if (null != supplier) { + JSONObject customerBody = assembleBody(OAUtils.l(dataEntity.getPkValue())); + if (null != customerBody) { + String customerPostjson = null; + try { + customerPostjson = HttpClientUtils.postjson(customerUrl, customerHeader, customerBody.toJSONString()); + JSONObject jsonObject = JSONObject.parseObject(customerPostjson); + + if (!jsonObject.isEmpty()) { + String result = jsonObject.getString("success"); + boolean success = "true".equals(result); + + DobeDWUtils.saveLog(dataEntity.getString("name"), + "致远", customerBody.toJSONString(), customerPostjson, + success, "调用ICS新增/更新OA客户租户接口"); + } + } catch (Exception ex) { + DobeDWUtils.saveLog(dataEntity.getString("name"), + "致远", customerBody.toJSONString(), customerPostjson, + false, "调用ICS新增/更新OA客户租户接口"); + throw new RuntimeException(ex); + } + } +// } + + } + /** * OA接口绑定用户 * 代办接口之前需要先(用户的绑定 你通过定时任务 增量推就行,或者你们系统有人员进来推一次,这个人绑定成功了 就不需要再绑定,除非人员工号有变动)