Commit 4955405a authored by 鲁鑫's avatar 鲁鑫

成本中心导入优化

parent 4675c708
......@@ -79,4 +79,13 @@ function getId() {
return $("#id").val();
}
function checkConstraints(){
var kostl = $("#kostl").val();
if (kostl.length != 10){
Public.tip("成本中心编码只能是10位数,请检查")
return false;
}
return true;
}
......@@ -33,6 +33,7 @@
<x:hidden name="statusId"/>
<x:hidden name="isEnable"/>
<x:hidden name="isDelete"/>
<x:hidden name="isCostCenterHis"/>
<div class="hg-form-row">
<x:inputC name="kostl" required="true" label="成本中心编码" labelCol="2" maxLength="64" fieldCol="4"/>
<x:inputC name="ktext" required="true" label="名称" labelCol="2" maxLength="64" fieldCol="4"/>
......
$(document).ready(function(){
bindEvent();
})
function bindEvent(){
$('#khinr').treebox({
name:'sapOrgDpt',
searchName:'sapOrgDpt',
searchType:'bsn',
hasSearch :true,
minWidth:500,
param:{
treeViewMappingType:"bsn",
parentId:'ogn'
},
back:{
//text:$('#queryDataManageName')
},
onChange:function(node,data){
$('#khinr').val(data.id);
}
});
}
\ No newline at end of file
<%--
Created by IntelliJ IDEA.
User: zht
Date: 2023/12/13
Time: 16:39
--%>
<%@ page language="java" contentType="text/html; charset=utf-8" %>
<%@taglib uri="/WEB-INF/taglib.tld" prefix="x" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<html>
<head>
<x:base include="layout,dialog,grid,tree,combox,commonTree,date"/>
<x:script src='/biz/topsun/sap/costCenter/sapCostCenterDetail.js'/>
</head>
<body>
<div class="container-fluid">
<x:billTitle title="成本中心" needStatus="false" needPerson="true"/>
<div class="blank_div clearfix"></div>
<form class="hg-form" method="post" action="" id="submitForm">
<x:hidden name="id"/>
<x:hidden name="version"/>
<x:hidden name="billCode"/>
<x:hidden name="fillinDate" type="datetime"/>
<x:hidden name="fullId"/>
<x:hidden name="organId"/>
<x:hidden name="organName"/>
<x:hidden name="deptId"/>
<x:hidden name="deptName"/>
<x:hidden name="positionId"/>
<x:hidden name="positionName"/>
<x:hidden name="personMemberId"/>
<x:hidden name="personMemberName"/>
<x:hidden name="statusId"/>
<x:hidden name="isEnable"/>
<x:hidden name="isDelete"/>
<x:hidden name="isCostCenterHis"/>
<div class="hg-form-row">
<x:inputC name="kostl" required="true" readonly="true" label="成本中心编码" labelCol="2" maxLength="64" fieldCol="4"/>
<x:inputC name="ktext" required="true" label="名称" labelCol="2" maxLength="64" fieldCol="4"/>
<x:inputC name="ltext" required="false" label="描述" labelCol="2" maxLength="64" fieldCol="4"/>
<x:selectC name="kosar" required="true" label="成本中心类型" labelCol="2" dictionary="KOSAR" fieldCol="4"/>
<x:inputC name="datbi" required="true" label="有限期自" labelCol="2" wrapper="date" fieldCol="4"/>
<x:inputC name="datab" required="true" label="有限截止日" labelCol="2" wrapper="date" fieldCol="4"/>
<x:inputC name="verak" required="true" label="负责人" labelCol="2" maxLength="64" fieldCol="4"/>
<x:inputC name="khinr" required="true" label="层次结构范围" labelCol="2" maxLength="64" fieldCol="4" wrapper="select"/>
<x:selectC name="prctr" required="true" label="利润中心" labelCol="2" dictionary="PRCTR" fieldCol="4"/>
<x:inputC name="telePhone" required="false" label="联系方式" labelCol="2" maxLength="64" fieldCol="4"/>
<x:inputC name="reason" required="false" label="原因" labelCol="2" maxLength="255" fieldCol="4"/>
</div>
<div class="blank_div clearfix"></div>
</form>
</div>
</body>
</html>
var gridManager = null;
var gridManager = null,refreshFlag = null;
$(document).ready(function () {
initializateUI();
......@@ -16,10 +16,10 @@ function loadCostCenterListGrid() {
addHandler();
},
impExcelDataHandler:{id:'impExcelData',img:'fa-table',text:'导入数据',click:impExcelDataHandler},
// updateHandler: function () {
// updateHandler();
// },
// deleteHandler: deleteHandler,
updateHandler: function () {
updateHandler();
},
deleteHandler: deleteHandler,
// disableHandler: disableHandler,
frozenHandler: {
id: 'frozenHandler', text: '冻结', img: 'fa-clipboard', click: function () {
......@@ -53,23 +53,26 @@ function loadCostCenterListGrid() {
{display: "申请人", name: "personMemberName", width: 140, minWidth: 60, type: "string", align: "left"},
{display: "申请部门", name: "deptName", width: 140, minWidth: 60, type: "string", align: "left"},
{display: "联系方式", name: "telePhone", width: 140, minWidth: 60, type: "string", align: "left"},
{display: "申请日期", name: "fillinDate", width: 140, minWidth: 60, type: "string", align: "left"},
{display: "申请日期", name: "fillinDate", width: 140, minWidth: 60, type: "date", align: "left"},
{display: "原因", name: "reason", width: 140, minWidth: 60, type: "string", align: "left"},
{
display: "状态", name: "isEnable", width: 60, minWidth: 60, type: "string", align: "center",
render: function (item) {
return UICtrl.getStatusInfo(item.isEnable);
}
display: "状态", name: "statusTextView", width: 60, minWidth: 60, type: "string", align: "center",
// render: function (item) {
// return UICtrl.getStatusInfo(item.isEnable);
// }
},
{display: "消息类型", name: "typeTextView", width: 140, minWidth: 60, type: "string", align: "left"},
//{display: "消息编号", name: "number", width: 140, minWidth: 60, type: "string", align: "left"},
{display: "消息文本", name: "message", width: 200, minWidth: 60, type: "string", align: "left"},
{display: "是否历史数据", name: "isCostCenterHisTextView", width: 200, minWidth: 60, type: "string", align: "left"},
//{display: "应用程序日志", name: "logNo", width: 140, minWidth: 60, type: "string", align: "left"},
],
dataAction: "server",
url: web_app.name + '/sapCostCenter/slicedCostCenterList.ajax',
pageSize: 20,
usePager: true,
sortName: 'fillinDate',
sortOrder: 'desc',
toolbar: toolbarOptions,
width: "100%",
height: "100%",
......@@ -79,7 +82,7 @@ function loadCostCenterListGrid() {
selectRowButtonOnly: true,
// 双击执行
onDblClickRow: function (data, rowindex, rowobj) {
updateHandler(data);
viewHandler(data);
}
});
UICtrl.setSearchAreaToggle(gridManager);
......@@ -108,11 +111,19 @@ function addHandler() {
//从EXCEL导入数据
function impExcelDataHandler(){
ExcelImpManager.showImpDialog('导入', 'sapCostCenterData', '100', function (){
ExcelImpManager.showImpDialog('导入', 'sapCostCenterData',new Date().getTime(), function (){
reloadGrid();
});
}
function viewHandler(data){
UICtrl.addTabItem({
tabid: data.id,
text: "查看成本中心",
url: web_app.name + '/sapCostCenter/showCostCenter.job?isReadOnly=true&bizId='+data.id
})
}
function updateHandler(row) {
if (!row) {
row = DataUtil.getUpdateRow(gridManager);
......@@ -120,15 +131,42 @@ function updateHandler(row) {
return;
}
}
UICtrl.addTabItem({
tabid: 'CostCenterDetail',
text: "查看成本中心",
url: web_app.name + '/sapCostCenter/showCostCenterDetail.job?isReadOnly=true&id=' + row.id
})
if (row.isCostCenterHis != 1){
Public.tip("只能修改历史数据")
return false;
}
UICtrl.showAjaxDialog({
url: web_app.name + '/sapCostCenter/showLoadCostCenterHis.load',
param:{id:row.id},
title: "编辑功能",
width: 800,
ok: function doSaveNodeFunction(div){
var _self=this;
$('#submitForm').ajaxSubmit({
url : web_app.name + '/sapCostCenter/saveCostCenter.ajax',
success : function() {
refreshFlag = true;
_self.close();
reloadGrid();
}
});
},
//关闭对话框
close:function dialogClose(){
if(refreshFlag){
refreshFlag=false;
}
},
});
}
//删除按钮
function deleteHandler() {
let row = DataUtil.getSelectedRow(gridManager);
if (row.isCostCenterHis != 1){
Public.tip("只能删除历史数据")
return false;
}
DataUtil.del({
action: 'sapCostCenter/deleteCostCenterById.ajax',
gridManager: gridManager, idFieldName: 'id',
......
......@@ -59,6 +59,8 @@ public class CostCenterApplicationImpl extends FlowBroker implements CostCenterA
queryModel.putDictionary("kosar", DictUtil.getDictionary("KOSAR"));
queryModel.putDictionary("prctr", DictUtil.getDictionary("PRCTR"));
queryModel.putDictionary("TYPE", DictUtil.getDictionary("TYPE"));
queryModel.putDictionary("isCostCenterHis",DictUtil.getDictionary("isCostCenterHis"));
queryModel.putDictionary("status",BizBillStatus.getMap());
Map<String, Object> map = this.sqlExecutorDao.executeSlicedQuery(queryModel);
return map;
}
......
package com.huigou.topsun.sap.costCenter.application.impl;
import com.huigou.cache.DictUtil;
import cn.hutool.core.bean.BeanUtil;
import com.huigou.cache.SystemCache;
import com.huigou.context.Operator;
import com.huigou.context.OrgUnit;
import com.huigou.context.ThreadLocalUtil;
import com.huigou.topsun.sap.costCenter.application.CostCenterApplication;
import com.huigou.topsun.sap.costCenter.domain.CostCenter;
import com.huigou.topsun.sap.costCenter.domain.TmpCostCenterData;
import com.huigou.topsun.sap.costCenter.repository.CostCenterRepository;
import com.huigou.topsun.sap.costCenter.repository.TmpCostCenterDataRepository;
import com.huigou.topsun.sap.fixedAssets.domain.TmpFixedAssessData;
import com.huigou.topsun.sap.fixedAssets.repository.TmpFixedAssessDataRepository;
import com.huigou.uasp.bmp.common.BizBillStatus;
import com.huigou.uasp.bmp.opm.application.OrgApplication;
import com.huigou.uasp.bmp.opm.domain.model.org.Org;
import com.huigou.uasp.bpm.ProcessAction;
import com.huigou.uasp.bpm.ProcessStartModel;
import com.huigou.uasp.bpm.engine.application.WorkflowApplication;
import com.huigou.uasp.tool.dataimport.application.ExcelImportInterface;
import com.huigou.util.Constants;
import com.huigou.util.SDO;
import com.huigou.util.StringUtil;
import org.activiti.engine.runtime.ProcessInstance;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Service("costCenterDataExcelImport")
public class CostCenterDataExcelImport implements ExcelImportInterface {
......@@ -27,39 +36,109 @@ public class CostCenterDataExcelImport implements ExcelImportInterface {
@Autowired
private TmpCostCenterDataRepository tmpCostCenterDataRepository;
@Autowired
private OrgApplication orgApplication;
private CostCenterRepository costCenterRepository;
@Autowired
private CostCenterApplication costCenterApplication;
private WorkflowApplication workflowApplication;
@Override
public void executeImport(String batchNumer) {
List<TmpCostCenterData> centerDataList = tmpCostCenterDataRepository.findByBatchNumber(batchNumer);
if (!CollectionUtils.isEmpty(centerDataList)){
List<CostCenter> costCenterList = new ArrayList<>();
for (TmpCostCenterData tmpCostCenterData : centerDataList) {
if (StringUtil.isBlank(tmpCostCenterData.getKostl())){
throw new RuntimeException("成本中心编码不能为空");
}
if (tmpCostCenterData.getKostl().length()!=10){
throw new RuntimeException("成本中心编码只能是10位");
}
if (StringUtil.isBlank(tmpCostCenterData.getKtext())){
throw new RuntimeException("成本中心名称不能为空");
}
if (StringUtil.isBlank(tmpCostCenterData.getKosar())){
throw new RuntimeException("成本中心类型不能为空");
}
if (StringUtil.isBlank(tmpCostCenterData.getKhinr())){
throw new RuntimeException("层次结构范围不能为空");
}
if (StringUtil.isBlank(tmpCostCenterData.getPrctr())){
throw new RuntimeException("利润中心不能为空");
}
if (tmpCostCenterData.getDatab() == null){
throw new RuntimeException("有效截至日不能为空");
}
if (tmpCostCenterData.getDatbi() == null){
throw new RuntimeException("有效期自不能为空");
}
List<CostCenter> centerList = costCenterRepository.findByKostl(tmpCostCenterData.getKostl());
if (!CollectionUtils.isEmpty(centerList)){
centerList.forEach(costCenter -> {
//判断相同成本中心编码的是不是已终止的单据,如果不是终止的提示已存在。
if (costCenter.getStatusId() != BizBillStatus.ABORTED.getId()){
throw new RuntimeException("已存在编码为:" + tmpCostCenterData.getKostl() + "的成本中心");
}
});
}
CostCenter costCenter = new CostCenter();
BeanUtils.copyProperties(tmpCostCenterData,costCenter);
costCenter.setIsDelete(0);
costCenter.setIsEnable(1);
//costCenter.setStatusId(BizBillStatus.COMPLETED.getId());
//Org org = orgApplication.loadMainOrgByLoginName(tmpCostCenterData.getCreatedCode());
//costCenter.setDefaultValues(new OrgUnit(org.getFullId(), org.getFullName()));
//costCenterApplication.saveCostCenter(costCenter);
costCenter.setId(null);
costCenterList.add(costCenter);
}
//发起流程
this.saveCostCenterImportVo(costCenterList);
}
}
public void saveCostCenterImportVo(List<CostCenter> costCenterList) {
for (CostCenter costCenter : costCenterList) {
//初始化用户信息
Operator operator = ThreadLocalUtil.getOperator();
costCenter.setDefaultValues(new OrgUnit(operator.getFullId(), operator.getFullName()));
String isCostCenterHis = SystemCache.getParameter("isCostCenterHis", String.class);
costCenter.setIsCostCenterHis(isCostCenterHis);
//标识是不是历史数据导入,如果是,则不需要发起流程
if ("1".equals(isCostCenterHis)){
costCenter.setTYPE("S");
costCenter.setMESSAGE("成本中心主数据创建成功!");
costCenter.setStatusId(BizBillStatus.COMPLETED.getId());
// String value = DictUtil.getDictionaryDetailValue("KOSAR", tmpCostCenterData.getKosar());
// if (StringUtil.isBlank(value)){
// throw new RuntimeException("未识别的成本中心类型");
// }
//costCenter.setKosar(tmpCostCenterData.getKosar());
// String prctr = DictUtil.getDictionaryDetailValue("PRCTR", tmpCostCenterData.getPrctr());
// if (StringUtil.isBlank(prctr)){
// throw new RuntimeException("未识别的利润中心类型");
// }
//costCenter.setPrctr(prctr);
if (StringUtil.isBlank(tmpCostCenterData.getCreatedCode())){
throw new RuntimeException("创建人编码不能为空");
}
Org org = orgApplication.loadMainOrgByLoginName(tmpCostCenterData.getCreatedCode());
costCenter.setDefaultValues(new OrgUnit(org.getFullId(), org.getFullName()));
costCenterApplication.saveCostCenter(costCenter);
}else {
Map<String, Object> formData = BeanUtil.beanToMap(costCenter);
SDO localSdo = this.buildSDO(formData,operator);
String bizId = this.startProcessInstance(CostCenterApplication.PROCESS_DEFINITION_KEY, localSdo);
costCenter.setId(bizId);
costCenter.setStatusId(BizBillStatus.APPLYING.getId());
}
}
costCenterRepository.save(costCenterList);
}
public String startProcessInstance(String processDefinitionKey,SDO localSdo){
Map<String, Object> variables = new HashMap();
ThreadLocalUtil.putVariable(Constants.SDO, localSdo);
variables.put("startModel", ProcessStartModel.MANUAL.getId());
Operator operator = localSdo.getOperator();
variables.put("executorFullId", operator.getFullId());
variables.put("executorFullName", operator.getFullName());
ThreadLocalUtil.putOperator(operator);
ThreadLocalUtil.putVariable("client.ip", "127.0.0.1");
ProcessInstance processInstance = this.workflowApplication.startProcessInstanceByKey(processDefinitionKey, variables);
return processInstance.getBusinessKey();
}
private SDO buildSDO(Map<String, Object> formData,Operator operator) {
SDO localSdo = new SDO();
// 将业务数据传递给工作流
formData.forEach(localSdo::putProperty);
// 将业务流程信息传递给工作流
localSdo.putProperty("processAction", ProcessAction.SAVE);
localSdo.putProperty("procUnitId", "Apply");
localSdo.setOperator(operator);
return localSdo;
}
}
......@@ -93,6 +93,13 @@ public class CostCenterController extends CommonController {
return forward("sapCostCenterDetail", costCenterVo);
}
public String showLoadCostCenterHis(){
SDO sdo = this.getSDO();
String id = sdo.getId();
CostCenterVo costCenterVo = costCenterApplication.findCostCenterById(id);
return forward("sapCostCenterHisDetail",costCenterVo);
}
/**
* 根据id获取成本中心信息
*
......@@ -121,6 +128,7 @@ public class CostCenterController extends CommonController {
costCenterVo.setId(null);
costCenterVo.setReason(null);
costCenterVo.setTelePhone(null);
costCenterVo.setIsCostCenterHis("0");
return forward("sapCostCenterDetail", costCenterVo);
}
......
......@@ -138,6 +138,12 @@ public class CostCenter extends FlowBillAbstractEntity {
@JsonProperty("LOG_NO")
private String LOG_NO;
/**
* 是否历史数据
*/
@Column(name = "is_cost_center_his")
private String isCostCenterHis;
@Override
protected String getCodeRuleId() {
return "sapCostCenter";
......
......@@ -94,4 +94,16 @@ public class TmpCostCenterData extends AbstractPortalOrg {
@Column(name = "created_name")
private String createdName;
/**
* 联系方式
*/
@Column(name = "tele_phone")
private String telePhone;
/**
* 创建原因 CHAR 100 手工输入
*/
@Column(name = "reason")
private String reason;
}
......@@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSON;
import com.huigou.topsun.sap.costCenter.domain.CostCenter;
import lombok.Data;
import javax.persistence.Column;
import java.io.Serializable;
import java.util.Date;
......@@ -106,6 +107,11 @@ public class CostCenterVo implements Serializable {
private String telePhone;
/**
* 是否历史数据
*/
private String isCostCenterHis;
public static CostCenterVo getCostCenterVo(CostCenter costCenter) {
return JSON.parseObject(JSON.toJSONString(costCenter), CostCenterVo.class);
}
......
......@@ -356,6 +356,8 @@ public class SuppliersDataApplicationImpl extends FlowBroker implements Supplier
//账户明细放18位后的值
bankVo.setBkref(bankn.substring(18,bankn.length()));
}
//财务机构名称赋值组织名称1
bankVo.setBanka(suppliersInfoVo.getNameOrg1());
bankVoList.add(bankVo);
}
suppliersInfoVo.setSuppliersBankList(bankVoList);
......
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