订单同步按钮

highway
zhaoxiaolin 1 year ago
parent 1ff37dc20e
commit 06d740e85d

@ -183,15 +183,15 @@ public class ProWetMaterialPlanController extends BaseController {
public AjaxResult remove(@PathVariable String[] ids) {
return toAjax(proWetMaterialPlanService.deleteProWetMaterialPlanByIds(ids));
}
/**
* 湿WCS
* @param
* @return
*/
@Log(title = "湿料计划同步", businessType = BusinessType.EXPORT)
@GetMapping("/syncWCS/{id}")
@RequiresPermissions("mes:plan:add")
public AjaxResult syncWCS(@PathVariable String id) {
return proWetMaterialPlanService.syncWCS(id);
}
// /**
// * 提交湿料计划同步WCS
// * @param
// * @return
// */
// @Log(title = "湿料计划同步", businessType = BusinessType.EXPORT)
// @GetMapping("/syncWCS/{id}")
// @RequiresPermissions("mes:plan:add")
// public AjaxResult syncWCS(@PathVariable String id) {
// return proWetMaterialPlanService.syncWCS(id);
// }
}

@ -126,5 +126,5 @@ public interface IProWetMaterialPlanService {
*/
AjaxResult checkChangePlan(String id);
AjaxResult syncWCS(@PathVariable String id);
// AjaxResult syncWCS(@PathVariable String id);
}

@ -14,6 +14,7 @@ import com.op.common.core.utils.DateUtils;
import com.op.common.core.utils.StringUtils;
import com.op.common.core.utils.uuid.IdUtils;
import com.op.common.core.web.domain.AjaxResult;
import com.op.common.security.utils.SecurityUtils;
import com.op.plan.domain.*;
import com.op.plan.domain.dto.ProOrderDTO;
import com.op.plan.domain.dto.SplitOrderDTO;
@ -241,10 +242,14 @@ public class ProOrderServiceImpl implements IProOrderService {
@Transactional(rollbackFor = Exception.class)
@DS("#header.poolName")
public AjaxResult syncSAP() {
SapProOrder sapqo = proOrderMapper.getMaxCreatetime();
if (sapqo == null) {
sapqo.setCreateTime(DateUtils.getNowDate());
}
SapProOrder sapqo = new SapProOrder();//proOrderMapper.getMaxCreatetime();
//if (sapqo == null) {
// sapqo.setCreateTime(DateUtils.getNowDate());
//}
Calendar calendar = Calendar.getInstance(); //创建Calendar 的实例
calendar.add(Calendar.DAY_OF_MONTH,-1); //当前时间减去一天,即一天前的时间
sapqo.setCreateTime(calendar.getTime());
//获取当前所选工厂
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
String key = "#header.poolName";
@ -261,24 +266,37 @@ public class ProOrderServiceImpl implements IProOrderService {
proOrder = new ProOrder();
BeanUtils.copyProperties(sapProOrder, proOrder);
//pro_order_workorder
List<ProOrderWorkorder> orderExit = proOrderWorkorderMapper.selectWorkOrderByOrderCode(proOrder.getOrderCode());
if (CollectionUtils.isEmpty(orderExit)) {//不存在就插入
Date nowDate = DateUtils.getNowDate();
ProOrder orderExit = proOrderMapper.selectProOrderByOrderCode(proOrder.getOrderCode());
if (orderExit==null) {//不存在就插入
proOrder.setId(IdUtils.fastSimpleUUID());
//proOrder.setCreateTime(nowDate);
proOrder.setCreateBy(SecurityUtils.getUsername());
proOrderMapper.insertProOrder(proOrder);
} else if ("w0".equals(orderExit.get(0).getStatus())) {
//如果工单没下达则更新pro_order
proOrderMapper.updateProOrder(proOrder);
List<ProOrder> orderCodes = this.getListByPCode(proOrder);
if (!CollectionUtils.isEmpty(orderCodes)) {
List<String> idstr = orderCodes.stream().map(order -> order.getId()).collect(Collectors.toList());
String[] ids = idstr.stream().toArray(String[]::new);
//删除工单pro_order_workorder
proOrderWorkorderMapper.deleteProOrderWorkorderByWorkorderIds(ids);
//删除批次pro_order_workorder_batch
proOrderWorkorderBatchMapper.deleteProOrderWorkorderBatchByWorkorderIds(ids);
} else {//存在,如果没下发,更新,否则不允许更新,关闭订单
proOrder.setId(orderExit.getId());
proOrder.setQuantitySplit(0L);
ProOrderWorkorder owork = new ProOrderWorkorder();
owork.setOrderCode(proOrder.getOrderCode());
owork.setStatus("w1");
List<ProOrderWorkorder> workOrders = proOrderWorkorderMapper.selectProOrderWorkorderList(owork);
if (CollectionUtils.isEmpty(workOrders)) {//更新
proOrder.setUpdateTime(nowDate);
proOrder.setUpdateBy(SecurityUtils.getUsername());
//如果工单没下达则更新pro_order
proOrderMapper.updateProOrder(proOrder);
List<ProOrder> orderCodes = this.getListByPCode(proOrder);
if (!CollectionUtils.isEmpty(orderCodes)) {
List<String> idstr = orderCodes.stream().map(order -> order.getId()).collect(Collectors.toList());
String[] ids = idstr.stream().toArray(String[]::new);
//删除工单pro_order_workorder
proOrderWorkorderMapper.deleteProOrderWorkorderByWorkorderIds(ids);
//删除批次pro_order_workorder_batch
proOrderWorkorderBatchMapper.deleteProOrderWorkorderBatchByWorkorderIds(ids);
}
} else {//关闭订单
//TODO;不更新
}
} else if ("w1".equals(orderExit.get(0).getStatus())) {
//TODO;不更新
}
}
return success();

@ -47,9 +47,9 @@ public class ProWetMaterialPlanServiceImpl implements IProWetMaterialPlanService
private ProOrderWorkorderMapper proOrderWorkorderMapper;
@Autowired
private ProWetMaterialPlanDetailMapper proWetMaterialPlanDetailMapper;
@Value("${wcs.url1}")
public String materialPlanSyncUrl;
//
// @Value("${wcs.url1}")
// public String materialPlanSyncUrl;
/**
* 湿
*
@ -307,65 +307,65 @@ public class ProWetMaterialPlanServiceImpl implements IProWetMaterialPlanService
* ]
* }
*/
@Override
@DS("#header.poolName")
@Transactional(rollbackFor = Exception.class)
public AjaxResult syncWCS(@PathVariable String id) {
//获取湿料计划
WCSDTO wcsdto = new WCSDTO();
wcsdto.setReqCode(id);//主计划id
wcsdto.setReqTime(DateUtils.getNowDate());
List<ProWetMaterialPlanDetail> planDetails = proWetMaterialPlanDetailMapper.selectDetailListById(id);
//罐
List<String> gList = planDetails.stream().map(ProWetMaterialPlanDetail::getBucketCode)
.distinct().collect(Collectors.toList());
//罐-料
Map<String, String> glMap = planDetails.stream()
.collect(Collectors.toMap(ProWetMaterialPlanDetail::getBucketCode,
ProWetMaterialPlanDetail::getMaterialCode, (k1, k2) -> k1));
List<WCSDataDTO> data = new ArrayList<>();
WCSDataDTO wCSDataDTO = null;
for (String g : gList) {
wCSDataDTO = new WCSDataDTO();
wCSDataDTO.setSku(glMap.get(g));//罐
wCSDataDTO.setLoadNo(g);//料
List<WCSDataItemsDTO> unLoadItems = new ArrayList<>();//上位机集合
//罐-工单
List<ProWetMaterialPlanDetail> ggList = planDetails.stream()
.filter(plan -> plan.getBucketCode().equals(g))
.collect(Collectors.toList());
WCSDataItemsDTO wCSDataItemsDTO = null;
for (ProWetMaterialPlanDetail gg : ggList) {
//根据工单查收坯机编码
String bucketCode = proOrderWorkorderMapper.getBucketCodeByWorkId(gg.getWorkorderId());
if (StringUtils.isNotBlank(bucketCode)) {
wCSDataItemsDTO = new WCSDataItemsDTO();
wCSDataItemsDTO.setUnloadNo(bucketCode);
unLoadItems.add(wCSDataItemsDTO);
}
}
wCSDataDTO.setUnLoadItems(unLoadItems);
}
wcsdto.setData(data);
try {
String sendResult = HttpUtils.sendPost(materialPlanSyncUrl, JSON.toJSONString(wcsdto));
WCSDTO resultdto = JSON.parseObject(sendResult, WCSDTO.class);
if ("1".equals(resultdto.getCode())) {
return error(resultdto.getMessage());
}
}catch (Exception e){
return error("调用接口异常");
}
ProWetMaterialPlan detail = new ProWetMaterialPlan();
detail.setId(id);
detail.setSyncFlag("Y");//已经同步的标识
proWetMaterialPlanMapper.updateProWetMaterialPlan(detail);
return success();
}
// @Override
// @DS("#header.poolName")
// @Transactional(rollbackFor = Exception.class)
// public AjaxResult syncWCS(@PathVariable String id) {
//
// //获取湿料计划
// WCSDTO wcsdto = new WCSDTO();
// wcsdto.setReqCode(id);//主计划id
// wcsdto.setReqTime(DateUtils.getNowDate());
// List<ProWetMaterialPlanDetail> planDetails = proWetMaterialPlanDetailMapper.selectDetailListById(id);
//
// //罐
// List<String> gList = planDetails.stream().map(ProWetMaterialPlanDetail::getBucketCode)
// .distinct().collect(Collectors.toList());
// //罐-料
// Map<String, String> glMap = planDetails.stream()
// .collect(Collectors.toMap(ProWetMaterialPlanDetail::getBucketCode,
// ProWetMaterialPlanDetail::getMaterialCode, (k1, k2) -> k1));
//
// List<WCSDataDTO> data = new ArrayList<>();
// WCSDataDTO wCSDataDTO = null;
// for (String g : gList) {
// wCSDataDTO = new WCSDataDTO();
// wCSDataDTO.setSku(glMap.get(g));//罐
// wCSDataDTO.setLoadNo(g);//料
// List<WCSDataItemsDTO> unLoadItems = new ArrayList<>();//上位机集合
// //罐-工单
// List<ProWetMaterialPlanDetail> ggList = planDetails.stream()
// .filter(plan -> plan.getBucketCode().equals(g))
// .collect(Collectors.toList());
// WCSDataItemsDTO wCSDataItemsDTO = null;
// for (ProWetMaterialPlanDetail gg : ggList) {
// //根据工单查收坯机编码
// String bucketCode = proOrderWorkorderMapper.getBucketCodeByWorkId(gg.getWorkorderId());
// if (StringUtils.isNotBlank(bucketCode)) {
// wCSDataItemsDTO = new WCSDataItemsDTO();
// wCSDataItemsDTO.setUnloadNo(bucketCode);
// unLoadItems.add(wCSDataItemsDTO);
// }
// }
// wCSDataDTO.setUnLoadItems(unLoadItems);
// }
// wcsdto.setData(data);
// try {
// String sendResult = HttpUtils.sendPost(materialPlanSyncUrl, JSON.toJSONString(wcsdto));
// WCSDTO resultdto = JSON.parseObject(sendResult, WCSDTO.class);
// if ("1".equals(resultdto.getCode())) {
// return error(resultdto.getMessage());
// }
// }catch (Exception e){
// return error("调用接口异常");
// }
//
// ProWetMaterialPlan detail = new ProWetMaterialPlan();
// detail.setId(id);
// detail.setSyncFlag("Y");//已经同步的标识
// proWetMaterialPlanMapper.updateProWetMaterialPlan(detail);
// return success();
// }
/**
* 湿

@ -132,9 +132,12 @@
<delete id="deleteProOrderWorkorderBatchByWorkorderIds" parameterType="String">
delete from pro_order_workorder_batch where workorder_id in
<foreach item="workorderId" collection="array" open="(" separator="," close=")">
#{workorderId}
</foreach>
(
select workorder_id from pro_order_workorder where order_id in
<foreach item="workorderId" collection="array" open="(" separator="," close=")">
#{workorderId}
</foreach>
)
</delete>
</mapper>

@ -384,7 +384,7 @@
</delete>
<delete id="deleteProOrderWorkorderByWorkorderIds" parameterType="String">
delete from pro_order_workorder where workorder_id in
delete from pro_order_workorder where order_id in
<foreach item="workorderId" collection="array" open="(" separator="," close=")">
#{workorderId}
</foreach>

@ -40,7 +40,7 @@ public class SapOrderServiceImpl implements SapOrderService {
JCoTable maraTable = func.getTableParameterList().getTable("ZMES_PRO");
JCoRecordMetaData metaData = maraTable.getRecordMetaData();
System.out.println("###" + metaData.toString());
SapProOrder proOrder = new SapProOrder();
List<SapProOrder> proOrderList = new ArrayList<>();
// 循环输出 Table 数据
for (int i = 0; i < maraTable.getNumRows(); i++) {
@ -62,6 +62,7 @@ public class SapOrderServiceImpl implements SapOrderService {
System.out.println("订单号:" + AUFNR + " - 订单类型:" + AUART + " - 上级订单编号:" + MAUFNR + " - 物料号:" + PLNBEZ + " - 物料描述(短文本):" + MAKTX
+ " - 订单的计划工厂:" + PWERK + " - 订单数量总计:" + GAMNG + " - 基本计量单位:" + GMEIN + " - 任务清单组码:" + PLNNR + " - 基本开始日期:" + GSTRP
+ " - 基本完成日期:" + GLTRP + " - 输入者:" + ERNAM + " - 创建日期:" + ERDAT + " - 系统状态:" + STTXT);
SapProOrder proOrder = new SapProOrder();
proOrder.setId(IdUtils.fastSimpleUUID());
proOrder.setPlanFactoryCode(PWERK);
proOrder.setOrderCode(AUFNR);
@ -78,7 +79,7 @@ public class SapOrderServiceImpl implements SapOrderService {
proOrder.setCreateTime(DateUtils.dateTime("yyyy-MM-dd", ERDAT));
proOrder.setUpdateBy(ERNAM);
proOrder.setUpdateTime(DateUtils.dateTime("yyyy-MM-dd", ERDAT));
proOrder.setStatus("0");
proOrder.setStatus("o0");
proOrderList.add(proOrder);
// remotePlanService.sapAddOrder(proOrder);
// remoteMesService.sapAddOrder(proOrder);

Loading…
Cancel
Save