ItemDownloadService.java
1.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
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;
}
}