增加强制结单的接口

This commit is contained in:
jishenghua
2025-04-08 22:25:20 +08:00
parent 96ce1e48a7
commit 65c517b335
3 changed files with 51 additions and 0 deletions

View File

@@ -445,6 +445,9 @@ public class ExceptionConstants {
//单据录入-单据最新状态不能进行批量操作 //单据录入-单据最新状态不能进行批量操作
public static final int DEPOT_ITEM_EXIST_NEW_STATUS_FAILED_CODE = 8500030; public static final int DEPOT_ITEM_EXIST_NEW_STATUS_FAILED_CODE = 8500030;
public static final String DEPOT_ITEM_EXIST_NEW_STATUS_FAILED_MSG = "抱歉,单据:%s最新状态不能进行批量操作"; public static final String DEPOT_ITEM_EXIST_NEW_STATUS_FAILED_MSG = "抱歉,单据:%s最新状态不能进行批量操作";
//单据录入-单据在该状态不能强制结单
public static final int DEPOT_HEAD_FORCE_CLOSE_FAILED_CODE = 8500031;
public static final String DEPOT_HEAD_FORCE_CLOSE_FAILED_MSG = "抱歉,单据:%s在该状态不能强制结单";
/** /**
* 单据明细信息 * 单据明细信息

View File

@@ -115,6 +115,19 @@ public class DepotHeadController extends BaseController {
return returnStr(objectMap, delete); return returnStr(objectMap, delete);
} }
@PostMapping(value = "/forceCloseBatch")
@ApiOperation(value = "强制结单")
public String forceCloseBatch(@RequestBody JSONObject jsonObject, HttpServletRequest request)throws Exception {
Map<String, Object> objectMap = new HashMap<>();
String ids = jsonObject.getString("ids");
int res = depotHeadService.batchForceClose(ids, request);
if(res > 0) {
return returnJson(objectMap, ErpInfo.OK.name, ErpInfo.OK.code);
} else {
return returnJson(objectMap, ErpInfo.ERROR.name, ErpInfo.ERROR.code);
}
}
/** /**
* 批量设置状态-审核或者反审核 * 批量设置状态-审核或者反审核
* @param jsonObject * @param jsonObject

View File

@@ -597,6 +597,41 @@ public class DepotHeadService {
return list==null?0:list.size(); return list==null?0:list.size();
} }
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int batchForceClose(String ids, HttpServletRequest request) throws Exception {
int result = 0;
StringBuilder billNoStr = new StringBuilder();
List<Long> idList = StringUtil.strToLongList(ids);
for(Long id: idList) {
DepotHead depotHead = getDepotHead(id);
//状态里面不包含部分不能强制结单
if(!"3".equals(depotHead.getStatus())) {
throw new BusinessRunTimeException(ExceptionConstants.DEPOT_HEAD_FORCE_CLOSE_FAILED_CODE,
String.format(ExceptionConstants.DEPOT_HEAD_FORCE_CLOSE_FAILED_MSG, depotHead.getNumber()));
} else {
billNoStr.append(depotHead.getNumber()).append(" ");
}
}
if(idList.size()>0) {
DepotHead depotHead = new DepotHead();
//完成状态
depotHead.setStatus("2");
//给备注后面追加:强制结单
String remark = StringUtil.isNotEmpty(depotHead.getRemark())? depotHead.getRemark() + "[强制结单]": "[强制结单]";
depotHead.setRemark(remark);
DepotHeadExample example = new DepotHeadExample();
example.createCriteria().andIdIn(idList);
result = depotHeadMapper.updateByExampleSelective(depotHead, example);
//记录日志
String billNos = billNoStr.toString();
if(StringUtil.isNotEmpty(billNos)) {
logService.insertLog("单据", "强制结单:" + billNos,
((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest());
}
}
return result;
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class) @Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int batchSetStatus(String status, String depotHeadIDs)throws Exception { public int batchSetStatus(String status, String depotHeadIDs)throws Exception {
int result = 0; int result = 0;