1.临时提交

master
董哲奇 2 years ago
parent 79a4be237e
commit 40e232d48f

@ -1,14 +1,13 @@
package com.dsic.gj_erp.controller.jhgk;
import cn.hutool.core.date.DateUtil;
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.*;
import com.dsic.gj_erp.pc.service.三月滚动接口;
import com.dsic.gj_erp.pc.service.工序CD接口;
import com.dsic.gj_erp.pc.service.订货计划滚动信息接口;
import com.dsic.gj_erp.pc.service.设备产能接口;
import com.dsic.gj_erp.pc.工序CD;
import com.dsic.gj_erp.pc.排产;
import com.dsic.gj_erp.pc.设备产能;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;
@ -23,6 +22,7 @@ public class 三月滚动排产控制器 {
private final 三月滚动接口 _三月滚动接口;
private final 设备产能接口 _设备产能接口;
private final 工序CD接口 _工序CD接口;
private final 订货计划滚动信息接口 _订货计划滚动信息接口;
private static Semaphore semaphore = new Semaphore(1);
@ -82,6 +82,18 @@ public class 三月滚动排产控制器 {
return new ResultBean<>(map);
}
@GetMapping("getDhjhAll")
public ResultBean<?> 获取全部订货计划(){
Object o = _订货计划滚动信息接口.get();
return new ResultBean<>(o);
}
@PostMapping("saveDhjh")
public ResultBean<?> 设置订货计划(@RequestBody 订货计划 _订货计划){
_订货计划滚动信息接口.save(_订货计划);
return new ResultBean<>();
}
@GetMapping("getCdAll")
public ResultBean<?> 获取全部工序CD(){
Object o = _工序CD接口.get();

@ -12,6 +12,8 @@ import com.dsic.gj_erp.bean.jcsj.EmGcrl;
import com.dsic.gj_erp.bean.jcsj.EmSbcnp;
import com.dsic.gj_erp.bean.jcsj.EmSbjbb;
import com.dsic.gj_erp.bean.jhgk.DmSygdxq;
import com.dsic.gj_erp.bean.jhgk.DmZrcjh;
import com.dsic.gj_erp.bean.pgd.PgdSljh;
import com.dsic.gj_erp.pc.dto.data.Bom;
import com.dsic.gj_erp.pc.dto.data.钢料需求;
import com.dsic.gj_erp.pc.dto.gx.*;
@ -20,11 +22,14 @@ import com.dsic.gj_erp.pc.dto.tlt.*;
import com.dsic.gj_erp.pc.dto.排产结果;
import com.dsic.gj_erp.pc.dto.*;
import com.dsic.gj_erp.pc.service.工序CD接口;
import com.dsic.gj_erp.pc.service.订货计划滚动信息接口;
import com.dsic.gj_erp.pc.service.设备产能接口;
import com.dsic.gj_erp.service.jcsj.EmGcrlService;
import com.dsic.gj_erp.service.jcsj.EmSbcnpService;
import com.dsic.gj_erp.service.jcsj.EmSbjbbService;
import com.dsic.gj_erp.service.jhgk.DmSygdxqService;
import com.dsic.gj_erp.service.jhgk.DmZrcjhService;
import com.dsic.gj_erp.service.pgd.PgdSljhService;
import com.google.common.collect.ImmutableMap;
import lombok.extern.slf4j.Slf4j;
@ -43,6 +48,8 @@ import static com.dsic.gj_erp.pc.Manager.*;
public class DataFactory {
public static void 排产2() {
装载中日程数据();
套料图所占工序的资源.clear();
Manager.排产结果=new ArrayList<>();
List<钢料需求> list=读取钢料需求();
@ -54,28 +61,29 @@ public class DataFactory {
list.forEach(钢料需求 -> {
CountDownLatch latch = new CountDownLatch(钢料需求.getBomList().size());
String xzglxq = 钢料需求.getXzglxq();
String dzglxq = 钢料需求.getDzglxq();
钢料需求.getBomList().forEach(bom -> {
套料图工序 _套料图工序 = 套料图工序工厂(bom);
_套料图工序.set工序CD(工序CDMap);
AtomicBoolean atomicBoolean = new AtomicBoolean(false);
if (_套料图工序!=null){
_套料图工序.set需求日期(钢料需求.getXzglxq());
es.execute(() -> {
try{
_套料图工序.run(atomicBoolean);
}finally {
latch.countDown();
}
});
}else {
//套料图未定义/定义错误
if (_套料图工序==null){
latch.countDown();
return;
}
// if(atomicBoolean.get()){
// String errText = StrUtil.format("船号:{},批量:{},图号:{},需求日期:{},不满足上料需求",
// bom.getDcch(), bom.getPl(), bom.getTzbh(), bom.getXzglxq());
// 清理冗余数据(list);
// throw new RuntimeException(errText);
// }
_套料图工序.setXzglxq(xzglxq);
_套料图工序.setDzglxq(dzglxq);
_套料图工序.set工序CD(工序CDMap);
_套料图工序.set中日程(获取中日程(bom.getDcch() + bom.getPl() + bom.getFd()));
es.execute(() -> {
try{
_套料图工序.run();
}finally {
latch.countDown();
}
});
});
try {
latch.await(10, TimeUnit.SECONDS);// 指定超时时间
@ -83,13 +91,33 @@ public class DataFactory {
throw new RuntimeException(e);
}
});
清理冗余数据(list);
if (Manager.排产结果.size()>0){
log.info("排产异常--{}个未完整排产,{}",Manager.排产结果.size(),Manager.排产结果);
}
}
public static List<PgdSljh> 获取完工的上料计划(Bom bom){
return getBean(PgdSljhService.class).已排产上料计划装载(bom.getDcch(),bom.getPl(),bom.getFd(),bom.getTzbh());
}
public static Map<String,List<订货计划>> 获取订货计划(){
List<订货计划> _订货计划 = getBean(订货计划滚动信息接口.class).get();
Map<String,List<订货计划>> map= _订货计划.stream().collect(Collectors.groupingBy(订货计划::getDcch));
return map;
}
private static DmZrcjh 获取中日程(String key){
return getBean(DmZrcjhService.class).排产获取中日程数据(key);
}
private static void 装载中日程数据(){
getBean(DmZrcjhService.class).排产中日程数据加载();
}
private static void 清理冗余数据(List<钢料需求> list){
list.forEach(钢料需求->{
钢料需求.getBomList().forEach(bom -> {
if (bom.get所在设备()!=null){
@ -177,7 +205,7 @@ public class DataFactory {
资源 tmp资源 = 提取资源(DateUtil.endOfMonth(DateUtil.parse(钢料需求.getXzglxq(), "yyyy/MM/dd")));
工序产能 _工序产能 = tmp资源.get工序产能MAP().get(gx);
Optional<设备> _设备 = _工序产能.get设备().values().stream().findAny();
bom.set所在设备(_设备.get());
bom.set所在设备(_设备.orElse(null));
bom.set所在资源(tmp资源);
_工序产能.占用资源(bom.getTzbh(), 0);
套料图所占工序的资源.put(bom.getTzbh(), tmp资源);

@ -17,7 +17,9 @@ import java.util.Map;
@Setter
public class Bom {
private String dcch;
private String mbch;
private String pl;
private String _pl;//曲外板pl需要增加Q,这里
private String fd;
private String xzglxq;
@ -33,6 +35,7 @@ public class Bom {
private 设备 所在设备;
private 资源 所在资源;
private List<Constant.工序> 已排工序;
private List<ErrorType> errors;
public static Bom of(String xzxq, String dzxq, DmBom bom){
Bom _bom = new Bom();
@ -40,10 +43,35 @@ public class Bom {
_bom.xzglxq=xzxq;
_bom.dzglxq=dzxq;
_bom.已排工序 =new ArrayList<>();
_bom.errors=new ArrayList<>();
return _bom;
}
public String toString() {
return JSONObject.toJSONString(this);
}
public void 坡口结束日期不满足大组需求期(){
this.errors.add(ErrorType.坡口结束日期不满足大组需求期);
}
public void 没有订货(){
this.errors.add(ErrorType.没有订货);
}
public void 订货计划到齐日期格式错误(){
this.errors.add(ErrorType.订货计划到齐日期格式错误);
}
public void 上料之前无法到货(){
this.errors.add(ErrorType.上料之前无法到货);
this.errors.add(ErrorType.需求日期按照中日程计算);
}
private enum ErrorType{
坡口结束日期不满足大组需求期,
没有订货,
订货计划到齐日期格式错误,
上料之前无法到货,
需求日期按照中日程计算
}
}

@ -0,0 +1,5 @@
package com.dsic.gj_erp.pc.dto.tlt;
public enum ZlType {
小组,大组,焊接机器人肘板
}

@ -11,6 +11,7 @@ public class 一跨平直大板 extends 套料图工序 {
this.kw = "7";
this.zl = "1010";
this.bom = bom;
this.zlType=ZlType.小组;
this.工序 = ImmutableList.<Constant.工序>builder()
.add(Constant.工序.上料)
.add(Constant.工序.抛丸)
@ -25,6 +26,7 @@ public class 一跨平直大板 extends 套料图工序 {
this.kw = "7";
this.zl = "1110";
this.bom = bom;
this.zlType=ZlType.大组;
this.工序 = ImmutableList.<Constant.工序>builder()
.add(Constant.工序.上料)
.add(Constant.工序.抛丸)

@ -15,6 +15,7 @@ public class 一跨进线板 extends 套料图工序 {
this.kw = "8";
this.zl = "1110";
this.bom = bom;
this.zlType=ZlType.大组;
this.工序 = ImmutableList.<Constant.工序>builder()
.add(Constant.工序.上料)
.add(Constant.工序.抛丸)

@ -11,6 +11,7 @@ public class 七跨型板 extends 套料图工序 {
this.kw = "16";
this.zl = "1010";
this.bom = bom;
this.zlType=ZlType.小组;
this.工序 = ImmutableList.<Constant.工序>builder()
.add(Constant.工序.上料)
.add(Constant.工序.抛丸)
@ -28,6 +29,7 @@ public class 七跨型板 extends 套料图工序 {
this.kw = "16";
this.zl = "1110";
this.bom = bom;
this.zlType=ZlType.大组;
this.工序 = ImmutableList.<Constant.工序>builder()
.add(Constant.工序.上料)
.add(Constant.工序.抛丸)

@ -11,6 +11,7 @@ public class 三跨厚板 extends 套料图工序 {
this.kw = "14";
this.zl = "1010";
this.bom = bom;
this.zlType=ZlType.小组;
this.工序 = ImmutableList.<Constant.工序>builder()
.add(Constant.工序.上料)
.add(Constant.工序.抛丸)
@ -25,6 +26,7 @@ public class 三跨厚板 extends 套料图工序 {
this.kw = "14";
this.zl = "1110";
this.bom = bom;
this.zlType=ZlType.大组;
this.工序 = ImmutableList.<Constant.工序>builder()
.add(Constant.工序.上料)
.add(Constant.工序.抛丸)

@ -11,6 +11,7 @@ public class 三跨平铁 extends 套料图工序 {
this.kw = "6";
this.zl = "1010";
this.bom = bom;
this.zlType=ZlType.小组;
this.工序 = ImmutableList.<Constant.工序>builder()
.add(Constant.工序.上料)
.add(Constant.工序.抛丸)
@ -28,6 +29,7 @@ public class 三跨平铁 extends 套料图工序 {
this.kw = "6";
this.zl = "1110";
this.bom = bom;
this.zlType=ZlType.大组;
this.工序 = ImmutableList.<Constant.工序>builder()
.add(Constant.工序.上料)
.add(Constant.工序.抛丸)
@ -45,6 +47,7 @@ public class 三跨平铁 extends 套料图工序 {
this.kw = "6";
this.zl = "4230";
this.bom = bom;
this.zlType=ZlType.焊接机器人肘板;
this.工序 = ImmutableList.<Constant.工序>builder()
.add(Constant.工序.上料)
.add(Constant.工序.抛丸)

@ -11,6 +11,7 @@ public class 三跨曲板 extends 套料图工序 {
this.kw = "13";
this.zl = "1010";
this.bom = bom;
this.zlType=ZlType.小组;
this.设置工序();
return this;
}
@ -19,6 +20,7 @@ public class 三跨曲板 extends 套料图工序 {
this.kw = "13";
this.zl = "1110";
this.bom = bom;
this.zlType=ZlType.大组;
this.设置工序();
return this;
}

@ -11,6 +11,7 @@ public class 二跨T型材腹板 extends 套料图工序 {
this.kw = "11";
this.zl = "1010";
this.bom = bom;
this.zlType=ZlType.小组;
this.设置工序();
return this;
}
@ -19,6 +20,7 @@ public class 二跨T型材腹板 extends 套料图工序 {
this.kw = "11";
this.zl = "1110";
this.bom = bom;
this.zlType=ZlType.大组;
this.设置工序();
return this;
}

@ -11,6 +11,7 @@ public class 二跨T型材面板 extends 套料图工序 {
this.kw = "5";
this.zl = "1010";
this.bom = bom;
this.zlType=ZlType.小组;
this.设置工序();
return this;
}
@ -19,6 +20,7 @@ public class 二跨T型材面板 extends 套料图工序 {
this.kw = "5";
this.zl = "1110";
this.bom = bom;
this.zlType=ZlType.大组;
this.设置工序();
return this;
}

@ -11,6 +11,7 @@ public class 二跨激光切割板 extends 套料图工序 {
this.kw = "12";
this.zl = "1010";
this.bom = bom;
this.zlType=ZlType.小组;
this.工序 = ImmutableList.<Constant.工序>builder()
.add(Constant.工序.上料)
.add(Constant.工序.抛丸)
@ -25,6 +26,7 @@ public class 二跨激光切割板 extends 套料图工序 {
this.kw = "12";
this.zl = "1110";
this.bom = bom;
this.zlType=ZlType.大组;
this.工序 = ImmutableList.<Constant.工序>builder()
.add(Constant.工序.上料)
.add(Constant.工序.抛丸)

@ -11,6 +11,7 @@ public class 二跨超长超宽曲板 extends 套料图工序 {
this.kw = "10";
this.zl = "1010";
this.bom = bom;
this.zlType=ZlType.小组;
this.工序 = ImmutableList.<Constant.工序>builder()
.add(Constant.工序.上料)
.add(Constant.工序.抛丸)
@ -27,6 +28,7 @@ public class 二跨超长超宽曲板 extends 套料图工序 {
_二跨超长超宽曲板.kw = "10";
_二跨超长超宽曲板.zl = "1110";
_二跨超长超宽曲板.bom = bom;
_二跨超长超宽曲板.zlType=ZlType.大组;
_二跨超长超宽曲板.工序 = ImmutableList.<Constant.工序>builder()
.add(Constant.工序.上料)
.add(Constant.工序.抛丸)

@ -11,6 +11,7 @@ public class 二跨超长超宽板 extends 套料图工序 {
this.kw = "9";
this.zl = "1010";
this.bom = bom;
this.zlType=ZlType.小组;
this.设置工序();
return this;
}
@ -19,6 +20,7 @@ public class 二跨超长超宽板 extends 套料图工序 {
this.kw = "9";
this.zl = "1110";
this.bom = bom;
this.zlType=ZlType.大组;
this.设置工序();
return this;
}

@ -11,6 +11,7 @@ public class 光电 extends 套料图工序 {
this.kw = "17";
this.zl = "1120";
this.bom = bom;
this.zlType=ZlType.小组;
this.工序 = ImmutableList.<Constant.工序>builder()
.add(Constant.工序.上料)
.add(Constant.工序.抛丸)

@ -11,6 +11,7 @@ public class 四跨普通板 extends 套料图工序 {
this.kw = "15";
this.zl = "1010";
this.bom = bom;
this.zlType= ZlType.小组;
this.设置工序();
return this;
}
@ -19,6 +20,7 @@ public class 四跨普通板 extends 套料图工序 {
this.kw = "15";
this.zl = "1110";
this.bom = bom;
this.zlType=ZlType.大组;
this.设置工序();
return this;
}
@ -27,6 +29,7 @@ public class 四跨普通板 extends 套料图工序 {
this.kw = "15";
this.zl = "4230";
this.bom = bom;
this.zlType=ZlType.大组;
this.设置工序();
return this;
}

@ -4,57 +4,109 @@ import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.ObjUtil;
import cn.hutool.core.util.StrUtil;
import com.dsic.gj_erp.pc.Constant;
import com.dsic.gj_erp.pc.Manager;
import com.dsic.gj_erp.bean.jhgk.DmZrcjh;
import com.dsic.gj_erp.pc.*;
import com.dsic.gj_erp.pc.dto.data.Bom;
import com.dsic.gj_erp.pc.dto.data.钢料需求;
import com.dsic.gj_erp.pc.dto.tlt.ZlType;
import com.dsic.gj_erp.pc.service.套料图工序接口;
import com.dsic.gj_erp.pc.工序CD;
import lombok.Getter;
import lombok.Setter;
import lombok.extern.slf4j.Slf4j;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.concurrent.atomic.AtomicBoolean;
//import static com.dsic.gj_erp.pc.Constant.工序CD;
import static com.dsic.gj_erp.pc.DataFactory.提取资源;
import static com.dsic.gj_erp.pc.DataFactory.搜索可用资源;
import static com.dsic.gj_erp.pc.Manager.from;
@Getter
@Setter
@Slf4j
public abstract class 套料图工序 implements 套料图工序接口 {
protected String kw;
protected String zl;
protected ZlType zlType;
protected String xzglxq;
protected String dzglxq;
protected 钢料需求 _钢料需求;
protected Bom bom;
protected String 需求日期;
protected Date _需求日期;
protected DateTime _需求日期;
protected DmZrcjh 中日程;
protected List<Constant.工序> 工序;
protected Map<Constant.工序,工序CD> 工序CD;
protected AtomicBoolean fail;
protected List<订货计划> 订货计划s;
public void run(){
fail=new AtomicBoolean(false);
基础设置();
this.run(fail);
}
protected void 基础设置(){
if (this.zlType==ZlType.小组){
this.set需求日期(this.xzglxq);
}
if (this.zlType==ZlType.大组){
this.set需求日期(this.dzglxq);
}
if (this.zlType==ZlType.大组&&this.工序.contains(Constant.工序.曲型)){
//大组需求有曲外板,需要按照大组需求期计算
this.set需求日期(dzglxq);
//曲外板批量名称设置
this.bom.set_pl(this.bom.getPl()+"Q");
}
//当大组需求期无法满足小组需求时,以小组需求期为准
if (StrUtil.isAllNotEmpty(xzglxq,dzglxq)){
if (DateUtil.parse(xzglxq,"yyyy/MM/dd").isAfter(DateUtil.parse(dzglxq,"yyyy/MM/dd"))){
this.set需求日期(dzglxq);
}
}
public void run(AtomicBoolean atomicBoolean) {
if (ObjUtil.isEmpty(this.bom)||StrUtil.isEmpty(this.bom.getTzbh())){
return;
}
this._需求日期 = DateUtil.parse(this.需求日期, "yyyy/MM/dd");
double 需求数量 = 1;
Map<String,List<订货计划>> _订货计划=DataFactory.获取订货计划();
this.订货计划s = _订货计划.get(bom.getDcch());
}
public void run(AtomicBoolean atomicBoolean) {
if (!this.是否订货()){
bom.没有订货();
}
double 需求数量 = 1;//默认数量为1,切割处理时候按照实际切割长度计算,切割产能在设备产能中单独计算
this.工序.forEach(_工序 -> {
if (!this.占用资源(_工序,需求数量)){
//可用资源最大前推日期设置为N天,最大前推日期意味从上料开始最小施工周期
//fixme 这里应该安装工序设置,暂时写死一个日期
Optional<资源> 可用资源 = 搜索可用资源(_工序, DateUtil.parse(from, "yyyy/MM/dd"), DateUtil.offsetDay(this._需求日期,0), 需求数量);
可用资源.ifPresent(_资源 -> {
if (_资源.占用资源(_工序,this.bom,需求数量)){
this.bom.set所在资源(_资源);
this.bom.get已排工序().add(0,_工序);
资源 _资源 = this.占用资源2(_工序, 需求数量);
if (_工序==Constant.工序.上料&&!this.能否到货(_资源)){
this.bom.上料之前无法到货();
//使用中日程定义需求日期
this._需求日期=this.zlType==ZlType.小组?DateUtil.parse(this.中日程.getGjjsXz()):DateUtil.parse(this.中日程.getGjjsDz());
//再次计算上料日期
this.占用资源2(_工序, 需求数量);
}
//只有大组需求期时,坡口结束日期需满足大组结束日期
if (StrUtil.isEmpty(xzglxq)&&StrUtil.isNotEmpty(dzglxq)&&_工序==Constant.工序.坡口){
if (this.中日程!=null){
String 大组结束日期=this.中日程.getGjjsDz();
if (DateUtil.parse(大组结束日期).isBefore(DateUtil.parse(_资源.getDate()))){
this.bom.坡口结束日期不满足大组需求期();
atomicBoolean.set(true);
}
});
}
}
});
//排产失败相关记录
if (bom.get已排工序().size()!=this.工序.size()) {
Manager.排产结果.add(this.bom);
@ -62,6 +114,60 @@ public abstract class 套料图工序 implements 套料图工序接口 {
}
}
protected boolean 是否订货(){
AtomicBoolean 是否订货=new AtomicBoolean(false);
if (ObjUtil.isEmpty(订货计划s)){
return 是否订货.get();
}
if (ObjUtil.isNotEmpty(订货计划s)){
订货计划s.forEach(item->{
if (item.getPlList().contains(bom.getPl())){
是否订货.set(true);
}
});
}
return 是否订货.get();
}
protected boolean 能否到货(资源 _资源){
AtomicBoolean 能否到货=new AtomicBoolean(false);
if (ObjUtil.isNotEmpty(订货计划s)){
订货计划s.forEach(item->{
if (item.getPlList().contains(bom.getPl())){
DateTime arriveDate;
try {
arriveDate=DateUtil.parse(item.getAllArriveData(),"yyyy/MM/dd");
}catch (Exception e){
this.bom.订货计划到齐日期格式错误();
log.error("上料计划时间格式错误--月份:{},船号:{},批次范围:{},到齐日期:{}",item.getMonth(),item.getDcch(),item.getPls(),item.getAllArriveData());
return;
}
if (_资源.get_date().isAfter(arriveDate)){
能否到货.set(true);
}
}
});
}
return 能否到货.get();
}
protected 资源 占用资源2(Constant.工序 _工序,double 需求数量){
Integer cd = 工序CD.get(_工序).getCd();
DateTime dateTime = DateUtil.offsetDay(this._需求日期, cd);
资源 _资源 = 提取资源(dateTime);
try {
if (_资源.占用资源(_工序,this.bom,需求数量)){
this.bom.set所在资源(_资源);
this.bom.get已排工序().add(0,_工序);
}
}catch (Exception e){
e.printStackTrace();
}
return _资源;
}
protected boolean 占用资源(Constant.工序 _工序,double 需求数量){
Integer cd = 工序CD.get(_工序).getCd();
DateTime dateTime = DateUtil.offsetDay(this._需求日期, cd);
@ -100,4 +206,9 @@ public abstract class 套料图工序 implements 套料图工序接口 {
this._钢料需求=_钢料需求;
return this;
}
public boolean getSuccess(){
return this.fail.get();
}
}

@ -1,5 +1,7 @@
package com.dsic.gj_erp.pc.dto;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import com.dsic.gj_erp.pc.Constant;
import com.dsic.gj_erp.pc.dto.data.Bom;
import lombok.Getter;
@ -16,6 +18,7 @@ import static com.dsic.gj_erp.pc.Manager.套料图所占工序的资源;
@Setter
public class 资源 {
private String date;
private DateTime _date;
private Map<Constant.工序,工序产能> 工序产能MAP;
public void 占用资源(Constant.工序 工序,String 套料图号,double 产能消耗){
@ -32,21 +35,11 @@ public class 资源 {
AtomicBoolean atomicBoolean = new AtomicBoolean(false);
工序产能 工序产能 = 工序产能MAP.get(工序);
Optional.ofNullable(工序产能).ifPresent(it->{
if (it.判断是否可以占用(产能消耗)){
it.占用资源(产能消耗,bom);
设置套料图所在资源(bom.getTzbh());
atomicBoolean.set(true);
}
});
return atomicBoolean.get();
}
public void 强占资源(Constant.工序 工序,Bom bom,double 产能消耗){
工序产能 工序产能 = 工序产能MAP.get(工序);
Optional.of(工序产能).ifPresent(it->{
it.强占资源(产能消耗,bom);
it.占用资源(产能消耗,bom);
设置套料图所在资源(bom.getTzbh());
atomicBoolean.set(true);
});
return atomicBoolean.get();
}
private static Semaphore semaphore = new Semaphore(1);
@ -76,6 +69,7 @@ public class 资源 {
public static 资源 of(String date,Map<Constant.工序,工序产能> 工序产能MAP){
资源 资源 = new 资源();
资源.date=date;
资源._date= DateUtil.parse(date,"yyyy/MM/dd");
资源.工序产能MAP=工序产能MAP;
return 资源;
}

@ -0,0 +1,51 @@
package com.dsic.gj_erp.pc.service;
import com.dsic.gj_erp.pc.工序CD;
import com.dsic.gj_erp.pc.订货计划;
import lombok.AllArgsConstructor;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.CachePut;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Set;
@Service
@AllArgsConstructor
public class 订货计划滚动信息接口 {
private static final String KEY="dhjh";
private final RedisTemplate<String,Object> redisTemplate;
@CachePut(cacheNames = {KEY},key = "#plan.getKey()")
public Object save(订货计划 plan){
return plan;
}
@Cacheable(value = {KEY},key = "#id")
public Object get(String id){
return new HashMap<>();
}
@CacheEvict(value = {KEY}, key="#id")
public Object remove(String id){
return new HashMap<>();
}
public List<订货计划> get(){
Set<String> keys = redisTemplate.keys(KEY+"::*");
List<订货计划> list=new ArrayList<>();
if (keys==null){
return new ArrayList<>();
}
for (String key:keys){
订货计划 _订货计划= (订货计划) redisTemplate.opsForValue().get(key);
list.add(_订货计划);
}
return list;
}
}

@ -0,0 +1,49 @@
package com.dsic.gj_erp.pc;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.StrUtil;
import lombok.Getter;
import lombok.Setter;
import lombok.extern.slf4j.Slf4j;
import java.util.List;
@Getter
@Setter
@Slf4j
public class 订货计划 {
private String month;
private String index;
private String dcch;
private String pls;//批量范围
private List<String> plList;
private String tonnage;
private String sumWeight;
private String allArriveData;//到齐日期
public String getKey(){
return this.month+this.dcch+pls;
}
public synchronized List<String> getPlList(){
if (this.plList!=null){
return this.plList;
}
List<String> split = StrUtil.split(pls, "-");
String logMsg=StrUtil.format("订货计划--船号:{},批量范围格式错误:{}",dcch,pls);
if (split.size()!=2){
log.error(logMsg);
throw new RuntimeException(logMsg);
}
try {
int start=Integer.parseInt(split.get(0));
int end=Integer.parseInt(split.get(1));
for (int i=start;i<=end;i++){
this.plList.add(i+"");
}
return this.plList;
}catch (Exception e){
log.error(logMsg);
throw new RuntimeException(logMsg);
}
}
}

@ -28,4 +28,8 @@ public interface DmZrcjhService extends IService<DmZrcjh> {
void tj(List<DmZrcjh> dmZrcjhs);
void sh(List<DmZrcjh> dmZrcjhs);
void 排产中日程数据加载();
DmZrcjh 排产获取中日程数据(String key);
}

@ -7,6 +7,7 @@ import cn.hutool.core.util.ObjectUtil;
import cn.hutool.poi.excel.ExcelReader;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.dsic.gj_erp.bean.jhgk.*;
import com.dsic.gj_erp.mapper.jhgk.DmZrcjhMapper;
@ -16,6 +17,8 @@ import com.dsic.gj_erp.util.ExcelUtil;
import com.google.common.collect.Lists;
import org.apache.commons.lang3.StringUtils;
import org.modelmapper.ModelMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
@ -28,6 +31,9 @@ import java.util.Date;
import java.util.List;
import java.util.Map;
import static com.dsic.gj_erp.pc.Manager.from;
import static com.dsic.gj_erp.pc.Manager.to;
/**
* <p>
* 服务实现类
@ -46,6 +52,9 @@ public class DmZrcjhServiceImpl extends ServiceImpl<DmZrcjhMapper, DmZrcjh> impl
@Resource
DmZrcjhOldService oldService;
@Autowired
RedisTemplate<String,Object> redisTemplate;
@Override
public List<DmZrcjh> getList(JSONObject json) {
QueryWrapper<DmZrcjh> queryWrapper = new QueryWrapper<>();
@ -163,4 +172,20 @@ public class DmZrcjhServiceImpl extends ServiceImpl<DmZrcjhMapper, DmZrcjh> impl
});
updateBatchById(dmZrcjhs);
}
@Override
public void 排产中日程数据加载() {
redisTemplate.delete("ZRC");
List<DmZrcjh> list = list(Wrappers.<DmZrcjh>lambdaQuery().between(DmZrcjh::getGjks, from, to));
list.parallelStream().forEach(item->{
String key=item.getDcCh()+item.getDcPl()+item.getDcFd();
redisTemplate.opsForHash().put("ZRC",key,item);
});
}
@Override
public DmZrcjh 排产获取中日程数据(String key) {
return (DmZrcjh) redisTemplate.opsForHash().get("ZRC",key);
}
}

@ -23,5 +23,5 @@ public interface PgdSljhService extends IService<PgdSljh> {
void saveSljhFk(List<PgdSljh> sljhs, HttpServletRequest request);
void saveSljhPgdXdBack(List<PgdSljh> sljhs, HttpServletRequest request);
List<PgdSljh> 已排产上料计划装载(String ch,String pl,String fd,String tlth);
}

@ -1,12 +1,17 @@
package com.dsic.gj_erp.service.pgd.impl;
import cn.hutool.core.date.DateUtil;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.dsic.gj_erp.bean.jhgk.DmZrcjh;
import com.dsic.gj_erp.bean.pgd.PgdDh;
import com.dsic.gj_erp.bean.pgd.PgdSljh;
import com.dsic.gj_erp.bean.pgd.PgdTzjh;
import com.dsic.gj_erp.mapper.pgd.PgdSljhMapper;
import com.dsic.gj_erp.pc.Manager;
import com.dsic.gj_erp.service.pgd.PgdSljhService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.AllArgsConstructor;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@ -14,6 +19,9 @@ import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;
import java.util.List;
import static com.dsic.gj_erp.pc.Manager.from;
import static com.dsic.gj_erp.pc.Manager.to;
/**
* <p>
* 服务实现类
@ -23,7 +31,11 @@ import java.util.List;
* @since 2023-11-13
*/
@Service
@AllArgsConstructor
public class PgdSljhServiceImpl extends ServiceImpl<PgdSljhMapper, PgdSljh> implements PgdSljhService {
private final RedisTemplate<String,Object> redisTemplate;
@Transactional(rollbackFor = Exception.class)
@Override
public void saveSljhPgdXd(List<PgdSljh> sljhs, HttpServletRequest request) {
@ -88,4 +100,16 @@ public class PgdSljhServiceImpl extends ServiceImpl<PgdSljhMapper, PgdSljh> impl
});
this.updateBatchById(ups);
}
@Override
public List<PgdSljh> 已排产上料计划装载(String ch, String pl, String fd, String tlth) {
return list(Wrappers.<PgdSljh>lambdaQuery()
.eq(PgdSljh::getCzbh,ch)
.eq(PgdSljh::getPl,pl)
.eq(PgdSljh::getFd,fd)
.eq(PgdSljh::getTlth,tlth)
.isNotNull(PgdSljh::getFkrq)
);
}
}

@ -9,9 +9,11 @@
<result column="dc_fd" property="dcFd" jdbcType="VARCHAR" />
<result column="zdh" property="zdh" jdbcType="VARCHAR" />
<result column="xzglxq" property="xzglxq" jdbcType="VARCHAR" />
<result column="dzglxq" property="dzglxq" jdbcType="VARCHAR" />
<collection property="bomList" ofType="dmBom" javaType="java.util.ArrayList" columnPrefix="bom_" >
<id column="id" property="id" jdbcType="INTEGER" />
<result column="dcch" property="dcch" jdbcType="VARCHAR" />
<result column="mbch" property="mbch" jdbcType="VARCHAR" />
<result column="pl" property="pl" jdbcType="VARCHAR" />
<result column="fd" property="fd" jdbcType="VARCHAR" />
<result column="kw" property="kw" jdbcType="VARCHAR" />
@ -33,8 +35,10 @@
xq.dc_pl,
xq.dc_fd,
xq.xzglxq,
xq.daglxq,
bom.id as bom_id,
bom.dcch as bom_dcch,
bom.mbch as bom_mbch,
bom.pl as bom_pl,
bom.fd as bom_fd,
bom.kw as bom_kw,

Loading…
Cancel
Save