Browse Source

Merge branch 'dev' of ssh://10.10.100.21/source/saas-platform into dev

zhoudw 7 years ago
parent
commit
b23a18d159

+ 1 - 1
applications/money/money-dto/src/main/java/com/usoftchina/saas/money/dto/VerificationdetDTO.java

@@ -23,7 +23,7 @@ public class VerificationdetDTO  extends  CommonBaseDTO implements Serializable
 
     private Integer vd_ym;
 
-    private Integer vd_slid;
+    private Long vd_slid;
 
     private String vd_slcode;
 

+ 1 - 1
applications/money/money-dto/src/main/java/com/usoftchina/saas/money/dto/VerificationdetailDTO.java

@@ -23,7 +23,7 @@ public class VerificationdetailDTO extends  CommonBaseDTO implements Serializabl
 
     private Integer vcd_ym;
 
-    private Integer vcd_slid;
+    private Long vcd_slid;
 
     private String vcd_slcode;
 

+ 4 - 3
applications/money/money-server/src/main/java/com/usoftchina/saas/money/controller/VerificationController.java

@@ -3,6 +3,7 @@ package com.usoftchina.saas.money.controller;
 import com.github.pagehelper.PageInfo;
 import com.usoftchina.saas.base.Result;
 import com.usoftchina.saas.commons.dto.BatchDealBaseDTO;
+import com.usoftchina.saas.commons.dto.DocBaseDTO;
 import com.usoftchina.saas.commons.dto.DocSavedDTO;
 import com.usoftchina.saas.commons.dto.ListReqDTO;
 import com.usoftchina.saas.money.dto.VerificationFormDTO;
@@ -59,7 +60,7 @@ public class VerificationController {
      */
     @RequestMapping("/save")
     public Result<DocSavedDTO> saveFormData(@RequestBody VerificationFormDTO form) {
-        DocSavedDTO base = verificationService.saveFormData(form);
+        DocBaseDTO base = verificationService.saveFormData(form);
         return Result.success(base);
     }
 
@@ -98,11 +99,11 @@ public class VerificationController {
 
     @RequestMapping("/audit")
     public Result audit(@RequestBody VerificationFormDTO formDTO) {
-        DocSavedDTO audit = verificationService.audit(formDTO);
+        DocBaseDTO audit = verificationService.audit(formDTO);
         return Result.success(audit);
     }
 
-    @RequestMapping("/resAudit/{id}")
+    @RequestMapping("/unAudit/{id}")
     public Result resAudit(@PathVariable("id") Long id) {
         verificationService.resAudit(id);
         return Result.success();

+ 9 - 0
applications/money/money-server/src/main/java/com/usoftchina/saas/money/po/Subledger.java

@@ -7,6 +7,7 @@ import java.util.Date;
 
 //中间表
 public class Subledger extends CommonBaseEntity implements Serializable {
+    private Long sl_id;
 
     private String sl_code;
 
@@ -138,4 +139,12 @@ public class Subledger extends CommonBaseEntity implements Serializable {
     public void setSl_ym(Integer sl_ym) {
         this.sl_ym = sl_ym;
     }
+
+    public Long getSl_id() {
+        return sl_id;
+    }
+
+    public void setSl_id(Long sl_id) {
+        this.sl_id = sl_id;
+    }
 }

+ 3 - 3
applications/money/money-server/src/main/java/com/usoftchina/saas/money/po/Verificationdet.java

@@ -20,7 +20,7 @@ public class Verificationdet extends CommonBaseEntity implements Serializable {
 
     private Integer vd_ym;
 
-    private Integer vd_slid;
+    private Long vd_slid;
 
     private String vd_slcode;
 
@@ -80,11 +80,11 @@ public class Verificationdet extends CommonBaseEntity implements Serializable {
         this.vd_ym = vd_ym;
     }
 
-    public Integer getVd_slid() {
+    public Long getVd_slid() {
         return vd_slid;
     }
 
-    public void setVd_slid(Integer vd_slid) {
+    public void setVd_slid(Long vd_slid) {
         this.vd_slid = vd_slid;
     }
 

+ 3 - 3
applications/money/money-server/src/main/java/com/usoftchina/saas/money/po/Verificationdetail.java

@@ -20,7 +20,7 @@ public class Verificationdetail extends CommonBaseEntity implements Serializable
 
     private Integer vcd_ym;
 
-    private Integer vcd_slid;
+    private Long vcd_slid;
 
     private String vcd_slcode;
 
@@ -80,11 +80,11 @@ public class Verificationdetail extends CommonBaseEntity implements Serializable
         this.vcd_ym = vcd_ym;
     }
 
-    public Integer getVcd_slid() {
+    public Long getVcd_slid() {
         return vcd_slid;
     }
 
-    public void setVcd_slid(Integer vcd_slid) {
+    public void setVcd_slid(Long vcd_slid) {
         this.vcd_slid = vcd_slid;
     }
 

+ 3 - 2
applications/money/money-server/src/main/java/com/usoftchina/saas/money/service/VerificationService.java

@@ -2,6 +2,7 @@ package com.usoftchina.saas.money.service;
 
 import com.github.pagehelper.PageInfo;
 import com.usoftchina.saas.commons.dto.BatchDealBaseDTO;
+import com.usoftchina.saas.commons.dto.DocBaseDTO;
 import com.usoftchina.saas.commons.dto.DocSavedDTO;
 import com.usoftchina.saas.commons.dto.ListReqDTO;
 import com.usoftchina.saas.money.dto.VerificationFormDTO;
@@ -37,7 +38,7 @@ public interface VerificationService {
      * @param formdata
      * @return
      */
-    DocSavedDTO saveFormData(VerificationFormDTO formdata);
+    DocBaseDTO saveFormData(VerificationFormDTO formdata);
 
     /**
      * 删除核销单
@@ -62,7 +63,7 @@ public interface VerificationService {
      * @param formData
      * @return
      */
-    DocSavedDTO audit(VerificationFormDTO formData);
+    DocBaseDTO audit(VerificationFormDTO formData);
 
     /**
      * 反审核核销单

+ 75 - 92
applications/money/money-server/src/main/java/com/usoftchina/saas/money/service/impl/VerificationServiceImpl.java

@@ -108,10 +108,11 @@ public class VerificationServiceImpl extends CommonBaseServiceImpl<VerificationM
     }
 
     @Override
-    public DocSavedDTO saveFormData(VerificationFormDTO formdata) {
+    public DocBaseDTO saveFormData(VerificationFormDTO formdata) {
         if (null == formdata || null == formdata.getMain()){
             throw new BizException(BizExceptionCode.EMPTY_DATA);
         }
+
         //公司ID
         Long companyId = BaseContextHolder.getCompanyId();
         //人员Id
@@ -122,100 +123,71 @@ public class VerificationServiceImpl extends CommonBaseServiceImpl<VerificationM
         List<VerificationdetDTO> items1 = formdata.getItems1();
         //获取从表2
         List<VerificationdetailDTO> items2 = formdata.getItems2();
-        //插入从表数据
-        List<Verificationdet> insertDetails1 = new ArrayList<>();
-        List<Verificationdetail> insertDetails2 = new ArrayList<>();
-        //更新从表数据
-        List<Verificationdet> updateDetails1 = new ArrayList<>();
-        List<Verificationdetail> updateDetails2 = new ArrayList<>();
-        DocSavedDTO saveDTO = new DocSavedDTO();
+
+        DocBaseDTO baseDTO = null;
         Long id = main.getId();
         String code = main.getVc_code();
-        Verification verification = BeanMapper.map(main,Verification.class);
-        verification.setCompanyId(companyId);
-        verification.setCreatorId(userId);
-        verification.setCreateTime(new Date());
-        String kind = verification.getVc_kind();
-        verification.setVc_kind(transferKind(kind));
+        //编号校验
+        code = pushMaxnubmer(code, id);
+        main.setVc_code(code);
 
-        //编号获取
-        code = pushMaxnubmer(code,id);
-        verification.setVc_code(code);
-        saveDTO.setCode(code);
+        Verification verification = BeanMapper.map(main,Verification.class);
+        if(id.longValue() > 0 ){
+            String kind = verification.getVc_kind();
+            verification.setVc_kind(transferKind(kind));
+            verificationMapper.updateByPrimaryKey(verification);
+            baseDTO = new DocBaseDTO(id, code, BillCodeSeq.VERIFICATION.getCaller());
+            if (!("AUDITED".equals(verification.getVc_statuscode()))) {
+                //日志记录
+                messageLogService.update(baseDTO);
+            }
+        }else{
+            verification.setCompanyId(companyId);
+            verification.setVc_recorder(BaseContextHolder.getUserName());
+            verification.setCreateTime(new Date());
+            verification.setCreatorId(userId);
+            verification.setCreatorName(BaseContextHolder.getUserName());
+            String kind = verification.getVc_kind();
+            verification.setVc_kind(transferKind(kind));
+            verificationMapper.insertSelective(verification);
+            id = verification.getId();
+            baseDTO = new DocBaseDTO(id, code, BillCodeSeq.VERIFICATION.getCaller());
+            if (!("AUDITED".equals(verification.getVc_statuscode()))) {
+                //日志记录
+                messageLogService.save(baseDTO);
+            }
+        }
         SimpleDateFormat simpleDateFormat = new SimpleDateFormat("YYYYMM");
         String dateYM = simpleDateFormat.format(verification.getVc_date());
         Integer numberYM = Integer.valueOf(dateYM);
         //判断更新与保存动作
-        if (StringUtils.isEmpty(id) || "0".equals(id.toString())){
-            //插入操作
-            getMapper().insertSelective(verification);
-            id = verification.getId();
-
-            //添加从表传输对象
-            for (VerificationdetDTO item : items1) {
-                Verificationdet detail = BeanMapper.map(item,Verificationdet.class);
-                detail.setVd_vcid(id);
-                detail.setCompanyId(companyId);
-                detail.setVd_ym(numberYM);
-                insertDetails1.add(detail);
-            }
-            for (VerificationdetailDTO item : items2) {
-                Verificationdetail detail = BeanMapper.map(item,Verificationdetail.class);
-                detail.setVcd_vcid(id);
-                detail.setVcd_ym(numberYM);
-                detail.setCompanyId(companyId);
-                insertDetails2.add(detail);
-            }
-            //插入从表
-            if (insertDetails1.size()>0) {
-                verificationdetMapper.batchInsert(insertDetails1);
-            }
-            if (insertDetails2.size()>0) {
-                verificationdetailMapper.batchInsert(insertDetails2);
-            }
-        }
-        //更新操作
-        getMapper().updateByPrimaryKeySelective(verification);
         //添加从表传输对象
         for (VerificationdetDTO item : items1) {
-            Verificationdet detail = BeanMapper.map(item, Verificationdet.class);
+            Verificationdet detail = BeanMapper.map(item,Verificationdet.class);
+            Long vd_id = detail.getId();
             detail.setVd_vcid(id);
-            detail.setVd_ym(numberYM);
             detail.setCompanyId(companyId);
-            if (StringUtils.isEmpty(detail.getId()) || "0".equals(detail.getId().toString())) {
-                insertDetails1.add(detail);
-            } else {
-                updateDetails1.add(detail);
+            detail.setVd_ym(numberYM);
+            if (vd_id>0){
+                verificationdetMapper.updateByPrimaryKey(detail);
+            }else{
+                verificationdetMapper.insertSelective(detail);
             }
         }
         for (VerificationdetailDTO item : items2) {
-            Verificationdetail detail = BeanMapper.map(item, Verificationdetail.class);
+            Verificationdetail detail = BeanMapper.map(item,Verificationdetail.class);
             detail.setVcd_vcid(id);
             detail.setVcd_ym(numberYM);
             detail.setCompanyId(companyId);
-            if (StringUtils.isEmpty(detail.getId()) || "0".equals(detail.getId().toString())) {
-                insertDetails2.add(detail);
-            } else {
-                updateDetails2.add(detail);
+            Long vcd_id = detail.getId();
+            if(vcd_id>0){
+                verificationdetailMapper.updateByPrimaryKey(detail);
+            }else{
+                verificationdetailMapper.insertSelective(detail);
             }
         }
-        //插入从表
-        if (insertDetails1.size()>0) {
-            verificationdetMapper.batchInsert(insertDetails1);
-        }
-        if (insertDetails2.size()>0) {
-            verificationdetailMapper.batchInsert(insertDetails2);
-        }
-        //更新从表
-        if (updateDetails1.size()>0) {
-            verificationdetMapper.batchUpdate(updateDetails1);
-        }
-        if (updateDetails2.size()>0) {
-            verificationdetailMapper.batchUpdate(updateDetails2);
-        }
         updateCorrespondingData(formdata);
-        saveDTO.setId(id);
-        return saveDTO;
+        return baseDTO;
     }
 
     private void updateCorrespondingData(VerificationFormDTO formdata) {
@@ -301,17 +273,18 @@ public class VerificationServiceImpl extends CommonBaseServiceImpl<VerificationM
             subledger.setSl_custid(verification.getVc_custid());
             subledger.setSl_vendid(0);
         }
-
+        Double amount1 = verification.getVc_amount1()==null?new Double(0):verification.getVc_amount1();
+        Double amount2 = verification.getVc_amount2()==null?new Double(0):verification.getVc_amount2();
         subledger.setSl_date(verification.getVc_date());
-        subledger.setSl_amount(-verification.getVc_amount2());
+        subledger.setSl_amount(-amount2);
         subledger.setSl_orderamount(new Double(0));
         subledger.setSl_yamount(new Double(0));
         subledger.setSl_remark(verification.getVc_remark());
         subledger.setSl_discount(new Double(0));
         if(kind.equals("receipts_offset_receivable") || kind.equals("prepaid_offset_payable")){
-            subledger.setSl_preamount(-verification.getVc_amount1());
+            subledger.setSl_preamount(-amount1);
         }else{
-            subledger.setSl_preamount(new Double(0));
+            subledger.setSl_preamount(amount1);
         }
         return subledger;
     }
@@ -320,10 +293,10 @@ public class VerificationServiceImpl extends CommonBaseServiceImpl<VerificationM
      * @param id
      * @param nowBalance
      */
-    private void updateAuditSubledeger(int id , Double nowBalance){
-        Subledger subledger = subledgerMapper.selectByPrimaryKey(id);
+    private void updateAuditSubledeger(Long id , Double nowBalance){
+        Subledger subledger = subledgerMapper.selectByPrimaryKey(Math.toIntExact(id));
         Subledger newSubledeger = new Subledger();
-        newSubledeger.setId(Long.valueOf(String.valueOf(id)));
+        newSubledeger.setSl_id(id);
         Double newNamout = subledger.getSl_namount()==null?new Double(0):subledger.getSl_namount()-nowBalance;
         Double newYamout = subledger.getSl_yamount()==null?new Double(0):subledger.getSl_yamount()+nowBalance;
         newSubledeger.setSl_yamount(newYamout);
@@ -370,7 +343,17 @@ public class VerificationServiceImpl extends CommonBaseServiceImpl<VerificationM
                 return "应收转应收";
             case "payable_to_payable":
                 return "应付转应付";
-                default:return "";
+            case "预收冲应收":
+                return "receipts_offset_receivable";
+            case "预付冲应付":
+                return "prepaid_offset_payable";
+            case "应收冲应付":
+                return "receivable_offset_payable";
+            case "应收转应收":
+                return "receivable_to_receivable";
+            case "应付转应付":
+                return "payable_to_payable";
+                default: return "";
         }
     }
 
@@ -418,13 +401,13 @@ public class VerificationServiceImpl extends CommonBaseServiceImpl<VerificationM
     @Override
     public void deleteDetail1(Long id) {
         if (null != id) {
-            verificationdetMapper.deleteByParentPrimaryKey(Long.valueOf(String.valueOf(id)));
             Verificationdet verificationdet = verificationdetMapper.selectByPrimaryKey(Integer.valueOf(String.valueOf(id)));
             Verification verification = verificationMapper.selectByPrimaryKey(verificationdet.getVd_vcid());
             DocBaseDTO baseDTO = new DocBaseDTO();
             baseDTO.setId(id);
             baseDTO.setCode(verification.getVc_code());
             baseDTO.setName(BillCodeSeq.VERIFICATION.getName());
+            verificationdetMapper.deleteByParentPrimaryKey(Long.valueOf(String.valueOf(id)));
             //日志
             messageLogService.deleteDetail(baseDTO);
         }
@@ -446,14 +429,14 @@ public class VerificationServiceImpl extends CommonBaseServiceImpl<VerificationM
     }
 
     @Override
-    public DocSavedDTO audit(VerificationFormDTO formData) {
+    public DocBaseDTO audit(VerificationFormDTO formData) {
         Long id = null;
-        DocSavedDTO savedDTO = new DocSavedDTO();
+        DocBaseDTO baseDTO = new DocBaseDTO();
         if (null != formData) {
-            id = Long.valueOf(String.valueOf(formData.getMain().getVc_id()));
+            id = formData.getMain().getId();
             if (StringUtils.isEmpty(id)) {
-                DocSavedDTO saveDTO = saveFormData(formData);
-                id = saveDTO.getId();
+                baseDTO = saveFormData(formData);
+                id = baseDTO.getId();
             }
             Verification verification = new Verification();
             verification.setVc_status(Status.AUDITED.getDisplay());
@@ -484,8 +467,8 @@ public class VerificationServiceImpl extends CommonBaseServiceImpl<VerificationM
                 updateAuditSubledeger(detail.getVcd_slid(),nowbalanceDet);
             }
         }
-        savedDTO.setId(id);
-        return savedDTO;
+        baseDTO.setId(id);
+        return baseDTO;
     }
 
     /**
@@ -669,7 +652,7 @@ public class VerificationServiceImpl extends CommonBaseServiceImpl<VerificationM
         }
 
         //更新客户或者供应商的金额
-        Verification nowverification = verificationMapper.selectByPrimaryKey(id);
+        Verification nowverification = verificationMapper.selectByPrimaryKey(Math.toIntExact(id));
         VerificationDTO verificationDTO = BeanMapper.map(nowverification,VerificationDTO.class);
         updateResAuditCustomer(verificationDTO);
         updateResAuditVendor(verificationDTO);

+ 2 - 3
applications/money/money-server/src/main/resources/mapper/VerificationListMapper.xml

@@ -51,8 +51,7 @@
     <select id="selectVerificationListByCondition"  resultMap="BaseResultMap">
         select
         <include refid="Base_Column_List" />
-        from verification left join verificationdet on vc_id=vd_vcid
-        and verification.companyid=verificationdet.companyid
+        from verification
         <where>
             <if test="con != null">
                 ${con}
@@ -76,6 +75,6 @@
                 and  verification.companyId = #{companyId}
             </if>
         </where>
-        order by vc_id
+        order by vc_date desc,vc_id desc
     </select>
 </mapper>

+ 1 - 1
applications/money/money-server/src/main/resources/mapper/VerificationMapper.xml

@@ -595,7 +595,7 @@
         vc_text5 = #{vc_text5,jdbcType=VARCHAR},
       </if>
     </set>
-    where vc_id = #{id,jdbcType=INTEGER}
+    where vc_id = #{vc_id,jdbcType=INTEGER}
   </update>
   <update id="updateByPrimaryKey" parameterType="com.usoftchina.saas.money.po.Verification" >
     update verification

+ 4 - 1
applications/money/money-server/src/main/resources/mapper/VerificationdetMapper.xml

@@ -246,6 +246,9 @@
         #{vd_text5,jdbcType=VARCHAR},
       </if>
     </trim>
+    <selectKey resultType="Long" keyProperty="id" order="AFTER">
+      SELECT LAST_INSERT_ID()
+    </selectKey>
   </insert>
   <select id="countByExample" parameterType="com.usoftchina.saas.money.po.VerificationdetExample" resultType="java.lang.Integer" >
     select count(*) from verificationdet
@@ -401,7 +404,7 @@
         vd_text5 = #{vd_text5,jdbcType=VARCHAR},
       </if>
     </set>
-    where vd_id = #{vd_id,jdbcType=INTEGER}
+    where vd_id = #{id,jdbcType=INTEGER}
   </update>
   <update id="updateByPrimaryKey" parameterType="com.usoftchina.saas.money.po.Verificationdet" >
     update verificationdet

+ 5 - 2
applications/money/money-server/src/main/resources/mapper/VerificationdetailMapper.xml

@@ -190,7 +190,7 @@
         vcd_text5,
       </if>
     </trim>
-    <trim prefix="values (" suffix=")" suffixOverrides="," >-0--0
+    <trim prefix="values (" suffix=")" suffixOverrides="," >
       <if test="vcd_vcid != null" >
         #{vcd_vcid,jdbcType=INTEGER},
       </if>
@@ -246,6 +246,9 @@
         #{vcd_text5,jdbcType=VARCHAR},
       </if>
     </trim>
+    <selectKey resultType="Long" keyProperty="id" order="AFTER">
+      SELECT LAST_INSERT_ID()
+    </selectKey>
   </insert>
   <select id="countByExample" parameterType="com.usoftchina.saas.money.po.VerificationdetailExample" resultType="java.lang.Integer" >
     select count(*) from verificationdetail
@@ -401,7 +404,7 @@
         vcd_text5 = #{vcd_text5,jdbcType=VARCHAR},
       </if>
     </set>
-    where vcd_id = #{vcd_id,jdbcType=INTEGER}
+    where vcd_id = #{id,jdbcType=INTEGER}
   </update>
   <update id="updateByPrimaryKey" parameterType="com.usoftchina.saas.money.po.Verificationdetail" >
     update verificationdetail

+ 6 - 1
frontend/saas-web/app/view/money/verification/QueryPanel.js

@@ -126,7 +126,12 @@ Ext.define('saas.view.money.verification.QueryPanel', {
             xtype: 'numbercolumn',
             width: 120,
             flex: 1,
-            hidden: true
+            renderer : function(v) {
+                var arr = (v + '.').split('.');
+                var xr = (new Array(arr[1].length > 2 ? 2 : arr[1].length)).fill('0');
+                var format = '0,000.' + xr.join();
+                return Ext.util.Format.number(v, format);
+            }
         }]
     }
 });