diff --git a/xm-core/src/main/java/com/xm/core/ctrl/XmTaskEvalController.java b/xm-core/src/main/java/com/xm/core/ctrl/XmTaskEvalController.java new file mode 100644 index 00000000..77ea6818 --- /dev/null +++ b/xm-core/src/main/java/com/xm/core/ctrl/XmTaskEvalController.java @@ -0,0 +1,296 @@ +package com.xm.core.ctrl; + +import java.util.*; +import java.util.stream.Collectors; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.util.StringUtils; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; +import io.swagger.annotations.*; + +import static com.mdp.core.utils.ResponseHelper.*; +import static com.mdp.core.utils.BaseUtils.*; +import com.mdp.core.entity.Tips; +import com.mdp.core.err.BizException; +import com.mdp.mybatis.PageUtils; +import com.mdp.core.utils.RequestUtils; +import com.mdp.core.utils.NumberUtil; +import com.mdp.safe.client.entity.User; +import com.mdp.safe.client.utils.LoginUtils; +import com.mdp.swagger.ApiEntityParams; +import springfox.documentation.annotations.ApiIgnore; + +import com.xm.core.service.XmTaskEvalService; +import com.xm.core.entity.XmTaskEval; + +/** + * url编制采用rest风格,如对xm_task_eval xm_task_eval的操作有增删改查,对应的url分别为:
+ * 组织 com 顶级模块 xm 大模块 core 小模块
+ * 实体 XmTaskEval 表 xm_task_eval 当前主键(包括多主键): id; + ***/ +@RestController("xm.core.xmTaskEvalController") +@RequestMapping(value="/**/core/xmTaskEval") +@Api(tags={"xm_task_eval操作接口"}) +public class XmTaskEvalController { + + static Logger logger =LoggerFactory.getLogger(XmTaskEvalController.class); + + @Autowired + private XmTaskEvalService xmTaskEvalService; + + + Map fieldsMap = toMap(new XmTaskEval()); + + + @ApiOperation( value = "查询xm_task_eval信息列表",notes=" ") + @ApiEntityParams( XmTaskEval.class ) + @ApiImplicitParams({ + @ApiImplicitParam(name="pageSize",value="每页大小,默认20条",required=false), + @ApiImplicitParam(name="pageNum",value="当前页码,从1开始",required=false), + @ApiImplicitParam(name="total",value="总记录数,服务器端收到0时,会自动计算总记录数,如果上传>0的不自动计算",required=false), + @ApiImplicitParam(name="count",value="是否计算总记录条数,如果count=true,则计算计算总条数,如果count=false 则不计算",required=false), + @ApiImplicitParam(name="orderBy",value="排序列 如性别、学生编号排序 orderBy = sex desc,student desc",required=false), + }) + @ApiResponses({ + @ApiResponse(code = 200,response=XmTaskEval.class,message = "{tips:{isOk:true/false,msg:'成功/失败原因',tipscode:'错误码'},total:总记录数,data:[数据对象1,数据对象2,...]}") + }) + @RequestMapping(value="/list",method=RequestMethod.GET) + public Map listXmTaskEval( @ApiIgnore @RequestParam Map xmTaskEval){ + Map m = new HashMap<>(); + Tips tips=new Tips("查询成功"); + RequestUtils.transformArray(xmTaskEval, "ids"); + PageUtils.startPage(xmTaskEval); + List> xmTaskEvalList = xmTaskEvalService.selectListMapByWhere(xmTaskEval); //列出XmTaskEval列表 + PageUtils.responePage(m, xmTaskEvalList); + m.put("data",xmTaskEvalList); + + m.put("tips", tips); + return m; + } + + + + /** + @ApiOperation( value = "新增一条xm_task_eval信息",notes=" ") + @ApiResponses({ + @ApiResponse(code = 200,response=XmTaskEval.class,message = "{tips:{isOk:true/false,msg:'成功/失败原因',tipscode:'失败时错误码'},data:数据对象}") + }) + @RequestMapping(value="/add",method=RequestMethod.POST) + public Map addXmTaskEval(@RequestBody XmTaskEval xmTaskEval) { + Map m = new HashMap<>(); + Tips tips=new Tips("成功新增一条数据"); + try{ + boolean createPk=false; + if(!StringUtils.hasText(xmTaskEval.getId())) { + createPk=true; + xmTaskEval.setId(xmTaskEvalService.createKey("id")); + } + if(createPk==false){ + if(xmTaskEvalService.selectOneObject(xmTaskEval) !=null ){ + return failed("pk-exists","编号重复,请修改编号再提交"); + } + } + xmTaskEvalService.insert(xmTaskEval); + m.put("data",xmTaskEval); + }catch (BizException e) { + tips=e.getTips(); + logger.error("",e); + }catch (Exception e) { + tips.setFailureMsg(e.getMessage()); + logger.error("",e); + } + m.put("tips", tips); + return m; + } + */ + + /** + @ApiOperation( value = "删除一条xm_task_eval信息",notes=" ") + @ApiResponses({ + @ApiResponse(code = 200, message = "{tips:{isOk:true/false,msg:'成功/失败原因',tipscode:'失败时错误码'}}") + }) + @RequestMapping(value="/del",method=RequestMethod.POST) + public Map delXmTaskEval(@RequestBody XmTaskEval xmTaskEval){ + Map m = new HashMap<>(); + Tips tips=new Tips("成功删除一条数据"); + try{ + if(!StringUtils.hasText(xmTaskEval.getId())) { + return failed("pk-not-exists","请上送主键参数id"); + } + XmTaskEval xmTaskEvalDb = xmTaskEvalService.selectOneObject(xmTaskEval); + if( xmTaskEvalDb == null ){ + return failed("data-not-exists","数据不存在,无法删除"); + } + xmTaskEvalService.deleteByPk(xmTaskEval); + }catch (BizException e) { + tips=e.getTips(); + logger.error("",e); + }catch (Exception e) { + tips.setFailureMsg(e.getMessage()); + logger.error("",e); + } + m.put("tips", tips); + return m; + } + */ + + /** + @ApiOperation( value = "根据主键修改一条xm_task_eval信息",notes=" ") + @ApiResponses({ + @ApiResponse(code = 200,response=XmTaskEval.class, message = "{tips:{isOk:true/false,msg:'成功/失败原因',tipscode:'失败时错误码'},data:数据对象}") + }) + @RequestMapping(value="/edit",method=RequestMethod.POST) + public Map editXmTaskEval(@RequestBody XmTaskEval xmTaskEval) { + Map m = new HashMap<>(); + Tips tips=new Tips("成功更新一条数据"); + try{ + if(!StringUtils.hasText(xmTaskEval.getId())) { + return failed("pk-not-exists","请上送主键参数id"); + } + XmTaskEval xmTaskEvalDb = xmTaskEvalService.selectOneObject(xmTaskEval); + if( xmTaskEvalDb == null ){ + return failed("data-not-exists","数据不存在,无法修改"); + } + xmTaskEvalService.updateSomeFieldByPk(xmTaskEval); + m.put("data",xmTaskEval); + }catch (BizException e) { + tips=e.getTips(); + logger.error("",e); + }catch (Exception e) { + tips.setFailureMsg(e.getMessage()); + logger.error("",e); + } + m.put("tips", tips); + return m; + } + */ + + /** + @ApiOperation( value = "批量修改某些字段",notes="") + @ApiEntityParams( value = XmTaskEval.class, props={ }, remark = "xm_task_eval", paramType = "body" ) + @ApiResponses({ + @ApiResponse(code = 200,response=XmTaskEval.class, message = "{tips:{isOk:true/false,msg:'成功/失败原因',tipscode:'失败时错误码'},data:数据对象}") + }) + @RequestMapping(value="/editSomeFields",method=RequestMethod.POST) + public Map editSomeFields( @ApiIgnore @RequestBody Map xmTaskEvalMap) { + Map m = new HashMap<>(); + Tips tips=new Tips("成功更新一条数据"); + try{ + List ids= (List) xmTaskEvalMap.get("ids"); + if(ids==null || ids.size()==0){ + return failed("ids-0","ids不能为空"); + } + + Set fields=new HashSet<>(); + fields.add("id"); + for (String fieldName : xmTaskEvalMap.keySet()) { + if(fields.contains(fieldName)){ + return failed(fieldName+"-no-edit",fieldName+"不允许修改"); + } + } + Set fieldKey=xmTaskEvalMap.keySet().stream().filter(i-> fieldsMap.containsKey(i)).collect(Collectors.toSet()); + fieldKey=fieldKey.stream().filter(i->!StringUtils.isEmpty(xmTaskEvalMap.get(i) )).collect(Collectors.toSet()); + + if(fieldKey.size()<=0) { + return failed("fieldKey-0","没有需要更新的字段"); + } + XmTaskEval xmTaskEval = fromMap(xmTaskEvalMap,XmTaskEval.class); + List xmTaskEvalsDb=xmTaskEvalService.selectListByIds(ids); + if(xmTaskEvalsDb==null ||xmTaskEvalsDb.size()==0){ + return failed("data-0","记录已不存在"); + } + List can=new ArrayList<>(); + List no=new ArrayList<>(); + User user = LoginUtils.getCurrentUserInfo(); + for (XmTaskEval xmTaskEvalDb : xmTaskEvalsDb) { + Tips tips2 = new Tips("检查通过"); + if(!tips2.isOk()){ + no.add(xmTaskEvalDb); + }else{ + can.add(xmTaskEvalDb); + } + } + if(can.size()>0){ + xmTaskEvalMap.put("ids",can.stream().map(i->i.getId()).collect(Collectors.toList())); + xmTaskEvalService.editSomeFields(xmTaskEvalMap); + } + List msgs=new ArrayList<>(); + if(can.size()>0){ + msgs.add(String.format("成功更新以下%s条数据",can.size())); + } + if(no.size()>0){ + msgs.add(String.format("以下%s个数据无权限更新",no.size())); + } + if(can.size()>0){ + tips.setOkMsg(msgs.stream().collect(Collectors.joining())); + }else { + tips.setFailureMsg(msgs.stream().collect(Collectors.joining())); + } + //m.put("data",xmMenu); + }catch (BizException e) { + tips=e.getTips(); + logger.error("",e); + }catch (Exception e) { + tips.setFailureMsg(e.getMessage()); + logger.error("",e); + } + m.put("tips", tips); + return m; + } + */ + + /** + @ApiOperation( value = "根据主键列表批量删除xm_task_eval信息",notes=" ") + @ApiResponses({ + @ApiResponse(code = 200, message = "{tips:{isOk:true/false,msg:'成功/失败原因',tipscode:'失败时错误码'}") + }) + @RequestMapping(value="/batchDel",method=RequestMethod.POST) + public Map batchDelXmTaskEval(@RequestBody List xmTaskEvals) { + Map m = new HashMap<>(); + Tips tips=new Tips("成功删除"); + try{ + if(xmTaskEvals.size()<=0){ + return failed("data-0","请上送待删除数据列表"); + } + List datasDb=xmTaskEvalService.selectListByIds(xmTaskEvals.stream().map(i-> i.getId() ).collect(Collectors.toList())); + + List can=new ArrayList<>(); + List no=new ArrayList<>(); + for (XmTaskEval data : datasDb) { + if(true){ + can.add(data); + }else{ + no.add(data); + } + } + List msgs=new ArrayList<>(); + if(can.size()>0){ + xmTaskEvalService.batchDelete(can); + msgs.add(String.format("成功删除%s条数据.",can.size())); + } + + if(no.size()>0){ + msgs.add(String.format("以下%s条数据不能删除.【%s】",no.size(),no.stream().map(i-> i.getId() ).collect(Collectors.joining(",")))); + } + if(can.size()>0){ + tips.setOkMsg(msgs.stream().collect(Collectors.joining())); + }else { + tips.setFailureMsg(msgs.stream().collect(Collectors.joining())); + } + }catch (BizException e) { + tips=e.getTips(); + logger.error("",e); + }catch (Exception e) { + tips.setFailureMsg(e.getMessage()); + logger.error("",e); + } + m.put("tips", tips); + return m; + } + */ +} diff --git a/xm-core/src/main/java/com/xm/core/entity/XmTaskEval.java b/xm-core/src/main/java/com/xm/core/entity/XmTaskEval.java new file mode 100644 index 00000000..b6e2d746 --- /dev/null +++ b/xm-core/src/main/java/com/xm/core/entity/XmTaskEval.java @@ -0,0 +1,80 @@ +package com.xm.core.entity; + +import lombok.Data; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import java.util.Date; + +/** + * 组织 com 顶级模块 xm 大模块 core 小模块
+ * 实体 XmTaskEval所有属性名:
+ * "id","评价","type","评价类型1-雇主对服务商的评价,2-服务商对雇主的评价,3-组长对组员的评价","wspeed","工作速度0-5分","wattit","工作态度0-5分","wquality","工作质量0-5分","totalStar","总体评价0-5分","remark","评价内容","evalUserid","评价人编号","evalUsername","评价人姓名","toUserid","被评价人编号","toUsername","被评价人姓名","evalBranchId","评价人归属机构","toBranchId","被评价人归属机构号","taskId","任务编号","evalTime","评价时间";
+ * 当前主键(包括多主键):
+ * id;
+ */ + @Data +@ApiModel(description="xm_task_eval") +public class XmTaskEval implements java.io.Serializable { + + private static final long serialVersionUID = 1L; + + @ApiModelProperty(notes="评价,主键",allowEmptyValue=true,example="",allowableValues="") + String id; + + + @ApiModelProperty(notes="评价类型1-雇主对服务商的评价,2-服务商对雇主的评价,3-组长对组员的评价",allowEmptyValue=true,example="",allowableValues="") + String type; + + @ApiModelProperty(notes="工作速度0-5分",allowEmptyValue=true,example="",allowableValues="") + Integer wspeed; + + @ApiModelProperty(notes="工作态度0-5分",allowEmptyValue=true,example="",allowableValues="") + Integer wattit; + + @ApiModelProperty(notes="工作质量0-5分",allowEmptyValue=true,example="",allowableValues="") + Integer wquality; + + @ApiModelProperty(notes="总体评价0-5分",allowEmptyValue=true,example="",allowableValues="") + Integer totalStar; + + @ApiModelProperty(notes="评价内容",allowEmptyValue=true,example="",allowableValues="") + String remark; + + @ApiModelProperty(notes="评价人编号",allowEmptyValue=true,example="",allowableValues="") + String evalUserid; + + @ApiModelProperty(notes="评价人姓名",allowEmptyValue=true,example="",allowableValues="") + String evalUsername; + + @ApiModelProperty(notes="被评价人编号",allowEmptyValue=true,example="",allowableValues="") + String toUserid; + + @ApiModelProperty(notes="被评价人姓名",allowEmptyValue=true,example="",allowableValues="") + String toUsername; + + @ApiModelProperty(notes="评价人归属机构",allowEmptyValue=true,example="",allowableValues="") + String evalBranchId; + + @ApiModelProperty(notes="被评价人归属机构号",allowEmptyValue=true,example="",allowableValues="") + String toBranchId; + + @ApiModelProperty(notes="任务编号",allowEmptyValue=true,example="",allowableValues="") + String taskId; + + @ApiModelProperty(notes="评价时间",allowEmptyValue=true,example="",allowableValues="") + Date evalTime; + + /** + *评价 + **/ + public XmTaskEval(String id) { + this.id = id; + } + + /** + * xm_task_eval + **/ + public XmTaskEval() { + } + +} \ No newline at end of file diff --git a/xm-core/src/main/java/com/xm/core/service/XmTaskEvalService.java b/xm-core/src/main/java/com/xm/core/service/XmTaskEvalService.java new file mode 100644 index 00000000..cbabd53b --- /dev/null +++ b/xm-core/src/main/java/com/xm/core/service/XmTaskEvalService.java @@ -0,0 +1,24 @@ +package com.xm.core.service; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import java.util.List; +import java.util.Map; +import org.springframework.stereotype.Service; +import com.mdp.core.service.BaseService; +import static com.mdp.core.utils.BaseUtils.*; +import com.mdp.core.entity.Tips; +import com.mdp.core.err.BizException; + +import com.xm.core.entity.XmTaskEval; +/** + * 父类已经支持增删改查操作,因此,即使本类什么也不写,也已经可以满足一般的增删改查操作了.
+ * 组织 com 顶级模块 xm 大模块 core 小模块
+ * 实体 XmTaskEval 表 xm_task_eval 当前主键(包括多主键): id; + ***/ +@Service("xm.core.xmTaskEvalService") +public class XmTaskEvalService extends BaseService { + static Logger logger =LoggerFactory.getLogger(XmTaskEvalService.class); + +} + diff --git a/xm-core/src/main/resources/mybatis/mapper/xm/core/dao/XmTaskEvalMapper.xml b/xm-core/src/main/resources/mybatis/mapper/xm/core/dao/XmTaskEvalMapper.xml new file mode 100644 index 00000000..ef3eb704 --- /dev/null +++ b/xm-core/src/main/resources/mybatis/mapper/xm/core/dao/XmTaskEvalMapper.xml @@ -0,0 +1,216 @@ + + + + + + + + + and (res.id) in + + ( #{item}) + + + + + + + + + + + + + + + + + + + + + + + + + + insert into xm_task_eval( + + ) values ( + #{id},#{type},#{wspeed},#{wattit},#{wquality},#{totalStar},#{remark},#{evalUserid},#{evalUsername},#{toUserid},#{toUsername},#{evalBranchId},#{toBranchId},#{taskId},#{evalTime} + ) + + + + + delete from xm_task_eval res + + + + + + + + delete from xm_task_eval + where id = #{id} + + + + + update xm_task_eval + + + + where id = #{id} + + + + + update xm_task_eval + + + + where id = #{id} + + + + + + + + update xm_task_eval + set + + where id = #{item.id} + + + + + + update xm_task_eval + + + + where (id) in + + ( #{item}) + + + + + delete from xm_task_eval + where + (id) in + + ( #{item.id} ) + + + + + + + id,type,wspeed,wattit,wquality,total_star,remark,eval_userid,eval_username,to_userid,to_username,eval_branch_id,to_branch_id,task_id,eval_time + + + + + and res.id = #{id} + and res.type = #{type} + and res.wspeed = #{wspeed} + and res.wattit = #{wattit} + and res.wquality = #{wquality} + and res.total_star = #{totalStar} + and res.remark = #{remark} + and res.eval_userid = #{evalUserid} + and res.eval_username = #{evalUsername} + and res.to_userid = #{toUserid} + and res.to_username = #{toUsername} + and res.eval_branch_id = #{evalBranchId} + and res.to_branch_id = #{toBranchId} + and res.task_id = #{taskId} + and date_format(res.eval_time,'%Y-%m-%d') = date_format(#{evalTime},'%Y-%m-%d') + + + + type = #{type}, + wspeed = #{wspeed}, + wattit = #{wattit}, + wquality = #{wquality}, + total_star = #{totalStar}, + remark = #{remark}, + eval_userid = #{evalUserid}, + eval_username = #{evalUsername}, + to_userid = #{toUserid}, + to_username = #{toUsername}, + eval_branch_id = #{evalBranchId}, + to_branch_id = #{toBranchId}, + task_id = #{taskId}, + eval_time = #{evalTime} + + + type = #{type}, + wspeed = #{wspeed}, + wattit = #{wattit}, + wquality = #{wquality}, + total_star = #{totalStar}, + remark = #{remark}, + eval_userid = #{evalUserid}, + eval_username = #{evalUsername}, + to_userid = #{toUserid}, + to_username = #{toUsername}, + eval_branch_id = #{evalBranchId}, + to_branch_id = #{toBranchId}, + task_id = #{taskId}, + eval_time = #{evalTime}, + + + + type = #{item.type}, + wspeed = #{item.wspeed}, + wattit = #{item.wattit}, + wquality = #{item.wquality}, + total_star = #{item.totalStar}, + remark = #{item.remark}, + eval_userid = #{item.evalUserid}, + eval_username = #{item.evalUsername}, + to_userid = #{item.toUserid}, + to_username = #{item.toUsername}, + eval_branch_id = #{item.evalBranchId}, + to_branch_id = #{item.toBranchId}, + task_id = #{item.taskId}, + eval_time = #{item.evalTime} + + \ No newline at end of file