xinyb_
2022-02-17 6e94d52d0ce0c92c2169cdb19bc675ae08391a35
src/com/yc/MaintenanceFee/service/impl/MaintainServiceImpl.java
@@ -9,6 +9,7 @@
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.RowMapper;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.sql.ResultSet;
import java.sql.SQLException;
@@ -46,13 +47,25 @@
            sb.append(" update t150372 \n" +
                    " set ISpay = 1 ,PayDate=GETDATE() \n" +
                    " where Refdoccode in(select SODoccode from t" + formId + "D where DocCode=@docCode) \n");
            sb.append(createPostSql(formId));
            sb.append(" --执行保存及过账---维护费支付后进行的保存及过账---\n" +
                    " exec p" + formId + "Save @doccode\n" +
                    "                         select @PostFormId = FormId,@DocStatusValue = DocStatus from t" + formId + "H where docCode=@docCode\n" +
                    "                    select @PreDocStatus = PreDocStatus,@PostDocStatus = a.PostDocStatus from gform a where a.formid = @PostFormId \n" +
                    "                if isnull(@DocStatusValue,0) = isnull(@PreDocStatus,0)\n" +
                    "                         begin \n" +
                    "                            update a set DocStatus = @PostDocStatus,PostCode=@EnterCode,PostName=@EnterName,PostDate=@now\n" +
                    "                             from t" + formId + "H a where a.DocCode = @docCode \n" +
                    "                             exec p" + formId + "Post @UserCode = @EnterCode,@UserName = @EnterName, \n" +
                    "                                @DocCode = @docCode,@FormId = @PostFormId,\n" +
                    "                                 @DocStatusValue = @DocStatusValue,@ButtonType ='提交', \n" +
                    "                                @Memo=@Memo output ,@LinkDocInfo = @LinkDocInfo output   \n" +
                    "                         end\n");
            sb.append(" select @docCode as docCode");
            log.info("do120311sql:" + sb.toString());
            this.jdbcTemplate.execute(sb.toString());
            return true;
        } catch (Exception e) {
            return false;
            throw e;
        }
    }
@@ -113,7 +126,8 @@
    @Override
    public String selectCltCodeDbId(String table, String docCode) throws Exception {
        try {
            String sql = "select DocCode,CltCode,DocType,DocDate \n" +
            String sql = "set nocount on\n" +
                    " select DocCode,CltCode,DocType,DocDate \n" +
                    " from " + table + " where DocCode = '" + docCode + "'";
            PayInfo info = super.jdbcTemplate.queryForObject(sql, new BeanPropertyRowMapper<>(PayInfo.class));
            if (info != null && !StringUtils.isBlank(info.getCltCode())) {
@@ -158,7 +172,8 @@
    @Override
    public List<Map<String, Object>> selectMaintainMsg() {
        try {
            String sql = "declare @today datetime = convert(varchar(10),getdate(),120) \n" +
            String sql = "set nocount on\n" +
                    " declare @today datetime = convert(varchar(10),getdate(),120) \n" +
                    " select a.autoid,a.messagetxt,a.refdoccode,a.refformid,a.refformtype,a.insertactioncode," +
                    " a.insertactionname,a.insertdate ,b.dbid,a.unvaliddate,a.tipcount \n" +
                    " from t150372 a join t110203 b on a.cltcode = b.cltcode \n" +
@@ -172,7 +187,8 @@
    @Override
    public Integer selectMaintainCunt(String dbId) {
        try {
            String sql = "select COUNT(*) from t120301H a join t110203 b on a.CltCode=b.cltCode and a.DocStatus=100 and isnull(a.ReceivMoney,0) - isnull(a.ShouKuanAmount,0)>0 where b.dbId=" + dbId;
            String sql = "set nocount on \n" +
                    " select COUNT(*) from t120301H a join t110203 b on a.CltCode=b.cltCode and a.DocStatus=100 and isnull(a.ReceivMoney,0) - isnull(a.ShouKuanAmount,0)>0 where b.dbId=" + dbId;
            return super.jdbcTemplate.queryForObject(sql, Integer.class);
        } catch (Exception e) {
            return 0;
@@ -197,7 +213,8 @@
    @Override
    public List<String> selectWHCode(String skCode) {
        try {
            String sql = "select SODoccode from t150101D where DocCode='" + skCode + "'";
            String sql = "set nocount on\n" +
                    " select SODoccode from t150101D where DocCode='" + skCode + "'";
            return super.jdbcTemplate.query(sql, new RowMapper<String>() {
                @Override
                public String mapRow(ResultSet resultSet, int i) throws SQLException {
@@ -212,7 +229,8 @@
    @Override
    public String queryPayDbId(String whCode) {
        try {
            String sql = "select b.dbid from t120301H a join t110203 b on a.CltCode=b.cltCode where a.docCode='" + whCode + "'";
            String sql = "set nocount on\n" +
                    " select b.dbid from t120301H a join t110203 b on a.CltCode=b.cltCode where a.docCode='" + whCode + "'";
            return super.jdbcTemplate.queryForObject(sql, String.class);
        } catch (Exception e) {
            return "";
@@ -242,28 +260,5 @@
        } catch (Exception e) {
            return -1;
        }
    }
    /**
     * 通过生成单据保存及过账sql,默认以@doccode为单号变量
     *
     * @param formid
     * @return
     */
    private String createPostSql(int formid) {
        return " --执行保存及过账---维护费支付后进行的保存及过账---\n" +
                " exec p" + formid + "Save @doccode\n" +
                "                         select @PostFormId = FormId,@DocStatusValue = DocStatus from t" + formid + "H where docCode=@docCode\n" +
                "                    select @PreDocStatus = PreDocStatus,@PostDocStatus = a.PostDocStatus from gform a where a.formid = @PostFormId \n" +
                "                if isnull(@DocStatusValue,0) = isnull(@PreDocStatus,0)\n" +
                "                         begin \n" +
                "                            update a set DocStatus = @PostDocStatus,PostCode=@EnterCode,PostName=@EnterName,PostDate=@now\n" +
                "                             from t" + formid + "H a where a.DocCode = @docCode \n" +
                "                             exec p" + formid + "Post @UserCode = @EnterCode,@UserName = @EnterName, \n" +
                "                                @DocCode = @docCode,@FormId = @PostFormId,\n" +
                "                                 @DocStatusValue = @DocStatusValue,@ButtonType ='提交', \n" +
                "                                @Memo=@Memo output ,@LinkDocInfo = @LinkDocInfo output   \n" +
                "                         end\n";
    }
}