|
|
@@ -4,18 +4,18 @@ import com.alibaba.fastjson.JSONObject;
|
|
|
import com.github.pagehelper.PageHelper;
|
|
|
import com.github.pagehelper.PageInfo;
|
|
|
import com.usoftchina.saas.account.api.CompanyApi;
|
|
|
-import com.usoftchina.saas.account.dto.CompanyDTO;
|
|
|
-import com.usoftchina.saas.base.Result;
|
|
|
+import com.usoftchina.saas.document.dto.VendorDTO;
|
|
|
+import com.usoftchina.saas.utils.CollectionUtils;
|
|
|
import com.usoftchina.saas.base.service.CommonBaseServiceImpl;
|
|
|
-import com.usoftchina.saas.commons.api.MaxnumberService;
|
|
|
import com.usoftchina.saas.commons.api.MessageLogService;
|
|
|
import com.usoftchina.saas.commons.dto.BatchDealBaseDTO;
|
|
|
import com.usoftchina.saas.commons.dto.DocBaseDTO;
|
|
|
import com.usoftchina.saas.commons.dto.ListReqDTO;
|
|
|
import com.usoftchina.saas.commons.exception.BizExceptionCode;
|
|
|
-import com.usoftchina.saas.commons.po.BillCodeSeq;
|
|
|
+import com.usoftchina.saas.commons.po.DataImportDetail;
|
|
|
import com.usoftchina.saas.context.BaseContextHolder;
|
|
|
-import com.usoftchina.saas.document.dto.VendApamountDTO;
|
|
|
+import com.usoftchina.saas.document.dto.ProductListDTO;
|
|
|
+import com.usoftchina.saas.document.dto.VendApamountListDTO;
|
|
|
import com.usoftchina.saas.document.entities.*;
|
|
|
import com.usoftchina.saas.document.mapper.*;
|
|
|
import com.usoftchina.saas.document.service.VendApamountService;
|
|
|
@@ -113,21 +113,21 @@ 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);
|
|
|
}
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat ("yyyyMM");
|
|
|
-
|
|
|
- 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);}
|
|
|
//更新余额
|
|
|
vendApamount.setVa_leftamount(vendApamount.getVa_beginapamount()-vendApamount.getVa_beginprepayamount()+vendApamount.getVa_payamount()-vendApamount.getVa_preamount());
|
|
|
|
|
|
- if(vendApamount.getId() == 0){
|
|
|
+ if(vendApamount.getId() == 0 || vendApamount.getId() == null){
|
|
|
//新增
|
|
|
vendApamount.setCompanyId(BaseContextHolder.getCompanyId());
|
|
|
vendApamount.setCreatorId(BaseContextHolder.getUserId());
|
|
|
@@ -227,4 +227,91 @@ public class VendApamountServiceImpl extends CommonBaseServiceImpl<VendApamountM
|
|
|
}
|
|
|
return null;
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void saveToFormal(Integer id, boolean update) {
|
|
|
+ if (null == id || "0".equals(id)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ Long companyId = BaseContextHolder.getCompanyId();
|
|
|
+ StringBuilder err = new StringBuilder();
|
|
|
+ List<VendApamount> list = new ArrayList<>();
|
|
|
+ VendApamount listDTO = null;
|
|
|
+ List<DataImportDetail> details = dataImportMapper.selectDataById(id);
|
|
|
+ if (!CollectionUtils.isEmpty(details)) {
|
|
|
+ int i = 0;
|
|
|
+ for (DataImportDetail detail : details) {
|
|
|
+ //数据验证
|
|
|
+ if (StringUtils.isEmpty(detail)) {
|
|
|
+ throw new BizException(BizExceptionCode.BIZ_REPORT_NOTCORRECT);
|
|
|
+ }
|
|
|
+ VendApamount vendApamount = JSONObject.parseObject(detail.getDd_maindata(), VendApamount.class);
|
|
|
+ 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);}
|
|
|
+ //判断是否已存在数据
|
|
|
+ List<VendorDTO> vendors = vendorMapper.getVendorsByCondition("ve_statuscode = 'ENABLE' AND ve_code = '"+vendApamount.getVa_vendcode()+"'",BaseContextHolder.getCompanyId());
|
|
|
+ if (vendors.size() == 0){
|
|
|
+ err.append("第" + (i + 3) + "行 : 供应商编号不存在或该供应商状态未启用!<br/> ");
|
|
|
+ }else{
|
|
|
+ int hasVendNameByCode = getMapper().hasVendNameByCode(vendApamount.getVa_vendcode(),BaseContextHolder.getCompanyId(),vendApamount.getVa_vendname());
|
|
|
+ if(hasVendNameByCode==0){
|
|
|
+ err.append("第" + (i + 3) + "行 : 供应商名称与编号不匹配!<br/> ");
|
|
|
+ }
|
|
|
+ vendApamount.setVa_vendid(vendors.get(0).getId());
|
|
|
+ }
|
|
|
+ int hasCurrency = getMapper().hasCurrency(vendApamount.getVa_currency(), BaseContextHolder.getCompanyId());
|
|
|
+ if (hasCurrency == 0){
|
|
|
+ err.append("第" + (i + 3) + "行 : 币别不存在!<br/> ");
|
|
|
+ }
|
|
|
+ int count = getMapper().validVendCodeAndCurrency(vendApamount.getVa_vendcode(), BaseContextHolder.getCompanyId(), vendApamount.getVa_currency(),0L);
|
|
|
+ if (count > 0){
|
|
|
+ //校验是否可以修改或新增供应商期初
|
|
|
+ Map<String, Object> map = new HashMap<String, Object>();
|
|
|
+ map.put("v_id",vendApamount.getVa_vendid());//供应商ID
|
|
|
+ map.put("v_code", vendApamount.getVa_vendcode());//供应商编号
|
|
|
+ map.put("v_type","vendCurrency");
|
|
|
+ map.put("v_currency",vendApamount.getVa_currency());
|
|
|
+ map.put("v_companyid",BaseContextHolder.getCompanyId());
|
|
|
+ map.put("v_res","");
|
|
|
+ getMapper().check(map);
|
|
|
+ Object result = map.get("v_res");
|
|
|
+ if(!StringUtils.isEmpty(result)){
|
|
|
+ err.append("第" + (i + 3) + "行 : "+result.toString()+"<br/> ");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ list.add(vendApamount);
|
|
|
+ i++;
|
|
|
+ }
|
|
|
+ if (err.length() > 0) {
|
|
|
+ dataImportMapper.updateDataImportError(err.toString(), id);
|
|
|
+ throw new BizException(12345, err.toString());
|
|
|
+ }
|
|
|
+ for (VendApamount vendApamount : list) {
|
|
|
+ //新增
|
|
|
+ vendApamount.setCompanyId(BaseContextHolder.getCompanyId());
|
|
|
+ vendApamount.setCreatorId(BaseContextHolder.getUserId());
|
|
|
+ vendApamount.setCreateTime(new Date());
|
|
|
+ vendApamount.setCreatorName(BaseContextHolder.getUserName());
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat ("yyyyMM");
|
|
|
+ //获取当前期间
|
|
|
+ String now = getMapper().selectPeriod(BaseContextHolder.getCompanyId());
|
|
|
+ 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号,当前日期既为本月第一天
|
|
|
+ vendApamount.setVa_begindate(calendar.getTime());
|
|
|
+
|
|
|
+ getMapper().insertSelective(vendApamount);
|
|
|
+ }
|
|
|
+ dataImportMapper.updateDataImport(id);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|