| | |
| | | package com.yuanchu.mom.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.yuanchu.mom.mapper.*; |
| | | import com.yuanchu.mom.pojo.*; |
| | | import com.yuanchu.mom.service.OrdersService; |
| | | import com.yuanchu.mom.service.SpecificationsService; |
| | | import com.yuanchu.mom.service.StandardService; |
| | | import com.yuanchu.mom.utils.MyUtil; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.Objects; |
| | | |
| | | /** |
| | | * 订单(Order)表服务实现类 |
| | |
| | | * @since 2023-07-31 11:57:44 |
| | | */ |
| | | @Service("orderService") |
| | | public class OrdersServiceImpl implements OrdersService { |
| | | public class OrdersServiceImpl implements OrdersService { |
| | | |
| | | @Resource |
| | | SaleMapper saleMapper; |
| | | |
| | | @Resource |
| | | MaterialMapper materialMapper; |
| | | |
| | | @Resource |
| | | StandardService standardService; |
| | | |
| | | @Resource |
| | | SpecificationsService specificationsService; |
| | | |
| | | @Resource |
| | | SaleMaterialMapper saleMaterialMapper; |
| | |
| | | TechnologyMapper technologyMapper; |
| | | |
| | | |
| | | |
| | | //查询所有订单列表 |
| | | @Override |
| | | public IPage<Map<String, Object>> selectAllOrder(Page<Object> page, String orderCode, String name, Integer type , String time) { |
| | | return saleMapper.selectAllOrder(page, orderCode,name,type, time); |
| | | public IPage<Map<String, Object>> selectAllOrder(Page<Object> page, String orderCode, String name, Integer type, String time) { |
| | | return saleMapper.selectAllOrder(page, orderCode, name, type, time); |
| | | } |
| | | |
| | | //编制订单BOM |
| | |
| | | .build(); |
| | | //新增生产订单 |
| | | manufactureOrderMapper.insert(manufactureOrder); |
| | | //查询产品的工序 |
| | | String[] split = manufactureOrder.getSpecifications().split("-"); |
| | | Specifications specifications = specificationsMapper.selectOne(Wrappers.<Specifications>query().eq("name", split[1])); |
| | | List<Technology> technologyList = technologyMapper.selectList(Wrappers.<Technology>query().eq("specifications_id", specifications.getId())); |
| | | //产品编码 |
| | | String code = materialMapper.selMcode(manufactureOrder.getName()); |
| | | //型号id |
| | | Integer specificationId = getSpecificationId(manufactureOrder.getName(), code, manufactureOrder.getSpecifications()); |
| | | //默认最新版本 |
| | | Integer version = technologyMapper.selectVerByTec(specificationId).get(0); |
| | | /*正序查询该型号最新版本下的工艺路线*/ |
| | | LambdaQueryWrapper<Technology> queryWrapper = new LambdaQueryWrapper<>(); |
| | | queryWrapper.eq(Technology::getSpecificationsId,specificationId); |
| | | queryWrapper.eq(Technology::getVersion,version); |
| | | queryWrapper.orderByAsc(Technology::getFather); |
| | | List<Technology> technologyList = technologyMapper.selectList(queryWrapper); |
| | | for (Technology technology : technologyList) { |
| | | ManualTechnology manualTechnology = ManualTechnology.builder() |
| | | .techname(technology.getName()) |
| | |
| | | .deviceGroup(technology.getDeviceGroup()) |
| | | .manufactureOrderId(manufactureOrder.getId()) |
| | | .productionQuota(technology.getProductionQuota()) |
| | | .technologyId(technology.getId()) |
| | | .build(); |
| | | //新增编制工序表 |
| | | manualTechnologyMapper.insert(manualTechnology); |
| | | } |
| | | } |
| | | |
| | | /*根据样品名称,样品编号,型号规格获取型号id*/ |
| | | private Integer getSpecificationId(String name, String mcode, String specification) { |
| | | //获取物料id |
| | | Material material = materialMapper.selectOne(Wrappers.<Material>query() |
| | | .eq("name", name) |
| | | .eq("code", mcode)); |
| | | if (Objects.isNull(material)) { |
| | | return null; |
| | | } |
| | | //获取规格名称和型号名称 |
| | | String[] split = specification.split("-"); |
| | | String stName = split[0]; |
| | | String spName = split[1]; |
| | | //获取规格id |
| | | Standard standard = standardService.getOne(Wrappers.<Standard>query() |
| | | .eq("name", stName) |
| | | .eq("material_id", material.getId())); |
| | | //获取型号id |
| | | Specifications specifications = specificationsService.getOne(Wrappers.<Specifications>query() |
| | | .eq("name", spName) |
| | | .eq("standard_id", standard.getId())); |
| | | return specifications.getId(); |
| | | } |
| | | |
| | | } |
| | | |