供应链采购、验货、入库等模块修改

This commit is contained in:
liux 2025-10-22 18:37:20 +08:00
parent 61bdab8a4e
commit c78029805e
12 changed files with 190 additions and 27 deletions

View File

@ -14,6 +14,7 @@ import com.bonus.common.log.enums.OperaType;
//import com.bonus.canteen.core.ims.common.annotation.PreventRepeatSubmit;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
@ -35,7 +36,7 @@ import com.bonus.common.core.web.page.TableDataInfo;
/**
* 采购订单主Controller
*
*
* @author xsheng
* @date 2025-06-30
*/
@ -119,6 +120,20 @@ public class OrderGoodsController extends BaseController {
}
}
@ApiOperation(value = "结束采购订单主")
//@PreventRepeatSubmit
//@RequiresPermissions("ims:goods:edit")
@SysLog(title = "结束采购订单主", businessType = OperaType.UPDATE, logType = 1,module = "仓储管理->修改采购订单主")
@PostMapping("/finishOrder")
public AjaxResult finishOrder(@RequestBody OrderGoodsUpdate orderGoodsUpdate) {
try {
return toAjax(orderGoodsService.finishOrder(orderGoodsUpdate.getOrderGoodsId()+""));
} catch (Exception e) {
return error(e.getMessage());
}
}
/**
* 删除采购订单主
*/
@ -126,7 +141,7 @@ public class OrderGoodsController extends BaseController {
//@PreventRepeatSubmit
//@RequiresPermissions("ims:goods:remove")
@SysLog(title = "采购订单主", businessType = OperaType.DELETE, logType = 1,module = "仓储管理->删除采购订单主")
@PostMapping("/del/{orderGoodsIds}")
@PostMapping("/del/{ims_order_goods}")
public AjaxResult remove(@PathVariable Long[] orderGoodsIds) {
return toAjax(orderGoodsService.deleteOrderGoodsByOrderGoodsIds(orderGoodsIds));
}

View File

@ -42,7 +42,7 @@ public class OrderGoods extends BaseEntity {
/** 订单状态(1待提交,2已提交) */
@Excel(name = "订单状态(1待提交,2已提交)")
@ApiModelProperty(value = "订单状态(1待提交,2已提交)")
@ApiModelProperty(value = "订单状态(1待提交,2已提交,不允许修改4订单结束)")
private Long orderStatus;
/** 订单总金额 */
@ -195,4 +195,7 @@ public class OrderGoods extends BaseEntity {
@ApiModelProperty(value = "是否全部入库 1-是 2-否")
private Integer ifAllInto;
@ApiModelProperty(value = "页码/表单 默认为1")
private int pageOrForm = 1;
}

View File

@ -92,5 +92,7 @@ public class OrderGoodsQuery implements Serializable {
private Long warehouseId;
@ApiModelProperty(value = "页码/表单 默认为1")
private int pageOrForm = 1;
}

View File

@ -34,7 +34,7 @@ public class InspectGoodsSum {
private BigDecimal totalQualifiedNum;
/** 累计合格总数量 */
@ApiModelProperty(value = "货品累计合格总数量")
@ApiModelProperty(value = "货品累计合格(待入库)总数量")
private Map<Long, BigDecimal> individualTotalQualifiedNum;
@ApiModelProperty(value = "货品累计累计送货数量")

View File

@ -3,6 +3,7 @@ package com.bonus.canteen.core.ims.mapper;
import java.util.List;
import com.bonus.canteen.core.ims.domain.InspectGoodsDetail;
import com.bonus.canteen.core.ims.domain.vo.InspectGoodsDetailVO;
import org.apache.ibatis.annotations.Param;
/**
* 验货单明细Mapper接口
@ -27,6 +28,9 @@ public interface InspectGoodsDetailMapper {
*/
public List<InspectGoodsDetailVO> selectInspectGoodsDetailList(InspectGoodsDetail inspectGoodsDetail);
public List<InspectGoodsDetailVO> selectInspectGoodsDetailListByInspectGoodsId(Long inspectGoodsId);
/**
* 新增验货单明细
*
@ -62,4 +66,6 @@ public interface InspectGoodsDetailMapper {
public int deleteInspectGoodsDetailByInspectGoodsId(Long inspectGoodsId);
public int deleteInspectGoodsDetailByInspectGoodsIds(Long[] inspectGoodsIds);
String selectOrderGoodCodeByInspectGoodsId(@Param("inspectGoodsId") Long inspectGoodsId);
}

View File

@ -2,6 +2,7 @@ package com.bonus.canteen.core.ims.mapper;
import java.util.List;
import com.bonus.canteen.core.ims.domain.OrderGoods;
import com.bonus.canteen.core.ims.domain.param.OrderGoodsUpdate;
import com.bonus.canteen.core.ims.domain.vo.OrderGoodsVO;
import com.bonus.canteen.core.ims.dto.SupplyStatisticsDTO;
import com.bonus.canteen.core.ims.dto.SupplyStatisticsPageDTO;
@ -68,4 +69,6 @@ public interface OrderGoodsMapper {
OrderNumAndAmountModel selectOrderNumAndAmount(@Param("supplierId") Long supplierId, @Param("content") SupplyStatisticsDTO content, @Param("supplierConfirmStatus") Integer supplierConfirmStatus);
int finishOrder(String orderGoodsUpdate);
}

View File

@ -8,14 +8,14 @@ import com.bonus.canteen.core.ims.domain.vo.OrderGoodsVO;
/**
* 采购订单主Service接口
*
*
* @author xsheng
* @date 2025-06-30
*/
public interface IOrderGoodsService {
/**
* 查询采购订单主
*
*
* @param orderGoodsId 采购订单主主键
* @return 采购订单主
*/
@ -23,7 +23,7 @@ public interface IOrderGoodsService {
/**
* 查询采购订单主列表
*
*
* @param orderGoods 采购订单主
* @return 采购订单主集合
*/
@ -31,7 +31,7 @@ public interface IOrderGoodsService {
/**
* 新增采购订单主
*
*
* @param orderGoodsAdd 采购订单主
* @return 结果
*/
@ -39,7 +39,7 @@ public interface IOrderGoodsService {
/**
* 修改采购订单主
*
*
* @param orderGoodsUpdate 采购订单主
* @return 结果
*/
@ -47,7 +47,7 @@ public interface IOrderGoodsService {
/**
* 批量删除采购订单主
*
*
* @param orderGoodsIds 需要删除的采购订单主主键集合
* @return 结果
*/
@ -55,9 +55,11 @@ public interface IOrderGoodsService {
/**
* 删除采购订单主信息
*
*
* @param orderGoodsId 采购订单主主键
* @return 结果
*/
public int deleteOrderGoodsByOrderGoodsId(Long orderGoodsId);
int finishOrder(String orderGoodsUpdate);
}

View File

@ -59,6 +59,8 @@ public class ImsIntoInventoryServiceImpl implements IImsIntoInventoryService
@Resource
private ReportInventoryBaseMapper reportInventoryBaseMapper;
@ -106,6 +108,10 @@ public class ImsIntoInventoryServiceImpl implements IImsIntoInventoryService
@Override
public ImsIntoInventory insertImsIntoInventory(ImsIntoInventoryAdd imsIntoInventoryAdd)
{
//新增验货单 暂时不要了
// if(!Objects.isNull(imsIntoInventoryAdd.getRelateOrderGoodsId())) {
// addImsInspectGoods(imsIntoInventoryAdd);
// }
ImsIntoInventory imsIntoInventory = new ImsIntoInventory();
BeanUtils.copyProperties(imsIntoInventoryAdd, imsIntoInventory);
imsIntoInventory.setCreateTime(DateUtils.getNowDate());
@ -117,8 +123,6 @@ public class ImsIntoInventoryServiceImpl implements IImsIntoInventoryService
long intoType = imsIntoInventoryAdd.getIntoType();
System.err.println("intoType==================="+intoType);
if(intoType == 4) {
//新增验货单
ImsOutInventoryAdd imsOutInventoryAdd = new ImsOutInventoryAdd();
BeanUtils.copyProperties(imsIntoInventory, imsOutInventoryAdd);
imsOutInventoryAdd.setOutType(intoType);
@ -130,10 +134,35 @@ public class ImsIntoInventoryServiceImpl implements IImsIntoInventoryService
return imsIntoInventoryVO;
// return rows;
}
private void addImsInspectGoods(Long orderGoodsId){
OrderGoodsVO orderGoodsVO = orderGoodsService.selectOrderGoodsByOrderGoodsId(orderGoodsId);
List<OrderGoodsDetailVO> orderGoodsDetailList = orderGoodsVO.getOrderGoodsDetailList();
private void addImsInspectGoods(ImsIntoInventoryAdd imsIntoInventoryAdd){
InspectGoodsAdd inspectGoodsAdd = new InspectGoodsAdd();
inspectGoodsAdd.setInspectDate(imsIntoInventoryAdd.getIntoDate());
inspectGoodsAdd.setDeliverySupplierId(null);
inspectGoodsAdd.setDeliveryWarehouseId(imsIntoInventoryAdd.getWarehouseId());
inspectGoodsAdd.setDeliveryMan(SecurityUtils.getUsername());
inspectGoodsAdd.setDeliveryPhone(SecurityUtils.getLoginUser().getSysUser().getPhonenumber());
inspectGoodsAdd.setInspector(SecurityUtils.getUserKey());
inspectGoodsAdd.setRemark("导入采购订单入库生成验货单");
inspectGoodsAdd.setDeliveryTotalNum(imsIntoInventoryAdd.getTotalNum());
inspectGoodsAdd.setInspectQualifiedNum(imsIntoInventoryAdd.getTotalNum());
inspectGoodsAdd.setStatus(imsIntoInventoryAdd.getStatus());
inspectGoodsAdd.setRelateOrderGoodsId(imsIntoInventoryAdd.getRelateOrderGoodsId());
List<ImsIntoInventoryDetailAdd> imsIntoInventoryDetailAddList = imsIntoInventoryAdd.getImsIntoInventoryDetailAddList();
List<InspectGoodsDetailAdd> inspectGoodsDetails = new ArrayList<>();
for (ImsIntoInventoryDetailAdd bean:imsIntoInventoryDetailAddList) {
InspectGoodsDetailAdd inspectGoodsDetailAdd = new InspectGoodsDetailAdd();
inspectGoodsDetailAdd.setMaterialId(bean.getMaterialId());
inspectGoodsDetailAdd.setOrderNum(bean.getPurNum());
inspectGoodsDetailAdd.setQualifiedNum(bean.getPurNum());
inspectGoodsDetailAdd.setDeliveryNum(bean.getPurNum());
inspectGoodsDetailAdd.setUnitPrice(bean.getUnitPrice());
inspectGoodsDetails.add(inspectGoodsDetailAdd);
inspectGoodsAdd.setDeliverySupplierId(bean.getSupplierId());
}
inspectGoodsAdd.setInspectGoodsDetails(inspectGoodsDetails);
inspectGoodsService.insertInspectGoods(inspectGoodsAdd);
}
private List<ImsOutInventoryDetailAdd> getImsOutInventoryDetailAddList(List<ImsIntoInventoryDetail> imsIntoInventoryDetailAddList) {

View File

@ -5,6 +5,8 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.function.Function;
import java.util.stream.Collectors;
import cn.hutool.core.collection.CollUtil;
@ -14,6 +16,7 @@ import com.bonus.canteen.core.ims.domain.*;
import com.bonus.canteen.core.ims.domain.param.*;
import com.bonus.canteen.core.ims.domain.vo.*;
import com.bonus.canteen.core.ims.enums.SupplierOrderGenerateTypeEnum;
import com.bonus.canteen.core.ims.mapper.InspectGoodsDetailMapper;
import com.bonus.canteen.core.ims.mapper.OrderGoodsDetailMapper;
import com.bonus.canteen.core.ims.mapper.OrderGoodsMapper;
import com.bonus.canteen.core.ims.service.*;
@ -38,6 +41,9 @@ import org.springframework.transaction.annotation.Transactional;
public class InspectGoodsServiceImpl implements IInspectGoodsService {
@Autowired
private InspectGoodsMapper inspectGoodsMapper;
@Autowired
private InspectGoodsDetailMapper inspectGoodsDetailMapper;
@Autowired
private IInspectGoodsDetailService inspectGoodsDetailService;
@Autowired
@ -153,12 +159,22 @@ public class InspectGoodsServiceImpl implements IInspectGoodsService {
}
OrderGoodsVO orderGoodsVO = orderGoodsMapper.selectOrderGoodsByOrderGoodsCode(inspectGoods.getRelateOrderGoodsId());
this.selectOrderGoodsByOrderGoodsId(orderGoodsVO.getOrderGoodsId());
if(2L==inspectGoodsAdd.getStatus()){
updateOrderStatus(orderGoodsVO.getOrderGoodsId(),orderGoodsVO.getOrderGoodsCode());
}
return inspectGoods.getInspectGoodsId();
} catch (Exception e) {
throw new ServiceException(e.getMessage());
}
}
private void updateOrderStatus(Long orderGoodsId,String orderGoodsCode) {
OrderGoods orderGoodsVO_update = new OrderGoods();
orderGoodsVO_update.setOrderGoodsId(orderGoodsId);
orderGoodsVO_update.setOrderStatus(3L);
orderGoodsMapper.updateOrderGoods(orderGoodsVO_update);
}
/**
* 修改验货单
*
@ -211,6 +227,9 @@ public class InspectGoodsServiceImpl implements IInspectGoodsService {
}
OrderGoodsVO orderGoodsVO = orderGoodsMapper.selectOrderGoodsByOrderGoodsCode(inspectGoods.getRelateOrderGoodsId());
this.selectOrderGoodsByOrderGoodsId(orderGoodsVO.getOrderGoodsId());
if(2L==inspectGoodsUpdate.getStatus()){
updateOrderStatus(orderGoodsVO.getOrderGoodsId(),orderGoodsVO.getOrderGoodsCode());
}
return inspectGoodsMapper.updateInspectGoods(inspectGoods);
} catch (Exception e) {
throw new ServiceException(e.getMessage());
@ -301,8 +320,61 @@ public class InspectGoodsServiceImpl implements IInspectGoodsService {
@Override
@Transactional(rollbackFor = Exception.class)
public int deleteInspectGoodsByInspectGoodsIds(Long[] inspectGoodsIds) {
inspectGoodsDetailService.deleteInspectGoodsDetailByInspectGoodsIds(inspectGoodsIds);
return inspectGoodsMapper.deleteInspectGoodsByInspectGoodsIds(inspectGoodsIds);
try{
if(inspectGoodsIds !=null||inspectGoodsIds.length >0){
checkIfAllInspect(inspectGoodsIds[0]);
}
inspectGoodsDetailService.deleteInspectGoodsDetailByInspectGoodsIds(inspectGoodsIds);
inspectGoodsMapper.deleteInspectGoodsByInspectGoodsIds(inspectGoodsIds);
}catch (Exception e){
throw new ServiceException("删除验货单失败,存在关联数据");
}
return 1;
}
private void checkIfAllInspect( Long inspectGoodsIds) {
inspectGoodsDetailMapper.selectOrderGoodCodeByInspectGoodsId(inspectGoodsIds);
// orderGoodsMapper.updateOrderGoods(new OrderGoods(){
// {
// setOrderGoodsCode(inspectGoodsDetailMapper.selectOrderGoodCodeByInspectGoodsId(inspectGoodsIds));
// setIfAllInspect(2L);
// }
// });
// List<InspectGoodsDetailVO> list = inspectGoodsDetailMapper.selectInspectGoodsDetailListByInspectGoodsId(inspectGoodsIds);
// List<InspectGoodsDetailVO> distinctList = list.stream()
// .filter(Objects::nonNull)
// .collect(Collectors.collectingAndThen(
// Collectors.toMap(
// InspectGoodsDetailVO::getMaterialId,
// Function.identity(),
// (existing, replacement) -> existing // 保留第一个出现的
// ),
// map -> new ArrayList<>(map.values())
// ));
// AtomicBoolean tf = new AtomicBoolean(false);
// distinctList.forEach(inspectGoodsDetailVO -> {
// Long materialId = inspectGoodsDetailVO.getMaterialId();
// BigDecimal orderNum = inspectGoodsDetailVO.getOrderNum();
// BigDecimal deliveryNum = list.stream()
// .filter(vo -> vo != null && Objects.equals(vo.getMaterialId(), materialId))
// .map(InspectGoodsDetailVO::getDeliveryNum)
// .reduce(BigDecimal.ZERO, BigDecimal::add);
// System.err.println("订单数量:" + orderNum + " 送货数量:" + deliveryNum);
// if(deliveryNum.compareTo(orderNum) < 0){
// tf.set(true);
// }
//
// });
// if(tf.get()){
// orderGoodsMapper.updateOrderGoods(new OrderGoods(){
// {
// setOrderGoodsCode( inspectGoodsDetailMapper.selectOrderGoodCodeByInspectGoodsId(inspectGoodsIds));
// setIfAllInspect(1L);
// }
// });
// }
}
/**
@ -343,7 +415,7 @@ public class InspectGoodsServiceImpl implements IInspectGoodsService {
List<OrderGoodsDetailVO> orderGoodsDetailList = orderGoodsDetailMapper.selectOrderGoodsDetailByOrderGoodsCode(orderGoodsCode);
//计算累计合格数量
//累计合格(待入库)数量
Map<Long, BigDecimal> result = inspectGoodsDetailListTotal.stream()
.filter(detail -> detail.getMaterialId() != null && detail.getQualifiedNum() != null)
.collect(Collectors.groupingBy(
@ -355,7 +427,7 @@ public class InspectGoodsServiceImpl implements IInspectGoodsService {
));
inspectGoodsSum.setIndividualTotalQualifiedNum(result);
//累计货数量
//累计货数量
Map<Long, BigDecimal> totalDeliveryNum = inspectGoodsDetailListTotal.stream()
.filter(detail -> detail.getMaterialId() != null && detail.getDeliveryNum() != null)
.collect(Collectors.groupingBy(
@ -367,6 +439,7 @@ public class InspectGoodsServiceImpl implements IInspectGoodsService {
));
inspectGoodsSum.setIndividualDeliveryNum(totalDeliveryNum);
//累计入库数量
Map<Long, BigDecimal> totalIntoNum = orderGoodsDetailList.stream()
.filter(detail -> detail.getMaterialId() != null && detail.getIntoNum() != null)
.collect(Collectors.groupingBy(
@ -379,6 +452,7 @@ public class InspectGoodsServiceImpl implements IInspectGoodsService {
inspectGoodsSum.setIndividualIntoNum(totalIntoNum);
//累计订单数量
Map<Long, BigDecimal> totalOrderNum = orderGoodsDetailList.stream()
.filter(detail -> detail.getMaterialId() != null && detail.getOrderNum() != null)
.collect(Collectors.groupingBy(

View File

@ -212,6 +212,8 @@ public class OrderGoodsServiceImpl implements IOrderGoodsService {
}else{
orderGoodsVO.setTotalQualifiedNum(BigDecimal.ZERO);
}
}
}
return purchasePlanVOList;
@ -352,4 +354,9 @@ public class OrderGoodsServiceImpl implements IOrderGoodsService {
inspectGoodsDetailService.deleteOrderGoodsDetailByOrderGoodsId(orderGoodsId);
return orderGoodsMapper.deleteOrderGoodsByOrderGoodsId(orderGoodsId);
}
@Override
public int finishOrder(String orderGoodsUpdate) {
return orderGoodsMapper.finishOrder(orderGoodsUpdate);
}
}

View File

@ -58,12 +58,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</where>
order by iigd.inspect_goods_detail_id
</select>
<select id="selectInspectGoodsDetailByInspectGoodsDetailId" parameterType="Long" resultMap="InspectGoodsDetailResult">
<include refid="selectInspectGoodsDetailVo"/>
where iigd.inspect_goods_detail_id = #{inspectGoodsDetailId}
where iig.relate_order_goods_id = (
select DISTINCT relate_order_goods_id from ims_inspect_goods where inspect_goods_id = #{inspectGoodsId} limit 1
)
</select>
<insert id="insertInspectGoodsDetail" parameterType="com.bonus.canteen.core.ims.domain.InspectGoodsDetail" useGeneratedKeys="true" keyProperty="inspectGoodsDetailId">
insert into ims_inspect_goods_detail
<trim prefix="(" suffix=")" suffixOverrides=",">
@ -143,9 +145,20 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</delete>
<delete id="deleteInspectGoodsDetailByInspectGoodsDetailIds" parameterType="String">
delete from ims_inspect_goods_detail where inspect_goods_detail_id in
delete from ims_inspect_goods_detail where inspect_goods_detail_id in
<foreach item="inspectGoodsDetailId" collection="array" open="(" separator="," close=")">
#{inspectGoodsDetailId}
</foreach>
</delete>
</mapper>
<select id="selectOrderGoodCodeByInspectGoodsId" resultType="java.lang.String">
update ims_order_goods SET if_all_inspect = 2 where order_goods_code = (
select DISTINCT iig.relate_order_goods_id from ims_inspect_goods iig
where iig.inspect_goods_id = #{inspectGoodsId} limit 1)
</select>
<select id="selectInspectGoodsDetailListByInspectGoodsId" parameterType="Long" resultMap="InspectGoodsDetailResult">
<include refid="selectInspectGoodsDetailVo"/>
where iigd.inspect_goods_id = #{inspectGoodsId}
</select>
</mapper>

View File

@ -52,7 +52,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
iog.create_time, iog.update_by, iog.update_time, isr.supplier_name, iwi.warehouse_name,
ba.area_name, bc.canteen_name, bs.stall_name, contract_code, iogps.pay_money_date,
iogps.pay_money_style, iogps.collect_money_account, iogps.collect_money_account_name,
iogps.collect_money_bank, iog.supplier_id, iog.warehouse_id,IFNULL(iig.delivery_total_num,0) as total_qualified_num
iogps.collect_money_bank, iog.supplier_id, iog.warehouse_id,IFNULL(delivery_total_num,0) as total_qualified_num
from ims_order_goods iog
left join ims_order_goods_pay_style iogps on iogps.order_goods_id = iog.order_goods_code
left join ims_supplier isr on isr.supplier_id = iog.supplier_id
@ -73,6 +73,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<include refid="selectOrderGoodsVo"/>
<where>
iog.del_flag = '0'
<if test="pageOrForm == 1 ">
and order_status in (2,3)
</if>
<if test="isInspect != null and isInspect != '' and isInspect != 0 and isInspect != '0'.toString()">
and iog.if_all_inspect = #{isInspect}
</if>
@ -83,7 +87,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
and iig.delivery_total_num > 0
</if>
<if test="supplierId != null "> and iog.supplier_id = #{supplierId}</if>
<if test="orderStatus != null "> and iog.order_status = #{orderStatus}</if>
<!-- <if test="orderStatus != null "> and iog.order_status = #{orderStatus}</if>-->
<if test="orderAmount != null "> and iog.order_amount = #{orderAmount}</if>
<if test="requestArrivalTime != null "> and iog.request_arrival_time = #{requestArrivalTime}</if>
<if test="supplyAddress != null and supplyAddress != ''"> and iog.supply_address = #{supplyAddress}</if>
@ -274,4 +278,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
AND DATE_FORMAT( create_time, '%Y-%m-%d' ) <![CDATA[ <= ]]> #{content.endTime}
</if>
</select>
<update id="finishOrder" >
update ims_order_goods set order_status = 4 ,if_all_inspect = 1 ,if_all_into = 1
where order_goods_id = #{orderGoodsId}
</update>
</mapper>