|
@@ -31,19 +31,14 @@ import java.text.ParseException;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.util.*;
|
|
|
|
|
|
-import org.slf4j.Logger;
|
|
|
-import org.slf4j.LoggerFactory;
|
|
|
-import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.stereotype.Service;
|
|
|
-
|
|
|
@Service(value = "ifMesEmsSwapfileService")
|
|
|
public class IfMesEmsSwapfileServiceImpl extends BaseServiceImpl<IfMesEmsSwapfile, String> implements IIfMesEmsSwapfileService {
|
|
|
-
|
|
|
+
|
|
|
private static final Logger logger = LoggerFactory.getLogger(IfMesEmsSwapfileServiceImpl.class);
|
|
|
|
|
|
- @Autowired
|
|
|
- private IfMesEmsSwapfileMapper ifmesemsswapfilemapper;
|
|
|
- @Autowired
|
|
|
+ @Autowired
|
|
|
+ private IfMesEmsSwapfileMapper ifmesemsswapfilemapper;
|
|
|
+ @Autowired
|
|
|
private LgWeightFeigenService lgWeightFeigenService;
|
|
|
|
|
|
@Autowired
|
|
@@ -58,12 +53,12 @@ public class IfMesEmsSwapfileServiceImpl extends BaseServiceImpl<IfMesEmsSwapfil
|
|
|
@Autowired
|
|
|
ITRmWorkprocProductService tRmWorkprocProductService;
|
|
|
|
|
|
- @Override
|
|
|
- protected IBaseMapper<IfMesEmsSwapfile, String> getMapper() {
|
|
|
- return ifmesemsswapfilemapper;
|
|
|
- }
|
|
|
+ @Override
|
|
|
+ protected IBaseMapper<IfMesEmsSwapfile, String> getMapper() {
|
|
|
+ return ifmesemsswapfilemapper;
|
|
|
+ }
|
|
|
|
|
|
- public String synchronousMesAnEmsData() {
|
|
|
+ public String synchronousMesAnEmsData() {
|
|
|
int addSize = 0;
|
|
|
int updateSize = 0;
|
|
|
String url = "http://172.16.100.91:8093/mes_interface/mesdata"; // 投入产出数据
|
|
@@ -81,7 +76,7 @@ public class IfMesEmsSwapfileServiceImpl extends BaseServiceImpl<IfMesEmsSwapfil
|
|
|
logger.info("获取投入产出数据条数:" + ja.size());
|
|
|
for (int i = 0; i < ja.size(); i++) {
|
|
|
JSONObject jo = (JSONObject) ja.get(i);
|
|
|
- if(!jo.containsKey("fid")){
|
|
|
+ if (!jo.containsKey("fid")) {
|
|
|
continue;
|
|
|
}
|
|
|
// 新数据
|
|
@@ -90,17 +85,17 @@ public class IfMesEmsSwapfileServiceImpl extends BaseServiceImpl<IfMesEmsSwapfil
|
|
|
// 原数据
|
|
|
String fid = jo.getString("fid");
|
|
|
IfMesEmsSwapfile ime = ifmesemsswapfilemapper.selectByPrimaryKey(fid);
|
|
|
- if(ime!=null){
|
|
|
+ if (ime != null) {
|
|
|
ifmesemsswapfilemapper.updateByPrimaryKey(model);
|
|
|
- updateSize +=1;
|
|
|
+ updateSize += 1;
|
|
|
logger.info("修改数据:" + jo.toJSONString());
|
|
|
if (!model.getStatus().equals("9")) {
|
|
|
- logger.error("有重复不正常的数据,fid:"+ fid + ",status:" + model.getStatus());
|
|
|
+ logger.error("有重复不正常的数据,fid:" + fid + ",status:" + model.getStatus());
|
|
|
}
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
addSize += ifmesemsswapfilemapper.insert(model);
|
|
|
if (!model.getStatus().equals("0")) {
|
|
|
- logger.error("有新增不正常的数据,fid:"+ fid + ",status:" + model.getStatus());
|
|
|
+ logger.error("有新增不正常的数据,fid:" + fid + ",status:" + model.getStatus());
|
|
|
}
|
|
|
}
|
|
|
HttpRequestMes.httpRequestMes(url, "post", "[{\"id\":\"" + jo.getString("fid") + "\",\"status\":\"1\"}]");
|
|
@@ -117,13 +112,15 @@ public class IfMesEmsSwapfileServiceImpl extends BaseServiceImpl<IfMesEmsSwapfil
|
|
|
}
|
|
|
logger.info("本次总共新增投入产出数据条数:" + addSize);
|
|
|
logger.info("本次总共更新投入产出数据条数:" + updateSize);
|
|
|
- return "本次新增" + addSize + "条,更新" + updateSize + "条。";
|
|
|
+ return "本次新增" + addSize + "条,更新" + updateSize + "条。";
|
|
|
}
|
|
|
|
|
|
public List<IfMesEmsSwapfile> selectNewMaterial(HashMap<String, Object> model) {
|
|
|
List<IfMesEmsSwapfile> list = ifmesemsswapfilemapper.selectNewMaterial(model);
|
|
|
return list;
|
|
|
- };
|
|
|
+ }
|
|
|
+
|
|
|
+ ;
|
|
|
|
|
|
public int updateStatus(HashMap<String, Object> m) {
|
|
|
return ifmesemsswapfilemapper.updateStatus(m);
|
|
@@ -131,7 +128,7 @@ public class IfMesEmsSwapfileServiceImpl extends BaseServiceImpl<IfMesEmsSwapfil
|
|
|
|
|
|
public BigDecimal getSUM(HashMap<String, Object> map) {
|
|
|
BigDecimal sum = ifmesemsswapfilemapper.getSUM(map);
|
|
|
- return sum;
|
|
|
+ return sum;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -140,24 +137,24 @@ public class IfMesEmsSwapfileServiceImpl extends BaseServiceImpl<IfMesEmsSwapfil
|
|
|
String url = "http://ems.sxzygc.com.cn/zhongsteel.pass.web/pass/ems/v1/ifmesemsswapfile/?pageNum=1&pageSize=2000&prodate=" + clock; // 投入产出数据
|
|
|
String res = HttpRequestMes.httpRequestMes(url, "get", null);
|
|
|
JSONObject jo = JSONObject.parseObject(res);
|
|
|
- if (jo != null && !jo.isEmpty() && jo.getString("code").equals("0")){
|
|
|
- JSONObject jo2 = (JSONObject)jo.get("data");
|
|
|
- JSONArray ja = (JSONArray)jo2.get("list");
|
|
|
+ if (jo != null && !jo.isEmpty() && jo.getString("code").equals("0")) {
|
|
|
+ JSONObject jo2 = (JSONObject) jo.get("data");
|
|
|
+ JSONArray ja = (JSONArray) jo2.get("list");
|
|
|
if (ja != null && !ja.isEmpty()) {
|
|
|
for (int i = 0; i < ja.size(); i++) {
|
|
|
JSONObject jo3 = (JSONObject) ja.get(i);
|
|
|
IfMesEmsSwapfile model = new IfMesEmsSwapfile();
|
|
|
model.setFid(jo3.getString("fid"));
|
|
|
model.setId(jo3.getString("fid"));
|
|
|
- model.setCreatetime(jo3.getString("createtime")!=null?jo3.getString("createtime").substring(0, 19):"");
|
|
|
+ model.setCreatetime(jo3.getString("createtime") != null ? jo3.getString("createtime").substring(0, 19) : "");
|
|
|
model.setWorks(jo3.getString("works"));
|
|
|
model.setMaterialcode(jo3.getString("materialcode"));
|
|
|
model.setMaterialname(jo3.getString("materialname"));
|
|
|
model.setOrderno(jo3.getString("orderno"));
|
|
|
- model.setProdate(jo3.getString("prodate")!=null?jo3.getString("prodate").substring(0, 19):"");
|
|
|
+ model.setProdate(jo3.getString("prodate") != null ? jo3.getString("prodate").substring(0, 19) : "");
|
|
|
model.setProdline(jo3.getString("prodline"));
|
|
|
model.setQty(jo3.getBigDecimal("qty"));
|
|
|
- model.setSendtime(jo3.getString("sendtime")!=null?jo3.getString("sendtime").substring(0, 19):"");
|
|
|
+ model.setSendtime(jo3.getString("sendtime") != null ? jo3.getString("sendtime").substring(0, 19) : "");
|
|
|
model.setStatus(jo3.getString("status"));
|
|
|
model.setType(jo3.getString("type"));
|
|
|
model.setUnit(jo3.getString("unit"));
|
|
@@ -171,7 +168,7 @@ public class IfMesEmsSwapfileServiceImpl extends BaseServiceImpl<IfMesEmsSwapfil
|
|
|
|
|
|
|
|
|
//获取炼钢的产出数据
|
|
|
- public void getLgDateProd(){
|
|
|
+ public void getLgDateProd() {
|
|
|
List<LgWeight> lgWeights = lgWeightFeigenService.QueryWeightByTime();
|
|
|
for (LgWeight lgWeight : lgWeights) {
|
|
|
IfMesEmsSwapfile model = new IfMesEmsSwapfile();
|
|
@@ -183,13 +180,13 @@ public class IfMesEmsSwapfileServiceImpl extends BaseServiceImpl<IfMesEmsSwapfil
|
|
|
model.setMaterialname(lgWeight.getMaterialname());
|
|
|
model.setUnit(lgWeight.getUnit());
|
|
|
model.setQty(lgWeight.getWeight());
|
|
|
- model.setCreatetime(DateUtils.dateStr(new Date(),"yyyy-MM-dd"));
|
|
|
+ model.setCreatetime(DateUtils.dateStr(new Date(), "yyyy-MM-dd"));
|
|
|
model.setStatus("0");
|
|
|
model.setFid(lgWeight.getFid());
|
|
|
IfMesEmsSwapfile ifMesEmsSwapfile = ifmesemsswapfilemapper.selectByPrimaryKey(lgWeight.getFid());
|
|
|
- if (ifMesEmsSwapfile != null ) {
|
|
|
+ if (ifMesEmsSwapfile != null) {
|
|
|
ifmesemsswapfilemapper.updateByPrimaryKey(model);
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
ifmesemsswapfilemapper.insert(model);
|
|
|
}
|
|
|
}
|
|
@@ -197,15 +194,15 @@ public class IfMesEmsSwapfileServiceImpl extends BaseServiceImpl<IfMesEmsSwapfil
|
|
|
}
|
|
|
|
|
|
//获取炼钢的投入数据
|
|
|
- public void getLgDateProd2() throws ParseException {
|
|
|
+ public void getLgDateProd2() throws ParseException {
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
- Date dt = sdf.parse(DateUtils.dateStr(new Date(),"yyyy-MM-dd"));
|
|
|
+ Date dt = sdf.parse(DateUtils.dateStr(new Date(), "yyyy-MM-dd"));
|
|
|
Calendar rightNow = Calendar.getInstance();
|
|
|
rightNow.setTime(dt);
|
|
|
rightNow.add(Calendar.DAY_OF_MONTH, -2);
|
|
|
Date dt1 = rightNow.getTime();
|
|
|
String reStr = sdf.format(dt1);
|
|
|
- List<LgWeight> lgWeights = lgWeightFeigenService.QueryWeightByTime2(reStr, DateUtils.dateStr(new Date(),"yyyy-MM-dd"));
|
|
|
+ List<LgWeight> lgWeights = lgWeightFeigenService.QueryWeightByTime2(reStr, DateUtils.dateStr(new Date(), "yyyy-MM-dd"));
|
|
|
for (LgWeight lgWeight : lgWeights) {
|
|
|
IfMesEmsSwapfile model = new IfMesEmsSwapfile();
|
|
|
model.setType(lgWeight.getType());
|
|
@@ -215,17 +212,19 @@ public class IfMesEmsSwapfileServiceImpl extends BaseServiceImpl<IfMesEmsSwapfil
|
|
|
model.setMaterialname(lgWeight.getMaterialname());
|
|
|
model.setUnit(lgWeight.getUnit());
|
|
|
model.setQty(lgWeight.getWeight());
|
|
|
- model.setCreatetime(DateUtils.dateStr(new Date(),"yyyy-MM-dd"));
|
|
|
+ model.setCreatetime(DateUtils.dateStr(new Date(), "yyyy-MM-dd"));
|
|
|
model.setStatus("0");
|
|
|
model.setFid(lgWeight.getFid());
|
|
|
IfMesEmsSwapfile ifMesEmsSwapfile = ifmesemsswapfilemapper.selectByPrimaryKey(lgWeight.getFid());
|
|
|
- if (ifMesEmsSwapfile != null ) {
|
|
|
+ if (ifMesEmsSwapfile != null) {
|
|
|
ifmesemsswapfilemapper.updateByPrimaryKey(model);
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
ifmesemsswapfilemapper.insert(model);
|
|
|
}
|
|
|
}
|
|
|
System.out.println("接收成功...");
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public PageList<Map<String, Object>> getQueryList(HashMap<String, Object> parmas, Integer pageNum, Integer pageSize) {
|
|
|
PageHelper.startPage(pageNum, pageSize);
|
|
@@ -235,7 +234,7 @@ public class IfMesEmsSwapfileServiceImpl extends BaseServiceImpl<IfMesEmsSwapfil
|
|
|
//String clock = new SimpleDateFormat("yyyy-MM-dd").format(cal.getTime());
|
|
|
//parmas.put("clockt", clock); // 可以修改的clock
|
|
|
//parmas.put("clocktm", clock.substring(0, 7)); // 可以修改的clock(月)
|
|
|
- if(parmas.get("workprocid")!=null && !parmas.get("workprocid").toString().isEmpty()){
|
|
|
+ if (parmas.get("workprocid") != null && !parmas.get("workprocid").toString().isEmpty()) {
|
|
|
String workProcids = parmas.get("workprocid").toString();
|
|
|
workProcids = "'" + workProcids.replaceAll(",", "','").replaceAll(",", "','") + "'";
|
|
|
parmas.put("workProcids", workProcids);
|
|
@@ -244,15 +243,16 @@ public class IfMesEmsSwapfileServiceImpl extends BaseServiceImpl<IfMesEmsSwapfil
|
|
|
PageList<Map<String, Object>> pageInfo = new PageList<Map<String, Object>>(rows);
|
|
|
return pageInfo;
|
|
|
}
|
|
|
+
|
|
|
@Override
|
|
|
public PageList<Map<String, Object>> queryProductAndMaterial(HashMap<String, Object> parmas, Integer pageNum, Integer pageSize) {
|
|
|
PageHelper.startPage(pageNum, pageSize);
|
|
|
- if(parmas.get("workprocid")!=null && !parmas.get("workprocid").toString().isEmpty()){
|
|
|
+ if (parmas.get("workprocid") != null && !parmas.get("workprocid").toString().isEmpty()) {
|
|
|
String workProcids = parmas.get("workprocid").toString();
|
|
|
workProcids = "'" + workProcids.replaceAll(",", "','").replaceAll(",", "','") + "'";
|
|
|
parmas.put("workProcids", workProcids);
|
|
|
}
|
|
|
- if(parmas.get("workproc")!=null && !parmas.get("workproc").toString().isEmpty()){
|
|
|
+ if (parmas.get("workproc") != null && !parmas.get("workproc").toString().isEmpty()) {
|
|
|
String workProcs = parmas.get("workproc").toString();
|
|
|
workProcs = "'" + workProcs.replaceAll(",", "','").replaceAll(",", "','") + "'";
|
|
|
parmas.put("workProcs", workProcs);
|
|
@@ -279,41 +279,39 @@ public class IfMesEmsSwapfileServiceImpl extends BaseServiceImpl<IfMesEmsSwapfil
|
|
|
String materialName;
|
|
|
int addSize = 0;
|
|
|
for (TRmWorkprocProduct tRmWorkprocProduct : tRmWorkprocProducts) {
|
|
|
- ifMesEmsSwapfile = ifmesemsswapfilemapper.selectByPrimaryKey(tRmWorkprocProduct.getProductid()+tRmWorkprocProduct.getMesProdline()+DateUtils.dateStr(new Date(),"yyyyMMdd"));
|
|
|
- if(ifMesEmsSwapfile == null)
|
|
|
- {
|
|
|
+ ifMesEmsSwapfile = ifmesemsswapfilemapper.selectByPrimaryKey(tRmWorkprocProduct.getProductid() + tRmWorkprocProduct.getMesProdline() + DateUtils.dateStr(new Date(), "yyyyMMdd"));
|
|
|
+ if (ifMesEmsSwapfile == null) {
|
|
|
materialName = tRmProductService.getById(tRmWorkprocProduct.getProductid()).getName();
|
|
|
model.setType("2");
|
|
|
model.setWorks(tRmWorkprocProduct.getWorkprocid());
|
|
|
model.setProdline(tRmWorkprocProduct.getMesProdline());
|
|
|
- model.setProdate(DateUtils.dateStr(new Date(),"yyyy-MM-dd"));
|
|
|
+ model.setProdate(DateUtils.dateStr(new Date(), "yyyy-MM-dd"));
|
|
|
model.setMaterialname(materialName);
|
|
|
model.setMaterialcode(tRmWorkprocProduct.getMesMaterialcode());
|
|
|
model.setUnit(tRmWorkprocProduct.getUnitid());
|
|
|
model.setQty(new BigDecimal(0));
|
|
|
// DateUtils.dateStr(new Date(),"yyyy-MM-dd hh-mm-ss")
|
|
|
- model.setCreatetime(DateUtils.dateStr(new Date(),"yyyy-MM-dd hh-mm-ss"));
|
|
|
+ model.setCreatetime(DateUtils.dateStr(new Date(), "yyyy-MM-dd hh-mm-ss"));
|
|
|
model.setStatus("0");
|
|
|
- model.setFid(tRmWorkprocProduct.getProductid()+tRmWorkprocProduct.getMesProdline()+DateUtils.dateStr(new Date(),"yyyyMMdd"));
|
|
|
+ model.setFid(tRmWorkprocProduct.getProductid() + tRmWorkprocProduct.getMesProdline() + DateUtils.dateStr(new Date(), "yyyyMMdd"));
|
|
|
addSize += ifmesemsswapfilemapper.insert(model);
|
|
|
}
|
|
|
}
|
|
|
for (TRmWorkprocMaterial tRmWorkprocMaterial : tRmWorkprocMaterials) {
|
|
|
- ifMesEmsSwapfile = ifmesemsswapfilemapper.selectByPrimaryKey(tRmWorkprocMaterial.getMaterialid()+tRmWorkprocMaterial.getMesProdline()+DateUtils.dateStr(new Date(),"yyyyMMdd"));
|
|
|
- if(ifMesEmsSwapfile == null)
|
|
|
- {
|
|
|
+ ifMesEmsSwapfile = ifmesemsswapfilemapper.selectByPrimaryKey(tRmWorkprocMaterial.getMaterialid() + tRmWorkprocMaterial.getMesProdline() + DateUtils.dateStr(new Date(), "yyyyMMdd"));
|
|
|
+ if (ifMesEmsSwapfile == null) {
|
|
|
materialName = tRmMaterialService.getById(tRmWorkprocMaterial.getMaterialid()).getName();
|
|
|
model.setType("1");
|
|
|
model.setWorks(tRmWorkprocMaterial.getWorkprocid());
|
|
|
model.setProdline(tRmWorkprocMaterial.getMesProdline());
|
|
|
- model.setProdate(DateUtils.dateStr(new Date(),"yyyy-MM-dd"));
|
|
|
+ model.setProdate(DateUtils.dateStr(new Date(), "yyyy-MM-dd"));
|
|
|
model.setMaterialname(materialName);
|
|
|
model.setMaterialcode(tRmWorkprocMaterial.getMesMaterialcode());
|
|
|
model.setUnit(tRmWorkprocMaterial.getUnitid());
|
|
|
model.setQty(new BigDecimal(0));
|
|
|
- model.setCreatetime(DateUtils.dateStr(new Date(),"yyyy-MM-dd hh-mm-ss"));
|
|
|
+ model.setCreatetime(DateUtils.dateStr(new Date(), "yyyy-MM-dd hh-mm-ss"));
|
|
|
model.setStatus("0");
|
|
|
- model.setFid(tRmWorkprocMaterial.getMaterialid()+tRmWorkprocMaterial.getMesProdline()+DateUtils.dateStr(new Date(),"yyyyMMdd"));
|
|
|
+ model.setFid(tRmWorkprocMaterial.getMaterialid() + tRmWorkprocMaterial.getMesProdline() + DateUtils.dateStr(new Date(), "yyyyMMdd"));
|
|
|
addSize += ifmesemsswapfilemapper.insert(model);
|
|
|
}
|
|
|
}
|