Commit 054de3d0dbf63bc3de1fd1d8f1feae4f129c913a
1 parent
edfbda52
1.加入工时获取接口
Showing
3 changed files
with
116 additions
and
0 deletions
src/main/java/com/bsth/entity/ManHours.java
0 → 100644
| 1 | +package com.bsth.entity; | |
| 2 | + | |
| 3 | +/** | |
| 4 | + * | |
| 5 | + * @author Hill | |
| 6 | + */ | |
| 7 | +public class ManHours { | |
| 8 | + | |
| 9 | + private String xlBm; | |
| 10 | + | |
| 11 | + private String lpName; | |
| 12 | + | |
| 13 | + private Float manHours; | |
| 14 | + | |
| 15 | + public String getXlBm() { | |
| 16 | + return xlBm; | |
| 17 | + } | |
| 18 | + | |
| 19 | + public void setXlBm(String xlBm) { | |
| 20 | + this.xlBm = xlBm; | |
| 21 | + } | |
| 22 | + | |
| 23 | + public String getLpName() { | |
| 24 | + return lpName; | |
| 25 | + } | |
| 26 | + | |
| 27 | + public void setLpName(String lpName) { | |
| 28 | + this.lpName = lpName; | |
| 29 | + } | |
| 30 | + | |
| 31 | + public Float getManHours() { | |
| 32 | + return manHours; | |
| 33 | + } | |
| 34 | + | |
| 35 | + public void setManHours(Float manHours) { | |
| 36 | + this.manHours = manHours; | |
| 37 | + } | |
| 38 | +} | ... | ... |
src/main/java/com/bsth/server_rs/man_hours/ManHoursRefreshScheduler.java
0 → 100644
| 1 | +package com.bsth.server_rs.man_hours; | |
| 2 | + | |
| 3 | +import com.bsth.entity.ManHours; | |
| 4 | +import org.joda.time.DateTime; | |
| 5 | +import org.springframework.beans.factory.annotation.Autowired; | |
| 6 | +import org.springframework.jdbc.core.BeanPropertyRowMapper; | |
| 7 | +import org.springframework.jdbc.core.JdbcTemplate; | |
| 8 | +import org.springframework.scheduling.annotation.EnableScheduling; | |
| 9 | +import org.springframework.scheduling.annotation.Scheduled; | |
| 10 | +import org.springframework.stereotype.Component; | |
| 11 | + | |
| 12 | +import java.util.HashMap; | |
| 13 | +import java.util.List; | |
| 14 | +import java.util.Map; | |
| 15 | + | |
| 16 | +/** | |
| 17 | + * @author Hill | |
| 18 | + */ | |
| 19 | +@Component | |
| 20 | +@EnableScheduling | |
| 21 | +public class ManHoursRefreshScheduler { | |
| 22 | + | |
| 23 | + @Autowired | |
| 24 | + private JdbcTemplate jdbcTemplate; | |
| 25 | + | |
| 26 | + @Autowired | |
| 27 | + private ManHoursRestService manHoursRestService; | |
| 28 | + | |
| 29 | + @Scheduled(cron = "0 0/25 3 * * ?") | |
| 30 | + public void refresh() { | |
| 31 | + Map<String, Float> linelp2mh = new HashMap<>(); | |
| 32 | + DateTime dateTime = DateTime.now().withTime(0,0,0,0); | |
| 33 | + List<ManHours> manHoursList = jdbcTemplate.query("select d.xl xl_bm,d.lp,d.gs man_hours,e.lp_name from (SELECT DISTINCT c.xl,c.lp,c.gs FROM `bsth_c_s_sp_info` a join bsth_c_s_ttinfo b on a.tt_info = b.id join bsth_c_s_ttinfo_bx_detail c on b.id = c.ttinfo where a.schedule_date = FROM_UNIXTIME(?)) d join bsth_c_s_gbi e on d.lp = e.id",new Object[]{ dateTime.getMillis() / 1000 }, BeanPropertyRowMapper.newInstance(ManHours.class)); | |
| 34 | + for (ManHours manHours : manHoursList) { | |
| 35 | + linelp2mh.put(String.format("%s_%s", manHours.getXlBm(), manHours.getLpName()), manHours.getManHours()); | |
| 36 | + } | |
| 37 | + manHoursRestService.setLinelp2mh(linelp2mh); | |
| 38 | + } | |
| 39 | +} | ... | ... |
src/main/java/com/bsth/server_rs/man_hours/ManHoursRestService.java
0 → 100644
| 1 | +package com.bsth.server_rs.man_hours; | |
| 2 | + | |
| 3 | +import com.bsth.entity.WhiteIp; | |
| 4 | +import org.springframework.beans.factory.annotation.Autowired; | |
| 5 | +import org.springframework.jdbc.core.BeanPropertyRowMapper; | |
| 6 | +import org.springframework.jdbc.core.JdbcTemplate; | |
| 7 | +import org.springframework.stereotype.Component; | |
| 8 | +import org.springframework.web.bind.annotation.PathVariable; | |
| 9 | + | |
| 10 | +import javax.ws.rs.GET; | |
| 11 | +import javax.ws.rs.Path; | |
| 12 | +import javax.ws.rs.PathParam; | |
| 13 | +import javax.ws.rs.Produces; | |
| 14 | +import javax.ws.rs.core.MediaType; | |
| 15 | +import java.util.HashMap; | |
| 16 | +import java.util.List; | |
| 17 | +import java.util.Map; | |
| 18 | + | |
| 19 | +/** | |
| 20 | + * @author hill | |
| 21 | + * @date | |
| 22 | + */ | |
| 23 | +@Component | |
| 24 | +@Path("/manHours") | |
| 25 | +@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) | |
| 26 | +public class ManHoursRestService { | |
| 27 | + | |
| 28 | + private Map<String, Float> linelp2mh = new HashMap<>(); | |
| 29 | + | |
| 30 | + @GET | |
| 31 | + @Path("/{xlBm}/{lpName}") | |
| 32 | + public Float manHours(@PathParam("xlBm") String xlBm, @PathParam("lpName") String lpName) { | |
| 33 | + return linelp2mh.get(String.format("%s_%s", xlBm, lpName)); | |
| 34 | + } | |
| 35 | + | |
| 36 | + public void setLinelp2mh(Map<String, Float> linelp2mh) { | |
| 37 | + this.linelp2mh = linelp2mh; | |
| 38 | + } | |
| 39 | +} | ... | ... |