Commit 0f2a1acd authored by neo's avatar neo

[DEV] add project status manage impl

parent c9fbd928
package pwc.taxtech.atms;
import pwc.taxtech.atms.dto.user.UserDto;
import pwc.taxtech.atms.service.OperationLogService;
import java.util.HashMap;
import java.util.Map;
public class AppCachePool {
private static Map<String, UserDto> CACHED_USERS = null;
private static Object _locker = new Object();
static {
CACHED_USERS = new HashMap<>();
}
public static UserDto getCachedUser(String name) {
String userName = name.toLowerCase();
synchronized (_locker) {
if (!CACHED_USERS.containsKey(userName)) {
UserDto dto = new UserDto();//TODO:should fixed to load from db (neo)
dto.setUserName("cach_test");
dto.setID("1");
CACHED_USERS.put(userName,dto);
}
return CACHED_USERS.get(userName);
}
}
}
package pwc.taxtech.atms.controller;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
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.OperationResultDto;
import pwc.taxtech.atms.dto.VMRegionDevTreeData;
import pwc.taxtech.atms.dto.navtree.DevTreeDto;
import pwc.taxtech.atms.dto.taxadmin.ProjectStatusManageDto;
import pwc.taxtech.atms.service.IdentityService;
import pwc.taxtech.atms.service.ProjectStatusManageService;
import java.util.List;
@RestController
@RequestMapping("/api/v1/ProjectStatusManage")
public class ProjectStatusManageController {
@Autowired
private ProjectStatusManageService projectStatusManageService;
private IdentityService identityService;
@ApiOperation(value = "setProjectStatus", notes = "")
@RequestMapping(value = { "/setProjectStatus/{dbName}/{periodId}/{status}" }, method = RequestMethod.GET,
produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@ResponseBody
public OperationResultDto<ProjectStatusManageDto> setProjectStatus(String dbName, Integer periodId, Integer status) {
return projectStatusManageService.setProjectStatus(dbName,periodId,status,identityService.getIdentityUser().getID());
}
}
package pwc.taxtech.atms.dto.taxadmin;
public class ProjectImportSubStatusDto {
private Boolean isAdjustImport ;
private Boolean isCustomInvoiceImport ;
private Boolean isEntryImport ;
private Boolean isErpImport ;
private Boolean isInputInvoiceImport ;
private Boolean isInvoiceMapImport ;
private Boolean isOutputInvoiceImport ;
private Boolean isTbImport ;
private Boolean isVoucherMapImport ;
public Boolean getAdjustImport() {
return isAdjustImport;
}
public void setAdjustImport(Boolean adjustImport) {
isAdjustImport = adjustImport;
}
public Boolean getCustomInvoiceImport() {
return isCustomInvoiceImport;
}
public void setCustomInvoiceImport(Boolean customInvoiceImport) {
isCustomInvoiceImport = customInvoiceImport;
}
public Boolean getEntryImport() {
return isEntryImport;
}
public void setEntryImport(Boolean entryImport) {
isEntryImport = entryImport;
}
public Boolean getErpImport() {
return isErpImport;
}
public void setErpImport(Boolean erpImport) {
isErpImport = erpImport;
}
public Boolean getInputInvoiceImport() {
return isInputInvoiceImport;
}
public void setInputInvoiceImport(Boolean inputInvoiceImport) {
isInputInvoiceImport = inputInvoiceImport;
}
public Boolean getInvoiceMapImport() {
return isInvoiceMapImport;
}
public void setInvoiceMapImport(Boolean invoiceMapImport) {
isInvoiceMapImport = invoiceMapImport;
}
public Boolean getOutputInvoiceImport() {
return isOutputInvoiceImport;
}
public void setOutputInvoiceImport(Boolean outputInvoiceImport) {
isOutputInvoiceImport = outputInvoiceImport;
}
public Boolean getTbImport() {
return isTbImport;
}
public void setTbImport(Boolean tbImport) {
isTbImport = tbImport;
}
public Boolean getVoucherMapImport() {
return isVoucherMapImport;
}
public void setVoucherMapImport(Boolean voucherMapImport) {
isVoucherMapImport = voucherMapImport;
}
}
package pwc.taxtech.atms.dto.taxadmin;
import java.util.Date;
public class ProjectStatusManageDto {
private Date createTime ;
private String creatorID ;
private String dbName ;
private String ID ;
private ProjectImportSubStatusDto importSubStatus ;
private Integer periodId ;
public Date getCreateTime() {
return createTime;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
public String getCreatorID() {
return creatorID;
}
public void setCreatorID(String creatorID) {
this.creatorID = creatorID;
}
public String getDbName() {
return dbName;
}
public void setDbName(String dbName) {
this.dbName = dbName;
}
public String getID() {
return ID;
}
public void setID(String ID) {
this.ID = ID;
}
public ProjectImportSubStatusDto getImportSubStatus() {
return importSubStatus;
}
public void setImportSubStatus(ProjectImportSubStatusDto importSubStatus) {
this.importSubStatus = importSubStatus;
}
public Integer getPeriodId() {
return periodId;
}
public void setPeriodId(Integer periodId) {
this.periodId = periodId;
}
public Integer getStatus() {
return status;
}
public void setStatus(Integer status) {
this.status = status;
}
public Date getUpdateTime() {
return updateTime;
}
public void setUpdateTime(Date updateTime) {
this.updateTime = updateTime;
}
private Integer status ;
private Date updateTime ;
}
package pwc.taxtech.atms.service;
import pwc.taxtech.atms.dto.user.UserDto;
public interface IdentityService {
UserDto getIdentityUser();
}
package pwc.taxtech.atms.service;
import pwc.taxtech.atms.dto.OperationResultDto;
import pwc.taxtech.atms.dto.taxadmin.ProjectStatusManageDto;
public interface ProjectStatusManageService {
OperationResultDto<ProjectStatusManageDto> setProjectStatus(String dbName, Integer periodId, Integer status, String id);
}
package pwc.taxtech.atms.service.impl;
import org.springframework.stereotype.Service;
import pwc.taxtech.atms.AppCachePool;
import pwc.taxtech.atms.dto.user.UserDto;
import pwc.taxtech.atms.service.IdentityService;
@Service
public class IdentityServiceImpl implements IdentityService {
@Override
public UserDto getIdentityUser() {
return AppCachePool.getCachedUser("cach_test");//TODO:should fixed use session username
}
}
package pwc.taxtech.atms.service.impl;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import pwc.taxtech.atms.dao.ProjectStatusManageMapper;
import pwc.taxtech.atms.dto.FieldsMapper;
import pwc.taxtech.atms.dto.OperationResultDto;
import pwc.taxtech.atms.dto.taxadmin.ProjectStatusManageDto;
import pwc.taxtech.atms.entitiy.ProjectStatusManage;
import pwc.taxtech.atms.entitiy.ProjectStatusManageExample;
import pwc.taxtech.atms.service.ProjectStatusManageService;
import java.util.Date;
import java.util.List;
import java.util.UUID;
@Service
public class ProjectStatusManageServiceImpl implements ProjectStatusManageService {
private static final int FIRST_OR_DFAULT = 0;
private static Logger LOGGER = LoggerFactory.getLogger(ProjectStatusManageServiceImpl.class);
@Autowired
ProjectStatusManageMapper projectStatusManageMapper;
@Override
public OperationResultDto<ProjectStatusManageDto> setProjectStatus(String dbName, Integer periodId, Integer status, String creatorId) {
try {
ProjectStatusManageExample example = new ProjectStatusManageExample();
example.createCriteria().andDbNameEqualTo(dbName).andPeriodIdEqualTo(periodId);
List<ProjectStatusManage> psmList = projectStatusManageMapper.selectByExample(example);
ProjectStatusManage psm = null;
if (psmList != null && !psmList.isEmpty()) {
psm = psmList.get(FIRST_OR_DFAULT);
psm.setStatus(status);
psm.setUpdateTime(new Date());
projectStatusManageMapper.updateByPrimaryKey(psm);
} else {
psm = new ProjectStatusManage();
psm.setID(UUID.randomUUID().toString());
psm.setDbName(dbName);
psm.setPeriodId(periodId);
psm.setStatus(status);
psm.setCreatorID(creatorId);
psm.setCreateTime(new Date());
psm.setUpdateTime(new Date());
projectStatusManageMapper.insert(psm);
}
OperationResultDto<ProjectStatusManageDto> ord = new OperationResultDto<>();
ord.setResult(true);
ord.setResultMsg("");
ProjectStatusManageDto dto = new ProjectStatusManageDto();
try {
FieldsMapper.map(psm, dto);
} catch (Exception e) {
e.printStackTrace();
LOGGER.warn("cast filed some error", e);
}
ord.setData(dto);
return ord;
}catch (Exception e){
LOGGER.error("ProjectStatusManageService,SetProjectStatus(string dbName, int periodId)发生错误: {}",e.getMessage());
OperationResultDto<ProjectStatusManageDto> ord = new OperationResultDto<>();
ord.setResult(false);
ord.setResultMsg(e.getMessage());
ord.setData(null);
return ord;
}
}
}
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