1.调整优化

2.增加作业计划反馈定位功能
master
董哲奇 8 months ago
parent 191be19076
commit 6228fa823b

@ -21,7 +21,10 @@ import com.dsic.gj_erp.service.kc.ImCkwpkwpService;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.sis.internal.jaxb.metadata.EX_Extent; import org.apache.sis.internal.jaxb.metadata.EX_Extent;
import org.mapstruct.factory.Mappers; import org.mapstruct.factory.Mappers;
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.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
@ -49,6 +52,7 @@ import java.util.stream.Stream;
@RequestMapping("/dmYdjh") @RequestMapping("/dmYdjh")
public class DmYdjhController { public class DmYdjhController {
private static final Logger log = LoggerFactory.getLogger(DmYdjhController.class);
@Autowired @Autowired
private DmYdjhService service; private DmYdjhService service;
@Autowired @Autowired
@ -57,6 +61,12 @@ public class DmYdjhController {
@Autowired @Autowired
private DmCzplpNewService czplpNewService; private DmCzplpNewService czplpNewService;
@PostMapping("save")
public ResultBean<?> save(@RequestBody List<DmYdjh> list){
service.updateBatchById(list);
return new ResultBean<>();
}
@RequestMapping("/getList") @RequestMapping("/getList")
@AuthFunction @AuthFunction
public ResultBean getList(@RequestBody Map<String, String> map ) { public ResultBean getList(@RequestBody Map<String, String> map ) {

@ -49,61 +49,6 @@ import static com.dsic.gj_erp.pc.Manager.*;
@Slf4j @Slf4j
public class DataFactory { public class DataFactory {
public static void 2() {
();
.clear();
Manager.=new ArrayList<>();
List<> list=();
CD _CD = getBean(CD.class);
List<CD> CDS = _CD.get();
Map<Constant.,CD> CDMap=new HashMap<>();
CDS.forEach(item->CDMap.put(item.getGx(),item));
(list,CDMap);
(list);
if (Manager..size()>0){
log.info("排产异常--{}个未完整排产,{}",Manager..size(),Manager.);
}
}
private static void (List<> list, Map<Constant., CD> CDMap){
list.forEach( -> {
CountDownLatch latch = new CountDownLatch(.getBomList().size());
String xzglxq = .getXzglxq();
String dzglxq = .getDzglxq();
.getBomList().forEach(bom -> {
_ = (bom);
//套料图未定义/定义错误
if (_==null){
latch.countDown();
return;
}
_.setXzglxq(xzglxq);
_.setDzglxq(dzglxq);
_.setCD(CDMap);
_.set((bom.getDcch() + bom.getPl() + bom.getFd()));
es.execute(() -> {
try{
_.run();
}finally {
latch.countDown();
}
});
});
try {
latch.await(10, TimeUnit.SECONDS);// 指定超时时间
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
});
}
private static DmZrcjh (String key){ private static DmZrcjh (String key){
return getBean(DmZrcjhService.class).(key); return getBean(DmZrcjhService.class).(key);
} }
@ -125,24 +70,6 @@ public class DataFactory {
}); });
} }
public static void 3(){
();
.clear();
Manager.=new ArrayList<>();
List<> list=();
Collection<> = (list);
();
try {
();
}catch (Exception e){
e.printStackTrace();
}finally {
(list);
}
}
public static void 4(){ public static void 4(){
(); ();
.clear(); .clear();
@ -207,9 +134,6 @@ public class DataFactory {
//记录6次计算的全部资源 //记录6次计算的全部资源
tmpList.add(_); tmpList.add(_);
if (_.()){ if (_.()){
if (item.getDcCh().equals("G175K-5")&&item.getDcPl().equals("003")){
System.out.println(111);
}
(item.getBomList(),item.get(),CDMap); (item.getBomList(),item.get(),CDMap);
break; break;
} }
@ -224,11 +148,7 @@ public class DataFactory {
//查找最小可用资源,进行占用 //查找最小可用资源,进行占用
tmpList.sort(Comparator.comparingDouble((tmp)->tmp.getMAP().get(Constant..).get())); tmpList.sort(Comparator.comparingDouble((tmp)->tmp.getMAP().get(Constant..).get()));
tmpList.stream().findFirst().ifPresent(tmp->{ tmpList.stream().findFirst().ifPresent(tmp->{
//由于资源日为切割日期,这里需要还原一下,修正传递的参照需求日期 DateTime offset = DateUtil.parse(tmp.getDate()).offset(DateField.DAY_OF_MONTH, -CDMap.get().getCd());
DateTime offset = tmp.get_date().offset(DateField.DAY_OF_MONTH, -CDMap.get().getCd());
if (item.getDcCh().equals("G175K-5")&&item.getDcPl().equals("003")){
System.out.println(offset.toDateStr());
}
(item.getBomList(),offset,CDMap); (item.getBomList(),offset,CDMap);
date.set(tmp.getDate()); date.set(tmp.getDate());
}); });
@ -242,91 +162,6 @@ public class DataFactory {
log.info("船号:{},批次:{},占用资源成功,切割日期:{}",item.getDcCh(),item.getDcPl(),date.get()); log.info("船号:{},批次:{},占用资源成功,切割日期:{}",item.getDcCh(),item.getDcPl(),date.get());
} }
public static void (Collection<> _){
CD _CD = getBean(CD.class);
List<CD> CDS = _CD.get();
Map<Constant.,CD> CDMap=new HashMap<>();
CDS.forEach(item->CDMap.put(item.getGx(),item));
for ( item:_){
if (ObjUtil.isNotEmpty(item.getBomList())){
(item,CDMap);
}
}
}
private static void ( item,Map<Constant.,CD> CDMap){
Constant. =Constant..;
//需求日期可利用范围是±3天
int times=-3;
List<> tmpList=new ArrayList<>();
AtomicDouble atomicDouble = item.get().get();
_=null;
do {
//因为第一次计算时候就是当前批量小组需求日期,所以再次循环到的时候不需要再次计算
if (times==0){
times+=1;
continue;
}
if (times>3){
break;
}
DateTime xzglxq = item.get().offset(DateField.DAY_OF_YEAR,CDMap.get().getCd());
if (xzglxq.isBefore(DateUtil.date())){
break;
}
_ = (xzglxq);
if (_.get_date().isBefore(DateUtil.date())){
break;
}
tmpList.add(_);
if (_.(,atomicDouble.get())){
// DateTime 上料日期 = item.get均衡需求日期().offset(DateField.DAY_OF_YEAR, -14);
// 资源 上料 = 提取资源(上料日期);
// for (Bom bom:item.getBomList()){
// 上料.占用资源(Constant.工序.上料,bom,item.get产能需求().get(Constant.工序.上料).get());
// _资源.占用资源(Constant.工序.切割,bom,1);
// }
if (item.getDcCh().equals("G175K-4")&&item.getDcPl().equals("020")){
System.out.println(111);
}
(item.getBomList(),item.get(),CDMap);
break;
}
//需求日期可利用范围是±3天,排产是需要根据产能进行调整
item.set(DateUtil.offsetDay(item.get(),times));
times+=1;
}while (true);
//若在需求期±3天内无法正常排产时,查找最大可用空闲资源进行占用
AtomicReference<String> date=new AtomicReference<>();
if (times>3){
//查找最小可用资源,进行占用
tmpList.sort(Comparator.comparingDouble((tmp)->tmp.getMAP().get(Constant..).get()));
tmpList.stream().findFirst().ifPresent(tmp->{
// DateTime 上料日期 = item.get均衡需求日期().offset(DateField.DAY_OF_YEAR, -14);
// 资源 上料 = 提取资源(上料日期);
// for (Bom bom:item.getBomList()){
// 上料.占用资源(Constant.工序.上料,bom,item.get产能需求().get(Constant.工序.上料).get());
// tmp.占用资源(Constant.工序.切割,bom,1);
// }
//由于资源日为切割日期,这里需要还原一下,修正传递的参照需求日期
if (item.getDcCh().equals("G175K-4")&&item.getDcPl().equals("020")){
System.out.println(111);
}
(item.getBomList(),tmp.get_date().offset(DateField.DAY_OF_YEAR,-CDMap.get().getCd()),CDMap);
date.set(tmp.getDate());
});
}
if (_!=null){
date.set(_.getDate());
log.info("船号:{},批次:{},占用资源成功,切割日期:{}",item.getDcCh(),item.getDcPl(),date.get());
}else {
log.info("船号:{},批次:{},早于当前日期无需排产",item.getDcCh(),item.getDcPl());
}
}
private static void (List<Bom> list,DateTime ,Map<Constant.,CD> CDMap){ private static void (List<Bom> list,DateTime ,Map<Constant.,CD> CDMap){
CountDownLatch latch = new CountDownLatch(list.size()); CountDownLatch latch = new CountDownLatch(list.size());
for (Bom bom:list){ for (Bom bom:list){
@ -358,11 +193,6 @@ public class DataFactory {
} }
} }
private static void (Collection<> _){
_.forEach(::);
}
private static List<> (List<> list){ private static List<> (List<> list){
Map<String,> map=new HashMap<>(); Map<String,> map=new HashMap<>();
list.forEach(item->{ list.forEach(item->{
@ -377,16 +207,6 @@ public class DataFactory {
return new ArrayList<>(map.values()); return new ArrayList<>(map.values());
} }
private static Collection<> (List<> list){
Map<String,> map=new HashMap<>();
list.forEach(item->{
String key=item.getDcCh() + item.getDcPl();
_ = map.computeIfAbsent(key, k -> new ());
_.of(item);
});
return map.values();
}
public static List<> 1(){ public static List<> 1(){
List<DmSygdxq> = getBean(DmSygdxqService.class).getXqWithBom(from, to); List<DmSygdxq> = getBean(DmSygdxqService.class).getXqWithBom(from, to);
return .stream().map(item->{ return .stream().map(item->{
@ -396,11 +216,6 @@ public class DataFactory {
}).collect(Collectors.toList()); }).collect(Collectors.toList());
} }
public static List<> (){
List<DmSygdxq> = getBean(DmSygdxqService.class).getXqWithBom(from, to);
return .stream().map(::of).collect(Collectors.toList());
}
private static Map<String,List<>> _=new HashMap<>(); private static Map<String,List<>> _=new HashMap<>();
public static List<> (String dcch){ public static List<> (String dcch){
List<> list=_.get(dcch); List<> list=_.get(dcch);
@ -412,17 +227,6 @@ public class DataFactory {
return map.get(dcch); return map.get(dcch);
} }
public static Optional<> (Constant. ,Date ,Date , double ){
return .values().stream().filter(->{
= .getMAP().get();
Date =DateUtil.parse(.getDate(),"yyyy/MM/dd");
if (==null){
return false;
}
return .()&&.after()&&.before();
}).findFirst();
}
public static (Date date){ public static (Date date){
= .get(DateUtil.format(date, "yyyy/MM/dd")); = .get(DateUtil.format(date, "yyyy/MM/dd"));
if (==null){ if (==null){

@ -3,6 +3,7 @@ package com.dsic.gj_erp.pc.dto;
import cn.hutool.core.date.DateTime; import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSONObject;
import com.dsic.gj_erp.pc.Constant; import com.dsic.gj_erp.pc.Constant;
import com.dsic.gj_erp.pc.dto.data.Bom; import com.dsic.gj_erp.pc.dto.data.Bom;
import com.google.common.util.concurrent.AtomicDouble; import com.google.common.util.concurrent.AtomicDouble;
@ -59,9 +60,6 @@ public class 资源 {
public boolean (Constant. , Bom bom, double ){ public boolean (Constant. , Bom bom, double ){
AtomicBoolean atomicBoolean = new AtomicBoolean(false); AtomicBoolean atomicBoolean = new AtomicBoolean(false);
if (bom.getTzbh().equals("B020N4PX004")){
System.out.println(111);
}
= MAP.get(); = MAP.get();
Optional.ofNullable().ifPresent(it->{ Optional.ofNullable().ifPresent(it->{
if (it.==0){ if (it.==0){
@ -104,10 +102,15 @@ public class 资源 {
public static of(String date,Map<Constant.,> MAP){ public static of(String date,Map<Constant.,> MAP){
= new (); = new ();
.date=date; .date=date;
._date= DateUtil.parse(date,"yyyy/MM/dd"); ._date= DateUtil.parse(date,"yyyy/MM/dd");
.MAP=MAP; .MAP=MAP;
return ; return ;
} }
private (){} private (){}
public String toString(){
return JSONObject.toJSONString(this);
}
} }

@ -12,10 +12,12 @@ import com.dsic.gj_erp.bean.jhgk.DmSygdMxLj;
import com.dsic.gj_erp.bean.jhgk.DmYdjhxf; import com.dsic.gj_erp.bean.jhgk.DmYdjhxf;
import com.dsic.gj_erp.mapper.jhgk.DmSygdxqMapper; import com.dsic.gj_erp.mapper.jhgk.DmSygdxqMapper;
import com.dsic.gj_erp.pc.Manager; import com.dsic.gj_erp.pc.Manager;
import com.dsic.gj_erp.service.jhgk.DmSygdMxLjService;
import com.dsic.gj_erp.service.jhgk.DmSygdMxService; import com.dsic.gj_erp.service.jhgk.DmSygdMxService;
import com.dsic.gj_erp.service.jhgk.DmSygdService; import com.dsic.gj_erp.service.jhgk.DmSygdService;
import com.dsic.gj_erp.service.jhgk.impl.DmSygdMxLjServiceImpl; import com.dsic.gj_erp.service.jhgk.impl.DmSygdMxLjServiceImpl;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
@ -23,12 +25,13 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@Slf4j
@Service @Service
@AllArgsConstructor @AllArgsConstructor
public class { public class {
private final DmSygdxqMapper sygdxqMapper; private final DmSygdxqMapper sygdxqMapper;
private final DmSygdMxLjServiceImpl ljService; private final DmSygdMxLjService ljService;
private final DmSygdMxService sygdMxService; private final DmSygdMxService sygdMxService;
private final DmSygdService sygdService; private final DmSygdService sygdService;
@ -51,17 +54,18 @@ public class 三月滚动接口 {
//2.根据 //2.根据
List<DmSygdMx> mxList = ljList.stream().map(DmSygdMx::ofWithDmSygdMxlj).collect(Collectors.toList()); 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())); Map<String, List<DmSygdMx>> collect = mxList.stream().collect(Collectors.groupingBy(item -> item.getDcCh() + item.getDcPl()));
DateTime from = DateUtil.parse(begin, "yyyy/MM/dd"); DateTime from = DateUtil.parse(begin, "yyyy/MM/dd");
DateTime to = DateUtil.parse(end, "yyyy/MM/dd"); DateTime to = DateUtil.parse(end, "yyyy/MM/dd");
Manager..values().parallelStream() Manager..values().stream()
.filter(_->DateUtil.isIn(_.get_date(),from,to)) // .filter(_资源->DateUtil.isIn(_资源.get_date(),from,to))
.forEach(_->{_.getMAP().values().forEach(_->{ .forEach(_->{
_.getMAP().values().forEach(_->{
_.get().values().forEach(_->{ _.get().values().forEach(_->{
_.get().parallelStream().forEach(_bom->{ _.get().forEach(_bom->{
List<DmSygdMx> dmSygdMxes = collect.get(_bom.getDcch() + _bom.getPl() + _bom.getTzbh()); List<DmSygdMx> dmSygdMxes = collect.get(_bom.getDcch() + _bom.getPl());
for (DmSygdMx mx:dmSygdMxes){ for (DmSygdMx mx:dmSygdMxes){
mx.(_.get(),_.getDate()); mx.(_.get(),_.getDate());
} }
@ -70,7 +74,7 @@ public class 三月滚动接口 {
}); });
}); });
//sygdMxService.saveBatch(mxList,500); sygdMxService.saveBatch(mxList,500);
ljList.forEach(lj-> mxList.forEach(mx->{ ljList.forEach(lj-> mxList.forEach(mx->{
if (lj.getDcch().equals(mx.getDcCh()) if (lj.getDcch().equals(mx.getDcCh())
@ -79,7 +83,7 @@ public class 三月滚动接口 {
lj.setParentId(mx.getId()); lj.setParentId(mx.getId());
} }
})); }));
//ljService.saveBatch(ljList,500); ljService.saveBatch(ljList,500);
List<DmYdjhxf> list= sygdMxService.tqSygd1(begin,end); List<DmYdjhxf> list= sygdMxService.tqSygd1(begin,end);
ResultBean r = new ResultBean(list); ResultBean r = new ResultBean(list);

@ -11,8 +11,10 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.dsic.gj_erp.bean.jhgk.DmQfxq; import com.dsic.gj_erp.bean.jhgk.DmQfxq;
import com.dsic.gj_erp.bean.jhgk.DmSygdMx; import com.dsic.gj_erp.bean.jhgk.DmSygdMx;
import com.dsic.gj_erp.bean.jhgk.DmYdjh; import com.dsic.gj_erp.bean.jhgk.DmYdjh;
import com.dsic.gj_erp.bean.jhgk.DmYdjhLj;
import com.dsic.gj_erp.mapper.jhgk.DmQfxqMapper; import com.dsic.gj_erp.mapper.jhgk.DmQfxqMapper;
import com.dsic.gj_erp.service.jhgk.DmQfxqService; import com.dsic.gj_erp.service.jhgk.DmQfxqService;
import com.dsic.gj_erp.service.jhgk.DmYdjhLjService;
import com.dsic.gj_erp.service.jhgk.DmYdjhService; import com.dsic.gj_erp.service.jhgk.DmYdjhService;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
@ -36,6 +38,9 @@ public class DmQfxqServiceImpl extends ServiceImpl<DmQfxqMapper, DmQfxq> impleme
@Resource @Resource
private DmYdjhService ydjhService; private DmYdjhService ydjhService;
@Resource
private DmYdjhLjService ljService;
@Override @Override
@Transactional @Transactional
public List<DmQfxq> saveXzList(List<DmQfxq> list, String username, String day){ public List<DmQfxq> saveXzList(List<DmQfxq> list, String username, String day){
@ -190,6 +195,9 @@ public class DmQfxqServiceImpl extends ServiceImpl<DmQfxqMapper, DmQfxq> impleme
l.setJssjOld(StrUtil.isEmpty(l.getJssj())?"":l.getJssj()); l.setJssjOld(StrUtil.isEmpty(l.getJssj())?"":l.getJssj());
l.setJssj(l.getXzglxq()); l.setJssj(l.getXzglxq());
} }
if (StrUtil.isEmpty(l.getTzbh())){
l.setJhlx("3");
}
}); });
ydjhService.saveBatch(ydjhList); ydjhService.saveBatch(ydjhList);
} }
@ -222,6 +230,11 @@ public class DmQfxqServiceImpl extends ServiceImpl<DmQfxqMapper, DmQfxq> impleme
.eq(DmYdjh::getDcPl,dcPl) .eq(DmYdjh::getDcPl,dcPl)
.in(DmYdjh::getTzbh,list) .in(DmYdjh::getTzbh,list)
); );
ljService.remove(Wrappers.<DmYdjhLj>lambdaQuery()
.eq(DmYdjhLj::getCzbh,dcCh)
.eq(DmYdjhLj::getPl,dcPl)
.in(DmYdjhLj::getTlth,list)
);
} }
} }

@ -53,7 +53,7 @@
from from
dm_sygdxq xq left join dm_bom bom on bom.dcch = xq.DC_CH and bom.pl = xq.DC_PL and bom.fd = xq.DC_FD dm_sygdxq xq left join dm_bom bom on bom.dcch = xq.DC_CH and bom.pl = xq.DC_PL and bom.fd = xq.DC_FD
where where
xq.xzglxq between #{from} and #{to} xq.xzglxq between #{from} and #{to} and bom.type='b'
<if test="dcch!=null and dcch!=''"> <if test="dcch!=null and dcch!=''">
and xq.DC_CH=#{dcch} and xq.DC_CH=#{dcch}
</if> </if>
@ -122,7 +122,7 @@
and dm_bom.pl = dm_sygdxq.DC_PL and dm_bom.pl = dm_sygdxq.DC_PL
and dm_bom.fd = dm_sygdxq.DC_FD and dm_bom.fd = dm_sygdxq.DC_FD
where where
dm_sygdxq.xzglxq between #{begin} and #{end} dm_sygdxq.xzglxq between #{begin} and #{end} and dm_bom.type = 'b'
ORDER BY dm_sygdxq.xzglxq,dm_sygdxq.DC_CH,dm_sygdxq.DC_PL,dm_bom.TZBH,dm_sygdxq.DC_FD ORDER BY dm_sygdxq.xzglxq,dm_sygdxq.DC_CH,dm_sygdxq.DC_PL,dm_bom.TZBH,dm_sygdxq.DC_FD
</select> </select>

Loading…
Cancel
Save