소스 검색

1、审批中的合同加上链接,可以打开合同
2、付款流程中选择合同列表,展示合同金额和已付金额,已付金额从付款中统计

ouyj 6 일 전
부모
커밋
17c907c41d

+ 4 - 3
src/main/contract/com/yw/contract/contract/dao/ContractEntryDaoImpl.java

@@ -32,13 +32,14 @@ public class ContractEntryDaoImpl extends BaseDao implements ContractEntryDao {
 	@Override
 	public List<ContractInfo> contractEntryList(int p, int pSize, ParameterHelper ph, ContractInfo info, IAppSession oasession) throws Exception {
 		StringBuffer sb = new StringBuffer("SELECT ec.universalid, ec.contract_number,ec.firstparty_name,ec.secondparty_name,ec.contract_name,ec.contract_type,ec.contract_signdate,"
-				+ " ec.contract_type,tu1.name AS duty_man_name,tu2.name AS salesman_name," + "tg.GROUPNAME AS duty_department_name ,ed.dname AS contract_type_name, ec.au_state, ec.flow_id,"
-				+ " ec.execute_state,ec.supplier_code,ec.supplier_name,ec.l_form_ins_id,ec.l_form_ins_id,ec.flow_ins_id, ec.is_valid,ec.process_id,ec.contract_entrying_date,"
+				+ " tu1.name AS duty_man_name,tu2.name AS salesman_name," + "tg.GROUPNAME AS duty_department_name ,ed.dname AS contract_type_name, ec.au_state, ec.flow_id,"
+				+ " ec.execute_state,ec.supplier_code,ec.supplier_name,ec.l_form_ins_id, ec.flow_ins_id, ec.is_valid,ec.process_id,ec.contract_entrying_date,"
 				+ "ec.purchase_id,ec.purchase_number,a.v_ins_sub_name,ec.order_number,ec.contract_money,ec.initiator "
 				+ " FROM contract ec LEFT JOIN t_user tu1 ON ec.duty_man=tu1.UNIVERSALID " + "LEFT JOIN t_user tu2 ON ec.salesman=tu2.UNIVERSALID "
 				+ " LEFT JOIN t_group tg ON ec.duty_department=tg.UNIVERSALID " + "LEFT JOIN contract_data_dictionary ed ON ec.contract_type=ed.dvalue "
 				+ " AND ed.parentid = (SELECT universalid FROM contract_data_dictionary WHERE dvalue = '" + ContractConstant.CONTRACT_TYPE + "' AND group_root_id=" + oasession.getUnit().getId() + ")"
-				+ " AND ed.is_valid = '1' left join bpm_flow_instance a on a.l_ins_id = ec.flow_ins_id " + " WHERE ec.contract_status='0' AND ec.isdraft = '0'  AND ec.unit_id=" + oasession.getUnit().getId());
+				+ " AND ed.is_valid = '1' left join bpm_flow_instance a on a.l_ins_id = ec.flow_ins_id "
+				+ " WHERE ec.contract_status='0' AND ec.isdraft = '0'  AND ec.unit_id=" + oasession.getUnit().getId());
 		sb.append(whereListSql(ph));
 		// String sql="SELECT ec.universalid,
 		// ec.contract_number,ec.contract_name,ec.contract_type,ec.contract_signdate,"

+ 9 - 0
src/main/contract/com/yw/contract/contract/model/ContractInfo.java

@@ -246,6 +246,9 @@ public class ContractInfo {
 	//子标题 
     private String v_ins_sub_name;
     
+    //已付金额(从付款申请表汇总)
+    private java.math.BigDecimal paidAmount;
+    
 	public Long getUnit_id() {
 		return unit_id;
 	}
@@ -750,6 +753,12 @@ public class ContractInfo {
 	public void setV_ins_sub_name(String v_ins_sub_name) {
 		this.v_ins_sub_name = v_ins_sub_name;
 	}
+	public java.math.BigDecimal getPaidAmount() {
+		return paidAmount;
+	}
+	public void setPaidAmount(java.math.BigDecimal paidAmount) {
+		this.paidAmount = paidAmount;
+	}
 	public String getOrderNumber() {
 		return orderNumber;
 	}

+ 40 - 2
src/main/contract/com/yw/contract/contract/service/ContractEntryServiceImpl.java

@@ -9,6 +9,7 @@ import java.util.Map;
 import org.apache.commons.lang.StringUtils;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.jdbc.core.JdbcTemplate;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.util.ObjectUtils;
 
@@ -41,7 +42,9 @@ public class ContractEntryServiceImpl implements ContractEntryService {
 	@Autowired
 	ContractPaymentDao contractPaymentDao;
 	@Autowired
-    ContractPurchaseDao purchaseDao;
+    ContractPurchaseDao purchaseDao; 
+	@Autowired
+	private JdbcTemplate jdbcTemplate;
 
 	@Override
 	public List<ContractInfo> contractEntryList(String p, String pSize,
@@ -59,7 +62,12 @@ public class ContractEntryServiceImpl implements ContractEntryService {
 		} else {
 			n_pSize = 20;
 		}		
-		return contractEntryDao.contractEntryList(n_p, n_pSize,ph, info, oasession);
+		List<ContractInfo> infoList = contractEntryDao.contractEntryList(n_p, n_pSize, ph, info, oasession);
+		// 填充已付金额
+		if (infoList != null && infoList.size() > 0) {
+			fillPaidAmount(infoList);
+		}
+		return infoList;
 	}
 
 	@Override
@@ -790,4 +798,34 @@ public class ContractEntryServiceImpl implements ContractEntryService {
 	public int countMesContractEntry(ParameterHelper ph, ContractInfo info) throws Exception {
 		return contractEntryDao.countMesContractEntry(ph, info);
 	}
+	
+
+
+	/**
+	 * 根据合同ID列表批量查询已付金额并填充到ContractInfo中
+	 */
+	private void fillPaidAmount(List<ContractInfo> infoList) {
+		try {
+			StringBuilder ids = new StringBuilder();
+			for (int i = 0; i < infoList.size(); i++) {
+				if (i > 0) ids.append(",");
+				ids.append(infoList.get(i).getUniversalid());
+			}
+			String sql = "SELECT contract_id, COALESCE(SUM(amount_lower), 0) AS paid_amount FROM oa_payment_apply WHERE contract_id IN ("
+					+ ids + ") AND is_valid IN (0, 1, 3) GROUP BY contract_id";
+			List<Map<String, Object>> rows = jdbcTemplate.queryForList(sql);
+			for (Map<String, Object> row : rows) {
+				Long contractId = ((Number) row.get("contract_id")).longValue();
+				BigDecimal paidAmount = (BigDecimal) row.get("paid_amount");
+				for (ContractInfo ci : infoList) {
+					if (contractId.equals(ci.getUniversalid())) {
+						ci.setPaidAmount(paidAmount);
+						break;
+					}
+				}
+			}
+		} catch (Exception e) {
+			e.printStackTrace();
+		}
+	}
 }

+ 16 - 1
src/main/contract/com/yw/contract/paymentApply/action/PaymentApplyAction.java

@@ -12,8 +12,13 @@ import java.util.Map;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
+import com.yw.contract.contract.model.ContractInfo;
+import com.yw.contract.contract.service.ContractEntryService;
+import com.yw.hr.staff.service.ContractService;
 import org.apache.commons.lang.StringUtils;
 import org.json.JSONObject;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.springframework.context.ApplicationContext;
 
 import com.yw.bpm.flow.model.FlowModel;
@@ -47,7 +52,8 @@ import com.yw.eu.base.user.service.UserService;
 import com.yw.oa.petition.action.BpmBaseAction; 
 
 public class PaymentApplyAction  extends BpmBaseAction {
-	private String startPaymentApplyUrl = "/yw/contract/paymentApply/startPaymentApply.jsp";  
+	private static final Logger log = LoggerFactory.getLogger(PaymentApplyAction.class);
+	private String startPaymentApplyUrl = "/yw/contract/paymentApply/startPaymentApply.jsp";
 	private String processPaymentApplyUrl = "/yw/contract/paymentApply/processPaymentApply.jsp";  
 	private String viewPaymentApplyUrl = "/yw/contract/paymentApply/viewPaymentApply.jsp";   
 	private String viewPaymentApplyInfoUrl = "/yw/contract/paymentApply/viewPaymentApplyInfo.jsp";
@@ -57,6 +63,7 @@ public class PaymentApplyAction  extends BpmBaseAction {
 	private PaymentApplyService paymentApplyService;
 	public PaymentApply paymentApply;
 	public CodeRuleService codeRuleService;
+	private ContractEntryService contractEntryService;
 	
 	@Override
 	public void afterSourceAction(HttpServletRequest request, HttpServletResponse response) throws Exception {
@@ -173,6 +180,7 @@ public class PaymentApplyAction  extends BpmBaseAction {
 	private void toProcessPaymentApply()  throws Exception{
 		this.getTacheFromElement();
 		paymentApplyService = this.getBean(PaymentApplyService.class, "paymentApplyService");
+		contractEntryService = this.getBean(ContractEntryService.class, "contractEntryService");
 		String flow_id = request.getParameter("flowInsId");
 		String formInsId = request.getParameter("formInsId"); 
 		if(paymentApply == null) {
@@ -180,6 +188,13 @@ public class PaymentApplyAction  extends BpmBaseAction {
 		}
 		paymentApply.setlFormInsId(StringUtil.strToLong(formInsId)); 
 		paymentApply = paymentApplyService.getPaymentApply(paymentApply);
+		if(paymentApply.getContractId() != null && paymentApply.getContractId() > 0){
+			ContractInfo contractInfo = contractEntryService.toEditContractEntry(paymentApply.getContractId(), oasession);
+			if(contractInfo != null){
+				paymentApply.setContractInsId(contractInfo.getFlowInsId());
+				//request.setAttribute("contractInsId", contractInfo.getFlowInsId());
+			}
+		}
 		request.setAttribute("paymentApply", paymentApply);
 		request.setAttribute("flow_ins_id", flow_id); 
 		String insId = paymentApply.getFlowInsId().toString();

+ 11 - 0
src/main/contract/com/yw/contract/paymentApply/model/PaymentApply.java

@@ -149,6 +149,8 @@ public class PaymentApply {
 	@Column(name="order_id_from_mes",type=Types.VARCHAR)
 	private String orderIdFromMes;			//MES 订单 ID
 
+	private Long contractInsId;			//合同流程实例ID
+
 	public Long getUniversalid() {
 		return universalid;
 	}
@@ -508,4 +510,13 @@ public class PaymentApply {
 	public void setOrderIdFromMes(String orderIdFromMes) {
 		this.orderIdFromMes = orderIdFromMes;
 	}
+
+	public Long getContractInsId() {
+		return contractInsId;
+	}
+
+	public void setContractInsId(Long contractInsId) {
+		this.contractInsId = contractInsId;
+	}
+
 }

+ 18 - 1
src/main/webapp/yw/bpm/customfrom/customViewFlow.jsp

@@ -61,7 +61,7 @@ span[id$="_filespan"] ul{
 		}
 // 		backValue();
 	});
-	function closeSelf(){
+	/* function closeSelf(){
 		var type = "${param.type}";
 		var parentDialogId = "ligerWindow_${param.parentDialogId}";
 		if(type==1){
@@ -71,6 +71,23 @@ span[id$="_filespan"] ul{
 		}else {
 			window.parent.frames['${param.tabid }'].closeODialog('${param.dialogId }');
 		}
+	} */
+	function closeSelf(){
+		var type = "${param.type}";
+		var parentDialogId = "ligerWindow_${param.parentDialogId}";
+		try {
+			if(type==1){
+				window.parent.frames['content'].frames['${param.tabid }'].closeODialog('${param.dialogId }');
+			} else if(type==2){
+				window.parent.frames[parentDialogId].closeODialog('${param.dialogId }');
+			}else {
+				window.parent.frames['${param.tabid }'].closeODialog('${param.dialogId }');
+				$("div#${param.dialogId } .l-dialog-winbtn.l-dialog-close",window.parent.document).click();
+			}
+		} catch (e) {
+			$("div#${param.dialogId } .l-dialog-winbtn.l-dialog-close",window.parent.document).click();
+		}
+
 	}
 
 	function openimg(){

+ 5 - 0
src/main/webapp/yw/contract/paymentApply/processPaymentApply.jsp

@@ -296,6 +296,10 @@
                     <c:when test="${curTacheModel.n_se ne 1 and !fn:contains(curTacheModel.table_fields, ',contract_number,')}">
                         <input type="hidden" name="paymentApply.contractNumber" value="${paymentApply.contractNumber}">
                         ${paymentApply.contractNumber}
+                        <input type="hidden" id="contractInsId" name="paymentApply.contractInsId" value="${paymentApply.contractInsId}"/>
+                        <c:if test="${not empty paymentApply.contractInsId}">
+                            <a href="#" onclick="openODialog('${pageContext.request.contextPath }/FlowAction.do?task=toCustomView&insId=${paymentApply.contractInsId}&tabid='+getCurrentTabId()+'&dialogId=${paymentApply.contractInsId}'+new Date().getTime(), '合同流程查看', '${paymentApply.contractInsId}'+new Date().getTime());">查看合同流程</a>
+                        </c:if>
                     </c:when>
                     <c:otherwise>
                         <input type="hidden" id="contractId" name="paymentApply.contractId" value="${paymentApply.contractId}" />
@@ -780,6 +784,7 @@
     <input type="hidden" name="paymentApply.bankAccount" id="bankAccount" value="${paymentApply.bankAccount}"/>
     <input type="hidden" id="accountId" name="paymentApply.accountId" value="${paymentApply.accountId}"/>
     <input type="hidden" id="accountName" name="paymentApply.accountName" value="${paymentApply.accountName}"/>
+
 </form>
 </body>
 </html>

+ 4 - 0
src/main/webapp/yw/contract/paymentApply/viewPaymentApply.jsp

@@ -122,6 +122,10 @@
             <td class="l-table-edit-text" style="width: 100px;">合同:</td>
             <td class="l-table-edit-td" style="width: 250px;">
                 ${paymentApply.contractNumber}
+                <input type="hidden" id="contractInsId" name="paymentApply.contractInsId" value="${paymentApply.contractInsId}"/>
+                <c:if test="${not empty paymentApply.contractInsId}">
+                    <a href="#" onclick="openODialog('${pageContext.request.contextPath }/FlowAction.do?task=toCustomView&insId=${paymentApply.contractInsId}&tabid='+getCurrentTabId()+'&dialogId=${paymentApply.contractInsId}'+new Date().getTime(), '合同流程查看', '${paymentApply.contractInsId}'+new Date().getTime());">查看合同流程</a>
+                </c:if>
             </td>
             <td class="l-table-edit-text" style="width: 100px;">单位:</td>
             <td class="l-table-edit-td" style="width: 250px;">

+ 10 - 1
src/main/webapp/yw/contract/selectContract.jsp

@@ -70,7 +70,16 @@
 										name : 'firstparty_name',
 										width : 200
 									},
-
+									{
+										display : '合同金额',
+										name : 'contract_money',
+										width : 150
+									},
+									{
+										display : '已付金额',
+										name : 'paidAmount',
+										width : 150
+									},
 									{
 										display : '合同发起日期',
 										name : 'contract_entrying_date',