1.优化代码

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

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

@ -1,6 +1,9 @@
package com.dsic.gj_erp; package com.dsic.gj_erp;
import com.github.jeffreyning.mybatisplus.conf.EnableMPP; 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 com.querydsl.jpa.impl.JPAQueryFactory;
import org.modelmapper.ModelMapper; import org.modelmapper.ModelMapper;
import org.modelmapper.convention.MatchingStrategies; import org.modelmapper.convention.MatchingStrategies;
@ -10,7 +13,9 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import springfox.documentation.swagger2.annotations.EnableSwagger2; import springfox.documentation.swagger2.annotations.EnableSwagger2;
import javax.annotation.PostConstruct;
import javax.persistence.EntityManager; import javax.persistence.EntityManager;
import java.util.Properties;
@EnableMPP @EnableMPP
@SpringBootApplication @SpringBootApplication
@ -19,7 +24,7 @@ import javax.persistence.EntityManager;
public class GjErpApplication { public class GjErpApplication {
public static void main(String[] args) { public static void main(String[] args) {
// new GjErpApplication().init();
SpringApplication.run(GjErpApplication.class, args); SpringApplication.run(GjErpApplication.class, args);
} }
@Bean @Bean
@ -40,4 +45,27 @@ public class GjErpApplication {
modelMapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT); modelMapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT);
return modelMapper; 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.List;
import java.util.Map; import java.util.Map;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
@ -57,9 +58,25 @@ public class DmYdjhController {
@AuthFunction @AuthFunction
public ResultBean tj(@RequestBody List<DmYdjh> list){ public ResultBean tj(@RequestBody List<DmYdjh> list){
List<String> idList=list.stream().map(DmYdjh::getId).collect(Collectors.toList()); List<String> idList=list.stream().map(DmYdjh::getId).collect(Collectors.toList());
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") service.update(new UpdateWrapper<DmYdjh>().set("zt","1")
.in( "id",idList) .in( "id",idList)
); );
}
return new ResultBean(); return new ResultBean();
} }

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

@ -4,6 +4,7 @@ package com.dsic.gj_erp.service.jhgk.impl;
import cn.hutool.core.util.ObjUtil; import cn.hutool.core.util.ObjUtil;
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.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; 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.DmYdjh; import com.dsic.gj_erp.bean.jhgk.DmYdjh;
@ -83,6 +84,7 @@ public class DmQfxqServiceImpl extends ServiceImpl<DmQfxqMapper, DmQfxq> impleme
@Override @Override
@Transactional @Transactional
public void saveDzList(List<DmQfxq> list,String username,String day){ public void saveDzList(List<DmQfxq> list,String username,String day){
List<DmQfxq> toYdList=new ArrayList<>();
list.forEach(l->{ list.forEach(l->{
l.setDcPl(l.getDcPl().length() == 1 ? "00" + l.getDcPl() : l.getDcPl().length() == 2 ? "0" + l.getDcPl() : l.getDcPl()); 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>() DmQfxq qfxq=this.getOne(new QueryWrapper<DmQfxq>()
@ -111,8 +113,13 @@ public class DmQfxqServiceImpl extends ServiceImpl<DmQfxqMapper, DmQfxq> impleme
l.setDrrq(day); l.setDrrq(day);
this.save(l); 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_Ch",dmYdjh.getDcCh())
.eq("Dc_Pl",dmYdjh.getDcPl()) .eq("Dc_Pl",dmYdjh.getDcPl())
.eq("Tzbh",dmYdjh.getTzbh())); .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() { public ResultBean sygdPC() {
//todo 重复导入(三月滚动计划)的数据处理 //todo 重复导入(三月滚动计划)的数据处理
//零件 删除 //零件 删除
String begin=DateUtil.format(DateUtil.nextMonth(),"yyyy/MM/01"); // String begin=DateUtil.format(DateUtil.nextMonth(),"yyyy/MM/01");
String end =DateUtil.format(DateUtil.endOfMonth(DateUtil.offsetMonth(DateUtil.date(),3)),"yyyy/MM/dd"); // String end =DateUtil.format(DateUtil.endOfMonth(DateUtil.offsetMonth(DateUtil.date(),3)),"yyyy/MM/dd");
//测试日期 //测试日期
// String begin = "2023/08/01"; String begin = "2023/08/01";
// String end = "2023/10/31"; String end = "2023/10/31";
//todo 零件 //todo 零件
ljService.remove(new QueryWrapper<DmSygdMxLj>().between("xzglxq", begin, end)); ljService.remove(new QueryWrapper<DmSygdMxLj>().between("xzglxq", begin, end));
//todo 三月滚动明细 //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())); Map<String, List<DmSygdMx>> mxMap = list.stream().collect(Collectors.groupingBy(x -> x.getKw() + x.getZl()));
//加工工序list //加工工序list
List<EmSbcnp> sbcnp = sbcnpService.list(new QueryWrapper<EmSbcnp>().orderByDesc("tzbh,zl,jgsx")); 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 ljkey : mxMap.keySet()) {
for (String cnkey : cnMap.keySet()) { for (String cnkey : cnMap.keySet()) {
if (ljkey.equals(cnkey)) { if (ljkey.equals(cnkey)) {
@ -457,9 +457,10 @@ public class DmSygdMxServiceImpl extends ServiceImpl<DmSygdMxMapper, DmSygdMx> i
//1.查询未来3个月明细信息 //1.查询未来3个月明细信息
//测试 //测试
// List<DmSygdMx> list=null; // List<DmSygdMx> list=null;
String begin = DateUtil.format(DateUtil.nextMonth(), "yyyy/MM/01"); // String begin = DateUtil.format(DateUtil.nextMonth(), "yyyy/MM/01");
String end = DateUtil.format(DateUtil.endOfMonth(DateUtil.offsetMonth(DateUtil.date(), 3)), "yyyy/MM/dd"); // 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>() List<DmSygdMx> list = this.list(new QueryWrapper<DmSygdMx>()
.between("jssj", .between("jssj",
begin, begin,

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

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

Loading…
Cancel
Save