| | |
| | | public Response getSopInfo(@RequestBody(required = false) List<SopDto> list, @RequestParam(required = false) String code, @RequestParam(required = false) String model) { |
| | | return service.getSopInfo(list,code,model); |
| | | } |
| | | |
| | | @ApiOperation("更新sop说明(不含锁信息)") |
| | | @PostMapping("updateSop") |
| | | public Response updateSop(@RequestBody SOP sop) { |
| | | return service.updateSop(sop); |
| | | } |
| | | } |
| | |
| | | private String uploadUser; |
| | | /**文件url*/ |
| | | private String fileUrl; |
| | | /**锁(0:未锁定,1:锁定)*/ |
| | | private int lockFlag; |
| | | |
| | | /** |
| | | * [ |
| | |
| | | public void setFileTypeList(List<Map<String, List<String>>> fileTypeList) { |
| | | this.fileTypeList = fileTypeList; |
| | | } |
| | | |
| | | public int getLockFlag() { |
| | | return lockFlag; |
| | | } |
| | | |
| | | public void setLockFlag(int lockFlag) { |
| | | this.lockFlag = lockFlag; |
| | | } |
| | | } |
| | |
| | | /**sop id*/ |
| | | private Integer sopId; |
| | | |
| | | /**锁(0:未锁定,1:锁定)*/ |
| | | private int lockFlag; |
| | | |
| | | public Integer getId() { |
| | | return id; |
| | | } |
| | |
| | | public void setSopId(Integer sopId) { |
| | | this.sopId = sopId; |
| | | } |
| | | |
| | | public int getLockFlag() { |
| | | return lockFlag; |
| | | } |
| | | |
| | | public void setLockFlag(int lockFlag) { |
| | | this.lockFlag = lockFlag; |
| | | } |
| | | } |
| | |
| | | package com.whyc.service; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.Wrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.whyc.mapper.SOPProductMapper; |
| | | import com.whyc.pojo.SOPProduct; |
| | | import org.springframework.stereotype.Service; |
| | |
| | | public void insertBatch(List<SOPProduct> sopProductList) { |
| | | mapper.insertBatchSomeColumn(sopProductList); |
| | | } |
| | | |
| | | public void updateBySid(List<SOPProduct> sopProductList,int sid) { |
| | | QueryWrapper wrapper= Wrappers.query(); |
| | | wrapper.eq("sop_id",sid); |
| | | List list=mapper.selectList(wrapper); |
| | | if(list.size()>0) { |
| | | //先删除 |
| | | UpdateWrapper delWrapp=Wrappers.update(); |
| | | delWrapp.eq("sop_id",sid); |
| | | mapper.delete(delWrapp); |
| | | } |
| | | //再插入 |
| | | mapper.insertBatchSomeColumn(sopProductList); |
| | | } |
| | | } |
| | |
| | | List<SOP> list=mapper.getSopInfo(sqlStr,code,model); |
| | | return new Response().setII(1,list.size()>0,list,"查询sop信息"); |
| | | } |
| | | //更新sop说明(不含锁信息) |
| | | @Transactional |
| | | public Response updateSop(SOP sop) { |
| | | List<SOPProduct> sopProductList = sop.getSopProductList(); |
| | | mapper.updateById(sop); |
| | | if(sopProductList.size()>0) { |
| | | sopProductList.forEach(product -> product.setSopId(sop.getId())); |
| | | productService.updateBySid(sopProductList,sop.getId()); |
| | | } |
| | | return new Response().setII(1,"更新sop说明完成"); |
| | | } |
| | | } |
| | |
| | | <result property="releaseNotes" column="release_notes"></result> |
| | | <result property="createTime" column="create_time"></result> |
| | | <result property="uploadUser" column="upload_user"></result> |
| | | <result property="lockFlag" column="lock_flag"></result> |
| | | <result property="fileUrl" column="file_url"/> |
| | | <collection property="sopProductList" ofType="SOPProduct"> |
| | | <id column="sid" property="id"/> |
| | | <result column="code" property="code"/> |
| | | <result column="model" property="model"/> |
| | | <result column="sop_id" property="sopId"/> |
| | | <result column="slock_flag" property="lockFlag"/> |
| | | </collection> |
| | | </resultMap> |
| | | <select id="getSopInfo" resultMap="sopList"> |
| | | select *,tb_sop_product.id as sid from tb_sop,tb_sop_product |
| | | select *, tb_sop_product.id as sid ,tb_sop_product.lock_flag as slock_flag from tb_sop |
| | | LEFT JOIN tb_sop_product on tb_sop.id=tb_sop_product.sop_id |
| | | <where> |
| | | tb_sop.id=tb_sop_product.sop_id |
| | | 1=1 |
| | | <if test="code!=null"> |
| | | and code LIKE '%${code}%' |
| | | </if> |
| | |
| | | </if> |
| | | ${sqlStr} |
| | | </where> |
| | | order by tb_sop.id desc |
| | | </select> |
| | | </mapper> |