|
@@ -3,7 +3,9 @@ package com.jpsoft.smart.modules.base.controller;
|
|
|
import com.github.pagehelper.Page;
|
|
|
import com.jpsoft.smart.modules.base.dto.CompanyInfoDTO;
|
|
|
import com.jpsoft.smart.modules.base.entity.CompanyPosition;
|
|
|
+import com.jpsoft.smart.modules.base.entity.PersonInfo;
|
|
|
import com.jpsoft.smart.modules.base.service.CompanyPositionService;
|
|
|
+import com.jpsoft.smart.modules.base.service.PersonInfoService;
|
|
|
import com.jpsoft.smart.modules.common.utils.PojoUtils;
|
|
|
import com.jpsoft.smart.modules.common.dto.Sort;
|
|
|
import com.jpsoft.smart.modules.common.dto.MessageResult;
|
|
@@ -22,6 +24,8 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
+import java.math.BigDecimal;
|
|
|
+import java.text.DecimalFormat;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.util.*;
|
|
|
|
|
@@ -33,11 +37,16 @@ public class CompanyInfoController {
|
|
|
|
|
|
@Autowired
|
|
|
private CompanyInfoService companyInfoService;
|
|
|
+
|
|
|
@Autowired
|
|
|
private UserService userService;
|
|
|
+
|
|
|
@Autowired
|
|
|
private CompanyPositionService companyPositionService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private PersonInfoService personInfoService;
|
|
|
+
|
|
|
@ApiOperation(value="创建空记录")
|
|
|
@GetMapping("create")
|
|
|
public MessageResult<CompanyInfoDTO> create(){
|
|
@@ -61,6 +70,18 @@ public class CompanyInfoController {
|
|
|
CompanyInfo companyInfo = new CompanyInfo();
|
|
|
PojoUtils.map(companyInfoDTO, companyInfo);
|
|
|
companyInfo.setId(UUID.randomUUID().toString());
|
|
|
+
|
|
|
+ DecimalFormat df = new DecimalFormat("000");
|
|
|
+
|
|
|
+ //上级单位code
|
|
|
+ if (StringUtils.isNotEmpty(companyInfo.getParentId())){
|
|
|
+ CompanyInfo parent = companyInfoService.get(companyInfo.getParentId());
|
|
|
+ companyInfo.setCode(parent.getCode() + "," + companyInfo.getId());
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ companyInfo.setCode(companyInfo.getId());
|
|
|
+ }
|
|
|
+
|
|
|
companyInfo.setDelFlag(false);
|
|
|
companyInfo.setCreateBy(subject);
|
|
|
companyInfo.setCreateTime(new Date());
|
|
@@ -153,6 +174,16 @@ public class CompanyInfoController {
|
|
|
int affectCount = 0;
|
|
|
CompanyInfo companyInfo = new CompanyInfo();
|
|
|
PojoUtils.map(companyInfoDTO, companyInfo);
|
|
|
+
|
|
|
+ //上级单位code
|
|
|
+ if (StringUtils.isNotEmpty(companyInfo.getParentId())){
|
|
|
+ CompanyInfo parent = companyInfoService.get(companyInfo.getParentId());
|
|
|
+ companyInfo.setCode(parent.getCode() + "," + companyInfo.getId());
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ companyInfo.setCode(companyInfo.getId());
|
|
|
+ }
|
|
|
+
|
|
|
companyInfo.setUpdateBy(subject);
|
|
|
companyInfo.setUpdateTime(new Date());
|
|
|
companyInfoService.update(companyInfo);
|
|
@@ -325,8 +356,12 @@ public class CompanyInfoController {
|
|
|
if (userService.hasRole(subject,"SYSADMIN")) {
|
|
|
list = companyInfoService.list();
|
|
|
}
|
|
|
- if(userService.hasRole(subject,"ADMIN")){
|
|
|
- list.add(companyInfoService.get(user.getCompanyId()));
|
|
|
+ else if(userService.hasRole(subject,"ADMIN")){
|
|
|
+ CompanyInfo companyInfo = companyInfoService.get(user.getCompanyId());
|
|
|
+
|
|
|
+ CompanyInfo parent = companyInfoService.get(companyInfo.getParentId());
|
|
|
+
|
|
|
+ list = companyInfoService.findByCompanyCode(parent.getCode() + "%");
|
|
|
}
|
|
|
|
|
|
msgResult.setResult(true);
|