no message
							parent
							
								
									890f4c9c28
								
							
						
					
					
						commit
						b26a3482bf
					
				| 
						 | 
				
			
			@ -10,9 +10,9 @@ import java.net.URL;
 | 
			
		|||
import java.net.URLConnection;
 | 
			
		||||
 | 
			
		||||
public class HttpPostUtil {
 | 
			
		||||
    public static String sendPostReq(String api_url, String request){
 | 
			
		||||
    public static String sendPostReq(String api_url, String request) {
 | 
			
		||||
        InputStream instr = null;
 | 
			
		||||
        String str = "";
 | 
			
		||||
        String str = null;
 | 
			
		||||
        try {
 | 
			
		||||
            URL url = new URL(api_url);
 | 
			
		||||
            URLConnection urlCon = url.openConnection();
 | 
			
		||||
| 
						 | 
				
			
			@ -35,9 +35,9 @@ public class HttpPostUtil {
 | 
			
		|||
                System.out.println("返回空");
 | 
			
		||||
            }
 | 
			
		||||
            str = ResponseString;
 | 
			
		||||
        }catch (Exception e){
 | 
			
		||||
        } catch (Exception e) {
 | 
			
		||||
            System.out.println("接口异常!");
 | 
			
		||||
           // throw new Error(e.getMessage());
 | 
			
		||||
            // throw new Error(e.getMessage());
 | 
			
		||||
        }
 | 
			
		||||
        return str;
 | 
			
		||||
    }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -116,4 +116,13 @@ public interface ItemService {
 | 
			
		|||
     */
 | 
			
		||||
    String impoertItem(MultipartFile multipartFile);
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 创建物料
 | 
			
		||||
     * @param itemCode 物料编码
 | 
			
		||||
     * @param itemName 物料名称
 | 
			
		||||
     * @param extendD1 单台用量
 | 
			
		||||
     * @param goodType 物料类型
 | 
			
		||||
     * @return Item
 | 
			
		||||
     */
 | 
			
		||||
    Item createItem(String itemCode, String itemName,Double extendD1,String goodType);
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -21,6 +21,7 @@ import com.youchain.basicdata.domain.Item;
 | 
			
		|||
import com.youchain.config.FileProperties;
 | 
			
		||||
import com.youchain.exception.BadRequestException;
 | 
			
		||||
import com.youchain.modules.system.domain.Dept;
 | 
			
		||||
import com.youchain.modules.system.repository.DeptRepository;
 | 
			
		||||
import com.youchain.utils.*;
 | 
			
		||||
import lombok.RequiredArgsConstructor;
 | 
			
		||||
import com.youchain.basicdata.repository.ItemRepository;
 | 
			
		||||
| 
						 | 
				
			
			@ -53,6 +54,7 @@ public class ItemServiceImpl implements ItemService {
 | 
			
		|||
    private final ItemRepository itemRepository;
 | 
			
		||||
    private final ItemMapper itemMapper;
 | 
			
		||||
    private final FileProperties properties;
 | 
			
		||||
    private final DeptRepository deptRepository;
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public Map<String, Object> queryAll(ItemQueryCriteria criteria, Pageable pageable) {
 | 
			
		||||
| 
						 | 
				
			
			@ -172,7 +174,7 @@ public class ItemServiceImpl implements ItemService {
 | 
			
		|||
 | 
			
		||||
 | 
			
		||||
        //获取已存在的物料
 | 
			
		||||
        Map<String, Item> existingPoint = findByCodes(itemCodes,null);
 | 
			
		||||
        Map<String, Item> existingPoint = findByCodes(itemCodes, null);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        List<Item> itemsToCreate = new ArrayList<>();//新增物料集合
 | 
			
		||||
| 
						 | 
				
			
			@ -202,6 +204,21 @@ public class ItemServiceImpl implements ItemService {
 | 
			
		|||
        return ("导入成功:" + " 新增(" + itemsToCreate.size() + ")修改(" + itemsToUpdate.size() + ")");
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public Item createItem(String itemCode, String itemName, Double extendD1, String goodType) {
 | 
			
		||||
        Item item = new Item();
 | 
			
		||||
        item.setCode(itemCode);
 | 
			
		||||
        item.setName(itemName);
 | 
			
		||||
        item.setExtendD1(extendD1);
 | 
			
		||||
        item.setGoodType(goodType);
 | 
			
		||||
        item.setUnit("PCS");
 | 
			
		||||
        item.setEnabled(true);
 | 
			
		||||
        Dept dept = deptRepository.getById(7L);
 | 
			
		||||
        item.setDept(dept);
 | 
			
		||||
        itemRepository.save(item);
 | 
			
		||||
        return item;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private Item updateItems(Item item, Dept dept, Map<String, Object> record) {
 | 
			
		||||
        item.setDept(dept);
 | 
			
		||||
        item.setName(Optional.ofNullable(record.get("名称")).map(Object::toString).map(String::trim).orElse(null));
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -88,7 +88,6 @@ public class PickController {
 | 
			
		|||
    }
 | 
			
		||||
 | 
			
		||||
    @PostMapping("/returnPick")
 | 
			
		||||
    @Log("mes-工单回传")
 | 
			
		||||
    @ApiOperation("mes-工单回传")
 | 
			
		||||
    @AnonymousAccess
 | 
			
		||||
    public ResponseEntity<Object> returnPick(@Validated @RequestBody Long pickId) {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -15,6 +15,7 @@
 | 
			
		|||
 */
 | 
			
		||||
package com.youchain.businessdata.service;
 | 
			
		||||
 | 
			
		||||
import com.alibaba.fastjson.JSONObject;
 | 
			
		||||
import com.youchain.RequestData.Yclbl;
 | 
			
		||||
import com.youchain.basicdata.domain.Point;
 | 
			
		||||
import com.youchain.businessdata.domain.Pick;
 | 
			
		||||
| 
						 | 
				
			
			@ -94,19 +95,22 @@ public interface PickService {
 | 
			
		|||
 | 
			
		||||
    /**
 | 
			
		||||
     * 根据出库单号查询出库单
 | 
			
		||||
     *
 | 
			
		||||
     * @param code 出库单号
 | 
			
		||||
     */
 | 
			
		||||
    Pick findByPickCode(String code);
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     *  根据状态查询、是否叫料出库单
 | 
			
		||||
     * 根据状态查询、是否叫料出库单
 | 
			
		||||
     *
 | 
			
		||||
     * @param statuses 状态集合
 | 
			
		||||
     * @param isCall 是否叫料
 | 
			
		||||
     * @param isCall   是否叫料
 | 
			
		||||
     */
 | 
			
		||||
    List<Pick> findByPickStatus(List<String> statuses, Boolean isCall);
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 刷新出库单拣货状态
 | 
			
		||||
     *
 | 
			
		||||
     * @param pick 出库单
 | 
			
		||||
     */
 | 
			
		||||
    void refreshPickStatus(Pick pick);
 | 
			
		||||
| 
						 | 
				
			
			@ -116,17 +120,19 @@ public interface PickService {
 | 
			
		|||
     *
 | 
			
		||||
     * @param pickDetail 工单明细
 | 
			
		||||
     */
 | 
			
		||||
    String returnPickJson(PickDetail pickDetail);
 | 
			
		||||
    JSONObject returnPickJson(PickDetail pickDetail);
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 工单回传
 | 
			
		||||
     * @param pick 出库单
 | 
			
		||||
     *
 | 
			
		||||
     * @param pickId 出库单
 | 
			
		||||
     */
 | 
			
		||||
    void returnPick(Long pick);
 | 
			
		||||
    void returnPick(Long pickId);
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 下发回传任务
 | 
			
		||||
     * @param url 地址
 | 
			
		||||
     *
 | 
			
		||||
     * @param url        地址
 | 
			
		||||
     * @param pickDetail 参数
 | 
			
		||||
     */
 | 
			
		||||
    void sendPick(String url, PickDetail pickDetail);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -181,9 +181,8 @@ public interface TaskService {
 | 
			
		|||
    /**
 | 
			
		||||
     * 定时任务轮询叫料反空车至备料缓存区
 | 
			
		||||
     *
 | 
			
		||||
     * @param goodType 小件/大件
 | 
			
		||||
     */
 | 
			
		||||
    void callEmptyStock(String goodType);
 | 
			
		||||
    void callEmptyStock(Point point);
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 定时任务轮询出库单叫料
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -153,8 +153,8 @@ public class KMReServiceImpl implements KMReService {
 | 
			
		|||
     * @param json 接口json
 | 
			
		||||
     */
 | 
			
		||||
    @Override
 | 
			
		||||
    public  void sendAgvTaskToContainer(String url, String json) {
 | 
			
		||||
        Dict dict = dictRepository.findDictByDescription("OPEN");
 | 
			
		||||
    public void sendAgvTaskToContainer(String url, String json) {
 | 
			
		||||
        Dict dict = dictRepository.findDictByName("OPEN");
 | 
			
		||||
        if (dict != null) {
 | 
			
		||||
            String resultJson = HttpPostUtil.sendPostReq(url, json);
 | 
			
		||||
            if (StringUtils.isEmpty(resultJson)) {
 | 
			
		||||
| 
						 | 
				
			
			@ -179,7 +179,7 @@ public class KMReServiceImpl implements KMReService {
 | 
			
		|||
     * @param agvTasks 任务
 | 
			
		||||
     */
 | 
			
		||||
    @Override
 | 
			
		||||
    public  String sendAgvTaskCcJson(AgvTask agvTasks) {
 | 
			
		||||
    public String sendAgvTaskCcJson(AgvTask agvTasks) {
 | 
			
		||||
        JSONObject jsonObject = new JSONObject(new LinkedHashMap<>());
 | 
			
		||||
 | 
			
		||||
        Map<String, Object> objMap = new LinkedHashMap<>();
 | 
			
		||||
| 
						 | 
				
			
			@ -231,7 +231,7 @@ public class KMReServiceImpl implements KMReService {
 | 
			
		|||
     * @param agvTasks 任务
 | 
			
		||||
     */
 | 
			
		||||
    @Override
 | 
			
		||||
    public  String sendAgvTaskHjJson(AgvTask agvTasks) {
 | 
			
		||||
    public String sendAgvTaskHjJson(AgvTask agvTasks) {
 | 
			
		||||
        JSONObject jsonObject = new JSONObject(new LinkedHashMap<>());
 | 
			
		||||
 | 
			
		||||
        Map<String, Object> objMap = new LinkedHashMap<>();
 | 
			
		||||
| 
						 | 
				
			
			@ -260,7 +260,7 @@ public class KMReServiceImpl implements KMReService {
 | 
			
		|||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public  String sendAgvTaskGtJson(AgvTask agvTask) {
 | 
			
		||||
    public String sendAgvTaskGtJson(AgvTask agvTask) {
 | 
			
		||||
        JSONObject jsonObject = new JSONObject(new LinkedHashMap<>());
 | 
			
		||||
        Map<String, Object> objMap = new LinkedHashMap<>();
 | 
			
		||||
        objMap.put("orgId", agvTask.getId());//库存组织 ID(或工厂代码,供应商代码)
 | 
			
		||||
| 
						 | 
				
			
			@ -321,7 +321,7 @@ public class KMReServiceImpl implements KMReService {
 | 
			
		|||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public  void sendAgvTask(AgvTask agvTasks, String json) {
 | 
			
		||||
    public void sendAgvTask(AgvTask agvTasks, String json) {
 | 
			
		||||
        Dict dict = dictRepository.findDictByName("OPEN");
 | 
			
		||||
        String resultJson = "";
 | 
			
		||||
        if (dict != null) {
 | 
			
		||||
| 
						 | 
				
			
			@ -650,6 +650,7 @@ public class KMReServiceImpl implements KMReService {
 | 
			
		|||
        }
 | 
			
		||||
 | 
			
		||||
        //回传MES
 | 
			
		||||
        pickService.returnPick(pick.getId());
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -9,6 +9,7 @@ import com.youchain.basicdata.domain.Item;
 | 
			
		|||
import com.youchain.basicdata.domain.Point;
 | 
			
		||||
import com.youchain.basicdata.domain.Stock;
 | 
			
		||||
import com.youchain.basicdata.repository.ItemRepository;
 | 
			
		||||
import com.youchain.basicdata.service.ItemService;
 | 
			
		||||
import com.youchain.basicdata.service.PointService;
 | 
			
		||||
import com.youchain.basicdata.service.StockService;
 | 
			
		||||
import com.youchain.businessdata.domain.AgvTask;
 | 
			
		||||
| 
						 | 
				
			
			@ -43,6 +44,7 @@ public class MesServiceImpl implements MesService {
 | 
			
		|||
    private final PickRepository pickRepository;
 | 
			
		||||
    private final PickDetailRepository pickDetailRepository;
 | 
			
		||||
    private final ItemRepository itemRepository;
 | 
			
		||||
    private final ItemService itemService;
 | 
			
		||||
    private final StockService stockService;
 | 
			
		||||
    private final PointService pointService;
 | 
			
		||||
    private final TaskService taskService;
 | 
			
		||||
| 
						 | 
				
			
			@ -60,24 +62,24 @@ public class MesServiceImpl implements MesService {
 | 
			
		|||
        //验证出库单是否存在
 | 
			
		||||
        checkIfGdExists(yclbl);
 | 
			
		||||
 | 
			
		||||
        //验证物料是否存在
 | 
			
		||||
        Map<String, Item> itemMap = checkIfItemExists(yclbl);
 | 
			
		||||
 | 
			
		||||
        List<Pick> createPicks = new ArrayList<>();
 | 
			
		||||
        List<PickDetail> createPickDetails = new ArrayList<>();
 | 
			
		||||
        AtomicInteger lineNo = new AtomicInteger(1);
 | 
			
		||||
 | 
			
		||||
        String orderNo = yclbl.getOrderNo();
 | 
			
		||||
        String taskCode = yclbl.getTaskCode();
 | 
			
		||||
 | 
			
		||||
        //遍历成品集合
 | 
			
		||||
        yclbl.getBlzc().forEach(zcData -> {
 | 
			
		||||
            Pick pick = createPick(orderNo, taskCode, lineNo.getAndIncrement(), zcData.getCompleteCode(), zcData.getStation(), BaseStatus.GD_TYPE_CT);
 | 
			
		||||
            Pick pick = createPick(orderNo, taskCode, zcData.getLineNo(), zcData.getCompleteCode(), zcData.getStation(), BaseStatus.GD_TYPE_CT);
 | 
			
		||||
            createPicks.add(pick);
 | 
			
		||||
            zcData.getBlzcmx().forEach(itemDate -> {
 | 
			
		||||
                Item item = itemMap.get(itemDate.getItemCode());
 | 
			
		||||
                item.setGoodType(BaseStatus.GD_TYPE_CT);
 | 
			
		||||
                itemRepository.save(item);
 | 
			
		||||
                Item item = itemRepository.findByCode(itemDate.getItemCode());
 | 
			
		||||
                if (item == null) {
 | 
			
		||||
                    item = itemService.createItem(itemDate.getItemCode(), itemDate.getItemName(), itemDate.getItemQty(), BizStatus.XJ);
 | 
			
		||||
                } else {
 | 
			
		||||
                    item.setGoodType(BizStatus.XJ);
 | 
			
		||||
                    itemRepository.save(item);
 | 
			
		||||
                }
 | 
			
		||||
                PickDetail pickDetail = createPickDetail(pick, item, BaseStatus.GD_TYPE_CT, itemDate.getItemQty(), zcData.getCompleteQty());
 | 
			
		||||
                createPickDetails.add(pickDetail);
 | 
			
		||||
            });
 | 
			
		||||
| 
						 | 
				
			
			@ -85,11 +87,15 @@ public class MesServiceImpl implements MesService {
 | 
			
		|||
 | 
			
		||||
        //遍历单品品集合
 | 
			
		||||
        yclbl.getBlzcmx().forEach(itemDate -> {
 | 
			
		||||
            Pick pick = createPick(orderNo, taskCode, lineNo.getAndIncrement(), itemDate.getItemCode(), itemDate.getStation(), BaseStatus.GD_TYPE_DP);
 | 
			
		||||
            Pick pick = createPick(orderNo, taskCode, itemDate.getLineNo(), itemDate.getItemCode(), itemDate.getStation(), BaseStatus.GD_TYPE_DP);
 | 
			
		||||
            createPicks.add(pick);
 | 
			
		||||
            Item item = itemMap.get(itemDate.getItemCode());
 | 
			
		||||
            item.setGoodType(BaseStatus.GD_TYPE_DP);
 | 
			
		||||
            itemRepository.save(item);
 | 
			
		||||
            Item item = itemRepository.findByCode(itemDate.getItemCode());
 | 
			
		||||
            if (item == null) {
 | 
			
		||||
                item = itemService.createItem(itemDate.getItemCode(), itemDate.getItemName(), itemDate.getItemQty(), BizStatus.DJ);
 | 
			
		||||
            } else {
 | 
			
		||||
                item.setGoodType(BizStatus.DJ);
 | 
			
		||||
                itemRepository.save(item);
 | 
			
		||||
            }
 | 
			
		||||
            PickDetail pickDetail = createPickDetail(pick, item, BaseStatus.GD_TYPE_DP, itemDate.getItemQty(), null);
 | 
			
		||||
            createPickDetails.add(pickDetail);
 | 
			
		||||
        });
 | 
			
		||||
| 
						 | 
				
			
			@ -128,7 +134,7 @@ public class MesServiceImpl implements MesService {
 | 
			
		|||
        pick.setCallPoint(point);
 | 
			
		||||
        pickRepository.save(pick);
 | 
			
		||||
 | 
			
		||||
        taskService.callEmptyStock(BaseStatus.GD_TYPE_DP);
 | 
			
		||||
        taskService.callEmptyStock(point);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
| 
						 | 
				
			
			@ -154,7 +160,7 @@ public class MesServiceImpl implements MesService {
 | 
			
		|||
        pick.setIsCall(true);
 | 
			
		||||
        pick.setCallPoint(point);
 | 
			
		||||
        pickRepository.save(pick);
 | 
			
		||||
        taskService.callEmptyStock(BaseStatus.GD_TYPE_CT);
 | 
			
		||||
        taskService.callEmptyStock(point);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
| 
						 | 
				
			
			@ -206,32 +212,6 @@ public class MesServiceImpl implements MesService {
 | 
			
		|||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 验证物料是否存在
 | 
			
		||||
     *
 | 
			
		||||
     * @param yclbl 备料参数
 | 
			
		||||
     */
 | 
			
		||||
    private Map<String, Item> checkIfItemExists(Yclbl yclbl) {
 | 
			
		||||
        // 获取所有成品和单品的itemCode
 | 
			
		||||
        Set<String> itemCodes = yclbl.getBlzc().stream().flatMap(zcData -> zcData.getBlzcmx().stream()).map(ItemDate::getItemCode).collect(Collectors.toSet());
 | 
			
		||||
 | 
			
		||||
        itemCodes.addAll(yclbl.getBlzcmx().stream().map(ItemDate::getItemCode).collect(Collectors.toSet()));
 | 
			
		||||
 | 
			
		||||
        // 查找数据库中存在的items
 | 
			
		||||
        List<Item> items = itemRepository.findByCodes(itemCodes, null);
 | 
			
		||||
        Set<String> newItemCodes = items.stream().map(Item::getCode).collect(Collectors.toSet());
 | 
			
		||||
 | 
			
		||||
        // 取itemCodes和newItemCodes的差集,说明有不存在的物料
 | 
			
		||||
        Set<String> diffItemCodes = itemCodes.stream().filter(code -> !newItemCodes.contains(code)).collect(Collectors.toSet());
 | 
			
		||||
 | 
			
		||||
        if (!diffItemCodes.isEmpty()) {
 | 
			
		||||
            throw new IllegalArgumentException("WMS不存在的物料集合,请维护:" + diffItemCodes);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        // 构建itemCode到Item的映射
 | 
			
		||||
        return items.stream().collect(Collectors.toMap(Item::getCode, item -> item));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public Pick createPick(String gdCode, String taskCode, int lineNo, String cpCodeOrpCode, String station, String orderType) {
 | 
			
		||||
        Pick pick = new Pick();
 | 
			
		||||
        pick.setTaskCode(taskCode);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -61,6 +61,7 @@ public class PickServiceImpl implements PickService {
 | 
			
		|||
    private final PickDetailRepository pickDetailRepository;
 | 
			
		||||
    private final PickMapper pickMapper;
 | 
			
		||||
    private final PickDetailService pickDetailService;
 | 
			
		||||
    private final LogService logService;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
| 
						 | 
				
			
			@ -169,7 +170,7 @@ public class PickServiceImpl implements PickService {
 | 
			
		|||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public String returnPickJson(PickDetail pickDetail) {
 | 
			
		||||
    public JSONObject returnPickJson(PickDetail pickDetail) {
 | 
			
		||||
        JSONObject jsonObject = new JSONObject(new LinkedHashMap<>());
 | 
			
		||||
        //需求工位
 | 
			
		||||
        jsonObject.put("OpName", pickDetail.getPick().getStation());
 | 
			
		||||
| 
						 | 
				
			
			@ -178,11 +179,10 @@ public class PickServiceImpl implements PickService {
 | 
			
		|||
        //物料编码
 | 
			
		||||
        jsonObject.put("MaterialCode", pickDetail.getItem().getCode());
 | 
			
		||||
        //数量
 | 
			
		||||
        jsonObject.put("number", pickDetail.getOrderQty());
 | 
			
		||||
        jsonObject.put("number", pickDetail.getOrderQty() == null ? 0 : pickDetail.getOrderQty().intValue());
 | 
			
		||||
        //taskId
 | 
			
		||||
        jsonObject.put("taskId", pickDetail.getPick().getTaskCode());
 | 
			
		||||
        System.out.println("叫料回传JSON:" + jsonObject.toString());
 | 
			
		||||
        return jsonObject.toString();
 | 
			
		||||
        return jsonObject;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
| 
						 | 
				
			
			@ -211,40 +211,56 @@ public class PickServiceImpl implements PickService {
 | 
			
		|||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void sendPick(String url, PickDetail pickDetail) {
 | 
			
		||||
        Dict dict = dictRepository.findDictByDescription("OPEN");
 | 
			
		||||
        String message = null;
 | 
			
		||||
        if (dict != null) {
 | 
			
		||||
            String resultJson = HttpPostUtil.sendPostReq(url, returnPickJson(pickDetail));
 | 
			
		||||
            System.out.println("url:" + url);
 | 
			
		||||
            System.out.println("报文:" + returnPickJson(pickDetail));
 | 
			
		||||
            System.out.println("返回信息:" + resultJson);
 | 
			
		||||
            if (StringUtils.isEmpty(resultJson)) {
 | 
			
		||||
                pickDetail.setSourceId(0L);
 | 
			
		||||
                pickDetail.setSourceName("MES返回信息:接口调用失败");
 | 
			
		||||
                pickDetailRepository.save(pickDetail);
 | 
			
		||||
                return;
 | 
			
		||||
            }
 | 
			
		||||
            JSONObject resultObject = JSON.parseObject(resultJson);
 | 
			
		||||
            if (resultObject == null) {
 | 
			
		||||
                pickDetail.setSourceId(0L);
 | 
			
		||||
                pickDetail.setSourceName("MES返回信息:接口数据返回为空");
 | 
			
		||||
                pickDetailRepository.save(pickDetail);
 | 
			
		||||
                return;
 | 
			
		||||
            }
 | 
			
		||||
            String code = resultObject.getString("code");
 | 
			
		||||
            message = resultObject.getString("message");
 | 
			
		||||
            if (!"0".equals(code)) {
 | 
			
		||||
                pickDetail.setSourceId(0L);
 | 
			
		||||
                pickDetail.setSourceName(message);
 | 
			
		||||
                pickDetailRepository.save(pickDetail);
 | 
			
		||||
                return;
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
        String resultJson = null;
 | 
			
		||||
        Dict dict = dictRepository.findDictByName("OPEN");
 | 
			
		||||
        if (dict == null) {
 | 
			
		||||
            pickDetail.setSourceId(1L);
 | 
			
		||||
            pickDetail.setSourceName("成功");
 | 
			
		||||
            pickDetailRepository.save(pickDetail);
 | 
			
		||||
            //保存日志
 | 
			
		||||
            logService.saveLogInfo(returnPickJson(pickDetail), pickDetail.getPick().getCode(), UrlApi.stock(), resultJson, "工单回传", 200, "info");
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        resultJson = HttpPostUtil.sendPostReq(url, returnPickJson(pickDetail).toString());
 | 
			
		||||
        if (StringUtils.isEmpty(resultJson)) {
 | 
			
		||||
            message = "MES返回信息:接口调用失败";
 | 
			
		||||
            handleFailure(pickDetail, returnPickJson(pickDetail), resultJson, message);
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
        JSONObject resultObject = JSON.parseObject(resultJson);
 | 
			
		||||
        if (resultObject == null) {
 | 
			
		||||
            message = "MES返回信息:接口数据返回为空";
 | 
			
		||||
            handleFailure(pickDetail, returnPickJson(pickDetail), resultJson, message);
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
        String code = resultObject.getString("code");
 | 
			
		||||
        message = resultObject.getString("message");
 | 
			
		||||
        if (!"200".equals(code)) {
 | 
			
		||||
            handleFailure(pickDetail, returnPickJson(pickDetail), resultJson, message);
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
        pickDetail.setSourceId(1L);
 | 
			
		||||
        pickDetail.setSourceName(message == null ? "成功" : message);
 | 
			
		||||
        pickDetail.setSourceName(resultJson);
 | 
			
		||||
        pickDetailRepository.save(pickDetail);
 | 
			
		||||
        //保存日志
 | 
			
		||||
        logService.saveLogInfo(returnPickJson(pickDetail), pickDetail.getPick().getCode(), UrlApi.stock(), resultJson, "工单回传", 200, "info");
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    private void handleFailure(PickDetail pickDetail, JSONObject requestJson, String resultJson, String message) {
 | 
			
		||||
        pickDetail.setSourceId(0L);
 | 
			
		||||
        pickDetail.setSourceName(message);
 | 
			
		||||
        pickDetailRepository.save(pickDetail);
 | 
			
		||||
        logService.saveLogInfo(requestJson,
 | 
			
		||||
                pickDetail.getPick().getGdCode() + "-" + pickDetail.getItem().getCode(),
 | 
			
		||||
                UrlApi.stock(),
 | 
			
		||||
                resultJson,
 | 
			
		||||
                "info",
 | 
			
		||||
                200,
 | 
			
		||||
                "info");
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -230,8 +230,6 @@ public class TaskServiceImpl implements TaskService {
 | 
			
		|||
            task.setAgvTask(agvTask);
 | 
			
		||||
            task.setTaskStatus(agvTask.getStatus());
 | 
			
		||||
            taskRepository.save(task);
 | 
			
		||||
           /* //叫料区是否有空车,呼叫到备料缓存区
 | 
			
		||||
            this.callEmptyStock(task.getPickDetail().getItem().getGoodType());*/
 | 
			
		||||
        }
 | 
			
		||||
        /*更新出库单状态*/
 | 
			
		||||
        pick.setStatus(BizStatus.PICKUP);
 | 
			
		||||
| 
						 | 
				
			
			@ -241,18 +239,14 @@ public class TaskServiceImpl implements TaskService {
 | 
			
		|||
 | 
			
		||||
    @Override
 | 
			
		||||
    @Transactional(rollbackFor = Exception.class)
 | 
			
		||||
    public void callEmptyStock(String goodType) {
 | 
			
		||||
        String srcAreaCode = "小件".equals(goodType) ? AreaNameDic.XJJLQ : AreaNameDic.DJJLQ;
 | 
			
		||||
    public void callEmptyStock(Point point) {
 | 
			
		||||
        String dstAreaCode = AreaNameDic.XJJLQ.equals(point.getArea().getName()) ? AreaNameDic.XJFBCQ : AreaNameDic.DJFBCQ;
 | 
			
		||||
 | 
			
		||||
        String dstAreaCode = "小件".equals(goodType) ? AreaNameDic.XJFBCQ : AreaNameDic.DJFBCQ;
 | 
			
		||||
 | 
			
		||||
        List<Stock> emptyStock = stockService.findByFreeOrUsedStock(srcAreaCode, BaseStatus.FREE);
 | 
			
		||||
        if (emptyStock.isEmpty()) {
 | 
			
		||||
        //容器
 | 
			
		||||
        Stock stock=stockService.findByPointCode(point.getCode());
 | 
			
		||||
        if (stock==null) {
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
        //容器
 | 
			
		||||
        Stock stock = emptyStock.get(0);
 | 
			
		||||
 | 
			
		||||
        //起点
 | 
			
		||||
        Point srcPoint = stock.getPoint();
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -44,7 +44,4 @@ public interface DictRepository extends JpaRepository<Dict, Long>, JpaSpecificat
 | 
			
		|||
 | 
			
		||||
    @Query(value = " select * from sys_dict b where b.name = :name ", nativeQuery = true)
 | 
			
		||||
    Dict findDictByName(String name);
 | 
			
		||||
 | 
			
		||||
    @Query(value = " from Dict where description = :description ")
 | 
			
		||||
    Dict findDictByDescription(String description);
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -246,7 +246,12 @@ public interface BizStatus {
 | 
			
		|||
    /**
 | 
			
		||||
     * 物料类型,小件
 | 
			
		||||
     */
 | 
			
		||||
    String XJ = "XJ";
 | 
			
		||||
    String XJ = "小件";
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 物料类型,大件
 | 
			
		||||
     */
 | 
			
		||||
    String DJ = "大件";
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 物料类型,门封
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -12,8 +12,8 @@ public class StockTypeToAreaMap {
 | 
			
		|||
    static {
 | 
			
		||||
        stockTypeToAreaMap = new HashMap<>();
 | 
			
		||||
        // 初始化Map
 | 
			
		||||
        stockTypeToAreaMap.put("小件", AreaNameDic.XJQ);
 | 
			
		||||
        stockTypeToAreaMap.put("大件", AreaNameDic.DJQ);
 | 
			
		||||
        stockTypeToAreaMap.put(BizStatus.XJ, AreaNameDic.XJQ);
 | 
			
		||||
        stockTypeToAreaMap.put(BizStatus.DJ, AreaNameDic.DJQ);
 | 
			
		||||
        // 更多的初始化操作...
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,50 +1,52 @@
 | 
			
		|||
package com.youchain.utils;
 | 
			
		||||
 | 
			
		||||
import com.youchain.modules.system.service.ApiDictService;
 | 
			
		||||
import com.youchain.modules.system.service.impl.ApiDictServiceImpl;
 | 
			
		||||
 | 
			
		||||
public class UrlApi {
 | 
			
		||||
    private static RedisUtils redisUtils = SpringContextHolder.getBean(RedisUtils.class);
 | 
			
		||||
    private static ApiDictServiceImpl apiDictServiceImpl = SpringContextHolder.getBean(ApiDictServiceImpl.class);
 | 
			
		||||
 | 
			
		||||
    public static String  getByKey(String key){
 | 
			
		||||
        String re= (String)redisUtils.get(key);
 | 
			
		||||
        if(re==null||re.length()<=0||"".equals(re.trim())){
 | 
			
		||||
    public static String getByKey(String key) {
 | 
			
		||||
        String re = (String) redisUtils.get(key);
 | 
			
		||||
        if (re == null || re.length() <= 0 || "".equals(re.trim())) {
 | 
			
		||||
            apiDictServiceImpl.queryAllToSave();
 | 
			
		||||
            re= (String)redisUtils.get(key);
 | 
			
		||||
            re = (String) redisUtils.get(key);
 | 
			
		||||
        }
 | 
			
		||||
        return re;
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    public static String submitMission(){
 | 
			
		||||
        return (String)getByKey("submitMission_url");
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public static String containerIn(){
 | 
			
		||||
        return (String)getByKey("containerIn_url");
 | 
			
		||||
    ;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    public static String submitMission() {
 | 
			
		||||
        return (String) getByKey("submitMission_url");
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public static String containerOut(){
 | 
			
		||||
        return (String)getByKey("containerOut_url");
 | 
			
		||||
    public static String containerIn() {
 | 
			
		||||
        return (String) getByKey("containerIn_url");
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public static String stock(){
 | 
			
		||||
        return (String)getByKey("stock_url");
 | 
			
		||||
    public static String containerOut() {
 | 
			
		||||
        return (String) getByKey("containerOut_url");
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public static String containerQuery(){
 | 
			
		||||
        return (String)getByKey("containerQuery"+"_url");
 | 
			
		||||
    }
 | 
			
		||||
    public static String querypoint(){
 | 
			
		||||
        return (String)getByKey("querypoint"+"_url");
 | 
			
		||||
    }
 | 
			
		||||
    public static String QueryCount(){
 | 
			
		||||
        return (String)getByKey("QueryCount"+"_url");
 | 
			
		||||
    public static String stock() {
 | 
			
		||||
        return (String) getByKey("stock_url");
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
   /* *//**
 | 
			
		||||
    public static String containerQuery() {
 | 
			
		||||
        return (String) getByKey("containerQuery" + "_url");
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public static String querypoint() {
 | 
			
		||||
        return (String) getByKey("querypoint" + "_url");
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public static String QueryCount() {
 | 
			
		||||
        return (String) getByKey("QueryCount" + "_url");
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /* *//**
 | 
			
		||||
     * 料箱任务下发
 | 
			
		||||
     *//*
 | 
			
		||||
    public static String submitMission = "http://10.177.202.230:10870/interfaces/api/amr/submitMission";
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -6,8 +6,8 @@ spring:
 | 
			
		|||
  freemarker:
 | 
			
		||||
    check-template-location: false
 | 
			
		||||
  profiles:
 | 
			
		||||
    #active: prod
 | 
			
		||||
    active: dev
 | 
			
		||||
    active: prod
 | 
			
		||||
    #active: dev
 | 
			
		||||
  jackson:
 | 
			
		||||
    time-zone: GMT+8
 | 
			
		||||
  data:
 | 
			
		||||
| 
						 | 
				
			
			@ -36,11 +36,11 @@ spring:
 | 
			
		|||
  redis:
 | 
			
		||||
    #数据库索引
 | 
			
		||||
    database: ${REDIS_DB:2}
 | 
			
		||||
    #host: ${REDIS_HOST:192.168.100.102}
 | 
			
		||||
    #password: ${REDIS_PWD:123456}
 | 
			
		||||
    host: ${REDIS_HOST:192.168.100.102}
 | 
			
		||||
    password: ${REDIS_PWD:123456}
 | 
			
		||||
 | 
			
		||||
    host: ${REDIS_HOST:localhost}
 | 
			
		||||
    password: ${REDIS_PWD:}
 | 
			
		||||
    #host: ${REDIS_HOST:localhost}
 | 
			
		||||
    #password: ${REDIS_PWD:}
 | 
			
		||||
    port: ${REDIS_PORT:6379}
 | 
			
		||||
    #连接超时时间
 | 
			
		||||
    timeout: 5000
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue