1.优化代码

master
董哲奇 1 year ago
parent 8118a37cfa
commit f4d77fa33f

@ -19,6 +19,13 @@
</properties>
<dependencies>
<dependency>
<groupId>com.jcraft</groupId>
<artifactId>jsch</artifactId>
<version>0.1.53</version>
</dependency>
<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt</artifactId>

@ -1,6 +1,9 @@
package com.dsic.gj_erp;
import com.github.jeffreyning.mybatisplus.conf.EnableMPP;
import com.jcraft.jsch.JSch;
import com.jcraft.jsch.JSchException;
import com.jcraft.jsch.Session;
import com.querydsl.jpa.impl.JPAQueryFactory;
import org.modelmapper.ModelMapper;
import org.modelmapper.convention.MatchingStrategies;
@ -10,7 +13,9 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
import javax.annotation.PostConstruct;
import javax.persistence.EntityManager;
import java.util.Properties;
@EnableMPP
@SpringBootApplication
@ -19,7 +24,7 @@ import javax.persistence.EntityManager;
public class GjErpApplication {
public static void main(String[] args) {
// new GjErpApplication().init();
SpringApplication.run(GjErpApplication.class, args);
}
@Bean
@ -40,4 +45,27 @@ public class GjErpApplication {
modelMapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT);
return modelMapper;
}
private static Session session;
// @PostConstruct
public void init() {
System.out.println(1111);
JSch jsch = new JSch();
Thread thread = new Thread(() -> {
try {
session = jsch.getSession("root", "43.143.202.126", 22);
jsch.addIdentity("E:\\文档\\润芃\\腾讯云服务器\\43.143.202.126\\Runpeng666.pem");
Properties config = new Properties();
config.put("StrictHostKeyChecking", "no");
session.setConfig(config);
session.connect();
session.setPortForwardingL(10005, "127.0.0.1", 10005);
System.out.println(session.isConnected());
} catch (JSchException e) {
e.printStackTrace();
}
});
thread.start();
}
}

@ -16,6 +16,7 @@ import org.springframework.web.bind.annotation.RestController;
import java.util.List;
import java.util.Map;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Collectors;
/**
@ -57,9 +58,25 @@ public class DmYdjhController {
@AuthFunction
public ResultBean tj(@RequestBody List<DmYdjh> list){
List<String> idList=list.stream().map(DmYdjh::getId).collect(Collectors.toList());
service.update(new UpdateWrapper<DmYdjh>().set("zt","1")
.in( "id",idList)
);
if (idList.size()>1000){
AtomicInteger index=new AtomicInteger(idList.size()/1000+1);
service.update(new UpdateWrapper<DmYdjh>().set("zt","1")
.in( "id",idList.subList(idList.size()/1000*1000, idList.size()))
);
do {
int i = index.decrementAndGet();
List<String> list1 = idList.subList((index.get()-1)*1000, i*1000);
service.update(new UpdateWrapper<DmYdjh>().set("zt","1")
.in( "id",list1)
);
}while (index.get()>1);
}else {
service.update(new UpdateWrapper<DmYdjh>().set("zt","1")
.in( "id",idList)
);
}
return new ResultBean();
}

@ -57,7 +57,7 @@ public class YppController {
.eq(StrUtil.isNotEmpty(qfxq.getDcPl()),DmQfxq::getDcPl, qfxq.getDcPl())
.eq(StrUtil.isNotEmpty(qfxq.getDcFd()),DmQfxq::getDcFd, qfxq.getDcFd())
.eq(StrUtil.isNotEmpty(qfxq.getZt()),DmQfxq::getZt,qfxq.getZt())
.exists(builder.toString())
.notExists(builder.toString())
);
return new ResultBean<>(list);
}

@ -4,6 +4,7 @@ package com.dsic.gj_erp.service.jhgk.impl;
import cn.hutool.core.util.ObjUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.dsic.gj_erp.bean.jhgk.DmQfxq;
import com.dsic.gj_erp.bean.jhgk.DmYdjh;
@ -83,6 +84,7 @@ public class DmQfxqServiceImpl extends ServiceImpl<DmQfxqMapper, DmQfxq> impleme
@Override
@Transactional
public void saveDzList(List<DmQfxq> list,String username,String day){
List<DmQfxq> toYdList=new ArrayList<>();
list.forEach(l->{
l.setDcPl(l.getDcPl().length() == 1 ? "00" + l.getDcPl() : l.getDcPl().length() == 2 ? "0" + l.getDcPl() : l.getDcPl());
DmQfxq qfxq=this.getOne(new QueryWrapper<DmQfxq>()
@ -111,8 +113,13 @@ public class DmQfxqServiceImpl extends ServiceImpl<DmQfxqMapper, DmQfxq> impleme
l.setDrrq(day);
this.save(l);
}
toYdList.add(this.getOne(Wrappers.<DmQfxq>lambdaQuery()
.eq(DmQfxq::getDcCh,l.getDcCh())
.eq(DmQfxq::getDcPl,l.getDcPl())
.eq(DmQfxq::getDcFd,l.getDcFd())
));
});
generateYdjh(list);
generateYdjh(toYdList);
}
/**
@ -134,8 +141,8 @@ public class DmQfxqServiceImpl extends ServiceImpl<DmQfxqMapper, DmQfxq> impleme
.eq("Dc_Ch",dmYdjh.getDcCh())
.eq("Dc_Pl",dmYdjh.getDcPl())
.eq("Tzbh",dmYdjh.getTzbh()));
ydjhService.save(dmYdjh);
}
ydjhService.saveBatch(ydjhList);
}
}

@ -81,11 +81,11 @@ public class DmSygdMxServiceImpl extends ServiceImpl<DmSygdMxMapper, DmSygdMx> i
public ResultBean sygdPC() {
//todo 重复导入(三月滚动计划)的数据处理
//零件 删除
String begin=DateUtil.format(DateUtil.nextMonth(),"yyyy/MM/01");
String end =DateUtil.format(DateUtil.endOfMonth(DateUtil.offsetMonth(DateUtil.date(),3)),"yyyy/MM/dd");
// String begin=DateUtil.format(DateUtil.nextMonth(),"yyyy/MM/01");
// String end =DateUtil.format(DateUtil.endOfMonth(DateUtil.offsetMonth(DateUtil.date(),3)),"yyyy/MM/dd");
//测试日期
// String begin = "2023/08/01";
// String end = "2023/10/31";
String begin = "2023/08/01";
String end = "2023/10/31";
//todo 零件
ljService.remove(new QueryWrapper<DmSygdMxLj>().between("xzglxq", begin, end));
//todo 三月滚动明细
@ -119,7 +119,7 @@ public class DmSygdMxServiceImpl extends ServiceImpl<DmSygdMxMapper, DmSygdMx> i
Map<String, List<DmSygdMx>> mxMap = list.stream().collect(Collectors.groupingBy(x -> x.getKw() + x.getZl()));
//加工工序list
List<EmSbcnp> sbcnp = sbcnpService.list(new QueryWrapper<EmSbcnp>().orderByDesc("tzbh,zl,jgsx"));
Map<String, List<EmSbcnp>> cnMap = sbcnp.stream().collect(Collectors.groupingBy(l -> l.getTzbh() + l.getZl()));
Map<String, List<EmSbcnp>> cnMap = sbcnp.stream().collect(Collectors.groupingBy(l -> l.getKw().substring(1) + l.getZl()));
for (String ljkey : mxMap.keySet()) {
for (String cnkey : cnMap.keySet()) {
if (ljkey.equals(cnkey)) {
@ -457,9 +457,10 @@ public class DmSygdMxServiceImpl extends ServiceImpl<DmSygdMxMapper, DmSygdMx> i
//1.查询未来3个月明细信息
//测试
// List<DmSygdMx> list=null;
String begin = DateUtil.format(DateUtil.nextMonth(), "yyyy/MM/01");
String end = DateUtil.format(DateUtil.endOfMonth(DateUtil.offsetMonth(DateUtil.date(), 3)), "yyyy/MM/dd");
// String begin = DateUtil.format(DateUtil.nextMonth(), "yyyy/MM/01");
// String end = DateUtil.format(DateUtil.endOfMonth(DateUtil.offsetMonth(DateUtil.date(), 3)), "yyyy/MM/dd");
String begin = "2023/08/01";
String end = "2023/10/31";
List<DmSygdMx> list = this.list(new QueryWrapper<DmSygdMx>()
.between("jssj",
begin,

@ -23,6 +23,7 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.*;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Collectors;
/**
@ -97,10 +98,10 @@ public class DmYdjhServiceImpl extends ServiceImpl<DmYdjhMapper, DmYdjh> impleme
if (dhList.size()<1){
List<PgdDh> dh= baseMapper.getDhjh(begin,end);
if (dh.size()>0){
dhService.saveBatch(dh);
dhList=dhService.list(new QueryWrapper<PgdDh>().between("slxqrq",begin,end).orderByAsc("czbh,slxqrq"));
}
}
//上料计划
List<PgdSljh> slList=slService.list(new QueryWrapper<PgdSljh>().between("sljhrq",begin,end).orderByAsc("czbh,pl,sljhrq"));
@ -131,22 +132,37 @@ public class DmYdjhServiceImpl extends ServiceImpl<DmYdjhMapper, DmYdjh> impleme
//下发 派工单状态改为编制 生成零件信息
@Override
@Transactional
public void xf(List<DmYdjh> ydjhList){
//修改状态
List<String> idList=ydjhList.stream().map(DmYdjh::getId).collect(Collectors.toList());
//修改汇总状态 改为 编制
int num= baseMapper.xfbc(idList);
if(num<1){
throw new RuntimeException("请先汇总,后下发!");
if (idList.size()>1000){
List<String> list = idList.subList(idList.size() / 1000 * 1000, idList.size());
AtomicInteger index=new AtomicInteger(idList.size()/1000+1);
this.update(new UpdateWrapper<DmYdjh>().set("zt","2")
.in( "id",list)
);
baseMapper.xfbc(list);
baseMapper.tqlj(list);
do {
int i = index.decrementAndGet();
List<String> list1 = idList.subList((index.get()-1)*1000, i*1000);
this.update(new UpdateWrapper<DmYdjh>().set("zt","2")
.in( "id",list1)
);
baseMapper.xfbc(list1);
baseMapper.tqlj(list1);
}while (index.get()>1);
}else {
this.update(new UpdateWrapper<DmYdjh>().set("zt","2")
.in( "id",idList)
);
//修改汇总状态 改为 编制
baseMapper.xfbc(idList);
//生成对应零件信息 bom->tzjhLj
baseMapper.tqlj(idList);
}
this.update(new UpdateWrapper<DmYdjh>().set("zt","2")
.in( "id",idList)
);
//生成对应零件信息 bom->tzjhLj
baseMapper.tqlj(idList);
}
}

@ -160,6 +160,7 @@
<select id="getTzjh" resultType="com.dsic.gj_erp.bean.pgd.PgdTzjh">
INSERT into pgd_tzjh(
tzzt,
zt,
czbh,
pl,
fd,
@ -174,6 +175,7 @@
)
SELECT
'00' as tzzt,
'01' as zt,
dm_ydjh.dc_ch as czbh,
dm_ydjh.dc_pl as pl,
dm_ydjh.dc_fd as fd,
@ -231,7 +233,8 @@
MS_DDMXP.WPCD as WPCD,
MS_DDMXP.WPKD as WPKD,
MS_DDMXP.RKXH as RKXH,
MS_DDJBP.dhqdh as dhqdh
MS_DDJBP.dhqdh as dhqdh,
'00' as zt
from MS_DDJBP,
MS_DDMXP,
im_crklsz
@ -270,7 +273,8 @@
lph,
kwh,
cs,
sljhrq
sljhrq,
zt
)
SELECT
REPLACE(CAST(CAST(NEWID()AS BINARY(10)) + CAST(GETDATE() AS BINARY(6)) AS UNIQUEIDENTIFIER),'-','')as id,
@ -289,7 +293,8 @@
IM_CKWPKWP.GCDDH as xhth,
(IM_CKWPKWP.LPH) AS lph,
(IM_CKWPKWP.CFCS1) AS cs,
(IM_CKWPKWP.dc_fd) AS hth
(IM_CKWPKWP.dc_fd) AS hth,
'00' as zt
from dm_ydjh LEFT JOIN IM_CKWPKWP on
dm_ydjh.dc_ch=IM_CKWPKWP.DC_CH and
@ -316,7 +321,8 @@
pwwz,
pwjhrq,
qfxqrqxz,
qfxqrqdz
qfxqrqdz,
zt
)
SELECT
REPLACE(CAST(CAST(NEWID()AS BINARY(10)) + CAST(GETDATE() AS BINARY(6)) AS UNIQUEIDENTIFIER),'-','')as id,
@ -333,7 +339,8 @@
dm_ydjh.pw as pwwz,
dm_ydjh.pwrq as pwjhrq,
dm_ydjh.jssj as qfxqrqxz,
dm_ydjh.gjjs_dz as qfxqrqdz
dm_ydjh.gjjs_dz as qfxqrqdz,
'00' as zt
from dm_ydjh
WHERE dm_ydjh.pwrq BETWEEN #{begin} and #{end}
</select>
@ -358,7 +365,8 @@
hxcd,
qgcd,
hxkccd,
qgkccd
qgkccd,
zt
)
SELECT
REPLACE(CAST(CAST(NEWID()AS BINARY(10)) + CAST(GETDATE() AS BINARY(6)) AS UNIQUEIDENTIFIER),'-','')as id,
@ -379,7 +387,8 @@
hxcd,
qgcd,
hxkc_cd as hxkccd,
qgkc_cd as qgkccd
qgkc_cd as qgkccd,
'00' as zt
from dm_ydjh
where dm_ydjh.qgrq BETWEEN #{begin} and #{end}
</select>

Loading…
Cancel
Save