|
@@ -1,6 +1,8 @@
|
|
|
package com.steerinfo.ems.emsprodplanround.controller;
|
|
|
|
|
|
import com.steerinfo.auth.utils.JwtUtil;
|
|
|
+import com.steerinfo.ems.emsgmpcjh.mapper.EmsGmPcJhMapper;
|
|
|
+import com.steerinfo.ems.emsgmpcjh.model.EmsGmPcJh;
|
|
|
import com.steerinfo.ems.emsprodplanmonth.mapper.EmsProdplanMonthMapper;
|
|
|
import com.steerinfo.ems.emsprodplanmonth.model.EmsProdplanMonth;
|
|
|
import com.steerinfo.ems.emsprodplanmonth.service.IEmsProdplanMonthService;
|
|
@@ -14,8 +16,10 @@ import com.steerinfo.ems.emsprodplanround.service.IEmsProdplanRoundService;
|
|
|
import io.swagger.annotations.ApiImplicitParam;
|
|
|
import io.swagger.annotations.ApiImplicitParams;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
+import lombok.val;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
|
|
+import org.apache.tools.ant.taskdefs.Get;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
@@ -44,7 +48,7 @@ public class EmsProdplanRoundController extends BaseRESTfulController {
|
|
|
@Autowired
|
|
|
IEmsProdplanRoundService emsProdplanRoundService;
|
|
|
@Autowired
|
|
|
- EmsProdplanMonthMapper emsProdplanMonthMapper;
|
|
|
+ EmsGmPcJhMapper emsGmPcJhMapper;
|
|
|
@Autowired
|
|
|
EmsProdplanRoundMapper emsProdplanRoundMapper;
|
|
|
@Autowired
|
|
@@ -76,35 +80,35 @@ public class EmsProdplanRoundController extends BaseRESTfulController {
|
|
|
@ApiOperation(value="创建", notes="根据EmsProdplanRound对象创建")
|
|
|
@ApiImplicitParam(name = "emsProdplanRound", value = "详细实体emsProdplanRound", required = true, dataType = "EmsProdplanRound")
|
|
|
@PostMapping(value = "/")
|
|
|
- public RESTfulResult add(@RequestBody EmsProdplanRound model){
|
|
|
+ public RESTfulResult add(@RequestBody EmsProdplanRound [] models){
|
|
|
String userId = JwtUtil.getUseridByToken();
|
|
|
- if(model.getWorkprocType() == null||model.getWorkprocType().equals("") || model.getMay() == null || model.getMay().equals("")){
|
|
|
- return failed(null,"工序或者时间为空");
|
|
|
- }
|
|
|
- HashMap<String,Object> map = new HashMap();
|
|
|
- String strDateFormat = "yyyy-MM";
|
|
|
- SimpleDateFormat sdf = new SimpleDateFormat(strDateFormat);
|
|
|
- map.put("workprocid",model.getWorkprocType());
|
|
|
- map.put("may",sdf.format(model.getMay()));
|
|
|
- EmsProdplanMonth emsProdplanMonth = emsProdplanMonthMapper.getBymayAndWorkprocid(map);
|
|
|
- if(emsProdplanMonth == null){
|
|
|
- return failed(null,"该工序无法找到"+sdf.format(model.getMay())+"月数据");
|
|
|
- }
|
|
|
- map.put("parentid",emsProdplanMonth.getId());
|
|
|
- EmsProdplanRound getbeyondWeight = emsProdplanRoundService.getbeyondWeight(map);
|
|
|
- model.setParentid(emsProdplanMonth.getId());
|
|
|
- model.setSqno(emsProdplanMonth.getSqno());
|
|
|
- model.setPlanWeight(model.getPlanWeight());
|
|
|
- model.setMsgFlag("I");
|
|
|
- model.setReadFlag("N");
|
|
|
- model.setPlanWeight(model.getPlanWeight());
|
|
|
- model.setState("0");
|
|
|
- model.setCreatetime(new Date());
|
|
|
- model.setCreateman(userId);
|
|
|
- model.setWorkprocType(map.get("workprocid").toString());
|
|
|
- EmsProdplanRound emsProdplanRound = emsProdplanRoundService.add(model);
|
|
|
- if(getbeyondWeight.getPlanWeight().compareTo(emsProdplanMonth.getWeightMonth()) == 1){
|
|
|
- return success(null,"新增成功,但是轮次计划重量已超出!!!");
|
|
|
+ String maxid = null;
|
|
|
+ for (EmsProdplanRound model : models) {
|
|
|
+ EmsGmPcJh emsGmPcJh = emsGmPcJhMapper.selectByPrimaryKey(model.getParentid());
|
|
|
+ if(emsGmPcJh.getState().equals("0")){
|
|
|
+ return failed("排产计划编号为"+emsGmPcJh.getId()+"做了取消下发操作,无法做新增操作");
|
|
|
+ }
|
|
|
+ if(model.getWorkprocType() == null || model.getWorkprocType().equals("")){
|
|
|
+ return failed(null,"工序或者时间为空");
|
|
|
+ }
|
|
|
+ if (model.getParentid().substring(0,1).equals("G")){
|
|
|
+ maxid = emsProdplanRoundService.getMaxidAsGm(model);
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ maxid = emsProdplanRoundService.getMaxidAsSC(model);
|
|
|
+ }
|
|
|
+ model.setId(maxid);
|
|
|
+ model.setPlanWeight(model.getPlanWeight());
|
|
|
+ model.setMsgFlag("I");
|
|
|
+ model.setReadFlag("N");
|
|
|
+ model.setState("0");
|
|
|
+ model.setCreatetime(new Date());
|
|
|
+ model.setCreateman(userId);
|
|
|
+ model.setWorkprocType(model.getWorkprocType());
|
|
|
+ emsProdplanRoundService.add(model);
|
|
|
+ emsGmPcJh.setState("2");
|
|
|
+ emsGmPcJh.setReceiveTime(new Date());
|
|
|
+ emsGmPcJhMapper.updateByPrimaryKeySelective(emsGmPcJh);
|
|
|
}
|
|
|
return success();
|
|
|
}
|
|
@@ -150,8 +154,8 @@ public class EmsProdplanRoundController extends BaseRESTfulController {
|
|
|
})
|
|
|
//@RequiresPermissions("emsprodplanround:update")
|
|
|
|
|
|
- @PutMapping(value = "/{id}", produces = "application/json;charset=UTF-8")
|
|
|
- public RESTfulResult update(@PathVariable String id, @RequestBody EmsProdplanRound[] models){
|
|
|
+ @PutMapping(value = "batchUpdate", produces = "application/json;charset=UTF-8")
|
|
|
+ public RESTfulResult update(@RequestBody EmsProdplanRound[] models){
|
|
|
String userId = JwtUtil.getUseridByToken();
|
|
|
for (int i = 0; i < models.length; i++) {
|
|
|
EmsProdplanRound model = models[i];
|
|
@@ -196,10 +200,10 @@ public class EmsProdplanRoundController extends BaseRESTfulController {
|
|
|
emsProdplanRoundMapper.updateByPrimaryKey(model);
|
|
|
}
|
|
|
EmsProdplanRound sumPlanWeight = emsProdplanRoundService.getSumPlanWeight(id);
|
|
|
- EmsProdplanMonth emsProdplanMonth = emsProdplanMonthMapper.selectByPrimaryKey(monthid);
|
|
|
- emsProdplanMonth.setKxf_weight(emsProdplanMonth.getWeightMonth().subtract(emsProdplanMonth.getYxf_weight().add(sumPlanWeight.getPlanWeight())));
|
|
|
- emsProdplanMonth.setYxf_weight(emsProdplanMonth.getYxf_weight().add(sumPlanWeight.getPlanWeight()));
|
|
|
- emsProdplanMonthMapper.updateByPrimaryKey(emsProdplanMonth);
|
|
|
+ EmsGmPcJh emsGmPcJh = emsGmPcJhMapper.selectByPrimaryKey(monthid);
|
|
|
+ emsGmPcJh.setKxfWeight(emsGmPcJh.getPlanWeight().subtract(emsGmPcJh.getYxfWeight().add(sumPlanWeight.getPlanWeight())));
|
|
|
+ emsGmPcJh.setYxfWeight(emsGmPcJh.getYxfWeight().add(sumPlanWeight.getPlanWeight()));
|
|
|
+ emsGmPcJhMapper.updateByPrimaryKey(emsGmPcJh);
|
|
|
return success();
|
|
|
}
|
|
|
@ApiOperation(value="取消下发", notes="根据models修改对象")
|
|
@@ -226,11 +230,11 @@ public class EmsProdplanRoundController extends BaseRESTfulController {
|
|
|
emsProdplanRoundMapper.updateByPrimaryKey(model);
|
|
|
}
|
|
|
EmsProdplanRound sumPlanWeight = emsProdplanRoundService.getSumPlanWeight(id);
|
|
|
- EmsProdplanMonth emsProdplanMonth = emsProdplanMonthMapper.selectByPrimaryKey(monthid);
|
|
|
+ EmsGmPcJh emsGmPcJh = emsGmPcJhMapper.selectByPrimaryKey(monthid);
|
|
|
// 取消下发操作
|
|
|
- emsProdplanMonth.setKxf_weight(emsProdplanMonth.getKxf_weight().add(sumPlanWeight.getPlanWeight()));
|
|
|
- emsProdplanMonth.setYxf_weight(emsProdplanMonth.getYxf_weight().subtract(sumPlanWeight.getPlanWeight()));
|
|
|
- emsProdplanMonthMapper.updateByPrimaryKey(emsProdplanMonth);
|
|
|
+ emsGmPcJh.setKxfWeight(emsGmPcJh.getKxfWeight().add(sumPlanWeight.getPlanWeight()));
|
|
|
+ emsGmPcJh.setYxfWeight(emsGmPcJh.getYxfWeight().subtract(sumPlanWeight.getPlanWeight()));
|
|
|
+ emsGmPcJhMapper.updateByPrimaryKey(emsGmPcJh);
|
|
|
return success();
|
|
|
}
|
|
|
|
|
@@ -240,14 +244,54 @@ public class EmsProdplanRoundController extends BaseRESTfulController {
|
|
|
public RESTfulResult delete(@RequestBody EmsProdplanRound [] models){
|
|
|
for (int i = 0; i < models.length; i++) {
|
|
|
EmsProdplanRound model = models[i];
|
|
|
- if(model.getState().equals("1") || model.getState().equals("2")){
|
|
|
- return failed(null,"数据已下发或者被接收,无法删除");
|
|
|
+ if (model.getState().equals("1") || model.getState().equals("2")) {
|
|
|
+ return failed(null, "数据已下发或者被接收,无法删除");
|
|
|
}
|
|
|
emsProdplanRoundMapper.deleteByPrimaryKey(model.getId());
|
|
|
+ deleteNbjh(model);
|
|
|
}
|
|
|
return success();
|
|
|
}
|
|
|
|
|
|
+ @ApiOperation(value="获取详细信息", notes="根据url获取长度*宽度")
|
|
|
+ @GetMapping(value = "getlengthTimesWidth")
|
|
|
+ public RESTfulResult getlengthTimesWidth(){
|
|
|
+ List<EmsProdplanRound> emsProdplanRounds = emsProdplanRoundService.getlengthTimesWidth();
|
|
|
+ return success(emsProdplanRounds);
|
|
|
+ }
|
|
|
|
|
|
+ @ApiOperation(value="获取详细信息", notes="根据url获取断面")
|
|
|
+ @GetMapping(value = "getiateralArea")
|
|
|
+ public RESTfulResult getiateralArea(){
|
|
|
+ List<EmsProdplanRound> emsProdplanRounds = emsProdplanRoundService.getiateralArea();
|
|
|
+ return success(emsProdplanRounds);
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value="获取详细信息", notes="根据url获取截取面积")
|
|
|
+ @GetMapping(value = "getdimension")
|
|
|
+ public RESTfulResult getdimension(){
|
|
|
+ List<EmsProdplanRound> emsProdplanRounds = emsProdplanRoundService.getdimension();
|
|
|
+ return success(emsProdplanRounds);
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value="获取详细信息", notes="根据url获取断面")
|
|
|
+ @GetMapping(value = "getsurfaceStandard")
|
|
|
+ public RESTfulResult getsurfaceStandard(){
|
|
|
+ List<EmsProdplanRound> emsProdplanRounds = emsProdplanRoundService.getsurfaceStandard();
|
|
|
+ return success(emsProdplanRounds);
|
|
|
+ }
|
|
|
|
|
|
+ //如果是内部计划 则判断有没有轮次计划 做删除操作
|
|
|
+ public void deleteNbjh(EmsProdplanRound emsProdplanRound) {
|
|
|
+ if (emsProdplanRound.getId().substring(0,1).equals("N")) {
|
|
|
+ if (emsProdplanRound.getParentid() != null || !emsProdplanRound.getParentid().equals("")) {
|
|
|
+ Map<String,Object> map = new HashMap();
|
|
|
+ map.put("parentid",emsProdplanRound.getParentid());
|
|
|
+ List list = emsProdplanRoundMapper.selectByParameters(map);
|
|
|
+ if (list.size()<1) {
|
|
|
+ emsGmPcJhMapper.deleteByPrimaryKey(emsProdplanRound.getParentid());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|