Blame view

src/main/java/com/huaheng/api/SSP/service/ItemDownloadApiService.java 2.29 KB
1
2
3
4
package com.huaheng.api.SSP.service;

import com.alibaba.fastjson.JSON;
import com.huaheng.api.SSP.domain.SSPmaterialModel;
5
import com.huaheng.common.exception.service.ServiceException;
6
7
8
9
10
11
12
13
14
15
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;
16
17

//物料信息上传
18
19
@Service
@Transactional
20
public class ItemDownloadApiService {
21
22
23
24
25
26
27

    @Autowired
    IMaterialService iMaterialService;


    public AjaxResult Idls(String url){
        Material material = new Material();
28
        material.setZoneCode("QG");
29
        material.setUserDef2("0");
30
31
        Material materials = iMaterialService.selectFirstEntity(material);
        if (materials==null){
32
            return AjaxResult.success("系统中没有钱柜的物料!!或钱柜的物流已全部发完!!");
33
        }
34
35
        try {
36
            SSPmaterialModel smm = new SSPmaterialModel();
37
            smm.setSpecification(materials.getSpecification());
38
            smm.setCubeCode(materials.getZoneCode());
39
40
41
42
43
44
            smm.setCompanyCode(materials.getCompanyCode());
            smm.setItemCode(materials.getCode());
            smm.setItemName(materials.getName());
            smm.setItemBarcode(materials.getBarcode());
            smm.setWarehouseCode(materials.getWarehouseCode());
            smm.setItemUnit(materials.getMasterUnit());
45
            SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:sss");
46
            smm.setcDatetime(df.format(new Date()));
47
48
49
50
51
52
53
54
55
56
57
58
59
            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("物料信息同步上传失败");
        }
60
    }
61
62
63
}