Bläddra i källkod

Merge branch 'test' of jishutao/kede-server into prod

anderx 3 år sedan
förälder
incheckning
79448b82fd
32 ändrade filer med 980 tillägg och 374 borttagningar
  1. 25 1
      src/main/java/com/goafanti/common/controller/PublicController.java
  2. 2 1
      src/main/java/com/goafanti/common/dao/PaymentNodeMapper.java
  3. 5 1
      src/main/java/com/goafanti/common/dao/TChangeTaskMapper.java
  4. 6 8
      src/main/java/com/goafanti/common/dao/TOrderMidMapper.java
  5. 1 0
      src/main/java/com/goafanti/common/dao/TOrderTaskMapper.java
  6. 2 0
      src/main/java/com/goafanti/common/dao/TTaskMemberMapper.java
  7. 2 2
      src/main/java/com/goafanti/common/dao/TTaskMidMapper.java
  8. 2 1
      src/main/java/com/goafanti/common/dao/ThirdPartyCompanyMapper.java
  9. 15 14
      src/main/java/com/goafanti/common/mapper/FinancialPaymentMapper.xml
  10. 70 20
      src/main/java/com/goafanti/common/mapper/PaymentNodeMapper.xml
  11. 15 3
      src/main/java/com/goafanti/common/mapper/TChangeTaskMapper.xml
  12. 145 32
      src/main/java/com/goafanti/common/mapper/TOrderMidMapper.xml
  13. 13 10
      src/main/java/com/goafanti/common/mapper/TOrderNewMapper.xml
  14. 15 13
      src/main/java/com/goafanti/common/mapper/TOrderTaskMapper.xml
  15. 10 1
      src/main/java/com/goafanti/common/mapper/TTaskMemberMapper.xml
  16. 2 9
      src/main/java/com/goafanti/common/mapper/TTaskMidMapper.xml
  17. 4 2
      src/main/java/com/goafanti/common/mapper/ThirdPartyCompanyMapper.xml
  18. 131 1
      src/main/java/com/goafanti/common/model/TOrderMid.java
  19. 2 1
      src/main/java/com/goafanti/customer/service/impl/CustomerServiceImpl.java
  20. 132 0
      src/main/java/com/goafanti/order/bo/OrderListBo.java
  21. 2 0
      src/main/java/com/goafanti/order/service/OrderProjectService.java
  22. 23 4
      src/main/java/com/goafanti/order/service/impl/OrderChangeServiceImpl.java
  23. 16 12
      src/main/java/com/goafanti/order/service/impl/OrderNewServiceImpl.java
  24. 44 1
      src/main/java/com/goafanti/order/service/impl/OrderProjectServiceImpl.java
  25. 1 2
      src/main/java/com/goafanti/order/service/impl/OrderReceivablesServiceImpl.java
  26. 37 10
      src/main/java/com/goafanti/order/service/impl/OutsourceOrgServiceImpl.java
  27. 167 166
      src/main/java/com/goafanti/organization/bo/OutThirdPartyCompany.java
  28. 21 3
      src/main/java/com/goafanti/organization/bo/ProjectTypePuls.java
  29. 13 13
      src/main/java/com/goafanti/organization/bo/outOrderPayment.java
  30. 50 36
      src/main/java/com/goafanti/organization/service/impl/ThirdPartyCompanyServiceImpl.java
  31. 6 6
      src/main/resources/props/config_local.properties
  32. 1 1
      src/main/resources/props/config_test.properties

+ 25 - 1
src/main/java/com/goafanti/common/controller/PublicController.java

@@ -11,7 +11,16 @@ import javax.annotation.Resource;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
+import com.goafanti.common.dao.TOrderMidMapper;
+import com.goafanti.common.dao.TOrderTaskMapper;
+import com.goafanti.common.model.TOrderMid;
+import com.goafanti.common.model.TOrderTask;
 import com.goafanti.common.utils.excel.Excel;
+import com.goafanti.order.bo.TOrderTaskBo;
+import com.goafanti.order.enums.NewProjectStatus;
+import com.goafanti.order.enums.ProjectStage;
+import com.goafanti.order.enums.ProjectType;
+import com.goafanti.order.service.OrderProjectService;
 import org.apache.commons.collections4.map.HashedMap;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.poi.ss.usermodel.Cell;
@@ -94,7 +103,7 @@ public class PublicController extends CertifyApiController {
 	private AdminService	adminService;
 
 	@Resource
-	private FieldGlossoryService			fieldGlossoryService;
+	private TOrderMidMapper			tOrderMidMapper;
 
 	@Autowired
 	private IndustryCategoryService	industryCategoryService;
@@ -102,6 +111,9 @@ public class PublicController extends CertifyApiController {
 	@Autowired
 	private DistrictGlossoryService	districtGlossoryService;
 
+	@Autowired
+	private OrderProjectService	orderProjectService;
+
 	@Value(value = "${patentTemplate}")
 	private String					patentTemplate		= null;
 
@@ -742,4 +754,16 @@ public class PublicController extends CertifyApiController {
       		return excel.exportExcel(list, "客户列表",uploadPath);
           }
 
+
+
+	@RequestMapping("/pushOrderMid")
+	public Result pushOrderMid() {
+		List<TOrderMid> list = tOrderMidMapper.selectAll();
+		for (TOrderMid mid : list) {
+			tOrderMidMapper.updateCostAmount(mid.getOrderNo());
+			orderProjectService.updateMidServiceProject(mid.getOrderNo());
+		}
+		return new Result().data(1);
+	}
+
 }

+ 2 - 1
src/main/java/com/goafanti/common/dao/PaymentNodeMapper.java

@@ -87,4 +87,5 @@ public interface PaymentNodeMapper {
 
 	void deleteByParam(@Param("tpcId")Integer tpcId, @Param("tid")Integer tid);
 
-}
+    void updateByCid(PaymentNode paymentNode);
+}

+ 5 - 1
src/main/java/com/goafanti/common/dao/TChangeTaskMapper.java

@@ -49,7 +49,11 @@ public interface TChangeTaskMapper {
     void updateTypeBatch(@Param("type") Integer type, @Param("list") List<Integer> list);
 
 
-    void selectByServiceYear(@Param("serviceYear") String serviceYear, @Param("sliptSuper")Integer sliptSuper, @Param("changeSplitSuper")Integer changeSplitSuper);
+
 
     void deleteByChangeSplitSuper(Integer tid);
+
+    void updateSuperServiceYear(TChangeTask tChangeTask);
+
+    void updateChangeSuperServiceYear(TChangeTask tChangeTask);
 }

+ 6 - 8
src/main/java/com/goafanti/common/dao/TOrderMidMapper.java

@@ -27,16 +27,17 @@ public interface TOrderMidMapper {
 
     void updateFinanceId(@Param("id")String id, @Param("financeId")String financeId);
 
-    void updatefinalReceivables(@Param("orderNo")String orderNo, @Param("amount") BigDecimal amount, @Param("receivablesTime") Date receivablesTime);
+    void updatefinalReceivables(@Param("orderNo")String orderNo, @Param("amount") BigDecimal amount,
+                                @Param("count") BigDecimal count,@Param("receivablesTime") Date receivablesTime);
 
     void updateInvoice(String orderNo);
 
 
     String selectDepNameByDepid(String orderDep);
 
-    void updateCostAmount(@Param("tid")Integer tid, @Param("cost")BigDecimal cost, @Param("payment")BigDecimal payment);
+    void updateCostAmount(String orderNo);
+
 
-    void updateAddCostAmount(@Param("tid")Integer tid, @Param("cost")BigDecimal cost);
 
     int updateByOrderNo(TOrderMid tm);
 
@@ -48,9 +49,6 @@ public interface TOrderMidMapper {
 
     int judgeProjectType(String orderNo);
 
-    /**
-     * 修改订单中间表的显示的所有名称和所有分类
-     * @param orderNo
-     */
-    void updateCountProjectAndType(String orderNo);
+
+    List<TOrderMid> selectAll();
 }

+ 1 - 0
src/main/java/com/goafanti/common/dao/TOrderTaskMapper.java

@@ -80,4 +80,5 @@ public interface TOrderTaskMapper {
     List<TChangeTask> selectByAid(String aid);
 
     Integer getSplitCount(Integer tid);
+
 }

+ 2 - 0
src/main/java/com/goafanti/common/dao/TTaskMemberMapper.java

@@ -24,4 +24,6 @@ public interface TTaskMemberMapper {
     void updateSplitSuper(@Param("id") Integer id, @Param("serviceLife") String serviceLife,
                           @Param("serviceYear") String serviceYear, @Param("yearSum") Integer yearSum,
                           @Param("contractTerm") String contractTerm);
+
+    void updateServiceYearBySplitSuper(Integer tid);
 }

+ 2 - 2
src/main/java/com/goafanti/common/dao/TTaskMidMapper.java

@@ -19,13 +19,13 @@ public interface TTaskMidMapper {
 
     int updateByPrimaryKey(TTaskMid record);
 
-    int updateCostAmount(@Param("tid")Integer tid, @Param("count") BigDecimal costAmount);
+    int updateCostAmount(@Param("tid")Integer tid, @Param("count") BigDecimal costAmount,@Param("party") BigDecimal party);
 
     int updatePaymentAmount(@Param("tid")Integer tid, @Param("paymentAmount")BigDecimal paymentAmount, @Param("type")Integer type);
 
     void updateCertificatesCountByTid(@Param("tid")Integer tid, @Param("count")Integer count);
 
-    List<TTaskMid> selectListByTid(Integer tid);
+
 
     void updateByTid(TTaskMid tm);
 

+ 2 - 1
src/main/java/com/goafanti/common/dao/ThirdPartyCompanyMapper.java

@@ -82,4 +82,5 @@ public interface ThirdPartyCompanyMapper {
 
 	void deleteByTid(Integer id);
 
-}
+
+}

+ 15 - 14
src/main/java/com/goafanti/common/mapper/FinancialPaymentMapper.xml

@@ -114,7 +114,7 @@
       This element is automatically generated by MyBatis Generator, do not modify.
       This element was generated on Tue Jun 16 16:45:09 CST 2020.
     -->
-    select 
+    select
     <include refid="Base_Column_List" />
     from financial_payment
     where id = #{id,jdbcType=INTEGER}
@@ -145,9 +145,9 @@
       This element is automatically generated by MyBatis Generator, do not modify.
       This element was generated on Tue Jun 16 16:45:09 CST 2020.
     -->
-    insert into financial_payment (id, pid, party_amount, 
+    insert into financial_payment (id, pid, party_amount,
       payment_time, create_time)
-    values (#{id,jdbcType=INTEGER}, #{pid,jdbcType=INTEGER}, #{partyAmount,jdbcType=DECIMAL}, 
+    values (#{id,jdbcType=INTEGER}, #{pid,jdbcType=INTEGER}, #{partyAmount,jdbcType=DECIMAL},
       #{paymentTime,jdbcType=TIMESTAMP}, #{createTime,jdbcType=TIMESTAMP})
   </insert>
   <insert id="insertSelective" parameterType="com.goafanti.common.model.FinancialPayment">
@@ -192,8 +192,8 @@
       </if>
     </trim>
   </insert>
-  
-  
+
+
   <insert id="insertSelectiveGetId" keyColumn="id" keyProperty="id" parameterType="com.goafanti.common.model.FinancialPayment" useGeneratedKeys="true">
     insert into financial_payment
     <trim prefix="(" suffix=")" suffixOverrides=",">
@@ -326,22 +326,23 @@
     where id = #{id,jdbcType=INTEGER}
   </update>
   <select id="selectByPid" resultType="com.goafanti.organization.bo.outFinancialPayment">
-  select id,pid,party_amount partyAmount,date_format(payment_time,'%Y-%m-%d') paymentTimes 
+  select id,pid,party_amount partyAmount,date_format(payment_time,'%Y-%m-%d') paymentTimes
   from financial_payment where pid= #{id}
   </select>
   <select id="selectBypidGetNotice" resultType="com.goafanti.organization.bo.NoticeInformationBo">
 	select b.id pid,d.order_no orderNo,d.salesman_id salesmanId,d.salesman_name salesmanName , d.buyer_name buyerName,
 	d.finance_id financeId,d.finance_name financeName,ta.name techName ,sa.email salesmanEmail,fa.email financeEmail,
-	ta.email techEmail,ta.id techId	from  t_order_payment b left join t_order_task c on b.tid=c.id 
-	left join t_order_mid d on c.order_no=d.order_no left join admin sa on d.salesman_id=sa.id 
+	ta.email techEmail,ta.id techId	from  t_order_payment b left join t_order_task c on b.tid=c.id
+	left join t_order_mid d on c.order_no=d.order_no left join admin sa on d.salesman_id=sa.id
 	left join admin fa on d.finance_id=fa.id left join admin ta on c.task_receiver=ta.id
 	where b.id= #{pid}
   </select>
-  
+
   <select id="updateOrderCost">
-  update t_order_mid x ,(select a.id,a.tid,b.order_no from t_order_payment a left join t_order_task b on a.tid=b.id 
-	where a.id=#{pid})y,t_task_mid z set x.payment_amount= x.payment_amount+ #{partyAmount}, z.party_amount=z.party_amount+ #{partyAmount}
-  where x.order_no=y.order_no and y.tid=z.tid
+  update  t_order_payment a,t_task_mid z,t_order_task b,t_order_new  c,t_order_mid d
+  set  z.party_amount=z.party_amount+ #{partyAmount} ,d.expect_profit =c.total_amount -d.cost_amount,
+       d.actual_profit =c.total_amount -d.payment_amount
+  where a.id=#{pid} and a.tid=z.tid and a.tid=b.id and b.order_no =c.order_no and c.order_no =d.order_no
   </select>
-  
-</mapper>
+
+</mapper>

+ 70 - 20
src/main/java/com/goafanti/common/mapper/PaymentNodeMapper.xml

@@ -98,7 +98,7 @@
       This element is automatically generated by MyBatis Generator, do not modify.
       This element was generated on Tue Jul 07 13:58:53 CST 2020.
     -->
-    id, tid, cid, company_name, project_type, dun_type, unit_price, quantity, total_amount, 
+    id, tid, cid, company_name, project_type, dun_type, unit_price, quantity, total_amount,
     party_amount, party_time, create_time, dun_status, effective_count, start_time, status
   </sql>
   <select id="selectByExample" parameterType="com.goafanti.common.model.PaymentNodeExample" resultMap="BaseResultMap">
@@ -126,7 +126,7 @@
       This element is automatically generated by MyBatis Generator, do not modify.
       This element was generated on Tue Jul 07 13:58:53 CST 2020.
     -->
-    select 
+    select
     <include refid="Base_Column_List" />
     from payment_node
     where id = #{id,jdbcType=INTEGER}
@@ -157,17 +157,17 @@
       This element is automatically generated by MyBatis Generator, do not modify.
       This element was generated on Tue Jul 07 13:58:53 CST 2020.
     -->
-    insert into payment_node (id, tid, cid, 
-      company_name, project_type, dun_type, 
-      unit_price, quantity, total_amount, 
-      party_amount, party_time, create_time, 
-      dun_status, effective_count, start_time, 
+    insert into payment_node (id, tid, cid,
+      company_name, project_type, dun_type,
+      unit_price, quantity, total_amount,
+      party_amount, party_time, create_time,
+      dun_status, effective_count, start_time,
       status)
-    values (#{id,jdbcType=INTEGER}, #{tid,jdbcType=INTEGER}, #{cid,jdbcType=INTEGER}, 
-      #{companyName,jdbcType=VARCHAR}, #{projectType,jdbcType=INTEGER}, #{dunType,jdbcType=INTEGER}, 
-      #{unitPrice,jdbcType=DECIMAL}, #{quantity,jdbcType=INTEGER}, #{totalAmount,jdbcType=DECIMAL}, 
-      #{partyAmount,jdbcType=DECIMAL}, #{partyTime,jdbcType=TIMESTAMP}, #{createTime,jdbcType=TIMESTAMP}, 
-      #{dunStatus,jdbcType=INTEGER}, #{effectiveCount,jdbcType=INTEGER}, #{startTime,jdbcType=TIMESTAMP}, 
+    values (#{id,jdbcType=INTEGER}, #{tid,jdbcType=INTEGER}, #{cid,jdbcType=INTEGER},
+      #{companyName,jdbcType=VARCHAR}, #{projectType,jdbcType=INTEGER}, #{dunType,jdbcType=INTEGER},
+      #{unitPrice,jdbcType=DECIMAL}, #{quantity,jdbcType=INTEGER}, #{totalAmount,jdbcType=DECIMAL},
+      #{partyAmount,jdbcType=DECIMAL}, #{partyTime,jdbcType=TIMESTAMP}, #{createTime,jdbcType=TIMESTAMP},
+      #{dunStatus,jdbcType=INTEGER}, #{effectiveCount,jdbcType=INTEGER}, #{startTime,jdbcType=TIMESTAMP},
       #{status,jdbcType=INTEGER})
   </insert>
   <insert id="insertSelective" parameterType="com.goafanti.common.model.PaymentNode">
@@ -457,8 +457,9 @@
       status = #{status,jdbcType=INTEGER}
     where id = #{id,jdbcType=INTEGER}
   </update>
-  
-  <select id="selectByTid" resultType="com.goafanti.organization.bo.OutPaymentNode">
+
+
+    <select id="selectByTid" resultType="com.goafanti.organization.bo.OutPaymentNode">
   select id,tid,cid,company_name companyName,unit_price unitPrice,quantity,total_amount totalAmount,create_time createTime,status,
    party_amount partyAmount, date_format(party_time,'%Y-%m-%d')partyTimes,project_type projectType,dun_type dunType
    from payment_node where tid= #{tid}
@@ -471,7 +472,7 @@
    party_amount partyAmount,party_time partyTime, date_format(party_time,'%Y-%m-%d')partyTimes,project_type projectType,dun_type dunType
    from payment_node where dun_status = #{status}
   </select>
-  
+
   <select id="selectBytidGetEmail" resultType="com.goafanti.common.bo.paymentNodeEmailBo">
     select a.tid,b.order_no orderNo,o.contract_no contractNo ,c.salesman_id salesmanId, c.salesman_name salesmanName,
            c.buyer_name userName,d.email
@@ -479,7 +480,7 @@
     left join t_order_mid c on b.order_no=c.order_no left join admin d on  c.salesman_id=d.id
     where a.tid= #{tid} limit 1
   </select>
-  
+
    <select id="selectByTidAndCid" resultType="com.goafanti.organization.bo.OutPaymentNode">
     select id,tid,cid,company_name companyName,unit_price unitPrice,quantity,total_amount totalAmount,create_time createTime,
    party_amount partyAmount, date_format(party_time,'%Y-%m-%d')partyTimes,project_type projectType,dun_type dunType
@@ -490,7 +491,7 @@
    <if test="cid !=null">
    and cid = #{cid}
    </if>
-  </select> 
+  </select>
   <select id="selectByCid" resultType="java.lang.Integer">
   select count(*) from payment_node where cid= #{tpcId}
   </select>
@@ -502,7 +503,56 @@
     </if>
     <if test="tid !=null">
     and tid= #{tid}
-    </if> 
+    </if>
   </delete>
-  
-</mapper>
+
+  <update id="updateByCid">
+    update payment_node
+    <set>
+      <if test="tid != null">
+        tid = #{tid,jdbcType=INTEGER},
+      </if>
+      <if test="companyName != null">
+        company_name = #{companyName,jdbcType=VARCHAR},
+      </if>
+      <if test="projectType != null">
+        project_type = #{projectType,jdbcType=INTEGER},
+      </if>
+      <if test="dunType != null">
+        dun_type = #{dunType,jdbcType=INTEGER},
+      </if>
+      <if test="unitPrice != null">
+        unit_price = #{unitPrice,jdbcType=DECIMAL},
+      </if>
+      <if test="quantity != null">
+        quantity = #{quantity,jdbcType=INTEGER},
+      </if>
+      <if test="totalAmount != null">
+        total_amount = #{totalAmount,jdbcType=DECIMAL},
+      </if>
+      <if test="partyAmount != null">
+        party_amount = #{partyAmount,jdbcType=DECIMAL},
+      </if>
+      <if test="partyTime != null">
+        party_time = #{partyTime,jdbcType=TIMESTAMP},
+      </if>
+      <if test="createTime != null">
+        create_time = #{createTime,jdbcType=TIMESTAMP},
+      </if>
+      <if test="dunStatus != null">
+        dun_status = #{dunStatus,jdbcType=INTEGER},
+      </if>
+      <if test="effectiveCount != null">
+        effective_count = #{effectiveCount,jdbcType=INTEGER},
+      </if>
+      <if test="startTime != null">
+        start_time = #{startTime,jdbcType=TIMESTAMP},
+      </if>
+      <if test="status != null">
+        status = #{status,jdbcType=INTEGER},
+      </if>
+    </set>
+    where cid = #{cid,jdbcType=INTEGER}
+  </update>
+
+</mapper>

+ 15 - 3
src/main/java/com/goafanti/common/mapper/TChangeTaskMapper.xml

@@ -444,6 +444,7 @@
   </update>
 
 
+
   <select id="selectBySuper" resultType="com.goafanti.order.bo.TChangeTaskOut">
 	select a.id,a.order_no as orderNo,a.main, c.cname,c.sort cSort,a.commodity_name as commodityName,
   	a.commodity_quantity as commodityQuantity,i.price,a.commodity_id as commodityId,a.type,a.tid,a.receiver_name receiverName,
@@ -470,7 +471,18 @@
     where noc.process_state &lt; 4 and noc.status in (0,1,2)
       and tct.tid= #{tid}
   </select>
-  <select id="selectByServiceYear">
-
-  </select>
+  <update id="updateSuperServiceYear" parameterType="com.goafanti.common.model.TChangeTask">
+    update t_change_task a,(select a.split_super,GROUP_CONCAT(a.service_year) counts
+        from t_change_task a where a.split_status =2 and a.type in (0,1,2)
+        and a.split_super=#{splitSuper} and  a.cid= #{cid}  group by a.split_super)x
+    set a.service_year =x.counts
+    where a.tid =x.split_super and a.cid= #{cid};
+  </update>
+  <update id="updateChangeSuperServiceYear" parameterType="com.goafanti.common.model.TChangeTask">
+    update t_change_task a,(select a.change_split_super,GROUP_CONCAT(a.service_year) counts
+        from t_change_task a where a.split_status =2 and a.type in (0,1,2)
+        and a.change_split_super = #{changeSplitSuper} group by a.change_split_super)x
+    set a.service_year =x.counts
+    where a.id =x.change_split_super
+  </update>
 </mapper>

+ 145 - 32
src/main/java/com/goafanti/common/mapper/TOrderMidMapper.xml

@@ -27,13 +27,24 @@
     <result column="project_type" jdbcType="INTEGER" property="projectType" />
     <result column="service_type" jdbcType="VARCHAR" property="serviceType" />
     <result column="service_project" jdbcType="VARCHAR" property="serviceProject" />
+    <result column="patent_cost" jdbcType="DECIMAL" property="patentCost" />
+    <result column="patent_cost_actual" jdbcType="DECIMAL" property="patentCostActual" />
+    <result column="soft_cost" jdbcType="DECIMAL" property="softCost" />
+    <result column="soft_cost_actual" jdbcType="DECIMAL" property="softCostActual" />
+    <result column="audit_cost" jdbcType="DECIMAL" property="auditCost" />
+    <result column="audit_cost_actual" jdbcType="DECIMAL" property="auditCostActual" />
+    <result column="other_cost" jdbcType="DECIMAL" property="otherCost" />
+    <result column="other_cost_actual" jdbcType="DECIMAL" property="otherCostActual" />
+    <result column="expect_profit" jdbcType="DECIMAL" property="expectProfit" />
+    <result column="actual_profit" jdbcType="DECIMAL" property="actualProfit" />
   </resultMap>
   <sql id="Base_Column_List">
     id, order_no, salesman_id, finance_id, salesman_name, finance_name, final_receivables,
     final_Receivables_time, invoice_amount, create_time, buyer_name, order_receivables,
     order_arrears, payment_amount, cost_amount, dep_name, province_name, legal_affairs,
     dun_start_time, legal_affairs_type, operation_time, legal_affairs_status, project_type,
-    service_type, service_project
+    service_type, service_project, patent_cost, patent_cost_actual, soft_cost, soft_cost_actual,
+    audit_cost, audit_cost_actual, other_cost, other_cost_actual, expect_profit, actual_profit
   </sql>
   <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
     select
@@ -54,7 +65,10 @@
       dep_name, province_name, legal_affairs,
       dun_start_time, legal_affairs_type, operation_time,
       legal_affairs_status, project_type, service_type,
-      service_project)
+      service_project, patent_cost, patent_cost_actual,
+      soft_cost, soft_cost_actual, audit_cost,
+      audit_cost_actual, other_cost, other_cost_actual,
+      expect_profit, actual_profit)
     values (#{orderNo,jdbcType=VARCHAR}, #{salesmanId,jdbcType=VARCHAR}, #{financeId,jdbcType=VARCHAR},
       #{salesmanName,jdbcType=VARCHAR}, #{financeName,jdbcType=VARCHAR}, #{finalReceivables,jdbcType=DECIMAL},
       #{finalReceivablesTime,jdbcType=TIMESTAMP}, #{invoiceAmount,jdbcType=DECIMAL},
@@ -63,7 +77,10 @@
       #{depName,jdbcType=VARCHAR}, #{provinceName,jdbcType=VARCHAR}, #{legalAffairs,jdbcType=INTEGER},
       #{dunStartTime,jdbcType=TIMESTAMP}, #{legalAffairsType,jdbcType=INTEGER}, #{operationTime,jdbcType=DATE},
       #{legalAffairsStatus,jdbcType=INTEGER}, #{projectType,jdbcType=INTEGER}, #{serviceType,jdbcType=VARCHAR},
-      #{serviceProject,jdbcType=VARCHAR})
+      #{serviceProject,jdbcType=VARCHAR}, #{patentCost,jdbcType=DECIMAL}, #{patentCostActual,jdbcType=DECIMAL},
+      #{softCost,jdbcType=DECIMAL}, #{softCostActual,jdbcType=DECIMAL}, #{auditCost,jdbcType=DECIMAL},
+      #{auditCostActual,jdbcType=DECIMAL}, #{otherCost,jdbcType=DECIMAL}, #{otherCostActual,jdbcType=DECIMAL},
+      #{expectProfit,jdbcType=DECIMAL}, #{actualProfit,jdbcType=DECIMAL})
   </insert>
   <insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.goafanti.common.model.TOrderMid" useGeneratedKeys="true">
     insert into t_order_mid
@@ -140,6 +157,36 @@
       <if test="serviceProject != null">
         service_project,
       </if>
+      <if test="patentCost != null">
+        patent_cost,
+      </if>
+      <if test="patentCostActual != null">
+        patent_cost_actual,
+      </if>
+      <if test="softCost != null">
+        soft_cost,
+      </if>
+      <if test="softCostActual != null">
+        soft_cost_actual,
+      </if>
+      <if test="auditCost != null">
+        audit_cost,
+      </if>
+      <if test="auditCostActual != null">
+        audit_cost_actual,
+      </if>
+      <if test="otherCost != null">
+        other_cost,
+      </if>
+      <if test="otherCostActual != null">
+        other_cost_actual,
+      </if>
+      <if test="expectProfit != null">
+        expect_profit,
+      </if>
+      <if test="actualProfit != null">
+        actual_profit,
+      </if>
     </trim>
     <trim prefix="values (" suffix=")" suffixOverrides=",">
       <if test="orderNo != null">
@@ -214,6 +261,36 @@
       <if test="serviceProject != null">
         #{serviceProject,jdbcType=VARCHAR},
       </if>
+      <if test="patentCost != null">
+        #{patentCost,jdbcType=DECIMAL},
+      </if>
+      <if test="patentCostActual != null">
+        #{patentCostActual,jdbcType=DECIMAL},
+      </if>
+      <if test="softCost != null">
+        #{softCost,jdbcType=DECIMAL},
+      </if>
+      <if test="softCostActual != null">
+        #{softCostActual,jdbcType=DECIMAL},
+      </if>
+      <if test="auditCost != null">
+        #{auditCost,jdbcType=DECIMAL},
+      </if>
+      <if test="auditCostActual != null">
+        #{auditCostActual,jdbcType=DECIMAL},
+      </if>
+      <if test="otherCost != null">
+        #{otherCost,jdbcType=DECIMAL},
+      </if>
+      <if test="otherCostActual != null">
+        #{otherCostActual,jdbcType=DECIMAL},
+      </if>
+      <if test="expectProfit != null">
+        #{expectProfit,jdbcType=DECIMAL},
+      </if>
+      <if test="actualProfit != null">
+        #{actualProfit,jdbcType=DECIMAL},
+      </if>
     </trim>
   </insert>
   <update id="updateByPrimaryKeySelective" parameterType="com.goafanti.common.model.TOrderMid">
@@ -291,6 +368,36 @@
       <if test="serviceProject != null">
         service_project = #{serviceProject,jdbcType=VARCHAR},
       </if>
+      <if test="patentCost != null">
+        patent_cost = #{patentCost,jdbcType=DECIMAL},
+      </if>
+      <if test="patentCostActual != null">
+        patent_cost_actual = #{patentCostActual,jdbcType=DECIMAL},
+      </if>
+      <if test="softCost != null">
+        soft_cost = #{softCost,jdbcType=DECIMAL},
+      </if>
+      <if test="softCostActual != null">
+        soft_cost_actual = #{softCostActual,jdbcType=DECIMAL},
+      </if>
+      <if test="auditCost != null">
+        audit_cost = #{auditCost,jdbcType=DECIMAL},
+      </if>
+      <if test="auditCostActual != null">
+        audit_cost_actual = #{auditCostActual,jdbcType=DECIMAL},
+      </if>
+      <if test="otherCost != null">
+        other_cost = #{otherCost,jdbcType=DECIMAL},
+      </if>
+      <if test="otherCostActual != null">
+        other_cost_actual = #{otherCostActual,jdbcType=DECIMAL},
+      </if>
+      <if test="expectProfit != null">
+        expect_profit = #{expectProfit,jdbcType=DECIMAL},
+      </if>
+      <if test="actualProfit != null">
+        actual_profit = #{actualProfit,jdbcType=DECIMAL},
+      </if>
     </set>
     where id = #{id,jdbcType=INTEGER}
   </update>
@@ -319,7 +426,17 @@
       legal_affairs_status = #{legalAffairsStatus,jdbcType=INTEGER},
       project_type = #{projectType,jdbcType=INTEGER},
       service_type = #{serviceType,jdbcType=VARCHAR},
-      service_project = #{serviceProject,jdbcType=VARCHAR}
+      service_project = #{serviceProject,jdbcType=VARCHAR},
+      patent_cost = #{patentCost,jdbcType=DECIMAL},
+      patent_cost_actual = #{patentCostActual,jdbcType=DECIMAL},
+      soft_cost = #{softCost,jdbcType=DECIMAL},
+      soft_cost_actual = #{softCostActual,jdbcType=DECIMAL},
+      audit_cost = #{auditCost,jdbcType=DECIMAL},
+      audit_cost_actual = #{auditCostActual,jdbcType=DECIMAL},
+      other_cost = #{otherCost,jdbcType=DECIMAL},
+      other_cost_actual = #{otherCostActual,jdbcType=DECIMAL},
+      expect_profit = #{expectProfit,jdbcType=DECIMAL},
+      actual_profit = #{actualProfit,jdbcType=DECIMAL}
     where id = #{id,jdbcType=INTEGER}
   </update>
 
@@ -339,7 +456,8 @@
   </update>
   <update id="updatefinalReceivables">
     update t_order_mid set final_receivables= #{amount},`final_Receivables_time`= #{receivablesTime},
-                           order_arrears=if(order_arrears- #{amount} &lt; 0,0,order_arrears- #{amount})
+      order_arrears=if(order_arrears- #{amount} &lt; 0,0,order_arrears- #{amount}),
+      actual_profit=#{count}-payment_amount
     where order_no= #{orderNo}
   </update>
   <update id="updateInvoice">
@@ -352,27 +470,22 @@
 
 
   <update id="updateCostAmount">
-    update t_order_task a ,t_order_mid b
-    <set>
-      <if test="cost !=null">
-        b.cost_amount= #{cost},
-      </if>
-      <if test="payment !=null">
-        b.payment_amount= #{payment},
-      </if>
-    </set>
-    where  a.order_no=b.order_no and a.id= #{tid}
+    update t_order_mid x,(select x.order_no,sum(cost)cost,sum(party)party, sum(if(type = 1, cost, 0))zlc, sum(if(type = 1, party, 0))zlf,
+     sum(if(type = 2, cost, 0))rzc, sum(if(type = 2, party, 0))rzf, sum(if(type = 3, cost, 0))sjc, sum(if(type = 3, party, 0))sjf,
+     sum(if(type = 0 or type>3, cost, 0))qtc, sum(if(type = 0 or type>3, party, 0))qtf
+    from(select b.order_no, c.`type`, sum(cost_amount)cost, sum(party_amount)party
+         from t_task_mid a left join t_order_task b on a.tid = b.id left join business_project c on b.commodity_id = c.id
+                           left join t_order_new d on b.order_no = d.order_no left join t_order_outsource too on a.tid =too.tid
+         where   too.`type` =1 and too.refund_status =1 and d.delete_sign in (0,2) and b.order_no = #{orderNo}
+         group by b.order_no , c.`type`)x group by x.order_no)y,t_order_new z
+    set x.cost_amount =y.cost,x.payment_amount =y.party,x.patent_cost =y.zlc,x.patent_cost_actual =y.zlf,
+        x.soft_cost =y.rzc,x.soft_cost_actual =y.rzf,x.audit_cost =y.sjc,x.audit_cost_actual =y.sjf,
+        x.other_cost =qtc,x.other_cost_actual =y.qtf,x.expect_profit =z.total_amount-y.cost,
+        x.actual_profit =z.settlement_amount-y.party
+    where x.order_no =y.order_no and x.order_no=z.order_no
   </update>
 
-  <update id="updateAddCostAmount">
-    update t_order_task a ,t_order_mid b
-    <set>
-      <if test="cost !=null">
-        b.cost_amount= b.cost_amount+#{cost},
-      </if>
-    </set>
-    where  a.order_no=b.order_no and a.id= #{tid}
-  </update>
+
   <update id="updateByOrderNo">
     update t_order_mid
     <set>
@@ -588,12 +701,12 @@
     where d.sort =6 and a.order_no = #{orderNo}
   </select>
 
-  <update id="updateCountProjectAndType">
-    update t_order_mid a ,(select a.order_no ,GROUP_CONCAT(DISTINCT a.commodity_name )pname, GROUP_CONCAT(DISTINCT c.cname )cname
-                           from t_order_task a left join business_project b on a.commodity_id =b.id
-                                               left join business_category c on b.cid =c.id
-                           group by a.order_no )b
-    set a.service_project =b.pname,a.service_type =b.cname
-    where a.order_no=b.order_no and a.order_no = #{orderNo};
-  </update>
+
+
+
+  <select id="selectAll" resultType="com.goafanti.common.model.TOrderMid">
+    select order_no orderNo
+    from t_order_mid
+  </select>
+
 </mapper>

+ 13 - 10
src/main/java/com/goafanti/common/mapper/TOrderNewMapper.xml

@@ -736,16 +736,19 @@
   </select>
   <!-- 财务专员查看需要待收款的数据 -->
   <select id="financeList" parameterType="Map" resultType="com.goafanti.order.bo.OrderListBo">
- select o.order_no as orderNo, o.sign_time as signTime, u.nickname as buyerName, o.order_status as orderStatus,a.finance_name financeName,
-	a.cost_amount costAmount,a.payment_amount paymentAmount,o.process_status as processStatus, o.settlement_amount as actuallyTotalAmount,
-	o.contract_no as contractNo, o.approval, o.back_status backStatus,a.salesman_name as sellerName, o.salesman_id as sellerId,
-	o.buyer_id as buyerId, o.liquidation_status as liquidationStatus ,too.amount outsourceAmount, o.first_amount as signFirstPayment,
-	o.total_amount as signTotalAmount, date_format(o.create_time, '%Y-%m-%d %H:%i:%s') as createTime, too.company_name as outsourceName,
-	0 as companyId, d.name as departmentName, a.final_receivables finalReceivables ,a.invoice_amount invoiceAmount ,
-    o.order_status orderStatus,a.project_type projectType,o.sales_type salesType,o.other ,o.delete_sign deleteSign,
-    date_format(a.`final_Receivables_time`, '%Y-%m-%d %H:%i:%s')finalReceivablesTime,a.order_receivables orderReceivables,a.order_arrears orderArrears
-	from t_order_new o left join department d on o.order_dep = d.id left join `user` u on o.buyer_id = u.id left join t_order_mid a on o.order_no=a.order_no
-	left join (select * from  t_order_outsource where type=0) too on o.order_no=too.order_no where delete_sign in(0,2) and approval in(0,1,2,4,5)
+    select o.order_no as orderNo, o.sign_time as signTime, u.nickname as buyerName, o.order_status as orderStatus,a.finance_name financeName,
+      a.cost_amount costAmount,a.payment_amount paymentAmount,o.process_status as processStatus, o.settlement_amount as actuallyTotalAmount,
+      o.contract_no as contractNo, o.approval, o.back_status backStatus,a.salesman_name as sellerName, o.salesman_id as sellerId,
+      o.buyer_id as buyerId, o.liquidation_status as liquidationStatus ,too.amount outsourceAmount, o.first_amount as signFirstPayment,
+      o.total_amount as signTotalAmount, date_format(o.create_time, '%Y-%m-%d %H:%i:%s') as createTime, too.company_name as outsourceName,
+      0 as companyId, d.name as departmentName, a.final_receivables finalReceivables ,a.invoice_amount invoiceAmount ,a.order_arrears orderArrears,
+      o.order_status orderStatus,a.project_type projectType,o.sales_type salesType,o.other ,o.delete_sign deleteSign, a.order_receivables orderReceivables,
+      date_format(a.`final_Receivables_time`, '%Y-%m-%d %H:%i:%s')finalReceivablesTime,a.patent_cost patentCost,a.patent_cost_actual patentCostActual ,
+      a.soft_cost softCost ,a.soft_cost_actual softCostActual ,a.audit_cost auditCost ,a.audit_cost_actual auditCostActual ,a.other_cost otherCost ,
+      a.other_cost_actual otherCostActual , a.expect_profit expectProfit ,a.actual_profit  actualProfit,a.service_type serviceType,
+      a.service_project serviceProject
+    from t_order_new o left join department d on o.order_dep = d.id left join `user` u on o.buyer_id = u.id left join t_order_mid a on o.order_no=a.order_no
+    left join (select * from  t_order_outsource where type=0) too on o.order_no=too.order_no where delete_sign in(0,2) and approval in(0,1,2,4,5)
     and outsource=   #{o.outsource,jdbcType=INTEGER}
     <if test="o.processStatus == 3">
       and o.process_status = #{o.processStatus,jdbcType=INTEGER}

+ 15 - 13
src/main/java/com/goafanti/common/mapper/TOrderTaskMapper.xml

@@ -811,16 +811,16 @@
 
   <select id="selectOrderTaskAll" resultType="com.goafanti.order.bo.TOrderTaskBo">
     select a.id,e.contract_no contractNo,a.order_no as orderNo,h.nickname userName,f.name salesmanName,a.outsource_name outsourceName,a.outsource,
-           a.outsource_price outsourcePrice,g.name depName,e.order_status orderStatus,d.name as contacts,d.contact_mobile as contactsMobile,a.main, c.cname,
-           c.sort cSort,a.commodity_name as commodityName,a.commodity_quantity as commodityQuantity,i.price,a.certificate_number as certificateNumber,a.receiver_name receiverName,
-           a.commodity_id as commodityId,a.manager_id managerId,a.consultant_id consultantId,a.project_status as projectStatus,a.set_up_amount setUpAmount,
-           a.task_comment as taskComment ,a.commodity_price as commodityPrice, a.task_status as taskStatus,  a.task_receiver as taskReceiver ,
-           a.split_status splitStatus,a.split_super splitSuper,a.split_aid splitAid,a.split_time splitTime,a.patent_type patentType,ttm.contract_term contractTerm,
-           a.picture_url pictureUrl, ttm.service_life serviceLife ,ttm.service_year serviceYear,ttm.year_sum yearSum,
-            tm.last_year lastYear,tm.last_year_capital lastYearCapital,tm.last_year_income lastYearIncome
-    from t_order_task a left join business_project b on a.commodity_id=b.id left join t_order_new e on a.order_no=e.order_no
-    left join admin f on e.salesman_id=f.id left join department g on e.order_dep=g.id left join user h on e.buyer_id=h.id
-    left join business_project i on a.commodity_id=i.id left join business_category c on b.cid=c.id left join admin d on a.task_receiver=d.id
+    a.outsource_price outsourcePrice,g.name depName,e.order_status orderStatus,d.name as contacts,d.contact_mobile as contactsMobile,a.main, c.cname,
+    c.sort cSort,a.commodity_name as commodityName,a.commodity_quantity as commodityQuantity,i.price,a.certificate_number as certificateNumber,a.receiver_name receiverName,
+    a.commodity_id as commodityId,a.manager_id managerId,a.consultant_id consultantId,a.project_status as projectStatus,a.set_up_amount setUpAmount,
+    a.task_comment as taskComment ,a.commodity_price as commodityPrice, a.task_status as taskStatus,  a.task_receiver as taskReceiver ,
+    a.split_status splitStatus,a.split_super splitSuper,a.split_aid splitAid,a.split_time splitTime,a.patent_type patentType,ttm.contract_term contractTerm,
+    a.picture_url pictureUrl, ttm.service_life serviceLife ,ttm.service_year serviceYear,ttm.year_sum yearSum,
+    tm.last_year lastYear,tm.last_year_capital lastYearCapital,tm.last_year_income lastYearIncome
+    from t_order_task a left join t_order_new e on a.order_no=e.order_no left join admin f on e.salesman_id=f.id
+    left join department g on e.order_dep=g.id left join user h on e.buyer_id=h.id left join business_project i on a.commodity_id=i.id
+    left join business_category c on i.cid=c.id left join admin d on a.task_receiver=d.id
     left join t_task_member ttm on a.id=ttm.tid left join t_task_mid tm on a.id=tm.tid
     where a.super_id is null   and  a.order_no= #{orderNo,jdbcType=VARCHAR}
     <if test="splitStatus !=null">
@@ -1737,9 +1737,10 @@
   </select>
 
   <select id="selectByTidGetDtails" resultType="com.goafanti.organization.bo.ProjectTypePuls">
-    select a.id,a.official_cost officialCost,a.cost_reduction costReduction ,a.commodity_quantity quantity ,a.patent_type patentType,b.patent_name_type projectType,
-           c.amount officialAmount,c.proportion85,b.patent_type outPatentType from t_order_task a left join t_order_outsource b on a.id=b.tid
-                                                                                                  left join official_fee_price c on a.patent_type =c.patent_type and b.patent_name_type =c.`type`
+    select a.id,a.order_no orderNo,a.official_cost officialCost,a.cost_reduction costReduction ,a.commodity_quantity quantity ,a.patent_type patentType,
+           b.patent_name_type projectType, c.amount officialAmount,c.proportion85,b.patent_type outPatentType,d.type
+    from t_order_task a left join t_order_outsource b on a.id=b.tid left join official_fee_price c on a.patent_type =c.patent_type and b.patent_name_type =c.`type`
+    left join business_project d on a.commodity_id=d.id
     where a.id= #{tid}
   </select>
   <select id="highNewRetrialStatistics" resultType="com.goafanti.order.bo.OutHighNewRetrialStatistics">
@@ -1940,4 +1941,5 @@
   </select>
 
 
+
 </mapper>

+ 10 - 1
src/main/java/com/goafanti/common/mapper/TTaskMemberMapper.xml

@@ -155,11 +155,20 @@
       where a.id=b.tid and a.split_super = #{id}
     </update>
 
-    <select id="selectByTid" parameterType="java.lang.Integer" resultMap="BaseResultMap">
+
+  <select id="selectByTid" parameterType="java.lang.Integer" resultMap="BaseResultMap">
     select
     <include refid="Base_Column_List" />
     from t_task_member
     where tid = #{id,jdbcType=INTEGER}
   </select>
 
+  <update id="updateServiceYearBySplitSuper">
+    update t_task_member a,(select a.split_super,GROUP_CONCAT(b.service_year) counts
+        from t_order_task a left join t_task_member b on a.id=b.tid
+        where a.split_status =2 and a.split_super= #{tid}
+        group by a.split_super)x
+    set a.service_year =x.counts
+    where a.tid =x.split_super
+  </update>
 </mapper>

+ 2 - 9
src/main/java/com/goafanti/common/mapper/TTaskMidMapper.xml

@@ -347,15 +347,11 @@
     </if>
     where tid = #{tid,jdbcType=INTEGER}
   </update>
-  <select id="selectListByTid" resultType="com.goafanti.common.model.TTaskMid">
-    select c.id,c.tid,c.cost_amount costAmount,c.party_amount partyAmount from t_order_task a left join t_order_task b on a.order_no=b.order_no
-                                                                                              left join t_task_mid c on b.id=c.tid
-    where a.id= #{tid}
-  </select>
+
 
   <update id="updateCostAmount">
     update t_order_task a ,t_task_mid c
-    set c.cost_amount=#{count}
+    set c.cost_amount=#{count},c.party_amount=#{party}
     where  a.id=c.tid and a.id= #{tid}
   </update>
 
@@ -368,9 +364,6 @@
   <update id="updateByTid" parameterType="com.goafanti.common.model.TTaskMid">
     update t_task_mid
     <set>
-      <if test="tid != null">
-        tid = #{tid,jdbcType=INTEGER},
-      </if>
       <if test="costAmount != null">
         cost_amount = #{costAmount,jdbcType=DECIMAL},
       </if>

+ 4 - 2
src/main/java/com/goafanti/common/mapper/ThirdPartyCompanyMapper.xml

@@ -520,11 +520,13 @@
       patent_type = #{patentType,jdbcType=INTEGER}
     where id = #{id,jdbcType=INTEGER}
   </update>
-  <select id="selectByTid" resultType="com.goafanti.organization.bo.OutThirdPartyCompany">
+
+    <select id="selectByTid" resultType="com.goafanti.organization.bo.OutThirdPartyCompany">
 	 select a.id,a.tid,a.company_name companyName,a.unit_price unitPrice,a.quantity,a.total_amount totalAmount,a.material,a.urgent,
 	a.patent_name_type patentNameType,a.audit,a.assets,a.income,a.remarks,a.cid,b.cost_reduction costReduction,b.official_cost officialCost,
 	a.type,a.party_amount partyAmount ,op.amount officialUnitPrice,op.proportion85 reductionAmount,a.start_type startType,a.patent_type patentType
-	from third_party_company a left join t_order_task b on a.tid=b.id  left join official_fee_price op on b.patent_type =op.patent_type  and a.patent_name_type =op.`type`
+	from third_party_company a left join t_order_task b on a.tid=b.id
+	left join official_fee_price op on b.patent_type =op.patent_type  and a.patent_name_type =op.`type`
  where tid= #{tid}
   </select>
 <!--   <select id="selectByTidPuls" resultType="com.goafanti.organization.bo.ProjectTypePuls">

+ 131 - 1
src/main/java/com/goafanti/common/model/TOrderMid.java

@@ -75,7 +75,7 @@ public class TOrderMid implements Serializable {
     private BigDecimal orderArrears;
 
     /**
-     * 支付金额
+     * 成本实付
      */
     private BigDecimal paymentAmount;
 
@@ -134,6 +134,56 @@ public class TOrderMid implements Serializable {
      */
     private String serviceProject;
 
+    /**
+     * 专利成本
+     */
+    private BigDecimal patentCost;
+
+    /**
+     * 专利成本实付
+     */
+    private BigDecimal patentCostActual;
+
+    /**
+     * 软著成本
+     */
+    private BigDecimal softCost;
+
+    /**
+     * 软著成本实付
+     */
+    private BigDecimal softCostActual;
+
+    /**
+     * 审计成本
+     */
+    private BigDecimal auditCost;
+
+    /**
+     * 审计成本实付
+     */
+    private BigDecimal auditCostActual;
+
+    /**
+     * 其他成本
+     */
+    private BigDecimal otherCost;
+
+    /**
+     * 其他成本实付
+     */
+    private BigDecimal otherCostActual;
+
+    /**
+     * 预计毛利
+     */
+    private BigDecimal expectProfit;
+
+    /**
+     * 实际毛利
+     */
+    private BigDecimal actualProfit;
+
     private static final long serialVersionUID = 1L;
 
     public Integer getId() {
@@ -335,4 +385,84 @@ public class TOrderMid implements Serializable {
     public void setServiceProject(String serviceProject) {
         this.serviceProject = serviceProject;
     }
+
+    public BigDecimal getPatentCost() {
+        return patentCost;
+    }
+
+    public void setPatentCost(BigDecimal patentCost) {
+        this.patentCost = patentCost;
+    }
+
+    public BigDecimal getPatentCostActual() {
+        return patentCostActual;
+    }
+
+    public void setPatentCostActual(BigDecimal patentCostActual) {
+        this.patentCostActual = patentCostActual;
+    }
+
+    public BigDecimal getSoftCost() {
+        return softCost;
+    }
+
+    public void setSoftCost(BigDecimal softCost) {
+        this.softCost = softCost;
+    }
+
+    public BigDecimal getSoftCostActual() {
+        return softCostActual;
+    }
+
+    public void setSoftCostActual(BigDecimal softCostActual) {
+        this.softCostActual = softCostActual;
+    }
+
+    public BigDecimal getAuditCost() {
+        return auditCost;
+    }
+
+    public void setAuditCost(BigDecimal auditCost) {
+        this.auditCost = auditCost;
+    }
+
+    public BigDecimal getAuditCostActual() {
+        return auditCostActual;
+    }
+
+    public void setAuditCostActual(BigDecimal auditCostActual) {
+        this.auditCostActual = auditCostActual;
+    }
+
+    public BigDecimal getOtherCost() {
+        return otherCost;
+    }
+
+    public void setOtherCost(BigDecimal otherCost) {
+        this.otherCost = otherCost;
+    }
+
+    public BigDecimal getOtherCostActual() {
+        return otherCostActual;
+    }
+
+    public void setOtherCostActual(BigDecimal otherCostActual) {
+        this.otherCostActual = otherCostActual;
+    }
+
+    public BigDecimal getExpectProfit() {
+        return expectProfit;
+    }
+
+    public void setExpectProfit(BigDecimal expectProfit) {
+        this.expectProfit = expectProfit;
+    }
+
+    public BigDecimal getActualProfit() {
+        return actualProfit;
+    }
+
+    public void setActualProfit(BigDecimal actualProfit) {
+        this.actualProfit = actualProfit;
+    }
 }

+ 2 - 1
src/main/java/com/goafanti/customer/service/impl/CustomerServiceImpl.java

@@ -2237,13 +2237,13 @@ public class CustomerServiceImpl extends BaseMybatisDao<UserMapper> implements C
 	public void pushReleaseLog(List<LockingReleaseBo> list, Integer type) throws InterruptedException {
 		Date date = new Date();
 		List<LockingReleaseBo> newList = new ArrayList<LockingReleaseBo>();
+		List<UserTransferLog> list3 = new ArrayList<UserTransferLog>();
 		if (list != null && list.size() > 0) {
 			for (int i = 0; i < list.size(); i++) {
 				newList.add(list.get(i));
 				if (50 == newList.size() || i == list.size() - 1) {
 					if (newList.size() > 0) {
 						// 处理日志
-						List<UserTransferLog> list3 = new ArrayList<UserTransferLog>();
 						for (LockingReleaseBo lrb : newList) {
 							UserTransferLog utl = new UserTransferLog();
 							utl.setAid(lrb.getAid());
@@ -2256,6 +2256,7 @@ public class CustomerServiceImpl extends BaseMybatisDao<UserMapper> implements C
 							list3.add(utl);
 						}
 						userTransferLogMapper.insertList(list3);
+						list3.clear();
 					}
 					newList.clear();
 					Thread.sleep(2000);

+ 132 - 0
src/main/java/com/goafanti/order/bo/OrderListBo.java

@@ -41,6 +41,27 @@ public class OrderListBo {
 	private BigDecimal  costAmount;
 	@Excel(name = "已付成本(万元)" ,scale = 6)
 	private BigDecimal paymentAmount;
+	@Excel(name = "专利成本(万元)" ,scale = 6)
+	private BigDecimal patentCost;
+	@Excel(name = "专利成本实付(万元)" ,scale = 6)
+	private BigDecimal patentCostActual;
+	@Excel(name = "软著成本(万元)" ,scale = 6)
+	private BigDecimal softCost;
+	@Excel(name = "软著成本实付(万元)" ,scale = 6)
+	private BigDecimal softCostActual;
+	@Excel(name = "审计成本(万元)" ,scale = 6)
+	private BigDecimal auditCost;
+	@Excel(name = "审计成本实付(万元)" ,scale = 6)
+	private BigDecimal auditCostActual;
+	@Excel(name = "其他成本(万元)" ,scale = 6)
+	private BigDecimal otherCost;
+	@Excel(name = "其他成本实付(万元)" ,scale = 6)
+	private BigDecimal otherCostActual;
+	@Excel(name = "预计毛利(万元)" ,scale = 6)
+	private BigDecimal expectProfit;
+	@Excel(name = "实际毛利(万元)" ,scale = 6)
+
+	private BigDecimal actualProfit;
 	@Excel(name = "最近收款(万元)",scale = 6)
 	private BigDecimal finalReceivables;
 	@Excel(name = "最近收款时间")
@@ -55,6 +76,10 @@ public class OrderListBo {
 	private Integer orderType;
 	@Excel(name="会员" ,readConverterExp = "0=否,1=是")
 	private Integer projectType;
+	@Excel(name = "订单类型")
+	private String serviceType;
+	@Excel(name = "订单内容",width = 32)
+	private String serviceProject;
 
 	/** 合同首付金额 **/
 	private BigDecimal signFirstPayment;
@@ -122,6 +147,113 @@ public class OrderListBo {
 	@Excel(name="销售说明")
 	private String other;
 
+
+	private String departmentId;
+
+	public String getServiceType() {
+		return serviceType;
+	}
+
+	public void setServiceType(String serviceType) {
+		this.serviceType = serviceType;
+	}
+
+	public String getServiceProject() {
+		return serviceProject;
+	}
+
+	public void setServiceProject(String serviceProject) {
+		this.serviceProject = serviceProject;
+	}
+
+	public String getDepartmentId() {
+		return departmentId;
+	}
+
+	public void setDepartmentId(String departmentId) {
+		this.departmentId = departmentId;
+	}
+
+	public BigDecimal getPatentCost() {
+		return patentCost;
+	}
+
+	public void setPatentCost(BigDecimal patentCost) {
+		this.patentCost = patentCost;
+	}
+
+	public BigDecimal getPatentCostActual() {
+		return patentCostActual;
+	}
+
+	public void setPatentCostActual(BigDecimal patentCostActual) {
+		this.patentCostActual = patentCostActual;
+	}
+
+	public BigDecimal getSoftCost() {
+		return softCost;
+	}
+
+	public void setSoftCost(BigDecimal softCost) {
+		this.softCost = softCost;
+	}
+
+	public BigDecimal getSoftCostActual() {
+		return softCostActual;
+	}
+
+	public void setSoftCostActual(BigDecimal softCostActual) {
+		this.softCostActual = softCostActual;
+	}
+
+	public BigDecimal getAuditCost() {
+		return auditCost;
+	}
+
+	public void setAuditCost(BigDecimal auditCost) {
+		this.auditCost = auditCost;
+	}
+
+	public BigDecimal getAuditCostActual() {
+		return auditCostActual;
+	}
+
+	public void setAuditCostActual(BigDecimal auditCostActual) {
+		this.auditCostActual = auditCostActual;
+	}
+
+	public BigDecimal getOtherCost() {
+		return otherCost;
+	}
+
+	public void setOtherCost(BigDecimal otherCost) {
+		this.otherCost = otherCost;
+	}
+
+	public BigDecimal getOtherCostActual() {
+		return otherCostActual;
+	}
+
+	public void setOtherCostActual(BigDecimal otherCostActual) {
+		this.otherCostActual = otherCostActual;
+	}
+
+	public BigDecimal getExpectProfit() {
+		return expectProfit;
+	}
+
+	public void setExpectProfit(BigDecimal expectProfit) {
+		this.expectProfit = expectProfit;
+	}
+
+	public BigDecimal getActualProfit() {
+		return actualProfit;
+	}
+
+	public void setActualProfit(BigDecimal actualProfit) {
+		this.actualProfit = actualProfit;
+	}
+
 	public String getDeps() {
 		return deps;
 	}

+ 2 - 0
src/main/java/com/goafanti/order/service/OrderProjectService.java

@@ -132,4 +132,6 @@ public interface OrderProjectService {
 	 * @return
 	 */
 	Integer getOrderProcessStatus(String orderNo);
+
+    void updateMidServiceProject(String orderNo);
 }

+ 23 - 4
src/main/java/com/goafanti/order/service/impl/OrderChangeServiceImpl.java

@@ -275,6 +275,9 @@ public class OrderChangeServiceImpl extends BaseMybatisDao<NewOrderChangeMapper>
 						return 1;
 					}
 				}else {
+					if(nb.getProcessState()==8) {//董事长项目变更通过
+						nb.setStatus(2);
+					}
 					if (nb.getChangeAmount().compareTo(new BigDecimal("0.2"))<0) {//小于则总裁通过,大于则董事长
 						if(nb.getProcessState()==7) {//总裁项目变更通过
 							nb.setStatus(2);
@@ -284,9 +287,6 @@ public class OrderChangeServiceImpl extends BaseMybatisDao<NewOrderChangeMapper>
 							nb.setProcessState(nb.getProcessState()+1);
 						}
 					}
-					if(nb.getProcessState()==8) {//董事长项目变更通过
-						nb.setStatus(2);
-					}
 					//营销管理通过则设置技术管理员通过表
 					if(nb.getProcessState()==1){
 						if (orderExamineMapper.checkCountStatus(orderNo,null,null)<1) {
@@ -772,7 +772,7 @@ public class OrderChangeServiceImpl extends BaseMybatisDao<NewOrderChangeMapper>
 		//清算状态 0-首付待付请,1-尾款待付清,2-已付请,3-部分退款,4-全部退款
 		o.setLiquidationStatus(OrderUtils.getLiquidationStatus(o));
 		tOrderNewMapper.updateByPrimaryKeySelective(o);
-		tOrderMidMapper.updateCountProjectAndType(o.getOrderNo());
+		orderProjectService.updateMidServiceProject(o.getOrderNo());
 		return o;
 	}
 
@@ -785,6 +785,7 @@ public class OrderChangeServiceImpl extends BaseMybatisDao<NewOrderChangeMapper>
 		HashMap<Integer, Integer> map=changeAddOrderTask(listct,null);
 		List<TChangeTaskOut> listct2=tChangeTaskMapper.selectByCid(id,2);
 		changeAddOrderTask(listct2,map);
+		//处理主项目显示派单年份
 		List<TChangeDunOut> listcd=tChangeDunMapper.selectByCid(id);
 		for (TChangeDunOut cd : listcd) {
 			NewOrderDun nd=new NewOrderDun();
@@ -838,9 +839,11 @@ public class OrderChangeServiceImpl extends BaseMybatisDao<NewOrderChangeMapper>
 				ot.setSplitStatus(cd.getSplitStatus());
 				if (cd.getSplitStatus()==2){
 					Integer tid;
+					//如果原本有上级直接使用
 					if (cd.getSplitSuper()!=null){
 						ot.setSplitSuper(cd.getSplitSuper());
 					}else {
+						//如果没有,原本项目,这用获取新增的项目
 						if (cd.getTid()!=null){
 							tid=cd.getTid();
 						}else{
@@ -881,6 +884,7 @@ public class OrderChangeServiceImpl extends BaseMybatisDao<NewOrderChangeMapper>
 			}else if(cd.getType()==3) {
 				tOrderTaskMapper.deleteByPrimaryKey(cd.getTid());
 			}
+
 		}
 		return map;
 	}
@@ -1097,12 +1101,14 @@ public class OrderChangeServiceImpl extends BaseMybatisDao<NewOrderChangeMapper>
 					BusinessProject bp = businessProjectMapper.selectByPrimaryKey(tt.getCommodityId());
 					Integer member=null;
 					if (t.getType()==3) {
+
 						//删除首先将项目删除,然后将所属催款做删除
 						if (bp.getType()==7)member=1;
 						tChangeTaskMapper.updateByTid(t.getTid(),null,tt.getCid(),3,member);
 						if (tt.getSplitStatus()==0) {
 							tChangeDunMapper.updateByTid(tt.getTid(),tt.getCid(),3);
 						}else if (tt.getSplitStatus()==1) {
+							t.setServiceYear("");
 							//删除父类下所有的子类
 							if (tt.getType()==1){
 								tChangeTaskMapper.deleteByChangeSplitSuper(tt.getTid());
@@ -1290,6 +1296,7 @@ public class OrderChangeServiceImpl extends BaseMybatisDao<NewOrderChangeMapper>
 		TChangeTask tChangeTask = tChangeTaskMapper.selectByPrimaryKey(id);
 		Integer tid=tChangeTask.getTid();
 		tChangeTask.setSplitStatus(1);
+		tChangeTask.setType(2);
 		tChangeTaskMapper.updateByPrimaryKey(tChangeTask);
 		//在判断是否有删除的年份没有就新增
 		tChangeTask.setId(null);
@@ -1305,9 +1312,19 @@ public class OrderChangeServiceImpl extends BaseMybatisDao<NewOrderChangeMapper>
 		tChangeTask.setTaskComment(taskComment);
 		tChangeTask.setServiceYear(serviceYear);
 		tChangeTaskMapper.insertSelective(tChangeTask);
+		//根据上级id修改上级
+		updateSuperServiceYear(tChangeTask);
 		return tChangeTask;
 	}
 
+	public  void updateSuperServiceYear(TChangeTask tChangeTask) {
+		if(tChangeTask.getSplitSuper()!=null){
+			tChangeTaskMapper.updateSuperServiceYear(tChangeTask);
+		}else {
+			tChangeTaskMapper.updateChangeSuperServiceYear(tChangeTask);
+		}
+	}
+
 	@Override
 	public int deleteMemberSonProject(Integer id) {
 		TChangeTask tChangeTask = tChangeTaskMapper.selectByPrimaryKey(id);
@@ -1328,6 +1345,7 @@ public class OrderChangeServiceImpl extends BaseMybatisDao<NewOrderChangeMapper>
 			changeTask.setSplitStatus(0);
 			tChangeTaskMapper.updateByPrimaryKeySelective(changeTask);
 		}
+		updateSuperServiceYear(tChangeTask);
 		return 1;
 	}
 
@@ -1337,6 +1355,7 @@ public class OrderChangeServiceImpl extends BaseMybatisDao<NewOrderChangeMapper>
 		tChangeTask.setType(2);
 		tChangeTask.setTaskComment(taskComment);
 		tChangeTaskMapper.updateByPrimaryKeySelective(tChangeTask);
+		updateSuperServiceYear(tChangeTask);
 		return tChangeTask;
 	}
 

+ 16 - 12
src/main/java/com/goafanti/order/service/impl/OrderNewServiceImpl.java

@@ -133,9 +133,10 @@ public class OrderNewServiceImpl extends BaseMybatisDao<TOrderNewMapper> impleme
 	private OrderProjectService orderProjectService;
 	@Autowired
 	private TTaskMemberMapper tTaskMemberMapper;
-
 	@Autowired
 	private DepartmentService departmentService;
+	@Autowired
+	private TOrderPaymentMapper tOrderPaymentMapper;
 	@Value(value = "${upload.path}")
 	private String					uploadPath			= null;
 
@@ -571,8 +572,7 @@ public class OrderNewServiceImpl extends BaseMybatisDao<TOrderNewMapper> impleme
 			tOrderMidMapper.insertSelective(tm);
 		}
 		//
-		tOrderMidMapper.updateCountProjectAndType(t.getOrderNo());
-
+		orderProjectService.updateMidServiceProject(t.getOrderNo());
 	}
 
 	/**
@@ -1678,7 +1678,9 @@ public class OrderNewServiceImpl extends BaseMybatisDao<TOrderNewMapper> impleme
 				tOrderOutsourceMapper.updateByidNull(o.getId());
 			}
 		}
-		updateOrderCostAmount(o.getTid(),o.getStartType());
+		if (o.getRefundStatus()==1){
+			updateOrderCostAmount(o.getTid(),o.getStartType());
+		}
 		return 1;
 	}
 
@@ -1692,6 +1694,7 @@ public class OrderNewServiceImpl extends BaseMybatisDao<TOrderNewMapper> impleme
 	public void updateOrderCostAmount(Integer tid,Integer type) {
 		//计算项目成本
 		List<OutThirdPartyCompany>list=thirdPartyCompanyMapper.selectByTid(tid);
+
 		BigDecimal tCount=new BigDecimal(0);
 		for (OutThirdPartyCompany op : list) {
 			tCount=tCount.add(new BigDecimal(op.getTotalAmount()));
@@ -1708,16 +1711,17 @@ public class OrderNewServiceImpl extends BaseMybatisDao<TOrderNewMapper> impleme
 				}
 			}
 		}
-		tTaskMidMapper.updateCostAmount(tid,tCount);
-		//计算订单成本
-		BigDecimal oCount=new BigDecimal(0);
-		List <TTaskMid> tlist=tTaskMidMapper.selectListByTid(tid);
-		for (TTaskMid tm : tlist) {
-			if (tm!=null&&tm.getCostAmount()!=null) {
-				oCount=oCount.add(tm.getCostAmount()==null?new BigDecimal(0):tm.getCostAmount());
+		BigDecimal party=new BigDecimal(0);
+		List<outOrderPayment> paymentList = tOrderPaymentMapper.selectByTid(tid, null, null);
+		for (outOrderPayment oo : paymentList) {
+			if (oo.getStatus()==3){
+				party=party.add(oo.getApplicationAmount());
 			}
 		}
-		tOrderMidMapper.updateCostAmount(tid,oCount,null);
+		tTaskMidMapper.updateCostAmount(tid,tCount,party);
+		// //计算订单成本 分类成本
+		ProjectTypePuls projectTypePuls = tOrderTaskMapper.selectByTidGetDtails(tid);
+		tOrderMidMapper.updateCostAmount(projectTypePuls.getOrderNo());
 	}
 
 	@Override

+ 44 - 1
src/main/java/com/goafanti/order/service/impl/OrderProjectServiceImpl.java

@@ -117,6 +117,8 @@ public class OrderProjectServiceImpl extends BaseMybatisDao<TOrderTaskMapper> im
 	private AsyncUtils	asyncUtils;
 	@Autowired
 	private TTaskMemberMapper tTaskMemberMapper;
+	@Autowired
+	private TOrderMidMapper	tOrderMidMapper;
 	@Value(value = "${upload.path}")
 	private String 					uploadPath 			= null;
 
@@ -305,6 +307,7 @@ public class OrderProjectServiceImpl extends BaseMybatisDao<TOrderTaskMapper> im
 
 
 
+
 	private void insetLog(Integer taskId, String taskReceiverId) {
 		TTaskLog tl=new TTaskLog();
 		tl.setCreateTime(new Date());
@@ -508,10 +511,14 @@ public class OrderProjectServiceImpl extends BaseMybatisDao<TOrderTaskMapper> im
 				taskMid.setCompleteCount(task2.getCommodityQuantity());
 				taskMid.setStockCount(0);
 			}
-			tTaskMidMapper.updateByTid(taskMid);
+			if (taskMid.getPromulgateCount()!=null||taskMid.getSetUpCount()!=null||
+					taskMid.getCompleteCount()!=null ||taskMid.getStockCount()!=null){
+				tTaskMidMapper.updateByTid(taskMid);
+			}
 			tOrderTaskMapper.updateByPrimaryKeySelective(t);
 			projectSplitPush(b.getTid(), b.getProjectStatus(),task2);
 			pushTaskLog(b.getTid(), b.getProjectStatus());
+			updateMidServiceProject(task2.getOrderNo());
 		}
 		return 1;
 	}
@@ -1181,6 +1188,9 @@ public class OrderProjectServiceImpl extends BaseMybatisDao<TOrderTaskMapper> im
 		}
 		addNoticMember(notice, ono, in.getType(),result);
 		addMemberLog(in.getId(),status,in.getRemarks());
+		if (nt.getProcessStatus()==3){
+			tTaskMemberMapper.updateServiceYearBySplitSuper(task.getSplitSuper());
+		}
 		return tOrderTaskMapper.updateByPrimaryKeySelective(nt);
 	}
 
@@ -1250,6 +1260,8 @@ public class OrderProjectServiceImpl extends BaseMybatisDao<TOrderTaskMapper> im
 		}
 
 		orderNewService.addTaskMid(tOrderTask.getId(),tOrderTask.getCommodityId(), tOrderTask.getOrderNo());
+		//处理主项目本次派单年份
+		tTaskMemberMapper.updateServiceYearBySplitSuper(tid);
 		addMemberLog(tOrderTask.getId(),0,"新增会员项目");
 		addNoticMember(NoticeStatus.MENBER_START.getCode(),tOrderTask.getOrderNo(),null,0);
 		return tb;
@@ -1370,6 +1382,7 @@ public class OrderProjectServiceImpl extends BaseMybatisDao<TOrderTaskMapper> im
 		tTaskMidMapper.deleteByPrimaryKey(id);
 		tTaskMemberMapper.deleteByPrimaryKey(id);
 		tTaskLogMapper.deleteByPrimaryKey(id);
+		tTaskMemberMapper.updateServiceYearBySplitSuper(task.getSplitSuper());
 		return 1;
 	}
 
@@ -1383,4 +1396,34 @@ public class OrderProjectServiceImpl extends BaseMybatisDao<TOrderTaskMapper> im
 	}
 
 
+	@Override
+	public void updateMidServiceProject(String orderNo) {
+		List<TOrderTaskBo> taskBos = tOrderTaskMapper.selectOrderTaskAll(orderNo, null);
+		if (!taskBos.isEmpty()){
+			List<String > cp=new ArrayList<>();
+			List<String > cc=new ArrayList<>();
+			StringBuffer ps=new StringBuffer();
+			StringBuffer cs=new StringBuffer();
+			for (TOrderTaskBo taskBo : taskBos) {
+				if (!cp.contains(taskBo.getCommodityName())){
+					cp.add(taskBo.getCommodityName());
+					ps=ps.append(taskBo.getCommodityName());
+					String str= NewProjectStatus.getValueByCode(taskBo.getProjectStatus());
+					ps=ps.append("-").append(str).append(",");
+
+				}
+				if (!cc.contains(taskBo.getCname())){
+					cc.add(taskBo.getCname());
+					cs=cs.append(taskBo.getCname()).append(",");
+				}
+			}
+			TOrderMid tOrderMid = new TOrderMid();
+			tOrderMid.setOrderNo(orderNo);
+			if (ps.length()>1)tOrderMid.setServiceProject(ps.substring(0,ps.length()-1));
+			if (ps.length()>1)tOrderMid.setServiceType(cs.substring(0,cs.length()-1));
+			tOrderMidMapper.updateByOrderNo(tOrderMid);
+		}
+	}
+
+
 }

+ 1 - 2
src/main/java/com/goafanti/order/service/impl/OrderReceivablesServiceImpl.java

@@ -237,7 +237,7 @@ public class OrderReceivablesServiceImpl extends BaseMybatisDao<TemporaryReceiva
 			tbn.setFinancialPayTime(tr.getReceivablesTime());
 			tbn.setFinancialPayNo(tr.getFinancialPayNo());
 			tbn.setRemarks(tr.getRemarks());
-			tOrderMidMapper.updatefinalReceivables(t.getOrderNo(),tr.getAmount(),date);
+			tOrderMidMapper.updatefinalReceivables(t.getOrderNo(),tr.getAmount(),count,date);
 			//修改订单结算金额和结算状态
 			//如果已经首付并且流程状态是没有派给咨询师的修改流程状态为4
 			TOrderNew orderNew = new TOrderNew();
@@ -254,7 +254,6 @@ public class OrderReceivablesServiceImpl extends BaseMybatisDao<TemporaryReceiva
 					bonus.setGrantType(0);
 					tOrderBonusMapper.insertSelective(bonus);
 			}
-
 				listBull.add(tbn);
 		}
 		if(!listBull.isEmpty()) {

+ 37 - 10
src/main/java/com/goafanti/order/service/impl/OutsourceOrgServiceImpl.java

@@ -1,5 +1,6 @@
 package com.goafanti.order.service.impl;
 
+import java.math.BigDecimal;
 import java.util.ArrayList;
 import java.util.Date;
 import java.util.HashMap;
@@ -7,20 +8,15 @@ import java.util.List;
 import java.util.Map;
 
 import com.goafanti.common.dao.*;
+import com.goafanti.common.model.*;
 import com.goafanti.order.bo.*;
+import com.goafanti.organization.bo.ProjectTypePuls;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 import com.goafanti.common.enums.NoticeStatus;
 import com.goafanti.common.enums.OrderLogProcess;
-import com.goafanti.common.model.Admin;
-import com.goafanti.common.model.OutsourceLog;
-import com.goafanti.common.model.OutsourceOrganization;
-import com.goafanti.common.model.TOrderLog;
-import com.goafanti.common.model.TOrderNew;
-import com.goafanti.common.model.TOrderOutsource;
-import com.goafanti.common.model.TOrderTask;
 import com.goafanti.core.mybatis.BaseMybatisDao;
 import com.goafanti.core.mybatis.page.Pagination;
 import com.goafanti.core.shiro.token.TokenManager;
@@ -53,6 +49,18 @@ public class OutsourceOrgServiceImpl  extends BaseMybatisDao<TOrderOutsourceMapp
 	private OutsourceLogMapper	outsourceLogMapper;
 	@Autowired
 	private OrderNewService	OrderNewService;
+	@Autowired
+	private TTaskMidMapper	tTaskMidMapper;
+	@Autowired
+	private TOrderMidMapper	tOrderMidMapper;
+
+
+
+
+
+
+
+
 	@Override
 	public int addOutsourceOrg(OutsourceOrganization o) {
 		return outsourceOrganizationMapper.insertSelective(o);
@@ -109,7 +117,7 @@ public class OutsourceOrgServiceImpl  extends BaseMybatisDao<TOrderOutsourceMapp
 		List<String> aids = new ArrayList<>();
 		Integer type=null;
 		TOrderNew t2=tOrderNewMapper.selectByPrimaryKey(o.getOrderNo());
-		//外包订单
+		//外包订单已删除
 		if (o.getType()==null||o.getType()==0) {
 			o.setType(0);
 			TOrderNew t=new TOrderNew();
@@ -146,17 +154,30 @@ public class OutsourceOrgServiceImpl  extends BaseMybatisDao<TOrderOutsourceMapp
 				type=NoticeStatus.PROJECT_OUTSOURCE_YES.getCode();
 				ol.setStatus(1);
 				addOrderLog(o.getOrderNo(),OrderLogProcess.XMWBTG.getCode(),o.getRemarks());
-				OrderNewService.updateOrderCostAmount(o.getTid(),0);
+
 			}else {
 				type=NoticeStatus.PROJECT_OUTSOURCE_NO.getCode();
 				ol.setStatus(2);
 				addOrderLog(o.getOrderNo(),OrderLogProcess.XMWBBH.getCode(),o.getRemarks());
+				pushRejectMid(o);
 			}
 			outsourceLogMapper.insertSelective(ol);
 		}
 		TOrderNewBo order=tOrderNewMapper.getSaleIdByOno(o.getOrderNo());
 		orderNewService.pushGeneralSendNoticeAndEmail(aids, type,order, TokenManager.getAdminId(),t2.getApproval(),o.getTid());
-		return tOrderOutsourceMapper.updateByPrimaryKeySelective(o);
+		tOrderOutsourceMapper.updateByPrimaryKeySelective(o);
+		if(o.getRefundStatus()==1 &&o.getType()==1){
+			OrderNewService.updateOrderCostAmount(o.getTid(),0);
+		}
+		return 1;
+	}
+
+	private void pushRejectMid(OrderOutsourceDtails o) {
+		TTaskMid tm=new TTaskMid();
+		tm.setTid(o.getTid());
+		tm.setCostAmount(new BigDecimal(0));
+		tTaskMidMapper.updateByTid(tm);
+		tOrderMidMapper.updateCostAmount(o.getOrderNo());
 	}
 
 	public void addOrderLog(String orderNo, Integer code,String remarks) {
@@ -211,6 +232,12 @@ public class OutsourceOrgServiceImpl  extends BaseMybatisDao<TOrderOutsourceMapp
 		TOrderOutsource tto2=new  TOrderOutsource();
 		tto2.setId(id);
 		tto2.setRefundStatus(2);
+		TTaskMid ttm=new TTaskMid();
+		ttm.setTid(tto.getTid());
+		ttm.setCostAmount(new BigDecimal(0));
+		tTaskMidMapper.updateByTid(ttm);
+		ProjectTypePuls typePuls = tOrderTaskMapper.selectByTidGetDtails(tto.getTid());
+		tOrderMidMapper.updateCostAmount(typePuls.getOrderNo());
 		return tOrderOutsourceMapper.updateByPrimaryKeySelective(tto2);
 	}
 

+ 167 - 166
src/main/java/com/goafanti/organization/bo/OutThirdPartyCompany.java

@@ -5,330 +5,331 @@ import java.util.Date;
 
 
 public class OutThirdPartyCompany  {
-	
+
 	private Integer costReduction;
-	
+
 	private Integer officialCost;
-	private String officialUnitPrice; 
+	private String officialUnitPrice;
 	private String reductionAmount;
-	
+
 	private Integer  patentType;
 
 	private BigDecimal proportion85;
-	
-	
+
+
 	private Integer id;
-	
-	
-	
+
+
+
 	private Integer tid;
-	
-	
-	
+
+
+
 	private String companyName;
-	
-	
-	
+
+
+
 	private String unitPrice;
-	
-	
-	
+
+
+
 	private Integer quantity;
-	
-	
-	
+
+
+
 	private String totalAmount;
-	
-	
-	
+
+
+
 	private Integer material;
-	
-	
-	
+
+
+
 	private Integer urgent;
-	
-	
-	
+
+
+
 	private Integer audit;
-	
-	
-	
+
+
+
 	private String assets;
-	
-	
-	
+
+
+
 	private String income;
-	
-	
-	
+
+
+
 	private String remarks;
-	
-	
-	
+
+
+
 	private Date createTime;
-	
-	
-	
+
+
+
 	private Integer cid;
-	
-	
-	
+
+
+
 	private BigDecimal partyAmount;
-	
-	
-	
+
+
+
 	private Integer type;
-	
-	
-	
+
+
+
 	private Integer patentNameType;
-	
-	
-	
-	
-	
 
-	
+
+
+
+
+
+
 	private Integer startType;
-	
-	
-	
+
+
+
+
 	public Integer getId() {
 		return id;
 	}
 
-	
-	
-	
-	
-	
+
+
+
+
+
 	public void setId(Integer id) {
 		this.id = id;
 	}
 
-	
-	
+
+
 	public Integer getTid() {
 		return tid;
 	}
 
-	
-	
-	
+
+
+
 	public void setTid(Integer tid) {
 		this.tid = tid;
 	}
 
-	
-	
-	
+
+
+
 	public String getCompanyName() {
 		return companyName;
 	}
 
-	
-	
-	
+
+
+
 	public void setCompanyName(String companyName) {
 		this.companyName = companyName;
 	}
 
-	
-	
-	
+
+
+
 	public String getUnitPrice() {
 		return unitPrice;
 	}
 
-	
-	
-	
+
+
+
 	public void setUnitPrice(String unitPrice) {
 		this.unitPrice = unitPrice;
 	}
 
-	
-	
-	
+
+
+
 	public Integer getQuantity() {
 		return quantity;
 	}
 
-	
-	
-	
+
+
+
 	public void setQuantity(Integer quantity) {
 		this.quantity = quantity;
 	}
 
-	
-	
-	
+
+
+
 	public String getTotalAmount() {
 		return totalAmount;
 	}
 
-	
-	
-	
+
+
+
 	public void setTotalAmount(String totalAmount) {
 		this.totalAmount = totalAmount;
 	}
 
-	
-	
-	
+
+
+
 	public Integer getMaterial() {
 		return material;
 	}
 
-	
-	
-	
+
+
+
 	public void setMaterial(Integer material) {
 		this.material = material;
 	}
 
-	
-	
-	
+
+
+
 	public Integer getUrgent() {
 		return urgent;
 	}
 
-	
-	
-	
+
+
+
 	public void setUrgent(Integer urgent) {
 		this.urgent = urgent;
 	}
 
-	
-	
-	
+
+
+
 	public Integer getAudit() {
 		return audit;
 	}
 
-	
-	
-	
+
+
+
 	public void setAudit(Integer audit) {
 		this.audit = audit;
 	}
 
-	
-	
-	
+
+
+
 	public String getAssets() {
 		return assets;
 	}
 
-	
-	
-	
+
+
+
 	public void setAssets(String assets) {
 		this.assets = assets;
 	}
 
-	
-	
-	
+
+
+
 	public String getIncome() {
 		return income;
 	}
 
-	
-	
-	
+
+
+
 	public void setIncome(String income) {
 		this.income = income;
 	}
 
-	
-	
-	
+
+
+
 	public String getRemarks() {
 		return remarks;
 	}
 
-	
-	
-	
+
+
+
 	public void setRemarks(String remarks) {
 		this.remarks = remarks;
 	}
 
-	
-	
-	
+
+
+
 	public Date getCreateTime() {
 		return createTime;
 	}
 
-	
-	
-	
+
+
+
 	public void setCreateTime(Date createTime) {
 		this.createTime = createTime;
 	}
 
-	
-	
-	
+
+
+
 	public Integer getCid() {
 		return cid;
 	}
 
-	
-	
-	
+
+
+
 	public void setCid(Integer cid) {
 		this.cid = cid;
 	}
 
-	
-	
-	
+
+
+
 	public BigDecimal getPartyAmount() {
 		return partyAmount;
 	}
 
-	
-	
-	
+
+
+
 	public void setPartyAmount(BigDecimal partyAmount) {
 		this.partyAmount = partyAmount;
 	}
 
-	
-	
-	
+
+
+
 	public Integer getType() {
 		return type;
 	}
 
-	
-	
-	
+
+
+
 	public void setType(Integer type) {
 		this.type = type;
 	}
 
-	
-	
-	
+
+
+
 	public Integer getPatentNameType() {
 		return patentNameType;
 	}
 
-	
-	
-	
+
+
+
 	public void setPatentNameType(Integer patentNameType) {
 		this.patentNameType = patentNameType;
 	}
-	
+
 	public Integer getCostReduction() {
 		return costReduction;
 	}
@@ -431,7 +432,7 @@ public class OutThirdPartyCompany  {
 	public void setProportion85(BigDecimal proportion85) {
 		this.proportion85 = proportion85;
 	}
-	
-	
+
+
 
 }

+ 21 - 3
src/main/java/com/goafanti/organization/bo/ProjectTypePuls.java

@@ -3,8 +3,9 @@ package com.goafanti.organization.bo;
 import java.math.BigDecimal;
 
 public class ProjectTypePuls {
-	
+
 	private Integer id;
+	private String orderNo;
 	private Integer patentType;
 	private Integer projectType;
 	private BigDecimal officialAmount;
@@ -13,6 +14,23 @@ public class ProjectTypePuls {
 	private Integer quantity;
 	private Integer officialCost;
 	private Integer outPatentType;
+	private Integer Type;
+
+	public String getOrderNo() {
+		return orderNo;
+	}
+
+	public void setOrderNo(String orderNo) {
+		this.orderNo = orderNo;
+	}
+
+	public Integer getType() {
+		return Type;
+	}
+
+	public void setType(Integer type) {
+		Type = type;
+	}
 
 	public Integer getOutPatentType() {
 		return outPatentType;
@@ -71,7 +89,7 @@ public class ProjectTypePuls {
 	public void setOfficialAmount(BigDecimal officialAmount) {
 		this.officialAmount = officialAmount;
 	}
-	
-	
+
+
 
 }

+ 13 - 13
src/main/java/com/goafanti/organization/bo/outOrderPayment.java

@@ -71,7 +71,7 @@ public class outOrderPayment {
 	 * This field was generated by MyBatis Generator. This field corresponds to the database column t_order_payment.application_amount
 	 * @mbg.generated  Tue Jul 07 11:46:04 CST 2020
 	 */
-	private String applicationAmount;
+	private BigDecimal applicationAmount;
 	/**
 	 * This field was generated by MyBatis Generator. This field corresponds to the database column t_order_payment.choose_type
 	 * @mbg.generated  Tue Jul 07 11:46:04 CST 2020
@@ -87,7 +87,7 @@ public class outOrderPayment {
 	 * @mbg.generated  Tue Jul 07 11:46:04 CST 2020
 	 */
 	private String aname;
-	
+
 	/**
 	 * Database Column Remarks: 流程状态 0发起 1咨询师管理员 2财务 This field was generated by MyBatis Generator. This field corresponds to the database column t_order_payment.process_status
 	 * @mbg.generated  Tue Jul 20 09:16:18 CST 2021
@@ -315,7 +315,7 @@ public class outOrderPayment {
 	 * @return  the value of t_order_payment.application_amount
 	 * @mbg.generated  Tue Jul 07 11:46:04 CST 2020
 	 */
-	public String getApplicationAmount() {
+	public BigDecimal getApplicationAmount() {
 		return applicationAmount;
 	}
 
@@ -324,7 +324,7 @@ public class outOrderPayment {
 	 * @param applicationAmount  the value for t_order_payment.application_amount
 	 * @mbg.generated  Tue Jul 07 11:46:04 CST 2020
 	 */
-	public void setApplicationAmount(String applicationAmount) {
+	public void setApplicationAmount(BigDecimal applicationAmount) {
 		this.applicationAmount = applicationAmount;
 	}
 
@@ -381,7 +381,7 @@ public class outOrderPayment {
 	public void setAname(String aname) {
 		this.aname = aname;
 	}
-	
+
 	public String getAuditNotes() {
 		return auditNotes;
 	}
@@ -392,13 +392,13 @@ public class outOrderPayment {
 
 	private String auditNotes;
 
-	
+
 
 	/**
 	 * 原数量
 	 */
 	 private Integer initialQuantity;
-	 
+
 	 /**
 	 * 原总价
 	 */
@@ -413,9 +413,9 @@ public class outOrderPayment {
 	 private String initialPaymentAmount;
 	 private String initialCompanyName;
 	 private String createTimes;
-	 
+
 	 private String financeName;
-	
+
 	 private String tpcName;
 	public String getFinanceName() {
 		return financeName;
@@ -473,8 +473,8 @@ public class outOrderPayment {
 	public void setProcessStatus(Integer processStatus) {
 		this.processStatus = processStatus;
 	}
-	
-	
+
+
 	/*public String getAuditInformation() {
 		if (getStatus()==null) return "";
 		else if (getStatus()==0) return "待"+financeName+"审核";
@@ -486,6 +486,6 @@ public class outOrderPayment {
 
 
 
-	 
-	 
+
+
 }

+ 50 - 36
src/main/java/com/goafanti/organization/service/impl/ThirdPartyCompanyServiceImpl.java

@@ -13,6 +13,8 @@ import java.util.UUID;
 import javax.servlet.http.HttpServletResponse;
 
 import com.goafanti.admin.service.DepartmentService;
+import com.goafanti.common.model.*;
+import com.goafanti.order.enums.ProjectType;
 import org.apache.commons.beanutils.BeanUtils;
 import org.apache.commons.collections4.map.HashedMap;
 import org.apache.commons.lang3.StringUtils;
@@ -38,18 +40,6 @@ import com.goafanti.common.dao.TOrderTaskMapper;
 import com.goafanti.common.dao.TTaskMidMapper;
 import com.goafanti.common.dao.ThirdPartyCompanyMapper;
 import com.goafanti.common.enums.NoticeStatus;
-import com.goafanti.common.model.Admin;
-import com.goafanti.common.model.CompanyLibrary;
-import com.goafanti.common.model.Notice;
-import com.goafanti.common.model.OfficialFeePrice;
-import com.goafanti.common.model.PatentPrice;
-import com.goafanti.common.model.PaymentLog;
-import com.goafanti.common.model.PaymentNode;
-import com.goafanti.common.model.SoftWritingPrice;
-import com.goafanti.common.model.TOrderPayment;
-import com.goafanti.common.model.TOrderTask;
-import com.goafanti.common.model.TTaskMid;
-import com.goafanti.common.model.ThirdPartyCompany;
 import com.goafanti.common.utils.AsyncUtils;
 import com.goafanti.common.utils.DateUtils;
 import com.goafanti.common.utils.excel.NewExcelUtil;
@@ -136,7 +126,8 @@ public class ThirdPartyCompanyServiceImpl extends  BaseMybatisDao<ThirdPartyComp
 			}
 			if (type!=null&&type==1) {
 				tOrderTaskMapper.updateAddCostAmount(t.getTid(), t.getTotalAmount());
-				tOrderMidMapper.updateAddCostAmount(t.getTid(), t.getTotalAmount());
+
+				updateCountByTid(t.getTid());
 			}
 		thirdPartyCompanyMapper.insertSelective(t);
 		return 1;
@@ -163,6 +154,14 @@ public class ThirdPartyCompanyServiceImpl extends  BaseMybatisDao<ThirdPartyComp
 			}
 			t.setTotalAmount(t.getUnitPrice().multiply(new BigDecimal(t.getQuantity())));
 		}
+		ThirdPartyCompany use = thirdPartyCompanyMapper.selectByPrimaryKey(t.getId());
+		if (!use.getUnitPrice().equals(t.getUnitPrice())){
+			PaymentNode paymentNode = new PaymentNode();
+			paymentNode.setCid(t.getId());
+			paymentNode.setUnitPrice(t.getUnitPrice());
+			paymentNodeMapper.updateByCid(paymentNode);
+		}
+
 		thirdPartyCompanyMapper.updateByPrimaryKeySelective(t);
 		return 1;
 	}
@@ -258,32 +257,42 @@ public class ThirdPartyCompanyServiceImpl extends  BaseMybatisDao<ThirdPartyComp
 
 	@Override
 	public int deleteCompany(String id) {
+		Integer tpcId=null;
+		Integer tid=null;
 		if (id.contains(",")) {
 			String []ids =id.split(",");
 			for (String s : ids) {
-				thirdPartyCompanyMapper.deleteByPrimaryKey(Integer.valueOf(s));
+				tpcId=Integer.valueOf(s);
+				ThirdPartyCompany tpc=thirdPartyCompanyMapper.selectByPrimaryKey(tpcId);
+				tid=tpc.getTid();
+				thirdPartyCompanyMapper.deleteByPrimaryKey(tpcId);
+				pushDeleteCompany(tpc);
 			}
 		}else {
-			Integer tpcId=Integer.valueOf(id);
+			tpcId=Integer.valueOf(id);
 			ThirdPartyCompany tpc=thirdPartyCompanyMapper.selectByPrimaryKey(tpcId);
+			tid=tpc.getTid();
 			thirdPartyCompanyMapper.deleteByPrimaryKey(tpcId);
+			pushDeleteCompany(tpc);
 
-			List<outOrderPayment> list=tOrderPaymentMapper.selectList(tpcId, null, null);
-			for (outOrderPayment o : list) {
-					TOrderPayment t=new TOrderPayment();
-					t.setId(o.getId());
-					t.setStatus(4);
-					tOrderPaymentMapper.updateByPrimaryKeySelective(t);
-			}
-			paymentNodeMapper.deleteByParam(tpcId,null);
-			sumTaskCost(tpc.getTid());
-			updateCountByTid(tpc.getId());
 		}
+		sumTaskCost(tid);
+		updateCountByTid(tid);
 		return 1;
 	}
 
+	private void pushDeleteCompany(ThirdPartyCompany tpc) {
 
+		List<outOrderPayment> list=tOrderPaymentMapper.selectList(tpc.getId(), null, null);
+		for (outOrderPayment o : list) {
+			TOrderPayment t=new TOrderPayment();
+			t.setId(o.getId());
+			t.setStatus(4);
+			tOrderPaymentMapper.updateByPrimaryKeySelective(t);
+		}
+		paymentNodeMapper.deleteByParam(tpc.getId(),null);
 
+	}
 
 
 	public void sumTaskCost(Integer tid) {
@@ -292,7 +301,15 @@ public class ThirdPartyCompanyServiceImpl extends  BaseMybatisDao<ThirdPartyComp
 		for (OutThirdPartyCompany op : list) {
 			tCount=tCount.add(new BigDecimal(op.getTotalAmount()));
 		}
-		tTaskMidMapper.updateCostAmount(tid,tCount);
+		BigDecimal party=new BigDecimal(0);
+		List<outOrderPayment> paymentList = tOrderPaymentMapper.selectByTid(tid, null, null);
+		for (outOrderPayment oo : paymentList) {
+			if (oo.getStatus()==3){
+				party=party.add(oo.getApplicationAmount());
+			}
+		}
+
+		tTaskMidMapper.updateCostAmount(tid,tCount,party);
 	}
 
 
@@ -463,7 +480,10 @@ public class ThirdPartyCompanyServiceImpl extends  BaseMybatisDao<ThirdPartyComp
 				tpc.setPartyAmount(tpc.getPartyAmount().add(p.getPaymentAmount()));
 				thirdPartyCompanyMapper.updateByPrimaryKeySelective(tpc);
 			}
+			//计算成本
+			ProjectTypePuls t = tOrderTaskMapper.selectByTidGetDtails(tp.getTid());
 			financialPaymentMapper.updateOrderCost(p.getId(),p.getPaymentAmount());
+			tOrderMidMapper.updateCostAmount(t.getOrderNo());
 	}
 
 
@@ -562,7 +582,7 @@ public class ThirdPartyCompanyServiceImpl extends  BaseMybatisDao<ThirdPartyComp
 				list=tOrderPaymentMapper.selectList(null,p.getNodeId(),p.getChooseType());
 			}
 			for (outOrderPayment o : list) {
-					a=a.add(new BigDecimal(o.getApplicationAmount()));
+					a=a.add(o.getApplicationAmount());
 			}
 			if (p.getChooseType()==0) {
 				ThirdPartyCompany t=thirdPartyCompanyMapper.selectByPrimaryKey(p.getTpcId());
@@ -1132,17 +1152,11 @@ public class ThirdPartyCompanyServiceImpl extends  BaseMybatisDao<ThirdPartyComp
 
 	/**
 	 * 根据项目编号重新计算订单成本与已付
-	 * @param id
+	 * @param id =tid 项目编号
 	 */
 	private void updateCountByTid(Integer id) {
-		List<TTaskMid> list=tTaskMidMapper.selectListByTid(id);
-		BigDecimal cost=new BigDecimal(0);
-		BigDecimal party=new BigDecimal(0);
-		for (TTaskMid t : list) {
-			cost=cost.add(t.getCostAmount());
-			party=party.add(t.getPartyAmount());
-		}
-		tOrderMidMapper.updateCostAmount(id, cost,party);
+		TOrderTask t = tOrderTaskMapper.selectByPrimaryKey(id);
+		tOrderMidMapper.updateCostAmount(t.getOrderNo());
 	}
 
 	@Override

+ 6 - 6
src/main/resources/props/config_local.properties

@@ -1,12 +1,12 @@
 dev.name=local
 jdbc.driverClassName=com.mysql.jdbc.Driver
-jdbc.url=jdbc\:mysql://localhost:3306/aft20220318?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&useSSL=false
+#jdbc.url=jdbc\:mysql://localhost:3306/aft20220318?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&useSSL=false
 #jdbc.url=jdbc\:mysql://localhost:3306/aft?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&useSSL=false
-jdbc.username=root
-jdbc.password=123456
-#jdbc.url=jdbc:mysql://101.37.32.31:3306/aft?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&useSSL=false
 #jdbc.username=root
-#jdbc.password=aftdev
+#jdbc.password=123456
+jdbc.url=jdbc:mysql://101.37.32.31:3306/aft?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&useSSL=false
+jdbc.username=root
+jdbc.password=aftdev
 jdbc.validationQuery=SELECT 'x'
 jdbc.initialSize=3
 jdbc.maxActive=20
@@ -50,7 +50,7 @@ yxy_max=100
 yxjl_max=100
 
 avatar.host=//static.jishutao.com
-static.host=//static.jishutao.com/1.2.47
+static.host=//static.jishutao.com/1.2.48
 #avatar.host=//172.16.0.255:3000
 #static.host=//172.16.0.255:3000/1.2.27
 #static.host=http://172.16.1.187/prod/1.2.25

+ 1 - 1
src/main/resources/props/config_test.properties

@@ -47,7 +47,7 @@ yxzj_max=800
 yxy_max=100
 yxjl_max=100
 
-static.host=//static.jishutao.com/1.2.47
+static.host=//static.jishutao.com/1.2.48
 portal.host=//static.jishutao.com/portal/2.0.6
 avatar.host=//static.jishutao.com
 avatar.upload.host=//static.jishutao.com/upload