给采购和销售单据支持分批操作

This commit is contained in:
季圣华 2021-09-25 22:09:36 +08:00
parent 8484742420
commit 1604a3fde5
9 changed files with 101 additions and 22 deletions

View File

@ -60,11 +60,12 @@ public class BusinessConstants {
public static final String ENABLE_SERIAL_NUMBER_ENABLED = "1";
public static final String ENABLE_SERIAL_NUMBER_NOT_ENABLED = "0";
/**
* 单据状态 billsStatus '0'未审核 '1'审核 '2'已转采购|销售
* 单据状态 billsStatus '0'未审核 '1'审核 '2'完成采购|销售 '3'部分采购|销售
* */
public static final String BILLS_STATUS_UN_AUDIT = "0";
public static final String BILLS_STATUS_AUDIT = "1";
public static final String BILLS_STATUS_SKIP = "2";
public static final String BILLS_STATUS_SKIPED = "2";
public static final String BILLS_STATUS_SKIPING = "3";
/**
* 出入库分类
*采购采购退货其它零售销售调拨等

View File

@ -336,6 +336,9 @@ public class ExceptionConstants {
//单据反审核-只有已审核的单据才能反审核
public static final int DEPOT_HEAD_AUDIT_TO_UN_AUDIT_FAILED_CODE = 8500013;
public static final String DEPOT_HEAD_AUDIT_TO_UN_AUDIT_FAILED_MSG = "抱歉,只有已审核的单据才能反审核";
//单据录入-商品条码XXX的数量需要修改下
public static final int DEPOT_HEAD_NUMBER_NEED_EDIT_FAILED_CODE = 85000014;
public static final String DEPOT_HEAD_NUMBER_NEED_EDIT_FAILED_MSG = "商品条码%s的数量需要修改下";
/**
* 单据明细信息
* type = 90

View File

@ -197,6 +197,8 @@ public class DepotItemController {
item.put("sku", diEx.getSku());
item.put("operNumber", diEx.getOperNumber());
item.put("basicNumber", diEx.getBasicNumber());
item.put("preNumber", diEx.getOperNumber()); //原数量
item.put("finishNumber", depotItemService.getFinishNumber(diEx.getMaterialId(), diEx.getHeaderId())); //已入库|已出库
item.put("unitPrice", diEx.getUnitPrice());
item.put("taxUnitPrice", diEx.getTaxUnitPrice());
item.put("allPrice", diEx.getAllPrice());

View File

@ -22,7 +22,7 @@ public interface DepotHeadMapperEx {
@Param("type") String type,
@Param("subType") String subType,
@Param("creatorArray") String[] creatorArray,
@Param("status") String status,
@Param("statusArray") String[] statusArray,
@Param("number") String number,
@Param("beginTime") String beginTime,
@Param("endTime") String endTime,
@ -38,7 +38,7 @@ public interface DepotHeadMapperEx {
@Param("type") String type,
@Param("subType") String subType,
@Param("creatorArray") String[] creatorArray,
@Param("status") String status,
@Param("statusArray") String[] statusArray,
@Param("number") String number,
@Param("beginTime") String beginTime,
@Param("endTime") String endTime,

View File

@ -123,4 +123,9 @@ public interface DepotItemMapperEx {
int findStockWarningCountTotal(
@Param("materialParam") String materialParam,
@Param("depotId") Long depotId);
BigDecimal getFinishNumber(
@Param("mId") Long mId,
@Param("linkNumber") String linkNumber,
@Param("goToType") String goToType);
}

View File

@ -107,11 +107,12 @@ public class DepotHeadService {
try{
String [] depotArray = getDepotArray(subType);
String [] creatorArray = getCreatorArray(roleType);
String [] statusArray = StringUtil.isNotEmpty(status) ? status.split(",") : null;
Map<Long,String> personMap = personService.getPersonMap();
Map<Long,String> accountMap = accountService.getAccountMap();
beginTime = Tools.parseDayToTime(beginTime,BusinessConstants.DAY_FIRST_TIME);
endTime = Tools.parseDayToTime(endTime,BusinessConstants.DAY_LAST_TIME);
list=depotHeadMapperEx.selectByConditionDepotHead(type, subType, creatorArray, status, number, beginTime, endTime,
list=depotHeadMapperEx.selectByConditionDepotHead(type, subType, creatorArray, statusArray, number, beginTime, endTime,
materialParam, organId, creator, depotId, depotArray, offset, rows);
if (null != list) {
for (DepotHeadVo4List dh : list) {
@ -155,9 +156,10 @@ public class DepotHeadService {
try{
String [] depotArray = getDepotArray(subType);
String [] creatorArray = getCreatorArray(roleType);
String [] statusArray = StringUtil.isNotEmpty(status) ? status.split(",") : null;
beginTime = Tools.parseDayToTime(beginTime,BusinessConstants.DAY_FIRST_TIME);
endTime = Tools.parseDayToTime(endTime,BusinessConstants.DAY_LAST_TIME);
result=depotHeadMapperEx.countsByDepotHead(type, subType, creatorArray, status, number, beginTime, endTime,
result=depotHeadMapperEx.countsByDepotHead(type, subType, creatorArray, statusArray, number, beginTime, endTime,
materialParam, organId, creator, depotId, depotArray);
}catch(Exception e){
JshException.readFail(logger, e);
@ -723,18 +725,6 @@ public class DepotHeadService {
/**入库和出库处理单据子表信息*/
depotItemService.saveDetials(rows,headId, request);
}
/**如果关联单据号非空则更新订单的状态为2 (只操作采购订单和销售订单) */
if(depotHead.getLinkNumber()!=null) {
DepotHead depotHeadOrders = new DepotHead();
depotHeadOrders.setStatus(BusinessConstants.BILLS_STATUS_SKIP);
DepotHeadExample example = new DepotHeadExample();
example.createCriteria().andNumberEqualTo(depotHead.getLinkNumber()).andTypeEqualTo("其它");
try{
depotHeadMapper.updateByExampleSelective(depotHeadOrders, example);
}catch(Exception e){
JshException.writeFail(logger, e);
}
}
logService.insertLog("单据",
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_ADD).append(depotHead.getNumber()).toString(),
((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest());

View File

@ -320,6 +320,8 @@ public class DepotItemService {
}
//删除单据的明细
deleteDepotItemHeadId(headerId);
//单据状态:是否全部完成 2-全部完成 3-部分完成针对订单的分批出入库
String billStatus = BusinessConstants.BILLS_STATUS_SKIPED;
JSONArray rowArr = JSONArray.parseArray(rows);
if (null != rowArr && rowArr.size()>0) {
for (int i = 0; i < rowArr.size(); i++) {
@ -351,6 +353,17 @@ public class DepotItemService {
depotItem.setBasicNumber(oNumber); //其他情况
}
}
//如果数量+已完成数量<原订单数量代表该单据状态为未全部完成出入库
if (StringUtil.isExist(rowObj.get("preNumber")) && StringUtil.isExist(rowObj.get("finishNumber"))) {
BigDecimal preNumber = rowObj.getBigDecimal("preNumber");
BigDecimal finishNumber = rowObj.getBigDecimal("finishNumber");
if(depotItem.getOperNumber().add(finishNumber).compareTo(preNumber)<0) {
billStatus = BusinessConstants.BILLS_STATUS_SKIPING;
} else if(depotItem.getOperNumber().add(finishNumber).compareTo(preNumber)>0) {
throw new BusinessRunTimeException(ExceptionConstants.DEPOT_HEAD_NUMBER_NEED_EDIT_FAILED_CODE,
String.format(ExceptionConstants.DEPOT_HEAD_NUMBER_NEED_EDIT_FAILED_MSG, barCode));
}
}
if (StringUtil.isExist(rowObj.get("unitPrice"))) {
depotItem.setUnitPrice(rowObj.getBigDecimal("unitPrice"));
}
@ -425,12 +438,37 @@ public class DepotItemService {
//更新当前库存
updateCurrentStock(depotItem);
}
//如果关联单据号非空则更新订单的状态
if(StringUtil.isNotEmpty(depotHead.getLinkNumber())) {
changeBillStatus(depotHead, billStatus);
}
} else {
throw new BusinessRunTimeException(ExceptionConstants.DEPOT_HEAD_ROW_FAILED_CODE,
String.format(ExceptionConstants.DEPOT_HEAD_ROW_FAILED_MSG));
}
}
/**
* 更新单据状态
* @param depotHead
* @param billStatus
*/
public void changeBillStatus(DepotHead depotHead, String billStatus) {
DepotHead depotHeadOrders = new DepotHead();
depotHeadOrders.setStatus(billStatus);
DepotHeadExample example = new DepotHeadExample();
List<String> linkNumberList = StringUtil.strToStringList(depotHead.getLinkNumber());
example.createCriteria().andNumberIn(linkNumberList);
try{
depotHeadMapper.updateByExampleSelective(depotHeadOrders, example);
}catch(Exception e){
logger.error("异常码[{}],异常提示[{}],异常[{}]",
ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e);
throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE,
ExceptionConstants.DATA_WRITE_FAIL_MSG);
}
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public void deleteDepotItemHeadId(Long headerId)throws Exception {
DepotItemExample example = new DepotItemExample();
@ -597,4 +635,19 @@ public class DepotItemService {
}
}
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public BigDecimal getFinishNumber(Long mId, Long headerId) {
String goToType = "";
DepotHead depotHead =depotHeadMapper.selectByPrimaryKey(headerId);
String linkNumber = depotHead.getNumber(); //订单号
if(BusinessConstants.SUB_TYPE_PURCHASE_ORDER.equals(depotHead.getSubType())) {
goToType = BusinessConstants.SUB_TYPE_PURCHASE;
}
if(BusinessConstants.SUB_TYPE_SALES_ORDER.equals(depotHead.getSubType())) {
goToType = BusinessConstants.SUB_TYPE_SALES;
}
BigDecimal count = depotItemMapperEx.getFinishNumber(mId, linkNumber, goToType);
return count;
}
}

View File

@ -61,8 +61,12 @@
<if test="subType != null">
and dh.sub_type=#{subType}
</if>
<if test="status != null">
and dh.status =#{status}
<if test="statusArray != null and statusArray !=''">
and dh.status in (
<foreach collection="statusArray" item="status" separator=",">
#{status}
</foreach>
)
</if>
<if test="number != null">
<bind name="bindNumber" value="'%'+number+'%'"/>
@ -121,8 +125,12 @@
<if test="subType != null">
and dh.sub_type=#{subType}
</if>
<if test="status != null">
and dh.status =#{status}
<if test="statusArray != null and statusArray !=''">
and dh.status in (
<foreach collection="statusArray" item="status" separator=",">
#{status}
</foreach>
)
</if>
<if test="number != null">
<bind name="bindNumber" value="'%'+number+'%'"/>

View File

@ -456,4 +456,21 @@
</if>
group by m.id,m.name, m.model, m.unit, m.color, u.name) tb
</select>
<select id="getFinishNumber" resultType="java.math.BigDecimal">
select ifnull(sum(di.basic_number),0) from jsh_depot_item di
where di.material_id=#{mId}
and ifnull(di.delete_flag,'0') !='1'
and di.header_id
in
(
select dh.id from jsh_depot_head dh
where
dh.link_number=#{linkNumber}
and ifnull(dh.delete_flag,'0') !='1'
<if test="goToType != null">
and dh.sub_type=#{goToType}
</if>
)
</select>
</mapper>