Commit a33d964a authored by neo's avatar neo

[DEV] add getProjectImportType impl

parent cebaf261
......@@ -28,4 +28,6 @@ public final class Constant {
public static final String CURRENT_USER_UPLOAD_FOLDER=CURRENT_USER_HOME+File.separator+UPLOAD_FOLDER_NAME;
public static final boolean DEFAULT_RESULT=true;
public static final int FIRST_OR_DEFAULT=0;
}
\ No newline at end of file
package pwc.taxtech.atms.constant.enums;
public enum TbImportType {
UnImported (0),
TbImported (1),
ErpImported (2);
private Integer code;
TbImportType(Integer code) {
this.code = code;
}
public Integer getCode() {
return code;
}
}
......@@ -2,6 +2,7 @@ package pwc.taxtech.atms.controller;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
......@@ -47,4 +48,11 @@ public class ProjectInfoController {
queryImportType.getServiceTypeId()
, identityService.getIdentityUser().getID());
}
@ApiOperation(value = "getImportType", notes = "")
@RequestMapping(value = "getImportType/{projectID}/{periodID}/{serviceType}", method = RequestMethod.GET)
public ResponseEntity getImportType(@PathVariable String projectID, @PathVariable Integer periodID,
@PathVariable Integer serviceType) {
return ResponseEntity.ok().body(projectInfoService.getImportType(projectID,periodID,serviceType));
}
}
\ No newline at end of file
......@@ -11,4 +11,6 @@ public interface ProjectInfoService {
OperationResultDto<Boolean> isProjectImportedData(String projectId, Integer importTypeId);
OperationResultDto<List<PeriodInfoDto>> getProjectImportType(String projectId, List<Integer> periods, Integer serviceTypeId, String id);
Integer getImportType(String projectID, Integer periodID, Integer serviceType);
}
......@@ -4,6 +4,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import pwc.taxtech.atms.constant.enums.TbImportType;
import pwc.taxtech.atms.dao.PeriodInfoMapper;
import pwc.taxtech.atms.dto.OperationResultDto;
import pwc.taxtech.atms.dto.taxadmin.PeriodInfoDto;
......@@ -11,8 +12,11 @@ import pwc.taxtech.atms.entitiy.PeriodInfo;
import pwc.taxtech.atms.entitiy.PeriodInfoExample;
import pwc.taxtech.atms.service.ProjectInfoService;
import java.util.Date;
import java.util.List;
import static pwc.taxtech.atms.constant.Constant.FIRST_OR_DEFAULT;
@Service
public class ProjectInfoServiceImpl implements ProjectInfoService {
private static final Logger LOGGER = LoggerFactory.getLogger(ProjectServiceImpl.class);
......@@ -50,4 +54,28 @@ public class ProjectInfoServiceImpl implements ProjectInfoService {
public OperationResultDto<List<PeriodInfoDto>> getProjectImportType(String projectId, List<Integer> periods, Integer serviceTypeId, String id) {
return null;
}
@Override
public Integer getImportType(String projectID, Integer periodID, Integer serviceType) {
PeriodInfoExample example = new PeriodInfoExample();
example.createCriteria().andProjectIDEqualTo(projectID).andProjectIDEqualTo(projectID).andServiceTypeEqualTo(serviceType);
List<PeriodInfo> periodInfoList =periodInfoMapper.selectByExample(example);
if(periodInfoList==null || periodInfoList.size()==0){
PeriodInfo periodInfo = new PeriodInfo();
periodInfo.setProjectID(projectID);
periodInfo.setPeriod(periodID);
periodInfo.setStatus(0);
periodInfo.setImportType(TbImportType.UnImported.getCode());
periodInfo.setServiceType(serviceType);
periodInfo.setCreateTime(new Date());
periodInfo.setUpdateTime(new Date());
periodInfoMapper.insert(periodInfo);
return TbImportType.UnImported.getCode();
}else {
return periodInfoList.get(FIRST_OR_DEFAULT).getImportType();
}
}
}
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