Blame view

src/main/java/com/huaheng/api/SSP/service/ItemDownloadApiService.java 3.44 KB
游杰 authored
1
2
3
4
5
package com.huaheng.api.SSP.service;

import com.alibaba.fastjson.JSON;
import com.huaheng.api.SSP.domain.SSPmaterialModel;
import com.huaheng.common.exception.service.ServiceException;
6
import com.huaheng.common.utils.StringUtils;
游杰 authored
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import com.huaheng.common.utils.http.HttpUtils;
import com.huaheng.framework.web.domain.AjaxResult;
import com.huaheng.pc.general.material.domain.Material;
import com.huaheng.pc.general.material.service.IMaterialService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Date;
import java.text.SimpleDateFormat;

//物料信息上传
@Service
@Transactional
public class ItemDownloadApiService {

    @Autowired
    IMaterialService iMaterialService;
26
27
    private  static String address="";
    //private  static String address="http://172.16.30.238:4322/api/SSP/";
游杰 authored
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44

    public AjaxResult Idls(String url){
        Material material = new Material();
        material.setZoneCode("QG");
        material.setUserDef2("0");
        Material materials = iMaterialService.selectFirstEntity(material);
        if (materials==null){
            return AjaxResult.success("系统中没有钱柜的物料!!或钱柜的物流已全部发完!!");
        }

        try {
            SSPmaterialModel smm = new SSPmaterialModel();
            smm.setSpecification(materials.getSpecification());
            smm.setCubeCode(materials.getZoneCode());
            smm.setCompanyCode(materials.getCompanyCode());
            smm.setItemCode(materials.getCode());
            smm.setItemName(materials.getName());
pengcheng authored
45
            smm.setItemBarcode(materials.getCode());
游杰 authored
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
            smm.setWarehouseCode(materials.getWarehouseCode());
            smm.setItemUnit(materials.getMasterUnit());
            SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:sss");
            smm.setcDatetime(df.format(new Date()));

            String JsonParam = JSON.toJSONString(smm);
            String result = HttpUtils.bodypost(url, JsonParam);
            AjaxResult ajaxResult = JSON.parseObject(result, AjaxResult.class);

            Material upm = new Material();
            upm.setId(materials.getId());
            upm.setUserDef2("1");
            iMaterialService.updateByModel(upm);
            return ajaxResult;
        }catch (Exception e){
            throw new ServiceException("物料信息同步上传失败");
        }
    }
65
66
67
68
69
70
71
    public AjaxResult sendMaterial(Material material){
        SSPmaterialModel smm = new SSPmaterialModel();
        smm.setSpecification(material.getSpecification());
        smm.setCubeCode(material.getZoneCode());
        smm.setCompanyCode(material.getCompanyCode());
        smm.setItemCode(material.getCode());
        smm.setItemName(material.getName());
pengcheng authored
72
        smm.setItemBarcode(material.getCode());
73
74
75
76
        smm.setWarehouseCode(material.getWarehouseCode());
        smm.setItemUnit(material.getMasterUnit());
        SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:sss");
        smm.setcDatetime(df.format(new Date()));
77
        String url=address+"ItemDownload";
78
79
        String JsonParam = JSON.toJSONString(smm);
        String result = HttpUtils.bodypost(url, JsonParam);
80
81
82
        if(StringUtils.isEmpty(result)){
            throw new ServiceException("接口地址错误");
        }
83
84
85
86
        AjaxResult ajaxResult = JSON.parseObject(result, AjaxResult.class);
        return ajaxResult;
    }
游杰 authored
87
88

}