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