|
@@ -1,11 +1,22 @@
|
|
package com.management.platform.service.impl;
|
|
package com.management.platform.service.impl;
|
|
|
|
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.management.platform.entity.EquipmentOwner;
|
|
import com.management.platform.entity.EquipmentOwner;
|
|
|
|
+import com.management.platform.entity.ExpenseSheet;
|
|
|
|
+import com.management.platform.entity.User;
|
|
import com.management.platform.mapper.EquipmentOwnerMapper;
|
|
import com.management.platform.mapper.EquipmentOwnerMapper;
|
|
|
|
+import com.management.platform.mapper.ExpenseSheetMapper;
|
|
|
|
+import com.management.platform.mapper.UserMapper;
|
|
import com.management.platform.service.EquipmentOwnerService;
|
|
import com.management.platform.service.EquipmentOwnerService;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
|
+import com.management.platform.util.HttpRespMsg;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
+import javax.annotation.Resource;
|
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
|
|
+import java.util.ArrayList;
|
|
|
|
+import java.util.List;
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* <p>
|
|
* <p>
|
|
* 服务实现类
|
|
* 服务实现类
|
|
@@ -17,4 +28,82 @@ import org.springframework.stereotype.Service;
|
|
@Service
|
|
@Service
|
|
public class EquipmentOwnerServiceImpl extends ServiceImpl<EquipmentOwnerMapper, EquipmentOwner> implements EquipmentOwnerService {
|
|
public class EquipmentOwnerServiceImpl extends ServiceImpl<EquipmentOwnerMapper, EquipmentOwner> implements EquipmentOwnerService {
|
|
|
|
|
|
|
|
+ @Resource
|
|
|
|
+ private UserMapper userMapper;
|
|
|
|
+ @Resource
|
|
|
|
+ private EquipmentOwnerMapper equipmentOwnerMapper;
|
|
|
|
+
|
|
|
|
+ @Resource
|
|
|
|
+ private ExpenseSheetMapper expenseSheetMapper;
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public HttpRespMsg addOrUpdate(EquipmentOwner equipmentOwner, HttpServletRequest request) {
|
|
|
|
+ HttpRespMsg msg = new HttpRespMsg();
|
|
|
|
+ String token = request.getHeader("TOKEN");
|
|
|
|
+ User user = userMapper.selectById(token);
|
|
|
|
+ if (user.getCompanyId()!=4811){
|
|
|
|
+ msg.setError("该公司无需操作设备归属人");
|
|
|
|
+ return msg;
|
|
|
|
+ }
|
|
|
|
+ if (equipmentOwner.getId()==null){
|
|
|
|
+ Integer count = equipmentOwnerMapper.selectCount(new QueryWrapper<EquipmentOwner>()
|
|
|
|
+ .eq("equipment_owner", equipmentOwner.getEquipmentOwner())
|
|
|
|
+ .eq("company_id", user.getCompanyId()));
|
|
|
|
+ if (count>0){
|
|
|
|
+ msg.setError("归属人名称:"+equipmentOwner.getEquipmentOwner()+",已存在");
|
|
|
|
+ }else {
|
|
|
|
+ int insert = equipmentOwnerMapper.insert(equipmentOwner);
|
|
|
|
+ if (insert>0){
|
|
|
|
+ return msg;
|
|
|
|
+ }else {
|
|
|
|
+ msg.setError("添加失败");
|
|
|
|
+ return msg;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ else {
|
|
|
|
+ Integer count = equipmentOwnerMapper.selectCount(new QueryWrapper<EquipmentOwner>()
|
|
|
|
+ .eq("equipment_owner", equipmentOwner.getEquipmentOwner())
|
|
|
|
+ .ne("id", equipmentOwner.getId())
|
|
|
|
+ .eq("company_id", user.getCompanyId()));
|
|
|
|
+ if (count>0){
|
|
|
|
+ msg.setError("归属人名称:"+equipmentOwner.getEquipmentOwner()+",已存在");
|
|
|
|
+ }else {
|
|
|
|
+ int update = equipmentOwnerMapper.updateById(equipmentOwner);
|
|
|
|
+ if (update>0){
|
|
|
|
+ return msg;
|
|
|
|
+ }else {
|
|
|
|
+ msg.setError("修改失败");
|
|
|
|
+ return msg;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return msg;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public HttpRespMsg getList(HttpServletRequest request) {
|
|
|
|
+ HttpRespMsg msg = new HttpRespMsg();
|
|
|
|
+ String token = request.getHeader("TOKEN");
|
|
|
|
+ User user = userMapper.selectById(token);
|
|
|
|
+ if (user.getCompanyId()!=4811){
|
|
|
|
+ msg.setData(new ArrayList<EquipmentOwner>());
|
|
|
|
+ }else {
|
|
|
|
+ List<EquipmentOwner> selectedList = equipmentOwnerMapper.selectList(new QueryWrapper<EquipmentOwner>().eq("company_id", user.getCompanyId()));
|
|
|
|
+ msg.setData(selectedList);
|
|
|
|
+ }
|
|
|
|
+ return msg;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public HttpRespMsg removeEquipmentOwner(Integer id, HttpServletRequest request) {
|
|
|
|
+ HttpRespMsg msg = new HttpRespMsg();
|
|
|
|
+ Integer count = expenseSheetMapper.selectCount(new QueryWrapper<ExpenseSheet>().eq("equipment_owner_id", id));
|
|
|
|
+ if (count>0){
|
|
|
|
+ msg.setError("存在报销单绑定该设备审核人,删除失败");
|
|
|
|
+ }else {
|
|
|
|
+ equipmentOwnerMapper.deleteById(id);
|
|
|
|
+ }
|
|
|
|
+ return msg;
|
|
|
|
+ }
|
|
}
|
|
}
|