提交 b3bead8c authored 作者: chaoyanjun's avatar chaoyanjun

--no commit message

上级 4abe65db
package com.zrqx.statistics.userlevel.controller;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.zrqx.core.form.userlevel.SaveOrUpdateLevelForm;
import com.zrqx.core.response.CallBack;
import com.zrqx.statistics.userlevel.service.UserLevelService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
@RestController
@RequestMapping("/level")
@Api("基准工时")
public class UserLevelController {
@Autowired
private UserLevelService service;
@ApiOperation(value = "人员-工时统计修改/添加基础工时")
@PostMapping("/saveOrUpdate/level")
public CallBack<Boolean> saveOrUpdate(@RequestBody SaveOrUpdateLevelForm form){
return CallBack.success(service.saveOrUpdate(form));
}
}
package com.zrqx.statistics.userlevel.mapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import com.zrqx.core.form.userlevel.QueryLevelForm;
import com.zrqx.core.mapper.BaseMapper;
import com.zrqx.core.model.userlevel.UserLevel;
@Mapper
public interface UserLevelMapper extends BaseMapper<UserLevel>{
@Select("<script>"
+ " select id from zt_user where realname = #{name} "
+ "</script>")
Integer selectUserId(@Param("name") String name);
@Select("<script>"
+ " select sum(level) from user_info where 1=1 "
+ " eq(name,form.name) "
+ "<if test = '" + NOTBLANK + "(form.startTime)'>"
+ " AND createTime &gt;= concat(#{form.startTime}) "
+ "</if>"
+ "<if test = '" + NOTBLANK + "(form.endTime)'>"
+ " AND createTime &lt;= concat(#{form.endTime}) "
+ "</if>"
+ "</script>")
Integer getSumLevel(@Param("form") QueryLevelForm form);
}
package com.zrqx.statistics.userlevel.service;
import com.zrqx.core.form.userlevel.QueryLevelForm;
import com.zrqx.core.form.userlevel.SaveOrUpdateLevelForm;
import com.zrqx.core.model.userlevel.UserLevel;
import com.zrqx.core.service.BaseService;
public interface UserLevelService extends BaseService<UserLevel, Integer>{
Boolean saveOrUpdate(SaveOrUpdateLevelForm form);
Integer getSumLevel(QueryLevelForm form);
}
package com.zrqx.statistics.userlevel.service;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.zrqx.core.form.userlevel.QueryLevelForm;
import com.zrqx.core.form.userlevel.SaveOrUpdateLevelForm;
import com.zrqx.core.mapper.BaseMapper;
import com.zrqx.core.model.userlevel.UserLevel;
import com.zrqx.core.service.BaseServiceImpl;
import com.zrqx.core.util.bean.BeanUtils;
import com.zrqx.core.util.datatype.ArrayUtils;
import com.zrqx.statistics.userlevel.mapper.UserLevelMapper;
@Service
public class UserLevelServiceImpl extends BaseServiceImpl<UserLevel, Integer> implements UserLevelService{
@Autowired
private UserLevelMapper mapper;
@Override
public BaseMapper<UserLevel> getMapper() {
return mapper;
}
@Override
public Boolean saveOrUpdate(SaveOrUpdateLevelForm form) {
// 查看该用户在基准工时表中是否存在 添加或修改
UserLevel userLe = new UserLevel();
userLe.setName(form.getName());
userLe.setCreateTime(form.getCreateTime());
List<UserLevel> list = mapper.select(userLe);
if (ArrayUtils.empty(list)) {//不存在,添加
Integer userId = mapper.selectUserId(form.getName());
UserLevel ul = new UserLevel();
BeanUtils.copyProperties(form, ul);
ul.setUserId(userId);
mapper.insert(ul);
}else {//存在,修改(不考虑同名同姓)
UserLevel ul = new UserLevel();
BeanUtils.copyProperties(form, ul, "level");
UserLevel level = mapper.selectOne(ul);
level.setLevel(form.getLevel());
mapper.updateByPrimaryKeySelective(level);
}
return true;
}
@Override
public Integer getSumLevel(QueryLevelForm form) {
return mapper.getSumLevel(form);
}
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论