订单同步按钮

highway
zhaoxiaolin 2 years ago
parent 1ff37dc20e
commit 06d740e85d

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

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

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

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

@ -384,7 +384,7 @@
</delete> </delete>
<delete id="deleteProOrderWorkorderByWorkorderIds" parameterType="String"> <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=")"> <foreach item="workorderId" collection="array" open="(" separator="," close=")">
#{workorderId} #{workorderId}
</foreach> </foreach>

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

Loading…
Cancel
Save