Commit 504febc9 by yukang

收款单修改、删除、反写数据逻辑处理

parent 9c2b4826
......@@ -26,6 +26,7 @@ import org.apache.commons.collections.CollectionUtils;
import java.math.BigDecimal;
import java.text.DecimalFormat;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
......@@ -177,35 +178,61 @@ public class ServiceHGCW014 extends ServiceBase {
hgcw014.setSigningDate(DateUtils.shortDate());
BigDecimal totalContractPriceIncluding = BigDecimal.ZERO;
StringBuffer contractNumber = new StringBuffer();
Map<String, BigDecimal> rowMap = new HashMap<>();
for (HGCW015 hgcw015 : hgcw015List) {
totalContractPriceIncluding = totalContractPriceIncluding.add(hgcw015.getTotalContractPriceIncluding());
contractNumber.append(hgcw015.getContractNumber()).append(",");
}
for (Map m : resultRows) {
String c = m.get("settlementNumber").toString();
BigDecimal remainingAmount = new BigDecimal(m.get("thisAmount").toString());
rowMap.put(c, remainingAmount);
totalContractPriceIncluding = totalContractPriceIncluding.add(remainingAmount);
}
hgcw014.setTotalContractPriceIncluding(new BigDecimal(decimalFormat.format(totalContractPriceIncluding)));
hgcw014.setPartyA(hgcw015List.get(0).getPartyA());
hgcw014.setProjCode(hgcw015List.get(0).getProjCode());
hgcw014.setProjName(hgcw015List.get(0).getProjName());
hgcw014.setContractNumber(contractNumber.toString().substring(0, contractNumber.length() - 1));
this.add(hgcw014);
//生成明细表
for (HGCW015 hgcw015 : hgcw015List) {
hgcw015.setMainId(hgcw014.getId());
// 反写金额
HGCWTools.HgCw010.cutAmount(hgcw015.getContractNumber(),rowMap.get(hgcw015.getContractNumber()));
DaoUtils.insert(HGCW015.INSERT, hgcw015);
}
} else {
// 更新主表
HGCW014 hgcw014 = HGCWTools.HgCw014.getId(mainId);
BigDecimal totalContractPriceIncluding = BigDecimal.ZERO;
StringBuffer contractNumber = new StringBuffer();
for (HGCW015 hgcw015 : hgcw015List) {
totalContractPriceIncluding = totalContractPriceIncluding.add(hgcw015.getTotalContractPriceIncluding());
contractNumber.append(hgcw015.getContractNumber()).append(",");
Map<String, BigDecimal> rowMap = new HashMap<>();
for (Map m : resultRows) {
String c = m.get("settlementNumber").toString();
BigDecimal remainingAmount = new BigDecimal(m.get("thisAmount").toString());
rowMap.put(c, remainingAmount);
}
hgcw014.setTotalContractPriceIncluding(new BigDecimal(decimalFormat.format(totalContractPriceIncluding)));
hgcw014.setContractNumber(contractNumber.toString().substring(0, contractNumber.length() - 1));
this.modify(hgcw014);
// 生成明细表
for (HGCW015 hgcw015 : hgcw015List) {
hgcw015.setMainId(hgcw014.getId());
DaoUtils.insert(HGCW015.INSERT, hgcw015);
// 反写金额
HGCWTools.HgCw010.cutAmount(hgcw015.getContractNumber(),rowMap.get(hgcw015.getContractNumber()));
this.addHGCW015(hgcw015);
}
List<HGCW015> hgcw015s = HGCWTools.HgCw015.getMainId(hgcw014.getId());
if (CollectionUtils.isNotEmpty(hgcw015s)) {
// 更新主表
BigDecimal totalContractPriceIncluding = BigDecimal.ZERO;
StringBuffer contractNumber = new StringBuffer();
for (HGCW015 hgcw015 : hgcw015s) {
totalContractPriceIncluding = totalContractPriceIncluding.add(hgcw015.getTotalContractPriceIncluding());
contractNumber.append(hgcw015.getContractNumber()).append(",");
}
hgcw014.setTotalContractPriceIncluding(totalContractPriceIncluding);
hgcw014.setPartyA(hgcw015s.get(0).getPartyA());
hgcw014.setProjCode(hgcw015s.get(0).getProjCode());
hgcw014.setProjName(hgcw015s.get(0).getProjName());
hgcw014.setContractNumber(contractNumber.toString().substring(0, contractNumber.length() - 1));
this.modify(hgcw014);
}
}
}
......@@ -215,6 +242,10 @@ public class ServiceHGCW014 extends ServiceBase {
return inInfo;
}
public void addHGCW015(HGCW015 HGCW015) {
DaoUtils.insert("HGCW015.insert", HGCW015);
}
}
......
package com.baosight.hggp.hg.cw.service;
import com.baosight.hggp.aspect.annotation.OperationLogAnnotation;
import com.baosight.hggp.common.DdynamicEnum;
import com.baosight.hggp.hg.cw.domain.HGCW008;
import com.baosight.hggp.hg.cw.domain.HGCW009;
import com.baosight.hggp.hg.cw.domain.HGCW015;
import com.baosight.hggp.hg.cw.tools.HGCWTools;
import com.baosight.hggp.util.CommonMethod;
import com.baosight.hggp.util.LogUtils;
import com.baosight.iplat4j.core.ei.EiConstant;
import com.baosight.iplat4j.core.ei.EiInfo;
import com.baosight.iplat4j.core.exception.PlatException;
import com.baosight.iplat4j.core.service.impl.ServiceBase;
import java.util.Arrays;
import java.util.List;
/**
* @author yukang
* @date 2024年05月06日 18:22
*/
public class ServiceHGCW014B extends ServiceBase {
/**
* 画面初始化
*
* @param inInfo
* @return
*/
@OperationLogAnnotation(operModul = "账期维护",operType = "查询",operDesc = "初始化")
public EiInfo initLoad(EiInfo inInfo) {
try {
CommonMethod.initBlock(inInfo, Arrays.asList(DdynamicEnum.FACTORY_RECORD_BLOCK_ID,
DdynamicEnum.COMPANY_BOX_BLOCK_ID,DdynamicEnum.PROJ_RECORD_BLOCK_ID), null, false);
inInfo.addBlock(EiConstant.resultBlock).addBlockMeta(new HGCW015().eiMetadata);
} catch (PlatException e) {
LogUtils.setDetailMsg(inInfo, e, "初始化失败");
}
return inInfo;
}
/**
* 查询操作
*
* @param inInfo
* @return
*/
@OperationLogAnnotation(operModul = "账期维护",operType = "查询",operDesc = "查询")
@Override
public EiInfo query(EiInfo inInfo) {
try {
inInfo = super.query(inInfo, HGCW015.QUERY, new HGCW015());
} catch (Exception e) {
LogUtils.setDetailMsg(inInfo, e, "查询失败");
}
return inInfo;
}
}
......@@ -13,6 +13,7 @@ import com.baosight.iplat4j.core.ei.EiInfo;
import com.baosight.iplat4j.core.exception.PlatException;
import com.baosight.iplat4j.core.service.impl.ServiceBase;
import java.math.BigDecimal;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
......@@ -70,20 +71,29 @@ public class ServiceHGCW015 extends ServiceBase {
try {
List<Map> resultRows = inInfo.getBlock(EiConstant.resultBlock).getRows();
// 写入数据
Long mainId = null;
for (int i = 0; i < resultRows.size(); i++) {
HGCW015 HGCW015 = new HGCW015();
HGCW015.fromMap(resultRows.get(i));
UserVO userVO = HGCWTools.HgCw002.getUserCompany();
HGCW015.setCompanyCode(userVO.getUsercode());
HGCW015.setCompanyName(userVO.getUsername());
mainId = HGCW015.getMainId();
if (HGCW015.getId() == null || HGCW015.getId() == 0) {
this.add(HGCW015);
} else {
// 回写数据
HGCW015 oldHGCW015 = HGCWTools.HgCw015.getId(HGCW015.getId());
//先加再扣
HGCWTools.HgCw010.cutAmount(oldHGCW015.getContractNumber(),
oldHGCW015.getTotalContractPriceIncluding().multiply(new BigDecimal(-1)));
this.modify(HGCW015);
HGCWTools.HgCw010.cutAmount(HGCW015.getContractNumber(),
HGCW015.getTotalContractPriceIncluding());
}
}
// 更新主表
HGCWTools.HgCw014.updateAmount(mainId);
inInfo = this.query(inInfo);
inInfo.setStatus(EiConstant.STATUS_DEFAULT);
inInfo.setMsg("操作成功!本次对[" + resultRows.size() + "]条数据保存成功!");
......@@ -123,9 +133,18 @@ public class ServiceHGCW015 extends ServiceBase {
public EiInfo delete(EiInfo inInfo) {
try {
List<Map> resultRows = inInfo.getBlock(EiConstant.resultBlock).getRows();
Long mainId = null;
for (int i = 0; i < resultRows.size(); i++) {
DaoUtils.update("HGCW015.delete", resultRows.get(i));
HGCW015 HGCW015 = new HGCW015();
HGCW015.fromMap(resultRows.get(i));
mainId = HGCW015.getMainId();
DaoUtils.update("HGCW015.delete", HGCW015);
HGCWTools.HgCw010.cutAmount(HGCW015.getContractNumber(),
HGCW015.getTotalContractPriceIncluding().multiply(new BigDecimal(-1)));
}
// 更新主表
HGCWTools.HgCw014.updateAmount(mainId);
inInfo = this.query(inInfo);
inInfo.setStatus(EiConstant.STATUS_DEFAULT);
inInfo.setMsg("操作成功!本次对[" + resultRows.size() + "]条数据删除成功!");
......
......@@ -218,6 +218,9 @@
DEP_CODE <!-- 部门编码 -->
)
VALUES (#id#, #accountCode#, #companyCode#, #companyName#, #projName#, #projCode#, #contractNumber#, #incomeNumber#, #signingDate#, #partyA#, #cancelStatus#, #reviewStatus#, #totalContractPriceIncluding#, #createdBy#, #createdName#, #createdTime#, #updatedBy#, #updatedName#, #updatedTime#, #depCode#)
<selectKey resultClass="long" keyProperty="id">
SELECT MAX(ID) AS "id" FROM ${hggpSchema}.HGCW014
</selectKey>
</insert>
<delete id="delete">
......
......@@ -172,7 +172,7 @@
-->
<insert id="insert">
INSERT INTO ${hggpSchema}.HGCW015 (ID,
INSERT INTO ${hggpSchema}.HGCW015 (
MAIN_ID, <!-- 主表ID -->
ACCOUNT_CODE, <!-- 企业编码 -->
COMPANY_CODE, <!-- 公司编码 -->
......@@ -190,7 +190,7 @@
UPDATED_TIME, <!-- 记录修改时间 -->
DEP_CODE <!-- 部门编码 -->
)
VALUES (#id#, #mainId#, #accountCode#, #companyCode#, #companyName#, #projName#, #projCode#, #contractNumber#, #partyA#, #totalContractPriceIncluding#, #createdBy#, #createdName#, #createdTime#, #updatedBy#, #updatedName#, #updatedTime#, #depCode#)
VALUES (#mainId#, #accountCode#, #companyCode#, #companyName#, #projName#, #projCode#, #contractNumber#, #partyA#, #totalContractPriceIncluding#, #createdBy#, #createdName#, #createdTime#, #updatedBy#, #updatedName#, #updatedTime#, #depCode#)
</insert>
<delete id="delete">
......
......@@ -146,9 +146,9 @@ public class HGCWTools {
public static void deductionAmount(String settlementNumber, BigDecimal deductionAmount) {
AssertUtils.isNull(settlementNumber, "结算单不能为空!");
if (deductionAmount.compareTo(new BigDecimal(BigInteger.ZERO)) <= 0) {
throw new PlatException("扣款金额不能小于等于0!");
}
// if (deductionAmount.compareTo(new BigDecimal(BigInteger.ZERO)) <= 0) {
// throw new PlatException("扣款金额不能小于等于0!");
// }
List<HGCW008> results = DaoBase.getInstance().query(HGCW008.QUERY,new HashMap<String,Object>(){
{put("settlementNumber",settlementNumber);}
});
......@@ -158,7 +158,7 @@ public class HGCWTools {
DecimalFormat decimalFormat = new DecimalFormat("#.000");
HGCW008 hgcw008 = results.get(0);
BigDecimal remainingAmount = new BigDecimal(decimalFormat.format(hgcw008.getRemainingAmount().subtract(deductionAmount)));
if (remainingAmount.compareTo(new BigDecimal(BigInteger.ZERO)) < 0) {
if (remainingAmount.compareTo(new BigDecimal(BigInteger.ZERO)) <= 0) {
throw new PlatException("扣款金额不能大于结算单剩余金额!");
}
hgcw008.setRemainingAmount(remainingAmount);
......@@ -303,9 +303,9 @@ public class HGCWTools {
public static class HgCw010 {
public static void cutAmount(String settlementNumber, BigDecimal cutAmount) {
AssertUtils.isNull(settlementNumber, "来源单号不能为空!");
if (cutAmount.compareTo(new BigDecimal(BigInteger.ZERO)) <= 0) {
throw new PlatException("扣款金额不能小于等于0!");
}
// if (cutAmount.compareTo(new BigDecimal(BigInteger.ZERO)) <= 0) {
// throw new PlatException("扣款金额不能小于等于0!");
// }
List<HGCW010> results = DaoBase.getInstance().query(HGCW010.QUERY,new HashMap<String,Object>(){
{put("settlementNumber",settlementNumber);}
});
......@@ -315,7 +315,7 @@ public class HGCWTools {
DecimalFormat decimalFormat = new DecimalFormat("#.000");
HGCW010 HGCW010 = results.get(0);
BigDecimal remainingAmount = new BigDecimal(decimalFormat.format(HGCW010.getRemainingAmount().subtract(cutAmount)));
if (remainingAmount.compareTo(new BigDecimal(BigInteger.ZERO)) < 0) {
if (remainingAmount.compareTo(new BigDecimal(BigInteger.ZERO)) <= 0) {
throw new PlatException("扣款金额不能大于销售开票剩余金额!");
}
HGCW010.setRemainingAmount(remainingAmount);
......@@ -332,9 +332,38 @@ public class HGCWTools {
});
return results.get(0);
}
public static void updateAmount(Long id) {
AssertUtils.isNull(id, "收款单ID不能为空!");
HGCW014 hgcw014 = HGCWTools.HgCw014.getId(id.toString());
List<HGCW015> hgcw015s = HGCWTools.HgCw015.getMainId(hgcw014.getId());
if (CollectionUtils.isNotEmpty(hgcw015s)) {
// 更新主表
BigDecimal totalContractPriceIncluding = BigDecimal.ZERO;
StringBuffer contractNumber = new StringBuffer();
for (HGCW015 hgcw015 : hgcw015s) {
totalContractPriceIncluding = totalContractPriceIncluding.add(hgcw015.getTotalContractPriceIncluding());
contractNumber.append(hgcw015.getContractNumber()).append(",");
}
hgcw014.setTotalContractPriceIncluding(totalContractPriceIncluding);
hgcw014.setPartyA(hgcw015s.get(0).getPartyA());
hgcw014.setProjCode(hgcw015s.get(0).getProjCode());
hgcw014.setProjName(hgcw015s.get(0).getProjName());
hgcw014.setContractNumber(contractNumber.toString().substring(0, contractNumber.length() - 1));
DaoUtils.update("HGCW014.update", hgcw014);
}
}
}
public static class HgCw015 {
public static HGCW015 getId(Long id) {
AssertUtils.isNull(id, "收款单ID不能为空!");
List<HGCW015> results = DaoBase.getInstance().query(HGCW015.QUERY,new HashMap<String,Object>(){
{put("id",id);}
});
return results.get(0);
}
public static List<HGCW015> mapToList(List<Map> rows, Long mainId) {
List<HGCW015> hgcw015List = new ArrayList<>();
if (CollectionUtils.isNotEmpty(rows)) {
......@@ -342,7 +371,7 @@ public class HGCWTools {
HGCW015 hgcw015 = new HGCW015();
hgcw015.fromMap(row);
String contractNumber = row.get("settlementNumber").toString();
String remainingAmount = row.get("remainingAmount").toString();
String remainingAmount = row.get("thisAmount").toString();
hgcw015.setContractNumber(contractNumber);
hgcw015.setTotalContractPriceIncluding(new BigDecimal(remainingAmount));
if (mainId != null) {
......@@ -353,6 +382,14 @@ public class HGCWTools {
}
return hgcw015List;
}
public static List<HGCW015> getMainId(Long mainId) {
AssertUtils.isNull(mainId, "主表ID不能为空!");
List<HGCW015> results = DaoBase.getInstance().query(HGCW015.QUERY,new HashMap<String,Object>(){
{put("mainId",mainId);}
});
return results;
}
}
public static class HgCw999 {
......
......@@ -95,8 +95,8 @@ function updateFunc() {
return;
}
JSColorbox.open({
href: "HGCW012B?methodName=initLoad&id=" + rows[0].id + "&efParentFormEname=HGCW012",
title: "<div style='text-align: center;'>修改合同</div>",
href: "HGCW014B?methodName=initLoad&inqu_status-0-mainId=" + rows[0].id + "&efParentFormEname=HGCW014",
title: "<div style='text-align: center;'>收款清单</div>",
width: "90%",
height: "90%",
callbackName: windowCallback
......
......@@ -38,7 +38,7 @@
<EF:EFOptions blockId="proj_record_block_id" valueField="valueField" textField="textField"/>
</EF:EFComboColumn>
<EF:EFColumn ename="projName" cname="项目编码" hidden="true"/>
<EF:EFColumn ename="signingDate" cname="收款日期" readonly="true" width="100" align="center"
<EF:EFColumn ename="signingDate" cname="收款日期" width="100" align="center"
editType="date" dateFormat="yyyy-MM-dd" parseFormats="['yyyyMMdd']"/>
<EF:EFColumn ename="contractNumber" cname="来源单号" width="120" enable="false" readonly="true" align="center"/>
<EF:EFColumn ename="incomeNumber" cname="收款单号" width="120" enable="false" readonly="true" align="center"/>
......
......@@ -63,13 +63,13 @@ function btnSaveFunc() {
return;
}
}
JSUtils.confirm("确定对勾选中的[" + rows.length + "]条数据生成出库单吗? ", {
JSUtils.confirm("确定对勾选中的[" + rows.length + "]条数据生成收款单吗? ", {
ok: function () {
JSUtils.submitGridsData("result", "HGCW014", "select",
true, function (e) {
var status = e.getStatus();
if (status !== -1) {
// parent.JSColorbox.setValueCallback();
parent.JSColorbox.setValueCallback();
}
}
);
......
$(function() {
// 查询
$("#QUERY").on("click", function () {
query();
});
IPLATUI.EFGrid.result = {
pageable: {
pageSize: 20,
pageSizes: [10,20,30,50,100,200],
},
onSave: function (e) {
// 阻止默认请求,使用自定义保存
e.preventDefault();
saveFunc();
},
onDelete: function (e) {
// 阻止默认请求,使用自定义删除
e.preventDefault();
deleteFunc();
}
}
window.document.addEventListener("keyup",function (event) {
if(event.keyCode === 13){
var grid = $("#ef_grid_result").data("kendoGrid");
// 回填
//grid.addRows(returnRows);
grid.closeCell();
}
})
});
$(window).load(function () {
// 查
query();
});
/**
* 查询
*/
let query = function () {
resultGrid.dataSource.page(1);
}
function cancelFunc() {
// 关闭弹窗
parent.JSColorbox.setValueCallback();
}
function saveFunc() {
let rows = resultGrid.getCheckedRows();
if (rows.length < 1) {
message("请选择数据");
return;
}
JSUtils.confirm("确定对勾选中的[" + rows.length + "]条数据做\"保存\"操作? ", {
ok: function () {
var info = new EiInfo();
info.addBlock(JSUtils.checkedRows2Block("result"));
EiCommunicator.send("HGCW015", "save", info, {
onSuccess: function (ei) {
if (ei.getStatus() >= 0) {
try {
query();
} catch (e) {
// TODO: handle exception
}
if (ei.getStatus() == 0) {
NotificationUtil(ei, 'warning');
} else {
NotificationUtil(ei);
}
} else {
NotificationUtil(ei, "error");
}
},
onFail: function (ei) {
// 发生异常
NotificationUtil("操作失败,原因[" + ei + "]", "error");
}
});
//JSUtils.submitGridsData("result", "HPSC001", "save", true);
}
});
}
function deleteFunc() {
let rows = resultGrid.getCheckedRows();
if (rows.length < 1) {
message("请选择数据");
return;
}
JSUtils.confirm("确定对勾选中的[" + rows.length + "]条数据做\"删除\"操作? ", {
ok: function () {
JSUtils.submitGridsData("result", "HGCW015", "delete", true);
}
});
}
<!DOCTYPE html>
<%@ page contentType="text/html; charset=UTF-8" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib prefix="EF" tagdir="/WEB-INF/tags/EF" %>
<c:set var="ctx" value="${pageContext.request.contextPath}"/>
<head>
</head>
<EF:EFPage title="收款清单">
<EF:EFInput cname="隐藏条件" ename="mainId" blockId="inqu_status" row="0" type="hidden"/>
<EF:EFRegion id="result" title="记录集">
<EF:EFGrid blockId="result" autoDraw="no" isFloat="true" autoBind="false" checkMode="row">
<EF:EFColumn ename="id" cname="主键" hidden="true"/>
<EF:EFColumn ename="projName" cname="项目名称" width="120" enable="false" readonly="true" align="center"/>
<EF:EFColumn ename="partyA" cname="客户名称" width="120" enable="false" readonly="true" align="center"/>
<EF:EFColumn ename="contractNumber" cname="来源单号" width="120" enable="false" readonly="true" align="center"/>
<EF:EFColumn ename="totalContractPriceIncluding" cname="收款总额" width="120" format="{0:N3}" align="center"/>
</EF:EFGrid>
</EF:EFRegion>
</EF:EFPage>
<script>
var ctx = "${ctx}";
</script>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment