@ -6,12 +6,15 @@ import cn.hutool.core.util.StrUtil;
import cn.hutool.cron.CronUtil ;
import cn.hutool.cron.CronUtil ;
import cn.hutool.cron.task.Task ;
import cn.hutool.cron.task.Task ;
import com.baomidou.mybatisplus.core.toolkit.Wrappers ;
import com.baomidou.mybatisplus.core.toolkit.Wrappers ;
import com.dsic.gj_erp.bean.jhgk.DmYdjh ;
import com.dsic.gj_erp.bean.pgd.PgdQgjh ;
import com.dsic.gj_erp.bean.pgd.PgdQgjh ;
import com.dsic.gj_erp.bean.xiaochi.CutPlan ;
import com.dsic.gj_erp.bean.xiaochi.CutPlan ;
import com.dsic.gj_erp.bean.xiaochi.Device ;
import com.dsic.gj_erp.bean.xiaochi.Device ;
import com.dsic.gj_erp.bean.xiaochi.XiaochiUser ;
import com.dsic.gj_erp.bean.xiaochi.XiaochiUser ;
import com.dsic.gj_erp.mapper.xiaochi.CutPlanMapper ;
import com.dsic.gj_erp.mapper.xiaochi.CutPlanMapper ;
import com.dsic.gj_erp.mapper.xiaochi.DeviceMapper ;
import com.dsic.gj_erp.service.pgd.PgdQgjhService ;
import com.dsic.gj_erp.service.pgd.PgdQgjhService ;
import com.dsic.gj_erp.service.zyjh.ZyjhService ;
import lombok.AllArgsConstructor ;
import lombok.AllArgsConstructor ;
import lombok.extern.slf4j.Slf4j ;
import lombok.extern.slf4j.Slf4j ;
import org.springframework.stereotype.Service ;
import org.springframework.stereotype.Service ;
@ -24,9 +27,10 @@ import java.util.stream.Collectors;
@AllArgsConstructor
@AllArgsConstructor
public class XiaoChiService {
public class XiaoChiService {
private final PgdQgjhService qg jhService;
private final ZyjhService zy jhService;
private final CutPlanMapper mapper ;
private final CutPlanMapper mapper ;
/ * *
/ * *
* 小 池 同 步 , 先 使 用 手 动 拉 取 方 式 , 让 钢 加 人 员 进 行 检 查
* 小 池 同 步 , 先 使 用 手 动 拉 取 方 式 , 让 钢 加 人 员 进 行 检 查
* 后 续 改 为 自 动 拉 取
* 后 续 改 为 自 动 拉 取
@ -40,50 +44,47 @@ public class XiaoChiService{
userMap . put ( item . getEmployeeNumber ( ) , item ) ;
userMap . put ( item . getEmployeeNumber ( ) , item ) ;
} ) ;
} ) ;
Map < Integer , Device > deviceMap = new HashMap < > ( ) ;
Map < Integer , Device > deviceMap = new HashMap < > ( ) ;
devices . forEach ( item - > {
devices . forEach ( item - > deviceMap . put ( item . getId ( ) , item ) ) ;
deviceMap . put ( item . getId ( ) , item ) ;
} ) ;
this . exe ( userMap , deviceMap ) ;
this . exe ( userMap , deviceMap ) ;
}
}
private void exe ( Map < String , XiaochiUser > userMap , Map < Integer , Device > deviceMap ) {
private void exe ( Map < String , XiaochiUser > userMap , Map < Integer , Device > deviceMap ) {
log . info ( "========小池同步开始===========" ) ;
log . info ( "========小池同步开始===========" ) ;
//todo sql查询时过滤划线数据
List < CutPlan > cutPlans = mapper . getCutPlanList ( DateUtil . lastMonth ( ) . toString ( ) , DateUtil . today ( ) )
List < CutPlan > cutPlans = mapper . getCutPlanList ( DateUtil . lastMonth ( ) . toString ( ) , DateUtil . today ( ) )
. stream ( ) . filter ( item - > StrUtil . isNotEmpty ( item . getNestKakuyakuDate ( ) ) ) . collect ( Collectors . toList ( ) ) ;
. stream ( ) . filter ( item - > StrUtil . isNotEmpty ( item . getNestKakuyakuDate ( ) ) ) . collect ( Collectors . toList ( ) ) ;
List < PgdQg jh> list = new ArrayList < > ( ) ;
List < DmYd jh> list = new ArrayList < > ( ) ;
cutPlans . forEach ( item - > {
cutPlans . forEach ( item - > {
PgdQgjh one = qgjhService . getOne ( Wrappers . < PgdQg jh> lambdaQuery ( )
DmYdjh one = zyjhService . getOne ( Wrappers . < DmYd jh> lambdaQuery ( )
. eq ( PgdQgjh: : getCzb h, item . getNestExtC02 ( ) )
. eq ( DmYdjh: : getDcC h, item . getNestExtC02 ( ) )
. eq ( PgdQgjh: : getTlt h, item . getNestNameSub1 ( ) )
. eq ( DmYdjh: : getTzb h, item . getNestNameSub1 ( ) )
. eq ( PgdQg jh: : getKw , item . getNestExtC03 ( ) )
. eq ( DmYd jh: : getKw , item . getNestExtC03 ( ) )
. eq ( PgdQgjh: : get Pl, item . getNestExtC04 ( ) )
. eq ( DmYdjh: : getDc Pl, item . getNestExtC04 ( ) )
) ;
) ;
if ( ObjectUtil . isNotEmpty ( one ) ) {
// if (ObjectUtil.isNotEmpty(one)){
PgdQgjh _item = new PgdQgjh ( ) ;
// DmYdjh _item=new DmYdjh();
_item . setId ( one . getId ( ) ) ;
// _item.setId(one.getId());
Optional . of ( userMap . get ( item . getNestExtC05 ( ) ) )
// Optional.of(userMap.get(item.getNestExtC05()))
. ifPresent ( user - > _item . setFkry ( userMap . get ( item . getNestExtC05 ( ) ) . getName ( ) ) ) ;
// .ifPresent(user-> _item.setFkry(userMap.get(item.getNestExtC05()).getName()));
//
Optional . of ( deviceMap . get ( item . getNestCutHo ( ) ) )
// Optional.of(deviceMap.get(item.getNestCutHo()))
. ifPresent ( user - > _item . setQgsbbh ( deviceMap . get ( item . getNestCutHo ( ) ) . getMachineName ( ) ) ) ;
// .ifPresent(user-> _item.setQgsbbh(deviceMap.get(item.getNestCutHo()).getMachineName()));
_item . setFkrq ( DateUtil . format ( DateUtil . date ( ) , "yyyy/MM/dd HH:mm:ss" ) ) ;
// _item.setFkrq(DateUtil.format(DateUtil.date(), "yyyy/MM/dd HH:mm:ss"));
_item . setQgksrq ( item . getQgkssj ( ) ) ;
// _item.setQgksrq(item.getQgkssj());
if ( StrUtil . isNotEmpty ( item . getQgjssj ( ) ) ) {
// if (StrUtil.isNotEmpty(item.getQgjssj())){
_item . setQgjsrq ( item . getQgjssj ( ) ) ;
// _item.setQgjsrq(item.getQgjssj());
_item . setZt ( "09" ) ;
// _item.setZt("09");
}
// }
list . add ( _item ) ;
// list.add(_item);
}
// }
} ) ;
} ) ;
qgjhService . updateBatchById ( list , 500 ) ;
// qgjhService.updateBatchById(list,500);
log . info ( "========小池同步完成===========" ) ;
log . info ( "========小池同步完成===========" ) ;
}
}
private void exeAuto ( Map < String , XiaochiUser > userMap , Map < Integer , Device > deviceMap ) {
private void exeAuto ( Map < String , XiaochiUser > userMap , Map < Integer , Device > deviceMap ) {
//CronUtil默认为分钟,目前未使用CronUtil.setMatchSecond(true)启动秒级任务,以下表示每30分钟执行一次
//CronUtil默认为分钟,目前未使用CronUtil.setMatchSecond(true)启动秒级任务,以下表示每30分钟执行一次
//每30分钟执行一次,获取小池今日加工并且未更新切割计划派工单的数据去更新派工单
//每30分钟执行一次,获取小池今日加工并且未更新切割计划派工单的数据去更新派工单
CronUtil . schedule ( "* /30 * * * * *", ( Task ) ( ) - > {
CronUtil . schedule ( "* * /30 * * * *", ( Task ) ( ) - > {
this . exe ( userMap , deviceMap ) ;
this . exe ( userMap , deviceMap ) ;
} ) ;
} ) ;
CronUtil . start ( ) ;
CronUtil . start ( ) ;