Commit 4c42be93 authored by 赵汉亭's avatar 赵汉亭

成本中心新增、冻结接口完成

parent 817f7fd4
......@@ -33,16 +33,15 @@
<x:hidden name="statusId"/>
<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"/>
<x:inputC name="ltext" required="true" label="描述" labelCol="2" maxLength="64" fieldCol="4"/>
<x:inputC name="ktext" required="false" 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="false" label="成本中心类型" labelCol="2" dictionary="KOSAR" fieldCol="4"/>
<x:inputC name="datab" required="true" label="有限期自" labelCol="2" wrapper="date" fieldCol="4" value="2024-01-01"/>
<x:inputC name="datbi" required="true" label="有限截止日" labelCol="2" wrapper="date" fieldCol="4" value="9999-12-31"/>
<x:inputC name="verak" required="true" label="负责人" labelCol="2" maxLength="64" fieldCol="4"/>
<x:selectC name="prctr" required="true" label="利润中心" labelCol="2" dictionary="PRCTR" fieldCol="4"/>
<x:selectC name="formType" required="true" label="业务类型" labelCol="2" dictionary="formType" fieldCol="4"/>
<x:inputC name="telePhone" required="true" label="联系方式" labelCol="2" maxLength="64" fieldCol="4"/>
<x:inputC name="reason" required="true" label="原因" labelCol="2" maxLength="255" fieldCol="4"/>
<x:inputC name="datab" required="false" label="有限期自" labelCol="2" wrapper="date" fieldCol="4" value="2024-01-01"/>
<x:inputC name="datbi" required="false" label="有限截止日" labelCol="2" wrapper="date" fieldCol="4" value="9999-12-31"/>
<x:inputC name="verak" required="false" label="负责人" labelCol="2" maxLength="64" fieldCol="4"/>
<x:selectC name="prctr" required="false" 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>
......
......@@ -19,6 +19,7 @@ function loadCostCenterListGrid() {
updateHandler();
},
deleteHandler: deleteHandler,
disableHandler: disableHandler,
});
gridManager = UICtrl.grid("#sapCostCenterListGrid", {
columns: [
......@@ -35,7 +36,16 @@ function loadCostCenterListGrid() {
{display: "联系方式", name: "telePhone", width: 140, minWidth: 60, type: "string", align: "left"},
{display: "申请日期", name: "fillinDate", width: 140, minWidth: 60, type: "string", align: "left"},
{display: "原因", name: "reason", width: 140, minWidth: 60, type: "string", align: "left"},
{
display: "状态", name: "isDelete", width: 60, minWidth: 60, type: "string", align: "center",
render: function (item) {
return UICtrl.getStatusInfo(item.isDelete);
}
},
{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: 140, minWidth: 60, type: "string", align: "left"},
{display: "应用程序日志", name: "LOG_NO", width: 140, minWidth: 60, type: "string", align: "left"},
],
dataAction: "server",
url: web_app.name + '/sapCostCenter/slicedCostCenterList.ajax',
......@@ -87,7 +97,7 @@ function updateHandler(row) {
UICtrl.addTabItem({
tabid: 'CostCenterDetail',
text: "修改成本中心",
url: web_app.name + '/sapCostCenter/showCostCenterDetail.do?id='+row.id
url: web_app.name + '/sapCostCenter/showCostCenterDetail.do?id=' + row.id
})
}
......@@ -102,3 +112,14 @@ function deleteHandler() {
});
}
// 冻结按钮
function disableHandler() {
DataUtil.updateById({
action: 'sapCostCenter/updateCostCenterStatus.ajax',
gridManager: gridManager, idFieldName: 'id', param: {status: 0},
message: 'common.confirm.disable',
onSuccess: function () {
reloadGrid();
}
});
}
......@@ -21,10 +21,10 @@
<div id="layout">
<div position="center" title="成本中心">
<x:title title="common.button.search" hideTable="queryMainForm" isHide="true" />
<form class="hg-form ui-hide" method="post" action="" id="queryMainForm">
<x:inputC name="ruleKind" required="false" label="成本中心名称" labelCol="1"/>
<x:searchButtons />
</form>
<%-- <form class="hg-form ui-hide" method="post" action="" id="queryMainForm">--%>
<%-- <x:inputC name="ruleKind" required="false" label="成本中心名称" labelCol="1"/>--%>
<%-- <x:searchButtons />--%>
<%-- </form>--%>
<div class="blank_div clearfix"></div>
<div id="sapCostCenterListGrid" style="margin: 2px;"></div>
</div>
......
......@@ -2,6 +2,7 @@ package com.huigou.topsun.sap.costCenter.application;
import com.huigou.topsun.sap.costCenter.domain.CostCenter;
import com.huigou.topsun.sap.costCenter.domain.query.CostCenterQueryRequest;
import com.huigou.topsun.sap.costCenter.domain.vo.CostCenterMessageVo;
import com.huigou.topsun.sap.costCenter.domain.vo.CostCenterVo;
import java.util.List;
......@@ -32,4 +33,6 @@ public interface CostCenterApplication {
CostCenterVo saveAndUpdate(CostCenter costCenter);
Map<String, Object> slicedCostCenterList(CostCenterQueryRequest queryRequest);
int updateCostCenterStatus(List<String> ids);
}
package com.huigou.topsun.sap.costCenter.application.impl;
import cn.hutool.core.util.ObjectUtil;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.huigou.cache.DictUtil;
import com.huigou.cache.SystemCache;
import com.huigou.context.Operator;
import com.huigou.data.query.model.QueryDescriptor;
import com.huigou.data.query.model.QueryModel;
import com.huigou.topsun.sap.common.HttpClient;
import com.huigou.topsun.sap.costCenter.application.CostCenterApplication;
import com.huigou.topsun.sap.costCenter.domain.CostCenter;
import com.huigou.topsun.sap.costCenter.domain.query.CostCenterQueryRequest;
import com.huigou.topsun.sap.costCenter.domain.vo.CostCenterMessageVo;
import com.huigou.topsun.sap.costCenter.domain.vo.CostCenterReturnVo;
import com.huigou.topsun.sap.costCenter.domain.vo.CostCenterVo;
import com.huigou.topsun.sap.costCenter.repository.CostCenterRepository;
......@@ -21,8 +25,10 @@ import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.io.IOException;
import java.util.List;
import java.util.Map;
import java.util.concurrent.atomic.AtomicInteger;
/**
* @Auther: xin.lu
......@@ -35,12 +41,16 @@ public class CostCenterApplicationImpl extends FlowBroker implements CostCenterA
@Autowired
private CostCenterRepository costCenterRepository;
@Autowired
private HttpClient httpClient;
@Override
public Map<String, Object> getCostCenterList(CostCenterQueryRequest costCenterQueryRequest) {
QueryDescriptor queryDescriptor = this.sqlExecutorDao.getQuery(QUERY_XML_FILE_PATH, "costCenter");
QueryModel queryModel = this.sqlExecutorDao.getQueryModel(queryDescriptor, costCenterQueryRequest);
queryModel.putDictionary("kosar", DictUtil.getDictionary("KOSAR"));
queryModel.putDictionary("prctr", DictUtil.getDictionary("PRCTR"));
queryModel.putDictionary("TYPE", DictUtil.getDictionary("TYPE"));
Map<String, Object> map = this.sqlExecutorDao.executeSlicedQuery(queryModel);
return map;
}
......@@ -81,6 +91,32 @@ public class CostCenterApplicationImpl extends FlowBroker implements CostCenterA
return this.sqlExecutorDao.executeSlicedQuery(queryModel);
}
@Override
public int updateCostCenterStatus(List<String> ids) {
AtomicInteger flog = new AtomicInteger();
ids.forEach(id -> {
CostCenter costCenter = costCenterRepository.findOne(id);
String returnJSON = new StringBuilder().append("[")
.append("{")
.append("'ZYWLX':'F',")
.append("'KOSTL':'").append(costCenter.getKostl()).append("'")
.append("}")
.append("]")
.toString().replaceAll("'", "\"");
CostCenterMessageVo costCenterMessageVo = send(returnJSON);
if (!ObjectUtil.isEmpty(costCenterMessageVo) || costCenterMessageVo.getTYPE() == "S") {
// 冻结成功,修改状态
costCenter.setIsDelete(0);
flog.getAndIncrement();
}
BeanUtils.copyProperties(costCenterMessageVo, costCenter);
costCenterRepository.save(costCenter);
});
if (ids.size() == flog.intValue())
return 1;
return 0;
}
@Override
protected void onEnd(DelegateExecution delegateExecution) {
super.onEnd(delegateExecution);
......@@ -92,6 +128,26 @@ public class CostCenterApplicationImpl extends FlowBroker implements CostCenterA
// 封装JSON数据
String returnJSON = getReturnVo(costCenter);
// 向SAP发送数据
CostCenterMessageVo send = send(returnJSON);
}
/**
* 向SAP发送数据
*
* @param returnJSON
* @return 返回的消息
*/
private CostCenterMessageVo send(String returnJSON) {
String url = SystemCache.getParameter("sap.service.costCent.url", String.class);
CostCenterMessageVo costCenterMessageVo;
try {
String execute = httpClient.execute(returnJSON, url);
costCenterMessageVo = new ObjectMapper().readValue(execute, CostCenterMessageVo.class);
} catch (IOException e) {
throw new RuntimeException(e);
}
return costCenterMessageVo;
}
/**
......@@ -144,6 +200,22 @@ public class CostCenterApplicationImpl extends FlowBroker implements CostCenterA
Operator operator = this.getOperator();
BeanUtils.copyProperties(operator, costCenter);
costCenter.setStatusId(BizBillStatus.APPLYING.getId());
costCenter.setIsDelete(1);
// 向SAP发送新增数据
CostCenterReturnVo costCenterReturnVo = new CostCenterReturnVo();
BeanUtils.copyProperties(costCenter, costCenterReturnVo);
costCenterReturnVo.setZYWLX("A");
String returnJson = null;
try {
returnJson = new ObjectMapper().writeValueAsString(costCenterReturnVo);
} catch (JsonProcessingException e) {
throw new RuntimeException(e);
}
// 发送
CostCenterMessageVo costCenterMessageVo = send(returnJson);
BeanUtils.copyProperties(costCenterMessageVo, costCenter);
} else {
costCenter = (CostCenter) commonDomainService.loadAndFillinProperties(costCenter);
}
......
......@@ -156,4 +156,16 @@ public class CostCenterController extends CommonController {
Map<String, Object> model = memEasySearcher.search(mapList, easySearchParse, pageRequest, null);
return model;
}
/**
* 冻结成本中心
*/
public String updateCostCenterStatus() {
// TODO 需要向ICP发送冻结信息
List<String> ids = this.getSDO().getIds();
int flog = costCenterApplication.updateCostCenterStatus(ids);
if (flog == 1)
return success();
return error("失败");
}
}
package com.huigou.topsun.sap.costCenter.domain;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.huigou.data.domain.model.FlowBillAbstractEntity;
import com.topsunit.query.annotations.Dictionary;
import lombok.Data;
......@@ -80,9 +81,8 @@ public class CostCenter extends FlowBillAbstractEntity {
/**
* 业务类型
*/
@Column(name = "form_type")
@Dictionary("formType")
private String formType;
@Column(name = "is_delete")
private int isDelete;
/**
* 创建原因 CHAR 100 手工输入
......@@ -102,6 +102,8 @@ public class CostCenter extends FlowBillAbstractEntity {
* 消息类型: S 成功,E 错误,W 警告,I 信息,A 中断
*/
@Column(name = "TYPE")
@Dictionary("TYPE")
@JsonProperty("TYPE")
private String TYPE;
/**
* 消息类__ID
......@@ -112,16 +114,19 @@ public class CostCenter extends FlowBillAbstractEntity {
* 消息编号
*/
@Column(name = "NUMBER")
@JsonProperty("NUMBER")
private BigDecimal NUMBER;
/**
* 消息文本
*/
@Column(name = "MESSAGE")
@JsonProperty("MESSAGE")
private String MESSAGE;
/**
* 应用程序日志,日志号
*/
@Column(name = "LOG_NO")
@JsonProperty("LOG_NO")
private String LOG_NO;
@Override
......
......@@ -65,9 +65,9 @@ public class CostCenterQueryRequest extends QueryAbstractRequest {
private String prctr;
/**
* 业务类型
* 冻结0 启用1
*/
private String formType;
private String is_delete;
/**
* 创建原因 CHAR 100 手工输入
......
{
[
{
"ZYWLX": "F",
"KOSTL": "666666"
},
{
"KOSTL": "1",
"DATAB": "2023.12.28",
"DATBI": "2023.12.31",
......@@ -13,4 +18,5 @@
"deptName": "测试使用部门",
"personMemberName": "系统管理员",
"telePhone": "1"
}
\ No newline at end of file
}
]
\ No newline at end of file
package com.huigou.topsun.sap.costCenter.domain.vo;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
import javax.persistence.Column;
import java.math.BigDecimal;
/**
* title:
* author:ZHT
* date:2024/1/8
* description:
* 成本中心SAP返回消息封装类
*/
@Data
public class CostCenterMessageVo {
/**
* 消息类型: S 成功,E 错误,W 警告,I 信息,A 中断
*/
@Column(name = "TYPE")
@JsonProperty("TYPE")
private String TYPE;
/**
* 消息类__ID
*/
@Column(name = "message_id")
@JsonProperty("ID")
private String messageId;
/**
* 消息编号
*/
@Column(name = "NUMBER")
@JsonProperty("NUMBER")
private BigDecimal NUMBER;
/**
* 消息文本
*/
@Column(name = "MESSAGE")
@JsonProperty("MESSAGE")
private String MESSAGE;
/**
* 应用程序日志,日志号
*/
@Column(name = "LOG_NO")
@JsonProperty("LOG_NO")
private String LOG_NO;
}
......@@ -12,9 +12,14 @@ import java.util.Date;
* author:ZHT
* date:2023/12/29
* description:
* 成本中心新增-返回给SAP的封装类
*/
@JsonIgnoreProperties
public class CostCenterReturnVo implements Serializable {
/**
* 业务类型
*/
private String ZYWLX;
/**
* 成本中心编码
......@@ -73,29 +78,13 @@ public class CostCenterReturnVo implements Serializable {
@JsonProperty("PRCTR")
private String prctr;
/**
* 业务类型
*/
@JsonProperty("formType")
private String formType;
/**
* 创建原因 CHAR 100 手工输入
*/
@JsonProperty("reason")
private String reason;
@JsonProperty("fillinDate")
private Date fillinDate;
@JsonProperty("deptName")
private String deptName;
@JsonProperty("personMemberName")
private String personMemberName;
public String getZYWLX() {
return ZYWLX;
}
@JsonProperty("telePhone")
private String telePhone;
public void setZYWLX(String ZYWLX) {
this.ZYWLX = ZYWLX;
}
public String getKostl() {
return kostl;
......@@ -161,51 +150,19 @@ public class CostCenterReturnVo implements Serializable {
this.prctr = prctr;
}
public String getFormType() {
return formType;
}
public void setFormType(String formType) {
this.formType = formType;
}
public String getReason() {
return reason;
}
public void setReason(String reason) {
this.reason = reason;
}
public CostCenterReturnVo(String ZYWLX, String kostl, Date datab, Date datbi, String ktext, String ltext, String verak, String kosar, String prctr) {
public Date getFillinDate() {
return fillinDate;
}
public void setFillinDate(Date fillinDate) {
this.fillinDate = fillinDate;
}
public String getDeptName() {
return deptName;
}
public void setDeptName(String deptName) {
this.deptName = deptName;
}
public String getPersonMemberName() {
return personMemberName;
}
public void setPersonMemberName(String personMemberName) {
this.personMemberName = personMemberName;
}
public String getTelePhone() {
return telePhone;
this.ZYWLX = ZYWLX;
this.kostl = kostl;
this.datab = datab;
this.datbi = datbi;
this.ktext = ktext;
this.ltext = ltext;
this.verak = verak;
this.kosar = kosar;
this.prctr = prctr;
}
public void setTelePhone(String telePhone) {
this.telePhone = telePhone;
public CostCenterReturnVo() {
}
}
......@@ -2,12 +2,8 @@ package com.huigou.topsun.sap.costCenter.domain.vo;
import com.alibaba.fastjson.JSON;
import com.huigou.topsun.sap.costCenter.domain.CostCenter;
import com.topsunit.query.annotations.Dictionary;
import lombok.Data;
import javax.persistence.Column;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import java.io.Serializable;
import java.util.Date;
......@@ -71,9 +67,9 @@ public class CostCenterVo implements Serializable {
private String prctr;
/**
* 业务类型
* 冻结0 启用1
*/
private String formType;
private int isDelete;
/**
* 创建原因 CHAR 100 手工输入
......
......@@ -153,17 +153,25 @@ public class SapPriceMasterDataApplicationImpl extends FlowBroker implements Sap
param.put("VTWEG", queryRequest.getVtweg());
param.put("KUNNR", queryRequest.getKunnr());
param.put("MATNR", queryRequest.getMatnr());
String[] strings = new String[1];
try {
strings[0] = new ObjectMapper().writeValueAsString(param);
strings.toString();
} catch (JsonProcessingException e) {
throw new RuntimeException(e);
}
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append("[")
.append("{")
.append("KSCHL:").append(queryRequest.getKschl()).append(",")
.append("VKORG:").append(queryRequest.getVkorg()).append(",")
.append("VTWEG:").append(queryRequest.getVtweg()).append(",")
.append("KUNNR:").append(queryRequest.getKunnr()).append(",")
.append("MATNR:").append(queryRequest.getMatnr())
.append("}")
.append("]");
.append("'KSCHL':'").append(queryRequest.getKschl()).append("',")
.append("'VKORG':'").append(queryRequest.getVkorg()).append("',")
.append("'VTWEG':'").append(queryRequest.getVtweg()).append("',")
.append("'KUNNR':'").append(queryRequest.getKunnr()).append("',")
.append("'MATNR':'").append(queryRequest.getMatnr())
.append("'}")
.append("]")
.toString().replaceAll("'", "\"");
List<SapPriceMasterDataItem> sapPriceMasterDataItemList = null;
try {
// 调用接口,获取返回数据
......
......@@ -2,7 +2,7 @@
<query-mappings>
<query name="costCenter" label="成本中心表" table="sap_cost_center">
<sql-query>
select t.* from sap_cost_center t
select t.* from sap_cost_center t where t.is_delete = 1
</sql-query>
</query>
......
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