Commit a39eb5ec by huluobin

update

parent 8997cfc0
......@@ -82,7 +82,7 @@ public class CostReviewerController {
@RequestParam Integer oaDepartmentId,
@RequestParam String departmentReviewerUserIds) {
oaDepartmentService.modifyFinancialReviewer(userId, oaDepartmentId, Lists.newArrayList(departmentReviewerUserIds.split(","))
.stream().map(Integer::valueOf).collect(Collectors.toList())));
.stream().map(Integer::valueOf).collect(Collectors.toList()));
return CostResult.success();
}
......
......@@ -50,21 +50,6 @@ public interface CostTypeKindService {
CostTypeKindDomain getKindByKindNo(String kindNo);
/**
* 根据费用小类名称和公司名称获取种类信息
* @param kindName
* @param companyName
* @return
*/
CostTypeKindDomain getKindByKindNameAndCompanyName(String kindName, String companyName);
/**
* 获取指定费用类型小类列表
* @param companyNo
* @return
*/
List<CostTypeKindDto> getListByCompanyNoAndCostForm(String companyNo,Integer costForm);
/**
* Excel 导入费用小类
* @param file
*/
......
......@@ -45,11 +45,19 @@ public class CostTemplateServiceImpl extends ServiceImpl<CostTemplateMapper, Cos
@Override
public void edit(CostTemplate costTemplate) {
this.save(costTemplate);
List<CostTemplateCol> costTemplateColList = costTemplate.getCostTemplateColList();
costTemplateColList.forEach(costTemplateCol -> costTemplateCol.setCostTemplateId(costTemplate.getId()));
costTemplateColService.saveBatch(costTemplateColList);
}
@Override
public void delete(Integer id) {
this.removeById(id);
if (id != null) {
this.removeById(id);
costTemplateColService.remove(new LambdaQueryWrapper<CostTemplateCol>()
.eq(CostTemplateCol::getCostTemplateId, id));
}
}
}
package com.blt.other.cost.service.impl;
import com.bailuntec.cost.api.dto.CostTypeKindDto;
import com.blt.other.auth.dao.UserDao;
import com.blt.other.cost.dao.CostCompanyDao;
import com.blt.other.cost.dao.CostTypeDao;
import com.blt.other.cost.dao.CostTypeKindDao;
import com.blt.other.cost.dao.LogisticsSupplierBankDao;
import com.bailuntec.cost.api.dto.CostTypeKindDto;
import com.blt.other.cost.service.CostTypeKindService;
import com.blt.other.database.mapper.StatusMapper;
import com.blt.other.database.model.*;
......@@ -57,20 +57,21 @@ public class CostTypeKindServiceImpl implements CostTypeKindService {
/**
* 分页获取所有费用小类
*
* @param pageSize
* @param pageNum
* @return
*/
@Override
public Map<String, Object> getAllKindWithPage(Integer pageNum, Integer pageSize) {
Map<String,Object> result = new HashMap<>();
PageHelper.startPage(pageNum,pageSize);
Map<String, Object> result = new HashMap<>();
PageHelper.startPage(pageNum, pageSize);
List<CostTypeKindDomain> costTypeKindDomains = costTypeKindDao.selectAll();
PageInfo<CostTypeKindDomain> pageInfo = new PageInfo<>(costTypeKindDomains);
List<CostTypeKindDto> dtoList = getDtoList(costTypeKindDomains);
result.put("kinds",dtoList);
result.put("pageInfo",pageInfo);
result.put("kinds", dtoList);
result.put("pageInfo", pageInfo);
return result;
}
......@@ -90,13 +91,14 @@ public class CostTypeKindServiceImpl implements CostTypeKindService {
/**
* 保存费用种类记录
*
* @return
*/
@Override
public Integer saveNewKind(CostTypeKindDomain costTypeKindDomain) {
// 是否已经存在相同 typeNo 、kindName 的记录
CostTypeKindDomain costTypeDomain = costTypeKindDao.selectByTypeNoAndKindName(costTypeKindDomain);
if (null != costTypeDomain && null != costTypeDomain.getTypeNo()){
if (null != costTypeDomain && null != costTypeDomain.getTypeNo()) {
return null;
}
// 执行 doInsert()
......@@ -106,6 +108,7 @@ public class CostTypeKindServiceImpl implements CostTypeKindService {
/**
* 根据 kindNo 获取费用单详情
*
* @param kindNo
* @return
*/
......@@ -114,40 +117,17 @@ public class CostTypeKindServiceImpl implements CostTypeKindService {
return costTypeKindDao.selectByKindNo(kindNo);
}
/**
* 根据费用小类名称和公司名称获取种类信息
* @param kindName
* @param companyName
* @return
*/
@Override
public CostTypeKindDomain getKindByKindNameAndCompanyName(String kindName, String companyName) {
return costTypeKindDao.selectByKindNameAndCompanyName(kindName, companyName);
}
/**
* 获取指定费用类型小类列表
* @param companyNo
* @return
*/
@Override
public List<CostTypeKindDto> getListByCompanyNoAndCostForm(String companyNo,Integer costForm) {
CostTypeKindDomain costTypeKindDomain = new CostTypeKindDomain();
costTypeKindDomain.setCompanyNo(companyNo);
costTypeKindDomain.setCostForm(costForm);
List<CostTypeKindDomain> domains = costTypeKindDao.selectByCompanyNoAndCostForm(costTypeKindDomain);
return getDtoList(domains);
}
/**
* Excel 导入费用小类
* Excel 导入费用小类
*
* @param file
* @return
* @throws Exception
*/
@Transactional(readOnly = false,rollbackFor = Exception.class)
@Transactional(rollbackFor = Exception.class)
@Override
public Boolean importByExcel(MultipartFile file,String createUsercode) throws Exception{
public Boolean importByExcel(MultipartFile file, String createUsercode) throws Exception {
boolean notNull = false;
boolean isExcel2003 = true;
String fileName = file.getOriginalFilename();
......@@ -161,70 +141,70 @@ public class CostTypeKindServiceImpl implements CostTypeKindService {
} else {
wb = new XSSFWorkbook(is);
}
if (null != wb){
if (null != wb) {
List<CostTypeKindDomain> list = new ArrayList<>();
for (int s =0 ;s < wb.getNumberOfSheets();s++){
for (int s = 0; s < wb.getNumberOfSheets(); s++) {
Sheet sheet = wb.getSheetAt(s);
if(sheet!=null){
if (sheet != null) {
notNull = true;
CostTypeKindDomain costTypeKindDomain;
String typeName = "";
for (int r = 1; r <= sheet.getLastRowNum(); r++) {
Row row = sheet.getRow(r);
if (row == null){
if (row == null) {
continue;
}
if (null == row.getCell(0) || String.valueOf(row.getCell(0).getNumericCellValue()).isEmpty()){
if (null == row.getCell(0) || String.valueOf(row.getCell(0).getNumericCellValue()).isEmpty()) {
// 超出的多余行数,跳过
continue;
// System.out.print("序号1 ");
}else if (null == row.getCell(0) || row.getCell(0).getNumericCellValue() == 0){
} else if (null == row.getCell(0) || row.getCell(0).getNumericCellValue() == 0) {
// System.out.print("序号2 ");
// 超出的多余行数,跳过
continue;
}else {
} else {
}
costTypeKindDomain = new CostTypeKindDomain();
CostCompanyDomain companyDomain = null;
if (null == row.getCell(1) || row.getCell(1).getStringCellValue().isEmpty()) {
throw new RuntimeException("sheet"+(s+1)+" "+"第 "+(r)+ " 行公司主体不能为空");
}else {
throw new RuntimeException("sheet" + (s + 1) + " " + "第 " + (r) + " 行公司主体不能为空");
} else {
// 根据公司主体名称获取主体信息,不存在则抛出异常
String companyName = row.getCell(1).getStringCellValue();
companyDomain = costCompanyDao.selectByName(companyName);
if (null == companyDomain || null == companyDomain.getCompanyNo()){
throw new RuntimeException("sheet"+(s+1)+" "+"第 "+(r)+ " 行公司主体不存在或主体信息不全");
if (null == companyDomain || null == companyDomain.getCompanyNo()) {
throw new RuntimeException("sheet" + (s + 1) + " " + "第 " + (r) + " 行公司主体不存在或主体信息不全");
}
costTypeKindDomain.setCompanyNo(companyDomain.getCompanyNo());
costTypeKindDomain.setCompanyName(companyDomain.getCompanyName());
}
// 科目编码 第 2 列
if (null != row.getCell(2) ){
if (null != row.getCell(2)) {
row.getCell(2).setCellType(Cell.CELL_TYPE_STRING);
if (!row.getCell(2).getStringCellValue().isEmpty()) {
costTypeKindDomain.setSubjectCode(row.getCell(2).getStringCellValue());
}else {
throw new RuntimeException("sheet"+(s+1)+" "+"第 "+(r)+ " 科目编码不明确");
} else {
throw new RuntimeException("sheet" + (s + 1) + " " + "第 " + (r) + " 科目编码不明确");
}
}else {
throw new RuntimeException("sheet"+(s+1)+" "+"第 "+(r)+ " 科目编码不明确");
} else {
throw new RuntimeException("sheet" + (s + 1) + " " + "第 " + (r) + " 科目编码不明确");
}
// 大类 第 5 列
if ((null != row.getCell(5) && !row.getCell(5).getStringCellValue().isEmpty())){
if ((null != row.getCell(5) && !row.getCell(5).getStringCellValue().isEmpty())) {
typeName = row.getCell(5).getStringCellValue();
// 11111111(companyDomain.getCompanyName()+" "+typeName);
saveTypePIO(companyDomain,typeName,row,s,r);
saveTypePIO(companyDomain, typeName, row, s, r);
}
CostTypeDomain typeDomain = costTypeDao.selectByCompanyNameAndTypeName(companyDomain.getCompanyName(),typeName);
if (null == typeDomain){
CostTypeDomain typeDomain = costTypeDao.selectByCompanyNameAndTypeName(companyDomain.getCompanyName(), typeName);
if (null == typeDomain) {
typeDomain = saveTypePIO(companyDomain, typeName, row, s, r);
// throw new RuntimeException("sheet"+(s+1)+" "+"第 "+(r)+ " null");
}else {
typeDomain = setCostForm(typeDomain, row,s,r);
} else {
typeDomain = setCostForm(typeDomain, row, s, r);
}
costTypeKindDomain.setTypeNo(typeDomain.getTypeNo());
costTypeKindDomain.setTypeName(typeName);
......@@ -234,21 +214,21 @@ public class CostTypeKindServiceImpl implements CostTypeKindService {
// 小类 第 6 列
costTypeKindDomain.setKindName(row.getCell(6).getStringCellValue());
CostTypeKindDomain costTypeKind = costTypeKindDao.selectByTypeNoAndKindName(costTypeKindDomain);
if (null != costTypeKind && null != costTypeKind.getKindName()){
if (null != costTypeKind && null != costTypeKind.getKindName()) {
continue;
}
costTypeKindDomain.setKindNo(createKindNo());
costTypeKindDomain.setId(r);
costTypeKindDomain = setCreateUser(costTypeKindDomain,createUsercode);
costTypeKindDomain = setCreateUser(costTypeKindDomain, createUsercode);
list.add(costTypeKindDomain);
}
}
}
// 将导入的小类列表加入数据库
if(null != list && list.size() >= 1){
for (CostTypeKindDomain costTypeKindDomain : list){
if (null != list && list.size() >= 1) {
for (CostTypeKindDomain costTypeKindDomain : list) {
CostTypeKindDomain costTypeKindDomainGet = costTypeKindDao.selectByKindNo(costTypeKindDomain.getKindNo());
while (null != costTypeKindDomainGet){
while (null != costTypeKindDomainGet) {
costTypeKindDomain.setKindNo(createKindNo());
costTypeKindDomainGet = costTypeKindDao.selectByKindNo(costTypeKindDomain.getKindNo());
}
......@@ -260,7 +240,7 @@ public class CostTypeKindServiceImpl implements CostTypeKindService {
return notNull;
}
private CostTypeKindDomain setCreateUser(CostTypeKindDomain costTypeKindDomain,String createUsercode){
private CostTypeKindDomain setCreateUser(CostTypeKindDomain costTypeKindDomain, String createUsercode) {
UserDomain select = userDao.select(createUsercode);
costTypeKindDomain.setCreateUsercode(createUsercode);
costTypeKindDomain.setCreateUsername(select.getUsername());
......@@ -284,48 +264,48 @@ public class CostTypeKindServiceImpl implements CostTypeKindService {
return costTypeKindDao.delete(kindNo);
}
private CostTypeDomain saveTypePIO (CostCompanyDomain companyDomain,
String typeName,
Row row,
Integer s,
Integer r){
CostTypeDomain type = costTypeDao.selectByCompanyNameAndTypeName(companyDomain.getCompanyName(),typeName);
private CostTypeDomain saveTypePIO(CostCompanyDomain companyDomain,
String typeName,
Row row,
Integer s,
Integer r) {
CostTypeDomain type = costTypeDao.selectByCompanyNameAndTypeName(companyDomain.getCompanyName(), typeName);
CostTypeDomain typeDomain = new CostTypeDomain();
if (null == type || null == type.getTypeNo()){
if (null == type || null == type.getTypeNo()) {
typeDomain.setTypeNo(createTypeNo());
typeDomain.setTypeName(typeName);
typeDomain.setSubjectCode(row.getCell(2).getStringCellValue());
typeDomain.setCompanyName(companyDomain.getCompanyName());
typeDomain.setCompanyNo(companyDomain.getCompanyNo());
typeDomain = setCostForm(typeDomain, row,s,r);
typeDomain = setCostForm(typeDomain, row, s, r);
// TODO try 重复的 typeNo
Integer insert = costTypeDao.insert(typeDomain);
}
return typeDomain;
}
private CostTypeDomain setCostForm(CostTypeDomain typeDomain,Row row,Integer s,Integer r){
private CostTypeDomain setCostForm(CostTypeDomain typeDomain, Row row, Integer s, Integer r) {
// 费用类型 第 4 列
if (null != row.getCell(4) && !row.getCell(4).getStringCellValue().isEmpty()){
if (null != row.getCell(4) && !row.getCell(4).getStringCellValue().isEmpty()) {
String costFormStr = row.getCell(4).getStringCellValue();
if ("付款".equals(costFormStr)){
if ("付款".equals(costFormStr)) {
typeDomain.setCostForm(1);
}else if ("收款".equals(costFormStr)){
} else if ("收款".equals(costFormStr)) {
typeDomain.setCostForm(2);
}else {
} else {
typeDomain.setCostForm(3);
if ("借支".equals(costFormStr)){
if ("借支".equals(costFormStr)) {
typeDomain.setIsLend(1);
}else if ("借还".equals(costFormStr)){
} else if ("借还".equals(costFormStr)) {
typeDomain.setIsLend(2);
}else {
throw new RuntimeException("sheet"+(s+1)+" "+"第 "+(r)+ " 行费用类型不明确");
} else {
throw new RuntimeException("sheet" + (s + 1) + " " + "第 " + (r) + " 行费用类型不明确");
}
}
}else {
throw new RuntimeException("sheet"+(s+1)+" "+"第 "+(r)+ " 行费用类型不明确");
} else {
throw new RuntimeException("sheet" + (s + 1) + " " + "第 " + (r) + " 行费用类型不明确");
}
return typeDomain;
}
......@@ -333,10 +313,10 @@ public class CostTypeKindServiceImpl implements CostTypeKindService {
private String createTypeNo() {
SimpleDateFormat sdf = new SimpleDateFormat("yyMMddhhmmss");
Random random = new Random();
String typeNo = "CTN"+sdf.format(new Date())+random.nextInt(9);
String typeNo = "CTN" + sdf.format(new Date()) + random.nextInt(9);
CostTypeDomain costTypeDomain = costTypeDao.selectByTypeNo(typeNo);
while (null != costTypeDomain){
typeNo = "CTN"+sdf.format(new Date())+random.nextInt(9);
while (null != costTypeDomain) {
typeNo = "CTN" + sdf.format(new Date()) + random.nextInt(9);
costTypeDomain = costTypeDao.selectByTypeNo(typeNo);
}
return typeNo;
......@@ -345,7 +325,7 @@ public class CostTypeKindServiceImpl implements CostTypeKindService {
private Integer doInsert(CostTypeKindDomain costTypeKindDomain) {
// 获取 type 信息
CostTypeDomain costTypeDomain = costTypeDao.selectByTypeNo(costTypeKindDomain.getTypeNo());
BeanUtils.copyProperties(costTypeDomain,costTypeKindDomain);
BeanUtils.copyProperties(costTypeDomain, costTypeKindDomain);
// 补充剩余属性,执行 insert
costTypeKindDomain.setId(null);
costTypeKindDomain.setKindNo(createKindNo());
......@@ -354,37 +334,39 @@ public class CostTypeKindServiceImpl implements CostTypeKindService {
Integer result = costTypeKindDao.insert(costTypeKindDomain);
return result;
}
/**
* 生成唯一的费用种类编号
*
* @return
*/
private String createKindNo(){
private String createKindNo() {
SimpleDateFormat sdf = new SimpleDateFormat("yyMMddHHmmss");
Random random = new Random();
String costTypeKindNo = "CTK"+sdf.format(new Date())+random.nextInt(9);
String costTypeKindNo = "CTK" + sdf.format(new Date()) + random.nextInt(9);
CostTypeKindDomain costTypeKindDomain = costTypeKindDao.selectByKindNo(costTypeKindNo);
while (null != costTypeKindDomain && null != costTypeKindDomain.getKindName()){
costTypeKindNo = "CTK"+sdf.format(new Date())+random.nextInt(9);
while (null != costTypeKindDomain && null != costTypeKindDomain.getKindName()) {
costTypeKindNo = "CTK" + sdf.format(new Date()) + random.nextInt(9);
costTypeKindDomain = costTypeKindDao.selectByKindNo(costTypeKindNo);
}
return costTypeKindNo;
}
private List<CostTypeKindDto> getDtoList(List<CostTypeKindDomain> list){
private List<CostTypeKindDto> getDtoList(List<CostTypeKindDomain> list) {
List<CostTypeKindDto> costTypeKindDtoList = new ArrayList<>();
if (null != list && list.size() >= 1){
if (null != list && list.size() >= 1) {
CostTypeKindDto costTypeKindDto;
for (CostTypeKindDomain costTypeKindDomain : list){
for (CostTypeKindDomain costTypeKindDomain : list) {
costTypeKindDto = new CostTypeKindDto();
BeanUtils.copyProperties(costTypeKindDomain,costTypeKindDto);
costTypeKindDto.setCostTypeStatusDto(getCostTypeStatus("cost_type_status",costTypeKindDto.getCostTypeStatus()));
BeanUtils.copyProperties(costTypeKindDomain, costTypeKindDto);
costTypeKindDto.setCostTypeStatusDto(getCostTypeStatus("cost_type_status", costTypeKindDto.getCostTypeStatus()));
costTypeKindDtoList.add(costTypeKindDto);
}
}
return costTypeKindDtoList;
}
private String getCostTypeStatus(String statusname,Integer statuskey){
private String getCostTypeStatus(String statusname, Integer statuskey) {
String statusValue = statusMapper.getStatusValue(statusname, statuskey);
return statusValue;
}
......
......@@ -6,7 +6,7 @@
SELECT t1.*, t2.`name` company_name
from oa_department t1
LEFT JOIN oa_company t2 on t1.company_id = t2.oa_company_id
left join cost_reviewer t3 on t1.id = t3.refer_id and (t3.type = 1)
left join cost_reviewer t3 on t1.department_id = t3.refer_id and (t3.type = 1)
where t1.parent_id = 0
/*审核人*/
<if test="req.reviewerUserId !=null">
......
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