产值确认逻辑优化(每次完工量隔离)
This commit is contained in:
parent
f0c3740510
commit
bfd607f019
|
@ -10,6 +10,7 @@ import kd.bos.entity.BasedataEntityType;
|
|||
import kd.bos.entity.datamodel.IDataModel;
|
||||
import kd.bos.entity.datamodel.events.BeforeDeleteEntryEventArgs;
|
||||
import kd.bos.entity.datamodel.events.IDataModelChangeListener;
|
||||
import kd.bos.entity.datamodel.events.PropertyChangedArgs;
|
||||
import kd.bos.entity.property.BasedataProp;
|
||||
import kd.bos.entity.property.EntryProp;
|
||||
import kd.bos.entity.property.MulBasedataProp;
|
||||
|
@ -205,6 +206,25 @@ public class ContractFormPlugin extends AbstractFormPlugin implements UploadLis
|
|||
this.getView().invokeOperation("refresh");
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void propertyChanged(PropertyChangedArgs e) {
|
||||
super.propertyChanged(e);
|
||||
|
||||
super.propertyChanged(e);
|
||||
String name = e.getProperty().getName();//字段名称
|
||||
if("qeug_chmentpanel_f".equals(name)){
|
||||
Object qeugChmentpanelF = this.getModel().getValue("qeug_chmentpanel_f");
|
||||
if (qeugChmentpanelF instanceof Number) {
|
||||
int pkLongValue = ((Number) qeugChmentpanelF).intValue(); // 转换为 long
|
||||
if (pkLongValue == 0) {
|
||||
this.getView().getModel().getEntryEntity("qeug_invoiceentryinfo").clear();
|
||||
this.getView().updateView("qeug_invoiceentryinfo");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterDoOperation(AfterDoOperationEventArgs args) {
|
||||
|
||||
|
@ -244,8 +264,9 @@ public class ContractFormPlugin extends AbstractFormPlugin implements UploadLis
|
|||
for (Map<String, Object> fileMap : attachments) {
|
||||
Object attPkId = fileMap.get("attPkId");
|
||||
if (null == attPkId) {
|
||||
this.getView().showTipNotification("请先保存单据");
|
||||
return;
|
||||
// this.getView().showTipNotification("请先保存单据");
|
||||
// return;
|
||||
this.getView().invokeOperation("save");//调用保存
|
||||
}
|
||||
List<Map<String, Object>> attachmentes = AttachmentServiceHelper.getAttachments("recon_contractbill", this.getModel().getValue("id"), "qeug_attachmentpanelap");
|
||||
for (Map<String, Object> attachment : attachmentes) {
|
||||
|
@ -307,7 +328,7 @@ public class ContractFormPlugin extends AbstractFormPlugin implements UploadLis
|
|||
case 0:
|
||||
double num = Double.parseDouble(cell.toString());
|
||||
int result = (int)num;
|
||||
contractsummarylist.set("qeug_seq",String.valueOf(result));//序号
|
||||
contractsummarylist.set("qeug_seqs",result);//序号
|
||||
break;
|
||||
case 1:
|
||||
contractsummarylist.set("qeug_projectnumber",cell);//项目编码
|
||||
|
@ -392,7 +413,7 @@ public class ContractFormPlugin extends AbstractFormPlugin implements UploadLis
|
|||
}
|
||||
this.getView().updateView("qeug_invoiceentryinfo");
|
||||
SaveServiceHelper.save(new DynamicObject[]{this.getView().getModel().getDataEntity()});
|
||||
this.getView().showSuccessNotification("清单汇总识别成功");
|
||||
// this.getView().showSuccessNotification("清单汇总识别成功");
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
|
|
@ -36,13 +36,16 @@ import java.util.Map;
|
|||
*/
|
||||
public class WorkloadcfmbillFormPlugin extends AbstractFormPlugin implements TabSelectListener {
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void beforeDoOperation(BeforeDoOperationEventArgs args) {
|
||||
super.beforeDoOperation(args);
|
||||
|
||||
DynamicObject cqcontract = (DynamicObject) this.getModel().getValue("contractbill");
|
||||
long id = 0;
|
||||
if (null != cqcontract) {
|
||||
id = cqcontract.getLong("id");
|
||||
}
|
||||
|
||||
FormOperate source = (FormOperate) args.getSource();
|
||||
String operateKey = source.getOperateKey();
|
||||
switch (operateKey) {
|
||||
|
@ -54,14 +57,35 @@ public class WorkloadcfmbillFormPlugin extends AbstractFormPlugin implements Tab
|
|||
this.getView().showTipNotification("新增行无法查看明细");
|
||||
return;
|
||||
}
|
||||
DynamicObject cqcontract = (DynamicObject) this.getModel().getValue("contractbill");
|
||||
long id = 0;
|
||||
if (null != cqcontract) {
|
||||
id = cqcontract.getLong("id");
|
||||
}
|
||||
|
||||
getListShowParamer(this.getView(), this.getModel(),String.valueOf(id));
|
||||
break;
|
||||
case "audit":
|
||||
//产值确认--清单明细
|
||||
DynamicObjectCollection invoiceentryinfos = this.getModel().getDataEntity(true).getDynamicObjectCollection("qeug_invoiceentryinfo");
|
||||
//产值确认审核时,将所有明细的完成百分比覆盖掉合同看的清单
|
||||
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, String.valueOf(this.getModel().getDataEntity().getPkValue()));
|
||||
DynamicObject[] recon_contractbills = BusinessDataServiceHelper.load("qeug_contractsummarylist",
|
||||
"id,qeug_seq,qeug_seqs,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,qeug_cumulativepreofpro", new QFilter[]{q3,q4,q5});
|
||||
if (recon_contractbills.length > 0) {
|
||||
for (int i = 0; i < recon_contractbills.length; i++) {
|
||||
DynamicObject contractsummarylist = recon_contractbills[i];
|
||||
QFilter q6 = new QFilter("qeug_workloadcfmid",QCP.equals, "");//未作产值确认时的清单
|
||||
QFilter q7 = new QFilter("qeug_seqs",QCP.equals, contractsummarylist.getBigDecimal("qeug_seqs"));//项目编码
|
||||
DynamicObject add = BusinessDataServiceHelper.loadSingle("qeug_contractsummarylist", new QFilter[]{q3, q4, q6, q7});
|
||||
if (null != add) {
|
||||
add.set("qeug_cumulativepreofpro",contractsummarylist.getBigDecimal("qeug_cumulativepreofpro"));//累计进度百分比(%)
|
||||
SaveServiceHelper.save(new DynamicObject[]{add});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -73,32 +97,14 @@ public class WorkloadcfmbillFormPlugin extends AbstractFormPlugin implements Tab
|
|||
* @param model 模型
|
||||
*/
|
||||
private void getListShowParamer(IFormView formView, IDataModel model,String contentId) {
|
||||
|
||||
// ListShowParameter parameter = ShowFormHelper.createShowListForm("qeug_contractsummarylist", true);
|
||||
// parameter.getOpenStyle().setShowType(ShowType.MainNewTabPage);//Floating MainNewTabPage NewBrowserPage NewTabPage
|
||||
// parameter.setBillFormId("qeug_contractsummarylist");
|
||||
// parameter.setHasRight(true);
|
||||
// StyleCss styleCss = new StyleCss();
|
||||
// styleCss.setWidth("1500");
|
||||
// styleCss.setHeight("800");
|
||||
// parameter.getOpenStyle().setInlineStyleCss(styleCss);
|
||||
DynamicObjectCollection dynColl = formView.getModel().getEntryEntity("qeug_invoiceentryinfo");
|
||||
int index = model.getEntryCurrentRowIndex("qeug_invoiceentryinfo");
|
||||
DynamicObject dynamicObject = dynColl.get(index);
|
||||
String qeug_summarycontent = dynamicObject.getString("qeug_summarycontent");//汇总内容(sheetName)
|
||||
//// Object pkValue = formView.getModel().getDataEntity().getPkValue();//合同ID
|
||||
//
|
||||
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<QFilter> listQF = Lists.newArrayList();
|
||||
// listQF.add(q1.and(q2));
|
||||
// parameter.setListFilterParameter(new ListFilterParameter(listQF, null));
|
||||
// parameter.setCustomParam("qeug_sheetname",qeug_summarycontent);
|
||||
// parameter.setCustomParam("qeug_contractid",contentId);
|
||||
// parameter.setStatus(OperationStatus.ADDNEW);
|
||||
// this.getView().showForm(parameter);
|
||||
// OpenFormUtils.openListPage();
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
map.put("Workloadcfmbill_id", this.getModel().getDataEntity().getPkValue());
|
||||
OpenFormUtils.openListPage(this.getView(), "qeug_contractsummarylist", ShowType.MainNewTabPage,map, q1.and(q2).and(q3), (CloseCallBack) null);
|
||||
|
@ -139,11 +145,6 @@ public class WorkloadcfmbillFormPlugin extends AbstractFormPlugin implements Tab
|
|||
add.set("qeug_isnew", qeug_invoiceentryinfo.get("qeug_isnew"));
|
||||
add.set("qeug_remarks", qeug_invoiceentryinfo.get("qeug_remarks"));
|
||||
add.set("qeug_currencylist", qeug_invoiceentryinfo.get("qeug_currencylist"));
|
||||
// this.getModel().setValue("qeug_summarycontent", qeug_invoiceentryinfo.get("qeug_summarycontent"), i);//汇总内容
|
||||
// this.getModel().setValue("qeug_amount", qeug_invoiceentryinfo.get("qeug_amount"), i);//金额(元)
|
||||
// this.getModel().setValue("qeug_isnew", qeug_invoiceentryinfo.get("qeug_isnew"), i);//是否新增行
|
||||
// this.getModel().setValue("qeug_remarks", qeug_invoiceentryinfo.get("qeug_remarks"), i);//备注
|
||||
// this.getModel().setValue("qeug_currencylist", qeug_invoiceentryinfo.get("qeug_currencylist"), i);//清单币别
|
||||
}
|
||||
|
||||
//携带工程经理
|
||||
|
@ -162,16 +163,16 @@ public class WorkloadcfmbillFormPlugin extends AbstractFormPlugin implements Tab
|
|||
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," +
|
||||
"id,qeug_seqs,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});
|
||||
"qeug_remarks,qeug_contractid,qeug_sheetname,qeug_cumulativepreofpro", 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_seqs", contractsummarylist.getString("qeug_seqs"));
|
||||
add.set("qeug_projectnumber", contractsummarylist.getString("qeug_projectnumber").trim());
|
||||
add.set("qeug_projectname", contractsummarylist.getString("qeug_projectname").trim());
|
||||
add.set("qeug_featuredescript", contractsummarylist.getString("qeug_featuredescript"));
|
||||
add.set("qeug_engincontent", contractsummarylist.getString("qeug_engincontent"));
|
||||
add.set("qeug_unit", contractsummarylist.getString("qeug_unit"));
|
||||
|
@ -183,6 +184,7 @@ public class WorkloadcfmbillFormPlugin extends AbstractFormPlugin implements Tab
|
|||
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_cumulativepreofpro", contractsummarylist.getString("qeug_cumulativepreofpro"));//累计完成百分比
|
||||
add.set("qeug_workloadcfmid",String.valueOf(this.getModel().getDataEntity().getPkValue()));
|
||||
add.set("enable","1");//使用状态
|
||||
add.set("status","A");//数据状态
|
||||
|
|
|
@ -21,11 +21,9 @@ public class IntroduceContractPlugin extends BatchImportPlugin {
|
|||
while (iterator.hasNext()){
|
||||
ImportBillData importBillData = iterator.next();
|
||||
JSONObject data = importBillData.getData();
|
||||
String qeug_bcdecimalqtys = (String) data.get("qeug_bcdecimalqtys");//本次完工量
|
||||
String qeug_decimalqty = (String) data.get("qeug_decimalqty");//工程量
|
||||
String qeug_preofpro = (String) data.get("qeug_preofpro");//进度百分比
|
||||
String qeug_workloadcfmid = (String) data.get("qeug_workloadcfmid");//产值确认id
|
||||
BigDecimal bcdecimalqty = null;
|
||||
String qeug_preofpro = (String) data.get("qeug_preofpro");//当前进度百分比
|
||||
String qeug_cumulativepreofpro = (String) data.get("qeug_cumulativepreofpro");//累计进度百分比
|
||||
BigDecimal decimalqty =null;
|
||||
BigDecimal preofpro =null;
|
||||
if (qeug_decimalqty != null && qeug_preofpro!= null) {
|
||||
|
@ -37,11 +35,17 @@ public class IntroduceContractPlugin extends BatchImportPlugin {
|
|||
logger.log(importBillData.getStartIndex(),"工程量数据格式有误").fail();
|
||||
iterator.remove();
|
||||
}
|
||||
// 本次完工量 = 工程量 * 进度百分比
|
||||
// 本次完工量 = 工程量 * (当前进度百分比-累计完成百分比)
|
||||
BigDecimal bd1 = new BigDecimal(qeug_decimalqty);
|
||||
BigDecimal bd2 = new BigDecimal(qeug_preofpro);
|
||||
BigDecimal result = bd1.multiply(bd2).multiply(BigDecimal.valueOf(0.01));
|
||||
// result = result.setScale(2, BigDecimal.ROUND_HALF_UP);
|
||||
BigDecimal bd3;
|
||||
if (StringUtils.isEmpty(qeug_cumulativepreofpro)) {
|
||||
bd3 = BigDecimal.ZERO; // 如果 qeug_cumulativepreofpro 为空,则赋值为 0
|
||||
} else {
|
||||
bd3 = new BigDecimal(qeug_cumulativepreofpro);
|
||||
}
|
||||
BigDecimal bd4 = bd2.subtract(bd3);
|
||||
BigDecimal result = bd1.multiply(bd4).multiply(BigDecimal.valueOf(0.01));
|
||||
data.put("qeug_bcdecimalqtys",result);
|
||||
if (StringUtils.isNotEmpty(qeug_preofpro)) {
|
||||
preofpro = new BigDecimal(qeug_preofpro);
|
||||
|
@ -51,6 +55,11 @@ public class IntroduceContractPlugin extends BatchImportPlugin {
|
|||
logger.log(importBillData.getStartIndex(), "进度百分比不能大于100").fail();
|
||||
iterator.remove();
|
||||
}
|
||||
if (bd3.compareTo(bd2) > 0) {
|
||||
logger.log(importBillData.getStartIndex(), "当前进度百分比不能小于累计完成百分比").fail();
|
||||
iterator.remove();
|
||||
}
|
||||
data.put("qeug_cumulativepreofpro",bd2);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue