package com.steerinfo.dil.service.impl; import com.steerinfo.dil.mapper.RmsPersonnelMapper; import com.steerinfo.dil.mapper.RmsShipperMapper; import com.steerinfo.dil.model.RmsPersonnel; import com.steerinfo.dil.model.RmsShipper; import com.steerinfo.dil.service.IRmsPersonnelService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.math.BigDecimal; import java.util.Date; import java.util.HashMap; import java.util.List; import java.util.Map; /** * RmsPersonnel服务实现: * @author generator * @version 1.0-SNAPSHORT 2021-10-22 06:01 * 类描述 * 修订历史: * 日期:2021-10-22 * 作者:HuJieHuan * 参考: * 描述:RmsPersonnel服务实现 * @see null * @Copyright 湖南视拓信息技术股份有限公司. All rights reserved. */ @Service(value = "rmsPersonnelService") public class RmsPersonnelServiceImpl implements IRmsPersonnelService { @Autowired private RmsPersonnelMapper rmsPersonnelMapper; @Autowired RmsShipperMapper rmsShipperMapper; /** * 操作人员信息 * @param mapVal * @return */ @Override public int operationPersonnel(Map mapVal) { // 得到金蝶人员管理主键id Integer EASPersonnelIdValue = (Integer) mapVal.get("EASPersonnelId"); BigDecimal EASPersonnelId = new BigDecimal(EASPersonnelIdValue); // 得到人员工号 String personnelJobNumber = (String) mapVal.get("personnelJobNumber"); // 得到人员姓名 String personnelName = (String) mapVal.get("personnelName"); // 得到数据状态 Integer dataStatus = (Integer) mapVal.get("dataStatus"); RmsPersonnel rmsPersonnel = new RmsPersonnel(); // rmsPersonnel.setEasPersonnelId(EASPersonnelId); rmsPersonnel.setPersonnelJobNumber(personnelJobNumber); rmsPersonnel.setPersonnelName(personnelName); BigDecimal deleted = new BigDecimal(0); Map map = new HashMap<>(); map.put("easPersonnelId",EASPersonnelId); map.put("deleted",deleted); int result = 0; List rmsPersonnels = rmsPersonnelMapper.selectByParameters(map); // 新增 if (rmsPersonnels.size() == 0) { BigDecimal personnelId = rmsPersonnelMapper.getPersonnelId(); rmsPersonnel.setPersonnelId(personnelId); rmsPersonnel.setDeleted(deleted); result = rmsPersonnelMapper.insertSelective(rmsPersonnel); } // 修改 if (rmsPersonnels.size() != 0 && dataStatus == 2) { RmsPersonnel rmsPersonnel1 = rmsPersonnels.get(0); rmsPersonnel.setPersonnelId(rmsPersonnel1.getPersonnelId()); result = rmsPersonnelMapper.updateByPrimaryKeySelective(rmsPersonnel); } // 逻辑删除 if (rmsPersonnels.size() != 0 && dataStatus == 3) { RmsPersonnel rmsPersonnel1 = rmsPersonnels.get(0); rmsPersonnel.setPersonnelId(rmsPersonnel1.getPersonnelId()); rmsPersonnel.setDeleted(new BigDecimal(1)); result = rmsPersonnelMapper.updateByPrimaryKeySelective(rmsPersonnel); } return result; } /** * 展示人员信息列表 * @param mapVal * @return */ @Override public List> getPersonnelList(Map mapVal) { return rmsPersonnelMapper.getPersonnelList(mapVal); } /** * 添加人员信息 * @param rmsPersonnel * @return */ @Override public int insertPersonnel(RmsPersonnel rmsPersonnel) { // 获取到用户名以及使用默认密码 String username=rmsPersonnel.getUsername(); String password="123456"; int i=0; String personnelJobNumber=rmsPersonnel.getPersonnelJobNumber(); Map map=new HashMap<>(); map.put("personnelJobNumber",personnelJobNumber); List rmsPersonnels=rmsPersonnelMapper.selectByParameters(map); if (rmsPersonnels.size()!=0){ RmsPersonnel rmsPersonnel1=rmsPersonnels.get(0); if (rmsPersonnel1.getDeleted().equals(new BigDecimal(1))){ rmsPersonnel.setInsertUsername("admin"); rmsPersonnel.setDeleted(new BigDecimal(0)); rmsPersonnel.setPersonnelId(rmsPersonnelMapper.getPersonnelId()); i+= rmsPersonnelMapper.insertSelective(rmsPersonnel); } else{ i=-1; } } else { rmsPersonnel.setInsertTime(new Date()); rmsPersonnel.setInsertUsername("admin"); rmsPersonnel.setDeleted(new BigDecimal(0)); rmsPersonnel.setPersonnelId(rmsPersonnelMapper.getPersonnelId()); i+= rmsPersonnelMapper.insertSelective(rmsPersonnel); } return i; } /** * 修改人员信息,根据id值 * @param * @return */ @Override public int updatePersonnel(RmsPersonnel rmsPersonnel) { rmsPersonnel.setUpdateUsername("admin"); rmsPersonnel.setUpdateTime(new Date()); return rmsPersonnelMapper.updateByPrimaryKeySelective(rmsPersonnel); } /** * 根据id逻辑删除人员信息 * @param id * @return */ @Override public int deletePersonnel(BigDecimal id) { RmsPersonnel rmsPersonnel=rmsPersonnelMapper.selectByPrimaryKey(id); rmsPersonnel.setDeleted(new BigDecimal(1)); return rmsPersonnelMapper.updateByPrimaryKeySelective(rmsPersonnel); } /** * 根据id值获取详细人员信息 * @param id * @return */ @Override public List> getPersonnelById(BigDecimal id) { return rmsPersonnelMapper.selectPersonnelById(id); } /** * 获取托运人id * @return */ @Override public List> getShipperId() { return rmsPersonnelMapper.getShipperId(); } /** * 得到二级部门下拉 * @return */ @Override public List> getSecondShipper() { return rmsPersonnelMapper.getSecondShipper(); } /** * 得到三级部门下拉 * @return */ @Override public List> getThirdShipper(BigDecimal shipperId) { return rmsPersonnelMapper.getThirdShipper(shipperId); } /** * 新增人员权限 * @param rmsPersonnel * @return */ @Override public int addPersonnel(RmsPersonnel rmsPersonnel) { BigDecimal personnelId = rmsPersonnelMapper.getPersonnelId(); rmsPersonnel.setPersonnelId(personnelId); int result = rmsPersonnelMapper.insertSelective(rmsPersonnel); return result; } /** * 查询SSO主键和机构编码 * @param shipperId * @return */ @Override public Map getShipperMap(BigDecimal shipperId) { return rmsPersonnelMapper.getShipperMap(shipperId); } }