| | |
| | | |
| | | import cn.hutool.core.collection.CollectionUtil; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import org.apache.commons.lang.StringUtils; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.jeecg.modules.mes.entity.MesProductionOrder; |
| | | import org.jeecg.modules.pms.entity.PmsProcessBillMaterials; |
| | | import org.jeecg.modules.pms.mapper.PmsProcessBillMaterialsMapper; |
| | |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.stream.Collectors; |
| | |
| | | private IPmsProcessBillMaterialsDetailService processBillMaterialsDetailService; |
| | | |
| | | @Override |
| | | public IPage<Map<String, Object>> getpmsProcessBillMaterialsListData(Integer pageNo, Integer pageSize, HttpServletRequest req) { |
| | | IPage<Map> pageData = new Page<Map>(pageNo, pageSize); |
| | | Map<String, String> paramMap = new HashMap<String, String>(); |
| | | Map<String, String[]> parameterMap = req.getParameterMap(); |
| | | if (null != parameterMap) { |
| | | if (parameterMap.containsKey("materialNumber") && StringUtils.isNotBlank(parameterMap.get("materialNumber")[0])) { |
| | | paramMap.put("materialNumber", parameterMap.get("materialNumber")[0]); |
| | | } |
| | | if (parameterMap.containsKey("materialName") && StringUtils.isNotBlank(parameterMap.get("materialName")[0])) { |
| | | paramMap.put("materialName", parameterMap.get("materialName")[0].trim()); |
| | | } |
| | | if (parameterMap.containsKey("batchNumber") && StringUtils.isNotBlank(parameterMap.get("batchNumber")[0])) { |
| | | paramMap.put("batchNumber", parameterMap.get("batchNumber")[0].trim()); |
| | | } |
| | | } |
| | | return super.getBaseMapper().getpmsProcessBillMaterialsListData(pageData, paramMap); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public boolean saveOrUpdateOrderBom(Map<String, MesProductionOrder> orderMap, List<OrderBomDTO> orderBomDTOList) { |
| | | for (Map.Entry<String, MesProductionOrder> entry : orderMap.entrySet()) { |
| | | for (Map.Entry<String, MesProductionOrder> entry : orderMap.entrySet()) { |
| | | MesProductionOrder order = entry.getValue(); |
| | | PmsProcessBillMaterials materials = getByOrderId(order.getId()); |
| | | if(materials != null) { |
| | | if (materials != null) { |
| | | //更新物料数据 |
| | | materials.setOrderId(order.getId()); |
| | | materials.setMaterialNumber(order.getMaterialNumber()); |
| | |
| | | //过滤出此订单的物料信息 |
| | | List<OrderBomDTO> collect = orderBomDTOList.stream().filter(orderBomDTO -> entry.getKey().equals(orderBomDTO.getAUFNR())).collect(Collectors.toList()); |
| | | processBillMaterialsDetailService.saveBatchDetail(materials.getId(), collect); |
| | | }else { |
| | | } else { |
| | | materials = new PmsProcessBillMaterials(); |
| | | materials.setOrderId(order.getId()); |
| | | materials.setMaterialNumber(order.getMaterialNumber()); |
| | |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | @Override |
| | | public IPage<PmsProcessBillMaterials> queryPageList(Page<PmsProcessBillMaterials> page, PmsProcessBillMaterials query) { |
| | | QueryWrapper<PmsProcessBillMaterials> queryWrapper = new QueryWrapper<>(); |
| | | queryWrapper.orderByDesc("pbm.create_time"); |
| | | if (query != null) { |
| | | //物料编码 模糊查询 |
| | | if (StringUtils.isNotBlank(query.getMaterialNumber())) { |
| | | queryWrapper.like("pbm.material_number", query.getMaterialNumber()); |
| | | } |
| | | //物料名称 模糊查询 |
| | | if (StringUtils.isNotBlank(query.getMaterialName())) { |
| | | queryWrapper.like("pbm.material_name", query.getMaterialName()); |
| | | } |
| | | //订单号 模糊查询 |
| | | if (StringUtils.isNotBlank(query.getOrderCode())) { |
| | | queryWrapper.like("po.order_code", query.getOrderCode()); |
| | | } |
| | | } |
| | | return this.getBaseMapper().queryPageList(page, queryWrapper); |
| | | } |
| | | } |