| | |
| | | </properties> |
| | | |
| | | <dependencies> |
| | | <dependency> |
| | | <groupId>org.springframework.boot</groupId> |
| | | <artifactId>spring-boot-devtools</artifactId> |
| | | <optional>true</optional> |
| | | </dependency> |
| | | |
| | | <dependency> |
| | | <groupId>org.springframework.boot</groupId> |
| | |
| | | <artifactId>commons-lang3</artifactId> |
| | | <version>3.9</version> |
| | | </dependency> |
| | | |
| | | <dependency> |
| | | <groupId>org.apache.poi</groupId> |
| | | <artifactId>poi</artifactId> |
| | | <version>4.0.1</version> |
| | | </dependency> |
| | | <!-- 处理Excel2007--> |
| | | <dependency> |
| | | <groupId>org.apache.poi</groupId> |
| | | <artifactId>poi-ooxml</artifactId> |
| | | <version>4.0.1</version> |
| | | </dependency> |
| | | |
| | | |
| | | <!-- swagger --> |
| | | <dependency> |
| | | <groupId>io.springfox</groupId> |
| | |
| | | </dependencies> |
| | | |
| | | <build> |
| | | <!--<resources>--> |
| | | <!--<resource>--> |
| | | <!--<directory>src/main/resources</directory>--> |
| | | <!--<includes>--> |
| | | <!--<include>**/*.xlsx</include>--> |
| | | <!--<include>**/*.yml</include>--> |
| | | <!--</includes>--> |
| | | <!--</resource>--> |
| | | <!--</resources>--> |
| | | <plugins> |
| | | <plugin> |
| | | <groupId>org.springframework.boot</groupId> |
| | |
| | | import org.mybatis.spring.annotation.MapperScan; |
| | | import org.springframework.boot.SpringApplication; |
| | | import org.springframework.boot.autoconfigure.SpringBootApplication; |
| | | import org.springframework.scheduling.annotation.EnableScheduling; |
| | | import springfox.documentation.swagger2.annotations.EnableSwagger2; |
| | | |
| | | @SpringBootApplication |
| | | @EnableSwagger2 |
| | | @EnableScheduling |
| | | @MapperScan(value = "com.highdatas.srs.mapper") |
| | | public class SrsApplication { |
| | | |
New file |
| | |
| | | package com.highdatas.srs.entity;
|
| | |
|
| | | public interface InfoSurface {
|
| | | void dataInsertOrUpdate();
|
| | | String getId();
|
| | | }
|
New file |
| | |
| | | package com.highdatas.srs.entity;
|
| | |
|
| | | import lombok.Data;
|
| | |
|
| | | import java.math.BigDecimal;
|
| | |
|
| | | /**
|
| | | * @author kimi
|
| | | * @description
|
| | | * @date 2020-04-24 13:08
|
| | | */
|
| | |
|
| | | @Data
|
| | | public class PersionGroupEntity {
|
| | | private String finishCnt;
|
| | | private String unFinishCnt;
|
| | | private BigDecimal finishMoney;
|
| | | private BigDecimal unFinishMoney;
|
| | |
|
| | | }
|
| | |
| | | import com.baomidou.mybatisplus.annotations.TableName; |
| | | |
| | | import java.io.Serializable; |
| | | import java.math.BigDecimal; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | private String id; |
| | | |
| | | private String name; |
| | | private String code; |
| | | private String type; |
| | | @TableField("lead_user_id") |
| | | private String leadUserId; |
| | | |
| | | @TableField("reseach_type") |
| | | private String reseachType; |
| | | @TableField("order_type") |
| | | private String orderType; |
| | | |
| | | private String desp; |
| | | private String desc; |
| | | private BigDecimal budget; |
| | | @TableField("pay_money") |
| | | private BigDecimal payMoney; |
| | | |
| | | @TableField("start_time") |
| | | private Date startTime; |
| | | |
| | | @TableField("user_id") |
| | | private String userId; |
| | | @TableField("charge_id") |
| | | private String chargeId; |
| | | |
| | | @TableField("end_time") |
| | | private Date endTime; |
| | |
| | | private Date createTime; |
| | | |
| | | private String status; |
| | | private String attachment; |
| | | |
| | | private transient List<List<String>> leadUserList; |
| | | |
| | | |
| | | public BigDecimal getPayMoney() { |
| | | return payMoney; |
| | | } |
| | | |
| | | public Scheme setPayMoney(BigDecimal payMoney) { |
| | | this.payMoney = payMoney; |
| | | return this; |
| | | } |
| | | |
| | | public String getType() { |
| | | return type; |
| | | } |
| | | |
| | | public Scheme setType(String type) { |
| | | this.type = type; |
| | | return this; |
| | | } |
| | | |
| | | public String getOrderType() { |
| | | return orderType; |
| | | } |
| | | |
| | | public Scheme setOrderType(String orderType) { |
| | | this.orderType = orderType; |
| | | return this; |
| | | } |
| | | |
| | | public String getChargeId() { |
| | | return chargeId; |
| | | } |
| | | |
| | | public String getCode() { |
| | | return code; |
| | | } |
| | | |
| | | public Scheme setCode(String code) { |
| | | this.code = code; |
| | | return this; |
| | | } |
| | | |
| | | public Scheme setChargeId(String chargeId) { |
| | | this.chargeId = chargeId; |
| | | return this; |
| | | } |
| | | |
| | | public BigDecimal getBudget() { |
| | | return budget; |
| | | } |
| | | |
| | | public Scheme setBudget(BigDecimal budget) { |
| | | this.budget = budget; |
| | | return this; |
| | | } |
| | | |
| | | public String getAttachment() { |
| | | return attachment; |
| | | } |
| | | |
| | | public void setAttachment(String attachment) { |
| | | this.attachment = attachment; |
| | | } |
| | | |
| | | |
| | | public List<List<String>> getLeadUserList() { |
| | | return leadUserList; |
| | | } |
| | | |
| | | public void setLeadUserList(List<List<String>> leadUserList) { |
| | | this.leadUserList = leadUserList; |
| | | } |
| | | |
| | | public String getLeadUserId() { |
| | | return leadUserId; |
| | | } |
| | | |
| | | public Scheme setLeadUserId(String leadUserId) { |
| | | this.leadUserId = leadUserId; |
| | | return this; |
| | | } |
| | | |
| | | public String getStatus() { |
| | | return status; |
| | |
| | | this.reseachType = reseachType; |
| | | return this; |
| | | } |
| | | public String getDesp() { |
| | | return desp; |
| | | public String getDesc() { |
| | | return desc; |
| | | } |
| | | |
| | | public Scheme setDesp(String desp) { |
| | | this.desp = desp; |
| | | public Scheme setDesc(String desp) { |
| | | this.desc = desp; |
| | | return this; |
| | | } |
| | | public Date getStartTime() { |
| | |
| | | "id=" + id + |
| | | ", name=" + name + |
| | | ", reseachType=" + reseachType + |
| | | ", desp=" + desp + |
| | | ", desp=" + desc + |
| | | ", startTime=" + startTime + |
| | | ", endTime=" + endTime + |
| | | ", createTime=" + createTime + |
| | |
| | | package com.highdatas.srs.entity; |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.activerecord.Model; |
| | | import com.baomidou.mybatisplus.annotations.TableField; |
| | | import com.baomidou.mybatisplus.annotations.TableName; |
| | |
| | | import java.io.Serializable; |
| | | import java.math.BigDecimal; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | private String id; |
| | | private String remark; |
| | | private String language; |
| | | @TableField("parttime_user") |
| | | private String parttimeUser; |
| | | @TableField(exist = false) |
| | | private String typeStr; |
| | | |
| | |
| | | private String detailInfoId; |
| | | |
| | | private BigDecimal budget; |
| | | private BigDecimal payment; |
| | | |
| | | @TableField("service_payment") |
| | | private BigDecimal servicePayment; |
| | | @TableField("real_payment") |
| | | private BigDecimal realPayment; |
| | | |
| | | |
| | | private String attachment; |
| | | @TableField("title_type") |
| | | private String titleType; |
| | | |
| | | @TableField("title_input") |
| | | private String titleInput; |
| | | |
| | | @TableField("must_attach") |
| | | private Boolean mustAttach; |
| | |
| | | private Boolean finish; |
| | | private Boolean edit; |
| | | private Boolean delay; |
| | | private Boolean parttime; |
| | | |
| | | @TableField("create_time") |
| | | private Date createTime; |
| | |
| | | @TableField("finish_time") |
| | | private Date finishTime; |
| | | |
| | | private transient JSONObject existsObject; |
| | | private transient List<SchemeDetailParttime> parttimeList; |
| | | private transient String schemeName; |
| | | |
| | | public String getSchemeName() { |
| | | return schemeName; |
| | | } |
| | | |
| | | public void setSchemeName(String schemeName) { |
| | | this.schemeName = schemeName; |
| | | } |
| | | |
| | | public JSONObject getExistsObject() { |
| | | return existsObject; |
| | | } |
| | | |
| | | public SchemeDetail setExistsObject(JSONObject existsObject) { |
| | | this.existsObject = existsObject; |
| | | return this; |
| | | } |
| | | |
| | | public List<SchemeDetailParttime> getParttimeList() { |
| | | return parttimeList; |
| | | } |
| | | |
| | | public void setParttimeList(List<SchemeDetailParttime> parttimeList) { |
| | | this.parttimeList = parttimeList; |
| | | } |
| | | |
| | | public String getTitleType() { |
| | | return titleType; |
| | | } |
| | | |
| | | public SchemeDetail setTitleType(String titleType) { |
| | | this.titleType = titleType; |
| | | return this; |
| | | } |
| | | |
| | | public String getTitleInput() { |
| | | return titleInput; |
| | | } |
| | | |
| | | public SchemeDetail setTitleInput(String titleInput) { |
| | | this.titleInput = titleInput; |
| | | return this; |
| | | } |
| | | |
| | | public BigDecimal getServicePayment() { |
| | | return servicePayment; |
| | | } |
| | | |
| | | public SchemeDetail setServicePayment(BigDecimal servicePayment) { |
| | | this.servicePayment = servicePayment; |
| | | return this; |
| | | } |
| | | |
| | | public BigDecimal getRealPayment() { |
| | | return realPayment; |
| | | } |
| | | |
| | | public SchemeDetail setRealPayment(BigDecimal realPayment) { |
| | | this.realPayment = realPayment; |
| | | return this; |
| | | } |
| | | |
| | | public BigDecimal getPayment() { |
| | | return payment; |
| | | } |
| | | |
| | | public SchemeDetail setPayment(BigDecimal payment) { |
| | | this.payment = payment; |
| | | return this; |
| | | |
| | | } |
| | | |
| | | public String getLanguage() { |
| | | return language; |
| | | } |
| | | |
| | | public SchemeDetail setLanguage(String language) { |
| | | this.language = language; |
| | | return this; |
| | | } |
| | | |
| | | public String getParttimeUser() { |
| | | return parttimeUser; |
| | | } |
| | | |
| | | public SchemeDetail setParttimeUser(String parttimeUser) { |
| | | this.parttimeUser = parttimeUser; |
| | | return this; |
| | | } |
| | | |
| | | public Boolean getParttime() { |
| | | return parttime; |
| | | } |
| | | |
| | | public SchemeDetail setParttime(Boolean parttime) { |
| | | this.parttime = parttime; |
| | | return this; |
| | | } |
| | | |
| | | public Date getFinishTime() { |
| | | return finishTime; |
| | | } |
| | |
| | | return this; |
| | | } |
| | | |
| | | public String getRemark() { |
| | | return remark; |
| | | } |
| | | |
| | | public void setRemark(String remark) { |
| | | this.remark = remark; |
| | | } |
| | | |
| | | public Boolean getEdit() { |
| | | return edit; |
| | | } |
| | |
| | | import com.highdatas.srs.util.Constant; |
| | | |
| | | public enum SchemeDetailType { |
| | | title, |
| | | analyse, |
| | | arrange, |
| | | compose, |
| | | Contribute, |
| | | evaluation, |
| | | find, |
| | | format, |
| | | get, |
| | | grade, |
| | | properties, |
| | | scheme, |
| | | search, |
| | | select, |
| | | get, |
| | | find, |
| | | properties, |
| | | risk, |
| | | target, |
| | | propertiesArrangement, |
| | | riskChart, |
| | | meta, |
| | | grade, |
| | | tsa, |
| | | compose, |
| | | translate, |
| | | evaluation, |
| | | recommend, |
| | | format, |
| | | Contribute; |
| | | |
| | | select, |
| | | title, |
| | | translate; |
| | | |
| | | public String covert() { |
| | | return Constant.schemeDetailTypes.get(this); |
| | |
| | | private String orgid; |
| | | |
| | | private String employeeid; |
| | | private transient String roleName; |
| | | |
| | | public String getRoleName() { |
| | | return roleName; |
| | | } |
| | | |
| | | public void setRoleName(String roleName) { |
| | | this.roleName = roleName; |
| | | } |
| | | |
| | | public String getLoginName() { |
| | | return loginName; |
| | |
| | | |
| | | private String id; |
| | | |
| | | private String title; |
| | | |
| | | private String desp; |
| | | |
| | | @TableField("user_id") |
| | | private String userId; |
| | | @TableField("title_status") |
| | | private Boolean titleStatus; |
| | | |
| | | @TableField("link_id") |
| | | private String linkId; |
| | | @TableField("title_id") |
| | | private String titleId; |
| | | |
| | | private String attachment; |
| | | private Boolean examine; |
| | | private transient TitleService titleService; |
| | | |
| | | public Boolean getTitleStatus() { |
| | | return titleStatus; |
| | | } |
| | | |
| | | public Topic setTitleStatus(boolean titleStatus) { |
| | | this.titleStatus = titleStatus; |
| | | return this; |
| | | } |
| | | |
| | | public TitleService getTitleService() { |
| | | return titleService; |
| | | } |
| | | |
| | | public void setTitleService(TitleService titleService) { |
| | | this.titleService = titleService; |
| | | } |
| | | |
| | | public String getTitleId() { |
| | | return titleId; |
| | | } |
| | | |
| | | public Topic setTitleId(String titleId) { |
| | | this.titleId = titleId; |
| | | return this; |
| | | } |
| | | |
| | | @TableField("create_time") |
| | | private Date createTime; |
| | |
| | | return this; |
| | | } |
| | | |
| | | public String getTitle() { |
| | | return title; |
| | | } |
| | | |
| | | public Topic setTitle(String title) { |
| | | this.title = title; |
| | | return this; |
| | | } |
| | | |
| | | public String getId() { |
| | | return id; |
| | |
| | | return this; |
| | | } |
| | | |
| | | public String getDesp() { |
| | | return desp; |
| | | } |
| | | |
| | | public Topic setDesp(String desp) { |
| | | this.desp = desp; |
| | | return this; |
| | | } |
| | | public String getUserId() { |
| | | return userId; |
| | | } |
| | |
| | | public String toString() { |
| | | return "Topic{" + |
| | | "id=" + id + |
| | | ", title=" + title + |
| | | ", createTime=" + createTime + |
| | | ", desp=" + desp + |
| | | ", userId=" + userId + |
| | | ", attachment=" + attachment + |
| | | "}"; |
| | |
| | | public interface SysRoleMapper extends BaseMapper<SysRole> { |
| | | |
| | | List<Map<String, Object>> findByDepart(@Param("departId") String departId); |
| | | List<Map<String, Object>> all(); |
| | | |
| | | Long selectTopicCnt(@Param("where") String where); |
| | | List<Map<String, Object>> selectTopic(@Param("where") String where,@Param("orderby") String orderby,@Param("limit") String limit); |
| | | Map<String, Object> selectTableById(@Param("tableName") String tableName,@Param("id") String id); |
| | | Map<String, Object> login(@Param("loginName") String loginName,@Param("password") String password); |
| | | } |
| | |
| | | public static CodeMsg USER_NOT_MATHED = new CodeMsg(1010,"找不到登陆用户"); |
| | | public static CodeMsg ERROR_ACTIVITI_NEXTTASK = new CodeMsg(1011,"审批流出现错误,未获取到下一节点"); |
| | | public static CodeMsg OPERATR_ERROR = new CodeMsg(2001,"操作失败"); |
| | | public static CodeMsg UNWORKING_ERROR = new CodeMsg(2003,"当前项目未启用"); |
| | | public static CodeMsg EXISTSCODE_ERROR = new CodeMsg(2004,"code已存在"); |
| | | public static CodeMsg Money_Check_ERROR = new CodeMsg(2005,"当前款项已确认"); |
| | | |
| | | public CodeMsg(int code, String msg) { |
| | | this.code = code; |
New file |
| | |
| | | package com.highdatas.srs.pojo;
|
| | |
|
| | | import lombok.Data;
|
| | |
|
| | | /**
|
| | | * @author kimi
|
| | | * @description
|
| | | * @date 2020-05-26 14:56
|
| | | */
|
| | |
|
| | | @Data
|
| | | public class SchemeDetailCountEntity {
|
| | | private Integer totalCnt;
|
| | | private Integer delayCnt;
|
| | | private Integer runtimeCnt;
|
| | | }
|
| | |
| | | */ |
| | | public interface ISchemeService extends IService<Scheme> { |
| | | |
| | | Scheme refreshBudget(String parentId); |
| | | |
| | | Scheme refreshCheckMoney(String parentId); |
| | | } |
| | |
| | | package com.highdatas.srs.service.impl; |
| | | |
| | | import com.highdatas.srs.entity.Scheme; |
| | | import com.highdatas.srs.mapper.SchemeMapper; |
| | | import com.highdatas.srs.service.ISchemeService; |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.baomidou.mybatisplus.service.impl.ServiceImpl; |
| | | import com.highdatas.srs.entity.Scheme; |
| | | import com.highdatas.srs.entity.SchemeBill; |
| | | import com.highdatas.srs.mapper.SchemeMapper; |
| | | import com.highdatas.srs.service.ISchemeBillService; |
| | | import com.highdatas.srs.service.ISchemeService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | */ |
| | | @Service |
| | | public class SchemeServiceImpl extends ServiceImpl<SchemeMapper, Scheme> implements ISchemeService { |
| | | @Autowired |
| | | ISchemeBillService billService; |
| | | @Override |
| | | public Scheme refreshBudget(String schemeId) { |
| | | Scheme scheme = selectById(schemeId); |
| | | if (scheme == null) { |
| | | return null; |
| | | } |
| | | BigDecimal decimal = new BigDecimal(0); |
| | | List<SchemeBill> parent_id = billService.selectList(new EntityWrapper<SchemeBill>().eq("parent_id", schemeId)); |
| | | if (parent_id != null) { |
| | | for (SchemeBill schemeBill : parent_id) { |
| | | BigDecimal money = schemeBill.getMoney(); |
| | | if (money != null) { |
| | | decimal = decimal.add(money); |
| | | } |
| | | } |
| | | scheme.setBudget(decimal).updateById(); |
| | | } |
| | | return scheme; |
| | | } |
| | | |
| | | @Override |
| | | public Scheme refreshCheckMoney(String schemeId) { |
| | | Scheme scheme = selectById(schemeId); |
| | | if (scheme == null) { |
| | | return null; |
| | | } |
| | | BigDecimal decimal = new BigDecimal(0); |
| | | List<SchemeBill> parent_id = billService.selectList(new EntityWrapper<SchemeBill>().eq("parent_id", schemeId)); |
| | | if (parent_id != null) { |
| | | for (SchemeBill schemeBill : parent_id) { |
| | | BigDecimal money = schemeBill.getMoney(); |
| | | Boolean checked = schemeBill.getChecked(); |
| | | if (money != null && checked != null && checked) { |
| | | decimal = decimal.add(money); |
| | | } |
| | | } |
| | | scheme.setPayMoney(decimal).updateById(); |
| | | } |
| | | return scheme; |
| | | } |
| | | } |
| | |
| | | import com.highdatas.srs.entity.SchemeDetail;
|
| | | import com.highdatas.srs.service.ISchemeDetailService;
|
| | | import com.highdatas.srs.service.ISchemeService;
|
| | | import lombok.extern.slf4j.Slf4j;
|
| | | import org.springframework.beans.factory.annotation.Autowired;
|
| | | import org.springframework.scheduling.annotation.EnableScheduling;
|
| | | import org.springframework.scheduling.annotation.Scheduled;
|
| | | import org.springframework.stereotype.Component;
|
| | |
|
| | | import java.util.Date;
|
| | | import java.util.HashSet;
|
| | |
| | | * @date 2020-02-12 10:40
|
| | | */
|
| | |
|
| | | @EnableScheduling
|
| | | @Component
|
| | | @Slf4j
|
| | | public class DelayTimeTask {
|
| | | @Autowired
|
| | | ISchemeService schemeService;
|
| | | @Autowired
|
| | | ISchemeDetailService schemeDetailService;
|
| | |
|
| | | @Scheduled(cron = "0 0 0 1/1 * ?")
|
| | | @Scheduled(cron = "0 0 1 1/1 * ?")
|
| | | private void delayTask(){
|
| | | log.info("start 定时任务");
|
| | | Date date = new Date();
|
| | | List<SchemeDetail> schemeDetailList = schemeDetailService.selectList(new EntityWrapper<SchemeDetail>().lt("end_time", date).eq("edit", false));
|
| | | List<SchemeDetail> schemeDetailList = schemeDetailService.selectList(new EntityWrapper<SchemeDetail>().lt("end_time", date).eq("edit", false).eq("finish", false));
|
| | | HashSet<String> parentIdSet = new HashSet<>();
|
| | | for (SchemeDetail detail : schemeDetailList) {
|
| | | parentIdSet.add(detail.getParentId());
|
| | |
| | | |
| | | public static HashMap<SchemeDetailType, String> schemeDetailTypes = new HashMap(); |
| | | static { |
| | | schemeDetailTypes.put(SchemeDetailType.title,"立题服务"); |
| | | schemeDetailTypes.put(SchemeDetailType.scheme,"方案开发服务"); |
| | | schemeDetailTypes.put(SchemeDetailType.analyse,"数据分析"); |
| | | schemeDetailTypes.put(SchemeDetailType.arrange,"数据整理与录入"); |
| | | schemeDetailTypes.put(SchemeDetailType.compose,"文稿撰写"); |
| | | schemeDetailTypes.put(SchemeDetailType.Contribute,"网上投稿"); |
| | | schemeDetailTypes.put(SchemeDetailType.evaluation,"文稿评估"); |
| | | |
| | | schemeDetailTypes.put(SchemeDetailType.find,"全文筛查"); |
| | | schemeDetailTypes.put(SchemeDetailType.get,"全文获取"); |
| | | schemeDetailTypes.put(SchemeDetailType.format,"文稿格式修改"); |
| | | |
| | | schemeDetailTypes.put(SchemeDetailType.properties,"定性信息"); |
| | | schemeDetailTypes.put(SchemeDetailType.grade,"GRADE证据质量评价"); |
| | | schemeDetailTypes.put(SchemeDetailType.recommend,"杂志推荐"); |
| | | schemeDetailTypes.put(SchemeDetailType.scheme,"方案开发"); |
| | | schemeDetailTypes.put(SchemeDetailType.search,"文献检索"); |
| | | schemeDetailTypes.put(SchemeDetailType.select,"文献初筛"); |
| | | schemeDetailTypes.put(SchemeDetailType.get,"全文获取"); |
| | | schemeDetailTypes.put(SchemeDetailType.find,"全文筛查"); |
| | | schemeDetailTypes.put(SchemeDetailType.properties,"定性信息"); |
| | | schemeDetailTypes.put(SchemeDetailType.risk,"风险偏倚信息"); |
| | | schemeDetailTypes.put(SchemeDetailType.target,"结局指标数据"); |
| | | schemeDetailTypes.put(SchemeDetailType.propertiesArrangement,"定性信息整理总结"); |
| | | schemeDetailTypes.put(SchemeDetailType.riskChart,"风险偏倚图表制作"); |
| | | schemeDetailTypes.put(SchemeDetailType.meta,"Meta分析"); |
| | | schemeDetailTypes.put(SchemeDetailType.grade,"GRADE证据质量评价"); |
| | | schemeDetailTypes.put(SchemeDetailType.tsa,"TSA分析"); |
| | | schemeDetailTypes.put(SchemeDetailType.compose,"文稿撰写"); |
| | | schemeDetailTypes.put(SchemeDetailType.title,"立题服务"); |
| | | schemeDetailTypes.put(SchemeDetailType.translate,"语言翻译及润色"); |
| | | schemeDetailTypes.put(SchemeDetailType.evaluation,"文稿评估"); |
| | | schemeDetailTypes.put(SchemeDetailType.recommend,"杂志推荐"); |
| | | schemeDetailTypes.put(SchemeDetailType.format,"文稿格式修改"); |
| | | schemeDetailTypes.put(SchemeDetailType.Contribute,"网上投稿"); |
| | | |
| | | |
| | | } |
| | | public static HashMap<SchemeDetailType, String> schemeDetailParentTypes = new HashMap(); |
| | | static { |
| | | schemeDetailParentTypes.put(SchemeDetailType.title,"立案与方案开发"); |
| | | schemeDetailParentTypes.put(SchemeDetailType.scheme,"立案与方案开发"); |
| | | schemeDetailParentTypes.put(SchemeDetailType.search,"文献检索与筛选"); |
| | | schemeDetailParentTypes.put(SchemeDetailType.select,"文献检索与筛选"); |
| | | schemeDetailParentTypes.put(SchemeDetailType.get,"文献检索与筛选"); |
| | | schemeDetailParentTypes.put(SchemeDetailType.find,"文献检索与筛选"); |
| | | schemeDetailParentTypes.put(SchemeDetailType.properties,"数据提取"); |
| | | schemeDetailParentTypes.put(SchemeDetailType.risk,"数据提取"); |
| | | schemeDetailParentTypes.put(SchemeDetailType.target," 数据分析"); |
| | | schemeDetailParentTypes.put(SchemeDetailType.propertiesArrangement," 数据分析"); |
| | | schemeDetailParentTypes.put(SchemeDetailType.riskChart," 数据分析"); |
| | | schemeDetailParentTypes.put(SchemeDetailType.meta," 数据分析"); |
| | | schemeDetailParentTypes.put(SchemeDetailType.grade," 数据分析"); |
| | | schemeDetailParentTypes.put(SchemeDetailType.tsa," 数据分析"); |
| | | schemeDetailParentTypes.put(SchemeDetailType.compose,"文稿撰写"); |
| | | schemeDetailParentTypes.put(SchemeDetailType.translate,"文稿撰写"); |
| | | schemeDetailParentTypes.put(SchemeDetailType.evaluation,"文稿撰写"); |
| | | schemeDetailParentTypes.put(SchemeDetailType.recommend,"文稿撰写"); |
| | | schemeDetailParentTypes.put(SchemeDetailType.format,"文稿撰写"); |
| | | schemeDetailParentTypes.put(SchemeDetailType.Contribute,"文稿撰写"); |
| | | schemeDetailTypes.put(SchemeDetailType.analyse,"数据分析"); |
| | | schemeDetailTypes.put(SchemeDetailType.arrange,"数据分析"); |
| | | schemeDetailTypes.put(SchemeDetailType.compose,"文稿撰写"); |
| | | schemeDetailTypes.put(SchemeDetailType.Contribute,"文稿撰写"); |
| | | schemeDetailTypes.put(SchemeDetailType.evaluation,"文稿撰写"); |
| | | |
| | | schemeDetailTypes.put(SchemeDetailType.find,"文献检索与筛查"); |
| | | schemeDetailTypes.put(SchemeDetailType.get,"文稿撰写"); |
| | | schemeDetailTypes.put(SchemeDetailType.format,"文稿撰写"); |
| | | |
| | | schemeDetailTypes.put(SchemeDetailType.properties,"数据提取"); |
| | | schemeDetailTypes.put(SchemeDetailType.grade,"数据分析"); |
| | | schemeDetailTypes.put(SchemeDetailType.recommend,"文稿撰写"); |
| | | schemeDetailTypes.put(SchemeDetailType.scheme,"方案开发"); |
| | | schemeDetailTypes.put(SchemeDetailType.search,"文献检索与筛查"); |
| | | schemeDetailTypes.put(SchemeDetailType.select,"文献检索与筛查"); |
| | | schemeDetailTypes.put(SchemeDetailType.title,"方案开发"); |
| | | schemeDetailTypes.put(SchemeDetailType.translate,"文稿撰写"); |
| | | } |
| | | } |
| | |
| | | import com.fasterxml.jackson.core.JsonProcessingException; |
| | | import com.fasterxml.jackson.databind.DeserializationFeature; |
| | | import com.fasterxml.jackson.databind.ObjectMapper; |
| | | import com.google.common.collect.Maps; |
| | | import com.highdatas.srs.pojo.Segment; |
| | | import com.highdatas.srs.pojo.TableSchemaResult; |
| | | import com.highdatas.srs.service.IModuleService; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.cglib.beans.BeanMap; |
| | | |
| | | import java.lang.reflect.Field; |
| | | import java.lang.reflect.Method; |
| | | import java.text.ParseException; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.Calendar; |
| | | import java.util.Date; |
| | | import java.util.Random; |
| | | import java.util.UUID; |
| | | import java.util.*; |
| | | import java.util.regex.Matcher; |
| | | import java.util.regex.Pattern; |
| | | |
| | | /** |
| | | * @author kimi |
| | |
| | | @Slf4j |
| | | public class DbUtils { |
| | | |
| | | public static IModuleService moduleService; |
| | | |
| | | |
| | | @Autowired |
| | | public void setModuleService (IModuleService moduleService) { |
| | | DbUtils.moduleService = moduleService; |
| | | } |
| | | |
| | | public static String getUUID() { |
| | | String id = UUID.randomUUID().toString().replaceAll("-", ""); |
| | |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | public static String lineToHump(String str) { |
| | | Pattern linePattern = Pattern.compile("_(\\w)"); |
| | | str = str.toLowerCase(); |
| | | Matcher matcher = linePattern.matcher(str); |
| | | StringBuffer sb = new StringBuffer(); |
| | | while (matcher.find()) { |
| | | matcher.appendReplacement(sb, matcher.group(1).toUpperCase()); |
| | | } |
| | | matcher.appendTail(sb); |
| | | return sb.toString(); |
| | | } |
| | | |
| | | public static <T> Map<String, Object> beanToMap(T bean) { |
| | | Map<String, Object> map = Maps.newHashMap(); |
| | | if (bean != null) { |
| | | BeanMap beanMap = BeanMap.create(bean); |
| | | for (Object key : beanMap.keySet()) { |
| | | map.put(key+"", beanMap.get(key)); |
| | | } |
| | | } |
| | | return map; |
| | | } |
| | | public static int getRangeDays(Date startDate, Date endDate, Date rangeStart, Date rangEnd) throws ParseException { |
| | | Date realStart, realEnd; |
| | | if (startDate.before(rangeStart)) { |
| | | realStart = rangeStart; |
| | | } else { |
| | | realStart = startDate; |
| | | } |
| | | if (endDate.before(rangEnd)) { |
| | | realEnd = endDate; |
| | | } else { |
| | | realEnd = rangEnd; |
| | | } |
| | | return getDayDiffer(realStart, realEnd); |
| | | } |
| | | |
| | | public static int getDayDiffer(Date startDate, Date endDate) throws ParseException { |
| | | //判断是否跨年 |
| | | SimpleDateFormat yearFormat = new SimpleDateFormat("yyyy"); |
| | |
| | | package com.highdatas.srs.util; |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | |
| | | import java.io.File; |
| | | import java.io.UnsupportedEncodingException; |
| | |
| | | } |
| | | |
| | | public static String createFile(String basePath,String project, String detail) { |
| | | String path = strJoin(basePath, "/", project,"/" ,detail); |
| | | String path; |
| | | if (StringUtils.isEmpty(detail)) { |
| | | path = strJoin(basePath, "/", project); |
| | | } |
| | | else { |
| | | path = strJoin(basePath, "/", project, "/", detail); |
| | | } |
| | | File dir = new File(path); |
| | | if (!dir.exists()) { |
| | | dir.mkdirs(); |
| | |
| | | // strategy.setCapitalMode(true);// 全局大写命名 ORACLE 注意 |
| | | strategy.setTablePrefix(new String[]{""});// 此处可以修改为您的表前缀 |
| | | strategy.setNaming(NamingStrategy.underline_to_camel);// 表名生成策略 |
| | | strategy.setInclude(new String[]{"sys_department"}); // 需要生成的表 |
| | | strategy.setInclude(new String[]{"sys_target"}); // 需要生成的表 |
| | | // strategy.setExclude(new String[]{"test"}); // 排除生成的表 |
| | | // 自定义实体父类 |
| | | // strategy.setSuperEntityClass("com.baomidou.demo.TestEntity"); |
| | |
| | | package com.highdatas.srs.web; |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.highdatas.srs.entity.ProjectDeal; |
| | | import com.highdatas.srs.entity.Scheme; |
| | | import com.highdatas.srs.entity.SchemeDetail; |
| | | import com.highdatas.srs.entity.Topic; |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.highdatas.srs.entity.*; |
| | | import com.highdatas.srs.pojo.CodeMsg; |
| | | import com.highdatas.srs.pojo.Result; |
| | | import com.highdatas.srs.service.IModuleService; |
| | | import com.highdatas.srs.service.ISchemeDetailService; |
| | | import com.highdatas.srs.service.ISchemeService; |
| | | import com.highdatas.srs.service.ITopicService; |
| | |
| | | import com.highdatas.srs.util.FileUtils; |
| | | import lombok.extern.java.Log; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.apache.poi.ss.usermodel.FillPatternType; |
| | | import org.apache.poi.ss.usermodel.IndexedColors; |
| | | import org.apache.poi.xssf.usermodel.*; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.web.bind.annotation.*; |
| | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.io.*; |
| | | import java.net.URLDecoder; |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.net.URLEncoder; |
| | | import java.text.MessageFormat; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * @author kimi |
| | |
| | | ISchemeService schemeService; |
| | | @Autowired |
| | | ITopicService topicService; |
| | | @Autowired |
| | | IModuleService moduleService; |
| | | |
| | | @Value("${base.file.path}") |
| | | String basePath; |
| | | @Value("${base.topic.path}") |
| | |
| | | ArrayList<JSONObject> childrenFiles = FileUtils.getChildrenFiles(path); |
| | | return Result.success(childrenFiles); |
| | | } |
| | | |
| | | @RequestMapping(value = "downloadPath", method = RequestMethod.GET) |
| | | public Result downloadPath(@RequestParam String path, HttpServletResponse response) throws UnsupportedEncodingException { |
| | | path = URLDecoder.decode(path, "UTF-8"); |
| | | File file = new File(path); |
| | | if(file.exists()){ //判断文件父目录是否存在 |
| | | if (file.exists()) { //判断文件父目录是否存在 |
| | | response.setContentType("application/vnd.ms-excel;charset=UTF-8"); |
| | | response.setCharacterEncoding("UTF-8"); |
| | | // response.setContentType("application/force-download"); |
| | | response.setHeader("Content-Disposition", "attachment;fileName=" + java.net.URLEncoder.encode(file.getName(),"UTF-8")); |
| | | response.setHeader("Content-Disposition", "attachment;fileName=" + java.net.URLEncoder.encode(file.getName(), "UTF-8")); |
| | | byte[] buffer = new byte[1024]; |
| | | FileInputStream fis = null; //文件输入流 |
| | | BufferedInputStream bis = null; |
| | |
| | | fis = new FileInputStream(file); |
| | | bis = new BufferedInputStream(fis); |
| | | int i = bis.read(buffer); |
| | | while(i != -1){ |
| | | while (i != -1) { |
| | | os.write(buffer); |
| | | i = bis.read(buffer); |
| | | } |
| | |
| | | } catch (IOException e) { |
| | | // TODO Auto-generated catch block |
| | | e.printStackTrace(); |
| | | }} |
| | | return null; |
| | | } |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | @RequestMapping("timeline/{schemeId}") |
| | | public void timeline(@PathVariable String schemeId, HttpServletResponse response) { |
| | | Scheme scheme = schemeService.selectById(schemeId); |
| | | if (scheme == null) { |
| | | return; |
| | | } |
| | | String status = scheme.getStatus(); |
| | | if (!status.equalsIgnoreCase("working")) { |
| | | return; |
| | | } |
| | | |
| | | try { |
| | | // 1.读取Excel模板 |
| | | String filePath = "D:/project/template.xlsx"; |
| | | File file = new File(filePath); |
| | | InputStream in = new FileInputStream(file); |
| | | XSSFWorkbook wb = new XSSFWorkbook(in); |
| | | // 2.读取模板里面的所有Sheet |
| | | XSSFSheet sheet = wb.getSheetAt(0); |
| | | // Font dateFont = wb.createFont(); |
| | | // dateFont.setFontName("等线"); |
| | | // dateFont.setFontHeightInPoints((short) 9); |
| | | // XSSFCellStyle dateCellStyle = wb.createCellStyle(); |
| | | // dateCellStyle.setRotation((short) (Math.abs(45))); |
| | | // dateCellStyle.setWrapText(true); |
| | | // dateCellStyle.setFont(dateFont); |
| | | XSSFCellStyle inTimeCellStyle = wb.createCellStyle(); |
| | | inTimeCellStyle.setFillBackgroundColor(IndexedColors.LIGHT_ORANGE.getIndex()); |
| | | inTimeCellStyle.setFillPattern(FillPatternType.THICK_HORZ_BANDS); |
| | | |
| | | XSSFCellStyle finishTimeCellStyle = wb.createCellStyle(); |
| | | finishTimeCellStyle.setFillBackgroundColor(IndexedColors.ORANGE.getIndex()); |
| | | finishTimeCellStyle.setFillPattern(FillPatternType.THICK_FORWARD_DIAG); |
| | | |
| | | |
| | | SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd"); |
| | | |
| | | XSSFRow dateRow = sheet.getRow(1); |
| | | XSSFRow firstRow = sheet.getRow(0); |
| | | XSSFCell planCell = firstRow.getCell(12); |
| | | XSSFCellStyle planStyle = planCell.getCellStyle(); |
| | | XSSFCell planEndCell = firstRow.getCell(17); |
| | | XSSFCell exportCell = firstRow.getCell(23); |
| | | |
| | | XSSFCellStyle exportStyle = exportCell.getCellStyle(); |
| | | XSSFCellStyle cellEndStyle = planEndCell.getCellStyle(); |
| | | XSSFRow titleRow = sheet.getRow(3); |
| | | XSSFRow datesRow = sheet.getRow(2); |
| | | datesRow.setHeightInPoints(60); |
| | | XSSFCell dateCell = datesRow.getCell(12); |
| | | XSSFCellStyle dateCellCellStyle = dateCell.getCellStyle(); |
| | | XSSFRow subTitleRow = sheet.getRow(4); |
| | | XSSFCell subTitleCell = subTitleRow.getCell(2); |
| | | XSSFCellStyle subTitleCellStyle = subTitleCell.getCellStyle(); |
| | | XSSFCell subStartCell = subTitleRow.getCell(6); |
| | | XSSFCellStyle subStartCellStyle = subStartCell.getCellStyle(); |
| | | XSSFCell subtimesCell = subTitleRow.getCell(7); |
| | | XSSFCellStyle subtimesCellStyle = subtimesCell.getCellStyle(); |
| | | XSSFCell subendTimeCell = subTitleRow.getCell(9); |
| | | XSSFCellStyle subendTimeCellCellStyle = subendTimeCell.getCellStyle(); |
| | | XSSFCell subendRemarkCell = subTitleRow.getCell(10); |
| | | XSSFCellStyle remarkCellCellStyle = subendRemarkCell.getCellStyle(); |
| | | |
| | | XSSFCell titleCell = titleRow.getCell(1); |
| | | XSSFCellStyle titleStyle = titleCell.getCellStyle(); |
| | | XSSFCell nameCell = dateRow.getCell(1); |
| | | nameCell.setCellValue(scheme.getName() + "(" + dateFormat.format(scheme.getStartTime()) + ")"); |
| | | |
| | | List<Module> parent_id = moduleService.selectList(new EntityWrapper<Module>().isNull("parent_id").orderBy("order_no")); |
| | | List<SchemeDetail> schemeDetailList = schemeDetailService.selectList(new EntityWrapper<SchemeDetail>().eq("parent_id", scheme.getId())); |
| | | Date startTime = scheme.getStartTime(); |
| | | Date endTime = scheme.getEndTime(); |
| | | |
| | | |
| | | Calendar start = Calendar.getInstance(); |
| | | start.setTime(startTime); |
| | | int index = 12; |
| | | XSSFRow dateRows = sheet.getRow(2); |
| | | while (startTime.before(endTime)) { |
| | | startTime = start.getTime(); |
| | | XSSFCell inTimeCell = dateRows.createCell(index); |
| | | inTimeCell.setCellValue(dateFormat.format(startTime)); |
| | | inTimeCell.setCellStyle(dateCellCellStyle); |
| | | |
| | | index++; |
| | | start.add(Calendar.DAY_OF_YEAR, 1); |
| | | } |
| | | startTime = scheme.getStartTime(); |
| | | start.setTime(startTime); |
| | | |
| | | int startRow = 3; |
| | | for (int i = 0; i < parent_id.size(); i++) { |
| | | Module module = parent_id.get(i); |
| | | XSSFRow row = sheet.createRow(startRow); |
| | | XSSFCell cell = row.createCell(1); |
| | | cell.setCellValue(MessageFormat.format("Step {0} {1}", i + 1, module.getTitle())); |
| | | cell.setCellStyle(titleStyle); |
| | | List<Module> subModuleList = moduleService.selectList(new EntityWrapper<Module>().eq("parent_id", module.getId()).orderBy("order_no")); |
| | | for (Module subModule : subModuleList) { |
| | | List<SchemeDetail> collect = schemeDetailList.stream().filter(schemeDetail -> schemeDetail.getType().toString().equals(subModule.getId())).collect(Collectors.toList()); |
| | | if (collect.isEmpty()) { |
| | | continue; |
| | | } |
| | | startRow++; |
| | | SchemeDetail detail = collect.get(0); |
| | | XSSFRow nextRow = sheet.createRow(startRow); |
| | | XSSFCell subtitleCell = nextRow.createCell(2); |
| | | subtitleCell.setCellValue(subModule.getTitle()); |
| | | subtitleCell.setCellStyle(subTitleCellStyle); |
| | | XSSFCell startCell = nextRow.createCell(6); |
| | | startCell.setCellValue(dateFormat.format(detail.getStartTime())); |
| | | startCell.setCellStyle(subStartCellStyle); |
| | | XSSFCell timesCell = nextRow.createCell(7); |
| | | int dayDiffer = DbUtils.getDayDiffer(detail.getStartTime(), detail.getEndTime()); |
| | | timesCell.setCellValue(dayDiffer); |
| | | timesCell.setCellStyle(titleRow.getRowStyle()); |
| | | |
| | | XSSFCell endCell = nextRow.createCell(9); |
| | | endCell.setCellValue(dateFormat.format(detail.getEndTime())); |
| | | endCell.setCellStyle(subtimesCellStyle); |
| | | |
| | | XSSFCell remarkCell = nextRow.createCell(10); |
| | | remarkCell.setCellValue((detail.getRemark())); |
| | | remarkCell.setCellStyle(titleRow.getRowStyle()); |
| | | |
| | | if (detail.getFinish()) { |
| | | XSSFCell finishCell = nextRow.createCell(8); |
| | | finishCell.setCellValue(dateFormat.format(detail.getFinishTime())); |
| | | finishCell.setCellStyle(subendTimeCellCellStyle); |
| | | |
| | | XSSFCell endScheduleCell = nextRow.createCell(11); |
| | | endScheduleCell.setCellValue(DbUtils.getDayDiffer(detail.getStartTime(), detail.getFinishTime())); |
| | | endScheduleCell.setCellStyle(titleRow.getRowStyle()); |
| | | } |
| | | |
| | | index = 12; |
| | | Boolean finish = detail.getFinish(); |
| | | startTime = scheme.getStartTime(); |
| | | start.setTime(scheme.getStartTime()); |
| | | endTime = scheme.getEndTime(); |
| | | while (startTime.before(endTime)) { |
| | | startTime = start.getTime(); |
| | | Date subStart = detail.getStartTime(); |
| | | Date subEnd = detail.getEndTime(); |
| | | Date lastTime; |
| | | if (finish && (DbUtils.getDayDiffer(detail.getFinishTime(), detail.getEndTime()) > 0)){ |
| | | lastTime = detail.getFinishTime(); |
| | | } |
| | | else{ |
| | | lastTime = detail.getEndTime(); |
| | | } |
| | | |
| | | if (DbUtils.getDayDiffer(startTime, subStart) <= 0 && DbUtils.getDayDiffer(startTime, subEnd) >= 0) { |
| | | XSSFCell inTimeCell = nextRow.createCell(index); |
| | | inTimeCell.setCellStyle(planStyle); |
| | | }else if(DbUtils.getDayDiffer(startTime, subEnd) <= 0 && DbUtils.getDayDiffer(startTime, lastTime) >= 0){ |
| | | XSSFCell inTimeCell = nextRow.createCell(index); |
| | | inTimeCell.setCellStyle(exportStyle); |
| | | } |
| | | if (detail.getFinish() && DbUtils.getDayDiffer(startTime, detail.getFinishTime()) == 0) { |
| | | XSSFCell inTimeCell = nextRow.createCell(index); |
| | | inTimeCell.setCellStyle(cellEndStyle); |
| | | } |
| | | |
| | | index++; |
| | | start.add(Calendar.DAY_OF_YEAR, 1); |
| | | } |
| | | |
| | | } |
| | | startRow++; |
| | | } |
| | | |
| | | response.setContentType("application/octet-stream;charset=UTF-8"); |
| | | response.setCharacterEncoding("UTF-8"); |
| | | response.setHeader("content-type", "application/octet-stream;charset=UTF-8"); |
| | | //默认Excel名称 |
| | | response.setHeader("Content-Disposition", "attachment;fileName=" + URLEncoder.encode("mapping数据.xlsx", "UTF-8")); |
| | | |
| | | |
| | | response.flushBuffer(); |
| | | wb.write(response.getOutputStream()); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | @RequestMapping("{detailId}/download/{fileName}") |
| | | public Result downLoad(@PathVariable String detailId, @PathVariable String fileName, HttpServletResponse response) throws UnsupportedEncodingException { |
| | | SchemeDetail detail = schemeDetailService.selectById(detailId); |
| | |
| | | |
| | | String path = FileUtils.createFile(basePath, scheme.getName(), detail.getType().covert()); |
| | | File file = new File(path); |
| | | if(file.exists()){ //判断文件父目录是否存在 |
| | | if (file.exists()) { //判断文件父目录是否存在 |
| | | response.setContentType("application/vnd.ms-excel;charset=UTF-8"); |
| | | response.setCharacterEncoding("UTF-8"); |
| | | // response.setContentType("application/force-download"); |
| | | response.setHeader("Content-Disposition", "attachment;fileName=" + java.net.URLEncoder.encode(fileName,"UTF-8")); |
| | | response.setHeader("Content-Disposition", "attachment;fileName=" + java.net.URLEncoder.encode(fileName, "UTF-8")); |
| | | byte[] buffer = new byte[1024]; |
| | | FileInputStream fis = null; //文件输入流 |
| | | BufferedInputStream bis = null; |
| | |
| | | fis = new FileInputStream(file); |
| | | bis = new BufferedInputStream(fis); |
| | | int i = bis.read(buffer); |
| | | while(i != -1){ |
| | | while (i != -1) { |
| | | os.write(buffer); |
| | | i = bis.read(buffer); |
| | | } |
| | |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | @RequestMapping("/download/{topicId}") |
| | | public Result downLoadTopic(@PathVariable String topicId, HttpServletResponse response) throws UnsupportedEncodingException { |
| | | Topic topic = topicService.selectById(topicId); |
| | | String path = topic.getAttachment(); |
| | | File file = new File(path); |
| | | if(file.exists()){ //判断文件父目录是否存在 |
| | | if (file.exists()) { //判断文件父目录是否存在 |
| | | response.setContentType("application/vnd.ms-excel;charset=UTF-8"); |
| | | response.setCharacterEncoding("UTF-8"); |
| | | // response.setContentType("application/force-download"); |
| | | response.setHeader("Content-Disposition", "attachment;fileName=" + java.net.URLEncoder.encode(file.getName(),"UTF-8")); |
| | | response.setHeader("Content-Disposition", "attachment;fileName=" + java.net.URLEncoder.encode(file.getName(), "UTF-8")); |
| | | byte[] buffer = new byte[1024]; |
| | | FileInputStream fis = null; //文件输入流 |
| | | BufferedInputStream bis = null; |
| | |
| | | fis = new FileInputStream(file); |
| | | bis = new BufferedInputStream(fis); |
| | | int i = bis.read(buffer); |
| | | while(i != -1){ |
| | | while (i != -1) { |
| | | os.write(buffer); |
| | | i = bis.read(buffer); |
| | | } |
| | |
| | | public Result downLoadPath(@PathVariable String path, HttpServletResponse response) throws UnsupportedEncodingException { |
| | | path = URLDecoder.decode(path, "UTF-8"); |
| | | File file = new File(path); |
| | | if(file.exists()){ //判断文件父目录是否存在 |
| | | if (file.exists()) { //判断文件父目录是否存在 |
| | | response.setContentType("application/vnd.ms-excel;charset=UTF-8"); |
| | | response.setCharacterEncoding("UTF-8"); |
| | | // response.setContentType("application/force-download"); |
| | | response.setHeader("Content-Disposition", "attachment;fileName=" + java.net.URLEncoder.encode(file.getName(),"UTF-8")); |
| | | response.setHeader("Content-Disposition", "attachment;fileName=" + java.net.URLEncoder.encode(file.getName(), "UTF-8")); |
| | | byte[] buffer = new byte[1024]; |
| | | FileInputStream fis = null; //文件输入流 |
| | | BufferedInputStream bis = null; |
| | |
| | | fis = new FileInputStream(file); |
| | | bis = new BufferedInputStream(fis); |
| | | int i = bis.read(buffer); |
| | | while(i != -1){ |
| | | while (i != -1) { |
| | | os.write(buffer); |
| | | i = bis.read(buffer); |
| | | } |
| | |
| | | |
| | | /** |
| | | * 实现文件上传 |
| | | * */ |
| | | */ |
| | | @RequestMapping("fileUpload/{detailId}") |
| | | @ResponseBody |
| | | public Result fileUpload(@PathVariable String detailId, @RequestParam("file") MultipartFile file, HttpServletRequest request){ |
| | | public Result fileUpload(@PathVariable String detailId, @RequestParam("file") MultipartFile file, HttpServletRequest request) { |
| | | String desp = request.getParameter("desp"); |
| | | SchemeDetail detail = schemeDetailService.selectById(detailId); |
| | | if (detail == null) { |
| | |
| | | ProjectDeal projectDeal = new ProjectDeal(); |
| | | projectDeal.setCreateTime(new Date()).setSchemeId(detail.getParentId()) |
| | | .setSchemeDetailId(detailId).setDesp(desp) |
| | | .setId(DbUtils.getUUID()).insert(); |
| | | .setId(DbUtils.getUUID()).insert(); |
| | | |
| | | detail.setFinish(true); |
| | | detail.setUpdateTime(new Date()); |
| | |
| | | detail.updateById(); |
| | | return Result.success(CodeMsg.SUCCESS); |
| | | } |
| | | if(file.isEmpty()){ |
| | | if (file.isEmpty()) { |
| | | return Result.error(CodeMsg.ERROR_PARAMS_NOT_MATHED); |
| | | } |
| | | |
| | |
| | | |
| | | String path = FileUtils.createFile(basePath, scheme.getName(), detail.getType().covert()); |
| | | File dest = new File(path + "/" + fileName); |
| | | if(!dest.getParentFile().exists()){ //判断文件父目录是否存在 |
| | | if (!dest.getParentFile().exists()) { //判断文件父目录是否存在 |
| | | dest.getParentFile().mkdirs(); |
| | | } |
| | | dest.deleteOnExit(); |
| | |
| | | } |
| | | } |
| | | |
| | | @RequestMapping("topicUpload") |
| | | /** |
| | | * 实现文件上传 |
| | | */ |
| | | @RequestMapping("/schemeUpload/{id}") |
| | | @ResponseBody |
| | | public Result topicUpload(@RequestParam("file") MultipartFile file, HttpServletRequest request){ |
| | | String id = request.getParameter("id"); |
| | | String title = request.getParameter("title"); |
| | | String desp = request.getParameter("desp"); |
| | | String userId = request.getParameter("userId"); |
| | | Topic topic; |
| | | if (StringUtils.isEmpty(id)) { |
| | | topic = new Topic().setId(DbUtils.getUUID()).setTitle(title).setDesp(desp).setUserId(userId).setCreateTime(new Date()); |
| | | } else { |
| | | topic = topicService.selectById(id).setTitle(title).setDesp(desp); |
| | | public Result schemeFileUpload(@PathVariable String id, @RequestParam("file") MultipartFile file, HttpServletRequest request) { |
| | | Scheme scheme = schemeService.selectById(id); |
| | | if (scheme == null) { |
| | | return Result.error(CodeMsg.SELECT_ERROR); |
| | | } |
| | | |
| | | String fileName = file.getOriginalFilename(); |
| | | int size = (int) file.getSize(); |
| | | log.info(fileName + "-->" + size); |
| | | String path = topicPath + "/"+ topic.getId() + fileName; |
| | | |
| | | String path = FileUtils.createFile(basePath, scheme.getName(), null); |
| | | File dest = new File(path + "/" + fileName); |
| | | if (!dest.getParentFile().exists()) { //判断文件父目录是否存在 |
| | | dest.getParentFile().mkdirs(); |
| | | } |
| | | dest.deleteOnExit(); |
| | | |
| | | try { |
| | | dest.createNewFile(); |
| | | file.transferTo(dest); //保存文件 |
| | | |
| | | scheme.setAttachment(path + "/" + fileName); |
| | | scheme.updateById(); |
| | | return Result.success(CodeMsg.SUCCESS); |
| | | } catch (IllegalStateException e) { |
| | | // TODO Auto-generated catch block |
| | | e.printStackTrace(); |
| | | return Result.error(CodeMsg.OPERATR_ERROR); |
| | | } catch (IOException e) { |
| | | // TODO Auto-generated catch block |
| | | e.printStackTrace(); |
| | | return Result.error(CodeMsg.OPERATR_ERROR); |
| | | } |
| | | } |
| | | |
| | | @RequestMapping("topicUpload") |
| | | @ResponseBody |
| | | public Result topicUpload(@RequestParam("file") MultipartFile file, HttpServletRequest request) { |
| | | // new TitleService().setPopulation(population); |
| | | Map<String, String[]> parameterMap = request.getParameterMap(); |
| | | String population = request.getParameter("population"); |
| | | String exposure = request.getParameter("exposure"); |
| | | String comparator = request.getParameter("comparator"); |
| | | String outcomes = request.getParameter("outcomes"); |
| | | String outcomesOther = request.getParameter("outcomesOther"); |
| | | String titleType = request.getParameter("titleType"); |
| | | |
| | | TitleService titleService =new TitleService().setPopulation(population) |
| | | .setExposure(exposure).setComparator(comparator).setOutcomes(outcomes).setOutcomesOther(outcomesOther) |
| | | .setTitleType(titleType); |
| | | String id = titleService.getId(); |
| | | |
| | | String title = titleService.createTitle(); |
| | | String userId = request.getParameter("userId"); |
| | | Topic topic; |
| | | if (StringUtils.isEmpty(id)) { |
| | | String uuid = DbUtils.getUUID(); |
| | | titleService.setId(uuid); |
| | | titleService.setTitle(titleService.createTitle()); |
| | | titleService.insert(); |
| | | topic = new Topic().setTitleId(uuid).setId(uuid).setUserId(userId).setCreateTime(new Date()); |
| | | } else { |
| | | titleService.setTitle(titleService.createTitle()); |
| | | titleService.updateById(); |
| | | topic = topicService.selectById(id); |
| | | } |
| | | |
| | | String fileName = file.getOriginalFilename(); |
| | | int size = (int) file.getSize(); |
| | | log.info(fileName + "-->" + size); |
| | | String path = topicPath + "/" + topic.getId() + fileName; |
| | | File dest = new File(path); |
| | | if(!dest.getParentFile().exists()){ //判断文件父目录是否存在 |
| | | if (!dest.getParentFile().exists()) { //判断文件父目录是否存在 |
| | | dest.getParentFile().mkdirs(); |
| | | } |
| | | dest.deleteOnExit(); |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 实现多文件上传 |
| | | * */ |
| | | @RequestMapping(value="multifileUpload",method= RequestMethod.POST) |
| | | public @ResponseBody String multifileUpload(HttpServletRequest request){ |
| | | */ |
| | | @RequestMapping(value = "multifileUpload", method = RequestMethod.POST) |
| | | public @ResponseBody |
| | | String multifileUpload(HttpServletRequest request) { |
| | | |
| | | List<MultipartFile> files = ((MultipartHttpServletRequest)request).getFiles("fileName"); |
| | | List<MultipartFile> files = ((MultipartHttpServletRequest) request).getFiles("fileName"); |
| | | |
| | | if(files.isEmpty()){ |
| | | if (files.isEmpty()) { |
| | | return "false"; |
| | | } |
| | | |
| | | String path = "F:/test" ; |
| | | String path = "F:/test"; |
| | | |
| | | for(MultipartFile file:files){ |
| | | for (MultipartFile file : files) { |
| | | String fileName = file.getOriginalFilename(); |
| | | int size = (int) file.getSize(); |
| | | log.info(fileName + "-->" + size); |
| | | |
| | | if(file.isEmpty()){ |
| | | if (file.isEmpty()) { |
| | | return "false"; |
| | | }else{ |
| | | } else { |
| | | File dest = new File(path + "/" + fileName); |
| | | if(!dest.getParentFile().exists()){ //判断文件父目录是否存在 |
| | | if (!dest.getParentFile().exists()) { //判断文件父目录是否存在 |
| | | dest.getParentFile().mkdir(); |
| | | } |
| | | try { |
| | | file.transferTo(dest); |
| | | }catch (Exception e) { |
| | | } catch (Exception e) { |
| | | // TODO Auto-generated catch block |
| | | e.printStackTrace(); |
| | | return "false"; |
| | |
| | | import com.highdatas.srs.entity.*; |
| | | import com.highdatas.srs.pojo.CodeMsg; |
| | | import com.highdatas.srs.pojo.Result; |
| | | import com.highdatas.srs.service.IProjectDealService; |
| | | import com.highdatas.srs.service.ISchemeDetailService; |
| | | import com.highdatas.srs.service.ISchemeService; |
| | | import com.highdatas.srs.service.ISysUserService; |
| | | import com.highdatas.srs.service.*; |
| | | import com.highdatas.srs.util.DbUtils; |
| | | import com.highdatas.srs.util.FileUtils; |
| | | import org.apache.commons.lang3.StringUtils; |
| | |
| | | import java.io.UnsupportedEncodingException; |
| | | import java.math.BigDecimal; |
| | | import java.text.DecimalFormat; |
| | | import java.text.MessageFormat; |
| | | import java.text.ParseException; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.*; |
| | | import java.util.function.IntFunction; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | ISchemeDetailService iSchemeDetailService; |
| | | @Autowired |
| | | IProjectDealService projectDealService; |
| | | |
| | | @Autowired |
| | | ISysRoleMappingService roleMappingService; |
| | | @Autowired |
| | | ISysRoleService roleService; |
| | | @Autowired |
| | | ISchemeDetailParttimeService detailParttimeService; |
| | | @Autowired |
| | | ISysTargetService targetService; |
| | | @Value("${base.file.path}") |
| | | String basePath; |
| | | |
| | | @RequestMapping(value = "/achieve", method = RequestMethod.GET) |
| | | public Result getAcheve(@RequestParam String type, HttpServletRequest request) throws ParseException { |
| | | EntityWrapper<Scheme> schemeEntityWrapper = new EntityWrapper<>(); |
| | | //编辑 取消 不计入 |
| | | schemeEntityWrapper.notIn("status", "edit"); |
| | | List<Scheme> schemes = schemeService.selectList(schemeEntityWrapper); |
| | | |
| | | List<SchemeDetail> detailList = new ArrayList<>(); |
| | | for (Scheme scheme : schemes) { |
| | | String id = scheme.getId(); |
| | | EntityWrapper<SchemeDetail> schemeDetailEntityWrapper = new EntityWrapper<>(); |
| | | schemeDetailEntityWrapper.eq("parent_id", id); |
| | | List<SchemeDetail> schemeDetails = iSchemeDetailService.selectList(schemeDetailEntityWrapper); |
| | | detailList.addAll(schemeDetails); |
| | | } |
| | | |
| | | if (type.equalsIgnoreCase("total")) { |
| | | Result result = getTotalOptions(detailList); |
| | | }else if (type.equalsIgnoreCase("per")) { |
| | | Result result = getPerOptions(detailList); |
| | | }else if (type.equalsIgnoreCase("after")) { |
| | | Result result = getAfterOptions(detailList); |
| | | }else if(type.equalsIgnoreCase("month")) { |
| | | Result result = getMonthOptions(detailList); |
| | | }else if(type.equalsIgnoreCase("team")) { |
| | | Result result = getTeamOptions(detailList); |
| | | }else if(type.equalsIgnoreCase("member")) { |
| | | Result result = getTeamOptions(detailList); |
| | | } |
| | | return Result.success(null); |
| | | } |
| | | |
| | | private Result getTeamOptions(List<SchemeDetail> detailList) { |
| | | return null; |
| | | } |
| | | |
| | | private Result getMonthOptions(List<SchemeDetail> detailList) throws ParseException { |
| | | Date now = new Date(); |
| | | Calendar calendar = Calendar.getInstance(); |
| | | calendar.setTime(now); |
| | | JSONObject resultData = new JSONObject(); |
| | | List<String> months = new ArrayList<>(); |
| | | List<String> types = new ArrayList<>(); |
| | | types.add("指标"); |
| | | types.add("完成"); |
| | | types.add("达成率"); |
| | | List<JSONObject> datas = new ArrayList<>(); |
| | | JSONObject targetDataObject = new JSONObject(); |
| | | targetDataObject.put("name", "指标"); |
| | | targetDataObject.put("type", "bar"); |
| | | datas.add(targetDataObject); |
| | | JSONObject amountDataObject = new JSONObject(); |
| | | amountDataObject.put("name", "完成"); |
| | | amountDataObject.put("type", "bar"); |
| | | datas.add(amountDataObject); |
| | | JSONObject achieveDataObject = new JSONObject(); |
| | | achieveDataObject.put("name", "达成率"); |
| | | achieveDataObject.put("type", "line"); |
| | | datas.add(achieveDataObject); |
| | | |
| | | List<JSONObject> entityset = new ArrayList<>(); |
| | | |
| | | JSONObject targetEntityObject = new JSONObject(); |
| | | targetEntityObject.put("type", "指标"); |
| | | entityset.add(targetEntityObject); |
| | | JSONObject amountEntityObject = new JSONObject(); |
| | | amountEntityObject.put("type", "完成"); |
| | | entityset.add(amountEntityObject); |
| | | JSONObject achieveEntityObject = new JSONObject(); |
| | | achieveEntityObject.put("type", "达成率"); |
| | | entityset.add(achieveEntityObject); |
| | | |
| | | for (int i = 0; i < 12; i++) { |
| | | |
| | | calendar.set(calendar.get(Calendar.YEAR),calendar.get(Calendar.MONTH),1,0,0,0); |
| | | Date yearStart = calendar.getTime(); |
| | | calendar.add(Calendar.MONTH, 1); |
| | | calendar.add(Calendar.DAY_OF_MONTH, -1); |
| | | Date yearEnd = calendar.getTime(); |
| | | int year = calendar.get(Calendar.YEAR); |
| | | int month = calendar.get(Calendar.MONTH) + 1; |
| | | String oneMonth = MessageFormat.format("{0}{1}", year, month); |
| | | |
| | | BigDecimal totalBudget = BigDecimal.ZERO; |
| | | |
| | | for (SchemeDetail schemeDetail : detailList) { |
| | | BigDecimal rangeBudget = getRangeBudget(schemeDetail, yearStart, yearEnd); |
| | | totalBudget = totalBudget.add(rangeBudget); |
| | | } |
| | | //2 target |
| | | |
| | | EntityWrapper<SysTarget> sysTargetEntityWrapper = new EntityWrapper<>(); |
| | | sysTargetEntityWrapper.eq("amt_type", "pro") |
| | | .eq("year", year); |
| | | List<SysTarget> sysTargets = targetService.selectList(sysTargetEntityWrapper); |
| | | BigDecimal totalTarget = BigDecimal.ZERO; |
| | | |
| | | for (SysTarget sysTarget : sysTargets) { |
| | | BigDecimal one = sysTarget.getTarget(); |
| | | totalTarget = totalTarget.add(one); |
| | | } |
| | | BigDecimal achieve; |
| | | if(totalTarget.compareTo(BigDecimal.ZERO) == 0) { |
| | | achieve = BigDecimal.ZERO; |
| | | }else { |
| | | achieve = totalBudget.multiply(BigDecimal.valueOf(100)).divide(totalTarget, 1, BigDecimal.ROUND_HALF_UP); |
| | | } |
| | | ArrayList<BigDecimal> targetData = (ArrayList<BigDecimal>) targetDataObject.get("data"); |
| | | if (targetData == null) { |
| | | targetData = new ArrayList<BigDecimal>(); |
| | | } |
| | | targetData.add(i, totalTarget); |
| | | |
| | | ArrayList<BigDecimal> amountData = (ArrayList<BigDecimal>) amountDataObject.get("data"); |
| | | if (amountData == null) { |
| | | amountData = new ArrayList<BigDecimal>(); |
| | | } |
| | | amountData.add(i, totalBudget); |
| | | |
| | | ArrayList<BigDecimal> achieveData = (ArrayList<BigDecimal>) achieveDataObject.get("data"); |
| | | if (achieveData == null) { |
| | | achieveData = new ArrayList<BigDecimal>(); |
| | | } |
| | | achieveData.add(i, achieve); |
| | | |
| | | targetEntityObject.put(oneMonth, totalTarget); |
| | | amountEntityObject.put(oneMonth, totalBudget); |
| | | achieveEntityObject.put(oneMonth, achieve); |
| | | |
| | | months.add(oneMonth); |
| | | calendar.add(Calendar.MONTH , -1); |
| | | } |
| | | resultData.put("months",months); |
| | | resultData.put("types",types); |
| | | resultData.put("datas",datas); |
| | | resultData.put("entityset",entityset); |
| | | |
| | | return Result.success(resultData); |
| | | } |
| | | |
| | | private Result getAfterOptions(List<SchemeDetail> detailList) throws ParseException { |
| | | //0 |
| | | Date now = new Date(); |
| | | Calendar calendar = Calendar.getInstance(); |
| | | calendar.setTime(now); |
| | | calendar.set(calendar.get(Calendar.YEAR),5,1,0,0,0); |
| | | Date yearStart = calendar.getTime(); |
| | | calendar.add(Calendar.MONTH, 7); |
| | | calendar.add(Calendar.DAY_OF_MONTH, -1); |
| | | |
| | | Date yearEnd = calendar.getTime(); |
| | | |
| | | //1 amount |
| | | BigDecimal totalBudget = BigDecimal.ZERO; |
| | | for (SchemeDetail schemeDetail : detailList) { |
| | | BigDecimal rangeBudget = getRangeBudget(schemeDetail, yearStart, yearEnd); |
| | | totalBudget = totalBudget.add(rangeBudget); |
| | | } |
| | | //2 target |
| | | int year = calendar.get(Calendar.YEAR); |
| | | EntityWrapper<SysTarget> sysTargetEntityWrapper = new EntityWrapper<>(); |
| | | sysTargetEntityWrapper.eq("amt_type", "pro") |
| | | .eq("year", year).eq("tgt_type","per"); |
| | | List<SysTarget> sysTargets = targetService.selectList(sysTargetEntityWrapper); |
| | | BigDecimal totalTarget = BigDecimal.ZERO; |
| | | |
| | | for (SysTarget sysTarget : sysTargets) { |
| | | BigDecimal one = sysTarget.getTarget(); |
| | | totalTarget = totalTarget.add(one); |
| | | } |
| | | if(totalTarget.compareTo(BigDecimal.ZERO) == 0) { |
| | | return Result.success(0); |
| | | }else { |
| | | BigDecimal achieve = totalBudget.multiply(BigDecimal.valueOf(100)).divide(totalTarget, 1, BigDecimal.ROUND_HALF_UP); |
| | | return Result.success(achieve); |
| | | } |
| | | } |
| | | |
| | | private Result getPerOptions(List<SchemeDetail> detailList) throws ParseException { |
| | | //0 |
| | | Date now = new Date(); |
| | | Calendar calendar = Calendar.getInstance(); |
| | | calendar.setTime(now); |
| | | calendar.set(calendar.get(Calendar.YEAR),0,1,0,0,0); |
| | | Date yearStart = calendar.getTime(); |
| | | calendar.add(Calendar.MONTH, 7); |
| | | calendar.add(Calendar.DAY_OF_MONTH, -1); |
| | | |
| | | Date yearEnd = calendar.getTime(); |
| | | |
| | | //1 amount |
| | | BigDecimal totalBudget = BigDecimal.ZERO; |
| | | for (SchemeDetail schemeDetail : detailList) { |
| | | BigDecimal rangeBudget = getRangeBudget(schemeDetail, yearStart, yearEnd); |
| | | totalBudget = totalBudget.add(rangeBudget); |
| | | } |
| | | //2 target |
| | | int year = calendar.get(Calendar.YEAR); |
| | | EntityWrapper<SysTarget> sysTargetEntityWrapper = new EntityWrapper<>(); |
| | | sysTargetEntityWrapper.eq("amt_type", "pro") |
| | | .eq("year", year).eq("tgt_type","per"); |
| | | List<SysTarget> sysTargets = targetService.selectList(sysTargetEntityWrapper); |
| | | BigDecimal totalTarget = BigDecimal.ZERO; |
| | | |
| | | for (SysTarget sysTarget : sysTargets) { |
| | | BigDecimal one = sysTarget.getTarget(); |
| | | totalTarget = totalTarget.add(one); |
| | | } |
| | | if(totalTarget.compareTo(BigDecimal.ZERO) == 0) { |
| | | return Result.success(0); |
| | | }else { |
| | | BigDecimal achieve = totalBudget.multiply(BigDecimal.valueOf(100)).divide(totalTarget, 1, BigDecimal.ROUND_HALF_UP); |
| | | return Result.success(achieve); |
| | | } |
| | | } |
| | | |
| | | private Result getTotalOptions(List<SchemeDetail> detailList) throws ParseException { |
| | | //0 |
| | | Date now = new Date(); |
| | | Calendar calendar = Calendar.getInstance(); |
| | | calendar.setTime(now); |
| | | calendar.set(calendar.get(Calendar.YEAR),0,1,0,0,0); |
| | | Date yearStart = calendar.getTime(); |
| | | calendar.add(Calendar.YEAR, 1); |
| | | calendar.add(Calendar.DAY_OF_MONTH, -1); |
| | | Date yearEnd = calendar.getTime(); |
| | | |
| | | //1 amount |
| | | BigDecimal totalBudget = BigDecimal.ZERO; |
| | | for (SchemeDetail schemeDetail : detailList) { |
| | | BigDecimal rangeBudget = getRangeBudget(schemeDetail, yearStart, yearEnd); |
| | | totalBudget = totalBudget.add(rangeBudget); |
| | | } |
| | | //2 target |
| | | int year = calendar.get(Calendar.YEAR); |
| | | EntityWrapper<SysTarget> sysTargetEntityWrapper = new EntityWrapper<>(); |
| | | sysTargetEntityWrapper.eq("amt_type", "pro").eq("year", year); |
| | | List<SysTarget> sysTargets = targetService.selectList(sysTargetEntityWrapper); |
| | | BigDecimal totalTarget = BigDecimal.ZERO; |
| | | |
| | | for (SysTarget sysTarget : sysTargets) { |
| | | BigDecimal one = sysTarget.getTarget(); |
| | | totalTarget = totalTarget.add(one); |
| | | } |
| | | if(totalTarget.compareTo(BigDecimal.ZERO) == 0) { |
| | | return Result.success(0); |
| | | }else { |
| | | BigDecimal achieve = totalBudget.multiply(BigDecimal.valueOf(100)).divide(totalTarget, 1, BigDecimal.ROUND_HALF_UP); |
| | | return Result.success(achieve); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | private BigDecimal getRangeBudget(SchemeDetail schemeDetail, Date yearStart, Date yearEnd) throws ParseException { |
| | | BigDecimal average = BigDecimal.ZERO; |
| | | BigDecimal rangeBudget = BigDecimal.ZERO; |
| | | Integer rangeDays; |
| | | BigDecimal budget = schemeDetail.getBudget(); |
| | | Boolean finish = schemeDetail.getFinish(); |
| | | Boolean edit = schemeDetail.getEdit(); |
| | | Boolean delay = schemeDetail.getDelay(); |
| | | if (edit) { |
| | | return BigDecimal.ZERO; |
| | | } |
| | | if (finish) { |
| | | int dayDiffer = DbUtils.getDayDiffer(schemeDetail.getStartTime(), schemeDetail.getFinishTime()); |
| | | dayDiffer = Math.abs(dayDiffer); |
| | | average = budget.divide(BigDecimal.valueOf(dayDiffer), 10, BigDecimal.ROUND_HALF_UP); |
| | | rangeDays = DbUtils.getRangeDays(schemeDetail.getStartTime(), schemeDetail.getFinishTime(), yearStart, yearEnd); |
| | | rangeDays = Math.abs(rangeDays); |
| | | } |
| | | if (delay) { |
| | | Date endTime = schemeDetail.getEndTime(); |
| | | Integer dayDiffer = null; |
| | | Date now = new Date(); |
| | | if (endTime.before(now)) { |
| | | dayDiffer = DbUtils.getDayDiffer(schemeDetail.getStartTime(), now); |
| | | dayDiffer = Math.abs(dayDiffer); |
| | | rangeDays = DbUtils.getRangeDays(schemeDetail.getStartTime(), now, yearStart, yearEnd); |
| | | rangeDays = Math.abs(rangeDays); |
| | | }else { |
| | | dayDiffer = DbUtils.getDayDiffer(schemeDetail.getStartTime(), schemeDetail.getEndTime()); |
| | | dayDiffer = Math.abs(dayDiffer); |
| | | rangeDays = DbUtils.getRangeDays(schemeDetail.getStartTime(), schemeDetail.getEndTime(), yearStart, yearEnd); |
| | | |
| | | } |
| | | average = budget.divide(BigDecimal.valueOf(dayDiffer), 10, BigDecimal.ROUND_HALF_UP); |
| | | rangeBudget = average.multiply(BigDecimal.valueOf(rangeDays)); |
| | | } |
| | | |
| | | return rangeBudget; |
| | | } |
| | | |
| | | @RequestMapping(value = "/daywork/{id}", method = RequestMethod.GET) |
| | | public Result dayByUser(@PathVariable String id, HttpServletRequest request) { |
| | |
| | | @RequestMapping(value = "/get/{id}", method = RequestMethod.GET) |
| | | public Result get(@PathVariable String id) { |
| | | Scheme scheme = schemeService.selectById(id); |
| | | String leadUserId = scheme.getLeadUserId(); |
| | | if (!StringUtils.isEmpty(leadUserId)) { |
| | | String[] split = leadUserId.split(";"); |
| | | ArrayList<List<String>> lists = new ArrayList<>(); |
| | | for (String one : split) { |
| | | if (StringUtils.isEmpty(one)) { |
| | | continue; |
| | | } |
| | | SysRoleMapping mapping = roleMappingService.selectOne(new EntityWrapper<SysRoleMapping>().eq("user_id", one)); |
| | | if (mapping == null) { |
| | | continue; |
| | | } |
| | | SysRole sysRole = roleService.selectById(mapping.getRoleId()); |
| | | ArrayList<String> sysRoleMappings = new ArrayList<>(); |
| | | sysRoleMappings.add(sysRole.getName()); |
| | | sysRoleMappings.add(mapping.getUserId()); |
| | | lists.add(sysRoleMappings); |
| | | } |
| | | scheme.setLeadUserList(lists); |
| | | } |
| | | |
| | | return Result.success(scheme); |
| | | } |
| | | |
| | |
| | | detail.setEdit(false); |
| | | detail.updateById(); |
| | | } |
| | | scheme.setStatus("working"); |
| | | if (scheme.getStatus().equalsIgnoreCase("edit")) { |
| | | scheme.setStatus("working"); |
| | | } |
| | | |
| | | boolean b = scheme.updateById(); |
| | | if (b) { |
| | | return Result.success(CodeMsg.UPDATE_SUCCESS); |
| | |
| | | return Result.success(schemes); |
| | | } |
| | | |
| | | @RequestMapping(value = "/save/{id}", method = RequestMethod.GET) |
| | | public Result save(@PathVariable String id, @RequestParam BigDecimal budget) { |
| | | Scheme scheme = schemeService.selectById(id); |
| | | if (scheme == null) { |
| | | return Result.error(CodeMsg.ERROR_PARAMS_NOT_MATHED); |
| | | } |
| | | scheme.setBudget(budget).updateById(); |
| | | return Result.success(scheme); |
| | | } |
| | | |
| | | @RequestMapping(value = "/page/{pageNo}", method = RequestMethod.GET) |
| | | public Result get(@PathVariable Integer pageNo, HttpServletRequest request) { |
| | | String pageSize = request.getParameter("pageSize"); |
| | |
| | | String status = request.getParameter("status"); |
| | | String type = request.getParameter("type"); |
| | | String userId = request.getParameter("userId"); |
| | | String isRun = request.getParameter("isRun"); |
| | | String orderBy = request.getParameter("orderBy"); |
| | | |
| | | EntityWrapper<Scheme> schemeEntityWrapper = new EntityWrapper<>(); |
| | | |
| | | if (!StringUtils.isEmpty(name)) { |
| | | schemeEntityWrapper.like("name", name); |
| | | } |
| | | if (!StringUtils.isEmpty(orderBy)) { |
| | | schemeEntityWrapper.orderBy(orderBy); |
| | | } |
| | | if (!StringUtils.isEmpty(userId)) { |
| | | schemeEntityWrapper.eq("user_id", userId); |
| | | } |
| | | if (!StringUtils.isEmpty(type)) { |
| | | schemeEntityWrapper.eq("reseach_type", type); |
| | | schemeEntityWrapper.like("type", type); |
| | | } |
| | | if (!StringUtils.isEmpty(status)) { |
| | | schemeEntityWrapper.eq("status", status); |
| | | } |
| | | if (!StringUtils.isEmpty(isRun) && Boolean.valueOf(isRun)) { |
| | | schemeEntityWrapper.ne("status", "edit"); |
| | | } |
| | | |
| | | Page<Scheme> schemePage; |
| | |
| | | } |
| | | |
| | | Page<Scheme> page = schemeService.selectPage(schemePage, schemeEntityWrapper); |
| | | List<Scheme> schemes = schemeService.selectList(schemeEntityWrapper); |
| | | JSONObject resultObj = new JSONObject(); |
| | | BigDecimal decimal = new BigDecimal(0); |
| | | BigDecimal moneydecimal = new BigDecimal(0); |
| | | for (Scheme scheme : schemes) { |
| | | if (scheme.getBudget() != null) { |
| | | decimal = decimal.add(scheme.getBudget()); |
| | | } |
| | | if (scheme.getPayMoney() != null) { |
| | | moneydecimal = moneydecimal.add(scheme.getPayMoney()); |
| | | } |
| | | } |
| | | resultObj.fluentPut("budget", decimal); |
| | | resultObj.fluentPut("payMoney", moneydecimal); |
| | | List<Scheme> records = page.getRecords(); |
| | | Page<JSONObject> jsonObjectPage = new Page<>(); |
| | | jsonObjectPage.setTotal(page.getTotal()); |
| | | jsonObjectPage.setCurrent(page.getCurrent()); |
| | | jsonObjectPage.setSize(page.getSize()); |
| | | List<JSONObject> result = new ArrayList<>(); |
| | | |
| | | for (Scheme scheme : records) { |
| | | JSONObject json = (JSONObject) JSON.toJSON(scheme); |
| | | Wrapper<SchemeDetail> delayWrapper = new EntityWrapper<SchemeDetail>().eq("parent_id", scheme.getId()); |
| | | Wrapper<SchemeDetail> finishWrapper = new EntityWrapper<SchemeDetail>().eq("parent_id", scheme.getId()); |
| | | int total = iSchemeDetailService.selectCount(delayWrapper); |
| | | List<SchemeDetail> detailList = iSchemeDetailService.selectList(delayWrapper); |
| | | BigDecimal totalBudget = new BigDecimal(0); |
| | | for (SchemeDetail detail : detailList) { |
| | | BigDecimal budget = detail.getBudget(); |
| | | totalBudget = totalBudget.add(budget); |
| | | } |
| | | int total =detailList.size(); |
| | | int delayInt = iSchemeDetailService.selectCount(delayWrapper.eq("delay", true)); |
| | | |
| | | int finishInt = iSchemeDetailService.selectCount(finishWrapper.eq("finish", true)); |
| | | json.fluentPut("totalCnt", total); |
| | | json.fluentPut("delayCnt", delayInt); |
| | | json.fluentPut("finishCnt", finishInt); |
| | | json.fluentPut("totalBudget", totalBudget); |
| | | |
| | | // |
| | | List<SchemeDetail> schemeDetailList = iSchemeDetailService.selectList(new EntityWrapper<SchemeDetail>().eq("parent_id", scheme.getId()).eq("finish", true)); |
| | |
| | | if (endDate == null) { |
| | | endDate = detail.getFinishTime(); |
| | | }else { |
| | | int i = DbUtils.compareDate(endDate, detail.getFinishTime()); |
| | | if(i == 1) { |
| | | endDate = detail.getFinishTime(); |
| | | if (detail.getFinish() && detail.getFinishTime() != null) { |
| | | |
| | | int i = DbUtils.compareDate(endDate, detail.getFinishTime()); |
| | | if(i == 1) { |
| | | endDate = detail.getFinishTime(); |
| | | } |
| | | } |
| | | |
| | | } |
| | | } |
| | | json.fluentPut("beginDate", beginDate); |
| | |
| | | result.add(json); |
| | | } |
| | | jsonObjectPage.setRecords(result); |
| | | return Result.success(jsonObjectPage); |
| | | resultObj.fluentPut("datas", jsonObjectPage); |
| | | return Result.success(resultObj); |
| | | } |
| | | @RequestMapping(value = "/checkCode/{code}", method = RequestMethod.GET) |
| | | public Result add(@RequestParam String code) { |
| | | int cnt = schemeService.selectCount(new EntityWrapper<Scheme>().eq("code", code)); |
| | | if (cnt == 0) { |
| | | return Result.success(true); |
| | | } |
| | | return Result.success(false); |
| | | } |
| | | |
| | | @RequestMapping(value = "/addOrUpdate", method = RequestMethod.GET) |
| | | public Result add(@RequestParam String reseachType, @RequestParam String name, @RequestParam Date startTime, @RequestParam Date endTime, HttpServletRequest request) { |
| | | String id = request.getParameter("id"); |
| | | String desp = request.getParameter("desp"); |
| | | String userId = request.getParameter("userId"); |
| | | Scheme scheme; |
| | | if (StringUtils.isEmpty(id)) { |
| | | scheme = new Scheme(); |
| | | }else{ |
| | | scheme = schemeService.selectById(id); |
| | | @RequestMapping(value = "/addOrUpdate", method = RequestMethod.POST) |
| | | public Result add( @RequestBody Scheme scheme) { |
| | | |
| | | String code = scheme.getCode(); |
| | | Wrapper<Scheme> codeWrapper = new EntityWrapper<Scheme>().eq("code", code); |
| | | if (!StringUtils.isEmpty(scheme.getId())) { |
| | | codeWrapper.ne("id", scheme.getId()); |
| | | } |
| | | if (scheme == null) { |
| | | return Result.error(CodeMsg.SELECT_ERROR_NOTFOUND); |
| | | int i = schemeService.selectCount(codeWrapper); |
| | | if (i > 0) { |
| | | return Result.error(CodeMsg.EXISTSCODE_ERROR); |
| | | } |
| | | // reseachType to enum |
| | | |
| | | if (StringUtils.isEmpty(scheme.getId())) { |
| | | scheme.setId(DbUtils.getUUID()); |
| | | scheme.setId(DbUtils.getUUID()).setCreateTime(new Date()); |
| | | } |
| | | scheme.setUserId(userId).setCreateTime(new Date()).setName(name).setStartTime(startTime).setEndTime(endTime) |
| | | .setDesp(desp).setReseachType(reseachType); |
| | | |
| | | Date startTime = scheme.getStartTime(); |
| | | Date endTime = scheme.getEndTime(); |
| | | |
| | | List<SchemeDetail> schemeDetailList = iSchemeDetailService.selectList(new EntityWrapper<SchemeDetail>().eq("parent_id", scheme.getId())); |
| | | for (SchemeDetail detail : schemeDetailList) { |
| | |
| | | detail.setEndTime(endTime); |
| | | } |
| | | } |
| | | |
| | | |
| | | boolean updated = detail.updateById(); |
| | | |
| | | } |
| | |
| | | @RequestMapping(value = "/del/{id}", method = RequestMethod.GET) |
| | | public Result del(@PathVariable String id, HttpServletRequest request) throws JsonProcessingException { |
| | | Scheme scheme = schemeService.selectById(id); |
| | | List<SchemeDetail> schemeDetailList = iSchemeDetailService.selectList(new EntityWrapper<SchemeDetail>().eq("parent_id", scheme.getId())); |
| | | for (SchemeDetail detail : schemeDetailList) { |
| | | detailParttimeService.delete(new EntityWrapper<SchemeDetailParttime>().eq("parent_id", detail.getId())); |
| | | detail.deleteById(); |
| | | } |
| | | |
| | | boolean delete = scheme.deleteById(); |
| | | |
| | | if (delete) { |
| | |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.baomidou.mybatisplus.mapper.Wrapper; |
| | | import com.highdatas.srs.entity.*; |
| | | import com.highdatas.srs.mapper.SysRoleMapper; |
| | | import com.highdatas.srs.pojo.CodeMsg; |
| | | import com.highdatas.srs.pojo.Result; |
| | | import com.highdatas.srs.service.ISchemeDetailService; |
| | | import com.highdatas.srs.service.ISchemeService; |
| | | import com.highdatas.srs.service.ISysRoleMappingService; |
| | | import com.highdatas.srs.service.ISysRoleService; |
| | | import com.highdatas.srs.pojo.SchemeDetailCountEntity; |
| | | import com.highdatas.srs.service.*; |
| | | import com.highdatas.srs.util.Constant; |
| | | import com.highdatas.srs.util.DbUtils; |
| | | import com.highdatas.srs.util.FileUtils; |
| | |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import java.math.BigDecimal; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | ISysRoleService roleService; |
| | | @Autowired |
| | | ISysRoleMappingService roleMappingService; |
| | | |
| | | @Autowired |
| | | ISysUserService userService; |
| | | @Autowired |
| | | IPartimepayService partimepayService; |
| | | @Autowired |
| | | ISchemeDetailParttimeService detailParttimeService; |
| | | @Autowired |
| | | IModuleService moduleService; |
| | | @Value("{base.file.path}") |
| | | String basePath; |
| | | @Autowired |
| | | SysRoleMapper mapper; |
| | | |
| | | |
| | | @RequestMapping(value = "dayTask", method = RequestMethod.GET) |
| | | public Result dayByUser(HttpServletRequest request) { |
| | |
| | | long totalCnt = 0; |
| | | long delayCnt = 0; |
| | | for (String type : types) { |
| | | long total = schemeDetailList.stream().filter(schemeDetail -> schemeDetail.getType().getParent().equalsIgnoreCase(type)).count(); |
| | | long delay = schemeDetailList.stream().filter(schemeDetail -> schemeDetail.getType().getParent().equalsIgnoreCase(type)) |
| | | long total = schemeDetailList.stream().filter(schemeDetail -> schemeDetail.getType() != null).filter(schemeDetail -> type.equalsIgnoreCase(schemeDetail.getType().getParent())).count(); |
| | | long delay = schemeDetailList.stream().filter(schemeDetail -> schemeDetail.getType() != null).filter(schemeDetail -> type.equalsIgnoreCase(schemeDetail.getType().getParent())) |
| | | .filter(schemeDetail -> schemeDetail.getDelay()).count(); |
| | | totalCnt += total; |
| | | delayCnt += delay; |
| | |
| | | return Result.success(endResult); |
| | | } |
| | | |
| | | |
| | | @RequestMapping(value = "/dealParttime/{id}", method = RequestMethod.GET) |
| | | public Result deal(@PathVariable String id, @RequestParam int month,@RequestParam int year, @RequestParam BigDecimal money ) { |
| | | partimepayService.delete(new EntityWrapper<Partimepay>().eq("month", month).eq("year", year).eq("parttime_id", id)); |
| | | new Partimepay().setId(DbUtils.getUUID()).setYear(year).setMonth(month).setParttimeId(id).setMoney(money).insert(); |
| | | return Result.success(null); |
| | | } |
| | | |
| | | @RequestMapping(value = "/deal/{id}", method = RequestMethod.GET) |
| | | public Result deal(@PathVariable String id, HttpServletRequest request) { |
| | |
| | | @RequestMapping(value = "/get/{id}", method = RequestMethod.GET) |
| | | public Result get(@PathVariable String id) { |
| | | SchemeDetail schemeDetail = schemeDetailService.selectById(id); |
| | | String userId = schemeDetail.getUserId(); |
| | | SysRoleMapping mapping = roleMappingService.selectOne(new EntityWrapper<SysRoleMapping>().eq("user_id", userId)); |
| | | if (mapping != null) { |
| | | String roleId = mapping.getRoleId(); |
| | | SysRole sysRole = roleService.selectById(roleId); |
| | | if (sysRole != null) { |
| | | schemeDetail.setRoleName(sysRole.getName()); |
| | | } |
| | | List<SchemeDetailParttime> parent_id = detailParttimeService.selectList(new EntityWrapper<SchemeDetailParttime>().eq("parent_id", schemeDetail.getId())); |
| | | schemeDetail.setParttimeList(parent_id); |
| | | } |
| | | |
| | | String dataInfoTable = schemeDetail.getDataInfoTable(); |
| | | |
| | | if (!StringUtils.isEmpty(dataInfoTable)) { |
| | | Map<String, Object> stringObjectMap = mapper.selectTableById(dataInfoTable, schemeDetail.getDetailInfoId()); |
| | | Set<String> keySet = stringObjectMap.keySet(); |
| | | JSONObject object = new JSONObject(); |
| | | for (String s : keySet) { |
| | | String key = DbUtils.lineToHump(s); |
| | | Object val = stringObjectMap.get(s); |
| | | object.fluentPut(key,val); |
| | | } |
| | | |
| | | schemeDetail.setExistsObject(object); |
| | | } |
| | | return Result.success(schemeDetail); |
| | | } |
| | | |
| | | |
| | | |
| | | @RequestMapping(value = "/getByParttime", method = RequestMethod.GET) |
| | | public Result getByParttime(@RequestParam int year, @RequestParam int month) { |
| | | Calendar calendar = Calendar.getInstance(); |
| | | calendar.set(year,month - 1,00); |
| | | Date startTime = calendar.getTime(); |
| | | calendar.set(year,month,00); |
| | | calendar.add(Calendar.DAY_OF_YEAR, -1); |
| | | Date endTime = calendar.getTime(); |
| | | List<Scheme> schemes = schemeService.selectList(new EntityWrapper<Scheme>().ne("status", "edit")); |
| | | |
| | | Map<String, Map<String,Double>> resultMap = new HashMap<>(); |
| | | |
| | | for (Scheme scheme : schemes) { |
| | | List<SchemeDetail> schemeDetailList = schemeDetailService.selectList(new EntityWrapper<SchemeDetail>().eq("parent_id", scheme.getId()).ge("start_time", startTime).le("end_time", endTime)); |
| | | for (SchemeDetail detail : schemeDetailList) { |
| | | Boolean finish = detail.getFinish(); |
| | | BigDecimal budget = detail.getBudget(); |
| | | List<SchemeDetailParttime> parent_id = detailParttimeService.selectList(new EntityWrapper<SchemeDetailParttime>().eq("parent_id", detail.getId())); |
| | | if (parent_id == null || parent_id.isEmpty()) { |
| | | continue; |
| | | } |
| | | |
| | | |
| | | for (SchemeDetailParttime parttime : parent_id) { |
| | | String parttimeUser = parttime.getParttimeUser(); |
| | | Map<String,Double> oneResult = resultMap.get(parttimeUser); |
| | | if (oneResult == null) { |
| | | oneResult = new HashMap<>(); |
| | | oneResult.put("payMoney", parttime.getParttimePay().doubleValue()); |
| | | } |
| | | |
| | | if (finish) { |
| | | double finishCnt = oneResult.get("finishCnt") == null ? 0 : oneResult.get("finishCnt"); |
| | | double finishMoney = oneResult.get("finishMoney") == null ? 0 : oneResult.get("finishMoney"); |
| | | finishCnt++; |
| | | oneResult.put("finishCnt", finishCnt); |
| | | oneResult.put("finishMoney", finishMoney + budget.doubleValue()); |
| | | } else { |
| | | double unFinishCnt = oneResult.get("unFinishCnt") == null ? 0 : oneResult.get("unFinishCnt"); |
| | | double unFinishMoney = oneResult.get("unFinishMoney") == null ? 0 : oneResult.get("unFinishMoney"); |
| | | unFinishCnt++; |
| | | oneResult.put("unFinishCnt", unFinishCnt); |
| | | oneResult.put("unFinishMoney", unFinishMoney + budget.doubleValue()); |
| | | } |
| | | resultMap.put(parttimeUser, oneResult); |
| | | } |
| | | } |
| | | } |
| | | Set<String> keySet = resultMap.keySet(); |
| | | List<Map<String,Object>> result = new ArrayList<>(); |
| | | for (String userId : keySet) { |
| | | SysUser sysUser = userService.selectById(userId); |
| | | if (sysUser == null) { |
| | | continue; |
| | | } |
| | | Map<String,Double> doubles = resultMap.get(userId); |
| | | HashMap<String, Object> stringObjectHashMap = new HashMap<>(doubles); |
| | | stringObjectHashMap.put("userId", sysUser.getId()); |
| | | stringObjectHashMap.put("userName", sysUser.getName()); |
| | | |
| | | Partimepay partimepay = partimepayService.selectOne(new EntityWrapper<Partimepay>().eq("year", year).eq("month", month).eq("parttime_id", userId)); |
| | | if (partimepay != null) { |
| | | stringObjectHashMap.put("money", partimepay.getMoney()); |
| | | } |
| | | |
| | | result.add(stringObjectHashMap); |
| | | } |
| | | return Result.success(result); |
| | | } |
| | | |
| | | @RequestMapping(value = "/getMoneyByPersion", method = RequestMethod.GET) |
| | | public Result getMoneyByPersion(@RequestParam String userId, @RequestParam Boolean isParttime) { |
| | | List<Scheme> schemes = schemeService.selectList(new EntityWrapper<Scheme>().ne("status", "edit")); |
| | | |
| | | List<Map<String,Object>> resultMap = new ArrayList<>(); |
| | | List<Map<String,Object>> parentMap = new ArrayList<>(); |
| | | |
| | | for (Scheme scheme : schemes) { |
| | | double schemeBudget = 0; |
| | | List<SchemeDetail> collect; |
| | | if (isParttime) { |
| | | List<String> detailIdList = schemeDetailService.selectList(new EntityWrapper<SchemeDetail>().eq("parent_id", scheme.getId())).stream().map(SchemeDetail::getId).collect(Collectors.toList()); |
| | | if (detailIdList.isEmpty()) { |
| | | collect = new ArrayList<>(); |
| | | } else { |
| | | List<SchemeDetailParttime> parttime_user = detailParttimeService.selectList(new EntityWrapper<SchemeDetailParttime>().eq("parttime_user", userId).in("parent_id", detailIdList)); |
| | | List<String> detailList = parttime_user.stream().map(SchemeDetailParttime::getParentId).collect(Collectors.toList()); |
| | | if (detailList == null || detailList.isEmpty()) { |
| | | collect = new ArrayList<>(); |
| | | |
| | | } else { |
| | | collect = schemeDetailService.selectBatchIds(detailList); |
| | | } |
| | | } |
| | | |
| | | } else { |
| | | collect = schemeDetailService.selectList(new EntityWrapper<SchemeDetail>().eq("parent_id", scheme.getId()).eq("user_id", userId)); |
| | | } |
| | | |
| | | for (SchemeDetail detail : collect) { |
| | | Boolean finish = detail.getFinish(); |
| | | BigDecimal budget = detail.getBudget(); |
| | | String detailUserId = detail.getUserId(); |
| | | List<SchemeDetailParttime> parttimeList = detailParttimeService.selectList(new EntityWrapper<SchemeDetailParttime>().eq("parent_id", detail.getId())); |
| | | List<String> parttimeIdList = parttimeList.stream().map(SchemeDetailParttime::getParttimeUser).collect(Collectors.toList()); |
| | | if (isParttime) { |
| | | if (!parttimeIdList.contains(userId)) { |
| | | continue; |
| | | } |
| | | }else { |
| | | if (!detailUserId.equalsIgnoreCase(userId)) { |
| | | continue; |
| | | } |
| | | } |
| | | |
| | | Date detailStartTime = detail.getStartTime(); |
| | | Date detailEndTime = detail.getEndTime(); |
| | | SchemeDetailType type = detail.getType(); |
| | | HashMap<String, Object> stringObjectHashMap = new HashMap<>(); |
| | | stringObjectHashMap.put("startTime", detailStartTime); |
| | | stringObjectHashMap.put("endTime", detailEndTime); |
| | | stringObjectHashMap.put("name", type.covert()); |
| | | stringObjectHashMap.put("budget", budget.doubleValue()); |
| | | stringObjectHashMap.put("finish", finish); |
| | | stringObjectHashMap.put("parentId", detail.getParentId()); |
| | | stringObjectHashMap.put("isPro", false); |
| | | stringObjectHashMap.put("id", detail.getId()); |
| | | |
| | | schemeBudget += detail.getBudget().doubleValue(); |
| | | resultMap.add(stringObjectHashMap); |
| | | |
| | | } |
| | | if (!collect.isEmpty()) { |
| | | HashMap<String, Object> proMap = new HashMap<>(); |
| | | proMap.put("startTime", scheme.getStartTime()); |
| | | proMap.put("endTime", scheme.getEndTime()); |
| | | proMap.put("name", scheme.getName()); |
| | | proMap.put("budget", schemeBudget); |
| | | proMap.put("finish", false); |
| | | proMap.put("id", scheme.getId()); |
| | | proMap.put("isPro", true); |
| | | parentMap.add(proMap); |
| | | } |
| | | |
| | | } |
| | | JSONObject object = new JSONObject(); |
| | | object.fluentPut("sub", resultMap); |
| | | object.fluentPut("scheme", parentMap); |
| | | return Result.success(object); |
| | | } |
| | | |
| | | @RequestMapping(value = "/getPersion", method = RequestMethod.GET) |
| | | public Result getPersion() { |
| | | List<Scheme> schemes = schemeService.selectList(new EntityWrapper<Scheme>().ne("status", "edit")); |
| | | |
| | | Map<String, Map<String,Double>> resultMap = new HashMap<>(); |
| | | |
| | | for (Scheme scheme : schemes) { |
| | | List<SchemeDetail> schemeDetailList = schemeDetailService.selectList(new EntityWrapper<SchemeDetail>().eq("parent_id", scheme.getId())); |
| | | for (SchemeDetail detail : schemeDetailList) { |
| | | Boolean finish = detail.getFinish(); |
| | | BigDecimal budget = detail.getBudget(); |
| | | String userId = detail.getUserId(); |
| | | |
| | | Map<String,Double> oneResult = resultMap.get(userId); |
| | | if (oneResult == null) { |
| | | oneResult = new HashMap<>(); |
| | | } |
| | | if (finish) { |
| | | double finishCnt = oneResult.get("finishCnt") == null ? 0 : oneResult.get("finishCnt"); |
| | | double finishMoney = oneResult.get("finishMoney") == null ? 0 : oneResult.get("finishMoney"); |
| | | finishCnt++; |
| | | oneResult.put("finishCnt", finishCnt); |
| | | oneResult.put("finishMoney", finishMoney + budget.doubleValue()); |
| | | } else { |
| | | double unFinishCnt = oneResult.get("unFinishCnt") == null ? 0 : oneResult.get("unFinishCnt"); |
| | | double unFinishMoney = oneResult.get("unFinishMoney") == null ? 0 : oneResult.get("unFinishMoney"); |
| | | unFinishCnt++; |
| | | oneResult.put("unFinishCnt", unFinishCnt); |
| | | oneResult.put("unFinishMoney", unFinishMoney + budget.doubleValue()); |
| | | } |
| | | resultMap.put(userId, oneResult); |
| | | |
| | | } |
| | | } |
| | | Set<String> keySet = resultMap.keySet(); |
| | | List<Map<String,Object>> result = new ArrayList<>(); |
| | | for (String userId : keySet) { |
| | | SysUser sysUser = userService.selectById(userId); |
| | | if (sysUser == null) { |
| | | continue; |
| | | } |
| | | Map<String,Double> doubles = resultMap.get(userId); |
| | | HashMap<String, Object> stringObjectHashMap = new HashMap<>(doubles); |
| | | stringObjectHashMap.put("userId", sysUser.getId()); |
| | | stringObjectHashMap.put("userName", sysUser.getName()); |
| | | |
| | | |
| | | result.add(stringObjectHashMap); |
| | | } |
| | | return Result.success(result); |
| | | } |
| | | |
| | | @RequestMapping(value = "/getMonth", method = RequestMethod.GET) |
| | |
| | | for (SchemeDetail detail : dealList) { |
| | | String userId = detail.getUserId(); |
| | | SysRoleMapping mapping = roleMappingService.selectOne(new EntityWrapper<SysRoleMapping>().eq("user_id", userId)); |
| | | String roleId = mapping.getRoleId(); |
| | | SysRole sysRole = roleService.selectById(roleId); |
| | | detail.setRoleName(sysRole.getName()); |
| | | if (mapping != null) { |
| | | String roleId = mapping.getRoleId(); |
| | | SysRole sysRole = roleService.selectById(roleId); |
| | | if (sysRole == null) { |
| | | continue; |
| | | } |
| | | detail.setRoleName(sysRole.getName()); |
| | | } |
| | | List<SchemeDetailParttime> parent_id = detailParttimeService.selectList(new EntityWrapper<SchemeDetailParttime>().eq("parent_id", detail.getId())); |
| | | detail.setParttimeList(parent_id); |
| | | |
| | | String dataInfoTable = detail.getDataInfoTable(); |
| | | if (!StringUtils.isEmpty(dataInfoTable)){ |
| | | Map<String, Object> stringObjectMap = mapper.selectTableById(dataInfoTable, detail.getDetailInfoId()); |
| | | |
| | | Set<String> keySet = stringObjectMap.keySet(); |
| | | JSONObject object = new JSONObject(); |
| | | for (String s : keySet) { |
| | | String key = DbUtils.lineToHump(s); |
| | | Object val = stringObjectMap.get(s); |
| | | object.fluentPut(key,val); |
| | | } |
| | | detail.setExistsObject(object); |
| | | } |
| | | } |
| | | return Result.success(dealList); |
| | | } |
| | | |
| | | @RequestMapping(value = "/updates", method = RequestMethod.GET) |
| | | public Result updates(@RequestParam String datas) { |
| | | @Transactional(rollbackFor = {RuntimeException.class, Error.class}) |
| | | @RequestMapping(value = "/updates", method = RequestMethod.POST) |
| | | public Result updates(@RequestBody JSONObject reqObj) { |
| | | String schemeId = reqObj.getString("schemeId"); |
| | | JSONArray datas = reqObj.getJSONArray("datas"); |
| | | Scheme scheme = schemeService.selectById(schemeId); |
| | | schemeDetailService.delete(new EntityWrapper<SchemeDetail>().eq("parent_id", schemeId)); |
| | | |
| | | try { |
| | | List<SchemeDetail> array = JSON.parseArray(datas, SchemeDetail.class); |
| | | for (SchemeDetail detail : array) { |
| | | SchemeDetail pre = schemeDetailService.selectById(detail.getId()); |
| | | if (pre == null) { |
| | | EntityWrapper<SchemeDetail> schemeDetailEntityWrapper = new EntityWrapper<>(); |
| | | schemeDetailEntityWrapper.eq("parent_id", detail.getParentId()); |
| | | schemeDetailEntityWrapper.eq("type", detail.getType()); |
| | | pre = schemeDetailService.selectOne(schemeDetailEntityWrapper); |
| | | if (pre == null) { |
| | | detail.setId(DbUtils.getUUID()); |
| | | detail.setCreateTime(new Date()); |
| | | detail.insert(); |
| | | continue; |
| | | for (Object data : datas) { |
| | | JSONObject one = (JSONObject) JSONObject.toJSON(data); |
| | | JSONObject existsObject = one.getJSONObject("existsObject"); |
| | | if (existsObject == null) { |
| | | continue; |
| | | } |
| | | SchemeDetail detail = JSON.parseObject(one.toJSONString(), SchemeDetail.class); |
| | | String dataInfoTable = detail.getDataInfoTable(); |
| | | if (!StringUtils.isEmpty(dataInfoTable)) { |
| | | String s = DbUtils.lineToHump(dataInfoTable); |
| | | String substring = s.substring(0, 1); |
| | | s = substring.toUpperCase() + s.substring(1); |
| | | s = "com.highdatas.srs.entity." +s; |
| | | Object o = JSON.parseObject(existsObject.toJSONString(), Class.forName(s)); |
| | | if (o instanceof InfoSurface) { |
| | | InfoSurface surface = (InfoSurface) o; |
| | | surface.dataInsertOrUpdate(); |
| | | } |
| | | if (o instanceof TitleService) { |
| | | TitleService titleService = (TitleService) o; |
| | | String title = titleService.getTitle(); |
| | | scheme.setName(title).updateById(); |
| | | } |
| | | } |
| | | if (pre.getMustAttach() != detail.getMustAttach()) { |
| | | if (detail.getMustAttach()) { |
| | | //必须传附件 |
| | | Scheme scheme = schemeService.selectById(detail.getParentId()); |
| | | detail.setAttachment(FileUtils.createFile(basePath, scheme.getName(), detail.getType().name())); |
| | | } else { |
| | | detail.setAttachment(null); |
| | | |
| | | } |
| | | List<SchemeDetail> array = JSON.parseArray(datas.toJSONString(), SchemeDetail.class); |
| | | for (SchemeDetail detail : array) { |
| | | if (StringUtils.isEmpty(detail.getId())) { |
| | | detail.setId(DbUtils.getUUID()).setCreateTime(new Date()); |
| | | } |
| | | detail.setUpdateTime(new Date()); |
| | | detail.insertOrUpdate(); |
| | | |
| | | if (detail.getMustAttach()) { |
| | | //必须传附件 |
| | | |
| | | detail.setAttachment(FileUtils.createFile(basePath, scheme.getName(), detail.getType().name())); |
| | | } else { |
| | | detail.setAttachment(null); |
| | | } |
| | | |
| | | detailParttimeService.delete(new EntityWrapper<SchemeDetailParttime>().eq("parent_id", detail.getId())); |
| | | Boolean parttime = detail.getParttime(); |
| | | if (parttime == null) { |
| | | parttime = false; |
| | | } |
| | | if(parttime) { |
| | | List<SchemeDetailParttime> parttimeList = detail.getParttimeList(); |
| | | for (SchemeDetailParttime schemeDetailParttime : parttimeList) { |
| | | schemeDetailParttime.setId(DbUtils.getUUID()).setParentId(detail.getId()).insert(); |
| | | } |
| | | } |
| | | detail.insertOrUpdate(); |
| | |
| | | return Result.error(CodeMsg.UPDATE_ERROR); |
| | | } |
| | | } |
| | | |
| | | @RequestMapping(value = "/view") |
| | | public Result view(@RequestParam Date startTime, @RequestParam Date endTime, HttpServletRequest request) { |
| | | String schemeId = request.getParameter("schemeId"); |
| | | String userId = request.getParameter("userId"); |
| | | Calendar calendar = Calendar.getInstance(); |
| | | calendar.setTime(startTime); |
| | | // calendar.add(Calendar.DAY_OF_YEAR, 1); |
| | | calendar.set(Calendar.HOUR, 0); |
| | | // endTime = calendar.getTime(); |
| | | // calendar.setTime(startTime); |
| | | // calendar.set(Calendar.HOUR, 0); |
| | | // calendar.add(Calendar.DAY_OF_YEAR, 1); |
| | | startTime = calendar.getTime(); |
| | | LinkedHashMap<Date, SchemeDetailCountEntity> resultMap = new LinkedHashMap<>(); |
| | | Date now = new Date(); |
| | | |
| | | ArrayList<String> dateList = new ArrayList<>(); |
| | | ArrayList<Integer> runtimeList = new ArrayList<>(); |
| | | ArrayList<Integer> delayList = new ArrayList<>(); |
| | | |
| | | SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); |
| | | |
| | | while (startTime.before(endTime) || startTime.compareTo(endTime) == 0) { |
| | | Wrapper<SchemeDetail> runtimeWrapper = new EntityWrapper<SchemeDetail>().eq("edit",false).eq("finish", false).eq("delay", false).le("start_time", startTime).ge("end_time", startTime); |
| | | Wrapper<SchemeDetail> delayWrapper = new EntityWrapper<SchemeDetail>().eq("edit",false).eq("finish", false).eq("delay", true).le("start_time", startTime); |
| | | if(!StringUtils.isEmpty(userId)) { |
| | | runtimeWrapper.eq("user_id", userId); |
| | | delayWrapper.eq("user_id", userId); |
| | | } |
| | | if(!StringUtils.isEmpty(schemeId)) { |
| | | runtimeWrapper.eq("parent_id", schemeId); |
| | | delayWrapper.eq("parent_id", schemeId); |
| | | } |
| | | |
| | | int runtimeCnt = schemeDetailService.selectCount(runtimeWrapper); |
| | | int delayCnt = 0; |
| | | // startTime.setDate(startTime.getDate() - 1); |
| | | |
| | | if (startTime.before(now) || startTime.compareTo(now) == 0) { |
| | | List<SchemeDetail> detailList = schemeDetailService.selectList(delayWrapper); |
| | | for (SchemeDetail detail : detailList) { |
| | | Date detailEndTime = detail.getEndTime(); |
| | | // detailEndTime.setDate(detailEndTime.getDate() + 1); |
| | | if (detailEndTime.compareTo(startTime) > -1) { |
| | | runtimeCnt++; |
| | | } else { |
| | | delayCnt++; |
| | | } |
| | | } |
| | | } |
| | | runtimeList.add(runtimeCnt); |
| | | delayList.add(delayCnt); |
| | | // startTime.setDate(startTime.getDate() - 1); |
| | | String dateStr = format.format(startTime); |
| | | // startTime.setDate(startTime.getDate() + 1); |
| | | dateList.add(dateStr); |
| | | calendar.add(Calendar.DAY_OF_YEAR, 1); |
| | | startTime = calendar.getTime(); |
| | | } |
| | | JSONObject object = new JSONObject(); |
| | | object.fluentPut("date", dateList); |
| | | object.fluentPut("runtime", runtimeList); |
| | | object.fluentPut("delay", delayList); |
| | | return Result.success(object); |
| | | } |
| | | |
| | | @RequestMapping(value = "/view/detail", method = RequestMethod.GET) |
| | | public Result view(@RequestParam Date startTime, HttpServletRequest request) { |
| | | String schemeId = request.getParameter("schemeId"); |
| | | String userId = request.getParameter("userId"); |
| | | Calendar calendar = Calendar.getInstance(); |
| | | calendar.setTime(startTime); |
| | | // calendar.add(Calendar.DAY_OF_YEAR, 1); |
| | | calendar.set(Calendar.HOUR, 0); |
| | | startTime = calendar.getTime(); |
| | | Wrapper<SchemeDetail> runtimeWrapper = new EntityWrapper<SchemeDetail>().eq("edit",false).eq("finish", false).eq("delay", false).le("start_time", startTime).ge("end_time", startTime); |
| | | Wrapper<SchemeDetail> delayWrapper = new EntityWrapper<SchemeDetail>().eq("edit",false).eq("finish", false).eq("delay", true).le("start_time", startTime); |
| | | if(!StringUtils.isEmpty(userId)) { |
| | | runtimeWrapper.eq("user_id", userId); |
| | | delayWrapper.eq("user_id", userId); |
| | | } |
| | | if(!StringUtils.isEmpty(schemeId)) { |
| | | runtimeWrapper.eq("parent_id", schemeId); |
| | | delayWrapper.eq("parent_id", schemeId); |
| | | } |
| | | Date now = new Date(); |
| | | List<SchemeDetail> resultList = new ArrayList<>(); |
| | | List<SchemeDetail> detailList; |
| | | // now.setDate(now.getDate() + 1); |
| | | // now.setHours(23); |
| | | if(now.compareTo(startTime) > -1) { |
| | | detailList = schemeDetailService.selectList(delayWrapper); |
| | | if (detailList != null && !detailList.isEmpty()) { |
| | | for (SchemeDetail detail : detailList) { |
| | | Date detailEndTime = detail.getEndTime(); |
| | | // detailEndTime.setDate(detailEndTime.getDate() + 1); |
| | | if (detailEndTime.compareTo(startTime) > -1) { |
| | | detail.setDelay(false); |
| | | } |
| | | // detailEndTime.setDate(detailEndTime.getDate() - 1); |
| | | resultList.add(detail); |
| | | } |
| | | |
| | | } |
| | | } |
| | | |
| | | detailList = schemeDetailService.selectList(runtimeWrapper); |
| | | if (detailList != null && !detailList.isEmpty()) { |
| | | detailList = detailList.stream().map(detail -> detail.setDelay(false)).collect(Collectors.toList()); |
| | | resultList.addAll(detailList); |
| | | } |
| | | Collections.sort(resultList, new Comparator<SchemeDetail>() { |
| | | @Override |
| | | public int compare(SchemeDetail o1, SchemeDetail o2) { |
| | | return o1.getStartTime().compareTo(o2.getStartTime()); |
| | | } |
| | | }); |
| | | for (SchemeDetail detail : resultList) { |
| | | String parentId = detail.getParentId(); |
| | | Scheme scheme = schemeService.selectById(parentId); |
| | | if (scheme == null) { |
| | | continue; |
| | | } |
| | | detail.setSchemeName(scheme.getName()); |
| | | SysUser sysUser = userService.selectById(detail.getUserId()); |
| | | detail.setUserId(sysUser.getName()); |
| | | Module module = moduleService.selectById(detail.getType()); |
| | | detail.setTypeStr(module.getTitle()); |
| | | } |
| | | return Result.success(resultList); |
| | | } |
| | | |
| | | |
| | | } |
| | |
| | | package com.highdatas.srs.web; |
| | | |
| | | |
| | | import com.highdatas.srs.entity.SysRole; |
| | | import com.highdatas.srs.mapper.SysRoleMapper; |
| | | import com.highdatas.srs.pojo.Result; |
| | | import com.highdatas.srs.service.ISysRoleService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | |
| | | */ |
| | | @Autowired |
| | | SysRoleMapper roleMapper; |
| | | @Autowired |
| | | ISysRoleService roleService; |
| | | |
| | | @RequestMapping("detail") |
| | | public Result downLoad() { |
| | |
| | | stringObjectHashMap.put("name", "研究员"); |
| | | stringObjectHashMap.put("roleName", null); |
| | | byDepart.add(stringObjectHashMap); |
| | | stringObjectHashMap = new HashMap<>(); |
| | | stringObjectHashMap.put("id", "实习生"); |
| | | stringObjectHashMap.put("name", "实习生"); |
| | | stringObjectHashMap.put("roleName", null); |
| | | byDepart.add(stringObjectHashMap); |
| | | // stringObjectHashMap = new HashMap<>(); |
| | | // stringObjectHashMap.put("id", "实习生"); |
| | | // stringObjectHashMap.put("name", "实习生"); |
| | | // stringObjectHashMap.put("roleName", null); |
| | | // byDepart.add(stringObjectHashMap); |
| | | stringObjectHashMap = new HashMap<>(); |
| | | stringObjectHashMap.put("id", "项目经理"); |
| | | stringObjectHashMap.put("name", "项目经理"); |
| | |
| | | |
| | | return Result.success(byDepart); |
| | | } |
| | | |
| | | @RequestMapping("partTime") |
| | | public Result partTime() { |
| | | List<Map<String, Object>> byDepart = roleMapper.findByDepart("01-600"); |
| | | return Result.success(byDepart); |
| | | } |
| | | |
| | | @RequestMapping("all") |
| | | public Result all() { |
| | | List<Map<String, Object>> byDepart = new ArrayList<>(); |
| | | |
| | | List<SysRole> sysRoles = roleService.selectList(null); |
| | | for (SysRole sysRole : sysRoles) { |
| | | HashMap stringObjectHashMap = new HashMap<>(); |
| | | stringObjectHashMap.put("id", sysRole.getName()); |
| | | stringObjectHashMap.put("name", sysRole.getName()); |
| | | stringObjectHashMap.put("roleName", null); |
| | | byDepart.add(stringObjectHashMap); |
| | | } |
| | | byDepart.addAll(roleMapper.all()); |
| | | return Result.success(byDepart); |
| | | } |
| | | } |
| | |
| | | return Result.success(sysUser); |
| | | } |
| | | |
| | | @RequestMapping(value = "/changePass/{id}", method = RequestMethod.GET) |
| | | public Result changePass(@PathVariable String id, @RequestParam String prePass, @RequestParam String newPass) { |
| | | SysUser sysUser = userService.selectById(id); |
| | | String password = sysUser.getPassword(); |
| | | if (prePass.equals(password)) { |
| | | sysUser.setPassword(newPass).updateById(); |
| | | }else { |
| | | return Result.error(CodeMsg.ERROR_PARAMS_NOT_MATHED); |
| | | } |
| | | |
| | | return Result.success(sysUser); |
| | | } |
| | | |
| | | @RequestMapping(value = "/login", method = RequestMethod.GET) |
| | | public Result login(@RequestParam String loginName, @RequestParam String password) { |
| | | try{ |
| | |
| | | package com.highdatas.srs.web; |
| | | |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.baomidou.mybatisplus.plugins.Page; |
| | | import com.highdatas.srs.entity.Topic; |
| | | import com.highdatas.srs.entity.*; |
| | | import com.highdatas.srs.mapper.SysRoleMapper; |
| | | import com.highdatas.srs.pojo.CodeMsg; |
| | | import com.highdatas.srs.pojo.Result; |
| | | import com.highdatas.srs.service.ITopicService; |
| | | import com.highdatas.srs.service.*; |
| | | import com.highdatas.srs.util.Constant; |
| | | import com.highdatas.srs.util.ContentBuilder; |
| | | import com.highdatas.srs.util.DbUtils; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.Set; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | public class TopicController { |
| | | @Autowired |
| | | ITopicService topicService; |
| | | @Autowired |
| | | ISchemeDetailService schemeDetailService; |
| | | @Autowired |
| | | ISchemeDetailParttimeService parttimeService; |
| | | @Autowired |
| | | ITitleServiceService titleServiceService; |
| | | @Autowired |
| | | ISchemeService schemeService; |
| | | |
| | | @Autowired |
| | | SysRoleMapper mapper; |
| | | |
| | | @RequestMapping(value = "/get/{id}", method = RequestMethod.GET) |
| | | public Result get(@PathVariable String id) { |
| | | Topic topic = topicService.selectById(id); |
| | | String titleId = topic.getTitleId(); |
| | | TitleService titleService = titleServiceService.selectById(titleId); |
| | | topic.setTitleService(titleService); |
| | | return Result.success(topic); |
| | | } |
| | | |
| | | @RequestMapping(value = "/page/{pageno}", method = RequestMethod.GET) |
| | | public Result page(@PathVariable Integer pageno, HttpServletRequest request) { |
| | | String title = request.getParameter("title"); |
| | | String desp = request.getParameter("desp"); |
| | | EntityWrapper<Topic> topicEntityWrapper = new EntityWrapper<>(); |
| | | if (!StringUtils.isEmpty(title)) { |
| | | topicEntityWrapper.like("title", title); |
| | | @RequestMapping(value = "/page/{pageno}", method = RequestMethod.POST) |
| | | public Result page(@PathVariable Integer pageno, @RequestBody TitleService titleService) { |
| | | Map<String, Object> stringObjectMap = DbUtils.beanToMap(titleService); |
| | | |
| | | Set<String> keySet = stringObjectMap.keySet(); |
| | | ContentBuilder builder = new ContentBuilder(" and "); |
| | | for (String key : keySet) { |
| | | if (key.equalsIgnoreCase("orderBy")){ |
| | | continue; |
| | | } |
| | | Object o = stringObjectMap.get(key); |
| | | if (o == null) { |
| | | continue; |
| | | } |
| | | builder.append(key + " like '%" + o.toString() + "%'"); |
| | | } |
| | | if (!StringUtils.isEmpty(desp)) { |
| | | topicEntityWrapper.like("desp", desp); |
| | | String filter = builder.toString(); |
| | | if (StringUtils.isEmpty(filter)) { |
| | | filter = Constant.WHERE_DEFAULT; |
| | | } |
| | | Page<Topic> topicPage= new Page<Topic>(pageno, 15); |
| | | topicEntityWrapper.orderBy("create_time desc"); |
| | | Page<Topic> result = topicService.selectPage(topicPage, topicEntityWrapper); |
| | | List<Topic> records = result.getRecords(); |
| | | JSONArray array = new JSONArray(); |
| | | for (Topic record : records) { |
| | | JSONObject one = (JSONObject) JSON.toJSON(record); |
| | | Date createTime = record.getCreateTime(); |
| | | String s = DbUtils.convert_before(createTime.getTime()); |
| | | one.fluentPut("time", s); |
| | | array.add(one); |
| | | } |
| | | Long aLong = mapper.selectTopicCnt(filter); |
| | | JSONObject object = new JSONObject(); |
| | | object.fluentPut("records", array); |
| | | object.fluentPut("total", result.getTotal()); |
| | | object.fluentPut("maxPage", result.getPages()); |
| | | object.fluentPut("pageno", result.getCurrent()); |
| | | if (aLong == null) { |
| | | return Result.success(object); |
| | | } |
| | | com.highdatas.srs.pojo.Page page = new com.highdatas.srs.pojo.Page(aLong); |
| | | page.setPageNo(pageno); |
| | | page.setPageSize(10); |
| | | String orderBy = titleService.getOrderBy(); |
| | | if (StringUtils.isEmpty(orderBy)) { |
| | | orderBy = " create_time desc "; |
| | | } else { |
| | | orderBy = orderBy + ", create_time desc"; |
| | | } |
| | | |
| | | List<Map<String, Object>> maps = mapper.selectTopic(filter, orderBy, page.getLimitSQL()); |
| | | |
| | | object.fluentPut("records", maps); |
| | | object.fluentPut("total", page.getRecordCount()); |
| | | object.fluentPut("maxPage", page.getPageCount()); |
| | | object.fluentPut("pageno", pageno); |
| | | |
| | | return Result.success(object); |
| | | |
| | | |
| | | } |
| | | |
| | | @RequestMapping(value = "/exam/{id}", method = RequestMethod.GET) |
| | | public Result exam(@PathVariable String id, @RequestParam String projectId) { |
| | | Topic topic = topicService.selectById(id); |
| | | if (StringUtils.isEmpty(topic.getTitleId())) { |
| | | return Result.error(CodeMsg.ERROR_PARAMS_NOT_MATHED); |
| | | } |
| | | SchemeDetail detail = schemeDetailService.selectById(topic.getTitleId()); |
| | | detail.setParentId(projectId).updateById(); |
| | | topic.setExamine(true); |
| | | topic.setLinkId(projectId); |
| | | |
| | | boolean insert = topic.updateById(); |
| | | |
| | | if (insert) { |
| | |
| | | } |
| | | |
| | | } |
| | | @RequestMapping(value = "/saveLinkTitle/{topicId}", method = RequestMethod.POST) |
| | | public Result saveLinkTitle(@PathVariable String topicId, @RequestBody SchemeDetail detail) { |
| | | Topic topic = topicService.selectById(topicId); |
| | | String titleId = topic.getTitleId(); |
| | | if (StringUtils.isEmpty(titleId)) { |
| | | titleId = DbUtils.getUUID(); |
| | | } |
| | | |
| | | @RequestMapping(value = "/add", method = RequestMethod.GET) |
| | | public Result add(HttpServletRequest request) { |
| | | String id = request.getParameter("id"); |
| | | String title = request.getParameter("title"); |
| | | String userId = request.getParameter("userId"); |
| | | parttimeService.delete(new EntityWrapper<SchemeDetailParttime>().eq("parent_id", detail.getId())); |
| | | if (detail.getParttime() != null && detail.getParttime()) { |
| | | List<SchemeDetailParttime> parttimeList = detail.getParttimeList(); |
| | | for (SchemeDetailParttime parttime : parttimeList) { |
| | | parttime.setParentId(detail.getId()).setId(DbUtils.getUUID()).insert(); |
| | | } |
| | | } |
| | | |
| | | detail.setId(titleId).setDetailInfoId(titleId).insertOrUpdate(); |
| | | JSONObject existsObject = detail.getExistsObject(); |
| | | if (existsObject != null) { |
| | | TitleService titleService = JSONObject.parseObject(existsObject.toJSONString(), TitleService.class); |
| | | String title = titleService.createTitle(); |
| | | Scheme scheme = schemeService.selectById(detail.getParentId()); |
| | | if (scheme == null) { |
| | | scheme = new Scheme().setUserId(detail.getUserId()).setStatus("edit").setId(DbUtils.getUUID()); |
| | | scheme.setCreateTime(new Date()); |
| | | } |
| | | scheme.setName(title); |
| | | } |
| | | topic.setTitleStatus(true).updateById(); |
| | | return Result.success(null); |
| | | } |
| | | |
| | | @RequestMapping(value = "/add", method = RequestMethod.POST) |
| | | public Result add(@RequestBody TitleService titleService) { |
| | | String id = titleService.getId(); |
| | | String title = titleService.createTitle(); |
| | | String userId = titleService.getUserId(); |
| | | |
| | | if(StringUtils.isEmpty(title)) { |
| | | return Result.error(CodeMsg.ERROR_PARAMS_NOT_MATHED); |
| | | } |
| | | String desp = request.getParameter("desp"); |
| | | |
| | | if (StringUtils.isEmpty(id)) { |
| | | Topic topic = new Topic().setUserId(userId).setTitle(title).setDesp(desp).setCreateTime(new Date()); |
| | | topic.setId(DbUtils.getUUID()); |
| | | Topic topic = new Topic().setUserId(userId).setCreateTime(new Date()); |
| | | String uuid = DbUtils.getUUID(); |
| | | titleService.setTitle(titleService.createTitle()); |
| | | titleService.setId(uuid).insert(); |
| | | topic.setId(uuid); |
| | | topic.setTitleId(uuid); |
| | | boolean insert = topic.insert(); |
| | | if (insert) { |
| | | return Result.success(null); |
| | |
| | | } |
| | | } else { |
| | | Topic topic = topicService.selectById(id); |
| | | boolean b = topic.setDesp(desp).setTitle(title).updateById(); |
| | | titleService.setTitle(titleService.createTitle()); |
| | | titleService.updateById(); |
| | | boolean b = topic.updateById(); |
| | | if (b) { |
| | | return Result.success(null); |
| | | } else { |
| | |
| | | server: |
| | | port: 9010 |
| | | port: 8090 |
| | | #url: jdbc:mysql://180.169.94.250:8306/data_admin?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=UTC&nullCatalogMeansCurrent=true |
| | | base: |
| | | file: |
| | |
| | | |
| | | datasource: |
| | | driver-class-name: com.mysql.cj.jdbc.Driver |
| | | url: jdbc:mysql://localhost:3306/srs?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=UTC&nullCatalogMeansCurrent=true |
| | | url: jdbc:mysql://localhost:3306/srs?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=Asia/Shanghai&nullCatalogMeansCurrent=true |
| | | username: root |
| | | password: 123456 |
| | | |
| | |
| | | |
| | | datasource: |
| | | driver-class-name: com.mysql.cj.jdbc.Driver |
| | | url: jdbc:mysql://rm-8vbgt2g7d2p34t91ao.mysql.zhangbei.rds.aliyuncs.com:3306/srs?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=UTC&nullCatalogMeansCurrent=true |
| | | url: jdbc:mysql://rm-8vbgt2g7d2p34t91ao.mysql.zhangbei.rds.aliyuncs.com:3306/srs?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=Asia/Shanghai&nullCatalogMeansCurrent=true |
| | | username: demo |
| | | password: Demo123456 |
| | | |
| | |
| | | where r.departid = #{departId} |
| | | </select> |
| | | |
| | | <select id="all" parameterType="String" resultType="java.util.Map"> |
| | | select u.id, u.name, r.name as roleName from sys_user u |
| | | LEFT JOIN sys_role_mapping rm on rm.user_id = u.id |
| | | LEFT JOIN sys_role r on r.id = rm.role_id |
| | | LEFT JOIN sys_department d on d.id = r.departid |
| | | WHERE r.departid not in ('01-600') or r.departid is null |
| | | </select> |
| | | |
| | | <select id="selectTopicCnt" parameterType="String" resultType="java.lang.Long"> |
| | | select count(1) from topic t |
| | | LEFT JOIN title_service ts on t.title_id = ts.id |
| | | WHERE ${where} |
| | | </select> |
| | | |
| | | |
| | | <select id="selectTopic" parameterType="String" resultType="java.util.Map"> |
| | | select t.*, ts.*, t.title_status as titleStatus, ts.outcomes_other as outcomesOther, ts.title_type as titleType,t.create_time as createTime, u.name from topic t |
| | | LEFT JOIN title_service ts on t.title_id = ts.id |
| | | LEFT JOIN sys_user u on u.id = t.user_id |
| | | WHERE ${where} ORDER BY ${orderby} ${limit} |
| | | </select> |
| | | |
| | | |
| | | <select id="login" parameterType="String" resultType="java.util.Map"> |
| | | select u.id, u.login_name as loginName, u.name, r.name as roleName, r.code as roleCode, |
| | |
| | | LEFT JOIN sys_department d on d.id = r.departid |
| | | where u.login_name = #{loginName} and u.password = #{password} |
| | | </select> |
| | | |
| | | |
| | | <select id="selectTableById" parameterType="String" resultType="java.util.Map"> |
| | | select * from ${tableName} where id = #{id} |
| | | </select> |
| | | </mapper> |