parent
0f67cd5804
commit
c8eacf4703
@ -0,0 +1,74 @@
|
||||
package com.dsic.gj_erp.controller.jhgk;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.dsic.gj_erp.bean.ResultBean;
|
||||
import com.dsic.gj_erp.pc.Manager;
|
||||
import com.dsic.gj_erp.pc.service.三月滚动接口;
|
||||
import com.dsic.gj_erp.pc.排产;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.concurrent.Semaphore;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("sygdpc")
|
||||
@AllArgsConstructor
|
||||
public class 三月滚动排产控制器 {
|
||||
|
||||
private final 三月滚动接口 _三月滚动接口;
|
||||
|
||||
private static Semaphore semaphore = new Semaphore(1);
|
||||
|
||||
@GetMapping("createSygdjh")
|
||||
public ResultBean<?> 生成三月滚动(String from, String to){
|
||||
try {
|
||||
semaphore.acquire();
|
||||
return _三月滚动接口.生成三月滚动(from,to);
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
} finally {
|
||||
semaphore.release();
|
||||
}
|
||||
}
|
||||
|
||||
@GetMapping("pc")
|
||||
public ResultBean<?> pc(String from, String to){
|
||||
try {
|
||||
semaphore.acquire();
|
||||
排产.execute(from,to);
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
} finally {
|
||||
semaphore.release();
|
||||
}
|
||||
return new ResultBean<>();
|
||||
}
|
||||
|
||||
@GetMapping("sygdjh")
|
||||
public ResultBean<?> 获取三月滚动计划(String from, String to) throws InterruptedException {
|
||||
semaphore.acquire();
|
||||
if (!StrUtil.isAllNotEmpty(from,to)){
|
||||
semaphore.release();
|
||||
return new ResultBean<>();
|
||||
}
|
||||
|
||||
HashMap<Object, Object> map = new HashMap<>();
|
||||
if (from.equals(Manager.from)&&to.equals(Manager.to)){
|
||||
semaphore.release();
|
||||
map.put("zy",Manager.资源池);
|
||||
return new ResultBean<>(map);
|
||||
}
|
||||
|
||||
try {
|
||||
排产.execute(from,to);
|
||||
}finally {
|
||||
semaphore.release();
|
||||
}
|
||||
map.put("zy",Manager.资源池);
|
||||
return new ResultBean<>(map);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,82 @@
|
||||
package com.dsic.gj_erp.pc.service;
|
||||
|
||||
import cn.hutool.core.util.ObjUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.dsic.gj_erp.bean.ResultBean;
|
||||
import com.dsic.gj_erp.bean.jhgk.DmSygd;
|
||||
import com.dsic.gj_erp.bean.jhgk.DmSygdMx;
|
||||
import com.dsic.gj_erp.bean.jhgk.DmSygdMxLj;
|
||||
import com.dsic.gj_erp.bean.jhgk.DmYdjhxf;
|
||||
import com.dsic.gj_erp.mapper.jhgk.DmSygdxqMapper;
|
||||
import com.dsic.gj_erp.pc.Manager;
|
||||
import com.dsic.gj_erp.service.jhgk.DmSygdMxService;
|
||||
import com.dsic.gj_erp.service.jhgk.DmSygdService;
|
||||
import com.dsic.gj_erp.service.jhgk.impl.DmSygdMxLjServiceImpl;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
@AllArgsConstructor
|
||||
public class 三月滚动接口 {
|
||||
|
||||
private final DmSygdxqMapper sygdxqMapper;
|
||||
private final DmSygdMxLjServiceImpl ljService;
|
||||
private final DmSygdMxService sygdMxService;
|
||||
private final DmSygdService sygdService;
|
||||
|
||||
|
||||
|
||||
@Transactional
|
||||
public ResultBean 生成三月滚动(String begin, String end) {
|
||||
//清理历史数据
|
||||
ljService.remove(new QueryWrapper<DmSygdMxLj>().between("xzglxq", begin, end));
|
||||
sygdMxService.remove(new QueryWrapper<DmSygdMx>().between("jssj", begin, end));
|
||||
sygdService.remove(new QueryWrapper<DmSygd>().between("sl_sj", begin, end));
|
||||
|
||||
//开始汇总
|
||||
List<DmSygdMxLj> ljList = sygdxqMapper.getSygdLjMx(begin,end);
|
||||
|
||||
if (ljList.size() < 1) {
|
||||
return new ResultBean(false, 1, "请先导入" + begin + " ~ " + end + "分段钢料需求!");
|
||||
}
|
||||
|
||||
//2.根据
|
||||
List<DmSygdMx> mxList = ljList.stream().map(DmSygdMx::ofWithDmSygdMxlj).collect(Collectors.toList());
|
||||
|
||||
Map<String, List<DmSygdMx>> collect = mxList.stream().collect(Collectors.groupingBy(item -> item.getDcCh() + item.getDcPl() + item.getTzbh()));
|
||||
|
||||
Manager.资源池.values().forEach(_资源->{
|
||||
_资源.get工序产能MAP().values().forEach(_工序产能->{
|
||||
_工序产能.get设备().values().forEach(_设备->{
|
||||
_设备.get资源占用图表().parallelStream().forEach(_bom->{
|
||||
List<DmSygdMx> dmSygdMxes = collect.get(_bom.getDcch() + _bom.getPl() + _bom.getTzbh());
|
||||
for (DmSygdMx mx:dmSygdMxes){
|
||||
mx.更新排产信息(_工序产能.get工序(),_资源.getDate());
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
sygdMxService.saveBatch(mxList,500);
|
||||
|
||||
ljList.forEach(lj-> mxList.forEach(mx->{
|
||||
if (lj.getDcch().equals(mx.getDcCh())
|
||||
&&lj.getPl().equals(mx.getDcPl())
|
||||
&& (StrUtil.isBlank(lj.getTzbh())||lj.getTzbh().equals(mx.getTzbh()))){
|
||||
lj.setParentId(mx.getId());
|
||||
}
|
||||
}));
|
||||
ljService.saveBatch(ljList,500);
|
||||
|
||||
List<DmYdjhxf> list= sygdMxService.tqSygd1(begin,end);
|
||||
ResultBean r = new ResultBean(list);
|
||||
return r;
|
||||
}
|
||||
}
|
Loading…
Reference in new issue