|
@@ -20,6 +20,8 @@ import lombok.extern.slf4j.Slf4j;
|
|
import org.apache.commons.lang3.BooleanUtils;
|
|
import org.apache.commons.lang3.BooleanUtils;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
+import org.springframework.transaction.annotation.Isolation;
|
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
import java.sql.Date;
|
|
import java.sql.Date;
|
|
@@ -323,7 +325,9 @@ public class CzrkServiceImpl implements ICzrkService {
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
|
+ @Transactional(rollbackFor = Exception.class, isolation = Isolation.READ_COMMITTED)
|
|
public AjaxResult addRlry(Czrk czrk) {
|
|
public AjaxResult addRlry(Czrk czrk) {
|
|
|
|
+ String username = SecurityUtils.getUsername();
|
|
if (isNotEmpty(czrk.getVillageTowns())) {
|
|
if (isNotEmpty(czrk.getVillageTowns())) {
|
|
czrk.setRlr(SecurityUtils.getUsername());
|
|
czrk.setRlr(SecurityUtils.getUsername());
|
|
czrk.setIsRl("是");
|
|
czrk.setIsRl("是");
|
|
@@ -338,12 +342,33 @@ public class CzrkServiceImpl implements ICzrkService {
|
|
return AjaxResult.error(String.format("该人员[身份证号为: %s]已存在,请勿重复添加", czrk.getIdCard()));
|
|
return AjaxResult.error(String.format("该人员[身份证号为: %s]已存在,请勿重复添加", czrk.getIdCard()));
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ czrk.setCreateBy(username);
|
|
|
|
+ czrk.setUpdateBy(username);
|
|
count = czrkMapper.insertCzrk(czrk);
|
|
count = czrkMapper.insertCzrk(czrk);
|
|
- return count > 0 ? AjaxResult.success() : AjaxResult.error();
|
|
|
|
|
|
+ if (count <= 0) {
|
|
|
|
+ return AjaxResult.error();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ List<CzrkJzdz> czrkJzdzList = czrk.getCzrkJzdzList();
|
|
|
|
+ if (isEmpty(czrkJzdzList)) {
|
|
|
|
+ return AjaxResult.error("该人员常住地址未添加");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ int sort = 0, childCount = 0;
|
|
|
|
+ for (CzrkJzdz czrkJzdz : czrkJzdzList) {
|
|
|
|
+ czrkJzdz.setCzrkId(czrk.getId());
|
|
|
|
+ czrkJzdz.setSort(++sort);
|
|
|
|
+ czrkJzdz.setCreateBy(SecurityUtils.getUsername());
|
|
|
|
+ czrkJzdz.setUpdateBy(SecurityUtils.getUsername());
|
|
|
|
+ childCount += czrkJzdzService.insertCzrkJzdz(czrkJzdz);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return childCount == czrkJzdzList.size() ? AjaxResult.success() : AjaxResult.error();
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- public int editRlry(Czrk czrk) {
|
|
|
|
|
|
+ public AjaxResult editRlry(Czrk czrk) {
|
|
|
|
+ String username = SecurityUtils.getUsername();
|
|
if (isNotEmpty(czrk.getVillageTowns())) {
|
|
if (isNotEmpty(czrk.getVillageTowns())) {
|
|
czrk.setRlr(SecurityUtils.getUsername());
|
|
czrk.setRlr(SecurityUtils.getUsername());
|
|
czrk.setIsRl("是");
|
|
czrk.setIsRl("是");
|
|
@@ -353,7 +378,28 @@ public class CzrkServiceImpl implements ICzrkService {
|
|
czrk.setRlTime(null);
|
|
czrk.setRlTime(null);
|
|
}
|
|
}
|
|
|
|
|
|
- return czrkMapper.updateCzrk(czrk);
|
|
|
|
|
|
+ czrk.setUpdateBy(username);
|
|
|
|
+ int count = czrkMapper.updateCzrk(czrk);
|
|
|
|
+ if (count <= 0) {
|
|
|
|
+ return AjaxResult.error();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ List<CzrkJzdz> czrkJzdzList = czrk.getCzrkJzdzList();
|
|
|
|
+ if (isEmpty(czrkJzdzList)) {
|
|
|
|
+ return AjaxResult.error("该人员常住地址未添加");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ czrkJzdzService.deleteByCzrkId(czrk.getId());
|
|
|
|
+ int sort = 0, childCount = 0;
|
|
|
|
+ for (CzrkJzdz czrkJzdz : czrkJzdzList) {
|
|
|
|
+ czrkJzdz.setCzrkId(czrk.getId());
|
|
|
|
+ czrkJzdz.setSort(++sort);
|
|
|
|
+ czrkJzdz.setCreateBy(username);
|
|
|
|
+ czrkJzdz.setUpdateBy(username);
|
|
|
|
+ childCount += czrkJzdzService.insertCzrkJzdz(czrkJzdz);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return childCount == czrkJzdzList.size() ? AjaxResult.success() : AjaxResult.error();
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|