Commit b4f3bdf6 authored by gary's avatar gary

1、fixbug

2、分析数据导入的导出
parent ed3867cb
......@@ -51,12 +51,19 @@ public class AnalysisController extends BaseController {
}
@RequestMapping(value = "downloadDomesticFile/get", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public void downloadCILQueryData(@RequestBody AnalysisDomesticlParam param, HttpServletResponse response) {
public void downloadDomesticFile(@RequestBody AnalysisDomesticlParam param, HttpServletResponse response) {
logger.debug("enter downloadDomesticFile");
String fileName="testFile";
analysisServiceImpl.downloadDomesticFile(response, param, fileName);
}
@RequestMapping(value = "downloadInternationalFile/get", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public void downloadInternationalFile(@RequestBody AnalysisInternationlParam param, HttpServletResponse response) {
logger.debug("enter downloadInternationalFile");
String fileName="testFile";
analysisServiceImpl.downloadInternationalFile(response, param, fileName);
}
@ResponseBody
@RequestMapping(value = "getAnalysisInternationalCompanyList", method = RequestMethod.GET)
......
......@@ -9,5 +9,7 @@ public class ErrorMessageCN {
public static final String DoNotSelectCompany = "非选定主体";
public static final String StrctureRepeat = "层级重复!";
public static final String BusinssUnitRepeat = "事业部重复!";
public static final String BusinssUnitUpdateFailed = "未对事业部名称或状态进行修改!";
public static final String OrgStructureFailed = "未对事业部名称或状态进行修改!";
}
package pwc.taxtech.atms.constant.enums;
public enum EnumAnalysisExpTempPath {
EachTaxAmount(0, "/analysis_excel_template/tax_data.xlsx"),
ActualReturnTax(1, "/analysis_excel_template/actual_tax_return.xlsx"),
GMVSubsidy(2, "/analysis_excel_template/gmv_subsidy.xlsx"),
EmployeeNum(3, "/analysis_excel_template/employ_num.xlsx"),
DriverNum(4, "/analysis_excel_template/driver_num.xlsx"),
BUData(100, "/analysis_excel_template/international_bu_data.xlsx"),
TaxData(101, "/analysis_excel_template/international_tax_data.xlsx"),
;
private Integer code;
private String path;
EnumAnalysisExpTempPath(Integer code, String path) {
this.code = code;
this.path = path;
}
public Integer getCode() {
return code;
}
public String getPath() {
return path;
}
public static EnumAnalysisExpTempPath fromCode(Integer code){
for(EnumAnalysisExpTempPath enu: EnumAnalysisExpTempPath.values()){
if(enu.getCode().intValue()==code.intValue())return enu;
}
return null;
}
public static String getPath(Integer code){
for(EnumAnalysisExpTempPath eaetp: EnumAnalysisExpTempPath.values()){
if(eaetp.getCode().intValue()==code.intValue())return eaetp.path;
}
return null;
}
}
......@@ -8,6 +8,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import pwc.taxtech.atms.dto.ApiResultDto;
import pwc.taxtech.atms.dto.BusinessUnitDto;
import pwc.taxtech.atms.dto.BusinessUnitInputDto;
import pwc.taxtech.atms.dto.IdModel;
......@@ -36,9 +37,9 @@ public class BusinessUnitController {
// @ApiOperation(value = "主数据事业部增加", notes = "根据Request Body的信息添加一个或多个新的事业部数据")
@RequestMapping(value = "/add", method = RequestMethod.POST)
public void addBusinessUnits(@RequestBody List<BusinessUnitInputDto> businessUnitDtoList) {
public ApiResultDto addBusinessUnits(@RequestBody List<BusinessUnitInputDto> businessUnitDtoList) {
logger.debug("BusinessUnitController addBusinessUnits");
businessUnitService.addBusinessUnits(businessUnitDtoList);
return businessUnitService.addBusinessUnits(businessUnitDtoList);
}
// @ApiOperation(value = "主数据事业部删除", notes = "根据给定的id删除一条事业部数据")
......@@ -52,7 +53,7 @@ public class BusinessUnitController {
// @ApiOperation(value = "主数据事业部修改", notes = "根据Request Body的信息修改一个或多个事业部数据")
@RequestMapping(method = RequestMethod.PUT)
public @ResponseBody
Boolean updateBusinessUnits(@RequestBody List<BusinessUnitDto> businessUnitDtoList) {
ApiResultDto updateBusinessUnits(@RequestBody List<BusinessUnitDto> businessUnitDtoList) {
logger.debug("BusinessUnitController updateBusinessUnit");
return businessUnitService.updateBusinessUnits(businessUnitDtoList);
}
......
......@@ -8,6 +8,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import pwc.taxtech.atms.dto.ApiResultDto;
import pwc.taxtech.atms.dto.IdModel;
import pwc.taxtech.atms.dto.OrganizationStructureDto;
import pwc.taxtech.atms.dto.OrganizationStructureInputDto;
......@@ -35,9 +36,9 @@ public class OrganizationStructureController {
// @ApiOperation(value = "主数据机构层级增加")
// @ApiImplicitParam(name = "organizationStructureDtoList", value = "organizationStructureDto List", required = true, dataType = "List<OrganizationStructureDto>")
@RequestMapping(value = "/add", method = RequestMethod.POST)
public void addOrganizationStructures(@RequestBody List<OrganizationStructureInputDto> organizationStructureDtoList) {
public ApiResultDto addOrganizationStructures(@RequestBody List<OrganizationStructureInputDto> organizationStructureDtoList) {
logger.debug("OrganizationStructureController /add");
organizationStructureService.addOrganizationStructures(organizationStructureDtoList);
return organizationStructureService.addOrganizationStructures(organizationStructureDtoList);
}
// @ApiOperation(value = "主数据机构层级删除")
......@@ -53,7 +54,7 @@ public class OrganizationStructureController {
// @ApiImplicitParam(name = "organizationStructureDtoList", value = "organizationStructureDto List", required = true, dataType = "List<OrganizationStructureDto>")
@RequestMapping(method = RequestMethod.PUT)
public @ResponseBody
Boolean updateOrganizationStructure(@RequestBody List<OrganizationStructureInputDto> organizationStructureDtoList) {
ApiResultDto updateOrganizationStructure(@RequestBody List<OrganizationStructureInputDto> organizationStructureDtoList) {
logger.debug("OrganizationStructureController update");
return organizationStructureService.updateOrganizationStructures(organizationStructureDtoList);
}
......
package pwc.taxtech.atms.dto.analysis;
import java.math.BigDecimal;
/**
* @Auther: Gary J Li
* @Date: 15/03/2019 00:30
* @Description:
*/
public class AnalysisDriverNumDto {
private String driverType;
private BigDecimal driverNum;
public String getDriverType() {
return driverType;
}
public void setDriverType(String driverType) {
this.driverType = driverType;
}
public BigDecimal getDriverNum() {
return driverNum;
}
public void setDriverNum(BigDecimal driverNum) {
this.driverNum = driverNum;
}
}
......@@ -7,8 +7,11 @@ import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
import pwc.taxtech.atms.analysis.dao.*;
import pwc.taxtech.atms.analysis.entity.*;
import pwc.taxtech.atms.common.message.ErrorMessage;
import pwc.taxtech.atms.common.message.ErrorMessageCN;
import pwc.taxtech.atms.common.util.DateUtils;
import pwc.taxtech.atms.constant.enums.EnumAnalysisExpTempPath;
import pwc.taxtech.atms.constant.enums.EnumAnalysisImportType;
import pwc.taxtech.atms.dto.OperationResultDto;
import pwc.taxtech.atms.dto.analysis.*;
import pwc.taxtech.atms.exception.ServiceException;
......@@ -16,6 +19,7 @@ import pwc.taxtech.atms.exception.ServiceException;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.io.InputStream;
import java.io.OutputStream;
import java.math.BigDecimal;
import java.text.DecimalFormat;
import java.text.NumberFormat;
......@@ -70,7 +74,7 @@ public class AnalysisServiceImpl extends BaseService {
Map<String, List<AnalysisTax>> actrs =
list.stream().collect(Collectors.groupingBy(AnalysisTax::getCompanyName));
actrs.forEach((k, v) -> processAts(k, v,dtos));
objects.add(dtos);
objects.addAll(dtos);
break;
case 1:
AnalysisActualTaxReturnExample analysisActualTaxReturnExample = new AnalysisActualTaxReturnExample();
......@@ -80,13 +84,13 @@ public class AnalysisServiceImpl extends BaseService {
Map<String, List<AnalysisActualTaxReturn>> actrs2 =
list2.stream().collect(Collectors.groupingBy(AnalysisActualTaxReturn::getCompanyName));
actrs2.forEach((k, v) -> processActrs(k, v,dtos2));
objects.add(dtos2);
objects.addAll(dtos2);
return objects;
case 2:
AnalysisGmvSubsidyExample analysisGmvSubsidyExample = new AnalysisGmvSubsidyExample();
analysisGmvSubsidyExample.createCriteria().andPeriodEqualTo(period);
List<AnalysisGMVSubsidyDto> dtos3 = generalDtos(analysisGmvSubsidyMapper.selectByExample(analysisGmvSubsidyExample));
objects.add(dtos3);
objects.addAll(dtos3);
break;
case 3:
AnalysisEmployeeNumExample analysisEmployeeNumExample = new AnalysisEmployeeNumExample();
......@@ -96,7 +100,8 @@ public class AnalysisServiceImpl extends BaseService {
case 4:
AnalysisDriverNumExample analysisDriverNumExample = new AnalysisDriverNumExample();
analysisDriverNumExample.createCriteria().andPeriodEqualTo(period);
objects.addAll(analysisDriverNumMapper.selectByExample(analysisDriverNumExample));
List<AnalysisDriverNumDto> dtos4 = processDns(analysisDriverNumMapper.selectByExample(analysisDriverNumExample));
objects.addAll(dtos4);
break;
default:
break;
......@@ -144,6 +149,29 @@ public class AnalysisServiceImpl extends BaseService {
dtos.add(dto);
}
private List<AnalysisDriverNumDto> processDns(List<AnalysisDriverNum> list) {
List<AnalysisDriverNumDto> dtos = Lists.newArrayList();
list.forEach(l->{
AnalysisDriverNumDto dto1 = new AnalysisDriverNumDto();
dto1.setDriverType("加盟");
dto1.setDriverNum(l.getJoinInAmount());
AnalysisDriverNumDto dto2 = new AnalysisDriverNumDto();
dto2.setDriverType("自营");
dto2.setDriverNum(l.getSelfSupportAmount());
AnalysisDriverNumDto dto3 = new AnalysisDriverNumDto();
dto3.setDriverType("直营");
dto3.setDriverNum(l.getDirectSaleAmount());
AnalysisDriverNumDto dto4 = new AnalysisDriverNumDto();
dto4.setDriverType("对公");
dto4.setDriverNum(l.getRightPublicAmount());
dtos.add(dto1);
dtos.add(dto2);
dtos.add(dto3);
dtos.add(dto4);
});
return dtos;
}
private BigDecimal getTaxAmountByGroup(List<AnalysisActualTaxReturn> v, String group) {
List<AnalysisActualTaxReturn> filterRes = v.stream().filter(o-> group.equals(o.getTaxReturnGroup())).collect(Collectors.toList());
BigDecimal res = filterRes.size()>0?filterRes.get(0).getTaxReturnAmount():BigDecimal.ZERO;
......@@ -553,7 +581,7 @@ public class AnalysisServiceImpl extends BaseService {
}
}
public Object displayAnalysisInternationalImportData(AnalysisInternationlParam param) {
public List<Object> displayAnalysisInternationalImportData(AnalysisInternationlParam param) {
List<Object> objects = new ArrayList<>();
Integer period = DateUtils.strToPeriod(param.getPeriod());
String country = param.getCountry();
......@@ -614,31 +642,45 @@ public class AnalysisServiceImpl extends BaseService {
return objects;
}
public void downloadDomesticFile(HttpServletResponse response, AnalysisDomesticlParam param, String fileName) {
/*String excelTemplatePathInClassPath = ExportTemplatePathConstant.CERTIFIED_INVOICES_LIST;
CertifiedInvoicesListCondition condition = beanUtil.copyProperties(param, new CertifiedInvoicesListCondition());
List<CertifiedInvoicesList> datas = certifiedInvoicesListMapper.selectByCondition(condition);
public HttpServletResponse downloadDomesticFile(HttpServletResponse response, AnalysisDomesticlParam param, String fileName) {
String excelTemplatePathInClassPath = EnumAnalysisExpTempPath.getPath(param.getType());
List<Object> datas = displayAnalysisImportData(param.getType(),param.getPeriod());
if(datas.size()<1){
throw new ServiceException(ErrorMessage.ExportFailed);
}
CertifiedInvoicesListHeader header = new CertifiedInvoicesListHeader();
Organization org = organizationMapper.selectByPrimaryKey(param.getOrgId());
header.setTaxPayerNumber(org.getTaxPayerNumber());
header.setPeriod(param.getPeriodStart());
header.setUnit(datas.get(0).getUnit());
List<CertifiedInvoicesListDto> dtoList = Lists.newArrayList();
datas.forEach(cil -> {
CertifiedInvoicesListDto dto = beanUtil.copyProperties(cil, new CertifiedInvoicesListDto());
dtoList.add(dto);
});
OutputStream outputStream = commonDocumentHelper.toXlsxFileUsingJxls(header,dtoList, excelTemplatePathInClassPath);
OutputStream outputStream = commonDocumentHelper.toXlsxFileUsingJxls(datas, excelTemplatePathInClassPath);
try {
return responseMessageBuilder.getDownloadTmpResponseMessage(response, outputStream, fileName);
} catch (Exception e) {
logger.error(String.format("导出已认证发票清单异常:%s",e.getMessage()));
logger.error(String.format("导出国内税数据异常:%s",e.getMessage()));
}
return null;*/
return null;
}
public HttpServletResponse downloadInternationalFile(HttpServletResponse response, AnalysisInternationlParam param, String fileName) {
String excelTemplatePathInClassPath = EnumAnalysisExpTempPath.getPath(param.getType());
List<Object> datas = Lists.newArrayList();
if(param.getType().equals(EnumAnalysisImportType.InternationalBuData.getCode())){
Integer period = DateUtils.strToPeriod(param.getPeriod());
String country = param.getCountry();
String companyName = param.getCompanyName();
AnalysisInternationalBusinessDataExample analysisInternationalBusinessDataExample = new AnalysisInternationalBusinessDataExample();
analysisInternationalBusinessDataExample.createCriteria().andPeriodEqualTo(period).andCompanyNameEqualTo(companyName).andCountryEqualTo(country);
List<AnalysisInternationalBusinessData> list = analysisInternationalBusinessDataMapper.selectByExample(analysisInternationalBusinessDataExample);
datas.addAll(list);
}else{
datas = displayAnalysisInternationalImportData(param);
}
if(datas.size()<1){
throw new ServiceException(ErrorMessage.ExportFailed);
}
OutputStream outputStream = commonDocumentHelper.toXlsxFileUsingJxls(datas, excelTemplatePathInClassPath);
try {
return responseMessageBuilder.getDownloadTmpResponseMessage(response, outputStream, fileName);
} catch (Exception e) {
logger.error(String.format("导出国际税数据异常:%s",e.getMessage()));
}
return null;
}
public List<String> getAnalysisInternationalCompanyList(Integer type, String periodStr) {
......@@ -673,8 +715,6 @@ public class AnalysisServiceImpl extends BaseService {
return countryList;
}
private String getCellStringValue(Cell cell) {
if (cell.getCellTypeEnum().equals(CellType.STRING)) {
return cell.getStringCellValue();
......
......@@ -23,9 +23,9 @@ public class BaseService {
@Autowired
protected BeanUtil beanUtil;
@Autowired
protected RestTemplate restTemplate;/*
protected RestTemplate restTemplate;
@Autowired
protected CommonDocumentHelper commonDocumentHelper;*/
protected CommonDocumentHelper commonDocumentHelper;
@Autowired
protected ResponseMessageBuilder responseMessageBuilder;
......
......@@ -14,15 +14,12 @@ import pwc.taxtech.atms.common.OperationAction;
import pwc.taxtech.atms.common.OperationModule;
import pwc.taxtech.atms.common.message.ErrorMessageCN;
import pwc.taxtech.atms.dao.BusinessUnitMapper;
import pwc.taxtech.atms.dto.BusinessUnitDto;
import pwc.taxtech.atms.dto.BusinessUnitInputDto;
import pwc.taxtech.atms.dto.IdModel;
import pwc.taxtech.atms.dto.OperationLogDto;
import pwc.taxtech.atms.dto.UpdateLogParams;
import pwc.taxtech.atms.dto.*;
import pwc.taxtech.atms.entity.BusinessUnit;
import pwc.taxtech.atms.entity.BusinessUnitExample;
import pwc.taxtech.atms.entity.BusinessUnitExample.Criteria;
import pwc.taxtech.atms.exception.ApplicationException;
import pwc.taxtech.atms.exception.ServiceException;
import java.util.ArrayList;
import java.util.Date;
......@@ -56,17 +53,25 @@ public class BusinessUnitServiceImpl {
}
@Transactional
public void addBusinessUnits(List<BusinessUnitInputDto> businessUnitDtoList) {
public ApiResultDto addBusinessUnits(List<BusinessUnitInputDto> businessUnitDtoList) {
logger.debug("BusinessUnitServiceImpl addBusinessUnits");
ApiResultDto res = ApiResultDto.success();
if (businessUnitDtoList.isEmpty()) {
throw new ApplicationException(CommonConstants.JSONNULLOBJECT);
}
for (BusinessUnitInputDto businessUnitDto : businessUnitDtoList) {
addBusinessUnit(businessUnitDto);
res = addBusinessUnit(businessUnitDto);
if(ApiResultDto.FAILED == res.getCode()) break;
}
return res;
}
public void addBusinessUnit(BusinessUnitInputDto businessUnitDto) {
public ApiResultDto addBusinessUnit(BusinessUnitInputDto businessUnitDto) {
BusinessUnitExample example = new BusinessUnitExample();
example.createCriteria().andNameEqualTo(businessUnitDto.getName());
if(businessUnitMapper.countByExample(example)>0){
return ApiResultDto.fail(ErrorMessageCN.BusinssUnitRepeat);
}
BusinessUnit businessUnit = rotateBusinessUnitDtoForInput(businessUnitDto);
businessUnit.setId(CommonUtils.getUUID());
businessUnit.setCreateTime(new Date());
......@@ -80,6 +85,7 @@ public class BusinessUnitServiceImpl {
operationLogDto.setAction(OperationAction.New.value());
operationLogDto.setLogType(OperateLogType.OperationLogBasicData.value());
operationLogService.addOperationLog(operationLogDto);
return ApiResultDto.success();
}
@Transactional
......@@ -109,11 +115,11 @@ public class BusinessUnitServiceImpl {
}
@Transactional
public Boolean updateBusinessUnits(List<BusinessUnitDto> businessUnitDtoList) {
public ApiResultDto updateBusinessUnits(List<BusinessUnitDto> businessUnitDtoList) {
logger.debug("BusinessUnitServiceImpl updateBusinessUnits");
if (businessUnitDtoList.isEmpty()) {
throw new ApplicationException(CommonConstants.JSONNULLOBJECT);
return ApiResultDto.fail(CommonConstants.JSONNULLOBJECT);
}
for (BusinessUnitDto businessUnitDto : businessUnitDtoList) {
......@@ -121,16 +127,17 @@ public class BusinessUnitServiceImpl {
boolean isStatusChangeOperation = false;
if (businessUnitDto == null || !StringUtils.hasText(businessUnitDto.getId())) {
throw new ApplicationException("primary key can't be null");
return ApiResultDto.fail("primary key can't be null");
}
// current businessUnit
BusinessUnit businessUnit = businessUnitMapper.selectByPrimaryKey(businessUnitDto.getId());
if (businessUnit == null) {
throw new ApplicationException("can't find business unit, id: " + businessUnitDto.getId());
return ApiResultDto.fail("can't find business unit, id: " + businessUnitDto.getId());
}
if(businessUnit.getName().equals(businessUnitDto.getName())){
throw new ApplicationException(ErrorMessageCN.BusinssUnitRepeat);
if(businessUnitDto.getIsActive().equals(businessUnit.getIsActive())&&
businessUnit.getName().equals(businessUnitDto.getName())){
return ApiResultDto.fail(ErrorMessageCN.BusinssUnitUpdateFailed);
}
// copy current businessUnit as tmp
......@@ -163,8 +170,7 @@ public class BusinessUnitServiceImpl {
operationLogService.updateDataAddLog(updateLogParams);
}
}
return true;
return ApiResultDto.success();
}
private List<BusinessUnitDto> rotateBusinessUnitList(List<BusinessUnit> businessUnitList) {
......
......@@ -14,11 +14,7 @@ import pwc.taxtech.atms.common.OperationAction;
import pwc.taxtech.atms.common.OperationModule;
import pwc.taxtech.atms.common.message.ErrorMessageCN;
import pwc.taxtech.atms.dao.OrganizationStructureMapper;
import pwc.taxtech.atms.dto.IdModel;
import pwc.taxtech.atms.dto.OperationLogDto;
import pwc.taxtech.atms.dto.OrganizationStructureDto;
import pwc.taxtech.atms.dto.OrganizationStructureInputDto;
import pwc.taxtech.atms.dto.UpdateLogParams;
import pwc.taxtech.atms.dto.*;
import pwc.taxtech.atms.entity.OrganizationStructure;
import pwc.taxtech.atms.entity.OrganizationStructureExample;
import pwc.taxtech.atms.exception.ApplicationException;
......@@ -53,24 +49,26 @@ public class OrganizationStructureServiceImpl {
return rotateOrganizationStructureList(organizationStructureList);
}
public void addOrganizationStructures(List<OrganizationStructureInputDto> organizationStructureDtoList) {
public ApiResultDto addOrganizationStructures(List<OrganizationStructureInputDto> organizationStructureDtoList) {
logger.debug("OrganizationStructureService addOrganizationStructure");
logger.debug("organization structure to add: {}", JSON.toJSONString(organizationStructureDtoList, true));
ApiResultDto res = ApiResultDto.success();
if (organizationStructureDtoList.isEmpty()) {
throw new ApplicationException(CommonConstants.JSONNULLOBJECT);
return ApiResultDto.fail(CommonConstants.JSONNULLOBJECT);
}
for (OrganizationStructureInputDto organizationStructureDto : organizationStructureDtoList) {
addOrganizationStructure(organizationStructureDto);
res = addOrganizationStructure(organizationStructureDto);
if(ApiResultDto.FAILED == res.getCode()) break;
}
return res;
}
public void addOrganizationStructure(OrganizationStructureInputDto organizationStructureDto) {
public ApiResultDto addOrganizationStructure(OrganizationStructureInputDto organizationStructureDto) {
OrganizationStructureExample example = new OrganizationStructureExample();
example.createCriteria().andNameEqualTo(organizationStructureDto.getName());
if(organizationStructureMapper.countByExample(example)>0){
throw new ApplicationException(ErrorMessageCN.StrctureRepeat);
return ApiResultDto.fail(ErrorMessageCN.StrctureRepeat);
}
OrganizationStructure organizationStructure = rotateOrganizationStructureDto(organizationStructureDto);
organizationStructure.setId(CommonUtils.getUUID());
......@@ -84,6 +82,7 @@ public class OrganizationStructureServiceImpl {
operationLogDto.setOperationObject(organizationStructureDto.getName());
operationLogDto.setAction(OperationAction.New.value());
operationLogService.addOperationLog(operationLogDto);
return ApiResultDto.success();
}
private void makeUpOperationLogDto(OperationLogDto operationLogDto) {
......@@ -115,12 +114,12 @@ public class OrganizationStructureServiceImpl {
return result;
}
public Boolean updateOrganizationStructures(List<OrganizationStructureInputDto> organizationStructureDtoList) {
public ApiResultDto updateOrganizationStructures(List<OrganizationStructureInputDto> organizationStructureDtoList) {
logger.debug("OrganizationStructureService updateOrganizationStructures");
logger.debug("organization structure to update: {}", JSON.toJSONString(organizationStructureDtoList, true));
if (organizationStructureDtoList.isEmpty()) {
throw new ApplicationException(CommonConstants.JSONNULLOBJECT);
return ApiResultDto.fail(CommonConstants.JSONNULLOBJECT);
}
for (OrganizationStructureInputDto organizationStructureDto : organizationStructureDtoList) {
......@@ -128,14 +127,18 @@ public class OrganizationStructureServiceImpl {
boolean isStatusChangeOperation = false;
if (organizationStructureDto == null || !StringUtils.hasText(organizationStructureDto.getId())) {
throw new ApplicationException("primary key can't be null");
return ApiResultDto.fail("primary key can't be null");
}
// current OrganizationStructure
OrganizationStructure organizationStructure = organizationStructureMapper
.selectByPrimaryKey(organizationStructureDto.getId());
if (organizationStructure == null) {
throw new ApplicationException("can't find organizationStructure, id: " + organizationStructureDto.getId());
return ApiResultDto.fail("can't find organizationStructure, id: " + organizationStructureDto.getId());
}
if(organizationStructureDto.getIsActive().equals(organizationStructure.getIsActive())&&
organizationStructure.getName().equals(organizationStructureDto.getName())){
return ApiResultDto.fail(ErrorMessageCN.OrgStructureFailed);
}
//copy current OrganizationStructure as tmp
......@@ -147,12 +150,13 @@ public class OrganizationStructureServiceImpl {
isStatusChangeOperation = true;
organizationStructure.setIsActive(organizationStructureDto.getIsActive());
organizationStructure.setName(organizationStructureDto.getName());
if (!organizationStructureDto.getIsActive()&&
// 参照atms取消层级若有机构不能停用的限制
/*if (!organizationStructureDto.getIsActive()&&
organizationService.isOrganizationStructureExists(organizationStructureDto.getId())) {
// continue;
// return false;
throw new ApplicationException("the organization must not contain sub-organization!");
}
}*/
}
organizationStructure.setUpdateTime(new Date());
organizationStructureMapper.updateByPrimaryKey(organizationStructure);
......@@ -172,7 +176,7 @@ public class OrganizationStructureServiceImpl {
}
}
return true;
return ApiResultDto.success();
}
......
......@@ -1912,5 +1912,6 @@
"Country": "Country",
"Company": "Company",
"CompanySimpleName": "Company Simple Name",
"DriverType": "Driver Type",
"~MustBeEndOneApp": "I Must be the End One, please!"
}
\ No newline at end of file
......@@ -2270,6 +2270,7 @@
"Company": "公司",
"CompanySimpleName": "公司简称",
"DriverType": "司机类型",
"~MustBeEndOneApp": "我必须是最后一个!"
}
......@@ -60,7 +60,7 @@
var businessUnitArray = [];
businessUnitArray.push($scope.editingObject);
var successedFun = function(rst) {
var successedFun = function() {
$scope.refreshData();
......@@ -71,14 +71,25 @@
} else {
SweetAlert.success($translate.instant("OrganizationStructureAddSuccess"));
}
}
};
if ($scope.isEdit) {
businessUnitService.updateBusinessUnit(businessUnitArray).success(successedFun);
businessUnitService.updateBusinessUnit(businessUnitArray).success(function (data) {
if (data.code===0) {
successedFun();
}else {
SweetAlert.error(data.message);
}
});
} else {
businessUnitService.addBusinessUnit(businessUnitArray).success(successedFun);
businessUnitService.addBusinessUnit(businessUnitArray).success(function (data) {
if (data.code===0) {
successedFun();
}else {
SweetAlert.error(data.message);
}
});
}
};
......@@ -208,7 +219,7 @@
function intiValidate() {
$.validator.addMethod("BURepeated", function(value, element, param) {
/*后台校验$.validator.addMethod("BURepeated", function(value, element, param) {
if ($scope.gridOptions.data && $scope.gridOptions.data.length > 0) {
var objects = $.grep($scope.gridOptions.data, function(n, i) {
return $scope.editingObject.ID != n.id && $.trim(n.name) == $.trim(value);
......@@ -219,7 +230,7 @@
return true;
});
});*/
formValidator = $(editModalSelector).find("#edit-form").validate({
debug: true,
......@@ -228,8 +239,8 @@
Name: {
required: true,
minlength: 2,
maxlength: 50,
BURepeated: true
maxlength: 50
// BURepeated: true
},
IsActive: {
required: "input[name='IsActive']:checked"
......@@ -239,8 +250,8 @@
Name: {
required: $translate.instant('BusinessUnitEmptyNode'),
minlength: $translate.instant('BusinessUnitEmptyNode'),
maxlength: $translate.instant('BusinessUnitOutOfLengthNode'),
BURepeated: $translate.instant('TaxData')
maxlength: $translate.instant('BusinessUnitOutOfLengthNode')
// BURepeated: $translate.instant('BusinessUnitDuplicateNode')
},
IsActive: $translate.instant('BusinessUnitStatusUnsureness')
},
......
......@@ -31,7 +31,7 @@
<label class="col-sm-3 control-label">{{'BusinessUnitName' | translate}}:</label>
<div class="col-sm-6">
<input class="form-control" name="Name" ng-model="editingObject.Name" maxlength="50">
<div class="validate-success" data-for="Name"></div>
<!--<div class="validate-success" data-for="Name"></div>-->
</div>
</div>
......
......@@ -65,7 +65,7 @@
var osArray = [];
osArray.push($scope.editingObject);
var successedFun = function(rst) {
var successedFun = function() {
$scope.refreshData();
$(editModalSelector).modal('hide');
......@@ -78,9 +78,21 @@
}
if ($scope.isEdit) {
organizationStructureService.updateOrganizationStructure(osArray).success(successedFun);
organizationStructureService.updateOrganizationStructure(osArray).success(function (data) {
if (data.code===0) {
successedFun();
}else {
SweetAlert.error(data.message);
}
});
} else {
organizationStructureService.addOrganizationStructure(osArray).success(successedFun);
organizationStructureService.addOrganizationStructure(osArray).success(function (data) {
if (data.code===0) {
successedFun();
}else {
SweetAlert.error(data.message);
}
});
}
};
......
analysisModule.controller('domesticDataImportController', ['$scope', '$log', '$translate', '$timeout', '$q', '$interval'
analysisModule.controller('domesticDataImportController', ['$scope','$filter', '$log', '$translate', '$timeout', '$q', '$interval'
, 'apiInterceptor', 'Upload', 'vatImportService', 'SweetAlert', 'uiGridConstants', '$uibModal'
, 'vatSessionService', 'enums', 'vatOperationLogService'
, 'projectService', 'vatCommonService','templateService','orgService',
function ($scope, $log, $translate, $timeout, $q, $interval
function ($scope,$filter, $log, $translate, $timeout, $q, $interval
, apiInterceptor, Upload, vatImportService, SweetAlert, uiGridConstants, $uibModal
, vatSessionService, enums, vatOperationLogService
, projectService, vatCommonService,templateService,orgService) {
......@@ -163,12 +163,15 @@
fileName = m.name + $scope.UploadPeriodTime+"_" +localDate;
}
});
vatImportService.downloadDomesticFile($scope.queryParams,fileName).then(function (data) {
var downloadParam = {
type: $scope.importType,
period: $scope.UploadPeriodTime
};
vatImportService.downloadDomesticFile(downloadParam,fileName).then(function (data) {
if (data) {
ackMessageBox.success(translate('FileExportSuccess'));
}
});
};
//导入事件
......@@ -380,7 +383,7 @@
var getImportTax = function () {
vatImportService.displayAnalysisImportData($scope.importType,$scope.UploadPeriodTime).success(function (data) {
if (data.data) {
$scope.taxGridSource = data.data[0];
$scope.taxGridSource = data.data;
}else {
SweetAlert.error($translate.instant('SystemError'));
}
......@@ -472,7 +475,7 @@
var getImportReturnTax = function () {
vatImportService.displayAnalysisImportData($scope.importType,$scope.UploadPeriodTime).success(function (data) {
if (data.data) {
$scope.returnTaxGridSource = data.data[0];
$scope.returnTaxGridSource = data.data;
}else {
SweetAlert.error($translate.instant('SystemError'));
}
......@@ -569,7 +572,7 @@
var getImportGMVSubsidy = function () {
vatImportService.displayAnalysisImportData($scope.importType,$scope.UploadPeriodTime).success(function (data) {
if (data.data) {
$scope.GMVSubsidyGridSource = data.data[0];
$scope.GMVSubsidyGridSource = data.data;
}else {
SweetAlert.error($translate.instant('SystemError'));
}
......@@ -680,25 +683,15 @@
allowHeaderFiltering: false,
caption: $translate.instant('id')
}, {
dataField: "joinInAmount",
width: '25%',
allowHeaderFiltering: false,
caption: $translate.instant('JoinInAmount')
}, {
dataField: "selfSupportAmount",
dataField: "driverType",
width: '50%',
allowHeaderFiltering: false,
caption: $translate.instant('SelfSupportAmount'),
width: '25%'
caption: $translate.instant('DriverType')
}, {
dataField: "directSaleAmount",
dataField: "driverNum",
allowHeaderFiltering: false,
width: '25%',
caption: $translate.instant('DirectSaleAmount')
}, {
dataField: "rightPublicAmount",
allowHeaderFiltering: false,
width: '25%',
caption: $translate.instant('RightPublicAmount')
caption: $translate.instant('DriverNum'),
width: '50%'
}],
onContentReady: function (e) {
$scope.driverNumInstance = e.component;
......
analysisModule.controller('internationalDataImportController', ['$scope', '$log', '$translate', '$timeout', '$q', '$interval'
analysisModule.controller('internationalDataImportController', ['$scope','$filter', '$log', '$translate', '$timeout', '$q', '$interval'
, 'apiInterceptor', 'Upload', 'vatImportService', 'SweetAlert', 'uiGridConstants', '$uibModal'
, 'vatSessionService', 'enums', 'vatOperationLogService'
, 'projectService', 'vatCommonService','templateService','orgService',
function ($scope, $log, $translate, $timeout, $q, $interval
function ($scope,$filter, $log, $translate, $timeout, $q, $interval
, apiInterceptor, Upload, vatImportService, SweetAlert, uiGridConstants, $uibModal
, vatSessionService, enums, vatOperationLogService
, projectService, vatCommonService,templateService,orgService) {
......@@ -167,7 +167,22 @@
};
var doExport = function () {
var localDate=$filter('date')(new Date(), 'yyyyMMddHHmmss');
var fileName = '';
constant.anlDownLoadFileNameList.forEach(function (m) {
if (m.code === $scope.importType) {
fileName = m.name + $scope.UploadPeriodTime+"_" +localDate;
}
});
param.companyName = $scope.selectCompany;
param.country = $scope.selectCountry;
param.type = $scope.importType;
param.period = $scope.UploadPeriodTime;
vatImportService.downloadInternationalFile(param,fileName).then(function (data) {
if (data) {
ackMessageBox.success(translate('FileExportSuccess'));
}
});
};
......
webservices.factory('vatImportService', ['$http', 'apiConfig', 'vatSessionService', function ($http, apiConfig, vatSessionService) {
webservices.factory('vatImportService', ['$http', 'apiConfig', 'vatSessionService','FileSaver', function ($http, apiConfig, vatSessionService,FileSaver) {
'use strict';
return {
sample: function () {
......@@ -425,6 +425,14 @@
var data = new Blob([response.data], {type: response.headers('Content-Type')});
FileSaver.saveAs(data, fileName + '.xlsx');
});
},
downloadInternationalFile: function (queryParm, fileName) {
var thisConfig = apiConfig.create();
thisConfig.responseType = "arraybuffer";
return $http.post('/Analysis/downloadInternationalFile/get', queryParm, thisConfig).then(function (response) {
var data = new Blob([response.data], {type: response.headers('Content-Type')});
FileSaver.saveAs(data, fileName + '.xlsx');
});
}
/***************************************批量数据导入服务(真) end**************************************************************/
......
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