Browse Source

客户期初代码提交

hy 6 years ago
parent
commit
dc7476efbb

+ 2 - 0
applications/commons/commons-dto/src/main/java/com/usoftchina/saas/commons/exception/BizExceptionCode.java

@@ -49,6 +49,8 @@ public enum BizExceptionCode implements BaseExceptionCode {
     BIZ_NOPERIOD_UPDATE(79354, "期初日期所在期间未结账,不能修改期初金额"),
     BIZ_NOPERIOD_DELETE(79355, "期初日期所在期间未结账,不能删除"),
     BIZ_NOCUST_SAVE(79356, "选择的客户不存在或已禁用"),
+    BIZ_SAMEVENDAP_SAVE(79357, "已存在相同供应商和币别的期初数据,不能新增"),
+    BIZ_SAMECUSTAR_SAVE(79358, "已存在相同客户和币别的期初数据,不能新增"),
 
     NO_OPRATIONDATA(79400,"无可操作单据"),
     NULL_DATA(23232,"无数据"),

+ 7 - 1
applications/document/document-server/src/main/java/com/usoftchina/saas/document/mapper/CustAramountMapper.java

@@ -18,10 +18,12 @@ public interface CustAramountMapper extends CommonBaseMapper<CustAramount> {
 
     int hasCurrency(@Param("name") String name, @Param("companyId") Long companyId);
 
-    int validCustCodeAndCurrency(@Param("custCode") String custCode, @Param("companyId") Long companyId, @Param("currency") String currency, @Param("id") Long id);
+    CustAramount getCustAramountByCustCodeAndCurrency(@Param("custCode") String custCode, @Param("companyId") Long companyId, @Param("currency") String currency, @Param("id") Long id);
 
     void check(Map<String, Object> map);
 
+    void checkForImport(Map<String, Object> map);
+
     String selectPeriod(@Param("companyId") Long companyId);
 
     int checkBeginData(@Param("pd_detno") String pd_detno, @Param("companyId") Long companyId);
@@ -29,4 +31,8 @@ public interface CustAramountMapper extends CommonBaseMapper<CustAramount> {
     CustAramount getCustAramount(@Param("id") Long id, @Param("companyId") Long companyId);
 
     int hasCustNameByCode(@Param("custCode") String custCode, @Param("companyId") Long companyId, @Param("custName") String custName);
+
+    void batchInsert(List<CustAramount> custAramounts);
+
+    void batchUpdate(List<CustAramount> custAramounts);
 }

+ 135 - 36
applications/document/document-server/src/main/java/com/usoftchina/saas/document/service/impl/CustAramountServiceImpl.java

@@ -21,6 +21,8 @@ import com.usoftchina.saas.document.service.CustAramountService;
 import com.usoftchina.saas.exception.BizException;
 import com.usoftchina.saas.page.PageRequest;
 import com.usoftchina.saas.utils.CollectionUtils;
+import com.usoftchina.saas.utils.DateUtils;
+import com.usoftchina.saas.utils.ObjectUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -46,7 +48,8 @@ public class CustAramountServiceImpl extends CommonBaseServiceImpl<CustAramountM
     private DataImportMapper dataImportMapper;
     @Autowired
     private CompanyApi companyApi;
-
+    @Autowired
+    private SubledgerMapper subledgerMapper;
     private static final Logger LOGGER = LoggerFactory.getLogger(CustAramountServiceImpl.class);
 
     public PageInfo<CustAramountList> getListDataByCondition(PageRequest page, ListReqDTO listReqDTO){
@@ -81,13 +84,19 @@ public class CustAramountServiceImpl extends CommonBaseServiceImpl<CustAramountM
             CustAramount custAramount = getMapper().getCustAramount(id,BaseContextHolder.getCompanyId());
             validMoney(custAramount);
             SimpleDateFormat sdf = new SimpleDateFormat ("yyyyMM");
+            String ca_begindate = sdf.format(custAramount.getCa_begindate());
             //判断本次期间是否已结账,结账了就不能删除
-            int checkBeginData = getMapper().checkBeginData(sdf.format(custAramount.getCa_begindate()),BaseContextHolder.getCompanyId());
+            int checkBeginData = getMapper().checkBeginData(ca_begindate,BaseContextHolder.getCompanyId());
             if(checkBeginData > 0){
                 throw new BizException(BizExceptionCode.BIZ_NOPERIOD_DELETE);
             }
-
+            //删除中间表subledger数据
+            String delcond="sl_kind='期初余额' and sl_currency='"+custAramount.getCa_currency()+"' and sl_custid='"+custAramount.getCa_custid()+"'"+
+                    " and sl_ym="+ca_begindate;
+            subledgerMapper.deleteBycondition(delcond,BaseContextHolder.getCompanyId());
             getMapper().deleteByPrimaryKey(id);
+            //更新供应商资料本位币余额
+            customerMapper.updateCustleftamountByPrimaryKey(custAramount.getCa_custid());
             //记录LOG
             messageLogService.delete(generateMsgObj(id));
         }
@@ -111,15 +120,17 @@ public class CustAramountServiceImpl extends CommonBaseServiceImpl<CustAramountM
 
     public DocBaseDTO saveData(CustAramount custAramount){
         DocBaseDTO docBaseDTO = null;
+        if(custAramount.getId()==null){custAramount.setId(0L);}
         if(custAramount.getCa_recamount()==null){custAramount.setCa_recamount(0.00);}
         if(custAramount.getCa_beginaramount()==null){custAramount.setCa_beginaramount(0.00);}
         if(custAramount.getCa_beginprerecamount()==null){custAramount.setCa_beginprerecamount(0.00);}
         if(custAramount.getCa_preamount()==null){custAramount.setCa_preamount(0.00);}
         //判断是否已存在数据
         boolean hasData = hasData(custAramount.getCa_custcode(),custAramount.getCa_currency(),custAramount.getId());
-        if(hasData){
-            validMoney(custAramount);
+        if(hasData&&custAramount.getId() == 0){
+            throw new BizException(BizExceptionCode.BIZ_SAMECUSTAR_SAVE);
         }
+        validMoney(custAramount);
         SimpleDateFormat sdf = new SimpleDateFormat ("yyyyMM");
         //更新余额
         custAramount.setCa_leftamount(custAramount.getCa_beginaramount()-custAramount.getCa_beginprerecamount()+custAramount.getCa_recamount()-custAramount.getCa_preamount());
@@ -164,9 +175,47 @@ public class CustAramountServiceImpl extends CommonBaseServiceImpl<CustAramountM
         }
         //调用更新
         customerMapper.updateCustleftamountByPrimaryKey(custAramount.getCa_custid());
+        updateSubledger(custAramount);
         return docBaseDTO;
     }
 
+    private  void updateSubledger(CustAramount custAramount){
+        //中间表subledger处理
+        Subledger subledger = new Subledger();
+        subledger.setSl_code("期初余额");
+        subledger.setSl_kind("期初余额");
+        subledger.setSl_vendid(0);
+        subledger.setSl_custid(Math.toIntExact(custAramount.getCa_custid()));
+        subledger.setCompanyId(BaseContextHolder.getCompanyId());
+        subledger.setSl_date(custAramount.getCa_begindate());
+        subledger.setSl_ym(DateUtils.getYm(custAramount.getCa_begindate()));
+        subledger.setSl_currency(custAramount.getCa_currency());
+        if(custAramount.getCa_beginaramount()>custAramount.getCa_beginprerecamount()){
+            subledger.setSl_preamount(new Double(0));
+            subledger.setSl_amount(Math.abs(custAramount.getCa_beginaramount()-custAramount.getCa_beginprerecamount()));
+        }else{
+            subledger.setSl_amount(new Double(0));
+            subledger.setSl_preamount(Math.abs(custAramount.getCa_beginaramount()-custAramount.getCa_beginprerecamount()));
+        }
+        subledger.setSl_orderamount(Math.abs(custAramount.getCa_beginaramount()-custAramount.getCa_beginprerecamount()));
+        subledger.setSl_namount(Math.abs(custAramount.getCa_beginaramount()-custAramount.getCa_beginprerecamount()));
+        subledger.setCreateTime(new Date());
+        subledger.setCreatorId(BaseContextHolder.getUserId());
+        subledger.setCreatorName(BaseContextHolder.getUserName());
+        //获取当前期间
+        SimpleDateFormat sdf = new SimpleDateFormat ("yyyyMM");
+        String sl_ym = sdf.format(custAramount.getCa_begindate());
+        String con="sl_kind='期初余额' and sl_custid="+Math.toIntExact(custAramount.getCa_custid())+" and sl_currency='"+custAramount.getCa_currency()+"'"+
+                " and sl_ym="+sl_ym;
+        Long sl_id = subledgerMapper.selectIdBycondition(con,BaseContextHolder.getCompanyId());
+        subledger.setId(sl_id);
+        if ( sl_id!=null && sl_id > 0 ) {
+            subledgerMapper.updateByPrimaryKeySelective(subledger);
+        }else {
+            subledgerMapper.insertSelective(subledger);
+        }
+    };
+
 
     private boolean hasData(String custCode, String currency,Long id){
         int hasCustCode = getMapper().hasCustCode(custCode, BaseContextHolder.getCompanyId());
@@ -177,8 +226,8 @@ public class CustAramountServiceImpl extends CommonBaseServiceImpl<CustAramountM
         if (hasCurrency == 0){
             throw new BizException(BizExceptionCode.BIZ_NOCURRENCY_SAVE);
         }
-        int count = getMapper().validCustCodeAndCurrency(custCode, BaseContextHolder.getCompanyId(), currency,id);
-        if (count > 0){
+        CustAramount custAramount = getMapper().getCustAramountByCustCodeAndCurrency(custCode, BaseContextHolder.getCompanyId(), currency,id);
+        if (!ObjectUtils.isEmpty(custAramount)){
             return true;
         }
         return false;
@@ -232,8 +281,8 @@ public class CustAramountServiceImpl extends CommonBaseServiceImpl<CustAramountM
         }
         Long companyId = BaseContextHolder.getCompanyId();
         StringBuilder err = new StringBuilder();
-        List<CustAramount> list = new ArrayList<>();
-        CustAramount listDTO = null;
+        List<CustAramount> addList = new ArrayList<>();//新增
+        List<CustAramount> updateList = new ArrayList<>();//更新
         List<DataImportDetail> details = dataImportMapper.selectDataById(id);
         if (!CollectionUtils.isEmpty(details)) {
             int i = 0;
@@ -243,6 +292,7 @@ public class CustAramountServiceImpl extends CommonBaseServiceImpl<CustAramountM
                     throw new BizException(BizExceptionCode.BIZ_REPORT_NOTCORRECT);
                 }
                 CustAramount custAramount = JSONObject.parseObject(detail.getDd_maindata(), CustAramount.class);
+                custAramount.setCompanyId(companyId);
                 if(custAramount.getId()==null){custAramount.setId(0L);}
                 if(custAramount.getCa_recamount()==null){custAramount.setCa_recamount(0.00);}
                 if(custAramount.getCa_beginaramount()==null){custAramount.setCa_beginaramount(0.00);}
@@ -251,7 +301,7 @@ public class CustAramountServiceImpl extends CommonBaseServiceImpl<CustAramountM
                 //判断是否已存在数据
                 List<Customer> customers = customerMapper.getCustomersByCondition("cu_statuscode = 'ENABLE' AND cu_code = '"+custAramount.getCa_custcode()+"'",BaseContextHolder.getCompanyId());
                 if (customers.size() == 0){
-                    err.append("第" + (i + 3) + "行 : 客户编号不存在或该客户状态为禁用!<br/> ");
+                    err.append("第" + (i + 3) + "行 : 客户编号不存在或该客户禁用!<br/> ");
                 }else{
                     int hasCustNameByCode = getMapper().hasCustNameByCode(custAramount.getCa_custcode(),BaseContextHolder.getCompanyId(),custAramount.getCa_custname());
                     if(hasCustNameByCode==0){
@@ -263,9 +313,11 @@ public class CustAramountServiceImpl extends CommonBaseServiceImpl<CustAramountM
                 if (hasCurrency == 0){
                     err.append("第" + (i + 3) + "行 : 币别不存在!<br/> ");
                 }
-                int count = getMapper().validCustCodeAndCurrency(custAramount.getCa_custcode(), BaseContextHolder.getCompanyId(), custAramount.getCa_currency(),0L);
-                if (count > 0){
-                    //校验是否可以修改或新增客户期初
+                SimpleDateFormat sdf = new SimpleDateFormat ("yyyyMM");
+                CustAramount oldCustAramount = getMapper().getCustAramountByCustCodeAndCurrency(custAramount.getCa_custcode(), BaseContextHolder.getCompanyId(), custAramount.getCa_currency(),0L);
+                if (!ObjectUtils.isEmpty(oldCustAramount)){
+                    //更新
+                    //校验是否修改客户期初
                     Map<String, Object> map = new HashMap<String, Object>();
                     map.put("v_id",custAramount.getCa_custid());//客户ID
                     map.put("v_code", custAramount.getCa_custcode());//客户编号
@@ -277,39 +329,86 @@ public class CustAramountServiceImpl extends CommonBaseServiceImpl<CustAramountM
                     Object result =  map.get("v_res");
                     if(!StringUtils.isEmpty(result)){
                         err.append("第" + (i + 3) + "行 : "+result.toString()+"<br/> ");
+                    }else{
+                        //加载已存在的数据
+                        custAramount.setId(oldCustAramount.getId());
+                        custAramount.setCa_recamount(oldCustAramount.getCa_recamount());
+                        custAramount.setCa_preamount(oldCustAramount.getCa_preamount());
+                        custAramount.setCa_begindate(oldCustAramount.getCa_begindate());
                     }
+                    custAramount.setUpdaterId(companyId);
+                    custAramount.setUpdateTime(new Date());
+                    //期初日期是否已结账
+                    int checkBeginData = getMapper().checkBeginData(sdf.format(custAramount.getCa_begindate()),companyId);
+                    if(checkBeginData > 0){
+                        err.append("第" + (i + 3) + "行 : "+BizExceptionCode.BIZ_NOPERIOD_UPDATE.getMessage()+"!<br/> ");
+                    }
+                    //更新余额
+                    custAramount.setCa_leftamount(custAramount.getCa_beginaramount()-custAramount.getCa_beginprerecamount()+custAramount.getCa_recamount()-custAramount.getCa_preamount());
+                    updateList.add(custAramount);
+                }else{
+                    //新增
+                    custAramount.setCreatorId(companyId);
+                    custAramount.setCreateTime(new Date());
+                    custAramount.setCreatorName(BaseContextHolder.getUserName());
+                    //获取当前期间
+                    String now = getMapper().selectPeriod(companyId);
+                    Date date = null;
+                    try {
+                        date = sdf.parse(now);
+                    } catch (ParseException e) {
+                        e.printStackTrace();
+                    }
+                    Calendar calendar = Calendar.getInstance();
+                    calendar.setTime(date);
+                    calendar.set(Calendar.DAY_OF_MONTH,1);//设置为1号,当前日期既为本月第一天
+                    custAramount.setCa_begindate(calendar.getTime());
+                    //更新余额
+                    custAramount.setCa_leftamount(custAramount.getCa_beginaramount()-custAramount.getCa_beginprerecamount()+custAramount.getCa_recamount()-custAramount.getCa_preamount());
+                    addList.add(custAramount);
                 }
-                list.add(custAramount);
                 i++;
             }
             if (err.length() > 0) {
                 dataImportMapper.updateDataImportError(err.toString(), id);
                 throw new BizException(12345, err.toString());
             }
-            for (CustAramount  custAramount : list) {
-                //新增
-                custAramount.setCompanyId(BaseContextHolder.getCompanyId());
-                custAramount.setCreatorId(BaseContextHolder.getUserId());
-                custAramount.setCreateTime(new Date());
-                custAramount.setCreatorName(BaseContextHolder.getUserName());
-                SimpleDateFormat sdf = new SimpleDateFormat ("yyyyMM");
-                //更新余额
-                custAramount.setCa_leftamount(custAramount.getCa_beginaramount()-custAramount.getCa_beginprerecamount()+custAramount.getCa_recamount()-custAramount.getCa_preamount());
-                //获取当前期间
-                String now = getMapper().selectPeriod(BaseContextHolder.getCompanyId());
-                Date date = null;
-                try {
-                    date = sdf.parse(now);
-                } catch (ParseException e) {
-                    e.printStackTrace();
+            //新增和更新 批量执行到数据库
+            if(addList.size()>0){
+                //校验是否有重复的数据
+                HashSet<Map<String,String>> hs = new HashSet<Map<String,String>>();
+                for(CustAramount list : addList){
+                    Map<String,String> m = new HashMap<String,String>();
+                    m.put("custCode",list.getCa_custcode());
+                    m.put("currency",list.getCa_currency());
+                    hs.add(m);
+                }
+                if(addList.size()==hs.size()){
+                    getMapper().batchInsert(addList);
+                }else{
+                    throw new BizException(12345, "检测到有客户编号和币别相同的数据,无法导入");
+                }
+            }
+            if(updateList.size()>0){
+                //校验是否有重复的数据
+                HashSet<Map<String,String>> hs = new HashSet<Map<String,String>>();
+                for(CustAramount list : updateList){
+                    Map<String,String> m = new HashMap<String,String>();
+                    m.put("custCode",list.getCa_custcode());
+                    m.put("currency",list.getCa_currency());
+                    hs.add(m);
+                }
+                if(updateList.size()==hs.size()){
+                    getMapper().batchUpdate(updateList);
+                }else{
+                    throw new BizException(12345, "检测到有客户编号和币别相同的数据,无法导入");
                 }
-                Calendar calendar = Calendar.getInstance();
-                calendar.setTime(date);
-                calendar.set(Calendar.DAY_OF_MONTH,1);//设置为1号,当前日期既为本月第一天
-                custAramount.setCa_begindate(calendar.getTime());
-                getMapper().insertSelective(custAramount);
-                customerMapper.updateCustleftamountByPrimaryKey(custAramount.getCa_custid());
             }
+            //校验是否可以修改供应商期初
+            Map<String, Object> map = new HashMap<String, Object>();
+            map.put("v_type","custCurrency");
+            map.put("v_companyid",companyId);
+            getMapper().checkForImport(map);
             dataImportMapper.updateDataImport(id);
         }
     }

+ 40 - 7
applications/document/document-server/src/main/java/com/usoftchina/saas/document/service/impl/VendApamountServiceImpl.java

@@ -83,13 +83,15 @@ public class VendApamountServiceImpl extends CommonBaseServiceImpl<VendApamountM
             VendApamount vendApamount = getMapper().getVendApamount(id,BaseContextHolder.getCompanyId());
             validMoney(vendApamount);
             SimpleDateFormat sdf = new SimpleDateFormat ("yyyyMM");
+            String va_begindate = sdf.format(vendApamount.getVa_begindate());
             //判断本次期间是否已结账,结账了就不能删除
-            int checkBeginData = getMapper().checkBeginData(sdf.format(vendApamount.getVa_begindate()),BaseContextHolder.getCompanyId());
+            int checkBeginData = getMapper().checkBeginData(va_begindate,BaseContextHolder.getCompanyId());
             if(checkBeginData > 0){
                 throw new BizException(BizExceptionCode.BIZ_NOPERIOD_DELETE);
             }
             //删除中间表subledger数据
-            String delcond="sl_kind='期初余额' and sl_currency='"+vendApamount.getVa_currency()+"' and sl_vendid='"+vendApamount.getVa_vendid()+"'";
+            String delcond="sl_kind='期初余额' and sl_currency='"+vendApamount.getVa_currency()+"' and sl_vendid='"+vendApamount.getVa_vendid()+"'"+
+                    " and sl_ym="+va_begindate;
             subledgerMapper.deleteBycondition(delcond,BaseContextHolder.getCompanyId());
             getMapper().deleteByPrimaryKey(id);
             //更新供应商资料本位币余额
@@ -117,15 +119,17 @@ public class VendApamountServiceImpl extends CommonBaseServiceImpl<VendApamountM
 
     public DocBaseDTO saveData(VendApamount vendApamount){
         DocBaseDTO docBaseDTO = null;
+        if(vendApamount.getId()==null){vendApamount.setId(0L);}
         if(vendApamount.getVa_payamount()==null){vendApamount.setVa_payamount(0.00);}
         if(vendApamount.getVa_beginapamount()==null){vendApamount.setVa_beginapamount(0.00);}
         if(vendApamount.getVa_beginprepayamount()==null){vendApamount.setVa_beginprepayamount(0.00);}
         if(vendApamount.getVa_preamount()==null){vendApamount.setVa_preamount(0.00);}
         //判断是否已存在数据
         boolean hasData = hasData(vendApamount.getVa_vendcode(),vendApamount.getVa_currency(),vendApamount.getId());
-        if(hasData){
-            validMoney(vendApamount);
+        if(hasData&&vendApamount.getId() == 0){
+            throw new BizException(BizExceptionCode.BIZ_SAMEVENDAP_SAVE);
         }
+        validMoney(vendApamount);
         SimpleDateFormat sdf = new SimpleDateFormat ("yyyyMM");
         //更新余额
         vendApamount.setVa_leftamount(vendApamount.getVa_beginapamount()-vendApamount.getVa_beginprepayamount()+vendApamount.getVa_payamount()-vendApamount.getVa_preamount());
@@ -197,7 +201,11 @@ public class VendApamountServiceImpl extends CommonBaseServiceImpl<VendApamountM
         subledger.setCreateTime(new Date());
         subledger.setCreatorId(BaseContextHolder.getUserId());
         subledger.setCreatorName(BaseContextHolder.getUserName());
-        String con="sl_kind='期初余额' and sl_vendid="+Math.toIntExact(vendApamount.getVa_vendid())+" and sl_currency='"+vendApamount.getVa_currency()+"'";
+        //获取当前期间
+        SimpleDateFormat sdf = new SimpleDateFormat ("yyyyMM");
+        String sl_ym = sdf.format(vendApamount.getVa_begindate());
+        String con="sl_kind='期初余额' and sl_vendid="+Math.toIntExact(vendApamount.getVa_vendid())+" and sl_currency='"+vendApamount.getVa_currency()+"'"+
+                " and sl_ym="+sl_ym;
         Long sl_id = subledgerMapper.selectIdBycondition(con,BaseContextHolder.getCompanyId());
         subledger.setId(sl_id);
         if ( sl_id!=null && sl_id > 0 ) {
@@ -364,16 +372,41 @@ public class VendApamountServiceImpl extends CommonBaseServiceImpl<VendApamountM
             }
             //新增和更新 批量执行到数据库
             if(addList.size()>0){
-                getMapper().batchInsert(addList);
+                //校验是否有重复的数据
+                HashSet<Map<String,String>> hs = new HashSet<Map<String,String>>();
+                for(VendApamount list : addList){
+                    Map<String,String> m = new HashMap<String,String>();
+                    m.put("vendCode",list.getVa_vendcode());
+                    m.put("currency",list.getVa_currency());
+                    hs.add(m);
+                }
+                if(addList.size()==hs.size()){
+                    getMapper().batchInsert(addList);
+                }else{
+                    throw new BizException(12345, "检测到有供应商编号和币别相同的数据,无法导入");
+                }
             }
             if(updateList.size()>0){
-                getMapper().batchUpdate(updateList);
+                //校验是否有重复的数据
+                HashSet<Map<String,String>> hs = new HashSet<Map<String,String>>();
+                for(VendApamount list : updateList){
+                    Map<String,String> m = new HashMap<String,String>();
+                    m.put("vendCode",list.getVa_vendcode());
+                    m.put("currency",list.getVa_currency());
+                    hs.add(m);
+                }
+                if(updateList.size()==hs.size()){
+                    getMapper().batchUpdate(updateList);
+                }else{
+                    throw new BizException(12345, "检测到有供应商编号和币别相同的数据,无法导入");
+                }
             }
             //校验是否可以修改供应商期初
             Map<String, Object> map = new HashMap<String, Object>();
             map.put("v_type","vendCurrency");
             map.put("v_companyid",companyId);
             getMapper().checkForImport(map);
+            dataImportMapper.updateDataImport(id);
         }
     }
 }

+ 56 - 2
applications/document/document-server/src/main/resources/mapper/CustAramountMapper.xml

@@ -82,6 +82,14 @@
         <parameter property="v_res" jdbcType="VARCHAR" mode="OUT" />
     </parameterMap>
 
+    <select id="checkForImport" parameterMap="checkForImportParamMap" statementType="CALLABLE">
+        CALL SP_CUSTARORVENDAPAFTER(?, ?)
+    </select>
+    <parameterMap id="checkForImportParamMap" type="java.util.Map">
+        <parameter property="v_type" jdbcType="VARCHAR" mode="IN" />
+        <parameter property="v_companyid" jdbcType="INTEGER" mode="IN" />
+    </parameterMap>
+
     <insert id="insertSelective" parameterType="com.usoftchina.saas.document.entities.CustAramount">
         <selectKey resultType="java.lang.Long" keyProperty="id">
             SELECT LAST_INSERT_ID() AS ID
@@ -203,6 +211,9 @@
             <if test="ca_beginprerecamount != null">
                 ca_beginprerecamount = #{ca_beginprerecamount,jdbcType=DOUBLE},
             </if>
+            <if test="ca_leftamount != null">
+                ca_leftamount = #{ca_leftamount,jdbcType=DOUBLE},
+            </if>
             <if test="updaterId != null">
                 updaterId = #{updaterId,jdbcType=INTEGER},
             </if>
@@ -282,8 +293,8 @@
         </where>
     </select>
 
-    <select id="validCustCodeAndCurrency" resultType="int">
-        SELECT COUNT(*) FROM CustAramount
+    <select id="getCustAramountByCustCodeAndCurrency" resultMap="CustAramountResultMapper">
+        SELECT * FROM CustAramount
         <where>
             <if test="custCode!=null">
                 and ca_custcode=#{custCode}
@@ -300,4 +311,47 @@
         </where>
     </select>
 
+    <insert id="batchInsert" parameterType="java.util.List">
+        INSERT INTO custaramount (ca_custid, ca_custcode, ca_custname, ca_currency, ca_begindate, ca_beginaramount,
+        ca_beginprerecamount, ca_recamount, ca_preamount, ca_leftamount, companyId, creatorName, creatorId, createTime)
+        VALUES
+        <foreach collection="list" item="item" index="index" open="" close="" separator=",">
+            (
+            #{item.ca_custid,jdbcType=INTEGER},
+            #{item.ca_custcode,jdbcType=VARCHAR}, #{item.ca_custname,jdbcType=VARCHAR}, #{item.ca_currency,jdbcType=VARCHAR},
+            #{item.ca_begindate,jdbcType=TIMESTAMP}, #{item.ca_beginaramount,jdbcType=DOUBLE}, #{item.ca_beginprerecamount,jdbcType=DOUBLE},
+            #{item.ca_recamount,jdbcType=DOUBLE},#{item.ca_preamount,jdbcType=DOUBLE}, #{item.ca_leftamount,jdbcType=DOUBLE},
+            #{item.companyId,jdbcType=INTEGER},#{item.creatorName,jdbcType=VARCHAR}, #{item.creatorId,jdbcType=INTEGER},
+            #{item.createTime,jdbcType=TIMESTAMP}
+            )
+        </foreach>
+    </insert>
+
+    <update id="batchUpdate" parameterType="com.usoftchina.saas.document.entities.CustAramount">
+        <foreach collection="list" item="item" index="index" separator=";">
+            update custaramount
+            <set>
+                <if test="item.ca_beginaramount != null">
+                    ca_beginaramount = #{item.ca_beginaramount,jdbcType=DOUBLE},
+                </if>
+                <if test="item.ca_beginprerecamount != null">
+                    ca_beginprerecamount = #{item.ca_beginprerecamount,jdbcType=DOUBLE},
+                </if>
+                <if test="item.ca_leftamount != null">
+                    ca_leftamount = #{item.ca_leftamount,jdbcType=DOUBLE},
+                </if>
+                <if test="item.updaterId != null">
+                    updaterId = #{item.updaterId,jdbcType=INTEGER},
+                </if>
+                <if test="item.updateTime != null">
+                    updateTime = #{item.updateTime,jdbcType=TIMESTAMP},
+                </if>
+                <if test="item.updaterName != null">
+                    updaterName = #{item.updaterName,jdbcType=VARCHAR},
+                </if>
+            </set>
+            where ca_id = #{item.id}
+        </foreach>
+    </update>
+
 </mapper>

+ 1 - 0
frontend/saas-web/app/view/core/form/field/FileField.js

@@ -8,6 +8,7 @@ Ext.define('saas.view.core.form.field.FileField', {
 	collapsible: true,
 	multi: true,
 	allowBlank:true,
+	isFormField:true,
 	initComponent: function() {
 		this.columnWidth = 1;//强制占一行
 		this.cls = '';