|
|
|
@ -32,6 +32,7 @@ import com.op.system.api.RemoteSapService;
|
|
|
|
|
import com.op.system.api.RemoteUserService;
|
|
|
|
|
import com.op.system.api.domain.SysSapLog;
|
|
|
|
|
import com.op.system.api.domain.SysUser;
|
|
|
|
|
import com.op.system.api.domain.sap.SapCloseOrderQuery;
|
|
|
|
|
import com.op.system.api.domain.sap.SapShopOrderQuery;
|
|
|
|
|
import com.op.system.api.model.SapProOrder;
|
|
|
|
|
import org.apache.commons.lang3.time.DateFormatUtils;
|
|
|
|
@ -1084,6 +1085,87 @@ public class ProOrderServiceImpl implements IProOrderService {
|
|
|
|
|
}
|
|
|
|
|
return success();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
@DS("#header.poolName")
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
|
|
public int deleteOrder(String[] orderIds) {
|
|
|
|
|
//可以进行订单关闭的数据
|
|
|
|
|
List<ProOrderWorkorder> checkWorkOrders = proOrderWorkorderMapper.getWorkOrderByOrders(orderIds);
|
|
|
|
|
if(checkWorkOrders.size() != orderIds.length){
|
|
|
|
|
return 2;
|
|
|
|
|
}
|
|
|
|
|
for(ProOrderWorkorder workorder:checkWorkOrders){
|
|
|
|
|
//要删除的工单id们
|
|
|
|
|
List<String> delteIds = new ArrayList<>();
|
|
|
|
|
delteIds.add(workorder.getWorkorderId());
|
|
|
|
|
//关闭订单用
|
|
|
|
|
List<String> ordercodes = new ArrayList<>();
|
|
|
|
|
ordercodes.add(workorder.getWorkorderCodeSap());
|
|
|
|
|
//删领料单用
|
|
|
|
|
List<String> workorderCodes = new ArrayList<>();
|
|
|
|
|
workorderCodes.add(workorder.getWorkorderCode());
|
|
|
|
|
//删除订单
|
|
|
|
|
List<ProOrderWorkorder> workers = new ArrayList<>();
|
|
|
|
|
workers.add(workorder);
|
|
|
|
|
ProOrderWorkorder topWork = workorder;
|
|
|
|
|
Boolean run = true;
|
|
|
|
|
while (run) {
|
|
|
|
|
//下级
|
|
|
|
|
ProOrderWorkorder sonWorkers = proOrderWorkorderMapper.selectSonWorkOrder(topWork.getWorkorderCode());
|
|
|
|
|
//有上级code
|
|
|
|
|
if (sonWorkers != null) {
|
|
|
|
|
workers.add(sonWorkers);
|
|
|
|
|
delteIds.add(sonWorkers.getWorkorderId());
|
|
|
|
|
ordercodes.add(sonWorkers.getWorkorderCodeSap());
|
|
|
|
|
workorderCodes.add(sonWorkers.getWorkorderCode());
|
|
|
|
|
topWork.setWorkorderCode(sonWorkers.getWorkorderCode());
|
|
|
|
|
} else {
|
|
|
|
|
run = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//调用sap订单关闭接口
|
|
|
|
|
//关闭母子订单//订单的订单编码(关闭订单暂时隐藏)
|
|
|
|
|
SapCloseOrderQuery sapCloseOrderQuery = new SapCloseOrderQuery();
|
|
|
|
|
sapCloseOrderQuery.setOrderCodes(ordercodes);
|
|
|
|
|
R closeR= remoteSapService.sapCloseOrder(sapCloseOrderQuery);
|
|
|
|
|
logger.info(workorderCodes.get(0)+"删除订单后关闭订单"+
|
|
|
|
|
JSONObject.toJSONString(sapCloseOrderQuery)+
|
|
|
|
|
closeR.getCode()+","+
|
|
|
|
|
closeR.getMsg()+","+
|
|
|
|
|
closeR.getData());
|
|
|
|
|
//if(closeR.getCode()==200){
|
|
|
|
|
String[] workorderIds = (String[]) delteIds.toArray(new String[delteIds.size()]);
|
|
|
|
|
if (workorderIds.length > 0) {
|
|
|
|
|
//删除工单(字母)pro_order_workorder
|
|
|
|
|
int m1 = proOrderWorkorderMapper.deleteProOrderWorkorderByWorkorderIds(workorderIds);
|
|
|
|
|
logger.info(workorderCodes.get(0)+"删除订单m1:"+m1);
|
|
|
|
|
//删除批次pro_order_workorder_batch
|
|
|
|
|
int m2 = proOrderWorkorderBatchMapper.deleteBatch(workorderIds);
|
|
|
|
|
logger.info(workorderCodes.get(0)+"删除订单m2:"+m2);
|
|
|
|
|
//删除领料单mes_prepare
|
|
|
|
|
int m3 = proOrderWorkorderMapper.deletePrepareBatch(workorderCodes);
|
|
|
|
|
logger.info(workorderCodes.get(0)+"删除订单m3:"+m3);
|
|
|
|
|
//删除领料单明细mes_prepare_detail
|
|
|
|
|
int m4 = proOrderWorkorderMapper.deletePrepareDetailBatch(workorderCodes);
|
|
|
|
|
logger.info(workorderCodes.get(0)+"删除订单m4:"+m4);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!CollectionUtils.isEmpty(workers)) {
|
|
|
|
|
//删除订单pro_order
|
|
|
|
|
int m5 = proOrderMapper.updateCloseOrderBatch(workers);
|
|
|
|
|
logger.info(workorderCodes.get(0)+"删除订单m5:"+m5);
|
|
|
|
|
}
|
|
|
|
|
// }else{
|
|
|
|
|
// logger.info(workorder.getWorkorderCode()+"删除订单后关闭订单sap返回结果:"+
|
|
|
|
|
// JSONObject.toJSONString(closeR));
|
|
|
|
|
// return 0;
|
|
|
|
|
// }
|
|
|
|
|
}
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void main(String args[]){
|
|
|
|
|
String arrayStr = "[[\"GX01\",\"LG1\"],[\"GX01\",\"LG2\"],[\"GX02\",\"S1\"],[\"GX02\",\"S2\"],[\"GX03\",\"HF01\"],[\"GX04\",\"SPJ01\"]]";
|
|
|
|
|
JSONArray jsonArray = JSONArray.parseArray(arrayStr);
|
|
|
|
|