Browse Source

新增人员资料根据账号获取的api接口

zhoudw 7 years ago
parent
commit
c9ba8e6ac7

+ 14 - 0
applications/document/document-api/src/main/java/com/usoftchina/saas/document/api/EmployeeApi.java

@@ -0,0 +1,14 @@
+package com.usoftchina.saas.document.api;
+
+import org.springframework.cloud.openfeign.FeignClient;
+import org.springframework.web.bind.annotation.GetMapping;
+
+import java.util.Map;
+
+@FeignClient(name = "document-server")
+public interface EmployeeApi {
+
+    @GetMapping("/employee/getEmployeeByAccount")
+    public Map<String,Object> getEmployeeByAccount();
+
+}

+ 8 - 0
applications/document/document-server/pom.xml

@@ -71,6 +71,14 @@
             <groupId>com.usoftchina.saas</groupId>
             <artifactId>commons-api</artifactId>
         </dependency>
+        <dependency>
+            <groupId>com.usoftchina.saas</groupId>
+            <artifactId>account-api</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>com.usoftchina.saas</groupId>
+            <artifactId>account-dto</artifactId>
+        </dependency>
     </dependencies>
 
     <build>

+ 7 - 0
applications/document/document-server/src/main/java/com/usoftchina/saas/document/controller/EmployeeController.java

@@ -90,4 +90,11 @@ public class EmployeeController {
         return Result.success();
     }
 
+    @GetMapping("/getEmployeeByAccount")
+    public Map<String,Object> getEmployeeByAccount(){
+        return employeeService.getEmployeeByAccount();
+    }
+
+
+
 }

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

@@ -14,6 +14,8 @@ public interface EmployeeMapper extends CommonBaseMapper<Employee> {
 
     Employee selectByPrimaryKey(Long em_id);
 
+    Employee selectByMobile(String mobile);
+
     int updateByPrimaryKeySelective(Employee record);
 
     List<EmployeeDTO> selectEmployeeListByCondition(@Param("con") String con,@Param("companyId") Long companyId);
@@ -21,4 +23,10 @@ public interface EmployeeMapper extends CommonBaseMapper<Employee> {
     Integer validateCodeWhenInsert(@Param("code") String code, @Param("companyId") Long companyId);
 
     Integer validateCodeWhenUpdate(@Param("code") String code, @Param("id") Long id, @Param("companyId") Long company);
+
+    Integer validatePhoneWhenInsert(@Param("phone") String phone, @Param("companyId") Long companyId);
+
+    Integer validatePhoneWhenUpdate(@Param("phone") String phone, @Param("id") Long id, @Param("companyId") Long company);
+
+
 }

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

@@ -10,6 +10,8 @@ import com.usoftchina.saas.document.entities.Employee;
 import com.usoftchina.saas.document.mapper.EmployeeMapper;
 import com.usoftchina.saas.page.PageRequest;
 
+import java.util.Map;
+
 /**
  * Created by zdw
  * 2018-10-23 15:26.
@@ -26,4 +28,5 @@ public interface EmployeeService extends CommonBaseService<EmployeeMapper, Emplo
 
     void batchDelete(BatchDealBaseDTO baseDTOs);
 
+    Map<String,Object> getEmployeeByAccount();
 }

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

@@ -2,6 +2,8 @@ package com.usoftchina.saas.document.service.impl;
 
 import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageInfo;
+import com.usoftchina.saas.account.api.AccountApi;
+import com.usoftchina.saas.account.dto.AccountDTO;
 import com.usoftchina.saas.base.service.CommonBaseServiceImpl;
 import com.usoftchina.saas.commons.api.MaxnumberService;
 import com.usoftchina.saas.commons.api.MessageLogService;
@@ -21,7 +23,9 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 import java.util.Date;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 
 /**
  * Created by zdw
@@ -34,6 +38,8 @@ public class EmployeeServiceImpl extends CommonBaseServiceImpl<EmployeeMapper, E
     private MessageLogService messageLogService;
     @Autowired
     private MaxnumberService maxnumberService;
+    @Autowired
+    private AccountApi accountApi;
 
 
     @Override
@@ -64,6 +70,11 @@ public class EmployeeServiceImpl extends CommonBaseServiceImpl<EmployeeMapper, E
             employee.setCompanyId(BaseContextHolder.getCompanyId());
             employee.setCreatorId(BaseContextHolder.getUserId());
             employee.setCreateTime(new Date());
+            //检查电话号码
+            int count = getMapper().validatePhoneWhenInsert(employee.getEm_mobile(),BaseContextHolder.getCompanyId());
+            if (count>0) {
+                throw new BizException(500, "电话号码重复");
+            }
             getMapper().insertSelective(employee);
             docBaseDTO = generateMsgObj(employee.getId(), code);
             //记录LOG
@@ -71,6 +82,11 @@ public class EmployeeServiceImpl extends CommonBaseServiceImpl<EmployeeMapper, E
         }else{
             employee.setUpdaterId(BaseContextHolder.getUserId());
             employee.setUpdateTime(new Date());
+            //检查电话号码
+            int count = getMapper().validatePhoneWhenUpdate(employee.getEm_mobile(),employee.getId(),BaseContextHolder.getCompanyId());
+            if (count>0) {
+                throw new BizException(500, "电话号码重复");
+            }
             getMapper().updateByPrimaryKeySelective(employee);
             docBaseDTO = generateMsgObj(employee.getId(), employee.getEm_code());
             //记录LOG
@@ -91,6 +107,21 @@ public class EmployeeServiceImpl extends CommonBaseServiceImpl<EmployeeMapper, E
         }
     }
 
+    @Override
+    public Map<String,Object> getEmployeeByAccount() {
+        Map<String,Object> map = new HashMap();
+        AccountDTO accountDTO = accountApi.getAccountById(BaseContextHolder.getUserId()).getData();
+        Employee employee = getMapper().selectByMobile(accountDTO.getMobile());
+        if (employee!=null){
+            map.put("em_id",employee.getId());
+            map.put("em_name",employee.getEm_name());
+        }else {
+            map.put("em_id",accountDTO.getId());
+            map.put("em_name",accountDTO.getRealname());
+        }
+        return map;
+    }
+
     private List<EmployeeDTO> getList(ListReqDTO listReqDTO){
         Long companyId = BaseContextHolder.getCompanyId();
         String condition = listReqDTO.getFinalCondition();

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

@@ -28,6 +28,16 @@
     from employee
     where em_id = #{em_id,jdbcType=INTEGER}
   </select>
+
+  <select id="selectByMobile" parameterType="string" resultMap="BaseResultMap">
+    select
+    <include refid="Base_Column_List" />
+    from employee
+    where em_mobile = #{mobile,jdbcType=INTEGER}
+  </select>
+
+
+
   <delete id="deleteByPrimaryKey" parameterType="long">
     delete from employee
     where em_id = #{em_id,jdbcType=INTEGER}
@@ -200,5 +210,12 @@
     select count(*) from Employee where em_code = #{code} and em_id != #{id} and companyId =#{companyId}
   </select>
 
+  <select id="validatePhoneWhenInsert" resultType="int">
+    select count(*) from Employee where em_mobile = #{phone} and companyId =#{companyId}
+  </select>
+  <select id="validatePhoneWhenUpdate" resultType="int" >
+    select count(*) from Employee where em_mobile = #{phone} and em_id != #{id} and companyId =#{companyId}
+  </select>
+
 
 </mapper>

+ 4 - 0
applications/purchase/purchase-server/pom.xml

@@ -81,6 +81,10 @@
             <groupId>com.usoftchina.saas</groupId>
             <artifactId>commons-api</artifactId>
         </dependency>
+        <dependency>
+            <groupId>com.usoftchina.saas</groupId>
+            <artifactId>document-api</artifactId>
+        </dependency>
     </dependencies>
 
     <build>

+ 8 - 1
applications/purchase/purchase-server/src/main/java/com/usoftchina/saas/purchase/service/impl/ProdInOutServiceImpl.java

@@ -13,6 +13,7 @@ import com.usoftchina.saas.commons.exception.BizExceptionCode;
 import com.usoftchina.saas.commons.po.BillCodeSeq;
 import com.usoftchina.saas.commons.po.Status;
 import com.usoftchina.saas.context.BaseContextHolder;
+import com.usoftchina.saas.document.api.EmployeeApi;
 import com.usoftchina.saas.document.api.WarehouseApi;
 import com.usoftchina.saas.exception.BizException;
 import com.usoftchina.saas.exception.ExceptionCode;
@@ -52,6 +53,8 @@ public class ProdInOutServiceImpl extends CommonBaseServiceImpl<ProdInOutMapper,
     private ProdInOutListMapper prodInOutListMapper;
     @Autowired
     private WarehouseApi warehouseApi;
+    @Autowired
+    private EmployeeApi employeeApi;
 
     @Autowired
     private MaxnumberService maxnumberService;
@@ -116,7 +119,9 @@ public class ProdInOutServiceImpl extends CommonBaseServiceImpl<ProdInOutMapper,
         //公司ID
         Long companyId = BaseContextHolder.getCompanyId();
         //人员Id
-        Long userId = BaseContextHolder.getUserId();
+        Map<String,Object>  emp= employeeApi.getEmployeeByAccount();
+        Long userId = Long.valueOf(String.valueOf(emp.get("em_id")));
+
         //获取主表信息
         ProdInOutDTO main = formdata.getMain();
         List<ProdIODetailDTO> items = formdata.getItems();
@@ -130,6 +135,8 @@ public class ProdInOutServiceImpl extends CommonBaseServiceImpl<ProdInOutMapper,
         String pi_class = main.getPi_class();
         ProdInOut prodInOut = BeanMapper.map(main,ProdInOut.class);
         prodInOut.setCompanyId(companyId);
+        prodInOut.setPi_recordmanid(userId.intValue());
+        prodInOut.setPi_recordman(emp.get("em_name").toString());
         prodInOut.setCreatorId(userId);
         prodInOut.setCreateTime(new Date());
         prodInOut.setPi_date(new Date());

+ 6 - 1
applications/purchase/purchase-server/src/main/java/com/usoftchina/saas/purchase/service/impl/PurchaseServiceImpl.java

@@ -13,6 +13,7 @@ import com.usoftchina.saas.commons.exception.BizExceptionCode;
 import com.usoftchina.saas.commons.po.BillCodeSeq;
 import com.usoftchina.saas.commons.po.Status;
 import com.usoftchina.saas.context.BaseContextHolder;
+import com.usoftchina.saas.document.api.EmployeeApi;
 import com.usoftchina.saas.document.api.ProductApi;
 import com.usoftchina.saas.exception.BizException;
 import com.usoftchina.saas.exception.ExceptionCode;
@@ -33,6 +34,7 @@ import org.springframework.util.StringUtils;
 import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
+import java.util.Map;
 
 
 /**
@@ -51,6 +53,8 @@ public class PurchaseServiceImpl extends CommonBaseServiceImpl<PurchaseMapper, P
     @Autowired
     private ProductApi productApi;
     @Autowired
+    private EmployeeApi employeeApi;
+    @Autowired
     private MaxnumberService maxnumberService;
     @Autowired
     private ProdInOutMapper prodInOutMapper;
@@ -106,7 +110,8 @@ public class PurchaseServiceImpl extends CommonBaseServiceImpl<PurchaseMapper, P
         //公司ID
         Long companyId = BaseContextHolder.getCompanyId();
         //人员Id
-        Long userId = BaseContextHolder.getUserId();
+        Map<String,Object>  emp= employeeApi.getEmployeeByAccount();
+        Long userId = (Long)emp.get("em_id");
         //获取主表信息
         PurchaseDTO main = formdata.getMain();
         List<PurchaseDetailDTO> items = formdata.getItems();

+ 1 - 0
frontend/saas-web/app/view/document/employee/FormPanel.js

@@ -46,6 +46,7 @@ Ext.define('saas.view.document.employee.FormPanel', {
         queryMode: 'local',
         displayField: 'name',
         valueField: 'value',
+        allowBlank:false,
         editable:false,
         store: Ext.create('Ext.data.ArrayStore', {
             fields: ['name', 'value'],