@ -1,16 +1,27 @@
package com.dsic.gj_erp.controller.jcsj ;
package com.dsic.gj_erp.controller.jcsj ;
import cn.hutool.core.date.DateUtil ;
import cn.hutool.core.util.StrUtil ;
import cn.hutool.core.util.StrUtil ;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper ;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper ;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper ;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper ;
import com.baomidou.mybatisplus.core.toolkit.IdWorker ;
import com.dsic.gj_erp.annotation.AuthFunction ;
import com.dsic.gj_erp.annotation.AuthFunction ;
import com.dsic.gj_erp.bean.ResultBean ;
import com.dsic.gj_erp.bean.ResultBean ;
import com.dsic.gj_erp.bean.jcsj. DmBom ;
import com.dsic.gj_erp.bean.jcsj. * ;
import com.dsic.gj_erp.bean.jcsj.vo.BomVO ;
import com.dsic.gj_erp.bean.jcsj.vo.BomVO ;
import com.dsic.gj_erp.bean.jhgk.DmYdjh ;
import com.dsic.gj_erp.bean.sy.Dm_zhbmp ;
import com.dsic.gj_erp.dao.sy.Dm_zhbmpRepository ;
import com.dsic.gj_erp.exception.CustomException ;
import com.dsic.gj_erp.exception.CustomException ;
import com.dsic.gj_erp.service.jcsj.DmBchxjbpService ;
import com.dsic.gj_erp.service.jcsj.DmBchxmxpService ;
import com.dsic.gj_erp.service.jcsj.DmBchxylpService ;
import com.dsic.gj_erp.service.jcsj.DmBomService ;
import com.dsic.gj_erp.service.jcsj.DmBomService ;
import com.dsic.gj_erp.service.jcsj.impl.BomUploadServiceImpl ;
import com.dsic.gj_erp.service.jcsj.impl.BomUploadServiceImpl ;
import com.dsic.gj_erp.service.jhgk.DmYdjhService ;
import com.dsic.gj_erp.service.sy.SYService ;
import com.dsic.gj_erp.service.sy.SYService ;
import com.dsic.gj_erp.util.ObjConvertUtils ;
import io.swagger.annotations.ApiOperation ;
import org.apache.commons.lang3.StringUtils ;
import org.apache.commons.lang3.StringUtils ;
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.PostMapping ;
@ -19,6 +30,8 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController ;
import org.springframework.web.bind.annotation.RestController ;
import javax.servlet.http.HttpServletRequest ;
import javax.servlet.http.HttpServletRequest ;
import java.util.ArrayList ;
import java.util.HashMap ;
import java.util.List ;
import java.util.List ;
import java.util.Map ;
import java.util.Map ;
import java.util.stream.Collectors ;
import java.util.stream.Collectors ;
@ -38,11 +51,25 @@ public class DmBomController {
@Autowired
@Autowired
DmBomService dmBomService ;
DmBomService dmBomService ;
@Autowired
Dm_zhbmpRepository dm_zhbmpRepository ;
@Autowired
@Autowired
BomUploadServiceImpl bomUploadService ;
BomUploadServiceImpl bomUploadService ;
@Autowired
@Autowired
SYService syService ;
SYService syService ;
@Autowired
DmBchxjbpService dmBchxjbpService ;
@Autowired
DmBchxmxpService dmBchxmxpService ;
@Autowired
DmBchxylpService bchxylpService ;
@Autowired
DmYdjhService dmYdjhService ;
@PostMapping ( "/saveDegs" )
@PostMapping ( "/saveDegs" )
@AuthFunction
@AuthFunction
@ -113,5 +140,110 @@ public class DmBomController {
// return null;
// return null;
}
}
@ApiOperation ( value = "生成月度计划" )
@PostMapping ( "/scydjh" )
public ResultBean scydjh ( HttpServletRequest req ) throws CustomException {
List < String > AAA = new ArrayList < > ( ) ;
AAA . add ( "165" ) ;
for ( String aa : AAA ) {
List < DmBchxjbp > dmBchxjbps = dmBchxjbpService . list ( new QueryWrapper < DmBchxjbp > ( ) . eq ( "DC_CH" , "G175K-7" ) . eq ( "DC_PL" , aa ) ) ;
List < Dm_zhbmp > zllbs = dm_zhbmpRepository . findByBMLB ( "ZLLB" ) ;
List < Dm_zhbmp > kwxxs = dm_zhbmpRepository . findByBMLB ( "KWXX" ) ;
List < Dm_zhbmp > qgkws = dm_zhbmpRepository . findByBMLB ( "QGKW" ) ;
Map < String , String > zllbMap = zllbs . stream ( ) . collect ( Collectors . toMap ( Dm_zhbmp : : getBmsm , Dm_zhbmp : : getBM ) ) ;
Map < String , String > kwxxMap = kwxxs . stream ( ) . collect ( Collectors . toMap ( Dm_zhbmp : : getBM , Dm_zhbmp : : getBmsm ) ) ;
Map < String , String > qgKwMap = qgkws . stream ( ) . collect ( Collectors . toMap ( Dm_zhbmp : : getBmsm , Dm_zhbmp : : getBM ) ) ;
String dcch = dmBchxjbps . get ( 0 ) . getDcCh ( ) ;
String dcpl = dmBchxjbps . get ( 0 ) . getDcPl ( ) ;
List < DmBchxylp > tjListOld = bchxylpService . list ( new QueryWrapper < DmBchxylp > ( ) . eq ( "dc_ch" , dcch ) . eq ( "dc_pl" , dcpl ) ) ;
List < DmYdjh > ydjhs = dmYdjhService . list ( new QueryWrapper < DmYdjh > ( ) . eq ( "dc_ch" , dcch )
. eq ( "dc_pl" , dcpl )
) ;
List < DmYdjh > adds = new ArrayList < > ( ) ;
List < DmYdjh > ups = new ArrayList < > ( ) ;
for ( DmBchxjbp dmBchxjbp1 : dmBchxjbps ) {
//wpgg ,wpxh
// DmBchxjbp dmBchxjbp = (DmBchxjbp) ObjConvertUtils.checkNullNew(dmBchxjbp1);
DmBchxjbp dmBchxjbp = ( DmBchxjbp ) ObjConvertUtils . checkNullNew ( dmBchxjbp1 ) ;
DmBchxmxp bchxmxp = dmBchxmxpService . list ( new QueryWrapper < DmBchxmxp > ( ) . eq ( "hxbh" , dmBchxjbp1 . getHxbh ( ) ) ) . get ( 0 ) ;
DmBchxylp bchxylp = tjListOld . stream ( ) . filter ( fst - > fst . getTzbh ( ) . equals ( dmBchxjbp . getTzbh ( ) )
& & fst . getWpgg ( ) . equalsIgnoreCase ( dmBchxjbp . getWpgg ( ) ) & & fst . getWpxh ( ) . equalsIgnoreCase ( dmBchxjbp . getWpxh ( ) )
) . findFirst ( ) . orElse ( null ) ;
// dmBchxjbp
String wpgg = dmBchxjbp . getWpgg ( ) ;
String wpxh = dmBchxjbp . getWpxh ( ) ;
String tzbh = dmBchxjbp . getTzbh ( ) ;
String hxfl = dmBchxjbp . getHxfl ( ) ;
if ( StringUtils . isBlank ( wpgg ) | | "hxfl" . equals ( "X" ) ) {
continue ;
}
DmYdjh dmYdjhadd = new DmYdjh ( ) ;
String hxlx = "" ;
if ( tzbh . substring ( 4 , 5 ) . equals ( "S" ) ) {
hxlx = "1010" ;
} else if ( tzbh . substring ( 4 , 5 ) . equals ( "N" ) ) {
hxlx = "1020" ;
}
dmYdjhadd . setDcCh ( dmBchxjbp . getDcCh ( ) ) ;
dmYdjhadd . setDcPl ( dmBchxjbp . getDcPl ( ) ) ;
if ( tzbh . substring ( 4 , 5 ) . equals ( "X" ) ) {
dmYdjhadd . setLx ( "X" ) ;
} else {
dmYdjhadd . setLx ( "B" ) ;
}
dmYdjhadd . setWpgg ( dmBchxjbp . getWpgg ( ) ) ;
dmYdjhadd . setWpxh ( dmBchxjbp . getWpxh ( ) ) ;
if ( null ! = bchxylp ) {
dmYdjhadd . setYlbs ( null = = bchxylp . getSfyl ( ) ? "" : bchxylp . getSfyl ( ) ) ;
}
dmYdjhadd . setLqlb ( hxlx ) ;
dmYdjhadd . setTzbh ( tzbh ) ;
dmYdjhadd . setHxcd ( dmBchxjbp . getHxcd ( ) . doubleValue ( ) ) ;
dmYdjhadd . setQgcd ( dmBchxjbp . getYlzd4 ( ) . doubleValue ( ) ) ;
dmYdjhadd . setLjsl ( dmBchxjbp . getLjsl ( ) . doubleValue ( ) ) ;
dmYdjhadd . setZl ( dmBchxjbp . getDcZl ( ) ) ;
String s = ( String ) kwxxMap . get ( tzbh . substring ( 4 , 7 ) ) ;
String zzcj = ( String ) qgKwMap . get ( s ) ; //xhj
dmYdjhadd . setKw ( zzcj ) ;
dmYdjhadd . setDcFd ( StringUtils . isBlank ( bchxmxp . getWph ( ) ) ? "" : bchxmxp . getWph ( ) . substring ( 0 , 4 ) ) ;
dmYdjhadd . setZt ( "2" ) ;
dmYdjhadd . setId ( IdWorker . get32UUID ( ) ) ;
dmYdjhadd . setBmbzrq ( DateUtil . format ( DateUtil . date ( ) , "yyyy/MM/dd HH:mm" ) ) ;
dmYdjhadd . setBmbzry ( "xhj" ) ;
// 新增数据得时候 应该看 是不是有排产数据 有排产数据 给上日期
// dmYdjhadd
adds . add ( dmYdjhadd ) ;
}
dmYdjhService . saveBatch ( adds ) ;
}
// List<DmBchxjbp> dmBchxjbps = dmBchxjbpService.list(new QueryWrapper<DmBchxjbp>().eq("DC_CH", "T300K-103").in("DC_PL", "109","112","114","115","117"));
// dmBchxjbps.forEach(e->{
// dmBchxmxpService.list(new QueryWrapper<DmBchxmxp>().eq("hxbh", e.getHxbh()).eq("xh", ));
// });
//List<DmBchxmxp> mxs = dmBchxmxpService.list(new QueryWrapper<DmBchxmxp>().eq("DC_CH", "T300K-103").eq("DC_PL", "109"));
return new ResultBean ( ) ;
}
}
}