| | |
| | | |
| | | return model; |
| | | } |
| | | |
| | | |
| | | //8.1修改参数信息 |
| | | @PutMapping("/") |
| | | @ApiOperation(notes = "",value="修改参数信息") |
| | | @ApiOperation(notes = "{ \"num\": 15, \"param_name\": \"\", \"preset_time\": 0, \"preset_cap\": 0.0, \"preset_monvol\": 0.0, \"preset_groupvol\": 0.0, \"preset_curr\": 0.0, \"preset_mon\": 0, \"dcvolhighlimit\": 0.0, \"chargecurrset\": 0.0, \"note\": \"CC\", \"plan_circle\": 0, \"plan_rate\": 0 }",value="修改参数信息") |
| | | public ServiceModel update(@RequestBody BattDischarge_param param){ |
| | | // BattDischarge_param param = getGson("yyyy-MM-dd").fromJson(json, BattDischarge_param.class); |
| | | ServiceModel model = service.update(param); |
| | |
| | | |
| | | @DeleteMapping("/") |
| | | @ApiOperation(notes = "",value="删除") |
| | | public ServiceModel del(@RequestBody BattDischarge_param param){ |
| | | // BattDischarge_param param = getGson("yyyy-MM-dd HH:mm:ss").fromJson(json, BattDischarge_param.class); |
| | | public ServiceModel del(@RequestParam Integer num) { |
| | | BattDischarge_param param = new BattDischarge_param(); |
| | | param.setNum(num); |
| | | ServiceModel model = service.del(param); |
| | | |
| | | return model; |
| | |
| | | return model; |
| | | } |
| | | |
| | | @GetMapping("byCondition") |
| | | @PostMapping("byCondition") |
| | | @ApiOperation(notes = "",value="byCondition") |
| | | public ServiceModel serchByCondition(@RequestBody BattDischarge_param param){ |
| | | // BattDischarge_param param = getGson("yyyy-MM-dd HH:mm:ss").fromJson(json, BattDischarge_param.class); |
| | | public ServiceModel serchByCondition(@RequestParam Integer num){ |
| | | BattDischarge_param param = new BattDischarge_param(); |
| | | param.setNum(num); |
| | | ServiceModel model = service.serchByCondition(param); |
| | | return model; |
| | | } |
| | |
| | | private BattDischarge_planService service; |
| | | |
| | | @PostMapping("/") |
| | | @ApiOperation(notes = "",value="新增") |
| | | @ApiOperation(notes = "除num外所有参数",value="新增") |
| | | public ServiceModel add(@RequestBody BattDischarge_plan plan){ |
| | | // BattDischarge_plan plan = ActionUtil.getGson("yyyy-MM-dd HH:mm:ss").fromJson(json, BattDischarge_plan.class); |
| | | ServiceModel model =service.add(plan); |
| | |
| | | //8.1批量添加电池计划 |
| | | @PostMapping("/batch") |
| | | @ApiOperation(notes = "",value="批量添加电池计划") |
| | | public ServiceModel addPro(@RequestBody List<BattDischarge_plan> plans){ |
| | | public ServiceModel addPro(@RequestBody List<BattDischarge_plan> list){ |
| | | // List<BattDischarge_plan> plans = getGson("yyyy-MM-dd HH:mm:ss").fromJson(json,new TypeToken<List<BattDischarge_plan>>(){}.getType()); |
| | | ServiceModel model = service.addPro(plans); |
| | | ServiceModel model = service.addPro(list); |
| | | |
| | | return model; |
| | | } |
| | |
| | | @Insert("insert into web_site.tb_battdischarge_plan(battgroupid,BattIndexInFbs,discharge_starttime,discharge_stoptime,discharge_state,discharge_reason,discharge_cleartype,preset_time,preset_cap,preset_monvol,preset_groupvol,preset_curr,preset_mon,dcvolhighlimit,chargecurrset,plan_circle,plan_rate,note) " + |
| | | "values(#{battgroupid},#{battIndexInFbs},#{discharge_starttime},#{discharge_stoptime},#{discharge_state},#{discharge_reason},#{discharge_cleartype},#{preset_time},#{preset_cap},#{preset_monvol},#{preset_groupvol},#{preset_curr},#{preset_mon},#{dcvolhighlimit},#{chargecurrset},#{plan_circle},#{plan_rate},#{note})") |
| | | public int add(BattDischarge_plan obj); |
| | | |
| | | //8.1批量添加电池计划 |
| | | public boolean addPro(Object obj); |
| | | @Insert("insert into web_site.tb_battdischarge_plan(battgroupid,battIndexInFbs,discharge_starttime,discharge_state,discharge_reason,discharge_cleartype," + |
| | | "preset_time,preset_cap,preset_monvol,preset_groupvol,preset_curr,preset_mon,dcvolhighlimit,chargecurrset,plan_circle,plan_rate) " + |
| | | "values(#{battgroupid},#{battIndexInFbs},#{discharge_starttime},#{discharge_state},#{discharge_reason}" + |
| | | ",#{discharge_cleartype},#{preset_time},#{preset_cap} ,#{preset_monvol},#{preset_groupvol},#{preset_curr}" + |
| | | ",#{preset_mon},#{dcvolhighlimit},#{chargecurrset} ,#{plan_circle},#{plan_rate})") |
| | | public int addPro(BattDischarge_plan obj); |
| | | |
| | | |
| | | // @Update("update web_site.tb_battdischarge_plan set battgroupid=#{battgroupid},battIndexInFbs=#{battIndexInFbs},discharge_starttime=#{discharge_starttime},discharge_stoptime=#{discharge_stoptime}," + |
| | |
| | | "preset_monvol=#{preset_monvol},preset_groupvol=#{preset_groupvol},preset_curr=#{preset_curr},preset_mon=#{preset_mon},dcvolhighlimit=#{dcvolhighlimit}," + |
| | | "chargecurrset=#{chargecurrset},note=#{note} where num=#{num}") |
| | | public int update(BattDischarge_plan obj); |
| | | |
| | | |
| | | //8.1批量修改放电计划的开始时间/放电参数的修改/启用计划和取消计划 |
| | | public int updatePro(List<BattDischarge_plan> obj); |
| | | @Update("update web_site.tb_battdischarge_plan set discharge_starttime=#{discharge_starttime},discharge_cleartype=#{discharge_cleartype}," + |
| | | "discharge_reason=#{discharge_reason},discharge_state=#{discharge_state},preset_time=#{preset_time},preset_cap=#{preset_cap}," + |
| | | "preset_monvol=#{preset_monvol},preset_groupvol=#{preset_groupvol},preset_curr=#{preset_curr},preset_mon=#{preset_mon}," + |
| | | "dcvolhighlimit=#{dcvolhighlimit},chargecurrset=#{chargecurrset} ,plan_circle=#{plan_circle},plan_rate=#{plan_rate} " + |
| | | "where battgroupid=#{battgroupid} and num=#{num}") |
| | | public int updatePro(BattDischarge_plan obj); |
| | | |
| | | @Delete("delete from web_site.tb_battdischarge_plan where num=#{num} ") |
| | | public int del(BattDischarge_plan obj); |
| | |
| | | @Resource |
| | | private BattDischarge_paramMapper mapper;; |
| | | |
| | | ServiceModel model = new ServiceModel(); |
| | | |
| | | //8.1添加新的参数 |
| | | public ServiceModel add(BattDischarge_param obj){ |
| | | ServiceModel model = new ServiceModel(); |
| | | Boolean bl=mapper.add(obj); |
| | | if(bl){ |
| | | model.setCode(1); |
| | |
| | | } |
| | | //8.1修改参数信息 |
| | | public ServiceModel update(BattDischarge_param obj){ |
| | | ServiceModel model = new ServiceModel(); |
| | | Boolean bl=mapper.update(obj); |
| | | if(bl){ |
| | | model.setCode(1); |
| | |
| | | return model; |
| | | } |
| | | public ServiceModel del(BattDischarge_param obj){ |
| | | ServiceModel model = new ServiceModel(); |
| | | Boolean bl=mapper.del(obj); |
| | | if(bl){ |
| | | model.setCode(1); |
| | |
| | | } |
| | | //8.1查询所有的参数 |
| | | public ServiceModel searchAll(){ |
| | | ServiceModel model = new ServiceModel(); |
| | | List<BattDischarge_param> list=mapper.searchAll(); |
| | | if(list!=null&&list.size()>0){ |
| | | model.setCode(1); |
| | |
| | | } |
| | | return model; |
| | | } |
| | | public ServiceModel serchByCondition(BattDischarge_param obj){ |
| | | List list=mapper.serchByCondition(obj); |
| | | if(list!=null&&list.size()>0){ |
| | | public ServiceModel serchByCondition(BattDischarge_param obj) { |
| | | ServiceModel model = new ServiceModel(); |
| | | List list = mapper.serchByCondition(obj); |
| | | if (list != null && list.size() > 0) { |
| | | model.setCode(1); |
| | | model.setMsg("查询成功!"); |
| | | model.setData(list); |
| | | }else{ |
| | | } else { |
| | | model.setCode(0); |
| | | model.setMsg("查询失败!"); |
| | | } |
| | |
| | | import com.fgkj.mapper.impl.BattDischarge_planMapper; |
| | | import com.fgkj.mapper.impl.BattInfMapper; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.jdbc.datasource.DataSourceTransactionManager; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.TransactionDefinition; |
| | | import org.springframework.transaction.TransactionStatus; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.web.bind.annotation.RequestBody; |
| | | |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | |
| | | |
| | | @Resource |
| | | private User_logService userLogService; |
| | | @Autowired |
| | | DataSourceTransactionManager dataSourceTransactionManager; |
| | | @Autowired |
| | | TransactionDefinition transactionDefinition; |
| | | |
| | | ServiceModel model = new ServiceModel(); |
| | | |
| | |
| | | return model; |
| | | } |
| | | public ServiceModel update(BattDischarge_plan obj){ |
| | | ServiceModel model = new ServiceModel(); |
| | | Boolean bl=mapper.update(obj)>0; |
| | | if(bl){ |
| | | model.setCode(1); |
| | |
| | | return model; |
| | | } |
| | | //8.1批量添加电池计划 |
| | | public ServiceModel addPro(Object obj){ |
| | | Boolean bl=mapper.addPro(obj); |
| | | if(bl){ |
| | | public ServiceModel addPro(@RequestBody List<BattDischarge_plan> list) { |
| | | ServiceModel model = new ServiceModel(); |
| | | TransactionStatus transactionStatus = dataSourceTransactionManager.getTransaction(transactionDefinition); |
| | | Boolean bl = true; |
| | | if (list != null && list.size() > 0) { |
| | | for (int i = 0; i < list.size(); i++) { |
| | | if (!bl)continue; |
| | | BattDischarge_plan bdp = list.get(i); |
| | | try { |
| | | bl = mapper.addPro(bdp) > 0; |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | model.setCode(0); |
| | | model.setMsg("添加失败!"); |
| | | return model; |
| | | } |
| | | String msg = "添加" + bdp.getNote() + "电池组在" + bdp.getDischarge_starttime() + "的放电计划"; |
| | | User_log ulog = UinfDaoFactory.CreateULog(UinfDaoFactory.Increase, msg); |
| | | userLogService.add(ulog); |
| | | } |
| | | }else{ |
| | | bl = false; |
| | | } |
| | | if (bl) { |
| | | dataSourceTransactionManager.commit(transactionStatus); |
| | | model.setCode(1); |
| | | model.setMsg("添加成功!"); |
| | | }else{ |
| | | } else { |
| | | dataSourceTransactionManager.rollback(transactionStatus); |
| | | model.setCode(0); |
| | | model.setMsg("添加失败!"); |
| | | } |
| | | return model; |
| | | } |
| | | //8.1批量修改放电计划的开始时间 |
| | | public ServiceModel updatePro(List<BattDischarge_plan> list){ |
| | | public ServiceModel updatePro(List<BattDischarge_plan> list) { |
| | | ServiceModel model = new ServiceModel(); |
| | | List<User_log> listU=new ArrayList<User_log>();//存放user_log |
| | | List<BattDischarge_plan> listlast= new ArrayList<>(); |
| | | for(int i=0;i<list.size();i++){ |
| | | BattDischarge_plan ddata=list.get(i); |
| | | String formattime = DateUtil.sdf.format(ddata.getDischarge_starttime()); |
| | | list.get(i).setFormattime(formattime); |
| | | { |
| | | String msg="批量修改放电计划的开始时间"+formattime+" "+ddata.getBattgroupid()+"组 "+ddata.getNote()+""; |
| | | User_log ulog= UinfDaoFactory.CreateULog(UinfDaoFactory.Alter, msg); |
| | | listU.add(ulog); |
| | | TransactionStatus transactionStatus = dataSourceTransactionManager.getTransaction(transactionDefinition); |
| | | Boolean bl = true; |
| | | if (list != null && list.size() > 0) { |
| | | for (int i = 0; i < list.size(); i++) { |
| | | if (!bl) continue; |
| | | BattDischarge_plan bdp = list.get(i); |
| | | try { |
| | | bl = mapper.updatePro(bdp) > 0; |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | model.setCode(0); |
| | | model.setMsg("添加失败!"); |
| | | return model; |
| | | } |
| | | { |
| | | String msg = "批量修改放电计划的开始时间" + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(bdp.getDischarge_starttime())+ " " + bdp.getBattgroupid() + "组 " + bdp.getNote(); |
| | | User_log ulog = UinfDaoFactory.CreateULog(UinfDaoFactory.Alter, msg); |
| | | userLogService.add(ulog); |
| | | } |
| | | } |
| | | }else{ |
| | | bl = false; |
| | | } |
| | | System.out.println("list = " + list); |
| | | Boolean bl = mapper.updatePro(list)>0; |
| | | userLogService.addPro(listU);//将用户的操作记录下来 |
| | | if(bl){ |
| | | if (bl) { |
| | | dataSourceTransactionManager.commit(transactionStatus); |
| | | model.setCode(1); |
| | | model.setMsg("修改成功!"); |
| | | }else{ |
| | | } else { |
| | | dataSourceTransactionManager.rollback(transactionStatus); |
| | | model.setCode(0); |
| | | model.setMsg("修改失败!"); |
| | | } |
| | |
| | | --> |
| | | |
| | | <!-- <insert id="add"></insert>--> |
| | | <insert id="addPro"></insert> |
| | | <!-- <insert id="addPro"></insert>--> |
| | | <!-- <update id="update"></update>--> |
| | | <update id="updatePro"> |
| | | <!-- <update id="updatePro"> |
| | | <foreach collection="list" item="item" separator=";"> |
| | | update web_site.tb_battdischarge_plan set discharge_starttime=#{item.formattime},discharge_cleartype=#{item.discharge_cleartype}, |
| | | discharge_reason=#{item.discharge_reason},discharge_state=#{item.discharge_state},preset_time=#{item.preset_time}, |
| | |
| | | plan_circle=#{item.plan_circle},plan_rate=#{item.plan_rate} |
| | | where battgroupid=#{item.battgroupid} and num=#{item.num} |
| | | </foreach> |
| | | </update> |
| | | </update>--> |
| | | <!-- <delete id="del"></delete>--> |
| | | <select id="judgePlan" resultType="java.lang.Integer"></select> |
| | | <!-- <select id="searchAll" resultType="java.util.List"></select>--> |