Commit 39a7aef8 by wuwenlong

会计期管理dev;

parent c9280883
......@@ -77,13 +77,13 @@ public class ServiceHGCB001 extends ServiceBase {
try {
List<Map> resultRows = inInfo.getBlock(EiConstant.resultBlock).getRows();
List<HGCB001> hgcb001List = MapUtils.toDaoEPBase(resultRows,HGCB001.class);
checkSaveData(hgcb001List);
checkRepetition(hgcb001List);
// 写入数据
Optional.ofNullable(hgcb001List).orElse(new ArrayList<>()).forEach(hgcb001 -> {
hgcb001.setAccountPeriod(DateUtils.formatShort(hgcb001.getAccountPeriod()));
});
List<HGCB001> addList = Optional.ofNullable(hgcb001List).orElse(new ArrayList<>()).stream().filter(o -> Objects.isNull(o.getId())||o.getId()==0).collect(Collectors.toList());
add(addList);
HGCBTools.HgCb001.add(addList);
List<HGCB001> updateList = Optional.ofNullable(hgcb001List).orElse(new ArrayList<>()).stream().filter(o -> Objects.nonNull(o.getId())&&o.getId()!=0).collect(Collectors.toList());
modify(updateList);
inInfo = this.query(inInfo);
......@@ -95,7 +95,7 @@ public class ServiceHGCB001 extends ServiceBase {
return inInfo;
}
private void checkSaveData(List<HGCB001> hgcb001List){
private void checkRepetition(List<HGCB001> hgcb001List){
if(CollectionUtils.isNotEmpty(hgcb001List)) {
List<String> stringList = hgcb001List.stream().map(o -> {
return o.getCompanyCode() + "-" + o.getAccountPeriod();
......@@ -105,24 +105,7 @@ public class ServiceHGCB001 extends ServiceBase {
}
}
/**
* 新增操作
*
* @param addList
* @return
*/
public void add(List<HGCB001> addList) {
Map<String,List<String>> periodMap = Optional.ofNullable(addList).orElse(new ArrayList<>()).stream().collect(
Collectors.groupingBy(HGCB001::getCompanyCode,Collectors.mapping(HGCB001::getAccountPeriod,Collectors.toList())));
Optional.ofNullable(periodMap).orElse(new HashMap<>()).forEach((k,v)->{
Map paramMap = new HashMap();
paramMap.put(HGCB001.FIELD_COMPANY_CODE,k);
paramMap.put("accountPeriods",v);
List dbList = HGCBTools.HgCb001.queryNoAuth(paramMap);
AssertUtils.isNotEmpty(dbList,"账期重复,请检查数据!");
});
DaoUtils.insertBatch(HGCB001.INSERT, addList);
}
/**
* 修改操作
......@@ -131,6 +114,7 @@ public class ServiceHGCB001 extends ServiceBase {
* @return
*/
public void modify(List<HGCB001> updateList) {
HGCBTools.HgCb001.checkSaveData(updateList);
Map<String,List<String>> periodMap = Optional.ofNullable(updateList).orElse(new ArrayList<>()).stream().collect(
Collectors.groupingBy(HGCB001::getCompanyCode,Collectors.mapping(HGCB001::getAccountPeriod,Collectors.toList()))); List<Long> notIds = Optional.ofNullable(updateList).orElse(new ArrayList<>()).stream().map(HGCB001::getId).collect(Collectors.toList());
Optional.ofNullable(periodMap).orElse(new HashMap<>()).forEach((k,v)->{
......@@ -232,23 +216,8 @@ public class ServiceHGCB001 extends ServiceBase {
List<Map> resultRows = inInfo.getBlock(EiConstant.resultBlock).getRows();
HGCB001 hgcb001 = new HGCB001();
hgcb001.fromMap(resultRows.get(0));
Integer accountPeriodStatus = hgcb001.getAccountPeriodStatus();
if (accountPeriodStatus == 1) {
//开账 - 做关账
//当前账期的上个账期是否关账,当前账期对应的业务账是否关账
hgcb001.setAccountPeriodStatus(0);
DaoUtils.update("HGCB001.updateSwitchRow", hgcb001);
} else if (accountPeriodStatus == 0) {
//当前账期的下个账期是否开账状态
int switchRowNum = dao.count("HGCB001.getSwitchRowNum", hgcb001);
if (switchRowNum > 0) {
inInfo.setStatus(EiConstant.STATUS_FAILURE);
inInfo.setMsg("操作失败!已经有一个会计期为开账状态!");
return inInfo;
}
hgcb001.setAccountPeriodStatus(1);
DaoUtils.update("HGCB001.updateSwitchRow", hgcb001);
}
checkSwitchDate(hgcb001);
DaoUtils.update("HGCB001.updateSwitchRow", hgcb001);
inInfo = this.query(inInfo);
inInfo.setStatus(EiConstant.STATUS_DEFAULT);
inInfo.setMsg("操作成功!本次对[" + resultRows.size() + "]条数据操作成功!");
......@@ -261,6 +230,7 @@ public class ServiceHGCB001 extends ServiceBase {
private void checkSwitchDate(HGCB001 hgcb001){
try {
HGCB001 dbhgcb001 = null;
switch (hgcb001.getAccountPeriodStatus()) {
case 0:
Date nextDate = DateUtils.addMonths(DateUtils.parseDate(hgcb001.getAccountPeriod(), DateUtil.DATE12_PATTERN), 1);
......@@ -269,7 +239,8 @@ public class ServiceHGCB001 extends ServiceBase {
put(HGCW001.FIELD_COMPANY_CODE,hgcb001.getCompanyCode());
put(HGCW001.FIELD_ACCOUNT_PERIOD,nextDateStr);
}});
AssertUtils.isTrue(Objects.nonNull(dbhgcb001)&&dbhgcb001.getAccountPeriodStatus()== CommonConstant.YesNo.NO_0,String.format("下个账期为关账状态:%s[%s]账期会计账已经关账!",dbhgcb001.getCompanyName(),dbhgcb001.getAccountPeriod()));
AssertUtils.isTrue(Objects.nonNull(dbhgcb001)&&dbhgcb001.getAccountPeriodStatus().compareTo( CommonConstant.YesNo.NO_0)==0,String.format("下个账期为关账状态:%s[%s]账期会计账已经关账!",hgcb001.getCompanyName(),nextDateStr));
hgcb001.setAccountPeriodStatus(CommonConstant.YesNo.YES_1);
break;
case 1:
Date lastDate = DateUtils.addMonths(DateUtils.parseDate(hgcb001.getAccountPeriod(), DateUtil.DATE12_PATTERN), -1);
......@@ -279,12 +250,13 @@ public class ServiceHGCB001 extends ServiceBase {
put(HGCW001.FIELD_ACCOUNT_PERIOD,lastDateStr);
}});
AssertUtils.isNull(Objects.isNull(dbhgcb001),String.format("会计账期缺失:%s[%s]账期会计账不存在!",hgcb001.getCompanyName(),lastDateStr));
AssertUtils.isTrue(dbhgcb001.getAccountPeriodStatus()== CommonConstant.YesNo.YES_1,String.format("上个账期未关账:%s[%s]账期会计账未关账!",dbhgcb001.getCompanyName(),dbhgcb001.getAccountPeriod()));
AssertUtils.isTrue(dbhgcb001.getAccountPeriodStatus().compareTo(CommonConstant.YesNo.YES_1)==0,String.format("上个账期未关账:%s[%s]账期会计账未关账!",hgcb001.getCompanyName(),lastDateStr));
HGCW001 hgcw001 = HGCWTools.HgCw001.getNoAuth(new HashMap(){{
put(HGCW001.FIELD_COMPANY_CODE,hgcb001.getCompanyCode());
put(HGCW001.FIELD_ACCOUNT_PERIOD,hgcb001.getAccountPeriod());
}});
AssertUtils.isTrue(Objects.nonNull(hgcw001)&&hgcw001.getAccountPeriodStatus()== CommonConstant.YesNo.YES_1,String.format("业务账未关账:%s[%s]账期业务账未关账!",hgcb001.getCompanyName(),hgcb001.getAccountPeriod()));
AssertUtils.isTrue(Objects.nonNull(hgcw001)&&hgcw001.getAccountPeriodStatus().compareTo(CommonConstant.YesNo.YES_1)==0,String.format("业务账未关账:%s[%s]账期业务账未关账!",hgcb001.getCompanyName(),hgcb001.getAccountPeriod()));
hgcb001.setAccountPeriodStatus(CommonConstant.YesNo.NO_0);
break;
default:
AssertUtils.isTrue(true,"会计账期状态异常!");
......
......@@ -191,7 +191,7 @@
$orderBy$
</isNotEmpty>
<isEmpty property="orderBy">
ID asc
COMPANY_CODE,ACCOUNT_PERIOD desc
</isEmpty>
</dynamic>
......
......@@ -90,6 +90,36 @@ public class HGCBTools {
return CollectionUtils.isEmpty(list) ? null : list.get(0);
}
/**
* 新增操作
*
* @param addList
* @return
*/
public static void add(List<HGCB001> addList) {
checkSaveData(addList);
Map<String,List<String>> periodMap = Optional.ofNullable(addList).orElse(new ArrayList<>()).stream().collect(
Collectors.groupingBy(HGCB001::getCompanyCode,Collectors.mapping(HGCB001::getAccountPeriod,Collectors.toList())));
Optional.ofNullable(periodMap).orElse(new HashMap<>()).forEach((k,v)->{
Map paramMap = new HashMap();
paramMap.put(HGCB001.FIELD_COMPANY_CODE,k);
paramMap.put("accountPeriods",v);
List dbList = HGCBTools.HgCb001.queryNoAuth(paramMap);
AssertUtils.isNotEmpty(dbList,"账期重复,请检查数据!");
});
DaoUtils.insertBatch(HGCB001.INSERT, addList);
}
public static void checkSaveData(List<HGCB001> addList){
Optional.ofNullable(addList).orElse(new ArrayList<>()).forEach( hgcb001 -> {
AssertUtils.isEmpty(hgcb001.getCompanyCode(),"保存失败,会计账公司编码不能为空!");
AssertUtils.isEmpty(hgcb001.getCompanyName(),"保存失败,会计账公司名称不能为空!");
AssertUtils.isEmpty(hgcb001.getAccountYear(),"保存失败,会计账会计年份不能为空!");
AssertUtils.isEmpty(hgcb001.getAccountPeriod(),"保存失败,会计账会计期不能为空!");
AssertUtils.isNull(hgcb001.getAccountPeriodStatus(),"保存失败,会计账会计状态不能为空!");
});
}
/**
* 查询当前公司账期
......
$(function() {
var globalCompanyList = __eiInfo.getBlock("roleCompany").getMappedRows();
// 查询
$("#QUERY").on("click", function () {
......@@ -14,8 +15,21 @@ $(function() {
pageSize: 20,
pageSizes: [10,20,30,50,100,200],
},
columns: [
],
columns: [{
field: "companyCode",
template: function (item) {
let template = "";
if (item.companyCode) {
for (let i = 0; i < globalCompanyList.length; i++) {
if (item.companyCode === globalCompanyList[i]['companyCode']) {
item['companyName'] = globalCompanyList[i]['companyName'];
template = globalCompanyList[i]['companyName'];
}
}
}
return template;
}
}],
onSave: function (e) {
// 阻止默认请求,使用自定义保存
e.preventDefault();
......
......@@ -12,7 +12,7 @@
<div class="row">
<EF:EFSelect cname="公司名称" blockId="inqu_status" ename="companyCode" row="0" colWidth="3" filter="contains">
<EF:EFOption label="全部" value=""/>
<EF:EFOptions blockId="companyBox_block_id" textField="textField" valueField="valueField"/>
<EF:EFOptions blockId="roleCompany" textField="companyName" valueField="companyCode"/>
</EF:EFSelect>
<EF:EFDatePicker cname="会计期" blockId="inqu_status" ename="accountPeriod" row="0" colWidth="3"
format="yyyy-MM" parseFormats="['yyyyMM']" start="year" depth="year"/>
......@@ -26,6 +26,7 @@
<EF:EFRegion id="result" title="记录集">
<EF:EFGrid blockId="result" autoDraw="no" isFloat="true" autoBind="false">
<EF:EFColumn ename="id" cname="主键" hidden="true"/>
<%-- <EF:EFColumn ename="companyName" cname="公司名称" hidden="false"/>--%>
<EF:EFComboColumn ename="companyCode" cname="公司名称" width="110" align="center"
filter="contains" readonly="true">
<EF:EFOptions blockId="roleCompany" valueField="companyCode" textField="companyName"/>
......@@ -46,5 +47,4 @@
<script>
var ctx = "${ctx}";
</script>
<script src="${ctx}/HG/CW/HGCB001.js"></script>
\ No newline at end of file
</script>
\ No newline at end of file
$(function (){
var companyCodeBox = __eiInfo.getBlock("company_code_block_id").getMappedRows();
var whCodeBox = __eiInfo.getBlock("wh_record_block_id").getMappedRows();
$(".row").children().attr("class", "col-md-3");
$("#QUERY").on("click", function (e) {
query();
})
$("#SYNC").on("click", function () {
showDetail();
});
IPLATUI.EFGrid= {
"result": {
pageable: {
pageSize: 20,
pageSizes: [10, 20, 50, 100],
},
columns: [
{
field: "accountPeriod",
title: "会计期",
template: function (item) {
return item.accountYear + "-" + item.accountMonth;
}
}
],
exportGrid: {
exportFileName: function (gridInstance) {
// 导出的文件名包含时间戳 yyyy-MM-dd HH:mm:ss
return "产副品制造成本核算_" + kendo.toString(new Date(), IPLAT.FORMAT.DATE_14_PR);
},
exportFileType: "xls", // 默认值是xls,可选值为pdf[规划中]
exportBlockId: "result", // 默认值和blockId相同,导出的EiInfo中的指定数据块被导出
},
loadComplete: function(grid) {
// 此 grid 对象
// 处理父子级联动,通过监听 change 事件,判断父级节点是否发生变化
grid.dataSource.bind("change", function(e) {
// 判断父级节点是否发生变化
if (e.field === "unitCost") {
let items = e.items[0];
for (let i = 0; i < items.length; i++) {
let totalCost = items[i].unitCost * items[i].totalWeight;
resultGrid.setCellValue(e.items[i],"totalCost",totalCost);
}
}
if (e.field === "totalCost") {
let items = e.items[0];
for (let i = 0; i < items.length; i++) {
let unitCost = items[i].totalCost / items[i].totalWeight;
resultGrid.setCellValue(e.items[i],"unitCost",unitCost);
}
}
});
},
onSave: function (e) {
// 阻止默认请求,使用自定义保存
e.preventDefault();
let btnNode = $(this);
//禁用按钮
btnNode.attr("disabled", true);
save(btnNode);
},
onDelete: function (e) {
// 阻止默认请求,使用自定义删除
//e.preventDefault();
//deleteFunc();
},
onSuccess: function (e) {
if (e.eiInfo.extAttr.methodName == 'save' || e.eiInfo.extAttr.methodName == 'delete') {
query();
}
},
onRowClick: function (e) {
}
}
}
downKeyUp();
});
/**
* 页面加载时执行
*/
$(window).load(function () {
// 查询
query();
});
let query = function () {
resultGrid.dataSource.page(1);
}
/**
* 保存
*/
let save = function (btnNode) {
let rows = resultGrid.getCheckedRows();
if (rows.length < 1) {
message("请选择数据");
return;
}
let flag = true;
$.each(rows, function(index, item) {
let unitCost = item.get("unitCost");
let totalCost= item.get("totalCost");
if(isBlank(unitCost)){
message("选中的第"+(index+1)+"行\"单位成本\",不能为空!");
flag = false;
return false;
}
if(isBlank(totalCost)){
message("选中的第"+(index+1)+"行\"总成本\",不能为空!");
flag = false;
return false;
}
});
if(flag) {
JSUtils.confirm("确定对勾选中的[" + rows.length + "]条数据做\"保存\"操作? ", {
ok: function () {
JSUtils.submitGridsData("result", "HGCB005", "save", true);
btnNode.attr("disabled", false);
}
});
}
};
/**
* 显示详情
*/
function showDetail() {
JSColorbox.open({
href: "HGCB002A?methodName=initLoad",
title: "<div style='text-align: center;'>选择公司</div>",
width: "60%",
height: "60%",
callbackName: windowCallback
});
}
function windowCallback(item) {
synchData(item);
// 关闭弹窗
JSColorbox.close();
}
/**
* 确认
*/
let synchData = function (item) {
let info = new EiInfo();
info.set("inqu_status-0-companyCode", item.companyCode);
info.set("inqu_status-0-accountYear", item.accountYear);
info.set("inqu_status-0-accountPeriod", item.accountPeriod);
info.set("inqu_status-0-createdTimeFrom", item.accountPeriodDateStart);
info.set("inqu_status-0-createdTimeTo", item.accountPeriodDateEnd);
EiCommunicator.send("HGCB005", "synchData", info, {
onSuccess: function (ei) {
if (ei.getStatus() >= 0) {
if (ei.getStatus() == 0) {
NotificationUtil(ei, 'warning');
} else {
NotificationUtil(ei);
}
// 刷新列表
query();
} else {
NotificationUtil(ei, "error");
}
},
onFail: function (ei) {
NotificationUtil("操作失败,原因[" + ei + "]", "error");
}
});
}
\ No newline at end of file
<!DOCTYPE html>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib prefix="EF" tagdir="/WEB-INF/tags/EF" %>
<%@ page import="com.baosight.iplat4j.core.web.threadlocal.UserSession" %>
<%
String loginName = UserSession.getLoginName();
%>
<c:set var="ctx" value="${pageContext.request.contextPath}"/>
<c:set var="loginName" value="<%=loginName%>" />
<EF:EFPage title="产副品制造成本核算">
<EF:EFRegion id="inqu" title="查询条件">
<div class="row">
<EF:EFSelect blockId="inqu_status" row="0" ename="companyCode" cname="公司名称" colWidth="3" filter="contains">
<EF:EFOption label="全部" value=""/>
<EF:EFOptions blockId="company_code_block_id" textField="companyName" valueField="companyCode"/>
</EF:EFSelect>
<EF:EFDatePicker blockId="inqu_status" row="0" ename="accountYear" cname="会计期(年)" colWidth="3"
format="yyyy" depth="year" start="year"/>
<EF:EFDatePicker blockId="inqu_status" row="0" ename="accountMonth" cname="会计期(月)" colWidth="3"
format="MM" depth="month" start="month"/>
</div>
</EF:EFRegion>
<EF:EFRegion id="result" title="明细信息">
<EF:EFGrid blockId="result" autoDraw="override" isFloat="true">
<EF:EFColumn ename="id" primaryKey="true" cname="内码" hidden="true"/>
<EF:EFColumn ename="accountYear" cname="会计期(年)" hidden="true"/>
<EF:EFColumn ename="accountMonth" cname="会计期(月)" hidden="true"/>
<EF:EFColumn ename="returnQuantity" cname="退回数量" hidden="true"/>
<EF:EFColumn ename="accountCode" cname="企业编码" hidden="true"/>
<EF:EFComboColumn ename="companyCode" cname="公司名称"
columnTemplate="#=textField#" itemTemplate="#=textField#"
textField="textField" valueField="valueField"
maxLength="16" width="200" required="true"
align="center" filter="contains" sort="true">
<EF:EFOptions blockId="company_code_block_id" textField="companyName" valueField="companyCode"/>
</EF:EFComboColumn>
<EF:EFColumn ename="accountPeriod" cname="会计期" enable="false" width="120" align="center"
editType="date" dateFormat="yyyy-MM" parseFormats="['yyyyMM']"/>
<EF:EFColumn ename="projCode" cname="项目编码" enable="true" width="120" align="center" readonly="true"/>
<EF:EFColumn ename="projName" cname="项目名称" width="120" enable="true" align="center" readonly="true"/>
<EF:EFColumn ename="inventCode" cname="存货编码" width="120" enable="true" readonly="true" align="center" required="true"/>
<EF:EFColumn ename="inventName" cname="存货名称" width="120" enable="true" readonly="true" align="center" required="true"/>
<EF:EFColumn ename="processCode" cname="工序编码" width="120" enable="true" readonly="true" align="center" required="true"/>
<EF:EFColumn ename="processName" cname="工序名称" width="120" enable="true" readonly="true" align="center" required="true"/>
<EF:EFColumn ename="spec" cname="规格" width="120" enable="true" readonly="true" align="center" required="true"/>
<EF:EFColumn ename="quantity" cname="数量" width="120" enable="false" format="{0:N3}" editType="text"
displayType="0.000" sort="true" align="right" maxLength="17" required="true" defaultValue="0"
data-regex="/^-?[0-9]{1,15}?$/"
data-errorprompt="请输入数字,该值最大可设置15位整数!"/>
<EF:EFColumn ename="singleWeight" cname="单重(kg)" width="120" enable="false" format="{0:N3}" editType="text"
displayType="0.000" sort="true" align="right" maxLength="17" required="true" defaultValue="0"
data-regex="/^-?[0-9]{1,15}([.][0-9]{1,3})?$/"
data-errorprompt="请输入数字,该值最大可设置15位整数和3位小数!"/>
<EF:EFColumn ename="totalWeight" cname="总重(kg)" width="120" enable="false" format="{0:N3}" editType="text"
displayType="0.000" sort="true" align="right" maxLength="17" required="true" defaultValue="0"
data-regex="/^-?[0-9]{1,15}([.][0-9]{1,3})?$/"
data-errorprompt="请输入数字,该值最大可设置15位整数和3位小数!"/>
<EF:EFColumn ename="unitCost" cname="单位成本" width="120" enable="false" format="{0:N3}" editType="text"
displayType="0.000" sort="true" align="right" maxLength="17" required="true" defaultValue="0"
data-regex="/^-?[0-9]{1,15}([.][0-9]{1,3})?$/"
data-errorprompt="请输入数字,该值最大可设置15位整数和3位小数!"/>
<EF:EFColumn ename="totalCost" cname="总成本" width="120" enable="false" format="{0:N3}" editType="text"
displayType="0.000" sort="true" align="right" maxLength="17" required="true" defaultValue="0"
data-regex="/^-?[0-9]{1,15}([.][0-9]{1,3})?$/"
data-errorprompt="请输入数字,该值最大可设置15位整数和3位小数!"/>
</EF:EFGrid>
</EF:EFRegion>
</EF:EFPage>
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