|
|
@ -1,12 +1,17 @@ |
|
|
|
package com.win.web.controller.base; |
|
|
|
|
|
|
|
import com.alibaba.fastjson2.JSONObject; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
import com.jcraft.jsch.JSchException; |
|
|
|
import com.win.common.annotation.Log; |
|
|
|
import com.win.common.constant.HttpStatus; |
|
|
|
import com.win.common.core.domain.AjaxResult; |
|
|
|
import com.win.common.enums.BusinessType; |
|
|
|
import com.win.common.utils.ProfileUtil; |
|
|
|
import com.win.system.domain.LinuxAccess; |
|
|
|
import com.win.system.domain.QadAccess; |
|
|
|
import com.win.system.service.LinuxAccessService; |
|
|
|
import com.win.system.service.QadAccessService; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
import org.slf4j.Logger; |
|
|
@ -20,8 +25,6 @@ import org.springframework.web.bind.annotation.RestController; |
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest; |
|
|
|
import java.io.IOException; |
|
|
|
import java.lang.reflect.InvocationTargetException; |
|
|
|
import java.lang.reflect.Method; |
|
|
|
import java.util.List; |
|
|
|
|
|
|
|
@Slf4j |
|
|
@ -33,6 +36,8 @@ public class ShellController { |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private LinuxAccessService linuxAccessService; |
|
|
|
@Autowired |
|
|
|
private QadAccessService qadAccessService; |
|
|
|
|
|
|
|
/** |
|
|
|
* 对外提供一个接口,通过header中的interfaceName反射机制调用方法,方法必须写到这个controller中,并且不用加PostMapping注解。 |
|
|
@ -43,7 +48,7 @@ public class ShellController { |
|
|
|
*/ |
|
|
|
@PostMapping("/api") |
|
|
|
@Log(title = "远程行对接qad", businessType = BusinessType.INSERT, isManager = false) |
|
|
|
public AjaxResult api(HttpServletRequest request, @RequestBody String body) throws NoSuchMethodException, InvocationTargetException, IllegalAccessException { |
|
|
|
public AjaxResult api(HttpServletRequest request, @RequestBody String body) throws IOException, JSchException { |
|
|
|
String interfaceName = request.getHeader("interface"); |
|
|
|
String sign = request.getHeader("sign"); |
|
|
|
String timeStr = request.getHeader("timestamp"); |
|
|
@ -69,108 +74,43 @@ public class ShellController { |
|
|
|
if(/*!activeProfile.contains("dev") && */!StringUtils.equals(sign, computeSign)) { |
|
|
|
return AjaxResult.error(HttpStatus.SIGN_ERROR, "签名不正确"); |
|
|
|
} |
|
|
|
Method method = this.getClass().getMethod(interfaceName, String.class); |
|
|
|
return (AjaxResult) method.invoke(this, body); |
|
|
|
} |
|
|
|
|
|
|
|
public AjaxResult poreceipt(String body) throws JSchException, IOException { |
|
|
|
return linuxAccessService.executeShell(body, "purchaseorder/poreceipt/", "dsPoreceiver"); |
|
|
|
} |
|
|
|
|
|
|
|
public AjaxResult projectdetail(String body) throws JSchException, IOException { |
|
|
|
return linuxAccessService.executeShell(body, "project/projectdetail/", "dsSearchCondition"); |
|
|
|
} |
|
|
|
|
|
|
|
public AjaxResult itemmaster(String body) throws JSchException, IOException { |
|
|
|
return linuxAccessService.executeShell(body, "items/itemmaster/", "dsItemmaster"); |
|
|
|
} |
|
|
|
|
|
|
|
public AjaxResult inventorydetail(String body) throws JSchException, IOException { |
|
|
|
return linuxAccessService.executeShell(body, "inventory/inventorydetail/", "dsSearchCondition"); |
|
|
|
} |
|
|
|
|
|
|
|
public AjaxResult podetexport(String body) throws JSchException, IOException { |
|
|
|
return linuxAccessService.executeShell(body, "puchaseorder/podetexport/", "dsSearchCondition"); |
|
|
|
} |
|
|
|
|
|
|
|
public AjaxResult exportsupplier(String body) throws JSchException, IOException { |
|
|
|
return linuxAccessService.executeShell(body, "supplier/exportsupplier/", "dsSearchCondition"); |
|
|
|
} |
|
|
|
|
|
|
|
public AjaxResult discretepo(String body) throws JSchException, IOException { |
|
|
|
return linuxAccessService.executeShell(body, "purchaseorder/discretepo/", "dsDescreteOrder"); |
|
|
|
} |
|
|
|
|
|
|
|
public AjaxResult custrequiredschedule(String body) throws JSchException, IOException { |
|
|
|
return linuxAccessService.executeShell(body, "customer/custrequiredschedule/", "dsSearchCondition"); |
|
|
|
} |
|
|
|
|
|
|
|
public AjaxResult qadgrirexport(String body) throws JSchException, IOException { |
|
|
|
return linuxAccessService.executeShell(body, "qadgrir/qadgrirexport/", "dsSearchCondition"); |
|
|
|
} |
|
|
|
|
|
|
|
public AjaxResult Unplannedissue(String body) throws JSchException, IOException { |
|
|
|
return linuxAccessService.executeShell(body, "transactions/Unplannedissue/", "dsUnplanISRC"); |
|
|
|
} |
|
|
|
|
|
|
|
public AjaxResult supplierschedule(String body) throws JSchException, IOException { |
|
|
|
return linuxAccessService.executeShell(body, "supplier/supplierschedule/", "dsSearchCondition"); |
|
|
|
} |
|
|
|
|
|
|
|
public AjaxResult bommastr(String body) throws JSchException, IOException { |
|
|
|
return linuxAccessService.executeShell(body, "bom/bommastr/", "dsBommaster"); |
|
|
|
} |
|
|
|
|
|
|
|
public AjaxResult backflush(String body) throws JSchException, IOException { |
|
|
|
return linuxAccessService.executeShell(body, "workorder/backflush/", "dsBackflushMaster"); |
|
|
|
} |
|
|
|
|
|
|
|
public AjaxResult supplierasn(String body) throws JSchException, IOException { |
|
|
|
return linuxAccessService.executeShell(body, "supplier/supplierasn/", "dsttsupplierasn"); |
|
|
|
} |
|
|
|
|
|
|
|
public AjaxResult supplierinvoicebalance(String body) throws JSchException, IOException { |
|
|
|
return linuxAccessService.executeShell(body, "supplier/supplierinvoicebalance/", "dsSearchCondition"); |
|
|
|
} |
|
|
|
|
|
|
|
public AjaxResult createsupplierinvoice(String body) throws JSchException, IOException { |
|
|
|
return linuxAccessService.executeShell(body, "supplierinvoice/createsupplierinvoice/", "dsSupplierInvoice"); |
|
|
|
} |
|
|
|
|
|
|
|
public AjaxResult loadbommstr(String body) throws JSchException, IOException { |
|
|
|
return linuxAccessService.executeShell(body, "bommstr/loadbommstr/", "dsBommaster"); |
|
|
|
} |
|
|
|
|
|
|
|
public AjaxResult costcenterdetail(String body) throws JSchException, IOException { |
|
|
|
return linuxAccessService.executeShell(body, "costcenter/costcenterdetail/", "dsSearchCondition"); |
|
|
|
} |
|
|
|
|
|
|
|
public AjaxResult salesorderexport(String body) throws JSchException, IOException { |
|
|
|
return linuxAccessService.executeShell(body, "salesorder/salesorderexport/", "dsSearchCondition"); |
|
|
|
} |
|
|
|
|
|
|
|
public AjaxResult costdetail(String body) throws JSchException, IOException { |
|
|
|
return linuxAccessService.executeShell(body, "cost/costdetail/", "dsSearchCondition"); |
|
|
|
} |
|
|
|
|
|
|
|
public AjaxResult exportcustomer(String body) throws JSchException, IOException { |
|
|
|
return linuxAccessService.executeShell(body, "customer/exportcustomer/", "dsSearchCondition"); |
|
|
|
} |
|
|
|
|
|
|
|
public AjaxResult routingdetail(String body) throws JSchException, IOException { |
|
|
|
return linuxAccessService.executeShell(body, "routing/routingdetail/", "dsRouting"); |
|
|
|
} |
|
|
|
|
|
|
|
public AjaxResult productionschedule(String body) throws JSchException, IOException { |
|
|
|
return linuxAccessService.executeShell(body, "production/productionschedule/", "dsSearchCondition"); |
|
|
|
} |
|
|
|
|
|
|
|
public AjaxResult intransfer(String body) throws JSchException, IOException { |
|
|
|
return linuxAccessService.executeShell(body, "transactions/intransfer/", "dsinvtransfer"); |
|
|
|
} |
|
|
|
|
|
|
|
public AjaxResult loadbommastr(String body) throws JSchException, IOException { |
|
|
|
return linuxAccessService.executeShell(body, "bom/loadbommastr/", "dsBommaster"); |
|
|
|
JSONObject jsonObject = JSONObject.parseObject(body); |
|
|
|
String key = ""; |
|
|
|
for(String keyTemp : jsonObject.keySet()) { |
|
|
|
jsonObject = JSONObject.parseObject(jsonObject.getString(keyTemp)); |
|
|
|
key = keyTemp; |
|
|
|
} |
|
|
|
String domain = jsonObject.getString("domain"); |
|
|
|
if(domain == null || domain.isEmpty()) { |
|
|
|
return AjaxResult.error(HttpStatus.DOMAIN_ERROR, "域不能为空"); |
|
|
|
} |
|
|
|
String companyCode = jsonObject.getString("company_code"); |
|
|
|
if(companyCode == null || companyCode.isEmpty()) { |
|
|
|
return AjaxResult.error(HttpStatus.COMPANY_CODE_ERROR, "公司编码不能为空"); |
|
|
|
} |
|
|
|
QueryWrapper<LinuxAccess> linuxAccessQueryWrapper = new QueryWrapper<>(); |
|
|
|
linuxAccessQueryWrapper.eq("company_code", companyCode); |
|
|
|
linuxAccessQueryWrapper.eq("uri", interfaceName); |
|
|
|
LinuxAccess linuxAccess = linuxAccessService.getOne(linuxAccessQueryWrapper); |
|
|
|
if(linuxAccess == null) { |
|
|
|
return AjaxResult.error(HttpStatus.LINUX_ACCESS_ERROR, "linux访问控制不存在"); |
|
|
|
} |
|
|
|
QueryWrapper<QadAccess> qadAccessQueryWrapper = new QueryWrapper<>(); |
|
|
|
qadAccessQueryWrapper.eq("company_code", companyCode); |
|
|
|
qadAccessQueryWrapper.eq("domain", domain); |
|
|
|
QadAccess qadAccess = qadAccessService.getOne(qadAccessQueryWrapper); |
|
|
|
if(qadAccess == null) { |
|
|
|
return AjaxResult.error(HttpStatus.QAD_ACCESS_ERROR, "QAD_ACCESS_ERROR"); |
|
|
|
} |
|
|
|
//生成traceid
|
|
|
|
String traceid = jsonObject.getString("traceid"); |
|
|
|
jsonObject.remove("traceid"); |
|
|
|
jsonObject.remove("dataid"); |
|
|
|
jsonObject.remove("company_code"); |
|
|
|
jsonObject.remove("domain"); |
|
|
|
String inJson = "{\"" + key + "\":"+ jsonObject+"}"; |
|
|
|
log.info("inJson: {}", inJson); |
|
|
|
return linuxAccessService.executeShell(linuxAccess, qadAccess, traceid, inJson, domain); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|