Browse Source

PDA材料出库单

wanfa99 2 năm trước cách đây
mục cha
commit
0978c92178

+ 100 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/openApi/controller/PDARdrecord11Controller.java

@@ -0,0 +1,100 @@
+package org.jeecg.modules.openApi.controller;
+
+import io.swagger.annotations.Api;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang.StringUtils;
+import org.jeecg.common.system.base.controller.JeecgController;
+import org.jeecg.common.util.oConvertUtils;
+import org.jeecg.modules.openApi.entity.ResHttpStatus;
+import org.jeecg.modules.openApi.entity.SubcontractingOrder;
+import org.jeecg.modules.openApi.service.*;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.ResponseBody;
+import org.springframework.web.bind.annotation.RestController;
+
+import javax.servlet.http.HttpServletRequest;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @Description: PDA材料出库单
+ * @Author: jeecg-boot
+ * @Date:   2022-04-28
+ * @Version: V1.0
+ */
+@Slf4j
+@Api(tags="PDA材料出库单")
+@RestController
+@RequestMapping("/openApi/PDARdrecord")
+public class PDARdrecord11Controller extends JeecgController<SubcontractingOrder, SubcontractingOrderService> {
+    @Autowired
+    private IRdrecord11Service rdrecord11Service;
+
+
+    /***
+     * 条件查询材料出库单
+     * @param org
+     * @param cCode
+     * @return
+     */
+    @RequestMapping(value = "/getRdrecord",method = RequestMethod.GET)
+    @ResponseBody
+    public ResponseEntity<ResHttpStatus> getRdrecord(String org,String cCode) {
+        ResHttpStatus res = new ResHttpStatus();
+        res.setCode("0");
+        res.setSuccess(false);
+        if(oConvertUtils.isEmpty(org)){
+            res.setMsg("账套号不能为空");
+            return new ResponseEntity<>(res, HttpStatus.OK);
+        }
+       if(oConvertUtils.isEmpty(cCode)){
+            res.setMsg("单据号不能为空");
+            return new ResponseEntity<>(res, HttpStatus.OK);
+        }
+        try {
+            res.setData(rdrecord11Service.getRdrecord(org,cCode));
+            res.setCode("200");
+            res.setMsg("成功");
+            res.setSuccess(true);
+        }catch (Exception e) {
+            res.setMsg("数据获取失败:" + e.getMessage());
+            e.printStackTrace();
+        }
+        return new ResponseEntity<>(res, HttpStatus.OK);
+    }
+    /***
+     * 条件查询材料出库单并打印生成二维码
+     * @param org
+     * @param cCode
+     * @return
+     */
+    @RequestMapping(value = "/getRdrecordToPrint",method = RequestMethod.GET)
+    @ResponseBody
+    public ResponseEntity<ResHttpStatus> getRdrecordToPrint(String org,String cCode) {
+        ResHttpStatus res = new ResHttpStatus();
+        res.setCode("0");
+        res.setSuccess(false);
+        if(oConvertUtils.isEmpty(org)){
+            res.setMsg("账套号不能为空");
+            return new ResponseEntity<>(res, HttpStatus.OK);
+        }
+        if(oConvertUtils.isEmpty(cCode)){
+            res.setMsg("单据号不能为空");
+            return new ResponseEntity<>(res, HttpStatus.OK);
+        }
+        try {
+            res.setData(rdrecord11Service.getRdrecordToPrint(org,cCode));
+            res.setCode("200");
+            res.setMsg("成功");
+            res.setSuccess(true);
+        }catch (Exception e) {
+            res.setMsg("数据获取失败:" + e.getMessage());
+            e.printStackTrace();
+        }
+        return new ResponseEntity<>(res, HttpStatus.OK);
+    }
+}

+ 14 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/openApi/service/IRdrecord11Service.java

@@ -0,0 +1,14 @@
+package org.jeecg.modules.openApi.service;
+
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import org.jeecg.modules.openApi.entity.SubcontractingOrder;
+
+import java.util.List;
+
+public interface IRdrecord11Service {
+
+    public JSONObject getRdrecord(String org,String cCode) throws Exception;//条件查询材料出库单
+
+    public JSONObject getRdrecordToPrint(String org,String cCode) throws Exception;//条件查询材料出库单并打印生成二维码
+}

+ 74 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/openApi/service/impl/Rdrecord11ServiceImpl.java

@@ -0,0 +1,74 @@
+package org.jeecg.modules.openApi.service.impl;
+
+import com.alibaba.fastjson.JSONObject;
+import org.jeecg.modules.openApi.service.IRdrecord11Service;
+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.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+import java.util.Map;
+
+@Service
+public class Rdrecord11ServiceImpl  implements IRdrecord11Service {
+
+    @Autowired
+    private ISenYuDataSourceOne senYuDataSourceOne;
+    @Autowired
+    private ISenYuDataSourceTwo senYuDataSourceTwo;
+    @Autowired
+    private ISenYuDataSourceThree senYuDataSourceThree;
+
+    @Override
+    public JSONObject getRdrecord(String org, String cCode) throws Exception{
+        JSONObject resultJson=new JSONObject();
+        //主表查询SQl
+        String hsql="select *  From rdrecord11 where cCode='"+cCode+"'";
+        //子表查询SQl
+        String bsql="select a.* From rdrecords11 a,rdrecord11 b where  a.id=b.id and b.cCode='"+cCode+"'";
+        if(org.equals("101")){
+            List<Map<String, Object>> hresult = senYuDataSourceOne.queryForList(hsql);
+            List<Map<String, Object>> bresult = senYuDataSourceOne.queryForList(bsql);
+            if(hresult.size()!=1||bresult.size()==0){
+                throw  new Exception(cCode+"单号查询有误,请确认数据!");
+            }
+            resultJson=JsonChangeUtils.toJSONObject(hresult).get(0);
+            resultJson.put("b",JsonChangeUtils.toJSONObject(bresult));
+        }else if(org.equals("102")){
+
+        }else if(org.equals("103")){
+
+        }else{
+            throw  new Exception(org+"该账套号不存在!");
+        }
+        return resultJson;
+    }
+
+    @Override
+    public JSONObject getRdrecordToPrint(String org, String cCode) throws Exception {
+        JSONObject resultJson=new JSONObject();
+        //查询SQl
+        String sql="select a.csysbarcode as '缸单条码(单据条码)',c.cCusCode as '客户',b.cBatch as '缸号' ,a.cVenCode as '供应商', " +
+                "'染厂色号',d.cVenCode  as '委外供应商',b.iQuantity   as '数量',b.csocode as '上游订单号',b.irowno   as '匹数(行号)', " +
+                "b.comcode as '委外订单号',b.cInvCode as '存货名称',a.cCode  as '材料出库单号','描述'  From rdrecord11 a left join  rdrecords11 b " +
+                "on a.id=b.id left join SO_SOMain c on  b.csocode=c.csocode left join OM_MOMain d on b.comcode=d.cCode " +
+                "where  a.cCode='"+cCode+"'";
+        if(org.equals("101")){
+            List<Map<String, Object>> result = senYuDataSourceOne.queryForList(sql);
+            if(result.size()==0){
+                throw  new Exception(cCode+"单号查询有误,请确认数据!");
+            }
+            resultJson.put("b",JsonChangeUtils.toJSONObject(result));
+        }else if(org.equals("102")){
+
+        }else if(org.equals("103")){
+
+        }else{
+            throw  new Exception(org+"该账套号不存在!");
+        }
+        return resultJson;
+    }
+}

+ 23 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/util/JsonChangeUtils.java

@@ -32,6 +32,29 @@ public class JsonChangeUtils implements ApplicationContextAware{
 
     private static ISenYuDataSourceThree iSenYuDataSourceThree;
 
+    /**
+     * 原始通用转JSON方法
+     * @param result
+     * @return
+     */
+    public static List<JSONObject> toJSONObject (List<Map<String, Object>> result){
+        List<JSONObject> pljf = new ArrayList<JSONObject>();// 表数据json集合
+        JSONObject jf = new JSONObject();
+        for (int i = 0; i < result.size(); i++) {
+            Map<String, Object> map = result.get(i);
+            Set<String> keys = map.keySet();
+            jf = new JSONObject();
+            for (String key : keys) {
+                if(null==map.get(key)){
+                    jf.put(key, "");
+                }else{
+                    jf.put(key, map.get(key));
+                }
+            }
+            pljf.add(jf);
+        }
+        return pljf;
+    }
 
 
     /**