Commit c4742a0f by huluobin

update

parent dd49d703
package com.blt.other.common.config.property;
/**
* <p>
*
* </p>
*
* @author robbendev
* @since 2021/1/4 1:16 下午
*/
public class ProjectConstant {
public static final String CNY = "CNY";
}
...@@ -17,6 +17,7 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -17,6 +17,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.text.ParseException; import java.text.ParseException;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.time.LocalDateTime; import java.time.LocalDateTime;
...@@ -30,7 +31,7 @@ import java.util.stream.Collectors; ...@@ -30,7 +31,7 @@ import java.util.stream.Collectors;
@RequestMapping("/cost/api") @RequestMapping("/cost/api")
public class CostApiController implements CostApi { public class CostApiController implements CostApi {
@Autowired @Resource
private CostApiService costApiService; private CostApiService costApiService;
private static Logger logger = LoggerFactory.getLogger(CostApiController.class); private static Logger logger = LoggerFactory.getLogger(CostApiController.class);
......
...@@ -2,9 +2,9 @@ package com.blt.other.module.cost.dao; ...@@ -2,9 +2,9 @@ package com.blt.other.module.cost.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.blt.other.database.model.CostTypeDomain;
import com.blt.other.module.cost.dto.request.CostTypeQueryPageReq; import com.blt.other.module.cost.dto.request.CostTypeQueryPageReq;
import com.blt.other.module.cost.dto.response.CostTypeResult; import com.blt.other.module.cost.dto.response.CostTypeResult;
import com.blt.other.database.model.CostTypeDomain;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
...@@ -25,4 +25,7 @@ public interface CostTypeDao extends BaseMapper<CostTypeDomain> { ...@@ -25,4 +25,7 @@ public interface CostTypeDao extends BaseMapper<CostTypeDomain> {
//获取费用类型详情 //获取费用类型详情
CostTypeResult queryByNo(String typeNo); CostTypeResult queryByNo(String typeNo);
//根据费用类型名称和类型查询
CostTypeDomain selectByNameAndType(@Param("name") String name, @Param("type") Integer type);
} }
...@@ -6,21 +6,24 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; ...@@ -6,21 +6,24 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.blt.other.common.config.property.CostUrlProperties; import com.blt.other.common.config.property.CostUrlProperties;
import com.blt.other.common.config.property.ProjectConstant;
import com.blt.other.common.exception.BizRuntimeException;
import com.blt.other.common.util.CurUtils; import com.blt.other.common.util.CurUtils;
import com.blt.other.common.util.HttpUtil; import com.blt.other.common.util.HttpUtil;
import com.blt.other.common.util.PathUtil; import com.blt.other.common.util.PathUtil;
import com.blt.other.database.model.CostCompanyDomain;
import com.blt.other.database.model.CostLogDomain;
import com.blt.other.database.model.CostTypeDomain;
import com.blt.other.database.model.UserDomain;
import com.blt.other.module.auth.dao.UserDao; import com.blt.other.module.auth.dao.UserDao;
import com.blt.other.module.cost.dao.*; import com.blt.other.module.cost.dao.*;
import com.blt.other.module.cost.model.AccountingSubject;
import com.blt.other.module.cost.model.CostDetailDomain; import com.blt.other.module.cost.model.CostDetailDomain;
import com.blt.other.module.cost.model.CostDomain; import com.blt.other.module.cost.model.CostDomain;
import com.blt.other.module.cost.service.CostApiService; import com.blt.other.module.cost.service.CostApiService;
import com.blt.other.module.cost.service.UserCostFinansysService; import com.blt.other.module.cost.service.UserCostFinansysService;
import com.blt.other.module.cost.utils.CostFileUtil; import com.blt.other.module.cost.utils.CostFileUtil;
import com.blt.other.module.cost.utils.CostUtils; import com.blt.other.module.cost.utils.CostUtils;
import com.blt.other.database.model.CostCompanyDomain;
import com.blt.other.database.model.CostLogDomain;
import com.blt.other.database.model.CostTypeKindDomain;
import com.blt.other.database.model.UserDomain;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
...@@ -260,68 +263,74 @@ public class CostApiServiceImpl implements CostApiService { ...@@ -260,68 +263,74 @@ public class CostApiServiceImpl implements CostApiService {
.in(CostDomain::getCostNo, costNoList)); .in(CostDomain::getCostNo, costNoList));
} }
@Override @Override
public CostDomain getCostDetails(String costNo) { public CostDomain getCostDetails(String costNo) {
return costDao.selectByCostNo(costNo); return costDao.selectByCostNo(costNo);
} }
@Resource
CostTypeDao costTypeDao;
@Resource
AccountingSubjectMapper accountingSubjectMapper;
@Override @Override
public String pushWageCost(WageCostDto wageCostDto) throws IOException { public String pushWageCost(WageCostDto wageCostDto) throws IOException {
CostDomain costDomain = new CostDomain(); CostDomain costDomain = new CostDomain();
String costNo = CostUtils.getIdNum(); String costNo = CostUtils.getIdNum();
costDomain.setCostNo(costNo); costDomain.setCostNo(costNo);
// 付款费用单 1付款 2收款 3借支/借还 // 付款费用单 1付款 2收款 3借支/借还
costDomain.setCostForm(1); costDomain.setCostForm(CostDomain.COST_FROM_1);
// 0 待提交 1待审核 2待出纳付款 3被驳回 4已支付 5已作废 // 0 待提交 1待审核 2待出纳付款 3被驳回 4已支付 5已作废
costDomain.setCostStatus(7); costDomain.setCostStatus(CostDomain.STATUS_FINANCIAL_CHECK);
costDomain.setCostRemark(wageCostDto.getCostRemark());
costDomain.setCostReason(wageCostDto.getCostReason());
// CostTypeDomain costTypeDomain = costTypeDao.selectByCompanyNameAndTypeName(wageCostDto.getCompanyName(), "人工支出");
CostTypeKindDomain sqlParam = new CostTypeKindDomain();
// sqlParam.setTypeNo(costTypeDomain.getTypeNo());
sqlParam.setKindName("工资");
sqlParam.setCompanyName(wageCostDto.getCompanyName());
//类型信息
CostTypeDomain costTypeDomain = costTypeDao.selectByNameAndType("工资", CostTypeDomain.feeType);
AccountingSubject accountingSubject = accountingSubjectMapper.selectByNo(costTypeDomain.getAccountingSubjectNo());
costDomain.setTypeNo(costTypeDomain.getTypeName());
costDomain.setTypeName(costTypeDomain.getTypeName());
costDomain.setAccountingSubjectNo(accountingSubject.getSubjectNo());
costDomain.setAccountingSubjectName(accountingSubject.getName());
//公司
CostCompanyDomain costCompany = costCompanyDao.selectByName(wageCostDto.getCompanyName()); CostCompanyDomain costCompany = costCompanyDao.selectByName(wageCostDto.getCompanyName());
CostTypeKindDomain costTypeKindDomain = costTypeKindDao.selectByKindNameAndCompanyNo("工资", costCompany.getCompanyNo()); costDomain.setCompanyNo(costCompany.getCompanyNo());
costDomain.setTypeNo(costTypeKindDomain.getTypeNo()); //财务主体信息
costDomain.setTypeName(costTypeKindDomain.getTypeName()); costDomain.setCompanyName(wageCostDto.getCompanyName());
// costDomain.setSubjectCode(costTypeKindDomain.getSubjectCode());
costDomain.setCompanyNo(costTypeKindDomain.getCompanyNo());
costDomain.setCompanyName(wageCostDto.getCompanyName()); //dy
costDomain.setCompanyValue(wageCostDto.getCompanyValue()); costDomain.setCompanyValue(wageCostDto.getCompanyValue());
//银行卡四要素
costDomain.setBankCard(wageCostDto.getBankCard()); costDomain.setBankCard(wageCostDto.getBankCard());
costDomain.setBankCardUser(wageCostDto.getBankCardUser()); costDomain.setBankCardUser(wageCostDto.getBankCardUser());
costDomain.setBankCompany(wageCostDto.getBankCompany()); costDomain.setBankCompany(wageCostDto.getBankCompany());
costDomain.setBankName(wageCostDto.getBankName()); costDomain.setBankName(wageCostDto.getBankName());
//金额信息
// costDomain.setKindNo(costTypeKindDomain.getKindNo());
// costDomain.setKindName(costTypeKindDomain.getKindName());
costDomain.setAmount(wageCostDto.getAmount()); costDomain.setAmount(wageCostDto.getAmount());
costDomain.setDic(wageCostDto.getCurrency()); costDomain.setDic(wageCostDto.getCurrency());
//费用单来源
costDomain.setSourceFrom(wageCostDto.getSourceFrom()); costDomain.setSourceFrom(wageCostDto.getSourceFrom());
BigDecimal toRmbRate = null; costDomain.setCostRemark(wageCostDto.getCostRemark());
if ("CNY".equals(wageCostDto.getCurrency())) { costDomain.setCostReason(wageCostDto.getCostReason());
BigDecimal toRmbRate;
//todo simplify
if (ProjectConstant.CNY.equals(wageCostDto.getCurrency())) {
toRmbRate = BigDecimal.ONE; toRmbRate = BigDecimal.ONE;
costDomain.setAmountRmb(wageCostDto.getAmount()); costDomain.setAmountRmb(wageCostDto.getAmount());
} else { } else {
toRmbRate = CurUtils.getCur(wageCostDto.getCurrency(), "CNY"); toRmbRate = CurUtils.getCur(wageCostDto.getCurrency(), ProjectConstant.CNY);
costDomain.setAmountRmb(wageCostDto.getAmount().multiply(toRmbRate).setScale(2, BigDecimal.ROUND_HALF_UP)); costDomain.setAmountRmb(wageCostDto.getAmount().multiply(toRmbRate).setScale(2, BigDecimal.ROUND_HALF_UP));
} }
costDomain.setToRmbRate(toRmbRate); costDomain.setToRmbRate(toRmbRate);
UserDomain user = userDao.selectByuserid(wageCostDto.getUserId()); UserDomain user = userDao.selectByuserid(wageCostDto.getUserId());
if (user == null) { if (user == null) {
throw new RuntimeException("费用系统中没有该用户信息,请先登录一次费用系统再进行推送!"); throw new BizRuntimeException("费用系统中没有该用户信息,请先登录一次费用系统再进行推送!");
} else { } else {
costDomain.setCreateUserid(user.getUserid()); costDomain.setCreateUserid(user.getUserid());
costDomain.setCreateUsername(user.getUsername()); costDomain.setCreateUsername(user.getUsername());
......
...@@ -2,8 +2,8 @@ spring: ...@@ -2,8 +2,8 @@ spring:
# 数据源配置 # 数据源配置
datasource: datasource:
driver-class-name: com.mysql.jdbc.Driver driver-class-name: com.mysql.jdbc.Driver
url: jdbc:mysql://gz-cdb-lnrmt5zh.sql.tencentcdb.com:61369/bailun_other?useUnicode=true&characterEncoding=UTF-8&useSSL=false&rewriteBatchedStatements=true # url: jdbc:mysql://gz-cdb-lnrmt5zh.sql.tencentcdb.com:61369/bailun_other?useUnicode=true&characterEncoding=UTF-8&useSSL=false&rewriteBatchedStatements=true
# url: jdbc:mysql://10.0.8.2:3306/bailun_other?useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&rewriteBatchedStatements=true url: jdbc:mysql://10.0.8.2:3306/bailun_other?useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&rewriteBatchedStatements=true
username: root username: root
password: "#7kfnymAM$Y9-Ntf" password: "#7kfnymAM$Y9-Ntf"
hikari: hikari:
......
...@@ -65,4 +65,11 @@ ...@@ -65,4 +65,11 @@
where t1.type_no = #{typeNo} where t1.type_no = #{typeNo}
</select> </select>
<select id="selectByNameAndType" resultType="com.blt.other.database.model.CostTypeDomain">
select *
from cost_type
where cost_template_type = #{type}
and type_name = #{name}
</select>
</mapper> </mapper>
...@@ -42,6 +42,7 @@ import org.springframework.transaction.annotation.Transactional; ...@@ -42,6 +42,7 @@ import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.stream.Collectors; import java.util.stream.Collectors;
...@@ -227,6 +228,12 @@ public class OtherApplicationTests { ...@@ -227,6 +228,12 @@ public class OtherApplicationTests {
} }
private void syncData() { private void syncData() {
Map<Integer, Integer> map = new HashMap<>();
map.put(1, CostTypeDomain.feeType);
map.put(2, CostTypeDomain.incomeType);
map.put(3, CostTypeDomain.borrow);
list.forEach(item -> { list.forEach(item -> {
AccountingSubjectMapper accountingSubjectMapper = SpringContextUtil.getBean(AccountingSubjectMapper.class); AccountingSubjectMapper accountingSubjectMapper = SpringContextUtil.getBean(AccountingSubjectMapper.class);
AccountingSubject accountingSubject = accountingSubjectMapper.selectByName(item.getAccountType()); AccountingSubject accountingSubject = accountingSubjectMapper.selectByName(item.getAccountType());
...@@ -237,21 +244,24 @@ public class OtherApplicationTests { ...@@ -237,21 +244,24 @@ public class OtherApplicationTests {
accountingSubjectMapper.insert(accountingSubject); accountingSubjectMapper.insert(accountingSubject);
} }
CostTypeDao costTypeDao = SpringContextUtil.getBean(CostTypeDao.class); CostTypeDao costTypeDao = SpringContextUtil.getBean(CostTypeDao.class);
CostTypeDomain costTypeDomain = new CostTypeDomain();
if (item.getCostType() == 1) { CostTypeDomain costTypeDomain = costTypeDao.selectOne(new LambdaQueryWrapper<CostTypeDomain>()
costTypeDomain.setCostTemplateType(CostTypeDomain.feeType); .eq(CostTypeDomain::getTypeName, item.getType())
} .eq(CostTypeDomain::getCostTemplateType, map.get(item.getCostType()))
if (item.getCostType() == 2) { .eq(CostTypeDomain::getAccountingSubjectNo, accountingSubject.getSubjectNo()));
costTypeDomain.setCostTemplateType(CostTypeDomain.incomeType);
} if (costTypeDomain == null) {
if (item.getCostType() == 3) { costTypeDomain = new CostTypeDomain();
costTypeDomain.setCostTemplateType(CostTypeDomain.borrow);
} }
costTypeDomain.setCostTemplateType(map.get(item.getCostType()));
costTypeDomain.setTypeName(item.getType()); costTypeDomain.setTypeName(item.getType());
costTypeDomain.setTypeNo(IdWorker.getIdStr()); costTypeDomain.setTypeNo(IdWorker.getIdStr());
costTypeDomain.setDescription(item.getDesc()); costTypeDomain.setDescription(item.getDesc());
costTypeDomain.setAccountingSubjectNo(accountingSubject.getSubjectNo()); costTypeDomain.setAccountingSubjectNo(accountingSubject.getSubjectNo());
costTypeDao.insert(costTypeDomain);
boolean b = costTypeDao.updateById(costTypeDomain) > 0 || costTypeDao.insert(costTypeDomain) > 0;
}); });
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment