|
@@ -1,6 +1,9 @@
|
|
|
package com.steerinfo.ems.emsprodplanyear.controller;
|
|
|
|
|
|
import com.steerinfo.auth.utils.JwtUtil;
|
|
|
+import com.steerinfo.ems.emsprodplanmonth.mapper.EmsProdplanMonthMapper;
|
|
|
+import com.steerinfo.ems.emsprodplanmonth.model.EmsProdplanMonth;
|
|
|
+import com.steerinfo.ems.emsprodplanmonth.service.IEmsProdplanMonthService;
|
|
|
import com.steerinfo.ems.emsprodplanyear.mapper.EmsProdplanYearMapper;
|
|
|
import com.steerinfo.ems.emsprodplanyear.model.EmsProdplanYear;
|
|
|
import com.steerinfo.ems.emsprodplanyear.service.IEmsProdplanYearService;
|
|
@@ -13,6 +16,8 @@ import io.swagger.annotations.ApiOperation;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
+import java.math.BigDecimal;
|
|
|
+import java.text.ParseException;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
@@ -40,6 +45,11 @@ public class EmsProdplanYearController extends BaseRESTfulController {
|
|
|
@Autowired
|
|
|
private EmsProdplanYearMapper emsProdplanYearMapper;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private EmsProdplanMonthMapper emsProdplanMonthMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IEmsProdplanMonthService emsProdplanMonthService;
|
|
|
|
|
|
@ApiOperation(value="获取列表", notes="分页查询")
|
|
|
@ApiImplicitParams({
|
|
@@ -101,8 +111,9 @@ public class EmsProdplanYearController extends BaseRESTfulController {
|
|
|
@ApiOperation(value="创建", notes="根据EmsProdplanYear对象创建")
|
|
|
@ApiImplicitParam(name = "emsProdplanYear", value = "详细实体emsProdplanYear", required = true, dataType = "EmsProdplanYear")
|
|
|
@PostMapping(value = "/", produces = "application/json;charset=UTF-8")
|
|
|
- public RESTfulResult add(@RequestBody EmsProdplanYear[] models){
|
|
|
+ public RESTfulResult add(@RequestBody EmsProdplanYear[] models) throws ParseException {
|
|
|
String userId = JwtUtil.getUseridByToken();
|
|
|
+ Calendar c = Calendar.getInstance();
|
|
|
for (int i = 0; i < models.length; i++) {
|
|
|
EmsProdplanYear model = models[i];
|
|
|
Boolean lineBool = (model.getLine() == null || model.getLine().equals(""))
|
|
@@ -124,10 +135,118 @@ public class EmsProdplanYearController extends BaseRESTfulController {
|
|
|
if (list.size()>0){
|
|
|
return failed(null,"该月时间段数据已生成,无法再次生成");
|
|
|
}
|
|
|
-
|
|
|
model.setCjr(userId);
|
|
|
model.setCjsj(new Date());
|
|
|
- EmsProdplanYear emsProdplanYear = emsProdplanYearService.add(model);
|
|
|
+ emsProdplanYearService.add(model);
|
|
|
+ int dayMax = emsProdplanYearService.getDaysOfMonth(model.getYearmonth());
|
|
|
+ Integer sumWeight = 0;
|
|
|
+ EmsProdplanMonth maxSqno = emsProdplanMonthService.getMaxSqno();
|
|
|
+ String unit = "008";
|
|
|
+ String productid = "";
|
|
|
+ String workProcid = "";
|
|
|
+ switch (model.getParentid()) {
|
|
|
+ case "LG":
|
|
|
+ sumWeight = model.getWeight().intValue();
|
|
|
+ productid="钢坯";
|
|
|
+ unit="008";
|
|
|
+ workProcid = "AT2004";
|
|
|
+ break;
|
|
|
+ case "LT":
|
|
|
+ sumWeight = model.getWeight().intValue();
|
|
|
+ productid="生铁";
|
|
|
+ unit="008";
|
|
|
+ break;
|
|
|
+ case "SJ":
|
|
|
+ sumWeight = model.getWeight().intValue();
|
|
|
+ productid="烧结矿";
|
|
|
+ unit="008";
|
|
|
+ break;
|
|
|
+ case "ZG" :
|
|
|
+ sumWeight = model.getWeight().intValue();
|
|
|
+ productid="线材";
|
|
|
+ if(model.getLine().equals("AT2007")) {
|
|
|
+ productid="H型钢";
|
|
|
+ }
|
|
|
+ unit="008";
|
|
|
+ break;
|
|
|
+ case "FDC" :
|
|
|
+ sumWeight = model.getWeight().intValue();
|
|
|
+ productid="发电量";
|
|
|
+ unit="006";
|
|
|
+ break;
|
|
|
+ case "JCS" :
|
|
|
+ sumWeight = model.getWeight().intValue();
|
|
|
+ productid="白灰";
|
|
|
+ unit="008";
|
|
|
+ break;
|
|
|
+ case "JCW" :
|
|
|
+ sumWeight = model.getWeight().intValue();
|
|
|
+ productid="矿渣粉";
|
|
|
+ unit="008";
|
|
|
+ workProcid = model.getProductid();
|
|
|
+ break;
|
|
|
+ case "JJZ" :
|
|
|
+ sumWeight = model.getWeight1().intValue() + model.getWeight2().intValue();
|
|
|
+ productid="焦炭";
|
|
|
+ unit="008";
|
|
|
+ workProcid = "AT1007";
|
|
|
+ break;
|
|
|
+ case "JJF" :
|
|
|
+ sumWeight = model.getWeight().intValue();
|
|
|
+ productid="焦油";
|
|
|
+ if(model.getLine().equals("AT3009")){
|
|
|
+ productid="粗苯";
|
|
|
+ }
|
|
|
+ if(model.getLine().equals("AT3010")){
|
|
|
+ productid="硫铵";
|
|
|
+ }
|
|
|
+ unit="008";
|
|
|
+ //workProcid = "AT1007";
|
|
|
+ break;
|
|
|
+ default: break;
|
|
|
+ }
|
|
|
+ int[] avgWeight = emsProdplanYearService.avgWeight(sumWeight,dayMax);
|
|
|
+ for (int k = 0;k < dayMax;k++) {
|
|
|
+ EmsProdplanMonth monModel = new EmsProdplanMonth();
|
|
|
+ c.setTime(model.getYearmonth());
|
|
|
+ c.add(Calendar.DATE, k);
|
|
|
+ monModel.setMay(c.getTime());
|
|
|
+ monModel.setUnit(unit);
|
|
|
+ monModel.setProductid(productid);
|
|
|
+ monModel.setWeightMonth(model.getWeight());
|
|
|
+ if (workProcid.equals("")) {
|
|
|
+ monModel.setWorkprocid(model.getLine());
|
|
|
+ } else {
|
|
|
+ monModel.setWorkprocid(workProcid);
|
|
|
+ monModel.setWeightMonth(BigDecimal.valueOf(sumWeight));
|
|
|
+ }
|
|
|
+ monModel.setWeightDay(BigDecimal.valueOf(avgWeight[k]));
|
|
|
+ monModel.setKxf_weight(BigDecimal.valueOf(avgWeight[k]));
|
|
|
+ monModel.setYxf_weight(BigDecimal.valueOf(0));
|
|
|
+ monModel.setJxdays("0");
|
|
|
+ monModel.setMemo("根据年计划,系统自动生成。");
|
|
|
+ monModel.setCreateman("系统");
|
|
|
+ monModel.setCreatetime(new Date());
|
|
|
+ monModel.setSqno(maxSqno.getSqno()+k);
|
|
|
+ Map monMap = new HashMap();
|
|
|
+ monMap.put("may",new SimpleDateFormat("yyyy-MM-dd").format(monModel.getMay()));
|
|
|
+ monMap.put("workprocid","'"+monModel.getWorkprocid()+"'");
|
|
|
+ monMap.put("productid",monModel.getProductid());
|
|
|
+ monMap.put("startTime",new SimpleDateFormat("yyyy-MM-dd").format(monModel.getMay()));
|
|
|
+ monMap.put("endTime",new SimpleDateFormat("yyyy-MM-dd").format(monModel.getMay()));
|
|
|
+ List<EmsProdplanMonth> monList = emsProdplanMonthMapper.selectByParameters(monMap);
|
|
|
+ if(monList.size()<=0){
|
|
|
+ EmsProdplanMonth emsProdplanMonth = emsProdplanMonthService.add(monModel);
|
|
|
+ } else {
|
|
|
+ if(model.getParentid().equals("LG") || model.getParentid().equals("JJZ")) {
|
|
|
+ monModel.setKxf_weight(monList.get(0).getKxf_weight().add(monModel.getKxf_weight()));
|
|
|
+ monModel.setWeightMonth(monList.get(0).getWeightMonth().add(monModel.getWeightMonth()));
|
|
|
+ monModel.setWeightDay(monList.get(0).getWeightDay().add(monModel.getWeightDay()));
|
|
|
+ monModel.setId(monList.get(0).getId());
|
|
|
+ emsProdplanMonthService.modify(monModel);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
return success();
|
|
|
}
|