给所有单据都增加审核功能
This commit is contained in:
@@ -327,6 +327,9 @@ public class ExceptionConstants {
|
||||
//单据录入-调入仓库与原仓库不能重复
|
||||
public static final int DEPOT_HEAD_ANOTHER_DEPOT_EQUAL_FAILED_CODE = 8500010;
|
||||
public static final String DEPOT_HEAD_ANOTHER_DEPOT_EQUAL_FAILED_MSG = "调入仓库与原仓库不能重复";
|
||||
//单据删除-只有未审核的单据才能删除
|
||||
public static final int DEPOT_HEAD_UN_AUDIT_DELETE_FAILED_CODE = 8500011;
|
||||
public static final String DEPOT_HEAD_UN_AUDIT_DELETE_FAILED_MSG = "抱歉,只有未审核的单据才能删除";
|
||||
/**
|
||||
* 单据明细信息
|
||||
* type = 90
|
||||
@@ -356,6 +359,9 @@ public class ExceptionConstants {
|
||||
//单据录入-明细不能为空
|
||||
public static final int ACCOUNT_HEAD_ROW_FAILED_CODE = 9500003;
|
||||
public static final String ACCOUNT_HEAD_ROW_FAILED_MSG = "单据明细不能为空";
|
||||
//单据删除-只有未审核的单据才能删除
|
||||
public static final int ACCOUNT_HEAD_UN_AUDIT_DELETE_FAILED_CODE = 9500004;
|
||||
public static final String ACCOUNT_HEAD_UN_AUDIT_DELETE_FAILED_MSG = "抱歉,只有未审核的单据才能删除";
|
||||
/**
|
||||
* 财务明细信息
|
||||
* type = 100
|
||||
|
||||
@@ -7,6 +7,7 @@ import com.jsh.erp.datasource.entities.AccountHeadVo4Body;
|
||||
import com.jsh.erp.datasource.entities.AccountHeadVo4ListEx;
|
||||
import com.jsh.erp.service.accountHead.AccountHeadService;
|
||||
import com.jsh.erp.utils.BaseResponseInfo;
|
||||
import com.jsh.erp.utils.ErpInfo;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
@@ -17,6 +18,8 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static com.jsh.erp.utils.ResponseJsonUtil.returnJson;
|
||||
|
||||
/**
|
||||
* @author jishenghua 752*718*920
|
||||
*/
|
||||
@@ -28,6 +31,26 @@ public class AccountHeadController {
|
||||
@Resource
|
||||
private AccountHeadService accountHeadService;
|
||||
|
||||
/**
|
||||
* 批量设置状态-审核或者反审核
|
||||
* @param jsonObject
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
@PostMapping(value = "/batchSetStatus")
|
||||
public String batchSetStatus(@RequestBody JSONObject jsonObject,
|
||||
HttpServletRequest request) throws Exception{
|
||||
Map<String, Object> objectMap = new HashMap<>();
|
||||
String status = jsonObject.getString("status");
|
||||
String ids = jsonObject.getString("ids");
|
||||
int res = accountHeadService.batchSetStatus(status, ids);
|
||||
if(res > 0) {
|
||||
return returnJson(objectMap, ErpInfo.OK.name, ErpInfo.OK.code);
|
||||
} else {
|
||||
return returnJson(objectMap, ErpInfo.ERROR.name, ErpInfo.ERROR.code);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增财务主表及财务子表信息
|
||||
* @param body
|
||||
|
||||
@@ -30,6 +30,8 @@ public class AccountHead {
|
||||
|
||||
private String fileName;
|
||||
|
||||
private String status;
|
||||
|
||||
private Long tenantId;
|
||||
|
||||
private String deleteFlag;
|
||||
@@ -138,6 +140,14 @@ public class AccountHead {
|
||||
this.fileName = fileName == null ? null : fileName.trim();
|
||||
}
|
||||
|
||||
public String getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(String status) {
|
||||
this.status = status == null ? null : status.trim();
|
||||
}
|
||||
|
||||
public Long getTenantId() {
|
||||
return tenantId;
|
||||
}
|
||||
|
||||
@@ -926,6 +926,76 @@ public class AccountHeadExample {
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andStatusIsNull() {
|
||||
addCriterion("status is null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andStatusIsNotNull() {
|
||||
addCriterion("status is not null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andStatusEqualTo(String value) {
|
||||
addCriterion("status =", value, "status");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andStatusNotEqualTo(String value) {
|
||||
addCriterion("status <>", value, "status");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andStatusGreaterThan(String value) {
|
||||
addCriterion("status >", value, "status");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andStatusGreaterThanOrEqualTo(String value) {
|
||||
addCriterion("status >=", value, "status");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andStatusLessThan(String value) {
|
||||
addCriterion("status <", value, "status");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andStatusLessThanOrEqualTo(String value) {
|
||||
addCriterion("status <=", value, "status");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andStatusLike(String value) {
|
||||
addCriterion("status like", value, "status");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andStatusNotLike(String value) {
|
||||
addCriterion("status not like", value, "status");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andStatusIn(List<String> values) {
|
||||
addCriterion("status in", values, "status");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andStatusNotIn(List<String> values) {
|
||||
addCriterion("status not in", values, "status");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andStatusBetween(String value1, String value2) {
|
||||
addCriterion("status between", value1, value2, "status");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andStatusNotBetween(String value1, String value2) {
|
||||
addCriterion("status not between", value1, value2, "status");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andTenantIdIsNull() {
|
||||
addCriterion("tenant_id is null");
|
||||
return (Criteria) this;
|
||||
|
||||
@@ -2,13 +2,12 @@ package com.jsh.erp.service.accountHead;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.jsh.erp.constants.BusinessConstants;
|
||||
import com.jsh.erp.datasource.entities.AccountHead;
|
||||
import com.jsh.erp.datasource.entities.AccountHeadExample;
|
||||
import com.jsh.erp.datasource.entities.AccountHeadVo4ListEx;
|
||||
import com.jsh.erp.datasource.entities.User;
|
||||
import com.jsh.erp.constants.ExceptionConstants;
|
||||
import com.jsh.erp.datasource.entities.*;
|
||||
import com.jsh.erp.datasource.mappers.AccountHeadMapper;
|
||||
import com.jsh.erp.datasource.mappers.AccountHeadMapperEx;
|
||||
import com.jsh.erp.datasource.mappers.AccountItemMapperEx;
|
||||
import com.jsh.erp.exception.BusinessRunTimeException;
|
||||
import com.jsh.erp.exception.JshException;
|
||||
import com.jsh.erp.service.accountItem.AccountItemService;
|
||||
import com.jsh.erp.service.log.LogService;
|
||||
@@ -197,21 +196,20 @@ public class AccountHeadService {
|
||||
List<AccountHead> list = getAccountHeadListByIds(ids);
|
||||
for(AccountHead accountHead: list){
|
||||
sb.append("[").append(accountHead.getBillNo()).append("]");
|
||||
if("1".equals(accountHead.getStatus())) {
|
||||
throw new BusinessRunTimeException(ExceptionConstants.ACCOUNT_HEAD_UN_AUDIT_DELETE_FAILED_CODE,
|
||||
String.format(ExceptionConstants.ACCOUNT_HEAD_UN_AUDIT_DELETE_FAILED_MSG));
|
||||
}
|
||||
}
|
||||
logService.insertLog("财务", sb.toString(),
|
||||
((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest());
|
||||
User userInfo=userService.getCurrentUser();
|
||||
String [] idArray=ids.split(",");
|
||||
int result = 0;
|
||||
try{
|
||||
//删除主表
|
||||
result = accountItemMapperEx.batchDeleteAccountItemByHeadIds(new Date(),userInfo==null?null:userInfo.getId(),idArray);
|
||||
//删除子表
|
||||
result = accountHeadMapperEx.batchDeleteAccountHeadByIds(new Date(),userInfo==null?null:userInfo.getId(),idArray);
|
||||
}catch(Exception e){
|
||||
JshException.writeFail(logger, e);
|
||||
}
|
||||
return result;
|
||||
//删除主表
|
||||
accountItemMapperEx.batchDeleteAccountItemByHeadIds(new Date(),userInfo==null?null:userInfo.getId(),idArray);
|
||||
//删除子表
|
||||
accountHeadMapperEx.batchDeleteAccountHeadByIds(new Date(),userInfo==null?null:userInfo.getId(),idArray);
|
||||
logService.insertLog("财务", sb.toString(),
|
||||
((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest());
|
||||
return 1;
|
||||
}
|
||||
|
||||
public int checkIsNameExist(Long id, String name)throws Exception {
|
||||
@@ -226,11 +224,45 @@ public class AccountHeadService {
|
||||
return list==null?0:list.size();
|
||||
}
|
||||
|
||||
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
|
||||
public int batchSetStatus(String status, String accountHeadIds)throws Exception {
|
||||
int result = 0;
|
||||
try{
|
||||
List<Long> ahIds = new ArrayList<>();
|
||||
List<Long> ids = StringUtil.strToLongList(accountHeadIds);
|
||||
for(Long id: ids) {
|
||||
AccountHead accountHead = getAccountHead(id);
|
||||
if("0".equals(status)){
|
||||
if("1".equals(accountHead.getStatus())) {
|
||||
ahIds.add(id);
|
||||
}
|
||||
} else if("1".equals(status)){
|
||||
if("0".equals(accountHead.getStatus())) {
|
||||
ahIds.add(id);
|
||||
}
|
||||
}
|
||||
}
|
||||
if(ahIds.size()>0) {
|
||||
AccountHead accountHead = new AccountHead();
|
||||
accountHead.setStatus(status);
|
||||
AccountHeadExample example = new AccountHeadExample();
|
||||
example.createCriteria().andIdIn(ahIds);
|
||||
result = accountHeadMapper.updateByExampleSelective(accountHead, example);
|
||||
} else {
|
||||
return 1;
|
||||
}
|
||||
}catch(Exception e){
|
||||
JshException.writeFail(logger, e);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
|
||||
public void addAccountHeadAndDetail(String beanJson, String rows, HttpServletRequest request) throws Exception {
|
||||
AccountHead accountHead = JSONObject.parseObject(beanJson, AccountHead.class);
|
||||
User userInfo=userService.getCurrentUser();
|
||||
accountHead.setCreator(userInfo==null?null:userInfo.getId());
|
||||
accountHead.setStatus(BusinessConstants.BILLS_STATUS_UN_AUDIT);
|
||||
accountHeadMapper.insertSelective(accountHead);
|
||||
//根据单据编号查询单据id
|
||||
AccountHeadExample dhExample = new AccountHeadExample();
|
||||
|
||||
@@ -106,7 +106,7 @@ public class DepotHeadService {
|
||||
List<DepotHeadVo4List> list=new ArrayList<>();
|
||||
try{
|
||||
String depotIds = depotService.findDepotStrByCurrentUser();
|
||||
String [] depotArray=depotIds.split(",");
|
||||
String [] depotArray=StringUtil.isNotEmpty(depotIds)?depotIds.split(","):null;
|
||||
String [] creatorArray = getCreatorArray(roleType);
|
||||
Map<Long,String> personMap = personService.getPersonMap();
|
||||
Map<Long,String> accountMap = accountService.getAccountMap();
|
||||
@@ -155,7 +155,7 @@ public class DepotHeadService {
|
||||
Long result=null;
|
||||
try{
|
||||
String depotIds = depotService.findDepotStrByCurrentUser();
|
||||
String [] depotArray=depotIds.split(",");
|
||||
String [] depotArray=StringUtil.isNotEmpty(depotIds)?depotIds.split(","):null;
|
||||
String [] creatorArray = getCreatorArray(roleType);
|
||||
beginTime = Tools.parseDayToTime(beginTime,BusinessConstants.DAY_FIRST_TIME);
|
||||
endTime = Tools.parseDayToTime(endTime,BusinessConstants.DAY_LAST_TIME);
|
||||
@@ -248,70 +248,59 @@ public class DepotHeadService {
|
||||
|
||||
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
|
||||
public int batchDeleteBillByIds(String ids)throws Exception {
|
||||
int result=0;
|
||||
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);
|
||||
//只有未审核的单据才能被删除
|
||||
if("0".equals(depotHead.getStatus())) {
|
||||
User userInfo = userService.getCurrentUser();
|
||||
//删除出库数据回收序列号
|
||||
if (BusinessConstants.DEPOTHEAD_TYPE_OUT.equals(depotHead.getType())
|
||||
&& !BusinessConstants.SUB_TYPE_TRANSFER.equals(depotHead.getSubType())) {
|
||||
//查询单据子表列表
|
||||
List<DepotItem> depotItemList = null;
|
||||
try {
|
||||
depotItemList = depotItemMapperEx.findDepotItemListBydepotheadId(id, BusinessConstants.ENABLE_SERIAL_NUMBER_ENABLED);
|
||||
} catch (Exception e) {
|
||||
JshException.readFail(logger, e);
|
||||
}
|
||||
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("]");
|
||||
//只有未审核的单据才能被删除
|
||||
if("0".equals(depotHead.getStatus())) {
|
||||
User userInfo = userService.getCurrentUser();
|
||||
//删除出库数据回收序列号
|
||||
if (BusinessConstants.DEPOTHEAD_TYPE_OUT.equals(depotHead.getType())
|
||||
&& !BusinessConstants.SUB_TYPE_TRANSFER.equals(depotHead.getSubType())) {
|
||||
//查询单据子表列表
|
||||
List<DepotItem> depotItemList = null;
|
||||
try {
|
||||
depotItemList = depotItemMapperEx.findDepotItemListBydepotheadId(depotHead.getId(), BusinessConstants.ENABLE_SERIAL_NUMBER_ENABLED);
|
||||
} catch (Exception e) {
|
||||
JshException.readFail(logger, e);
|
||||
}
|
||||
|
||||
/**回收序列号*/
|
||||
if (depotItemList != null && depotItemList.size() > 0) {
|
||||
for (DepotItem depotItem : depotItemList) {
|
||||
//BasicNumber=OperNumber*ratio
|
||||
serialNumberService.cancelSerialNumber(depotItem.getMaterialId(), depotItem.getHeaderId(), (depotItem.getBasicNumber() == null ? 0 : depotItem.getBasicNumber()).intValue(), userInfo);
|
||||
}
|
||||
}
|
||||
/**回收序列号*/
|
||||
if (depotItemList != null && depotItemList.size() > 0) {
|
||||
for (DepotItem depotItem : depotItemList) {
|
||||
//BasicNumber=OperNumber*ratio
|
||||
serialNumberService.cancelSerialNumber(depotItem.getMaterialId(), depotItem.getHeaderId(), (depotItem.getBasicNumber() == null ? 0 : depotItem.getBasicNumber()).intValue(), userInfo);
|
||||
}
|
||||
//对于零售出库单据,更新会员的预收款信息
|
||||
if (BusinessConstants.DEPOTHEAD_TYPE_OUT.equals(depotHead.getType())
|
||||
&& BusinessConstants.SUB_TYPE_RETAIL.equals(depotHead.getSubType())){
|
||||
if(BusinessConstants.PAY_TYPE_PREPAID.equals(depotHead.getPayType())) {
|
||||
if (depotHead.getOrganId() != null) {
|
||||
supplierService.updateAdvanceIn(depotHead.getOrganId(), depotHead.getTotalPrice().abs());
|
||||
}
|
||||
}
|
||||
}
|
||||
/**删除单据子表数据*/
|
||||
depotItemMapperEx.batchDeleteDepotItemByDepotHeadIds(new Long[]{id});
|
||||
//更新当前库存
|
||||
List<DepotItem> list = depotItemService.getListByHeaderId(id);
|
||||
for (DepotItem depotItem : list) {
|
||||
depotItemService.updateCurrentStock(depotItem);
|
||||
}
|
||||
/**删除单据主表信息*/
|
||||
batchDeleteDepotHeadByIds(id.toString());
|
||||
}
|
||||
}
|
||||
//对于零售出库单据,更新会员的预收款信息
|
||||
if (BusinessConstants.DEPOTHEAD_TYPE_OUT.equals(depotHead.getType())
|
||||
&& BusinessConstants.SUB_TYPE_RETAIL.equals(depotHead.getSubType())){
|
||||
if(BusinessConstants.PAY_TYPE_PREPAID.equals(depotHead.getPayType())) {
|
||||
if (depotHead.getOrganId() != null) {
|
||||
supplierService.updateAdvanceIn(depotHead.getOrganId(), depotHead.getTotalPrice().abs());
|
||||
}
|
||||
}
|
||||
}
|
||||
/**删除单据子表数据*/
|
||||
depotItemMapperEx.batchDeleteDepotItemByDepotHeadIds(new Long[]{depotHead.getId()});
|
||||
//更新当前库存
|
||||
List<DepotItem> list = depotItemService.getListByHeaderId(depotHead.getId());
|
||||
for (DepotItem depotItem : list) {
|
||||
depotItemService.updateCurrentStock(depotItem);
|
||||
}
|
||||
/**删除单据主表信息*/
|
||||
batchDeleteDepotHeadByIds(depotHead.getId().toString());
|
||||
} else {
|
||||
throw new BusinessRunTimeException(ExceptionConstants.DEPOT_HEAD_UN_AUDIT_DELETE_FAILED_CODE,
|
||||
String.format(ExceptionConstants.DEPOT_HEAD_UN_AUDIT_DELETE_FAILED_MSG));
|
||||
}
|
||||
result = 1;
|
||||
}catch(Exception e){
|
||||
JshException.writeFail(logger, e);
|
||||
}
|
||||
return result;
|
||||
logService.insertLog("单据", sb.toString(),
|
||||
((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest());
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user