123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174 |
- package com.steerinfo.dil.service.impl;
- import com.steerinfo.dil.mapper.RmsSupplierMapper;
- import com.steerinfo.dil.model.RmsSupplier;
- import com.steerinfo.dil.service.IRmsSupplierService;
- 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;
- /**
- * RmsSupplier服务实现:
- * @author generator
- * @version 1.0-SNAPSHORT 2021-10-22 06:18
- * 类描述
- * 修订历史:
- * 日期:2021-10-22
- * 作者:HuJieHuan
- * 参考:
- * 描述:RmsSupplier服务实现
- * @see null
- * @Copyright 湖南视拓信息技术股份有限公司. All rights reserved.
- */
- @Service(value = "rmsSupplierService")
- public class RmsSupplierServiceImpl implements IRmsSupplierService {
- @Autowired
- private RmsSupplierMapper rmsSupplierMapper;
- /**
- * 操作供应商
- * @param mapVal
- * @return
- */
- @Override
- public int operationSupplier(Map<String, Object> mapVal) {
- // 得到金蝶主键供应商id
- Integer EASSupplierIdValue = (Integer) mapVal.get("EASSupplierId");
- BigDecimal EASSupplierId = new BigDecimal(EASSupplierIdValue);
- // 得到供应商名称
- String supplierName = (String) mapVal.get("supplierName");
- // 得到供应商供应商简称
- String supplierAbbreviation = (String) mapVal.get("supplierAbbreviation");
- // 得到供应商代码
- String supplierDutyParagraph = (String) mapVal.get("supplierDutyParagraph");
- // 得到供应商地址
- String supplierAddress = (String) mapVal.get("supplierAddress");
- // 得到注册时间
- Date supplierRegisterDate = (Date) mapVal.get("supplierRegisterDate");
- // 得到委托代理人
- String supplierContactsName = (String) mapVal.get("supplierAgent");
- // 得到联系电话
- String supplierContactNumber = (String) mapVal.get("supplierContactNumber");
- // 得到数据数据状态
- Integer dataStatus = (Integer) mapVal.get("dataStatus");
- // 判断是否EASId已存在
- Map<String,Object> map1 = new HashMap<>();
- map1.put("easSupplierId",EASSupplierId);
- BigDecimal deleted = new BigDecimal(0);
- map1.put("deleted",deleted);
- List<RmsSupplier> rmsSuppliers = rmsSupplierMapper.selectByParameters(map1);
- RmsSupplier rmsSupplier = new RmsSupplier();
- rmsSupplier.setEasSupplierId(EASSupplierId);
- rmsSupplier.setSupplierName(supplierName);
- rmsSupplier.setSupplierAbbreviation(supplierAbbreviation);
- rmsSupplier.setSupplierDutyParagraph(supplierDutyParagraph);
- rmsSupplier.setSupplierAddress(supplierAddress);
- rmsSupplier.setSupplierRegisterDate(supplierRegisterDate);
- rmsSupplier.setSupplierContactsName(supplierContactsName);
- rmsSupplier.setSupplierContactNumber(supplierContactNumber);
- int result = 0;
- // 新增
- if (rmsSuppliers.size() == 0) {
- BigDecimal supplierId = rmsSupplierMapper.getSupplierId();
- rmsSupplier.setSupplierId(supplierId);
- rmsSupplier.setDeleted(new BigDecimal(0));
- result = rmsSupplierMapper.insertSelective(rmsSupplier);
- }
- // 修改
- if (rmsSuppliers.size() != 0 && dataStatus == 2) {
- RmsSupplier rmsSupplier1 = rmsSuppliers.get(0);
- rmsSupplier.setSupplierId(rmsSupplier1.getSupplierId());
- result = rmsSupplierMapper.updateByPrimaryKeySelective(rmsSupplier);
- }
- // 逻辑删除
- if (rmsSuppliers.size() != 0 && dataStatus == 3) {
- RmsSupplier rmsSupplier1 = rmsSuppliers.get(0);
- rmsSupplier.setSupplierId(rmsSupplier1.getSupplierId());
- rmsSupplier.setDeleted(new BigDecimal(1));
- result = rmsSupplierMapper.updateByPrimaryKeySelective(rmsSupplier);
- }
- return result;
- }
- /**
- * 查询供应商列表
- * @param mapVal
- * @return
- */
- @Override
- public List<Map<String, Object>> getSupplierList(Map<String, Object> mapVal) {
- return rmsSupplierMapper.getSupplierList(mapVal);
- }
- /**
- * 添加供应商列表
- * @param rmsSupplier
- * @return
- */
- @Override
- public int insertSupplier(RmsSupplier rmsSupplier) {
- // 新增用户名和密码将其传到SSO接口
- // String username=mapValue.get("username");
- // String password="123456";
- int i=0;
- // 判断用户输入的船名在数据库中是否存在
- String supplierName=rmsSupplier.getSupplierName();
- int size = rmsSupplierMapper.selectByParametersSupplierName(supplierName);
- if (size == 0 ) {
- rmsSupplier.setInsertTime(new Date());
- rmsSupplier.setInsertUsername("admin");
- rmsSupplier.setDeleted(new BigDecimal(0));
- rmsSupplier.setSupplierId(rmsSupplierMapper.getSupplierId());
- i+=rmsSupplierMapper.insertSelective(rmsSupplier);
- }
- else{
- i=-1;
- }
- return i;
- }
- /**
- * 修改供应商信息
- * @param rmsSupplier
- * @return
- */
- @Override
- public int updateSupplier(RmsSupplier rmsSupplier) {
- rmsSupplier.setUpdateUsername("admin");
- // 增加修改时间
- rmsSupplier.setUpdateTime(new Date());
- return rmsSupplierMapper.updateByPrimaryKeySelective(rmsSupplier);
- }
- /**
- * 根据id值删除供应商信息
- * @param id
- * @return
- */
- @Override
- public int deleteSupplier(BigDecimal id) {
- // 使用逻辑删除
- RmsSupplier rmsSupplier=rmsSupplierMapper.selectByPrimaryKey(id);
- // 对于我们要删除的供应商,将他的deleted字段的值变为1
- rmsSupplier.setDeleted(new BigDecimal(1));
- return rmsSupplierMapper.updateByPrimaryKeySelective(rmsSupplier);
- }
- /**
- * 根据id值展示供应商信息
- * @param id
- * @return
- */
- @Override
- public List<Map<String, Object>> getSupplierById(BigDecimal id) {
- return rmsSupplierMapper.selectSupplierById(id);
- }
- }
|