zhangyuewww 2 years ago
parent
commit
7dbb48a7d0

+ 15 - 0
winsea-haixin-plugin-yiliangyiyun/src/main/java/com/yh/saas/plugin/yiliangyiyun/controller/ContractManagementInfoController.java

@@ -183,5 +183,20 @@ public class ContractManagementInfoController {
     public ContractManagementInfo selectContractChart(ContractManagementInfo contractManagementInfo) {
         return contractManagementInfoService.selectContractChart(contractManagementInfo);
     }
+    /**
+     * 出库根据合同号查信息
+     */
+    @GetMapping("/getOutContract")
+    public ContractManagementInfo getOutContract(@RequestParam String contractNo,String compId) {
+        return contractManagementInfoService.getOutContract(contractNo,compId);
+    }
+    /**
+     * 入库根据合同号查信息
+     */
+    @GetMapping("/getInContract")
+    public ContractManagementInfo getInContract(@RequestParam String contractNo,String compId) {
+        return contractManagementInfoService.getInContract(contractNo,compId);
     }
 
+}
+

+ 12 - 0
winsea-haixin-plugin-yiliangyiyun/src/main/java/com/yh/saas/plugin/yiliangyiyun/service/IContractManagementInfoService.java

@@ -136,4 +136,16 @@ public interface IContractManagementInfoService extends IService<ContractManagem
      * @param contractManagementInfo
      */
     List<ContractManagementInfo> selectRelationContract(ContractManagementInfo contractManagementInfo);
+    /**
+     * 出库根据合同号查信息
+     *
+     * @param contractNo,compId
+     */
+    ContractManagementInfo getOutContract(String contractNo,String compId);
+    /**
+     * 入库根据合同号查信息
+     *
+     * @param contractNo,compId
+     */
+    ContractManagementInfo getInContract(String contractNo,String compId);
 }

+ 288 - 0
winsea-haixin-plugin-yiliangyiyun/src/main/java/com/yh/saas/plugin/yiliangyiyun/service/impl/ContractManagementInfoServiceImpl.java

@@ -32,6 +32,7 @@ import org.apache.poi.hssf.usermodel.*;
 import org.apache.poi.ss.usermodel.IndexedColors;
 import org.apache.poi.ss.usermodel.Workbook;
 import org.apache.poi.ss.util.CellRangeAddress;
+import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import com.baomidou.mybatisplus.plugins.Page;
 import com.baomidou.mybatisplus.mapper.EntityWrapper;
@@ -2784,4 +2785,291 @@ public class ContractManagementInfoServiceImpl extends ServiceImpl<ContractManag
         return contractManagementInfoList;
     }
 
+    @Override
+    public ContractManagementInfo getOutContract(String contractNo, String compId) {
+        ContractManagementInfo contractManagementInfo = this.selectOne(new EntityWrapper<ContractManagementInfo>()
+                .eq("comp_id", compId)
+                .eq("delete_flag", "0")
+                .eq("status_flag", "1")
+                .eq("contract_type", "1")
+                .eq("contract_no",contractNo));
+        if (contractManagementInfo!=null){
+            ContractGoodsInfo contractGoodsInfo = contractGoodsInfoService.selectOne(new EntityWrapper<ContractGoodsInfo>()
+                    .eq("contract_id", contractManagementInfo.getId()));
+            //查合同下的车牌号,出库只能查到未出库的
+            List<TranCarInfo> tranCarInfoList = tranCarInfoService.selectList(new EntityWrapper<TranCarInfo>()
+                    .eq("contract_no", contractManagementInfo.getContractNo()).eq("fleet_flag", "0").eq("tran_type", "1").eq("submit", "0")
+                    .last("ORDER BY CONVERT ( car_no USING gbk ) ASC"));
+            if (!org.springframework.util.CollectionUtils.isEmpty(tranCarInfoList)) {
+                contractManagementInfo.setTranCarInfoList(tranCarInfoList);
+            }
+            List<TranCarInfo> tranCarInfoList1 = tranCarInfoService.selectList(new EntityWrapper<TranCarInfo>()
+                    .eq("contract_no", contractManagementInfo.getContractNo())
+                    .eq("fleet_flag", "1")
+                    .last("ORDER BY CONVERT ( fleet_name USING gbk ) ASC"));
+            if (!org.springframework.util.CollectionUtils.isEmpty(tranCarInfoList1)) {
+                contractManagementInfo.setTranCarInfoList1(tranCarInfoList1);
+            }
+            //查船名
+            Wrapper<TranCarInfo> shipListWrapper = new EntityWrapper<>();
+            shipListWrapper.eq("contract_no", contractManagementInfo.getContractNo())
+                    .eq("delete_flag", "0");
+            shipListWrapper.andNew().eq("tran_type", "3").or()
+                    .eq("three_tran_type", "散船");
+            List<TranCarInfo> shipInfoList = tranCarInfoService.selectList(shipListWrapper);
+            if (!org.springframework.util.CollectionUtils.isEmpty(shipInfoList)) {
+                contractManagementInfo.setShipInfoList(shipInfoList);
+            }
+            //查火运流向
+            List<TranCarInfo> fireList = tranCarInfoService.selectList(new EntityWrapper<TranCarInfo>()
+                    .eq("contract_no", contractManagementInfo.getContractNo())
+                    .eq("tran_type", "2")
+                    .eq("delete_flag", "0"));
+            if (!org.springframework.util.CollectionUtils.isEmpty(fireList)) {
+                contractManagementInfo.setFireDirectionList(fireList);
+            }
+            contractManagementInfo.setGoodsName(contractGoodsInfo.getGoodsName());
+            contractManagementInfo.setGoodsNameKey(contractGoodsInfo.getGoodsNameKey());
+            contractManagementInfo.setGrade(contractGoodsInfo.getGrade());
+            contractManagementInfo.setInOutType("销售出库");
+            //期货取点价,现货取单价
+            if (contractManagementInfo.getUnitContractPrice() != null) {
+                contractManagementInfo.setContractPrice(contractManagementInfo.getPointPrice() != null ? contractManagementInfo.getPointPrice() : Float.valueOf(String.valueOf(contractManagementInfo.getUnitContractPrice())));
+            }
+            return contractManagementInfo;
+        }
+        else {
+            InOutWarehouseTask inOutWarehouseTask = inOutWarehouseTaskService.selectOne(new EntityWrapper<InOutWarehouseTask>()
+                    .eq("comp_id", compId)
+                    .eq("delete_flag", "0")
+                    .eq("task_type_key", "3")
+                    .eq("task_status_key", "5")
+                    .eq("move_task_no",contractNo)
+                    .eq("in_out_flag", "1"));
+            if (inOutWarehouseTask != null) {
+                ContractManagementInfo contractManagementInfo1 = new ContractManagementInfo();
+                BeanUtils.copyProperties(inOutWarehouseTask, contractManagementInfo1);
+                //查移库任务编号下的车牌号,移库出库只能查到未出库的
+                List<TranCarInfo> tranCarInfoList = tranCarInfoService.selectList(new EntityWrapper<TranCarInfo>()
+                        .eq("contract_no", inOutWarehouseTask.getMoveTaskNo()).eq("fleet_flag", "0").eq("tran_type", "1").eq("submit", "0")
+                        .last("ORDER BY CONVERT ( car_no USING gbk ) ASC"));
+                if (!org.springframework.util.CollectionUtils.isEmpty(tranCarInfoList)) {
+                    contractManagementInfo1.setTranCarInfoList(tranCarInfoList);
+                }
+                List<TranCarInfo> tranCarInfoList1 = tranCarInfoService.selectList(new EntityWrapper<TranCarInfo>()
+                        .eq("contract_no", inOutWarehouseTask.getMoveTaskNo())
+                        .eq("fleet_flag", "1")
+                        .last("ORDER BY CONVERT ( fleet_name USING gbk ) ASC"));
+                if (!org.springframework.util.CollectionUtils.isEmpty(tranCarInfoList1)) {
+                    contractManagementInfo1.setTranCarInfoList1(tranCarInfoList1);
+                }
+                //查船名
+                Wrapper<TranCarInfo> shipListWrapper = new EntityWrapper<>();
+                shipListWrapper.eq("contract_no", inOutWarehouseTask.getMoveTaskNo())
+                        .eq("delete_flag", "0");
+                shipListWrapper.andNew().eq("tran_type", "3").or()
+                        .eq("three_tran_type", "散船");
+                List<TranCarInfo> shipInfoList = tranCarInfoService.selectList(shipListWrapper);
+                if (!org.springframework.util.CollectionUtils.isEmpty(shipInfoList)) {
+                    contractManagementInfo1.setShipInfoList(shipInfoList);
+                }
+                //查火运流向
+                List<TranCarInfo> fireList = tranCarInfoService.selectList(new EntityWrapper<TranCarInfo>()
+                        .eq("contract_no", inOutWarehouseTask.getMoveTaskNo())
+                        .eq("tran_type", "2")
+                        .eq("delete_flag", "0"));
+                if (!org.springframework.util.CollectionUtils.isEmpty(fireList)) {
+                    contractManagementInfo1.setFireDirectionList(fireList);
+                }
+                //移库看成自运
+                contractManagementInfo1.setDeliverType("1");
+                contractManagementInfo1.setContractNo(inOutWarehouseTask.getMoveTaskNo());
+                ContractManagementInfo contractManagementInfo2 = contractManagementInfoService.selectOne(new EntityWrapper<ContractManagementInfo>()
+                        .eq("contract_no", inOutWarehouseTask.getWarehouseName())
+                        .eq("comp_id", inOutWarehouseTask.getCompId()));
+                if (contractManagementInfo2 != null && "定价采购".equals(contractManagementInfo2.getPriceType())) {
+                    contractManagementInfo1.setContractPrice(Float.valueOf(String.valueOf(contractManagementInfo2.getUnitContractPrice())));
+                    contractManagementInfo1.setPriceType(contractManagementInfo2.getPriceType());
+                } else if (contractManagementInfo2 != null && "随行就市".equals(contractManagementInfo2.getPriceType())) {
+                    contractManagementInfo1.setPriceType(contractManagementInfo2.getPriceType());
+                }
+                contractManagementInfo1.setGrade(inOutWarehouseTask.getGrade());
+                contractManagementInfo1.setSendWarehouse(inOutWarehouseTask.getSendWarehouse());
+                contractManagementInfo1.setReceiveWarehouse(inOutWarehouseTask.getReceiveWarehouse());
+                contractManagementInfo1.setInOutType("移库出库");
+                return contractManagementInfo1;
+            }
+        }
+        return contractManagementInfo;
+    }
+
+    @Override
+    public ContractManagementInfo getInContract(String contractNo, String compId) {
+        ContractManagementInfo contractManagementInfo = contractManagementInfoService.selectOne(new EntityWrapper<ContractManagementInfo>()
+                .eq("comp_id", compId)
+                .eq("delete_flag", "0")
+                .eq("contract_type", "2")
+                .eq("status_flag", "1")
+                .eq("deliver_type", "2")
+                .eq("contract_no",contractNo));
+        if (contractManagementInfo!=null){
+            ContractGoodsInfo contractGoodsInfo = contractGoodsInfoService.selectOne(new EntityWrapper<ContractGoodsInfo>()
+                    .eq("contract_id", contractManagementInfo.getId()));
+            //查合同下的车牌号,入库只能查到未提交的
+            List<TranCarInfo> tranCarInfoList = tranCarInfoService.selectList(new EntityWrapper<TranCarInfo>()
+                    .eq("contract_no", contractManagementInfo.getContractNo())
+                    .eq("fleet_flag", "0").eq("tran_type", "4").eq("three_tran_type", "汽运").ne("submit", "2")
+                    .last("ORDER BY CONVERT ( car_no USING gbk ) ASC"));
+            if (!org.springframework.util.CollectionUtils.isEmpty(tranCarInfoList)) {
+                contractManagementInfo.setTranCarInfoList(tranCarInfoList);
+            }
+            //查合同下的车队,入库只能查到未提交的
+            List<TranCarInfo> tranCarInfoList1 = tranCarInfoService.selectList(new EntityWrapper<TranCarInfo>()
+                    .eq("contract_no", contractManagementInfo.getContractNo())
+                    .eq("fleet_flag", "1").eq("tran_type", "4").eq("three_tran_type", "汽运")
+                    .last("ORDER BY CONVERT ( fleet_name USING gbk ) ASC"));
+            if (!org.springframework.util.CollectionUtils.isEmpty(tranCarInfoList1)) {
+                contractManagementInfo.setTranCarInfoList1(tranCarInfoList1);
+            }
+            //查船名
+            Wrapper<TranCarInfo> shipListWrapper = new EntityWrapper<>();
+            shipListWrapper.eq("contract_no", contractManagementInfo.getContractNo())
+                    .eq("delete_flag", "0");
+            shipListWrapper.andNew().eq("tran_type", "3").or()
+                    .eq("three_tran_type", "散船");
+            List<TranCarInfo> shipInfoList = tranCarInfoService.selectList(shipListWrapper);
+            if (!org.springframework.util.CollectionUtils.isEmpty(shipInfoList)) {
+                contractManagementInfo.setShipInfoList(shipInfoList);
+            }
+            //查火运流向
+            List<TranCarInfo> fireList = tranCarInfoService.selectList(new EntityWrapper<TranCarInfo>()
+                    .eq("contract_no", contractManagementInfo.getContractNo())
+                    .eq("tran_type", "2")
+                    .eq("delete_flag", "0"));
+            if (!org.springframework.util.CollectionUtils.isEmpty(fireList)) {
+                contractManagementInfo.setFireDirectionList(fireList);
+            }
+            contractManagementInfo.setGoodsName(contractGoodsInfo.getGoodsName());
+            contractManagementInfo.setGoodsNameKey(contractGoodsInfo.getGoodsNameKey());
+            contractManagementInfo.setGrade(contractGoodsInfo.getGrade());
+            contractManagementInfo.setInOutType("采购入库");
+            if (contractManagementInfo.getUnitContractPrice() != null) {
+                //期货取点价,现货取单价
+                contractManagementInfo.setContractPrice(contractManagementInfo.getPointPrice() != null ? contractManagementInfo.getPointPrice() : Float.valueOf(String.valueOf(contractManagementInfo.getUnitContractPrice())));
+            }
+        }
+        else {
+            contractManagementInfo= contractManagementInfoService.selectOne(new EntityWrapper<ContractManagementInfo>()
+                    .eq("comp_id", compId)
+                    .eq("status_flag", "1")
+                    .eq("contract_type", "1")
+                    .eq("delete_flag", "0")
+                    .eq("contract_no",contractNo));
+            if (contractManagementInfo!=null){
+                ContractGoodsInfo contractGoodsInfo = contractGoodsInfoService.selectOne(new EntityWrapper<ContractGoodsInfo>()
+                        .eq("contract_id", contractManagementInfo.getId()));
+                //查合同下的车牌号,入库只能查到未提交的
+                List<TranCarInfo> tranCarInfoList = tranCarInfoService.selectList(new EntityWrapper<TranCarInfo>()
+                        .eq("contract_no", contractManagementInfo.getContractNo()).eq("fleet_flag", "0").eq("tran_type", "1").ne("submit", "2")
+                        .last("ORDER BY CONVERT ( car_no USING gbk ) ASC"));
+                if (!org.springframework.util.CollectionUtils.isEmpty(tranCarInfoList)) {
+                    contractManagementInfo.setTranCarInfoList(tranCarInfoList);
+                }
+                List<TranCarInfo> tranCarInfoList1 = tranCarInfoService.selectList(new EntityWrapper<TranCarInfo>()
+                        .eq("contract_no", contractManagementInfo.getContractNo()).eq("fleet_flag", "1").eq("tran_type", "1")
+                        .last("ORDER BY CONVERT ( fleet_name USING gbk ) ASC"));
+                if (!org.springframework.util.CollectionUtils.isEmpty(tranCarInfoList1)) {
+                    contractManagementInfo.setTranCarInfoList1(tranCarInfoList1);
+                }
+                //查船名
+                Wrapper<TranCarInfo> shipListWrapper = new EntityWrapper<>();
+                shipListWrapper.eq("contract_no", contractManagementInfo.getContractNo())
+                        .eq("delete_flag", "0");
+                shipListWrapper.andNew().eq("tran_type", "3").or()
+                        .eq("three_tran_type", "散船");
+                List<TranCarInfo> shipInfoList = tranCarInfoService.selectList(shipListWrapper);
+                if (!org.springframework.util.CollectionUtils.isEmpty(shipInfoList)) {
+                    contractManagementInfo.setShipInfoList(shipInfoList);
+                }
+                //查火运流向
+                List<TranCarInfo> fireList = tranCarInfoService.selectList(new EntityWrapper<TranCarInfo>()
+                        .eq("contract_no", contractManagementInfo.getContractNo())
+                        .eq("tran_type", "2")
+                        .eq("delete_flag", "0"));
+                if (!org.springframework.util.CollectionUtils.isEmpty(fireList)) {
+                    contractManagementInfo.setFireDirectionList(fireList);
+                }
+                contractManagementInfo.setGoodsName(contractGoodsInfo.getGoodsName());
+                contractManagementInfo.setGoodsNameKey(contractGoodsInfo.getGoodsNameKey());
+                contractManagementInfo.setGrade(contractGoodsInfo.getGrade());
+                contractManagementInfo.setInOutType("退库");
+            }
+            else {
+                InOutWarehouseTask inOutWarehouseTask = inOutWarehouseTaskService.selectOne(new EntityWrapper<InOutWarehouseTask>()
+                        .eq("comp_id", compId)
+                        .eq("delete_flag", "0")
+                        .eq("task_type_key", "3")
+                        .eq("task_status_key", "5")
+                        .eq("in_out_flag", "1")
+                        .eq("move_task_no",contractNo));
+               if (inOutWarehouseTask!=null) {
+                    ContractManagementInfo contractManagementInfo1 = new ContractManagementInfo();
+                    BeanUtils.copyProperties(inOutWarehouseTask, contractManagementInfo1);
+                    //查移库任务编号下的车牌号,入库只能查到已出库的
+                    List<TranCarInfo> tranCarInfoList = tranCarInfoService.selectList(new EntityWrapper<TranCarInfo>()
+                            .eq("contract_no", inOutWarehouseTask.getMoveTaskNo()).eq("fleet_flag", "0").eq("tran_type", "1").eq("submit", "1")
+                            .last("ORDER BY CONVERT ( car_no USING gbk ) ASC"));
+                    if (!org.springframework.util.CollectionUtils.isEmpty(tranCarInfoList)) {
+                        contractManagementInfo1.setTranCarInfoList(tranCarInfoList);
+                    }
+                    List<TranCarInfo> tranCarInfoList1 = tranCarInfoService.selectList(new EntityWrapper<TranCarInfo>()
+                            .eq("contract_no", inOutWarehouseTask.getMoveTaskNo()).eq("fleet_flag", "1").eq("tran_type", "1")
+                            .last("ORDER BY CONVERT ( fleet_name USING gbk ) ASC"));
+                    if (!org.springframework.util.CollectionUtils.isEmpty(tranCarInfoList1)) {
+                        contractManagementInfo1.setTranCarInfoList1(tranCarInfoList1);
+                    }
+                    //查船名
+                    Wrapper<TranCarInfo> shipListWrapper = new EntityWrapper<>();
+                    shipListWrapper.eq("contract_no", inOutWarehouseTask.getMoveTaskNo())
+                            .eq("delete_flag", "0");
+                    shipListWrapper.andNew().eq("tran_type", "3").or()
+                            .eq("three_tran_type", "散船");
+                    List<TranCarInfo> shipInfoList = tranCarInfoService.selectList(shipListWrapper);
+                    if (!org.springframework.util.CollectionUtils.isEmpty(shipInfoList)) {
+                        contractManagementInfo1.setShipInfoList(shipInfoList);
+                    }
+                    //查火运流向
+                    List<TranCarInfo> fireList = tranCarInfoService.selectList(new EntityWrapper<TranCarInfo>()
+                            .eq("contract_no", inOutWarehouseTask.getMoveTaskNo())
+                            .eq("tran_type", "2")
+                            .eq("delete_flag", "0"));
+                    if (!org.springframework.util.CollectionUtils.isEmpty(fireList)) {
+                        contractManagementInfo1.setFireDirectionList(fireList);
+                    }
+                    contractManagementInfo1.setContractNo(inOutWarehouseTask.getMoveTaskNo());
+                    ContractManagementInfo contractManagementInfo2 = contractManagementInfoService.selectOne(new EntityWrapper<ContractManagementInfo>()
+                            .eq("contract_no", inOutWarehouseTask.getWarehouseName())
+                            .eq("comp_id", inOutWarehouseTask.getCompId()));
+                    if (contractManagementInfo2 != null && contractManagementInfo2.getUnitContractPrice() != null) {
+                        contractManagementInfo1.setContractPrice(Float.valueOf(String.valueOf(contractManagementInfo2.getUnitContractPrice())));
+                    }
+                    //自运采购的移库
+                    ContractManagementInfo contractManagementInfo3 = contractManagementInfoService.selectOne(new EntityWrapper<ContractManagementInfo>()
+                            .eq("comp_id", inOutWarehouseTask.getCompId())
+                            .eq("contract_no", inOutWarehouseTask.getSendWarehouse()));
+                    if (contractManagementInfo3 != null && contractManagementInfo3.getUnitContractPrice() != null) {
+                        contractManagementInfo1.setContractPrice(Float.valueOf(String.valueOf(contractManagementInfo3.getUnitContractPrice())));
+                    }
+                    //移库看成自运
+                    contractManagementInfo1.setDeliverType("1");
+                    contractManagementInfo1.setSendWarehouse(inOutWarehouseTask.getSendWarehouse());
+                    contractManagementInfo1.setGrade(inOutWarehouseTask.getGrade());
+                    contractManagementInfo1.setInOutType("移库入库");
+                    return contractManagementInfo1;
+                }
+            }
+        }
+       return contractManagementInfo;
+    }
+
 }