ItemDownloadService.java 1.93 KB
package com.huaheng.api.SSP.service;

import com.alibaba.fastjson.JSON;
import com.huaheng.api.SSP.domain.SSPmaterialModel;
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;
import java.util.ArrayList;
import java.util.List;

@Service
@Transactional
public class ItemDownloadService {

    @Autowired
    IMaterialService iMaterialService;


    public AjaxResult Idls(String url){
        Material material = new Material();
        material.setUserDef1("QG");
        List<Material> materials = iMaterialService.selectListEntityByEqual(material);
        if (materials.size()<1){
            return AjaxResult.success("系统中没有钱柜的物料!!");
        }
        List<SSPmaterialModel> list = new ArrayList<>();
        for (Material item:materials) {
            SSPmaterialModel smm = new SSPmaterialModel();
            smm.setCubeCode(item.getUserDef1());
            smm.setCompanyCode(item.getCompanyCode());
            smm.setItemCode(item.getCode());
            smm.setItemName(item.getName());
            smm.setItemBarcode(item.getBarcode());
            smm.setWarehouseCode(item.getWarehouseCode());
            smm.setItemUnit(item.getMasterUnit());
            SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            smm.setcDatetime(df.format(new Date()));
            list.add(smm);
        }
        String JsonParam = JSON.toJSONString(list);
        String result = HttpUtils.sendPost(url, JsonParam);
        AjaxResult ajaxResult = JSON.parseObject(result, AjaxResult.class);

        return ajaxResult;
    }
}