Browse Source

人员资料增加姓名,编号限制

zhoudw 7 years ago
parent
commit
1f2f205a8f

+ 1 - 0
applications/commons/commons-dto/src/main/java/com/usoftchina/saas/commons/exception/BizExceptionCode.java

@@ -41,6 +41,7 @@ public enum BizExceptionCode implements BaseExceptionCode {
     REPEAT_CODE(79502, "编号重复"),
     REPEAT_CUSTOMERCODE(79503, "客户名称或编号重复"),
     REPEAT_TEL(79504, "电话号码重复"),
+    REPEAT_EMNAMECODE(79505, "姓名或编号重复"),
     NO_DATA(79998, "未找到数据"),
     ILLEGAL_ID(79999, "id不正确"),
     PRODUCT_HAS_WAREHOUSE(79502, "存在物料默认仓库资料为该仓库,无法删除"),

+ 12 - 0
applications/document/document-server/src/main/java/com/usoftchina/saas/document/controller/CustomerController.java

@@ -3,6 +3,7 @@ package com.usoftchina.saas.document.controller;
 import com.github.pagehelper.PageInfo;
 import com.usoftchina.saas.base.Result;
 import com.usoftchina.saas.commons.dto.BatchDealBaseDTO;
+import com.usoftchina.saas.commons.dto.ComboDTO;
 import com.usoftchina.saas.commons.dto.DocBaseDTO;
 import com.usoftchina.saas.commons.dto.ListReqDTO;
 import com.usoftchina.saas.document.dto.CustomerFormDTO;
@@ -12,6 +13,8 @@ import com.usoftchina.saas.page.PageRequest;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 
+import java.util.List;
+
 /**
  * Created by zdw
  * 2018-10-23 11:39.
@@ -101,6 +104,15 @@ public class CustomerController {
         return Result.success();
     }
 
+
+    @GetMapping("/getAddressCombo")
+    public Result getCombo(Long id){
+        List<ComboDTO> comboDTOList = customerService.getAddressCombo(id);
+        return Result.success(comboDTOList);
+    }
+
+
+
     /**
      * 客户资料批量删除
      *

+ 6 - 2
applications/document/document-server/src/main/java/com/usoftchina/saas/document/mapper/CustomerMapper.java

@@ -1,9 +1,11 @@
 package com.usoftchina.saas.document.mapper;
 
 import com.usoftchina.saas.base.mapper.CommonBaseMapper;
+import com.usoftchina.saas.commons.dto.ComboDTO;
 import com.usoftchina.saas.document.entities.Customer;
 import org.apache.ibatis.annotations.Param;
 
+import java.util.List;
 import java.util.Map;
 
 public interface CustomerMapper extends CommonBaseMapper<Customer> {
@@ -24,13 +26,15 @@ public interface CustomerMapper extends CommonBaseMapper<Customer> {
     Integer validateCodeWhenUpdate(@Param("code") String code, @Param("id") Long id,
                                    @Param("companyId") Long companyId);
 
-    int validNameAndCodeWhenInsert(Customer record);
+    int validNameAndCodeWhenInsert(@Param("cu_code") String cu_code,@Param("cu_name") String cu_name,@Param("companyId") Long companyId);
 
-    int validNameAndCodeWhenUpdate(Customer record);
+    int validNameAndCodeWhenUpdate(@Param("cu_code") String cu_code,@Param("cu_name") String cu_name,@Param("id") Long cu_id,@Param("companyId") Long companyId);
 
     int validFinish(@Param("id") Long id,@Param("companyId") Long companyId);
 
     void check(Map<String, Object> map);
 
     int validNameAndCodeWhenRelated(Customer customer);
+
+    List<ComboDTO> getCombo(@Param("id") Long id,@Param("companyId") Long companyId);
 }

+ 3 - 0
applications/document/document-server/src/main/java/com/usoftchina/saas/document/mapper/EmployeeMapper.java

@@ -29,4 +29,7 @@ public interface EmployeeMapper extends CommonBaseMapper<Employee> {
     Integer validatePhoneWhenUpdate(@Param("phone") String phone, @Param("id") Long id, @Param("companyId") Long company);
 
 
+    Integer validateNameAndCodeWhenInsert(@Param("code") String code,@Param("name") String em_name,@Param("companyId") Long companyId);
+
+    Integer validateNameAndCodeWhenUpdate(@Param("code") String code,@Param("name") String em_name,@Param("id") Long em_id,@Param("companyId") Long id);
 }

+ 3 - 0
applications/document/document-server/src/main/java/com/usoftchina/saas/document/service/CustomerService.java

@@ -3,6 +3,7 @@ package com.usoftchina.saas.document.service;
 import com.github.pagehelper.PageInfo;
 import com.usoftchina.saas.base.service.CommonBaseService;
 import com.usoftchina.saas.commons.dto.BatchDealBaseDTO;
+import com.usoftchina.saas.commons.dto.ComboDTO;
 import com.usoftchina.saas.commons.dto.DocBaseDTO;
 import com.usoftchina.saas.commons.dto.ListReqDTO;
 import com.usoftchina.saas.document.dto.CustomerFormDTO;
@@ -41,4 +42,6 @@ public interface CustomerService extends CommonBaseService<CustomerMapper, Custo
     void batchOpen(BatchDealBaseDTO baseDTOs);
 
     PageInfo<CustomerList> getDbfind(PageRequest page, ListReqDTO listReqDTO);
+
+    List<ComboDTO> getAddressCombo(Long id);
 }

+ 8 - 2
applications/document/document-server/src/main/java/com/usoftchina/saas/document/service/impl/CustomerServiceImpl.java

@@ -6,6 +6,7 @@ import com.usoftchina.saas.base.service.CommonBaseServiceImpl;
 import com.usoftchina.saas.commons.api.MaxnumberService;
 import com.usoftchina.saas.commons.api.MessageLogService;
 import com.usoftchina.saas.commons.dto.BatchDealBaseDTO;
+import com.usoftchina.saas.commons.dto.ComboDTO;
 import com.usoftchina.saas.commons.dto.DocBaseDTO;
 import com.usoftchina.saas.commons.dto.ListReqDTO;
 import com.usoftchina.saas.commons.exception.BizExceptionCode;
@@ -160,7 +161,7 @@ public class CustomerServiceImpl extends CommonBaseServiceImpl<CustomerMapper, C
         //新增
         if (StringUtils.isEmpty(cu_id) || "0".equals(cu_id.toString())) {
             //检查名称和编号
-            int count = getMapper().validNameAndCodeWhenInsert(customer);
+            int count = getMapper().validNameAndCodeWhenInsert(cu_code,customer.getCu_name(),companyId);
             if (count>0) {
                 throw new BizException(BizExceptionCode.REPEAT_CUSTOMERCODE);
             }
@@ -197,7 +198,7 @@ public class CustomerServiceImpl extends CommonBaseServiceImpl<CustomerMapper, C
             //更新
         }else {
             //检查名称和编号
-            int count = getMapper().validNameAndCodeWhenUpdate(customer);
+            int count = getMapper().validNameAndCodeWhenUpdate(cu_code,customer.getCu_name(),customer.getId(),companyId);
             if (count > 0) {
                 throw new BizException(BizExceptionCode.REPEAT_CUSTOMERCODE);
             }
@@ -479,6 +480,11 @@ public class CustomerServiceImpl extends CommonBaseServiceImpl<CustomerMapper, C
         return pageInfo;
     }
 
+    @Override
+    public List<ComboDTO> getAddressCombo(Long id) {
+        return getMapper().getCombo(id,BaseContextHolder.getCompanyId());
+    }
+
 
     private List<CustomerList> getListByMode(ListReqDTO req) {
         List<CustomerList> list = null;

+ 22 - 9
applications/document/document-server/src/main/java/com/usoftchina/saas/document/service/impl/EmployeeServiceImpl.java

@@ -65,29 +65,39 @@ public class EmployeeServiceImpl extends CommonBaseServiceImpl<EmployeeMapper, E
     @Override
     public DocBaseDTO saveFormData(Employee employee) {
         DocBaseDTO docBaseDTO = null;
+        String code = pushMaxnubmer(employee.getEm_code(), employee.getId());
         if(employee.getId() == 0){
-            String code = pushMaxnubmer(employee.getEm_code(), employee.getId());
-            employee.setCompanyId(BaseContextHolder.getCompanyId());
-            employee.setCreatorId(BaseContextHolder.getUserId());
-            employee.setCreateTime(new Date());
-            employee.setCreatorName(BaseContextHolder.getUserName());
+            //检查名称和编号
+            int count = getMapper().validateNameAndCodeWhenInsert(code,employee.getEm_name(),BaseContextHolder.getCompanyId());
+            if (count>0) {
+                throw new BizException(BizExceptionCode.REPEAT_EMNAMECODE);
+            }
             //检查电话号码
-            int count = getMapper().validatePhoneWhenInsert(employee.getEm_mobile(),BaseContextHolder.getCompanyId());
+            count = getMapper().validatePhoneWhenInsert(employee.getEm_mobile(),BaseContextHolder.getCompanyId());
             if (count>0) {
                 throw new BizException(BizExceptionCode.REPEAT_TEL);
             }
+            employee.setCompanyId(BaseContextHolder.getCompanyId());
+            employee.setCreatorId(BaseContextHolder.getUserId());
+            employee.setCreateTime(new Date());
+            employee.setCreatorName(BaseContextHolder.getUserName());
             getMapper().insertSelective(employee);
             docBaseDTO = generateMsgObj(employee.getId(), code);
             //记录LOG
             messageLogService.save(docBaseDTO);
         }else{
-            employee.setUpdaterId(BaseContextHolder.getUserId());
-            employee.setUpdateTime(new Date());
+            //检查名称和编号
+            int count = getMapper().validateNameAndCodeWhenUpdate(code,employee.getEm_name(),employee.getId(),BaseContextHolder.getCompanyId());
+            if (count>0) {
+                throw new BizException(BizExceptionCode.REPEAT_EMNAMECODE);
+            }
             //检查电话号码
-            int count = getMapper().validatePhoneWhenUpdate(employee.getEm_mobile(),employee.getId(),BaseContextHolder.getCompanyId());
+            count = getMapper().validatePhoneWhenUpdate(employee.getEm_mobile(),employee.getId(),BaseContextHolder.getCompanyId());
             if (count>0) {
                 throw new BizException(BizExceptionCode.REPEAT_TEL);
             }
+            employee.setUpdaterId(BaseContextHolder.getUserId());
+            employee.setUpdateTime(new Date());
             getMapper().updateByPrimaryKeySelective(employee);
             docBaseDTO = generateMsgObj(employee.getId(), employee.getEm_code());
             //记录LOG
@@ -199,6 +209,9 @@ public class EmployeeServiceImpl extends CommonBaseServiceImpl<EmployeeMapper, E
             Integer count = "0".equals(String.valueOf(id)) ? getMapper().validateCodeWhenInsert(code, companyId) :
                     getMapper().validateCodeWhenUpdate(code, id, companyId);
             em_code =  maxnumberService.pushMaxnubmer(count, code, BillCodeSeq.EMPLOYEE.getCaller()).getData();
+            if (em_code==null){
+                em_code = code;
+            }
         }
         return em_code;
     }

+ 5 - 0
applications/document/document-server/src/main/resources/mapper/CustomerMapper.xml

@@ -393,4 +393,9 @@
   </select>
 
 
+  <select id="getCombo" resultType="com.usoftchina.saas.commons.dto.ComboDTO">
+    SELECT ca_address display,ca_address value FROM customeraddress WHERE ca_cuid=#{id} and COMPANYID=#{companyId} order by ca_id desc
+  </select>
+
+
 </mapper>

+ 8 - 0
applications/document/document-server/src/main/resources/mapper/EmployeeMapper.xml

@@ -236,4 +236,12 @@
   </select>
 
 
+  <select id="validateNameAndCodeWhenInsert" resultType="int">
+    select count(*) from Employee where (em_code = #{code} or em_name = #{name}) and companyId =#{companyId}
+  </select>
+  <select id="validateNameAndCodeWhenUpdate" resultType="int" >
+    select count(*) from Employee where (em_code = #{code} or em_name = #{name}) and em_id !=#{id} and companyId =#{companyId}
+  </select>
+
+
 </mapper>