Browse Source

党群服务中心删除

dev
zxc 4 years ago
parent
commit
bed41c106b
  1. 23
      epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/DelPartyServiceCenterResultDTO.java
  2. 2
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/IcPartyServiceCenterController.java
  3. 27
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/IcPartyServiceCenterDao.java
  4. 51
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/IcPartyServiceCenterServiceImpl.java
  5. 49
      epmet-module/gov-org/gov-org-server/src/main/resources/mapper/IcPartyServiceCenterDao.xml

23
epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/DelPartyServiceCenterResultDTO.java

@ -0,0 +1,23 @@
package com.epmet.dto.result;
import lombok.Data;
import java.io.Serializable;
/**
* @Author zxc
* @DateTime 2022/3/15 10:43 上午
* @DESC
*/
@Data
public class DelPartyServiceCenterResultDTO implements Serializable {
private static final long serialVersionUID = -2238226229442700788L;
private String date;
private String matterId;
private String timeId;
private String startTime;
private String endTime;
private String centerName;
}

2
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/IcPartyServiceCenterController.java

@ -84,7 +84,7 @@ public class IcPartyServiceCenterController {
return new Result();
}
@DeleteMapping
@PostMapping("del")
public Result delete(@RequestBody String[] ids){
//效验数据
AssertUtils.isArrayEmpty(ids, "id");

27
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/IcPartyServiceCenterDao.java

@ -19,12 +19,14 @@ package com.epmet.dao;
import com.epmet.commons.mybatis.dao.BaseDao;
import com.epmet.dto.result.AllMattersResultDTO;
import com.epmet.dto.result.DelPartyServiceCenterResultDTO;
import com.epmet.dto.result.PartyServiceCenterListResultDTO;
import com.epmet.entity.IcPartyServiceCenterEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Map;
/**
* 党群服务中心
@ -61,4 +63,29 @@ public interface IcPartyServiceCenterDao extends BaseDao<IcPartyServiceCenterEnt
List<AllMattersResultDTO> getAllMattersByOrgId(@Param("matterIds")List<String> matterIds);
/**
* Desc: 根据党群服务中心查询可预约事项ID
* @param centerIds
* @author zxc
* @date 2022/3/15 9:33 上午
*/
List<String> selectMatterByIds(@Param("centerIds")List<String> centerIds);
/**
* Desc: 根据事项ID查询预约记录
* @param matterIds
* @author zxc
* @date 2022/3/15 9:46 上午
*/
List<DelPartyServiceCenterResultDTO> selectAppointmentList(@Param("matterIds")List<String> matterIds);
/**
* Desc: 删除可预约事项
* @param centerIds
* @author zxc
* @date 2022/3/15 1:37 下午
*/
void delMatters(@Param("centerIds")List<String> centerIds);
}

51
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/IcPartyServiceCenterServiceImpl.java

@ -41,7 +41,6 @@ import com.epmet.constant.PartyServiceCenterConstant;
import com.epmet.dao.IcMatterAppointmentRecordDao;
import com.epmet.dao.IcPartyServiceCenterDao;
import com.epmet.dto.IcPartyServiceCenterDTO;
import com.epmet.dto.RegisterRelationDTO;
import com.epmet.dto.TimeDTO;
import com.epmet.dto.form.*;
import com.epmet.dto.result.*;
@ -63,6 +62,7 @@ import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicReference;
import java.util.stream.Collectors;
@ -130,8 +130,53 @@ public class IcPartyServiceCenterServiceImpl extends BaseServiceImpl<IcPartyServ
@Override
@Transactional(rollbackFor = Exception.class)
public void delete(String[] ids) {
// 逻辑删除(@TableLogic 注解)
baseDao.deleteBatchIds(Arrays.asList(ids));
List<String> centerIds = Arrays.asList(ids);
List<String> matterIds = baseDao.selectMatterByIds(centerIds);
if (CollectionUtils.isEmpty(matterIds)){
baseDao.deleteBatchIds(centerIds);
}else {
List<DelPartyServiceCenterResultDTO> appointmentList = baseDao.selectAppointmentList(matterIds);
if (CollectionUtils.isEmpty(appointmentList)){
baseDao.deleteBatchIds(centerIds);
baseDao.delMatters(centerIds);
}else {
List<String> names = new ArrayList<>();
Map<String, List<DelPartyServiceCenterResultDTO>> groupByMatterId = appointmentList.stream().collect(Collectors.groupingBy(DelPartyServiceCenterResultDTO::getMatterId));
groupByMatterId.forEach((k,v) -> {
if (getMatterAppointmentList(v)){
names.add(v.get(0).getCenterName());
}
});
if (CollectionUtils.isNotEmpty(names)){
throw new EpmetException(names.stream().collect(Collectors.joining("、")) + "存在未来时间的预约事项,不允许删除");
}
baseDao.deleteBatchIds(centerIds);
baseDao.delMatters(centerIds);
}
}
}
public boolean getMatterAppointmentList(List<DelPartyServiceCenterResultDTO> list){
AtomicBoolean result = new AtomicBoolean(false);
if (CollectionUtils.isNotEmpty(list)){
list.forEach(l -> {
int[] timeIds = Arrays.asList(l.getTimeId().split(",")).stream().mapToInt(m -> Integer.parseInt(m)).toArray();
List<String> intervalTimeList = getIntervalTimeList(l.getStartTime(), l.getEndTime(), 30);
for (int timeId : timeIds) {
for (int i1 = 0; i1 < intervalTimeList.size(); i1++) {
if (timeId == i1 + 1){
String date = l.getDate() + " " + intervalTimeList.get(i1) + ":00";
if (DateUtils.parse(date,DateUtils.DATE_TIME_PATTERN).after(new Date())){
result.set(true);
return;
}
}
}
}
});
}
return result.get();
}
/**

49
epmet-module/gov-org/gov-org-server/src/main/resources/mapper/IcPartyServiceCenterDao.xml

@ -118,4 +118,53 @@
</foreach>
)
</select>
<!-- 根据党群服务中心查询可预约事项ID -->
<select id="selectMatterByIds" resultType="java.lang.String">
SELECT
ID
FROM ic_party_service_center_matter
WHERE DEL_FLAG = 0
AND PARTY_SERVICE_CENTER_ID IN (
<foreach collection="centerIds" item="centerId" separator=",">
#{centerId}
</foreach>
)
</select>
<!-- 根据事项ID查询预约记录 -->
<select id="selectAppointmentList" resultType="com.epmet.dto.result.DelPartyServiceCenterResultDTO">
SELECT
r.APPOINTMENT_DATE AS date,
r.MATTER_ID AS matterId,
r.TIME_ID AS timeId,
m.START_TIME AS startTime,
m.END_TIME AS endTime,
c.CENTER_NAME
FROM ic_matter_appointment_record r
INNER JOIN ic_party_service_center_matter m ON (m.ID = r.MATTER_ID AND m.DEL_FLAG = 0)
INNER JOIN ic_party_service_center c ON (c.id = m.PARTY_SERVICE_CENTER_ID AND c.DEL_FLAG = 0)
WHERE r.DEL_FLAG = 0
AND r.`STATUS` = 'appointing'
AND STR_TO_DATE(r.APPOINTMENT_DATE,'%Y-%m-%d') >= DATE_FORMAT(NOW(),'%Y-%m-%d')
AND r.MATTER_ID IN (
<foreach collection="matterIds" item="matterId" separator=",">
#{matterId}
</foreach>
)
</select>
<!-- 删除可预约事项 -->
<update id="delMatters">
UPDATE ic_party_service_center_matter
SET del_flag = 1,
UPDATED_TIME = NOW()
WHERE DEL_FLAG = 0
AND PARTY_SERVICE_CENTER_ID IN (
<foreach collection="centerIds" item="centerId" separator=",">
#{centerId}
</foreach>
)
</update>
</mapper>
Loading…
Cancel
Save