|
@@ -1,5 +1,7 @@
|
|
|
package org.jeecg.modules.documents.orderData.controller;
|
|
|
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import io.swagger.annotations.Api;
|
|
@@ -10,16 +12,29 @@ import org.jeecg.common.aspect.annotation.AutoLog;
|
|
|
import org.jeecg.common.system.base.controller.JeecgController;
|
|
|
import org.jeecg.modules.documents.orderData.entity.SyOrderData;
|
|
|
import org.jeecg.modules.documents.orderData.entity.SyOrderDataItem;
|
|
|
+import org.jeecg.modules.documents.orderData.entity.SyOrderDataVO;
|
|
|
import org.jeecg.modules.documents.orderData.entity.SySOAndOM;
|
|
|
+import org.jeecg.modules.documents.orderData.mapper.SyOrderDataMapper;
|
|
|
import org.jeecg.modules.documents.orderData.service.ISyOrderDataItemService;
|
|
|
import org.jeecg.modules.documents.orderData.service.ISyOrderDataService;
|
|
|
import org.jeecg.modules.documents.orderData.service.ISySOAndOMService;
|
|
|
+import org.jeecg.modules.documents.orderData.service.impl.SyOrderDataItemServiceImpl;
|
|
|
+import org.jeecg.modules.openApi.entity.DxpDataPlan;
|
|
|
+import org.jeecg.modules.openApi.service.IDxpDataPlanService;
|
|
|
+import org.jeecg.modules.openApi.service.ISenYuDataSourceOne;
|
|
|
+import org.jeecg.modules.openApi.service.ISenYuDataSourceThree;
|
|
|
+import org.jeecg.modules.openApi.service.ISenYuDataSourceTwo;
|
|
|
+import org.jeecg.modules.system.util.JsonChangeUtils;
|
|
|
+import org.springframework.beans.BeansException;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.context.ApplicationContext;
|
|
|
+import org.springframework.context.ApplicationContextAware;
|
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
@@ -29,7 +44,7 @@ import java.util.Map;
|
|
|
@Api(tags="订单数据同步接口")
|
|
|
@RestController
|
|
|
@RequestMapping("/orderData/sySOAndOM")
|
|
|
-public class SySOAndOMController extends JeecgController<SySOAndOM, ISySOAndOMService> {
|
|
|
+public class SySOAndOMController extends JeecgController<SySOAndOM, ISySOAndOMService> implements ApplicationContextAware {
|
|
|
@Autowired
|
|
|
private ISySOAndOMService sySOAndOMService;
|
|
|
@Autowired
|
|
@@ -37,6 +52,12 @@ public class SySOAndOMController extends JeecgController<SySOAndOM, ISySOAndOMSe
|
|
|
@Autowired
|
|
|
private ISyOrderDataItemService syOrderDataItemService;
|
|
|
|
|
|
+ //数据源one
|
|
|
+ private static ISenYuDataSourceOne senYuDataSourceOne;
|
|
|
+ private static ISenYuDataSourceTwo senYuDataSourceTwo;
|
|
|
+ private static ISenYuDataSourceThree senYuDataSourceThree;
|
|
|
+ private static IDxpDataPlanService dxpDataPlanService;
|
|
|
+
|
|
|
@AutoLog(value = "订单数据同步接口-分页列表查询销售订单")
|
|
|
@ApiOperation(value="订单数据同步接口-分页列表查询销售订单", notes="订单数据同步接口-分页列表查询销售订单")
|
|
|
@RequestMapping(value = "/querySOList")
|
|
@@ -103,6 +124,32 @@ public class SySOAndOMController extends JeecgController<SySOAndOM, ISySOAndOMSe
|
|
|
syOrderDataService.save(syOrderData);
|
|
|
for (SySOAndOM sy:sySOAndOM) {
|
|
|
SyOrderDataItem syOrderDataItem = sySOAndOMService.queryOrderItemByCode(sy);
|
|
|
+ SyOrderDataVO ordervo = sySOAndOMService.queryOM(sy);
|
|
|
+ syOrderDataItem.setOmpoAccount(ordervo.getOmpoAccount());
|
|
|
+ syOrderDataItem.setOmpoCode(ordervo.getOmpoCode());
|
|
|
+ syOrderDataItem.setOmpoId(ordervo.getOmpoId());
|
|
|
+ syOrderDataItem.setDArriveDate(ordervo.getDArriveDate());
|
|
|
+ syOrderDataItem.setOmpoIdItem(ordervo.getOmpoIdItem());
|
|
|
+ syOrderDataItem.setITaxPrice(ordervo.getITaxPrice());
|
|
|
+ if(syOrderDataItem.getGuangpeiGateWidth()==null||syOrderDataItem.getGuangpeiGateWidth().equals("/")||
|
|
|
+ syOrderDataItem.getGuangpeiGateWidth().equals("")){
|
|
|
+ syOrderDataItem.setGuangpeiGateWidth(ordervo.getGuangpeiGateWidth());
|
|
|
+ }
|
|
|
+ syOrderDataItem.setSupplier(ordervo.getSupplier());
|
|
|
+ if(syOrderDataItem.getInventoryCcode().substring(0,2).equals("19")){
|
|
|
+ syOrderDataItem.setGarmentFactory(ordervo.getSupplier());
|
|
|
+ }else if(syOrderData.getCustomerAbbreviation().equals("International Apparel Group") || syOrderData.getCustomerAbbreviation().equals("宁波森语") ) {
|
|
|
+ syOrderDataItem.setGarmentFactory(queryGSupplier(syOrderData.getOrderNumber(),syOrderData.getAccount(),syOrderData.getCustomerCode()));
|
|
|
+ }else {
|
|
|
+ syOrderDataItem.setGarmentFactory(syOrderData.getGarmentFactory());
|
|
|
+ }
|
|
|
+ if(syOrderDataItem.getOmpoIdItem()!=null && sy.getAccount()!=null){
|
|
|
+ List<String> rsup = queryRSupplier(syOrderDataItem.getOmpoIdItem(),sy.getAccount());
|
|
|
+ if(rsup.size()>0){
|
|
|
+ syOrderDataItem.setRSupplierCode(rsup.get(0));
|
|
|
+ syOrderDataItem.setRSupplier(rsup.get(1));
|
|
|
+ }
|
|
|
+ }
|
|
|
syOrderDataItemService.save(syOrderDataItem);
|
|
|
}
|
|
|
//回写U8
|
|
@@ -110,4 +157,135 @@ public class SySOAndOMController extends JeecgController<SySOAndOM, ISySOAndOMSe
|
|
|
return Result.OK("同步成功!!!");
|
|
|
}
|
|
|
|
|
|
+ /*
|
|
|
+ * 查询成衣工厂 (面辅料供应商编码 面辅料供应商名称)
|
|
|
+ * */
|
|
|
+ public String queryGSupplier(String soCode,String zhangtao,String customerCode){
|
|
|
+ /*
|
|
|
+ 查询账套用于判断
|
|
|
+ */
|
|
|
+ QueryWrapper<DxpDataPlan> queryWrapper = new QueryWrapper<>();
|
|
|
+ queryWrapper.eq("code", "senYu_syOrder");
|
|
|
+ List<DxpDataPlan> pageList = dxpDataPlanService.list(queryWrapper);
|
|
|
+ String pkorg = pageList.get(0).getPkOrg();
|
|
|
+ String pkorgSplit[] = pkorg.split(",");
|
|
|
+ //定义账套集合
|
|
|
+ String account[] = new String[3];
|
|
|
+ int index = 0;
|
|
|
+ //得到对应的账套
|
|
|
+ for (String str : pkorgSplit) {
|
|
|
+ String pkorgValue[] = str.split(":");
|
|
|
+ account[index] = pkorgValue[1];
|
|
|
+ index++;
|
|
|
+ }
|
|
|
+
|
|
|
+ String resql = " select max(ss.cSOCode) as soCode from PO_Podetails t " +
|
|
|
+ " left join PO_Pomain m on m.poid=t.poid " +
|
|
|
+ " left join SO_SODetails s on s.isosid=t.iorderdid " +
|
|
|
+ " left join SO_SOMain ss on ss.id=s.id " +
|
|
|
+ " where m.cpoid = '"+soCode+"'";
|
|
|
+
|
|
|
+ List<Map<String, Object>> list = new ArrayList<>();
|
|
|
+ if(zhangtao.equals(account[2]) && customerCode.equals("T020001")){
|
|
|
+ list = senYuDataSourceThree.queryForList(resql);
|
|
|
+ List<JSONObject> jSONObject = JsonChangeUtils.toJSONObject(list);
|
|
|
+ if(jSONObject.size()>0){
|
|
|
+ for (JSONObject json:jSONObject) {
|
|
|
+ soCode = json.get("soCode").toString();
|
|
|
+ zhangtao = account[0];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ String sql = "SELECT max(v.cVenName) as cVenName from OM_MOMain m right join OM_MODetails t on m.moid = t.moid " +
|
|
|
+ " left join Vendor v on m.cVenCode=v.cVenCode " +
|
|
|
+ " where t.isosid=( select max(s.isosid) from PO_Podetails t " +
|
|
|
+ " left join PO_Pomain m on m.poid=t.poid " +
|
|
|
+ " left join SO_SODetails s on s.isosid=t.iorderdid " +
|
|
|
+ " where m.cpoid = '"+soCode+"') ";
|
|
|
+
|
|
|
+ if(zhangtao.equals(account[0])){
|
|
|
+ list = senYuDataSourceOne.queryForList(sql);
|
|
|
+ }
|
|
|
+ List<JSONObject> jSONObject = JsonChangeUtils.toJSONObject(list);
|
|
|
+ String result = "";
|
|
|
+ if(jSONObject.size()>0){
|
|
|
+ for (JSONObject json:jSONObject) {
|
|
|
+ result=json.get("cVenName").toString();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ /*
|
|
|
+ * 查询染厂供应商编码 供应商名称
|
|
|
+ * */
|
|
|
+ public List<String> queryRSupplier(String id,String zhangtao){
|
|
|
+ /*
|
|
|
+ 查询账套用于判断
|
|
|
+ */
|
|
|
+ QueryWrapper<DxpDataPlan> queryWrapper = new QueryWrapper<>();
|
|
|
+ queryWrapper.eq("code", "senYu_syOrder");
|
|
|
+ List<DxpDataPlan> pageList = dxpDataPlanService.list(queryWrapper);
|
|
|
+ String pkorg = pageList.get(0).getPkOrg();
|
|
|
+ String pkorgSplit[] = pkorg.split(",");
|
|
|
+ //定义账套集合
|
|
|
+ String account[] = new String[3];
|
|
|
+ int index = 0;
|
|
|
+ //得到对应的账套
|
|
|
+ for (String str : pkorgSplit) {
|
|
|
+ String pkorgValue[] = str.split(":");
|
|
|
+ account[index] = pkorgValue[1];
|
|
|
+ index++;
|
|
|
+ }
|
|
|
+
|
|
|
+ String sql = "select om.cVenCode as cVenCode,v.cVenName as cVenName From OM_MODetails o " +
|
|
|
+ "join ( " +
|
|
|
+ " select ommos.isosid,ommom.cInvCode from " +
|
|
|
+ " OM_MODetails ommos " +
|
|
|
+ "left join OM_MOMaterials ommom on ommom.MoDetailsID=ommos.MODetailsID " +
|
|
|
+ "where ommos.MODetailsID = '"+id+"' " +
|
|
|
+ ")tab on tab.isosid=o.isosid and tab.cInvCode =o.cInvCode " +
|
|
|
+ "left join OM_MOMain om on om.moid=o.moid " +
|
|
|
+ "LEFT JOIN Vendor v ON om.cVenCode=v.cVenCode " +
|
|
|
+ "union " +
|
|
|
+ "select om.cVenCode as cVenCode,v.cVenName as cVenName From PO_Podetails o " +
|
|
|
+ "join ( " +
|
|
|
+ " select ommos.isosid,ommom.cInvCode from " +
|
|
|
+ " OM_MODetails ommos " +
|
|
|
+ "left join OM_MOMaterials ommom on ommom.MoDetailsID=ommos.MODetailsID " +
|
|
|
+ "where ommos.MODetailsID = '"+id+"' " +
|
|
|
+ ")tab on tab.isosid=o.isosid and tab.cInvCode =o.cInvCode " +
|
|
|
+ "left join PO_Pomain om on om.POID=o.POID " +
|
|
|
+ "LEFT JOIN Vendor v ON om.cVenCode=v.cVenCode";
|
|
|
+
|
|
|
+ List<Map<String, Object>> list = new ArrayList<>();
|
|
|
+ if(zhangtao.equals(account[0])){
|
|
|
+ list = senYuDataSourceOne.queryForList(sql);
|
|
|
+ }else if(zhangtao.equals(account[1])){
|
|
|
+ list = senYuDataSourceTwo.queryForList(sql);
|
|
|
+ }else if(zhangtao.equals(account[2])){
|
|
|
+ list = senYuDataSourceThree.queryForList(sql);
|
|
|
+ }
|
|
|
+ List<JSONObject> jSONObject = JsonChangeUtils.toJSONObject(list);
|
|
|
+ List<String> result = new ArrayList<>();
|
|
|
+ if(jSONObject.size()>0){
|
|
|
+ for (JSONObject json:jSONObject) {
|
|
|
+ result.add(json.get("cVenCode").toString());
|
|
|
+ result.add(json.get("cVenName").toString());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
|
|
|
+
|
|
|
+ this.dxpDataPlanService = applicationContext.getBean(IDxpDataPlanService.class);
|
|
|
+ this.senYuDataSourceOne = applicationContext.getBean(ISenYuDataSourceOne.class);
|
|
|
+ this.senYuDataSourceTwo = applicationContext.getBean(ISenYuDataSourceTwo.class);
|
|
|
+ this.senYuDataSourceThree = applicationContext.getBean(ISenYuDataSourceThree.class);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
}
|