优化单据新增和更新接口

This commit is contained in:
季圣华
2020-10-13 01:17:45 +08:00
parent 73ad4dc2bb
commit 247fe119c4
4 changed files with 8 additions and 25 deletions

View File

@@ -1353,8 +1353,6 @@
} }
this.endAllEdit(); this.endAllEdit();
var inserted = $("#materialData").datagrid('getRows'); var inserted = $("#materialData").datagrid('getRows');
var deleted = [];
var updated = [];
$.ajax({ $.ajax({
type:"post", type:"post",
url: url, url: url,
@@ -1363,9 +1361,7 @@
async : false, async : false,
data: JSON.stringify({ data: JSON.stringify({
info:infoStr, info:infoStr,
inserted: JSON.stringify(inserted), inserted: JSON.stringify(inserted)
deleted: JSON.stringify(deleted),
updated: JSON.stringify(updated)
}), }),
success: function (tipInfo){ success: function (tipInfo){
if(tipInfo){ if(tipInfo){
@@ -1396,8 +1392,6 @@
var self = this; var self = this;
this.endAllEdit(); this.endAllEdit();
var inserted = $("#materialData").datagrid('getRows'); var inserted = $("#materialData").datagrid('getRows');
var deleted = [];
var updated = [];
$.ajax({ $.ajax({
type:"post", type:"post",
url: url, url: url,
@@ -1408,8 +1402,6 @@
id:url.substring(url.lastIndexOf("?id=")+4,url.length), id:url.substring(url.lastIndexOf("?id=")+4,url.length),
info:infoStr, info:infoStr,
inserted: JSON.stringify(inserted), inserted: JSON.stringify(inserted),
deleted: JSON.stringify(deleted),
updated: JSON.stringify(updated),
preTotalPrice:preTotalPrice preTotalPrice:preTotalPrice
}), }),
success: function (tipInfo){ success: function (tipInfo){

View File

@@ -342,8 +342,6 @@ public class DepotHeadController {
JSONObject result = ExceptionConstants.standardSuccess(); JSONObject result = ExceptionConstants.standardSuccess();
String beanJson = body.getInfo(); String beanJson = body.getInfo();
String inserted = body.getInserted(); String inserted = body.getInserted();
String deleted = body.getDeleted();
String updated = body.getUpdated();
Long billsNumLimit = Long.parseLong(request.getSession().getAttribute("billsNumLimit").toString()); Long billsNumLimit = Long.parseLong(request.getSession().getAttribute("billsNumLimit").toString());
Long tenantId = Long.parseLong(request.getSession().getAttribute("tenantId").toString()); Long tenantId = Long.parseLong(request.getSession().getAttribute("tenantId").toString());
Long count = depotHeadService.countDepotHead(null,null,null,null,null,null,null,null); Long count = depotHeadService.countDepotHead(null,null,null,null,null,null,null,null);
@@ -351,7 +349,7 @@ public class DepotHeadController {
throw new BusinessParamCheckingException(ExceptionConstants.DEPOT_HEAD_OVER_LIMIT_FAILED_CODE, throw new BusinessParamCheckingException(ExceptionConstants.DEPOT_HEAD_OVER_LIMIT_FAILED_CODE,
ExceptionConstants.DEPOT_HEAD_OVER_LIMIT_FAILED_MSG); ExceptionConstants.DEPOT_HEAD_OVER_LIMIT_FAILED_MSG);
} else { } else {
depotHeadService.addDepotHeadAndDetail(beanJson,inserted,deleted,updated,tenantId, request); depotHeadService.addDepotHeadAndDetail(beanJson,inserted,tenantId, request);
} }
return result; return result;
} }
@@ -370,10 +368,8 @@ public class DepotHeadController {
Long id = body.getId(); Long id = body.getId();
String beanJson = body.getInfo(); String beanJson = body.getInfo();
String inserted = body.getInserted(); String inserted = body.getInserted();
String deleted = body.getDeleted();
String updated = body.getUpdated();
BigDecimal preTotalPrice = body.getPreTotalPrice(); BigDecimal preTotalPrice = body.getPreTotalPrice();
depotHeadService.updateDepotHeadAndDetail(id,beanJson,inserted,deleted,updated,preTotalPrice,tenantId,request); depotHeadService.updateDepotHeadAndDetail(id,beanJson,inserted,preTotalPrice,tenantId,request);
return result; return result;
} }

View File

@@ -470,14 +470,12 @@ public class DepotHeadService {
* 新增单据主表及单据子表信息 * 新增单据主表及单据子表信息
* @param beanJson * @param beanJson
* @param inserted * @param inserted
* @param deleted
* @param updated
* @param tenantId * @param tenantId
* @param request * @param request
* @throws Exception * @throws Exception
*/ */
@Transactional(value = "transactionManager", rollbackFor = Exception.class) @Transactional(value = "transactionManager", rollbackFor = Exception.class)
public void addDepotHeadAndDetail(String beanJson, String inserted, String deleted, String updated,Long tenantId, public void addDepotHeadAndDetail(String beanJson, String inserted, Long tenantId,
HttpServletRequest request) throws Exception { HttpServletRequest request) throws Exception {
/**处理单据主表数据*/ /**处理单据主表数据*/
DepotHead depotHead = JSONObject.parseObject(beanJson, DepotHead.class); DepotHead depotHead = JSONObject.parseObject(beanJson, DepotHead.class);
@@ -504,7 +502,7 @@ public class DepotHeadService {
if(list!=null) { if(list!=null) {
Long headId = list.get(0).getId(); Long headId = list.get(0).getId();
/**入库和出库处理单据子表信息*/ /**入库和出库处理单据子表信息*/
depotItemService.saveDetials(inserted,deleted,updated,headId,tenantId, request); depotItemService.saveDetials(inserted,headId,tenantId, request);
} }
/**如果关联单据号非空则更新订单的状态为2 */ /**如果关联单据号非空则更新订单的状态为2 */
if(depotHead.getLinkNumber()!=null) { if(depotHead.getLinkNumber()!=null) {
@@ -528,15 +526,13 @@ public class DepotHeadService {
* @param id * @param id
* @param beanJson * @param beanJson
* @param inserted * @param inserted
* @param deleted
* @param updated
* @param preTotalPrice * @param preTotalPrice
* @param tenantId * @param tenantId
* @param request * @param request
* @throws Exception * @throws Exception
*/ */
@Transactional(value = "transactionManager", rollbackFor = Exception.class) @Transactional(value = "transactionManager", rollbackFor = Exception.class)
public void updateDepotHeadAndDetail(Long id, String beanJson, String inserted, String deleted, String updated, public void updateDepotHeadAndDetail(Long id, String beanJson, String inserted,
BigDecimal preTotalPrice, Long tenantId,HttpServletRequest request)throws Exception { BigDecimal preTotalPrice, Long tenantId,HttpServletRequest request)throws Exception {
/**更新单据主表信息*/ /**更新单据主表信息*/
DepotHead depotHead = JSONObject.parseObject(beanJson, DepotHead.class); DepotHead depotHead = JSONObject.parseObject(beanJson, DepotHead.class);
@@ -554,7 +550,7 @@ public class DepotHeadService {
} }
} }
/**入库和出库处理单据子表信息*/ /**入库和出库处理单据子表信息*/
depotItemService.saveDetials(inserted,deleted,updated,depotHead.getId(),tenantId,request); depotItemService.saveDetials(inserted,depotHead.getId(),tenantId,request);
logService.insertLog("单据", logService.insertLog("单据",
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_EDIT).append(depotHead.getNumber()).toString(), new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_EDIT).append(depotHead.getNumber()).toString(),
((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest()); ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest());

View File

@@ -296,7 +296,7 @@ public class DepotItemService {
} }
@Transactional(value = "transactionManager", rollbackFor = Exception.class) @Transactional(value = "transactionManager", rollbackFor = Exception.class)
public String saveDetials(String inserted, String deleted, String updated, Long headerId, Long tenantId, HttpServletRequest request) throws Exception{ public String saveDetials(String inserted, Long headerId, Long tenantId, HttpServletRequest request) throws Exception{
//查询单据主表信息 //查询单据主表信息
DepotHead depotHead=null; DepotHead depotHead=null;
try{ try{
@@ -308,7 +308,6 @@ public class DepotItemService {
User userInfo=userService.getCurrentUser(); User userInfo=userService.getCurrentUser();
//转为json //转为json
JSONArray insertedJson = JSONArray.parseArray(inserted); JSONArray insertedJson = JSONArray.parseArray(inserted);
JSONArray deletedJson = JSONArray.parseArray(deleted);
//删除单据的明细 //删除单据的明细
deleteDepotItemHeadId(headerId); deleteDepotItemHeadId(headerId);