解决批量删除单据bug
This commit is contained in:
@@ -3,10 +3,7 @@ package com.jsh.erp.service.depotHead;
|
|||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.jsh.erp.constants.BusinessConstants;
|
import com.jsh.erp.constants.BusinessConstants;
|
||||||
import com.jsh.erp.constants.ExceptionConstants;
|
import com.jsh.erp.constants.ExceptionConstants;
|
||||||
import com.jsh.erp.datasource.entities.DepotHead;
|
import com.jsh.erp.datasource.entities.*;
|
||||||
import com.jsh.erp.datasource.entities.DepotHeadExample;
|
|
||||||
import com.jsh.erp.datasource.entities.DepotItem;
|
|
||||||
import com.jsh.erp.datasource.entities.User;
|
|
||||||
import com.jsh.erp.datasource.mappers.DepotHeadMapper;
|
import com.jsh.erp.datasource.mappers.DepotHeadMapper;
|
||||||
import com.jsh.erp.datasource.mappers.DepotHeadMapperEx;
|
import com.jsh.erp.datasource.mappers.DepotHeadMapperEx;
|
||||||
import com.jsh.erp.datasource.mappers.DepotItemMapperEx;
|
import com.jsh.erp.datasource.mappers.DepotItemMapperEx;
|
||||||
@@ -241,8 +238,30 @@ public class DepotHeadService {
|
|||||||
|
|
||||||
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
|
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
|
||||||
public int deleteDepotHead(Long id, HttpServletRequest request)throws Exception {
|
public int deleteDepotHead(Long id, HttpServletRequest request)throws Exception {
|
||||||
|
return batchDeleteBillByIds(id.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
|
||||||
|
public int batchDeleteDepotHead(String ids, HttpServletRequest request)throws Exception {
|
||||||
|
return batchDeleteBillByIds(ids);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
|
||||||
|
public int batchDeleteBillByIds(String ids)throws Exception {
|
||||||
int result=0;
|
int result=0;
|
||||||
try{
|
try{
|
||||||
|
StringBuffer sb = new StringBuffer();
|
||||||
|
sb.append(BusinessConstants.LOG_OPERATION_TYPE_DELETE);
|
||||||
|
List<DepotHead> dhList = getDepotHeadListByIds(ids);
|
||||||
|
for(DepotHead depotHead: dhList){
|
||||||
|
sb.append("[").append(depotHead.getNumber()).append("]");
|
||||||
|
}
|
||||||
|
logService.insertLog("单据", sb.toString(),
|
||||||
|
((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest());
|
||||||
|
if(StringUtil.isNotEmpty(ids)){
|
||||||
|
String [] headIds=ids.split(",");
|
||||||
|
for(int i=0;i<headIds.length;i++){
|
||||||
|
Long id = Long.parseLong(headIds[i]);
|
||||||
//查询单据主表信息
|
//查询单据主表信息
|
||||||
DepotHead depotHead =getDepotHead(id);
|
DepotHead depotHead =getDepotHead(id);
|
||||||
//只有未审核的单据才能被删除
|
//只有未审核的单据才能被删除
|
||||||
@@ -285,25 +304,7 @@ public class DepotHeadService {
|
|||||||
}
|
}
|
||||||
/**删除单据主表信息*/
|
/**删除单据主表信息*/
|
||||||
batchDeleteDepotHeadByIds(id.toString());
|
batchDeleteDepotHeadByIds(id.toString());
|
||||||
logService.insertLog("单据",
|
|
||||||
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_DELETE).append(depotHead.getNumber()).toString(),
|
|
||||||
((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest());
|
|
||||||
result = 1;
|
|
||||||
}
|
}
|
||||||
}catch(Exception e){
|
|
||||||
JshException.writeFail(logger, e);
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
|
|
||||||
public int batchDeleteDepotHead(String ids, HttpServletRequest request)throws Exception {
|
|
||||||
int result=0;
|
|
||||||
try{
|
|
||||||
if(StringUtil.isNotEmpty(ids)){
|
|
||||||
String [] headIds=ids.split(",");
|
|
||||||
for(int i=0;i<headIds.length;i++){
|
|
||||||
deleteDepotHead(Long.valueOf(headIds[i]), request);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
result = 1;
|
result = 1;
|
||||||
@@ -313,6 +314,12 @@ public class DepotHeadService {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除单据主表信息
|
||||||
|
* @param ids
|
||||||
|
* @return
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
|
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
|
||||||
public int batchDeleteDepotHeadByIds(String ids)throws Exception {
|
public int batchDeleteDepotHeadByIds(String ids)throws Exception {
|
||||||
User userInfo=userService.getCurrentUser();
|
User userInfo=userService.getCurrentUser();
|
||||||
@@ -326,6 +333,19 @@ public class DepotHeadService {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<DepotHead> getDepotHeadListByIds(String ids)throws Exception {
|
||||||
|
List<Long> idList = StringUtil.strToLongList(ids);
|
||||||
|
List<DepotHead> list = new ArrayList<>();
|
||||||
|
try{
|
||||||
|
DepotHeadExample example = new DepotHeadExample();
|
||||||
|
example.createCriteria().andIdIn(idList);
|
||||||
|
list = depotHeadMapper.selectByExample(example);
|
||||||
|
}catch(Exception e){
|
||||||
|
JshException.readFail(logger, e);
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
public int checkIsNameExist(Long id, String name)throws Exception {
|
public int checkIsNameExist(Long id, String name)throws Exception {
|
||||||
DepotHeadExample example = new DepotHeadExample();
|
DepotHeadExample example = new DepotHeadExample();
|
||||||
example.createCriteria().andIdNotEqualTo(id).andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
|
example.createCriteria().andIdNotEqualTo(id).andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
|
||||||
@@ -625,7 +645,6 @@ public class DepotHeadService {
|
|||||||
* 新增单据主表及单据子表信息
|
* 新增单据主表及单据子表信息
|
||||||
* @param beanJson
|
* @param beanJson
|
||||||
* @param rows
|
* @param rows
|
||||||
* @param tenantId
|
|
||||||
* @param request
|
* @param request
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
@@ -710,7 +729,6 @@ public class DepotHeadService {
|
|||||||
* 更新单据主表及单据子表信息
|
* 更新单据主表及单据子表信息
|
||||||
* @param beanJson
|
* @param beanJson
|
||||||
* @param rows
|
* @param rows
|
||||||
* @param tenantId
|
|
||||||
* @param request
|
* @param request
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user