| | |
| | | package zy.cloud.wms.common.utils; |
| | | |
| | | import zy.cloud.wms.manager.entity.Comb; |
| | | import zy.cloud.wms.manager.entity.LocDetl; |
| | | import zy.cloud.wms.manager.entity.Mat; |
| | | import zy.cloud.wms.manager.entity.Pakout; |
| | | import zy.cloud.wms.manager.entity.*; |
| | | |
| | | /** |
| | | * Created by vincent on 2020/7/14 |
| | |
| | | locDetl.setDocNum(pakout.getDocNum()); |
| | | } |
| | | |
| | | public static void setOrderDetl(OrderDetl orderDetl, Mat mat) { |
| | | orderDetl.setMatnr(mat.getMatnr()); |
| | | orderDetl.setMaktx(mat.getMaktx()); |
| | | orderDetl.setName(mat.getName()); |
| | | orderDetl.setSpecs(mat.getSpecs()); |
| | | orderDetl.setModel(mat.getModel()); |
| | | orderDetl.setBatch(mat.getBatch()); |
| | | orderDetl.setUnit(mat.getUnit()); |
| | | orderDetl.setBarcode(mat.getBarcode()); |
| | | orderDetl.setItemNum(mat.getItemNum()); |
| | | orderDetl.setCount(mat.getCount()); |
| | | orderDetl.setWeight(mat.getWeight()); |
| | | } |
| | | |
| | | } |
| | |
| | | private Long itemId; |
| | | |
| | | /** |
| | | * 项目名称 |
| | | */ |
| | | @ApiModelProperty(value= "项目名称") |
| | | @TableField("item_name") |
| | | private String itemName; |
| | | |
| | | /** |
| | | * 调拨项目编号 |
| | | */ |
| | | @ApiModelProperty(value= "调拨项目编号") |
| | |
| | | |
| | | public Order() {} |
| | | |
| | | public Order(String uuid,String orderNo,String orderTime,Long docType,Long itemId,Long allotItemId,String defNumber,String number,Long cstmr,String cstmrName,String tel,String operMemb,Double totalFee,Double discount,Double discountFee,Double otherFee,Double actFee,Integer payType,String salesman,Integer accountDay,Integer postFeeType,Double postFee,Date payTime,Date sendTime,String shipName,String shipCode,Long settle,Integer status,Long createBy,Date createTime,Long updateBy,Date updateTime,String memo) { |
| | | public Order(String uuid,String orderNo,String orderTime,Long docType,Long itemId,String itemName,Long allotItemId,String defNumber,String number,Long cstmr,String cstmrName,String tel,String operMemb,Double totalFee,Double discount,Double discountFee,Double otherFee,Double actFee,Integer payType,String salesman,Integer accountDay,Integer postFeeType,Double postFee,Date payTime,Date sendTime,String shipName,String shipCode,Long settle,Integer status,Long createBy,Date createTime,Long updateBy,Date updateTime,String memo) { |
| | | this.uuid = uuid; |
| | | this.orderNo = orderNo; |
| | | this.orderTime = orderTime; |
| | | this.docType = docType; |
| | | this.itemId = itemId; |
| | | this.itemName = itemName; |
| | | this.allotItemId = allotItemId; |
| | | this.defNumber = defNumber; |
| | | this.number = number; |
| | |
| | | this.itemId = itemId; |
| | | } |
| | | |
| | | public String getItemName() { |
| | | return itemName; |
| | | } |
| | | |
| | | public void setItemName(String itemName) { |
| | | this.itemName = itemName; |
| | | } |
| | | |
| | | public Long getAllotItemId() { |
| | | return allotItemId; |
| | | } |
| | |
| | | package zy.cloud.wms.manager.entity; |
| | | |
| | | import com.baomidou.mybatisplus.annotations.TableField; |
| | | import com.baomidou.mybatisplus.annotations.TableId; |
| | | import com.baomidou.mybatisplus.annotations.TableName; |
| | | import com.baomidou.mybatisplus.enums.IdType; |
| | | import com.core.common.Cools; |
| | | import com.core.common.SpringUtils; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | |
| | | * ID |
| | | */ |
| | | @ApiModelProperty(value= "ID") |
| | | @TableId(value = "id", type = IdType.AUTO) |
| | | private Long id; |
| | | |
| | | /** |
| | |
| | | |
| | | public OrderDetl() {} |
| | | |
| | | public OrderDetl(Long id,Long orderId,Double anfme,String matnr,String maktx,String name,String specs,String model,String batch,String unit,String barcode,String supplier,Double unitPrice,Integer itemNum,Integer count,Double weight,Integer status,Long createBy,Date createTime,Long updateBy,Date updateTime,String memo) { |
| | | this.id = id; |
| | | public OrderDetl(Long orderId,Double anfme,String matnr,String maktx,String name,String specs,String model,String batch,String unit,String barcode,String supplier,Double unitPrice,Integer itemNum,Integer count,Double weight,Integer status,Long createBy,Date createTime,Long updateBy,Date updateTime,String memo) { |
| | | this.orderId = orderId; |
| | | this.anfme = anfme; |
| | | this.matnr = matnr; |
| | |
| | | } |
| | | |
| | | // OrderDetl orderDetl = new OrderDetl( |
| | | // null, // ID |
| | | // null, // 订单内码 |
| | | // null, // 数量 |
| | | // null, // 商品编码 |
| | |
| | | package zy.cloud.wms.manager.entity.param; |
| | | |
| | | import lombok.Data; |
| | | import zy.cloud.wms.common.model.MatnrDto; |
| | | |
| | | import java.util.List; |
| | | |
| | |
| | | @Data |
| | | public class InitOrderParam { |
| | | |
| | | private String number; |
| | | // 单据类型 |
| | | private Long docType; |
| | | |
| | | private String customerTypeId; |
| | | // 单据编号 |
| | | private String orderNo; |
| | | |
| | | private List<PakinMatDto> list; |
| | | // 单据时间 |
| | | private String orderTime; |
| | | |
| | | // 项目 |
| | | private String item; |
| | | |
| | | // 客户 |
| | | private String cstmr; |
| | | |
| | | // 商品数量列表 |
| | | private List<MatnrDto> list; |
| | | |
| | | } |
| | |
| | | |
| | | public interface CstmrService extends IService<Cstmr> { |
| | | |
| | | Cstmr selectByName(String name); |
| | | |
| | | } |
| | |
| | | |
| | | public interface ItemService extends IService<Item> { |
| | | |
| | | Item selectByName(String name); |
| | | |
| | | } |
| | |
| | | |
| | | public interface OrderService extends IService<Order> { |
| | | |
| | | Order selectByOrderNo(String oderNo); |
| | | |
| | | Order selectByUuid(String uuid); |
| | | |
| | | Integer insertReturnId(Order order); |
| | | |
| | | } |
| | |
| | | package zy.cloud.wms.manager.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import zy.cloud.wms.manager.mapper.CstmrMapper; |
| | | import zy.cloud.wms.manager.entity.Cstmr; |
| | | import zy.cloud.wms.manager.service.CstmrService; |
| | |
| | | @Service("cstmrService") |
| | | public class CstmrServiceImpl extends ServiceImpl<CstmrMapper, Cstmr> implements CstmrService { |
| | | |
| | | @Override |
| | | public Cstmr selectByName(String name) { |
| | | Cstmr cstmr = new Cstmr(); |
| | | cstmr.setName(name); |
| | | return this.selectOne(new EntityWrapper<>(cstmr)); |
| | | } |
| | | } |
| | |
| | | package zy.cloud.wms.manager.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import zy.cloud.wms.manager.mapper.ItemMapper; |
| | | import zy.cloud.wms.manager.entity.Item; |
| | | import zy.cloud.wms.manager.service.ItemService; |
| | |
| | | @Service("itemService") |
| | | public class ItemServiceImpl extends ServiceImpl<ItemMapper, Item> implements ItemService { |
| | | |
| | | @Override |
| | | public Item selectByName(String name) { |
| | | Item item = new Item(); |
| | | item.setName(name); |
| | | return this.selectOne(new EntityWrapper<>(item)); |
| | | } |
| | | } |
| | |
| | | package zy.cloud.wms.manager.service.impl; |
| | | |
| | | import zy.cloud.wms.manager.mapper.OrderMapper; |
| | | import zy.cloud.wms.manager.entity.Order; |
| | | import zy.cloud.wms.manager.service.OrderService; |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.baomidou.mybatisplus.service.impl.ServiceImpl; |
| | | import org.springframework.stereotype.Service; |
| | | import zy.cloud.wms.manager.entity.Order; |
| | | import zy.cloud.wms.manager.mapper.OrderMapper; |
| | | import zy.cloud.wms.manager.service.OrderService; |
| | | |
| | | @Service("orderService") |
| | | public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements OrderService { |
| | | |
| | | @Override |
| | | public Order selectByOrderNo(String orderNo) { |
| | | Order order = new Order(); |
| | | order.setOrderNo(orderNo); |
| | | return this.selectOne(new EntityWrapper<>(order)); |
| | | } |
| | | |
| | | @Override |
| | | public Order selectByUuid(String uuid) { |
| | | Order order = new Order(); |
| | | order.setUuid(uuid); |
| | | return this.selectOne(new EntityWrapper<>(order)); |
| | | } |
| | | |
| | | @Override |
| | | public Integer insertReturnId(Order order) { |
| | | return this.baseMapper.insert(order); |
| | | } |
| | | |
| | | } |
| | |
| | | |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.core.common.Cools; |
| | | import com.core.common.DateUtils; |
| | | import com.core.common.R; |
| | | import com.core.common.SnowflakeIdWorker; |
| | | import com.core.exception.CoolException; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | |
| | | /** |
| | | * Created by vincent on 2021/2/25 |
| | | */ |
| | | @Slf4j |
| | | @Service("workService") |
| | | public class WorkServiceImpl implements WorkService { |
| | | |
| | |
| | | private ErpService erpService; |
| | | @Autowired |
| | | private CheckService checkService; |
| | | @Autowired |
| | | private OrderService orderService; |
| | | @Autowired |
| | | private OrderDetlService orderDetlService; |
| | | @Autowired |
| | | private ItemService itemService; |
| | | @Autowired |
| | | private CstmrService cstmrService; |
| | | |
| | | @Override |
| | | @Transactional |
| | |
| | | @Override |
| | | @Transactional |
| | | public R initOrder(InitOrderParam param, Long userId) { |
| | | if (custOrderService.selectCount(new EntityWrapper<CustOrder>().eq("number", param.getNumber()).ne("bType_id", param.getCustomerTypeId())) > 0) { |
| | | Order order = orderService.selectByOrderNo(param.getOrderNo()); |
| | | if (order != null) { |
| | | return R.error("抱歉单号已存在,请修改单号"); |
| | | } |
| | | Date now = new Date(); |
| | | for (PakinMatDto dto : param.getList()){ |
| | | Item item = itemService.selectByName(param.getItem()); |
| | | Cstmr cstmr = cstmrService.selectByName(param.getCstmr()); |
| | | // 新增订单表头 |
| | | order = new Order( |
| | | String.valueOf(snowflakeIdWorker.nextId()), // 编号[非空] |
| | | param.getOrderNo(), // 订单编号 |
| | | param.getOrderTime(), // 单据日期 |
| | | param.getDocType(), // 单据类型 |
| | | item==null?null:item.getId(), // 项目编号 |
| | | param.getItem(), // 项目名称 |
| | | null, // 调拨项目编号 |
| | | null, // 初始票据号 |
| | | null, // 票据号 |
| | | cstmr==null?null:cstmr.getId(), // 客户编号 |
| | | param.getCstmr(), // 客户 |
| | | null, // 联系方式 |
| | | null, // 操作人员 |
| | | null, // 合计金额 |
| | | null, // 优惠率 |
| | | null, // 优惠金额 |
| | | null, // 销售或采购费用合计 |
| | | null, // 实付金额 |
| | | null, // 付款类型 |
| | | null, // 业务员 |
| | | null, // 结算天数 |
| | | null, // 邮费支付类型 |
| | | null, // 邮费 |
| | | null, // 付款时间 |
| | | null, // 发货时间 |
| | | null, // 物流名称 |
| | | null, // 物流单号 |
| | | null, // 订单状态 |
| | | 1, // 状态 |
| | | userId, // 添加人员 |
| | | now, // 添加时间 |
| | | userId, // 修改人员 |
| | | now, // 修改时间 |
| | | null // 备注 |
| | | ); |
| | | Integer orderId = orderService.insertReturnId(order); |
| | | if (orderId == 0) { |
| | | throw new CoolException("保存订单表头失败!"); |
| | | } |
| | | // 遍历商品数量并保存 |
| | | for (MatnrDto dto : param.getList()){ |
| | | Mat mat = matService.selectByMatnr(dto.getMatnr()); |
| | | if (mat == null) { |
| | | log.error("{}商品不存在。", dto.getMatnr()); |
| | | continue; |
| | | } |
| | | CustOrder custOrder = new CustOrder( |
| | | param.getNumber(), // 销售单号 |
| | | DateUtils.convert(now), // 单据日期[非空] |
| | | param.getCustomerTypeId(), // 客户编号 |
| | | null, // 经手人编号[空] |
| | | null, |
| | | dto.getMatnr(), // 商品编号 |
| | | dto.getCount(), // 商品数量 |
| | | dto.getCount(), // 总数量 |
| | | Cools.isEmpty(mat.getName())?0.0D:Double.parseDouble(mat.getName()), // 商品单价 |
| | | null, // 商品明细行号 |
| | | null, // 商品备注[空] |
| | | 1, // 状态 |
| | | now, // 添加时间 |
| | | now, // 修改时间 |
| | | null // 备注 |
| | | ); |
| | | if (!custOrderService.insert(custOrder)) { |
| | | throw new CoolException("保存销售订单失败"); |
| | | OrderDetl orderDetl = new OrderDetl(); |
| | | orderDetl.setOrderId(orderId.longValue()); // 订单内码 |
| | | orderDetl.setAnfme(dto.getCount()); // 数量 |
| | | orderDetl.setCreateBy(userId); |
| | | orderDetl.setCreateTime(now); |
| | | orderDetl.setUpdateBy(userId); |
| | | orderDetl.setUpdateTime(now); |
| | | orderDetl.setStatus(1); |
| | | VersionUtils.setOrderDetl(orderDetl, mat); |
| | | if (!orderDetlService.insert(orderDetl)) { |
| | | throw new CoolException("保存订单明细失败"); |
| | | } |
| | | } |
| | | return R.ok("生成销售订单" + param.getNumber() + "成功"); |
| | | return R.ok("创建订单成功"); |
| | | } |
| | | |
| | | @Override |
| | |
| | | |
| | | <!-- 通用查询映射结果 --> |
| | | <resultMap id="BaseResultMap" type="zy.cloud.wms.manager.entity.OrderDetl"> |
| | | <result column="id" property="id" /> |
| | | <id column="id" property="id" /> |
| | | <result column="order_id" property="orderId" /> |
| | | <result column="anfme" property="anfme" /> |
| | | <result column="matnr" property="matnr" /> |
| | |
| | | <result column="order_time" property="orderTime" /> |
| | | <result column="doc_type" property="docType" /> |
| | | <result column="item_id" property="itemId" /> |
| | | <result column="item_name" property="itemName" /> |
| | | <result column="allot_item_id" property="allotItemId" /> |
| | | <result column="def_number" property="defNumber" /> |
| | | <result column="number" property="number" /> |