|
@@ -1,5 +1,6 @@
|
|
package com.steerinfo.ems.emsprodplanroundweight.service.impl;
|
|
package com.steerinfo.ems.emsprodplanroundweight.service.impl;
|
|
|
|
|
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
import com.steerinfo.ems.Utils.DateUtils;
|
|
import com.steerinfo.ems.Utils.DateUtils;
|
|
import com.steerinfo.feigen.model.GxWeight;
|
|
import com.steerinfo.feigen.model.GxWeight;
|
|
import com.steerinfo.feigen.model.LgWeight;
|
|
import com.steerinfo.feigen.model.LgWeight;
|
|
@@ -10,6 +11,8 @@ import com.steerinfo.framework.service.impl.BaseServiceImpl;
|
|
import com.steerinfo.ems.emsprodplanroundweight.model.EmsProdplanRoundWeight;
|
|
import com.steerinfo.ems.emsprodplanroundweight.model.EmsProdplanRoundWeight;
|
|
import com.steerinfo.ems.emsprodplanroundweight.mapper.EmsProdplanRoundWeightMapper;
|
|
import com.steerinfo.ems.emsprodplanroundweight.mapper.EmsProdplanRoundWeightMapper;
|
|
import com.steerinfo.ems.emsprodplanroundweight.service.IEmsProdplanRoundWeightService;
|
|
import com.steerinfo.ems.emsprodplanroundweight.service.IEmsProdplanRoundWeightService;
|
|
|
|
+import org.slf4j.Logger;
|
|
|
|
+import org.slf4j.LoggerFactory;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
@@ -39,6 +42,8 @@ public class EmsProdplanRoundWeightServiceImpl extends BaseServiceImpl<EmsProdpl
|
|
private LgWeightFeigenService lgWeightFeigenService;
|
|
private LgWeightFeigenService lgWeightFeigenService;
|
|
@Autowired
|
|
@Autowired
|
|
private GxWeightFeigenService gxWeightFeigenService;
|
|
private GxWeightFeigenService gxWeightFeigenService;
|
|
|
|
+ private static final Logger logger = LoggerFactory.getLogger(EmsProdplanRoundWeightServiceImpl.class);
|
|
|
|
+
|
|
@Override
|
|
@Override
|
|
protected IBaseMapper<EmsProdplanRoundWeight, String> getMapper() {
|
|
protected IBaseMapper<EmsProdplanRoundWeight, String> getMapper() {
|
|
return emsProdplanRoundWeightMapper;
|
|
return emsProdplanRoundWeightMapper;
|
|
@@ -54,30 +59,38 @@ public class EmsProdplanRoundWeightServiceImpl extends BaseServiceImpl<EmsProdpl
|
|
Date dt1 = rightNow.getTime();
|
|
Date dt1 = rightNow.getTime();
|
|
String reStr = sdf.format(dt1);
|
|
String reStr = sdf.format(dt1);
|
|
List<LgWeight> lgWeights = lgWeightFeigenService.QueryWeightforRound(reStr, DateUtils.dateStr(new Date(), "yyyy-MM-dd"));
|
|
List<LgWeight> lgWeights = lgWeightFeigenService.QueryWeightforRound(reStr, DateUtils.dateStr(new Date(), "yyyy-MM-dd"));
|
|
|
|
+ logger.info("获取炼钢计划条数" + lgWeights.size());
|
|
lgWeights.forEach(item -> {
|
|
lgWeights.forEach(item -> {
|
|
- EmsProdplanRoundWeight model = new EmsProdplanRoundWeight();
|
|
|
|
- model.setFid(item.getFid());
|
|
|
|
- model.setLcId(item.getRoundid());
|
|
|
|
- model.setQty(item.getWeight());
|
|
|
|
- model.setMaterialcode(item.getMaterialcode());
|
|
|
|
- model.setMaterialname(item.getMaterialname());
|
|
|
|
- model.setProdate(item.getProdate());
|
|
|
|
- model.setUnit(item.getUnit());
|
|
|
|
- //fid有重复
|
|
|
|
-// EmsProdplanRoundWeight emsProdplanRoundWeight = emsProdplanRoundWeightMapper.selectByPrimaryKey(model.getFid());
|
|
|
|
- Map<String,Object> map = new HashMap();
|
|
|
|
- map.put("fid",model.getFid());
|
|
|
|
- map.put("lcId",model.getLcId());
|
|
|
|
- List<EmsProdplanRoundWeight> emsProdplanRoundWeights = emsProdplanRoundWeightMapper.selectByParameters(map);
|
|
|
|
- for(EmsProdplanRoundWeight emsProdplanRoundWeight:emsProdplanRoundWeights){
|
|
|
|
|
|
+ try{
|
|
|
|
+ EmsProdplanRoundWeight model = new EmsProdplanRoundWeight();
|
|
|
|
+ model.setFid(item.getFid());
|
|
|
|
+ model.setLcId(item.getRoundid());
|
|
|
|
+ model.setQty(item.getWeight());
|
|
|
|
+ model.setMaterialcode(item.getMaterialcode());
|
|
|
|
+ model.setMaterialname(item.getMaterialname());
|
|
|
|
+ model.setProdate(item.getProdate());
|
|
|
|
+ model.setUnit(item.getUnit());
|
|
|
|
+ model.setRemark("");
|
|
|
|
+ //fid有重复
|
|
|
|
+ // EmsProdplanRoundWeight emsProdplanRoundWeight = emsProdplanRoundWeightMapper.selectByPrimaryKey(model.getFid());
|
|
|
|
+ Map<String,Object> map = new HashMap();
|
|
|
|
+ map.put("fid",model.getFid());
|
|
|
|
+ map.put("lcId",model.getLcId());
|
|
|
|
+ List<EmsProdplanRoundWeight> emsProdplanRoundWeights = emsProdplanRoundWeightMapper.selectByParameters(map);
|
|
|
|
+ EmsProdplanRoundWeight emsProdplanRoundWeight =null;
|
|
|
|
+ if(emsProdplanRoundWeights.size()>0) {
|
|
|
|
+ emsProdplanRoundWeight = emsProdplanRoundWeights.get(0);
|
|
|
|
+ }
|
|
if(emsProdplanRoundWeight != null){
|
|
if(emsProdplanRoundWeight != null){
|
|
|
|
+ emsProdplanRoundWeight.setQty(item.getWeight());
|
|
emsProdplanRoundWeightMapper.updateByPrimaryKeySelective(emsProdplanRoundWeight);
|
|
emsProdplanRoundWeightMapper.updateByPrimaryKeySelective(emsProdplanRoundWeight);
|
|
- }
|
|
|
|
- else {
|
|
|
|
|
|
+ }else {
|
|
emsProdplanRoundWeightMapper.insert(model);
|
|
emsProdplanRoundWeightMapper.insert(model);
|
|
}
|
|
}
|
|
|
|
+ }catch (Exception e) {
|
|
|
|
+ logger.info("本次获取炼钢计划出错" + JSONObject.toJSONString(item));
|
|
|
|
+ e.printStackTrace();
|
|
}
|
|
}
|
|
-
|
|
|
|
});
|
|
});
|
|
|
|
|
|
}
|
|
}
|
|
@@ -111,41 +124,66 @@ public class EmsProdplanRoundWeightServiceImpl extends BaseServiceImpl<EmsProdpl
|
|
}
|
|
}
|
|
});
|
|
});
|
|
}
|
|
}
|
|
- //获取炼钢计划的重量
|
|
|
|
- public void getWeightForLg半年() throws ParseException {
|
|
|
|
|
|
+ //获取炼钢计划的重量(可以指定生成哪段时间的)
|
|
|
|
+ public void getWeightForLg半年(String day) throws ParseException {
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
|
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();
|
|
Calendar rightNow = Calendar.getInstance();
|
|
rightNow.setTime(dt);
|
|
rightNow.setTime(dt);
|
|
- rightNow.add(Calendar.DAY_OF_MONTH, -150);
|
|
|
|
|
|
+ rightNow.add(Calendar.DAY_OF_MONTH, -(Integer.parseInt(day)));
|
|
Date dt1 = rightNow.getTime();
|
|
Date dt1 = rightNow.getTime();
|
|
String reStr = sdf.format(dt1);
|
|
String reStr = sdf.format(dt1);
|
|
List<LgWeight> lgWeights = lgWeightFeigenService.QueryWeightforRound(reStr, DateUtils.dateStr(new Date(), "yyyy-MM-dd"));
|
|
List<LgWeight> lgWeights = lgWeightFeigenService.QueryWeightforRound(reStr, DateUtils.dateStr(new Date(), "yyyy-MM-dd"));
|
|
|
|
+ logger.info("获取炼钢计划条数" + lgWeights.size());
|
|
lgWeights.forEach(item -> {
|
|
lgWeights.forEach(item -> {
|
|
- EmsProdplanRoundWeight model = new EmsProdplanRoundWeight();
|
|
|
|
- model.setFid(item.getFid());
|
|
|
|
- model.setLcId(item.getRoundid());
|
|
|
|
- model.setQty(item.getWeight());
|
|
|
|
- model.setMaterialcode(item.getMaterialcode());
|
|
|
|
- model.setMaterialname(item.getMaterialname());
|
|
|
|
- model.setProdate(item.getProdate());
|
|
|
|
- model.setUnit(item.getUnit());
|
|
|
|
- //fid有重复
|
|
|
|
-// EmsProdplanRoundWeight emsProdplanRoundWeight = emsProdplanRoundWeightMapper.selectByPrimaryKey(model.getFid());
|
|
|
|
- Map<String,Object> map = new HashMap();
|
|
|
|
- map.put("fid",model.getFid());
|
|
|
|
- map.put("lcId",model.getLcId());
|
|
|
|
- List<EmsProdplanRoundWeight> emsProdplanRoundWeights = emsProdplanRoundWeightMapper.selectByParameters(map);
|
|
|
|
- for(EmsProdplanRoundWeight emsProdplanRoundWeight:emsProdplanRoundWeights){
|
|
|
|
|
|
+ try{
|
|
|
|
+ EmsProdplanRoundWeight model = new EmsProdplanRoundWeight();
|
|
|
|
+ model.setFid(item.getFid());
|
|
|
|
+ model.setLcId(item.getRoundid());
|
|
|
|
+ model.setQty(item.getWeight());
|
|
|
|
+ model.setMaterialcode(item.getMaterialcode());
|
|
|
|
+ model.setMaterialname(item.getMaterialname());
|
|
|
|
+ model.setProdate(item.getProdate());
|
|
|
|
+ model.setUnit(item.getUnit());
|
|
|
|
+ model.setRemark("");
|
|
|
|
+ //fid有重复
|
|
|
|
+ // EmsProdplanRoundWeight emsProdplanRoundWeight = emsProdplanRoundWeightMapper.selectByPrimaryKey(model.getFid());
|
|
|
|
+ Map<String,Object> map = new HashMap();
|
|
|
|
+ map.put("fid",model.getFid());
|
|
|
|
+ map.put("lcId",model.getLcId());
|
|
|
|
+ logger.info("查询参数" + JSONObject.toJSONString(map));
|
|
|
|
+ List<EmsProdplanRoundWeight> emsProdplanRoundWeights = emsProdplanRoundWeightMapper.selectByParameters(map);
|
|
|
|
+ logger.info("查询结果" + JSONObject.toJSONString(emsProdplanRoundWeights));
|
|
|
|
+ EmsProdplanRoundWeight emsProdplanRoundWeight =null;
|
|
|
|
+ if(emsProdplanRoundWeights.size()>0) {
|
|
|
|
+ emsProdplanRoundWeight = emsProdplanRoundWeights.get(0);
|
|
|
|
+ }
|
|
if(emsProdplanRoundWeight != null){
|
|
if(emsProdplanRoundWeight != null){
|
|
|
|
+ emsProdplanRoundWeight.setQty(item.getWeight());
|
|
emsProdplanRoundWeightMapper.updateByPrimaryKeySelective(emsProdplanRoundWeight);
|
|
emsProdplanRoundWeightMapper.updateByPrimaryKeySelective(emsProdplanRoundWeight);
|
|
- }
|
|
|
|
- else {
|
|
|
|
|
|
+ logger.info("更新" );
|
|
|
|
+ }else {
|
|
emsProdplanRoundWeightMapper.insert(model);
|
|
emsProdplanRoundWeightMapper.insert(model);
|
|
|
|
+ logger.info("插入" );
|
|
}
|
|
}
|
|
|
|
+ }catch (Exception e) {
|
|
|
|
+ logger.info("本次获取炼钢计划出错" + JSONObject.toJSONString(item));
|
|
|
|
+ e.printStackTrace();
|
|
}
|
|
}
|
|
-
|
|
|
|
});
|
|
});
|
|
|
|
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ public static void main(String[] args) throws ParseException {
|
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("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, -150);
|
|
|
|
+ Date dt1 = rightNow.getTime();
|
|
|
|
+ String reStr = sdf.format(dt1);
|
|
|
|
+ System.out.println(reStr);
|
|
|
|
+ System.out.println(DateUtils.dateStr(new Date(), "yyyy-MM-dd"));
|
|
|
|
+
|
|
|
|
+ }
|
|
}
|
|
}
|