Commit b0315d01 authored by frank.xa.zhang's avatar frank.xa.zhang

add apis for report name changed

parent 6062aa0a
......@@ -41,13 +41,13 @@ public class TemplateGroupController {
@RequestMapping(value = "updateTemplateGroupName", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public @ResponseBody
OperationResultDto<Object> updateTemplateGroupName(TemplateGroupDto templateGroupDto) {
OperationResultDto<Object> updateTemplateGroupName(@RequestBody TemplateGroupDto templateGroupDto) {
return templateGroupService.updateTemplateGroupName(templateGroupDto);
}
@RequestMapping(value = "deleteTemplateGroup", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public @ResponseBody
OperationResultDto<Object> DeleteTemplateGroup(TemplateGroupDto templateGroupDto) {
OperationResultDto<Object> DeleteTemplateGroup(@RequestBody TemplateGroupDto templateGroupDto) {
OperationResultDto<Object> result = templateGroupService.deleteTemplateGroup(templateGroupDto);
if (result.getResult()) {
List<String> pathList = (List<String>) result.getData();
......
......@@ -7,6 +7,7 @@ import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.session.RowBounds;
import pwc.taxtech.atms.MyMapper;
import pwc.taxtech.atms.dto.TemplateAndGroupDbDto;
import pwc.taxtech.atms.dto.TemplateUniqDto;
import pwc.taxtech.atms.entitiy.Template;
import pwc.taxtech.atms.entitiy.TemplateExample;
......@@ -118,4 +119,8 @@ public interface TemplateMapper extends MyMapper {
* @return TemplateUniqDto List
*/
List<TemplateUniqDto> getTemplateUniqDtosByTemplateAndTemplateGroup(Map<String,Object> map);
TemplateAndGroupDbDto getTemplateAndGroupByID(@Param("ID") String ID);
long getCountOfTemplateAndGroupByTemplateName(Map<String,Object> map);
}
\ No newline at end of file
package pwc.taxtech.atms.dto;
public class TemplateAndGroupDbDto {
private String templateID;
private String templateGroupID;
private String templateCode;
public String getTemplateID() {
return templateID;
}
public void setTemplateID(String templateID) {
this.templateID = templateID;
}
public String getTemplateGroupID() {
return templateGroupID;
}
public void setTemplateGroupID(String templateGroupID) {
this.templateGroupID = templateGroupID;
}
public String getTemplateCode() {
return templateCode;
}
public void setTemplateCode(String templateCode) {
this.templateCode = templateCode;
}
}
package pwc.taxtech.atms.dto;
public class UpateNameParam {
private String ID;
private String name;
public String getID() {
return ID;
}
public void setID(String ID) {
this.ID = ID;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
package pwc.taxtech.atms.service;
import pwc.taxtech.atms.dto.OperationResultDto;
import pwc.taxtech.atms.dto.TemplateDto;
import pwc.taxtech.atms.dto.TemplateUniqDto;
import pwc.taxtech.atms.dto.UpateNameParam;
import java.util.List;
......@@ -16,4 +18,6 @@ public interface TemplateService {
String getTemplatePath(String templateID);
List<TemplateUniqDto> getTemplateUniqList(String serviceTypeID, Integer payTaxType, Integer reportType, String industryIDs);
OperationResultDto<Object> updateTemplateName(UpateNameParam param);
}
......@@ -92,7 +92,7 @@ public class TemplateGroupServiceImpl extends AbstractService implements Templat
List<String> pathList = new ArrayList<>();
for (Template templateDb : templateDbList) {
boolean anySameCodeExists = allTemplateDbList.stream().anyMatch(a -> a.getCode().equals(templateDb.getCode()) && a.getID().equals(templateDb.getCode()));
boolean anySameCodeExists = allTemplateDbList.stream().anyMatch(a -> a.getCode()==templateDb.getCode() && a.getID()==templateDb.getCode());
if (!anySameCodeExists) {
pathList.add((templateDb.getPath()));
......
......@@ -3,9 +3,7 @@ package pwc.taxtech.atms.service.impl;
import org.springframework.stereotype.Service;
import pwc.taxtech.atms.common.CommonUtils;
import pwc.taxtech.atms.constant.Constant;
import pwc.taxtech.atms.dto.NameDto;
import pwc.taxtech.atms.dto.TemplateDto;
import pwc.taxtech.atms.dto.TemplateUniqDto;
import pwc.taxtech.atms.dto.*;
import pwc.taxtech.atms.entitiy.Template;
import pwc.taxtech.atms.entitiy.TemplateExample;
import pwc.taxtech.atms.service.TemplateService;
......@@ -114,4 +112,38 @@ public class TemplateServiceImpl extends AbstractService implements TemplateServ
}
return result;
}
@Override
public OperationResultDto<Object> updateTemplateName(UpateNameParam param) {
OperationResultDto<Object> result = new OperationResultDto<>();
TemplateAndGroupDbDto templateDb = templateMapper.getTemplateAndGroupByID(param.getID());
if (templateDb == null) {
result.setResult(false);
result.setResultMsg("TemplateNotExist");
return result;
}
Map<String, Object> map = new HashMap<>();
map.put("templateGroupID", templateDb.getTemplateGroupID());
map.put("templateID", param.getID());
map.put("templateName", param.getName());
long templateDbCount = templateMapper.getCountOfTemplateAndGroupByTemplateName(map);
if (templateDbCount > 0) {
result.setResult(false);
result.setData(templateDb.getTemplateCode() + "_" + param.getName());
result.setResultMsg("SameNameTemplateRepeat");
return result;
}
Template updateTemplate = templateMapper.selectByPrimaryKey(templateDb.getTemplateID());
updateTemplate.setName(param.getName());
updateTemplate.setUpdateTime(new Date());
templateMapper.updateByPrimaryKey(updateTemplate);
result.setResult(true);
return result;
}
}
......@@ -530,6 +530,18 @@
</select>
<delete id="deleteCellTemplateConfigByCellTemplate" parameterType="java.lang.String">
DELETE FROM CellTemplateConfig a WHERE a.ID in(SELECT b.ID FROM CellTemplateConfig b INNER JOIN CellTemplate c on b.CellTemplateID=c.ID WHERE c.ReportTemplateID=#{templateDbID,jdbcType=VARCHAR})
delete a.*
FROM
CellTemplateConfig a
WHERE
ID IN (select ID from(
SELECT
b.ID
FROM
CellTemplateConfig b
INNER JOIN CellTemplate c ON b.CellTemplateID = c.ID
WHERE
c.ReportTemplateID = #{templateDbID,jdbcType=VARCHAR}
) x)
</delete>
</mapper>
\ No newline at end of file
......@@ -319,6 +319,18 @@
</if>
</select>
<delete id="deleteKeyValueReferenceByCellTemplate" parameterType="java.lang.String">
DELETE FROM KeyValueReference a WHERE a.ID in(SELECT b.ID FROM KeyValueReference b INNER JOIN CellTemplate c on b.CellTemplateID=c.ID WHERE c.ReportTemplateID=#{templateDbID,jdbcType=VARCHAR})
delete a.*
FROM
KeyValueReference a
WHERE
ID IN (select ID from(
SELECT
b.ID
FROM
KeyValueReference b
INNER JOIN CellTemplate c ON b.CellTemplateID = c.ID
WHERE
c.ReportTemplateID = #{templateDbID,jdbcType=VARCHAR}
) x)
</delete>
</mapper>
\ No newline at end of file
......@@ -290,7 +290,7 @@
where m.OrganizationID = #{orgId}
order by m.ServiceTypeID
</select>
<select id="getOrgnizationServiceTemplateGroupOrgNames" parameterType="java.lang.String" resultMap="java.lang.String">
SELECT q.Name FROM OrganizationServiceTemplateGroup p LEFT JOIN Organization q on p.OrganizationID=q.ID WHERE p.TemplateGroupID=#{templateGroupDtoID,jdbcType:VARCHAR} AND q.IsActive=1
<select id="getOrgnizationServiceTemplateGroupOrgNames" parameterType="java.lang.String" resultType="java.lang.String">
SELECT q.Name FROM OrganizationServiceTemplateGroup p LEFT JOIN Organization q on p.OrganizationID=q.ID WHERE p.TemplateGroupID=#{templateGroupDtoID,jdbcType=VARCHAR} AND q.IsActive=1
</select>
</mapper>
\ No newline at end of file
......@@ -417,7 +417,7 @@
<select id="getTemplateUniqDtosByTemplateAndTemplateGroup" parameterType="map" resultMap="TemplateUniqDto" >
SELECT p.ID,p.Code,p.Name,p.ReportType,q.ID as TemplateGroupID,q.Name as TemplateGroupName,p.IsActiveAssociation FROM Template p join TemplateGroup q on p.templategroupID=q.ID
<if test="serviceTypeID">
<if test="serviceTypeID!=null">
WHERE q.ServiceTypeID=#{serviceTypeID,jdbcType=VARCHAR}
</if>
<if test="payTaxType!=null">
......@@ -426,9 +426,29 @@ SELECT p.ID,p.Code,p.Name,p.ReportType,q.ID as TemplateGroupID,q.Name as Templat
<if test="reportType!=null">
AND p.ReportType =#{reportType,jdbcType=INTEGER}
</if>
<if test="industryIDs">
<if test="industryIDs!=null">
AND q.IndustryIDs =#{industryID,jdbcType=VARCHAR}
</if>
ORDER BY p.TemplateGroupID, p.OrderIndex
</select>
<resultMap id="TemplateAndGroupDbDto" type="pwc.taxtech.atms.dto.TemplateAndGroupDbDto">
<id column="ID" jdbcType="VARCHAR" property="templateID"/>
<result column="templateGroupID" jdbcType="VARCHAR" property="templateGroupID"/>
<result column="templateCode" jdbcType="VARCHAR" property="templateCode"/>
</resultMap>
<select id="getTemplateAndGroupByID" parameterType="java.lang.String" resultMap="TemplateAndGroupDbDto">
SELECT p.ID as ID,q.ID as templateGroupID,p.Code as templateCode FROM Template p JOIN TemplateGroup q on p.TemplateGroupID=q.ID WHERE p.ID=#{ID,jdbcType=VARCHAR} LIMIT 1
</select>
<select id="getCountOfTemplateAndGroupByTemplateName" parameterType="map" resultType="java.lang.Long">
SELECT COUNT(1) FROM Template p join TemplateGroup q on p.TemplateGroupID=q.ID
<if test="templateGroupID!=null">
WHERE q.ID = #{templateGroupID,jdbcType=VARCHAR}
</if>
<if test="templateID!=null">
AND p.ID<>#{templateID,jdbcType=VARCHAR}
</if>
<if test="templateName!=null">
AND p.Name= #{templateName,jdbcType=VARCHAR}
</if>
</select>
</mapper>
\ No newline at end of file
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