王辉 1 mese fa
parent
commit
777fab0ce3

+ 57 - 3
src/main/java/cn/chinaunicom/omniFlowNetCompute/controller/FreemarketController.java

@@ -1,14 +1,15 @@
 package cn.chinaunicom.omniFlowNetCompute.controller;
 
 import cn.chinaunicom.omniFlowNetCompute.core.web.controller.BaseController;
+import cn.chinaunicom.omniFlowNetCompute.core.web.domain.AjaxResult;
 import cn.chinaunicom.omniFlowNetCompute.core.web.page.TableDataInfo;
 import cn.chinaunicom.omniFlowNetCompute.domain.Freemarket;
+import cn.chinaunicom.omniFlowNetCompute.pojo.OpportunityFreemarketVO;
 import cn.chinaunicom.omniFlowNetCompute.service.FreemarketService;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
 
+import javax.validation.Valid;
 import java.util.List;
 
 @RestController
@@ -24,4 +25,57 @@ public class FreemarketController extends BaseController {
         List<Freemarket> list = freemarketService.listByCondition(param);
         return getDataTable(list);
     }
+
+    /**
+     * 根据ID获取公告详情
+     */
+    @GetMapping("/{id}")
+    public AjaxResult getInfo(@PathVariable Long id) {
+        OpportunityFreemarketVO freemarket = freemarketService.selectFreemarketById(id);
+        return AjaxResult.success(freemarket);
+    }
+
+
+    /**
+     * 新增公告
+     */
+    @PostMapping
+    public AjaxResult add(@RequestBody Freemarket freemarket) {
+        int result = freemarketService.insertFreemarket(freemarket);
+        return result > 0 ? AjaxResult.success("新增成功") : AjaxResult.error("新增失败");
+    }
+
+    /**
+     * 修改公告
+     */
+    @PutMapping
+    public AjaxResult edit(@RequestBody Freemarket freemarket) {
+        int result = freemarketService.updateFreemarket(freemarket);
+        return result > 0 ? AjaxResult.success("修改成功") : AjaxResult.error("修改失败");
+    }
+
+    /**
+     * 删除公告
+     */
+    @DeleteMapping("/{ids}")
+    public AjaxResult remove(@PathVariable Long[] ids) {
+        int result = freemarketService.deleteFreemarketByIds(ids);
+        return result > 0 ? AjaxResult.success("删除成功") : AjaxResult.error("删除失败");
+    }
+
+    /**
+     * 更新参与状态
+     */
+    @PutMapping("/participate/{id}")
+    public AjaxResult updateParticipate(@PathVariable Long id,
+                                        @RequestParam Integer isParticipate,
+                                        @RequestParam(required = false) String notParticipateReason) {
+        Freemarket freemarket = new Freemarket();
+        freemarket.setId(id);
+        freemarket.setIsParticipate(isParticipate);
+        freemarket.setNotParticipateReason(notParticipateReason);
+        int result = freemarketService.updateFreemarket(freemarket);
+        return result > 0 ? AjaxResult.success("更新成功") : AjaxResult.error("更新失败");
+    }
 }
+

+ 47 - 8
src/main/java/cn/chinaunicom/omniFlowNetCompute/controller/OpportunityController.java

@@ -3,11 +3,13 @@ import cn.chinaunicom.omniFlowNetCompute.core.web.controller.BaseController;
 import cn.chinaunicom.omniFlowNetCompute.core.web.domain.AjaxResult;
 import cn.chinaunicom.omniFlowNetCompute.core.web.page.TableDataInfo;
 import cn.chinaunicom.omniFlowNetCompute.domain.Opportunity;
+import cn.chinaunicom.omniFlowNetCompute.pojo.OpportunityFreemarketVO;
 import cn.chinaunicom.omniFlowNetCompute.pojo.OpportunityQueryParam;
 import cn.chinaunicom.omniFlowNetCompute.service.OpportunityService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 
+import javax.validation.Valid;
 import java.util.List;
 
 @RestController
@@ -24,12 +26,49 @@ public class OpportunityController extends BaseController {
         return getDataTable(list);
     }
 
-    // /**
-    //  * 根据商机id获取详细信息
-    //  */
-    // @GetMapping(value = "/{noticeId}")
-    // public AjaxResult getInfo(@PathVariable Long noticeId)
-    // {
-    //     return success(opportunityService.selectNoticeById(noticeId));
-    // }
+    /**
+     * 根据ID获取商机详情
+     */
+    @GetMapping("/{id}")
+    public AjaxResult getInfo(@PathVariable Long id) {
+        OpportunityFreemarketVO opportunity = opportunityService.selectOpportunityById(id);
+        return AjaxResult.success(opportunity);
+    }
+
+    /**
+     * 根据商机编号获取详情
+     */
+    @GetMapping("/code/{code}")
+    public AjaxResult getInfoByCode(@PathVariable String code) {
+        List<Opportunity> opportunity = opportunityService.selectOpportunityByCode(code);
+        return AjaxResult.success(opportunity);
+    }
+
+    /**
+     * 新增商机
+     */
+    @PostMapping
+    public AjaxResult add(@RequestBody Opportunity opportunity) {
+        int result = opportunityService.insertOpportunity(opportunity);
+        return result > 0 ? AjaxResult.success("新增成功") : AjaxResult.error("新增失败");
+    }
+
+    /**
+     * 修改商机
+     */
+    @PutMapping
+    public AjaxResult edit(@RequestBody Opportunity opportunity) {
+        int result = opportunityService.updateOpportunity(opportunity);
+        return result > 0 ? AjaxResult.success("修改成功") : AjaxResult.error("修改失败");
+    }
+
+    /**
+     * 删除商机
+     */
+    @DeleteMapping("/{ids}")
+    public AjaxResult remove(@PathVariable Long[] ids) {
+        int result = opportunityService.deleteOpportunityByIds(ids);
+        return result > 0 ? AjaxResult.success("删除成功") : AjaxResult.error("删除失败");
+    }
+
 }

+ 33 - 126
src/main/java/cn/chinaunicom/omniFlowNetCompute/domain/Freemarket.java

@@ -7,197 +7,104 @@ import lombok.Data;
 import java.math.BigDecimal;
 import java.util.Date;
 
-/**
- * 项目公告信息表 实体类
- * 对应表:project_announcement
- */
 @Data
 public class Freemarket {
-
-    /**
-     * 主键ID
-     */
+    /** 主键ID */
     private Long id;
 
-    /**
-     * 公告类型(如“单一”)
-     */
+    /** 公告类型(如"单一") */
     private String announcementType;
 
-    /**
-     * 公告标题
-     */
+    /** 公告标题 */
     private String announcementTitle;
 
-    /**
-     * 项目编号
-     */
+    /** 项目编号 */
     private String projectCode;
 
-    /**
-     * 是否相关(1=是,0=否)
-     */
+    /** 是否相关(1=是,0=否, 2=重复) */
     private Integer isRelevant;
 
-    /**
-     * 采购单位
-     */
+    /** 采购单位 */
     private String purchaseUnit;
 
-    /**
-     * 最终使用客户
-     */
+    /** 最终使用客户 */
     private String finalUser;
 
-    /**
-     * 对应自然客户ID
-     */
+    /** 对应自然客户ID */
     private Long naturalCustomerId;
 
-    /**
-     * 客户群(如“要客”“非要客”)
-     */
+    /** 客户群(如"要客""非要客") */
     private String customerGroup;
 
-    /**
-     * 分类(如“G”“B”)
-     */
+    /** 分类(如"G""B") */
     private String category;
 
-    /**
-     * 项目名称
-     */
+    /** 项目名称 */
     private String projectName;
 
-    /**
-     * 招标代理
-     */
+    /** 招标代理 */
     private String tenderAgent;
 
-    /**
-     * 招标代理联系电话
-     */
+    /** 招标代理联系电话 */
     private String tenderAgentPhone;
 
-    /**
-     * 信息匹配词
-     */
+    /** 信息匹配词 */
     private String matchKeywords;
 
-    /**
-     * 购买标书截止时间
-     */
-    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+    /** 购买标书截止时间 */
     private Date bidDocumentDeadline;
 
-    /**
-     * 开标日期
-     */
-    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+    /** 开标日期 */
     private Date bidOpeningDate;
 
-    /**
-     * 公告地址(链接)
-     */
+    /** 公告地址(链接) */
     private String announcementUrl;
 
-    /**
-     * 剑鱼地址(链接)
-     */
+    /** 剑鱼地址(链接) */
     private String jianyuUrl;
 
-    /**
-     * 预算(万元)
-     */
+    /** 预算(万元) */
     private BigDecimal budget;
 
-    /**
-     * 招标信息发布时间
-     */
+    /** 招标信息发布时间 */
     private Date tenderInfoPublishTime;
 
-    /**
-     * 分公司
-     */
+    /** 分公司 */
     private String branchCompany;
 
-    /**
-     * 行业
-     */
+    /** 行业 */
     private String industry;
 
-    /**
-     * 业务分类
-     */
+    /** 业务分类 */
     private String businessCategory;
 
-    /**
-     * 业务需求
-     */
+    /** 业务需求 */
     private String businessDemand;
 
-    /**
-     * 商机编号
-     */
+    /** 商机id,关联opportunity表id */
     private Long opportunityId;
 
-    /**
-     * 是否参与(1=是,0=否)
-     */
+    /** 是否参与(1=是,0=否) */
     private Integer isParticipate;
 
-    /**
-     * 不参与原因
-     */
+    /** 不参与原因 */
     private String notParticipateReason;
 
-
-    /**
-     * 本阶段开始时间
-     */
-    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
-    private Date currentStageStartTime;
-
-    /**
-     * 支撑主责单位
-     */
-    private String supportMainUnit;
-
-    /**
-     * 支撑部门和责任人
-     */
-    private String supportDepartment;
-
-    /**
-     * 是否知晓(1=是,0=否)
-     */
+    /** 是否知晓(1=是,0=否) */
     private Integer isAware;
 
-    /**
-     * 红黄绿牌
-     */
+    /** 红黄绿牌 */
     private String rbgLabel;
 
-    /**
-     * 弃标审批单号
-     */
+    /** 弃标审批单号 */
     private String discardApprovalNumber;
 
-    /**
-     * 发布时间
-     */
-    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+    /** 发布时间 */
     private Date publishTime;
 
-    /**
-     * 创建时间
-     */
-    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+    /** 创建时间 */
     private Date createTime;
 
-    /**
-     * 更新时间
-     */
-    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+    /** 更新时间 */
     private Date updateTime;
 }

+ 47 - 9
src/main/java/cn/chinaunicom/omniFlowNetCompute/domain/Opportunity.java

@@ -1,22 +1,60 @@
 package cn.chinaunicom.omniFlowNetCompute.domain;
 
-
-import com.fasterxml.jackson.annotation.JsonFormat;
 import lombok.Data;
 
+import java.math.BigDecimal;
 import java.util.Date;
 
 @Data
 public class Opportunity {
+    /** 主键ID */
     private Long id;
-    private String opportunityName;
+
+    /** 商机编号 */
     private String opportunityCode;
-    private Long naturalCustomerId;
-    private String opportunityStage;
+
+    /** 商机名称 */
+    private String opportunityName;
+
+    /** 自然客户id */
+    private Integer naturalCustomerId;
+
+    /** 自然客户名称 */
+    private String naturalCustomerName;
+
+    /** 预计合同总金额(万元) */
+    private BigDecimal estimatedContractAmount;
+
+    /** 预计签约时间 */
+    private Date estimatedSignDate;
+
+    /** 商机归属人 */
+    private String opportunityOwner;
+
+    /** 商机单位 */
+    private String opportunityUnit;
+
+    /** 支撑负责人 */
     private String supportPerson;
+
+    /** 支撑单位 */
     private String supportUnit;
-    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
-    private Date signTimeStart;
-    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
-    private Date estimatedSignDate;
+
+    /** 客户需求简介 */
+    private String customerRequirement;
+
+    /** 支撑部门 */
+    private String supportDepartment;
+
+    /** 客户资金来源 */
+    private String customerFundSource;
+
+    /** 填报时间 */
+    private Date fillTime;
+
+    /** 商机阶段 */
+    private String opportunityStage;
+
+    /** 建立时间 */
+    private Date establishTime;
 }

+ 27 - 0
src/main/java/cn/chinaunicom/omniFlowNetCompute/mapper/FreemarketMapper.java

@@ -1,6 +1,7 @@
 package cn.chinaunicom.omniFlowNetCompute.mapper;
 
 import cn.chinaunicom.omniFlowNetCompute.domain.Freemarket;
+import cn.chinaunicom.omniFlowNetCompute.pojo.OpportunityFreemarketVO;
 import org.apache.ibatis.annotations.Mapper;
 
 import java.util.List;
@@ -12,4 +13,30 @@ public interface FreemarketMapper {
      * 分页查询公开市场列表(带条件)
      */
     List<Freemarket> selectPageByCondition(Freemarket param);
+
+    /**
+     * 根据ID查询公告
+     */
+    OpportunityFreemarketVO selectFreemarketById(Long id);
+
+
+    /**
+     * 新增公告
+     */
+    int insertFreemarket(Freemarket freemarket);
+
+    /**
+     * 修改公告
+     */
+    int updateFreemarket(Freemarket freemarket);
+
+    /**
+     * 删除公告
+     */
+    int deleteFreemarketById(Long id);
+
+    /**
+     * 批量删除公告
+     */
+    int deleteFreemarketByIds(Long[] ids);
 }

+ 28 - 2
src/main/java/cn/chinaunicom/omniFlowNetCompute/mapper/OpportunityMapper.java

@@ -1,6 +1,7 @@
 package cn.chinaunicom.omniFlowNetCompute.mapper;
 
 import cn.chinaunicom.omniFlowNetCompute.domain.Opportunity;
+import cn.chinaunicom.omniFlowNetCompute.pojo.OpportunityFreemarketVO;
 import cn.chinaunicom.omniFlowNetCompute.pojo.OpportunityQueryParam;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
@@ -16,7 +17,32 @@ public interface OpportunityMapper {
     List<Opportunity> selectPageByCondition(OpportunityQueryParam param);
 
     /**
-     * 根据商机编号查询详情
+     * 根据ID查询商机
      */
-    Opportunity selectDetailByCode(@Param("opportunityCode") String opportunityCode);
+    OpportunityFreemarketVO selectOpportunityById(Long id);
+
+    /**
+     * 根据商机编号查询
+     */
+    List<Opportunity> selectOpportunityByCode(String opportunityCode);
+
+    /**
+     * 新增商机
+     */
+    int insertOpportunity(Opportunity opportunity);
+
+    /**
+     * 修改商机
+     */
+    int updateOpportunity(Opportunity opportunity);
+
+    /**
+     * 删除商机
+     */
+    int deleteOpportunityById(Long id);
+
+    /**
+     * 批量删除商机
+     */
+    int deleteOpportunityByIds(Long[] ids);
 }

+ 63 - 0
src/main/java/cn/chinaunicom/omniFlowNetCompute/pojo/OpportunityFreemarketVO.java

@@ -0,0 +1,63 @@
+package cn.chinaunicom.omniFlowNetCompute.pojo;
+
+import lombok.Data;
+
+import java.math.BigDecimal;
+import java.util.Date;
+
+@Data
+public class OpportunityFreemarketVO {
+    // ========== Opportunity 表字段 ==========
+    private Long oppId;                     // 商机ID
+    private String opportunityCode;         // 商机编号
+    private String opportunityName;         // 商机名称
+    private Integer oppNaturalCustomerId;   // 商机-自然客户id
+    private String oppNaturalCustomerName;  // 商机-自然客户名称
+    private BigDecimal estimatedContractAmount; // 预计合同总金额(万元)
+    private Date estimatedSignDate;         // 预计签约时间
+    private String opportunityOwner;        // 商机归属人
+    private String opportunityUnit;         // 商机单位
+    private String supportPerson;           // 支撑负责人
+    private String supportUnit;             // 支撑单位
+    private String customerRequirement;     // 客户需求简介
+    private String supportDepartment;       // 支撑部门
+    private String customerFundSource;      // 客户资金来源
+    private Date fillTime;                  // 填报时间
+    private String opportunityStage;        // 商机阶段
+    private Date establishTime;             // 建立时间
+    
+    // ========== Freemarket 表字段 ==========
+    private Long fmId;                      // 公告ID
+    private String announcementType;        // 公告类型(如"单一")
+    private String announcementTitle;       // 公告标题
+    private String projectCode;             // 项目编号
+    private Integer isRelevant;             // 是否相关(1=是,0=否, 2=重复)
+    private String purchaseUnit;            // 采购单位
+    private String finalUser;               // 最终使用客户
+    private Long fmNaturalCustomerId;       // 公告-对应自然客户ID
+    private String customerGroup;           // 客户群(如"要客""非要客")
+    private String category;                // 分类(如"G""B")
+    private String projectName;             // 项目名称
+    private String tenderAgent;             // 招标代理
+    private String tenderAgentPhone;        // 招标代理联系电话
+    private String matchKeywords;           // 信息匹配词
+    private Date bidDocumentDeadline;       // 购买标书截止时间
+    private Date bidOpeningDate;            // 开标日期
+    private String announcementUrl;         // 公告地址(链接)
+    private String jianyuUrl;               // 剑鱼地址(链接)
+    private BigDecimal budget;              // 预算(万元)
+    private Date tenderInfoPublishTime;     // 招标信息发布时间
+    private String branchCompany;           // 分公司
+    private String industry;                // 行业
+    private String businessCategory;        // 业务分类
+    private String businessDemand;          // 业务需求
+    private Long opportunityId;             // 关联的商机id
+    private Integer isParticipate;          // 是否参与(1=是,0=否)
+    private String notParticipateReason;    // 不参与原因
+    private Integer isAware;                // 是否知晓(1=是,0=否)
+    private String rbgLabel;                // 红黄绿牌
+    private String discardApprovalNumber;   // 弃标审批单号
+    private Date publishTime;               // 发布时间
+    private Date fmCreateTime;              // 公告创建时间
+    private Date fmUpdateTime;              // 公告更新时间
+}

+ 18 - 0
src/main/java/cn/chinaunicom/omniFlowNetCompute/pojo/OpportunityQueryDTO.java

@@ -0,0 +1,18 @@
+package cn.chinaunicom.omniFlowNetCompute.pojo;
+
+import lombok.Data;
+
+import java.util.Date;
+
+@Data
+public class OpportunityQueryDTO {
+    private String opportunityCode;
+    private String opportunityName;
+    private String naturalCustomerName;
+    private String opportunityStage;
+    private String opportunityOwner;
+    private Date startTime;
+    private Date endTime;
+    private Integer pageNum;
+    private Integer pageSize;
+}

+ 29 - 0
src/main/java/cn/chinaunicom/omniFlowNetCompute/service/FreemarketService.java

@@ -1,6 +1,7 @@
 package cn.chinaunicom.omniFlowNetCompute.service;
 
 import cn.chinaunicom.omniFlowNetCompute.domain.Freemarket;
+import cn.chinaunicom.omniFlowNetCompute.pojo.OpportunityFreemarketVO;
 
 import java.util.List;
 
@@ -9,4 +10,32 @@ public interface FreemarketService
 {
 
     public List<Freemarket> listByCondition(Freemarket param) ;
+
+
+    /**
+     * 根据ID查询公告
+     */
+    OpportunityFreemarketVO selectFreemarketById(Long id);
+
+
+
+    /**
+     * 新增公告
+     */
+    int insertFreemarket(Freemarket freemarket);
+
+    /**
+     * 修改公告
+     */
+    int updateFreemarket(Freemarket freemarket);
+
+    /**
+     * 批量删除公告
+     */
+    int deleteFreemarketByIds(Long[] ids);
+
+    /**
+     * 删除公告
+     */
+    int deleteFreemarketById(Long id);
 }

+ 32 - 2
src/main/java/cn/chinaunicom/omniFlowNetCompute/service/OpportunityService.java

@@ -1,6 +1,7 @@
 package cn.chinaunicom.omniFlowNetCompute.service;
 
 import cn.chinaunicom.omniFlowNetCompute.domain.Opportunity;
+import cn.chinaunicom.omniFlowNetCompute.pojo.OpportunityFreemarketVO;
 import cn.chinaunicom.omniFlowNetCompute.pojo.OpportunityQueryParam;
 
 import java.util.List;
@@ -9,6 +10,35 @@ import java.util.List;
 public interface OpportunityService
 {
 
-    public List<Opportunity> listByCondition(OpportunityQueryParam param) ;
-    //public OpportunityDetailVO getDetailByCode(String opportunityCode) ;
+    List<Opportunity> listByCondition(OpportunityQueryParam param) ;
+
+    /**
+     * 根据ID查询商机
+     */
+    OpportunityFreemarketVO selectOpportunityById(Long id);
+
+    /**
+     * 根据商机编号查询
+     */
+    List<Opportunity> selectOpportunityByCode(String opportunityCode);
+
+    /**
+     * 新增商机
+     */
+    int insertOpportunity(Opportunity opportunity);
+
+    /**
+     * 修改商机
+     */
+    int updateOpportunity(Opportunity opportunity);
+
+    /**
+     * 批量删除商机
+     */
+    int deleteOpportunityByIds(Long[] ids);
+
+    /**
+     * 删除商机
+     */
+    int deleteOpportunityById(Long id);
 }

+ 33 - 0
src/main/java/cn/chinaunicom/omniFlowNetCompute/service/impl/FreemarketServiceImpl.java

@@ -3,9 +3,11 @@ package cn.chinaunicom.omniFlowNetCompute.service.impl;
 
 import cn.chinaunicom.omniFlowNetCompute.domain.Freemarket;
 import cn.chinaunicom.omniFlowNetCompute.mapper.FreemarketMapper;
+import cn.chinaunicom.omniFlowNetCompute.pojo.OpportunityFreemarketVO;
 import cn.chinaunicom.omniFlowNetCompute.service.FreemarketService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
 
 import java.util.List;
 
@@ -20,4 +22,35 @@ public class FreemarketServiceImpl implements FreemarketService {
     public List<Freemarket> listByCondition(Freemarket param) {
         return freemarketMapper.selectPageByCondition(param);
     }
+
+
+    @Override
+    public OpportunityFreemarketVO selectFreemarketById(Long id) {
+        return freemarketMapper.selectFreemarketById(id);
+    }
+
+    @Override
+    public int insertFreemarket(Freemarket freemarket) {
+        return freemarketMapper.insertFreemarket(freemarket);
+    }
+
+    @Override
+    public int updateFreemarket(Freemarket freemarket) {
+        return freemarketMapper.updateFreemarket(freemarket);
+    }
+
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public int deleteFreemarketByIds(Long[] ids) {
+        int count = 0;
+        for (Long id : ids) {
+            count += freemarketMapper.deleteFreemarketById(id);
+        }
+        return count;
+    }
+
+    @Override
+    public int deleteFreemarketById(Long id) {
+        return freemarketMapper.deleteFreemarketById(id);
+    }
 }

+ 37 - 5
src/main/java/cn/chinaunicom/omniFlowNetCompute/service/impl/OpportunityServiceImpl.java

@@ -3,10 +3,13 @@ package cn.chinaunicom.omniFlowNetCompute.service.impl;
 
 import cn.chinaunicom.omniFlowNetCompute.domain.Opportunity;
 import cn.chinaunicom.omniFlowNetCompute.mapper.OpportunityMapper;
+import cn.chinaunicom.omniFlowNetCompute.pojo.OpportunityFreemarketVO;
+import cn.chinaunicom.omniFlowNetCompute.pojo.OpportunityQueryDTO;
 import cn.chinaunicom.omniFlowNetCompute.pojo.OpportunityQueryParam;
 import cn.chinaunicom.omniFlowNetCompute.service.OpportunityService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
 
 import java.util.List;
 
@@ -22,9 +25,38 @@ public class OpportunityServiceImpl implements OpportunityService {
         return opportunityMapper.selectPageByCondition(param);
     }
 
-    // @Override
-    // public SysBanner selectNoticeById(Long noticeId)
-    // {
-    //     return bannerMapper.selectNoticeById(noticeId);
-    // }
+    @Override
+    public OpportunityFreemarketVO selectOpportunityById(Long id) {
+        return opportunityMapper.selectOpportunityById(id);
+    }
+
+    @Override
+    public List<Opportunity> selectOpportunityByCode(String opportunityCode) {
+        return opportunityMapper.selectOpportunityByCode(opportunityCode);
+    }
+
+    @Override
+    public int insertOpportunity(Opportunity opportunity) {
+        return opportunityMapper.insertOpportunity(opportunity);
+    }
+
+    @Override
+    public int updateOpportunity(Opportunity opportunity) {
+        return opportunityMapper.updateOpportunity(opportunity);
+    }
+
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public int deleteOpportunityByIds(Long[] ids) {
+        int count = 0;
+        for (Long id : ids) {
+            count += opportunityMapper.deleteOpportunityById(id);
+        }
+        return count;
+    }
+
+    @Override
+    public int deleteOpportunityById(Long id) {
+        return opportunityMapper.deleteOpportunityById(id);
+    }
 }

+ 270 - 41
src/main/resources/mapper/omni/FreemarketMapper.xml

@@ -2,46 +2,102 @@
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 
 <mapper namespace="cn.chinaunicom.omniFlowNetCompute.mapper.FreemarketMapper">
-
-    <resultMap type="cn.chinaunicom.omniFlowNetCompute.domain.Freemarket" id="BaseResultMap">
-        <id column="id" property="id" jdbcType="BIGINT"/>
-        <result column="announcement_type" property="announcementType" jdbcType="VARCHAR"/>
-        <result column="announcement_title" property="announcementTitle" jdbcType="VARCHAR"/>
-        <result column="project_code" property="projectCode" jdbcType="VARCHAR"/>
-        <result column="is_relevant" property="isRelevant" jdbcType="TINYINT"/>
-        <result column="purchase_unit" property="purchaseUnit" jdbcType="VARCHAR"/>
-        <result column="final_user" property="finalUser" jdbcType="VARCHAR"/>
-        <result column="natural_customer_id" property="naturalCustomerId" jdbcType="BIGINT"/>
-        <result column="customer_group" property="customerGroup" jdbcType="VARCHAR"/>
-        <result column="category" property="category" jdbcType="VARCHAR"/>
-        <result column="project_name" property="projectName" jdbcType="VARCHAR"/>
-        <result column="tender_agent" property="tenderAgent" jdbcType="VARCHAR"/>
-        <result column="tender_agent_phone" property="tenderAgentPhone" jdbcType="VARCHAR"/>
-        <result column="match_keywords" property="matchKeywords" jdbcType="VARCHAR"/>
-        <result column="bid_document_deadline" property="bidDocumentDeadline" />
-        <result column="bid_opening_date" property="bidOpeningDate" />
-        <result column="announcement_url" property="announcementUrl" jdbcType="VARCHAR"/>
-        <result column="jianyu_url" property="jianyuUrl" jdbcType="VARCHAR"/>
-        <result column="budget" property="budget" jdbcType="DECIMAL"/>
-        <result column="tender_info_publish_time" property="tenderInfoPublishTime" />
-        <result column="branch_company" property="branchCompany" jdbcType="VARCHAR"/>
-        <result column="industry" property="industry" jdbcType="VARCHAR"/>
-        <result column="business_category" property="businessCategory" jdbcType="VARCHAR"/>
-        <result column="business_demand" property="businessDemand" jdbcType="VARCHAR"/>
-        <result column="opportunity_id" property="opportunityId" jdbcType="BIGINT"/>
-        <result column="is_participate" property="isParticipate" jdbcType="TINYINT"/>
-        <result column="not_participate_reason" property="notParticipateReason" jdbcType="VARCHAR"/>
-        <result column="current_stage_start_time" property="currentStageStartTime" />
-        <result column="support_main_unit" property="supportMainUnit" jdbcType="VARCHAR"/>
-        <result column="support_department" property="supportDepartment" jdbcType="VARCHAR"/>
-        <result column="is_aware" property="isAware" jdbcType="TINYINT"/>
-        <result column="rbg_label" property="rbgLabel" jdbcType="VARCHAR"/>
-        <result column="discard_approval_number" property="discardApprovalNumber" jdbcType="VARCHAR"/>
-        <result column="publish_time" property="publishTime" />
-        <result column="create_time" property="createTime" />
-        <result column="update_time" property="updateTime" />
+    
+    <resultMap type="cn.chinaunicom.omniFlowNetCompute.domain.Freemarket" id="FreemarketResult">
+        <id property="id" column="id" />
+        <result property="announcementType" column="announcement_type" />
+        <result property="announcementTitle" column="announcement_title" />
+        <result property="projectCode" column="project_code" />
+        <result property="isRelevant" column="is_relevant" />
+        <result property="purchaseUnit" column="purchase_unit" />
+        <result property="finalUser" column="final_user" />
+        <result property="naturalCustomerId" column="natural_customer_id" />
+        <result property="customerGroup" column="customer_group" />
+        <result property="category" column="category" />
+        <result property="projectName" column="project_name" />
+        <result property="tenderAgent" column="tender_agent" />
+        <result property="tenderAgentPhone" column="tender_agent_phone" />
+        <result property="matchKeywords" column="match_keywords" />
+        <result property="bidDocumentDeadline" column="bid_document_deadline" />
+        <result property="bidOpeningDate" column="bid_opening_date" />
+        <result property="announcementUrl" column="announcement_url" />
+        <result property="jianyuUrl" column="jianyu_url" />
+        <result property="budget" column="budget" />
+        <result property="tenderInfoPublishTime" column="tender_info_publish_time" />
+        <result property="branchCompany" column="branch_company" />
+        <result property="industry" column="industry" />
+        <result property="businessCategory" column="business_category" />
+        <result property="businessDemand" column="business_demand" />
+        <result property="opportunityId" column="opportunity_id" />
+        <result property="isParticipate" column="is_participate" />
+        <result property="notParticipateReason" column="not_participate_reason" />
+        <result property="isAware" column="is_aware" />
+        <result property="rbgLabel" column="rbg_label" />
+        <result property="discardApprovalNumber" column="discard_approval_number" />
+        <result property="publishTime" column="publish_time" />
+        <result property="createTime" column="create_time" />
+        <result property="updateTime" column="update_time" />
     </resultMap>
-
+    
+    <!-- 共享的ResultMap,两个Mapper都可以引用 -->
+    <resultMap type="cn.chinaunicom.omniFlowNetCompute.pojo.OpportunityFreemarketVO"
+               id="OpportunityFreemarketResult">
+        <!-- ========== Opportunity 字段映射 ========== -->
+        <result property="oppId" column="opp_id" />
+        <result property="opportunityCode" column="opportunity_code" />
+        <result property="opportunityName" column="opportunity_name" />
+        <result property="oppNaturalCustomerId" column="opp_natural_customer_id" />
+        <result property="oppNaturalCustomerName" column="opp_natural_customer_name" />
+        <result property="estimatedContractAmount" column="estimated_contract_amount" />
+        <result property="estimatedSignDate" column="estimated_sign_date" />
+        <result property="opportunityOwner" column="opportunity_owner" />
+        <result property="opportunityUnit" column="opportunity_unit" />
+        <result property="supportPerson" column="support_person" />
+        <result property="supportUnit" column="support_unit" />
+        <result property="customerRequirement" column="customer_requirement" />
+        <result property="supportDepartment" column="support_department" />
+        <result property="customerFundSource" column="customer_fund_source" />
+        <result property="fillTime" column="fill_time" />
+        <result property="opportunityStage" column="opportunity_stage" />
+        <result property="establishTime" column="establish_time" />
+        
+        <!-- ========== Freemarket 字段映射 ========== -->
+        <result property="fmId" column="fm_id" />
+        <result property="announcementType" column="announcement_type" />
+        <result property="announcementTitle" column="announcement_title" />
+        <result property="projectCode" column="project_code" />
+        <result property="isRelevant" column="is_relevant" />
+        <result property="purchaseUnit" column="purchase_unit" />
+        <result property="finalUser" column="final_user" />
+        <result property="fmNaturalCustomerId" column="fm_natural_customer_id" />
+        <result property="customerGroup" column="customer_group" />
+        <result property="category" column="category" />
+        <result property="projectName" column="project_name" />
+        <result property="tenderAgent" column="tender_agent" />
+        <result property="tenderAgentPhone" column="tender_agent_phone" />
+        <result property="matchKeywords" column="match_keywords" />
+        <result property="bidDocumentDeadline" column="bid_document_deadline" />
+        <result property="bidOpeningDate" column="bid_opening_date" />
+        <result property="announcementUrl" column="announcement_url" />
+        <result property="jianyuUrl" column="jianyu_url" />
+        <result property="budget" column="budget" />
+        <result property="tenderInfoPublishTime" column="tender_info_publish_time" />
+        <result property="branchCompany" column="branch_company" />
+        <result property="industry" column="industry" />
+        <result property="businessCategory" column="business_category" />
+        <result property="businessDemand" column="business_demand" />
+        <result property="opportunityId" column="opportunity_id" />
+        <result property="isParticipate" column="is_participate" />
+        <result property="notParticipateReason" column="not_participate_reason" />
+        <result property="isAware" column="is_aware" />
+        <result property="rbgLabel" column="rbg_label" />
+        <result property="discardApprovalNumber" column="discard_approval_number" />
+        <result property="publishTime" column="publish_time" />
+        <result property="fmCreateTime" column="fm_create_time" />
+        <result property="fmUpdateTime" column="fm_update_time" />
+    </resultMap>
+    
+    
     <!-- 通用查询字段 -->
     <sql id="Base_Column_List">
         id, announcement_type, announcement_title, project_code, is_relevant, purchase_unit, final_user,
@@ -53,7 +109,7 @@
     </sql>
 
     <!-- ========== 核心SQL 1:详情页查询 - 根据主键ID查询单条详情数据 ========== -->
-    <select id="selectById" parameterType="java.lang.Long" resultMap="BaseResultMap">
+    <select id="selectById" parameterType="java.lang.Long" resultMap="FreemarketResult">
         SELECT
         <include refid="Base_Column_List"/>
         FROM project_announcement
@@ -61,7 +117,7 @@
     </select>
 
     <!-- ========== 核心SQL 2:列表页查询 - 分页+多条件模糊查询(最常用) ========== -->
-    <select id="selectPageByCondition" parameterType="cn.chinaunicom.omniFlowNetCompute.domain.Freemarket" resultMap="BaseResultMap">
+    <select id="selectPageByCondition" parameterType="cn.chinaunicom.omniFlowNetCompute.domain.Freemarket" resultMap="FreemarketResult">
         SELECT
         <include refid="Base_Column_List"/>
         FROM freemarket
@@ -93,4 +149,177 @@
         <!-- 排序:按创建时间倒序,最新的在前面 -->
         ORDER BY create_time DESC
     </select>
+    
+    <select id="selectFreemarketById" parameterType="Long"
+            resultMap="OpportunityFreemarketResult">
+        SELECT
+            f.id as fm_id,
+            f.announcement_type,
+            f.announcement_title,
+            f.project_code,
+            f.is_relevant,
+            f.purchase_unit,
+            f.final_user,
+            f.natural_customer_id as fm_natural_customer_id,
+            f.customer_group,
+            f.category,
+            f.project_name,
+            f.tender_agent,
+            f.tender_agent_phone,
+            f.match_keywords,
+            f.bid_document_deadline,
+            f.bid_opening_date,
+            f.announcement_url,
+            f.jianyu_url,
+            f.budget,
+            f.tender_info_publish_time,
+            f.branch_company,
+            f.industry,
+            f.business_category,
+            f.business_demand,
+            f.opportunity_id,
+            f.is_participate,
+            f.not_participate_reason,
+            f.is_aware,
+            f.rbg_label,
+            f.discard_approval_number,
+            f.publish_time,
+            f.create_time as fm_create_time,
+            f.update_time as fm_update_time,
+            
+            o.id as opp_id,
+            o.opportunity_code,
+            o.opportunity_name,
+            o.natural_customer_id as opp_natural_customer_id,
+            o.natural_customer_name as opp_natural_customer_name,
+            o.estimated_contract_amount,
+            o.estimated_sign_date,
+            o.opportunity_owner,
+            o.opportunity_unit,
+            o.support_person,
+            o.support_unit,
+            o.customer_requirement,
+            o.support_department,
+            o.customer_fund_source,
+            o.fill_time,
+            o.opportunity_stage,
+            o.establish_time
+        FROM freemarket f
+                 LEFT JOIN opportunity o ON f.opportunity_id = o.id
+        WHERE f.id = #{id}
+    </select>
+    
+    <insert id="insertFreemarket" parameterType="cn.chinaunicom.omniFlowNetCompute.domain.Freemarket" useGeneratedKeys="true" keyProperty="id">
+        insert into freemarket (
+            announcement_type,
+            announcement_title,
+            project_code,
+            is_relevant,
+            purchase_unit,
+            final_user,
+            natural_customer_id,
+            customer_group,
+            category,
+            project_name,
+            tender_agent,
+            tender_agent_phone,
+            match_keywords,
+            bid_document_deadline,
+            bid_opening_date,
+            announcement_url,
+            jianyu_url,
+            budget,
+            tender_info_publish_time,
+            branch_company,
+            industry,
+            business_category,
+            business_demand,
+            opportunity_id,
+            is_participate,
+            not_participate_reason,
+            is_aware,
+            rbg_label,
+            discard_approval_number,
+            publish_time
+        ) values (
+                     #{announcementType},
+                     #{announcementTitle},
+                     #{projectCode},
+                     #{isRelevant},
+                     #{purchaseUnit},
+                     #{finalUser},
+                     #{naturalCustomerId},
+                     #{customerGroup},
+                     #{category},
+                     #{projectName},
+                     #{tenderAgent},
+                     #{tenderAgentPhone},
+                     #{matchKeywords},
+                     #{bidDocumentDeadline},
+                     #{bidOpeningDate},
+                     #{announcementUrl},
+                     #{jianyuUrl},
+                     #{budget},
+                     #{tenderInfoPublishTime},
+                     #{branchCompany},
+                     #{industry},
+                     #{businessCategory},
+                     #{businessDemand},
+                     #{opportunityId},
+                     #{isParticipate},
+                     #{notParticipateReason},
+                     #{isAware},
+                     #{rbgLabel},
+                     #{discardApprovalNumber},
+                     #{publishTime}
+                 )
+    </insert>
+    
+    <update id="updateFreemarket" parameterType="cn.chinaunicom.omniFlowNetCompute.domain.Freemarket">
+        update freemarket
+        <set>
+            <if test="announcementType != null">announcement_type = #{announcementType},</if>
+            <if test="announcementTitle != null">announcement_title = #{announcementTitle},</if>
+            <if test="projectCode != null">project_code = #{projectCode},</if>
+            <if test="isRelevant != null">is_relevant = #{isRelevant},</if>
+            <if test="purchaseUnit != null">purchase_unit = #{purchaseUnit},</if>
+            <if test="finalUser != null">final_user = #{finalUser},</if>
+            <if test="naturalCustomerId != null">natural_customer_id = #{naturalCustomerId},</if>
+            <if test="customerGroup != null">customer_group = #{customerGroup},</if>
+            <if test="category != null">category = #{category},</if>
+            <if test="projectName != null">project_name = #{projectName},</if>
+            <if test="tenderAgent != null">tender_agent = #{tenderAgent},</if>
+            <if test="tenderAgentPhone != null">tender_agent_phone = #{tenderAgentPhone},</if>
+            <if test="matchKeywords != null">match_keywords = #{matchKeywords},</if>
+            <if test="bidDocumentDeadline != null">bid_document_deadline = #{bidDocumentDeadline},</if>
+            <if test="bidOpeningDate != null">bid_opening_date = #{bidOpeningDate},</if>
+            <if test="announcementUrl != null">announcement_url = #{announcementUrl},</if>
+            <if test="jianyuUrl != null">jianyu_url = #{jianyuUrl},</if>
+            <if test="budget != null">budget = #{budget},</if>
+            <if test="tenderInfoPublishTime != null">tender_info_publish_time = #{tenderInfoPublishTime},</if>
+            <if test="branchCompany != null">branch_company = #{branchCompany},</if>
+            <if test="industry != null">industry = #{industry},</if>
+            <if test="businessCategory != null">business_category = #{businessCategory},</if>
+            <if test="businessDemand != null">business_demand = #{businessDemand},</if>
+            <if test="opportunityId != null">opportunity_id = #{opportunityId},</if>
+            <if test="isParticipate != null">is_participate = #{isParticipate},</if>
+            <if test="notParticipateReason != null">not_participate_reason = #{notParticipateReason},</if>
+            <if test="isAware != null">is_aware = #{isAware},</if>
+            <if test="rbgLabel != null">rbg_label = #{rbgLabel},</if>
+            <if test="discardApprovalNumber != null">discard_approval_number = #{discardApprovalNumber},</if>
+            <if test="publishTime != null">publish_time = #{publishTime},</if>
+        </set>
+        where id = #{id}
+    </update>
+    
+    <delete id="deleteFreemarketById" parameterType="Long">
+        delete from freemarket where id = #{id}
+    </delete>
+    
+    <delete id="deleteFreemarketByIds" parameterType="Long">
+        delete from freemarket where id in
+        <foreach item="id" collection="array" open="(" separator="," close=")">
+            #{id}
+        </foreach>
+    </delete>
 </mapper>

+ 246 - 25
src/main/resources/mapper/omni/OpportunityMapper.xml

@@ -2,34 +2,97 @@
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 
 <mapper namespace="cn.chinaunicom.omniFlowNetCompute.mapper.OpportunityMapper">
-
+    
     <resultMap type="cn.chinaunicom.omniFlowNetCompute.domain.Opportunity" id="OpportunityResult">
-        <result property="id"             column="id"       />
-        <result property="opportunityName"    column="opportunity_name"    />
-        <result property="opportunityCode"     column="opportunity_code"     />
-        <result property="naturalCustomerId"  column="natural_customer_id"  />
-        <result property="opportunityStage"         column="opportunity_stage"          />
-        <result property="supportPerson"       column="support_person"       />
-        <result property="supportUnit"     column="support_unit"     />
-        <result property="estimatedSignDate"       column="estimated_sign_date"       />
+        <id property="id" column="id" />
+        <result property="opportunityCode" column="opportunity_code" />
+        <result property="opportunityName" column="opportunity_name" />
+        <result property="naturalCustomerId" column="natural_customer_id" />
+        <result property="naturalCustomerName" column="natural_customer_name" />
+        <result property="estimatedContractAmount" column="estimated_contract_amount" />
+        <result property="estimatedSignDate" column="estimated_sign_date" />
+        <result property="opportunityOwner" column="opportunity_owner" />
+        <result property="opportunityUnit" column="opportunity_unit" />
+        <result property="supportPerson" column="support_person" />
+        <result property="supportUnit" column="support_unit" />
+        <result property="customerRequirement" column="customer_requirement" />
+        <result property="supportDepartment" column="support_department" />
+        <result property="customerFundSource" column="customer_fund_source" />
+        <result property="fillTime" column="fill_time" />
+        <result property="opportunityStage" column="opportunity_stage" />
+        <result property="establishTime" column="establish_time" />
+    </resultMap>
+    
+    <!-- 共享的ResultMap,两个Mapper都可以引用 -->
+    <resultMap type="cn.chinaunicom.omniFlowNetCompute.pojo.OpportunityFreemarketVO"
+               id="OpportunityFreemarketResult">
+        <!-- ========== Opportunity 字段映射 ========== -->
+        <result property="oppId" column="opp_id" />
+        <result property="opportunityCode" column="opportunity_code" />
+        <result property="opportunityName" column="opportunity_name" />
+        <result property="oppNaturalCustomerId" column="opp_natural_customer_id" />
+        <result property="oppNaturalCustomerName" column="opp_natural_customer_name" />
+        <result property="estimatedContractAmount" column="estimated_contract_amount" />
+        <result property="estimatedSignDate" column="estimated_sign_date" />
+        <result property="opportunityOwner" column="opportunity_owner" />
+        <result property="opportunityUnit" column="opportunity_unit" />
+        <result property="supportPerson" column="support_person" />
+        <result property="supportUnit" column="support_unit" />
+        <result property="customerRequirement" column="customer_requirement" />
+        <result property="supportDepartment" column="support_department" />
+        <result property="customerFundSource" column="customer_fund_source" />
+        <result property="fillTime" column="fill_time" />
+        <result property="opportunityStage" column="opportunity_stage" />
+        <result property="establishTime" column="establish_time" />
+        
+        <!-- ========== Freemarket 字段映射 ========== -->
+        <result property="fmId" column="fm_id" />
+        <result property="announcementType" column="announcement_type" />
+        <result property="announcementTitle" column="announcement_title" />
+        <result property="projectCode" column="project_code" />
+        <result property="isRelevant" column="is_relevant" />
+        <result property="purchaseUnit" column="purchase_unit" />
+        <result property="finalUser" column="final_user" />
+        <result property="fmNaturalCustomerId" column="fm_natural_customer_id" />
+        <result property="customerGroup" column="customer_group" />
+        <result property="category" column="category" />
+        <result property="projectName" column="project_name" />
+        <result property="tenderAgent" column="tender_agent" />
+        <result property="tenderAgentPhone" column="tender_agent_phone" />
+        <result property="matchKeywords" column="match_keywords" />
+        <result property="bidDocumentDeadline" column="bid_document_deadline" />
+        <result property="bidOpeningDate" column="bid_opening_date" />
+        <result property="announcementUrl" column="announcement_url" />
+        <result property="jianyuUrl" column="jianyu_url" />
+        <result property="budget" column="budget" />
+        <result property="tenderInfoPublishTime" column="tender_info_publish_time" />
+        <result property="branchCompany" column="branch_company" />
+        <result property="industry" column="industry" />
+        <result property="businessCategory" column="business_category" />
+        <result property="businessDemand" column="business_demand" />
+        <result property="opportunityId" column="opportunity_id" />
+        <result property="isParticipate" column="is_participate" />
+        <result property="notParticipateReason" column="not_participate_reason" />
+        <result property="isAware" column="is_aware" />
+        <result property="rbgLabel" column="rbg_label" />
+        <result property="discardApprovalNumber" column="discard_approval_number" />
+        <result property="publishTime" column="publish_time" />
+        <result property="fmCreateTime" column="fm_create_time" />
+        <result property="fmUpdateTime" column="fm_update_time" />
     </resultMap>
 
     <!-- 分页查询 -->
     <select id="selectPageByCondition" resultMap="OpportunityResult"
             parameterType="cn.chinaunicom.omniFlowNetCompute.pojo.OpportunityQueryParam">
         SELECT
-        id, opportunity_code, opportunity_name, natural_customer_id,
-        natural_customer_name, estimated_contract_amount, estimated_sign_date,
-        opportunity_owner, opportunity_unit, support_person, support_unit,
-        customer_requirement, support_department, customer_fund_source,
-        fill_time, opportunity_stage, establish_time
+        *
         FROM opportunity
         <where>
             <if test="opportunityName != null and opportunityName != ''">
                 AND opportunity_name LIKE CONCAT('%', #{opportunityName}, '%')
             </if>
             <if test="opportunityCode != null and opportunityCode != ''">
-                AND opportunity_code = #{opportunityCode}
+                AND opportunity_code LIKE CONCAT('%', #{opportunityCode}, '%')
             </if>
             <if test="naturalCustomerId != null">
                 AND natural_customer_id = #{naturalCustomerId}
@@ -51,17 +114,175 @@
             </if>
         </where>
     </select>
-
-    <!-- 详情查询 -->
-    <select id="selectDetailByCode" resultType="cn.chinaunicom.omniFlowNetCompute.domain.Opportunity">
+    
+    <sql id="selectOpportunityVo">
+        select id, opportunity_code, opportunity_name, natural_customer_id,
+               natural_customer_name, estimated_contract_amount, estimated_sign_date,
+               opportunity_owner, opportunity_unit, support_person, support_unit,
+               customer_requirement, support_department, customer_fund_source,
+               fill_time, opportunity_stage, establish_time
+        from opportunity
+    </sql>
+    
+    <select id="selectOpportunityList" parameterType="cn.chinaunicom.omniFlowNetCompute.pojo.OpportunityQueryDTO" resultMap="OpportunityResult">
+        <include refid="selectOpportunityVo"/>
+        <where>
+            <if test="opportunityCode != null and opportunityCode != ''">
+                AND opportunity_code LIKE CONCAT('%', #{opportunityCode}, '%')
+            </if>
+            <if test="opportunityName != null and opportunityName != ''">
+                AND opportunity_name LIKE CONCAT('%', #{opportunityName}, '%')
+            </if>
+            <if test="naturalCustomerName != null and naturalCustomerName != ''">
+                AND natural_customer_name LIKE CONCAT('%', #{naturalCustomerName}, '%')
+            </if>
+            <if test="opportunityStage != null and opportunityStage != ''">
+                AND opportunity_stage = #{opportunityStage}
+            </if>
+            <if test="opportunityOwner != null and opportunityOwner != ''">
+                AND opportunity_owner LIKE CONCAT('%', #{opportunityOwner}, '%')
+            </if>
+            <if test="startTime != null and endTime != null">
+                AND establish_time BETWEEN #{startTime} AND #{endTime}
+            </if>
+        </where>
+        order by establish_time desc
+    </select>
+    
+    <select id="selectOpportunityById" parameterType="Long"
+            resultMap="OpportunityFreemarketResult">
         SELECT
-            id, opportunity_code, opportunity_name, natural_customer_id,
-            natural_customer_name, estimated_contract_amount, estimated_sign_date,
-            opportunity_owner, opportunity_unit, support_person, support_unit,
-            customer_requirement, support_department, customer_fund_source,
-            fill_time, opportunity_stage, establish_time
-        FROM opportunity
-        WHERE opportunity_code = #{opportunityCode}
+            o.id as opp_id,
+            o.opportunity_code,
+            o.opportunity_name,
+            o.natural_customer_id as opp_natural_customer_id,
+            o.natural_customer_name as opp_natural_customer_name,
+            o.estimated_contract_amount,
+            o.estimated_sign_date,
+            o.opportunity_owner,
+            o.opportunity_unit,
+            o.support_person,
+            o.support_unit,
+            o.customer_requirement,
+            o.support_department,
+            o.customer_fund_source,
+            o.fill_time,
+            o.opportunity_stage,
+            o.establish_time,
+            
+            f.id as fm_id,
+            f.announcement_type,
+            f.announcement_title,
+            f.project_code,
+            f.is_relevant,
+            f.purchase_unit,
+            f.final_user,
+            f.natural_customer_id as fm_natural_customer_id,
+            f.customer_group,
+            f.category,
+            f.project_name,
+            f.tender_agent,
+            f.tender_agent_phone,
+            f.match_keywords,
+            f.bid_document_deadline,
+            f.bid_opening_date,
+            f.announcement_url,
+            f.jianyu_url,
+            f.budget,
+            f.tender_info_publish_time,
+            f.branch_company,
+            f.industry,
+            f.business_category,
+            f.business_demand,
+            f.opportunity_id,
+            f.is_participate,
+            f.not_participate_reason,
+            f.is_aware,
+            f.rbg_label,
+            f.discard_approval_number,
+            f.publish_time,
+            f.create_time as fm_create_time,
+            f.update_time as fm_update_time
+        FROM opportunity o
+                 LEFT JOIN freemarket f ON o.id = f.opportunity_id
+        WHERE o.id = #{id}
+    </select>
+    
+    <select id="selectOpportunityByCode" parameterType="String" resultMap="OpportunityResult">
+        <include refid="selectOpportunityVo"/>
+        where opportunity_code LIKE CONCAT('%', #{opportunityCode}, '%')
     </select>
+    
+    <insert id="insertOpportunity" parameterType="cn.chinaunicom.omniFlowNetCompute.domain.Opportunity" useGeneratedKeys="true" keyProperty="id">
+        insert into opportunity (
+            opportunity_code,
+            opportunity_name,
+            natural_customer_id,
+            natural_customer_name,
+            estimated_contract_amount,
+            estimated_sign_date,
+            opportunity_owner,
+            opportunity_unit,
+            support_person,
+            support_unit,
+            customer_requirement,
+            support_department,
+            customer_fund_source,
+            fill_time,
+            opportunity_stage,
+            establish_time
+        ) values (
+                     #{opportunityCode},
+                     #{opportunityName},
+                     #{naturalCustomerId},
+                     #{naturalCustomerName},
+                     #{estimatedContractAmount},
+                     #{estimatedSignDate},
+                     #{opportunityOwner},
+                     #{opportunityUnit},
+                     #{supportPerson},
+                     #{supportUnit},
+                     #{customerRequirement},
+                     #{supportDepartment},
+                     #{customerFundSource},
+                     #{fillTime},
+                     #{opportunityStage},
+                     #{establishTime}
+                 )
+    </insert>
+    
+    <update id="updateOpportunity" parameterType="cn.chinaunicom.omniFlowNetCompute.domain.Opportunity">
+        update opportunity
+        <set>
+            <if test="opportunityCode != null">opportunity_code = #{opportunityCode},</if>
+            <if test="opportunityName != null">opportunity_name = #{opportunityName},</if>
+            <if test="naturalCustomerId != null">natural_customer_id = #{naturalCustomerId},</if>
+            <if test="naturalCustomerName != null">natural_customer_name = #{naturalCustomerName},</if>
+            <if test="estimatedContractAmount != null">estimated_contract_amount = #{estimatedContractAmount},</if>
+            <if test="estimatedSignDate != null">estimated_sign_date = #{estimatedSignDate},</if>
+            <if test="opportunityOwner != null">opportunity_owner = #{opportunityOwner},</if>
+            <if test="opportunityUnit != null">opportunity_unit = #{opportunityUnit},</if>
+            <if test="supportPerson != null">support_person = #{supportPerson},</if>
+            <if test="supportUnit != null">support_unit = #{supportUnit},</if>
+            <if test="customerRequirement != null">customer_requirement = #{customerRequirement},</if>
+            <if test="supportDepartment != null">support_department = #{supportDepartment},</if>
+            <if test="customerFundSource != null">customer_fund_source = #{customerFundSource},</if>
+            <if test="fillTime != null">fill_time = #{fillTime},</if>
+            <if test="opportunityStage != null">opportunity_stage = #{opportunityStage},</if>
+            <if test="establishTime != null">establish_time = #{establishTime},</if>
+        </set>
+        where id = #{id}
+    </update>
+    
+    <delete id="deleteOpportunityById" parameterType="Long">
+        delete from opportunity where id = #{id}
+    </delete>
+    
+    <delete id="deleteOpportunityByIds" parameterType="Long">
+        delete from opportunity where id in
+        <foreach item="id" collection="array" open="(" separator="," close=")">
+            #{id}
+        </foreach>
+    </delete>
 
 </mapper>