Commit 3ee146f0 authored by chase's avatar chase

fix add project bug

parent 3563a062
......@@ -177,23 +177,32 @@ public class ProjectServiceImpl {
try {
project.setId(UUID.randomUUID().toString());
OrganizationServiceTemplateGroupExample example = new OrganizationServiceTemplateGroupExample();
example.createCriteria().andOrganizationIdEqualTo(projectDto.getOrganizationId());
organizationServiceTemplateGroupMapper.selectByExample(example).forEach(ostg -> {
ProjectServiceType pst = new ProjectServiceType();
pst.setId(UUID.randomUUID().toString());
pst.setProjectId(project.getId());
pst.setServiceTypeId(ostg.getServiceTypeId());
pst.setTemplateGroupId(ostg.getTemplateGroupId());
projectServiceTypeMapper.insert(pst);
project.setUpdateTime(new Date());
int row = projectMapper.insertOnWhere(project);
if(row<=0){
ProjectExample projectExample = new ProjectExample();
projectExample.createCriteria().andIsActiveEqualTo(true).andOrganizationIdEqualTo(project.getOrganizationId()).andYearEqualTo(project.getYear());
List<Project> dataList = projectMapper.selectByExample(projectExample);
project = dataList.get(0);
}else{
final Project project1 = project;
OrganizationServiceTemplateGroupExample example = new OrganizationServiceTemplateGroupExample();
example.createCriteria().andOrganizationIdEqualTo(projectDto.getOrganizationId());
organizationServiceTemplateGroupMapper.selectByExample(example).forEach(ostg -> {
ProjectServiceType pst = new ProjectServiceType();
pst.setId(UUID.randomUUID().toString());
pst.setProjectId(project1.getId());
pst.setServiceTypeId(ostg.getServiceTypeId());
pst.setTemplateGroupId(ostg.getTemplateGroupId());
projectServiceTypeMapper.insert(pst);
// operationLogService.addDataAddLog(pst, OperationModule.ProjectServiceType, userName,//TODO add peration log
// Message.Project.AddProjectServiceType, pst.getId(), projectDto.getName(), LOG_TYPE);
});
});
}
project.setUpdateTime(new Date());
projectMapper.insert(project);
// operationLogService.addDataAddLog(project, OperationModule.Project, userName, Message.Project.AddProject,
// project.getId(), projectDto.getName(), LOG_TYPE);
......
package pwc.taxtech.atms.dao;
import java.util.List;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
......@@ -251,4 +250,6 @@ public interface ProjectMapper extends MyMapper {
List<ProjectAnaylsisDto> getTemlateWithServiceType2(@Param("orgId")String orgId, @Param("year") Integer year, @Param("month") Integer month,@Param("code")String code);
List<Project> queryChildOrgAndProjectByOrgId(@Param("year")Integer year ,@Param("orgId")String orgId);
int insertOnWhere(Project record);
}
\ No newline at end of file
......@@ -46,7 +46,34 @@
and o.parent_id = #{orgId,jdbcType=VARCHAR}
</select>
<insert id="insertOnWhere" parameterType="pwc.taxtech.atms.entity.Project">
insert into project (id, code, name,
year, client_code, is_active,
create_time, update_time, region_id,
industry_id, rule_type, organization_id,
db_name, enterprise_account_set_id, start_period,
end_period)
select #{id,jdbcType=VARCHAR}, #{code,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR},
#{year,jdbcType=INTEGER}, #{clientCode,jdbcType=VARCHAR}, #{isActive,jdbcType=BIT},
#{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP}, #{regionId,jdbcType=VARCHAR},
#{industryId,jdbcType=VARCHAR}, #{ruleType,jdbcType=INTEGER}, #{organizationId,jdbcType=VARCHAR},
#{dbName,jdbcType=VARCHAR}, #{enterpriseAccountSetId,jdbcType=VARCHAR}, #{startPeriod,jdbcType=INTEGER},
#{endPeriod,jdbcType=INTEGER}
FROM dual
where not exists(
select
*
from
project
where
organization_id = #{organizationId,jdbcType=VARCHAR}
and
year = #{year,jdbcType=INTEGER}
and
is_active = 1
)
</insert>
......
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