1.推送上料计划到料场

master
董哲奇 1 month ago
parent 4e89b5dfb9
commit c9f486c88d

@ -4,12 +4,15 @@ import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.dsic.gj_erp.bean.jhgk.DmYdjh;
import com.dsic.gj_erp.bean.kc.SlKc;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
@Getter
@Setter
@TableName("im_slxx")
@NoArgsConstructor
public class Sljh {
@TableId(type = IdType.AUTO)
private Integer slid;
@ -51,14 +54,39 @@ public class Sljh {
private String lrrq;//导入日期
public Sljh(SlKc slKc){
this.lsh="";//fixme 交换码单张板唯一码2200049281年度+流水号
this.ysch=slKc.getDcTpbh();
this.czbh=slKc.getDCCH();
this.ql=slKc.getDzwz();
this.hth=slKc.getDcFd();//购单号
this.ghsbm=slKc.getGHSBM();//供货商--带到出库接口中-用于成本
this.xhth=slKc.getGCDDH();//合同号
this.wlbm=slKc.getLPH();//物料号-炉批号
this.wph=slKc.getWPH();//物品号
this.wpmc=slKc.getWPMC();//物品名称
this.wpgg=slKc.getWPGG();//物品规格
this.t="";//fixme 物品名称
this.b="";//fixme 物品名称
this.l="";//fixme 物品名称
public static Sljh ofWithYdjh(DmYdjh ydjh){
Sljh sljh=new Sljh();
sljh.dcCh=ydjh.getDcCh();
sljh.dcPl=ydjh.getDcPl();
sljh.dcLx=ydjh.getLx();
sljh.dcKw=ydjh.getKw();
sljh.dcPw=ydjh.getPw();
return sljh;
this.sllsh=slKc.getSllsh();//上料流水号20230322001
this.ylzl="";//fixme 领用重量(KG)
this.kwh=slKc.getKWH();//垛位
this.kwcs=slKc.getCFCS1();//垛位层数01/02/03等
this.dcCh=slKc.getZYCH();//需求船只
this.dcPl=slKc.getZYPL();//需求批量
this.dcLx=slKc.getZYLX();
this.dcKw=slKc.getSLDW();//切割跨位
this.dcPw=slKc.getPwwz();//抛丸位置
this.ddlsh="";//fixme 订单流水号--带到出库接口中-用于成本
this.ddxh="";//fixme 订单序号--带到出库接口中-用于成本
this.wpzt="";//fixme 物品状态--新增
this.lrry=slKc.getDyry();//导入人员
this.lrrq=slKc.getDyrq();//导入日期
}
}

@ -67,6 +67,7 @@ public class SlKc {
private Integer xh;
private String cz;
private String pwbz;
private String GHSBM;
private List<SlKc> list;
}

@ -0,0 +1,15 @@
package com.dsic.gj_erp.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.client.RestTemplate;
@Configuration
public class RestTemplateConfig {
@Bean
public RestTemplate restTemplate() {
return new RestTemplate();
}
}

@ -10,6 +10,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
import com.dsic.gj_erp.annotation.AuthFunction;
import com.dsic.gj_erp.bean.ResultBean;
import com.dsic.gj_erp.bean.SpringContextHolder;
import com.dsic.gj_erp.bean.jcsj.DmCbxxp;
import com.dsic.gj_erp.bean.jhgk.DmYdjh;
import com.dsic.gj_erp.bean.kc.ImCkwpkwp;
@ -21,6 +22,7 @@ import com.dsic.gj_erp.controller.zyjh.dto.PwExportExcel;
import com.dsic.gj_erp.controller.zyjh.dto.PwpgDto;
import com.dsic.gj_erp.dao.sy.Dm_zhbmpRepository;
import com.dsic.gj_erp.exception.CustomException;
import com.dsic.gj_erp.jiuzhou.SlPlanEvent;
import com.dsic.gj_erp.mapper.jhgk.DmYdjhMapper;
import com.dsic.gj_erp.mapper.kc.ImCkwpkwpMapper;
import com.dsic.gj_erp.service.jcsj.DmCbxxpService;
@ -77,8 +79,6 @@ public class PgdSljhController {
DmCbxxpService dmCbxxpService;
@Autowired
SYService syService;
@ -95,6 +95,7 @@ public class PgdSljhController {
//dw_1.object.dyry[ll_ii] = gs_user
//dw_1.object.dyrq[ll_ii] = ls_datetime
List<DmYdjh> ydupList = new ArrayList<>();
List<DmYdjh> ydAddList = new ArrayList<>();
List<ImCkwpkwp> ckupList = new ArrayList<>();
for (SlKc slKc : list) {
String idd = IdWorker.get32UUID();
@ -128,42 +129,6 @@ public class PgdSljhController {
ydjh.setZylx(slKc.getZYLX());
ydjh.setSlbz(slKc.getBZ());
ydjh.setSldrry((String) req.getAttribute("yhms"));
// if("1".equals(slKc.getSLDW()) || "13".equals(slKc.getSLDW()) || "14".equals(slKc.getSLDW()) ||"3".equals(slKc.getSLDW())
// || "6".equals(slKc.getSLDW())|| "7".equals(slKc.getSLDW())||"8".equals(slKc.getSLDW())
// ){
// ydjh.setZyq("FP2Q");
// ydjh.setZyq1("二区");
//
// ydjh.setKw(slKc.getSLDW());
// }
// if("10".equals(slKc.getSLDW()) || "11".equals(slKc.getSLDW()) || "12".equals(slKc.getSLDW()) ||"2".equals(slKc.getSLDW())
// || "5".equals(slKc.getSLDW())|| "9".equals(slKc.getSLDW())
// ){
// ydjh.setZyq("FP3Q");
// ydjh.setZyq1("三区");
//
// ydjh.setKw(slKc.getSLDW());
//
// //作业区默认值修正
// //二跨T型材腹板对应四区
// //二跨T型材面板对应三区 上面已处理 这里只做记录
// if("11".equals(slKc.getSLDW())){
// ydjh.setZyq("FP4Q");
// ydjh.setZyq1("四区");
// }
// }
//
// if("4".equals(slKc.getSLDW())|| "15".equals(slKc.getSLDW())
// ){
// ydjh.setZyq("FP4Q");
// ydjh.setZyq1("四区");
//
// ydjh.setKw(slKc.getSLDW());
// }
// if("11".equals(slKc.getSLDW())) {
// ydjh.setZyq("FP4Q");
// ydjh.setZyq1("四区");
// }
ydupList.add(ydjh);
}
if (StringUtils.isBlank(slKc.getYdid()) || StringUtils.isBlank(slKc.getDCTH())) {
@ -234,6 +199,7 @@ public class PgdSljhController {
ydjh.setZyq("FP3Q");
ydjh.setZyq1("三区");
}
ydAddList.add(ydjh);
dmYdjhService.save(ydjh);
}
}
@ -241,6 +207,11 @@ public class PgdSljhController {
dmYdjhService.updateBatchById(ydupList);
imCkwpkwpService.updateBatchByMultiId(ckupList);
//=================发布推送上料计划到料场的事件========================
ydAddList.addAll(ydupList);
SlPlanEvent slPlanEvent = new SlPlanEvent(this, list);
SpringContextHolder.pushEvent(slPlanEvent);
//================================================================
List<Dm_zhbmp> qgkws = dm_zhbmpRepository.findByBMLB("QGKW");
List<Dm_zhbmp> zylxs = dm_zhbmpRepository.findByBMLB("zylx");
@ -288,14 +259,12 @@ public class PgdSljhController {
}
return new ResultBean(slKcList);
}
@PostMapping("/slPrintD")
@ResponseBody
public ResultBean slPrintD(HttpServletRequest req, @RequestBody List<SlKc> list) throws Exception, CustomException {
@ -372,14 +341,12 @@ public class PgdSljhController {
}
return new ResultBean(slKcList);
}
@PostMapping("/slPrintqx")
@ResponseBody
public ResultBean slPrintqx(HttpServletRequest req, @RequestBody List<SlKc> list) throws Exception, CustomException {
@ -423,7 +390,6 @@ public class PgdSljhController {
imCkwpkwpService.updateBatchByMultiId(ckupList);
return new ResultBean();
}
@ -443,7 +409,6 @@ public class PgdSljhController {
// 库存标识 不等于 01 没有匹配上
if (map.get("rqopt").equals("01")) {
qw.ne("isnull(ZT,'')", "11");
} else if (map.get("rqopt").equals("02")) {
@ -460,7 +425,6 @@ public class PgdSljhController {
}
@PostMapping("/getKcAndSljh1")
@ResponseBody
public ResultBean getKcAndSljh1(HttpServletRequest req, @RequestBody Map map) throws Exception, CustomException {
@ -475,7 +439,6 @@ public class PgdSljhController {
// 库存标识 不等于 01 没有匹配上
if (map.get("rqopt").equals("01")) {
qw.eq("isnull(ZT,'')", "2").eq("isnull(slkcdw,'')", "");
} else if (map.get("rqopt").equals("02")) {
@ -594,9 +557,7 @@ public class PgdSljhController {
}
/**
*
* @param req
*
* @param req
* dm_ydjh
* dm_ydjh id dm_ydjh
* @return
@ -630,7 +591,6 @@ public class PgdSljhController {
imCkwpkwp.setYdid(slKc.getYdid());
if (StringUtils.isBlank(slKc.getYdid())) {
// 手工进行 批量了
String cjs = "";
@ -896,6 +856,7 @@ public class PgdSljhController {
}
return ""; // Return empty string if hyphen is not found
}
@PostMapping("kcAdnSlZx")
@ResponseBody
public ResultBean kcAdnSlZx(HttpServletRequest req, @RequestBody Map map) throws Exception, CustomException {
@ -968,7 +929,6 @@ public class PgdSljhController {
}
@PostMapping("/saveSljhPgdFk")
@ResponseBody
@AuthFunction
@ -986,7 +946,6 @@ public class PgdSljhController {
}
// @PostMapping("/getKcAndSljh")
// @ResponseBody
// @AuthFunction
@ -1107,8 +1066,6 @@ public class PgdSljhController {
*/
List<DmCbxxp> czList = dmCbxxpService.list();
List<DmYdjh> ydupList = new ArrayList<>();
List<SlKc> ckupList = new ArrayList<>();
@ -1157,7 +1114,6 @@ public class PgdSljhController {
// ckupList.add(imCkwpkwp);
slKc.setZYLX(getLx(dmYdjh.getLqlb(), dmYdjh.getZl(), dmYdjh.getTzbh()));
slKc.setZYCH(dmYdjh.getDcCh());
slKc.setZYPL(dmYdjh.getDcPl());
@ -1180,7 +1136,6 @@ public class PgdSljhController {
}
slKc.setDHH(dmYdjh.getSljhrq());
//slKc.setPwwz(dmYdjh.getKw());
slKc.setYdid(dmYdjh.getId());
@ -1197,7 +1152,6 @@ public class PgdSljhController {
}
@PostMapping("kcAdnSlBdQX")
@ResponseBody
@Transactional(rollbackFor = Exception.class)
@ -1277,7 +1231,6 @@ public class PgdSljhController {
}
}
int num = 1;
for (SlKc slKc : slKcs1) {
@ -1298,7 +1251,6 @@ public class PgdSljhController {
}
response.setContentType("application/vnd.ms-excel");
response.setCharacterEncoding("utf-8");
String fileName = "example.xlsx";

@ -0,0 +1,18 @@
package com.dsic.gj_erp.jiuzhou;
import com.dsic.gj_erp.bean.kc.SlKc;
import lombok.Getter;
import org.springframework.context.ApplicationEvent;
import java.util.List;
@Getter
public class SlPlanEvent extends ApplicationEvent {
private final List<SlKc> slKcList;
public SlPlanEvent(Object source,List<SlKc> slKcList) {
super(source);
this.slKcList=slKcList;
}
}

@ -1,30 +1,54 @@
package com.dsic.gj_erp.service.jiuzhou;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.dsic.gj_erp.bean.jhgk.DmYdjh;
import com.dsic.gj_erp.bean.jiuzhou.Sljh;
import com.dsic.gj_erp.jiuzhou.SlPlanEvent;
import com.dsic.gj_erp.jiuzhoumapper.SljhMapper;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.event.EventListener;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;
@Slf4j
//@Service
@Service
@RequiredArgsConstructor
public class SljhService extends ServiceImpl<SljhMapper, Sljh> {
@Value("${api-central.jiuzhou.sl-plan}")
String slPlanUrl;
private final RestTemplate restTemplate;
@Async
@EventListener
public void save(List<DmYdjh> slYdjh){
log.info("开始执行九州接口推送:{}",slYdjh);
List<Sljh> collect = slYdjh.stream().map(Sljh::ofWithYdjh).collect(Collectors.toList());
log.info("生成九州数据完成:{}",collect);
public void save(SlPlanEvent slYdjh){
log.info("开始执行九州接口推送");
List<Sljh> collect = slYdjh.getSlKcList().stream().map(Sljh::new).collect(Collectors.toList());
log.info("生成九州数据完成:{},开始推送",collect);
try {
this.saveBatch(collect);
HttpHeaders headers = new HttpHeaders();
headers.set("Content-Type", "application/json");
headers.set("Accept-Language", "zh-CHS");
headers.set("X-ECC-Current-Tenant", "10000");
headers.set("Authorization", "Bearer 10473672-12a5-2432-c1f1-1c865a814ece");
HttpEntity<List<Sljh>> entity = new HttpEntity<>(collect,headers);
restTemplate.exchange(slPlanUrl, HttpMethod.POST, entity, JSONObject.class);
}catch (Exception e){
e.printStackTrace();
log.error("推送失败",e);
return;
}
log.info("推送完成");
}

@ -51,5 +51,5 @@ spring.resources.static-locations=file:./static,file:D:/??????/static/upload/TWD
pdfUri=D:/javaweb/static/upload
api-central.jiuzhou.sl-plan=http://127.0.0.1:8182/jiuZhou/slPlan

@ -8,6 +8,7 @@
SELECT (IM_CKWPKWP.KWH) AS KWH ,
IM_CKWPKWP.SXRQ ,
MS_DDJBP1.dzwz,
MS_DDJBP1.GHSBM,
(IM_CKWPKWP.NBSBM) AS NBSBM ,
(IM_CKWPKWP.BSBS) AS BSBS ,
(IM_CKWPKWP.BSSCH) AS BSSCH ,
@ -66,11 +67,10 @@
IM_CKWPKWP.ydid,
'N' as bs,
'N' as bs_all
FROM IM_CKWPKWP
join DM_WPJBP on((IM_CKWPKWP.WPH) = (DM_WPJBP.WPH))
left join (select MS_DDJBP.dzwz,
MS_DDJBP.ddmc,MS_DDMXP.dc_ch
MS_DDJBP.ddmc,MS_DDMXP.dc_ch,MS_DDJBP.GHSBM
from MS_DDJBP,MS_DDMXP
where MS_DDJBP.CGFLM = MS_DDMXP.CGFLM and MS_DDJBP.DDH = MS_DDMXP.DDH
and MS_DDJBP.CGFLM = '01' and MS_DDJBP.DDLX = 'B') as MS_DDJBP1 on(IM_CKWPKWP.gcddh =MS_DDJBP1.dc_ch )

Loading…
Cancel
Save